From 428e2a059788553d8af008f94d6167499bf20a73 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 7 Nov 2023 14:46:41 +0530 Subject: [PATCH 1/2] FFT functions and EVS helper functions [x] Some EVS helper functions imported. [x] Converted DoFFT and fft functions to fixed point. [x] Saturation overflow to be taken care at all calling locations of FFT. --- Workspace_msvc/decoder.vcxproj | 1 + Workspace_msvc/lib_com.vcxproj | 19 + Workspace_msvc/lib_com.vcxproj.filters | 55 + Workspace_msvc/lib_debug.vcxproj | 9 +- Workspace_msvc/lib_dec.vcxproj | 2 +- Workspace_msvc/lib_dec.vcxproj.filters | 8 +- Workspace_msvc/lib_enc.vcxproj | 2 +- apps/decoder.c | 8 + lib_com/ari_hm.c | 10 +- lib_com/arith_coder.c | 28 +- lib_com/basop32.c | 609 +- lib_com/basop32.h | 57 +- lib_com/basop_com_lpc.c | 4 +- lib_com/basop_lsf_tools.c | 4 +- lib_com/basop_mpy.c | 108 +- lib_com/basop_mpy.h | 23 +- lib_com/basop_tcx_utils.c | 46 +- lib_com/basop_util.c | 1901 +++++- lib_com/basop_util.h | 556 ++ lib_com/bitalloc.c | 4 +- lib_com/bits_alloc.c | 16 +- lib_com/bitstream.c | 12 +- lib_com/bitstream_fx.c | 2649 ++++++++ lib_com/cb_shape.c | 2 +- lib_com/cldfb.c | 92 +- lib_com/cnst.h | 772 ++- lib_com/codec_tcx_common.c | 2 +- lib_com/complex_basop.c | 457 ++ lib_com/complex_basop.h | 77 + lib_com/control.c | 250 + lib_com/control.h | 314 +- lib_com/core_com_config.c | 46 +- lib_com/count.c | 772 +++ lib_com/count.h | 542 ++ lib_com/deemph.c | 163 +- lib_com/delay_comp.c | 87 + lib_com/enh64.c | 1782 +++++ lib_com/enh64.h | 87 + lib_com/enhUL32.c | 409 ++ lib_com/enhUL32.h | 76 + lib_com/enr_1_az.c | 109 + lib_com/env_adj.c | 155 + lib_com/env_stab.c | 196 +- lib_com/env_stab_trans.c | 149 +- lib_com/fd_cng_com.c | 24 +- lib_com/fft.c | 23 +- lib_com/fft_fx.c | 6377 ++++++++++++++++++ lib_com/fft_rel.c | 184 +- lib_com/fill_spectrum.c | 263 + lib_com/findpulse.c | 107 + lib_com/frame_ener.c | 223 +- lib_com/get_gain.c | 113 +- lib_com/gs_gains_fx.c | 727 ++ lib_com/gs_noisefill.c | 1010 ++- lib_com/gs_preech.c | 122 +- lib_com/guided_plc_util.c | 6 +- lib_com/hp50.c | 292 +- lib_com/hq2_bit_alloc.c | 26 +- lib_com/hq2_bit_alloc_fx.c | 213 + lib_com/hq2_core_com.c | 8 +- lib_com/hq_conf.c | 289 +- lib_com/hq_tools.c | 10 +- lib_com/hq_tools_fx.c | 2433 +++++++ lib_com/hvq_pvq_bitalloc.c | 4 +- lib_com/ifft_rel.c | 369 +- lib_com/igf_base.c | 30 +- lib_com/int_lsp.c | 136 + lib_com/interleave_spectrum.c | 183 + lib_com/interpol.c | 80 +- lib_com/ivas_prot.h | 6 +- lib_com/ivas_td_decorr.c | 2 +- lib_com/logqnorm.c | 6 +- lib_com/logqnorm_fx.c | 218 + lib_com/lpc_tools.c | 10 +- lib_com/lpc_tools_fx.c | 1107 +++ lib_com/lsf_msvq_ma.c | 8 +- lib_com/lsf_tools.c | 30 +- lib_com/lsf_tools_fx.c | 3900 +++++++++++ lib_com/math_op.h | 48 + lib_com/move.h | 5 + lib_com/mslvq_com_fx.c | 660 ++ lib_com/oper_32b.c | 414 ++ lib_com/oper_32b.h | 18 + lib_com/options.h | 8 +- lib_com/ppp.c | 4 +- lib_com/prot.h | 40 +- lib_com/prot_fx1.h | 441 ++ lib_com/prot_fx2.h | 1208 ++++ lib_com/pvq_com.c | 10 +- lib_com/range_com.c | 4 +- lib_com/recovernorm.c | 2 +- lib_com/rom_basop_util.c | 816 +++ lib_com/rom_basop_util.h | 54 + lib_com/rom_com.c | 4094 ++++++++++- lib_com/rom_com.h | 189 +- lib_com/rom_com_fx.c | 877 +++ lib_com/rom_com_fx.h | 70 + lib_com/scale_mem_fx.c | 378 ++ lib_com/stat_com.h | 182 +- lib_com/stl.h | 13 +- lib_com/swb_bwe_com.c | 12 +- lib_com/swb_bwe_com_fx.c | 789 +++ lib_com/swb_tbe_com.c | 16 +- lib_com/tcq_position_arith.c | 19 +- lib_com/tcx_ltp.c | 38 +- lib_com/tcx_utils.c | 32 +- lib_com/tec_com.c | 16 +- lib_com/tns_base.c | 4 +- lib_com/tools.c | 8 +- lib_com/tools_fx.c | 3054 +++++++++ lib_com/typedef.h | 10 +- lib_com/typedefs.h | 218 + lib_debug/debug.c | 978 +++ lib_debug/debug.h | 257 + lib_debug/sba_debug.c | 431 ++ lib_debug/sba_debug.h | 61 + lib_debug/snr.c | 465 ++ lib_dec/FEC_HQ_phase_ecu.c | 2 +- lib_dec/TonalComponentDetection.c | 30 +- lib_dec/acelp_core_dec.c | 22 +- lib_dec/acelp_core_switch_dec.c | 14 +- lib_dec/amr_wb_dec.c | 18 +- lib_dec/ari_hm_dec.c | 2 +- lib_dec/arith_coder_dec.c | 2 +- lib_dec/cng_dec.c | 5 +- lib_dec/core_dec_init.c | 88 +- lib_dec/core_dec_reconf.c | 14 +- lib_dec/core_switching_dec.c | 12 +- lib_dec/dec_LPD.c | 24 +- lib_dec/dec_ace.c | 20 +- lib_dec/dec_post.c | 60 +- lib_dec/dec_prm.c | 14 +- lib_dec/dec_tcx.c | 142 +- lib_dec/dec_uv.c | 2 +- lib_dec/er_dec_acelp.c | 20 +- lib_dec/er_dec_tcx.c | 22 +- lib_dec/er_util.c | 14 +- lib_dec/evs_dec.c | 48 +- lib_dec/fd_cng_dec.c | 146 +- lib_dec/gaus_dec.c | 2 +- lib_dec/hf_synth.c | 12 +- lib_dec/hq_core_dec.c | 10 +- lib_dec/hq_env_dec.c | 4 +- lib_dec/igf_dec.c | 108 +- lib_dec/init_dec.c | 2 +- lib_dec/inov_dec.c | 8 +- lib_dec/ivas_core_dec.c | 8 +- lib_dec/ivas_cpe_dec.c | 2 +- lib_dec/ivas_dec.c | 23 +- lib_dec/ivas_init_dec.c | 2 +- lib_dec/ivas_ism_metadata_dec.c | 12 +- lib_dec/ivas_ism_renderer.c | 4 +- lib_dec/ivas_jbm_dec.c | 22 +- lib_dec/ivas_lfe_dec.c | 2 +- lib_dec/ivas_masa_dec.c | 10 +- lib_dec/ivas_mc_paramupmix_dec.c | 4 +- lib_dec/ivas_mdct_core_dec.c | 34 +- lib_dec/ivas_omasa_dec.c | 4 +- lib_dec/ivas_osba_dec.c | 4 +- lib_dec/ivas_post_proc.c | 12 +- lib_dec/ivas_range_uni_dec.c | 8 +- lib_dec/ivas_sce_dec.c | 6 +- lib_dec/ivas_sns_dec.c | 4 +- lib_dec/ivas_stat_dec.h | 4 +- lib_dec/ivas_stereo_cng_dec.c | 16 +- lib_dec/ivas_stereo_mdct_core_dec.c | 4 +- lib_dec/ivas_stereo_mdct_stereo_dec.c | 10 +- lib_dec/ivas_stereo_switching_dec.c | 48 +- lib_dec/ivas_svd_dec.c | 6 +- lib_dec/ivas_tcx_core_dec.c | 24 +- lib_dec/lib_dec.c | 10 +- lib_dec/lsf_dec.c | 28 +- lib_dec/lsf_msvq_ma_dec.c | 20 +- lib_dec/peak_vq_dec.c | 2 +- lib_dec/post_dec.c | 12 +- lib_dec/range_dec.c | 4 +- lib_dec/stat_dec.h | 1858 ++++- lib_dec/swb_tbe_dec.c | 10 +- lib_dec/tonalMDCTconcealment.c | 156 +- lib_dec/updt_dec.c | 10 +- lib_dec/vlpc_2st_dec.c | 2 +- lib_dec/waveadjust_fec_dec.c | 34 +- lib_enc/acelp_core_enc.c | 64 +- lib_enc/acelp_core_switch_enc.c | 14 +- lib_enc/amr_wb_enc.c | 58 +- lib_enc/ari_hm_enc.c | 2 +- lib_enc/arith_coder_enc.c | 10 +- lib_enc/bw_detect.c | 2 +- lib_enc/cod4t64.c | 18 +- lib_enc/cod_ace.c | 58 +- lib_enc/cod_tcx.c | 146 +- lib_enc/cod_uv.c | 2 +- lib_enc/core_enc_2div.c | 8 +- lib_enc/core_enc_init.c | 156 +- lib_enc/core_enc_ol.c | 110 +- lib_enc/core_enc_reconf.c | 10 +- lib_enc/core_enc_switch.c | 4 +- lib_enc/core_enc_updt.c | 46 +- lib_enc/core_switching_enc.c | 28 +- lib_enc/dtx.c | 8 +- lib_enc/enc_acelp.c | 6 +- lib_enc/enc_acelpx.c | 2 +- lib_enc/enc_amr_wb.c | 10 +- lib_enc/enc_gen_voic.c | 16 +- lib_enc/enc_gen_voic_rf.c | 44 +- lib_enc/enc_higher_acelp.c | 2 +- lib_enc/enc_nelp.c | 24 +- lib_enc/enc_pit_exc.c | 12 +- lib_enc/enc_ppp.c | 20 +- lib_enc/enc_prm.c | 2 +- lib_enc/enc_tran.c | 14 +- lib_enc/enc_uv.c | 32 +- lib_enc/evs_enc.c | 14 +- lib_enc/ext_sig_ana.c | 32 +- lib_enc/fd_cng_enc.c | 38 +- lib_enc/gs_enc.c | 10 +- lib_enc/guided_plc_enc.c | 8 +- lib_enc/hq_core_enc.c | 10 +- lib_enc/hq_env_enc.c | 2 +- lib_enc/igf_enc.c | 26 +- lib_enc/init_enc.c | 66 +- lib_enc/inov_enc.c | 8 +- lib_enc/ivas_core_pre_proc.c | 70 +- lib_enc/ivas_core_pre_proc_front.c | 28 +- lib_enc/ivas_enc.c | 4 +- lib_enc/ivas_front_vad.c | 6 +- lib_enc/ivas_mc_param_enc.c | 6 +- lib_enc/ivas_mct_core_enc.c | 2 +- lib_enc/ivas_mct_enc_mct.c | 12 +- lib_enc/ivas_mdct_core_enc.c | 22 +- lib_enc/ivas_osba_enc.c | 2 +- lib_enc/ivas_range_uni_enc.c | 4 +- lib_enc/ivas_sns_enc.c | 4 +- lib_enc/ivas_stereo_dmx_evs.c | 12 +- lib_enc/ivas_stereo_ica_enc.c | 8 +- lib_enc/ivas_stereo_mdct_core_enc.c | 12 +- lib_enc/ivas_stereo_mdct_stereo_enc.c | 12 +- lib_enc/ivas_stereo_switching_enc.c | 22 +- lib_enc/ivas_tcx_core_enc.c | 34 +- lib_enc/ivas_td_low_rate_enc.c | 20 +- lib_enc/lsf_enc.c | 38 +- lib_enc/lsf_msvq_ma_enc.c | 24 +- lib_enc/mdct_classifier.c | 18 +- lib_enc/mdct_selector.c | 6 +- lib_enc/peak_vq_enc.c | 2 +- lib_enc/pitch_ol2.c | 10 +- lib_enc/plc_enc_ext.c | 12 +- lib_enc/pre_proc.c | 44 +- lib_enc/q_gain2p.c | 20 +- lib_enc/range_enc.c | 6 +- lib_enc/rst_enc.c | 10 +- lib_enc/sig_clas.c | 4 +- lib_enc/speech_music_classif.c | 38 +- lib_enc/stat_enc.h | 745 +- lib_enc/swb_bwe_enc.c | 2 +- lib_enc/swb_pre_proc.c | 4 +- lib_enc/swb_tbe_enc.c | 26 +- lib_enc/tcx_ltp_enc.c | 42 +- lib_enc/tcx_utils_enc.c | 36 +- lib_enc/tns_base_enc.c | 14 +- lib_enc/transient_detection.c | 64 +- lib_enc/updt_enc.c | 14 +- lib_enc/vlpc_2st_cod.c | 2 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 28 +- lib_rend/ivas_dirac_output_synthesis_dec.c | 18 +- lib_rend/ivas_efap.c | 2 +- lib_util/mime_io.c | 4 +- lib_util/test_fft.c | 213 + 268 files changed, 50402 insertions(+), 2904 deletions(-) create mode 100644 lib_com/bitstream_fx.c create mode 100644 lib_com/complex_basop.c create mode 100644 lib_com/complex_basop.h create mode 100644 lib_com/control.c create mode 100644 lib_com/count.c create mode 100644 lib_com/count.h create mode 100644 lib_com/enh64.c create mode 100644 lib_com/enh64.h create mode 100644 lib_com/enhUL32.c create mode 100644 lib_com/enhUL32.h create mode 100644 lib_com/fft_fx.c create mode 100644 lib_com/gs_gains_fx.c create mode 100644 lib_com/hq2_bit_alloc_fx.c create mode 100644 lib_com/hq_tools_fx.c create mode 100644 lib_com/logqnorm_fx.c create mode 100644 lib_com/lpc_tools_fx.c create mode 100644 lib_com/lsf_tools_fx.c create mode 100644 lib_com/math_op.h create mode 100644 lib_com/mslvq_com_fx.c create mode 100644 lib_com/oper_32b.c create mode 100644 lib_com/oper_32b.h create mode 100644 lib_com/prot_fx1.h create mode 100644 lib_com/prot_fx2.h create mode 100644 lib_com/rom_basop_util.c create mode 100644 lib_com/rom_basop_util.h create mode 100644 lib_com/rom_com_fx.c create mode 100644 lib_com/rom_com_fx.h create mode 100644 lib_com/scale_mem_fx.c create mode 100644 lib_com/swb_bwe_com_fx.c create mode 100644 lib_com/tools_fx.c create mode 100644 lib_com/typedefs.h create mode 100644 lib_debug/debug.c create mode 100644 lib_debug/debug.h create mode 100644 lib_debug/sba_debug.c create mode 100644 lib_debug/sba_debug.h create mode 100644 lib_debug/snr.c create mode 100644 lib_util/test_fft.c diff --git a/Workspace_msvc/decoder.vcxproj b/Workspace_msvc/decoder.vcxproj index e59992847..98827b70c 100644 --- a/Workspace_msvc/decoder.vcxproj +++ b/Workspace_msvc/decoder.vcxproj @@ -149,6 +149,7 @@ + diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 22407fb02..5db9f886e 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -134,12 +134,14 @@ + + @@ -148,6 +150,7 @@ + @@ -157,6 +160,7 @@ + @@ -165,6 +169,7 @@ + @@ -176,6 +181,7 @@ + @@ -224,16 +230,21 @@ + + + + + @@ -247,11 +258,15 @@ + + + + @@ -265,6 +280,7 @@ + @@ -295,8 +311,11 @@ + + + diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index 7a8f8e013..2b88b2d97 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -472,6 +472,52 @@ common_ivas_c + + common_all_c + + + common_all_c + + + common_all_c + + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + @@ -539,6 +585,15 @@ common_h + + common_h + + + common_h + + + common_h + diff --git a/Workspace_msvc/lib_debug.vcxproj b/Workspace_msvc/lib_debug.vcxproj index f54f282f0..bef619b8f 100644 --- a/Workspace_msvc/lib_debug.vcxproj +++ b/Workspace_msvc/lib_debug.vcxproj @@ -56,8 +56,8 @@ Disabled - ..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) + ..\lib_com;..\lib_util;..\lib_debug;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;DEBUGGING;DBG_WAV_WRITER;$(Macros);%(PreprocessorDefinitions) false EnableFastChecks @@ -100,9 +100,14 @@ + + + + + diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 10a3ac1b4..2b90c2610 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -347,4 +347,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index ef14ddf0e..b916d743c 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -439,6 +439,9 @@ decoder_all_c + + decoder_all_c + decoder_all_c @@ -517,7 +520,6 @@ decoder_all_c - @@ -556,7 +558,9 @@ decoder_h - + + decoder_h + diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index e2db02d61..e3deeb989 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -362,4 +362,4 @@ - + \ No newline at end of file diff --git a/apps/decoder.c b/apps/decoder.c index afb288dc0..3b7116a48 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -129,6 +129,7 @@ static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); +void run_fft_unit_test(void); /*------------------------------------------------------------------------------------------* * main() @@ -155,6 +156,7 @@ int main( Vector3PairFileReader *referenceVectorReader = NULL; RenderConfigReader *renderConfigReader = NULL; int16_t *pcmBuf = NULL; + int16_t run_unit_tests = 0; #ifdef WMOPS reset_wmops(); @@ -167,6 +169,12 @@ int main( IVAS_DEC_PrintDisclaimer(); + if (run_unit_tests) + { + run_fft_unit_test(); + return; + } + if ( !parseCmdlIVAS_dec( (int16_t) argc, argv, &arg ) ) { /* Error printout done in parseCmdlIVAS_dec() */ diff --git a/lib_com/ari_hm.c b/lib_com/ari_hm.c index 3995913c4..5d6d3315b 100644 --- a/lib_com/ari_hm.c +++ b/lib_com/ari_hm.c @@ -218,13 +218,13 @@ int16_t tcx_hm_render( f0 = L_shl( lag, sub( 15, fract_res ) ); /* Q15 */ - tmp32 = Mpy_32_16( f0, -26474 ); + tmp32 = Mpy_32_16_1( f0, -26474 ); tmp32 = L_shr_r( BASOP_Util_InvLog2( L_shl( tmp32, 7 ) ), 2 ); tmp32 = L_sub( 603979776L, tmp32 ); - tmp32 = L_add( L_add( tmp32, tmp32 ), Mpy_32_16( tmp32, 26214 ) ); + tmp32 = L_add( L_add( tmp32, tmp32 ), Mpy_32_16_1( tmp32, 26214 ) ); height = round_fx( tmp32 ); /* Q13 */ - tmp32 = Mpy_32_16( f0, -18910 ); + tmp32 = Mpy_32_16_1( f0, -18910 ); tmp32 = L_shr_r( BASOP_Util_InvLog2( L_shl( tmp32, 7 ) ), 2 ); tmp32 = L_sub( 1395864371L, tmp32 ); PeakDeviation = round_fx( tmp32 ); /* Q14 */ @@ -245,7 +245,7 @@ int16_t tcx_hm_render( for ( k = 1; k <= kTcxHmParabolaHalfWidth; ++k ) { - p[kTcxHmParabolaHalfWidth + k] = round_fx( Mpy_32_16( BASOP_Util_InvLog2( L_shl( L_mult0( mult0( negate( k ), k ), tmp ), 10 ) ), height ) ); + p[kTcxHmParabolaHalfWidth + k] = round_fx( Mpy_32_16_1( BASOP_Util_InvLog2( L_shl( L_mult0( mult0( negate( k ), k ), tmp ), 10 ) ), height ) ); } /* Mirror */ for ( k = -kTcxHmParabolaHalfWidth; k < 0; ++k ) @@ -293,7 +293,7 @@ void tcx_hm_modify_envelope( for ( x = max( 0, k - kTcxHmParabolaHalfWidth ); x <= min( k + kTcxHmParabolaHalfWidth, L_frame - 1 ); ++x ) { - env[x] = Mpy_32_16( env[x], inv_shape[x - k + kTcxHmParabolaHalfWidth] ); + env[x] = Mpy_32_16_1( env[x], inv_shape[x - k + kTcxHmParabolaHalfWidth] ); } ++h; k = ( h * lag ) >> fract_res; diff --git a/lib_com/arith_coder.c b/lib_com/arith_coder.c index f27617b27..9ebe09592 100644 --- a/lib_com/arith_coder.c +++ b/lib_com/arith_coder.c @@ -96,13 +96,13 @@ Word16 expfp( b3 = s_and( xi, 8 ); if ( b0 != 0 ) - y = Mpy_32_16( y, 24109 ); /* exp(-1) in -1Q16 */ + y = Mpy_32_16_1( y, 24109 ); /* exp(-1) in -1Q16 */ if ( b1 != 0 ) - y = Mpy_32_16( y, 17739 ); /* exp(-2) in -2Q17 */ + y = Mpy_32_16_1( y, 17739 ); /* exp(-2) in -2Q17 */ if ( b2 != 0 ) - y = Mpy_32_16( y, 19205 ); /* exp(-4) in -5Q20 */ + y = Mpy_32_16_1( y, 19205 ); /* exp(-4) in -5Q20 */ if ( b3 != 0 ) - y = Mpy_32_16( y, 22513 ); /* exp(-8) in -11Q26 */ + y = Mpy_32_16_1( y, 22513 ); /* exp(-8) in -11Q26 */ /* scaling: -1*b0 - 2*b1 -5*b2 -11*b3 */ y = L_shr( y, add( add( xi, shr( xi, 2 ) ), shr( b3, 3 ) ) ); @@ -252,10 +252,10 @@ void tcx_arith_scale_envelope( /* Boosting to account for expected spectrum truncation (kMax) */ /* target_bits = (int16_t)(target_bits * (1.2f - 0.00045f * target_bits + 0.00000025f * target_bits * target_bits)); */ - L_tmp = L_shr( Mpy_32_16( L_mult0( target_bits, target_bits ), 17180 ), 6 ); /* Q15; 17180 -> 0.00000025f (Q36) */ + L_tmp = L_shr( Mpy_32_16_1( L_mult0( target_bits, target_bits ), 17180 ), 6 ); /* Q15; 17180 -> 0.00000025f (Q36) */ L_tmp = L_sub( L_tmp, L_shr( L_mult0( target_bits, 30199 ), 11 ) ); /* Q15; 30199 -> 0.00045f (Q26) */ L_tmp = L_add( L_tmp, 39322 ); /* Q15; 39322 -> 1.2f (Q15) */ - L_tmp = Mpy_32_16( L_tmp, target_bits ); /* Q0 */ + L_tmp = Mpy_32_16_1( L_tmp, target_bits ); /* Q0 */ assert( L_tmp < 32768 ); target_bits = extract_l( L_tmp ); @@ -280,7 +280,7 @@ void tcx_arith_scale_envelope( tmp = norm_s( L_frame ); tmp2 = div_s( 8192, shl( L_frame, tmp ) ); tmp = shl( tmp2, sub( tmp, 7 ) ); - mean = L_shr( Mpy_32_16( mean, tmp ), 6 ); /* Q16 */ + mean = L_shr( Mpy_32_16_1( mean, tmp ), 6 ); /* Q16 */ /* Rate dependent compensation to get closer to the target on average */ /* mean = powf(mean, (float)L_frame / target_bits * 0.357f); */ @@ -307,9 +307,9 @@ void tcx_arith_scale_envelope( /* scale = (-b + sqrtf(b*b - 4.0f*a*0.035f)) / (2.0f * a); */ #ifndef BASOP_NOGLOB - tmp = round_fx( BASOP_Util_Add_Mant32Exp( L_mult( b, b ), shl( b_e, 1 ), Mpy_32_16( a, FL2WORD16( -4.0f * 0.035f ) ), a_e, &tmp2 ) ); + tmp = round_fx( BASOP_Util_Add_Mant32Exp( L_mult( b, b ), shl( b_e, 1 ), Mpy_32_16_1( a, FL2WORD16( -4.0f * 0.035f ) ), a_e, &tmp2 ) ); #else - tmp = round_fx_o( BASOP_Util_Add_Mant32Exp( L_mult( b, b ), shl( b_e, 1 ), Mpy_32_16( a, FL2WORD16( -4.0f * 0.035f ) ), a_e, &tmp2 ), &Overflow ); + tmp = round_fx_o( BASOP_Util_Add_Mant32Exp( L_mult( b, b ), shl( b_e, 1 ), Mpy_32_16_1( a, FL2WORD16( -4.0f * 0.035f ) ), a_e, &tmp2 ), &Overflow ); #endif IF( tmp <= 0 ) @@ -362,7 +362,7 @@ void tcx_arith_scale_envelope( FOR( k = 0; k < L_frame; k++ ) { - s = Mpy_32_16( ienv[k], scale ); /* Q16 */ + s = Mpy_32_16_1( ienv[k], scale ); /* Q16 */ IF( L_sub( s, FL2WORD32_SCALE( 0.08f, 15 ) ) <= 0 ) { @@ -377,9 +377,9 @@ void tcx_arith_scale_envelope( ELSE IF( L_sub( s, FL2WORD32_SCALE( 255.0, 15 ) ) <= 0 ) { /* a = 5.436564f * s + 0.15f + 0.035f * env[k] * iscale; */ - L_tmp = L_shl( Mpy_32_16( s, FL2WORD16_SCALE( 5.436564f, 3 ) ), 3 ); + L_tmp = L_shl( Mpy_32_16_1( s, FL2WORD16_SCALE( 5.436564f, 3 ) ), 3 ); L_tmp = L_add( L_tmp, FL2WORD32_SCALE( 0.15f, 15 ) ); - L_tmp = L_add( L_tmp, L_shl( Mpy_32_16( env[k], mult_r( FL2WORD16( 0.035f ), iscale ) ), iscale_e ) ); + L_tmp = L_add( L_tmp, L_shl( Mpy_32_16_1( env[k], mult_r( FL2WORD16( 0.035f ), iscale ) ), iscale_e ) ); tmp = norm_l( L_tmp ); #ifndef BASOP_NOGLOB @@ -398,7 +398,7 @@ void tcx_arith_scale_envelope( /* for large envelope values, s > 255, bit consumption is approx log2(2*e*s) * further, we use round(log2(x)) = floor(log2(x)+0.5) = floor(log2(x*sqrt(2))) */ /* a = 5.436564f * s; */ - L_tmp = Mpy_32_16( s, FL2WORD16_SCALE( 5.436564f * 1.4142f, 3 ) ); /* Q13 */ + L_tmp = Mpy_32_16_1( s, FL2WORD16_SCALE( 5.436564f * 1.4142f, 3 ) ); /* Q13 */ bits = add( bits, sub( 17, norm_l( L_tmp ) ) ); } } @@ -495,7 +495,7 @@ void tcx_arith_scale_envelope( FOR( k = 0; k < L_frame; k++ ) { - L_tmp = Mpy_32_16( L_shl( env[k], tmp ), iscale ); + L_tmp = Mpy_32_16_1( L_shl( env[k], tmp ), iscale ); L_tmp = L_min( L_tmp, a ); s_env[k] = round_fx( L_tmp ); move16(); diff --git a/lib_com/basop32.c b/lib_com/basop32.c index 3e608e4a6..448964a28 100644 --- a/lib_com/basop32.c +++ b/lib_com/basop32.c @@ -170,6 +170,11 @@ HISTORY: #pragma warning( disable : 4310 ) #endif +#if (WMOPS) +extern BASIC_OP multiCounter[MAXCOUNTERS]; +extern int currCounter; +#endif + /*___________________________________________________________________________ | | | Local Functions | @@ -186,15 +191,139 @@ static Word16 saturate( Word32 L_var1 ); | Constants and Globals | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB +#ifdef BASOP_NOGLOB + +#ifdef BASOP_PRINT_ON_WARNING +#include +#if defined(__unix__) || defined(__unix) || defined(__APPLE__) +#include +/* Using macro instead of function here to avoid pushing new frames onto the stack */ +#define PRINT_STACK() \ + do { \ + void *call_stack[200]; \ + int i; \ + int num_frames; \ + char **strings; \ + \ + num_frames = backtrace(call_stack, 200); \ + strings = backtrace_symbols(call_stack, num_frames); \ + for (i = 0; i < num_frames; ++i) { \ + printf("[BASOP] %s\n", strings[i]); \ + } \ + free(strings); \ + } while (0) +#elif defined _WIN32 || defined _WIN64 +#include +#include +#pragma comment(lib, "Dbghelp.lib") + +/* Using macro instead of function here to avoid pushing new frames onto the stack */ +#define PRINT_STACK() \ + do { \ + void *call_stack[200]; \ + int i; \ + int num_frames; \ + DWORD64 offset; \ + SYMBOL_INFO *symbol; \ + IMAGEHLP_MODULE module; \ + HANDLE process; \ + \ + process = GetCurrentProcess(); \ + SymInitialize(process, NULL, TRUE); \ + symbol = \ + (SYMBOL_INFO *)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1); \ + symbol->MaxNameLen = 255; \ + symbol->SizeOfStruct = sizeof(SYMBOL_INFO); \ + module.SizeOfStruct = sizeof(IMAGEHLP_MODULE64); \ + \ + IMAGEHLP_LINE *line_info = \ + (IMAGEHLP_LINE *)calloc(sizeof(IMAGEHLP_LINE), 1); \ + line_info->SizeOfStruct = sizeof(IMAGEHLP_LINE); \ + \ + num_frames = CaptureStackBackTrace(0, 200, call_stack, NULL); \ + for (i = 0; i < num_frames; ++i) { \ + DWORD dwLineDisplacement; \ + SymFromAddr(process, (DWORD64)(call_stack[i]), &offset, symbol); \ + SymGetModuleInfo(process, (DWORD)symbol->ModBase, &module); \ + if (SymGetLineFromAddr(process, (DWORD64)(call_stack[i]), \ + &dwLineDisplacement, line_info)) { \ + printf("[BASOP] %i\t%s(%s+0x%llX) [0x%llX] %s:%d\n", i, \ + module.ModuleName, symbol->Name, offset, symbol->Address, \ + line_info->FileName, line_info->LineNumber); \ + } else { \ + printf("[BASOP] %i\t%s(%s+0x%llX) [0x%llX]\n", i, module.ModuleName, \ + symbol->Name, offset, symbol->Address); \ + } \ + } \ + free(line_info); \ + free(symbol); \ + } while (0) +#else +#define PRINT_STACK() \ + do { \ + printf("[BASOP] - printing call stack is not " \ + "supported on this platform\n"); \ + } while (0) +#endif + +/* Using macro instead of function here to avoid pushing new frames onto the stack */ +#define PRINT_BASOP_NOGLOB_WARNING() \ + do { \ + printf("[BASOP] Overflow occured. Call stack:\n"); \ + PRINT_STACK(); \ + } while (0) + +/* Using macro instead of function here to avoid pushing new frames onto the stack */ +#define PRINT_BASOP_NOGLOB_ERROR() \ + do { \ + printf("[BASOP] Overflow error occured. Call stack:\n"); \ + PRINT_STACK(); \ + } while (0) +#endif /* BASOP_PRINT_ON_WARNING */ + +#if defined BASOP_PRINT_ON_WARNING || defined BASOP_ABORT_ON_WARNING +int BASOP_saturation_warning_enable = 1, BASOP_saturation_warning_disable_counter = 0; +int BASOP_warnings_as_errors = 0; +#endif + +#ifdef BASOP_PRINT_ON_WARNING +#define B_HELPER_PRINT_WARNING() do { if (BASOP_saturation_warning_enable) { if(BASOP_warnings_as_errors) { PRINT_BASOP_NOGLOB_ERROR(); } else { PRINT_BASOP_NOGLOB_WARNING(); } } } while(0) +#else +#define B_HELPER_PRINT_WARNING() do { (void)0; } while(0) /* no-op */ +#endif + +#ifdef BASOP_ABORT_ON_WARNING +#define B_HELPER_ABORT() do { if (BASOP_saturation_warning_enable) { assert(0); } } while(0) +#else +#define B_HELPER_ABORT() do { (void)0; } while(0) /* no-op */ +#endif + +#ifdef BASOP_NOGLOB_DEV_USE_GLOBALS Flag Overflow = 0; Flag Carry = 0; -#else /* BASOP_NOGLOB */ -/* -Flag BASOP_Overflow = 0; -Flag BASOP_Carry = 0; -*/ +#define B_HELPER_SET_GLOBAL(global_flag, value) do { (global_flag) = (value); } while (0) +#define B_HELPER_GET_GLOBAL(global_flag) (global_flag) +#else +#define B_HELPER_SET_GLOBAL(global_flag, value) do { (void)0; } while(0) /* no-op */ +#define B_HELPER_GET_GLOBAL(global_flag) 0 /* Default to 0 */ +#endif + +void set_overflow(Flag *overflow) { if (overflow) *overflow = 1; else { B_HELPER_PRINT_WARNING(); B_HELPER_ABORT(); B_HELPER_SET_GLOBAL(Overflow, 1); } } +void unset_overflow(Flag* overflow) { if (overflow) *overflow = 0; else { B_HELPER_PRINT_WARNING(); B_HELPER_ABORT(); B_HELPER_SET_GLOBAL(Overflow, 0); } } +void set_carry(Flag *carry) { if (carry) *carry = 1; else { B_HELPER_PRINT_WARNING(); B_HELPER_ABORT(); B_HELPER_SET_GLOBAL(Carry, 1); } } +void unset_carry(Flag* carry) { if (carry) *carry = 0; else { B_HELPER_PRINT_WARNING(); B_HELPER_ABORT(); B_HELPER_SET_GLOBAL(Carry, 0); } } +Flag get_carry(const Flag* carry) { if (carry) return *carry; else { B_HELPER_PRINT_WARNING(); B_HELPER_ABORT(); } return B_HELPER_GET_GLOBAL(Carry); } + +/* Undef helper macros - these should only be used in functions above */ +#undef B_HELPER_PRINT_WARNING +#undef B_HELPER_ABORT +#undef B_HELPER_SET_GLOBAL +#undef B_HELPER_GET_GLOBAL + +#else /* BASOP_NOGLOB */ +Flag Overflow = 0; +Flag Carry = 0; #endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ @@ -352,8 +481,12 @@ Word16 add( Word16 var1, Word16 var2 ) return ( var_out ); } - - +#ifdef BASOP_NOGLOB +Word16 add_sat(Word16 var1, Word16 var2) { + Flag Overflow; + return add_o(var1, var2, &Overflow); +} +#endif /*___________________________________________________________________________ | | | Function Name : sub | @@ -410,8 +543,12 @@ Word16 sub( Word16 var1, Word16 var2 ) return ( var_out ); } - - +#ifdef BASOP_NOGLOB +Word16 sub_sat(Word16 var1, Word16 var2) { + Flag Overflow; + return sub_o(var1, var2, &Overflow); +} +#endif /*___________________________________________________________________________ | | | Function Name : abs_s | @@ -574,6 +711,11 @@ Word16 shl( Word16 var1, Word16 var2 ) return ( var_out ); } + +Word16 shl_sat(Word16 var1, Word16 var2) { + Flag Overflow; + return shl_o(var1, var2, &Overflow); +} #endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ @@ -610,44 +752,55 @@ Word16 shl( Word16 var1, Word16 var2 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -Word16 shr( Word16 var1, Word16 var2 ) -{ - Word16 var_out; +#ifdef BASOP_NOGLOB +Word16 shr_o(Word16 var1, Word16 var2, Flag *Overflow) { +#else /* BASOP_NOGLOB */ +Word16 shr(Word16 var1, Word16 var2) { +#endif /* BASOP_NOGLOB */ + Word16 var_out; - if ( var2 < 0 ) - { + if (var2 < 0) { + if (var2 < -16) + var2 = -16; + var2 = -var2; #ifdef BASOP_NOGLOB - assert( 0 ); + var_out = shl_o(var1, var2, Overflow); +#else /* BASOP_NOGLOB */ + var_out = shl(var1, var2); #endif /* BASOP_NOGLOB */ - if ( var2 < -16 ) - var2 = -16; - var2 = -var2; - var_out = shl( var1, var2 ); + +#if (WMOPS) + multiCounter[currCounter].shl--; +#endif + } + else { + if (var2 >= 15) { + var_out = (var1 < 0) ? -1 : 0; } - else - { - if ( var2 >= 15 ) - { - var_out = ( var1 < 0 ) ? -1 : 0; - } - else - { - if ( var1 < 0 ) - { - var_out = ~( ( ~var1 ) >> var2 ); - } - else - { - var_out = var1 >> var2; - } - } + else { + if (var1 < 0) { + var_out = ~((~var1) >> var2); + } + else { + var_out = var1 >> var2; + } } + } - BASOP_CHECK(); + BASOP_CHECK(); + return (var_out); +} - return ( var_out ); +#ifdef BASOP_NOGLOB +Word16 shr(Word16 var1, Word16 var2) { + return shr_o(var1, var2, NULL); +} +Word16 shr_sat(Word16 var1, Word16 var2) { + Flag Overflow; + return shr_o(var1, var2, &Overflow); } +#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ @@ -685,25 +838,30 @@ Word16 shr( Word16 var1, Word16 var2 ) |___________________________________________________________________________| */ #ifdef BASOP_NOGLOB -Word16 mult_o( Word16 var1, Word16 var2, Flag *Overflow ) -{ - Word16 var_out; - Word32 L_product; - - L_product = (Word32) var1 * (Word32) var2; +Word16 mult_o(Word16 var1, Word16 var2, Flag *Overflow) { +#else /* BASOP_NOGLOB */ +Word16 mult(Word16 var1, Word16 var2) { +#endif /* BASOP_NOGLOB */ + Word16 var_out; + Word32 L_product; - L_product = ( L_product & (Word32) 0xffff8000L ) >> 15; + L_product = (Word32)var1 *(Word32)var2; - if ( L_product & (Word32) 0x00010000L ) - L_product = L_product | (Word32) 0xffff0000L; + L_product = (L_product & (Word32)0xffff8000L) >> 15; - var_out = saturate_o( L_product, Overflow ); + if (L_product & (Word32)0x00010000L) + L_product = L_product | (Word32)0xffff0000L; +#ifdef BASOP_NOGLOB + var_out = saturate_o(L_product, Overflow); +#else /* BASOP_NOGLOB */ + var_out = saturate(L_product); +#endif /* BASOP_NOGLOB */ - return ( var_out ); + BASOP_CHECK(); + return (var_out); } - -#endif /* BASOP_NOGLOB */ +#ifdef BASOP_NOGLOB Word16 mult( Word16 var1, Word16 var2 ) { Word16 var_out; @@ -722,6 +880,12 @@ Word16 mult( Word16 var1, Word16 var2 ) return ( var_out ); } +Word16 mult_sat(Word16 var1, Word16 var2) { + Flag Overflow; + return mult_o(var1, var2, &Overflow); +} + +#endif /*___________________________________________________________________________ | | @@ -807,6 +971,11 @@ Word32 L_mult( Word16 var1, Word16 var2 ) return ( L_var_out ); } + +Word32 L_mult_sat(Word16 var1, Word16 var2) { + Flag Overflow; + return L_mult_o(var1, var2, &Overflow); +} #endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ @@ -992,8 +1161,12 @@ Word16 round_fx( Word32 L_var1 ) return ( var_out ); } - - +#ifdef BASOP_NOGLOB +Word16 round_fx_sat(Word32 L_var1) { + Flag Overflow; + return round_fx_o(L_var1, &Overflow); +} +#endif /*___________________________________________________________________________ | | | Function Name : L_mac | @@ -1057,8 +1230,12 @@ Word32 L_mac( Word32 L_var3, Word16 var1, Word16 var2 ) return ( L_var_out ); } - - +#ifdef BASOP_NOGLOB +Word32 L_mac_sat(Word32 L_var3, Word16 var1, Word16 var2) { + Flag Overflow; + return L_mac_o(L_var3, var1, var2, &Overflow); +} +#endif /*___________________________________________________________________________ | | | Function Name : L_msu | @@ -1122,8 +1299,12 @@ Word32 L_msu( Word32 L_var3, Word16 var1, Word16 var2 ) return ( L_var_out ); } - - +#ifdef BASOP_NOGLOB +Word32 L_msu_sat(Word32 L_var3, Word16 var1, Word16 var2) { + Flag Overflow; + return L_msu_o(L_var3, var1, var2, &Overflow); +} +#endif /*___________________________________________________________________________ | | | Function Name : L_macNs | @@ -1170,28 +1351,43 @@ Word32 L_msu( Word32 L_var3, Word16 var1, Word16 var2 ) | operators which take into account its value. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word32 L_macNs( Word32 L_var3, Word16 var1, Word16 var2 ) -#else /* BASOP_NOGLOB */ +#ifdef BASOP_NOGLOB Word32 DEPR_L_macNs( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out; L_var_out = L_mult( var1, var2 ); -#ifndef BASOP_NOGLOB - L_var_out = L_add_c( L_var3, L_var_out ); -#else /* BASOP_NOGLOB */ L_var_out = DEPR_L_add_c( L_var3, L_var_out, Carry ); -#endif /* BASOP_NOGLOB */ /* BASOP_CHECK(); Do not check for overflow here, function produces the carry bit instead */ - - return ( L_var_out ); } +#endif +#ifdef BASOP_NOGLOB +Word32 L_macNs_co(Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry, Flag *Overflow) { +#else /* BASOP_NOGLOB */ +Word32 L_macNs(Word32 L_var3, Word16 var1, Word16 var2) { +#endif /* BASOP_NOGLOB */ + Word32 L_var_out; - +#ifdef BASOP_NOGLOB + L_var_out = L_mult_o(var1, var2, Overflow); + L_var_out = L_add_co(L_var3, L_var_out, Carry, Overflow); +#else /* BASOP_NOGLOB */ + L_var_out = L_mult(var1, var2); + L_var_out = L_add_c(L_var3, L_var_out); +#endif /* BASOP_NOGLOB */ + return (L_var_out); +} +#ifdef BASOP_NOGLOB +Word32 L_macNs(Word32 L_var3, Word16 var1, Word16 var2) { + return L_macNs_co(L_var3, var1, var2, NULL, NULL); +} +Word32 L_macNs_sat(Word32 L_var3, Word16 var1, Word16 var2) { + Flag Carry, Overflow; + return L_macNs_co(L_var3, var1, var2, &Carry, &Overflow); +} +#endif /*___________________________________________________________________________ | | | Function Name : L_msuNs | @@ -1259,7 +1455,25 @@ Word32 DEPR_L_msuNs( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB +Word32 L_msuNs_co(Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry, Flag *Overflow) { + Word32 L_var_out; + + L_var_out = L_mult(var1, var2); + L_var_out = L_sub_co(L_var3, L_var_out, Carry, Overflow); + + return (L_var_out); +} + +Word32 L_msuNs(Word32 L_var3, Word16 var1, Word16 var2) { + return L_msuNs_co(L_var3, var1, var2, NULL, NULL); +} +Word32 L_msuNs_sat(Word32 L_var3, Word16 var1, Word16 var2) { + Flag Carry, Overflow; + return L_msuNs_co(L_var3, var1, var2, &Carry, &Overflow); +} +#endif /*___________________________________________________________________________ | | | Function Name : L_add | @@ -1338,6 +1552,10 @@ Word32 L_add( Word32 L_var1, Word32 L_var2 ) return ( L_var_out ); } +Word32 L_add_sat(Word32 L_var1, Word32 L_var2) { + Flag Overflow; + return L_add_o(L_var1, L_var2, &Overflow); +} #endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ @@ -1419,6 +1637,10 @@ Word32 L_sub( Word32 L_var1, Word32 L_var2 ) return ( L_var_out ); } +Word32 L_sub_sat(Word32 L_var1, Word32 L_var2) { + Flag Overflow; + return L_sub_o(L_var1, L_var2, &Overflow); +} #endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ @@ -1578,8 +1800,67 @@ Word32 DEPR_L_add_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB +Word32 L_add_co(Word32 L_var1, Word32 L_var2, Flag *Carry, Flag *Overflow) { + Word32 L_var_out; + Word32 L_test; + Flag carry_int = 0; + + L_var_out = L_var1 + L_var2 + get_carry(Carry); + + L_test = L_var1 + L_var2; + + if ((L_var1 > 0) && (L_var2 > 0) && (L_test < 0)) { + set_overflow(Overflow); + carry_int = 0; + } + else { + if ((L_var1 < 0) && (L_var2 < 0)) { + if (L_test >= 0) { + set_overflow(Overflow); + carry_int = 1; + } + else { + unset_overflow(Overflow); + carry_int = 1; + } + } + else { + if (((L_var1 ^ L_var2) < 0) && (L_test >= 0)) { + unset_overflow(Overflow); + carry_int = 1; + } + else { + unset_overflow(Overflow); + carry_int = 0; + } + } + } + if (get_carry(Carry)) { + if (L_test == MAX_32) { + set_overflow(Overflow); + carry_int ? set_carry(Carry) : unset_carry(Carry); + } + else { + if (L_test == (Word32)0xFFFFFFFFL) { + set_carry(Carry); + } + else { + carry_int ? set_carry(Carry) : unset_carry(Carry); + } + } + } + else { + carry_int ? set_carry(Carry) : unset_carry(Carry); + } + return (L_var_out); +} +Word32 L_add_c(Word32 L_var1, Word32 L_var2) { + return L_add_co(L_var1, L_var2, NULL, NULL); +} +#endif /*___________________________________________________________________________ | | | Function Name : L_sub_c | @@ -1718,8 +1999,51 @@ Word32 DEPR_L_sub_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB +Word32 L_sub_co(Word32 L_var1, Word32 L_var2, Flag *Carry, Flag *Overflow) { + Word32 L_var_out; + Word32 L_test; + Flag carry_int = 0; + + if (get_carry(Carry)) { + unset_carry(Carry); + if (L_var2 != MIN_32) { + L_var_out = L_add_co(L_var1, -L_var2, Carry, Overflow); + } + else { + L_var_out = L_var1 - L_var2; + if (L_var1 > 0L) { + unset_carry(Carry); + } + } + } + else { + L_var_out = L_var1 - L_var2 - (Word32)0X00000001L; + L_test = L_var1 - L_var2; + if ((L_test < 0) && (L_var1 > 0) && (L_var2 < 0)) { + carry_int = 0; + } + else if ((L_test > 0) && (L_var1 < 0) && (L_var2 > 0)) { + carry_int = 1; + } + else if ((L_test > 0) && ((L_var1 ^ L_var2) > 0)) { + carry_int = 1; + } + if (L_test == MIN_32) { + carry_int ? set_carry(Carry) : unset_carry(Carry); + } + else { + carry_int ? set_carry(Carry) : unset_carry(Carry); + } + } + return (L_var_out); +} +Word32 L_sub_c(Word32 L_var1, Word32 L_var2) { + return L_sub_co(L_var1, L_var2, NULL, NULL); +} +#endif /*___________________________________________________________________________ | | | Function Name : L_negate | @@ -1834,7 +2158,12 @@ Word16 mult_r( Word16 var1, Word16 var2 ) return ( var_out ); } - +#ifdef BASOP_NOGLOB +Word16 mult_r_sat(Word16 var1, Word16 var2) { + Flag Overflow; + return mult_ro(var1, var2, &Overflow); +} +#endif /*___________________________________________________________________________ | | | Function Name : L_shl | @@ -1964,8 +2293,13 @@ Word32 L_shl( Word32 L_var1, Word16 var2 ) return ( L_var_out ); } -#endif /* BASOP_NOGLOB */ +Word32 L_shl_sat(Word32 L_var1, Word16 var2) { + Flag Overflow; + return L_shl_o(L_var1, var2, &Overflow); +} + +#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | | Function Name : L_shr | @@ -2072,8 +2406,12 @@ Word32 L_shr( Word32 L_var1, Word16 var2 ) return ( L_var_out ); } - - +#ifdef BASOP_NOGLOB +Word32 L_shr_sat(Word32 L_var1, Word16 var2) { + Flag Overflow; + return L_shr_o(L_var1, var2, &Overflow); +} +#endif /*___________________________________________________________________________ | | | Function Name : shr_r | @@ -2140,8 +2478,29 @@ Word16 shr_r( Word16 var1, Word16 var2 ) return ( var_out ); } - - +#ifdef BASOP_NOGLOB +Word16 shr_ro(Word16 var1, Word16 var2, Flag* Overflow) { + Word16 var_out; + + if (var2 > 15) { + var_out = 0; + } + else { + var_out = shr_o(var1, var2, Overflow); + + if (var2 > 0) { + if ((var1 & ((Word16)1 << (var2 - 1))) != 0) { + var_out++; + } + } + } + return (var_out); +} +Word16 shr_r_sat(Word16 var1, Word16 var2) { + Flag Overflow; + return shr_ro(var1, var2, &Overflow); +} +#endif /*___________________________________________________________________________ | | | Function Name : mac_r | @@ -2209,8 +2568,12 @@ Word16 mac_r( Word32 L_var3, Word16 var1, Word16 var2 ) return ( var_out ); } - - +#ifdef BASOP_NOGLOB +Word16 mac_r_sat(Word32 L_var3, Word16 var1, Word16 var2) { + Flag Overflow; + return mac_ro(L_var3, var1, var2, &Overflow); +} +#endif /*___________________________________________________________________________ | | | Function Name : msu_r | @@ -2276,8 +2639,12 @@ Word16 msu_r( Word32 L_var3, Word16 var1, Word16 var2 ) return ( var_out ); } - - +#ifdef BASOP_NOGLOB +Word16 msu_r_sat(Word32 L_var3, Word16 var1, Word16 var2) { + Flag Overflow; + return msu_ro(L_var3, var1, var2, &Overflow); +} +#endif /*___________________________________________________________________________ | | | Function Name : L_deposit_h | @@ -2427,8 +2794,29 @@ Word32 L_shr_r( Word32 L_var1, Word16 var2 ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB +Word32 L_shr_ro(Word32 L_var1, Word16 var2, Flag * Overflow) { + Word32 L_var_out; + + if (var2 > 31) { + L_var_out = 0; + } + else { + L_var_out = L_shr_o(L_var1, var2, Overflow); + if (var2 > 0) { + if ((L_var1 & ((Word32)1 << (var2 - 1))) != 0) { + L_var_out++; + } + } + } + return (L_var_out); +} - +Word32 L_shr_r_sat(Word32 L_var1, Word16 var2) { + Flag Overflow = 0; + return L_shr_ro(L_var1, var2, &Overflow); +} +#endif /*___________________________________________________________________________ | | | Function Name : L_abs | @@ -2547,8 +2935,30 @@ Word32 DEPR_L_sat_co( Word32 L_var1, Flag Overflow, Flag Carry ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB +Word32 L_sat_co(Word32 L_var1, Flag Carry, Flag Overflow) { + Word32 L_var_out; + + L_var_out = L_var1; + if (Overflow) { + if (Carry) { + L_var_out = MIN_32; + } + else { + L_var_out = MAX_32; + } + + } + return (L_var_out); +} + +Word32 L_sat(Word32 L_var1) { + assert(0); /* Overflow and Carry are no longer global, must be passed as parameters */ + return L_sat_co(L_var1, 0, 0); +} +#endif /*___________________________________________________________________________ | | | Function Name : norm_s | @@ -2846,7 +3256,12 @@ Word32 L_mls( Word32 Lv, Word16 v ) return Temp; } - +#ifdef BASOP_NOGLOB +Word32 L_mls_sat(Word32 Lv, Word16 v) { + Flag Overflow; + return L_mls_o(Lv, v, &Overflow); +} +#endif /*__________________________________________________________________________ | | @@ -2981,7 +3396,23 @@ Word16 DEPR_i_mult( Word16 a, Word16 b ) #endif } - +#ifdef BASOP_NOGLOB +Word16 i_mult_o(Word16 a, Word16 b, Flag* Overflow) { +#ifdef ORIGINAL_G7231 + return a * b; +#else + Word32 register c = a * b; + return saturate_o(c, Overflow); +#endif +} +Word16 i_mult(Word16 a, Word16 b) { + return i_mult_o(a, b, NULL); +} +Word16 i_mult_sat(Word16 a, Word16 b) { + Flag Overflow; + return i_mult_o(a, b, &Overflow); +} +#endif /* ****************************************************************************** * The following three operators are not part of the original @@ -3088,8 +3519,12 @@ Word32 L_mac0( Word32 L_var3, Word16 var1, Word16 var2 ) return ( L_var_out ); } - - +#ifdef BASOP_NOGLOB +Word32 L_mac0_sat(Word32 L_var3, Word16 var1, Word16 var2) { + Flag Overflow; + return L_mac0_o(L_var3, var1, var2, &Overflow); +} +#endif /*___________________________________________________________________________ | | Function Name : L_msu0 @@ -3149,5 +3584,11 @@ Word32 L_msu0( Word32 L_var3, Word16 var1, Word16 var2 ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB +Word32 L_msu0_sat(Word32 L_var3, Word16 var1, Word16 var2) { + Flag Overflow; + return L_msu0_o(L_var3, var1, var2, &Overflow); +} +#endif #undef WMC_TOOL_SKIP diff --git a/lib_com/basop32.h b/lib_com/basop32.h index f1a7e1b86..8ad777b00 100644 --- a/lib_com/basop32.h +++ b/lib_com/basop32.h @@ -97,6 +97,11 @@ extern Flag BASOP_Overflow, BASOP_Overflow2; extern Flag BASOP_Carry; */ #endif /* BASOP_NOGLOB */ +#define BASOP_SATURATE_WARNING_ON_EVS +#define BASOP_SATURATE_WARNING_OFF_EVS +#define BASOP_SATURATE_ERROR_ON_EVS +#define BASOP_SATURATE_ERROR_OFF_EVS + #define BASOP_SATURATE_WARNING_ON #define BASOP_SATURATE_WARNING_OFF #define BASOP_SATURATE_ERROR_ON @@ -109,7 +114,13 @@ extern Flag BASOP_Carry; #define MAX_16 (Word16) 0x7fff #define MIN_16 (Word16) 0x8000 - +#ifdef BASOP_NOGLOB +void set_overflow(Flag *overflow); +void unset_overflow(Flag* overflow); +void set_carry(Flag *carry); +void unset_carry(Flag* carry); +Flag get_carry(const Flag* carry); +#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | | Prototypes for basic arithmetic operators | @@ -148,6 +159,13 @@ Word32 L_mac( Word32 L_var3, Word16 var1, Word16 var2 ); /* Word32 L_msu( Word32 L_var3, Word16 var1, Word16 var2 ); /* Msu, 1 */ Word32 DEPR_L_macNs( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry ); /* Mac without sat, 1 */ +Word32 L_macNs(Word32 L_var3, Word16 var1, Word16 var2); /* Mac without sat, 1 */ +Word32 L_msuNs(Word32 L_var3, Word16 var1, Word16 var2); /* Msu without sat, 1 */ +Word32 L_add_co(Word32 L_var1, Word32 L_var2, Flag * Carry, Flag *Overflow); +Word32 L_sub_co(Word32 L_var1, Word32 L_var2, Flag * Carry, Flag *Overflow); +Word32 L_add_c(Word32 L_var1, Word32 L_var2); /* Long add with c, 2 */ +Word32 L_sub_c(Word32 L_var1, Word32 L_var2); /* Long sub with c, 2 */ + #endif /* BASOP_NOGLOB */ #ifndef BASOP_NOGLOB @@ -235,6 +253,7 @@ Word16 i_mult( Word16 a, Word16 b ); /* Weight FFS; currently assigned 3 */ #else /* BASOP_NOGLOB */ Word32 L_mls( Word32, Word16 ); /* Weight FFS; currently assigned 5 */ Word16 div_l( Word32, Word16 ); /* Weight FFS; currently assigned 32 */ +Word16 i_mult(Word16 a, Word16 b); /* Weight FFS; currently assigned 3 */ Word16 DEPR_i_mult( Word16 a, Word16 b ); /* Weight FFS; currently assigned 3 */ #endif /* BASOP_NOGLOB */ @@ -249,9 +268,12 @@ Word32 L_msu0( Word32 L_v3, Word16 v1, Word16 v2 ); /* 32-bit Msu w/o shift 1 * /* * Overflowing operators */ +Word16 i_mult_o(Word16 a, Word16 b, Flag* Overflow); Word16 add_o( Word16 var1, Word16 var2, Flag *Overflow ); Word16 sub_o( Word16 var1, Word16 var2, Flag *Overflow ); Word16 shl_o( Word16 var1, Word16 var2, Flag *Overflow ); +Word16 shr_o(Word16 var1, Word16 var2, Flag * Overflow); +Word16 shr_ro(Word16 var1, Word16 var2, Flag* Overflow); Word16 mult_o( Word16 var1, Word16 var2, Flag *Overflow ); Word32 L_mult_o( Word16 var1, Word16 var2, Flag *Overflow ); Word16 round_fx_o( Word32 L_var1, Flag *Overflow ); @@ -267,9 +289,40 @@ Word32 L_msu0_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ); Word16 mult_ro( Word16 var1, Word16 var2, Flag *Overflow ); Word16 mac_ro( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ); Word16 msu_ro( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ); -#endif /* BASOP_NOGLOB */ +Word32 L_sat_co(Word32 L_var1, Flag Carry, Flag Overflow); +Word32 L_shr_ro(Word32 L_var1, Word16 var2, Flag* Overflow); +Word32 L_macNs_co(Word32 L_var3, Word16 var1, Word16 var2, Flag * Carry, Flag* Overflow); +Word32 L_msuNs_co(Word32 L_var3, Word16 var1, Word16 var2, Flag * Carry, Flag* Overflow); +#endif /* BASOP_NOGLOB */ +/* + * Saturating operators + */ +Word16 i_mult_sat(Word16 a, Word16 b); +Word16 add_sat(Word16 var1, Word16 var2); +Word16 sub_sat(Word16 var1, Word16 var2); +Word16 shl_sat(Word16 var1, Word16 var2); +Word16 shr_sat(Word16 var1, Word16 var2); +Word16 shr_r_sat(Word16 var1, Word16 var2); +Word16 mult_sat(Word16 var1, Word16 var2); +Word32 L_mult_sat(Word16 var1, Word16 var2); +Word16 round_fx_sat(Word32 L_var1); +Word32 L_mac_sat(Word32 L_var3, Word16 var1, Word16 var2); +Word32 L_msu_sat(Word32 L_var3, Word16 var1, Word16 var2); +Word32 L_macNs_sat(Word32 L_var3, Word16 var1, Word16 var2); +Word32 L_msuNs_sat(Word32 L_var3, Word16 var1, Word16 var2); +Word32 L_add_sat(Word32 L_var1, Word32 L_var2); +Word32 L_sub_sat(Word32 L_var1, Word32 L_var2); +Word32 L_shr_sat(Word32 L_var1, Word16 var2); +Word32 L_shl_sat(Word32 L_var1, Word16 var2); +Word32 L_mls_sat(Word32 Lv, Word16 v); +Word32 L_mac0_sat(Word32 L_var3, Word16 var1, Word16 var2); +Word32 L_msu0_sat(Word32 L_var3, Word16 var1, Word16 var2); +Word16 mult_r_sat(Word16 var1, Word16 var2); +Word16 mac_r_sat(Word32 L_var3, Word16 var1, Word16 var2); +Word16 msu_r_sat(Word32 L_var3, Word16 var1, Word16 var2); +Word32 L_shr_r_sat(Word32 L_var1, Word16 var2); #endif /* ifndef _BASIC_OP_H */ diff --git a/lib_com/basop_com_lpc.c b/lib_com/basop_com_lpc.c index 442afe554..b172ff76a 100644 --- a/lib_com/basop_com_lpc.c +++ b/lib_com/basop_com_lpc.c @@ -49,8 +49,8 @@ #define NC_MAX 8 #define GUESS_TBL_SZ 256 -#define Madd_32_16( accu, x, y ) L_add( accu, Mpy_32_16( x, y ) ) -#define Msub_32_16( accu, x, y ) L_sub( accu, Mpy_32_16( x, y ) ) +#define Madd_32_16( accu, x, y ) L_add( accu, Mpy_32_16_1( x, y ) ) +#define Msub_32_16( accu, x, y ) L_sub( accu, Mpy_32_16_1( x, y ) ) /* diff --git a/lib_com/basop_lsf_tools.c b/lib_com/basop_lsf_tools.c index eddce99e8..0fb0c4a95 100644 --- a/lib_com/basop_lsf_tools.c +++ b/lib_com/basop_lsf_tools.c @@ -285,13 +285,13 @@ static Word16 E_LPC_f_lsp_pol_get( /*f[i] = -b*f[i-1] + 2.0f*f[i-2];*/ move32(); - f[i] = L_shl( L_sub( f[i - 2], Mpy_32_16( f[i - 1], b ) ), 1 ); + f[i] = L_shl( L_sub( f[i - 2], Mpy_32_16_1( f[i - 1], b ) ), 1 ); FOR( j = i - 1; j > 1; j-- ) { /*f[j] += b*f[j-1] + f[j-2];*/ move32(); - f[j] = L_add( f[j], L_sub( f[j - 2], L_shl( Mpy_32_16( f[j - 1], b ), 1 ) ) ); + f[j] = L_add( f[j], L_sub( f[j - 2], L_shl( Mpy_32_16_1( f[j - 1], b ), 1 ) ) ); } move32(); f[1] = L_add( f[1], b32 ); diff --git a/lib_com/basop_mpy.c b/lib_com/basop_mpy.c index cb6268d62..606f49c93 100644 --- a/lib_com/basop_mpy.c +++ b/lib_com/basop_mpy.c @@ -50,16 +50,6 @@ Word32 Mpy_32_16_1( Word32 x, Word16 y ) return ( mh ); } -Word32 Mpy_32_16( Word32 x, Word16 y ) -{ - Word32 mh; - UWord16 ml; - - Mpy_32_16_ss( x, y, &mh, &ml ); - - return ( mh ); -} - Word32 Mpy_32_16_r( Word32 x, Word16 y ) { Word32 mh; @@ -86,4 +76,102 @@ Word32 Mpy_32_32( Word32 x, Word32 y ) return ( mh ); } + +Word32 Mpy_32_32_r(Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; + Word64 L64_var1; + + L64_var1 = ((Word64)L_var1 * L_var2); + L64_var1 = W_shr(L64_var1, 15); + L_var_out = W_round48_L(L64_var1); + return L_var_out; +} + + +Word32 Madd_32_16(Word32 L_var3, Word32 L_var1, Word16 var2) { + Word32 L_var_out; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + L_var_out = Mpy_32_16_1(L_var1, var2); +#ifdef BASOP_NOGLOB + L_var_out = L_add_o(L_var3, L_var_out, &Overflow); +#else /* BASOP_NOGLOB */ + L_var_out = L_add(L_var3, L_var_out); +#endif /* BASOP_NOGLOB */ + + return L_var_out; +} + +Word32 Madd_32_16_r(Word32 L_var3, Word32 L_var1, Word16 var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_16_r(L_var1, var2); + L_var_out = L_add(L_var3, L_var_out); + + return L_var_out; +} + +Word32 Msub_32_16(Word32 L_var3, Word32 L_var1, Word16 var2) { + Word32 L_var_out; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + L_var_out = Mpy_32_16_1(L_var1, var2); +#ifdef BASOP_NOGLOB + L_var_out = L_sub_o(L_var3, L_var_out, &Overflow); +#else /* BASOP_NOGLOB */ + L_var_out = L_sub(L_var3, L_var_out); +#endif + + return L_var_out; +} + +Word32 Msub_32_16_r(Word32 L_var3, Word32 L_var1, Word16 var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_16_r(L_var1, var2); + L_var_out = L_sub(L_var3, L_var_out); + + return L_var_out; +} + +Word32 Madd_32_32(Word32 L_var3, Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_32(L_var1, L_var2); + L_var_out = L_add(L_var3, L_var_out); + + return L_var_out; +} + +Word32 Madd_32_32_r(Word32 L_var3, Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_32_r(L_var1, L_var2); + L_var_out = L_add(L_var3, L_var_out); + + return L_var_out; +} + +Word32 Msub_32_32(Word32 L_var3, Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_32(L_var1, L_var2); + L_var_out = L_sub(L_var3, L_var_out); + + return L_var_out; +} + + +Word32 Msub_32_32_r(Word32 L_var3, Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_32_r(L_var1, L_var2); + L_var_out = L_sub(L_var3, L_var_out); + + return L_var_out; +} #undef WMC_TOOL_SKIP diff --git a/lib_com/basop_mpy.h b/lib_com/basop_mpy.h index c35531fa6..ef1a3cd9d 100644 --- a/lib_com/basop_mpy.h +++ b/lib_com/basop_mpy.h @@ -54,19 +54,6 @@ Word32 Mpy_32_16_1( Word32 x, Word16 y ); -/** - * \brief 32*16 Bit fractional Multiplication using 40 bit OPS - * Performs a multiplication of a 32-bit variable x by - * a 16-bit variable y, returning a 32-bit value. - * - * \param[i] x - * \param[i] y - * - * \return x*y - */ -Word32 Mpy_32_16( Word32 x, Word16 y ); - - /** * \brief 32*16 Bit fractional Multiplication using 40 bit OPS * Performs a multiplication of a 32-bit variable x by @@ -94,4 +81,14 @@ Word32 Mpy_32_16_r( Word32 x, Word16 y ); Word32 Mpy_32_32( Word32 x, Word32 y ); +Word32 Madd_32_16(Word32 L_var3, Word32 L_var1, Word16 var2); +Word32 Madd_32_16_r(Word32 L_var3, Word32 L_var1, Word16 var2); +Word32 Msub_32_16(Word32 L_var3, Word32 L_var1, Word16 var2); +Word32 Msub_32_16_r(Word32 L_var3, Word32 L_var1, Word16 var2); +Word32 Madd_32_32(Word32 L_var3, Word32 L_var1, Word32 L_var2); +Word32 Madd_32_32_r(Word32 L_var3, Word32 L_var1, Word32 L_var2); +Word32 Msub_32_32(Word32 L_var3, Word32 L_var1, Word32 L_var2); +Word32 Msub_32_32_r(Word32 L_var3, Word32 L_var1, Word32 L_var2); + + #endif /* __BASOP_SETTINGS_H */ diff --git a/lib_com/basop_tcx_utils.c b/lib_com/basop_tcx_utils.c index f57bf10a8..7f2df1e56 100644 --- a/lib_com/basop_tcx_utils.c +++ b/lib_com/basop_tcx_utils.c @@ -47,18 +47,18 @@ /* compare two positive normalized 16 bit mantissa/exponent values */ /* return value: positive if first value greater, negative if second value greater, zero if equal */ -static Word16 compMantExp16Unorm( Word16 m1, Word16 e1, Word16 m2, Word16 e2 ) -{ - Word16 tmp; - - assert( ( m1 >= 0x4000 ) && ( m2 >= 0x4000 ) ); /* comparisons below work only for normalized mantissas */ - - tmp = sub( e1, e2 ); - if ( tmp == 0 ) - tmp = sub( m1, m2 ); - - return tmp; -} +//static Word16 compMantExp16Unorm( Word16 m1, Word16 e1, Word16 m2, Word16 e2 ) +//{ +// Word16 tmp; +// +// assert( ( m1 >= 0x4000 ) && ( m2 >= 0x4000 ) ); /* comparisons below work only for normalized mantissas */ +// +// tmp = sub( e1, e2 ); +// if ( tmp == 0 ) +// tmp = sub( m1, m2 ); +// +// return tmp; +//} void basop_lpc2mdct( Word16 *lpcCoeffs, Word16 lpcOrder, Word16 *mdct_gains, Word16 *mdct_gains_exp, Word16 *mdct_inv_gains, Word16 *mdct_inv_gains_exp ) { @@ -251,11 +251,11 @@ void basop_mdct_noiseShaping_interp( Word32 x[], Word16 lg, Word16 gains[], Word e = s_max( gains_exp[j], gains_exp[jp] ); tmp = mac_r( L_mult( pg, FL2WORD16( 0.375f ) ), g, FL2WORD16( 0.625f ) ); - x[i] = L_shl( Mpy_32_16( x[i], tmp ), e ); + x[i] = L_shl( Mpy_32_16_1( x[i], tmp ), e ); move32(); tmp = mac_r( L_mult( pg, FL2WORD16( 0.125f ) ), g, FL2WORD16( 0.875f ) ); - x[i + 1] = L_shl( Mpy_32_16( x[i + 1], tmp ), e ); + x[i + 1] = L_shl( Mpy_32_16_1( x[i + 1], tmp ), e ); move32(); /* common exponent for g and ng */ @@ -269,11 +269,11 @@ void basop_mdct_noiseShaping_interp( Word32 x[], Word16 lg, Word16 gains[], Word e = s_max( gains_exp[j], gains_exp[jn] ); tmp = mac_r( L_mult( g, FL2WORD16( 0.875f ) ), ng, FL2WORD16( 0.125f ) ); - x[i + 2] = L_shl( Mpy_32_16( x[i + 2], tmp ), e ); + x[i + 2] = L_shl( Mpy_32_16_1( x[i + 2], tmp ), e ); move32(); tmp = mac_r( L_mult( g, FL2WORD16( 0.625f ) ), ng, FL2WORD16( 0.375f ) ); - x[i + 3] = L_shl( Mpy_32_16( x[i + 3], tmp ), e ); + x[i + 3] = L_shl( Mpy_32_16_1( x[i + 3], tmp ), e ); move32(); jp = j; @@ -310,15 +310,15 @@ void basop_mdct_noiseShaping_interp( Word32 x[], Word16 lg, Word16 gains[], Word e = s_max( gains_exp[j], gains_exp[jp] ); tmp = mac_r( L_mult( pg, FL2WORD16( 0.40f ) ), g, FL2WORD16( 0.60f ) ); - x[i] = L_shl( Mpy_32_16( x[i], tmp ), e ); + x[i] = L_shl( Mpy_32_16_1( x[i], tmp ), e ); move32(); tmp = mac_r( L_mult( pg, FL2WORD16( 0.20f ) ), g, FL2WORD16( 0.80f ) ); - x[i + 1] = L_shl( Mpy_32_16( x[i + 1], tmp ), e ); + x[i + 1] = L_shl( Mpy_32_16_1( x[i + 1], tmp ), e ); move32(); - x[i + 2] = L_shl( Mpy_32_16( x[i + 2], gains[j] ), gains_exp[j] ); + x[i + 2] = L_shl( Mpy_32_16_1( x[i + 2], gains[j] ), gains_exp[j] ); move32(); /* common exponent for g and ng */ @@ -332,11 +332,11 @@ void basop_mdct_noiseShaping_interp( Word32 x[], Word16 lg, Word16 gains[], Word e = s_max( gains_exp[j], gains_exp[jn] ); tmp = mac_r( L_mult( g, FL2WORD16( 0.80f ) ), ng, FL2WORD16( 0.20f ) ); - x[i + 3] = L_shl( Mpy_32_16( x[i + 3], tmp ), e ); + x[i + 3] = L_shl( Mpy_32_16_1( x[i + 3], tmp ), e ); move32(); tmp = mac_r( L_mult( g, FL2WORD16( 0.60f ) ), ng, FL2WORD16( 0.40f ) ); - x[i + 4] = L_shl( Mpy_32_16( x[i + 4], tmp ), e ); + x[i + 4] = L_shl( Mpy_32_16_1( x[i + 4], tmp ), e ); move32(); jp = j; @@ -352,7 +352,7 @@ void basop_mdct_noiseShaping_interp( Word32 x[], Word16 lg, Word16 gains[], Word { FOR( l = 0; l < k; l++ ) { - *x = L_shl( Mpy_32_16( *x, *gains ), *gains_exp ); + *x = L_shl( Mpy_32_16_1( *x, *gains ), *gains_exp ); move32(); x++; } @@ -423,7 +423,7 @@ void basop_PsychAdaptLowFreqDeemph( Word32 x[], const Word16 lpcGains[], const W /* gradual lowering of lowest 32 bins; DC is lowered by (max/tmp)^1/4 */ FOR( i = 31; i >= 0; i-- ) { - x[i] = Mpy_32_16( x[i], fac ); + x[i] = Mpy_32_16_1( x[i], fac ); move32(); if ( lf_deemph_factors != NULL ) { diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index ff42b0eb4..c4f265580 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -37,6 +37,7 @@ #include #include #include "options.h" +#include "complex_basop.h" #include "basop_util.h" #include "rom_com.h" #include "basop_settings.h" @@ -54,7 +55,12 @@ extern const Word16 ISqrtDiffTable[32]; extern const Word32 InvTable[32]; extern const Word16 InvDiffTable[32]; +static __inline Word16 L_Extract_lc(const Word32 L_32, Word16 *p_hi) +{ + *p_hi = extract_h(L_32); + return lshr(extract_l(L_32), 1); +} Word32 BASOP_Util_Log2( Word32 x ) @@ -159,7 +165,7 @@ Word32 BASOP_Util_InvLog2( exp = negate( exp ); } - lookup3f = L_add( exp2x_tab_long[index3], L_shr( Mpy_32_16( 0x0016302F, frac ), 1 ) ); + lookup3f = L_add( exp2x_tab_long[index3], L_shr( Mpy_32_16_1( 0x0016302F, frac ), 1 ) ); lookup12 = Mpy_32_32( exp2_tab_long[index1], exp2w_tab_long[index2] ); lookup = Mpy_32_32( lookup12, lookup3f ); @@ -231,6 +237,70 @@ Word16 BASOP_Util_Add_MantExp /*!< Exponent of result */ } +void BASOP_Util_Divide_MantExp(Word16 a_m, /*!< Mantissa of dividend a */ + Word16 a_e, /*!< Exponent of dividend a */ + Word16 b_m, /*!< Mantissa of divisor b */ + Word16 b_e, /*!< Exponent of divisor b */ + Word16 *ptrResult_m, /*!< Mantissa of quotient a/b */ + Word16 *ptrResult_e /*!< Exponent of quotient a/b */ +) +{ + Word16 index, frac; + Word16 preShift, postShift; + Word16 m; + Word32 m32; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + + + assert(b_m != 0); + + /* normalize b */ + preShift = norm_s(b_m); + m = shl(b_m, preShift); + + /* make b positive */ + BASOP_SATURATE_WARNING_OFF_EVS; + if (m < 0) m = negate(m); + BASOP_SATURATE_WARNING_ON_EVS; + + /* get table index (upper 6 bits minus 16) */ + /* index = (m >> 9) - 32; */ + index = mac_r(-32768 - (32 << 16), m, 1 << 6); + + /* get fractional part for interpolation (lower 9 bits) */ + frac = shl(s_and(m, 0x1FF), 1); /* Q10 */ + + /* interpolate 1/b */ + m = msu_r(InvTable[index], InvDiffTable[index], frac); + + /* restore sign */ + if (b_m < 0) m = negate(m); + + /* multiply with a */ + m32 = L_mult(a_m, m); + + /* normalize result */ + postShift = norm_l(m32); +#ifdef BASOP_NOGLOB + m = round_fx_o(L_shl(m32, postShift), &Overflow); +#else + m = round_fx(L_shl(m32, postShift)); +#endif + + /* exponent */ + *ptrResult_e = sub(add(add(a_e, sub(1, b_e)), preShift), postShift); + move16(); + + *ptrResult_m = m; + move16(); + +} + + + /* local function for Sqrt16 */ static Word16 Sqrt16_common( Word16 m, @@ -269,6 +339,100 @@ static Word16 Sqrt16_common( return m; } +/* local function for Sqrt32 and Sqrt32norm */ +static Word32 Sqrt32_common(Word32 m, + Word16 e) +{ + Word16 m16, index, frac; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + assert((m >= 0x40000000) || (m == 0)); + +#ifdef BASOP_NOGLOB + m16 = round_fx_o(m, &Overflow); +#else /* BASOP_NOGLOB */ + m16 = round_fx(m); +#endif /* BASOP_NOGLOB */ + + /* get table index (upper 6 bits minus 32) */ + /* index = (m16 >> 9) - 32; */ + index = mac_r(-32768 - (32 << 16), m16, 1 << 6); + + /* get fractional part for interpolation (lower 9 bits) */ + frac = s_and(m16, 0x1FF); /* Q9 */ + + /* interpolate */ + if (m != 0) + { + BASOP_SATURATE_WARNING_OFF_EVS; + m = L_mac(SqrtTable[index], SqrtDiffTable[index], frac); + BASOP_SATURATE_WARNING_ON_EVS; + } + + /* handle odd exponents */ + if (s_and(e, 1) != 0) m = Mpy_32_16_1(m, 0x5a82); + + return m; +} + +/* local function for ISqrt16 and ISqrt16norm */ +static Word16 ISqrt16_common(Word16 m, + Word16 e) +{ + Word16 index, frac; + + assert(m >= 0x4000); + + /* get table index (upper 6 bits minus 32) */ + /* index = (m >> 9) - 32; */ + index = mac_r(-32768 - (32 << 16), m, 1 << 6); + + /* get fractional part for interpolation (lower 9 bits) */ + frac = s_and(m, 0x1FF); /* Q9 */ + + /* interpolate */ + m = msu_r(ISqrtTable[index], ISqrtDiffTable[index], frac); + + /* handle even exponents */ + if (s_and(e, 1) == 0) m = mult_r(m, 0x5a82); + + return m; +} + +/* local function for ISqrt32 and ISqrt32norm */ +static Word32 ISqrt32_common(Word32 m, + Word16 e) +{ + Word16 m16, index, frac; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + assert(m >= 0x40000000); + +#ifdef BASOP_NOGLOB + m16 = round_fx_o(m, &Overflow); +#else + m16 = round_fx(m); +#endif + + /* get table index (upper 6 bits minus 32) */ + /* index = (m16 >> 25) - 32; */ + index = mac_r(-32768 - (32 << 16), m16, 1 << 6); + + /* get fractional part for interpolation (lower 9 bits) */ + frac = s_and(m16, 0x1FF); /* Q9 */ + + /* interpolate */ + m = L_msu(ISqrtTable[index], ISqrtDiffTable[index], frac); + + /* handle even exponents */ + if (s_and(e, 1) == 0) m = Mpy_32_16_1(m, 0x5a82); + + return m; +} Word16 Sqrt16( /*!< output mantissa */ Word16 mantissa, /*!< input mantissa */ @@ -295,6 +459,121 @@ Word16 Sqrt16( /*!< output mantissa */ return mantissa; } + +Word16 Sqrt16norm( /*!< output mantissa */ + Word16 mantissa, /*!< normalized input mantissa */ + Word16 *exponent /*!< pointer to exponent */ +) +{ + + assert((mantissa >= 0x4000) || (mantissa == 0)); + + /* calc mantissa */ + mantissa = Sqrt16_common(mantissa, *exponent); + + /* e = (e + 1) >> 1 */ + *exponent = mult_r(*exponent, 1 << 14); + move16(); + + return mantissa; +} + + +Word16 ISqrt16( /*!< output mantissa */ + Word16 mantissa, /*!< input mantissa */ + Word16 *exponent /*!< pointer to exponent */ +) +{ + Word16 preShift, e; + + assert(mantissa > 0); + + /* normalize */ + preShift = norm_s(mantissa); + + e = sub(*exponent, preShift); + mantissa = shl(mantissa, preShift); + + /* calc mantissa */ + mantissa = ISqrt16_common(mantissa, e); + + /* e = (2 - e) >> 1 */ + *exponent = msu_r(1L << 15, e, 1 << 14); + move16(); + + return mantissa; +} + + +Word32 Sqrt32( /*!< output mantissa */ + Word32 mantissa, /*!< input mantissa */ + Word16 *exponent /*!< pointer to exponent */ +) +{ + Word16 preShift, e; + + assert(mantissa >= 0); + + /* normalize */ + preShift = norm_l(mantissa); + + e = sub(*exponent, preShift); + mantissa = L_shl(mantissa, preShift); + + /* calc mantissa */ + mantissa = Sqrt32_common(mantissa, e); + + /* e = (e + 1) >> 1 */ + *exponent = mult_r(e, 1 << 14); + move16(); + + return mantissa; +} + + +Word32 ISqrt32( /*!< output mantissa */ + Word32 mantissa, /*!< input mantissa */ + Word16 *exponent /*!< pointer to exponent */ +) +{ + Word16 preShift, e; + + assert(mantissa > 0); + + /* normalize */ + preShift = norm_l(mantissa); + + e = sub(*exponent, preShift); + mantissa = L_shl(mantissa, preShift); + + /* calc mantissa */ + mantissa = ISqrt32_common(mantissa, e); + + /* e = (2 - e) >> 1 */ + *exponent = msu_r(1L << 15, e, 1 << 14); + move16(); + + return mantissa; +} + +Word32 ISqrt32norm( /*!< output mantissa */ + Word32 mantissa, /*!< normalized input mantissa */ + Word16 *exponent /*!< pointer to exponent */ +) +{ + + assert(mantissa >= 0x40000000); + + /* calc mantissa */ + mantissa = ISqrt32_common(mantissa, *exponent); + + /* e = (2 - e) >> 1 */ + *exponent = msu_r(1L << 15, *exponent, 1 << 14); + move16(); + + return mantissa; +} + Word16 Inv16( /*!< output mantissa */ Word16 mantissa, /*!< input mantissa */ Word16 *exponent /*!< pointer to exponent */ @@ -395,6 +674,55 @@ void BASOP_Util_Sqrt_InvSqrt_MantExp( move16(); } +/********************************************************************/ +/*! + \brief Calculates the scalefactor needed to normalize input array + + The scalefactor needed to normalize the Word16 input array is returned
+ If the input array contains only '0', a scalefactor 0 is returned
+ Scaling factor is determined wrt a normalized target x: 16384 <= x <= 32767 for positive x
+ and -32768 <= x <= -16384 for negative x +*/ + +Word16 getScaleFactor16( /* o: measured headroom in range [0..15], 0 if all x[i] == 0 */ + const Word16 *x, /* i: array containing 16-bit data */ + const Word16 len_x) /* i: length of the array to scan */ +{ + Word16 i, i_min, i_max; + Word16 x_min, x_max; + + + + x_max = 0; + move16(); + x_min = 0; + move16(); + FOR(i = 0; i < len_x; i++) + { + if (x[i] >= 0) + x_max = s_max(x_max, x[i]); + if (x[i] < 0) + x_min = s_min(x_min, x[i]); + } + + i_max = 0x10; + move16(); + i_min = 0x10; + move16(); + + if (x_max != 0) + i_max = norm_s(x_max); + + if (x_min != 0) + i_min = norm_s(x_min); + + i = s_and(s_min(i_max, i_min), 0xF); + + + return i; +} + + /********************************************************************/ /*! \brief Calculates the scalefactor needed to normalize input array @@ -439,6 +767,176 @@ Word16 getScaleFactor32( return i; } +Word16 normalize16(Word16 mantissa, Word16 *pexponent) +{ + Word16 tmp; + + tmp = norm_s(mantissa); + mantissa = shl(mantissa, tmp); + move16(); + *pexponent = sub(*pexponent, tmp); + + + return mantissa; +} +Word16 divide3216(Word32 x, Word16 y) +{ + Word16 z; + + + z = 0; + move16(); + if (0 == y) + { + return 0x7fff; + } + + IF(x != 0) + { + Word16 den, sign; + Word32 num; + num = L_abs(x); + den = abs_s(y); + + sign = s_and(s_xor(extract_h(x), y), -32768 /* 0x8000 */); + + z = div_l(num, den); + if (0 != sign) + { + z = negate(z); + } + } + + + return z; +} + +Word16 divide1616(Word16 x, Word16 y) +{ + Word16 z, num, den, sign; + + + num = abs_s(x); + den = abs_s(y); + + sign = s_and(s_xor(x, y), -32768 /* 0x8000 */); + + move16(); + z = 0x7fff; + if (LT_16(num, den)) + z = div_s(num, den); + + if (0 != sign) + { + z = negate(z); + } + + + return z; +} + +Word16 divide3232(Word32 L_num, Word32 L_denom) +{ + Word16 z; + Word32 sign; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + + sign = L_and(L_xor(L_num, L_denom), 0x80000000); + + L_num = L_abs(L_num); + L_denom = L_abs(L_denom); + + /* limit the range of denominator to Word16 */ + z = s_min(norm_l(L_num), norm_l(L_denom)); + L_num = L_shl(L_num, z); + L_denom = L_shl(L_denom, z); + + /* round_fx instead of extract_h improves spectral distortion in E_UTIL_lev_dur (schur version). */ +#ifdef BASOP_NOGLOB + z = div_l(L_num, round_fx_o(L_denom, &Overflow)); +#else + z = div_l(L_num, round_fx(L_denom)); +#endif + if (0 != sign) + { + z = negate(z); + } + + + return z; +} + +Word16 BASOP_Util_Divide3232_uu_1616_Scale(Word32 x, Word32 y, Word16 *s) +{ + Word16 z; + Word16 sx; + Word16 sy; + Word16 x16; + Word16 y16; + + + + assert(x >= 0); + assert(y > 0); + + if (x == 0) + { + *s = 0; + move16(); + + + return (0); + } + + sx = norm_l(x); + sy = norm_l(y); + + x16 = extract_h(L_shl(x, sx)); + y16 = extract_h(L_shl(y, sy)); + + if (GT_16(x16, y16)) + { + sx = sub(sx, 1); + } + + if (LT_16(y16, x16)) + { + x16 = mult_r(x16, 0x4000); + } + + + z = div_s(x16, y16); + move16(); + *s = sub(sy, sx); + + + return (z); +} + +Word16 BASOP_Util_Divide3232_Scale(Word32 x, Word32 y, Word16 *s) +{ + Word16 z; + Word16 sy; + + + + sy = norm_l(y); + if (sy > 0) + { + sy = sub(sy, 1); + } + y = L_shl(y, sy); + + z = BASOP_Util_Divide3216_Scale(x, extract_h(y), s); + move16(); + *s = add(*s, sy); + + + return (z); +} Word16 BASOP_Util_Divide1616_Scale( Word16 x, @@ -541,6 +1039,88 @@ Word16 mult0( return extract_l( L_mult0( x, y ) ); } +void copyWord8(const Word8 *src, Word8 *dst, const Word32 n) +{ + Word32 i; + + + FOR(i = 0; i < n; i++) + { + dst[i] = src[i]; + move16(); + } + +} + + + +void set_zero_Word8(Word8 X[], Word32 n) +{ + Word32 i; + + + FOR(i = 0; i < n; i++) + { + X[i] = 0; + move16(); + } + +} + + +Word32 L_mult0_3216(Word32 x, Word16 y) +{ + UWord16 mpy_low16; + Word32 mpy_high32; + + + Mpy_32_16_ss(x, y, &mpy_high32, &mpy_low16); + + mpy_high32 = L_add(L_shl(mpy_high32, 15), L_lshr(L_deposit_h(mpy_low16), 17)); + + + return mpy_high32; +} + +Word16 BASOP_util_norm_l_dim2_cplx(const Word32 * const *re, /*!< Real part of 32 Bit input */ + const Word32 * const *im, /*!< Imag part if 32 Bit input */ + Word16 startBand, /*!< start band of cplx data */ + Word16 stopBand, /*!< stop band of cplx data */ + Word16 startSlot, /*!< start slot of cplx data */ + Word16 stopSlot /*!< stop slot of cplx data */ +) +{ + Word16 col; + Word16 band; + Word16 maxShift; + Word32 maxVal; + + + + maxVal = L_deposit_l(1); + + FOR(col = startSlot; col < stopSlot; col++) + { + FOR(band = startBand; band < stopBand; band++) + { + maxVal = L_max(maxVal, L_abs(re[col][band])); + maxVal = L_max(maxVal, L_abs(im[col][band])); + } + } + maxShift = norm_l(maxVal); + + + return (maxShift); +} + +Word16 BASOP_util_norm_s_bands2shift(Word16 x) +{ + Word16 shift; + + shift = sub(WORD16_BITS - 1, norm_s(negate(x))); + + return (shift); +} #define SINETAB SineTable512_fx #define LD 9 @@ -633,6 +1213,20 @@ static Word16 fixp_sin_cos_residual_16( return residual; } +Word16 getCosWord16(Word16 theta) +{ + Word16 result, residual, sine, cosine; + + residual = fixp_sin_cos_residual_16(theta, 2, &sine, &cosine, 0); + /* This negation prevents the subsequent addition from overflow */ + /* The negation cannot overflow, sine is in range [0x0..0x7FFF] */ + sine = negate(sine); + result = mac_r(L_mult0(sine, residual), cosine, 16384); + + + return result; +} + Word16 getCosWord16R2( Word16 theta ) @@ -650,13 +1244,125 @@ Word16 getCosWord16R2( return result; } - -Word16 idiv1616U( - Word16 x, - Word16 y ) +/* + * Calculate Integer Square Root of 'val'. This is the equivalent of (int)sqrt(val); + * The return value will be truncated to the lowest integer (throwing away the fractionnal part. + * + * There are many ways to do this. The approach here is to use a simple function to get a + * 1st estimate of (int)sqrt(val) and then correct this estimate if it is too low or too high. + * + * Using Word16, the range of 'val' is limited to roughly 2^30. + * + * Complexity: Worst=31Clks, Best=27Clks + */ +Word16 getSqrtWord32(Word32 val) { - Word16 s; - Word16 tmp; + Word32 L_temp, L_temp2; + Word16 temp, temp2; + Word16 exp, exp2; + + /* Calc Approximation */ + exp2 = norm_l(val); + L_temp2 = L_shl(val, exp2); + exp = sub(31 - 32, exp2); + L_temp = Isqrt_lc(L_temp2, &exp); /* 12 clks */ + +#ifdef BASOP_NOGLOB + temp = round_fx_sat(L_temp); +#else + temp = round_fx(L_temp); +#endif + L_temp = Mpy_32_16_1(L_temp2, temp); /* 2 clks */ + + L_temp = L_shl(L_temp, sub(exp, exp2)); + + /* The Approximation Error Range is -1..+7, so Too Low by 1 or Up to Too High by 7 */ + temp = round_fx(L_temp); + + /* Too High? */ + if (L_msu0(val, temp, temp) < 0) + { + /* Reduce by 2 */ + temp = sub(temp, 2); + } + /* Too High? */ + if (L_msu0(val, temp, temp) < 0) + { + /* Reduce by 2 */ + temp = sub(temp, 2); + } + /* Too High? */ + if (L_msu0(val, temp, temp) < 0) + { + /* Reduce by 2 */ + temp = sub(temp, 2); + } + /* Too High? */ + if (L_msu0(val, temp, temp) < 0) + { + /* Reduce by 1 */ + temp = sub(temp, 1); + } + + /* Try +1 */ + temp2 = add(temp, 1); + /* It fits? */ + if (L_msu0(val, temp2, temp2) >= 0) + { + /* Yes */ + temp = temp2; + move16(); + } + return temp; +} +Word16 findIndexOfMinWord32(Word32 *x, const Word16 len) +{ + Word16 i, indx; + + + indx = 0; + move16(); + FOR(i = 1; i < len; i++) + { + if (LT_32(x[i], x[indx])) + { + indx = i; + move16(); + } + } + + + return indx; +} + + +Word16 imult1616(Word16 x, Word16 y) +{ + assert((int)x * (int)y < 32768 && (int)x * (int)y >= -32768); + return extract_l(L_mult0(x, y)); +} + +Word32 imult3216(Word32 x, Word16 y) +{ + Word32 mh; + UWord16 ml; + + Mpy_32_16_ss(x, y, &mh, &ml); + + mh = L_shl(mh, 15); + ml = lshr(ml, 1); + + return L_or(mh, L_deposit_l(ml)); +} + + + +Word16 idiv1616U( + Word16 x, + Word16 y ) +{ + Word16 s; + Word16 tmp; /* make y > x */ s = add( sub( norm_s( y ), norm_s( x ) ), 1 ); @@ -673,6 +1379,216 @@ Word16 idiv1616U( return y; } +Word16 idiv1616(Word16 x, Word16 y) +{ + Word16 s, num, den, sign; + + + num = abs_s(x); + den = abs_s(y); + + sign = s_and(s_xor(x, y), -32768 /* 0x8000 */); + + /* make num > den */ + s = add(sub(norm_s(den), norm_s(num)), 1); + s = s_max(s, 0); + + den = shl(den, s); + + /* divide and shift */ + y = shr(div_s(num, den), sub(15, s)); + + if (0 != sign) + { + y = negate(y); + } + + + return y; +} + +Word32 norm_llQ31( /* o : normalized result Q31 */ + Word32 L_c, /* i : upper bits of accu Q-1 */ + Word32 L_sum, /* i : lower bits of accu, unsigned Q31 */ + Word16 * exp /* o : exponent of result in [-32,31] Q0 */ +) +{ + Word16 i; + Word32 L_tmp; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; + Flag Carry = 0; +#endif /* BASOP_NOGLOB */ + + /* Move MSBit of L_sum into L_c */ + Carry = 0; +#ifdef BASOP_NOGLOB + L_tmp = L_add_co(L_sum, L_sum, &Carry, &Overflow); /* L_tmp = L_sum << 1 */ + L_c = L_add_co(L_c, L_c, &Carry, &Overflow); +#else /* BASOP_NOGLOB */ + L_tmp = L_add_c(L_sum, L_sum); /* L_tmp = L_sum << 1 */ + L_c = L_add_c(L_c, L_c); +#endif + L_add(0, 0); + test(); + IF((L_c != (Word32)0L) && (L_c != (Word32)0xFFFFFFFFL)) + { + i = norm_l(L_c); + L_c = L_shl(L_c, i); + i = sub(31, i); /* positive exponent */ + L_sum = L_lshr(L_tmp, 1); /* L_sum with MSBit=0 */ + L_sum = L_lshr(L_sum, i); + L_sum = L_add(L_c, L_sum); + } + ELSE + { + i = -32; + move16(); /* default exponent, if total sum=0 */ + IF(L_sum) + { + i = norm_l(L_sum); + L_sum = L_shl(L_sum,i); + i = negate(i); /* negative or zero exponent */ + } + } + *exp = i; + move16(); + return L_sum; +} + +Word32 w_norm_llQ31(Word64 L_sum, Word16 * exp); +Word32 w_norm_llQ31( /* o : normalized result Q31 */ + Word64 L_sum, /* i : upper and lower bits of accu, unsigned Q31 */ + Word16 * exp /* o : exponent of result in [-32,31] Q0 */ +) +{ + Word32 L_tmp; + Word16 exp_val; + Word64 L64_inp64 = L_sum; move64(); + + L64_inp64 = W_shl(L64_inp64, 1); + exp_val = W_norm(L64_inp64); + L64_inp64 = W_shl(L64_inp64, exp_val); + exp_val = sub(31, exp_val); + if (EQ_64(L_sum, 0)) + { + exp_val = -32; move16(); + } + *exp = exp_val; move16(); + + L_tmp = W_extract_h(L64_inp64); + return L_tmp; +} + +Word32 Dot_product16HQ( /* o : normalized result Q31 */ + const Word32 L_off, /* i : initial sum value Qn */ + const Word16 x[], /* i : x vector Qn */ + const Word16 y[], /* i : y vector Qn */ + const Word16 lg, /* i : vector length, range [0..7FFF] Q0 */ + Word16 * exp /* o : exponent of result in [-32,31] Q0 */ +) +{ + Word16 i; + Word32 L_sum; + Word64 L_sum64; + + L_sum64 = W_deposit32_l(L_off); + + FOR(i = 0; i < lg; i++) + { + L_sum64 = W_mac_16_16(L_sum64, x[i], y[i]); + } + + L_sum = w_norm_llQ31(L_sum64, exp); + return L_sum; +} + +Word32 Norm32Norm(const Word32 *x, const Word16 headroom, const Word16 length, Word16 *result_e) +{ + Word32 L_tmp, L_tmp2; + Word16 i, shift, tmp; + + move16(); + shift = headroom; + + L_tmp = L_deposit_l(0); + + FOR(i = 0; i < length; i++) + { + L_tmp2 = L_sub(L_tmp, 0x40000000); + if (L_tmp2 >= 0) shift = sub(shift, 1); + if (L_tmp2 >= 0) L_tmp = L_shr(L_tmp, 2); + +#ifdef BASOP_NOGLOB + tmp = round_fx_sat(L_shl_sat(x[i], shift)); + L_tmp = L_mac0_sat(L_tmp, tmp, tmp); /* exponent = (1-shift*2) , Q(30+shift*2) */ +#else + tmp = round_fx(L_shl(x[i], shift)); + L_tmp = L_mac0(L_tmp, tmp, tmp); /* exponent = (1-shift*2) , Q(30+shift*2) */ +#endif + } + + move16(); + *result_e = sub(1, shl(shift, 1)); + + return L_tmp; +} + +Word32 Dot_productSq16HQ( /* o : normalized result Q31 */ + const Word32 L_off, /* i : initial sum value Qn */ + const Word16 x[], /* i : x vector Qn */ + const Word16 lg, /* i : vector length, range [0..7FFF] Q0 */ + Word16 * exp /* o : exponent of result in [-32,31] Q0 */ +) +{ + Word16 i; + Word32 L_sum; + Word64 L_sum64; + + L_sum64 = W_deposit32_l(L_off); + + FOR(i = 0; i < lg; i++) + { + L_sum64 = W_mac_16_16(L_sum64, x[i], x[i]); + } + L_sum = w_norm_llQ31(L_sum64, exp); + + return L_sum; +} + +Word32 dotp_s_fx(const Word16 *x, const Word16 *y, const Word16 n, Word16 s) +{ + Word16 i; + Word16 n2; + Word32 L_tmp; + Word32 L_sum; + + + L_sum = 0; + move32(); + + n2 = shr(n, 1); + + s = sub(s, 1); + + FOR(i = 0; i < n2; i++) + { + L_tmp = L_mult0(x[2 * i], y[2 * i]); + L_tmp = L_mac0(L_tmp, x[2 * i + 1], y[2 * i + 1]); + L_sum = L_add(L_sum, L_shr(L_tmp, s)); + } + + IF(s_and(n, 1)) + { + L_tmp = L_mult0(x[n - 1], y[n - 1]); + L_sum = L_add(L_sum, L_shr(L_tmp, s)); + } + + + return L_sum; +} + + Word32 BASOP_util_Pow2( const Word32 exp_m, const Word16 exp_e, @@ -727,15 +1643,15 @@ Word32 BASOP_util_Pow2( /* First taylor series coefficient a_0 = 1.0, scaled by 0.5 due to L_shr(,1). */ - result_m = L_add( FL2WORD32( 1.0 / 2.0 ), L_shr( Mpy_32_16( frac_part, pow2Coeff[0] ), 1 ) ); + result_m = L_add( FL2WORD32( 1.0 / 2.0 ), L_shr( Mpy_32_16_1( frac_part, pow2Coeff[0] ), 1 ) ); p = Mpy_32_32( frac_part, frac_part ); FOR( i = 1; i < 7; i++ ) { /* next taylor series term: a_i * x^i, x=0 */ - result_m = L_add( result_m, L_shr( Mpy_32_16( p, pow2Coeff[i] ), 1 ) ); + result_m = L_add( result_m, L_shr( Mpy_32_16_1( p, pow2Coeff[i] ), 1 ) ); p = Mpy_32_32( p, frac_part ); } - result_m = L_add( result_m, L_shr( Mpy_32_16( p, pow2Coeff[i] ), 1 ) ); + result_m = L_add( result_m, L_shr( Mpy_32_16_1( p, pow2Coeff[i] ), 1 ) ); } *result_e = int_part; move16(); @@ -743,6 +1659,42 @@ Word32 BASOP_util_Pow2( return result_m; } +Word16 findIndexOfMaxWord32(Word32 *x, const Word16 len) +{ + Word16 i, indx; + + + indx = 0; + move16(); + FOR(i = 1; i < len; i++) + { + if (GT_32(x[i], x[indx])) + { + indx = i; + move16(); + } + } + + + return indx; +} + +Word16 getNormReciprocalWord16(Word16 x) +{ + + assert(x < (Word16)(sizeof(BASOP_util_normReciprocal) / sizeof(BASOP_util_normReciprocal[0]))); + + return extract_h(BASOP_util_normReciprocal[x]); +} +Word16 getNormReciprocalWord16Scale(Word16 x, Word16 s) +{ + + assert(x < (Word16)(sizeof(BASOP_util_normReciprocal) / sizeof(BASOP_util_normReciprocal[0]))); + + return round_fx(L_shl(BASOP_util_normReciprocal[x], s)); +} + + /*! r: result of division x/y, not normalized */ Word16 BASOP_Util_Divide3216_Scale( Word32 x, /* i : numerator, signed */ @@ -929,6 +1881,209 @@ Word32 BASOP_Util_fPow( return result_m; } +/*___________________________________________________________________________ + | | + | Function Name : Dot_product12_offs() | + | | + | Compute scalar product of using accumulator. | + | The parameter 'L_off' is added to the accumulation result. | + | The result is normalized (in Q31) with exponent (0..30). | + | Notes: | + | o data in x[],y[] must provide enough headroom for accumulation | + | o L_off must correspond in format with product of x,y | + | Example: 0.01f for Q9 x Q9: 0x0000147B in Q19 | + | means: L_off = FL2WORD32_SCALE(0.01,31-19) | + |---------------------------------------------------------------------------| + | Algorithm: | + | | + | dot_product = L_off + sum(x[i]*y[i]) i=0..N-1 | + |___________________________________________________________________________| +*/ +Word32 Dot_product12_offs( /* (o) Q31: normalized result (1 < val <= -1) */ + const Word16 x[], /* (i) 12bits: x vector */ + const Word16 y[], /* (i) 12bits: y vector */ + const Word16 lg, /* (i) : vector length in range [1..256] */ + Word16 * exp, /* (o) : exponent of result (0..+30) */ + Word32 L_off /* (i) initial summation offset / 2 */ +) +{ + Word16 i, sft; + Word32 L_sum; + + Word64 L_sum64; + + L_sum64 = W_deposit32_l(L_off); + FOR(i = 0; i < lg; i++) + { + L_sum64 = W_mac0_16_16(L_sum64, x[i], y[i]); + } + L_sum = W_sat_l(L_sum64); + + /* Normalize acc in Q31 */ + + sft = norm_l(L_sum); + if (exp != NULL) + { + L_sum = L_shl(L_sum, sft); + } + + /* exponent = 0..30, when L_sum != 0 */ + if (L_sum != 0) + { + sft = sub(31, sft); + } + + if (exp != NULL) + { + *exp = sft; + move16(); + } + + return L_sum; +} + +Word32 Dot_product15_offs( /* (o) Q31: normalized result (1 < val <= -1) */ + const Word16 x[], /* (i) 15bits: x vector */ + const Word16 y[], /* (i) 15bits: y vector */ + const Word16 lg, /* (i) : vector length in range [1..256] */ + Word16 *exp, /* (o) : exponent of result (0..+30) */ + Word32 L_off /* (i) initial summation offset */ +) +{ + Word16 i, sft, fac, ld; + Word32 L_sum; + + ld = sub(14, norm_s(lg)); + fac = shr(-32768, ld); + L_sum = L_shr(L_off, ld); + + FOR(i = 0; i < lg; i++) + { + L_sum = L_add(L_sum, Mpy_32_16_1(L_msu(0, y[i], fac), x[i])); + } + + /* Avoid returning 0 */ + if (L_sum == 0) + { + L_sum = L_add(L_sum, 1); + } + + /* Normalize acc in Q31 */ + sft = norm_l(L_sum); + L_sum = L_shl(L_sum, sft); + + /* exponent = 0..30, when L_sum != 0 */ + if (L_sum != 0) + { + sft = add(ld, sub(30, sft)); + } + + *exp = sft; + move16(); + + return L_sum; +} + +Word16 BASOP_Util_Cmp_Mant32Exp /*!< o: flag: result of comparison */ +/* 0, if a == b */ +/* 1, if a > b */ +/* -1, if a < b */ +(Word32 a_m, /*!< i: Mantissa of 1st operand a */ + Word16 a_e, /*!< i: Exponent of 1st operand a */ + Word32 b_m, /*!< i: Mantissa of 2nd operand b */ + Word16 b_e) /*!< i: Exponent of 2nd operand b */ + +{ + Word32 diff_m; + Word16 diff_e, shift, result; + + + + /* + This function compares two input parameters, both represented by a 32-bit mantissa and a 16-bit exponent. + If both values are identical, 0 is returned. + If a is greater b, 1 is returned. + If a is less than b, -1 is returned. + */ + + /* Check, if both mantissa and exponents are identical, when normalized: return 0 */ + shift = norm_l(a_m); + if (shift) + a_m = L_shl(a_m, shift); + if (shift) + a_e = sub(a_e, shift); + + shift = norm_l(b_m); + if (shift) + b_m = L_shl(b_m, shift); + if (shift) + b_e = sub(b_e, shift); + + /* align exponent, if any mantissa is zero */ + if (!a_m) + { + a_e = b_e; + move16(); + } + if (!b_m) + { + b_e = a_e; + move16(); + } + + BASOP_SATURATE_WARNING_OFF_EVS + diff_m = L_sub(a_m, b_m); + BASOP_SATURATE_WARNING_ON_EVS + diff_e = sub(a_e, b_e); + + test(); + IF(diff_m == 0 && diff_e == 0) + { + return 0; + } + + /* Check sign, exponent and mantissa to identify, whether a is greater b or not */ + result = sub(0, 1); + + IF(a_m >= 0) + { + /* a is positive */ + if (b_m < 0) + { + result = 1; + move16(); + } + + test(); + test(); + test(); + if ((b_m >= 0) && ((diff_e > 0) || (diff_e == 0 && diff_m > 0))) + { + result = 1; + move16(); + } + } + ELSE + { + /* a is negative */ + test(); + test(); + test(); + if ((b_m < 0) && ((diff_e < 0) || (diff_e == 0 && diff_m > 0))) + { + result = 1; + move16(); + } + } + return result; +} + +/* + + headroom is introduced into acc +*/ + + Word32 BASOP_Util_Add_Mant32Exp /* o : normalized result mantissa */ ( Word32 a_m, /* i : Mantissa of 1st operand a */ Word16 a_e, /* i : Exponent of 1st operand a */ @@ -1003,7 +2158,7 @@ static const Word16 table_isqrt_diff[48] = { 154, 150, 147, 143, 139, 136, 132, 130 }; -static const Word16 shift[] = { 9, 10 }; +static const Word16 shift_lc[] = { 9, 10 }; Word32 Isqrt_lc1( Word32 frac, /* i : Q31: normalized value (1.0 < frac <= 0.5) */ @@ -1021,7 +2176,7 @@ Word32 Isqrt_lc1( } /* If exponant odd -> shift right by 10 (otherwise 9) */ - L_tmp = L_shr( frac, shift[s_and( *exp, 1 )] ); + L_tmp = L_shr( frac, shift_lc[s_and( *exp, 1 )] ); /* 1) -16384 to shift left and change sign */ /* 2) 32768 to Add 1 to Exponent like it was divided by 2 */ @@ -1106,4 +2261,726 @@ Word32 Sqrt_l( return ( L_y ); } +void bufferCopyFx( + Word16* src, /*old_exc, exc_buf, st->old_exc_len);*/ + tmp_16 = sub(sub(Qf_src, Qf_dest), sub(Q_src, Q_dest)); + IF(tmp_16 > 0) /*if value will be shifted right, do a multiplication with rounding ->preserves more accuracy*/ + { + tmp_16 = shl(1, sub(15, tmp_16)); + FOR(i = 0; i < length; i++) + { + *(dest + i) = mult_r(*(src + i), tmp_16); + move16(); + } + } + ELSE IF(tmp_16 < 0)/*leftshift - no accuracy preservation needed*/ + { + FOR(i = 0; i < length; i++) + { +#ifdef BASOP_NOGLOB + *(dest + i) = shr_sat(*(src + i), tmp_16); +#else + *(dest + i) = shr(*(src + i), tmp_16); +#endif + move16(); + } + } + ELSE /*no shift, simply copy*/ + { + FOR(i = 0; i < length; i++) + { + *(dest + i) = *(src + i); + move16(); + } + } +} + +Word32 dotWord32_16_Mant32Exp(const Word32 *bufX32,/* i: 32-bit buffer with unknown headroom */ + Word16 bufX32_exp, /* i: exponent of buffer bufX32 */ + const Word16 *bufY16,/* i: 16-bit buffer quite right-aligned */ + Word16 bufY16_exp, /* i: exponent of buffer bufY16 */ + Word16 len, /* i: buffer len to process */ + Word16 *exp) /* o: result exponent */ +{ + Word32 L_sum; + Word16 shift, shift1, i; + + + + shift = getScaleFactor32(bufX32, len); /* current available headroom */ + shift = sub(shift, sub(14, norm_s(len))); /* reduced required headroom */ + L_sum = 0; /* Clear accu */ + move32(); + FOR(i = 0; i < len; i++) + { + L_sum = L_mac0(L_sum, round_fx(L_shl(bufX32[i], shift)), bufY16[i]); + } + shift1 = norm_l(L_sum); + L_sum = L_shl(L_sum, shift1); /* return value */ + + shift = sub(add(bufX32_exp, bufY16_exp), add(shift, shift1)); + shift = add(shift, 1); /* compensate for factor of 2 introduced by L_mac0 */ + /* In case of NULL result, we want to have a 0 exponent too */ + if (L_sum == 0) + shift = 0; + *exp = shift; + move16(); + + + return L_sum; + +} + +Word16 BASOP_Util_lin2dB(Word32 x, Word16 x_e, Word16 fEnergy) +{ + assert(x >= 0); + + /* log2 */ + x = L_shr(BASOP_Util_Log2(x), 25 - 16); /* Q16 */ + + /* add exponent */ + x = L_msu(x, x_e, -32768 /* 0x8000 */); + + /* convert log2 to 20*log10 */ + x = Mpy_32_16_1(x, 24660/*6.0206f Q12*/); /* Q13 */ + + /* if energy divide by 2 (->10*log10) */ + if (fEnergy != 0) x = L_shr(x, 1); + + /* return dB as 7Q8 */ + return round_fx(L_shl(x, 8 - 13 + 16)); /* Q8 */ +} + +/* --- fixp_atan() ---- */ +#define Q_ATANINP (25) /* Input in q25, Output in q14 */ +#define Q_ATANOUT (14) +#define ATI_SF ((32-1)-Q_ATANINP) /* 6 */ +#define ATO_SF ((16-1)-Q_ATANOUT) /* 1 ] -pi/2 .. pi/2 [ */ +/* --- fixp_atan2() --- */ +#define Q_ATAN2OUT (13) +#define AT2O_SF ((16-1)-Q_ATAN2OUT) /* 2 ] -pi .. pi ] */ + + +Word16 BASOP_util_atan2( /* o: atan2(y,x) [-pi,pi] Q13 */ + Word32 y, /* i: */ + Word32 x, /* i: */ + Word16 e /* i: exponent difference (exp_y - exp_x) */ +) +{ + Word16 q; + Word32 at; + Word16 ret = -32768/*-1.0f Q15*/; + Word16 sf, sfo, stf; + Word32 L_sign; + + if (L_or(y, x) == 0) + { + return 0; + } + + IF(x == 0) + { + ret = 12868/*+EVS_PI/2 Q13*/; + move16(); + if (y < 0) + { + ret = negate(ret); + } + + return ret; + } + + /* --- division */ + L_sign = L_and(L_xor(x, y), 0x80000000); + + q = 32767/*1.0f Q15*/; /* y/x = neg/zero = -Inf */ + sf = 0; + BASOP_SATURATE_WARNING_OFF_EVS + q = BASOP_Util_Divide3232_uu_1616_Scale(L_abs(y), L_abs(x), &sf); + BASOP_SATURATE_WARNING_ON_EVS + + BASOP_SATURATE_WARNING_OFF_EVS + if (L_sign < 0) + q = negate(q); + BASOP_SATURATE_WARNING_ON_EVS + + sfo = add(sf, e); + + /* --- atan() */ + IF(GT_16(sfo, ATI_SF)) + { + /* --- could not calc fixp_atan() here bec of input data out of range + ==> therefore give back boundary values */ + + sfo = s_min(sfo, MAXSFTAB); + + /*q = FL2WORD16( 0.0f ); move16();*/ + + if (q > 0) + { + move16(); + q = +f_atan_expand_range[sfo - ATI_SF - 1]; + } + if (q < 0) + { + move16(); + q = -f_atan_expand_range[sfo - ATI_SF - 1]; + } + } + ELSE + { + /* --- calc of fixp_atan() is possible; input data within range + ==> set q on fixed scale level as desired from fixp_atan() */ + stf = sub(sfo, ATI_SF); + + at = L_deposit_h(q); + if (stf < 0) at = L_shl(at,stf); + + q = BASOP_util_atan(at); /* ATO_SF*/ + } + + + /* --- atan2() */ + + ret = shr(q, (AT2O_SF - ATO_SF)); /* now AT2O_SF for atan2 */ + IF(x < 0) + { + if (y >= 0) + { + ret = add(ret, 25736/*EVS_PI Q13*/); + } + if (y < 0) + { + ret = sub(ret, 25736/* EVS_PI Q13*/); + } + } + + return ret; +} + +/* SNR of fixp_atan() = 56 dB*/ +#define ONEBY3P56 0x26800000 /* 1.0/3.56 in q31*/ +#define P281 0x00026000 /* 0.281 in q19*/ +#define ONEP571 0x6487 /* 1.571 in q14*/ + +Word16 BASOP_util_atan( /* o: atan(x) [-pi/2;pi/2] 1Q14 */ + Word32 x /* i: input data (-64;64) 6Q25 */ +) +{ + Word16 sign, result, exp; + Word16 res_e; + Word16 tmp, xx; + + + + sign = 0; + move16(); + if (x < 0) + { + sign = 1; + move16(); + } + x = L_abs(x); + + /* calc of arctan */ + IF(LT_32(x, 1509950l/*0.045f/64.0f Q31*/)) + { + result = round_fx(L_shl(x, 5)); /*Q14*/ + /*BASOP_util_atan_16(0.0444059968): max error 0.0000567511, mean 0.000017, abs mean 0.000017*/ + } + ELSE + IF(LT_32(x, (L_shl(1, Q_ATANINP) - 8482560l/*0.00395 Q31*/))) + { + xx = round_fx(L_shl(x, 6)); + tmp = mult_r(xx, xx); /* q15 * q15 - (16-1) = q15*/ + tmp = mult_r(tmp, 0x1340); /* 15 * (ONEBY3P56) q14 - (16-1) = q14*/ + tmp = add(tmp, 0x4000); /*L_shl(1,14) = 524288*/ /* q14 + q14 = q14 */ + res_e = Q_ATANOUT - 15 + 14 - 16 + 1; + move16(); + if (GT_16(xx, tmp)) + { + res_e = add(res_e, 1); + } + if (GT_16(xx, tmp)) + { + xx = shr(xx, 1); + } + result = div_s(xx, tmp); + result = msu_r(0, result, shl(-32768, res_e)); + /*BASOP_util_atan_16(0.7471138239): max error 0.0020029545, mean 0.000715, abs mean 0.000715*/ + } + ELSE IF(LT_32(x, 42949673l/*1.28/64.0 Q31*/)) + { + Word16 delta_fix; + Word32 PI_BY_4 = 1686629684l/*3.1415926/4.0 Q31*/ / 2; /* pi/4 in q30 */ + + delta_fix = round_fx(L_shl(L_sub(x, 33554432l/*1.0/64.0 Q31*/), 5)); /* q30 */ + result = round_fx(L_sub(L_add(PI_BY_4, L_msu(0, delta_fix, -16384)), (L_mult0(delta_fix, delta_fix)))); + /* BASOP_Util_fPow(0.7472000122): max error 0.0020237688, mean 0.000026, abs mean 0.000520 */ + } + ELSE + { + exp = sub(norm_l(x),1); + xx = round_fx(L_shl(x,exp)); + /* q25+exp * q25+exp - (16-1) = q19+2*exp*/ + tmp = mac_r(L_shl(P281,shl(exp,1)),xx, xx); /* q19+2*exp + q19+2*exp = q19+2*exp*/ + res_e = norm_s(tmp); + result = div_s(xx, shl(tmp,res_e)); + result = shl(result, add(add(Q_ATANOUT - Q_ATANINP/*-exp*/ + 19/*+2*exp*/ - 16 + 1, res_e),exp)); + result = sub(ONEP571,result); /* q14 + q14 = q14*/ + /*BASOP_Util_fPow(1.2799999714): max error 0.0020168927, mean 0.000066, abs mean 0.000072*/ + } + + if (sign) + { + result = negate(result); + } + + return(result); +} + +/* compare two positive normalized 16 bit mantissa/exponent values */ +/* return value: positive if first value greater, negative if second value greater, zero if equal */ +Word16 compMantExp16Unorm(Word16 m1, Word16 e1, Word16 m2, Word16 e2) +{ + Word16 tmp; + + assert((m1 >= 0x4000) && (m2 >= 0x4000)); /* comparisons below work only for normalized mantissas */ + + tmp = sub(e1, e2); + if (tmp == 0) tmp = sub(m1, m2); + + return tmp; +} + +cmplx CL_scale_t(cmplx x, Word16 y) +{ + cmplx result; + result.re = Mpy_32_16_1(x.re, y); + result.im = Mpy_32_16_1(x.im, y); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].CL_scale++; +#endif + return (result); +} + +cmplx CL_dscale_t(cmplx x, Word16 y1, Word16 y2) +{ + cmplx result; + result.re = Mpy_32_16_1(x.re, y1); + result.im = Mpy_32_16_1(x.im, y2); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].CL_dscale++; +#endif/* #if (WMOPS) */ + return (result); +} + +cmplx CL_mult_32x16(cmplx input, cmplx_s coeff) +{ + cmplx result; + result.re = L_sub(Mpy_32_16_1(input.re, coeff.re), Mpy_32_16_1(input.im, coeff.im)); + result.im = L_add(Mpy_32_16_1(input.re, coeff.im), Mpy_32_16_1(input.im, coeff.re)); +#if (WMOPS) + multiCounter[currCounter].CL_multr_32x16++; + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].L_sub--; + multiCounter[currCounter].L_add--; +#endif + return result; +} + +/*___________________________________________________________________________ + | | + | Function Name : Isqrt_lc | + | | + | Compute 1/sqrt(value). | + | if value is negative or zero, result is 1 (frac=7fffffff, exp=0). | + |---------------------------------------------------------------------------| + | Algorithm: | + | | + | The function 1/sqrt(value) is approximated by a table and linear | + | interpolation. | + | | + | 1- If exponant is odd then shift fraction right once. | + | 2- exponant = -((exponant-1)>>1) | + | 3- i = bit25-b30 of fraction, 16 <= i <= 63 ->because of normalization. | + | 4- a = bit10-b24 | + | 5- i -=16 | + | 6- fraction = table[i]<<16 - (table[i] - table[i+1]) * a * 2 | + |___________________________________________________________________________| +*/ +Word32 Isqrt_lc( + Word32 frac, /* (i) Q31: normalized value (1.0 < frac <= 0.5) */ + Word16 * exp /* (i/o) : exponent (value = frac x 2^exponent) */ +) +{ + Word16 i, a; + Word32 L_tmp; + + IF(frac <= (Word32)0) + { + *exp = 0; move16(); + return 0x7fffffff; /*0x7fffffff*/ + } + + /* If exponant odd -> shift right by 10 (otherwise 9) */ + L_tmp = L_shr(frac, shift_Isqrt_lc[s_and(*exp, 1)]); + + /* 1) -16384 to shift left and change sign */ + /* 2) 32768 to Add 1 to Exponent like it was divided by 2 */ + /* 3) We let the mac_r add another 0.5 because it imitates */ + /* the behavior of shr on negative number that should */ + /* not be rounded towards negative infinity. */ + /* It replaces: */ + /* *exp = negate(shr(sub(*exp, 1), 1)); move16(); */ + *exp = mac_r(32768, *exp, -16384); move16(); + + a = extract_l(L_tmp); /* Extract b10-b24 */ + a = lshr(a, 1); + + i = mac_r(L_tmp, -16 * 2 - 1, 16384); /* Extract b25-b31 minus 16 */ + + L_tmp = L_msu(L_table_isqrt[i], table_isqrt_diff[i], a);/* table[i] << 16 - diff*a*2 */ + + return L_tmp; +} + +Word32 Isqrt( /* (o) Q31 : output value (range: 0<=val<1) */ + Word32 L_x /* (i) Q0 : input value (range: 0<=val<=7fffffff) */ +) +{ + Word16 exp; + Word32 L_y; + + exp = norm_l(L_x); + L_x = L_shl(L_x, exp); /* L_x is normalized */ + exp = sub(31, exp); + + L_x = Isqrt_lc(L_x, &exp); + + L_y = L_shl(L_x, exp); /* denormalization */ + + return (L_y); +} + +#ifdef BASOP_NOGLOB +Word32 Dot_product12_o( /* (o) Q31: normalized result (1 < val <= -1) */ + const Word16 x[], /* (i) 12bits: x vector */ + const Word16 y[], /* (i) 12bits: y vector */ + const Word16 lg, /* (i) : vector length */ + Word16* exp, /* (o) : exponent of result (0..+30) */ + Flag* Overflow_out /* o : propagating the Overflow flag to upper level, set to NULL to ignore internal overflows */ +) +#else /* BASOP_NOGLOB */ +Word32 Dot_product12( /* (o) Q31: normalized result (1 < val <= -1) */ + const Word16 x[], /* (i) 12bits: x vector */ + const Word16 y[], /* (i) 12bits: y vector */ + const Word16 lg, /* (i) : vector length */ + Word16 * exp /* (o) : exponent of result (0..+30) */ +) +#endif /* BASOP_NOGLOB */ +{ + Word16 i, sft; + Word32 L_sum; +#ifdef BASOP_NOGLOB + Flag Overflow_ignored = 0; +#endif /* BASOP_NOGLOB */ + +#ifdef BASOP_NOGLOB + L_sum = L_mac_o(1, x[0], y[0], &Overflow_ignored); +#else + L_sum = L_mac(1, x[0], y[0]); +#endif + FOR(i = 1; i < lg; i++) + { +#ifdef BASOP_NOGLOB + L_sum = L_mac_o(L_sum, x[i], y[i], Overflow_out ? Overflow_out : &Overflow_ignored); +#else /* BASOP_NOGLOB */ + L_sum = L_mac(L_sum, x[i], y[i]); +#endif /* BASOP_NOGLOB */ + } + + /* Normalize acc in Q31 */ + + sft = norm_l(L_sum); + L_sum = L_shl(L_sum, sft); + + *exp = sub(30, sft); move16(); /* exponent = 0..30 */ + + return L_sum; +} + +#ifdef BASOP_NOGLOB +Word32 Dot_product12( /* (o) Q31: normalized result (1 < val <= -1) */ + const Word16 x[], /* (i) 12bits: x vector */ + const Word16 y[], /* (i) 12bits: y vector */ + const Word16 lg, /* (i) : vector length */ + Word16 * exp /* (o) : exponent of result (0..+30) */ +) +{ + /* Ignore internal overflows */ + return Dot_product12_o(x, y, lg, exp, NULL); +} +#endif /* BASOP_NOGLOB */ + +Word32 Energy_scale( /* (o) : Q31: normalized result (1 < val <= -1) */ + const Word16 x[], /* (i) : input vector x */ + const Word16 lg, /* (i) : vector length */ + Word16 expi, /* (i) : exponent of input */ + Word16 *exp /* (o) : exponent of result (0..+30) */ +) +{ + Word16 i, sft, tmp; + Word32 L_sum; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + + L_sum = 0; /* just to avoid superflous compiler warning about uninitialized use of L_sum */ + + IF(expi == 0) + { +#ifdef BASOP_NOGLOB + L_sum = L_mac_o(1, x[0], x[0], &Overflow); +#else + L_sum = L_mac(1, x[0], x[0]); +#endif + FOR(i = 1; i < lg; i++) + { +#ifdef BASOP_NOGLOB + L_sum = L_mac_o(L_sum, x[i], x[i], &Overflow); +#else /* BASOP_NOGLOB */ + L_sum = L_mac(L_sum, x[i], x[i]); +#endif + } + } + IF(expi < 0) + { + sft = lshl(-32768 /* 0x8000 */, expi); + tmp = mult_r(x[0], sft); + L_sum = L_mac(1, tmp, tmp); + FOR(i = 1; i < lg; i++) + { + tmp = mult_r(x[i], sft); +#ifdef BASOP_NOGLOB + L_sum = L_mac_o(L_sum, tmp, tmp, &Overflow); +#else + L_sum = L_mac(L_sum, tmp, tmp); +#endif + } + } + IF(expi > 0) + { +#ifdef BASOP_NOGLOB + tmp = shl_o(x[0], expi, &Overflow); + L_sum = L_mac_o(1, tmp, tmp, &Overflow); + FOR(i = 1; i < lg; i++) + { + tmp = shl_o(x[i], expi, &Overflow); + L_sum = L_mac_o(L_sum, tmp, tmp, &Overflow); + } +#else + tmp = shl(x[0], expi); + L_sum = L_mac(1, tmp, tmp); + FOR(i = 1; i < lg; i++) + { + tmp = shl(x[i], expi); + L_sum = L_mac(L_sum, tmp, tmp); + } +#endif + } + + /* Normalize acc in Q31 */ + + sft = norm_l(L_sum); + L_sum = L_shl(L_sum, sft); + + *exp = sub(30, sft); move16(); /* exponent = 0..30 */ + + + return L_sum; +} + +Word32 L_Frac_sqrtQ31( /* o : Square root if input */ + const Word32 x /* i : Input */ +) +{ + Word32 log2_work; + Word16 log2_int, log2_frac; + + test(); + if (x > 0) + { + log2_int = norm_l(x); + log2_frac = Log2_norm_lc(L_shl(x, log2_int)); + + log2_work = L_msu((31 + 30) * 65536L / 2, 16384, log2_int); + log2_work = L_mac0(log2_work, log2_frac, 1); + + log2_frac = L_Extract_lc(log2_work, &log2_int); + + return Pow2(log2_int, log2_frac); + } + return 0; +} + +Word16 Frac_sqrt( /* o : Square root if input */ + const Word16 x /* i : Input */ +) +{ + return round_fx(L_Frac_sqrtQ31(L_deposit_h(x))); +} + +Word16 i_mult2(Word16 a, Word16 b) +{ + return extract_l(L_mult0(a, b)); + +} + +UWord32 UL_deposit_l(UWord16 uvar) { + UWord32 UL_result; + UL_result = (UWord32)uvar; /* no sign extension*/ + return (UL_result); +} + +UWord32 UL_addNs(UWord32 UL_var1, UWord32 UL_var2, UWord16 * wrap) { + UWord32 UL_var3; + + /* STL Overflow flag is not updated */ + UL_var3 = UL_var1 + UL_var2; /* 32-bit wrap may occur, like in C */ + + if (((UWord64)UL_var1 + (UWord64)UL_var2) > 0xFFFFFFFFU) { + *wrap = 1; /* wrapped output */ + } + else { + *wrap = 0; + } + + return UL_var3; +} + +UWord32 UL_subNs(UWord32 UL_var1, UWord32 UL_var2, UWord16 * sgn) { + UWord32 UL_var3; + + UL_var3 = UL_var1 - UL_var2; /*wrap may occur, like in C */ + if (UL_var1 >= UL_var2) { + *sgn = 0; + } + else { + *sgn = 1; /* "negative", wrapped output */ + } + return UL_var3; +} + +void Mpy_32_16_uu(UWord32 UL_var1, UWord16 uvar2, UWord32 *UL_varout_h, UWord16 *varout_l) { + UWord64 UL64_var1; + + /* 4294967295 * 65535 < 281474976710655 */ + /* (uint64(2)^16-1 )*(uint64(2)^32-1) < (uint64(2)^(16+32)-1) */ + UL64_var1 = ((UWord64)UL_var1)*((UWord64)uvar2); + *varout_l = (UWord16)UL64_var1; + *UL_varout_h = (UWord32)(UL64_var1 >> 16); + + + return; +} + +void Mpy_32_32_uu(UWord32 UL_var1, UWord32 UL_var2, UWord32 *UL_varout_h, UWord32 *UL_varout_l) { + UWord64 UL64_var1; + /* (uint64(2)^32-1 )*(uint64(2)^32-1) < (uint64(2)^(32+32)-1) */ + UL64_var1 = ((UWord64)UL_var1)*((UWord64)UL_var2); + *UL_varout_h = (UWord32)(UL64_var1 >> 32); + *UL_varout_l = (UWord32)(UL64_var1); + + + return; + +} + +UWord32 UL_Mpy_32_32(UWord32 UL_var1, UWord32 UL_var2) { + UWord32 UL_varout_l; + +#define MASK32 0xFFFFFFFFU + /* MASK32 may be needed in case Hardware is using larger than 32 bits for UWord32 type */ + UL_varout_l = (UL_var1&MASK32)*(UL_var2&MASK32); + UL_varout_l = UL_varout_l & MASK32; +#undef MASK32 + + + return UL_varout_l; +} + +/* (Reuse of existing signed STL "L" operators) with + typecasting to make the resulting "UL" code a lot cleaner and more readable. */ + +UWord32 UL_lshl(UWord32 UL_var1, Word16 var2) { + return((UWord32)L_lshl((Word32)UL_var1, var2)); +} + +UWord32 UL_lshr(UWord32 UL_var1, Word16 var2) { + return((UWord32)L_lshr((Word32)UL_var1, var2)); +} + +UWord32 UL_and(UWord32 UL_var1, UWord32 UL_var2) +{ + return (UWord32)L_and((Word32)UL_var1, (Word32)UL_var2); +} + +UWord32 UL_or(UWord32 UL_var1, UWord32 UL_var2) +{ + return (UWord32)L_or((Word32)UL_var1, (Word32)UL_var2); +} + +UWord32 UL_xor(UWord32 UL_var1, UWord32 UL_var2) +{ + return (UWord32)L_xor((Word32)UL_var1, (Word32)UL_var2); +} + +UWord32 UL_deposit_h(UWord16 uvar1) +{ + return (UWord32)L_deposit_h((Word32)uvar1); +} + +UWord16 u_extract_h(UWord32 UL_var1) +{ + return (UWord16)extract_h((Word32)UL_var1); +} + +UWord16 u_extract_l(UWord32 UL_var1) +{ + return (UWord32)extract_l((Word32)UL_var1); +} + +/* enable convenient reuse of Non-saturating UL_subNs , UL_addNs while "D"iscarding the sgn/wrap output flags */ +UWord32 UL_subNsD(UWord32 UL_var1, UWord32 UL_var2) +{ + UWord16 dummy_sign; + return UL_subNs(UL_var1, UL_var2, &dummy_sign); +} + +UWord32 UL_addNsD(UWord32 UL_var1, UWord32 UL_var2) +{ + UWord16 dummy_wrap; + return UL_addNs(UL_var1, UL_var2, &dummy_wrap); +} + #undef WMC_TOOL_SKIP diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index c09b8ea62..910a635a0 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -91,6 +91,23 @@ Word16 BASOP_Util_Add_MantExp /*!< Exponent of result */ Word16 b_e, /*!< Exponent of 2nd operand b */ Word16 *ptrSum_m ); /*!< Mantissa of result */ +/************************************************************************/ +/*! + \brief Divide two values given by mantissa and exponent. + + Mantissas are in 16-bit-fractional format with values between 0 and 1.
+ The base for exponents is 2. Example: \f$ a = a\_m * 2^{a\_e} \f$
+ + For performance reasons, the division is based on a table lookup + which limits accuracy. +*/ +void BASOP_Util_Divide_MantExp(Word16 a_m, /*!< Mantissa of dividend a */ + Word16 a_e, /*!< Exponent of dividend a */ + Word16 b_m, /*!< Mantissa of divisor b */ + Word16 b_e, /*!< Exponent of divisor b */ + Word16 *ptrResult_m, /*!< Mantissa of quotient a/b */ + Word16 *ptrResult_e /*!< Exponent of quotient a/b */ +); /************************************************************************/ /*! @@ -106,6 +123,56 @@ Word16 Sqrt16( /*!< output mantissa */ Word16 *exponent /*!< pointer to exponent */ ); +Word16 Sqrt16norm( /*!< output mantissa */ + Word16 mantissa, /*!< normalized input mantissa */ + Word16 *exponent /*!< pointer to exponent */ +); + +Word32 Sqrt32( /*!< output mantissa */ + Word32 mantissa, /*!< input mantissa */ + Word16 *exponent /*!< pointer to exponent */ +); + + +/* deprecated, use Sqrt16! */ +void BASOP_Util_Sqrt_MantExp(Word16 *mantissa, /*!< Pointer to mantissa */ + Word16 *exponent /*!< Pointer to exponent */ +); + +/* deprecated, use Sqrt16norm! */ +void BASOP_Util_Sqrt_MantExpNorm(Word16 *mantissa, /*!< Pointer to normalized mantissa */ + Word16 *exponent /*!< Pointer to exponent */ +); + +/****************************************************************************/ +/*! + \brief Calculate the inverse of the squareroot of a number given by mantissa and exponent + + Mantissa is in 16/32-bit-fractional format with values between 0 and 1.
+ For *norm versions mantissa has to be between 0.5 and 1.
+ The base for the exponent is 2. Example: \f$ a = a\_m * 2^{a\_e} \f$
+ The exponent is addressed via pointers and will be overwritten with the result. +*/ +Word16 ISqrt16( /*!< output mantissa */ + Word16 mantissa, /*!< input mantissa */ + Word16 *exponent /*!< pointer to exponent */ +); + +Word32 ISqrt32( /*!< output mantissa */ + Word32 mantissa, /*!< input mantissa */ + Word16 *exponent /*!< pointer to exponent */ +); + +Word32 ISqrt32norm( /*!< output mantissa */ + Word32 mantissa, /*!< normalized input mantissa */ + Word16 *exponent /*!< pointer to exponent */ +); + +/* deprecated, use ISqrt16! */ +void BASOP_Util_InvSqrt_MantExp(Word16 *mantissa, /*!< Pointer to mantissa */ + Word16 *exponent /*!< Pointer to exponent */ +); + /*****************************************************************************/ /*! \brief Calculate the inverse of a number given by mantissa and exponent @@ -136,6 +203,19 @@ void BASOP_Util_Sqrt_InvSqrt_MantExp( Word16 mantissa, /*!< mantissa */ Word16 *isqrt_exp /*!< Pointer to 1/sqrt exponent */ ); +/********************************************************************/ +/*! + \brief Calculates the scalefactor needed to normalize input array + + The scalefactor needed to normalize the Word16 input array is returned
+ If the input array contains only '0', a scalefactor 0 is returned
+ Scaling factor is determined wrt a normalized target x: 16384 <= x <= 32767 for positive x
+ and -32768 <= x <= -16384 for negative x +*/ + +Word16 getScaleFactor16( /* o: measured headroom in range [0..15], 0 if all x[i] == 0 */ + const Word16 *x, /* i: array containing 16-bit data */ + const Word16 len_x); /* i: length of the array to scan */ /********************************************************************/ /*! @@ -152,6 +232,97 @@ Word16 getScaleFactor32( const Word32 *x, /* i : array containing 32-bit data */ const Word16 len_x ); /* i : length of the array to scan */ + +/** + * \brief normalize mantissa and update the exponent accordingly. + * \param mantissa the mantissa to be normalized + * \param pexponent pointer to the exponent. + * \return the normalized mantissa. + */ +Word16 normalize16(Word16 mantissa, Word16 *pexponent); +/****************************************************************************/ +/*! + \brief Does fractional integer division of Word32 arg1 by Word16 arg2 + + both input arguments may be positive or negative
+ the result is truncated to Word16 + + \return fractional integer Word16 result of arg1/arg2 +*/ +Word16 divide3216(Word32 x, /*!< Numerator*/ + Word16 y); /*!< Denominator*/ + + +/****************************************************************************/ +/*! + \brief Does fractional integer division of Word16 arg1 by Word16 arg2 + + both input arguments may be positive or negative
+ the result is truncated to Word16 + + \return fractional integer Word16 result of arg1/arg2 +*/ +Word16 divide1616(Word16 x, /*!< Numerator*/ + Word16 y); /*!< Denominator*/ + + +/****************************************************************************/ +/*! + \brief Does fractional integer division of Word32 arg1 by Word32 arg2 + + this function makes both the numerator and the denominator positive integers, + and scales up both values to avoid losing the accuracy of the outcome + too much + + WARNING: it should be arg1 < arg2 because of the maximum degree of scaling for the mantissa! + + \return fractional Word16 integer z = arg1(32bits)/arg2(32bits) +*/ +Word16 divide3232(Word32 x, /*!< Numerator*/ + Word32 y); /*!< Denominator*/ + + +/****************************************************************************/ +/*! + \brief Does fractional integer division of UWord32 arg1 by UWord32 arg2 + + This function ensures both the numerator and the denominator are positive integers, + and scales up both values to avoid losing the accuracy of the outcome + too much.
+ + CAUTION: Arg 3 is a Word16 pointer which will point to the scalefactor difference + s_diff = sub(s2,s1), where s1 and s2 are the scalefactors of the arguments, which + were shifted in order to e.g. preserve accuracy. + I.e. the result has to be scaled due to shifting it + s_diff to the right to obtain the real result of the division. + + \return fractional Word16 integer z = arg1(32bits)/arg2(32bits) +*/ +Word16 BASOP_Util_Divide3232_uu_1616_Scale(Word32 x, /*!< i : Numerator*/ + Word32 y, /*!< i : Denominator*/ + Word16 *s); /*!< o : Additional scalefactor difference*/ + + +/****************************************************************************/ +/*! + \brief Does fractional integer division of Word32 arg1 by Word32 arg2 + + This function scales up both values to avoid losing the accuracy of the outcome + too much.
+ + CAUTION: Arg 3 is a Word16 pointer which will point to the scalefactor difference + s_diff = sub(s2,s1), where s1 and s2 are the scalefactors of the arguments, which + were shifted in order to e.g. preserve accuracy. + I.e. the result has to be scaled due to shifting it + s_diff to the right to obtain the real result of the division. + + \return fractional Word16 integer z = arg1(32bits)/arg2(32bits) +*/ +Word16 BASOP_Util_Divide3232_Scale(Word32 x, /*!< i : Numerator*/ + Word32 y, /*!< i : Denominator*/ + Word16 *s); /*!< o : Additional scalefactor difference*/ + + /************************************************************************/ /*! \brief Binary logarithm with 7 iterations @@ -239,7 +410,56 @@ Word32 BASOP_Util_log2_i5( Word32 val ); /************************************************************************/ Word32 BASOP_Util_InvLog2( Word32 x ); +Word16 BASOP_util_norm_s_bands2shift(Word16 x); + + +/***********************************************************************/ +/*! + \brief Calculate the headroom of the complex data in a 2 dimensional array + + \return number of headroom bits + */ +Word16 BASOP_util_norm_l_dim2_cplx(const Word32 * const *re, /*!< Real part of 32 Bit input */ + const Word32 * const *im, /*!< Imag part if 32 Bit input */ + Word16 startBand, /*!< start band of cplx data */ + Word16 stopBand, /*!< stop band of cplx data */ + Word16 startSlot, /*!< start slot of cplx data */ + Word16 stopSlot /*!< stop slot of cplx data */ +); +/****************************************************************************/ +/*! + \brief Does a data copy of Word8 *arg1 to Word8 *arg2 with Word16 arg3 number of moves +*/ +void copyWord8(const Word8 *src, /*!< i : Source address */ + Word8 *dst, /*!< i : Destination address */ + const Word32 n); /*!< i : Number of elements to copy */ + + +/****************************************************************************/ +/*! + \brief Sets Word8 array arg1[] to zero for a length of Word16 arg2 elements +*/ +void set_zero_Word8(Word8 X[], /*!< i : Address of array */ + Word32 n); /*!< i : Number of elements to set to zero */ +/****************************************************************************/ +/*! + \brief Does a multiplication of Word32 * Word16 input values + + \return z32 = x32 * y16 +*/ +Word32 L_mult0_3216(Word32 x, /*!< : Multiplier */ + Word16 y); /*!< : Multiplicand */ + +/* Calculate sin/cos. Angle in 2Q13 format, result has exponent = 1 */ +Word16 getCosWord16(Word16 theta); +Word32 getCosWord32(Word32 theta); +/** + * \brief calculate cosine of angle. Tuned for ISF domain. + * \param theta Angle normalized to radix 2, theta = (angle in radians)*2.0/pi + * \return result with exponent 0. + */ +Word16 getCosWord16R2(Word16 theta); /****************************************************************************/ /*! \brief Sets Array Word16 arg1 to value Word16 arg2 for Word16 arg3 elements @@ -273,6 +493,63 @@ Word16 mult0( Word16 x, /* i : Multiplier */ */ Word16 getCosWord16R2( Word16 theta ); + +/****************************************************************************/ +/*! + \brief square root abacus algorithm + + \return integer sqrt(x) + */ +Word16 getSqrtWord32(Word32 x); + +/****************************************************************************/ +/*! + \brief finds index of min Word16 in array + + \return index of min Word16 + */ +Word16 findIndexOfMinWord16(Word16 *x, const Word16 len); + +/****************************************************************************/ +/*! + \brief finds index of min Word32 in array + + \return index of min Word32 + */ +Word16 findIndexOfMinWord32(Word32 *x, const Word16 len); + +/****************************************************************************/ +/*! + \brief finds index of max Word16 in array + + \return index of max Word16 + */ +Word16 findIndexOfMaxWord16(Word16 *x, const Word16 len); + +/****************************************************************************/ +/*! + \brief finds index of max Word32 in array + + \return index of max Word32 + */ +Word16 findIndexOfMaxWord32(Word32 *x, const Word16 len); + +/****************************************************************************/ +/*! + \brief 16x16->16 integer multiplication without overflow control + + \return 16x16->16 integer + */ +Word16 imult1616(Word16 x, Word16 y); + +/****************************************************************************/ +/*! + \brief 32x16->32 integer multiplication with overflow control + + \return 32x16->32 integer + */ +Word32 imult3216(Word32 x, Word16 y); + /****************************************************************************/ /*! \brief 16/16->16 unsigned integer division @@ -284,6 +561,75 @@ Word16 getCosWord16R2( Word16 theta ); Word16 idiv1616U( Word16 x, Word16 y ); +/****************************************************************************/ +/*! + \brief 16/16->16 signed integer division + + x and y have to be positive, x has to be < 16384 + + \return 16/16->16 integer + */ + +Word16 idiv1616(Word16 x, Word16 y); + +/*------------------------------------------------------------------* + * Dot_product16HQ: + * + * \brief Compute scalar product of using 64-bit accumulator. + * + * Performs normalization of the result, returns the exponent + * Note: In contrast to dotWord32, no headroom is required for data + * in x[] and y[], means, they may have any format Qn + *------------------------------------------------------------------*/ +Word32 Dot_product16HQ( /* using 64-bit accumulator. + * + * Performs normalization of the result, returns the exponent + * Note: In contrast to dotWord32, no headroom is required for data + * in x[], means, they may have any format Qn + *------------------------------------------------------------------*/ +Word32 Dot_productSq16HQ( /* using accumulator. | + | The parameter 'L_off' is added to the accumulation result. | + | The result is normalized (in Q31) with exponent (0..30). | + | Notes: | + | o data in x[],y[] must provide enough headroom for accumulation | + | o L_off must correspond in format with product of x,y | + | Example: 0.01f for Q9 x Q9: 0x0000147B in Q19 | + | means: L_off = FL2WORD32_SCALE(0.01f,31-19) | + |---------------------------------------------------------------------------| + | Algorithm: | + | | + | dot_product = L_off + sum(x[i]*y[i]) i=0..N-1 | + |___________________________________________________________________________| +*/ + +Word32 Dot_product12_offs( /* (o) Q31: normalized result (1 < val <= -1) */ + const Word16 x[], /* (i) 12bits: x vector */ + const Word16 y[], /* (i) 12bits: y vector */ + const Word16 lg, /* (i) : vector length in range [1..256] */ + Word16 * exp, /* (o) : exponent of result (0..+30) */ + Word32 L_off /* (i) initial summation offset /2 */ +); + +Word32 Dot_product15_offs( /* (o) Q31: normalized result (1 < val <= -1) */ + const Word16 x[], /* (i) 15bits: x vector */ + const Word16 y[], /* (i) 15bits: y vector */ + const Word16 lg, /* (i) : vector length in range [1..256] */ + Word16 *exp, /* (o) : exponent of result (0..+30) */ + Word32 L_off /* (i) initial summation offset */ +); + /*!********************************************************************** \brief Add two values given by mantissa and exponent. @@ -400,6 +801,83 @@ Word32 BASOP_Util_Add_Mant32Exp /* o : normalized result mantissa */ Word16 b_e, /* i : Exponent of 2nd operand b */ Word16 *ptr_e ); /* o : exponent of result */ +/*!********************************************************************** + \brief Returns the comparison result of two normalized values given by mantissa and exponent. + return value: -1: a < b, 0: a == b, 1; a > b + + Mantissas are in 32-bit-fractional format with values between 0 and 1.
+ The base for exponents is 2. Example: \f$ a = a\_m * 2^{a\_e} \f$
+ +************************************************************************/ +Word16 BASOP_Util_Cmp_Mant32Exp /*!< o: flag: result of comparison */ +(Word32 a_m, /*!< i: Mantissa of 1st operand a */ + Word16 a_e, /*!< i: Exponent of 1st operand a */ + Word32 b_m, /*!< i: Mantissa of 2nd operand b */ + Word16 b_e); /*!< i: Exponent of 2nd operand b */ + +/******************************************************************** + * bufferCopyFx + * + * \brief copies buffer while preserving Format of destination buffer +********************************************************************* +*/ +void bufferCopyFx( + Word16* src, /* + The base for exponent x_e is 2.
+ +************************************************************************/ +Word16 BASOP_Util_lin2dB( /*!< o: dB value (7Q8) */ + Word32 x, /*!< i: mantissa */ + Word16 x_e, /*!< i: exponent */ + Word16 fEnergy); /*!< i: flag indicating if x is energy */ + +/*!********************************************************************** + \brief Calculates atan(x). +************************************************************************/ +Word16 BASOP_util_atan( /*!< o: atan(x) [-pi/2;pi/2] 1Q14 */ + Word32 x /*!< i: input data (-64;64) 6Q25 */ +); + +/*!********************************************************************** + \brief Calculates atan2(y,x). +************************************************************************/ +Word16 BASOP_util_atan2( /*!< o: atan2(y,x) [-pi,pi] Q13 */ + Word32 y, /*!< i: */ + Word32 x, /*!< i: */ + Word16 e /*!< i: exponent difference (exp_y - exp_x) */ +); + /****************************************************************************/ /*! \brief Accumulates multiplications @@ -415,4 +893,82 @@ Word32 dotWord32_16_guards( const Word32 *X, const Word16 *Y, Word16 n, Word16 h Word32 Sqrt_l( Word32 L_x, Word16 *exp ); +Word32 Isqrt( /* (o) Q31 : output value (range: 0<=val<1) */ + Word32 L_x /* (i) Q0 : input value (range: 0<=val<=7fffffff) */ +); + +#ifdef BASOP_NOGLOB +Word32 Dot_product12_o( /* (o) Q31: normalized result (1 < val <= -1) */ + const Word16 x[], /* (i) 12bits: x vector */ + const Word16 y[], /* (i) 12bits: y vector */ + const Word16 lg, /* (i) : vector length */ + Word16* exp, /* (o) : exponent of result (0..+30) */ + Flag* Overflow_out /* o : propagating the Overflow flag to upper level, set to NULL to ignore internal overflows */ +); +#else /* BASOP_NOGLOB */ +Word32 Dot_product12( /* (o) Q31: normalized result (1 < val <= -1) */ + const Word16 x[], /* (i) 12bits: x vector */ + const Word16 y[], /* (i) 12bits: y vector */ + const Word16 lg, /* (i) : vector length */ + Word16 * exp /* (o) : exponent of result (0..+30) */ +); +#endif /* BASOP_NOGLOB */ + +#ifdef BASOP_NOGLOB +Word32 Dot_product12( /* (o) Q31: normalized result (1 < val <= -1) */ + const Word16 x[], /* (i) 12bits: x vector */ + const Word16 y[], /* (i) 12bits: y vector */ + const Word16 lg, /* (i) : vector length */ + Word16 * exp /* (o) : exponent of result (0..+30) */ +); +#endif + +Word32 Energy_scale( /* (o) : Q31: normalized result (1 < val <= -1) */ + const Word16 x[], /* (i) : input vector x */ + const Word16 lg, /* (i) : vector length */ + Word16 expi, /* (i) : exponent of input */ + Word16 *exp /* (o) : exponent of result (0..+30) */ +); + +Word32 L_Frac_sqrtQ31( /* o : Square root if input */ + const Word32 x /* i : Input */ +); + +Word16 Frac_sqrt( /* o : Square root if input */ + const Word16 x /* i : Input */ +); + + +Word16 i_mult2(Word16 a, Word16 b); + +UWord32 UL_deposit_l(UWord16 uvar); + +UWord32 UL_addNs(UWord32 UL_var1, UWord32 UL_var2, UWord16 * wrap); + +UWord32 UL_subNs(UWord32 UL_var1, UWord32 UL_var2, UWord16 * sgn); + +void Mpy_32_16_uu(UWord32 UL_var1, UWord16 uvar2, UWord32 *UL_varout_h, UWord16 *varout_l); + +void Mpy_32_32_uu(UWord32 UL_var1, UWord32 UL_var2, UWord32 *UL_varout_h, UWord32 *UL_varout_l); + +UWord32 UL_Mpy_32_32(UWord32 UL_var1, UWord32 UL_var2); + +UWord32 UL_lshl(UWord32 UL_var1, Word16 var2); +UWord32 UL_lshr(UWord32 UL_var1, Word16 var2); +UWord32 UL_and(UWord32 UL_var1, UWord32 UL_var2); +UWord32 UL_or(UWord32 UL_var1, UWord32 UL_var2); +UWord32 UL_xor(UWord32 UL_var1, UWord32 UL_var2); +UWord32 UL_deposit_h(UWord16 uvar1); +UWord16 u_extract_h(UWord32 UL_var1); +UWord16 u_extract_l(UWord32 UL_var1); + +/* enable convenient reuse of Non-saturating UL_subNs , UL_addNs + while "D"iscarding the sgn/wrap output flags */ +UWord32 UL_subNsD(UWord32 UL_var1, UWord32 UL_var2); +UWord32 UL_addNsD(UWord32 UL_var1, UWord32 UL_var2); + + +//function defined in basop_util commented from basop_tcx_utils.c +Word16 compMantExp16Unorm(Word16 m1, Word16 e1, Word16 m2, Word16 e2); + #endif /* __BASOP_UTIL_H__ */ diff --git a/lib_com/bitalloc.c b/lib_com/bitalloc.c index 351ab9e3a..34a31136f 100644 --- a/lib_com/bitalloc.c +++ b/lib_com/bitalloc.c @@ -299,7 +299,7 @@ int16_t BitAllocF( if ( Rsubband_w32_fx[i] > 0 ) { n = add( n, Nb[i] ); - Rsubband_w32_fx[i] = Mpy_32_16( Rsubband_w32_fx[i], tmp ); + Rsubband_w32_fx[i] = Mpy_32_16_1( Rsubband_w32_fx[i], tmp ); move32(); /*exp1 - 15*/ Rsubband_w32_fx[i] = L_shl( Rsubband_w32_fx[i], sub( 30, exp1 ) ); /*Q15*/ @@ -340,7 +340,7 @@ int16_t BitAllocF( if ( Rsubband_w32_fx[i] > 0 ) { n = add( n, Nb[i] ); - Rsubband_w32_fx[i] = Mpy_32_16( Rsubband_w32_fx[i], tmp ); + Rsubband_w32_fx[i] = Mpy_32_16_1( Rsubband_w32_fx[i], tmp ); move32(); /*exp1 - 15*/ Rsubband_w32_fx[i] = L_shl( Rsubband_w32_fx[i], sub( 30, exp1 ) ); /*Q15*/ diff --git a/lib_com/bits_alloc.c b/lib_com/bits_alloc.c index 0d1611de6..ec251f187 100644 --- a/lib_com/bits_alloc.c +++ b/lib_com/bits_alloc.c @@ -92,8 +92,8 @@ void BITS_ALLOC_init_config_acelp( { acelp_cfg->pre_emphasis = 1; acelp_cfg->formant_enh = 1; - acelp_cfg->formant_enh_num = FORMANT_SHARPENING_G1; - acelp_cfg->formant_enh_den = FORMANT_SHARPENING_G2; + acelp_cfg->formant_enh_num_flt = FORMANT_SHARPENING_G1_FLT; + acelp_cfg->formant_enh_den_flt = FORMANT_SHARPENING_G2_FLT; acelp_cfg->formant_tilt = 0; acelp_cfg->voice_tilt = 0; } @@ -101,8 +101,8 @@ void BITS_ALLOC_init_config_acelp( { acelp_cfg->pre_emphasis = 0; acelp_cfg->formant_enh = 1; - acelp_cfg->formant_enh_num = FORMANT_SHARPENING_G1; - acelp_cfg->formant_enh_den = FORMANT_SHARPENING_G2; + acelp_cfg->formant_enh_num_flt = FORMANT_SHARPENING_G1_FLT; + acelp_cfg->formant_enh_den_flt = FORMANT_SHARPENING_G2_FLT; acelp_cfg->formant_tilt = 1; acelp_cfg->voice_tilt = 1; } @@ -112,8 +112,8 @@ void BITS_ALLOC_init_config_acelp( { acelp_cfg->pre_emphasis = 1; acelp_cfg->formant_enh = 1; - acelp_cfg->formant_enh_num = FORMANT_SHARPENING_G1_16k; - acelp_cfg->formant_enh_den = FORMANT_SHARPENING_G2_16k; + acelp_cfg->formant_enh_num_flt = FORMANT_SHARPENING_G1_16k_FLT; + acelp_cfg->formant_enh_den_flt = FORMANT_SHARPENING_G2_16k_FLT; acelp_cfg->formant_tilt = 0; acelp_cfg->voice_tilt = 2; } @@ -165,7 +165,7 @@ int16_t BITS_ALLOC_config_acelp( { acelp_cfg->pre_emphasis = 0; acelp_cfg->formant_enh = 0; - acelp_cfg->formant_enh_num = FORMANT_SHARPENING_G1_16k; + acelp_cfg->formant_enh_num_flt = FORMANT_SHARPENING_G1_16k_FLT; acelp_cfg->formant_tilt = 1; acelp_cfg->voice_tilt = 1; } @@ -173,7 +173,7 @@ int16_t BITS_ALLOC_config_acelp( { acelp_cfg->pre_emphasis = 1; acelp_cfg->formant_enh = 1; - acelp_cfg->formant_enh_num = FORMANT_SHARPENING_G1; + acelp_cfg->formant_enh_num_flt = FORMANT_SHARPENING_G1_FLT; acelp_cfg->formant_tilt = 0; acelp_cfg->voice_tilt = 0; } diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 0aeed3040..2c743fd6f 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -97,7 +97,7 @@ static Word16 rate2AMRWB_IOmode( * * lookup EVS mode *-------------------------------------------------------------------*/ -Word16 rate2EVSmode( +Word16 rate2EVSmode_float( const Word32 brate, /* i : bitrate */ int16_t *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ ) @@ -111,7 +111,7 @@ Word16 rate2EVSmode( { /* EVS Primary modes */ case FRAME_NO_DATA: - return NO_DATA_RECEIVED; + return NO_DATA_TYPE; case SID_2k40: return PRIMARY_SID; case PPP_NELP_2k80: @@ -2129,7 +2129,7 @@ ivas_error read_indices( { st_ivas->element_mode_init = EVS_MONO; - if ( rate2EVSmode( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */ + if ( rate2EVSmode_float( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */ { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error, illegal bitrate (%d) in the G.192 frame ! Exiting ! \n", total_brate ); } @@ -2507,7 +2507,7 @@ static void berCheck( * Check if the frame includes a partial copy for channel aware processing. *-------------------------------------------------------------------*/ -void getPartialCopyInfo( +void getPartialCopyInfo_float( Decoder_State *st, /* i/o: decoder state structure */ int16_t *sharpFlag ) { @@ -2648,7 +2648,7 @@ static uint16_t get_indice_preview( * Signalling index preview for JBM *-------------------------------------------------------------------*/ -void evs_dec_previewFrame( +void evs_dec_previewFrame_float( uint8_t *bitstream, int16_t bitstreamSize, int16_t *partialCopyFrameType, @@ -2714,7 +2714,7 @@ void evs_dec_previewFrame( void dtx_read_padding_bits( - DEC_CORE_HANDLE st, + DEC_CORE_HANDLE_FLOAT st, const int16_t num_bits ) { /* TODO: temporary hack, need to decide what to do with core-coder bitrate */ diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c new file mode 100644 index 000000000..38d9dc9fe --- /dev/null +++ b/lib_com/bitstream_fx.c @@ -0,0 +1,2649 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +/*==================================================================================== + EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 + ====================================================================================*/ + +#include +#include +#include "options.h" +#include "ivas_cnst.h" /* Common constants */ +#include "prot_fx2.h" /* Function prototypes */ +#include "basop_util.h" +#include "rom_com.h" +#include "mime.h" + +#ifdef DEBUGGING + /*-------------------------------------------------------------------* + * Global variables + *--------------------------------------------------------------------*/ + +int16_t FEC_seed = 12558; /* Seed for random FEC generator */ +FILE* FEC_pattern = NULL; /* FEC pattern file (for simulation of FEC) */ +#ifndef IVAS_CODE +float FEC_random = 0; /* FEC rate in percent (for simulation of FEC) */ +/*-------------------------------------------------------------------* + * file_read_FECpattern() + * + * Simulate packet losses by reading FEC pattern from external file + *-------------------------------------------------------------------*/ + +static int16_t file_read_FECpattern(void) +{ + int16_t bfi = 0; + + /* FEC pattern file provided */ + if (FEC_pattern != NULL) + { + int16_t tmp = 0; + if (fread(&tmp, sizeof(int16_t), 1, FEC_pattern) != 1) + { + if (feof(FEC_pattern) != 0) + { + tmp = 0; + fseek(FEC_pattern, 0L, SEEK_SET); + } + else + { + fprintf(stderr, "\nError reading the FEC pattern file !"); + exit(-1); + } + } + + if (tmp == 2609 || tmp == 1 || tmp == SYNC_BAD_FRAME) + { + bfi = 1; + } + else + { + bfi = 0; + } + } + + /* random FEC simulation requested */ + else if (FEC_random > 0) + { + float ftmp = (float)/*own_random*/Random(&FEC_seed) + 32768.0f; + if (ftmp <= FEC_random / 100.0f * 65535.0f) + { + bfi = 1; + } + else + { + bfi = 0; + } + } + + return bfi; +} +#endif +#endif +/*-------------------------------------------------------------------* +* pack_bit() +* +* insert a bit into packed octet +*-------------------------------------------------------------------*/ +static void pack_bit( + const Word16 bit, /* i: bit to be packed */ + UWord8 **pt, /* i/o: pointer to octet array into which bit will be placed */ + UWord8 *omask /* i/o: output mask to indicate where in the octet the bit is to be written */ +) +{ + if (*omask == 0x80) + { + **pt = 0; + } + if (bit != 0) + { + **pt = **pt | *omask; + } + *omask >>= 1; + if (*omask == 0) + { + *omask = 0x80; + (*pt)++; + } + + return; +} + +/*-------------------------------------------------------------------* +* unpack_bit() +* +* unpack a bit from packed octet +*-------------------------------------------------------------------*/ +static Word16 unpack_bit( + UWord8 **pt, /* i/o: pointer to octet array from which bit will be read */ + UWord8 *mask /* i/o: mask to indicate the bit in the octet */ +) +{ + Word16 bit; + + bit = (**pt & *mask) != 0; + *mask >>= 1; + if (*mask == 0) + { + *mask = 0x80; + (*pt)++; + } + return bit; +} + +/*-------------------------------------------------------------------* +* rate2AMRWB_IOmode() +* +* lookup AMRWB IO mode +*-------------------------------------------------------------------*/ +static Word16 rate2AMRWB_IOmode( + Word32 brate /* i: bitrate */ +) +{ + switch (brate) + { + /* EVS AMR-WB IO modes */ + case SID_1k75: + return AMRWB_IO_SID; + case ACELP_6k60: + return AMRWB_IO_6600; + case ACELP_8k85: + return AMRWB_IO_8850; + case ACELP_12k65: + return AMRWB_IO_1265; + case ACELP_14k25: + return AMRWB_IO_1425; + case ACELP_15k85: + return AMRWB_IO_1585; + case ACELP_18k25: + return AMRWB_IO_1825; + case ACELP_19k85: + return AMRWB_IO_1985; + case ACELP_23k05: + return AMRWB_IO_2305; + case ACELP_23k85: + return AMRWB_IO_2385; + default: + break; + } + return -1; +} + +/*-------------------------------------------------------------------* +* rate2EVSmode() +* +* lookup EVS mode +*-------------------------------------------------------------------*/ +Word16 rate2EVSmode( + const Word32 brate, /* i: bitrate */ + Word16* is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ +) +{ + if (is_amr_wb != NULL) + { + *is_amr_wb = 0; + } + switch (brate) + { + /* EVS Primary modes */ + case FRAME_NO_DATA: + return NO_DATA_TYPE; + case SID_2k40: + return PRIMARY_SID; + case PPP_NELP_2k80: + return PRIMARY_2800; + case ACELP_7k20: + return PRIMARY_7200; + case ACELP_8k00: + return PRIMARY_8000; + case ACELP_9k60: + return PRIMARY_9600; + case ACELP_13k20: + return PRIMARY_13200; + case ACELP_16k40: + return PRIMARY_16400; + case ACELP_24k40: + return PRIMARY_24400; + case ACELP_32k: + return PRIMARY_32000; + case ACELP_48k: + return PRIMARY_48000; + case ACELP_64k: + return PRIMARY_64000; + case HQ_96k: + return PRIMARY_96000; + case HQ_128k: + return PRIMARY_128000; + default: + break; + } + if (is_amr_wb != NULL) + { + *is_amr_wb = 1; + } + return rate2AMRWB_IOmode(brate); +} + +/*-------------------------------------------------------------------* + * push_indice_fx( ) + * + * Push a new indice into the buffer + *-------------------------------------------------------------------*/ + +void push_indice_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ + Word16 id, /* i : ID of the indice */ + UWord16 value, /* i : value of the quantized indice */ + Word16 nb_bits /* i : number of bits used to quantize the indice */ +) +{ + Word16 i; + + + IF(EQ_16(hBstr->last_ind_fx, id)) + { + /* indice with the same name as the previous one */ + i = hBstr->next_ind_fx; + } + ELSE + { + /* new indice - find an empty slot in the list */ + i = id; + move16(); + WHILE(NE_16(hBstr->ind_list_fx[i].nb_bits, -1)) + { + i = add(i, 1); + } + } + + /* store the values in the list */ + hBstr->ind_list_fx[i].value = value; + move16(); + hBstr->ind_list_fx[i].nb_bits = nb_bits; + move16(); + + /* updates */ + hBstr->next_ind_fx = add(i, 1); + hBstr->last_ind_fx = id; + move16(); + hBstr->nb_bits_tot_fx = add(hBstr->nb_bits_tot_fx, nb_bits); + + return; +} + +/*-------------------------------------------------------------------* + * push_next_indice_fx() * + * Push a new indice into the buffer at the next position + *-------------------------------------------------------------------*/ + +void push_next_indice_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ + UWord16 value, /* i : value of the quantized indice */ + Word16 nb_bits /* i : number of bits used to quantize the indice */ +) +{ + + /* store the values in the list */ + hBstr->ind_list_fx[hBstr->next_ind_fx].value = value; + move16(); + hBstr->ind_list_fx[hBstr->next_ind_fx].nb_bits = nb_bits; + move16(); + hBstr->next_ind_fx = add(hBstr->next_ind_fx, 1); + + + /* update the total number of bits already written */ + hBstr->nb_bits_tot_fx = add(hBstr->nb_bits_tot_fx, nb_bits); + + return; +} + + +/*-------------------------------------------------------------------* + * push_next_bits_fx() + * Push a bit buffer into the buffer at the next position + *-------------------------------------------------------------------*/ + +void push_next_bits_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ + Word16 bits[], /* i : bit buffer to pack, sequence of single bits */ + Word16 nb_bits /* i : number of bits to pack */ +) +{ + UWord16 code; + Word16 i, nb_bits_m15; + Indice *ptr; + + ptr = &hBstr->ind_list_fx[hBstr->next_ind_fx]; + nb_bits_m15 = sub(nb_bits, 15); + i = 0; + move16(); + IF(nb_bits_m15 > 0) + { + FOR(; i < nb_bits_m15; i += 16) + { + code = s_or(lshl(bits[i], 15), s_or(lshl(bits[i + 1], 14), s_or(lshl(bits[i + 2], 13), s_or(lshl(bits[i + 3], 12), + s_or(lshl(bits[i + 4], 11), s_or(lshl(bits[i + 5], 10), s_or(lshl(bits[i + 6], 9), s_or(lshl(bits[i + 7], 8), + s_or(lshl(bits[i + 8], 7), s_or(lshl(bits[i + 9], 6), s_or(lshl(bits[i + 10], 5), s_or(lshl(bits[i + 11], 4), + s_or(lshl(bits[i + 12], 3), s_or(lshl(bits[i + 13], 2), s_or(lshl(bits[i + 14], 1), bits[i + 15]))))))))))))))); + + ptr->value = code; + move16(); + ptr->nb_bits = 16; + move16(); + ++ptr; + } + } + IF(LT_16(i, nb_bits)) + { + FOR(; i < nb_bits; ++i) + { + ptr->value = bits[i]; + move16(); + ptr->nb_bits = 1; + move16(); + ++ptr; + } + } + hBstr->next_ind_fx = (Word16)(ptr - hBstr->ind_list_fx); + hBstr->nb_bits_tot_fx = add(hBstr->nb_bits_tot_fx, nb_bits); +} + +/*-------------------------------------------------------------------* + * get_next_indice_fx( ) + * + * Get the next indice from the buffer + *-------------------------------------------------------------------*/ + +UWord16 get_next_indice_fx( /* o : value of the indice */ + Decoder_State_fx *st_fx, /* i/o: decoder state structure */ + Word16 nb_bits /* i : number of bits that were used to quantize the indice */ +) +{ + UWord16 value; + Word16 i; + + assert(nb_bits <= 16); + value = 0; + move16(); + + /* detect corrupted bitstream */ + IF(GT_16(add(st_fx->next_bit_pos_fx, nb_bits), st_fx->total_num_bits)) + { + st_fx->BER_detect = 1; + move16(); + return(0); + } + + FOR(i = 0; i < nb_bits; i++) + { + value = lshl(value, 1); + value = add(value, st_fx->bit_stream_fx[st_fx->next_bit_pos_fx + i]); + } + + /* update the position in the bitstream */ + st_fx->next_bit_pos_fx = add(st_fx->next_bit_pos_fx, nb_bits); + return value; +} + +/*-------------------------------------------------------------------* + * get_next_indice_1_fx( ) + * + * Get the next 1-bit indice from the buffer + *-------------------------------------------------------------------*/ + +UWord16 get_next_indice_1_fx( /* o : value of the indice */ + Decoder_State_fx *st_fx /* i/o: decoder state structure */ +) +{ + /* detect corrupted bitstream */ + test(); + test(); + test(); + IF((GT_16(add(st_fx->next_bit_pos_fx, 1), st_fx->total_num_bits) && EQ_16(st_fx->codec_mode, MODE1)) || + (GT_16(add(st_fx->next_bit_pos_fx, 1), add(st_fx->total_num_bits, 2 * 8)) && EQ_16(st_fx->codec_mode, MODE2)) /* add two zero bytes for arithmetic coder flush */ + ) + { + st_fx->BER_detect = 1; + move16(); + return(0); + } + + return st_fx->bit_stream_fx[st_fx->next_bit_pos_fx++]; +} + +/*-------------------------------------------------------------------* + * get_next_indice_tmp() + * + * update the total number of bits and the position in the bitstream + *-------------------------------------------------------------------*/ + +void get_next_indice_tmp_fx( + Decoder_State_fx *st_fx, /* o : decoder state structure */ + Word16 nb_bits /* i : number of bits that were used to quantize the indice */ +) +{ + /* update the position in the bitstream */ + st_fx->next_bit_pos_fx = add(st_fx->next_bit_pos_fx, nb_bits); +} + +/*-------------------------------------------------------------------* + * get_indice_fx( ) + * + * Get indice at specific position in the buffer + *-------------------------------------------------------------------*/ + +UWord16 get_indice_fx( /* o : value of the indice */ + Decoder_State_fx *st_fx, /* i/o: decoder state structure */ + Word16 pos, /* i : absolute position in the bitstream (update after the read) */ + Word16 nb_bits /* i : number of bits that were used to quantize the indice */ +) +{ + UWord16 value; + Word16 i; + + assert(nb_bits <= 16); + + /* detect corrupted bitstream */ + IF(GT_16(add(pos, nb_bits), st_fx->total_num_bits)) + { + st_fx->BER_detect = 1; + move16(); + return(0); + } + + value = 0; + move16(); + FOR(i = 0; i < nb_bits; i++) + { + value = lshl(value, 1); + value = add(value, st_fx->bit_stream_fx[pos + i]); + } + + return value; +} + +/*-------------------------------------------------------------------* + * get_indice_1_fx( ) + * + * Get a 1-bit indice at specific position in the buffer + *-------------------------------------------------------------------*/ + +UWord16 get_indice_1_fx( /* o : value of the indice */ + Decoder_State_fx *st_fx, /* i/o: decoder state structure */ + Word16 pos /* i : absolute position in the bitstream (update after the read) */ +) +{ + /* detect corrupted bitstream */ + IF(GT_16(add(pos, 1), st_fx->total_num_bits)) + { + st_fx->BER_detect = 1; + move16(); + return(0); + } + + return st_fx->bit_stream_fx[pos]; +} + +/*-------------------------------------------------------------------* + * reset_indices_enc_fx() + * + * Reset the buffer of indices + *-------------------------------------------------------------------*/ + +void reset_indices_enc_fx( + BSTR_ENC_HANDLE hBstr /* i/o: encoder state structure */ +) +{ + Word16 i; + + hBstr->nb_bits_tot_fx = 0; + move16(); + hBstr->next_ind_fx = 0; + move16(); + hBstr->last_ind_fx = -1; + move16(); + + FOR(i = 0; i < MAX_NUM_INDICES; i++) + { + hBstr->ind_list_fx[i].nb_bits = -1; + move16(); + } + + return; +} + +/*-------------------------------------------------------------------* + * reset_indices_dec_fx() + * + * Reset the buffer of decoder indices + *-------------------------------------------------------------------*/ + +void reset_indices_dec_fx( + Decoder_State_fx *st_fx +) +{ + st_fx->next_bit_pos_fx = 0; + move16(); + + return; +} + + +/*-------------------------------------------------------------------* + * write_indices_fx() + * + * Write the buffer of indices to a file + *-------------------------------------------------------------------*/ + +void write_indices_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ + FILE *file /* i : output bitstream file */ + , UWord8 *pFrame, /* i: byte array with bit packet and byte aligned coded speech data */ + Word16 pFrame_size /* i: size of the binary encoded access unit [bits] */ +) +{ + Word16 i, k; + Word16 stream[2 + MAX_BITS_PER_FRAME], *pt_stream; + Word32 mask; + UWord8 header; + Word16 isAmrWb = 0; + + if (st_fx->bitstreamformat == G192) + { + /*-----------------------------------------------------------------* + * Encode Sync Header and Frame Length + *-----------------------------------------------------------------*/ + pt_stream = stream; + for (i = 0; i < (2 + MAX_BITS_PER_FRAME); ++i) + { + stream[i] = 0; + } + *pt_stream++ = (Word16)SYNC_GOOD_FRAME; + *pt_stream++ = hBstr->nb_bits_tot_fx; + + /*----------------------------------------------------------------* + * Bitstream packing (conversion of individual indices into a serial stream) + * Writing the serial stream into file + *----------------------------------------------------------------*/ + + for (i = 0; i < MAX_NUM_INDICES; i++) + { + if (hBstr->ind_list_fx[i].nb_bits != -1) + { + /* mask from MSB to LSB */ + mask = 1 << (hBstr->ind_list_fx[i].nb_bits - 1); + + /* write bit by bit */ + for (k = 0; k < hBstr->ind_list_fx[i].nb_bits; k++) + { + if (hBstr->ind_list_fx[i].value & mask) + { + *pt_stream++ = G192_BIN1; + } + else + { + *pt_stream++ = G192_BIN0; + } + + mask >>= 1; + } + } + } + + } + else + { + /* Create and write ToC header */ + /* qbit always set to 1 on encoder side for AMRWBIO , no qbit in use for EVS, but set to 0(bad) */ + header = (UWord8)(st_fx->Opt_AMR_WB << 5 | st_fx->Opt_AMR_WB << 4 | rate2EVSmode(hBstr->nb_bits_tot_fx * 50, &isAmrWb)); + fwrite(&header, sizeof(UWord8), 1, file); + /* Write speech bits */ + fwrite(pFrame, sizeof(UWord8), (pFrame_size + 7) >> 3, file); + } + + /* Clearing of indices */ + FOR(i = 0; i < MAX_NUM_INDICES; i++) + { + hBstr->ind_list_fx[i].nb_bits = -1; + move16(); + } + + + if (st_fx->bitstreamformat == G192) + { + /* write the serial stream into file */ + fwrite(stream, sizeof(unsigned short), 2 + stream[1], file); + } + /* reset index pointers */ + hBstr->nb_bits_tot_fx = 0; + hBstr->next_ind_fx = 0; + hBstr->last_ind_fx = -1; + + return; +} + +/*-------------------------------------------------------------------* + * indices_to_serial() + * + * pack indices into serialized payload format + *-------------------------------------------------------------------*/ + +void indices_to_serial( + const Encoder_State *st_fx, /* i: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ + UWord8 *pFrame, /* o: byte array with bit packet and byte aligned coded speech data */ + Word16 *pFrame_size /* o: size of the binary encoded access unit [bits] */ +) +{ + Word16 i, k, j; + Word16 cmi = 0, core_mode = 0; + Word32 mask; + Word16 amrwb_bits[(ACELP_23k85 / 50)]; + UWord8 omask = 0x80; + UWord8 *pt_pFrame = pFrame; + Word16 isAmrWb = 0; + + if (st_fx->Opt_AMR_WB) + { + cmi = rate2EVSmode(st_fx->total_brate, &isAmrWb); + core_mode = rate2EVSmode(hBstr->nb_bits_tot_fx * 50, &isAmrWb); + + j = 0; + for (i = 0; i < MAX_NUM_INDICES; i++) + { + if (hBstr->ind_list_fx[i].nb_bits != -1) + { + /* mask from MSB to LSB */ + mask = 1 << (hBstr->ind_list_fx[i].nb_bits - 1); + + /* temporarily save bit */ + for (k = 0; k < hBstr->ind_list_fx[i].nb_bits; k++) + { + amrwb_bits[j++] = (hBstr->ind_list_fx[i].value & mask) > 0; + mask >>= 1; + } + } + } + } + + *pFrame_size = hBstr->nb_bits_tot_fx; + + /*----------------------------------------------------------------* + * Bitstream packing (conversion of individual indices into a serial stream) + *----------------------------------------------------------------*/ + j = 0; + for (i = 0; i < MAX_NUM_INDICES; i++) + { + if (hBstr->ind_list_fx[i].nb_bits != -1) + { + /* mask from MSB to LSB */ + mask = 1 << (hBstr->ind_list_fx[i].nb_bits - 1); + + /* write bit by bit */ + for (k = 0; k < hBstr->ind_list_fx[i].nb_bits; k++) + { + if (st_fx->Opt_AMR_WB) + { + pack_bit(amrwb_bits[sort_ptr[core_mode][j++]], &pt_pFrame, &omask); + } + else + { + pack_bit(hBstr->ind_list_fx[i].value & mask, &pt_pFrame, &omask); + j++; + } + mask >>= 1; + } + } + } + + if (st_fx->Opt_AMR_WB && core_mode == AMRWB_IO_SID) /* SID UPD frame always written now .... */ + { + /* insert STI bit and CMI */ + pack_bit(1, &pt_pFrame, &omask); + for (mask = 0x08; mask > 0; mask >>= 1) + { + pack_bit(cmi & mask, &pt_pFrame, &omask); + } + } +} + + +/*-------------------------------------------------------------------* + * indices_to_serial_generic() + * + * pack indices into serialized payload format + *-------------------------------------------------------------------*/ + +void indices_to_serial_generic( + const Indice *ind_list, /* i: indices list */ + const Word16 num_indices, /* i: number of indices to write */ + UWord8 *pFrame, /* o: byte array with bit packet and byte aligned coded speech data */ + Word16 *pFrame_size /* i/o: number of bits in the binary encoded access unit [bits] */ +) +{ + Word16 i, k, j; + Word32 mask; + UWord8 omask; + UWord8 *pt_pFrame = pFrame; + Word16 nb_bits_tot; + + nb_bits_tot = 0; + move16(); + omask = (0x80 >> (*pFrame_size & 0x7)); + pt_pFrame += shr(*pFrame_size, 3); + + /*----------------------------------------------------------------* + * Bitstream packing (conversion of individual indices into a serial stream) + *----------------------------------------------------------------*/ + j = 0; + move16(); + for (i = 0; i < num_indices; i++) + { + if (ind_list[i].nb_bits != -1) + { + /* mask from MSB to LSB */ + mask = 1 << (ind_list[i].nb_bits - 1); + + /* write bit by bit */ + for (k = 0; k < ind_list[i].nb_bits; k++) + { + pack_bit(ind_list[i].value & mask, &pt_pFrame, &omask); + j++; + mask >>= 1; + } + nb_bits_tot = add(nb_bits_tot, ind_list[i].nb_bits); + } + } + + *pFrame_size = add(*pFrame_size, nb_bits_tot); + + return; +} + + +static void decoder_selectCodec( + Decoder_State_fx *st, /* i/o: decoder state structure */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 bit0 +) +{ + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + /* check if we are in AMR-WB IO mode */ + IF(EQ_32(total_brate, SID_1k75) || + EQ_32(total_brate, ACELP_6k60) || EQ_32(total_brate, ACELP_8k85) || EQ_32(total_brate, ACELP_12k65) || + EQ_32(total_brate, ACELP_14k25) || EQ_32(total_brate, ACELP_15k85) || EQ_32(total_brate, ACELP_18k25) || + EQ_32(total_brate, ACELP_19k85) || EQ_32(total_brate, ACELP_23k05) || EQ_32(total_brate, ACELP_23k85)) + { + st->Opt_AMR_WB_fx = 1; + move16(); + } + ELSE IF(NE_32(total_brate, FRAME_NO_DATA)) + { + st->Opt_AMR_WB_fx = 0; + move16(); + } + + /* select MODE1 or MODE2 */ + IF(st->Opt_AMR_WB_fx) + { + st->codec_mode = MODE1; + move16();/**/ + } + ELSE + { + SWITCH(total_brate) + { + case 0: + st->codec_mode = st->last_codec_mode; + move16(); + BREAK; + case 2400: + st->codec_mode = st->last_codec_mode; + move16(); + BREAK; + case 2800: + st->codec_mode = MODE1; + move16(); + BREAK; + case 7200: + st->codec_mode = MODE1; + move16(); + BREAK; + case 8000: + st->codec_mode = MODE1; + move16(); + BREAK; + case 9600: + st->codec_mode = MODE2; + move16(); + BREAK; + case 13200: + st->codec_mode = MODE1; + move16(); + BREAK; + case 16400: + st->codec_mode = MODE2; + move16(); + BREAK; + case 24400: + st->codec_mode = MODE2; + move16(); + BREAK; + case 32000: + st->codec_mode = MODE1; + move16(); + BREAK; + case 48000: + st->codec_mode = MODE2; + move16(); + BREAK; + case 64000: + st->codec_mode = MODE1; + move16(); + BREAK; + case 96000: + st->codec_mode = MODE2; + move16(); + BREAK; + case 128000: + st->codec_mode = MODE2; + move16(); + BREAK; + default: + /* validate that total_brate (derived from RTP packet or a file header) is one of the defined bit rates */ + st->codec_mode = st->last_codec_mode; + st->bfi_fx = 1; + move16(); + move16(); + BREAK; + } + } + + IF(st->ini_frame_fx == 0) + { + IF(EQ_16(st->codec_mode, -1)) + { + st->codec_mode = MODE1; + move16(); + } + st->last_codec_mode = st->codec_mode; + move16(); + } + + /* set SID/CNG type */ + IF(EQ_32(total_brate, SID_2k40)) + { + IF(bit0 == G192_BIN0) + { + st->cng_type_fx = LP_CNG; + move16(); + + /* force MODE1 when selecting LP_CNG */ + st->codec_mode = MODE1; + move16(); + } + ELSE + { + st->cng_type_fx = FD_CNG; + test(); + if (EQ_16(st->last_codec_mode, MODE2) && EQ_32(st->last_total_brate_fx,13200)) + { + st->codec_mode = MODE1; + move16(); + } + } + st->hTdCngDec->last_cng_type_fx = st->cng_type_fx; /* CNG type switching at the first correctly received SID frame */ + } + + + return; +} + + + + +void dec_prm_core(Decoder_State_fx *st) +{ + Word16 n, frame_size_index, num_bits; + UWord16 lsb; + Word32 L_tmp; + + frame_size_index = -1; + move16(); + st->core_fx = -1; + move16(); + + IF(EQ_32(st->total_brate_fx, FRAME_NO_DATA)) + { + st->m_frame_type = ZERO_FRAME; + move16(); + } + ELSE IF(EQ_32(st->total_brate_fx, SID_2k40)) + { + st->m_frame_type = SID_FRAME; + move16(); + } + ELSE + { + st->m_frame_type = ACTIVE_FRAME; + move16(); + Mpy_32_16_ss(st->total_brate_fx, 5243, &L_tmp, &lsb); /* 5243 is 1/50 in Q18. (0+18-15=3) */ + num_bits = extract_l(L_shr(L_tmp, 3)); /* Q0 */ + assert(num_bits == st->total_brate_fx / 50); + FOR(n = 0; n < FRAME_SIZE_NB; ++n) + { + IF(EQ_16(FrameSizeConfig[n].frame_bits, num_bits)) + { + frame_size_index = n; + move16(); + BREAK; + } + } + + /* Get bandwidth mode */ + st->bwidth_fx = get_next_indice_fx(st, FrameSizeConfig[frame_size_index].bandwidth_bits); + + st->bwidth_fx = add(st->bwidth_fx, FrameSizeConfig[frame_size_index].bandwidth_min); + + if (GT_16(st->bwidth_fx, FB)) + { + st->bwidth_fx = FB; + move16(); + st->BER_detect = 1; + move16(); + } + + if (GT_16(st->bwidth_fx, SWB) && LT_32(st->total_brate_fx,ACELP_16k40)) + { + st->bwidth_fx = SWB; + move16(); + st->BER_detect = 1; + move16(); + } + + /* Skip reserved bit */ + get_next_indice_tmp_fx(st, FrameSizeConfig[frame_size_index].reserved_bits); + + IF(get_next_indice_1_fx(st) != 0) /* TCX */ + { + st->core_fx = TCX_20_CORE; + move16(); + if (get_next_indice_1_fx(st) != 0) + { + st->core_fx = HQ_CORE; + move16(); + } + } + ELSE /* ACELP */ + { + st->core_fx = ACELP_CORE; + move16(); + } + } +} + +/*-----------------------------------------------------------------* + * decision_matrix_core_dec() + * + * Read core mode signalling bits from the bitstream + * Set st->core, and st->bwidth if signalled together with the core. + *-----------------------------------------------------------------*/ + +void decision_matrix_core_dec( + Decoder_State_fx *st /* i/o: decoder state structure */ +) +{ + Word16 start_idx; + Word32 ind; + Word16 nBits; + + assert(st->bfi_fx != 1); + + st->core_fx = -1; + move16(); + st->bwidth_fx = -1; + move16(); + + test(); + IF(EQ_32(st->total_brate_fx, FRAME_NO_DATA) || EQ_32(st->total_brate_fx, SID_2k40)) + { + st->core_fx = ACELP_CORE; + move16(); + } + /* SC-VBR */ + ELSE IF(st->total_brate_fx == PPP_NELP_2k80) + { + st->core_fx = ACELP_CORE; + move16(); + return; + } + + /*---------------------------------------------------------------------* + * ACELP/HQ core selection + *---------------------------------------------------------------------*/ + + test(); + IF(LT_32(st->total_brate_fx, ACELP_24k40)) + { + st->core_fx = ACELP_CORE; + move16(); + } + ELSE IF(GE_32(st->total_brate_fx, ACELP_24k40) && LE_32(st->total_brate_fx, ACELP_64k)) + { + /* read the ACELP/HQ core selection bit */ + st->core_fx = imult1616(get_next_indice_fx(st, 1), HQ_CORE); + } + ELSE + { + st->core_fx = HQ_CORE; + move16(); + } + + /*-----------------------------------------------------------------* + * Read ACELP signalling bits from the bitstream + *-----------------------------------------------------------------*/ + + IF(EQ_16(st->core_fx, ACELP_CORE)) + { + /* find the section in the ACELP signalling table corresponding to bitrate */ + start_idx = 0; + move16(); + WHILE(NE_32(acelp_sig_tbl[start_idx], st->total_brate_fx)) + { + start_idx = add(start_idx, 1); + } + + /* skip the bitrate */ + start_idx = add(start_idx, 1); + + /* retrieve the number of bits */ + nBits = extract_l(acelp_sig_tbl[start_idx]); + start_idx = add(start_idx, 1); + + /* retrieve the signalling indice */ + ind = acelp_sig_tbl[add(start_idx, get_next_indice_fx(st, nBits))]; + st->bwidth_fx = extract_l(L_and(L_shr(ind, 3), 0x7)); + + /* convert signalling indice into signalling information */ + if (EQ_32(L_and(ind, 0x7), LR_MDCT)) + { + st->core_fx = HQ_CORE; + move16(); + } + } + + /*-----------------------------------------------------------------* + * Read HQ signalling bits from the bitstream + * Set HQ core type + *-----------------------------------------------------------------*/ + + IF(EQ_16(st->core_fx, HQ_CORE)) + { + /* read the HQ/TCX core switching flag */ + if (get_next_indice_fx(st, 1) != 0) + { + st->core_fx = TCX_20_CORE; + move16(); + } + + /* For TCX: read/set band-width (needed for different I/O sampling rate support) */ + test(); + IF(EQ_16(st->core_fx, TCX_20_CORE) && GT_32(st->total_brate_fx, ACELP_16k40)) + { + ind = get_next_indice_fx(st, 2); + + IF(ind == 0) + { + st->bwidth_fx = NB; + move16(); + } + ELSE IF(EQ_32(ind, 1)) + { + st->bwidth_fx = WB; + move16(); + } + ELSE IF(EQ_32(ind, 2)) + { + st->bwidth_fx = SWB; + move16(); + } + ELSE + { + st->bwidth_fx = FB; + move16(); + } + } + } + + return; +} + +/*-------------------------------------------------------------------* + * mdct_switching_dec() + * + * Set up MDCT core switching if indicated in the bit stream + *-------------------------------------------------------------------*/ + +static void mdct_switching_dec( + Decoder_State_fx *st /* i/o: decoder state structure */ +) +{ + IF(st->Opt_AMR_WB_fx != 0) + { + return; + } + + test(); + test(); + IF(EQ_32(st->total_brate_fx, ACELP_13k20) || EQ_32(st->total_brate_fx, ACELP_32k)) + { + st->mdct_sw_enable = MODE1; + move16(); + } + ELSE IF(LE_32(ACELP_16k40, st->total_brate_fx) && LE_32(st->total_brate_fx, ACELP_24k40)) + { + st->mdct_sw_enable = MODE2; + move16(); + } + + test(); + test(); + IF(EQ_16(st->codec_mode, MODE1) && EQ_16(st->mdct_sw_enable, MODE1)) + { + /* Read ahead core mode signaling */ + Word16 next_bit_pos_save; + Word16 core_save; + Word16 bwidth_save; + + next_bit_pos_save = st->next_bit_pos_fx; + move16(); + core_save = st->core_fx; + move16(); + bwidth_save = st->bwidth_fx; + move16(); + + decision_matrix_core_dec(st); /* sets st->core */ + + IF(EQ_16(st->core_fx, TCX_20_CORE)) + { + /* Trigger TCX */ + st->codec_mode = MODE2; + move16(); + st->mdct_sw = MODE1; + move16(); + } + ELSE + { + /* Rewind bitstream */ + st->next_bit_pos_fx = next_bit_pos_save; + move16(); + IF(st->bfi_fx != 0) + { + st->core_fx = core_save; + move16(); + st->bwidth_fx = bwidth_save; + move16(); + } + } + } + ELSE IF(EQ_16(st->codec_mode, MODE2) && EQ_16(st->mdct_sw_enable, MODE2)) + { + /* Read ahead core mode signaling */ + Word16 next_bit_pos_save; + Word16 core_save; + Word16 bwidth_save; + + next_bit_pos_save = st->next_bit_pos_fx; + move16(); + core_save = st->core_fx; + move16(); + bwidth_save = st->bwidth_fx; + move16(); + + dec_prm_core(st); /* sets st->core */ + + IF(EQ_16(st->core_fx, HQ_CORE)) + { + /* Trigger HQ_CORE */ + st->codec_mode = MODE1; + move16(); + st->mdct_sw = MODE2; + move16(); + } + ELSE + { + /* Rewind bitstream */ + st->next_bit_pos_fx = next_bit_pos_save; + move16(); + IF(st->bfi_fx != 0) + { + st->core_fx = core_save; + move16(); + } + /* always reset bwidth, to not interfere with BER logic */ + st->bwidth_fx = bwidth_save; + move16(); + } + } +} + +/*-------------------------------------------------------------------* + * BRATE2IDX_fx() + * + * Convert Bitrate to Index Value + *-------------------------------------------------------------------*/ + +Word16 BRATE2IDX_fx(Word32 brate) +{ + + Word32 L_temp; + Word32 L_idx; +#define START 9 + extern const Word16 bit_rates_div50[]; + + /* This is a Fast Bit Rate Value to Index Value Binary Search */ + L_temp = L_msu0(brate, bit_rates_div50[START], 50); + L_temp = L_min(6, L_max(-6, L_temp)); + L_idx = L_add(L_temp, START); + L_temp = L_msu0(brate, bit_rates_div50[L_idx], 50); + L_temp = L_min(3, L_max(-3, L_temp)); + L_idx = L_add(L_temp, L_idx); + L_temp = L_msu0(brate, bit_rates_div50[L_idx], 50); + L_temp = L_min(1, L_max(-2, L_temp)); + L_idx = L_add(L_temp, L_idx); + L_temp = L_msu0(brate, bit_rates_div50[L_idx], 50); + if (L_temp != 0) L_idx = L_add(L_idx, 1); + return (Word16)L_idx; +} + + +/*-------------------------------------------------------------------* + * BRATE2IDX16k_fx() + * + * Convert Bitrate to Index Value + *-------------------------------------------------------------------*/ + +Word16 BRATE2IDX16k_fx(Word32 brate) +{ + Word32 L_temp, L_idx; +#define START_16K 5 + extern const Word16 bit_rates_16k_div50[]; + + if (EQ_32(brate, ACELP_16k40)) + { + brate = ACELP_14k80; + } + + /* This is a Fast Bit Rate Value to Index Value Binary Search */ + L_temp = L_msu0(brate, bit_rates_16k_div50[START_16K], 50); + L_temp = L_min(3, L_max(-3, L_temp)); + L_idx = L_add(L_temp, START_16K); + L_temp = L_msu0(brate, bit_rates_16k_div50[L_idx], 50); + L_temp = L_min(2, L_max(-2, L_temp)); + L_idx = L_add(L_temp, L_idx); + L_temp = L_msu0(brate, bit_rates_16k_div50[L_idx], 50); + L_temp = L_min(1, L_max(-1, L_temp)); + L_idx = L_add(L_temp, L_idx); + + return (Word16)L_idx; +} + +/*-------------------------------------------------------------------* + * BIT_ALLOC_IDX_fx() + *-------------------------------------------------------------------*/ + +Word32 BIT_ALLOC_IDX_fx(Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc) +{ + Word32 L_temp; + Word16 temp; + if (ctype == INACTIVE) /* no sub(ctype, INACTIVE) because it is '0' */ + ctype = GENERIC; + move16(); + L_temp = L_mac0(-1l * 256, 1 * 256, ctype); + + temp = BRATE2IDX_fx(brate); + L_temp = L_mac0(L_temp, 4 * 256, temp); + if (tc >= 0) + L_temp = L_mac0(L_temp, (10 - 4) * 256, temp); + /* So either 'temp' x 4 when 'tc < 0', 'temp' x 10 otherwise */ + + L_temp = L_mac0(L_temp, 1 * 256, s_max(0, tc)); + + L_temp = L_mac0(L_temp, s_max(0, sfrm), 1); + if (sfrm < 0) + L_temp = L_shr(L_temp, 2); + L_temp = L_shr(L_temp, 6); + + return L_temp; +} + +/*-------------------------------------------------------------------* + * BIT_ALLOC_IDX_16KHZ_fx() + *-------------------------------------------------------------------*/ + +Word32 BIT_ALLOC_IDX_16KHZ_fx(Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc) +{ + Word32 L_temp; + Word16 temp; + /* 'ctype' = + TRANSITION => 2 + GENERIC => 1 + ALL Other => 0 + */ + L_temp = L_and(shr(0x0240l, shl(ctype, 1)), 3); + + temp = BRATE2IDX16k_fx(brate); + L_temp = L_mac0(L_temp, 3, temp); + if (tc >= 0) + L_temp = L_mac0(L_temp, (7 - 3), temp); + /* So either 'temp' x 3 when 'tc < 0', 'temp' x 7 otherwise */ + + L_temp = L_mac0(L_temp, 1, s_max(0, tc)); + + IF(sfrm >= 0) + { + /* Mult by 5 */ + L_temp = L_add(L_temp, L_shl(L_temp, 2)); + L_temp = L_mac0(L_temp, shr(sfrm, 6), 1); + } + + return L_temp; +} + + +/*-------------------------------------------------------------------* + * read_indices_fx() + * + * Read indices from an ITU-T G.192 bitstream to the buffer + * Simulate packet losses by inserting frame erasures + *-------------------------------------------------------------------*/ + +Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem */ + Decoder_State_fx *st, /* i/o: decoder state structure */ + FILE *file, /* i : bitstream file */ + Word16 rew_flag /* i : rewind flag (rewind file after reading)*/ +) +{ + Word16 k; + UWord16 utmp, stream[2 + MAX_BITS_PER_FRAME], *pt_stream, *bit_stream_ptr; + Word16 num_bits; + Word32 total_brate; + Word32 L_tmp; + Word16 curr_ft_good_sp, curr_ft_bad_sp; + Word16 g192_sid_first, sid_upd_bad, sid_update; + Word16 speech_bad, speech_lost; + Word16 num_bits_read; + + st->bfi_fx = 0; + st->BER_detect = 0; + st->mdct_sw_enable = 0; + st->mdct_sw = 0; + reset_indices_dec_fx(st); + + /* read the Sync Header field from the bitstream */ + /* in case rew_flag is set, read until first good frame is encountered */ + do + { + /* read the Sync header */ + if (fread(&utmp, sizeof(unsigned short), 1, file) != 1) + { + if (ferror(file)) + { + /* error during reading */ + fprintf(stderr, "\nError reading the bitstream !"); + exit(-1); + } + else + { + /* end of file reached */ + return 0; + } + } + + /* set the BFI indicator according the value of Sync Header */ + if (EQ_16(utmp, SYNC_BAD_FRAME)) + { + st->bfi_fx = 1; + } + + + else + { + st->bfi_fx = 0; + } + + /* read the Frame Length field from the bitstream */ + if (fread(&num_bits, sizeof(unsigned short), 1, file) != 1) + { + if (ferror(file)) + { + /* error during reading */ + fprintf(stderr, "\nError reading the bitstream !"); + exit(-1); + } + else + { + /* end of file reached */ + return 0; + } + } + /* convert the frame length to total bitrate */ + total_brate = (long)(num_bits * 50); + + /* read ITU-T G.192 serial stream of indices from file to the local buffer */ + /* Validate that the G.192 length is within the defined bit rate range + to not allow writing past the end of the "stream" buffer */ + if (num_bits > MAX_BITS_PER_FRAME) + { + fprintf(stderr, "\nError, too large G.192 frame (size(%d))! Exiting ! \n", num_bits); + exit(-1); + } + + /* verify that a valid num bits value is present in the G.192 file */ + /* only AMRWB or EVS bit rates or 0(NO DATA) are allowed in G.192 file frame reading */ + if (rate2EVSmode(total_brate, NULL) < 0) /* negative value means that a valid rate was not found */ + { + fprintf(stderr, "\nError, illegal bit rate (%d) in the G.192 frame ! Exiting ! \n", total_brate); + exit(-1); + } + pt_stream = stream; + + num_bits_read = (Word16)fread(pt_stream, sizeof(unsigned short), num_bits, file); + + if (num_bits_read != num_bits) + { + fprintf(stderr, "\nError, invalid number of bits read ! Exiting ! \n"); + exit(-1); + } + + } while (rew_flag && (st->bfi_fx || LT_32(total_brate, 2800))); + + /* G.192 RX DTX handler*/ + if (!rew_flag) + { + /* handle SID_FIRST, SID_BAD, SPEECH_LOST, NO_DATA as properly as possible for the ITU-T G.192 format */ + + /* (total_brate, bfi , st_CNG) = rx_handler(received frame type, [previous frame type], past CNG state, past core) */ + curr_ft_good_sp = 0; + curr_ft_bad_sp = 0; + + if (total_brate > SID_2k40) + { + if (st->bfi_fx == 0) + { + curr_ft_good_sp = 1; + } + else + { + curr_ft_bad_sp = 1; + } + } + sid_update = 0; + sid_upd_bad = 0; + + if (total_brate == SID_1k75 || total_brate == SID_2k40) + { + if (st->bfi_fx == 0) + { + sid_update = 1; + } + else + { + sid_upd_bad = 1; /* may happen in CS , corrupt but detected sid frame */ + } + } + + /* all zero indeces/bits iSP AMRWB SID_update results in a valid LP filter with extremely high LP-filter-gain */ + /* all zero indeces/bits may be a result of CS bit errors and/or erroneously injected by gateways or by a bad dejitter handlers */ + if (total_brate == SID_1k75 && sid_update == 1) + { + /* valid sid_update received, check for very risky but formally valid content */ + Word16 sum = 0; + for (k = 0; k < num_bits; ++k) + { + sum += (pt_stream[k] == G192_BIN1);/* check of 35 zeroes, 35 ones */ + } + if (sum == 0) + { /* all zeros */ + sid_upd_bad = 1; /* initial signal as corrupt (BER likley) */ + } + } + + /* AMRWB 26.173 G.192 file reader (read_serial) does not declare/use SID_BAD ft, + it declares every bad synch marked frame initially as a lost_speech frame, + and then the RXDTX handler CNG state decides the decoding mode CNG/SPEECH. + While In the AMRWB ETSI/3GPP format eid a CRC error in a detected SID_UPDATE frame triggers SID_UPD_BAD. + + Here we inhibit use of the SID-length info, even though it is available in the G.192 file format after STL/EID-XOR . + */ + if (sid_upd_bad) + { + sid_upd_bad = 0; + total_brate = FRAME_NO_DATA; /* treat SID_BAD as a stolen signaling frame --> SPEECH LOST */ + + } + + g192_sid_first = 0; + if (st->core_fx == AMR_WB_CORE && st->prev_ft_speech_fx && total_brate == FRAME_NO_DATA && st->bfi_fx == 0) + { + g192_sid_first = 1; /* SID_FIRST detected for previous AMRWB/AMRWBIO active frames only */ + /* + It is not possible to perfectly simulate rate switching conditions EVS->AMRWBIO where: + the very first SID_FIRST detection is based on a past EVS active frame + and a good length 0 "SID_FIRST"(NO_DATA) frame is sent in AMRWBIO, + , due to the one frame state memory in the AMRWB legacy G.192 SID_FIRST encoding + */ + } + + speech_bad = 0; + if (total_brate > SID_2k40 && st->bfi_fx != 0) /* CS-type of CRC failure frame */ + { + speech_bad = 1; /* initial assumption, CNG_state decides what to do */ + } + + speech_lost = 0; + if (total_brate == 0 && st->bfi_fx != 0) /* unsent NO_DATA or stolen NO_DATA/signaling frame */ + { + speech_lost = 1; /* initial assumption, CNG_state decides what to do */ + } + + /* Do not allow decoder to enter CNG-synthesis for any instantly received GOOD+LENGTH==0 frame + as this frame was never transmitted, one can not know it is good and has a a length of zero ) */ + + if (st->CNG_fx != 0) + { + /* We were in CNG synthesis */ + if (curr_ft_good_sp != 0) + { + /* only a good speech frame makes you leave CNG synthesis */ + st->CNG_fx = 0; + } + } + else + { + /* We were in SPEECH synthesis */ + /* only a received SID frame can make the decoder enter into CNG synthsis */ + if (g192_sid_first || sid_update || sid_upd_bad) + { + st->CNG_fx = 1; + } + } + + /* handle the g.192 _simulated_ untransmitted frame, setting for decoder SPEECH synthesis */ + if ((st->CNG_fx == 0) && (total_brate == 0 && st->bfi_fx == 0)) + { + st->bfi_fx = 1; + move16(); /* SPEECH PLC code will now become active as in a real system */ + /* total_brate= 0 */ + } + + /* handle bad speech frame(and bad sid frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */ + if (((st->CNG_fx != 0) && ((speech_bad != 0) || (speech_lost != 0))) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ + (sid_upd_bad != 0)) /* SID_UPD_BAD --> start CNG */ + { + st->bfi_fx = 0; + total_brate = 0; + } + /* update for next frame's G.192 file format's SID_FIRST detection (primarily for AMRWBIO) */ + st->prev_ft_speech_fx = ((curr_ft_good_sp != 0) || (curr_ft_bad_sp != 0)); + + /* st->total brate= total_brate ; updated in a good frame below */ + } /* rew_flag */ + + /* get total bit-rate */ +#ifdef DEBUGGING + st->bfi_fx |= file_read_FECpattern(); +#endif + if (st->bfi_fx == 0 && !rew_flag) + { + /* select MODE1 or MODE2 */ + decoder_selectCodec(st, total_brate, *pt_stream); + } + + Mpy_32_16_ss(total_brate, 5243, &L_tmp, &utmp); /* 5243 is 1/50 in Q18. (0+18-15=3) */ + st->total_num_bits = extract_l(L_shr(L_tmp, 3)); /* Q0 */ + + /* in case rew_flag is set, rewind the file and return */ + /* (used in io_enc() to print out info about technologies and to initialize the codec) */ + if (rew_flag) + { + rewind(file); + st->total_brate_fx = total_brate; + move16(); + return 1; + } + + /* GOOD frame */ + if (st->bfi_fx == 0) + { + /* GOOD frame - convert ITU-T G.192 words to short values */ + bit_stream_ptr = st->bit_stream_fx; + + for (k = 0; k < num_bits; ++k) + { + *bit_stream_ptr++ = (*pt_stream++ == G192_BIN1); + } + + /*add two zero bytes for arithmetic coder flush*/ + for (k = 0; k < 2 * 8; ++k) + { + *bit_stream_ptr++ = 0; + } + /*a change of the total bitrate should not be + known to the decoder, if the received frame was lost*/ + st->total_brate_fx = total_brate; + + mdct_switching_dec(st); + } +#ifdef DEBUGGING + else + { + bit_stream_ptr = st->bit_stream_fx; + + for (k = 0; k < num_bits + 2 * 8; ++k) + { + *bit_stream_ptr++ = 0; + } + + } +#endif + return 1; +} + + +/*-------------------------------------------------------------------* + * read_indices_mime_handle_dtx() + * + * Handle DTX for MIME and RTP_DUMP decoding. + * Returns the actual total_brate. + *-------------------------------------------------------------------*/ + +static Word32 read_indices_mime_handle_dtx( + Decoder_State_fx *st, + Word16 isAMRWB_IOmode, + Word16 core_mode, + Word32 total_brate, + Word16 sti, + Word16 speech_lost, + Word16 no_data +) +{ + Word16 curr_ft_good_sp = 0; + Word16 speech_bad = 0; + Word16 sid_upd_bad = 0, sid_update = 0; + Word16 amrwb_sid_first = 0; /* derived from sti SID_FIRST indicator in AMRWB payload */ + + /* keep st->CNG , st_bfi and total_brate updated for proper synthesis in DTX and FER */ + if (GT_32(total_brate, SID_2k40)) + { + if (st->bfi_fx != 1) /* so far derived from q bit in AMRWB/AMRWBIO cases */ + { + curr_ft_good_sp = 1; + } + } + + /* handle q_bit and lost_sp clash , assume worst case */ + if (speech_lost != 0) /* overrides a good q_bit */ + { + curr_ft_good_sp = 0; + st->bfi_fx = 1; /* override qbit */ + } + + /* now_bfi_fx has been set based on q_bit and ToC fields */ + + + /* SID_UPDATE check */ + if (total_brate == SID_1k75 || total_brate == SID_2k40) + { + if (st->bfi_fx == 0) + { + /* typically from q bit */ + sid_update = 1; + } + else + { + sid_upd_bad = 1; /* may happen in saving from e.g. a CS-connection */ + } + } + + if (isAMRWB_IOmode && total_brate == 0 && sti == 0) + { + if (st->bfi_fx) + { + sid_upd_bad = 1; /* corrupt sid_first, signaled as bad sid */ + } + else + { + amrwb_sid_first = 1; /* 1-sti */ + } + } + + if (sid_upd_bad != 0 && ( + (isAMRWB_IOmode != 0 && st->Opt_AMR_WB_fx == 0) || /* switch to AMRWBIO */ + (isAMRWB_IOmode != 1 && st->Opt_AMR_WB_fx == 1) /* switch from AMRWBIO */ + )) + { + /* do not allow a normal start of CNG synthesis if this SID(with BER or FER) is a switch to/from AMRWBIO */ + sid_upd_bad = 0; /* revert this detection due to AMRWBIO/EVS mode switch */ + total_brate = 0; + no_data = 1; + assert(st->bfi_fx == 1); /* bfi stays 1 */ + } + + if (GT_32(total_brate, SID_2k40) && st->bfi_fx == 1) /* typically from q bit */ + { + speech_bad = 1; /* initial assumption, CNG synt state decides what to actually do */ + } + /* all frame types decoded */ + + /* update CNG synthesis state */ + /* Decoder can only enter CNG-synthesis for CNG frame types (sid_upd, sid_bad, sid_first) */ + if (st->CNG_fx != 0) + { + /* We were in CNG synthesis */ + if (curr_ft_good_sp != 0) + { + /* only a good speech frame makes decoder leave CNG synthesis */ + st->CNG_fx = 0; + } + } + else + { + /* We were in SPEECH synthesis */ + /* only a received SID frame can make the decoder enter into CNG synthesis */ + if (amrwb_sid_first || sid_update || sid_upd_bad) + { + st->CNG_fx = 1; + } + } + + /* Now modify bfi flag for the decoder's SPEECH/CNG synthesis logic */ + /* in SPEECH synthesis, make sure to activate speech plc for a received no_data frame, + no_data frames may be injected by the network or by the dejitter buffer */ + /* modify bfi_flag to stay/move into the correct decoder PLC section */ + if ((st->CNG_fx == 0) && (no_data != 0)) + { + /* treat no_data received in speech synthesis as SP_LOST frames, SPEECH PLC code will now become active */ + st->bfi_fx = 1; + /* total_brate= 0; always zero for no_data */ + } + + /* in CNG */ + /* handle bad speech frame(and bad sid frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */ + if ((st->CNG_fx != 0 && (speech_bad || speech_lost || no_data)) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ + sid_upd_bad) /* SID_UPD_BAD --> start/stay CNG */ + { + st->bfi_fx = 0; /* mark as good to not start speech PLC */ + total_brate = 0; /* this zeroing needed for speech_bad, sid_bad frames */ + } + + + /* now bfi, total_brate are set by RX-DTX handler:: + bfi==0, total_brate!=0 cng or speech pending bitrate + bfi==0, total_brate==0 cng will continue or start(sid_first, sid_bad) + bfi==1, total_brate!=0 speech plc + bfi==1, total_brate==0 , speech plc + */ + + + /* handle available AMRWB/AMRWBIO MIME header ToC rate-info at startup */ + if ((st->bfi_fx == 1 && st->ini_frame_fx == 0) && + ((st->amrwb_rfc4867_flag != 0) || (st->amrwb_rfc4867_flag == 0 && isAMRWB_IOmode != 0))) /*AMRWB ToC */ + { + Word32 init_rate; + + init_rate = total_brate; /* default , may have been modified from original ToC value */ + if (speech_lost != 0 || no_data != 0) + { + init_rate = ACELP_12k65; /* make sure the decoder starts up in a selected AMRWB mode */ + } + else if (speech_bad != 0) + { + init_rate = AMRWB_IOmode2rate[core_mode]; /* read from from ToC */ + } + st->total_brate_fx = init_rate; /* not updated on bfi as decoderSelectCodec is not called below */ + st->core_brate_fx = init_rate; + } + + return total_brate; +} + + +/*-------------------------------------------------------------------* + * read_indices_mime_handle_sti_and_all_zero_bits() + * + * Handle STI and frames with all zero bits for MIME and RTP_DUMP decoding. + *-------------------------------------------------------------------*/ + +static void read_indices_mime_handle_sti_and_all_zero_bits( + Decoder_State_fx *st, + Word32 *total_brate, + Word16 sti +) +{ + Word16 k; + + if (sti == 0) + { + *total_brate = 0; /* signal received SID_FIRST as a good frame with no bits */ + for (k = 0; k < 35; k++) + { + st->bfi_fx |= st->bit_stream_fx[k]; /* partity check of 35 zeroes, any single 1 gives BFI */ + } + } + /* all zero bit SID_update results in a valid LP filter with extremely high LP-filter-gain */ + /* all zero bits signal may be a result of CS bit errors or erronesouly injected by gateways or bad dejitter handlers */ + if (sti == 1) + { /*sid_update received */ + Word16 sum = 0; + for (k = 0; k < 35; k++) + { + sum += st->bit_stream_fx[k]; /* check of 35 zeroes */ + } + + if (sum == 0) + { + st->bfi_fx = 1; /* eventually becomes SID_UPD_BAD */ + } + } +} + + +/*------------------------------------------------------------------------------------------* +* read_indices_mime() +* +* Read indices from MIME formatted bitstream to the buffer +* The magic word and number of channnels should be consumed before calling this function +*-------------------------------------------------------------------------------------------*/ + +Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem */ + Decoder_State_fx *st, /* i/o: decoder state structure */ + FILE *file, /* i : bitstream file */ + Word16 rew_flag /* i : rewind flag (rewind file after reading) */ +) +{ + Word16 k, isAMRWB_IOmode, cmi, core_mode = -1, qbit, sti; + UWord8 header; + UWord8 pFrame[(MAX_BITS_PER_FRAME + 7) >> 3]; + UWord8 mask = 0x80, *pt_pFrame = pFrame; + UWord16 *bit_stream_ptr; + Word16 num_bits; + Word32 total_brate; + UWord16 utmp; + Word32 L_tmp; + Word16 speech_lost = 0, no_data = 0; + Word16 num_bytes_read; + + st->BER_detect = 0; + st->bfi_fx = 0; + st->mdct_sw_enable = 0; + st->mdct_sw = 0; + reset_indices_dec_fx(st); + + /* read the FT Header field from the bitstream */ + if (fread(&header, sizeof(UWord8), 1, file) != 1) + { + if (ferror(file)) + { + /* error during reading */ + fprintf(stderr, "\nError reading the bitstream !"); + exit(-1); + } + else + { + /* end of file reached */ + return 0; + } + } + + /* init local RXDTX flags */ + sti = -1; + + if (st->amrwb_rfc4867_flag != 0) + { + /* RFC 4867 + 5.3 .... + Each stored speech frame starts with a one-octet frame header with + the following format: + 0 1 2 3 4 5 6 7 + +-+-+-+-+-+-+-+-+ + |P| FT |Q|P|P| + +-+-+-+-+-+-+-+-+ + The FT field and the Q bit are defined in the same way as in + Section 4.3.2. The P bits are padding and MUST be set to 0, and MUST be ignored. */ + + isAMRWB_IOmode = 1; + qbit = (header >> 2) & 0x01; /* b2 bit (b7 is the F bit ) */ + st->bfi_fx = !qbit; + core_mode = ((header >> 3) & 0x0F); /* b6..b3 */ + total_brate = AMRWB_IOmode2rate[core_mode]; /* get the frame length from the header */ + } + else + { + /*0 1 2 3 4 5 6 7 MS-bit ---> LS-bit + +-+-+-+-+-+-+-+-+ + |H|F|E|x| brate | + +-+-+-+-+-+-+-+-+ + where : + "E|x| brate " is the 6 bit "FT" -field + x is unused if E=0, (should be 0 ) + x is the q-bit if E=1, q==1(good), Q==0(bad, maybe bit errors in payload ) + H,F always 0 in RTP format. + */ + isAMRWB_IOmode = (header & 0x20) > 0; /* get EVS mode-from header */ /* b2 */ + core_mode = (header & 0x0F); /* b4,b5,b6,b7 */ + + if (isAMRWB_IOmode) + { + qbit = (header & 0x10) > 0; /* get Q bit, valid for IO rates */ /* b3 */ + total_brate = AMRWB_IOmode2rate[core_mode]; + } + else + { + qbit = 1; /* assume good q_bit for the unused EVS-mode bit, complete ToC validity checked later */ + total_brate = PRIMARYmode2rate[core_mode]; + } + st->bfi_fx = !qbit; + } + + + + + /* set up RX-DTX-handler input */ + if (core_mode == 14) + { + /* SP_LOST */ + speech_lost = 1; + } + if (core_mode == 15) + { + /* NO_DATA unsent CNG frame OR any frame marked or injected as no_data by e.g a signaling layer or dejitter buffer */ + no_data = 1; + } + + Mpy_32_16_ss(total_brate, 5243, &L_tmp, &utmp); /* 5243 is 1/50 in Q18. (0+18-15=3) */ + num_bits = extract_l(L_shr(L_tmp, 3)); /* Q0 */ + st->total_num_bits = num_bits; + + if (total_brate < 0) + { + /* validate that total_brate (derived from RTP packet or a file header) is one of the defined bit rates */ + fprintf(stderr, "\n Error. Illegal total bit rate (= %d) in MIME ToC header \n", total_brate); + /* num_bits = -1; not needed as BASOP multiplication preserves sign */ + } + + /* Check correctness of ToC headers */ + if (st->amrwb_rfc4867_flag == 0) + { + /* EVS ToC header (FT field(b2-b7), H bit (b0), F bit (b1) , (EVS-modebit(b2)=0 unused(Qbit)(b3)==0) */ + if ((isAMRWB_IOmode == 0) && ((num_bits < 0) || ((header & 0x80) > 0) || ((header & 0x40) > 0) || (header & 0x30) != 0x00)) + { + /* incorrect FT header */ + fprintf(stderr, "\nError in EVS FT ToC header(%02x) ! ", header); + exit(-1); + } + else if ((isAMRWB_IOmode != 0) && ((num_bits < 0) || ((header & 0x80) > 0) || ((header & 0x40) > 0))) /* AMRWBIO */ + { + /* incorrect IO FT header */ + fprintf(stderr, "\nError in EVS(AMRWBIO) FT ToC header(%02x) ! ", header); + exit(-1); + } + } + else + { + /* legacy AMRWB ToC, is only using Padding bits which MUST be ignored */ + if (num_bits < 0) + { + /* incorrect FT header */ + fprintf(stderr, "\nError in AMRWB RFC4867 Toc(FT) header(%02x) !", header); + exit(-1); + } + } + + /* read serial stream of indices from file to the local buffer */ + num_bytes_read = (Word16)fread(pFrame, sizeof(UWord8), (num_bits + 7) >> 3, file); + if (num_bytes_read != (num_bits + 7) >> 3) + { + fprintf(stderr, "\nError, invalid number of bytes read ! Exiting ! \n"); + exit(-1); + } + + /* in case rew_flag is set, rewind the file and return */ + /* (used in io_dec() to attempt print out info about technologies and to initialize the codec ) */ + if (rew_flag) + { + st->total_brate_fx = total_brate; /* used for the codec banner output */ + if (st->bfi_fx == 0 && speech_lost == 0 && no_data == 0) + { + decoder_selectCodec(st, total_brate, unpack_bit(&pt_pFrame, &mask) ? G192_BIN1 : G192_BIN0); + } + return 1; + } + + + + /* unpack speech data */ + bit_stream_ptr = st->bit_stream_fx; + for (k = 0; k < num_bits; k++) + { + if (isAMRWB_IOmode) + { + st->bit_stream_fx[sort_ptr[core_mode][k]] = unpack_bit(&pt_pFrame, &mask); + bit_stream_ptr++; + } + else + { + *bit_stream_ptr++ = unpack_bit(&pt_pFrame, &mask); + } + } + + /* unpack auxiliary bits */ + /* Note: the cmi bits are unpacked for demo purposes; */ + if (isAMRWB_IOmode && total_brate == SID_1k75) + { + sti = unpack_bit(&pt_pFrame, &mask); + cmi = unpack_bit(&pt_pFrame, &mask) << 3; + cmi |= unpack_bit(&pt_pFrame, &mask) << 2; + cmi |= unpack_bit(&pt_pFrame, &mask) << 1; + cmi |= unpack_bit(&pt_pFrame, &mask); + + read_indices_mime_handle_sti_and_all_zero_bits(st, &total_brate, sti); + } + + /*add two zero bytes for arithmetic coder flush*/ + for (k = 0; k < 2 * 8; ++k) + { + *bit_stream_ptr++ = 0; + } + + /* MIME RX_DTX handler */ + if (!rew_flag) + { + total_brate = read_indices_mime_handle_dtx(st, isAMRWB_IOmode, core_mode, total_brate, sti, speech_lost, no_data); + } + + if (st->bfi_fx == 0) + { + /* select MODE1 or MODE2 in MIME */ + decoder_selectCodec(st, total_brate, *st->bit_stream_fx ? G192_BIN1 : G192_BIN0); + + /* a change of the total bitrate should not be known to the decoder, if the received frame was truly lost */ + st->total_brate_fx = total_brate; + mdct_switching_dec(st); + } + /* else{ bfi stay in past synthesis mode(SP,CNG) } */ + + return 1; +} + +/*-------------------------------------------------------------------* +* berCheck() +* +* Check for bit errors in channel aware signalling. +*-------------------------------------------------------------------*/ + +static void berCheck( + Decoder_State_fx *st, /* i/o: decoder state structure */ + Word16 *coder_type /* i/o: coder type */ +) +{ + /* In case of RF flag = 1, and valid RF packet with primary and partial copy */ + if ((EQ_16(st->bwidth_fx, NB) || EQ_16(st->bwidth_fx, FB)) + || (GE_16(*coder_type, TRANSITION)) + ) + { + if (EQ_16(st->use_partial_copy, 1)) + { + st->use_partial_copy = 0; + move16(); + } + + st->bfi_fx = 1; + move16(); + st->bwidth_fx = st->last_bwidth_fx; + move16(); + st->BER_detect = 1; + move16(); + *coder_type = GENERIC; + move16(); + } + + return; +} + +/*-------------------------------------------------------------------* +* getPartialCopyInfo() +* +* Check if the frame includes a partial copy for channel aware processing. +*-------------------------------------------------------------------*/ + +void getPartialCopyInfo( + Decoder_State_fx *st, /* i/o: decoder state structure */ + Word16 *coder_type, + Word16 *sharpFlag +) +{ + Word16 nBits; + Word16 ind; + /* check the rf flag in the packet */ + get_rfFlag(st, &(st->rf_flag), &nBits, &ind); + + /* get rf frame type info */ + get_rfFrameType(st, &(st->rf_frame_type)); + + /* Get the FEC offset info */ + get_rf_fec_offset(st, &(st->rf_fec_offset)); + + /* reset number of target bits in case of rate switching */ + st->rf_target_bits = 0; + + /* Get the number of bits used for RF*/ + IF(EQ_16(st->rf_flag, 1)) + { + *coder_type = s_and(ind, 0x7); + st->bwidth_fx = s_and(shr(ind, 3), 0x7); + *sharpFlag = s_and(shr(ind, 6), 0x1); + st->codec_mode = MODE2; + move16(); + get_rfTargetBits(st->rf_frame_type, &(st->rf_target_bits)); + + IF(EQ_16(st->bfi_fx, FRAMEMODE_FUTURE)) + { + st->use_partial_copy = 1; + /* now set the frame mode to normal mode */ + test(); + IF(GE_16(st->rf_frame_type, RF_TCXFD) && LE_16(st->rf_frame_type, RF_TCXTD2)) + { + st->bfi_fx = 1; + st->core_fx = 1; + } + ELSE + { + st->bfi_fx = FRAMEMODE_NORMAL; + st->core_fx = 0; + } + } + /* check for bit errors */ + berCheck(st, coder_type); + + get_next_indice_tmp_fx(st, nBits); + + } +} + +/*-------------------------------------------------------------------* +* get_rfFlag() +* +* Check if rf flag is present in the bitstream +*-------------------------------------------------------------------*/ + +void get_rfFlag( + Decoder_State_fx *st, /* i: decoder state structure */ + Word16 *rf_flag, /* o : check for the RF flag */ + Word16 *nBits, + Word16 *ind +) +{ + Word16 start_idx, nBits_tmp; + Word16 ind_tmp; + + /* Init */ + *rf_flag = 0; + + /* check for rf_flag in the packet and extract the rf_frame_type and rf_fec_offset */ + test(); + test(); + IF(EQ_32(st->total_brate_fx, ACELP_13k20) && (EQ_16(st->bfi_fx, FRAMEMODE_NORMAL) || EQ_16(st->bfi_fx, FRAMEMODE_FUTURE))) + { + /* find the section in the ACELP signalling table corresponding to bitrate */ + start_idx = 0; + WHILE(NE_32(acelp_sig_tbl[start_idx], st->total_brate_fx)) + { + start_idx++; + assert((start_idx < MAX_ACELP_SIG) && "ERROR: start_idx larger than acelp_sig_tbl[].\n"); + } + + /* skip the bitrate */ + start_idx = add(start_idx, 1); + + /* retrieve the number of bits */ + nBits_tmp = (Word16)acelp_sig_tbl[start_idx++]; + + /* retrieve the signalling indice */ + ind_tmp = (Word16)acelp_sig_tbl[start_idx + get_indice_fx(st, 0, nBits_tmp)]; + + /* convert signalling indice into RF flag. */ + *rf_flag = s_and(shr(ind_tmp, 7), 0x1); + + if (ind) + { + *ind = ind_tmp; + } + + if (nBits) + { + *nBits = nBits_tmp; + } + } +} + +/*-------------------------------------------------------------------* +* get_rfFrameType() +* +* Extract the rf frame type +*-------------------------------------------------------------------*/ + +void get_rfFrameType( + Decoder_State_fx *st, /* i : decoder state structure */ + Word16 *rf_frame_type /* o : RF frame type */ +) +{ + Word16 num_bits = 0; + + IF(EQ_16(st->rf_flag, 1)) + { + /*num_bits = st->total_brate_fx/50;*/ + if (EQ_32(st->total_brate_fx, ACELP_13k20)) + { + num_bits = 264; + move16(); /* @13.2kbps */ + } + else + { + UWord16 lsb; + Word32 L_tmp; + Mpy_32_16_ss(st->total_brate_fx, 5243, &L_tmp, &lsb); /* 5243 is 1/50 in Q18. (0+18-15=3) */ + num_bits = extract_l(L_shr(L_tmp, 3)); /* Q0 */ + } + + /* the last three bits in a packet is the RF frame type */ + *rf_frame_type = get_indice_fx(st, num_bits - 3, 3); + } + ELSE + { + *rf_frame_type = 0; + } +} + +/*-------------------------------------------------------------------* +* get_rf_fec_offset() +* +* Extract the FEC offset +*-------------------------------------------------------------------*/ + +void get_rf_fec_offset( + Decoder_State_fx *st, /* i : decoder state structure */ + Word16 *rf_fec_offset /* o : RF fec offset */ +) +{ + Word16 num_bits, tmp; + + IF(EQ_16(st->rf_flag, 1)) + { + /*num_bits = st->total_brate_fx/50;*/ + if (EQ_32(st->total_brate_fx, ACELP_13k20)) + { + num_bits = 264; + move16(); /* @13.2kbps */ + } + else + { + UWord16 lsb; + Word32 L_tmp; + Mpy_32_16_ss(st->total_brate_fx, 5243, &L_tmp, &lsb); /* 5243 is 1/50 in Q18. (0+18-15=3) */ + num_bits = extract_l(L_shr(L_tmp, 3)); /* Q0 */ + } + + /* the two bits before the rf frame type contain the fec offset */ + tmp = get_indice_fx(st, num_bits - 5, 2); + + if (tmp == 0) + { + *rf_fec_offset = 2; + move16(); + } + else + { + *rf_fec_offset = add(shl(tmp, 1), 1); + } + } + ELSE + { + *rf_fec_offset = 0; + move16(); + } +} + +/*-------------------------------------------------------------------* +* get_rfTargetBits() +* +* Return the number of RF target bits +*-------------------------------------------------------------------*/ + +void get_rfTargetBits( + Word16 rf_frame_type, /* i : RF frame type */ + Word16 *rf_target_bits /* o : Number of RF target bits */ +) +{ + + /* Number of RF bits for different RF coder types */ + + SWITCH(rf_frame_type) + { + case RF_NO_DATA: + *rf_target_bits = 5; + BREAK; + case RF_TCXFD: + *rf_target_bits = 27; + BREAK; + case RF_TCXTD1: + *rf_target_bits = 16; + BREAK; + case RF_TCXTD2: + *rf_target_bits = 16; + BREAK; + case RF_ALLPRED: + /* Es_pred bits 3 bits, LTF: 1, pitch: 8,5,5,5, FCB: 0, gain: 7,0,7,0, Diff GFr: 4*/ + *rf_target_bits = 63; + BREAK; + case RF_NOPRED: + /* Es_pred bits 3 bits, LTF: 0, pitch: 0, FCB: 7,7,7,7, gain: 6,0,6,0, Diff GFr: 2*/ + *rf_target_bits = 66; + BREAK; + case RF_GENPRED: + /* Es_pred bits 3 bits, LTF: 1, pitch: 8,0,8,0, FCB: 6,7,5,5, gain: 5,0,5,0, Diff GFr: 0*/ + *rf_target_bits = 70; + BREAK; + case RF_NELP: + /* gain: 19, Diff GFr: 5 */ + *rf_target_bits = 45; + BREAK; + } +} + + +/*-------------------------------------------------------------------* + * get_NextCoderType_fx() + * + * Extract the coder type of next frame + *-------------------------------------------------------------------*/ + +void get_NextCoderType_fx( + UWord8 *bitsteam, /* i : bitstream */ + Word16 *next_coder_type /* o : next coder type */ +) +{ + Word16 k; + Word16 start_idx; + Word16 nBits_tmp; + Word8 bit_stream[ACELP_13k20 / 50]; + UWord16 tmp; + + + FOR(k = 0; k < ACELP_13k20 / 50; k++) + { + bit_stream[k] = (bitsteam[k / 8] >> (7 - (k % 8))) & 0x1; + } + start_idx = 0; + WHILE(NE_32(acelp_sig_tbl[start_idx], ACELP_13k20)) + { + start_idx = add(start_idx, 1); + assert((start_idx < MAX_ACELP_SIG) && "ERROR: start_idx larger than acelp_sig_tbl[].\n"); + } + + /* skip the bitrate */ + start_idx = add(start_idx, 1); + + tmp = 0; + move16(); + nBits_tmp = (Word16)acelp_sig_tbl[start_idx++]; + FOR(k = 0; k < nBits_tmp; k++) + { + tmp = lshl(tmp, 1); + tmp = add(tmp, bit_stream[k]); + } + /* retrieve the signalling indice */ + *next_coder_type = s_and((Word16)acelp_sig_tbl[start_idx + tmp], 0x7); +} + +/*-------------------------------------------------------------------* + * read_indices_from_djb_fx() + * + * Read indices from the de-jitter buffer payload (works also for AMR-WB IO mode) + *-------------------------------------------------------------------*/ + +void read_indices_from_djb_fx( + Decoder_State_fx *st, /* i/o: decoder state structure */ + UWord8 *pt_stream, /* i : bitstream file */ + Word16 num_bits, /* i : input frame length in bits */ + Word16 isAMRWB_IOmode, + Word16 core_mode, + Word16 qbit, + Word16 partialframe, /* i : partial frame information */ + Word16 next_coder_type /* i : next coder type information */ +) +{ + Word16 k; + UWord8 mask = 0x80; + Word16 no_data = 0; + Word16 sti = -1; + UWord16 *bit_stream_ptr; + Word32 total_brate; + Word16 speech_lost = 0; + + st->bfi_fx = 0; + st->BER_detect = 0; + st->mdct_sw_enable = 0; + st->mdct_sw = 0; + reset_indices_dec_fx(st); + + st->bfi_fx = !qbit; + total_brate = (Word32)(num_bits) * 50; + st->total_num_bits = num_bits; + + if (num_bits == 0) /* guess type of missing frame for SP_LOST and NO_DATA */ + { + speech_lost = st->CNG_fx == 0; + no_data = st->CNG_fx != 0; + } + + if (partialframe || st->prev_use_partial_copy) + { + st->next_coder_type = next_coder_type; + } + else + { + st->next_coder_type = INACTIVE; + } + + if (partialframe == 1) + { + st->bfi_fx = 2; + } + + /* unpack speech data */ + bit_stream_ptr = st->bit_stream_fx; + /* convert bitstream from compact bytes to short values and store it in decoder state */ + for (k = 0; k < num_bits; k++) + { + if (st->bitstreamformat == VOIP_RTPDUMP && isAMRWB_IOmode) + { + st->bit_stream_fx[sort_ptr[core_mode][k]] = unpack_bit(&pt_stream, &mask); + bit_stream_ptr++; + } + else + { + *bit_stream_ptr++ = unpack_bit(&pt_stream, &mask); + } + } + + /* unpack auxiliary bits */ + if (isAMRWB_IOmode && total_brate == SID_1k75) + { + if (st->bitstreamformat == VOIP_RTPDUMP) + { + /* A.2.2.1.3: AMR-WB SID_1k75 frame is followed by STI bit and CMI bits */ + sti = unpack_bit(&pt_stream, &mask); + } + else + { + /* VOIP_G192_RTP does not contain STI and CMI */ + sti = 1; + } + read_indices_mime_handle_sti_and_all_zero_bits(st, &total_brate, sti); + + } + + /* add two zero bytes for arithmetic coder flush */ + for (k = 0; k < 8 * 2; ++k) + { + *bit_stream_ptr++ = 0; + } + + total_brate = read_indices_mime_handle_dtx(st, isAMRWB_IOmode, core_mode, total_brate, sti, speech_lost, no_data); + /* st->CNG_fx set inside */ + + if (st->bfi_fx != 1) + { + /* select Mode 1 or Mode 2 */ + decoder_selectCodec(st, total_brate, *st->bit_stream_fx ? G192_BIN1 : G192_BIN0); + + /* a change of the total bitrate should not be known to the decoder, if the received frame was truly lost */ + st->total_brate_fx = total_brate; + + mdct_switching_dec(st); + } +} + + + +/*-------------------------------------------------------------------* + * get_indice_preview() + * + * Indices preview to parse for the presence of partial copy + *-------------------------------------------------------------------*/ +static UWord16 get_indice_preview( + UWord8 *bitstream, + Word16 bitstreamSize, + Word16 pos, + Word16 nb_bits +) +{ + UWord16 value; + Word16 i; + UWord16 bitstreamShort[MAX_BITS_PER_FRAME + 16]; + UWord16 *bitstreamShortPtr; + + /* convert bitstream from compact bytes to short values */ + bitstreamShortPtr = bitstreamShort; + FOR(i = 0; i < bitstreamSize; i++) + { + *bitstreamShortPtr++ = (bitstream[i / 8] >> (7 - (i % 8))) & 0x1; + } + + assert(nb_bits <= 16); + value = 0; + FOR(i = 0; i < nb_bits; i++) + { + value = shl(value, 1); + value = add(value, bitstreamShort[pos + i]); + } + return value; +} + +/*-------------------------------------------------------------------* + * evs_dec_previewFrame() + * + * Signalling index preview + *-------------------------------------------------------------------*/ +void evs_dec_previewFrame( + UWord8 *bitstream, + Word16 bitstreamSize, + Word16 *partialCopyFrameType, + Word16 *partialCopyOffset +) +{ + Word32 total_brate; + Word16 start_idx, nBits; + Word32 ind; + Word16 rf_flag; + + rf_flag = 0; + *partialCopyFrameType = 0; + *partialCopyOffset = 0; + total_brate = bitstreamSize * 50; + + IF(EQ_32(total_brate, ACELP_13k20)) + { + /* find the section in the ACELP signalling table corresponding to bitrate */ + start_idx = 0; + WHILE(NE_32(acelp_sig_tbl[start_idx], total_brate)) + { + start_idx = add(start_idx, 1); + assert((start_idx < MAX_ACELP_SIG) && "ERROR: start_idx larger than acelp_sig_tbl[].\n"); + } + + /* skip the bitrate */ + start_idx = add(start_idx, 1); + /* retrieve the number of bits */ + nBits = (Word16)acelp_sig_tbl[start_idx++]; + + /* retrieve the signalling indice */ + ind = acelp_sig_tbl[start_idx + get_indice_preview(bitstream, bitstreamSize, 0, nBits)]; + + /* convert signalling indice into RF flag. */ + rf_flag = s_and(extract_l(L_shr(ind, 7)), 0x1); + assert(rf_flag == ((ind >> 7) & 0x1)); + IF(rf_flag != 0) + { + /* read the fec offset at which the partial copy is received */ + ind = get_indice_preview(bitstream, bitstreamSize, (bitstreamSize - 5), 2); + IF(ind == 0) *partialCopyOffset = 2; + ELSE IF(EQ_32(ind, 1))*partialCopyOffset = 3; + ELSE IF(EQ_32(ind, 2))*partialCopyOffset = 5; + ELSE IF(EQ_32(ind, 3))*partialCopyOffset = 7; + + /* the last three bits in a packet is the RF frame type */ + *partialCopyFrameType = get_indice_preview(bitstream, bitstreamSize, bitstreamSize - 3, 3); + } + } +} + + diff --git a/lib_com/cb_shape.c b/lib_com/cb_shape.c index 77f17eb23..8552d6047 100644 --- a/lib_com/cb_shape.c +++ b/lib_com/cb_shape.c @@ -106,7 +106,7 @@ void cb_shape( { mvr2r( A_num, buff + M, M + 1 ); syn_filt( A_den, M, buff + M, buff + M, L_subfr, buff, 0 ); - tilt = get_gain( buff + M + 1, buff + M, L_subfr - 1, NULL ); + tilt = get_gain_flt( buff + M + 1, buff + M, L_subfr - 1, NULL ); tmp = 0.0; preemph( code, 0.5f * tilt_code - 0.25f * tilt, L_subfr, &tmp ); } diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index 716dff7a3..a7dd5512f 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -147,7 +147,7 @@ void cldfbAnalysis( rot_vctr_re = h_cldfb->rot_vec_ana_re; rot_vctr_im = h_cldfb->rot_vec_ana_im; - ptr_pf = h_cldfb->p_filter; + ptr_pf = h_cldfb->p_filter_flt; for ( i = 0; i < no_col; i++ ) { @@ -325,7 +325,7 @@ void cldfbAnalysis_ts( rot_vctr_delay_re = h_cldfb->rot_vec_ana_delay_re; rot_vctr_delay_im = h_cldfb->rot_vec_ana_delay_im; - ptr_pf = h_cldfb->p_filter; + ptr_pf = h_cldfb->p_filter_flt; for ( i = 0; i < no_col; i++ ) { @@ -512,7 +512,7 @@ void cldfbSynthesis( float new_samples[2 * CLDFB_NO_CHANNELS_MAX]; float *ptr_time_out; - const float *p_filter; + const float *p_filter_flt; float accu0, accu1, accu2, accu3, accu4; int16_t no_col = h_cldfb->no_col; @@ -539,7 +539,7 @@ void cldfbSynthesis( synthesisBuffer = buffer; mvr2r( h_cldfb->cldfb_state, synthesisBuffer + ( M1 * no_col ), h_cldfb->p_filter_length ); - p_filter = h_cldfb->p_filter; + p_filter_flt = h_cldfb->p_filter_flt; ptr_time_out = timeOut; /*synthesisBuffer += M1 * h_cldfb->no_col;*/ @@ -632,11 +632,11 @@ void cldfbSynthesis( /* synthesis prototype filter */ for ( i = 0; i < L2; i++ ) { - accu0 = synthesisBuffer[0 * L2 + i] + p_filter[( 0 * L2 + i )] * new_samples[L2 - 1 - i]; - accu1 = synthesisBuffer[1 * L2 + i] + p_filter[( 1 * L2 + i )] * new_samples[L2 - 1 - i]; - accu2 = synthesisBuffer[2 * L2 + i] + p_filter[( 2 * L2 + i )] * new_samples[L2 - 1 - i]; - accu3 = synthesisBuffer[3 * L2 + i] + p_filter[( 3 * L2 + i )] * new_samples[L2 - 1 - i]; - accu4 = synthesisBuffer[4 * L2 + i] + p_filter[( 4 * L2 + i )] * new_samples[L2 - 1 - i]; + accu0 = synthesisBuffer[0 * L2 + i] + p_filter_flt[( 0 * L2 + i )] * new_samples[L2 - 1 - i]; + accu1 = synthesisBuffer[1 * L2 + i] + p_filter_flt[( 1 * L2 + i )] * new_samples[L2 - 1 - i]; + accu2 = synthesisBuffer[2 * L2 + i] + p_filter_flt[( 2 * L2 + i )] * new_samples[L2 - 1 - i]; + accu3 = synthesisBuffer[3 * L2 + i] + p_filter_flt[( 3 * L2 + i )] * new_samples[L2 - 1 - i]; + accu4 = synthesisBuffer[4 * L2 + i] + p_filter_flt[( 4 * L2 + i )] * new_samples[L2 - 1 - i]; synthesisBuffer[0 * L2 + i] = accu0; synthesisBuffer[1 * L2 + i] = accu1; @@ -712,7 +712,7 @@ ivas_error openCldfb( hs->prototype = prototype; configureCldfb( hs, sampling_rate ); - hs->memory = NULL; + hs->memory_flt = NULL; hs->memory_length = 0; if ( type == CLDFB_ANALYSIS ) @@ -832,7 +832,7 @@ static float GetEnergyCldfb( tempEnergyValuesArry[j] = &energyValues[j][0]; } - calcHiEnvLoBuff( numberCols, freqTable, 1, tempEnergyValuesArry, hTecEnc->loBuffer, hTecEnc->hiTempEnv ); + calcHiEnvLoBuff( numberCols, freqTable, 1, tempEnergyValuesArry, hTecEnc->loBuffer_flt, hTecEnc->hiTempEnv_flt); } for ( j = 0; j < numberBands; j++ ) @@ -918,8 +918,8 @@ static void cldfb_init_proto_and_twiddles( if ( hs->prototype == CLDFB_PROTOTYPE_1_25MS ) { - hs->p_filter = CLDFB80_10; - hs->scale = CLDFB80_10_SCALE; + hs->p_filter_flt = CLDFB80_10; + hs->scale_flt = CLDFB80_10_SCALE; hs->ds = 10; hs->da = 10; hs->rot_vec_ana_delay_re = NULL; @@ -929,8 +929,8 @@ static void cldfb_init_proto_and_twiddles( } else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS ) { - hs->p_filter = LDQMF_10; - hs->scale = LDQMF_10_SCALE; + hs->p_filter_flt = LDQMF_10; + hs->scale_flt = LDQMF_10_SCALE; hs->ds = 40; hs->da = -20; hs->rot_vec_ana_delay_re = rot_vec_delay_re_LDQMF; @@ -947,8 +947,8 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_syn_im = rot_vec_syn_im_L16; if ( hs->prototype == CLDFB_PROTOTYPE_1_25MS ) { - hs->p_filter = CLDFB80_16; - hs->scale = CLDFB80_16_SCALE; + hs->p_filter_flt = CLDFB80_16; + hs->scale_flt = CLDFB80_16_SCALE; hs->ds = 20; hs->da = 20; hs->rot_vec_ana_delay_re = NULL; @@ -958,8 +958,8 @@ static void cldfb_init_proto_and_twiddles( } else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS ) { - hs->p_filter = LDQMF_16; - hs->scale = LDQMF_16_SCALE; + hs->p_filter_flt = LDQMF_16; + hs->scale_flt = LDQMF_16_SCALE; hs->ds = 80; hs->da = -40; hs->rot_vec_ana_delay_re = rot_vec_delay_re_LDQMF; @@ -976,8 +976,8 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_syn_im = rot_vec_syn_im_L20; if ( hs->prototype == CLDFB_PROTOTYPE_1_25MS ) { - hs->p_filter = CLDFB80_20; - hs->scale = CLDFB80_20_SCALE; + hs->p_filter_flt = CLDFB80_20; + hs->scale_flt = CLDFB80_20_SCALE; hs->ds = 20; hs->da = 20; hs->rot_vec_ana_delay_re = NULL; @@ -987,8 +987,8 @@ static void cldfb_init_proto_and_twiddles( } else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS ) { - hs->p_filter = LDQMF_20; - hs->scale = LDQMF_20_SCALE; + hs->p_filter_flt = LDQMF_20; + hs->scale_flt = LDQMF_20_SCALE; hs->ds = 80; hs->da = -40; hs->rot_vec_ana_delay_re = rot_vec_delay_re_LDQMF; @@ -1005,8 +1005,8 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_syn_im = rot_vec_syn_im_L30; if ( hs->prototype == CLDFB_PROTOTYPE_1_25MS ) { - hs->p_filter = CLDFB80_30; - hs->scale = CLDFB80_30_SCALE; + hs->p_filter_flt = CLDFB80_30; + hs->scale_flt = CLDFB80_30_SCALE; hs->ds = 30; hs->da = 30; hs->rot_vec_ana_delay_re = NULL; @@ -1016,8 +1016,8 @@ static void cldfb_init_proto_and_twiddles( } else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS ) { - hs->p_filter = LDQMF_30; - hs->scale = LDQMF_30_SCALE; + hs->p_filter_flt = LDQMF_30; + hs->scale_flt = LDQMF_30_SCALE; hs->ds = 120; hs->da = -60; hs->rot_vec_ana_delay_re = rot_vec_delay_re_LDQMF; @@ -1034,8 +1034,8 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_syn_im = rot_vec_syn_im_L32; if ( hs->prototype == CLDFB_PROTOTYPE_1_25MS ) { - hs->p_filter = CLDFB80_32; - hs->scale = CLDFB80_32_SCALE; + hs->p_filter_flt = CLDFB80_32; + hs->scale_flt = CLDFB80_32_SCALE; hs->ds = 32; hs->da = 32; hs->rot_vec_ana_delay_re = NULL; @@ -1045,8 +1045,8 @@ static void cldfb_init_proto_and_twiddles( } else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS ) { - hs->p_filter = LDQMF_32; - hs->scale = LDQMF_32_SCALE; + hs->p_filter_flt = LDQMF_32; + hs->scale_flt = LDQMF_32_SCALE; hs->ds = 160; hs->da = -80; hs->rot_vec_ana_delay_re = rot_vec_delay_re_LDQMF; @@ -1063,8 +1063,8 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_syn_im = rot_vec_syn_im_L40; if ( hs->prototype == CLDFB_PROTOTYPE_1_25MS ) { - hs->p_filter = CLDFB80_40; - hs->scale = CLDFB80_40_SCALE; + hs->p_filter_flt = CLDFB80_40; + hs->scale_flt = CLDFB80_40_SCALE; hs->ds = 40; hs->da = 40; hs->rot_vec_ana_delay_re = NULL; @@ -1074,8 +1074,8 @@ static void cldfb_init_proto_and_twiddles( } else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS ) { - hs->p_filter = LDQMF_40; - hs->scale = LDQMF_40_SCALE; + hs->p_filter_flt = LDQMF_40; + hs->scale_flt = LDQMF_40_SCALE; hs->ds = 160; hs->da = -80; hs->rot_vec_ana_delay_re = rot_vec_delay_re_LDQMF; @@ -1092,8 +1092,8 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_syn_im = rot_vec_syn_im_L60; if ( hs->prototype == CLDFB_PROTOTYPE_1_25MS ) { - hs->p_filter = CLDFB80_60; - hs->scale = CLDFB80_60_SCALE; + hs->p_filter_flt = CLDFB80_60; + hs->scale_flt = CLDFB80_60_SCALE; hs->ds = 60; hs->da = 60; hs->rot_vec_ana_delay_re = NULL; @@ -1103,8 +1103,8 @@ static void cldfb_init_proto_and_twiddles( } else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS ) { - hs->p_filter = LDQMF_60; - hs->scale = LDQMF_60_SCALE; + hs->p_filter_flt = LDQMF_60; + hs->scale_flt = LDQMF_60_SCALE; hs->ds = 240; hs->da = -120; hs->rot_vec_ana_delay_re = rot_vec_delay_re_LDQMF; @@ -1131,7 +1131,7 @@ ivas_error cldfb_save_memory( { uint16_t offset = hs->p_filter_length - hs->no_channels; - if ( hs->memory != NULL || hs->memory_length != 0 ) + if ( hs->memory_flt != NULL || hs->memory_length != 0 ) { /* memory already stored; Free memory first */ return IVAS_ERR_OK; @@ -1146,13 +1146,13 @@ ivas_error cldfb_save_memory( hs->memory_length = hs->p_filter_length; } - if ( ( hs->memory = (float *) malloc( hs->memory_length * sizeof( float ) ) ) == NULL ) + if ( ( hs->memory_flt = (float *) malloc( hs->memory_length * sizeof( float ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" ); } /* save the memory */ - mvr2r( hs->cldfb_state, hs->memory, hs->memory_length ); + mvr2r( hs->cldfb_state, hs->memory_flt, hs->memory_length ); return IVAS_ERR_OK; } @@ -1171,7 +1171,7 @@ void cldfb_restore_memory( uint16_t offset = hs->p_filter_length - hs->no_channels; uint16_t size; - if ( hs->memory == NULL || hs->memory_length == 0 ) + if ( hs->memory_flt == NULL || hs->memory_length == 0 ) { /* memory not allocated */ return; @@ -1187,7 +1187,7 @@ void cldfb_restore_memory( } /* read the memory */ - mvr2r( hs->memory, hs->cldfb_state, hs->memory_length ); + mvr2r( hs->memory_flt, hs->cldfb_state, hs->memory_length ); /* adjust sample rate if it was changed in the meanwhile */ if ( hs->memory_length != size ) @@ -1196,8 +1196,8 @@ void cldfb_restore_memory( } hs->memory_length = 0; - free( hs->memory ); - hs->memory = NULL; + free( hs->memory_flt); + hs->memory_flt = NULL; return; } diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 5bfffa4dd..104c639b3 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -42,6 +42,80 @@ /* clang-format off */ + +/*----------------------------------------------------------------------------------* + *Q values + *----------------------------------------------------------------------------------*/ + +#define Q1 1 +#define Q2 2 +#define Q3 3 +#define Q4 4 +#define Q5 5 +#define Q6 6 +#define Q7 7 +#define Q8 8 +#define Q9 9 +#define Q10 10 +#define Q11 11 +#define Q12 12 +#define Q13 13 +#define Q14 14 +#define Q15 15 +#define Q16 16 +#define Q17 17 +#define Q18 18 +#define Q19 19 +#define Q20 20 +#define Q21 21 +#define Q22 22 +#define Q23 23 +#define Q24 24 +#define Q25 25 +#define Q26 26 +#define Q27 27 +#define Q28 28 +#define Q29 29 +#define Q30 30 +#define Q31 31 + +/*----------------------------------------------------------------------------------* + * one in Q + *----------------------------------------------------------------------------------*/ + +#define ONE_IN_Q1 2 +#define ONE_IN_Q2 4 +#define ONE_IN_Q3 8 +#define ONE_IN_Q4 16 +#define ONE_IN_Q5 32 +#define ONE_IN_Q6 64 +#define ONE_IN_Q7 128 +#define ONE_IN_Q8 256 +#define ONE_IN_Q9 512 +#define ONE_IN_Q10 1024 +#define ONE_IN_Q11 2048 +#define ONE_IN_Q12 4096 +#define ONE_IN_Q13 8192 +#define ONE_IN_Q14 16384 +#define ONE_IN_Q15 32768 +#define ONE_IN_Q16 65536 +#define ONE_IN_Q17 131072 +#define ONE_IN_Q18 262144 +#define ONE_IN_Q19 524288 +#define ONE_IN_Q20 1048576 +#define ONE_IN_Q21 2097152 +#define ONE_IN_Q22 4194304 +#define ONE_IN_Q23 8388608 +#define ONE_IN_Q24 16777216 +#define ONE_IN_Q25 33554432 +#define ONE_IN_Q26 67108864 +#define ONE_IN_Q27 134217728 +#define ONE_IN_Q28 268435456 +#define ONE_IN_Q29 536870912 +#define ONE_IN_Q30 1073741824 +#define ONE_IN_Q31 0x7fffffff + + /*----------------------------------------------------------------------------------* * General constants *----------------------------------------------------------------------------------*/ @@ -105,7 +179,8 @@ enum{ /* Conversion of ns to samples for a given sampling frequency */ #define NS2SA( fs, x ) ( int16_t )( ( ( ( int32_t )( fs ) / 100L ) * ( ( x ) / 100L ) ) / 100000L ) - +#define NRG_CHANGE_E 8 +#define AVG_FLAT_E 8 #define ACTIVE_FRAME 0xFF #define SID_FRAME 0xFA #define ZERO_FRAME 0xF0 @@ -228,6 +303,7 @@ enum{ /* Combine parameters into a single index (used to retrieve number of bits from bit allocation tables) */ #define LSF_BIT_ALLOC_IDX( brate, ctype ) ( 6 * BRATE2IDX( brate ) + ( ctype ) ) +#define LSF_BIT_ALLOC_IDX_fx(brate,ctype) (L_mac0(L_mult0(6, BRATE2IDX_fx(brate)), (ctype), 1)) #define BIT_ALLOC_IDX( brate, ctype, sfrm, tc ) \ ( ( sfrm != -1 ? NB_SUBFR : 1 ) * \ @@ -241,6 +317,7 @@ enum{ /* Combine coder_type, bandwidth, formant sharpening flag, and channel-aware flag into one indice */ #define SIG2IND( ctype, bw, sf, ca_rf ) ( ctype | ( bw << 3 ) | ( sf << 6 ) | ( ca_rf << 7 ) ) +#define SIG2IND_fx(ctype, bw, sf, ca_rf) L_mac0(L_mac0(L_mac0(L_mult0(ctype, 1), bw, 1<<3), sf, 1<<6), ca_rf, 1<<7) #define MAX_ACELP_SIG 100 @@ -438,6 +515,7 @@ enum IND_STEREO_2ND_CODER_T, IND_UNUSED, + MAX_NUM_INDICES = IND_UNUSED + 127 }; /*----------------------------------------------------------------------------------* @@ -556,6 +634,9 @@ enum #define L_FRAME 256 /* frame size at 12.8kHz */ #define NB_SUBFR 4 /* number of subframes per frame */ #define L_SUBFR ( L_FRAME / NB_SUBFR ) /* subframe size */ +#define L_SUBFR_Q6 ((L_FRAME/NB_SUBFR)*64) /* subframe size */ +#define L_SUBFR_Q16 ((L_FRAME/NB_SUBFR)*65536) /* subframe size */ + #define L_INP_MEM ( L_LOOK_16k + ( ( L_LP_16k - ( NS2SA( INT_FS_16k, ACELP_LOOK_NS ) + L_SUBFR16k / 2 ) ) - 3 * L_SUBFR16k / 2 ) ) /*=240 samples length of memory of input signal, given by the Look-Ahead + the past memory (max needed for the LP window at 16 kHz) */ #define L_INP_12k8 ( L_INP_MEM + L_FRAME ) /* length of input signal buffer @12.8kHz */ #define L_INP ( L_INP_MEM + L_FRAME32k ) /* length of input signal buffer @32kHz */ @@ -583,9 +664,12 @@ enum #define L_INTERPOL2 16 /* Length of filter for interpolation */ #define L_INTERPOL ( L_INTERPOL2 + 1 ) /* Length of filter for interpolation */ #define TILT_FAC 0.68f /* tilt factor (denominator) */ +#define TILT_FAC_FX 22282 /* tilt factor (denominator) fixed-point*/ #define M16k 20 /* order of the LP filter @ 16kHz */ #define PIT_SHARP 0.85f /* pitch sharpening factor */ +#define PIT_SHARP_fx 27853 /* pitch sharpening factor */ #define PIT_UP_SAMP 4 /* upsampling factor for 1/4 interpolation filter */ +#define UP_SAMP 4 /* upsampling factor for 1/4 interpolation filter */ #define PIT_L_INTERPOL2 16 #define PIT_FIR_SIZE2 ( PIT_UP_SAMP * PIT_L_INTERPOL2 + 1 ) #define PIT_UP_SAMP6 6 @@ -595,7 +679,12 @@ enum #define STEP_DELTA 0.0625f /* quantization step for tilt compensation of gaussian cb. excitation */ #define GAMMA_EV 0.92f /* weighting factor for core synthesis error weighting */ #define FORMANT_SHARPENING_NOISE_THRESHOLD 21.0f /* lp_noise level above which formant sharpening is deactivated */ -#define LP_NOISE_THRESH 20.f +#define E_MIN_FX 1 /* QSCALE (Q7)*/ +#define STEP_DELTA_FX 11 +#define FORMANT_SHARPENING_NOISE_THRESHOLD_FX 5376 /* 21 (!8)lp_noise level above which formant sharpening is deactivated - at this level most of 20 dB SNR office noisy speech still uses sharpening */ + +#define LP_NOISE_THRESH_FLT 20.f +#define LP_NOISE_THRESH 167772160l/*20.f Q23*/ #define L_FILT_UP8k 24 /* Resampling - delay of filter for 8 kHz output signals (at 12.8 kHz sampling rate) */ #define LEN_WIN_SSS 120 @@ -660,16 +749,26 @@ typedef enum #define VOIC_BAND 17 /* Spectral analysis - number of critical bands considered as voiced (related to VOIC_BINS) */ #define VOIC_BINS_8k 115 /* Spectral analysis - max number of frequency bins considered as voiced in NB (related to VOIC_BAND_8k and L_FFT) */ #define VOIC_BAND_8k 17 /* Spectral analysis - number of critical bands considered as voiced in NB (related to VOIC_BINS_8k) */ +#define N_SPEC (L_FFT/2) /* number of spectral bins */ #define M_ALPHA 0.9f /* Multi-harm analysis - forgetting factor of LT correlation map */ #define M_GAMMA 0.99f /* Multi-harm analysis - forgetting factor of active speech decision predictor */ #define THR_CORR 56 /* Multi-harm analysis - starting threshold of multi-harm. correlation */ +#define M_GAMMA_FX 32440 /* Q15 - forgetting factor of active speech decision predictor */ +#define M_ALPHA_FX 29491 /* Q15 - forgetting factor of LT correlation map */ +#define ONE_MINUS_M_ALPHA 3277 /* Q15 - one minus forgetting factor of LT correlation map */ +#define THR_CORR_INIT_FX (56<<9 ) /* Q9 - starting threshold of multi-harm. correlation */ +#define THR_NCHAR_WB_FX 2048 /* Q11 threshold for noise character (WB) */ +#define THR_NCHAR_NB_FX 2048 /* Q11 threshold for noise character (NB) */ + + #define L_LP 320 /* LP analysis - LP window size */ #define L_LP_16k 400 /* LP analysis @16kHz - LP window size for 16kHz */ #define L_LP_AMR_WB 384 /* LP analysis - windows size (only for AMR-WB IO mode) */ #define GRID50_POINTS 51 /* LP analysis - half-number of points to evaluate Chebyshev polynomials used in the LP coefs. conversion */ #define GRID40_POINTS 41 /* LP analysis - half-number of points to evaluate Chebyshev polynomials used in the LP coefs. conversion */ +#define GRID80_POINTS 80 /* LP analysis - number of points to evaluate Chebyshev polynomials used in the LP coefs. conversion */ #define GRID100_POINTS 100 /* LP analysis - number of points to evaluate Chebyshev polynomials */ #define PIT_MIN 34 /* OL pitch analysis - Minimum pitch lag */ @@ -702,6 +801,7 @@ typedef enum #define PIT_MAX_32k 577 #define PIT_FR1_8b_32k 75 #define PIT_MAX_MAX PIT_MAX_32k +#define PIT_MAX_16k 289 #define PIT_FR1_8b 92 /* Pitch encoding - Minimum pitch lag with resolution 1 */ #define PIT_FR2_9b 128 /* Pitch encoding - Minimum pitch lag with resolution 1/2 */ @@ -733,20 +833,36 @@ typedef enum #define DTX_HIST_SIZE 8 /* CNG & DTX - number of last signal frames used for CNG averaging */ #define CNG_ISF_FACT 0.9f /* CNG & DTX - CNG spectral envelope smoothing factor */ #define STEP_AMR_WB_SID 2.625f /* CNG & DTX - CNG energy quantization step */ +#define CNG_ISF_FACT_FX 29491 /* Q15(0.9), CNG & DTX - CNG spectral envelope smoothing factor*/ +#define STEP_AMR_WB_SID_FX 10752 /* Q12 */ #define HO_HIST_SIZE 8 /* CNG & DTX - maximal number of hangover frames used for averaging */ #define NUM_ENV_CNG 20 #define BUF_L_NRG 0.7f /* CNG & DTX - lower threshold factor for hangover updates */ #define BUF_H_NRG 1.03f /* CNG & DTX - higher threshold factor for hangover updates */ #define CNG_TYPE_HO 20 /* CNG & DTX - hangover for switching between CNG types */ +#define BUF_L_NRG_FX 22938 /* Q15(0.7), CNG & DTX - lower threshold offset for hangover updates */ +#define ONE_OVER_BUF_H_NRG_FX 31814 /* Q15(1/1.03), CNG & DTX - inverse of higher threshold offset for hangover updates */ +#define HO_ATT_FAC_FX 3277 /* Q15(0.1), CNG & DTX - Hangover frame attenuation rate factor */ + #define BUF_DEC_RATE 25 /* CNG & DTX - buffer size decrease rate for active frames */ #define STEP_SID 5.25f /* CNG & DTX - CNG energy quantization step */ +#define STEP_SID_FX 21504 /* Q12 */ +#define ISTEP_SID_FX 6242 /* Inverse of CNG & DTX - CNG energy quantization step in Q15(1/5.25 in Q15)*/ +#define ISTEP_AMR_WB_SID_FX 12483 /* Q15(1/2.625) Inverse of CNG & DTX - CNG energy quantization step */ + #define MIN_ACT_CNG_UPD 20 /* DTX - Minimum number of consecutive active frames for CNG mode update */ #define FIXED_SID_RATE 8 /* DTX SID rate */ #define TOTALNOISE_HIST_SIZE 4 +#define SUBFFT_QIN 10 +#define DATAFFT_Q 5 +#define SUBFFT_QOUT SUBFFT_QIN-DATAFFT_Q +#define SPECAMP_Q SUBFFT_QIN + + #define UNKNOWN_NOISE 0 /* unknown noisy type */ #define SILENCE 1 /* speech with high SNR */ #define CLDFBVAD_NB_ID 1 @@ -758,6 +874,10 @@ typedef enum #define PRE_SNR_NUM 32 /* number of snr to calculate average SNR of all sub-bands */ #define POWER_NUM 56 /* number of energy of several frames*/ #define PRE_SPEC_DIF_NUM 56 /* number of energy of several frames*/ +#define CLDFBVAD_VAD_ON 1 +#define COM_VAD_ON 2 + + #define MAX_SUBBAND_NUM 12 /* max number of sub-band divided non-uniformly*/ #define BG_ENG_NUM MAX_SUBBAND_NUM /* number of energy of sub-band divided non-uniformly*/ @@ -767,9 +887,19 @@ typedef enum #define STABLE_NUM 4 /* number of time-domain stable rate*/ #define SFM_NUM 3 /* number of spectral flatness */ +#define MAX_CORR_SHIFT_FX 16384 /* corrshift limit, 0.5 in Q15 */ + + #define START_NG 5 /* Stationary noise UV modification */ #define FULL_NG 10 /* Stationary noise UV modification */ #define ISP_SMOOTHING_QUANT_A1 0.9f /* Stationary noise UV modification */ +#define ISP_SMOOTHING_QUANT_A1_FX 29491 /* 0.9f in Q15 */ /* Stationary noise UV modification */ + +#define KP559016994_FX 18318 /* EDCT & EMDCT constants */ +#define KP951056516_FX 31164 /* EDCT & EMDCT constants */ +#define KP587785252_FX 19261 /* EDCT & EMDCT constants */ +#define KP866025403_FX 28378 /* EDCT & EMDCT constants */ +#define KP250000000_FX 8192 /* EDCT & EMDCT constants */ #define FEC_BITS_CLS 2 /* FEC - number of bits for clas information */ #define FEC_BITS_ENR 5 /* FEC - number of bits for energy information */ @@ -790,18 +920,34 @@ typedef enum #define BWD_N_BINS_MAX 13 /* maximum number of BWD bins */ #define BWS_TRAN_PERIOD 5 /* BWS - number of frames for transition period */ -#define PREEMPH_FAC 0.68f /* preemphasis factor at 12.8kHz */ -#define PREEMPH_FAC_16k 0.72f -#define PREEMPH_FAC_SWB 0.9f /* preemphasis factor for super wide band */ -#define GAMMA1 0.92f /* weighting factor (numerator) default:0.92 */ -#define GAMMA16k 0.94f - -#define FORMANT_SHARPENING_G1 0.75f /* Formant sharpening numerator weighting at 12.8kHz */ -#define FORMANT_SHARPENING_G2 0.9f /* Formant sharpening denominator weighting at 12.8kHz */ -#define FORMANT_SHARPENING_G1_16k 0.8f /* Formant sharpening numerator weighting at 16kHz */ -#define FORMANT_SHARPENING_G2_16k 0.92f /* Formant sharpening denominator weighting at 16kHz */ - -#define FSCALE_DENOM 512 +#define PREEMPH_FAC_FLT 0.68f /* preemphasis factor at 12.8kHz */ +#define PREEMPH_FAC_16k_FLT 0.72f +#define PREEMPH_FAC_SWB_FLT 0.9f /* preemphasis factor for super wide band */ +#define GAMMA1_FLT 0.92f /* weighting factor (numerator) default:0.92 */ +#define GAMMA16k_FLT 0.94f + +#define FORMANT_SHARPENING_G1_FLT 0.75f /* Formant sharpening numerator weighting at 12.8kHz */ +#define FORMANT_SHARPENING_G2_FLT 0.9f /* Formant sharpening denominator weighting at 12.8kHz */ +#define FORMANT_SHARPENING_G1_16k_FLT 0.8f /* Formant sharpening numerator weighting at 16kHz */ +#define FORMANT_SHARPENING_G2_16k_FLT 0.92f /* Formant sharpening denominator weighting at 16kHz */ + +#define PREEMPH_FAC 22282 /* preemphasis factor at 12.8kHz (0.68f in 0Q15) */ +#define PREEMPH_FAC_16k 23593 /* preemphasis factor at 16kHz (0.72f in 0Q15) */ +#define PREEMPH_FAC_SWB 29491 /* preemphasis factor for super wide band (0.9f in 0Q15) */ +#define GAMMA1 30147 /* weighting factor (numerator) default:0.92 (0Q15format) */ +#define GAMMA1_INV 17809 /* weighting factor (numerator) default:0.92 (1Q14format) */ +#define GAMMA16k 30802 /* weighting factor (numerator) default:0.94 (0Q15format) */ +#define GAMMA16k_INV 17430 /* weighting factor (numerator) default:0.94 (1Q14format) */ + +#define FORMANT_SHARPENING_G1 24576 /* Formant sharpening numerator weighting at 12.8kHz (0.75f) */ +#define FORMANT_SHARPENING_G2 29491 /* Formant sharpening denominator weighting at 12.8kHz (0.9f) */ +#define FORMANT_SHARPENING_G1_16k 26214 /* Formant sharpening numerator weighting at 16kHz (0.8f) */ +#define FORMANT_SHARPENING_G2_16k 30147 /* Formant sharpening denominator weighting at 16kHz (0.92f) */ + +#define LD_FSCALE_DENOM 9 +#define FSCALE_DENOM (1 << LD_FSCALE_DENOM) +#define FSCALE_DENOM_HALF FSCALE_DENOM/2 +#define FSCALE_E 2 #define ACELP_FIXED_CDK_NB 41 #define ACELP_FIXED_CDK_BITS( n ) PulseConfTable[n].bits @@ -848,6 +994,12 @@ enum #define G_AVQ_MIN 0.80f /* lower limit for gain Q in higher-rate ACELP contribution */ #define G_AVQ_MAX 96.0f /* upper limit for gain Q in higher-rate ACELP contribution */ #define FAC_PRE_AVQ 0.3f /* preemhasis factor in ACELP pre-quantizer */ +#define G_AVQ_MIN_FX 6554 /* Q13 */ +#define G_AVQ_MIN_DIV10_FX 655 /* Q13 */ +#define G_AVQ_MAX_FX 6144 /* Q6 */ +#define FAC_PRE_AVQ_FX 9830 /* preemhasis factor in ACELP pre-quantizer (0.3 in Q15) */ + + #define G_AVQ_MIN_INACT 0.70f /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments */ #define G_AVQ_MAX_INACT 4.1f /* upper limit for gain Q in higher-rate ACELP contribution, inactive segments */ @@ -855,6 +1007,12 @@ enum #define G_AVQ_MAX_INACT_48k 2.8f /* upper limit for gain Q in higher-rate ACELP contribution, inactive segments, 48 kbps */ #define G_AVQ_MIN_INACT_64k 0.25f /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments, 64 kbps */ #define G_AVQ_MAX_INACT_64k 1.5f /* upper limit for gain Q in higher-rate ACELP contribution, inactive segments, 64 kbps */ +#define G_AVQ_MIN_INACT_Q12 2867 /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments (0.7 in Q12) */ +#define G_AVQ_MIN_INACT_48k_Q12 1434 /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments, 48 kbit/s (0.35 in Q12) */ +#define G_AVQ_MIN_INACT_64k_Q12 1024 /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments, 64 kbit/s (0.25 in Q12 )*/ +#define G_AVQ_DELTA_INACT_Q12 221 /* (4.1 - 0.7) / ((1 << G_AVQ_BITS) - 1) in Q12 */ +#define G_AVQ_DELTA_INACT_48k_Q12 159 /* (2.8 - 0.35) / ((1 << G_AVQ_BITS) - 1) */ +#define G_AVQ_DELTA_INACT_64k_Q12 81 /*(1.5 - 0.25) / ((1 << G_AVQ_BITS) - 1) */ #define G_AVQ_DELTA_INACT_48k ( G_AVQ_MAX_INACT_48k - G_AVQ_MIN_INACT_48k ) / ( ( 1 << G_AVQ_BITS ) - 1 ) #define G_AVQ_DELTA_INACT_64k ( G_AVQ_MAX_INACT_64k - G_AVQ_MIN_INACT_64k ) / ( ( 1 << G_AVQ_BITS ) - 1 ) #define G_AVQ_BITS 6 /* number of bits to quantize the AVQ gain in higher-rate ACELP contribtuion */ @@ -871,8 +1029,31 @@ enum #define G_CODE_MIN_TC192 0.6f #define G_CODE_MAX_TC192 41.0f +#define G_PITCH_MIN_Q14 0 +#define G_PITCH_MAX_Q13 9994/*1.22 */ +#define G_PITCH_MAX_Q14 19988 /* 1.22 in Q14 */ + +#define G_CODE_MIN_FX 164 /* Q13 */ +#define G_CODE_MAX_FX 320 /* Q6 */ + +#define G_PITCH_MIN_TC192_Q14 1638 +#define G_PITCH_MAX_TC192_Q14 15565 /* 0.95 in Q14 */ +#define G_PITCH_MAX_MINUS_MIN_TC192_Q13 6963/*(G_PITCH_MAX_TC192 - G_PITCH_MIN_TC192) */ +#define G_CODE_MIN_TC192_Q15 19661 +#define G_CODE_MIN_TC192_FX 4915 /* Q13 */ +#define G_CODE_MAX_TC192_Q0 41 + #define BIT_SAVING_LOW_THR 10 #define BIT_SAVING_HIGH_THR 80 + /*--------------------------------------------------------------* + * ACELP constants + *---------------------------------------------------------------*/ + +#define MODE_MAX 15 + +#define NB_PULSES_MAX 15 +#define ACELP_GAINS_CONST 0.8f /* ACELP - adaptive codebook gain constraint */ + /*--------------------------------------------------------------* * TCX constants @@ -884,7 +1065,9 @@ enum #define NBITS_NOISE_FILL_LEVEL 3 /* Number of bits used for coding noise filling level for each range */ #define NF_GAIN_BITS ( NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL ) #define MIN_NOISE_FILLING_HOLE 8 -#define HOLE_SIZE_FROM_LTP( gain ) ( 4 + ( int16_t )( 2.0f * gain * ( 4.0f / 0.625f ) ) ) +#define HOLE_SIZE_FROM_LTP_FLT( gain ) ( 4 + ( int16_t )( 2.0f * gain * ( 4.0f / 0.625f ) ) ) +#define HOLE_SIZE_FROM_LTP(gain) (add(4, extract_h(L_shr(L_mult0(gain, 0x6666), 10)))) /* 0x6666 -> 2.0*(4.0/0.625) (4Q11) */ + #define FDNS_NPTS 64 #define AVG_TCX20_LSF_BITS 40 #define AVG_TCX10_LSF_BITS 59 @@ -900,6 +1083,8 @@ enum #define N_MAX_ARI 800 #define N_LTP_GAIN_MEMS 4 +#define SPEC_EXP_DEC 20 /* initial decoder spectrum exponent */ + #define N_TCX_STARTLINE_NOISE_WB 11 #define N_TCX_STARTLINE_NOISE_SWB 9 @@ -947,6 +1132,15 @@ enum #define NC M / 2 #define LSF_GAP 50.0f + +#define SPC_FX 770 /* q15 */ +#define SPC_PLUS_FX 771 + +#define LSF_GAP_FX 128 /*50.0f x 2.56*/ +#define MODE1_LSF_GAP_FX 179 /* MODE1_LSF_GAP*2.56 */ /* Minimum LSF separation for end-frame ISFs */ +#define FREQ_MAX 16384 /*6400Hz in 14Q1*1.28 */ +#define FREQ_DIV 800 /*400.0f in 14Q1 */ + #define LSF_BITS_CNG 29 #define MU_MA ( 1.0f / 3.0f ) /* original prediction factor (only for AMR-WB IO mode) */ @@ -954,11 +1148,18 @@ enum #define LSF_GAP_MID 80.0f /* Minimum LSF separation for mid-frame LSFs */ #define MODE1_LSF_GAP 70.0f /* Minimum LSF separation for end-frame ISFs */ #define PREFERSFNET 1.05 -#define SFNETLOWLIMIT_WB 35000 /* new sampling rate dependent thresholds used in LSF codebook decision logic, WB case */ -#define SFNETLOWLIMIT_NB 38000 /* new sampling rate dependent thresholds used in LSF codebook decision logic, NB case */ +#define ISF_GAP_FX 128 /* Minimum ISF separation for end-frame ISFs (only in AMR-WB IO mode) */ +#define LSF_GAP_MID_FX 205 /* 80.0 * 2.56 */ /* Minimum LSF separation for mid-frame LSFs */ +#define PREFERSFNET_FX 1638 /* 0.05 in Q16*/ + +#define SFNETLOWLIMIT_WB_FLT 35000 /* new sampling rate dependent thresholds used in LSF codebook decision logic, WB case */ +#define SFNETLOWLIMIT_NB_FLT 38000 /* new sampling rate dependent thresholds used in LSF codebook decision logic, NB case */ +#define SFNETLOWLIMIT_WB 3670016 /* 2.56x2.56*Q4 LSF quantizer - new sampling rate dependent thresholds used in LSF codebook decision logic, WB case */ +#define SFNETLOWLIMIT_NB 3984589 /* 2.56x2.56*Q4 LSF quantizer - new sampling rate dependent thresholds used in LSF codebook decision logic, NB case */ #define LSFMBEST 2 /* number of survivors from one stage to another */ #define STREAKLEN 3 /* Allow this many predictive frames, before starting limiting */ #define STREAKMULT 0.8f /* Exponential limiting multiplier */ +#define STREAKMULT_FX 26214 /* Exponential limiting multiplier */ #define LSFMBEST_MAX 16 @@ -966,7 +1167,10 @@ enum #define TCXLPC_NUMBITS 13 #define TCXLPC_IND_NUMSTAGES 1 #define TCXLPC_IND_NUMBITS 2 -#define TCXLPC_LSF_GAP 80.0f +#define TCXLPC_LSF_GAP_FLT 80.0f +#define TCXLPC_LSF_GAP 204 /* 80 in 14Q1*1.28 */ +#define kMaxC 8 + #define MAX_VQ_STAGES 4 #define MAX_VQ_STAGES_USED 9 /* this is the maximum number of stages currently used and changing this will affect the memory allocated \ @@ -995,7 +1199,8 @@ enum #define N_STAGE_VQ 8 #define N_DIM 2 #define NUM_SUBSET 8 -#define OP_LOOP_THR_HVO 3784536.3f /* 80% : Open-loop Threshold */ +#define OP_LOOP_THR_HVO_FLT 3784536.3f /* 80% : Open-loop Threshold */ +#define OP_LOOP_THR_HVO 1550146 /* 80% : Open-loop Threshold 2.56*2.56/16 */ #define NUM_STATE 16 /* BC-TCQ - Number of state of the Trellis */ #define N_STAGE 16 /* BC-TCQ - Smaple number in a frame */ @@ -1035,6 +1240,11 @@ enum #define MIN_OVERLAP 2 #define HALF_OVERLAP 3 #define ALDO_WINDOW 4 +#define WINDECAY48 1230 +#define WINDECAY48_256 656 +#define WINDECAY16 410 +#define N16_CORE_SW 90 +#define N_ZERO_8 45 #define SWITCH_OVERLAP_8k 15 /* == NS2SA(8000, SWITCH_GAP_LENGTH_NS) - NS2SA(8000, 10000000.0f - N_ZERO_MDCT_NS) */ #define SWITCH_GAP_LENGTH_8k 50 @@ -1063,6 +1273,8 @@ enum #define BETA_FEC 0.75f /* FEC - weighting factor for LSF estimation in FER */ #define STAB_FAC_LIMIT 0.25f /* FEC - limit at which safety net is forced for next frame */ +#define BETA_FEC_FX 24576 /* FEC - weighting factor for LSF estimation in FER */ +#define STAB_FAC_LIMIT_FX 8192 /* FEC - limit at which safety net is forced for next frame */ #define MODE1_L_FIR_FER 5 /* FEC - impulse response length for low- and high-pass filters in FEC */ #define L_FIR_FER 3 /* impulse response length for low- & high-pass filters in FER concealment */ @@ -1074,12 +1286,20 @@ enum #define ALPHA_UT 0.8f /* FEC - damping factor for UNVOICED_TRANSITION frames */ #define ALPHA_U 0.4f /* FEC - damping factor for UNVOICED_CLAS frames */ #define ALPHA_UU 1.0f /* FEC - damping factor for UNVOICED_CLAS frames */ + /* attenuation strategy in case of FER */ +#define _ALPHA_S_FX 19661 +#define _ALPHA_V_FX 32767 +#define _ALPHA_VT_FX 13107 +#define _ALPHA_UT_FX 26214 +#define _ALPHA_U_FX 13107 +#define _ALPHA_U_FX_X_2 26214 +#define _ALPHA_UU_FX 32767 #define AGC 0.98f -#define PLC_MIN_CNG_LEV 0.01f /* minimum background level */ +#define PLC_MIN_CNG_LEV_FLT 0.01f /* minimum background level */ +#define PLC_MIN_CNG_LEV 328/*0.01f Q15*/ #define PLC_MIN_STAT_BUFF_SIZE 50 /* buffer size for minimum statistics */ -#define PLC_MIN_CNG_LEV 0.01f #define G_LPC_RECOVERY_BITS 1 /*----------------------------------------------------------------------------------* @@ -1091,6 +1311,11 @@ enum #define TC_SUBFR2IDX_16KHZ( x ) ( x == 0 ? 0 : x == 64 ? 1 : x == 128 ? 2 : x == 192 ? 3 : x == 256 ? 4 : 0 ) +#define TC_SUBFR2IDX_16KHZ_fx(x) mac_r(1024L, (x), 512) /* -1 => 0, 0 => 0, 64 => 1, 128 => 2, 192 => 3, 256 => 4 */ + +#define TC_SUBFR2IDX_fx(x) add(s_min(3, s_max(0, sub((x), 1))), TC_SUBFR2IDX_16KHZ_fx(x)) + + #define L_IMPULSE 17 /* TC - length of one prototype impulse */ #define L_IMPULSE2 8 /* TC - half-length of one prototype impulse == floor(L_IMPULSE/2) */ #define NUM_IMPULSE 8 /* TC - number of prototype impulses */ @@ -1144,6 +1369,9 @@ enum *----------------------------------------------------------------------------------*/ #define MAX_PULSES 560 +#define MAX_POS 320 +#define MAX_LEN MAX_PULSES +#define NUM_ENG_PACKED_WORDS 20 /* Storage for variable rate quantizer bits */ #define NORMAL_HQ_CORE 0 /* Signal use of Normal HQ core */ #define LOW_RATE_HQ_CORE 1 /* Signal use of Low Rate MDCT core */ @@ -1208,6 +1436,7 @@ enum #define NUM_BITS_SHB_FrameGain_LBR_WB 4 #define RECIP_ROOT_EIGHT 0.3535534f /* 1.0 / sqrt(8.0) - constant Gain Shape over TD BWE subframes */ +#define RECIP_ROOT_EIGHT_FX 11585 /* 1.0 / sqrt(8.0) - constant Gain Shape over TD BWE subframes */ #define LPC_SHB_ORDER_WB 6 #define LPC_WHTN_ORDER_WB 2 /* Order of whitening filter for WB excitation */ @@ -1230,10 +1459,20 @@ enum #define SHB_GAIN_QDELTA 0.15f /* SHB gain scalar quantizer stepsize */ #define SHB_GAIN_QLOW_1k75 0.0f /* SHB gain lowest scalar quantizer value */ #define SHB_GAIN_QDELTA_1k75 0.08f /* SHB gain scalar quantizer stepsize */ +#define SHB_GAIN_QLOW_FX -262144 /* Q18*/ /* SHB gain lowest scalar quantizer value */ +#define SHB_GAIN_QLOW_FX_16 -65536 /* SHB gain lowest scalar quantizer value */ +#define SHB_GAIN_QDELTA_FX_15 4915 /* SHB gain scalar quantizer step size */ +#define SHB_GAIN_QDELTA_FX_16 9830 +#define SHB_GAIN_QDELTA_FX 19661 /* 0.15 in Q17*/ + #define NUM_Q_LSF 5 /* Number of quantized LSFs */ #define MIRROR_POINT_BITS 2 /* Number of bits used to quantize mirror point */ #define MIRROR_POINT_Q_CB_SIZE 4 /* Size of codebook used to quantize mirror point */ #define MAX_LSF 0.5f /* Maximum value of the LSFs */ +#define MAX_LSF_FX_2 8192 /* Maximum value of the LSFs */ +#define MAX_LSF_FX 16384 /* Maximum value of the LSFs */ +#define MAX_LSF_FX_BY_2 8192 /* Maximum value of the LSFs */ + #define NUM_MAP_LSF 5 /* Number of mapped LSFs */ #define NUM_LSF_GRIDS 4 /* Number of LSF grids */ #define NUM_LSF_GRID_BITS 2 /* Number of bits used for the LSF grids */ @@ -1242,6 +1481,10 @@ enum #define VF_0th_PARAM 0.34f #define VF_1st_PARAM 0.5f #define VF_2nd_PARAM ( VF_1st_PARAM - VF_0th_PARAM ) +#define VF_0th_PARAM_FX 11141 /*.34*/ +#define VF_1st_PARAM_FX 16384 /*.5*/ +#define VF_2nd_PARAM_FX (VF_1st_PARAM_FX - VF_0th_PARAM_FX) + #define GAMMA0 0.65f /* Mean value of gamma1/gamma2 for formant PF */ #define GAMMA_SHARP 0.15f /* Largest sharpening for gamma1/gamma2 (0.83/0.67)*/ @@ -1254,21 +1497,42 @@ enum #define AGC_FAC_WB 0.85f /* WB post-filter - gain adjustment factor */ #define AGC_FAC1_WB ( 1.0f - AGC_FAC_WB ) /* WB post-filter - gain adjustment factor complement */ +#define GAMMA0_FX 21299 /* Mean value of gamma1/gamma2 for formant PF */ +#define GAMMA_SHARP_FX 4915 /* Largest sharpening for gamma1/gamma2 (0.83/0.67)*/ +#define SWB_NOISE_MIX_FAC_FX 4915 /* 0.15f in Q15 */ +#define SWB_TILT_LOW_FX 4096 /* Q12 1.0f Lower threshold for PF tilt adaptation */ +#define SWB_TILT_HIGH_FX 8192 /* Q12 2.0f Higher threshold for PF tilt adaptation */ +#define SWB_TILT_DELTA_FX 32767 /* Q15 (1.0f/(SWB_TILT_HIGH-SWB_TILT_LOW)) Inclination between thresholds */ +#define HALF_POINT_FX (16384) +#define GAMMA3_PLUS_FX 6554 /* NB post-filter - tilt weighting factor when k1>0 */ +#define GAMMA3_MINUS_FX 29491 /* NB post-filter - tilt weighting factor when k1<0 */ +#define GAMMA3_PLUS_WB_FX 21299 /* WB post-filter */ +#define GAMMA3_MINUS_WB_FX 27853 /* WB post-filter */ +#define AGC_FAC_WB_FX 27853 /* WB post-filter - gain adjustment factor */ +#define AGC_FAC1_WB_FX (Word16)(32768L-AGC_FAC_WB_FX) /* WB post-filter - gain adjustment factor complement */ + + #define MAX_LEN_MA_FILTER 20 /* maximum length of the MA filter for SHB TD envelope calculation */ #define TABLE_CUMSUM_MAX_N 320 /* maximum length of cumsum(i) and cumsum(i*i) tables */ #define NUM_BITS_FB_FRAMEGAIN_TBE 4 /* Number of bits for framegain for FB TBE */ +/* SWB TBE, FX only constants */ +#define NOISE_QFAC 6 +#define NOISE_QADJ (15-NOISE_QFAC) /*----------------------------------------------------------------------------------* * SWB BWE constants *----------------------------------------------------------------------------------*/ #define INV_L_SUBFR16k 0.0125f +#define INV_L_SUBFR16k_FX 410 /*Q15 */ #define SWB_L_SUBFR 160 #define FB_L_SUBFR 240 #define SWB_FENV 14 #define FB_GAIN_QLOW 0.0f #define FB_GAIN_QDELTA 0.03125f +#define FB_GAIN_QLOW_FX 0 +#define FB_GAIN_QDELTA_FX 512 /*Q14 */ #define FB_MAX_GAIN_VAR 0.5f @@ -1344,6 +1608,13 @@ enum #define BWE_HR_NONTRANS_EN_LIMIT1 0.5f /* HF (noncoded) energy equalization limit 1, non-transient frames */ #define BWE_HR_NONTRANS_EN_LIMIT2 1.2f /* HF (noncoded) energy equalization limit 2, non-transient frames */ #define BWE_HR_NONTRANS_EN_LIMIT3 0.8f /* HF (noncoded) energy equalization limit 3, non-transient frames */ +#define BWE_HR_TRANS_EN_LIMIT1_FX_Q16 6554 +#define BWE_HR_TRANS_EN_LIMIT2_FX_Q16 19661 +#define BWE_HR_TRANS_EN_LIMIT3_FX_Q16 32767 +#define BWE_HR_NONTRANS_EN_LIMIT1_FX_Q15 16384 /* 0.5 */ +#define BWE_HR_NONTRANS_EN_LIMIT2_FX_Q14 19661 /* 1.2 */ +#define BWE_HR_NONTRANS_EN_LIMIT2_FX_Q15 16384 +#define BWE_HR_NONTRANS_EN_LIMIT3_FX_Q15 26214 /* 0.8 */ /*----------------------------------------------------------------------------------* * FD CNG @@ -1365,7 +1636,11 @@ enum #define OUTMAX_INV 0.000030517578125f /* 1/2^15 */ #define OUTMAX_SQ 1073741824.f /* 2^30 */ #define OUTMAX_SQ_INV 0.00000000093132257461547852f /* 1/2^30 */ + #define DELTA ( 1e-20f ) +#define DELTA_MANTISSA_W16 0x5e73 +#define DELTA_MANTISSA_W32 0x5e728433 +#define DELTA_EXPONENT (-66) #define CLDFB_SCALING ( 1.5f ) @@ -1399,25 +1674,51 @@ typedef enum _DCTTYPE #define MSSUBFRLEN 12 #define MSNUMSUBFR 6 #define MSBUFLEN 5 -#define MSALPHACORALPHA 0.7f -#define MSALPHACORMAX 0.3f -#define MSALPHAMAX 0.96f -#define MSALPHAHATMIN 0.05f /* It is used for all bands except the first one to get a stable bass */ -#define MSQEQINVMAX ( 1.f / 5.f ) -#define MSAV 2.12f -#define MSBETAMAX 0.8f -#define MSSNREXP ( -0.02f / 0.064f ) - -#define NB_LAST_BAND_SCALE 0.8f -#define SWB_13k2_LAST_BAND_SCALE 0.8f + +#define NOISE_HEADROOM 5 /* headroom of noise in generate_masking_noise */ + +#define MSALPHACORALPHA_FLT 0.7f +#define MSALPHACORMAX_FLT 0.3f +#define MSALPHAMAX_FLT 0.96f +#define MSALPHAHATMIN_FLT 0.05f /* It is used for all bands except the first one to get a stable bass */ +#define MSQEQINVMAX_FLT ( 1.f / 5.f ) +#define MSAV_FLT 2.12f +#define MSBETAMAX_FLT 0.8f +#define MSSNREXP_FLT ( -0.02f / 0.064f ) +#define MSALPHACORALPHA 22938/*0.7f Q15*/ +#define MSALPHACORALPHA2 9830/*0.3f Q15*/ +#define MSALPHACORMAX 9830/*0.3f Q15*/ +#define MSALPHAMAX 31457/*0.96f Q15*/ +#define MSALPHAHATMIN 107374184l/*0.05f Q31*/ +#define MSQEQINVMAX 6554/*1.f/5.f Q15*/ +#define MSAV 17367/*2.12f Q13*/ +#define MSAV_EXP 2 +#define MSBETAMAX 1717986944l/*0.8f Q31*/ +#define MSBETAMAX_SQRT 1920767767l/*0.894427191 Q31*/ /* sqrt(MSBETAMAX) */ +#define MSSNREXP -10240/*-0.02f/0.064f Q15*/ + +#define NB_LAST_BAND_SCALE_FLT 0.8f +#define SWB_13k2_LAST_BAND_SCALE_FLT 0.8f +#define NB_LAST_BAND_SCALE 26214/*0.8f Q15*/ +#define SWB_13k2_LAST_BAND_SCALE 26214/*0.8f Q15*/ #define CNG_LOG_SCALING 512.f /*2^9*/ #define M_MAX 32 +#define NSTAGES_MAX 9 +#define MBEST_MAX 8 #define N_GAIN_MIN 4 #define N_GAIN_MAX 17 +#define numSlots_inv_EXP (-3) +#define PREEMPH_COMPENSATION_EXP 4 + #define CHEAP_NORM_SIZE 161 +#define CLDFBscalingFactor_EXP (-15) +#define CLDFBinvScalingFactor_EXP ( 16) + +#define CNG_NORM_RECIPROCAL_RANGE_SHIFT 2 +#define CNG_RAND_GAUSS_SHIFT 2 #define CNA_MAX_BRATE ACELP_13k20 @@ -1443,10 +1744,20 @@ typedef enum _DCTTYPE #define LONG_H_ST 20 /* NB post-filter - impulse response length */ #define POST_G1 0.75f /* NB post-filter - denominator weighting factor 12kbps */ #define POST_G2 0.7f /* NB post-filter - numerator weighting factor 12kbps */ +#define GAMMA1_PST12K_FX 24576 /* denominator weighting factor 12K (0.75 in Q15) */ +#define GAMMA2_PST12K_FX 22938 /* numerator weighting factor 12K (0.7 in Q15) */ +#define POST_G1_FX GAMMA1_PST12K_FX /* 12 kbps default */ +#define POST_G2_FX GAMMA2_PST12K_FX /* 12 kbps default */ + #define GAMMA1_PST 0.7f /* denominator weighting factor */ #define GAMMA2_PST 0.55f /* numerator weighting factor */ #define GAMMA3_PLUS 0.2f /* NB post-filter - tilt weighting factor when k1>0 */ #define GAMMA3_MINUS 0.9f /* NB post-filter - tilt weighting factor when k1<0 */ +#define GAMMA1_PST12K_MIN_FX 21299 /* 0.65 in Q15 */ +#define GAMMA2_PST12K_MIN_FX 18022 /* 0.55 in Q15 */ +#define GAMMA1_PST12K_NOIS_FX 4915 /* 0.15 in Q15 */ +#define GAMMA2_PST12K_NOIS_FX 3277 /* 0.10 in Q15 */ + #define F_UP_PST 8 /* NB post-filter - resolution for fractionnal delay */ #define LH2_S 4 /* NB post-filter - length of INT16 interp. subfilters */ #define LH2_L 16 /* NB post-filter - length of long interp. subfilters */ @@ -1470,6 +1781,13 @@ typedef enum _DCTTYPE #define C_LP_NOISE ( 0.1f / 4.0f ) #define K_LP_NOISE 15.0f #define LP_NOISE_THR 25.0f +#define BG1_FX -328 /* -0.01 in Q15 */ +#define BG2_FX -1638 /* -0.05 in Q15 */ +#define CG1_FX 29491 /* 0.9 in Q15 */ +#define CG2_FX 47514L /* 1.45 in Q15 */ +#define C_LP_NOISE_FX 819 /* 0.1/4.0 in Q15 */ +#define CK_LP_NOISE_FX 6291456L /* 15.0 * 0.1/4 in Q8 * 65536 */ +#define LP_NOISE_THR_FX 6400 /* 25.0 in Q8 */ /*----------------------------------------------------------------------------------* * Stability estimation @@ -1483,6 +1801,10 @@ typedef enum _DCTTYPE #define TH_1_MIN 1.875f #define TH_2_MIN 1.5625f #define TH_3_MIN 1.3125f +#define TH_0_MIN_FX 5120 /* 2.5f in Q11 */ +#define TH_1_MIN_FX 3840 /* 1.875f in Q11 */ +#define TH_2_MIN_FX 3200 /* 1.5625f in Q11 */ +#define TH_3_MIN_FX 2688 /* 1.3125f in Q11 */ /*----------------------------------------------------------------------------------* * Speech/music classifier constants @@ -1514,6 +1836,8 @@ typedef enum _DCTTYPE #define BUF_LEN 60 #define L_OVR 8 +#define N_FEATURES_2 3 /* number of features */ + #define ATT_NSEG 32 /* strong attack detection - number of time blocks */ #define TOD_NSPEC 80 /* number of spectral bins of the tonal detector */ @@ -1530,6 +1854,10 @@ typedef enum _DCTTYPE #define TH_1_MIN2 1.25f #define TH_2_MIN2 0.9375f #define TH_3_MIN2 0.625f +#define TH_0_MIN2_FX 3840 /* Q11 -> 1.875 */ +#define TH_1_MIN2_FX 2560 /* Q11 -> 1.25 */ +#define TH_2_MIN2_FX 1920 /* Q11 -> 0.9375 */ +#define TH_3_MIN2_FX 1280 /* Q11 -> 0.625 */ #define DCT_L_POST 640 #define OFFSET2 192 @@ -1667,10 +1995,13 @@ typedef enum _DCTTYPE #define MAXVALUEOFFIRSTGAIN 2.5f #define MINVALUEOFFIRSTGAIN -2.5f +#define MAXVALUEOFFIRSTGAIN_FX 20480 /*2.5f in Q13 */ +#define MINVALUEOFFIRSTGAIN_FX -20480 #define NOOFGAINBITS1 6 #define AUDIODELAYBITS 6 #define DELTAOFFIRSTGAIN (float) ( MAXVALUEOFFIRSTGAIN - MINVALUEOFFIRSTGAIN ) / (float) ( ( 1 << NOOFGAINBITS1 ) - 1 ) +#define DELTAOFFIRSTGAIN_FX 2601 /*Q15 */ #define MAX_D1M_16k ( ( L_FRAME16k >> 1 ) - NS2SA( 16000, SWITCH_GAP_LENGTH_NS ) - 16 ) #define MAX_D1M_12k8 ( ( L_FRAME16k >> 1 ) - NS2SA( 16000, SWITCH_GAP_LENGTH_NS ) - 20 ) @@ -1684,10 +2015,14 @@ typedef enum _DCTTYPE #define ENV_SMOOTH_FAC 0.1f /* Smoothing factor for envelope stability measure */ #define L_STAB_TBL 10 /* Number of elements in stability transition table */ +#define LUMPED_ENV_SMOOTH_FAC_FX ((Word16)10089) /* Q19 (no typo error), 0.1/sqrt(27) */ +#define CMPLMNT_ENV_SMOOTH_FAC_FX ((Word16)29491) /* Q15 0.9 */ #define M_STAB_TBL_FX ( (Word16) 21068 ) /* Q13, 2.571756 */ #define D_STAB_TBL_FX ( (Word16) 845 ) /* Q13 0.1013138 */ #define HALF_D_STAB_TBL_FX ( (Word16) 422 ) /* Q13 0.1013138/2.0 */ #define NUM_ENV_STAB_PLC_STATES 2 /* Number of states of markov model */ +#define INV_NUM_ENV_STAB_PLC_STATES 16384 /* Q15 */ +#define INV_STAB_TRANS_FX 16497 /* Q14. Equal to 1.0f/(1-2*stab_trans_fx[L_STAB_TBL-1]) */ #define ENV_STAB_EST1 2.93f /* env_stab estimation coefficient 1 */ #define ENV_STAB_EST2 (-2.20f) /* env_stab estimation coefficient 2 */ @@ -1772,13 +2107,25 @@ typedef enum _DCTTYPE #define HVQ_PE_WEIGHT2 0.80285f /* HVQ Classifier - Peak envelope estimate weight 2 */ #define HVQ_THR_POW 0.88f /* HVQ Classifier power factor for threshold calc */ #define HVQ_SHARP_THRES 9 /* HVQ Classifier - Sharpness threshold */ +#define HVQ_NF_WEIGHT1_FX 31385 /* Q15 0.9578 - HVQ Classifier - Noise floor estimate weight 1 */ +#define HVQ_NF_WEIGHT1B 1383 /* Q15, 1 - HVQ_NF_WEIGHT1_FX */ +#define HVQ_NF_WEIGHT2_FX 21207 /* Q15 0.6472 - HVQ Classifier - Noise floor estimate weight 2 */ +#define HVQ_NF_WEIGHT2B 11561 /* Q15 1 - HVQ_NF_WEIGHT2_FX */ +#define HVQ_PE_WEIGHT1_FX 13840 /* Q15 0.42237 - HVQ Classifier - Peak envelope estimate weight 1 */ +#define HVQ_PE_WEIGHT1B 18928 /* Q15, 1 - HVQ_PE_WEIGHT1_FX */ +#define HVQ_PE_WEIGHT2_FX 26308 /* Q15 0.80285 - HVQ Classifier - Peak envelope estimate weight 2 */ +#define HVQ_PE_WEIGHT2B 6460 /* Q15, 1 - HVQ_PE_WEIGHT2_FX */ +#define HVQ_SHARP_THRES_FX 576 /*9 in Q6 */ #define HVQ_PA_FAC 0.7071f /* HVQ Classifier peak allocation factor */ +#define HVQ_PA_FAC_FX 23170 /* Q15 0.7071 - HVQ Classifier peak allocation factor */ #define HVQ_PA_PEAKS_SHARP1 9 /* HVQ Classifier - Maximum number of peaks for band with high sharpness */ #define HVQ_PA_PEAKS_SHARP2 3 /* HVQ Classifier - Maximum number of peaks for band with medium sharpness */ #define HVQ_PA_PEAKS_SHARP3 2 /* HVQ Classifier - Maximum number of peaks for band with low sharpness */ #define HVQ_PA_SHARP_THRES2 16.0f /* HVQ Classifier - Sharpness threshold for band with medium sharpness */ #define HVQ_PA_SHARP_THRES3 12.0f /* HVQ Classifier - Sharpness threshold for band with low sharpness */ +#define HVQ_PA_SHARP_THRES2_FX 1024 /* Q6 16.0 - HVQ Classifier - Sharpness threshold for band with medium sharpness */ +#define HVQ_PA_SHARP_THRES3_FX 768 /* Q6 12.0 - HVQ Classifier - Sharpness threshold for band with low sharpness */ #define HVQ_BW 32 /* HVQ Classifier subband bandwidth */ #define HVQ_NSUB_32k 10 @@ -1793,6 +2140,10 @@ typedef enum _DCTTYPE #define HVQ_BWE_WEIGHT2 0.2f #define HVQ_NFPE_FACTOR 6.4f #define HVQ_LB_NFPE_FACTOR 3.2f +#define HVQ_BWE_WEIGHT1_FX ((Word16)31130) /* 0.95 in Q15 */ +#define HVQ_BWE_WEIGHT2_FX ((Word16)6554) /* 0.2 in Q15 */ +#define HVQ_NFPE_FACTOR_CUBE_FX ((Word16)16777) /* 6.4^3 in Q6 */ +#define HVQ_LB_NFPE_FACTOR_CUBE_FX ((Word16)16777) /* 3.2^3 in Q9 */ #define HVQ_VQ_DIM 5 /* HVQ peak VQ dimension */ #define HVQ_PVQ_GAIN_BITS 5 /* Number of bits to encode PVQ gains in HVQ */ @@ -1836,6 +2187,9 @@ enum QuantaMode #define KMAX 512 #define KMAX_NON_DIRECT 96 /* max K for non-direct indexing recursion rows */ #define ODD_DIV_SIZE 48 /* ind0=1/1 ind1 =1/3 ... ind47=1/95 */ +#define KMAX_FX 512 +#define KMAX_NON_DIRECT_FX 96 /* max K for non-direct indexing recursion rows is 1+KMAX_NON_DIRECT +1 */ +#define ODD_DIV_SIZE_FX 48 /* ind0=1/1 ind1 =1/3 ... ind47=1/95 */ /* TCQ */ #define TCQ_MAX_BAND_SIZE 120 /* Maxiumum supported band size for TCQ+USQ search */ @@ -1945,6 +2299,7 @@ enum QuantaMode #define SWB_BWE_LR_Qs 12 #define SWB_BWE_LR_Qbe 14 #define SWB_BWE_LR_QRk 16 +#define SWB_BWE_LR_QsEn 4 /* Q value of smoothed sqrt band energy */ /*----------------------------------------------------------------------------------* @@ -1991,7 +2346,8 @@ enum QuantaMode #define MAX_PLOCS L_PROT48k / 4 + 1 /* maximum number of spectral peaks to be searched */ #define QUOT_LPR_LTR 4 #define LGW_MAX 9 /* maximum number frequency group widths */ -#define BETA_MUTE_FAC_INI 0.5f /* initial noise attenuation factor */ +#define BETA_MUTE_FAC_INI_FLT 0.5f /* initial noise attenuation factor */ +#define BETA_MUTE_FAC_INI 16384 /* Q15, initial noise attenuation factor */ #define L_TRANA32k ( L_PROT32k / QUOT_LPR_LTR ) /* transient analysis frame length */ #define L_TRANA16k ( L_TRANA32k / 2 ) #define L_TRANA8k ( L_TRANA32k / 4 ) @@ -2014,6 +2370,10 @@ enum QuantaMode #define ED_THRES_12P 0.032209f #define ED_THRES_50P 0.159063f #define ED_THRES_90P 0.532669 +#define ED_THRES_12P_fx 66 +#define ED_THRES_50P_fx 326 +#define ED_THRES_90P_fx 1091 + #define MAXDELAY_FEC 224 #define RANDOM_START 1 @@ -2030,19 +2390,29 @@ enum QuantaMode #define GROUP_LENGTH 7 #define MAX_PEAKS_FROM_PITCH 10 #define LAST_HARMONIC_POS_TO_CHECK 128 /* 128 because we check harmonics only up to 3.2 kHz */ -#define ALLOWED_SIDE_LOBE_FLUCTUATION 3.0f /* 4.8 dB */ -#define LEVEL_ABOVE_ENVELOPE 7.59f /* 8.8 dB */ -#define UNREACHABLE_THRESHOLD 16.0f /* 12 dB Increase of LEVEL_ABOVE_ENVELOPE so that the threshold is not reached */ -#define SMALL_THRESHOLD 1.10f /* 0.41 dB Increase of LEVEL_ABOVE_ENVELOPE for the peak detection at a definitive peak in the estimated spectrum */ -#define BIG_THRESHOLD 1.5f /* 1.76 dB Increase of LEVEL_ABOVE_ENVELOPE for the peak detection at a probable peak in the estimated spectrum */ +#define ALLOWED_SIDE_LOBE_FLUCTUATION_FLT 3.0f /* 4.8 dB */ +#define ALLOWED_SIDE_LOBE_FLUCTUATION 24576/*3.0f Q13*/ /* 4.8 dB */ +#define ALLOWED_SIDE_LOBE_FLUCTUATION_EXP 2 +#define LEVEL_ABOVE_ENVELOPE_FLT 7.59f /* 8.8 dB */ +#define UNREACHABLE_THRESHOLD_FLT 16.0f /* 12 dB Increase of LEVEL_ABOVE_ENVELOPE_FLT so that the threshold is not reached */ +#define SMALL_THRESHOLD_FLT 1.10f /* 0.41 dB Increase of LEVEL_ABOVE_ENVELOPE_FLT for the peak detection at a definitive peak in the estimated spectrum */ +#define BIG_THRESHOLD_FLT 1.5f /* 1.76 dB Increase of LEVEL_ABOVE_ENVELOPE_FLT for the peak detection at a probable peak in the estimated spectrum */ +#define LEVEL_ABOVE_ENVELOPE 7.59f /* 8.8 dB */ +#define UNREACHABLE_THRESHOLD 16384/*16.0f Q10*/ /* 12 dB Increase of LEVEL_ABOVE_ENVELOPE so that the threshold is not reached */ +#define SMALL_THRESHOLD 1126/*1.10f Q10*/ /* 0.41 dB Increase of LEVEL_ABOVE_ENVELOPE for the peak detection at a definitive peak in the estimated spectrum */ +#define BIG_THRESHOLD 1536/*1.5f Q10*/ /* 1.76 dB Increase of LEVEL_ABOVE_ENVELOPE for the peak detection at a probable peak in the estimated spectrum */ #define kSmallerLagsTargetBitsThreshold 150 -#define kCtxHmOlRSThr 2.6f +#define kCtxHmOlRSThr_FLT 2.6f +#define kLtpHmGainThr_FLT 0.46f /* Use the LTP pitch lag in the harmonic model? */ +#define kLtpHmGainThr 0x3AE1 /* 0.46f */ +#define kCtxHmOlRSThr 0x5333 /* 2.6f (2Q13) */ +#define kTcxHmSnrOffsetGc 8/*0.03125f Q8*/ +#define kTcxHmSnrOffsetVc 0 #define kTcxHmNumGainBits 2 /* Number of bits for the gain index */ #define kTcxHmParabolaHalfWidth 4 /* Parabola half width */ -#define kLtpHmGainThr 0.46f /* Use the LTP pitch lag in the harmonic model? */ #define LOWRATE_TCXLPC_MAX_BR_CPE ACELP_13k20 #define LOWRATE_TCXLPC_MAX_BR ACELP_9k60 @@ -2149,9 +2519,29 @@ enum #define VBR_ADR_MAX_TARGET 6.15f /* max target ADR for VBR. This rate is used in the closed loop rate control */ #define PPP_LAG_THRLD 180 /* max lag allowed for PPP coding */ +#define PPP_LAG_THRLD_Q6 180*64 +#define PPP_LAG_THRLD 180 +#define SNR_THLD_FX_Q8 17152 /* Threshold is upscaled to Q8 to compared with st->vadsnr*/ + + #define MAXLAG_WI ( PPP_LAG_THRLD / 2 + 12 ) /* Maximum lag used in waveform interpolation */ #define MAX_LAG_PIT ( PPP_LAG_THRLD + 21 ) /* Max possible pitch lag after adding delta lag */ +#define WI_FX_phase_fx 512 + +#define VBR_ADR_MAX_TARGET_x10_Q1 123 /* VBR_ADR_MAX_TARGET(6.15f)*10 in Q1 */ + +#define Q_SCALE 7 + +#define CONST_1_16_Q14 19005 /* 1.16*16384 */ +#define CONST_1_37_Q14 22446 /* 1.37*16384 */ +#define SCALE_DOWN_ERAS_Q15 26214 /* 0.8*32768 */ +#define SHAPE1_COEF_QF 15 /* shape1 num and den coeffcient Q format */ +#define SHAPE2_COEF_QF 15 /* shape2 num and den coeffcient Q format */ +#define SHAPE3_COEF_QF 15 /* shape3 num and den coeffcient Q format */ +#define BP1_COEF_WB_QF 14 /* wb num and den coeffcient Q format */ +#define BP1_COEF_NB_QF_ORDER7 13 /* nb num and den coeffcient Q format */ + /*----------------------------------------------------------------------------------* * JBM *----------------------------------------------------------------------------------*/ @@ -2159,6 +2549,203 @@ enum #define MAX_JBM_SLOTS 100 /* every primary copy and partial copy stored in JBM needs one slot */ #define MAX_AU_SIZE ( ( MAX_BITS_PER_FRAME + 7 ) / 8 ) /* max frame size in bytes */ +#define ACTIVE 4 +#define BACKGROUND 1 +#define LOST 14 +#define SIZE_UNDERFLOW_ARRAY 10000 +#define TIME_WARP_SPACING 4 +#define FLAG_DECREASING_BUFFER_DEPTH 1 +#define TIME_WARP_SPACING_EXPAND 1 +#define PREALLOCATE_OUTPUT_SIZE 1000 + + /*------------------------------------------------------------------------------------* + FEC_clas_estim constants + *-------------------------------------------------------------------------------------*/ +#define Q_MAX 12 +#define LG10 24660 /* 10*log10(2) in Q13 */ +#define L_Q_MEM 5 + +#define GE_SHIFT 6 +#define LSF_1_OVER_256SQ 5000 +#define LSF_1_OVER_256SQSQ 763 + +#define G_CODE_MIN_TC_Q15 655 /*0.02 Q15*/ +#define G_CODE_MAX_TC_Q0 5 + +#define G_PITCH_MIN_Q14 0 /* SQ of gains: pitch gain lower limit (0.0 in Q13) */ +#define G_PITCH_MAX_MINUS_MIN_Q13 9994 /* SQ of gains: pitch gain upper limit (1.22-0 in Q13) */ + /* higher ACELP constants */ +#define G_AVQ_MIN_32kbps_Q15 2621 /* lower limit for gain Q in higher-rate ACELP contribtuion @32kbps (0.08 in Q15) */ +#define G_AVQ_MIN_Q15 26214 /* lower limit for gain Q in higher-rate ACELP contribtuion (0.8 in Q15) */ +#define G_AVQ_MAX_Q0 96 /* upper limit for gain Q in higher-rate ACELP contribtuion */ + +#define LG10_G_AVQ_MIN_32kbps_Q14 (-17972) /* log10(0.08) lower limit for gain Q in higher-rate ACELP contribtuion @32kbps (0.08 in Q15) */ +#define LG10_G_AVQ_MIN_Q14 (-1588) /* log10(0.8) lower limit for gain Q in higher-rate ACELP contribtuion (0.8 in Q15) */ +#define LG10_G_AVQ_MAX_Q13 16239 /* log10(96) upper limit for gain Q in higher-rate ACELP contribtuion */ +#define LG10_G_CODE_MIN_TC192_Q14 (-3635) /* log10(0.6) */ +#define LG10_G_CODE_MAX_TC192_Q13 13212 /* log10(41) */ +#define LG10_G_CODE_MAX_Q13 5726 /* log10(5) SQ of gains: code gain upper limit */ +#define LG10_G_CODE_MIN_Q14 (-27836) /* log10(0.02) SQ of gains: code gain lower limit */ +#define LG10_G_CODE_MIN_TC_Q14 LG10_G_CODE_MIN_Q14 /* log10(0.02) Q15*/ +#define LG10_G_CODE_MAX_TC_Q13 LG10_G_CODE_MAX_Q13 + +/* AVQ (RE8) related consatnts */ +#define QR 32768 +#define Q_AVQ_OUT 6 /* AVQ_output scaling currently Q9, but may change */ +#define Q_AVQ_OUT_DEC 10 + +#define PIT_DECODE_2XL_SUBFR (2*L_SUBFR) +#define PIT_FR1_8b_MINUS_PIT_MIN_X2 ((PIT_FR1_8b-PIT_MIN)*2) +#define PIT_FR1_8b_MINUS_PIT_FR1_8b_MINUS_PIT_MIN_X2 (PIT_FR1_8b-PIT_FR1_8b_MINUS_PIT_MIN_X2) +#define PIT_FR2_9b_MINUS_PIT_MIN_X4 ((PIT_FR2_9b-PIT_MIN)*4) +#define PIT_FR1_EXT8b_MINUS_PIT_MIN_EXT_X2 ((PIT_FR1_EXTEND_8b-PIT_MIN_EXTEND)*2) +#define PIT_FR2_EXT9b_MINUS_PIT_MIN_EXT_X4 ((PIT_FR2_EXTEND_9b-PIT_MIN_EXTEND)*4) +#define PIT_FR1_EXT9b_MINUS_PIT_FR2_EXT9b_X2 ((PIT_FR1_EXTEND_9b-PIT_FR2_EXTEND_9b)*2) +#define PIT_FR1_DEXT8b_MINUS_PIT_MIN_DEXT_X2 ((PIT_FR1_DOUBLEEXTEND_8b-PIT_MIN_DOUBLEEXTEND)*2 ) +#define PIT_FR2_DEXT9b_MINUS_PIT_MIN_DEXT_X4 ((PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4 ) + +#define PIT_DECODE_1 ((PIT_FR2_9b-PIT_MIN)*4 + (PIT_FR1_9b-PIT_FR2_9b)*2) +#define PIT_DECODE_2 ((PIT_FR2_9b-PIT_MIN)*4) +#define PIT_DECODE_3 (PIT_FR1_9b - ((PIT_FR2_9b-PIT_MIN)*4) - ((PIT_FR1_9b-PIT_FR2_9b)*2)) +#define PIT_DECODE_7 (PIT_FR1_EXTEND_9b - (PIT_FR2_EXT9b_MINUS_PIT_MIN_EXT_X4) - (PIT_FR1_EXT9b_MINUS_PIT_FR2_EXT9b_X2)) +#define PIT_DECODE_8 (PIT_FR1_DOUBLEEXTEND_8b - ((PIT_FR1_DOUBLEEXTEND_8b-PIT_MIN_DOUBLEEXTEND)*2)) +#define PIT_DECODE_9 (( (PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4 + (PIT_FR1_DOUBLEEXTEND_9b-PIT_FR2_DOUBLEEXTEND_9b)*2)) +#define PIT_DECODE_10 (PIT_FR1_DOUBLEEXTEND_9b - ((PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4) - ((PIT_FR1_DOUBLEEXTEND_9b-PIT_FR2_DOUBLEEXTEND_9b)*2)) + +#define BIN4_FX 800 +#define TH_COR_FX 19661 /* Q15 Minimum correlation for per bin processing */ +#define TH_D_FX 800 /* 50 (Q4) Difference limit between nearest harmonic and a frequency bin */ +#define TH_PIT_FX 128 /* (Fs / (2.0f * TH_D)) Maximum pitch for per bin processing */ + +#define GUESS_TBL_SZ 256 +#define INT_FS_FX 12800 /* internal sampling frequency */ +#define INT_FS_16k_FX 16000 /* CELP core internal sampling frequency @16kHz */ + +#define WB_LIMIT_LSF_FX 16256 +#define Fs_2 16384 /* lsf max value (Use in reorder_fx.c) */ +#define Fs_2_16k 20480 /* lsf max value (Use in reorder_fx.c) */ + +#define LG10 24660 /* 10*log10(2) in Q13 */ +#define LG10_s3_0 16440 /* 10*log10(2)/1.55 = 1.00343331 in Q14 */ + +#define MU_MA_FX 10923 /* original prediction factor for the AMR WB tables (Q15) */ + +#define E_MIN_FXQ15 115 /* Q15*/ + +#define MAX_DYNAMIC_FX (82*128) +#define MIN_DYNAMIC_FX (50*128) +#define DYNAMIC_RANGE_FX (MAX_DYNAMIC_FX-MIN_DYNAMIC_FX) +#define MAX_GSC_NF_BITS 3 +//#define GSC_NF_STEPS (1 << MAX_GSC_NF_BITS) +#define GSF_NF_DELTA_FX (DYNAMIC_RANGE_FX/GSC_NF_STEPS) + +/*----------------------------------------------------------------------------------* + * AVQ constants + *----------------------------------------------------------------------------------*/ + +#define MIN_GLOB_GAIN_BWE_HR_FX 24576 /* Q13 */ +#define MAX_GLOB_GAIN_BWE_HR_FX 32000 /* Q6 */ + +#define LG10_MIN_GLOB_GAIN_BWE_HR_Q14 7817 +#define LG10_MAX_GLOB_GAIN_BWE_HR_Q13 22110 + +/*----------------------------------------------------------------------------------* + * LD music post-filter constants + *----------------------------------------------------------------------------------*/ + +#define BIN_16kdct_fx (6400/DCT_L_POST) +#define E_MIN_Q15 14680 /* 0.0035 -> Q22 */ + +#define QSCALE 7 +#define MODE2_E_MIN 4/*0.03f Q0*/ /* 0.03f in QSCALE */ +#define MODE2_E_MIN_Q15 983/*0.03f Q15*/ /* 0.03f in Q15*/ + + /* long term pst parameters : */ +#define L2_LH2_L 4 /* log2(LH2_L) */ +#define MIN_GPLT_FX 21845 /* LT gain minimum 1/1.5 (Q15) */ + +#define AGC_FAC_FX 32358 /* gain adjustment factor 0.9875 (Q15) */ +#define AGC_FAC1_FX (Word16)(32768L - AGC_FAC_FX) + +#define DOWNMIX_12k8_FX 1850 + +/*----------------------------------------------------------------------------------* + * HQ Constants + *----------------------------------------------------------------------------------*/ + +#define INV2POWHALF 23170 /* Q15, sqrt(2)/2 */ +#define EPSILLON_FX (Word16) 1 +#define MAX_SFM_LEN_FX 96 +#define MAX_P_ATT_FX (Word16) 40 /* Maximum number of pulses for gain attenuation factor */ +#define MAX_PHG_FX (Word16) 10 /* Q0, Maximum number of pulses for which to apply pulse height dependent gain */ +#define PHG_START_FX (Word16) 3277 /* Q15, 0.1f */ +#define PHG_DELTA_FX (Word16) 2621 /* Q15, ((PHG_END-PHG_START)/MAX_PHG) */ +#define ENV_ADJ_START_FX (Word16) 6 /* Q0, Number of consecutive bands for which the attenuation is maximum */ +#define ENV_ADJ_INV_INCL_FX (Word16) 6554 /* Q15, 1/5.0f, Inverse inclination for mapping between attenuation region width and attenuation limit */ + +#define INV_HVQ_THRES_BIN_24k 9362 /* 1/224 in Q21 */ +#define INV_HVQ_THRES_BIN_32k 6554 /* 1/320 in Q21 */ +#define INV_BANDS_PER_SUBFRAMES 14564 /* 1/9 in Q17 */ +#define NUM_SUBFRAMES 4 +#define BANDS_PER_SUBFRAMES 9 +#define ENERGY_TH_NUM_SUBFRAMES 1638400L /* 400 in Q12 */ +#define INV_SFM_N_ENV_STAB 19418 /* 1/27 in Q19 */ +#define ENERGY_TH_FX 819200L /* 100 in Q13 */ +#define ENERGY_LT_BETA_FX 30474 /* 0.93 in Q15 - Smoothing factor for long-term energy measure */ +#define ENERGY_LT_BETA_1_FX 2294 /* 0.07 i Q15 - (1 - ENERGY_LT_BETA_FX) */ +#define INV_DELTA_TH 13107 /* 1/5 in Q16 - Inverse Delta energy threshold for transient detection for envelope stability */ + +#define ONE_OVER_HVQ_BAND_MAX_BITS_24k_FX ((Word16) 410) /* Q15, 1/80 = 0.0125 */ +#define ONE_OVER_HVQ_BAND_MAX_BITS_32k_FX ((Word16) 345) /* Q15, 1/95 = 0.010526315 */ + +#define INV_PREECHO_SMOOTH_LENP1_FX 1560 /*(32768 / (PREECHO_SMOOTH_LEN + 1.0));*/ + +#define INV_HVQ_BW 1024 /* Q15 1/32 */ + +#define ACELP_48k_BITS 960 /* Q0 - ACELP_48k / 50 */ + + /*----------------------------------------------------------------------------------* + * ISF quantizer constants + *----------------------------------------------------------------------------------*/ + /*qlpc_avq, lsf_msvq_ma*/ +#define W_MODE0 0x1333 /*60.0f/FREQ_DIV in 0Q15*/ +#define W_MODE1 0x14CD /*65.0f/FREQ_DIV in 0Q15*/ +#define W_MODE2 0x147B /*64.0f/FREQ_DIV in 0Q15*/ +#define W_MODE_ELSE 0x1429 /*60.0f/FREQ_DIV in 0Q15*/ +/* qmc_cng_common.h */ +/* codec side */ +#define SCALE_TABLE_SHIFT_FACTOR (31-23) + +/* parameter_bitmapping.h */ +#define NPARAMS_MAX 10 +/* Flags for CLDFB intialization */ +/* Flag indicating that the states should be kept. */ +#define CLDFB_FLAG_KEEP_STATES 8 +/* Flag indicating 2.5 ms setup */ +#define CLDFB_FLAG_2_5MS_SETUP 128 +typedef enum SIGNAL_CLASSIFER_MODE +{ + CLASSIFIER_ACELP, + CLASSIFIER_TCX +} SIGNAL_CLASSIFIER_MODE; + +#define CNT0P1 1717986918 /* 0.1*2^34 */ +#define CNT0P001 1099511627 /* 0.001*2^40 */ +#define CNT0P0001 1759218604 /* 0.0001*2^44 */ + +#define CNT0P05 1717986918 /* 0.05*2^35 */ + +#define CNT1DIV28 1227133513 /* (1/28)*2^35 */ +#define CNT1DIV14 1227133513 /* (1/14)*2^34 */ +#define CNT1DIV8 1073741824 /* (1/8)*2^33 */ + +#define SP_CENTER_Q 10 +#define ITD_STABLE_RATE_Q 15 +#define SPEC_AMP_Q 14 +#define SFM_Q 15 +#define TONA_Q 14 +#define lt_bg_highf_eng_Q 16 + /*----------------------------------------------------------------------------------* * TEC/TFA *----------------------------------------------------------------------------------*/ @@ -2167,6 +2754,75 @@ enum #define EXT_DELAY_HI_TEMP_ENV 2 + /************************************************************************/ + /* CLDFB */ + /************************************************************************/ +#define SCALE_MODULATION ( 1 ) + +#define SCALE_GAIN_ANA_10 ( 4 ) +#define SCALE_GAIN_ANA_16 ( 3 ) +#define SCALE_GAIN_ANA_20 ( 3 ) +#define SCALE_GAIN_ANA_32 ( 2 ) +#define SCALE_GAIN_ANA_40 ( 2 ) +#define SCALE_GAIN_ANA_60 ( 1 ) + +#define SCALE_GAIN_SYN (-6 ) + +#define SCALE_CLDFB_ANA_10 ( SCALE_MODULATION + SCALE_GAIN_ANA_10 ) +#define SCALE_CLDFB_ANA_16 ( SCALE_MODULATION + SCALE_GAIN_ANA_16 ) +#define SCALE_CLDFB_ANA_20 ( SCALE_MODULATION + SCALE_GAIN_ANA_20 ) +#define SCALE_CLDFB_ANA_32 ( SCALE_MODULATION + SCALE_GAIN_ANA_32 ) +#define SCALE_CLDFB_ANA_40 ( SCALE_MODULATION + SCALE_GAIN_ANA_40 ) +#define SCALE_CLDFB_ANA_60 ( SCALE_MODULATION + SCALE_GAIN_ANA_60 ) + +#define SCALE_CLDFB_SYN_10 ( SCALE_MODULATION + SCALE_GAIN_SYN ) +#define SCALE_CLDFB_SYN_16 ( SCALE_MODULATION + SCALE_GAIN_SYN ) +#define SCALE_CLDFB_SYN_20 ( SCALE_MODULATION + SCALE_GAIN_SYN ) +#define SCALE_CLDFB_SYN_32 ( SCALE_MODULATION + SCALE_GAIN_SYN ) +#define SCALE_CLDFB_SYN_40 ( SCALE_MODULATION + SCALE_GAIN_SYN ) +#define SCALE_CLDFB_SYN_60 ( SCALE_MODULATION + SCALE_GAIN_SYN ) + +/************************************************************************/ +/* FFT */ +/************************************************************************/ +#define SCALEFACTORN2 ( 3) +#define SCALEFACTOR2 ( 2) +#define SCALEFACTOR3 ( 3) +#define SCALEFACTOR4 ( 3) +#define SCALEFACTOR5 ( 4) +#define SCALEFACTOR8 ( 4) +#define SCALEFACTOR10 ( 5) +#define SCALEFACTOR12 ( 5) +#define SCALEFACTOR15 ( 5) +#define SCALEFACTOR16_5 ( 5) +#define SCALEFACTOR20_5 ( 5) +#define SCALEFACTOR24 ( 6) +#define SCALEFACTOR30 ( 6) +#define SCALEFACTOR30_1 ( 5) +#define SCALEFACTOR30_2 ( 1) +#define SCALEFACTOR32 ( 6) +#define SCALEFACTOR32_1 ( 5) +#define SCALEFACTOR32_2 ( 1) +#define SCALEFACTOR40 ( 7) +#define SCALEFACTOR60 ( 7) +#define SCALEFACTOR64 ( 7) +#define SCALEFACTOR80 ( 8) +#define SCALEFACTOR100 (10) +#define SCALEFACTOR120 ( 8) +#define SCALEFACTOR128 ( 8) +#define SCALEFACTOR160 ( 8) +#define SCALEFACTOR192 (10) +#define SCALEFACTOR200 (10) +#define SCALEFACTOR240 ( 9) +#define SCALEFACTOR256 ( 9) +#define SCALEFACTOR320 (10) +#define SCALEFACTOR400 (10) +#define SCALEFACTOR480 (11) +#define SCALEFACTOR600 (10) + +#define BASOP_CFFT_MAX_LENGTH 600 + + /*----------------------------------------------------------------------------------* * BASOP ROM Tables *----------------------------------------------------------------------------------*/ @@ -2197,7 +2853,7 @@ enum PRIMARY_SID, PRIMARY_FUT1, SPEECH_LOST, - NO_DATA_RECEIVED + NO_DATA_TYPE }; enum @@ -2228,6 +2884,40 @@ enum VOIP_RTPDUMP }; +//EVS macros +#define LT_UV_THR_FX (100*64) /* in Q6 */ +#define INV_MAX_LT_FX (Word16)((1.0f/MAX_LT)*32768) + +#define EVS_PI 3.14159265358979323846264338327950288f + +#define LG10 24660 /* 10*log10(2) in Q13 */ + + +#define EVS_LW_MIN (Word32)0x80000000 +#define EVS_LW_MAX (Word32)0x7fffffff + +#define EVS_SW_MAX (Word16)0x7fff /* largest Ram */ + +#define SYNC_GOOD_FRAME (UWord16) 0x6B21 /* synchronization word of a "good" frame */ +#define SYNC_BAD_FRAME (UWord16) 0x6B20 /* synchronization word of a "bad" frame */ +#define G192_BIN0 (UWord16) 0x007F /* binary "0" according to ITU-T G.192 */ +#define G192_BIN1 (UWord16) 0x0081 /* binary "1" according to ITU-T G.192 */ + +extern const Word16 Idx2Freq_Tbl[]; +#if 0 +//TO do add in rom_com +#endif +#define chk_fs(fs) +/* 'x' is converted to Q6, 'Freq_Tbl'/1000 in Q9 */ +/* only works for 'fs' = [8000,12800,16000,25600,32000,48000] (unpredictable otherwise) */ +/* 15625 is 1000000.0f/Q6 but we use the calculated value to avoid float point code */ +#define NS2SA_fx2(fs,x) (chk_fs(fs) mult((&Idx2Freq_Tbl[-2])[L_and(L_shr(fs,8),7)], (Word16)((x)/15625))) + +#define L_FRAME_12k8 256 /* Frame size at 12k8Hz: 20ms = 256 samples */ +#define L_FRAME_16k 320 /* Frame size at 16kHz: 20ms = 320 samples */ +#define L_NEXT_MAX_12k8 112 /* maximum encoder lookahead at 12k8Hz */ +#define L_PAST_MAX_12k8 144 /* maximum encoder past samples at 12k8Hz */ +#define L_DIV 256 /* 20ms frame size (ACELP or short TCX frame) */ /* clang-format on */ #endif /* CNST_H */ diff --git a/lib_com/codec_tcx_common.c b/lib_com/codec_tcx_common.c index 2375ef387..c919067a3 100644 --- a/lib_com/codec_tcx_common.c +++ b/lib_com/codec_tcx_common.c @@ -62,7 +62,7 @@ int16_t tcxGetNoiseFillingTilt( else { firstLine = L_frame / 8; - *noiseTiltFactor = get_gain( A + 1, A, M, NULL ); + *noiseTiltFactor = get_gain_flt( A + 1, A, M, NULL ); *noiseTiltFactor = min( 1.0f, ( *noiseTiltFactor ) + 0.09375f ); } diff --git a/lib_com/complex_basop.c b/lib_com/complex_basop.c new file mode 100644 index 000000000..3a65d65a6 --- /dev/null +++ b/lib_com/complex_basop.c @@ -0,0 +1,457 @@ +/***************************************************************************** + +* + +* Complex arithmetic operators + +* + +*****************************************************************************/ + + +#include "typedef.h" +#include "basop32.h" + +#include "complex_basop.h" + +#include "stl.h" + + + +#if (WMOPS) + +extern BASIC_OP multiCounter[MAXCOUNTERS]; + +extern int currCounter; + +#endif /* if WMOPS */ + + + +#ifdef COMPLEX_OPERATOR + +/* ================================ New Complex Basops ========================= */ + +cmplx CL_shr (cmplx inp, Word32 shift_val) { + cmplx out; + out.re = L_shr (inp.re, shift_val); + out.im = L_shr (inp.im, shift_val); +#if (WMOPS) + multiCounter[currCounter].CL_shr++; + multiCounter[currCounter].L_shr--; + multiCounter[currCounter].L_shr--; +#endif + return out; +} + +cmplx CL_shl (cmplx inp, Word32 shift_val) { + cmplx out; + out.re = L_shl (inp.re, shift_val); + out.im = L_shl (inp.im, shift_val); +#if (WMOPS) + multiCounter[currCounter].CL_shl++; + multiCounter[currCounter].L_shl--; + multiCounter[currCounter].L_shl--; +#endif + return out; +} + +cmplx CL_add (cmplx inp1, cmplx inp2) { + cmplx out; + out.re = L_add (inp1.re, inp2.re); + out.im = L_add (inp1.im, inp2.im); +#if (WMOPS) + multiCounter[currCounter].CL_add++; + multiCounter[currCounter].L_add--; + multiCounter[currCounter].L_add--; +#endif + return out; +} + +cmplx CL_sub (cmplx inp1, cmplx inp2) { + cmplx out; + out.re = L_sub (inp1.re, inp2.re); + out.im = L_sub (inp1.im, inp2.im); +#if (WMOPS) + multiCounter[currCounter].CL_sub++; + multiCounter[currCounter].L_sub--; + multiCounter[currCounter].L_sub--; +#endif + return out; +} + +cmplx CL_scale(cmplx x, Word16 y) { + cmplx result; + result.re = Mpy_32_16_r (x.re, y); + result.im = Mpy_32_16_r (x.im, y); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_r--; + multiCounter[currCounter].Mpy_32_16_r--; + multiCounter[currCounter].CL_scale++; +#endif/* #if (WMOPS) */ + return (result); +} + +cmplx CL_dscale (cmplx x, Word16 y1, Word16 y2) { + cmplx result; + result.re = Mpy_32_16_r (x.re, y1); + result.im = Mpy_32_16_r (x.im, y2); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_r--; + multiCounter[currCounter].Mpy_32_16_r--; + multiCounter[currCounter].CL_dscale++; +#endif/* #if (WMOPS) */ + return (result); +} + +cmplx CL_msu_j (cmplx x, cmplx y) { + cmplx result; + result.re = L_add (x.re, y.im); + result.im = L_sub (x.im, y.re); +#if (WMOPS) + multiCounter[currCounter].CL_msu_j++; + multiCounter[currCounter].L_add--; + multiCounter[currCounter].L_sub--; +#endif + return result; +} + +cmplx CL_mac_j (cmplx x, cmplx y) { + cmplx result; + result.re = L_sub (x.re, y.im ); + result.im = L_add (x.im, y.re ); +#if (WMOPS) + multiCounter[currCounter].CL_mac_j++; + multiCounter[currCounter].L_add--; + multiCounter[currCounter].L_sub--; +#endif + return result; +} + +cmplx CL_move (cmplx x) { +#if (WMOPS) + multiCounter[currCounter].CL_move++; +#endif + return x; +} + +Word32 CL_Extract_real (cmplx x) { +#if (WMOPS) + multiCounter[currCounter].CL_Extract_real++; +#endif + return x.re; +} + +Word32 CL_Extract_imag (cmplx x) { +#if (WMOPS) + multiCounter[currCounter].CL_Extract_imag++; +#endif + return x.im; +} + +cmplx CL_form (Word32 re, Word32 im) { + cmplx result; + result.re = re; + result.im = im; +#if (WMOPS) + multiCounter[currCounter].CL_form++; +#endif + return result; +} + +cmplx CL_multr_32x16 (cmplx input, cmplx_s coeff) { + cmplx result; + result.re = W_round48_L (W_sub_nosat (W_mult_32_16 (input.re, coeff.re), W_mult_32_16 (input.im, coeff.im) ) ); + result.im = W_round48_L (W_add_nosat (W_mult_32_16 (input.re, coeff.im), W_mult_32_16 (input.im, coeff.re) ) ); +#if (WMOPS) + multiCounter[currCounter].CL_multr_32x16++; + multiCounter[currCounter].W_mult_32_16--; + multiCounter[currCounter].W_mult_32_16--; + multiCounter[currCounter].W_mult_32_16--; + multiCounter[currCounter].W_mult_32_16--; + multiCounter[currCounter].W_sub_nosat--; + multiCounter[currCounter].W_add_nosat--; + multiCounter[currCounter].W_round48_L--; + multiCounter[currCounter].W_round48_L--; +#endif + return result; +} + +cmplx CL_negate(cmplx x) { + cmplx result; + result.re = L_negate (x.re); + result.im = L_negate (x.im); +#if (WMOPS) + multiCounter[currCounter].CL_negate++; + multiCounter[currCounter].L_negate--; + multiCounter[currCounter].L_negate--; +#endif + return result; +} + +cmplx CL_conjugate (cmplx x) { + cmplx result; + result.re = x.re; + result.im = L_negate (x.im); +#if (WMOPS) + multiCounter[currCounter].CL_conjugate++; + multiCounter[currCounter].L_negate--; +#endif + return result; +} + + +cmplx CL_mul_j (cmplx input) { + cmplx temp, result; + temp = CL_negate (input); + result.re = temp.im; + result.im = input.re; +#if (WMOPS) + multiCounter[currCounter].CL_mul_j++; + multiCounter[currCounter].CL_negate--; +#endif + return result; +} + +cmplx CL_swap_real_imag (cmplx input) { + cmplx result; + result.re = input.im; + result.im = input.re; +#if (WMOPS) + multiCounter[currCounter].CL_swap_real_imag++; +#endif + return result; +} + +cmplx_s C_add (cmplx_s inp1, cmplx_s inp2) { + cmplx_s out; + out.re = add (inp1.re, inp2.re); + out.im = add (inp1.im, inp2.im); + +#if (WMOPS) + multiCounter[currCounter].C_add++; + multiCounter[currCounter].add--; + multiCounter[currCounter].add--; +#endif + return out; +} + +cmplx_s C_sub (cmplx_s inp1, cmplx_s inp2) { + cmplx_s out; + out.re = sub (inp1.re, inp2.re); + out.im = sub (inp1.im, inp2.im); + +#if (WMOPS) + multiCounter[currCounter].C_sub++; + multiCounter[currCounter].sub--; + multiCounter[currCounter].sub--; +#endif + return out; +} + +cmplx_s C_mul_j (cmplx_s input) { + cmplx_s result; + Word16 temp; + temp = negate(input.im); + result.re = temp; + result.im = input.re; + +#if (WMOPS) + multiCounter[currCounter].C_mul_j++; + multiCounter[currCounter].negate--; +#endif + return result; +} + +cmplx_s C_multr (cmplx_s x, cmplx_s c) { + cmplx_s result; + result.re = round_fx (W_sat_l (W_sub_nosat (W_mult_16_16 (x.re, c.re), W_mult_16_16 (x.im, c.im) ) ) ); + result.im = round_fx (W_sat_l (W_add_nosat (W_mult_16_16 (x.im, c.re), W_mult_16_16 (x.re, c.im) ) ) ); + +#if (WMOPS) + multiCounter[currCounter].C_multr++; + multiCounter[currCounter].W_mult_16_16--; + multiCounter[currCounter].W_mult_16_16--; + multiCounter[currCounter].W_mult_16_16--; + multiCounter[currCounter].W_mult_16_16--; + multiCounter[currCounter].W_sub_nosat--; + multiCounter[currCounter].W_add_nosat--; + multiCounter[currCounter].W_sat_l--; + multiCounter[currCounter].W_sat_l--; + multiCounter[currCounter].round--; + multiCounter[currCounter].round--; +#endif + return result; +} + +cmplx_s C_form ( Word16 re, Word16 im) { + cmplx_s result; + result.re = re; + result.im = im; +#if (WMOPS) + multiCounter[currCounter].C_form++; +#endif + return result; +} + +cmplx C_scale(cmplx_s x, Word16 y) { + cmplx result; + result.re = L_mult(x.re, y); + result.im = L_mult(x.im, y); +#if (WMOPS) + multiCounter[currCounter].L_mult--; + multiCounter[currCounter].L_mult--; + multiCounter[currCounter].C_scale++; +#endif/* #if (WMOPS) */ + return (result); +} + +cmplx_s CL_round32_16 (cmplx x) { + cmplx_s result; + result.re = round_fx (x.re); + result.im = round_fx (x.im); + +#if (WMOPS) + multiCounter[currCounter].CL_round32_16++; + multiCounter[currCounter].round--; + multiCounter[currCounter].round--; +#endif + return result; +} + +cmplx CL_scale_32 (cmplx x, Word32 y) { + cmplx result; + result.re = Mpy_32_32_r (x.re, y); + result.im = Mpy_32_32_r (x.im, y); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_32_r--; + multiCounter[currCounter].Mpy_32_32_r--; + multiCounter[currCounter].CL_scale_32++; +#endif/* #if (WMOPS) */ + return (result); +} + +cmplx CL_dscale_32 (cmplx x, Word32 y1, Word32 y2) { + cmplx result; + result.re = Mpy_32_32_r (x.re, y1); + result.im = Mpy_32_32_r (x.im, y2); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_32_r--; + multiCounter[currCounter].Mpy_32_32_r--; + multiCounter[currCounter].CL_dscale_32++; +#endif/* #if (WMOPS) */ + return (result); +} + +cmplx CL_multr_32x32 (cmplx x, cmplx y) { + cmplx result; + result.re = W_round64_L (W_sub (W_mult_32_32 (x.re, y.re), W_mult_32_32(x.im, y.im) ) ) ; + result.im = W_round64_L (W_add (W_mult_32_32 (x.im, y.re), W_mult_32_32(x.re, y.im) ) ) ; + +#if (WMOPS) + multiCounter[currCounter].CL_multr_32x32++; + multiCounter[currCounter].W_mult_32_32--; + multiCounter[currCounter].W_mult_32_32--; + multiCounter[currCounter].W_mult_32_32--; + multiCounter[currCounter].W_mult_32_32--; + multiCounter[currCounter].W_round64_L--; + multiCounter[currCounter].W_round64_L--; + multiCounter[currCounter].W_sub--; + multiCounter[currCounter].W_add--; +#endif + return result; +} + +cmplx_s C_mac_r (cmplx x, cmplx_s y, Word16 c) { + cmplx_s result; + cmplx temp = CL_add (x, C_scale (y, c) ); + result = CL_round32_16 (temp); + +#if (WMOPS) + multiCounter[currCounter].C_mac_r++; + multiCounter[currCounter].CL_add--; + multiCounter[currCounter].C_scale--; + multiCounter[currCounter].CL_round32_16--; +#endif + return result; +} + +cmplx_s C_msu_r (cmplx x, cmplx_s y, Word16 c) { + cmplx_s result; + cmplx temp = CL_sub (x, C_scale (y, c) ); + result = CL_round32_16 (temp); + +#if (WMOPS) + multiCounter[currCounter].C_msu_r++; + multiCounter[currCounter].CL_sub--; + multiCounter[currCounter].C_scale--; + multiCounter[currCounter].CL_round32_16--; +#endif + return result; +} + +Word16 C_Extract_real (cmplx_s x) { +#if (WMOPS) + multiCounter[currCounter].C_Extract_real++; +#endif + return x.re; +} + +Word16 C_Extract_imag (cmplx_s x) { +#if (WMOPS) + multiCounter[currCounter].C_Extract_imag++; +#endif + return x.im; +} + +cmplx_s C_negate (cmplx_s x) { + cmplx_s result; + result.re = negate (x.re); + result.im = negate (x.im); +#if (WMOPS) + multiCounter[currCounter].C_negate++; + multiCounter[currCounter].negate--; + multiCounter[currCounter].negate--; +#endif + return result; +} + +cmplx_s C_conjugate (cmplx_s x) { + cmplx_s result; + result.re = x.re; + result.im = negate (x.im); +#if (WMOPS) + multiCounter[currCounter].C_conjugate++; + multiCounter[currCounter].negate--; +#endif + return result; +} + +cmplx_s C_shr (cmplx_s inp, Word16 shift_val) { + cmplx_s out; + out.re = shr (inp.re, shift_val); + out.im = shr (inp.im, shift_val); +#if (WMOPS) + multiCounter[currCounter].C_shr++; + multiCounter[currCounter].shr--; + multiCounter[currCounter].shr--; +#endif + return out; +} + +cmplx_s C_shl (cmplx_s inp, Word16 shift_val) { + cmplx_s out; + out.re = shl (inp.re, shift_val); + out.im = shl (inp.im, shift_val); +#if (WMOPS) + multiCounter[currCounter].C_shl++; + multiCounter[currCounter].shl--; + multiCounter[currCounter].shl--; +#endif + return out; +} + +#endif /* #ifdef COMPLEX_OPERATOR */ + +/* end of file */ + diff --git a/lib_com/complex_basop.h b/lib_com/complex_basop.h new file mode 100644 index 000000000..c3deb1455 --- /dev/null +++ b/lib_com/complex_basop.h @@ -0,0 +1,77 @@ + /***************************************************************************** + + * + + * Complex arithmetic operators + + * + + *****************************************************************************/ +#ifndef _COMPLEX_BASIC_OP_H +#define _COMPLEX_BASIC_OP_H + +#include "typedef.h" +#include "basop32.h" +#include "stl.h" + +#ifdef COMPLEX_OPERATOR + +typedef struct +{ + Word32 re; + Word32 im; +}cmplx; + +typedef struct +{ + Word16 re; + Word16 im; +}cmplx_s; + +/*___________________________________________________________________________ + | | + | Prototypes for complex arithmetic operators | + |___________________________________________________________________________| +*/ + +cmplx CL_shr (cmplx inp, Word32 shift_val); +cmplx CL_shl (cmplx inp, Word32 shift_val); +cmplx CL_add (cmplx inp1, cmplx inp2); +cmplx CL_sub (cmplx inp1, cmplx inp2); +cmplx CL_scale (cmplx x, Word16 y); +cmplx CL_dscale (cmplx x, Word16 y1, Word16 y2); +cmplx CL_msu_j (cmplx x, cmplx y); +cmplx CL_mac_j (cmplx x, cmplx y); +cmplx CL_move (cmplx x); +Word32 CL_Extract_real (cmplx x); +Word32 CL_Extract_imag (cmplx x); +cmplx CL_form (Word32 re, Word32 im); +cmplx CL_multr_32x16 (cmplx input, cmplx_s coeff); +cmplx CL_negate (cmplx x); +cmplx CL_conjugate (cmplx x); +cmplx CL_mul_j (cmplx input); +cmplx CL_swap_real_imag (cmplx input); +cmplx_s C_add (cmplx_s inp1, cmplx_s inp2); +cmplx_s C_sub (cmplx_s inp1, cmplx_s inp2); +cmplx_s C_mul_j (cmplx_s input); +cmplx_s C_multr (cmplx_s x, cmplx_s c); +cmplx_s C_form (Word16 re, Word16 im ); + +cmplx C_scale (cmplx_s x, Word16 y); +cmplx_s CL_round32_16 (cmplx x); +cmplx CL_scale_32 (cmplx x, Word32 y); +cmplx CL_dscale_32 (cmplx x, Word32 y1, Word32 y2); +cmplx CL_multr_32x32 (cmplx x, cmplx y); +cmplx_s C_mac_r (cmplx x, cmplx_s y, Word16 c); +cmplx_s C_msu_r (cmplx x, cmplx_s y, Word16 c); +Word16 C_Extract_real (cmplx_s x ); +Word16 C_Extract_imag (cmplx_s x ); +cmplx_s C_negate (cmplx_s x); +cmplx_s C_conjugate (cmplx_s x); +cmplx_s C_shr (cmplx_s inp, Word16 shift_val); +cmplx_s C_shl (cmplx_s inp, Word16 shift_val); + +#endif /* #ifdef COMPLEX_OPERATOR */ + +#endif /* ifndef _COMPLEX_BASIC_OP_H */ + diff --git a/lib_com/control.c b/lib_com/control.c new file mode 100644 index 000000000..2d0a46c25 --- /dev/null +++ b/lib_com/control.c @@ -0,0 +1,250 @@ +/* + =========================================================================== + File: CONTROL.C v.2.3 - 30.Nov.2009 + =========================================================================== + + ITU-T STL BASIC OPERATORS + + CONTROL FLOW OPERATOR INTERNAL VARIABLE DECLARATIONS + + History: + 07 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control + operators for the ITU-T Standard Tool Library as + described in Geneva, 20-30 January 2004 WP 3/16 Q10/16 + TD 11 document and subsequent discussions on the + wp3audio@yahoogroups.com email reflector. + March 06 v2.1 Changed to improve portability. + + ============================================================================ +*/ + +#include "stl.h" + +#ifdef WMOPS +int funcId_where_last_call_to_else_occurred; +long funcid_total_wmops_at_last_call_to_else; +int call_occurred = 1; +#endif + +#ifdef CONTROL_CODE_OPS + +Flag LT_16 (Word16 var1, Word16 var2) { + Flag F_ret = 0; + + if( var1 < var2 ) + { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].LT_16++; +#endif + return F_ret; +} + +Flag GT_16 (Word16 var1, Word16 var2) { + Flag F_ret = 0; + + if( var1 > var2 ) + { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].GT_16++; +#endif + return F_ret; +} + +Flag LE_16 (Word16 var1, Word16 var2) { + Flag F_ret = 0; + + if (var1 <= var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].LE_16++; +#endif + return F_ret; +} + +Flag GE_16 (Word16 var1, Word16 var2) { + Flag F_ret = 0; + + if (var1 >= var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].GE_16++; +#endif + return F_ret; +} + +Flag EQ_16 (Word16 var1, Word16 var2) { + Flag F_ret = 0; + + if (var1 == var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].EQ_16++; +#endif + return F_ret; +} + +Flag NE_16 (Word16 var1, Word16 var2) { + Flag F_ret = 0; + + if (var1 != var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].NE_16++; +#endif + return F_ret; +} + +Flag LT_32 (Word32 L_var1, Word32 L_var2) { + Flag F_ret = 0; + + if (L_var1 < L_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].LT_32++; +#endif + return F_ret; +} + +Flag GT_32 (Word32 L_var1, Word32 L_var2) { + Flag F_ret = 0; + + if (L_var1 > L_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].GT_32++; +#endif + return F_ret; +} + +Flag LE_32 (Word32 L_var1, Word32 L_var2) { + Flag F_ret = 0; + + if (L_var1 <= L_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].LE_32++; +#endif + return F_ret; +} + +Flag GE_32 (Word32 L_var1, Word32 L_var2) { + Flag F_ret = 0; + + if (L_var1 >= L_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].GE_32++; +#endif + return F_ret; +} + +Flag EQ_32 (Word32 L_var1, Word32 L_var2) { + Flag F_ret = 0; + + if (L_var1 == L_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].EQ_32++; +#endif + return F_ret; +} + +Flag NE_32 (Word32 L_var1, Word32 L_var2) { + Flag F_ret = 0; + + if (L_var1 != L_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].NE_32++; +#endif + return F_ret; +} + +Flag LT_64 (Word64 L64_var1, Word64 L64_var2) { + Flag F_ret = 0; + + if (L64_var1 < L64_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].LT_64++; +#endif + return F_ret; +} + +Flag GT_64 (Word64 L64_var1, Word64 L64_var2) { + Flag F_ret = 0; + + if (L64_var1 > L64_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].GT_64++; +#endif + return F_ret; +} + +Flag LE_64 (Word64 L64_var1, Word64 L64_var2) { + Flag F_ret = 0; + + if (L64_var1 <= L64_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].LE_64++; +#endif + return F_ret; +} +Flag GE_64 (Word64 L64_var1, Word64 L64_var2) { + Flag F_ret = 0; + + if (L64_var1 >= L64_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].GE_64++; +#endif + return F_ret; +} + +Flag EQ_64 (Word64 L64_var1, Word64 L64_var2) { + Flag F_ret = 0; + + if (L64_var1 == L64_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].EQ_64++; +#endif + return F_ret; +} +Flag NE_64 (Word64 L64_var1, Word64 L64_var2) { + Flag F_ret = 0; + + if (L64_var1 != L64_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].NE_64++; +#endif + return F_ret; +} + +#endif /* #ifdef CONTROL_CODE_OPS */ + + +/* end of file */ diff --git a/lib_com/control.h b/lib_com/control.h index 725163728..80b074b4e 100644 --- a/lib_com/control.h +++ b/lib_com/control.h @@ -30,53 +30,315 @@ *******************************************************************************************************/ -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - #ifndef _CONTROL_H #define _CONTROL_H -/* BASOP -> FLC brigde: flow control instructions */ - #include "stl.h" -#define FOR( a ) \ - if ( incrFor(), 0 ) \ - ; \ - else \ - for ( a ) -static __inline void incrFor( void ) -{ + +/***************************************************************************** + * + * Constants and Globals + * + *****************************************************************************/ +#if (WMOPS) +extern BASIC_OP multiCounter[MAXCOUNTERS]; +extern int currCounter; + + /* Technical note : + * The following 3 variables are only used for correct complexity + * evaluation of the following structure : + * IF{ + * ... + * } ELSE IF { + * ... + * } ELSE IF { + * ... + * } + * ... + * } ELSE { + * ... + * } + */ +extern int funcId_where_last_call_to_else_occurred; +extern long funcid_total_wmops_at_last_call_to_else; +extern int call_occurred; +#endif /* ifdef WMOPS */ + + +/***************************************************************************** + * + * Function Macros + * + *****************************************************************************/ + +/***************************************************************************** + * + * Function Name : FOR + * + * Purpose : + * + * The macro FOR should be used instead of the 'for' C statement. + * The complexity is independent of the number of loop iterations that are + * performed. + * + * Complexity weight : 3 (regardless of number of iterations). + * + *****************************************************************************/ +#ifndef WMOPS +#define FOR( a) for( a) + +#else /* ifndef WMOPS */ +#define FOR( a) if( incrFor(), 0); else for( a) + +static __inline void incrFor (void) { + multiCounter[currCounter].For++; } +#endif /* ifndef WMOPS */ + -#define WHILE( a ) \ - if ( incrFlcWhile(), 0 ) \ - ; \ - else \ - while ( a ) -static __inline void incrFlcWhile( void ) -{ +/***************************************************************************** + * + * Function Name : WHILE + * + * Purpose : + * + * The macro WHILE should be used instead of the 'while' C statement. + * The complexity is proportional to the number of loop iterations that + * are performed. + * + * Complexity weight : 4 x 'number of loop iterations'. + * + *****************************************************************************/ +#ifndef WMOPS +#define WHILE(a) while (a) + +#else /* ifndef WMOPS */ +#define WHILE(a) while (incrWhile(), a) + +static __inline void incrWhile (void) { + multiCounter[currCounter].While++; } +#endif /* ifndef WMOPS */ + +/***************************************************************************** + * + * Function Name : DO + * + * Purpose : + * + * The macro DO should be used instead of the 'do' C statement. + * + * Complexity weight : 0 (complexity counted by WHILE macro). + * + *****************************************************************************/ +#ifndef WMOPS #define DO do -#define IF( a ) if ( incrIf(), a ) -static __inline void incrIf( void ) -{ +#else /* ifndef WMOPS */ +#define DO do + +#endif /* ifndef WMOPS */ + + +/***************************************************************************** + * + * Function Name : IF + * + * Purpose : + * + * The macro IF should : + * + * - not be used when : + * - the 'if' structure does not have any 'else if' nor 'else' statement + * - and it conditions only one DSP basic operations. + * + * - be used instead of the 'if' C statement in every other case : + * - when there is an 'else' or 'else if' statement, + * - or when the 'if' conditions several DSP basic operations, + * - or when the 'if' conditions a function call. + * + * Complexity weight : 4 + * + *****************************************************************************/ +#ifndef WMOPS +#define IF(a) if (a) + +#else /* ifndef WMOPS */ +#define IF(a) if (incrIf (), a) + +static __inline void incrIf (void) { + /* Technical note : + * If the "IF" operator comes just after an "ELSE", its counter + * must not be incremented. + */ + if ((currCounter != funcId_where_last_call_to_else_occurred) + || (TotalWeightedOperation () != funcid_total_wmops_at_last_call_to_else) + || (call_occurred == 1)) + multiCounter[currCounter].If++; + + call_occurred = 0; + funcId_where_last_call_to_else_occurred = MAXCOUNTERS; } +#endif /* ifndef WMOPS */ + +/***************************************************************************** + * + * Function Name : ELSE + * + * Purpose : + * + * The macro ELSE should be used instead of the 'else' C statement. + * + * Complexity weight : 4 + * + *****************************************************************************/ +#ifndef WMOPS #define ELSE else -#define SWITCH( a ) switch ( incrSwitch(), a ) -static __inline void incrSwitch( void ) -{ +#else /* ifndef WMOPS */ +#define ELSE else if (incrElse (), 0) ; else + +static __inline void incrElse (void) { + multiCounter[currCounter].If++; + + /* We keep track of the funcId of the last function which used ELSE {...} structure. */ + funcId_where_last_call_to_else_occurred = currCounter; + + /* We keep track of the number of WMOPS of this funcId when the ELSE macro was called. */ + funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation (); + + /* call_occurred is set to 0, in order to count the next IF (if necessary) */ + call_occurred = 0; } +#endif /* ifndef WMOPS */ + +/***************************************************************************** + * + * Function Name : SWITCH + * + * Purpose : + * + * The macro SWITCH should be used instead of the 'switch' C statement. + * + * Complexity weight : 8 + * + *****************************************************************************/ +#ifndef WMOPS +#define SWITCH(a) switch (a) + +#else /* ifndef WMOPS */ +#define SWITCH(a) switch (incrSwitch (), a) + +static __inline void incrSwitch (void) { + multiCounter[currCounter].Switch++; +} +#endif /* ifndef WMOPS */ + + +/***************************************************************************** + * + * Function Name : CONTINUE + * + * Purpose : + * + * The macro CONTINUE should be used instead of the 'continue' C statement. + * + * Complexity weight : 4 + * + *****************************************************************************/ +#ifndef WMOPS #define CONTINUE continue +#else /* ifndef WMOPS */ +#define CONTINUE if (incrContinue (), 0); else continue + +static __inline void incrContinue (void) { + multiCounter[currCounter].Continue++; +} +#endif /* ifndef WMOPS */ + + +/***************************************************************************** + * + * Function Name : BREAK + * + * Purpose : + * + * The macro BREAK should be used instead of the 'break' C statement. + * + * Complexity weight : 4 + * + *****************************************************************************/ +#ifndef WMOPS #define BREAK break +#else /* ifndef WMOPS */ +#define BREAK if (incrBreak (), 0); else break + +static __inline void incrBreak (void) { + multiCounter[currCounter].Break++; +} +#endif /* ifndef WMOPS */ + + +/***************************************************************************** + * + * Function Name : GOTO + * + * Purpose : + * + * The macro GOTO should be used instead of the 'goto' C statement. + * + * Complexity weight : 4 + * + *****************************************************************************/ +#ifndef WMOPS #define GOTO goto +#else /* ifndef WMOPS */ +#define GOTO if (incrGoto (), 0); else goto + +static __inline void incrGoto (void) { + multiCounter[currCounter].Goto++; +} +#endif /* ifndef WMOPS */ + + + +/* + * New control code basops +*/ +#ifdef CONTROL_CODE_OPS + +Flag LT_16 (Word16 var1, Word16 var2); +Flag GT_16 (Word16 var1, Word16 var2); +Flag LE_16 (Word16 var1, Word16 var2); +Flag GE_16 (Word16 var1, Word16 var2); +Flag EQ_16 (Word16 var1, Word16 var2); +Flag NE_16 (Word16 var1, Word16 var2); + +Flag LT_32 (Word32 L_var1, Word32 L_var2); +Flag GT_32 (Word32 L_var1, Word32 L_var2); +Flag LE_32 (Word32 L_var1, Word32 L_var2); +Flag GE_32 (Word32 L_var1, Word32 L_var2); +Flag EQ_32 (Word32 L_var1, Word32 L_var2); +Flag NE_32 (Word32 L_var1, Word32 L_var2); + +Flag LT_64 (Word64 L64_var1, Word64 L64_var2); +Flag GT_64 (Word64 L64_var1, Word64 L64_var2); +Flag LE_64 (Word64 L64_var1, Word64 L64_var2); +Flag GE_64 (Word64 L64_var1, Word64 L64_var2); +Flag EQ_64 (Word64 L64_var1, Word64 L64_var2); +Flag NE_64 (Word64 L64_var1, Word64 L64_var2); + + +#endif /* #ifdef CONTROL_CODE_OPS */ + #endif /* _CONTROL_H */ + + +/* end of file */ diff --git a/lib_com/core_com_config.c b/lib_com/core_com_config.c index 13fe05bbb..2a3f6fbd9 100644 --- a/lib_com/core_com_config.c +++ b/lib_com/core_com_config.c @@ -716,33 +716,33 @@ void init_tcx_window_cfg( hTcxCfg->tcx_mdct_window_length = mdctWindowLength; hTcxCfg->tcx_mdct_window_lengthFB = mdctWindowLengthFB; - mdct_window_sine( hTcxCfg->tcx_mdct_window, sr_core, hTcxCfg->tcx_mdct_window_length, FULL_OVERLAP, element_mode ); + mdct_window_sine( hTcxCfg->tcx_mdct_window_flt, sr_core, hTcxCfg->tcx_mdct_window_length, FULL_OVERLAP, element_mode ); if ( hTcxCfg->tcx_mdct_window_length == hTcxCfg->tcx_mdct_window_lengthFB ) { - mvr2r( hTcxCfg->tcx_mdct_window, hTcxCfg->tcx_mdct_windowFB, hTcxCfg->tcx_mdct_window_length ); + mvr2r( hTcxCfg->tcx_mdct_window_flt, hTcxCfg->tcx_mdct_windowFB_flt, hTcxCfg->tcx_mdct_window_length ); } else { - mdct_window_sine( hTcxCfg->tcx_mdct_windowFB, input_Fs, hTcxCfg->tcx_mdct_window_lengthFB, FULL_OVERLAP, element_mode ); + mdct_window_sine( hTcxCfg->tcx_mdct_windowFB_flt, input_Fs, hTcxCfg->tcx_mdct_window_lengthFB, FULL_OVERLAP, element_mode ); } /*ALDO windows for MODE2*/ - mdct_window_aldo( hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_2, L_frame ); - mdct_window_aldo( hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_2_FB, NS2SA( input_Fs, FRAME_SIZE_NS ) ); - hTcxCfg->tcx_aldo_window_1_trunc = hTcxCfg->tcx_aldo_window_1 + NS2SA( sr_core, N_ZERO_MDCT_NS ); - hTcxCfg->tcx_aldo_window_1_FB_trunc = hTcxCfg->tcx_aldo_window_1_FB + NS2SA( input_Fs, N_ZERO_MDCT_NS ); + mdct_window_aldo( hTcxCfg->tcx_aldo_window_1_flt, hTcxCfg->tcx_aldo_window_2_flt, L_frame ); + mdct_window_aldo( hTcxCfg->tcx_aldo_window_1_FB_flt, hTcxCfg->tcx_aldo_window_2_FB_flt, NS2SA( input_Fs, FRAME_SIZE_NS ) ); + hTcxCfg->tcx_aldo_window_1_trunc_flt = hTcxCfg->tcx_aldo_window_1_flt + NS2SA( sr_core, N_ZERO_MDCT_NS ); + hTcxCfg->tcx_aldo_window_1_FB_trunc_flt = hTcxCfg->tcx_aldo_window_1_FB_flt + NS2SA( input_Fs, N_ZERO_MDCT_NS ); /*1.25ms transition window for ACELP->TCX*/ hTcxCfg->tcx_mdct_window_trans_length = NS2SA( sr_core, ACELP_TCX_TRANS_NS ); - mdct_window_sine( hTcxCfg->tcx_mdct_window_trans, sr_core, hTcxCfg->tcx_mdct_window_trans_length, TRANSITION_OVERLAP, element_mode ); + mdct_window_sine( hTcxCfg->tcx_mdct_window_trans_flt, sr_core, hTcxCfg->tcx_mdct_window_trans_length, TRANSITION_OVERLAP, element_mode ); hTcxCfg->tcx_mdct_window_trans_lengthFB = NS2SA( input_Fs, ACELP_TCX_TRANS_NS ); if ( hTcxCfg->tcx_mdct_window_trans_length == hTcxCfg->tcx_mdct_window_trans_lengthFB ) { - mvr2r( hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_trans_length ); + mvr2r( hTcxCfg->tcx_mdct_window_trans_flt, hTcxCfg->tcx_mdct_window_transFB_flt, hTcxCfg->tcx_mdct_window_trans_length ); } else { - mdct_window_sine( hTcxCfg->tcx_mdct_window_transFB, input_Fs, hTcxCfg->tcx_mdct_window_trans_lengthFB, TRANSITION_OVERLAP, element_mode ); + mdct_window_sine( hTcxCfg->tcx_mdct_window_transFB_flt, input_Fs, hTcxCfg->tcx_mdct_window_trans_lengthFB, TRANSITION_OVERLAP, element_mode ); } /*Mid-OLA*/ @@ -751,14 +751,14 @@ void init_tcx_window_cfg( hTcxCfg->tcx_mdct_window_half_lengthFB = 2 * ( ( encoderLookahead_FB - (int16_t) ( 0.005f * input_Fs + 0.5f ) ) >> 1 ); assert( ( hTcxCfg->tcx_mdct_window_half_length > 16 ) && "Half window can not be large enough!" ); - mdct_window_sine( hTcxCfg->tcx_mdct_window_half, sr_core, hTcxCfg->tcx_mdct_window_half_length, HALF_OVERLAP, element_mode ); + mdct_window_sine( hTcxCfg->tcx_mdct_window_half_flt, sr_core, hTcxCfg->tcx_mdct_window_half_length, HALF_OVERLAP, element_mode ); if ( hTcxCfg->tcx_mdct_window_half_length == hTcxCfg->tcx_mdct_window_half_lengthFB ) { - mvr2r( hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_half_length ); + mvr2r( hTcxCfg->tcx_mdct_window_half_flt, hTcxCfg->tcx_mdct_window_halfFB_flt, hTcxCfg->tcx_mdct_window_half_length ); } else { - mdct_window_sine( hTcxCfg->tcx_mdct_window_halfFB, input_Fs, hTcxCfg->tcx_mdct_window_half_lengthFB, HALF_OVERLAP, element_mode ); + mdct_window_sine( hTcxCfg->tcx_mdct_window_halfFB_flt, input_Fs, hTcxCfg->tcx_mdct_window_half_lengthFB, HALF_OVERLAP, element_mode ); } /* minimum overlap 1.25 ms */ @@ -767,24 +767,24 @@ void init_tcx_window_cfg( /* save complexity by copying the small windows if they have the same length */ if ( hTcxCfg->tcx_mdct_window_min_length == hTcxCfg->tcx_mdct_window_trans_length ) { - mvr2r( hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_min_length ); + mvr2r( hTcxCfg->tcx_mdct_window_trans_flt, hTcxCfg->tcx_mdct_window_minimum_flt, hTcxCfg->tcx_mdct_window_min_length ); } else { - mdct_window_sine( hTcxCfg->tcx_mdct_window_minimum, sr_core, hTcxCfg->tcx_mdct_window_min_length, MIN_OVERLAP, element_mode ); + mdct_window_sine( hTcxCfg->tcx_mdct_window_minimum_flt, sr_core, hTcxCfg->tcx_mdct_window_min_length, MIN_OVERLAP, element_mode ); } if ( hTcxCfg->tcx_mdct_window_min_lengthFB == hTcxCfg->tcx_mdct_window_trans_lengthFB ) { - mvr2r( hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_min_lengthFB ); + mvr2r( hTcxCfg->tcx_mdct_window_transFB_flt, hTcxCfg->tcx_mdct_window_minimumFB_flt, hTcxCfg->tcx_mdct_window_min_lengthFB ); } else if ( hTcxCfg->tcx_mdct_window_min_length == hTcxCfg->tcx_mdct_window_min_lengthFB ) { - mvr2r( hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_min_lengthFB ); + mvr2r( hTcxCfg->tcx_mdct_window_minimum_flt, hTcxCfg->tcx_mdct_window_minimumFB_flt, hTcxCfg->tcx_mdct_window_min_lengthFB ); } else { - mdct_window_sine( hTcxCfg->tcx_mdct_window_minimumFB, input_Fs, hTcxCfg->tcx_mdct_window_min_lengthFB, MIN_OVERLAP, element_mode ); + mdct_window_sine( hTcxCfg->tcx_mdct_window_minimumFB_flt, input_Fs, hTcxCfg->tcx_mdct_window_min_lengthFB, MIN_OVERLAP, element_mode ); } /* TCX Offset */ @@ -828,7 +828,7 @@ void init_tcx_cfg( int16_t mdctWindowLengthFB; int16_t na_scale_bwidth; - hTcxCfg->preemph_fac = preemph_fac; + hTcxCfg->preemph_fac_flt = preemph_fac; hTcxCfg->tcx5Size = NS2SA( sr_core, FRAME_SIZE_NS / 4 ); /* Always 5 ms */ hTcxCfg->tcx5SizeFB = NS2SA( input_Fs, FRAME_SIZE_NS / 4 ); /* Always 5 ms */ @@ -839,14 +839,14 @@ void init_tcx_cfg( init_tcx_window_cfg( hTcxCfg, sr_core, input_Fs, L_frame, L_frameTCX, encoderLookahead_enc, encoderLookahead_FB, mdctWindowLength, mdctWindowLengthFB, element_mode ); /* SQ deadzone & memory quantization*/ - hTcxCfg->sq_rounding = 0.375f; /*deadzone of 1.25->rounding=1-1.25/2 (No deadzone=0.5)*/ + hTcxCfg->sq_rounding_flt = 0.375f; /*deadzone of 1.25->rounding=1-1.25/2 (No deadzone=0.5)*/ /* TCX rate loop */ hTcxCfg->tcxRateLoopOpt = ( tcxonly ) ? 2 : 0; hTcxCfg->tcxRateLoopOpt = ( element_mode == IVAS_CPE_MDCT ) ? 3 : hTcxCfg->tcxRateLoopOpt; /* TCX bandwidth */ - hTcxCfg->bandwidth = getTcxBandwidth( bwidth ); + hTcxCfg->bandwidth_flt = getTcxBandwidth( bwidth ); /* set number of coded lines */ hTcxCfg->tcx_coded_lines = getNumTcxCodedLines( bwidth ); @@ -890,7 +890,7 @@ void init_tcx_cfg( } /* Scale TCX for non-active frames to adjust loudness with ACELP*/ - hTcxCfg->na_scale = 1.f; + hTcxCfg->na_scale_flt = 1.f; if ( na_scale_bwidth < SWB && !tcxonly ) { @@ -904,7 +904,7 @@ void init_tcx_cfg( { i--; } - hTcxCfg->na_scale = scaleTcxTable[i].scale; + hTcxCfg->na_scale_flt = scaleTcxTable[i].scale_flt; break; } } diff --git a/lib_com/count.c b/lib_com/count.c new file mode 100644 index 000000000..edb33a24d --- /dev/null +++ b/lib_com/count.c @@ -0,0 +1,772 @@ +/* + =========================================================================== + File: COUNT.C v.2.3 - 30.Nov.2009 + =========================================================================== + + ITU-T STL BASIC OPERATORS + + COMPLEXITY EVALUATION FUNCTIONS + + History: + 03 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control + operators for the ITU-T Standard Tool Library as + described in Geneva, 20-30 January 2004 WP 3/16 Q10/16 + TD 11 document and subsequent discussions on the + wp3audio@yahoogroups.com email reflector. + norm_s() weight reduced from 15 to 1. + norm_l() weight reduced from 30 to 1. + L_abs() weight reduced from 2 to 1. + L_add() weight reduced from 2 to 1. + L_negate() weight reduced from 2 to 1. + L_shl() weight reduced from 2 to 1. + L_shr() weight reduced from 2 to 1. + L_sub() weight reduced from 2 to 1. + mac_r() weight reduced from 2 to 1. + msu_r() weight reduced from 2 to 1. + mult_r() weight reduced from 2 to 1. + L_deposit_h() weight reduced from 2 to 1. + L_deposit_l() weight reduced from 2 to 1. + March 06 v2.1 Changed to improve portability. + Dec 06 v2.2 Changed to specify frame rate using setFrameRate() + Adding WMOPS_output_avg() for global average computation + L_mls() weight of 5. + div_l() weight of 32. + i_mult() weight of 3. + ============================================================================ +*/ + + +/***************************************************************************** + * + * This file contains functions for the automatic complexity calculation + * + *****************************************************************************/ + + +#include +#include +#include +#include "stl.h" + +#ifdef WMOPS +static double frameRate = FRAME_RATE; /* default value : 10 ms */ +#endif /* ifdef WMOPS */ + +#ifdef WMOPS +/* Global counter variable for calculation of complexity weight */ +BASIC_OP multiCounter[MAXCOUNTERS]; +int currCounter = 0; /* Zero equals global counter */ +#endif /* ifdef WMOPS */ + +#ifdef WMOPS +void setFrameRate (int samplingFreq, int frameLength) { + if (frameLength > 0) { + frameRate = samplingFreq / 1000000.0 / frameLength; + } + return; +} + +#endif /* ifdef WMOPS */ + +#ifdef WMOPS +/* + * Below list is used for displaying the code profiling information in + * the file which name is defined by CODE_PROFILE_FILENAME. + * For further details see generic_WMOPS_output() function. + * Attention, the ordering in this table must be kept in synchronisation + * with the structure definition BASIC_OP. + */ +char *BasicOperationList[] = { + "add", "sub", "abs_s", "shl", "shr", + "extract_h", "extract_l", "mult", "L_mult", "negate", + "round", "L_mac", "L_msu", "L_macNs", "L_msuNs", + "L_add", "L_sub", "L_add_c", "L_sub_c", "L_negate", + "L_shl", "L_shr", "mult_r", "shr_r", "mac_r", + + "msu_r", "L_deposit_h", "L_deposit_l", "L_shr_r", "L_abs", + "L_sat", "norm_s", "div_s", "norm_l", "move16", + "move32", "Logic16", "Logic32", "Test", "s_max", + "s_min", "L_max", "L_min", "L40_max", "L40_min", + "shl_r", "L_shl_r", "L40_shr_r", "L40_shl_r", "norm_L40", + + "L40_shl", "L40_shr", "L40_negate", "L40_add", "L40_sub", + "L40_abs", "L40_mult", "L40_mac", "mac_r40", + "L40_msu", "msu_r40", "Mpy_32_16_ss", "Mpy_32_32_ss", "L_mult0", + "L_mac0", "L_msu0", "lshl", "lshr", "L_lshl", + "L_lshr", "L40_lshl", "L40_lshr", "s_and", "s_or", + + "s_xor", "L_and", "L_or", "L_xor", "rotl", + "rotr", "L_rotl", "L_rotr", "L40_set", "L40_deposit_h", + "L40_deposit_l", "L40_deposit32", "Extract40_H", "Extract40_L", "L_Extract40", + "L40_round", "L_saturate40", "round40", "IF", "GOTO", + "BREAK", "SWITCH", "FOR", "WHILE", "CONTINUE", + + "L_mls", "div_l", "i_mult" + + /* New complex basops */ + #ifdef COMPLEX_OPERATOR + , "CL_shr", "CL_shl", "CL_add" + , "CL_sub", "CL_scale", "CL_dscale" + , "CL_msu_j", "CL_mac_j", "CL_move" + , "CL_Extract_real", "CL_Extract_imag", "CL_form" + , "CL_multr_32x16", "CL_negate", "CL_conjugate" + , "CL_mul_j" + , "CL_swap_real_imag" + , "C_add" + , "C_sub" + , "C_mul_j" + , "C_multr" + , "C_form" + + , "C_scale" + , "CL_round32_16", "CL_scale_32", "CL_dscale_32", "CL_multr_32x32" + , "C_mac_r", "C_msu_r", "C_Extract_real", "C_Extract_imag" + , "C_negate", "C_conjugate" + , "C_shr", "C_shl" + +#endif /* #ifdef COMPLEX_OPERATOR */ + + /* New 64 bit basops */ +#ifdef ENH_64_BIT_OPERATOR + , "move64" , "W_add_nosat" ,"W_sub_nosat" + , "W_shl" , "W_shr" + , "W_shl_nosat" , "W_shr_nosat" + , "W_mac_32_16" , "W_msu_32_16" , "W_mult_32_16" + , "W_mult0_16_16" , "W_mac0_16_16" , "W_msu0_16_16" + , "W_mult_16_16" , "W_mac_16_16" , "W_msu_16_16" + , "W_shl_sat_l" , "W_sat_l" + , "W_sat_m" , "W_deposit32_l" ,"W_deposit32_h" + , "W_extract_l" , "W_extract_h" + , "W_round48_L" , "W_round32_s" + , "W_norm" + , "W_add" , "W_sub" ,"W_neg" ,"W_abs" + , "W_mult_32_32" , "W_mult0_32_32" + , "W_lshl" , "W_lshr" ,"W_round64_L" + +#endif /* #ifdef ENH_64_BIT_OPERATOR */ + +#ifdef ENH_32_BIT_OPERATOR + , "Mpy_32_16_1" + , "Mpy_32_16_r" + , "Mpy_32_32" + , "Mpy_32_32_r" + , "Madd_32_16" + , "Madd_32_16_r" + , "Msub_32_16" + , "Msub_32_16_r" + , "Madd_32_32" + , "Madd_32_32_r" + , "Msub_32_32" + , "Msub_32_32_r" +#endif /* #ifdef ENH_32_BIT_OPERATOR */ + +#ifdef ENH_U_32_BIT_OPERATOR + , "UL_addNs" + , "UL_subNs" + , "UL_Mpy_32_32" + , "Mpy_32_32_uu" + , "Mpy_32_16_uu" + , "norm_ul_float" + , "UL_deposit_l" +#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ + +#ifdef CONTROL_CODE_OPS + , "LT_16" + , "GT_16" + , "LE_16" + , "GE_16" + , "EQ_16" + , "NE_16" + , "LT_32" + , "GT_32" + , "LE_32" + , "GE_32" + , "EQ_32" + , "NE_32" + , "LT_64" + , "GT_64" + , "LE_64" + , "GE_64" + , "EQ_64" + , "NE_64" +#endif /* #ifdef CONTROL_CODE_OPS */ + +}; +#endif /* ifdef WMOPS */ + + +#ifdef WMOPS +const BASIC_OP op_weight = { + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 2, 2, 1, + 1, 1, 1, 2, 1, + + 1, 1, 1, 2, 1, + 1, 1, 18, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + 2, 2, 2, 2, 1, + + 1, 1, 1, 1, 1, + 1, 1, 1, 2, + 1, 2, 2, 2, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 3, + 3, 3, 3, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 3, 2, + 2, 6, 3, 3, 2, + + 1, 32, 1 + +/* New complex basops */ + #ifdef COMPLEX_OPERATOR + , 1, 1, 1 + , 1, 1, 1 + , 1, 1, 1 + , 1, 1, 1 + , 2, 1, 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 2 + , 1 + + , 1 + , 1, 1, 1, 2 + , 2, 2, 1, 1 + , 1, 1 + , 1, 1 + +#endif /* #ifdef COMPLEX_OPERATOR */ + +#ifdef ENH_64_BIT_OPERATOR + /* Weights of new 64 bit basops */ + , 1 , 1 ,1 + , 1 , 1 + , 1 , 1 + , 1 , 1 , 1 + , 1 , 1 , 1 + , 1 , 1 , 1 + , 1 , 1 + , 1 , 1 , 1 + , 1 , 1 + , 1 , 1 + , 1 + , 1 , 1 , 1 , 1 + , 1 , 1 + , 1 , 1 , 1 +#endif /* #ifdef ENH_64_BIT_OPERATOR */ + +#ifdef ENH_32_BIT_OPERATOR + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 +#endif /* #ifdef ENH_32_BIT_OPERATOR */ + +#ifdef ENH_U_32_BIT_OPERATOR + , 1 + , 1 + , 1 + , 2 + , 2 + , 1 + , 1 +#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ + +#ifdef CONTROL_CODE_OPS + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 +#endif /* #ifdef CONTROL_CODE_OPS */ +}; +#endif /* ifdef WMOPS */ + + +Word32 TotalWeightedOperation (void); +Word32 DeltaWeightedOperation (void); + + +#ifdef WMOPS +/* Counters for separating counting for different objects */ + + +static int maxCounter = 0; +static char *objectName[MAXCOUNTERS + 1]; + +static Word16 fwc_corr[MAXCOUNTERS + 1]; +static long int nbTimeObjectIsCalled[MAXCOUNTERS + 1]; + +#define NbFuncMax 1024 + +static Word16 funcid[MAXCOUNTERS], nbframe[MAXCOUNTERS]; +static Word32 glob_wc[MAXCOUNTERS], wc[MAXCOUNTERS][NbFuncMax]; +static float total_wmops[MAXCOUNTERS]; + +static Word32 LastWOper[MAXCOUNTERS]; +#endif /* ifdef WMOPS */ + + +#ifdef WMOPS +static char *my_strdup (const char *s) { + /* + * duplicates UNIX function strdup() which is not ANSI standard: + * -- malloc() memory area big enough to hold the string s + * -- copy string into new area + * -- return pointer to new area + * + * returns NULL if either s==NULL or malloc() fails + */ + char *dup; + + if (s == NULL) + return NULL; + + /* allocate memory for copy of ID string (including string terminator) */ + /* NOTE: the ID strings will never be deallocated because there is no way to "destroy" a counter that is not longer needed */ + if ((dup = (char *) malloc (strlen (s) + 1)) == NULL) + return NULL; + + return strcpy (dup, s); +} +#endif /* ifdef WMOPS */ + + +int getCounterId (char *objectNameArg) { +#if WMOPS + if (maxCounter >= MAXCOUNTERS - 1) + return 0; + objectName[++maxCounter] = my_strdup (objectNameArg); + return maxCounter; + +#else /* ifdef WMOPS */ + (void)objectNameArg; + return 0; /* Dummy */ + +#endif /* ifdef WMOPS */ +} + + +#if WMOPS +int readCounterId () { + return currCounter; +} +#endif /* ifdef WMOPS */ + + +#ifdef WMOPS +char *readCounterIdName () { + return objectName[currCounter]; +} +#endif /* ifdef WMOPS */ + +void setCounter (int counterId) { +#if WMOPS + if ((counterId > maxCounter) + || (counterId < 0)) { + currCounter = 0; + return; + } + currCounter = counterId; + call_occurred = 1; +#else + (void)counterId; +#endif /* ifdef WMOPS */ +} + + +void incrementNbTimeObjectIsCalled (int counterId) { +#if WMOPS + if ((counterId > maxCounter) + || (counterId < 0)) { + nbTimeObjectIsCalled[0]++; + return; + } + nbTimeObjectIsCalled[counterId]++; +#else + (void)counterId; +#endif /* ifdef WMOPS */ +} + + +#if WMOPS +static Word32 WMOPS_frameStat (void) { +/* calculate the WMOPS seen so far and update the global + per-frame maximum (glob_wc) + */ + Word32 tot; + + tot = TotalWeightedOperation (); + if (tot > glob_wc[currCounter]) + glob_wc[currCounter] = tot; + + /* check if fwc() was forgotten at end of last frame */ + if (tot > LastWOper[currCounter]) { + if (!fwc_corr[currCounter]) { + fprintf (stderr, + "count: operations counted after last fwc() for '%s'; " "-> fwc() called\n", + objectName[currCounter] ? objectName[currCounter] : ""); + } + fwc (); + } + + return tot; +} +#endif /* ifdef WMOPS */ + + +#ifdef WMOPS +static void WMOPS_clearMultiCounter (void) { + Word16 i; + + Word32 *ptr = (Word32 *) & multiCounter[currCounter]; + for (i = 0; i < (Word16)(sizeof (multiCounter[currCounter]) / sizeof (Word32)); i++) { + *ptr++ = 0; + } +} +#endif /* ifdef WMOPS */ + + +void ClearNbTimeObjectsAreCalled () { +#if WMOPS + Word16 i; + + for (i = 0; i < (Word16)(sizeof (multiCounter[currCounter]) / sizeof (Word32)); i++) { + nbTimeObjectIsCalled[i] = 0; + } +#endif /* ifdef WMOPS */ +} + +Word32 TotalWeightedOperation () { +#if WMOPS + Word16 i; + Word32 tot, *ptr, *ptr2; + + tot = 0; + ptr = (Word32 *) & multiCounter[currCounter]; + ptr2 = (Word32 *) & op_weight; + for (i = 0; i < (Word16)(sizeof (multiCounter[currCounter]) / sizeof (Word32)); i++) { + tot += ((*ptr++) * (*ptr2++)); + } + + return ((Word32) tot); + +#else /* ifdef WMOPS */ + return 0; /* Dummy */ + +#endif /* ifdef WMOPS */ + +} + +Word32 DeltaWeightedOperation () { +#if WMOPS + Word32 NewWOper, delta; + + NewWOper = TotalWeightedOperation (); + delta = NewWOper - LastWOper[currCounter]; + LastWOper[currCounter] = NewWOper; + return (delta); + +#else /* ifdef WMOPS */ + return 0; /* Dummy */ + +#endif /* ifdef WMOPS */ +} + + +void Init_WMOPS_counter (void) { +#if WMOPS + Word16 i; + + /* reset function weight operation counter variable */ + + for (i = 0; i < NbFuncMax; i++) + wc[currCounter][i] = (Word32) 0; + glob_wc[currCounter] = 0; + nbframe[currCounter] = 0; + total_wmops[currCounter] = 0.0; + + /* initially clear all counters */ + WMOPS_clearMultiCounter (); + LastWOper[currCounter] = 0; + funcid[currCounter] = 0; + + /* Following line is useful for incrIf(), see control.h */ + call_occurred = 1; + funcId_where_last_call_to_else_occurred = MAXCOUNTERS; +#endif /* ifdef WMOPS */ +} + + +void Reset_WMOPS_counter (void) { +#if WMOPS + Word32 tot = WMOPS_frameStat (); + + /* increase the frame counter --> a frame is counted WHEN IT BEGINS */ + nbframe[currCounter]++; + + /* add wmops used in last frame to count, then reset counter (in first frame, this is a no-op */ + total_wmops[currCounter] += (float) (tot * frameRate); + + /* clear counter before new frame starts */ + WMOPS_clearMultiCounter (); + LastWOper[currCounter] = 0; + funcid[currCounter] = 0; /* new frame, set function id to zero */ +#endif /* ifdef WMOPS */ +} + + +Word32 fwc (void) { +/* function worst case */ +#if WMOPS + Word32 tot; + + tot = DeltaWeightedOperation (); + if (tot > wc[currCounter][funcid[currCounter]]) + wc[currCounter][funcid[currCounter]] = tot; + + funcid[currCounter]++; + return (tot); + +#else /* ifdef WMOPS */ + return 0; /* Dummy */ + +#endif /* ifdef WMOPS */ +} + +void WMOPS_output (Word16 dtx_mode) { +#if WMOPS + Word16 i; + Word32 tot, tot_wm, tot_wc; + + /* get operations since last reset (or init), but do not update the counters (except the glob_wc[] maximum) + so output CAN be called in each frame without problems. The frame counter is NOT updated! */ + tot = WMOPS_frameStat (); + tot_wm = (Word32) (total_wmops[currCounter] + ((float) tot) * frameRate); + + fprintf (stdout, + "%10s:WMOPS=%.3f", objectName[currCounter] ? objectName[currCounter] : "", + ((float) tot) * frameRate); + + if (nbframe[currCounter] != 0) { + fprintf (stdout, " Average=%.3f", tot_wm / (float) nbframe[currCounter]); + } + fprintf (stdout, " WorstCase=%.3f", ((float) glob_wc[currCounter]) * frameRate); + + /* Worst worst case printed only when not in DTX mode */ + if (dtx_mode == 0) { + tot_wc = 0L; + for (i = 0; i < funcid[currCounter]; i++) + tot_wc += wc[currCounter][i]; + fprintf (stdout, " WorstWC=%.3f", ((float) tot_wc) * frameRate); + } + fprintf (stdout, " (%d frames)\n", nbframe[currCounter]); +#else + (void)dtx_mode; +#endif /* ifdef WMOPS */ +} + + +void WMOPS_output_avg (Word16 dtx_mode, Word32 * tot_wm, Word16 * num_frames) { +#if WMOPS + Word16 i; + Word32 tot, tot_wc; + + /* get operations since last reset (or init), but do not update the counters (except the glob_wc[] maximum) + so output CAN be called in each frame without problems. The frame counter is NOT updated! */ + tot = WMOPS_frameStat (); + *tot_wm = (Word32) (total_wmops[currCounter] + ((float) tot) * frameRate); + *num_frames = nbframe[currCounter]; + + fprintf (stdout, "%10s:WMOPS=%.3f", objectName[currCounter] ? objectName[currCounter] : "", ((float) tot) * frameRate); + + if (nbframe[currCounter] != 0) { + fprintf (stdout, " Average=%.3f", *tot_wm / (float) nbframe[currCounter]); + } + fprintf (stdout, " WorstCase=%.3f", ((float) glob_wc[currCounter]) * frameRate); + + /* Worst worst case printed only when not in DTX mode */ + if (dtx_mode == 0) { + tot_wc = 0L; + for (i = 0; i < funcid[currCounter]; i++) + tot_wc += wc[currCounter][i]; + fprintf (stdout, " WorstWC=%.3f", ((float) tot_wc) * frameRate); + } + fprintf (stdout, " (%d frames)\n", nbframe[currCounter]); +#else + (void)dtx_mode; + (void)tot_wm; + (void)num_frames; +#endif /* ifdef WMOPS */ +} + +void generic_WMOPS_output (Word16 dtx_mode, char *test_file_name) { +#if WMOPS + int saved_value; + Word16 i; + Word32 tot, tot_wm, tot_wc, *ptr, *ptr2; + Word40 grand_total; + FILE *WMOPS_file; + + saved_value = currCounter; + + /* Count the grand_total WMOPS so that % ratio per function group can be displayed. */ + grand_total = 0; + for (currCounter = 0; currCounter <= maxCounter; currCounter++) { + tot = WMOPS_frameStat (); + grand_total += tot; + } + + + if ((WMOPS_file = fopen (WMOPS_DATA_FILENAME, "a")) != NULL) { + + printf ("opened file %s in order to print WMOPS for each function group.\n", WMOPS_DATA_FILENAME); + + /* Print the file header line. */ + fprintf (WMOPS_file, "Test file name\tFunction Name \tFrame\tNb Times Called\tWMOPS\t%% versus grand total"); + + if (nbframe[saved_value] != 0) + fprintf (WMOPS_file, "\tAverage"); + + fprintf (WMOPS_file, "\tWorstCase"); + + /* Worst worst case printed only when not in DTX mode */ + if (dtx_mode == 0) + fprintf (WMOPS_file, "\tWorstWC"); + + fprintf (WMOPS_file, "\n"); + + /* Print the WMOPS for each Function Group by scanning all the function groups with currCounter index. */ + for (currCounter = 0; currCounter <= maxCounter; currCounter++) { + + fprintf (WMOPS_file, "%s", test_file_name); + fprintf (WMOPS_file, "\t%s", objectName[currCounter] ? objectName[currCounter] : ""); + fprintf (WMOPS_file, "\t%d", nbframe[currCounter]); + + tot = WMOPS_frameStat (); + tot_wm = (Word32) (total_wmops[currCounter] + ((float) tot) * frameRate); + + fprintf (WMOPS_file, "\t\t%ld", nbTimeObjectIsCalled[currCounter]); + fprintf (WMOPS_file, "\t%.6f", ((float) tot) * frameRate); + fprintf (WMOPS_file, "\t%.3f", ((float) tot) / grand_total * 100); + + if (nbframe[currCounter] != 0) + fprintf (WMOPS_file, "\t%.3f", tot_wm / (float) nbframe[currCounter]); + + fprintf (WMOPS_file, "\t%.3f", ((float) glob_wc[currCounter]) * frameRate); + + /* Worst worst case printed only when not in DTX mode */ + if (dtx_mode == 0) { + tot_wc = 0L; + for (i = 0; i < funcid[currCounter]; i++) + tot_wc += wc[currCounter][i]; + fprintf (WMOPS_file, "\t%.3f", ((float) tot_wc) * frameRate); + } + fprintf (WMOPS_file, "\n"); + + } + + /* Print the file Grand Total line */ + fprintf (WMOPS_file, "%s", test_file_name); + fprintf (WMOPS_file, "\tGrand Total"); + fprintf (WMOPS_file, "\t%d", nbframe[saved_value]); + fprintf (WMOPS_file, "\t\t%.6f", ((float) grand_total) * frameRate); + fprintf (WMOPS_file, "\t100.000"); + fprintf (WMOPS_file, "\n"); + fclose (WMOPS_file); + + } else + printf ("Can not open file %s for WMOPS editing\n", WMOPS_DATA_FILENAME); + + + if ((WMOPS_file = fopen (WMOPS_TOTAL_FILENAME, "a")) != NULL) { + printf ("opened file %s in order to print application's total WMOPS.\n", WMOPS_TOTAL_FILENAME); + fprintf (WMOPS_file, "%s", test_file_name); + fprintf (WMOPS_file, "\tframe=%d", nbframe[currCounter]); + fprintf (WMOPS_file, "\tWMOPS=%.6f", ((float) grand_total) * frameRate); + fprintf (WMOPS_file, "\n"); + fclose (WMOPS_file); + + } else + printf ("Can not open file %s for WMOPS editing.\n", WMOPS_TOTAL_FILENAME); + + + if ((WMOPS_file = fopen (CODE_PROFILE_FILENAME, "a")) != NULL) { + + printf ("opened file %s in order to print basic operation distribution statistics.\n", CODE_PROFILE_FILENAME); + + /* Print the file header line. */ + fprintf (WMOPS_file, "Test file name\tBasic Operation Name\tframe\tWMOPS\t\t%% versus grand total\n"); + + /* Print the WMOPS for each Basic Operation across all the defined */ + /* Function Groups. */ + for (i = 0; i < (Word16)(sizeof (op_weight) / sizeof (Word32)); i++) { + fprintf (WMOPS_file, "%-16s", test_file_name); + fprintf (WMOPS_file, "\t%s", BasicOperationList[i]); + fprintf (WMOPS_file, "\t%d", nbframe[0]); + + tot = 0; + ptr = (Word32 *) & multiCounter[0] + i; + ptr2 = (Word32 *) & op_weight + i; + for (currCounter = 0; currCounter <= maxCounter; currCounter++) { + tot += ((*ptr) * (*ptr2)); + ptr += (sizeof (op_weight) / sizeof (Word32)); + } + + fprintf (WMOPS_file, "\t%.6f", ((float) tot) * frameRate); + fprintf (WMOPS_file, "\t%.3f", ((float) tot) / grand_total * 100); + fprintf (WMOPS_file, "\n"); + } + + /* Print the file Grand Total line */ + fprintf (WMOPS_file, "%s", test_file_name); + fprintf (WMOPS_file, "\tGrand Total"); + fprintf (WMOPS_file, "\t%d", nbframe[saved_value]); + fprintf (WMOPS_file, "\t%.6f", ((float) grand_total) * frameRate); + fprintf (WMOPS_file, "\t100.000"); + fprintf (WMOPS_file, "\n"); + fclose (WMOPS_file); + + } else + printf ("Can not open file %s for basic operations distribution statistic editing\n", CODE_PROFILE_FILENAME); + + currCounter = saved_value; + +#else + (void)dtx_mode; + (void)test_file_name; +#endif /* ifdef WMOPS */ +} + + +/* end of file */ diff --git a/lib_com/count.h b/lib_com/count.h new file mode 100644 index 000000000..4e853d6f4 --- /dev/null +++ b/lib_com/count.h @@ -0,0 +1,542 @@ +/* + =========================================================================== + File: COUNT.H v.2.3 - 30.Nov.2009 + =========================================================================== + + ITU-T STL BASIC OPERATORS + + PROTOTYPES & DEFINITION FOR COUNTING OPERATIONS + + History + 09.Aug.1999 V1.0.0 Input to UGST from ETSI AMR (count.h); + + 26.Jan.2000 V1.1.0 Added counter entries for G.723.1's + L_mls(), div_l(), i_mult() [from basop32.c] + + 05.Jul.2000 V1.2.0 Added counter entries for 32bit shiftless + operators L_mult0(), L_mac0(), L_msu0() + + 03 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control + operators for the ITU-T Standard Tool Library as + described in Geneva, 20-30 January 2004 WP 3/16 Q10/16 + TD 11 document and subsequent discussions on the + wp3audio@yahoogroups.com email reflector. + March 06 v2.1 Changed to improve portability. + Dec 06 v2.2 Changed to specify frame rate using setFrameRate() + Adding WMOPS_output_avg() for global average computation + L_mls() weight of 5. + div_l() weight of 32. + i_mult() weight of 3. + ============================================================================ +*/ + + +/****************************************************************************** + * Functions for counting operations. + * + * These functions make it possible to measure the wMOPS of a codec. + * + * All functions in this file, and in other *.h files, update a structure so + * that it will be possible to track how many calls to add(), sub(), L_mult() + * ... was made by the code and to estimate the wMOPS (and MIPS) for a certain + * part of the code. + * + * It is also possible to measure the wMOPS separatly for different parts + * of the codec. + * + * This is done by creating a counter group (getCounterId) for each part of + * the code that one wants a seperate measure for. Before a part of the code + * is executed a call to the "setCounter" function is needed to identify + * which counter group to use. + * + * Currently there is a limit of 255 different counter groups. + * + * In the end of this file, there is a piece of code illustrating how the + * functions can be used. + * +******************************************************************************/ + + +#ifndef _COUNT_H +#define _COUNT_H "$Id$" +#if 0 +#define WMOPS 1 /* enable WMOPS profiling features */ +#undef WMOPS /* disable WMOPS profiling features */ +#endif +#define MAXCOUNTERS (256) + + +#define BASOP_sub_start(label) +#define BASOP_sub_end() +#define SUB_WMOPS_INIT(label) BASOP_sub_start(label) +#define END_SUB_WMOPS BASOP_sub_end() +#define BASOP_push_wmops(label) +#define BASOP_pop_wmops() +#define BASOP_end_noprint +#define BASOP_end +#define BASOP_init + +int getCounterId (char *objectName); +/* + * Create a counter group, the "objectname" will be used when printing + * statistics for this counter group. + * + * Returns 0 if no more counter groups are available. + */ + + +int readCounterId (void); +/* + * Returns the current CounterId. + */ + + +void setCounter (int counterId); +/* + * Defines which counter group to use, default is zero. + */ + + +char *readCounterIdName (void); +/* + * Returns the current CounterId name. + */ + + +void incrementNbTimeObjectIsCalled (int counterId); +/* + * This function enables to increment by 1 a counter + * tracking the number of times the application enters a groups of functions. + * If the counterId is not refering to a defined function counter group, then it is + * the default function group (0) which is impacted. + * + */ + + +void ClearNbTimeObjectsAreCalled (void); +/* + * This function enables to clear to 0 all the counters enabling to + * track the number of times the application enters any groups of functions. + */ + + +void Init_WMOPS_counter (void); +/* + * Initiates the current counter group. + */ + + +void Reset_WMOPS_counter (void); +/* + * Resets the current counter group. + */ + + +void WMOPS_output (Word16 notPrintWorstWorstCase); +/* + * Prints the statistics to the screen, if the argument is non zero + * the statistics for worst worst case will not be printed. This is typically + * done for dtx frames. + * + */ + +void WMOPS_output_avg (Word16 dtx_mode, Word32 * tot_wm, Word16 * num_frames); +/* + * same as WMOPS_output + returns the total wmops counter and the number of frames + * to support the computation of global average. + * + */ + + +Word32 fwc (void); +/* + * worst worst case counter. + * + * This function calculates the worst possible case that can be reached. + * + * This is done by calling this function for each subpart of the calculations + * for a frame. This function then stores the maximum wMOPS for each part. + * + * The WMOPS_output function add together all parts and presents the sum. + */ + +void setFrameRate (int samplingFreq, int frameLength); +/* + * This function can overwrite the value of the frameRate variable that is + * initialized by the FRAME_RATE constant. + */ + + +#define WMOPS_DATA_FILENAME "wmops_data.txt" +/* + * WMOPS_DATA_FILENAME is the macro defining the name of the file + * where the Weighted Million of Operations per Second (wMOPS) + * are appended, function group by function group. +*/ + + +#define CODE_PROFILE_FILENAME "code_profile.txt" +/* + * CODE_PROFILE_FILENAME is the macro defining the name of the file + * where the Weighted Million of Operations per Second (WMOPS) + * are appended, basic operation by basic operation. +*/ + + +#define WMOPS_TOTAL_FILENAME "wmops_total.txt" +/* + * WMOPS_TOTAL_FILENAME is the macro defining the name of the file + * where the Weighted Million of Operations per Second (WMOPS) + * are printed, globally for the application. +*/ + + +#define FRAME_RATE (0.0001F) /* in this version frame_rate can be overwriten online by the new setFrameRate function */ +/* FRAME_RATE of 0.000025 is corresponding to 40ms frame.*/ +/* FRAME_RATE of 0.00005 is corresponding to 20ms frame.*/ +/* FRAME_RATE of 0.0001 is corresponding to 10ms frame.*/ +/* + * FRAME_RATE is the macro defining the calling rate of the + * application to benchmark. +*/ + + +/* Global counter variable for calculation of complexity weight */ +typedef struct { + UWord32 add; /* Complexity Weight of 1 */ + UWord32 sub; /* Complexity Weight of 1 */ + UWord32 abs_s; /* Complexity Weight of 1 */ + UWord32 shl; /* Complexity Weight of 1 */ + UWord32 shr; /* Complexity Weight of 1 */ + + UWord32 extract_h; /* Complexity Weight of 1 */ + UWord32 extract_l; /* Complexity Weight of 1 */ + UWord32 mult; /* Complexity Weight of 1 */ + UWord32 L_mult; /* Complexity Weight of 1 */ + UWord32 negate; /* Complexity Weight of 1 */ + + UWord32 round; /* Complexity Weight of 1 */ + UWord32 L_mac; /* Complexity Weight of 1 */ + UWord32 L_msu; /* Complexity Weight of 1 */ + UWord32 L_macNs; /* Complexity Weight of 1 */ + UWord32 L_msuNs; /* Complexity Weight of 1 */ + + UWord32 L_add; /* Complexity Weight of 1 */ + UWord32 L_sub; /* Complexity Weight of 1 */ + UWord32 L_add_c; /* Complexity Weight of 2 */ + UWord32 L_sub_c; /* Complexity Weight of 2 */ + UWord32 L_negate; /* Complexity Weight of 1 */ + + UWord32 L_shl; /* Complexity Weight of 1 */ + UWord32 L_shr; /* Complexity Weight of 1 */ + UWord32 mult_r; /* Complexity Weight of 1 */ + UWord32 shr_r; /* Complexity Weight of 3 */ + UWord32 mac_r; /* Complexity Weight of 1 */ + + UWord32 msu_r; /* Complexity Weight of 1 */ + UWord32 L_deposit_h; /* Complexity Weight of 1 */ + UWord32 L_deposit_l; /* Complexity Weight of 1 */ + UWord32 L_shr_r; /* Complexity Weight of 3 */ + UWord32 L_abs; /* Complexity Weight of 1 */ + + UWord32 L_sat; /* Complexity Weight of 4 */ + UWord32 norm_s; /* Complexity Weight of 1 */ + UWord32 div_s; /* Complexity Weight of 18 */ + UWord32 norm_l; /* Complexity Weight of 1 */ + UWord32 move16; /* Complexity Weight of 1 */ + + UWord32 move32; /* Complexity Weight of 2 */ + UWord32 Logic16; /* Complexity Weight of 1 */ + UWord32 Logic32; /* Complexity Weight of 2 */ + UWord32 Test; /* Complexity Weight of 2 */ + UWord32 s_max; /* Complexity Weight of 1 */ + + UWord32 s_min; /* Complexity Weight of 1 */ + UWord32 L_max; /* Complexity Weight of 1 */ + UWord32 L_min; /* Complexity Weight of 1 */ + UWord32 L40_max; /* Complexity Weight of 1 */ + UWord32 L40_min; /* Complexity Weight of 1 */ + + UWord32 shl_r; /* Complexity Weight of 2 */ + UWord32 L_shl_r; /* Complexity Weight of 2 */ + UWord32 L40_shr_r; /* Complexity Weight of 2 */ + UWord32 L40_shl_r; /* Complexity Weight of 2 */ + UWord32 norm_L40; /* Complexity Weight of 1 */ + + UWord32 L40_shl; /* Complexity Weight of 1 */ + UWord32 L40_shr; /* Complexity Weight of 1 */ + UWord32 L40_negate; /* Complexity Weight of 1 */ + UWord32 L40_add; /* Complexity Weight of 1 */ + UWord32 L40_sub; /* Complexity Weight of 1 */ + + UWord32 L40_abs; /* Complexity Weight of 1 */ + UWord32 L40_mult; /* Complexity Weight of 1 */ + UWord32 L40_mac; /* Complexity Weight of 1 */ + UWord32 mac_r40; /* Complexity Weight of 2 */ + + UWord32 L40_msu; /* Complexity Weight of 1 */ + UWord32 msu_r40; /* Complexity Weight of 2 */ + UWord32 Mpy_32_16_ss; /* Complexity Weight of 2 */ + UWord32 Mpy_32_32_ss; /* Complexity Weight of 2 */ + UWord32 L_mult0; /* Complexity Weight of 1 */ + + UWord32 L_mac0; /* Complexity Weight of 1 */ + UWord32 L_msu0; /* Complexity Weight of 1 */ + UWord32 lshl; /* Complexity Weight of 1 */ + UWord32 lshr; /* Complexity Weight of 1 */ + UWord32 L_lshl; /* Complexity Weight of 1 */ + + UWord32 L_lshr; /* Complexity Weight of 1 */ + UWord32 L40_lshl; /* Complexity Weight of 1 */ + UWord32 L40_lshr; /* Complexity Weight of 1 */ + UWord32 s_and; /* Complexity Weight of 1 */ + UWord32 s_or; /* Complexity Weight of 1 */ + + UWord32 s_xor; /* Complexity Weight of 1 */ + UWord32 L_and; /* Complexity Weight of 1 */ + UWord32 L_or; /* Complexity Weight of 1 */ + UWord32 L_xor; /* Complexity Weight of 1 */ + UWord32 rotl; /* Complexity Weight of 3 */ + + UWord32 rotr; /* Complexity Weight of 3 */ + UWord32 L_rotl; /* Complexity Weight of 3 */ + UWord32 L_rotr; /* Complexity Weight of 3 */ + UWord32 L40_set; /* Complexity Weight of 1 */ + UWord32 L40_deposit_h; /* Complexity Weight of 1 */ + + UWord32 L40_deposit_l; /* Complexity Weight of 1 */ + UWord32 L40_deposit32; /* Complexity Weight of 1 */ + UWord32 Extract40_H; /* Complexity Weight of 1 */ + UWord32 Extract40_L; /* Complexity Weight of 1 */ + UWord32 L_Extract40; /* Complexity Weight of 1 */ + + UWord32 L40_round; /* Complexity Weight of 1 */ + UWord32 L_saturate40; /* Complexity Weight of 1 */ + UWord32 round40; /* Complexity Weight of 1 */ + UWord32 If; /* Complexity Weight of 3 */ + UWord32 Goto; /* Complexity Weight of 2 */ + + UWord32 Break; /* Complexity Weight of 2 */ + UWord32 Switch; /* Complexity Weight of 6 */ + UWord32 For; /* Complexity Weight of 3 */ + UWord32 While; /* Complexity Weight of 3 */ + UWord32 Continue; /* Complexity Weight of 2 */ + + UWord32 L_mls; /* Complexity Weight of 1 */ + UWord32 div_l; /* Complexity Weight of 32 */ + UWord32 i_mult; /* Complexity Weight of 1 */ + +/* New complex basic operators */ +#ifdef COMPLEX_OPERATOR + UWord32 CL_shr; /* Complexity Weight of 1 */ + UWord32 CL_shl; /* Complexity Weight of 1 */ + UWord32 CL_add; /* Complexity Weight of 1 */ + UWord32 CL_sub; /* Complexity Weight of 1 */ + UWord32 CL_scale; /* Complexity Weight of 1 */ + UWord32 CL_dscale; /* Complexity Weight of 1 */ + UWord32 CL_msu_j; /* Complexity Weight of 1 */ + UWord32 CL_mac_j; /* Complexity Weight of 1 */ + UWord32 CL_move; /* Complexity Weight of 1 */ + UWord32 CL_Extract_real; /* Complexity Weight of 1 */ + UWord32 CL_Extract_imag; /* Complexity Weight of 1 */ + UWord32 CL_form; /* Complexity Weight of 1 */ + UWord32 CL_multr_32x16; /* Complexity Weight of 2 */ + UWord32 CL_negate; /* Complexity Weight of 1 */ + UWord32 CL_conjugate; /* Complexity Weight of 1 */ + UWord32 CL_mul_j; /* Complexity Weight of 1 */ + UWord32 CL_swap_real_imag; /* Complexity Weight of 1 */ + UWord32 C_add; /* Complexity Weight of 1 */ + UWord32 C_sub; /* Complexity Weight of 1 */ + UWord32 C_mul_j; /* Complexity Weight of 1 */ + UWord32 C_multr; /* Complexity Weight of 2 */ + UWord32 C_form; /* Complexity Weight of 1 */ + + UWord32 C_scale; /* Complexity Weight of 1 */ + UWord32 CL_round32_16; /* Complexity Weight of 1 */ + UWord32 CL_scale_32; /* Complexity Weight of 1 */ + UWord32 CL_dscale_32; /* Complexity Weight of 1 */ + UWord32 CL_multr_32x32; /* Complexity Weight of 2 */ + UWord32 C_mac_r; /* Complexity Weight of 2 */ + UWord32 C_msu_r; /* Complexity Weight of 2 */ + UWord32 C_Extract_real; /* Complexity Weight of 1 */ + UWord32 C_Extract_imag; /* Complexity Weight of 1 */ + UWord32 C_negate; /* Complexity Weight of 1 */ + UWord32 C_conjugate; /* Complexity Weight of 1 */ + UWord32 C_shr; /* Complexity Weight of 1 */ + UWord32 C_shl; /* Complexity Weight of 1 */ + +#endif /* #ifdef COMPLEX_OPERATOR */ + +/* New 64 bit basops */ +#ifdef ENH_64_BIT_OPERATOR + UWord32 move64; /* Complexity Weight of 1 */ + UWord32 W_add_nosat; /* Complexity Weight of 1 */ + UWord32 W_sub_nosat; /* Complexity Weight of 1 */ + UWord32 W_shl; /* Complexity Weight of 1 */ + UWord32 W_shr; /* Complexity Weight of 1 */ + UWord32 W_shl_nosat; /* Complexity Weight of 1 */ + UWord32 W_shr_nosat; /* Complexity Weight of 1 */ + UWord32 W_mac_32_16; /* Complexity Weight of 1 */ + UWord32 W_msu_32_16; /* Complexity Weight of 1 */ + UWord32 W_mult_32_16; /* Complexity Weight of 1 */ + UWord32 W_mult0_16_16; /* Complexity Weight of 1 */ + UWord32 W_mac0_16_16; /* Complexity Weight of 1 */ + UWord32 W_msu0_16_16; /* Complexity Weight of 1 */ + UWord32 W_mult_16_16; /* Complexity Weight of 1 */ + UWord32 W_mac_16_16; /* Complexity Weight of 1 */ + UWord32 W_msu_16_16; /* Complexity Weight of 1 */ + UWord32 W_shl_sat_l; /* Complexity Weight of 1 */ + UWord32 W_sat_l; /* Complexity Weight of 1 */ + UWord32 W_sat_m; /* Complexity Weight of 1 */ + UWord32 W_deposit32_l; /* Complexity Weight of 1 */ + UWord32 W_deposit32_h; /* Complexity Weight of 1 */ + UWord32 W_extract_l; /* Complexity Weight of 1 */ + UWord32 W_extract_h; /* Complexity Weight of 1 */ + UWord32 W_round48_L; /* Complexity Weight of 1 */ + UWord32 W_round32_s; /* Complexity Weight of 1 */ + UWord32 W_norm; /* Complexity Weight of 1 */ + + UWord32 W_add; /* Complexity Weight of 1 */ + UWord32 W_sub; /* Complexity Weight of 1 */ + UWord32 W_neg; /* Complexity Weight of 1 */ + UWord32 W_abs; /* Complexity Weight of 1 */ + UWord32 W_mult_32_32; /* Complexity Weight of 1 */ + UWord32 W_mult0_32_32; /* Complexity Weight of 1 */ + UWord32 W_lshl; /* Complexity Weight of 1 */ + UWord32 W_lshr; /* Complexity Weight of 1 */ + UWord32 W_round64_L; /* Complexity Weight of 1 */ + +#endif /* #ifdef ENH_64_BIT_OPERATOR */ + +#ifdef ENH_32_BIT_OPERATOR + UWord32 Mpy_32_16_1; /* Complexity Weight of 1 */ + UWord32 Mpy_32_16_r; /* Complexity Weight of 1 */ + UWord32 Mpy_32_32; /* Complexity Weight of 1 */ + UWord32 Mpy_32_32_r; /* Complexity Weight of 1 */ + UWord32 Madd_32_16; /* Complexity Weight of 1 */ + UWord32 Madd_32_16_r; /* Complexity Weight of 1 */ + UWord32 Msub_32_16; /* Complexity Weight of 1 */ + UWord32 Msub_32_16_r; /* Complexity Weight of 1 */ + UWord32 Madd_32_32; /* Complexity Weight of 1 */ + UWord32 Madd_32_32_r; /* Complexity Weight of 1 */ + UWord32 Msub_32_32; /* Complexity Weight of 1 */ + UWord32 Msub_32_32_r; /* Complexity Weight of 1 */ +#endif /* #ifdef ENH_32_BIT_OPERATOR */ + +#ifdef ENH_U_32_BIT_OPERATOR + UWord32 UL_addNs; /* Complexity Weight of 1 */ + UWord32 UL_subNs; /* Complexity Weight of 1 */ + UWord32 UL_Mpy_32_32; /* Complexity Weight of 1 */ + UWord32 Mpy_32_32_uu; /* Complexity Weight of 2 */ + UWord32 Mpy_32_16_uu; /* Complexity Weight of 2 */ + UWord32 norm_ul_float; /* Complexity Weight of 1 */ + UWord32 UL_deposit_l; /* Complexity Weight of 1 */ +#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ + +#ifdef CONTROL_CODE_OPS + UWord32 LT_16; /* Complexity Weight of 1 */ + UWord32 GT_16; /* Complexity Weight of 1 */ + UWord32 LE_16; /* Complexity Weight of 1 */ + UWord32 GE_16; /* Complexity Weight of 1 */ + UWord32 EQ_16; /* Complexity Weight of 1 */ + UWord32 NE_16; /* Complexity Weight of 1 */ + UWord32 LT_32; /* Complexity Weight of 1 */ + UWord32 GT_32; /* Complexity Weight of 1 */ + UWord32 LE_32; /* Complexity Weight of 1 */ + UWord32 GE_32; /* Complexity Weight of 1 */ + UWord32 EQ_32; /* Complexity Weight of 1 */ + UWord32 NE_32; /* Complexity Weight of 1 */ + UWord32 LT_64; /* Complexity Weight of 1 */ + UWord32 GT_64; /* Complexity Weight of 1 */ + UWord32 LE_64; /* Complexity Weight of 1 */ + UWord32 GE_64; /* Complexity Weight of 1 */ + UWord32 EQ_64; /* Complexity Weight of 1 */ + UWord32 NE_64; /* Complexity Weight of 1 */ + +#endif /* #ifdef CONTROL_CODE_OPS */ +} BASIC_OP; + + +Word32 TotalWeightedOperation (void); +Word32 DeltaWeightedOperation (void); + + +void generic_WMOPS_output (Word16 notPrintWorstWorstCase, char *test_file_name); +/* + * This function enable to append : + * - to WMOPS_DATA_FILENAME file, the WMOPS information related + * to the execution of the application, function group by function + * group. + * - to CODE_PROFILE_FILENAME file, the WMOPS information related + * to the execution of the application, basic operation by basic + * operation. + * - to WMOPS_TOTAL_FILENAME file, the total WMOPS information related + * to the execution of the application. + * + * Note that : + * if the files exists, the data will be written at the end of file. + * + * test_file_name : Is a character string referencing each calls to + * generic_WMOPS_output(). Usually, it is the name of a test + * sequence file. + * + * notPrintWorstWorstCase : Same usage as in WMOPS_output(). + */ + + +#if 0 +/* + * Example of how count.h could be used. + * + * In the example below it is assumed that the init_OBJECT functions + * does not use any calls to counter.h or basic_op.h. If this is the case + * a call to the function Reset_WMOPS_counter() must be done after each call + * to init_OBJECT if these operations is not to be included in the statistics. + */ + +int main () { + int spe1Id, spe2Id, cheId; + + /* initiate counters and objects */ + spe1Id = getCounterId ("Spe 5k8"); + setCounter (spe1Id); + Init_WMOPS_counter (); + init_spe1 ( ...); + + spe2Id = getCounterId ("Spe 12k2"); + setCounter (spe2Id); + Init_WMOPS_counter (); + init_spe2 ( ...); + + cheId = getCounterId ("Channel encoder"); + setCounter (cheId); + Init_WMOPS_counter (); + init_che ( ...); + ... while (data) { + test (); /* Note this call to test(); */ + if (useSpe1) + setCounter (spe1Id); + else + setCounter (spe2Id); + Reset_WMOPS_counter (); + speEncode ( ...); + WMOPS_output (0); /* Normal routine for displaying WMOPS info */ + + setCounter (cheId); + Reset_WMOPS_counter (); + preChannelInter ( ...); + fwc (); /* Note the call to fwc() for each part */ + convolve ( ...); + fwc (); /* of the channel encoder. */ + interleave ( ...); + fwc (); + WMOPS_output (0); /* Normal routine for displaying WMOPS info */ + } +} +#endif /* #if 0 */ + + +#endif /* _COUNT_H */ + + +/* end of file */ diff --git a/lib_com/deemph.c b/lib_com/deemph.c index 26baccd04..5c3d5c1f0 100644 --- a/lib_com/deemph.c +++ b/lib_com/deemph.c @@ -38,7 +38,8 @@ #include "options.h" #include "prot.h" #include "wmc_auto.h" - +#include "prot_fx1.h" +#include "prot_fx2.h" /*-------------------------------------------------------------------* * deemph() * @@ -69,3 +70,163 @@ void deemph( return; } + +/*========================================================================*/ +/* FUNCTION : deemph_fx() */ +/*------------------------------------------------------------------------*/ +/* PURPOSE : Deemphasis: filtering through 1/(1-mu z^-1) */ +/*------------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* _ (Word16) mu : deemphasis factor Q15 */ +/* _ (Word16) L : vector size */ +/*------------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ (Word16*) signal : signal Q_syn2-1 */ +/* _ (Word16*) mem : memory (y[-1]) Q_syn2-1 */ +/*------------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/*------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ None */ +/*========================================================================*/ +void deemph_fx( + Word16 *signal, /* i/o: signal Qx */ + const Word16 mu, /* i : deemphasis factor Q15 */ + const Word16 L, /* i : vector size Q0 */ + Word16 *mem /* i/o: memory (y[-1]) Qx */ +) +{ + Word16 i; + Word32 L_tmp; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + L_tmp = L_deposit_h(signal[0]); +#ifdef BASOP_NOGLOB + L_tmp = L_mac_o(L_tmp, *mem, mu, &Overflow); + signal[0] = round_fx_o(L_tmp, &Overflow); +#else + L_tmp = L_mac(L_tmp, *mem, mu); + signal[0] = round_fx(L_tmp); +#endif + + FOR(i = 1; i < L; i++) + { + L_tmp = L_deposit_h(signal[i]); +#ifdef BASOP_NOGLOB + L_tmp = L_mac_o(L_tmp, signal[i - 1], mu, &Overflow); + signal[i] = round_fx_o(L_tmp, &Overflow); +#else /* BASOP_NOGLOB */ + L_tmp = L_mac(L_tmp, signal[i - 1], mu); + signal[i] = round_fx(L_tmp); +#endif /* BASOP_NOGLOB */ + } + + *mem = signal[L - 1]; + move16(); +} + +/*-------------------------------------------------------------------* + * Deeemph2 : + * + * Deemphasis: filtering through 1/(1-mu z^-1) + * Output divided by 2 + *-------------------------------------------------------------------*/ +void Deemph2( + Word16 x[], /* i/o: input signal overwritten by the output Qx/Qx-1 */ + const Word16 mu, /* i : deemphasis factor Q15 */ + const Word16 L, /* i : vector size Q0 */ + Word16 *mem /* i/o: memory (y[-1]) Qx-1 */ +) +{ + Word16 i; + Word32 L_tmp; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + /* saturation can occur in L_mac() */ + + L_tmp = L_mult(x[0], 16384); + x[0] = mac_r(L_tmp, *mem, mu); + move16(); + + FOR(i = 1; i < L; i++) + { + L_tmp = L_mult(x[i], 16384); +#ifdef BASOP_NOGLOB + x[i] = mac_ro(L_tmp, x[i - 1], mu, &Overflow); +#else + x[i] = mac_r(L_tmp, x[i - 1], mu); +#endif + move16(); + } + + *mem = x[L - 1]; + move16(); +} + + +/* + * E_UTIL_deemph2 + * + * Parameters: + * shift I: scale output + * x I/O: signal Qx/Qx-shift + * mu I: deemphasis factor Qx + * L I: vector size + * mem I/O: memory (signal[-1]) Qx + * + * Function: + * Filtering through 1/(1-mu z^-1) + * Signal is divided by 2. + * + * Returns: + * void + */ +void E_UTIL_deemph2(Word16 shift, Word16 *x, const Word16 mu, const Word16 L, Word16 *mem) +{ + Word16 i; + Word32 L_tmp; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + /* signal[0] = signal[0] + mu * (*mem); */ + L_tmp = L_deposit_h(*mem); + IF(shift >= 0) + { + shift = shr(-32768, shift); + FOR(i = 0; i < L; i++) + { +#ifdef BASOP_NOGLOB + L_tmp = L_msu_o(Mpy_32_16_1(L_tmp, mu), x[i], shift, &Overflow); + x[i] = round_fx_o(L_tmp, &Overflow); +#else + L_tmp = L_msu(Mpy_32_16_1(L_tmp, mu), x[i], shift); + x[i] = round_fx(L_tmp); +#endif + } + + } + ELSE + { + FOR(i = 0; i < L; i++) + { +#ifdef BASOP_NOGLOB + L_tmp = L_msu_o(Mpy_32_16_1(L_tmp, mu), shr_o(x[i],shift, &Overflow),-32768, &Overflow); + x[i] = round_fx_o(L_tmp, &Overflow); +#else /* BASOP_NOGLOB */ + L_tmp = L_msu(Mpy_32_16_1(L_tmp, mu), shr(x[i],shift),-32768); + x[i] = round_fx(L_tmp); +#endif + } + } + + *mem = x[L - 1]; + move16(); + + return; +} diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c index 66c81d440..475fbbd63 100644 --- a/lib_com/delay_comp.c +++ b/lib_com/delay_comp.c @@ -39,6 +39,8 @@ #include "prot.h" #include "ivas_cnst.h" #include "wmc_auto.h" +#include "prot_fx1.h" +#include "prot_fx2.h" /*-------------------------------------------------------------------------- * get_delay() @@ -109,3 +111,88 @@ int32_t get_delay( return delay; } + +/*-------------------------------------------------------------------------- +* get_delay_fx() +* +* Function returns various types of delays in the codec in ns. +*--------------------------------------------------------------------------*/ + +Word32 get_delay_fx( /* o : delay value in ms */ + const Word16 what_delay, /* i : what delay? (ENC or DEC) */ + const Word32 io_fs, /* i : input/output sampling frequency */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + const AUDIO_CONFIG output_config /* i : decoder output config */ +#endif +) +{ + Word32 delay = 0; + + IF(EQ_16(what_delay, ENC)) + { + IF(EQ_16(ivas_format, MONO_FORMAT)) /* EVS mono */ + { + delay = (DELAY_FIR_RESAMPL_NS + ACELP_LOOK_NS); + move32(); + } + ELSE + { + delay = IVAS_ENC_DELAY_NS; + test(); + IF(EQ_16(ivas_format, MASA_FORMAT) || EQ_16(ivas_format, MASA_ISM_FORMAT)) + { + delay = 0; /* All delay is compensated in the decoder with MASA */ + } + } + test(); + IF(EQ_16(ivas_format, SBA_FORMAT) || EQ_16(ivas_format, SBA_ISM_FORMAT)) + { + /* compensate for DirAC/SPAR filterbank delay */ + delay += IVAS_FB_ENC_DELAY_NS; + } + } + ELSE + { + IF(EQ_16(ivas_format, MONO_FORMAT)) /* EVS mono */ + { + IF(EQ_32(io_fs,8000)) + { + delay = DELAY_CLDFB_NS; + move32(); + } + ELSE + { + delay = DELAY_BWE_TOTAL_NS; + move32(); + } + } + ELSE /* IVAS */ + { + delay = IVAS_DEC_DELAY_NS; + +#ifdef SPLIT_REND_WITH_HEAD_ROT + + IF(NE_16(output_config, AUDIO_CONFIG_BINAURAL_SPLIT_CODED)) + { +#endif + IF(hCldfb != NULL) + { + /* compensate for filterbank delay */ + delay += IVAS_FB_DEC_DELAY_NS; + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif + test(); + IF(EQ_16(ivas_format, MASA_FORMAT) || EQ_16(ivas_format, MASA_ISM_FORMAT)) + { + delay += IVAS_ENC_DELAY_NS; /* Compensate also the encoder delay in the decoder with MASA */ + } + } + } + + return delay; +} diff --git a/lib_com/enh64.c b/lib_com/enh64.c new file mode 100644 index 000000000..95d844cb1 --- /dev/null +++ b/lib_com/enh64.c @@ -0,0 +1,1782 @@ +/***************************************************************************** +* +* Enhanced 64 bit operators : +* +* W_mac_32_16() +* W_mac0_16_16() +* W_msu0_16_16() +* +*****************************************************************************/ + + +/***************************************************************************** +* +* Include-Files +* +*****************************************************************************/ +#include +#include +#include "enh64.h" + +#if (WMOPS) +extern BASIC_OP multiCounter[MAXCOUNTERS]; +extern int currCounter; +#endif /* if WMOPS */ + + +/***************************************************************************** +* +* Local Functions +* +*****************************************************************************/ + +/***************************************************************************** +* +* Constants and Globals +* +*****************************************************************************/ + + +/***************************************************************************** +* +* Functions +* +*****************************************************************************/ + +#ifdef ENH_64_BIT_OPERATOR + + +/*___________________________________________________________________________ +| | +| Function Name : W_add_nosat | +| | +| Purpose : | +| | +| 64 bits addition of the two 64 bits variables (L64_var1+L64_var2) | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| L64_var2 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|___________________________________________________________________________| +*/ +Word64 W_add_nosat (Word64 L64_var1, Word64 L64_var2) { + Word64 L64_var_out; + + L64_var_out = L64_var1 + L64_var2; + +#if (WMOPS) + multiCounter[currCounter].W_add_nosat++; +#endif + + return L64_var_out; +} + + +/*___________________________________________________________________________ +| | +| Function Name : W_sub_nosat | +| | +| Purpose : | +| | +| 64 bits subtraction of the two 64 bits variables (L64_var1-L64_var2) | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| L64_var2 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|___________________________________________________________________________| +*/ +Word64 W_sub_nosat (Word64 L64_var1, Word64 L64_var2) { + Word64 L64_var_out; + + L64_var_out = L64_var1 - L64_var2; + +#if (WMOPS) + multiCounter[currCounter].W_sub_nosat++; +#endif + + return L64_var_out; +} + + +/*___________________________________________________________________________ +| | +| Function Name : W_shl | +| | +| Purpose : | +| | +| Arithmetically shift the 64 bit input L64_var1 left var2 positions. Zero| +| fill the var2 LSB of the result. If var2 is negative, arithmetically | +| shift L64_var1 right by -var2 with sign extension. Saturate the result | +| in case of underflows or overflows. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the| +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var1 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|___________________________________________________________________________| +*/ +#ifdef BASOP_NOGLOB +Word64 W_shl_o (Word64 L64_var1, Word16 var2, Flag* Overflow) { +#else /* BASOP_NOGLOB */ +Word64 W_shl (Word64 L64_var1, Word16 var2) { +#endif /* BASOP_NOGLOB */ + + Word64 L64_var_out = 0LL; + + if (var2 <= 0) { + if (var2 < -64) + var2 = -64; + var2 = -var2; + L64_var_out = L64_var1 >> var2; + } + else { + for (; var2 > 0; var2--) { + if (L64_var1 > (Word64) 0X3fffffffffffffffLL) { +#ifdef BASOP_NOGLOB + set_overflow(Overflow); +#else /* BASOP_NOGLOB */ + Overflow = 1; +#endif /* BASOP_NOGLOB */ + L64_var_out = (Word64) 0X7fffffffffffffffLL; + break; + } + else { + if (L64_var1 < (Word64) 0xc000000000000000LL) { +#ifdef BASOP_NOGLOB + set_overflow(Overflow); +#else /* BASOP_NOGLOB */ + Overflow = 1; +#endif /* BASOP_NOGLOB */ + L64_var_out = (Word64)0x8000000000000000LL; + break; + } + } + L64_var1 *= 2; + L64_var_out = L64_var1; + } + } +#if (WMOPS) + multiCounter[currCounter].W_shl++; +#endif + +/* BASOP_CHECK();*/ + + return (L64_var_out); +} + +#ifdef BASOP_NOGLOB +Word64 W_shl (Word64 L64_var1, Word16 var2) { + return W_shl_o(L64_var1, var2, NULL); +} +#endif /* BASOP_NOGLOB */ + + +/*___________________________________________________________________________ +| | +| Function Name : W_shr | +| | +| Purpose : | +| | +| Arithmetically shift the 64 bit input L64_var1 right var2 positions. | +| Zero fill the var2 LSB of the result. If var2 is negative, | +| arithmetically shift L64_var1 left by -var2 with sign extension. | +| Saturate the result in case of underflows or overflows. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the| +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var1 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|___________________________________________________________________________| +*/ +Word64 W_shr (Word64 L64_var1, Word16 var2) { + Word64 L64_var_out; + + if (var2 < 0) { + var2 = -var2; + L64_var_out = W_shl (L64_var1, var2); + +#if (WMOPS) + multiCounter[currCounter].W_shl--; +#endif /* if WMOPS */ + + } else { + L64_var_out = L64_var1 >> var2; + } + +#if (WMOPS) + multiCounter[currCounter].W_shr++; +#endif /* if WMOPS */ + + return (L64_var_out); +} + + +/*___________________________________________________________________________ +| | +| Function Name : W_shl_nosat | +| | +| Purpose : | +| | +| Arithmetically shifts left the 64-bit variable W_var1 by var2 positions. | +| if var2 is negative, W_var1 is shifted to the least significant bits by | +| (�var2) positions with extension of the sign bit . | +| if var2 is positive, W_var1 is shifted to the most significant bits by | +| (var2) positions without saturation control on 64 bits. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the| +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var1 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|___________________________________________________________________________| +*/ +Word64 W_shl_nosat (Word64 L64_var1, Word16 var2) { + + Word64 L64_var_out = 0LL; + + if (var2 <= 0) { + var2 = -var2; + L64_var_out = L64_var1 >> var2; + } + else { + L64_var_out = L64_var1 << var2; + } +#if (WMOPS) + multiCounter[currCounter].W_shl_nosat++; +#endif + +/* BASOP_CHECK();*/ + + return (L64_var_out); +} + + +/*___________________________________________________________________________ +| | +| Function Name : W_shr_nosat | +| | +| Purpose : | +| | +| Arithmetically shifts right the 64-bit variable W_var1 by var2 positions. | +| if var2 is negative, W_var1 is shifted to the most significant bits by | +| (�var2) positions without saturation control on 64 bits. | +| if var2 is positive, W_var1 is shifted to the least significant bits by | +| (var2) positions with extension of the sign bit . | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the| +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var1 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|___________________________________________________________________________| +*/ +Word64 W_shr_nosat (Word64 L64_var1, Word16 var2) { + Word64 L64_var_out; + + if (var2 < 0) { + var2 = -var2; + L64_var_out = L64_var1 << var2; + + } else { + L64_var_out = L64_var1 >> var2; + } + +#if (WMOPS) + multiCounter[currCounter].W_shr_nosat++; +#endif /* if WMOPS */ + + return (L64_var_out); +} + + +/*_________________________________________________________________________________________________ +| | +| Function Name : W_mac_32_16 | +| | +| Purpose : | +| | +| Multiply L_var2 by var3 and shift the result left by 1. Add the 64 bit | +| result to L64_var1, return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| L_var2 | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var2 <= 0x7fff ffff | +| | +| var3 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var3 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_mac_32_16 (Word64 L64_var1, Word32 L_var2, Word16 var3) { + Word64 L64_var_out = ((Word64) L_var2*var3) << 1; + L64_var_out += L64_var1; +#if (WMOPS) + multiCounter[currCounter].W_mac_32_16++; +#endif /* if WMOPS */ + return L64_var_out; +} + + +/*_________________________________________________________________________________________________ +| | +| Function Name : W_msu_32_16 | +| | +| Purpose : | +| | +| Multiply L_var2 by var3 and shift the result left by 1. Subtract the 64 bit | +| result from L64_var1, return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| L_var2 | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var2 <= 0x7fff ffff | +| | +| var3 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var3 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_msu_32_16(Word64 L64_var1, Word32 L_var2, Word16 var3) { + Word64 L64_var_out = ((Word64 )L_var2*var3) << 1; + L64_var_out = L64_var1 - L64_var_out; +#if (WMOPS) + multiCounter[currCounter].W_msu_32_16++; +#endif /* if WMOPS */ + return L64_var_out; +} + + +/*_________________________________________________________________________________________________ +| | +| Function Name : W_mult_32_16 | +| | +| Purpose : | +| | +| Multiply L_var1 by var2 and shift the result left by 1. Return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L_var1 | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var2 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_mult_32_16(Word32 L_var1, Word16 var2) { + Word64 L64_var_out = ((Word64 )L_var1*var2) << 1; +#if (WMOPS) + multiCounter[currCounter].W_mult_32_16++; +#endif /* if WMOPS */ + return L64_var_out; +} + +/*________________________________________________________________________________________________ +| | +| Function Name : W_mult0_16_16 | +| | +| Purpose : | +| | +| Multiply var1 by var2 and return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| var1 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var1 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_acc <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_mult0_16_16(Word16 var1, Word16 var2) { + Word64 L64_var_out = (Word64 )var1*var2; +#if (WMOPS) + multiCounter[currCounter].W_mult0_16_16++; +#endif /* if WMOPS */ + return L64_var_out; +} + +/*________________________________________________________________________________________________ +| | +| Function Name : W_mac0_16_16 | +| | +| Purpose : | +| | +| Multiply var2 by var3 and add the 64 bit result to L64_var1, return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var2 <= 0x0000 7fff. | +| | +| var3 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var3 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_mac0_16_16(Word64 L64_var1, Word16 var2, Word16 var3) { + Word64 L64_var_out = (Word64 )var2*var3; + L64_var_out += L64_var1; +#if (WMOPS) + multiCounter[currCounter].W_mac0_16_16++; +#endif /* if WMOPS */ + return L64_var_out; +} + + +/*________________________________________________________________________________________________ +| | +| Function Name : W_msu0_16_16 | +| | +| Purpose : | +| | +| Multiply var2 by var3 and subtract the 64 bit result from L64_var1, return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var2 <= 0x0000 7fff. | +| | +| var3 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var3 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_msu0_16_16 (Word64 L64_var1, Word16 var2, Word16 var3) { + Word64 L64_var_out = (Word64) var2*var3; + L64_var_out = L64_var1 - L64_var_out; +#if (WMOPS) + multiCounter[currCounter].W_msu0_16_16++; +#endif /* if WMOPS */ + return L64_var_out; +} + + + +/*_____________________________________________________________________________________ +| | +| Function Name : W_sat_l | +| | +| Purpose : | +| | +| Saturate the lower 32 bits of the 64 bit input number L64_var into 32 bits. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L_var_out | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var_out <= 0x7fff 0000. | +|_____________________________________________________________________________________| +*/ +Word32 W_sat_l (Word64 L64_var) { + Word32 L_var_out; + + if (L64_var > 0x7FFFFFFF) { + L_var_out = 0x7FFFFFFF; + } + else if (L64_var < (int)0x80000000) { + L_var_out = 0x80000000; + } + else { + L_var_out = (Word32)L64_var; + } + +#if (WMOPS) + multiCounter[currCounter].W_sat_l++; +#endif /* if WMOPS */ + + return L_var_out; +} + + + +/*___________________________________________________________________________________ +| | +| Function Name : W_sat_m | +| | +| Purpose : | +| | +| Truncates the lower 16 bits of the 64 bit input L64_var | +| and saturates the number into 32 bits. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L_var_out | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var_out <= 0x7fff 0000. | +|_____________________________________________________________________________________| +*/ +Word32 W_sat_m (Word64 L64_var) { + Word32 L_var_out; + + L64_var = L64_var >> 16; + L_var_out = W_sat_l (L64_var); + +#if (WMOPS) + multiCounter[currCounter].W_sat_l--; + multiCounter[currCounter].W_sat_m++; +#endif /* if WMOPS */ + + return L_var_out; +} + + +/*__________________________________________________________________________________ +| | +| Function Name : W_deposit32_l | +| | +| Purpose : | +| | +| Deposit the 32 bit L_var1 into the 32 LS bits of the 64 bit output. The | +| 32 MS bits of the output are sign extended. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L_var1 | +| 32 bit long signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= var_out <= 0x7fff 0000. | | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|__________________________________________________________________________________| +*/ +Word64 W_deposit32_l (Word32 L_var1) { + Word64 L64_var_out; + + L64_var_out = (Word64) L_var1; + +#if (WMOPS) + multiCounter[currCounter].W_deposit32_l++; +#endif + + return (L64_var_out); +} + + +/*__________________________________________________________________________________ +| | +| Function Name : W_deposit32_h | +| | +| Purpose : | +| | +| Deposit the 32 bit L_var1 into the 32 MS bits of the 64 bit output. The | +| 32 LS bits of the output are zeroed. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L_var1 | +| 32 bit long signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= var_out <= 0x7fff 0000. | | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|__________________________________________________________________________________| +*/ +Word64 W_deposit32_h (Word32 L_var1) { + Word64 L64_var_out; + + L64_var_out = (Word64) L_var1 << 32; + +#if (WMOPS) + multiCounter[currCounter].W_deposit32_h++; +#endif + + return (L64_var_out); +} + + +/*__________________________________________________________________________________ +| | +| Function Name : W_extract_l | +| | +| Purpose : | +| | +| Return the 32 LSB of L64_var1. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L_var_out | +| 32 bit long signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var_out <= 0x7fff 0000. | +|__________________________________________________________________________________| +*/ +Word32 W_extract_l (Word64 L64_var1) { + Word32 L_var_out; + + L_var_out = (Word32) L64_var1; + +#if (WMOPS) + multiCounter[currCounter].W_extract_l++; +#endif /* if WMOPS */ + + return (L_var_out); +} + + + +/*__________________________________________________________________________________ +| | +| Function Name : W_extract_h | +| | +| Purpose : | +| | +| Return the 32 MSB of L64_var1. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L_var_out | +| 32 bit long signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var_out <= 0x7fff 0000. | +|__________________________________________________________________________________| +*/ +Word32 W_extract_h (Word64 L64_var1) { + Word32 L_var_out; + + L_var_out = (Word32) (L64_var1 >> 32); + +#if (WMOPS) + multiCounter[currCounter].W_extract_h++; +#endif /* if WMOPS */ + + return (L_var_out); +} + + + +/*________________________________________________________________________________________________ +| | +| Function Name : W_mult_16_16 | +| | +| Purpose : | +| | +| Multiply var1 by var2 and shift the result left by 1. Return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| var1 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var1 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_acc <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_mult_16_16 (Word16 var1, Word16 var2) { + Word64 L64_var_out = ((Word64) var1*var2) << 1; +#if (WMOPS) + multiCounter[currCounter].W_mult_16_16++; +#endif /* if WMOPS */ + return L64_var_out; +} +/*________________________________________________________________________________________________ +| | +| Function Name : W_mac_16_16 | +| | +| Purpose : | +| | +| Multiply var1 by var2 and shift the result left by 1 and add the 64 bit result to L64_acc, | +| return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_acc | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_acc <= 0x7fffffff ffffffffLL. | +| | +| var1 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var1 <= 0x0000 7fff. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var2 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_mac_16_16 (Word64 L64_acc, Word16 var1, Word16 var2) { + Word64 L64_var_out = ((Word64) var1*var2) << 1; + L64_acc = L64_acc + L64_var_out; + +#if (WMOPS) + multiCounter[currCounter].W_mac_16_16++; +#endif /* if WMOPS */ + return L64_acc; +} + + + +/*________________________________________________________________________________________________ +| | +| Function Name : W_msu_16_16 | +| | +| Purpose : | +| | +| Multiply var2 by var3 and shift the result left by1 and subtract the 64 bit result | +| from L64_var1, return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var2 <= 0x0000 7fff. | +| | +| var3 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var3 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_msu_16_16 (Word64 L64_var1, Word16 var2, Word16 var3) { + Word64 L64_var_out = ((Word64)var2*var3) << 1; + L64_var_out = L64_var1 - L64_var_out; +#if (WMOPS) + multiCounter[currCounter].W_msu_16_16++; +#endif /* if WMOPS */ + return L64_var_out; +} + + +/*___________________________________________________________________________ +| | +| Function Name : W_shl_sat_l | +| | +| Purpose : | +| | +| Arithmetically shift the 64 bit input L64_var left by n positions with | +| lower 32 bit saturation and return the 32 LSB of 64 bit result | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var <= 0x7fffffff ffffffffLL. | +| | +| n | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= n <= 0x7fff 0000. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L_result | +| 32 bit long signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_result <= 0x7fff 0000. | +|___________________________________________________________________________| +*/ +Word32 W_shl_sat_l (Word64 L64_var, Word32 n) { + Word32 L_result; + Word64 d_var_64; + + d_var_64 = W_shl (L64_var, n); + L_result = W_sat_l (d_var_64); + +#if (WMOPS) + multiCounter[currCounter].W_shl_sat_l++; + multiCounter[currCounter].W_shl--; + multiCounter[currCounter].W_sat_l--; +#endif /* if WMOPS */ + + return L_result; +} + + +/*__________________________________________________________________________________ +| | +| Function Name : W_round48_L | +| | +| Purpose : | +| | +| Round asymmetrically lower 16 bits, and | +| saturate the 17.47-bit values to 1.31-bit values | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L_var_out | +| 32 bit long signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | +|__________________________________________________________________________________| +*/ +#ifdef BASOP_NOGLOB +Word32 W_round48_L_o (Word64 L64_var1, Flag* Overflow) { +#else /* BASOP_NOGLOB */ +Word32 W_round48_L (Word64 L64_var1) { +#endif /* BASOP_NOGLOB */ + Word64 L64_var_out; + Word32 L_result; + + Word64 L64_var2 = 0x80000000; + Word64 L64_MIN = 0x8000000000000000LL; + Word64 L64_MAX = 0x7FFFFFFFFFFFFFFFLL; + + L64_var1 = W_shl (L64_var1, 16); + + L64_var_out = L64_var1 + L64_var2; + + if ( ( (L64_var1 ^ L64_var2) & L64_MIN) == 0) { + if ( (L64_var_out ^ L64_var1) & L64_MIN) { + L64_var_out = (L64_var1 < 0) ? L64_MIN : L64_MAX; +#ifdef BASOP_NOGLOB + set_overflow(Overflow); +#else /* BASOP_NOGLOB */ + Overflow = 1; +#endif /* BASOP_NOGLOB */ + } + } + L_result = W_extract_h (L64_var_out); +#if (WMOPS) + multiCounter[currCounter].W_round48_L++; + multiCounter[currCounter].W_extract_h--; + multiCounter[currCounter].W_shl--; +#endif /* if WMOPS */ + + return (L_result); +} + +#ifdef BASOP_NOGLOB +Word32 W_round48_L (Word64 L64_var1) { + return W_round48_L_o(L64_var1, NULL); +} +#endif /* BASOP_NOGLOB */ + +/*__________________________________________________________________________________ +| | +| Function Name : W_round32_s | +| | +| Purpose : | +| | +| Round asymmetrically lower 32 bits, and | +| saturate the 17.47-bit values to 1.15-bit values | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| var_out | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var_out <= 0x0000 7fff. | +|__________________________________________________________________________________| +*/ +#ifdef BASOP_NOGLOB +Word16 W_round32_s_o (Word64 L64_var1, Flag* Overflow) { +#else /* BASOP_NOGLOB */ +Word16 W_round32_s (Word64 L64_var1) { +#endif /* BASOP_NOGLOB */ + Word64 L64_var_out; + Word32 L_var; + Word16 var_out; + + + Word64 L64_var2 = 0x800000000000LL; + Word64 L64_MIN = 0x8000000000000000LL; + Word64 L64_MAX = 0x7FFFFFFFFFFFFFFFLL; + + L64_var1 = W_shl (L64_var1, 16); + L64_var_out = L64_var1 + L64_var2; + + if (((L64_var1 ^ L64_var2) & L64_MIN) == 0) { + if ((L64_var_out ^ L64_var1) & L64_MIN) { + L64_var_out = (L64_var1 < 0) ? L64_MIN : L64_MAX; +#ifdef BASOP_NOGLOB + set_overflow(Overflow); +#else /* BASOP_NOGLOB */ + Overflow = 1; +#endif /* BASOP_NOGLOB */ + } + } + L_var = W_extract_h (L64_var_out); + var_out = extract_h (L_var); +#if (WMOPS) + multiCounter[currCounter].W_round32_s ++; + multiCounter[currCounter].W_extract_h--; + multiCounter[currCounter].extract_h--; + multiCounter[currCounter].W_shl--; +#endif /* if WMOPS */ + + return (var_out); +} + +#ifdef BASOP_NOGLOB +Word16 W_round32_s (Word64 L64_var1) { + return W_round32_s_o(L64_var1, NULL); +} +#endif /* BASOP_NOGLOB */ + +/*___________________________________________________________________________ +| | +| Function Name : W_norm | +| | +| Purpose : | +| | +| Produces the number of left shifts needed to normalize the 64 bit varia-| +| ble L64_var1. +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| var_out | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0x0000 0000 <= var_out <= 0x0000 003f. | +|___________________________________________________________________________| +*/ +Word16 W_norm (Word64 L64_var1) { + Word16 var_out; + if (L64_var1 == 0) { + var_out = 0; + } + else { + if (L64_var1 == (Word64) 0xffffffffffffffffLL) { + var_out = 63; + } + else { + if (L64_var1 < 0) { + L64_var1 = ~L64_var1; + } + for (var_out = 0; L64_var1 < (Word64) 0x4000000000000000LL; var_out++) { + L64_var1 <<= 1; + } + } + } +#if (WMOPS) + multiCounter[currCounter].W_norm ++; +#endif /* if WMOPS */ + return (var_out); +} + + + +/*______________________________________________________________________________ +| | +| Function Name : W_add | +| | +| Purpose : | +| | +| 64 bits addition of the two 64 bits variables (L64_var1+L64_var2) with | +| overflow control and saturation; the result is set at 0x7fffffffffffffffLL | +| when overflow occurs or at 0x8000000000000000LL when underflow occurs. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| L64_var2 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|_______________________________________________________________________________| +*/ +#ifdef BASOP_NOGLOB +Word64 W_add_o (Word64 L64_var1, Word64 L64_var2, Flag* Overflow) { +#else /* BASOP_NOGLOB */ +Word64 W_add (Word64 L64_var1, Word64 L64_var2) { +#endif /* BASOP_NOGLOB */ + Word64 L64_var_out; + + L64_var_out = L64_var1 + L64_var2; + + if (((L64_var1 ^ L64_var2) & MIN_64) == 0) { + if ((L64_var_out ^ L64_var1) & MIN_64) { + L64_var_out = (L64_var1 < 0) ? MIN_64 : MAX_64; +#ifdef BASOP_NOGLOB + set_overflow(Overflow); +#else /* BASOP_NOGLOB */ + Overflow = 1; +#endif /* BASOP_NOGLOB */ + } + } + +#if (WMOPS) + multiCounter[currCounter].W_add++; +#endif + return L64_var_out; +} + +#ifdef BASOP_NOGLOB +Word64 W_add (Word64 L64_var1, Word64 L64_var2) { + return W_add_o(L64_var1, L64_var2, NULL); +} +#endif /* BASOP_NOGLOB */ + +/*______________________________________________________________________________ +| | +| Function Name : W_sub | +| | +| Purpose : | +| | +| 64 bits subtraction of the two 64 bits variables (L64_var1-L64_var2) with | +| overflow control and saturation; the result is set at 0x7fffffffffffffffLL | +| when overflow occurs or at 0x8000000000000000LL when underflow occurs. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| L64_var2 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|_______________________________________________________________________________| +*/ +#ifdef BASOP_NOGLOB +Word64 W_sub_o (Word64 L64_var1, Word64 L64_var2, Flag* Overflow) { +#else /* BASOP_NOGLOB */ +Word64 W_sub (Word64 L64_var1, Word64 L64_var2) { +#endif /* BASOP_NOGLOB */ + Word64 L64_var_out; + + L64_var_out = L64_var1 - L64_var2; + + if (((L64_var1 ^ L64_var2) & MIN_64) != 0) { + if ((L64_var_out ^ L64_var1) & MIN_64) { + L64_var_out = (L64_var1 < 0) ? MIN_64 : MAX_64; +#ifdef BASOP_NOGLOB + set_overflow(Overflow); +#else /* BASOP_NOGLOB */ + Overflow = 1; +#endif /* BASOP_NOGLOB */ + } + } + +#if (WMOPS) + multiCounter[currCounter].W_add++; +#endif + return L64_var_out; +} + +#ifdef BASOP_NOGLOB +Word64 W_sub (Word64 L64_var1, Word64 L64_var2) { + return W_sub_o(L64_var1, L64_var2, NULL); +} +#endif /* BASOP_NOGLOB */ + + +/*______________________________________________________________________________ +| | +| Function Name : W_neg | +| | +| Purpose : | +| | +| Negate the 64 bit variable L64_var1 with overflow control and saturation; | +| Saturate and set overflow in the case where input is 0x8000000000000000LL. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|_______________________________________________________________________________| +*/ +#ifdef BASOP_NOGLOB +Word64 W_neg_o (Word64 L64_var1, Flag* Overflow) { +#else /* BASOP_NOGLOB */ +Word64 W_neg (Word64 L64_var1) { +#endif /* BASOP_NOGLOB */ + Word64 L64_var_out; + + if (L64_var1 == MIN_64) { + L64_var_out = MAX_64; +#ifdef BASOP_NOGLOB + set_overflow(Overflow); +#else /* BASOP_NOGLOB */ + Overflow = 1; +#endif /* BASOP_NOGLOB */ + } + else { + L64_var_out = -L64_var1; + } + +#if (WMOPS) + multiCounter[currCounter].W_neg++; +#endif + + return (L64_var_out); + +} + +#ifdef BASOP_NOGLOB +Word64 W_neg (Word64 L64_var1) { + return W_neg_o(L64_var1, NULL); +} +#endif /* BASOP_NOGLOB */ + + +/*___________________________________________________________________________ + | | + | Function Name : W_abs | + | | + | Purpose : | + | | + | Absolute value of L64_var1; Saturate in case where the input is | + | 0x8000000000000000LL | + | | + | Complexity weight : 1 | + | | + | Inputs : | + | | + | L64_var1 64 bit long signed integer (Word64) whose value falls in the | + | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | + | | + | Outputs : | + | | + | none | + | | + | Return Value : | + | | + | L64_var_out | + | 64 bit long signed integer (Word64) whose value falls in the | + | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | + |___________________________________________________________________________| +*/ +#ifdef BASOP_NOGLOB +Word64 W_abs_o (Word64 L64_var1, Flag* Overflow) { +#else /* BASOP_NOGLOB */ +Word64 W_abs (Word64 L64_var1) { +#endif /* BASOP_NOGLOB */ + Word64 L64_var_out; + + if (L64_var1 == MIN_64) { + L64_var_out = MAX_64; +#ifdef BASOP_NOGLOB + set_overflow(Overflow); +#else /* BASOP_NOGLOB */ + Overflow = 1; +#endif /* BASOP_NOGLOB */ + } + else { + if (L64_var1 < 0) { + L64_var_out = -L64_var1; + } + else { + L64_var_out = L64_var1; + } + } + +#if (WMOPS) + multiCounter[currCounter].W_abs++; +#endif + + return (L64_var_out); +} + +#ifdef BASOP_NOGLOB +Word64 W_abs (Word64 L64_var1) { + return W_abs_o(L64_var1, NULL); +} +#endif /* BASOP_NOGLOB */ + +/*_________________________________________________________________________________________________ +| | +| Function Name : W_mult_32_32 | +| | +| Purpose : | +| | +| Multiply L_var1 by L_var2 and shift the result left by 1.Saturate and set overflow in case | +| where both inputs are 0x80000000 . Return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L_var1 | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff | +| | +| L_var2 | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +#ifdef BASOP_NOGLOB +Word64 W_mult_32_32_o(Word32 L_var1, Word32 L_var2, Flag* Overflow) { +#else /* BASOP_NOGLOB */ +Word64 W_mult_32_32(Word32 L_var1, Word32 L_var2) { +#endif /* BASOP_NOGLOB */ + Word64 L64_var_out; + + if ((L_var1 == MIN_32) && (L_var2 == MIN_32)) { + L64_var_out = MAX_64; +#ifdef BASOP_NOGLOB + set_overflow(Overflow); +#else /* BASOP_NOGLOB */ + Overflow = 1; +#endif /* BASOP_NOGLOB */ + } + else { + L64_var_out = ((Word64 )L_var1*L_var2) << 1; + } + +#if (WMOPS) + multiCounter[currCounter].W_mult_32_32++; +#endif /* if WMOPS */ + return L64_var_out; +} + +#ifdef BASOP_NOGLOB +Word64 W_mult_32_32(Word32 L_var1, Word32 L_var2) { + return W_mult_32_32_o(L_var1, L_var2, NULL); +} +#endif /* BASOP_NOGLOB */ + +/*_________________________________________________________________________________________________ +| | +| Function Name : W_mult0_32_32 | +| | +| Purpose : | +| | +| Multiply L_var1 by L_var2. Return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L_var1 | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff | +| | +| L_var2 | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_mult0_32_32 (Word32 L_var1, Word32 L_var2) { + Word64 L64_var_out; + + L64_var_out = (Word64) L_var1*L_var2; + + +#if (WMOPS) + multiCounter[currCounter].W_mult0_32_32++; +#endif /* if WMOPS */ + return L64_var_out; +} + + +/*_____________________________________________________________________________ +| | +| Function Name : W_lshl | +| | +| Purpose : | +| | +| Logically shift the 64 bit unsigned input L64_var1 left by var2 positions. | +| Zero fill the var2 LSB of the result. If var2 is negative, logically shift | +| L64_var1 right by -var2 with zero fill in the MSB. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long unsigned signed integer (UWord64) whose value falls | +| in the range : 0LL <= L64_var1 <= 0xffffffff ffffffffLL. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var1 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long unsigned signed integer (UWord64) whose value falls | +| in the range : 0LL <= L64_var1 <= 0xffffffff ffffffffLL. | +|______________________________________________________________________________| +*/ +UWord64 W_lshl (UWord64 L64_var1, Word16 var2) { + + UWord64 L64_var_out = 0LL; + + if (var2 < 0) { + L64_var_out = L64_var1 >> (-var2); + } + else { + L64_var_out = L64_var1 << var2 ; + } +#if (WMOPS) + multiCounter[currCounter].W_lshl++; +#endif + + return (L64_var_out); +} + +/*_____________________________________________________________________________ +| | +| Function Name : W_lshr | +| | +| Purpose : | +| | +| Logically shift the 64 bit unsigned input L64_var1 right by var2 positions.| +| Zero fill the var2 MSB of the result. If var2 is negative, logically shift | +| L64_var1 left by -var2 with zero fill in the LSB. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long unsigned signed integer (UWord64) whose value falls | +| in the range : 0LL <= L64_var1 <= 0xffffffff ffffffffLL. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var1 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long unsigned signed integer (UWord64) whose value falls | +| in the range : 0LL <= L64_var1 <= 0xffffffff ffffffffLL. | +|______________________________________________________________________________| +*/ +UWord64 W_lshr (UWord64 L64_var1, Word16 var2) { + + UWord64 L64_var_out = 0LL; + + if (var2 < 0) { + L64_var_out = L64_var1 << (-var2); + } + else { + L64_var_out = L64_var1 >> var2 ; + } +#if (WMOPS) + multiCounter[currCounter].W_lshr++; +#endif + + return (L64_var_out); +} + + +/*__________________________________________________________________________________ +| | +| Function Name : W_round64_L | +| | +| Purpose : | +| | +| Round asymmetrically lower 32 bits, and | +| saturate the 1.63-bit values to 1.31-bit values | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L_var_out | +| 32 bit long signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | +|__________________________________________________________________________________| +*/ +Word32 W_round64_L (Word64 L64_var1) { + Word64 L64_var_out; + Word32 L_result; + + + Word64 L64_tmp = 0x80000000; + L64_var_out = W_add (L64_var1, L64_tmp); + L_result = W_extract_h (L64_var_out); + +#if (WMOPS) + multiCounter[currCounter].W_round64_L++; + multiCounter[currCounter].W_extract_h--; + multiCounter[currCounter].W_add--; +#endif /* if WMOPS */ + + return (L_result); +} + +#endif /* #ifdef ENH_64_BIT_OPERATOR */ + +/* end of file */ diff --git a/lib_com/enh64.h b/lib_com/enh64.h new file mode 100644 index 000000000..9364c250d --- /dev/null +++ b/lib_com/enh64.h @@ -0,0 +1,87 @@ + +#ifndef _ENH64_H +#define _ENH64_H + +#include "stl.h" + +#ifndef Word64 +#define Word64 long long int +#endif + +#ifndef UWord64 +#define UWord64 unsigned long long int +#endif + +#define MAX_64 (Word64)0x7fffffffffffffffLL +#define MIN_64 (Word64)0x8000000000000000LL + + /***************************************************************************** + * + * Prototypes for enhanced 64 bit arithmetic operators + * + *****************************************************************************/ +#ifdef ENH_64_BIT_OPERATOR +Word64 W_add_nosat (Word64 L64_var1, Word64 L64_var2); +Word64 W_sub_nosat (Word64 L64_var1, Word64 L64_var2); +Word64 W_shl (Word64 L64_var1, Word16 var2); +Word64 W_shr (Word64 L64_var1, Word16 var2); +Word64 W_shl_nosat (Word64 L64_var1, Word16 var2); +Word64 W_shr_nosat (Word64 L64_var1, Word16 var2); +Word64 W_mult_32_16 (Word32 L_var1, Word16 var2); +Word64 W_mac_32_16 (Word64 L64_acc, Word32 L_var1, Word16 var2); +Word64 W_msu_32_16 (Word64 L64_acc, Word32 L_var1, Word16 var2); +Word64 W_mult0_16_16 (Word16 var1, Word16 var2); +Word64 W_mac0_16_16 (Word64 L64_acc, Word16 var1, Word16 var2); +Word64 W_msu0_16_16 (Word64 L64_acc, Word16 var1, Word16 var2); +Word64 W_mult_16_16 (Word16 var1, Word16 var2); +Word64 W_mac_16_16 (Word64 L64_acc, Word16 var1, Word16 var2); +Word64 W_msu_16_16 (Word64 L64_acc, Word16 var1, Word16 var2); + +Word64 W_deposit32_l (Word32 L_var1); +Word64 W_deposit32_h (Word32 L_var1); + +Word32 W_sat_l (Word64 L64_var); +Word32 W_sat_m (Word64 L64_var); +Word32 W_shl_sat_l (Word64 L64_var, Word32 n); + +Word32 W_extract_l (Word64 L64_var1); +Word32 W_extract_h (Word64 L64_var1); + +Word32 W_round48_L (Word64 L64_var1); +Word16 W_round32_s (Word64 L64_var1); + +Word16 W_norm (Word64 L_var1); + + +Word64 W_add (Word64 L64_var1, Word64 L64_var2); +Word64 W_sub (Word64 L64_var1, Word64 L64_var2); +Word64 W_neg (Word64 L64_var1); +Word64 W_abs (Word64 L64_var1); +Word64 W_mult_32_32 (Word32 L_var1, Word32 L_var2); +Word64 W_mult0_32_32 (Word32 L_var1, Word32 L_var2); +UWord64 W_lshl (UWord64 L64_var1, Word16 var2); +UWord64 W_lshr (UWord64 L64_var1, Word16 var2); +Word32 W_round64_L (Word64 L64_var1) ; + +#ifdef BASOP_NOGLOB +/* + * Overflowing operators + */ +Word64 W_shl_o (Word64 L64_var1, Word16 var2, Flag* Overflow); +Word32 W_round48_L_o (Word64 L64_var1, Flag* Overflow); +Word16 W_round32_s_o (Word64 L64_var1, Flag* Overflow); +Word64 W_add_o (Word64 L64_var1, Word64 L64_var2, Flag* Overflow); +Word64 W_sub_o (Word64 L64_var1, Word64 L64_var2, Flag* Overflow); +Word64 W_neg_o (Word64 L64_var1, Flag* Overflow); +Word64 W_abs_o (Word64 L64_var1, Flag* Overflow); +Word64 W_mult_32_32_o(Word32 L_var1, Word32 L_var2, Flag* Overflow); +#endif /* BASOP_NOGLOB */ + +#endif /* #ifdef ENH_64_BIT_OPERATOR */ + +#endif /*_ENH64_H*/ + + +/* end of file */ + + diff --git a/lib_com/enhUL32.c b/lib_com/enhUL32.c new file mode 100644 index 000000000..4cb6af850 --- /dev/null +++ b/lib_com/enhUL32.c @@ -0,0 +1,409 @@ +/* + ============================================================================ + File: ENHUL32.C v.1.0 - 01.July.2018 + ============================================================================ + + ENHANCED UNSIGNED 32-BIT ARITHMETIC OPERATORS + History: + v.0.5 - 21.March.2014 + + ============================================================================ +*/ + + /***************************************************************************** + * + * Enhanced Unsigned 32 bit operators : + * see complete list in .h file + * + *****************************************************************************/ + +/***************************************************************************** + * + * Include-Files + * + *****************************************************************************/ +#include +#include +#include "stl.h" +#include "enhUL32.h" + +#if (WMOPS) +extern BASIC_OP multiCounter[MAXCOUNTERS]; +extern int currCounter; +#endif /* if WMOPS */ + + +/***************************************************************************** + * + * Constants and Globals + * + *****************************************************************************/ + + +/***************************************************************************** + * + * Functions + * + *****************************************************************************/ +#ifdef ENH_U_32_BIT_OPERATOR + +/*___________________________________________________________________________ + | | + | Function Name : UL_deposit_l | + | | + | Purpose : | + | | + | Deposit the 16 bit var1 into the 16 LS bits of the 32 bit output. The | + | 16 MS bits of the output are not sign extended. | + |___________________________________________________________________________| +*/ + +UWord32 UL_deposit_l (UWord16 uvar) { + UWord32 UL_result; + UL_result = (UWord32) uvar; /* no sign extension*/ +#if (WMOPS) + multiCounter[currCounter].UL_deposit_l++; +#endif + return (UL_result); +} +#if 0 +/*_____________________________________________________________________________ + | | + | Function Name : norm_ul_float | + | | + | Purpose : | + | | + | Produces the number of left shifts needed to normalize the 32 bit varia- | + | ble UL_var1 for positive values on the interval with minimum of | + | 0 and maximum of 0xffffffff, ; in order to normalize the | + | result, the following operation must be done : | + | | + | norm_UL_var1 = UL_lshl(UL_var1, norm_ul_float(UL_var1)). | + | | + | Complexity weight : 1 | + | | + | Inputs : | + | | + | UL_var1 | + | 32 bit long unsigned integer (UWord32) whose value falls in the | + | range : 0x0000 0000 <= var1 <= 0xffff ffff. | + | | + | Outputs : | + | | + | none | + | | + | Return Value : | + | | + | var_out | + | 16 bit short signed integer (Word16) whose value falls in the | + | range : 0x0000 0000 <= var_out <= 0x0000 001f. (0..31d) | + |_____________________________________________________________________________| +*/ +Word16 norm_ul_float (UWord32 UL_var1) { + Word16 var_out; + + if (UL_var1 == 0) { + var_out = 0; + } + else { + /* simply test shift up until highest bit is set */ + for (var_out = 0; UL_var1 < (UWord32) 0x80000000U; var_out++) { + UL_var1 <<= 1; + } + } + +#if (WMOPS) + multiCounter[currCounter].norm_ul_float++; +#endif + + return (var_out); +} +#endif +/*___________________________________________________________________________ + | | + | Function Name : UL_addNs | + | | + | Purpose : | + | | + | 32 bits addition of the two unsigned 32 bits variables | + | (L_var1+L_var2) with overflow control, but without saturation | + | | + | Outputs : | + | | + | *wrap = 1 if wrap occured, otherwize 0 | + | | + | Return Value : | + | | + | UL_var3 = modulo(UL_var1+UL_var2,32) | + |___________________________________________________________________________| +*/ + +UWord32 UL_addNs (UWord32 UL_var1, UWord32 UL_var2, UWord16 * wrap) { + UWord32 UL_var3; + + /* STL Overflow flag is not updated */ + UL_var3 = UL_var1 + UL_var2; /* 32-bit wrap may occur, like in C */ + + if (((UWord64) UL_var1 + (UWord64) UL_var2) > 0xFFFFFFFFU) { + *wrap = 1; /* wrapped output */ + } + else { + *wrap = 0; + } + +#if WMOPS + multiCounter[currCounter].UL_addNs++; +#endif + + return UL_var3; +} + +/*___________________________________________________________________________ + | | + | Function Name : UL_subNs | + | | + | Purpose : | + | | + | 32 bits subtraction of the two unsigned 32 bits variables | + | (L_var1-L_var2) with overflow control, but without saturation | + | | + | Outputs : | + | | + | *sgn = 1 if wrap (to "negative" occured, otherwise 0) | + | | + | Return Value : | + | | + | UL_var3 = modulo(UL_var1-UL_var2,32) | + |___________________________________________________________________________| +*/ + +UWord32 UL_subNs (UWord32 UL_var1, UWord32 UL_var2, UWord16 * sgn) { + UWord32 UL_var3; + + UL_var3 = UL_var1 - UL_var2; /*wrap may occur, like in C */ + if (UL_var1 >= UL_var2) { + *sgn = 0; + } + else { + *sgn = 1; /* "negative", wrapped output */ + } + +#if WMOPS + multiCounter[currCounter].UL_subNs++; +#endif + return UL_var3; +} + +/*________________________________________________________________________________ + | | + | Function Name : Mpy_32_16_uu | + | | + | Purpose : | + | | + | Multiplies the 2 unsigned values UL_var1 and uvar2. | + | The operation is performed in fractional mode : | + | - UL_var1 is supposed to be in Q32 format. | + | - var2 is supposed to be in Q16 format. | + | - The result is produced in Q48 format : UL_varout_h points to the | + | 32 MSBits while varout_l points to the 16 LSBits. | + | | + | Complexity weight : 2 | + | | + | Inputs : | + | | + | UL_var1 32 bit long unsigned integer (UWord32) whose value falls in | + | the range : 0x0000 0000 <= L_var1 <= 0xffff ffff. | + | | + | var2 16 bit short unsigned integer (UWord16) whose value falls in | + | the range : 0x0000 <= var2 <= 0x0000 ffff. | + | | + | Outputs : | + | | + | *UL_varout_h 32 bit long unsigned integer (UWord32) whose value falls in | + | the range : 0x0000 0000 <= UL_varout_h <= 0xffff ffff. | + | | + | *varout_l 16 bit short unsigned integer (UWord16) whose value falls in | + | the range : 0x0000 0000 <= varout_l <= 0x0000 ffff. | + | | + | Return Value : | + | | + | none | + |________________________________________________________________________________| +*/ +void Mpy_32_16_uu (UWord32 UL_var1, UWord16 uvar2, UWord32 *UL_varout_h, UWord16 *varout_l) { + UWord64 UL64_var1; + + /* 4294967295 * 65535 < 281474976710655 */ + /* (uint64(2)^16-1 )*(uint64(2)^32-1) < (uint64(2)^(16+32)-1) */ + UL64_var1 = ((UWord64) UL_var1)*((UWord64) uvar2); + *varout_l = (UWord16) UL64_var1; + *UL_varout_h = (UWord32) (UL64_var1>>16); + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_uu++; +#endif /* if WMOPS */ + + return; +} + +/*__________________________________________________________________________________ + | | + | Function Name : Mpy_32_32_uu | + | | + | Purpose : | + | | + | Multiplies the 2 unsigned values UL_var1 and UL_var2. | + | The operation is performed in fractional mode : | + | - UL_var1 and UL_var2 are supposed to be in Q32 format. | + | - The result is produced in Q64 format : UL_varout_h points to the | + | 32 MSBits while UL_varout_l points to the 32 LSBits. | + | | + | Complexity weight : 4 | + | | + | Inputs : | + | | + | UL_var1 32 bit long unsigned integer (UWord32) whose value falls in the | + | range : 0x0000 0000 <= L_var1 <= 0xffff ffff. | + | | + | UL_var2 32 bit long unsigned integer (UWord32) whose value falls in the | + | range : 0x0000 0000 <= L_var2 <= 0xffff ffff. | + | | + | Outputs : | + | | + | *UL_varout_h 32 bit long signed integer (Word32) whose value falls in | + | the range : 0x0000 0000 <= UL_varout_h <= 0xffff ffff. | + | | + | *UL_varout_l 32 bit short unsigned integer (UWord32) whose value falls in | + | the range : 0x0000 0000 <= UL_varout_l <= 0xffff ffff. | + | | + | Return Value : | + | | + | none | + |__________________________________________________________________________________| + */ +void Mpy_32_32_uu (UWord32 UL_var1, UWord32 UL_var2, UWord32 *UL_varout_h, UWord32 *UL_varout_l) { + UWord64 UL64_var1; + /* (uint64(2)^32-1 )*(uint64(2)^32-1) < (uint64(2)^(32+32)-1) */ + UL64_var1 = ((UWord64) UL_var1)*((UWord64) UL_var2); + *UL_varout_h = (UWord32)(UL64_var1>>32); + *UL_varout_l = (UWord32)(UL64_var1); + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_32_uu++; +#endif /* if WMOPS */ + + return; +} + +/*_____________________________________________________________________________________ + | | + | Function Name : UL_Mpy_32_32 | + | | + | Purpose : | + | | + | Multiplies the 2 unsigned values UL_var1 and UL_var2 | + | and returns the lower 32 bits, without saturation control. | + | | + | - UL_var1 and UL_var2 are supposed to be in Q32 format. | + | - The result is produced in Q64 format, the 32 LSBits. | + | | + | operates like a regular 32-by-32 bit unsigned int multiplication in ANSI-C. | + | UWord32) = (unsigned int)*(unsigned int); | + | | + | | + | Complexity weight : 2 | + | | + | Inputs : | + | | + | UL_var1 32 bit long unsigned integer (UWord32) whose value falls in the | + | range : 0x0000 0000 <= UL_var1 <= 0xffff ffff. | + | | + | UL_var2 32 bit long unsigned integer (UWord32) whose value falls in the | + | range : 0x0000 0000 <= UL_var2 <= 0xffff ffff. | + | | + | Outputs : | + | | + | none | + | | + | Return Value : | + | *UL_varout_l 32 bit short unsigned integer (UWord32) whose value falls in | + | the range : 0x0000 0000 <= UL_varout_l <= 0xffff ffff. | + | | + |_____________________________________________________________________________________| +*/ +UWord32 UL_Mpy_32_32 (UWord32 UL_var1, UWord32 UL_var2) { + UWord32 UL_varout_l; + +#define MASK32 0xFFFFFFFFU + /* MASK32 may be needed in case Hardware is using larger than 32 bits for UWord32 type */ + UL_varout_l = (UL_var1&MASK32)*(UL_var2&MASK32); + UL_varout_l = UL_varout_l&MASK32; +#undef MASK32 + +#if (WMOPS) + multiCounter[currCounter].UL_Mpy_32_32++; +#endif /* if WMOPS */ + + return UL_varout_l; +} + + +#ifdef STL_TYPECASTS +/* (Reuse of existing signed STL "L" operators) with + typecasting to make the resulting "UL" code a lot cleaner and more readable. */ + +UWord32 UL_lshl( UWord32 UL_var1, Word16 var2) { + return( (UWord32)L_lshl( (Word32) UL_var1, var2)); +} + +UWord32 UL_lshr( UWord32 UL_var1, Word16 var2) { + return( (UWord32)L_lshr( (Word32) UL_var1, var2) ); +} + +UWord32 UL_and(UWord32 UL_var1, UWord32 UL_var2 ) +{ + return (UWord32) L_and((Word32)UL_var1,(Word32) UL_var2); +} + +UWord32 UL_or(UWord32 UL_var1, UWord32 UL_var2 ) +{ + return (UWord32) L_or((Word32)UL_var1,(Word32) UL_var2); +} + +UWord32 UL_xor(UWord32 UL_var1, UWord32 UL_var2 ) +{ + return (UWord32) L_xor((Word32)UL_var1,(Word32) UL_var2); +} + +UWord32 UL_deposit_h(UWord16 uvar1) +{ + return (UWord32) L_deposit_h((Word32)uvar1); +} + +UWord16 u_extract_h(UWord32 UL_var1) +{ + return (UWord16) extract_h((Word32)UL_var1); +} + +UWord16 u_extract_l(UWord32 UL_var1) +{ + return (UWord32)extract_l((Word32)UL_var1); +} + +/* enable convenient reuse of Non-saturating UL_subNs , UL_addNs while "D"iscarding the sgn/wrap output flags */ +UWord32 UL_subNsD(UWord32 UL_var1, UWord32 UL_var2 ) +{ + UWord16 dummy_sign; + return UL_subNs(UL_var1,UL_var2,&dummy_sign ); +} + +UWord32 UL_addNsD(UWord32 UL_var1, UWord32 UL_var2 ) +{ + UWord16 dummy_wrap; + return UL_addNs(UL_var1,UL_var2,&dummy_wrap ); +} +#endif + +#endif /* ENH_U_32_BIT_OPERATOR */ + +/* end of file */ diff --git a/lib_com/enhUL32.h b/lib_com/enhUL32.h new file mode 100644 index 000000000..7b3787289 --- /dev/null +++ b/lib_com/enhUL32.h @@ -0,0 +1,76 @@ +/* + ============================================================================ + File: ENHUL32.H v.1.0 - 01.July.2018 + ============================================================================ + + + ============================================================================ +*/ + +#ifndef _ENHUL32_H +#define _ENHUL32_H + +/***************************************************************************** + * + * Constants and Globals + * + *****************************************************************************/ +#define STL_TYPECASTS /* logical shift and bitwise manipulation functions */ + /* algorithmically exact to existing signed L_lshr and L_lshr */ + +#include "stl.h" + +#ifndef UWord64 +#define UWord64 unsigned long long /* for local use inside UL_Mpy_32_* */ +#endif + +#if (WMOPS) +#include "count.h" +extern BASIC_OP multiCounter[MAXCOUNTERS]; /* existing signed counters are reused for unsigedn operators */ +extern int currCounter; +#endif /* if WMOPS */ + +/***************************************************************************** + * + * Prototypes for enhanced unsigned 32 bit arithmetic operators + * + *****************************************************************************/ +#ifdef ENH_U_32_BIT_OPERATOR +UWord32 UL_addNs (UWord32 a, UWord32 b, UWord16* wrap); +UWord32 UL_subNs (UWord32 a, UWord32 b, UWord16* sgn); + +UWord32 UL_Mpy_32_32 (UWord32 a, UWord32 b); +void Mpy_32_32_uu (UWord32 a, UWord32 b, UWord32 *c_h, UWord32 *c_l); /* does not saturate */ +void Mpy_32_16_uu (UWord32 a, UWord16 b, UWord32 *c_h, UWord16 *c_l); /* does not saturate */ + +Word16 norm_ul_float (UWord32 UL_var1); +UWord32 UL_deposit_l (UWord16); /* deposit low without sign extension */ +#endif /* ENH_U_32_BIT_OPERATOR */ + +/***************************************************************************** + * + * Inline Functions + * + *****************************************************************************/ + +#ifdef STL_TYPECASTS +/* (Reuse of existing signed STL "L" operators) with + typecasting to make the resulting "UL" code a lot cleaner and more readable. */ +UWord32 UL_lshl( UWord32 UL_var1, Word16 var2); +UWord32 UL_lshr( UWord32 UL_var1, Word16 var2); +UWord32 UL_and(UWord32 UL_var1, UWord32 UL_var2 ); +UWord32 UL_or(UWord32 UL_var1, UWord32 UL_var2 ); +UWord32 UL_xor(UWord32 UL_var1, UWord32 UL_var2 ); +UWord32 UL_deposit_h(UWord16 uvar1); +UWord16 u_extract_h(UWord32 UL_var1); +UWord16 u_extract_l(UWord32 UL_var1); + +/* enable convenient reuse of Non-saturating UL_subNs , UL_addNs + while "D"iscarding the sgn/wrap output flags */ +UWord32 UL_subNsD(UWord32 UL_var1, UWord32 UL_var2 ); +UWord32 UL_addNsD(UWord32 UL_var1, UWord32 UL_var2 ); +#endif + +#endif /*_ENHUL32_H*/ + +/* end of file */ diff --git a/lib_com/enr_1_az.c b/lib_com/enr_1_az.c index 800fa185c..48ba3c336 100644 --- a/lib_com/enr_1_az.c +++ b/lib_com/enr_1_az.c @@ -63,3 +63,112 @@ float enr_1_Az( return enr_LP; } + +#ifdef BASOP_NOGLOB +Word16 Enr_1_Az_fx_o( /* o : impulse response energy Q3 */ + const Word16 Aq[], /* i : LP filter coefs Qx based on the fact that Aq[0] == 1.0 */ + const Word16 len, /* i : impulse response length Q0 */ + Flag* Overflow_out /* o : propagating the Overflow flag to upper level */ +) +#else +Word16 Enr_1_Az_fx( /* o : impulse response energy Q3 */ + const Word16 Aq[], /* i : LP filter coefs Qx based on the fact that Aq[0] == 1.0 */ + const Word16 len /* i : impulse response length Q0 */ +) +#endif +{ + Word16 h1[2 * L_SUBFR]; + Word16 *y; + Word16 i, j, a0, q; + Word32 L_tmp, L_tmp2; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + /* Find the impulse response */ + + q = sub(3, norm_s(Aq[0])); + a0 = shr(Aq[0], q); /* Q11 */ + q = sub(4, q); + + /*-----------------------------------------------------------------------* + * Do the filtering (first two iters unrolled to avoid multiplies with 0) + *-----------------------------------------------------------------------*/ + + y = h1; + /* h1_in Q11, h1_out Q10 */ + L_tmp = L_mult(a0, 1 << 13); /* Q25 = L_mult(Q11,Q13) */ + *y = round_fx(L_tmp); /* Q25 to Q9 */ + L_tmp2 = L_mult(*y, *y); /* Q19 = L_mult(Q9,Q9) */ + y++; + + L_tmp = L_msu(0, Aq[1], y[-1]); /* Q23 = L_mult(Q14,Q9) */ + L_tmp = L_shl(L_tmp, q); + *y = round_fx(L_tmp); /* Q25 to Q9 */ + L_tmp2 = L_mac(L_tmp2, *y, *y); /* Q19 = L_mult(Q9,Q9) */ + y++; + + /* Skip Zeros */ + FOR(i = 2; i < M; i++) + { + L_tmp = L_msu(0, Aq[1], y[-1]); + FOR(j = 2; j <= i; j++) + { +#ifdef BASOP_NOGLOB + L_tmp = L_msu_o(L_tmp, Aq[j], y[-j], &Overflow); +#else + L_tmp = L_msu(L_tmp, Aq[j], y[-j]); +#endif + } + +#ifdef BASOP_NOGLOB + L_tmp = L_shl_o(L_tmp, q, &Overflow); + *y = round_fx_o(L_tmp, &Overflow); + L_tmp2 = L_mac_o(L_tmp2, *y, *y, &Overflow); +#else + L_tmp = L_shl(L_tmp, q); + *y = round_fx(L_tmp); + L_tmp2 = L_mac(L_tmp2, *y, *y); +#endif + y++; + } + /* Normal Filtering */ + FOR(; i < len; i++) + { + L_tmp = L_msu(0, Aq[1], y[-1]); + FOR(j = 2; j <= M; j++) + { +#ifdef BASOP_NOGLOB + L_tmp = L_msu_o(L_tmp, Aq[j], y[-j], &Overflow); +#else + L_tmp = L_msu(L_tmp, Aq[j], y[-j]); +#endif + } + +#ifdef BASOP_NOGLOB + L_tmp = L_shl_o(L_tmp, q, &Overflow); + *y = round_fx_o(L_tmp, &Overflow); + L_tmp2 = L_mac_o(L_tmp2, *y, *y, &Overflow); +#else + L_tmp = L_shl(L_tmp, q); + *y = round_fx(L_tmp); + L_tmp2 = L_mac(L_tmp2, *y, *y); +#endif + y++; + } +#ifdef BASOP_NOGLOB + *Overflow_out = Overflow; + return round_fx_o(L_tmp2, Overflow_out); /* Q19 to Q3 */ +#else + return round_fx(L_tmp2); /* Q19 to Q3 */ +#endif +} +#ifdef BASOP_NOGLOB +Word16 Enr_1_Az_fx( /* o : impulse response energy Q3 */ + const Word16 Aq[], /* i : LP filter coefs Qx based on the fact that Aq[0] == 1.0 */ + const Word16 len /* i : impulse response length Q0 */ +) +{ + Flag Overflow = 0; + return Enr_1_Az_fx_o(Aq, len, &Overflow); +} +#endif \ No newline at end of file diff --git a/lib_com/env_adj.c b/lib_com/env_adj.c index 459c40338..20ed5410a 100644 --- a/lib_com/env_adj.c +++ b/lib_com/env_adj.c @@ -40,6 +40,8 @@ #include "rom_com.h" #include "prot.h" #include "wmc_auto.h" +#include "prot_fx1.h" +#include "prot_fx2.h" /*--------------------------------------------------------------------------* * env_adj() @@ -163,3 +165,156 @@ void env_adj( return; } + + +void env_adj_fx +( + const Word16 *pulses, /* i : number of pulses per band Q0 */ + const Word16 length, /* i : length of spectrum Q0 */ + const Word16 last_sfm, /* i : index of the last band Q0 */ + Word16 *adj, /* o : adjustment factors for the envelope Q15 */ + const Word16 env_stab, /* i : envelope stability Q15 */ + const Word16 *sfmsize /* i : subband sizes Q0 */ +) +{ + Word16 i, j, group; + Word16 npul; + Word16 att_state; + Word16 start, len; + Word16 tmp, tmp_diff; + Word16 gain_adj; + Word16 idx; + + att_state = 0; + move16(); + len = 0; + move16(); + start = 0; + move16(); + + /* Find attenuation levels */ + FOR(i = 0; i <= last_sfm; i++) + { + group = sub(shr(sfmsize[i], 3), 1); + npul = pulses[i]; + move16(); + + IF(EQ_16(length, L_FRAME32k)) + { + + IF(npul == 0) + { + /* Noise filled band */ + IF(LE_16(group, 1)) + { + test(); + test(); + test(); + test(); + IF(i > 0 && pulses[i - 1] != 0 && pulses[i + 1] != 0) + { + adj[i] = 11796; /* Q15, 0.36f */ move16(); + } + ELSE IF(i > 0 && (pulses[i - 1] == 0 || pulses[i + 1] == 0)) + { + adj[i] = 17695; /* Q15, 0.54f */ move16(); + } + ELSE + { + adj[i] = 23593; /* Q15, 0.72f */ move16(); + } + } + ELSE IF(LT_16(i, last_sfm)) + { + test(); + IF(pulses[i - 1] != 0 && pulses[i + 1] != 0) + { + adj[i] = 17695; /* Q15, 0.54f */ move16(); + } + ELSE + { + adj[i] = 23593; /* Q15, 0.72f */ move16(); + } + } + ELSE + { + adj[i] = 23593; /* Q15, 0.72f */ move16(); + } + + if (att_state == 0) + { + start = i; + move16(); + } + + len = add(len, 1); + move16(); + att_state = 1; + move16(); + } + ELSE + { + adj[i] = MAX_16; /* Q15, 1.0f (saturated) */ + IF(EQ_16(att_state, 1)) /* End of attenuation region found */ + { + /* tmp = min(1, max(0, len-ENV_ADJ_START)*(1.0f/ENV_ADJ_INCL)); */ +#ifdef BASOP_NOGLOB + tmp = round_fx_sat(L_shl_sat(L_mult0(s_max(0, sub(len, ENV_ADJ_START_FX)), ENV_ADJ_INV_INCL_FX),16)); /* Q15 (15+16-16) */ +#else + tmp = round_fx(L_shl(L_mult0(s_max(0, sub(len, ENV_ADJ_START_FX)), ENV_ADJ_INV_INCL_FX),16)); /* Q15 (15+16-16) */ +#endif + tmp_diff = sub(MAX_16, tmp); /* Q15 */ move16(); + FOR(j = start; j < i; j++) + { + /* adj[j] = max(tmp + (1-tmp)*adj[j],env_stab); */ + adj[j] = s_max(add(tmp, mult(tmp_diff, adj[j])), env_stab); /* Q15 (15+15-15) */ move16(); + } + len = 0; + move16(); + att_state = 0; + move16(); + } + } + } + /* length == L_FRAME16k */ + ELSE + { + + /* Calculate low accuracy band attenuation */ + gain_adj = 32767; /* Q15, 1.0f (saturated) */ move16(); + + test(); + IF(npul > 0 && LT_16(npul, MAX_P_ATT)) + { + /*idx = (short)(npul * att_step[group] + 0.5f) - 1; */ + idx = sub(mult_r(shl(npul,2),att_step_fx[group]), 1); /* Q0 (2+13+1-16) */ + if (LT_16(idx, MAX_P_ATT)) + { + gain_adj = gain_att_fx[idx]; /* Q15 */ move16(); + } + } + adj[i] = gain_adj; + move16(); + } + } + + /* Check if the sequence ended with an attenuation region */ + IF(EQ_16(att_state, 1)) + { + /* tmp = min(1, max(0, len-ENV_ADJ_START)*(1.0f/ENV_ADJ_INCL)); */ +#ifdef BASOP_NOGLOB + tmp = round_fx_sat(L_shl_sat(L_mult0(s_max(0, sub(len, ENV_ADJ_START_FX)), ENV_ADJ_INV_INCL_FX), 16)); /* Q15 (15+16-16) */ +#else + tmp = round_fx(L_shl(L_mult0(s_max(0, sub(len, ENV_ADJ_START_FX)), ENV_ADJ_INV_INCL_FX), 16)); /* Q15 (15+16-16) */ +#endif + tmp_diff = sub(MAX_16, tmp); /* Q15 */ move16(); + FOR(j = start; j < i; j++) + { + + /* adj[j] = max(tmp + (1-tmp)*adj[j],env_stab); */ + adj[j] = s_max(add(tmp, mult(tmp_diff, adj[j])), env_stab); /* Q15 (15+15-15) */ move16(); + } + } + + return; +} diff --git a/lib_com/env_stab.c b/lib_com/env_stab.c index ee07218f9..d4eb41e0c 100644 --- a/lib_com/env_stab.c +++ b/lib_com/env_stab.c @@ -34,6 +34,7 @@ EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 ====================================================================================*/ + #include #include "options.h" #include @@ -42,7 +43,8 @@ #include "rom_com.h" #include "wmc_auto.h" #include "stl.h" - +#include "prot_fx1.h" +#include "prot_fx2.h" /*--------------------------------------------------------------------------* * Local constants *--------------------------------------------------------------------------*/ @@ -180,6 +182,123 @@ float env_stability( return env_stab_f; } + +Word16 env_stability_fx( /* in Q15 */ + const Word16* ynrm, /*i: Norm vector for current frame */ + const Word16 nb_sfm, /*i: Number of sub-bands */ + Word16* mem_norm, /*i/o: Norm vector memory from past frame */ + Word16* mem_env_delta, /*i/o: Envelope stability memory for smoothing in Q12 */ + const Word16 core_switching_flag/* i : Core switching flag */ +) +{ + Word16 env_delta; + Word16 env_stab; + Word16 tmp, tmp_stab; + Word16 i; + + Word16 exp, exp2; + Word32 L_tmp, L_env_delta; + Word16 inv_nb_sfm; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + IF(core_switching_flag) + { + FOR(i = 0; i < nb_sfm; i++) + { + mem_norm[i] = ynrm[i]; move16(); + } + Overflow = 0; move16(); +#ifdef BASOP_NOGLOB /* Critical Overflow */ + env_delta = shl_o(*mem_env_delta, 1, &Overflow); +#else + env_delta = shl(*mem_env_delta, 1); +#endif + } + ELSE + { + /* Calculate envelope stability parameter */ +L_env_delta = L_deposit_l(0); +FOR(i = 0; i < nb_sfm; i++) +{ + tmp = sub(mem_norm[i], ynrm[i]); + L_env_delta = L_mac0(L_env_delta, tmp, tmp); + mem_norm[i] = ynrm[i]; + move16(); +} + +inv_nb_sfm = 19418; /* Q19 */ move16(); +if (nb_sfm == 26) +{ + inv_nb_sfm = 20165; /* Q19 */ move16(); +} +exp = norm_l(L_env_delta); +L_env_delta = Mult_32_16(L_shl(L_env_delta, exp), inv_nb_sfm); /* 0+exp+19-15 */ + +L_tmp = Sqrt_l(L_env_delta, &exp2); /* exp+4+31+exp2 */ + +exp = add(35, add(exp, exp2)); +if (EQ_16(s_and(exp, 1), 1)) +{ + L_tmp = Mult_32_16(L_tmp, 23170); /* 1/sqrt(2) in Q15 */ +} +exp = shr(exp, 1); + +env_delta = round_fx(L_shl(L_tmp, sub(26, exp))); /* Q10 */ + +L_tmp = L_mult0(26214, env_delta); /* 26214 is 0.1 in Q18. Q28 */ +L_tmp = L_mac(L_tmp, 29491, *mem_env_delta); /* 29491 is 0.9 in Q15. Q28 */ + +*mem_env_delta = round_fx(L_tmp); /* Q12 */ +Overflow = 0; +move16(); +#ifdef BASOP_NOGLOB /* Critical Overflow */ + env_delta = round_fx_o(L_shl_o(L_tmp, 1, &Overflow), &Overflow); /* Q13 */ +#else + env_delta = round_fx(L_shl(L_tmp, 1)); /* Q13 */ +#endif + } + IF(Overflow != 0) /* Saturated due to the above up-shifting operation. */ + { + return stab_trans_fx[L_STAB_TBL - 1]; /* The highest quantized index. */ + } + + /* If tmp_stab > (D_STAB_TBL*L_STAB_TBL + M_STAB_TBL), i.e., 0.103138*10+2.51757=3.603137, + * the quantized index is equal to 9. Hence, we only need to worry about any tmpStab < 4. + * In this case, Q13 is good enough. + */ + tmp_stab = sub(env_delta, M_STAB_TBL_FX); /* in Q13 */ + tmp_stab = abs_s(tmp_stab); + + /* Table lookup for smooth transitions + * First, find the quantization level, i, of tmpStab. */ +#if L_STAB_TBL > 10 +#error env_stability_fx: Use more efficient usquant() +#endif + tmp_stab = sub(tmp_stab, HALF_D_STAB_TBL_FX); /* in Q13 */ + FOR(i = 0; i < L_STAB_TBL - 1; i++) + { + IF(tmp_stab < 0) + { + BREAK; + } + ELSE + { + tmp_stab = sub(tmp_stab, D_STAB_TBL_FX); /* in Q13 */ + } + } + + env_stab = stab_trans_fx[i]; + move16(); + if (LT_16(env_delta, M_STAB_TBL_FX)) + { + env_stab = sub(0x7FFF, stab_trans_fx[i]); + } + + return env_stab; +} + /*--------------------------------------------------------------------------* * env_stab_smo_fx() * @@ -231,3 +350,78 @@ float env_stab_smo( return state; } + +Word16 env_stab_smo_fx( /* Q0 */ + Word16 env_stab, /*i : env_stab value Q15 */ + Word16 *env_stab_state_p, /*i/o: env_stab state probabilities Q15 */ + Word16 *ho_cnt /*i/o: hangover counter for speech state */ +) +{ + Word16 state, prev_state; + Word16 maxval, pp[NUM_ENV_STAB_PLC_STATES], pa[NUM_ENV_STAB_PLC_STATES]; + Word16 i; + Word16 tmp, sum, exp; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + /* get previous state */ + prev_state = maximum_fx(env_stab_state_p, NUM_ENV_STAB_PLC_STATES, &maxval); + + /* assume two states: speech(0), music(1) */ + /* set a posteriori likelihoods for the two states according to env_stab */ + /* re-scale. Unclear if needed */ + /* env_stab = (env_stab - stab_trans_fx[L_STAB_TBL-1])/(1-2*stab_trans_fx[L_STAB_TBL-1]); */ + tmp = sub(env_stab, stab_trans_fx[L_STAB_TBL - 1]); + tmp = round_fx(L_shl(L_mult(tmp, INV_STAB_TRANS_FX), 1)); /* Q15 */ + + pp[0] = sub(32767, tmp); + move16(); /* 1 in Q15 */ + pp[1] = tmp; + move16(); + + /* calculate a priori likelihoods */ + pa[0] = round_fx(Dot_product(env_stab_tp_fx[0], env_stab_state_p, NUM_ENV_STAB_PLC_STATES)); /* Q15*/ + pa[1] = round_fx(Dot_product(env_stab_tp_fx[1], env_stab_state_p, NUM_ENV_STAB_PLC_STATES)); + + /* multiply elementwise with a posteriori likelihoods */ + sum = 0; + move16(); + FOR(i = 0; i < NUM_ENV_STAB_PLC_STATES; i++) + { + env_stab_state_p[i] = mult_r(pa[i], pp[i]); + move16(); /* Q15 */ + sum = add(sum, env_stab_state_p[i]); + } + + /* renormalize state probabilities */ + exp = norm_s(sum); + tmp = div_s(16384, shl(sum, exp)); /* Q(14-exp) */ + /*tmp = shl(tmp, add(exp, 1));*/ /* Q15 */ + FOR(i = 0; i < NUM_ENV_STAB_PLC_STATES; i++) + { +#ifdef BASOP_NOGLOB + env_stab_state_p[i] = round_fx_o(L_shl_o(L_mult_o(env_stab_state_p[i], tmp, &Overflow), add(exp, 1), &Overflow), &Overflow); /* Q15 */ +#else + env_stab_state_p[i] = round_fx(L_shl(L_mult(env_stab_state_p[i], tmp), add(exp, 1))); /* Q15 */ +#endif + } + + /* find maximum index as return value */ + state = maximum_fx(env_stab_state_p, NUM_ENV_STAB_PLC_STATES, &maxval); + + /* apply some hangover for speech */ + test(); + if (state == 0 && EQ_16(prev_state, 1)) + { + *ho_cnt = ENV_STAB_SMO_HO; + move16(); + } + + IF(*ho_cnt > 0) + { + *ho_cnt = sub(*ho_cnt, 1); + move16(); + } + + return state; +} diff --git a/lib_com/env_stab_trans.c b/lib_com/env_stab_trans.c index 1850ed48b..6cebe2724 100644 --- a/lib_com/env_stab_trans.c +++ b/lib_com/env_stab_trans.c @@ -41,7 +41,8 @@ #include "prot.h" #include "rom_com.h" #include "wmc_auto.h" - +#include "prot_fx1.h" +#include "prot_fx2.h" /*--------------------------------------------------------------------------* * env_stab_transient_detect() * @@ -153,3 +154,149 @@ void env_stab_transient_detect( return; } + + +void env_stab_transient_detect_fx( + const Word16 is_transient, /* i: Transient flag */ + const Word16 length, /* i : Length of spectrum (32 or 48 kHz) */ + const Word16 norm[], /* i : quantization indices for norms */ + Word16 *no_att_hangover, /* i/o: Frame counter for attenuation hangover (Q0) */ + Word32 *L_energy_lt, /* i/o: Long-term energy measure for transient detection (Q13) */ + const Word16 HQ_mode, /* i : HQ coding mode */ + const Word16 bin_th, /* i : HVQ cross-over frequency bin */ + const Word32 *L_coeff, /* i : Coded spectral coefficients */ + const Word16 Qcoeff /* i : Q of coded spectral coefficients */ +) +{ + Word16 i, blk, norm_ind, sqrt_exp, bin_th_1, temp, sh; + Word32 L_e_frame, L_temp, L_d_max; + Word32 L_energy_lt_local; + Word32 L_E_sub[4]; + Word32 L_delta_e_sub; + + L_energy_lt_local = *L_energy_lt; + move32(); + + L_d_max = L_deposit_l(0); + L_e_frame = L_deposit_l(0); + temp = 32; + move16(); + + IF( EQ_16(HQ_mode,HQ_HVQ)) + { + FOR (i = 0; i < bin_th; i++) /* find adaptive shift */ + { + temp = s_min(temp,norm_l(L_coeff[i])); + } + sh = sub(temp,2); /* scale such that 2 msbs are not used, the resulting adaptive Qcoeff will be: Qcoeff+sh-16 */ + FOR (i = 0; i < bin_th; i++) /* Maximum number of loop runs 320 */ + { + temp = extract_h(L_shl(L_coeff[i],sh)); + L_e_frame = L_mac(L_e_frame,temp,temp); /* Q(2*(Qcoeff+sh-16)+1)=Q(2*(Qcoeff+sh)-31 */ + } + + bin_th_1 = INV_HVQ_THRES_BIN_24k; + move16(); + if (EQ_16(bin_th, HVQ_THRES_BIN_32k)) + { + bin_th_1 = INV_HVQ_THRES_BIN_32k; + move16(); + } + L_temp = Mult_32_16(L_e_frame,bin_th_1); /* Q(2*(Qcoeff-16+sh)+1+21-15) -> Q(2*(Qcoeff+sh)-25) */ + L_e_frame = Sqrt_l(L_temp,&sqrt_exp); + L_e_frame = L_shr(L_e_frame, add(sub(add(sh,Qcoeff),10),shr(sqrt_exp,1))); /* Adjust by (Qcoeff+sh-10) to fixed Q13: Qcoeff+sh+(-25+31)/2 - (Qcoeff+sh-10) -> Q13 */ + + IF ( GT_32(L_e_frame, ENERGY_TH_FX)) + { + L_energy_lt_local = Mult_32_16(*L_energy_lt, ENERGY_LT_BETA_FX); + L_temp = Mult_32_16(L_e_frame, ENERGY_LT_BETA_1_FX); + *L_energy_lt = L_add(L_energy_lt_local,L_temp); + move32(); + } + + IF (*no_att_hangover > 0) + { + (*no_att_hangover) = sub((*no_att_hangover), 1); + move16(); + } + } + ELSE + { + L_e_frame = L_deposit_l(0); + + test(); + IF (is_transient && EQ_16(length,L_FRAME32k)) + { + /* Measure subframe energies */ + FOR (blk = 0; blk < NUM_SUBFRAMES; blk++) + { + L_E_sub[blk] = L_deposit_l(0); /* Q9 */ + + FOR (i=0; i < 2^4 */ + { + norm_ind = subf_norm_groups[blk][i]; + move16(); + L_E_sub[blk] = L_add(L_E_sub[blk],L_shr(dicn_fx[norm[norm_ind]],4)); + move32(); ; /* Q10 */ + } + + L_E_sub[blk] = Mult_32_16(L_E_sub[blk], INV_BANDS_PER_SUBFRAMES); + move32(); /* Q(10+17-15) -> Q12 */ + + L_e_frame = L_add(L_e_frame,L_E_sub[blk]); /* Q12 */ + } + + /* Test for transient */ + /* if (e_frame > ENERGY_TH * NUM_SUBFRAMES) */ + IF (GT_32(L_e_frame, ENERGY_TH_NUM_SUBFRAMES)) + { + FOR (blk = 0; blk < NUM_SUBFRAMES-1; blk++) + { + L_delta_e_sub = L_sub(L_E_sub[blk+1],L_E_sub[blk]); /* Q12 */ + if (GT_32(L_delta_e_sub,L_d_max)) + { + L_d_max = L_delta_e_sub; /* L_d_max is NOT normalized with *energy_lt */ + move32(); + } + } + } + } + ELSE + { + /* Update long-term energy measure */ + L_e_frame = L_deposit_l(0); /* Q9 */ + FOR (i = 0; i < SFM_N_ENV_STAB; i++) /* 27 times -> < 2^5 */ + { + L_e_frame = L_add(L_e_frame,L_shr(dicn_fx[norm[i]],5)); + /* Q9 */ + } + + L_e_frame = Mult_32_16(L_e_frame, INV_SFM_N_ENV_STAB); /* Q(9+19-15) -> Q13 */ + + IF ( GT_32(L_e_frame, ENERGY_TH_FX)) + { + L_energy_lt_local = Mult_32_16(*L_energy_lt, ENERGY_LT_BETA_FX); + L_temp = Mult_32_16(L_e_frame, ENERGY_LT_BETA_1_FX); + *L_energy_lt = L_add(L_energy_lt_local,L_temp); + move32(); + } + } + + /* Add hang-over for conservative application of stability dependent attenuation */ + /* -> Note: L_d_max not normalized with *energy_lt */ + /* Hence, we compare L_d_max/DELTA_TH with *energy_lt */ + IF (GT_32(Mult_32_16(L_d_max, INV_DELTA_TH),L_energy_lt_local)) /* Q13 = Q(12 + 16 -15) */ + { + *no_att_hangover = ATT_LIM_HANGOVER; + move16(); + } + ELSE if (*no_att_hangover > 0) + { + *no_att_hangover = sub(*no_att_hangover,1); + move16(); + } + } + + return; +} + diff --git a/lib_com/fd_cng_com.c b/lib_com/fd_cng_com.c index a6029e105..6095c7508 100644 --- a/lib_com/fd_cng_com.c +++ b/lib_com/fd_cng_com.c @@ -332,8 +332,8 @@ void minimum_statistics( float *msPeriodogSum = hFdCngCom->msPeriodogSum; float slope; float *ptr; - float msAlphaCorAlpha = MSALPHACORALPHA; - float msAlphaCorAlpha2 = 1.f - MSALPHACORALPHA; + float msAlphaCorAlpha = MSALPHACORALPHA_FLT; + float msAlphaCorAlpha2 = 1.f - MSALPHACORALPHA_FLT; int16_t i, j, k; float scalar, scalar2, scalar3; @@ -392,15 +392,15 @@ void minimum_statistics( msPeriodogSum[cnt] = dotp( msPeriodog + start, psize + start, current_len ); scalar = msPeriodogSum[cnt] * msPeriodogSum[cnt] + DELTA; scalar2 = msPsdSum[cnt] - msPeriodogSum[cnt]; - scalar = max( scalar / ( scalar + scalar2 * scalar2 ), MSALPHACORMAX ); + scalar = max( scalar / ( scalar + scalar2 * scalar2 ), MSALPHACORMAX_FLT ); hFdCngCom->msAlphaCor[cnt] = msAlphaCorAlpha * hFdCngCom->msAlphaCor[cnt] + msAlphaCorAlpha2 * scalar; /* Compute SNR */ snr = dotp( msNoiseFloor + start, psize + start, current_len ); snr = ( msPsdSum[cnt] + DELTA ) / ( snr + DELTA ); - snr = (float) pow( snr, MSSNREXP ); - msAlphaHatMin2 = min( MSALPHAHATMIN, snr ); - scalar = MSALPHAMAX * hFdCngCom->msAlphaCor[cnt]; /*msAlpha,msPsd,msPeriodog,msNoiseFloor*/ + snr = (float) pow( snr, MSSNREXP_FLT ); + msAlphaHatMin2 = min( MSALPHAHATMIN_FLT, snr ); + scalar = MSALPHAMAX_FLT * hFdCngCom->msAlphaCor[cnt]; /*msAlpha,msPsd,msPeriodog,msNoiseFloor*/ for ( j = start; j < stop; j++ ) { /* Compute optimal smoothing parameter for PSD estimation */ @@ -419,12 +419,12 @@ void minimum_statistics( for ( j = start; j < stop; j++ ) { /* Compute variance of PSD */ - beta = min( msAlpha[j] * msAlpha[j], MSBETAMAX ); + beta = min( msAlpha[j] * msAlpha[j], MSBETAMAX_FLT ); scalar3 = msPsd[j] - msPsdFirstMoment[j]; msPsdFirstMoment[j] = beta * msPsdFirstMoment[j] + ( 1.f - beta ) * msPsd[j]; msPsdSecondMoment[j] = beta * msPsdSecondMoment[j] + ( 1.f - beta ) * scalar3 * scalar3; /* Compute inverse of amount of degrees of freedom */ - QeqInv = min( ( msPsdSecondMoment[j] + DELTA ) / ( 2.f * msNoiseFloor[j] * msNoiseFloor[j] + DELTA ), MSQEQINVMAX ); + QeqInv = min( ( msPsdSecondMoment[j] + DELTA ) / ( 2.f * msNoiseFloor[j] * msNoiseFloor[j] + DELTA ), MSQEQINVMAX_FLT ); QeqInvAv += QeqInv * psize[j]; /* Compute bias correction Bmin */ @@ -435,7 +435,7 @@ void minimum_statistics( hFdCngCom->msQeqInvAv[cnt] = QeqInvAv; /* New minimum? */ - BminCorr = 1.f + MSAV * (float) sqrt( QeqInvAv ); /*msPsd,msBminWin,msNewMinFlag,msCurrentMin,msCurrentMinSubWindow*/ + BminCorr = 1.f + MSAV_FLT * (float) sqrt( QeqInvAv ); /*msPsd,msBminWin,msNewMinFlag,msCurrentMin,msCurrentMinSubWindow*/ for ( j = start; j < stop; j++ ) { scalar = BminCorr * msPsd[j]; @@ -659,7 +659,7 @@ void apply_scale( assert( i < scaleTableSize ); - *scale += scaleTable[i].scale; + *scale += scaleTable[i].scale_flt; return; } @@ -931,7 +931,7 @@ void SynthesisSTFT( } tmp = buf[0]; - preemph( buf + 1, PREEMPH_FAC, M + hFdCngCom->frameSize, &tmp ); + preemph( buf + 1, PREEMPH_FAC_FLT, M + hFdCngCom->frameSize, &tmp ); residu( hFdCngCom->A_cng, M, buf + 1 + M, hFdCngCom->exc_cng, hFdCngCom->frameSize ); return; @@ -988,7 +988,7 @@ void SynthesisSTFT_dirac( /* Get excitation */ v_multc( olapBuffer + hFdCngCom->frameSize / 4 - ( M + 1 ), (float) ( hFdCngCom->fftlen / 2 ), buf, M + 1 + hFdCngCom->frameSize ); tmp = buf[0]; - preemph( buf + 1, PREEMPH_FAC, M + hFdCngCom->frameSize, &tmp ); + preemph( buf + 1, PREEMPH_FAC_FLT, M + hFdCngCom->frameSize, &tmp ); residu( hFdCngCom->A_cng, M, buf + 1 + M, hFdCngCom->exc_cng, hFdCngCom->frameSize ); /* update and window olapBuf if we have a output frame that is shorter than the default frame size...*/ diff --git a/lib_com/fft.c b/lib_com/fft.c index e5607dcc3..155883184 100644 --- a/lib_com/fft.c +++ b/lib_com/fft.c @@ -6392,9 +6392,6 @@ void rfft( #define WMC_TOOL_SKIP -#define SCALEFACTOR8 ( 4 ) -#define SCALEFACTOR64 ( 7 ) -#define SCALEFACTORN2 ( 3 ) #define SHC( x ) ( (Word16) x ) #define FFTC( x ) WORD322WORD16( (Word32) x ) @@ -6403,8 +6400,8 @@ void rfft( #define C82_FX ( FFTC( 0xa57d8666 ) ) /* FL2WORD32(-7.071067811865475e-1) */ #define cplxMpy4_8_0( re, im, a, b, c, d ) \ - re = L_shr( L_sub( Mpy_32_16( a, c ), Mpy_32_16( b, d ) ), 1 ); \ - im = L_shr( L_add( Mpy_32_16( a, d ), Mpy_32_16( b, c ) ), 1 ); + re = L_shr( L_sub( Mpy_32_16_1( a, c ), Mpy_32_16_1( b, d ) ), 1 ); \ + im = L_shr( L_add( Mpy_32_16_1( a, d ), Mpy_32_16_1( b, c ) ), 1 ); #define cplxMpy4_8_1( re, im, a, b ) \ re = L_shr( a, 1 ); \ @@ -6552,10 +6549,10 @@ static void BASOP_fft8( t00 = L_add( t07, t15 ); t03 = L_sub( t07, t15 ); - s12 = Mpy_32_16( L_add( t00, t02 ), C81_FX ); - s14 = Mpy_32_16( L_sub( t00, t02 ), C81_FX ); - s13 = Mpy_32_16( L_sub( t03, t01 ), C81_FX ); - s15 = Mpy_32_16( L_add( t01, t03 ), C82_FX ); + s12 = Mpy_32_16_1( L_add( t00, t02 ), C81_FX ); + s14 = Mpy_32_16_1( L_sub( t00, t02 ), C81_FX ); + s13 = Mpy_32_16_1( L_sub( t03, t01 ), C81_FX ); + s15 = Mpy_32_16_1( L_add( t01, t03 ), C82_FX ); /* Post-additions */ @@ -6696,10 +6693,10 @@ static void BASOP_fftN2( t00 = L_shr( L_add( t07, t15 ), SCALEFACTORN2 - 1 ); t03 = L_shr( L_sub( t07, t15 ), SCALEFACTORN2 - 1 ); - s12 = Mpy_32_16( L_add( t00, t02 ), C81_FX ); - s14 = Mpy_32_16( L_sub( t00, t02 ), C81_FX ); - s13 = Mpy_32_16( L_sub( t03, t01 ), C81_FX ); - s15 = Mpy_32_16( L_add( t01, t03 ), C82_FX ); + s12 = Mpy_32_16_1( L_add( t00, t02 ), C81_FX ); + s14 = Mpy_32_16_1( L_sub( t00, t02 ), C81_FX ); + s13 = Mpy_32_16_1( L_sub( t03, t01 ), C81_FX ); + s15 = Mpy_32_16_1( L_add( t01, t03 ), C82_FX ); re[sx * i + sx * 0 * dim1] = L_add( s00, s02 ); move32(); diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c new file mode 100644 index 000000000..c209c1080 --- /dev/null +++ b/lib_com/fft_fx.c @@ -0,0 +1,6377 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + + +/*==================================================================================== + 3GPP TS26.258 Aug 24, 2023. IVAS Codec Version IVAS-FL-1.0 + ====================================================================================*/ + +/*==================================================================================== + EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 + ====================================================================================*/ + +#include +#include +#include "options.h" +#include +#include "cnst.h" +//#include "prot.h" +#include "prot_fx1.h" +//#include "cnst_fx.h" +#include "rom_com.h" +#include "rom_com_fx.h" +#include "wmc_auto.h" + +#ifdef _MSC_VER +#pragma warning( disable : 4310 ) +#endif + +/*-----------------------------------------------------------------* + * Local constants + *-----------------------------------------------------------------*/ + +#if 0 + +#define FFT_15PONIT_WNK1 0.55901699f /* EDCT & EMDCT constants */ +#define FFT_15PONIT_WNK2 0.95105652f /* EDCT & EMDCT constants */ +#define FFT_15PONIT_WNK3 0.58778525f /* EDCT & EMDCT constants */ +#define FFT_15PONIT_WNK4 0.86602540f /* EDCT & EMDCT constants */ +#define FFT_15PONIT_WNK5 0.25000000f /* EDCT & EMDCT constants */ + +/* FFT constants */ +#define FFT_C31 -0.8660254037f +#define FFT_C51 0.9510565195f +#define FFT_C52 -1.5388417989f +#define FFT_C53 -0.3632712597f +#define FFT_C54 0.5590169895f +#define FFT_C55 -1.2500000000f +#define FFT_C61 0.8660254036f +#define FFT_C81 0.7071067811f +#define FFT_C82 -0.7071067811f +#define FFT_C161 0.7071067811f +#define FFT_C162 -0.7071067811f +#define FFT_C163 0.9238795325f +#define FFT_C164 -0.9238795325f +#define FFT_C165 0.3826834323f +#define FFT_C166 -0.3826834323f + +#else + +#define Mpy_32_xx Mpy_32_16_1 + +#define FFTC( x ) WORD322WORD16( (Word32) x ) + +/* DCT related */ +#define KP559016994_16FX ( FFTC( 1200479845 ) ) /* EDCT & EMDCT constants */ +#define KP951056516_16FX ( FFTC( 2042378325 ) ) /* EDCT & EMDCT constants */ +#define KP587785252_16FX ( FFTC( 1262259213 ) ) /* EDCT & EMDCT constants */ + +#define FFT_15PONIT_WNK1 ( FFTC( 0x478dde64 ) ) /* EDCT & EMDCT constants */ +#define FFT_15PONIT_WNK2 ( FFTC( 0x79bc3854 ) ) /* EDCT & EMDCT constants */ +#define FFT_15PONIT_WNK3 ( FFTC( 0x4B3C8C0D ) ) /* EDCT & EMDCT constants */ +#define FFT_15PONIT_WNK4 ( FFTC( 0x6ED9EBA0 ) ) /* EDCT & EMDCT constants */ +#define FFT_15PONIT_WNK5 ( FFTC( 0x20000000 ) ) /* EDCT & EMDCT constants */ + +/* FFT constants */ +#define FFT_C31 ( FFTC( 0x91261468 ) ) /* FL2WORD32( -0.86602540) -sqrt(3)/2 */ +#define FFT_C51 ( FFTC( 0x79bc3854 ) ) /* FL2WORD32( 0.95105652) */ +#define FFT_C52 ( FFTC( 0x9d839db0 ) ) /* FL2WORD32(-1.53884180/2) */ +#define FFT_C53 ( FFTC( 0xd18053ce ) ) /* FL2WORD32(-0.36327126) */ +#define FFT_C54 ( FFTC( 0x478dde64 ) ) /* FL2WORD32( 0.55901699) */ +#define FFT_C55 ( FFTC( 0xb0000001 ) ) /* FL2WORD32(-1.25/2) */ +#define FFT_C61 ( FFTC( 0x6ED9EBA0 ) ) +#define FFT_C81 ( FFTC( 0x5a82799a ) ) +#define FFT_C82 ( FFTC( 0xa57d8666 ) ) +#define FFT_C161 ( FFTC( 0x5a82799a ) ) /* FL2WORD32( 7.071067811865475e-1) INV_SQRT2 */ +#define FFT_C162 ( FFTC( 0xa57d8666 ) ) /* FL2WORD32(-7.071067811865475e-1) -INV_SQRT2 */ +#define FFT_C163 ( FFTC( 0x7641af3d ) ) /* FL2WORD32( 9.238795325112867e-1) COS_PI_DIV8 */ +#define FFT_C164 ( FFTC( 0x89be50c3 ) ) /* FL2WORD32(-9.238795325112867e-1) -COS_PI_DIV8 */ +#define FFT_C165 ( FFTC( 0x30fbc54d ) ) /* FL2WORD32( 3.826834323650898e-1) COS_3PI_DIV8 */ +#define FFT_C166 ( FFTC( 0xcf043ab3 ) ) /* FL2WORD32(-3.826834323650898e-1) -COS_3PI_DIV8 */ + +#define SCALEFACTORN2 ( 3) +#define SCALEFACTOR2 ( 2) +#define SCALEFACTOR3 ( 3) +#define SCALEFACTOR4 ( 3) +#define SCALEFACTOR5 ( 4) +#define SCALEFACTOR8 ( 4) +#define SCALEFACTOR10 ( 5) +#define SCALEFACTOR12 ( 5) +#define SCALEFACTOR15 ( 5) +#define SCALEFACTOR16 ( 0) +#define SCALEFACTOR20 ( 0) +#define SCALEFACTOR24 ( 6) +#define SCALEFACTOR30 ( 6) +#define SCALEFACTOR30_1 ( 5) +#define SCALEFACTOR30_2 ( 1) +#define SCALEFACTOR32 ( 6) +#define SCALEFACTOR32_1 ( 5) +#define SCALEFACTOR32_2 ( 1) +#define SCALEFACTOR40 ( 7) +#define SCALEFACTOR60 ( 7) +#define SCALEFACTOR64 ( 7) +#define SCALEFACTOR80 ( 8) +#define SCALEFACTOR100 (10) +#define SCALEFACTOR120 ( 8) +#define SCALEFACTOR128 ( 8) +#define SCALEFACTOR160 ( 8) +#define SCALEFACTOR192 (10) +#define SCALEFACTOR200 (10) +#define SCALEFACTOR240 ( 9) +#define SCALEFACTOR256 ( 9) +#define SCALEFACTOR320 (10) +#define SCALEFACTOR400 (10) +#define SCALEFACTOR480 (11) +#define SCALEFACTOR600 (10) + +#endif + + +/*-----------------------------------------------------------------* + * Local function prototypes + *-----------------------------------------------------------------*/ + +static void cdftForw( Word16 n, Word32 *a, const Word16 *ip, const Word16 *w ); +static void bitrv2_SR( Word16 n, const Word16 *ip, Word32 *a ); +static void cftfsub( Word16 n, Word32 *a, const Word16 *w ); +static void cft1st( Word16 n, Word32 *a, const Word16 *w ); +static void cftmdl( Word16 n, Word16 l, Word32 *a, const Word16 *w ); +static void fft16( Word32 *x, Word32 *y, const Word16 *Idx ); +static void fft5_shift1( Word16 n1, Word32 *zRe, Word32 *zIm, const Word16 *Idx ); +static void fft8( Word32 *x, Word32 *y, const Word16 *Idx ); +static void fft15_shift2( Word16 n1, Word32 *zRe, Word32 *zIm, const Word16 *Idx ); +static void fft15_shift8( Word16 n1, Word32 *zRe, Word32 *zIm, const Word16 *Idx ); +static void fft5_shift4( Word16 n1, Word32 *zRe, Word32 *zIm, const Word16 *Idx ); +static void fft5_32( Word32 *zRe, Word32 *zIm, const Word16 *Idx ); +static void fft64( Word32 *x, Word32 *y, const Word16 *Idx ); +static void fft32_15( Word32 *x, Word32 *y, const Word16 *Idx ); +static void fft32_5( Word32 *x, Word32 *y, const Word16 *Idx ); +static void fft8_5( Word32 *x, Word32 *y, const Word16 *Idx ); +static void fft5_8( Word16 n1, Word32 *zRe, Word32 *zIm, const Word16 *Idx ); +static void fft4_5( Word32 *x, Word32 *y, const Word16 *Idx ); +static void fft5_4( Word16 n1, Word32 *zRe, Word32 *zIm, const Word16 *Idx ); +void DoRTFTn_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y, /* i/o: imaginary part of input and output data */ + const Word16 n /* i : size of the FFT n=(2^k) up to 1024 */ +); + +/*-----------------------------------------------------------------* + * fft15_shift2() + * 15-point FFT with 2-point circular shift + *-----------------------------------------------------------------*/ + +static void fft15_shift2( + Word16 n1, /* i : length of data */ + Word32 *zRe, /* i/o: real part of input and output data */ + Word32 *zIm, /* i/o: imaginary part of input and output data */ + const Word16 *Idx /* i : pointer of the address table */ +) +{ + Word16 in0, in8, in16, in24, in32, in1, in9, in17, in25, in33, in2, in10, in18, in26, in34; + Word32 fi1, fi2, fi3, fi4, fi5, fi6, fi7, fi8, fi9, fi10, fi11, fi12, fi13, fi14, fi15; + Word32 fi16, fi17, fi18, fi19, fi20, fi21, fi22, fi23, fi24, fi25, fi26, fi27, fi28, fi29, fi30; + Word32 f2i1, f2i2, f2i3, f2i4, f2i5, f2i6, f2i7, f2i8, f2i9, f2i10, f2i11, f2i12; + Word32 f2i13, f2i14, f2i15, f2i16, f2i17, f2i18, f2i19, f2i20, f2i21, f2i22, f2i23, f2i24; + Word32 f3i1, f3i2, f3i3, f3i4, f3i5, f3i6, f3i7, f3i8, f3i9, f3i10, f3i11, f3i12, f3i13, f3i14, f3i15; + Word32 f4i1, f4i2, f4i3, f4i4, f4i5, f4i6, f4i7, f4i8, f4i9; + Word32 f4i10, f4i11, f4i12, f4i13, f4i14, f4i15, f4i16, f4i17, f4i18, f4i19, f4i20, fo1, fo2, fo3, fo4; + Word32 fo5, fo6, fo7, fo8, fo9, fo10, fo11, fo12, fo13, fo14, fo15, fo16, fo17, fo18; + Word32 f2o1, f2o2, f2o3, f2o4, f2o5, f2o6, f2o7, f2o8, f2o9, f2o10, f2o11, f2o12, f2o13; + Word32 f2o14, f2o15, f3o1, f3o2, f3o3, f3o4, f3o5, f3o6, f3o7, f3o8, f3o9, f3o10, f3o11; + Word32 f3o12, f3o13, f3o14, f3o15, f4o1, f4o2, f4o3, f4o4, f4o5, f4o6; + Word32 f4o7, f4o8, f4o9, f4o10, f4o11, f4o12, f4o13, f4o14, f4o15, f4o16, f4o17, f4o18, f4o19; + + in0 = Idx[0]; + in8 = Idx[n1]; + in16 = Idx[n1 * 2]; + in24 = Idx[n1 * 3]; + in32 = Idx[n1 * 4]; + in1 = Idx[n1 * 5]; + in9 = Idx[n1 * 6]; + in17 = Idx[n1 * 7]; + in25 = Idx[n1 * 8]; + in33 = Idx[n1 * 9]; + in2 = Idx[n1 * 10]; + in10 = Idx[n1 * 11]; + in18 = Idx[n1 * 12]; + in26 = Idx[n1 * 13]; + in34 = Idx[n1 * 14]; + + f2i13 = zRe[in0]; + f2i14 = zIm[in0]; + f2i21 = zRe[in1]; + f2i22 = zRe[in2]; + f2i23 = zIm[in1]; + f2i24 = zIm[in2]; + + f2i15 = L_add( f2i21, f2i22 ); + f2i16 = Mpy_32_16_1( L_sub( f2i22, f2i21 ), FFT_15PONIT_WNK4 ); + f2i17 = Mpy_32_16_1( L_sub( f2i23, f2i24 ), FFT_15PONIT_WNK4 ); + f2i18 = L_add( f2i23, f2i24 ); + fi1 = L_add( f2i13, f2i15 ); + fi2 = L_add( f2i14, f2i18 ); + + f2i19 = L_sub( f2i13, L_shr( f2i15, 1 ) ); + f2i20 = L_sub( f2i14, L_shr( f2i18, 1 ) ); + fi3 = L_sub( f2i19, f2i17 ); + fi4 = L_add( f2i19, f2i17 ); + fi5 = L_add( f2i16, f2i20 ); + fi6 = L_sub( f2i20, f2i16 ); + + f3i1 = zRe[in9]; + f4i2 = zRe[in10]; + f4i3 = zRe[in8]; + f3i2 = L_add( f4i2, f4i3 ); + f3i3 = L_sub( f3i1, L_shr( f3i2, 1 ) ); + f3i4 = Mpy_32_16_1( L_sub( f4i3, f4i2 ), FFT_15PONIT_WNK4 ); + + f3i5 = zIm[in9]; + f4i4 = zIm[in10]; + f4i5 = zIm[in8]; + f3i6 = L_add( f4i4, f4i5 ); + f3i7 = Mpy_32_16_1( L_sub( f4i4, f4i5 ), FFT_15PONIT_WNK4 ); + f3i8 = L_sub( f3i5, L_shr( f3i6, 1 ) ); + + f3i9 = zRe[in33]; + f4i6 = zRe[in34]; + f4i7 = zRe[in32]; + f3i10 = L_add(f4i6, f4i7); + f3i11 = L_sub( f3i9, L_shr( f3i10, 1 ) ); + f3i12 = Mpy_32_16_1( L_sub( f4i7, f4i6 ), FFT_15PONIT_WNK4 ); + + f3i13 = zIm[in33]; + f4i8 = zIm[in34]; + f4i9 = zIm[in32]; + f3i14 = L_add( f4i8, f4i9 ); + f3i15 = Mpy_32_16_1( L_sub( f4i8, f4i9 ), FFT_15PONIT_WNK4 ); + f4i1 = L_sub( f3i13, L_shr( f3i14, 1 ) ); + + fi7 = L_add( f3i1, f3i2 ); + fi8 = L_add( f3i9, f3i10 ); + fi9 = L_add( fi7, fi8 ); + fi10 = L_sub( f3i3, f3i7 ); + fi11 = L_sub( f3i11, f3i15 ); + fi12 = L_add( fi10, fi11 ); + fi13 = L_add( f3i5, f3i6 ); + fi14 = L_add( f3i13, f3i14 ); + fi15 = L_add( fi13, fi14 ); + fi16 = L_sub( f3i8, f3i4 ); + fi17 = L_sub( f4i1, f3i12 ); + fi18 = L_add( fi16, fi17 ); + fi19 = L_add( f3i4, f3i8 ); + fi20 = L_add( f3i12, f4i1 ); + fi21 = L_add( fi19, fi20 ); + fi22 = L_add( f3i3, f3i7 ); + fi23 = L_add( f3i11, f3i15 ); + fi24 = L_add( fi22, fi23 ); + + f4i10 = zRe[in24]; + fo6 = zRe[in25]; + fo7 = zRe[in26]; + f4i11 = L_add( fo6, fo7 ); + f4i12 = L_sub( f4i10, L_shr( f4i11, 1 ) ); + f4i13 = Mpy_32_16_1( L_sub( fo7, fo6 ), FFT_15PONIT_WNK4 ); + + f4i14 = zIm[in24]; + fo8 = zIm[in25]; + fo9 = zIm[in26]; + f4i15 = L_add( fo8, fo9 ); + f4i16 = Mpy_32_16_1( L_sub( fo8, fo9 ), FFT_15PONIT_WNK4 ); + f4i17 = L_sub( f4i14, L_shr( f4i15, 1 ) ); + + f4i18 = zRe[in18]; + f2o10 = zRe[in16]; + f2o11 = zRe[in17]; + f4i19 = L_add( f2o10, f2o11 ); + f4i20 = L_sub( f4i18, L_shr( f4i19, 1 ) ); + fo1 = Mpy_32_16_1( L_sub( f2o11, f2o10 ), FFT_15PONIT_WNK4 ); + + fo2 = zIm[in18]; + f2o12 = zIm[in16]; + f2o13 = zIm[in17]; + fo3 = L_add( f2o12, f2o13 ); + fo4 = Mpy_32_16_1( L_sub( f2o12, f2o13 ), FFT_15PONIT_WNK4 ); + fo5 = L_sub( fo2, L_shr( fo3, 1 ) ); + + fi25 = L_add( f4i10, f4i11 ); + fi26 = L_add( f4i18, f4i19 ); + fi27 = L_add( fi25, fi26 ); + fi28 = L_sub( f4i12, f4i16 ); + fi29 = L_sub( f4i20, fo4 ); + fi30 = L_add( fi28, fi29 ); + f2i1 = L_add( f4i14, f4i15 ); + f2i2 = L_add( fo2, fo3 ); + f2i3 = L_add( f2i1, f2i2 ); + f2i4 = L_sub( f4i17, f4i13 ); + f2i5 = L_sub( fo5, fo1 ); + f2i6 = L_add( f2i4, f2i5 ); + f2i7 = L_add( f4i13, f4i17 ); + f2i8 = L_add( fo1, fo5 ); + f2i9 = L_add( f2i7, f2i8 ); + f2i10 = L_add( f4i12, f4i16 ); + f2i11 = L_add( f4i20, fo4 ); + f2i12 = L_add( f2i10, f2i11 ); + + fo10 = Mpy_32_16_1( L_sub( fi27, fi9 ), FFT_15PONIT_WNK1 ); + fo11 = L_add( fi27, fi9 ); + fo12 = L_sub( fi1, Mpy_32_16_1( fo11, FFT_15PONIT_WNK5 ) ); + fo15 = L_sub( fi13, fi14 ); + fo16 = L_sub( f2i1, f2i2 ); + fo13 = L_sub( Mpy_32_16_1( fo15, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fo16, FFT_15PONIT_WNK3 ) ); + fo14 = L_add( Mpy_32_16_1( fo15, FFT_15PONIT_WNK3 ), Mpy_32_16_1( fo16, FFT_15PONIT_WNK2 ) ); + + zRe[in0] = L_add( fi1, fo11 ); + fo17 = L_add( fo10, fo12 ); + zRe[in18] = L_sub( fo17, fo14 ); + zRe[in24] = L_add( fo17, fo14 ); + fo18 = L_sub( fo12, fo10 ); + zRe[in9] = L_sub( fo18, fo13 ); + zRe[in33] = L_add( fo18, fo13 ); + + f2o1 = Mpy_32_16_1( L_sub( f2i3, fi15 ), FFT_15PONIT_WNK1 ); + f2o2 = L_add( f2i3, fi15 ); + f2o3 = L_sub( fi2, Mpy_32_16_1( f2o2, FFT_15PONIT_WNK5 ) ); + f2o6 = L_sub( fi7, fi8 ); + f2o7 = L_sub( fi25, fi26 ); + f2o4 = L_sub( Mpy_32_16_1( f2o6, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f2o7, FFT_15PONIT_WNK3 ) ); + f2o5 = L_add( Mpy_32_16_1( f2o6, FFT_15PONIT_WNK3 ), Mpy_32_16_1( f2o7, FFT_15PONIT_WNK2 ) ); + zIm[in0] = L_add( fi2, f2o2 ); + f2o8 = L_add( f2o1, f2o3 ); + zIm[in24] = L_sub( f2o8, f2o5 ); + zIm[in18] = L_add( f2o5, f2o8 ); + f2o9 = L_sub( f2o3, f2o1 ); + zIm[in33] = L_sub( f2o9, f2o4 ); + zIm[in9] = L_add( f2o4, f2o9 ); + + f2o14 = Mpy_32_16_1( L_sub( fi30, fi12 ), FFT_15PONIT_WNK1 ); + f2o15 = L_add( fi30, fi12 ); + f3o1 = L_sub( fi3, Mpy_32_16_1( f2o15, FFT_15PONIT_WNK5 ) ); + f3o4 = L_sub( fi16, fi17 ); + f3o5 = L_sub( f2i4, f2i5 ); + f3o2 = L_sub( Mpy_32_16_1( f3o4, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f3o5, FFT_15PONIT_WNK3 ) ); + f3o3 = L_add( Mpy_32_16_1( f3o5, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f3o4, FFT_15PONIT_WNK3 ) ); + zRe[in2] = L_add( fi3, f2o15 ); + f3o6 = L_add( f2o14, f3o1 ); + zRe[in17] = L_sub( f3o6, f3o3 ); + zRe[in26] = L_add( f3o6, f3o3 ); + f3o7 = L_sub( f3o1, f2o14 ); + zRe[in8] = L_sub( f3o7, f3o2 ); + zRe[in32] = L_add( f3o7, f3o2 ); + + f3o8 = Mpy_32_16_1( L_sub( f2i6, fi18 ), FFT_15PONIT_WNK1 ); + f3o9 = L_add( f2i6, fi18 ); + f3o10 = L_sub( fi6, Mpy_32_16_1( f3o9, FFT_15PONIT_WNK5 ) ); + f3o13 = L_sub( fi10, fi11 ); + f3o14 = L_sub( fi28, fi29 ); + f3o11 = L_sub( Mpy_32_16_1( f3o13, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f3o14, FFT_15PONIT_WNK3 ) ); + f3o12 = L_add( Mpy_32_16_1( f3o14, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f3o13, FFT_15PONIT_WNK3 ) ); + zIm[in2] = L_add( fi6, f3o9 ); + f3o15 = L_add( f3o8, f3o10 ); + zIm[in26] = L_sub( f3o15, f3o12 ); + zIm[in17] = L_add( f3o12, f3o15 ); + f4o1 = L_sub( f3o10, f3o8 ); + zIm[in8] = L_add( f3o11, f4o1 ); + zIm[in32] = L_sub( f4o1, f3o11 ); + + f4o2 = Mpy_32_16_1( L_sub( f2i9, fi21 ), FFT_15PONIT_WNK1 ); + f4o3 = L_add( f2i9, fi21 ); + f4o4 = L_sub( fi5, Mpy_32_16_1( f4o3, FFT_15PONIT_WNK5 ) ); + f4o7 = L_sub( f2i10, f2i11 ); + f4o8 = L_sub( fi22, fi23 ); + f4o5 = L_add( Mpy_32_16_1( f4o8, FFT_15PONIT_WNK3 ), Mpy_32_16_1( f4o7, FFT_15PONIT_WNK2 ) ); + f4o6 = L_sub( Mpy_32_16_1( f4o8, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f4o7, FFT_15PONIT_WNK3 ) ); + zIm[in1] = L_add( fi5, f4o3 ); + f4o9 = L_sub( f4o4, f4o2 ); + f4o10 = L_add( f4o2, f4o4 ); + + zIm[in10] = L_add( f4o6, f4o9 ); + zIm[in34] = L_sub( f4o9, f4o6 ); + zIm[in25] = L_sub( f4o10, f4o5 ); + zIm[in16] = L_add( f4o5, f4o10 ); + + f4o11 = Mpy_32_16_1( L_sub( f2i12, fi24 ), FFT_15PONIT_WNK1 ); + f4o12 = L_add( f2i12, fi24 ); + f4o13 = L_sub( fi4, Mpy_32_16_1( f4o12, FFT_15PONIT_WNK5 ) ); + f4o16 = L_sub( f2i7, f2i8 ); + f4o17 = L_sub( fi19, fi20 ); + f4o14 = L_add( Mpy_32_16_1( f4o16, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f4o17, FFT_15PONIT_WNK3 ) ); + f4o15 = L_sub( Mpy_32_16_1( f4o17, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f4o16, FFT_15PONIT_WNK3 ) ); + zRe[in1] = L_add( fi4, f4o12 ); + f4o18 = L_sub( f4o13, f4o11 ); + f4o19 = L_add( f4o11, f4o13 ); + + zRe[in10] = L_sub( f4o18, f4o15 ); + zRe[in34] = L_add( f4o18, f4o15 ); + zRe[in16] = L_sub( f4o19, f4o14 ); + zRe[in25] = L_add( f4o19, f4o14 ); + + return; +} + +/*-----------------------------------------------------------------* + * fft15_shift8() + * 15-point FFT with 8-point circular shift + *-----------------------------------------------------------------*/ + +static void fft15_shift8( + Word16 n1, /* i : length of data */ + Word32 *zRe, /* i/o: real part of input and output data */ + Word32 *zIm, /* i/o: imaginary part of input and output data */ + const Word16 *Idx /* i : pointer of the address table */ +) +{ + Word16 in0, in8, in16, in24, in32, in1, in9, in17, in25, in33, in2, in10, in18, in26, in34; + Word32 fi1, fi2, fi3, fi4, fi5, fi6, fi7, fi8, fi9, fi10, fi11, fi12, fi13, fi14, fi15; + Word32 fi16, fi17, fi18, fi19, fi20, fi21, fi22, fi23, fi24, fi25, fi26, fi27, fi28, fi29, fi30; + Word32 f2i1, f2i2, f2i3, f2i4, f2i5, f2i6, f2i7, f2i8, f2i9, f2i10, f2i11, f2i12; + Word32 f2i13, f2i14, f2i15, f3i1, f3i2, f3i3, f3i4, f3i5, f3i6, f3i7, f3i8, f3i9; + Word32 f3i10, f3i11, f3i12, f3i13, f3i14, f3i15, f4i1, f4i2, f4i3, f4i4, f4i5, f4i6, f4i7, f4i8, f4i9; + Word32 f4i10, f4i11, f4i12, f4i13, f4i14, f4i15, fo1, fo2, fo3, fo4, fo5, fo6; + Word32 fo7, fo8, fo9, fo10, fo11, fo12, fo13, fo14, fo15, f2o1, f2o2, f2o3, f2o4; + Word32 f2o5, f2o6, f2o7, f2o8, f2o9, f2o10, f2o11, f2o12, f2o13, f2o14, f2o15; + Word32 f3o1, f3o2, f3o3, f3o4, f3o5, f3o6, f3o7, f3o8, f3o9, f3o10, f3o11, f3o12; + Word32 f3o13, f3o14, f3o15, f4o1, f4o2, f4o3, f4o4, f4o5, f4o6, f4o7, f4o8, f4o9; + Word32 f4o10, f4o11, f4o12, f4o13, f4o14, f4o15, f5o1, f5o2, f5o3, f5o4, f5o5, f5o6, f5o7; + Word32 f5o8, f5o9, f5o10, f5o11, f5o12, f5o13, f5o14, f5o15, f5o16, f5o17, f5o18, f5o19, f5o21, f5o22; + + in0 = Idx[0]; + in8 = Idx[n1]; + in16 = Idx[n1 * 2]; + in24 = Idx[n1 * 3]; + in32 = Idx[n1 * 4]; + in1 = Idx[n1 * 5]; + in9 = Idx[n1 * 6]; + in17 = Idx[n1 * 7]; + in25 = Idx[n1 * 8]; + in33 = Idx[n1 * 9]; + in2 = Idx[n1 * 10]; + in10 = Idx[n1 * 11]; + in18 = Idx[n1 * 12]; + in26 = Idx[n1 * 13]; + in34 = Idx[n1 * 14]; + + f2i13 = zRe[in0]; + f2i14 = zIm[in0]; + f3i6 = zRe[in1]; + f3i7 = zRe[in2]; + f3i8 = zIm[in1]; + f3i9 = zIm[in2]; + + f2i15 = L_add( f3i6, f3i7 ); + f3i1 = Mpy_32_16_1( L_sub( f3i7, f3i6 ), FFT_15PONIT_WNK4 ); + f3i2 = Mpy_32_16_1( L_sub( f3i8, f3i9 ), FFT_15PONIT_WNK4 ); + f3i3 = L_add( f3i8, f3i9 ); + + fi1 = L_add( f2i13, f2i15 ); + fi2 = L_add( f2i14, f3i3 ); + f3i4 = L_sub( f2i13, L_shr( f2i15, 1 ) ); + fi3 = L_sub( f3i4, f3i2 ); + fi4 = L_add( f3i4, f3i2 ); + f3i5 = L_sub( f2i14, L_shr( f3i3, 1 ) ); + fi5 = L_add( f3i1, f3i5 ); + fi6 = L_sub( f3i5, f3i1 ); + + f3i10 = zRe[in9]; + f4i11 = zRe[in10]; + f4i12 = zRe[in8]; + f3i14 = zIm[in9]; + f4i13 = zIm[in10]; + f4i14 = zIm[in8]; + f4i3 = zRe[in33]; + f4i15 = zRe[in34]; + fo1 = zRe[in32]; + f4i7 = zIm[in33]; + fo2 = zIm[in34]; + fo3 = zIm[in32]; + + + f3i11 = L_add( f4i11, f4i12 ); + f3i12 = L_sub( f3i10, L_shr( f3i11, 1 ) ); + f3i13 = Mpy_32_16_1( L_sub( f4i12, f4i11 ), FFT_15PONIT_WNK4 ); + f3i15 = L_add( f4i13, f4i14 ); + f4i1 = Mpy_32_16_1( L_sub( f4i13, f4i14 ), FFT_15PONIT_WNK4 ); + f4i2 = L_sub( f3i14, L_shr( f3i15, 1 ) ); + f4i4 = L_add( f4i15, fo1 ); + f4i5 = L_sub( f4i3, L_shr( f4i4, 1 ) ); + f4i6 = Mpy_32_16_1( L_sub( fo1, f4i15 ), FFT_15PONIT_WNK4 ); + f4i8 = L_add( fo2, fo3 ); + f4i9 = Mpy_32_16_1( L_sub( fo2, fo3 ), FFT_15PONIT_WNK4 ); + f4i10 = L_sub( f4i7, L_shr( f4i8, 1 ) ); + + fi7 = L_add( f3i10, f3i11 ); + fi8 = L_add( f4i3, f4i4 ); + fi9 = L_add( fi7, fi8 ); + fi10 = L_sub( f3i12, f4i1 ); + fi11 = L_sub( f4i5, f4i9 ); + fi12 = L_add( fi10, fi11 ); + fi13 = L_add( f3i14, f3i15 ); + fi14 = L_add( f4i7, f4i8 ); + fi15 = L_add( fi13, fi14 ); + fi16 = L_sub( f4i2, f3i13 ); + fi17 = L_sub( f4i10, f4i6 ); + fi18 = L_add( fi16, fi17 ); + fi19 = L_add( f3i13, f4i2 ); + fi20 = L_add( f4i6, f4i10 ); + fi21 = L_add( fi19, fi20 ); + fi22 = L_add( f3i12, f4i1 ); + fi23 = L_add( f4i5, f4i9 ); + fi24 = L_add( fi22, fi23 ); + + fo4 = zRe[in24]; + f2o5 = zRe[in25]; + f2o6 = zRe[in26]; + fo8 = zIm[in24]; + f2o7 = zIm[in25]; + f2o8 = zIm[in26]; + fo12 = zRe[in18]; + f2o9 = zRe[in16]; + f2o10 = zRe[in17]; + f2o1 = zIm[in18]; + f2o11 = zIm[in16]; + f2o12 = zIm[in17]; + + + fo5 = L_add( f2o5, f2o6 ); + fo6 = L_sub( fo4, L_shr( fo5, 1 ) ); + fo7 = Mpy_32_16_1( L_sub( f2o6, f2o5 ), FFT_15PONIT_WNK4 ); + fo9 = L_add( f2o7, f2o8 ); + fo10 = Mpy_32_16_1( L_sub( f2o7, f2o8 ), FFT_15PONIT_WNK4 ); + fo11 = L_sub( fo8, L_shr( fo9, 1 ) ); + fo13 = L_add( f2o9, f2o10 ); + fo14 = L_sub( fo12, L_shr( fo13, 1 ) ); + fo15 = Mpy_32_16_1( L_sub( f2o10, f2o9 ), FFT_15PONIT_WNK4 ); + f2o2 = L_add( f2o11, f2o12 ); + f2o3 = Mpy_32_16_1( L_sub( f2o11, f2o12 ), FFT_15PONIT_WNK4 ); + f2o4 = L_sub( f2o1, L_shr( f2o2, 1 ) ); + + fi25 = L_add( fo4, fo5 ); + fi26 = L_add( fo12, fo13 ); + fi27 = L_add( fi25, fi26 ); + fi28 = L_sub( fo6, fo10 ); + fi29 = L_sub( fo14, f2o3 ); + fi30 = L_add( fi28, fi29 ); + f2i1 = L_add( fo8, fo9 ); + f2i2 = L_add( f2o1, f2o2 ); + f2i3 = L_add( f2i1, f2i2 ); + f2i4 = L_sub( fo11, fo7 ); + f2i5 = L_sub( f2o4, fo15 ); + f2i6 = L_add( f2i4, f2i5 ); + f2i7 = L_add( fo7, fo11 ); + f2i8 = L_add( fo15, f2o4 ); + f2i9 = L_add( f2i7, f2i8 ); + f2i10 = L_add( fo6, fo10 ); + f2i11 = L_add( fo14, f2o3 ); + f2i12 = L_add( f2i10, f2i11 ); + + f2o13 = Mpy_32_16_1( L_sub( fi27, fi9 ), FFT_15PONIT_WNK1 ); + f2o14 = L_add( fi27, fi9 ); + f2o15 = L_sub( fi1, Mpy_32_16_1( f2o14, FFT_15PONIT_WNK5 ) ); + f3o3 = L_sub( fi13, fi14 ); + f3o4 = L_sub( f2i1, f2i2 ); + f3o1 = L_sub( Mpy_32_16_1( f3o3, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f3o4, FFT_15PONIT_WNK3 ) ); + f3o2 = L_add( Mpy_32_16_1( f3o4, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f3o3, FFT_15PONIT_WNK3 ) ); + zRe[in0] = L_add( fi1, f2o14 ); + f3o5 = L_add( f2o13, f2o15 ); + zRe[in24] = L_sub( f3o5, f3o2 ); + zRe[in18] = L_add( f3o5, f3o2 ); + f3o6 = L_sub( f2o15, f2o13 ); + zRe[in33] = L_sub( f3o6, f3o1 ); + zRe[in9] = L_add( f3o6, f3o1 ); + + f3o7 = Mpy_32_16_1( L_sub( f2i3, fi15 ), FFT_15PONIT_WNK1 ); + f3o8 = L_add( f2i3, fi15 ); + f3o9 = L_sub( fi2, Mpy_32_16_1( f3o8, FFT_15PONIT_WNK5 ) ); + f3o12 = L_sub( fi7, fi8 ); + f3o13 = L_sub( fi25, fi26 ); + f3o10 = L_sub( Mpy_32_16_1( f3o12, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f3o13, FFT_15PONIT_WNK3 ) ); + f3o11 = L_add( Mpy_32_16_1( f3o13, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f3o12, FFT_15PONIT_WNK3 ) ); + zIm[in0] = L_add( fi2, f3o8 ); + f3o14 = L_add( f3o7, f3o9 ); + zIm[in18] = L_sub( f3o14, f3o11 ); + zIm[in24] = L_add( f3o11, f3o14 ); + f3o15 = L_sub( f3o9, f3o7 ); + zIm[in9] = L_sub( f3o15, f3o10 ); + zIm[in33] = L_add( f3o10, f3o15 ); + + f4o1 = Mpy_32_16_1( L_sub( fi30, fi12 ), FFT_15PONIT_WNK1 ); + f4o2 = L_add( fi30, fi12 ); + f4o3 = L_sub( fi3, Mpy_32_16_1( f4o2, FFT_15PONIT_WNK5 ) ); + f4o6 = L_sub( fi16, fi17 ); + f4o7 = L_sub( f2i4, f2i5 ); + f4o4 = L_sub( Mpy_32_16_1( f4o6, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f4o7, FFT_15PONIT_WNK3 ) ); + f4o5 = L_add( Mpy_32_16_1( f4o7, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f4o6, FFT_15PONIT_WNK3 ) ); + zRe[in2] = L_add( fi3, f4o2 ); + f4o8 = L_add( f4o1, f4o3 ); + zRe[in26] = L_sub( f4o8, f4o5 ); + zRe[in17] = L_add( f4o8, f4o5 ); + f4o9 = L_sub( f4o3, f4o1 ); + zRe[in32] = L_sub( f4o9, f4o4 ); + zRe[in8] = L_add( f4o9, f4o4 ); + + f4o10 = Mpy_32_16_1( L_sub( f2i6, fi18 ), FFT_15PONIT_WNK1 ); + f4o11 = L_add( f2i6, fi18 ); + f4o12 = L_sub( fi6, Mpy_32_16_1( f4o11, FFT_15PONIT_WNK5 ) ); + f4o15 = L_sub( fi10, fi11 ); + f5o1 = L_sub( fi28, fi29 ); + f4o13 = L_sub( Mpy_32_16_1( f4o15, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f5o1, FFT_15PONIT_WNK3 ) ); + f4o14 = L_add( Mpy_32_16_1( f5o1, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f4o15, FFT_15PONIT_WNK3 ) ); + zIm[in2] = L_add( fi6, f4o11 ); + f5o2 = L_add( f4o10, f4o12 ); + zIm[in17] = L_sub( f5o2, f4o14 ); + zIm[in26] = L_add( f4o14, f5o2 ); + f5o3 = L_sub( f4o12, f4o10 ); + zIm[in32] = L_add( f4o13, f5o3 ); + zIm[in8] = L_sub( f5o3, f4o13 ); + + f5o4 = Mpy_32_16_1( L_sub( f2i9, fi21 ), FFT_15PONIT_WNK1 ); + f5o5 = L_add( f2i9, fi21 ); + f5o6 = L_sub( fi5, Mpy_32_16_1( f5o5, FFT_15PONIT_WNK5 ) ); + f5o9 = L_sub( f2i10, f2i11 ); + f5o10 = L_sub( fi22, fi23 ); + f5o7 = L_add( Mpy_32_16_1( f5o9, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f5o10, FFT_15PONIT_WNK3 ) ); + f5o8 = L_sub( Mpy_32_16_1( f5o10, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f5o9, FFT_15PONIT_WNK3 ) ); + zIm[in1] = L_add( fi5, f5o5 ); + f5o11 = L_sub( f5o6, f5o4 ); + f5o12 = L_add( f5o4, f5o6 ); + zIm[in34] = L_add( f5o8, f5o11 ); + zIm[in10] = L_sub( f5o11, f5o8 ); + + zIm[in16] = L_sub( f5o12, f5o7 ); + zIm[in25] = L_add( f5o7, f5o12 ); + + f5o13 = Mpy_32_16_1( L_sub( f2i12, fi24 ), FFT_15PONIT_WNK1 ); + f5o14 = L_add( f2i12, fi24 ); + f5o15 = L_sub( fi4, Mpy_32_16_1( f5o14, FFT_15PONIT_WNK5 ) ); + f5o18 = L_sub( f2i7, f2i8 ); + f5o19 = L_sub( fi19, fi20 ); + f5o16 = L_add( Mpy_32_16_1( f5o18, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f5o19, FFT_15PONIT_WNK3 ) ); + f5o17 = L_sub( Mpy_32_16_1( f5o19, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f5o18, FFT_15PONIT_WNK3 ) ); + zRe[in1] = L_add( fi4, f5o14 ); + f5o21 = L_sub( f5o15, f5o13 ); + f5o22 = L_add( f5o13, f5o15 ); + + zRe[in34] = L_sub( f5o21, f5o17 ); + zRe[in10] = L_add( f5o21, f5o17 ); + zRe[in25] = L_sub( f5o22, f5o16 ); + zRe[in16] = L_add( f5o22, f5o16 ); + + return; +} + +/*-----------------------------------------------------------------* + * fft5_shift1() + * 5-point FFT with 1-point circular shift + *-----------------------------------------------------------------*/ + +static void fft5_shift1( + Word16 n1, /* i : length of data */ + Word32 *zRe, /* i/o: real part of input and output data */ + Word32 *zIm, /* i/o: imaginary part of input and output data */ + const Word16 *Idx /* i : pointer of the address table */ +) +{ + Word32 fi1, fi2, fi3, fi4, fi5, fi6, fi7, fi8; + Word32 fo1, fo2, fo3, fo4, fo5, fo6, fo7, fo8; + Word16 in1, in2, in3, in4, in5; + + in1 = Idx[0]; + in2 = Idx[n1]; + in3 = Idx[n1 * 2]; + in4 = Idx[n1 * 3]; + in5 = Idx[n1 * 4]; + + fi1 = zRe[in1]; + fi2 = zIm[in1]; + fo3 = zRe[in2]; + fo4 = zRe[in5]; + fo6 = zRe[in3]; + fo7 = zRe[in4]; + + fo5 = L_add( fo3, fo4 ); + fo8 = L_add( fo6, fo7 ); + fi3 = L_add( fo5, fo8 ); + fi4 = L_sub( fo6, fo7 ); + fi5 = Mpy_32_16_1( L_sub( fo5, fo8 ), FFT_15PONIT_WNK1 ); + fi6 = L_sub( fo3, fo4 ); + + fo3 = zIm[in2]; + fo4 = zIm[in5]; + fo6 = zIm[in3]; + fo7 = zIm[in4]; + + fo5 = L_add( fo3, fo4 ); + fo8 = L_add( fo6, fo7 ); + fi7 = L_sub( fo3, fo4 ); + fi8 = L_add( fo5, fo8 ); + fo1 = L_sub( fo6, fo7 ); + fo2 = Mpy_32_16_1( L_sub( fo5, fo8 ), FFT_15PONIT_WNK1 ); + + zRe[in1] = L_add( fi1, fi3 ); + zIm[in1] = L_add( fi2, fi8 ); + + fo3 = L_add( Mpy_32_16_1( fi7, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fo1, FFT_15PONIT_WNK3 ) ); + fo4 = L_sub( Mpy_32_16_1( fo1, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi7, FFT_15PONIT_WNK3 ) ); + fo7 = L_sub( fi1, L_shr( fi3, 2 ) ); + fo5 = L_add( fi5, fo7 ); + fo6 = L_sub( fo7, fi5 ); + + zRe[in2] = L_add( fo5, fo3 ); + zRe[in3] = L_sub( fo6, fo4 ); + zRe[in4] = L_add( fo6, fo4 ); + zRe[in5] = L_sub( fo5, fo3 ); + + fo3 = L_add( Mpy_32_16_1( fi6, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi4, FFT_15PONIT_WNK3 ) ); + fo4 = L_sub( Mpy_32_16_1( fi4, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi6, FFT_15PONIT_WNK3 ) ); + fo7 = L_sub( fi2, L_shr( fi8, 2 ) ); + fo5 = L_add( fo2, fo7 ); + fo6 = L_sub( fo7, fo2 ); + + zIm[in2] = L_sub( fo5, fo3 ); + zIm[in3] = L_add( fo4, fo6 ); + zIm[in4] = L_sub( fo6, fo4 ); + zIm[in5] = L_add( fo3, fo5 ); + + return; +} + +/*-----------------------------------------------------------------* + * fft5_shift4() + * 5-point FFT with 4-point circular shift + *-----------------------------------------------------------------*/ + +static void fft5_shift4( + Word16 n1, /* i : length of data */ + Word32 *zRe, /* i/o: real part of input and output data */ + Word32 *zIm, /* i/o: imaginary part of input and output data */ + const Word16 *Idx /* i : pointer of the address table */ +) +{ + Word32 fi1, fi2, fi3, fi4, fi5, fi6, fi7, fi8; + Word32 fo1, fo2, fo3, fo4, fo5, fo6, fo7, fo8; + Word16 in1, in2, in3, in4, in5; + + in1 = Idx[0]; + in2 = Idx[n1]; + in3 = Idx[n1 * 2]; + in4 = Idx[n1 * 3]; + in5 = Idx[n1 * 4]; + + fi1 = zRe[in1]; + fi2 = zIm[in1]; + fo3 = zRe[in2]; + fo4 = zRe[in5]; + fo6 = zRe[in3]; + fo7 = zRe[in4]; + + fo5 = L_add( fo3, fo4 ); + fo8 = L_add( fo6, fo7 ); + fi3 = L_add( fo5, fo8 ); + fi4 = L_sub( fo6, fo7 ); + fi5 = Mpy_32_16_1( L_sub( fo5, fo8 ), FFT_15PONIT_WNK1 ); + fi6 = L_sub( fo3, fo4 ); + + fo3 = zIm[in2]; + fo4 = zIm[in5]; + fo6 = zIm[in3]; + fo7 = zIm[in4]; + + fo5 = L_add( fo3, fo4 ); + fo8 = L_add( fo6, fo7 ); + fi7 = L_sub( fo3, fo4 ); + fi8 = L_add( fo5, fo8 ); + fo1 = L_sub( fo6, fo7 ); + fo2 = Mpy_32_16_1( L_sub( fo5, fo8 ), FFT_15PONIT_WNK1 ); + + zRe[in1] = L_add( fi1, fi3 ); + zIm[in1] = L_add( fi2, fi8 ); + + fo3 = L_add( Mpy_32_16_1( fi7, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fo1, FFT_15PONIT_WNK3 ) ); + fo4 = L_sub( Mpy_32_16_1( fo1, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi7, FFT_15PONIT_WNK3 ) ); + fo7 = L_sub( fi1, L_shr( fi3, 2 ) ); + fo5 = L_add( fi5, fo7 ); + fo6 = L_sub( fo7, fi5 ); + + zRe[in2] = L_sub( fo5, fo3 ); + zRe[in4] = L_sub( fo6, fo4 ); + zRe[in3] = L_add( fo6, fo4 ); + zRe[in5] = L_add( fo5, fo3 ); + + fo3 = L_add( Mpy_32_16_1( fi6, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi4, FFT_15PONIT_WNK3 ) ); + fo4 = L_sub( Mpy_32_16_1( fi4, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi6, FFT_15PONIT_WNK3 ) ); + fo7 = L_sub( fi2, L_shr( fi8, 2 ) ); + fo5 = L_add( fo2, fo7 ); + fo6 = L_sub( fo7, fo2 ); + + zIm[in3] = L_sub( fo6, fo4 ); + zIm[in2] = L_add( fo3, fo5 ); + zIm[in4] = L_add( fo4, fo6 ); + zIm[in5] = L_sub( fo5, fo3 ); + + return; +} + +/*-----------------------------------------------------------------* + * fft5_32() + * 5-point FFT called for 32 times + *-----------------------------------------------------------------*/ + +static void fft5_32( + Word32 *zRe, /* i/o: real part of input and output data */ + Word32 *zIm, /* i/o: imaginary part of input and output data */ + const Word16 *Idx /* i : pointer of the address table */ +) +{ + Word32 fi1, fi2, fi3, fi4, fi5, fi6, fi7, fi8; + Word32 fo1, fo2, fo3, fo4, fo5, fo6, fo7, fo8; + Word16 in1, in2, in3, in4, in5; + + in1 = Idx[0]; + in2 = Idx[32]; + in3 = Idx[64]; + in4 = Idx[96]; + in5 = Idx[128]; + + fi1 = zRe[in1]; + fi2 = zIm[in1]; + fo3 = zRe[in2]; + fo4 = zRe[in5]; + fo6 = zRe[in3]; + fo7 = zRe[in4]; + + fo5 = L_add( fo3, fo4 ); + fo8 = L_add( fo6, fo7 ); + fi3 = L_add( fo5, fo8 ); + fi4 = L_sub( fo6, fo7 ); + fi5 = Mpy_32_16_1( L_sub( fo5, fo8 ), FFT_15PONIT_WNK1 ); + fi6 = L_sub( fo3, fo4 ); + + fo3 = zIm[in2]; + fo4 = zIm[in5]; + fo6 = zIm[in3]; + fo7 = zIm[in4]; + + fo5 = L_add( fo3, fo4 ); + fo8 = L_add( fo6, fo7 ); + fi7 = L_sub( fo3, fo4 ); + fi8 = L_add( fo5, fo8 ); + fo1 = L_sub( fo6, fo7 ); + fo2 = Mpy_32_16_1( L_sub( fo5, fo8 ), FFT_15PONIT_WNK1 ); + + zRe[in1] = L_add( fi1, fi3 ); + zIm[in1] = L_add( fi2, fi8 ); + + fo3 = L_add( Mpy_32_16_1( fi7, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fo1, FFT_15PONIT_WNK3 ) ); + fo4 = L_sub( Mpy_32_16_1( fo1, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi7, FFT_15PONIT_WNK3 ) ); + fo7 = L_sub( fi1, L_shr( fi3, 2 ) ); + fo5 = L_add( fi5, fo7 ); + fo6 = L_sub( fo7, fi5 ); + + zRe[in2] = L_add( fo6, fo4 ); + zRe[in3] = L_add( fo5, fo3 ); + zRe[in4] = L_sub( fo5, fo3 ); + zRe[in5] = L_sub( fo6, fo4 ); + + fo3 = L_add( Mpy_32_16_1( fi6, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi4, FFT_15PONIT_WNK3 ) ); + fo4 = L_sub( Mpy_32_16_1( fi4, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi6, FFT_15PONIT_WNK3 ) ); + fo7 = L_sub( fi2, L_shr( fi8, 2 ) ); + fo5 = L_add( fo2, fo7 ); + fo6 = L_sub( fo7, fo2 ); + + zIm[in2] = L_sub( fo6, fo4 ); + zIm[in3] = L_sub( fo5, fo3 ); + zIm[in4] = L_add( fo3, fo5 ); + zIm[in5] = L_add( fo4, fo6 ); + + return; +} + +/*-----------------------------------------------------------------* + * fft64() + * 64-point FFT + *-----------------------------------------------------------------*/ + +static void fft64( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y, /* i/o: imaginary part of input and output data */ + const Word16 *Idx /* i : pointer of the address table */ +) +{ + Word16 i, id, jd; + Word32 z[128]; + FOR ( i = 0; i < 64; i++ ) + { + id = Idx[i]; + z[2 * i] = x[id]; + z[2 * i + 1] = y[id]; + } + + cdftForw( 128, z, Ip_fft64, w_fft64_fx ); + + FOR ( i = 0; i < 64; i++ ) + { + jd = Odx_fft64[i]; + id = Idx[jd]; + x[id] = z[2 * i]; + y[id] = z[2 * i + 1]; + } + + return; +} + + +/*-----------------------------------------------------------------* + * fft32_15() + * 32-point FFT called for 15 times + *-----------------------------------------------------------------*/ + +static void fft32_15( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y, /* i/o: imaginary part of input and output data */ + const Word16 *Idx /* i : pointer of the address table */ +) +{ + Word16 i, id, jd; + Word32 z[64]; + + FOR ( i = 0; i < 32; i++ ) + { + id = Idx[i]; + z[2 * i] = x[id]; + z[2 * i + 1] = y[id]; + } + + cdftForw( 64, z, Ip_fft32, w_fft32_fx ); + + FOR ( i = 0; i < 32; i++ ) + { + jd = Odx_fft32_15[i]; + id = Idx[jd]; + x[id] = z[2 * i]; + y[id] = z[2 * i + 1]; + } + + return; +} + +/*-----------------------------------------------------------------* + * fft32_5() + * 32-point FFT called for 5 times + *-----------------------------------------------------------------*/ + +static void fft32_5( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y, /* i/o: imaginary part of input and output data */ + const Word16 *Idx /* i : pointer of the address table */ +) +{ + Word16 i, id, jd; + Word32 z[64]; + + FOR ( i = 0; i < 32; i++ ) + { + id = Idx[i]; + z[2 * i] = x[id]; + z[2 * i + 1] = y[id]; + } + + cdftForw( 64, z, Ip_fft32, w_fft32_fx ); + + FOR ( i = 0; i < 32; i++ ) + { + jd = Odx_fft32_5[i]; + id = Idx[jd]; + x[id] = z[2 * i]; + y[id] = z[2 * i + 1]; + } + + return; +} + +/*-----------------------------------------------------------------* + * fft16() + * 16-point FFT + *-----------------------------------------------------------------*/ + +static void fft16( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y, /* i/o: imaginary part of input and output data */ + const Word16 *Idx /* i : pointer of the address table */ +) +{ + Word16 i, id, jd; + Word32 z[32]; + + FOR ( i = 0; i < 16; i++ ) + { + id = Idx[i]; + z[2 * i] = x[id]; + z[2 * i + 1] = y[id]; + } + + cdftForw( 32, z, Ip_fft16, w_fft16_fx ); + + FOR ( i = 0; i < 16; i++ ) + { + jd = Odx_fft16[i]; + id = Idx[jd]; + x[id] = z[2 * i]; + y[id] = z[2 * i + 1]; + } + + return; +} + +/*-----------------------------------------------------------------* + * fft8() + * 8-point FFT + *-----------------------------------------------------------------*/ + +static void fft8( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y, /* i/o: imaginary part of input and output data */ + const Word16 *Idx /* i : pointer of the address table */ +) +{ + Word16 i, id; + Word32 z[16]; + + FOR ( i = 0; i < 8; i++ ) + { + id = Idx[i]; + z[2 * i] = x[id]; + z[2 * i + 1] = y[id]; + } + + cdftForw( 16, z, Ip_fft8, w_fft8_fx ); + + FOR ( i = 0; i < 8; i++ ) + { + id = Idx[i]; + x[id] = z[2 * i]; + y[id] = z[2 * i + 1]; + } + + return; +} + +/*-----------------------------------------------------------------* + * fft8_5() + * 8-point FFT with shift 5 + *-----------------------------------------------------------------*/ + +static void fft8_5( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y, /* i/o: imaginary part of input and output data */ + const Word16 *Idx /* i : pointer of the address table */ +) +{ + Word16 i, id, jd; + Word32 z[16]; + + FOR ( i = 0; i < 8; i++ ) + { + id = Idx[i]; + z[2 * i] = x[id]; + z[2 * i + 1] = y[id]; + } + + cdftForw( 16, z, Ip_fft8, w_fft8_fx ); + + FOR ( i = 0; i < 8; i++ ) + { + jd = Odx_fft8_5[i]; + id = Idx[jd]; + x[id] = z[2 * i]; + y[id] = z[2 * i + 1]; + } + return; +} + +/*-----------------------------------------------------------------* + * fft5_8() + * 5-point FFT with shift 2 + *-----------------------------------------------------------------*/ + +static void fft5_8( + Word16 n1, /* i : length of data */ + Word32 *zRe, /* i/o: real part of input and output data */ + Word32 *zIm, /* i/o: imaginary part of input and output data */ + const Word16 *Idx /* i : pointer of the address table */ +) +{ + Word32 fi1, fi2, fi3, fi4, fi5, fi6, fi7, fi8; + Word32 fo1, fo2, fo3, fo4, fo5, fo6, fo7, fo8; + Word16 in1, in2, in3, in4, in5; + + in1 = Idx[0]; + in2 = Idx[n1]; + in3 = Idx[n1 * 2]; + in4 = Idx[n1 * 3]; + in5 = Idx[n1 * 4]; + + fi1 = zRe[in1]; + fi2 = zIm[in1]; + fo3 = zRe[in2]; + fo4 = zRe[in5]; + fo6 = zRe[in3]; + fo7 = zRe[in4]; + + fo5 = L_add( fo3, fo4 ); + fo8 = L_add( fo6, fo7 ); + fi3 = L_add( fo5, fo8 ); + fi4 = L_sub( fo6, fo7 ); + fi5 = Mpy_32_16_1( L_sub( fo5, fo8 ), FFT_15PONIT_WNK1 ); + fi6 = L_sub( fo3, fo4 ); + + fo3 = zIm[in2]; + fo4 = zIm[in5]; + fo6 = zIm[in3]; + fo7 = zIm[in4]; + + fo5 = L_add( fo3, fo4 ); + fo8 = L_add( fo6, fo7 ); + fi7 = L_sub( fo3, fo4 ); + fi8 = L_add( fo5, fo8 ); + fo1 = L_sub( fo6, fo7 ); + fo2 = Mpy_32_16_1( L_sub( fo5, fo8 ), FFT_15PONIT_WNK1 ); + + zRe[in1] = L_add( fi1, fi3 ); + zIm[in1] = L_add( fi2, fi8 ); + + fo3 = L_add( Mpy_32_16_1( fi7, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fo1, FFT_15PONIT_WNK3 ) ); + fo4 = L_sub( Mpy_32_16_1( fo1, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi7, FFT_15PONIT_WNK3 ) ); + fo7 = L_sub( fi1, L_shr( fi3, 2 ) ); + fo5 = L_add( fi5, fo7 ); + fo6 = L_sub( fo7, fi5 ); + + zRe[in2] = L_sub( fo6, fo4 ); + zRe[in3] = L_sub( fo5, fo3 ); + zRe[in5] = L_add( fo6, fo4 ); + zRe[in4] = L_add( fo5, fo3 ); + + fo3 = L_add( Mpy_32_16_1( fi6, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi4, FFT_15PONIT_WNK3 ) ); + fo4 = L_sub( Mpy_32_16_1( fi4, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi6, FFT_15PONIT_WNK3 ) ); + fo7 = L_sub( fi2, L_shr( fi8, 2 ) ); + fo5 = L_add( fo2, fo7 ); + fo6 = L_sub( fo7, fo2 ); + + zIm[in2] = L_add( fo4, fo6 ); + zIm[in3] = L_add( fo3, fo5 ); + zIm[in4] = L_sub( fo5, fo3 ); + zIm[in5] = L_sub( fo6, fo4 ); + + return; +} + +/*-----------------------------------------------------------------* + * fft4_5() + * 8-point FFT with shift 1 + *-----------------------------------------------------------------*/ + +static void fft4_5( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y, /* i/o: imaginary part of input and output data */ + const Word16 *Idx /* i : pointer of the address table */ +) +{ + Word16 i, id, jd; + Word32 z[8]; + + FOR ( i = 0; i < 4; i++ ) + { + id = Idx[i]; + z[2 * i] = x[id]; + z[2 * i + 1] = y[id]; + } + + cdftForw( 8, z, Ip_fft4, w_fft4_fx ); + + FOR ( i = 0; i < 4; i++ ) + { + jd = Odx_fft4_5[i]; + id = Idx[jd]; + x[id] = z[2 * i]; + y[id] = z[2 * i + 1]; + } + return; +} + +/*-----------------------------------------------------------------* + * fft5_4() + * 5-point FFT with shift 4 + *-----------------------------------------------------------------*/ + +static void fft5_4( + Word16 n1, + Word32 *zRe, + Word32 *zIm, + const Word16 *Idx ) +{ + Word32 fi1, fi2, fi3, fi4, fi5, fi6, fi7, fi8; + Word32 fo1, fo2, fo3, fo4, fo5, fo6, fo7, fo8; + Word16 in1, in2, in3, in4, in5; + + in1 = Idx[0]; + in2 = Idx[n1]; + in3 = Idx[n1 * 2]; + in4 = Idx[n1 * 3]; + in5 = Idx[n1 * 4]; + + fi1 = zRe[in1]; + fi2 = zIm[in1]; + fo3 = zRe[in2]; + fo4 = zRe[in5]; + fo6 = zRe[in3]; + fo7 = zRe[in4]; + + fo5 = L_add( fo3, fo4 ); + fo8 = L_add( fo6, fo7 ); + fi3 = L_add( fo5, fo8 ); + fi4 = L_sub( fo6, fo7 ); + fi5 = Mpy_32_16_1( L_sub( fo5, fo8 ), FFT_15PONIT_WNK1 ); + fi6 = L_sub( fo3, fo4 ); + + fo3 = zIm[in2]; + fo4 = zIm[in5]; + fo6 = zIm[in3]; + fo7 = zIm[in4]; + + fo5 = L_add( fo3, fo4 ); + fo8 = L_add( fo6, fo7 ); + fi7 = L_sub( fo3, fo4 ); + fi8 = L_add( fo5, fo8 ); + fo1 = L_sub( fo6, fo7 ); + fo2 = Mpy_32_16_1( L_sub( fo5, fo8 ), FFT_15PONIT_WNK1 ); + + zRe[in1] = L_add( fi1, fi3 ); + zIm[in1] = L_add( fi2, fi8 ); + + fo3 = L_add( Mpy_32_16_1( fi7, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fo1, FFT_15PONIT_WNK3 ) ); + fo4 = L_sub( Mpy_32_16_1( fo1, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi7, FFT_15PONIT_WNK3 ) ); + fo7 = L_sub( fi1, L_shr( fi3, 2 ) ); + fo5 = L_add( fi5, fo7 ); + fo6 = L_sub( fo7, fi5 ); + + zRe[in2] = L_sub( fo5, fo3 ); + zRe[in4] = L_sub( fo6, fo4 ); + zRe[in3] = L_add( fo6, fo4 ); + zRe[in5] = L_add( fo5, fo3 ); + + fo3 = L_add( Mpy_32_16_1( fi6, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi4, FFT_15PONIT_WNK3 ) ); + fo4 = L_sub( Mpy_32_16_1( fi4, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi6, FFT_15PONIT_WNK3 ) ); + fo7 = L_sub( fi2, L_shr( fi8, 2 ) ); + fo5 = L_add( fo2, fo7 ); + fo6 = L_sub( fo7, fo2 ); + + zIm[in2] = L_add( fo3, fo5 ); + zIm[in3] = L_sub( fo6, fo4 ); + zIm[in4] = L_add( fo4, fo6 ); + zIm[in5] = L_sub( fo5, fo3 ); + return; +} + + +/*-----------------------------------------------------------------* + * DoRTFT80_fx() + * a low complexity 2-dimensional DFT of 80 points + *-----------------------------------------------------------------*/ + +void DoRTFT80_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +) +{ + Word16 j; + + /* Applying 16-point FFT for 5 times based on the address table Idx_dortft80 */ + FOR ( j = 0; j < 5; j++ ) + { + fft16( x, y, Idx_dortft80 + 16 * j ); + } + + /* Applying 5-point FFT for 16 times based on the address table Idx_dortft80 */ + FOR ( j = 0; j < 16; j++ ) + { + fft5_shift1( 16, x, y, Idx_dortft80 + j ); + } + + return; +} + +/*-----------------------------------------------------------------* + * DoRTFT120_fx() + * a low complexity 2-dimensional DFT of 120 points + *-----------------------------------------------------------------*/ + +void DoRTFT120_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +) +{ + Word16 j; + + /* Applying 8-point FFT for 15 times based on the address table Idx_dortft120 */ + FOR ( j = 0; j < 15; j++ ) + { + fft8( x, y, Idx_dortft120 + 8 * j ); + } + + /* Applying 15-point FFT for 8 times based on the address table Idx_dortft120 */ + FOR ( j = 0; j < 8; j++ ) + { + fft15_shift2( 8, x, y, Idx_dortft120 + j ); + } + + return; +} + +/*-----------------------------------------------------------------* + * DoRTFT160_fx() + * a low complexity 2-dimensional DFT of 160 points + *-----------------------------------------------------------------*/ + +void DoRTFT160_fx( + Word32 x[], /* i/o: real part of input and output data */ + Word32 y[] /* i/o: imaginary part of input and output data */ +) +{ + Word16 j; + + /* Applying 32-point FFT for 5 times based on the address table Idx_dortft160 */ + FOR ( j = 0; j < 5; j++ ) + { + fft32_5( x, y, Idx_dortft160 + 32 * j ); + } + + /* Applying 5-point FFT for 32 times based on the address table Idx_dortft160 */ + FOR ( j = 0; j < 32; j++ ) + { + fft5_32( x, y, Idx_dortft160 + j ); + } + + return; +} + +/*-----------------------------------------------------------------* + * DoRTFT320_fx() + * a low complexity 2-dimensional DFT of 320 points + *-----------------------------------------------------------------*/ + +void DoRTFT320_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +) +{ + Word16 j; + + /* Applying 64-point FFT for 5 times based on the address table Idx_dortft160 */ + FOR ( j = 0; j < 5; j++ ) + { + fft64( x, y, Idx_dortft320 + 64 * j ); + } + + /* Applying 5-point FFT for 64 times based on the address table Idx_dortft160 */ + FOR ( j = 0; j < 64; j++ ) + { + fft5_shift4( 64, x, y, Idx_dortft320 + j ); + } + + return; +} + +/*-----------------------------------------------------------------* + * DoRTFT480_fx() + * a low complexity 2-dimensional DFT of 480 points + *-----------------------------------------------------------------*/ + +void DoRTFT480_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +) +{ + Word16 j; + + /* Applying 32-point FFT for 15 times based on the address table Idx_dortft160 */ + FOR ( j = 0; j < 15; j++ ) + { + fft32_15( x, y, Idx_dortft480 + 32 * j ); + } + + /* Applying 5-point FFT for 32 times based on the address table Idx_dortft160 */ + FOR ( j = 0; j < 32; j++ ) + { + fft15_shift8( 32, x, y, Idx_dortft480 + j ); + } + + return; +} + +/*-----------------------------------------------------------------* + * DoRTFT40_fx() + * a low complexity 2-dimensional DFT of 40 points + *-----------------------------------------------------------------*/ + +void DoRTFT40_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +) +{ + Word16 j; + /* Applying 8-point FFT for 5 times based on the address table Idx_dortft40 */ + FOR ( j = 0; j < 5; j++ ) + { + fft8_5( x, y, Idx_dortft40 + 8 * j ); + } + + /* Applying 5-point FFT for 8 times based on the address table Idx_dortft40 */ + FOR ( j = 0; j < 8; j++ ) + { + fft5_8( 8, x, y, Idx_dortft40 + j ); + } + + return; +} + +/*-----------------------------------------------------------------* + * DoRTFT20() + * a low complexity 2-dimensional DFT of 20 points + *-----------------------------------------------------------------*/ + +void DoRTFT20_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +) +{ + Word16 j; + + /* Applying 4-point FFT for 5 times based on the address table Idx_dortft20 */ + FOR ( j = 0; j < 5; j++ ) + { + fft4_5( x, y, Idx_dortft20 + 4 * j ); + } + + /* Applying 5-point FFT for 4 times based on the address table Idx_dortft20 */ + FOR ( j = 0; j < 4; j++ ) + { + fft5_4( 4, x, y, Idx_dortft20 + j ); + } + + return; +} + +/*-----------------------------------------------------------------* + * DoRTFT128_fx() + * FFT with 128 points + *-----------------------------------------------------------------*/ + +void DoRTFT128_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +) +{ + + Word16 i; + Word32 z[256]; + + FOR ( i = 0; i < 128; i++ ) + { + z[2 * i] = x[i]; + z[2 * i + 1] = y[i]; + } + + cdftForw( 256, z, Ip_fft128, w_fft128_fx ); + + x[0] = z[0]; + y[0] = z[1]; + FOR ( i = 1; i < 128; i++ ) + { + x[128 - i] = z[2 * i]; + y[128 - i] = z[2 * i + 1]; + } + + return; +} + +/*-----------------------------------------------------------------* + * cdftForw() + * Main fuction of Complex Discrete Fourier Transform + *-----------------------------------------------------------------*/ + +static void cdftForw( + Word16 n, /* i : data length of real and imag */ + Word32 *a, /* i/o: input/output data */ + const Word16 *ip, /* i : work area for bit reversal */ + const Word16 *w /* i : cos/sin table */ +) +{ + /* bit reversal */ + bitrv2_SR( n, ip + 2, a ); + + /* Do FFT */ + cftfsub( n, a, w ); +} + +/*-----------------------------------------------------------------* + * bitrv2_SR() + * Bit reversal + *-----------------------------------------------------------------*/ + +static void bitrv2_SR( + Word16 n, /* i : data length of real and imag */ + const Word16 *ip, /* i/o: work area for bit reversal */ + Word32 *a /* i/o: input/output data */ +) +{ + Word16 j, j1, k, k1, m, m2; + Word16 l; + Word32 xr, xi, yr, yi; + + IF (EQ_16(n, 64)) + { + m = 4; + l = -1; + } + ELSE IF (EQ_16(n, 256)) + { + m = 8; + l = -1; + } + ELSE IF (EQ_16(n, 16)) + { + m = 2; + l = -1; + } + ELSE + { + l = n; + m = 1; + + WHILE ( shl( m, 3 ) < l ) + { + l = shr(l, 1); + m = shl(m, 1); + } + l = sub(l, shl(m, 3)); + } + + m2 = shl(m, 1); + + IF (EQ_16(l, 0)) + { + FOR ( k = 0; k < m; k++ ) + { + FOR ( j = 0; j < k; j++ ) + { + j1 = add(shl(j, 1), ip[k]); + k1 = add(shl(k, 1), ip[j]); + xr = a[j1]; + xi = a[j1 + 1]; + yr = a[k1]; + yi = a[k1 + 1]; + a[j1] = yr; + a[j1 + 1] = yi; + a[k1] = xr; + a[k1 + 1] = xi; + j1 += m2; + k1 += 2 * m2; + xr = a[j1]; + xi = a[j1 + 1]; + yr = a[k1]; + yi = a[k1 + 1]; + a[j1] = yr; + a[j1 + 1] = yi; + a[k1] = xr; + a[k1 + 1] = xi; + j1 = add(j1, m2); + k1 = sub(k1, m2); + xr = a[j1]; + xi = a[j1 + 1]; + yr = a[k1]; + yi = a[k1 + 1]; + a[j1] = yr; + a[j1 + 1] = yi; + a[k1] = xr; + a[k1 + 1] = xi; + j1 = add(j1, m2); + k1 = add(k1, shl(m2, 1)); + xr = a[j1]; + xi = a[j1 + 1]; + yr = a[k1]; + yi = a[k1 + 1]; + a[j1] = yr; + a[j1 + 1] = yi; + a[k1] = xr; + a[k1 + 1] = xi; + } + + j1 = add(shl(k, 1), add(m2, ip[k])); + k1 = add(j1, m2); + xr = a[j1]; + xi = a[j1 + 1]; + yr = a[k1]; + yi = a[k1 + 1]; + a[j1] = yr; + a[j1 + 1] = yi; + a[k1] = xr; + a[k1 + 1] = xi; + } + } + ELSE + { + FOR ( k = 1; k < m; k++ ) + { + FOR ( j = 0; j < k; j++ ) + { + j1 = add(shl(j, 1), ip[k]); + k1 = add(shl(k, 1), ip[j]); + xr = a[j1]; + xi = a[j1 + 1]; + yr = a[k1]; + yi = a[k1 + 1]; + a[j1] = yr; + a[j1 + 1] = yi; + a[k1] = xr; + a[k1 + 1] = xi; + j1 = add(j1, m2); + k1 = add(k1, m2); + xr = a[j1]; + xi = a[j1 + 1]; + yr = a[k1]; + yi = a[k1 + 1]; + a[j1] = yr; + a[j1 + 1] = yi; + a[k1] = xr; + a[k1 + 1] = xi; + } + } + } + + return; +} + +/*-----------------------------------------------------------------* + * cftfsub() + * Complex Discrete Fourier Transform + *-----------------------------------------------------------------*/ + +static void cftfsub( + Word16 n, /* i : data length of real and imag */ + Word32 *a, /* i/o: input/output data */ + const Word16 *w /* i : cos/sin table */ +) +{ + Word16 j, j1, j2, j3, l; + Word32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + l = 2; + IF ( n > 8 ) + { + cft1st( n, a, w ); + + l = 8; + WHILE ( shl(l, 2 ) < n ) + { + cftmdl( n, l, a, w ); + l = shl(l, 2); + } + } + + IF (EQ_16(shl(l, 2 ), n)) + { + FOR ( j = 0; j < l; j += 2 ) + { + j1 = add(j, l); + j2 = add(j1, l); + j3 = add(j2, l); + x0r = L_add( a[j], a[j1] ); + x0i = L_add( a[j + 1], a[j1 + 1] ); + x1r = L_sub( a[j], a[j1] ); + x1i = L_sub( a[j + 1], a[j1 + 1] ); + x2r = L_add( a[j2], a[j3] ); + x2i = L_add( a[j2 + 1], a[j3 + 1] ); + x3r = L_sub( a[j2], a[j3] ); + x3i = L_sub( a[j2 + 1], a[j3 + 1] ); + a[j] = L_add( x0r, x2r ); + a[j + 1] = L_add( x0i, x2i ); + a[j2] = L_sub( x0r, x2r ); + a[j2 + 1] = L_sub( x0i, x2i ); + a[j1] = L_sub( x1r, x3i ); + a[j1 + 1] = L_add( x1i, x3r ); + a[j3] = L_add( x1r, x3i ); + a[j3 + 1] = L_sub( x1i, x3r ); + } + } + ELSE + { + FOR ( j = 0; j < l; j += 2 ) + { + j1 = add(j, l); + x0r = L_sub( a[j], a[j1] ); + x0i = L_sub( a[j + 1], a[j1 + 1] ); + a[j] = L_add( a[j], a[j1] ); + a[j + 1] = L_add( a[j + 1], a[j1 + 1] ); + a[j1] = x0r; + a[j1 + 1] = x0i; + } + } + + return; +} + +/*-----------------------------------------------------------------* + * cft1st() + * Subfunction of Complex Discrete Fourier Transform + *-----------------------------------------------------------------*/ + +static void cft1st( + Word16 n, /* i : data length of real and imag */ + Word32 *a, /* i/o: input/output data */ + const Word16 *w /* i : cos/sin table */ +) +{ + Word16 j, k1, k2; + Word16 wk1r, wk1i, wk2r, wk2i, wk3r, wk3i, wtmp; + Word32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + x0r = L_add( a[0], a[2] ); + x0i = L_add( a[1], a[3] ); + x1r = L_sub( a[0], a[2] ); + x1i = L_sub( a[1], a[3] ); + x2r = L_add( a[4], a[6] ); + x2i = L_add( a[5], a[7] ); + x3r = L_sub( a[4], a[6] ); + x3i = L_sub( a[5], a[7] ); + a[0] = L_add( x0r, x2r ); + a[1] = L_add( x0i, x2i ); + a[4] = L_sub( x0r, x2r ); + a[5] = L_sub( x0i, x2i ); + a[2] = L_sub( x1r, x3i ); + a[3] = L_add( x1i, x3r ); + a[6] = L_add( x1r, x3i ); + a[7] = L_sub( x1i, x3r ); + wk1r = w[2]; + x0r = L_add( a[8], a[10] ); + x0i = L_add( a[9], a[11] ); + x1r = L_sub( a[8], a[10] ); + x1i = L_sub( a[9], a[11] ); + x2r = L_add( a[12], a[14] ); + x2i = L_add( a[13], a[15] ); + x3r = L_sub( a[12], a[14] ); + x3i = L_sub( a[13], a[15] ); + a[8] = L_add( x0r, x2r ); + a[9] = L_add( x0i, x2i ); + a[12] = L_sub( x2i, x0i ); + a[13] = L_sub( x0r, x2r ); + x0r = L_sub( x1r, x3i ); + x0i = L_add( x1i, x3r ); + a[10] = Mpy_32_16_1( L_sub( x0r, x0i ), wk1r ); + a[11] = Mpy_32_16_1( L_add( x0r, x0i ), wk1r ); + x0r = L_add( x3i, x1r ); + x0i = L_sub( x3r, x1i ); + a[14] = Mpy_32_16_1( L_sub( x0i, x0r ), wk1r ); + a[15] = Mpy_32_16_1( L_add( x0i, x0r ), wk1r ); + k1 = 0; + + FOR ( j = 16; j < n; j += 16 ) + { + k1 = add(k1, 2); + k2 = shl(k1, 1); + wk2r = w[k1]; + wk2i = w[k1 + 1]; + wk1r = w[k2]; + wk1i = w[k2 + 1]; + wtmp = mult_r( wk2i, wk1i ); + wk3r = sub( wk1r, wtmp ); + wk3r = sub( wk3r, wtmp ); + wtmp = mult_r( wk2i, wk1r ); + wk3i = sub( wtmp, wk1i ); + wk3i = add( wtmp, wk3i ); + x0r = L_add( a[j], a[j + 2] ); + x0i = L_add( a[j + 1], a[j + 3] ); + x1r = L_sub( a[j], a[j + 2] ); + x1i = L_sub( a[j + 1], a[j + 3] ); + x2r = L_add( a[j + 4], a[j + 6] ); + x2i = L_add( a[j + 5], a[j + 7] ); + x3r = L_sub( a[j + 4], a[j + 6] ); + x3i = L_sub( a[j + 5], a[j + 7] ); + a[j] = L_add( x0r, x2r ); + a[j + 1] = L_add( x0i, x2i ); + x0r = L_sub( x0r, x2r ); + x0i = L_sub( x0i, x2i ); + a[j + 4] = L_sub( Mpy_32_16_1( x0r, wk2r ), Mpy_32_16_1( x0i, wk2i ) ); + a[j + 5] = L_add( Mpy_32_16_1( x0i, wk2r ), Mpy_32_16_1( x0r, wk2i ) ); + x0r = L_sub( x1r, x3i ); + x0i = L_add( x1i, x3r ); + a[j + 2] = L_sub( Mpy_32_16_1( x0r, wk1r ), Mpy_32_16_1( x0i, wk1i ) ); + a[j + 3] = L_add( Mpy_32_16_1( x0i, wk1r ), Mpy_32_16_1( x0r, wk1i ) ); + x0r = L_add( x1r, x3i ); + x0i = L_sub( x1i, x3r ); + a[j + 6] = L_sub( Mpy_32_16_1( x0r, wk3r ), Mpy_32_16_1( x0i, wk3i ) ); + a[j + 7] = L_add( Mpy_32_16_1( x0i, wk3r ), Mpy_32_16_1( x0r, wk3i ) ); + wk1r = w[k2 + 2]; + wk1i = w[k2 + 3]; + wtmp = mult_r( wk2r, wk1i ); + wk3r = sub( wk1r, wtmp ); + wk3r = sub( wk3r, wtmp ); + wtmp = mult_r( wk2r, wk1r ); + wk3i = sub( wtmp, wk1i ); + wk3i = add( wtmp, wk3i ); + x0r = L_add( a[j + 8], a[j + 10] ); + x0i = L_add( a[j + 9], a[j + 11] ); + x1r = L_sub( a[j + 8], a[j + 10] ); + x1i = L_sub( a[j + 9], a[j + 11] ); + x2r = L_add( a[j + 12], a[j + 14] ); + x2i = L_add( a[j + 13], a[j + 15] ); + x3r = L_sub( a[j + 12], a[j + 14] ); + x3i = L_sub( a[j + 13], a[j + 15] ); + a[j + 8] = L_add( x0r, x2r ); + a[j + 9] = L_add( x0i, x2i ); + x0r = L_sub( x0r, x2r ); + x0i = L_sub( x0i, x2i ); + a[j + 12] = L_negate(L_add( Mpy_32_16_1( x0r, wk2i ), Mpy_32_16_1( x0i, wk2r ) )); + a[j + 13] = L_sub( Mpy_32_16_1( x0r, wk2r ), Mpy_32_16_1( x0i, wk2i ) ); + x0r = L_sub( x1r, x3i ); + x0i = L_add( x1i, x3r ); + a[j + 10] = L_sub( Mpy_32_16_1( x0r, wk1r ), Mpy_32_16_1( x0i, wk1i ) ); + a[j + 11] = L_add( Mpy_32_16_1( x0i, wk1r ), Mpy_32_16_1( x0r, wk1i ) ); + x0r = L_add( x1r, x3i ); + x0i = L_sub( x1i, x3r ); + a[j + 14] = L_sub( Mpy_32_16_1( x0r, wk3r ), Mpy_32_16_1( x0i, wk3i ) ); + a[j + 15] = L_add( Mpy_32_16_1( x0i, wk3r ), Mpy_32_16_1( x0r, wk3i ) ); + } + + return; +} + +/*-----------------------------------------------------------------* + * cftmdl() + * Subfunction of Complex Discrete Fourier Transform + *-----------------------------------------------------------------*/ + +static void cftmdl( + Word16 n, /* i : data length of real and imag */ + Word16 l, /* i : initial shift for processing */ + Word32 *a, /* i/o: input/output data */ + const Word16 *w /* i : cos/sin table */ +) +{ + Word16 j, j1, j2, j3, k, k1, k2, m, m2; + Word16 wk1r, wk1i, wk2r, wk2i, wk3r, wk3i, wtmp; + Word32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + m = shl(l, 2); + FOR ( j = 0; j < l; j += 2 ) + { + j1 = add(j, l); + j2 = add(j1, l); + j3 = add(j2, l); + x0r = L_add( a[j], a[j1] ); + x0i = L_add( a[j + 1], a[j1 + 1] ); + x1r = L_sub( a[j], a[j1] ); + x1i = L_sub( a[j + 1], a[j1 + 1] ); + x2r = L_add( a[j2], a[j3] ); + x2i = L_add( a[j2 + 1], a[j3 + 1] ); + x3r = L_sub( a[j2], a[j3] ); + x3i = L_sub( a[j2 + 1], a[j3 + 1] ); + a[j] = L_add( x0r, x2r ); + a[j + 1] = L_add( x0i, x2i ); + a[j2] = L_sub( x0r, x2r ); + a[j2 + 1] = L_sub( x0i, x2i ); + a[j1] = L_sub( x1r, x3i ); + a[j1 + 1] = L_add( x1i, x3r ); + a[j3] = L_add( x1r, x3i ); + a[j3 + 1] = L_sub( x1i, x3r ); + } + + wk1r = w[2]; + FOR ( j = m; j < l + m; j += 2 ) + { + j1 = add(j, l); + j2 = add(j1, l); + j3 = add(j2, l); + x0r = L_add( a[j], a[j1] ); + x0i = L_add( a[j + 1], a[j1 + 1] ); + x1r = L_sub( a[j], a[j1] ); + x1i = L_sub( a[j + 1], a[j1 + 1] ); + x2r = L_add( a[j2], a[j3] ); + x2i = L_add( a[j2 + 1], a[j3 + 1] ); + x3r = L_sub( a[j2], a[j3] ); + x3i = L_sub( a[j2 + 1], a[j3 + 1] ); + a[j] = L_add( x0r, x2r ); + a[j + 1] = L_add( x0i, x2i ); + a[j2] = L_sub( x2i, x0i ); + a[j2 + 1] = L_sub( x0r, x2r ); + x0r = L_sub( x1r, x3i ); + x0i = L_add( x1i, x3r ); + a[j1] = Mpy_32_16_1( L_sub( x0r, x0i ), wk1r ); + a[j1 + 1] = Mpy_32_16_1( L_add( x0r, x0i ), wk1r ); + x0r = L_add( x3i, x1r ); + x0i = L_sub( x3r, x1i ); + a[j3] = Mpy_32_16_1( L_sub( x0i, x0r ), wk1r ); + a[j3 + 1] = Mpy_32_16_1( L_add( x0i, x0r ), wk1r ); + } + + k1 = 0; + m2 = shl(m, 1); + FOR ( k = m2; k < n; k += m2 ) + { + k1 = add(k1, 2); + k2 = shl(k1, 1); + wk2r = w[k1]; + wk2i = w[k1 + 1]; + wk1r = w[k2]; + wk1i = w[k2 + 1]; + wtmp = mult_r( wk2i, wk1i ); + wk3r = sub( wk1r, wtmp ); + wk3r = sub( wk3r, wtmp ); + wtmp = mult_r( wk2i, wk1r ); + wk3i = sub( wtmp, wk1i ); + wk3i = add( wtmp, wk3i ); + FOR ( j = k; j < l + k; j += 2 ) + { + j1 = add(j, l); + j2 = add(j1, l); + j3 = add(j2, l); + x0r = L_add( a[j], a[j1] ); + x0i = L_add( a[j + 1], a[j1 + 1] ); + x1r = L_sub( a[j], a[j1] ); + x1i = L_sub( a[j + 1], a[j1 + 1] ); + x2r = L_add( a[j2], a[j3] ); + x2i = L_add( a[j2 + 1], a[j3 + 1] ); + x3r = L_sub( a[j2], a[j3] ); + x3i = L_sub( a[j2 + 1], a[j3 + 1] ); + a[j] = L_add( x0r, x2r ); + a[j + 1] = L_add( x0i, x2i ); + x0r = L_sub( x0r, x2r ); + x0i = L_sub( x0i, x2i ); + a[j2] = L_sub( Mpy_32_16_1( x0r, wk2r ), Mpy_32_16_1( x0i, wk2i ) ); + a[j2 + 1] = L_add( Mpy_32_16_1( x0i, wk2r ), Mpy_32_16_1( x0r, wk2i ) ); + x0r = L_sub( x1r, x3i ); + x0i = L_add( x1i, x3r ); + a[j1] = L_sub( Mpy_32_16_1( x0r, wk1r ), Mpy_32_16_1( x0i, wk1i ) ); + a[j1 + 1] = L_add( Mpy_32_16_1( x0i, wk1r ), Mpy_32_16_1( x0r, wk1i ) ); + x0r = L_add( x1r, x3i ); + x0i = L_sub( x1i, x3r ); + a[j3] = L_sub( Mpy_32_16_1( x0r, wk3r ), Mpy_32_16_1( x0i, wk3i ) ); + a[j3 + 1] = L_add( Mpy_32_16_1( x0i, wk3r ), Mpy_32_16_1( x0r, wk3i ) ); + } + + wk1r = w[k2 + 2]; + wk1i = w[k2 + 3]; + wtmp = mult_r( wk2r, wk1i ); + wk3r = sub( wk1r, wtmp ); + wk3r = sub( wk3r, wtmp ); + wtmp = mult_r( wk2r, wk1r ); + wk3i = sub( wtmp, wk1i ); + wk3i = add( wtmp, wk3i ); + FOR ( j = k + m; j < l + ( k + m ); j += 2 ) + { + j1 = add(j, l); + j2 = add(j1, l); + j3 = add(j2, l); + x0r = L_add( a[j], a[j1] ); + x0i = L_add( a[j + 1], a[j1 + 1] ); + x1r = L_sub( a[j], a[j1] ); + x1i = L_sub( a[j + 1], a[j1 + 1] ); + x2r = L_add( a[j2], a[j3] ); + x2i = L_add( a[j2 + 1], a[j3 + 1] ); + x3r = L_sub( a[j2], a[j3] ); + x3i = L_sub( a[j2 + 1], a[j3 + 1] ); + a[j] = L_add( x0r, x2r ); + a[j + 1] = L_add( x0i, x2i ); + x0r = L_sub( x0r, x2r ); + x0i = L_sub( x0i, x2i ); + a[j2] = L_negate(L_add( Mpy_32_16_1( x0r, wk2i ), Mpy_32_16_1( x0i, wk2r ) )); + a[j2 + 1] = L_sub( Mpy_32_16_1( x0r, wk2r ), Mpy_32_16_1( x0i, wk2i ) ); + x0r = L_sub( x1r, x3i ); + x0i = L_add( x1i, x3r ); + a[j1] = L_sub( Mpy_32_16_1( x0r, wk1r ), Mpy_32_16_1( x0i, wk1i ) ); + a[j1 + 1] = L_add( Mpy_32_16_1( x0i, wk1r ), Mpy_32_16_1( x0r, wk1i ) ); + x0r = L_add( x1r, x3i ); + x0i = L_sub( x1i, x3r ); + a[j3] = L_sub( Mpy_32_16_1( x0r, wk3r ), Mpy_32_16_1( x0i, wk3i ) ); + a[j3 + 1] = L_add( Mpy_32_16_1( x0i, wk3r ), Mpy_32_16_1( x0r, wk3i ) ); + } + } + + return; +} + +static void cftbsub( + Word16 n, + Word32 *a, + const Word16 *w /* i : cos/sin table */ +) +{ + Word16 j, j1, j2, j3, l; + Word32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; + + l = 2; + IF ( n > 8 ) + { + cft1st( n, a, w ); + l = 8; + + WHILE ( shl(l, 2) < n ) + { + cftmdl( n, l, a, w ); + l = shl(l, 2); + } + } + + IF (EQ_16(shl(l, 2), n)) + { + FOR ( j = 0; j < l; j += 2 ) + { + j1 = add(j, l); + j2 = add(j1, l); + j3 = add(j2, l); + x0r = L_add( a[j], a[j1] ); + x0i = L_negate(L_add( a[j + 1], a[j1 + 1] )); + x1r = L_sub( a[j], a[j1] ); + x1i = L_sub( a[j1 + 1], a[j + 1] ); + x2r = L_add( a[j2], a[j3] ); + x2i = L_add( a[j2 + 1], a[j3 + 1] ); + x3r = L_sub( a[j2], a[j3] ); + x3i = L_sub( a[j2 + 1], a[j3 + 1] ); + a[j] = L_add( x0r, x2r ); + a[j + 1] = L_sub( x0i, x2i ); + a[j2] = L_sub( x0r, x2r ); + a[j2 + 1] = L_add( x0i, x2i ); + a[j1] = L_sub( x1r, x3i ); + a[j1 + 1] = L_sub( x1i, x3r ); + a[j3] = L_add( x1r, x3i ); + a[j3 + 1] = L_add( x1i, x3r ); + } + } + ELSE + { + FOR ( j = 0; j < l; j += 2 ) + { + j1 = add(j, l); + x0r = L_sub( a[j], a[j1] ); + x0i = L_sub( a[j1 + 1], a[j + 1] ); + a[j] = L_add( a[j], a[j1] ); + a[j + 1] = L_negate(L_add( a[j + 1], a[j1 + 1] )); + a[j1] = x0r; + a[j1 + 1] = x0i; + } + } + + return; +} + +static void rftfsub( + Word16 n, + Word32 *a, + Word16 nc, + const Word16 *c ) +{ + Word16 j, k, kk, ks, m; + Word16 wkr, wki; + Word32 xr, xi, yr, yi; + + m = shr(n, 1); + ks = 2 * nc / m; + kk = 0; + FOR ( j = 2; j < m; j += 2 ) + { + k = sub(n, j); + kk = add(kk, ks); + wkr = sub((Word16)0x4000, c[nc - kk]); + wki = c[kk]; + xr = L_sub(a[j], a[k]); + xi = L_add(a[j + 1], a[k + 1]); + yr = L_sub(Mpy_32_16_1(xr, wkr), Mpy_32_16_1(xi, wki)); + yi = L_add(Mpy_32_16_1(xi, wkr), Mpy_32_16_1(xr, wki)); + a[j] = L_sub(a[j], yr); + a[j + 1] = L_sub(a[j + 1], yi); + a[k] = L_add(a[k], yr); + a[k + 1] = L_sub(a[k + 1], yi); + } + + return; +} + + +static void rftbsub( + Word16 n, + Word32 *a, + Word16 nc, + const Word16 *c ) +{ + Word16 j, k, kk, ks, m; + Word16 wkr, wki; + Word32 xr, xi, yr, yi; + + a[1] = L_negate(a[1]); + m = n >> 1; + ks = 2 * nc / m; + kk = 0; + FOR ( j = 2; j < m; j += 2 ) + { + k = n - j; + kk += ks; + wkr = sub((Word16)0x4000, c[nc - kk]); + wki = c[kk]; + xr = L_sub(a[j], a[k]); + xi = L_add(a[j + 1], a[k + 1]); + yr = L_add(Mpy_32_16_1(xr, wkr), Mpy_32_16_1(xi, wki)); + yi = L_sub(Mpy_32_16_1(xi, wkr), Mpy_32_16_1(xr, wki)); + a[j] = L_sub(a[j], yr); + a[j + 1] = L_add(yi, a[j + 1]); + a[k] = L_add(a[k], yr); + a[k + 1] = L_sub(yi, a[k + 1]); + } + a[m + 1] = L_negate(a[m + 1]); + + return; +} + + +static void dctsub( + Word16 n, + Word32 *a, + Word16 nc, + const Word16 *c ) +{ + Word16 j, k, kk, ks, m; + Word16 wkr, wki; + Word32 xr; + + m = n >> 1; + ks = nc / n; + kk = 0; + FOR ( j = 1; j < m; j++ ) + { + k = n - j; + kk += ks; + wkr = sub(c[kk], c[nc - kk]); + wki = add(c[kk], c[nc - kk]); + xr = L_sub(Mpy_32_16_1(a[j], wki), Mpy_32_16_1(a[k], wkr)); + a[j] = L_add(Mpy_32_16_1(a[j], wkr), Mpy_32_16_1(a[k], wki)); + a[k] = xr; + } + a[m] = Mpy_32_16_1(a[m], c[0]); + + return; +} + +/*-----------------------------------------------------------------* + * edct2_fx() + * + * Transformation of the signal to DCT domain + * OR Inverse EDCT-II for short frames + *-----------------------------------------------------------------*/ + +void edct2_fx( + const Word16 n, + const Word16 isgn, + Word32 *in, + Word32 *a, + const Word16 *ip, + const Word16 *w ) +{ + Word16 j, nw, nc; + Word32 xr; + + Copy32(in, a, n); + + nw = ip[0]; + IF ( n > ( nw << 2 ) ) + { + nw = n >> 2; + } + + nc = ip[1]; + IF ( n > nc ) + { + nc = n; + } + + IF ( isgn < 0 ) + { + xr = a[n - 1]; + FOR ( j = n - 2; j >= 2; j -= 2 ) + { + a[j + 1] = L_sub(a[j], a[j - 1]); + a[j] = L_add(a[j], a[j - 1]); + } + a[1] = L_sub(a[0], xr); + a[0] = L_add(a[0], xr); + + IF ( n > 4 ) + { + rftbsub( n, a, nc, w + nw ); + bitrv2_SR( n, ip + 2, a ); + cftbsub( n, a, w ); + } + ELSE IF (EQ_16(n, 4)) + { + cftfsub( n, a, w ); + } + } + + IF ( isgn >= 0 ) + { + a[0] = L_shr(a[0], 1); + } + + dctsub( n, a, nc, w + nw ); + + IF ( isgn >= 0 ) + { + IF ( n > 4 ) + { + bitrv2_SR( n, ip + 2, a ); + cftfsub( n, a, w ); + rftfsub( n, a, nc, w + nw ); + } + ELSE IF (EQ_16(n, 4)) + { + cftfsub( n, a, w ); + } + xr = L_sub(a[0], a[1]); + a[0] = L_add(a[0], a[1]); + FOR ( j = 2; j < n; j += 2 ) + { + a[j - 1] = L_sub(a[j], a[j + 1]); + a[j] = L_add(a[j], a[j + 1]); + } + a[n - 1] = xr; + + FOR ( j = 0; j < n; j++ ) + { + a[j] = L_shr(a[j], 5); + } + } +} + +void DoRTFTn_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y, /* i/o: imaginary part of input and output data */ + const Word16 n /* i : size of the FFT up to 1024 */ +) +{ + + Word16 i; + Word32 z[2048]; + + FOR ( i = 0; i < n; i++ ) + { + z[2 * i] = x[i]; + z[2 * i + 1] = y[i]; + } + + SWITCH ( n ) + { + case ( 16 ): + cdftForw( 2 * n, z, Ip_fft16, w_fft16_fx ); + BREAK; + case ( 32 ): + cdftForw( 2 * n, z, Ip_fft32, w_fft32_fx ); + BREAK; + case ( 64 ): + cdftForw( 2 * n, z, Ip_fft64, w_fft64_fx ); + BREAK; + case ( 128 ): + cdftForw( 2 * n, z, Ip_fft128, w_fft128_fx ); + BREAK; + case ( 256 ): + cdftForw( 2 * n, z, Ip_fft256, w_fft256_fx ); + BREAK; + case ( 512 ): + cdftForw( 2 * n, z, Ip_fft512, w_fft512_fx ); + BREAK; + default: + assert( 0 ); + } + + x[0] = z[0]; + y[0] = z[1]; + FOR ( i = 1; i < n; i++ ) + { + x[n - i] = z[2 * i]; + y[n - i] = z[2 * i + 1]; + } + + return; +} + +static void butterfly( + const Word32 a, + const Word32 b, + Word32 *aPlusb, + Word32 *aMinusb ) +{ + *aPlusb = L_add( a, b ); + *aMinusb = L_sub( a, b ); + + return; +} + +static void fft2( + Word32 *pInOut ) +{ + /* FFT MATRIX: + 1.0000 1.0000 + 1.0000 -1.0000 + */ + Word32 re1, im1; + Word32 re2, im2; + + re1 = pInOut[0]; + im1 = pInOut[1]; + re2 = pInOut[2]; + im2 = pInOut[3]; + pInOut[0] = L_add( re1, re2 ); + pInOut[1] = L_add( im1, im2 ); + + pInOut[2] = L_sub( re1, re2 ); + pInOut[3] = L_sub( im1, im2 ); + + return; +} + +static const Word16 C31 = 0x4000; /*0.5f in Q15 cos(PI/3); sin(2*PI/3) */ +static const Word16 C32 = 0x6ED9; /*0.866025403784439f in Q15 cos(PI/3); sin(2*PI/3) */ + +static void fft3_2( Word32 *pInOut ) +{ + Word32 re1, im1; + Word32 re2, im2; + Word32 re3, im3; + + Word32 tmp1, tmp2; + Word32 tmp3, tmp4; + + re1 = pInOut[0]; + im1 = pInOut[1]; + re2 = pInOut[2]; + im2 = pInOut[3]; + re3 = pInOut[4]; + im3 = pInOut[5]; + + /* FFT MATRIX: + 1.0000 1.0000 1.0000 + C31 C32 + 1.0000 -0.5000 - 0.8660i -0.5000 + 0.8660i + 1.0000 -0.5000 + 0.8660i -0.5000 - 0.8660i + */ + tmp1 = L_add( re2, re3 ); + tmp3 = L_add( im2, im3 ); + tmp2 = L_sub( re2, re3 ); + tmp4 = L_sub( im2, im3 ); + pInOut[0] = L_add( re1, tmp1 ); + pInOut[1] = L_add( im1, tmp3 ); + pInOut[2] = L_sub( re1, L_sub( Mpy_32_16_1( tmp1, C31 ), Mpy_32_16_1( tmp4, C32 ) ) ); + pInOut[4] = L_sub( re1, L_add( Mpy_32_16_1( tmp1, C31 ), Mpy_32_16_1( tmp4, C32 ) ) ); + + pInOut[3] = L_sub( im1, L_add( Mpy_32_16_1( tmp2, C32 ), Mpy_32_16_1( tmp3, C31 ) ) ); + pInOut[5] = L_add( im1, L_sub( Mpy_32_16_1( tmp2, C32 ), Mpy_32_16_1( tmp3, C31 ) ) ); +} + + +static void fft4( + Word32 *pInOut ) +{ + Word32 re1, im1; + Word32 re2, im2; + Word32 re3, im3; + Word32 re4, im4; + + Word32 tmp1, tmp2; + Word32 tmp3, tmp4; + Word32 tmp5, tmp6; + Word32 tmp7, tmp8; + + re1 = pInOut[0]; + im1 = pInOut[1]; + re2 = pInOut[2]; + im2 = pInOut[3]; + re3 = pInOut[4]; + im3 = pInOut[5]; + re4 = pInOut[6]; + im4 = pInOut[7]; + + /* + 1.0000 1.0000 1.0000 1.0000 + 1.0000 -1.0000i -1.0000 1.0000i + 1.0000 -1.0000 1.0000 -1.0000 + 1.0000 1.0000i -1.0000 -1.0000i + */ + tmp1 = L_add( re1, re3 ); + tmp3 = L_add( re2, re4 ); + tmp5 = L_add( im1, im3 ); + tmp7 = L_add( im2, im4 ); + pInOut[0] = L_add( tmp1, tmp3 ); + pInOut[4] = L_sub( tmp1, tmp3 ); + + pInOut[1] = L_add( tmp5, tmp7 ); + pInOut[5] = L_sub( tmp5, tmp7 ); + tmp2 = L_sub( re1, re3 ); + tmp4 = L_sub( re2, re4 ); + tmp6 = L_sub( im1, im3 ); + tmp8 = L_sub( im2, im4 ); + pInOut[2] = L_add( tmp2, tmp8 ); + pInOut[6] = L_sub( tmp2, tmp8 ); + + pInOut[3] = L_sub( tmp6, tmp4 ); + pInOut[7] = L_add( tmp4, tmp6 ); + + return; +} + +static const Word16 C51 = 0x278D; /* 0.309016994374947f cos(2*PI/5); */ +static const Word16 C52 = 0x79bc; /* 0.951056516295154f sin(2*PI/5); */ +static const Word16 C53 = 0x678D; /* 0.809016994374947f cos( PI/5); */ +static const Word16 C54 = 0x4B3D; /* 0.587785252292473f sin( PI/5); */ + +static void fft5( + Word32 *pInOut ) +{ + Word32 re1, im1; + Word32 re2, im2; + Word32 re3, im3; + Word32 re4, im4; + Word32 re5, im5; + + Word32 tmp1, tmp2; + Word32 tmp3, tmp4; + Word32 tmp5, tmp6; + Word32 tmp7, tmp8; + + + re1 = pInOut[0]; + im1 = pInOut[1]; + re2 = pInOut[2]; + im2 = pInOut[3]; + re3 = pInOut[4]; + im3 = pInOut[5]; + re4 = pInOut[6]; + im4 = pInOut[7]; + re5 = pInOut[8]; + im5 = pInOut[9]; + + /* + 1.0000 1.0000 1.0000 1.0000 1.0000 + C51 C52 C53 C54 + 1.0000 0.3090 - 0.9511i -0.8090 - 0.5878i -0.8090 + 0.5878i 0.3090 + 0.9511i + 1.0000 -0.8090 - 0.5878i 0.3090 + 0.9511i 0.3090 - 0.9511i -0.8090 + 0.5878i + 1.0000 -0.8090 + 0.5878i 0.3090 - 0.9511i 0.3090 + 0.9511i -0.8090 - 0.5878i + 1.0000 0.3090 + 0.9511i -0.8090 + 0.5878i -0.8090 - 0.5878i 0.3090 - 0.9511i + */ + tmp1 = L_add( re2, re5 ); + tmp2 = L_sub( re2, re5 ); + tmp3 = L_add( im2, im5 ); + tmp4 = L_sub( im2, im5 ); + tmp5 = L_add( re3, re4 ); + tmp6 = L_sub( re3, re4 ); + tmp7 = L_add( im3, im4 ); + tmp8 = L_sub( im3, im4 ); + + + pInOut[0] = L_add( re1, L_add( tmp1, tmp5 ) ); + pInOut[1] = L_add( im1, L_add( tmp3, tmp7 ) ); + + pInOut[2] = re1 + Mpy_32_16_1( tmp1, C51 ) - Mpy_32_16_1( tmp5, C53 ) + Mpy_32_16_1( tmp4, C52 ) + Mpy_32_16_1( tmp8, C54 ); + pInOut[8] = re1 + Mpy_32_16_1( tmp1, C51 ) - Mpy_32_16_1( tmp5, C53 ) - Mpy_32_16_1( tmp4, C52 ) - Mpy_32_16_1( tmp8, C54 ); + pInOut[3] = im1 - Mpy_32_16_1( tmp2, C52 ) - Mpy_32_16_1( tmp6, C54 ) + Mpy_32_16_1( tmp3, C51 ) - Mpy_32_16_1( tmp7, C53 ); + pInOut[9] = im1 + Mpy_32_16_1( tmp2, C52 ) + Mpy_32_16_1( tmp6, C54 ) + Mpy_32_16_1( tmp3, C51 ) - Mpy_32_16_1( tmp7, C53 ); + pInOut[4] = re1 - Mpy_32_16_1( tmp1, C53 ) + Mpy_32_16_1( tmp5, C51 ) + Mpy_32_16_1( tmp4, C54 ) - Mpy_32_16_1( tmp8, C52 ); + pInOut[6] = re1 - Mpy_32_16_1( tmp1, C53 ) + Mpy_32_16_1( tmp5, C51 ) - Mpy_32_16_1( tmp4, C54 ) + Mpy_32_16_1( tmp8, C52 ); + pInOut[5] = im1 - Mpy_32_16_1( tmp2, C54 ) + Mpy_32_16_1( tmp6, C52 ) - Mpy_32_16_1( tmp3, C53 ) + Mpy_32_16_1( tmp7, C51 ); + pInOut[7] = im1 + Mpy_32_16_1( tmp2, C54 ) - Mpy_32_16_1( tmp6, C52 ) - Mpy_32_16_1( tmp3, C53 ) + Mpy_32_16_1( tmp7, C51 ); + + return; +} + +static const Word16 C81 = 0x5a82; /* 0.707106781186548f cos(PI/4); */ + +static void fft8_2( + Word32 *pInOut ) +{ + Word32 re0, im0, re4, im4; + + Word32 re1_7p, re1_7m; + Word32 im1_7p, im1_7m; + Word32 re2_6p, re2_6m; + Word32 im2_6p, im2_6m; + Word32 re3_5p, re3_5m; + Word32 im3_5p, im3_5m; + + re0 = pInOut[0]; + im0 = pInOut[1]; + re4 = pInOut[8]; + im4 = pInOut[9]; + butterfly( pInOut[1 * 2], pInOut[7 * 2], &re1_7p, &re1_7m ); + butterfly( pInOut[1 * 2 + 1], pInOut[7 * 2 + 1], &im1_7p, &im1_7m ); + butterfly( pInOut[2 * 2], pInOut[6 * 2], &re2_6p, &re2_6m ); + butterfly( pInOut[2 * 2 + 1], pInOut[6 * 2 + 1], &im2_6p, &im2_6m ); + butterfly( pInOut[3 * 2], pInOut[5 * 2], &re3_5p, &re3_5m ); + butterfly( pInOut[3 * 2 + 1], pInOut[5 * 2 + 1], &im3_5p, &im3_5m ); + + /* + 0: 1 + 0i 1 + 0i 1 + 0i 1 + 0i 1 + 0i 1 + 0i 1 + 0i 1 + 0i + 1: 1 + 0i C81 - C81i 0 - 1i -C81 - C81i -1 - 0i -C81 + C81i - 0 + 1i C81 + C81i + 2: 1 + 0i 0 - 1i -1 - 0i - 0 + 1i 1 + 0i 0 - 1i - 1 - 0i - 0 + 1i + 3: 1 + 0i -C81 - C81i -0 + 1i C81 - C81i -1 - 0i C81 + C81i 0 - 1i -C81 + C81i + 4: 1 + 0i - 1 - 0i 1 + 0i - 1 - 0i 1 + 0i - 1 - 0i 1 + 0i - 1 - 0i + 5: 1 + 0i -C81 + C81i 0 - 1i C81 + C81i -1 - 0i C81 - C81i - 0 + 1i -C81 - C81i + 6: 1 + 0i - 0 + 1i -1 - 0i 0 - 1i 1 + 0i - 0 + 1i - 1 - 0i - 0 - 1i + 7: 1 + 0i C81 + C81i -0 + 1i -C81 + C81i -1 - 0i -C81 - C81i - 0 - 1i C81 - C81i + */ + pInOut[0] = re0 + re4 + re1_7p + re2_6p + re3_5p; + pInOut[1] = im0 + im4 + im1_7p + im2_6p + im3_5p; + + pInOut[2] = re0 + Mpy_32_16_1( L_sub( re1_7p, re3_5p ), C81 ) - re4 + Mpy_32_16_1( L_add( im1_7m, im3_5m ), C81 ) + im2_6m; + pInOut[3] = im0 + Mpy_32_16_1( L_sub( im1_7p, im3_5p ), C81 ) - im4 - Mpy_32_16_1( L_add( re1_7m, re3_5m ), C81 ) - re2_6m; + + pInOut[4] = re0 - re2_6p + re4 + im1_7m - im3_5m; + pInOut[5] = im0 - im2_6p + im4 - re1_7m + re3_5m; + + pInOut[6] = re0 + Mpy_32_16_1( L_sub( re3_5p, re1_7p ), C81 ) - re4 + Mpy_32_16_1( L_add( im1_7m, im3_5m ), C81 ) - im2_6m; + pInOut[7] = im0 + Mpy_32_16_1( L_sub( im3_5p, im1_7p ), C81 ) - im4 - Mpy_32_16_1( L_add( re1_7m, re3_5m ), C81 ) + re2_6m; + + pInOut[8] = re0 - re1_7p + re2_6p - re3_5p + re4; + pInOut[9] = im0 - im1_7p + im2_6p - im3_5p + im4; + + pInOut[10] = re0 + Mpy_32_16_1( L_sub( re3_5p, re1_7p ), C81 ) - re4 - Mpy_32_16_1( L_add( im1_7m, im3_5m ), C81 ) + im2_6m; + pInOut[11] = im0 + Mpy_32_16_1( L_sub( im3_5p, im1_7p ), C81 ) - im4 + Mpy_32_16_1( L_add( re1_7m, re3_5m ), C81 ) - re2_6m; + + pInOut[12] = re0 - re2_6p + re4 - im1_7m + im3_5m; + pInOut[13] = im0 - im2_6p + im4 + re1_7m - re3_5m; + + pInOut[14] = re0 + Mpy_32_16_1( L_sub( re1_7p, re3_5p ), C81 ) - re4 - Mpy_32_16_1( L_add( im1_7m, im3_5m ), C81 ) - im2_6m; + pInOut[15] = im0 + Mpy_32_16_1( L_sub( im1_7p, im3_5p ), C81 ) - im4 + Mpy_32_16_1( L_add( re1_7m, re3_5m ), C81 ) + re2_6m; + + return; +} + +static void nextFFT( + Word32 *x, + const Word16 length ) +{ + SWITCH ( length ) + { + case 2: + fft2( x ); + BREAK; + case 3: + fft3_2( x ); + BREAK; + case 4: + fft4( x ); + BREAK; + case 5: + fft5( x ); + BREAK; + case 8: + fft8_2( x ); + BREAK; + default: + assert( !"length not supported" ); + BREAK; + } + + return; +} + +static const Word16 CTFFTfactors[] = { 9, 8, 7, 5, 4, 3, 2, 0 }; + +static __inline Word16 findFactor( + const Word16 length ) +{ + Word16 i = 0; + Word16 factor = 0; + + WHILE ( CTFFTfactors[i] != 0 ) + { + IF (EQ_16(0, ( length % CTFFTfactors[i] ))) + { + factor = CTFFTfactors[i]; + BREAK; + } + i++; + } + return factor; +} + +static __inline void twiddle( + Word32 *x, + const Word16 length, + const Word16 n1, + const Word16 n2 ) +{ + Word16 i, ii; + const Word16 *ptr_sin = &sin_twiddle_table_25_5_5[0]; + const Word16 *ptr_cos = &cos_twiddle_table_25_5_5[0]; + IF ( EQ_16(length, 16) && EQ_16(n1, 8) && EQ_16(n2, 2)) + { + ptr_sin = &sin_twiddle_table_16_8_2[0]; + ptr_cos = &cos_twiddle_table_16_8_2[0]; + } + ELSE IF (length != 25 || n1 != 5 || n2 != 5) + { + assert(0); + } + + FOR ( i = 1; i < n1; i++ ) + { + FOR ( ii = 1; ii < n2; ii++ ) + { + Word32 xRe, xIm; + xRe = x[2 * ( i * n2 + ii )]; + xIm = x[2 * ( i * n2 + ii ) + 1]; + x[2 * ( i * n2 + ii )] = (Word32)L_sub(Mpy_32_16_1(xRe, ptr_cos[i * n2 + ii]), Mpy_32_16_1(xIm, ptr_sin[i * n2 + ii])); + x[2 * ( i * n2 + ii ) + 1] = (Word32)L_add(Mpy_32_16_1(xRe, ptr_sin[i * n2 + ii]), Mpy_32_16_1(xIm, ptr_cos[i * n2 + ii])); + } + } + return; +} + +static void cooleyTukeyFFT( + Word32 *x, + const Word16 length, + Word32 *scratch ) +{ + Word16 factor; + Word16 i, ii; + Word16 n1, n2; + Word16 cnt = 0; + Word32 *src, *dest; + + SWITCH ( length ) + { + case 1: + BREAK; + case 2: + fft2( x ); + BREAK; + case 3: + fft3_2( x ); + BREAK; + case 4: + fft4( x ); + BREAK; + case 5: + fft5( x ); + BREAK; + case 8: + fft8_2( x ); + BREAK; + default: + { + factor = findFactor( length ); + IF ( factor > 0 && ( length / factor > 1 ) ) + { + n1 = factor; + n2 = length / factor; + + /* DATA Resorting for stage1 */ + dest = scratch; + FOR ( i = 0; i < 2 * n1; i += 2 ) + { + src = x + i; + FOR ( ii = 0; ii < n2; ii++ ) + { + /* *dest++ = x[2*(i+ii*n1)]; */ + /* *dest++ = x[2*(i+ii*n1)+1]; */ + *dest++ = *src; + *dest++ = *( src + 1 ); + src += 2 * n1; + } + } + src = scratch; + dest = x; + FOR ( i = 0; i < length; i++ ) + { + *dest++ = *src++; + *dest++ = *src++; + } + /* perform n1 ffts of length n2 */ + FOR ( i = 0; i < n1; i++ ) + { + cooleyTukeyFFT( x + 2 * i * n2, n2, scratch + 2 * i * n2 ); + } + /*data twiddeling */ + twiddle( x, length, n1, n2 ); + /* DATA Resorting for stage2 */ + cnt = 0; + FOR ( i = 0; i < n2; i++ ) + { + FOR ( ii = 0; ii < n1; ii++ ) + { + scratch[2 * cnt] = x[2 * ( i + ii * n2 )]; + scratch[2 * cnt + 1] = x[2 * ( i + ii * n2 ) + 1]; + cnt++; + } + } + /* perform n2 ffts of length n1 */ + FOR ( i = 0; i < n2; i++ ) + { + nextFFT( scratch + 2 * i * n1, n1 ); + } + cnt = 0; + FOR ( i = 0; i < n1; i++ ) + { + FOR ( ii = 0; ii < n2; ii++ ) + { + x[2 * cnt] = scratch[2 * ( i + ii * n1 )]; + x[2 * cnt + 1] = scratch[2 * ( i + ii * n1 ) + 1]; + cnt++; + } + } + } + ELSE + { + assert( !"length not supported" ); + } + } + } + + return; +} + +static void pfaDFT( + Word32 *x, + const Word16 length, + Word32 *scratch1, + const Word16 numFactors, + const Word16 *factor ) +{ + Word16 i, ii; + Word16 cnt; + + IF ( numFactors > 1 ) + { + Word32 *tmp = scratch1; + Word16 n1_inv = 1, n2_inv = 1; + Word16 n2 = factor[0 /*idx*/]; + Word16 n1 = length / n2; + Word16 idx, incr; + + WHILE ( ( ( n1_inv * n1 ) % n2 ) != 1 ) + { + n1_inv++; + } + WHILE ( ( ( n2_inv * n2 ) % n1 ) != 1 ) + { + n2_inv++; + } + idx = 0; + incr = n1 * n1_inv; + cnt = 0; + FOR ( i = 0; i < n1; i++ ) + { + FOR ( ii = 0; ii < n2 - 1; ii++ ) + { + tmp[cnt++] = x[2 * idx]; + tmp[cnt++] = x[2 * idx + 1]; + + idx += incr; + IF ( idx > length ) + { + idx -= length; + } + } + tmp[cnt++] = x[2 * idx]; + tmp[cnt++] = x[2 * idx + 1]; + idx++; + } + FOR ( cnt = 0; cnt < length; cnt += n2 ) + { + cooleyTukeyFFT( tmp + 2 * cnt, n2, x + 2 * cnt ); + } + FOR ( cnt = 0; cnt < n1; cnt++ ) + { + FOR ( i = 0; i < n2; i++ ) + { + x[2 * ( cnt + i * n1 )] = tmp[2 * ( cnt * n2 + i )]; + x[2 * ( cnt + i * n1 ) + 1] = tmp[2 * ( cnt * n2 + i ) + 1]; + } + } + FOR ( cnt = 0; cnt < length; cnt += n1 ) + { + pfaDFT( x + 2 * cnt, n1, tmp, numFactors - 1, &factor[1] ); + } + idx = 0; + cnt = 0; + FOR ( i = 0; i < n2; i++ ) + { + idx = i * n1; + FOR ( ii = 0; ii < n1; ii++ ) + { + tmp[2 * idx] = x[cnt++]; + tmp[2 * idx + 1] = x[cnt++]; + idx += n2; + IF ( idx > length ) + { + idx -= length; + } + } + } + FOR ( cnt = 0; cnt < length; cnt++ ) + { + x[2 * cnt] = tmp[2 * cnt]; + x[2 * cnt + 1] = tmp[2 * cnt + 1]; + } + } + ELSE + { + cooleyTukeyFFT( x, length, scratch1 ); + } + + return; +} + +static void fftf_interleave( + Word32 *re, + Word32 *im, + Word32 *out, + const Word16 len ) +{ + Word16 i = 0; + + FOR ( i = 0; i < len; i++ ) + { + *out++ = *re++; + *out++ = *im++; + } + + return; +} + +static void fftf_deinterleave( + Word32 *in, + Word32 *re, + Word32 *im, + const Word16 len ) +{ + Word16 i = 0; + + FOR ( i = 0; i < len; i++ ) + { + *re++ = *in++; + *im++ = *in++; + } + + return; +} + +static void DoRTFT600( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +) +{ + Word32 scratch[1200], cmplx[1200]; + Word16 factors[3] = { 25, 8, 3 }; + + fftf_interleave( x, y, cmplx, 600 ); + pfaDFT( cmplx, 600, scratch, 3, factors ); + fftf_deinterleave( cmplx, x, y, 600 ); + + return; +} + +static void DoRTFT400( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +) +{ + Word32 scratch[800], cmplx[800]; + Word16 factors[2] = { 25, 16 }; + + fftf_interleave( x, y, cmplx, 400 ); + pfaDFT( cmplx, 400, scratch, 2, factors ); + fftf_deinterleave( cmplx, x, y, 400 ); + + + return; +} + +static void DoRTFT240( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +) +{ + Word32 scratch[480], cmplx[480]; + Word16 factors[3] = { 16, 5, 3 }; + + fftf_interleave( x, y, cmplx, 240 ); + pfaDFT( cmplx, 240, scratch, 3, factors ); + fftf_deinterleave( cmplx, x, y, 240 ); + + return; +} + +static void DoRTFT200( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +) +{ + Word32 scratch[400], cmplx[400]; + Word16 factors[2] = { 25, 8 }; + + fftf_interleave( x, y, cmplx, 200 ); + pfaDFT( cmplx, 200, scratch, 2, factors ); + fftf_deinterleave( cmplx, x, y, 200 ); + + return; +} + +static void DoRTFT100( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +) +{ + Word32 scratch[200], cmplx[200]; + Word16 factors[2] = { 25, 4 }; + + fftf_interleave( x, y, cmplx, 100 ); + pfaDFT( cmplx, 100, scratch, 2, factors ); + fftf_deinterleave( cmplx, x, y, 100 ); + + return; +} + + +void DoFFT_fx( + Word32 *re2, + Word32 *im2, + const Word16 length ) +{ + SWITCH ( length ) + { + case 600: + DoRTFT600( re2, im2 ); + BREAK; + case 480: + DoRTFT480_fx( re2, im2 ); + BREAK; + case 400: + DoRTFT400( re2, im2 ); + BREAK; + case 320: + DoRTFT320_fx( re2, im2 ); + BREAK; + case 256: + DoRTFTn_fx( re2, im2, 256 ); + BREAK; + case 240: + DoRTFT240( re2, im2 ); + BREAK; + case 200: + DoRTFT200( re2, im2 ); + BREAK; + case 160: + DoRTFT160_fx( re2, im2 ); + BREAK; + case 128: + DoRTFT128_fx( re2, im2 ); + BREAK; + case 120: + DoRTFT120_fx( re2, im2 ); + BREAK; + case 100: + DoRTFT100( re2, im2 ); + BREAK; + case 80: + DoRTFT80_fx( re2, im2 ); + BREAK; + case 64: + DoRTFTn_fx( re2, im2, 64 ); + BREAK; + case 40: + DoRTFT40_fx( re2, im2 ); + BREAK; + case 20: + DoRTFT20_fx( re2, im2 ); + BREAK; + default: + assert( !"fft is not supported!" ); + } + + return; +} + +/*-----------------------------------------------------------------* + * Low-complexity implementation of FFT + *-----------------------------------------------------------------*/ + +static void fft_len5( + Word32 *re, + Word32 *im, + const Word16 s ) +{ + Word32 x0, x1, x2, x3, x4; + Word32 r1, r2, r3, r4; + Word32 s1, s2, s3, s4; + Word32 t; + + x0 = re[s * 0]; + x1 = re[s * 1]; + x2 = re[s * 2]; + x3 = re[s * 3]; + x4 = re[s * 4]; + + r1 = L_add( x1, x4 ); + r4 = L_sub( x1, x4 ); + r3 = L_add( x2, x3 ); + r2 = L_sub( x2, x3 ); + t = Mpy_32_16_1( L_sub( r1, r3 ), FFT_C54 ); + r1 = L_add( r1, r3 ); + re[0] = L_add( x0, r1 ); + + r1 = L_add( re[0], L_shl(Mpy_32_16_1( r1, FFT_C55 ), 1) ); + r3 = L_sub( r1, t ); + r1 = L_add( r1, t ); + t = Mpy_32_16_1(L_add( r4, r2 ), FFT_C51 ); + + r4 = L_add( t, L_shl(Mpy_32_16_1( r4, FFT_C52 ), 1) ); + r2 = L_add( t, Mpy_32_16_1( r2, FFT_C53 ) ); + + x0 = im[s * 0]; + x1 = im[s * 1]; + x2 = im[s * 2]; + x3 = im[s * 3]; + x4 = im[s * 4]; + + s1 = L_add( x1, x4 ); + s4 = L_sub( x1, x4 ); + s3 = L_add( x2, x3 ); + s2 = L_sub( x2, x3 ); + t = Mpy_32_16_1( L_sub( s1, s3 ), FFT_C54 ); + s1 = L_add( s1, s3 ); + im[0] = L_add( x0, s1 ); + + s1 = L_add( im[0], L_shl(Mpy_32_16_1( s1, FFT_C55 ), 1) ); + s3 = L_sub( s1, t ); + s1 = L_add( s1, t ); + t = Mpy_32_16_1(L_add( s4, s2 ), FFT_C51 ); + + s4 = L_add( t, L_shl(Mpy_32_16_1( s4, FFT_C52 ), 1) ); + s2 = L_add( t, Mpy_32_16_1( s2, FFT_C53 ) ); + + re[s * 1] = L_add( r1, s2 ); + re[s * 4] = L_sub( r1, s2 ); + re[s * 2] = L_sub( r3, s4 ); + re[s * 3] = L_add( r3, s4 ); + + im[s * 1] = L_sub( s1, r2 ); + im[s * 4] = L_add( s1, r2 ); + im[s * 2] = L_add( s3, r4 ); + im[s * 3] = L_sub( s3, r4 ); + + return; +} + +static void fft_len8( + Word32 *re, + Word32 *im, + const Word16 s ) +{ + Word32 x00, x01, x02, x03, x04, x05, x06, x07; + Word32 x08, x09, x10, x11, x12, x13, x14, x15; + Word32 t00, t01, t02, t03, t04, t05, t06, t07; + Word32 t08, t09, t10, t11, t12, t13, t14, t15; + Word32 s00, s01, s02, s03, s04, s05, s06, s07; + Word32 s08, s09, s10, s11, s12, s13, s14, s15; + + x00 = re[s * 0]; + x01 = im[s * 0]; + x02 = re[s * 1]; + x03 = im[s * 1]; + x04 = re[s * 2]; + x05 = im[s * 2]; + x06 = re[s * 3]; + x07 = im[s * 3]; + x08 = re[s * 4]; + x09 = im[s * 4]; + x10 = re[s * 5]; + x11 = im[s * 5]; + x12 = re[s * 6]; + x13 = im[s * 6]; + x14 = re[s * 7]; + x15 = im[s * 7]; + + t00 = L_add( x00, x08 ); + t02 = L_sub( x00, x08 ); + t01 = L_add( x01, x09 ); + t03 = L_sub( x01, x09 ); + t04 = L_add( x02, x10 ); + t06 = L_sub( x02, x10 ); + t05 = L_add( x03, x11 ); + t07 = L_sub( x03, x11 ); + t08 = L_add( x04, x12 ); + t10 = L_sub( x04, x12 ); + t09 = L_add( x05, x13 ); + t11 = L_sub( x05, x13 ); + t12 = L_add( x06, x14 ); + t14 = L_sub( x06, x14 ); + t13 = L_add( x07, x15 ); + t15 = L_sub( x07, x15 ); + + s00 = L_add( t00, t08 ); + s04 = L_sub( t00, t08 ); + s01 = L_add( t01, t09 ); + s05 = L_sub( t01, t09 ); + s08 = L_sub( t02, t11 ); + s10 = L_add( t02, t11 ); + s09 = L_add( t03, t10 ); + s11 = L_sub( t03, t10 ); + s02 = L_add( t04, t12 ); + s07 = L_sub( t04, t12 ); + s03 = L_add( t05, t13 ); + s06 = L_sub( t13, t05 ); + + t01 = L_add( t06, t14 ); + t02 = L_sub( t06, t14 ); + t00 = L_add( t07, t15 ); + t03 = L_sub( t07, t15 ); + + s12 = Mpy_32_16_1( L_add( t00, t02 ), FFT_C81 ); + s14 = Mpy_32_16_1( L_sub( t00, t02 ), FFT_C81 ); + s13 = Mpy_32_16_1( L_sub( t03, t01 ), FFT_C81 ); + s15 = Mpy_32_16_1( L_add( t01, t03 ), FFT_C82 ); + + re[s * 0] = L_add( s00, s02 ); + re[s * 4] = L_sub( s00, s02 ); + im[s * 0] = L_add( s01, s03 ); + im[s * 4] = L_sub( s01, s03 ); + re[s * 2] = L_sub( s04, s06 ); + re[s * 6] = L_add( s04, s06 ); + im[s * 2] = L_sub( s05, s07 ); + im[s * 6] = L_add( s05, s07 ); + re[s * 3] = L_add( s08, s14 ); + re[s * 7] = L_sub( s08, s14 ); + im[s * 3] = L_add( s09, s15 ); + im[s * 7] = L_sub( s09, s15 ); + re[s * 1] = L_add( s10, s12 ); + re[s * 5] = L_sub( s10, s12 ); + im[s * 1] = L_add( s11, s13 ); + im[s * 5] = L_sub( s11, s13 ); + + return; +} + +static void fft_len10( + Word32 *re, + Word32 *im, + const Word16 s ) +{ + Word32 t; + Word32 x0, x1, x2, x3, x4; + Word32 r1, r2, r3, r4; + Word32 s1, s2, s3, s4; + Word32 y00, y01, y02, y03, y04, y05, y06, y07, y08, y09; + Word32 y10, y11, y12, y13, y14, y15, y16, y17, y18, y19; + + x0 = re[s * 0]; + x1 = re[s * 2]; + x2 = re[s * 4]; + x3 = re[s * 6]; + x4 = re[s * 8]; + + r1 = L_add( x3, x2 ); + r4 = L_sub( x3, x2 ); + r3 = L_add( x1, x4 ); + r2 = L_sub( x1, x4 ); + t = Mpy_32_16_1(L_sub( r1, r3 ), FFT_C54 ); + r1 = L_add( r1, r3 ); + y00 = L_add( x0, r1 ); + r1 = L_add( y00, L_shl(Mpy_32_16_1(r1, FFT_C55), 1)); + r3 = L_sub( r1, t ); + r1 = L_add( r1, t ); + t = Mpy_32_16_1( L_add( r4, r2 ) , FFT_C51 ); + r4 = L_add( t, L_shl(Mpy_32_16_1( r4, FFT_C52 ), 1) ); + r2 = L_add( t, Mpy_32_16_1( r2, FFT_C53 ) ); + + x0 = im[s * 0]; + x1 = im[s * 2]; + x2 = im[s * 4]; + x3 = im[s * 6]; + x4 = im[s * 8]; + + s1 = L_add( x3, x2 ); + s4 = L_sub( x3, x2 ); + s3 = L_add( x1, x4 ); + s2 = L_sub( x1, x4 ); + t = Mpy_32_16_1( L_sub( s1, s3 ), FFT_C54 ); + s1 = L_add( s1, s3 ); + y01 = L_add( x0, s1 ); + s1 = L_add( y01, L_shl(Mpy_32_16_1( s1, FFT_C55 ), 1) ); + s3 = L_sub( s1, t ); + s1 = L_add( s1, t ); + t = Mpy_32_16_1( L_add( s4, s2 ), FFT_C51 ); + s4 = L_add( t, L_shl(Mpy_32_16_1( s4, FFT_C52 ), 1) ); + s2 = L_add( t, Mpy_32_16_1( s2, FFT_C53 ) ); + + y04 = L_add( r1, s2 ); + y16 = L_sub( r1, s2 ); + y08 = L_sub( r3, s4 ); + y12 = L_add( r3, s4 ); + + y05 = L_sub( s1, r2 ); + y17 = L_add( s1, r2 ); + y09 = L_add( s3, r4 ); + y13 = L_sub( s3, r4 ); + + x0 = re[s * 5]; + x1 = re[s * 1]; + x2 = re[s * 3]; + x3 = re[s * 7]; + x4 = re[s * 9]; + + r1 = L_add( x1, x4 ); + r4 = L_sub( x1, x4 ); + r3 = L_add( x3, x2 ); + r2 = L_sub( x3, x2 ); + t = Mpy_32_16_1( L_sub( r1, r3 ), FFT_C54 ); + r1 = L_add( r1, r3 ); + y02 = L_add( x0, r1 ); + r1 = L_add( y02, L_shl(Mpy_32_16_1(r1, FFT_C55), 1) ); + r3 = L_sub( r1, t ); + r1 = L_add( r1, t ); + t = Mpy_32_16_1(L_add( r4, r2 ), FFT_C51 ); + r4 = L_add( t, L_shl(Mpy_32_16_1( r4, FFT_C52 ), 1) ); + r2 = L_add( t, Mpy_32_16_1( r2, FFT_C53 ) ); + + x0 = im[s * 5]; + x1 = im[s * 1]; + x2 = im[s * 3]; + x3 = im[s * 7]; + x4 = im[s * 9]; + + s1 = L_add( x1, x4 ); + s4 = L_sub( x1, x4 ); + s3 = L_add( x3, x2 ); + s2 = L_sub( x3, x2 ); + t = Mpy_32_16_1(L_sub( s1, s3 ), FFT_C54 ); + s1 = L_add( s1, s3 ); + y03 = L_add( x0, s1 ); + s1 = L_add( y03, L_shl(Mpy_32_16_1(s1, FFT_C55), 1) ); + s3 = L_sub( s1, t ); + s1 = L_add( s1, t ); + t = Mpy_32_16_1( L_add( s4, s2 ), FFT_C51 ); + s4 = L_add( t, L_shl(Mpy_32_16_1( s4, FFT_C52 ), 1) ); + s2 = L_add( t, Mpy_32_16_1( s2, FFT_C53 ) ); + + y06 = L_add( r1, s2 ); + y18 = L_sub( r1, s2 ); + y10 = L_sub( r3, s4 ); + y14 = L_add( r3, s4 ); + + y07 = L_sub( s1, r2 ); + y19 = L_add( s1, r2 ); + y11 = L_add( s3, r4 ); + y15 = L_sub( s3, r4 ); + + re[s * 0] = L_add( y00, y02 ); + im[s * 0] = L_add( y01, y03 ); + re[s * 5] = L_sub( y00, y02 ); + im[s * 5] = L_sub( y01, y03 ); + + re[s * 2] = L_add( y04, y06 ); + im[s * 2] = L_add( y05, y07 ); + re[s * 7] = L_sub( y04, y06 ); + im[s * 7] = L_sub( y05, y07 ); + + re[s * 4] = L_add( y08, y10 ); + im[s * 4] = L_add( y09, y11 ); + re[s * 9] = L_sub( y08, y10 ); + im[s * 9] = L_sub( y09, y11 ); + + re[s * 6] = L_add( y12, y14 ); + im[s * 6] = L_add( y13, y15 ); + re[s * 1] = L_sub( y12, y14 ); + im[s * 1] = L_sub( y13, y15 ); + + re[s * 8] = L_add( y16, y18 ); + im[s * 8] = L_add( y17, y19 ); + re[s * 3] = L_sub( y16, y18 ); + im[s * 3] = L_sub( y17, y19 ); + + return; +} + +static void fft_len15( + Word32 *re, + Word32 *im, + const Word16 s ) +{ + Word32 t; + Word32 r1, r2, r3, r4; + Word32 s1, s2, s3, s4; + Word32 x00, x01, x02, x03, x04, x05, x06, x07, x08, x09; + Word32 x10, x11, x12, x13, x14, x15, x16, x17, x18, x19; + Word32 x20, x21, x22, x23, x24, x25, x26, x27, x28, x29; + Word32 y00, y01, y02, y03, y04, y05, y06, y07, y08, y09; + Word32 y10, y11, y12, y13, y14, y15, y16, y17, y18, y19; + Word32 y20, y21, y22, y23, y24, y25, y26, y27, y28, y29; + + x00 = re[s * 0]; + x01 = im[s * 0]; + x02 = re[s * 3]; + x03 = im[s * 3]; + x04 = re[s * 6]; + x05 = im[s * 6]; + x06 = re[s * 9]; + x07 = im[s * 9]; + x08 = re[s * 12]; + x09 = im[s * 12]; + + x10 = re[s * 5]; + x11 = im[s * 5]; + x12 = re[s * 8]; + x13 = im[s * 8]; + x14 = re[s * 11]; + x15 = im[s * 11]; + x16 = re[s * 14]; + x17 = im[s * 14]; + x18 = re[s * 2]; + x19 = im[s * 2]; + + x20 = re[s * 10]; + x21 = im[s * 10]; + x22 = re[s * 13]; + x23 = im[s * 13]; + x24 = re[s * 1]; + x25 = im[s * 1]; + x26 = re[s * 4]; + x27 = im[s * 4]; + x28 = re[s * 7]; + x29 = im[s * 7]; + + r1 = L_add( x02, x08 ); + r4 = L_sub( x02, x08 ); + r3 = L_add( x04, x06 ); + r2 = L_sub( x04, x06 ); + t = Mpy_32_16_1( L_sub( r1, r3 ), FFT_C54 ); + r1 = L_add( r1, r3 ); + y00 = L_add( x00, r1 ); + r1 = L_add( y00, L_shl(Mpy_32_16_1(r1, FFT_C55), 1) ); + r3 = L_sub( r1, t ); + r1 = L_add( r1, t ); + t = Mpy_32_16_1( L_add( r4, r2 ), FFT_C51 ); + r4 = L_add( t, L_shl(Mpy_32_16_1( r4, FFT_C52 ), 1) ); + r2 = L_add( t, Mpy_32_16_1( r2, FFT_C53 ) ); + + s1 = L_add( x03, x09 ); + s4 = L_sub( x03, x09 ); + s3 = L_add( x05, x07 ); + s2 = L_sub( x05, x07 ); + t = Mpy_32_16_1( L_sub( s1, s3 ), FFT_C54 ); + s1 = L_add( s1, s3 ); + y01 = L_add( x01, s1 ); + s1 = L_add( y01, L_shl(Mpy_32_16_1(s1, FFT_C55), 1) ); + s3 = L_sub( s1, t ); + s1 = L_add( s1, t ); + t = Mpy_32_16_1( L_add( s4, s2 ), FFT_C51 ); + s4 = L_add( t, L_shl(Mpy_32_16_1( s4, FFT_C52 ), 1) ); + s2 = L_add( t, Mpy_32_16_1( s2, FFT_C53 ) ); + + y02 = L_add( r1, s2 ); + y08 = L_sub( r1, s2 ); + y04 = L_sub( r3, s4 ); + y06 = L_add( r3, s4 ); + + y03 = L_sub( s1, r2 ); + y09 = L_add( s1, r2 ); + y05 = L_add( s3, r4 ); + y07 = L_sub( s3, r4 ); + + r1 = L_add( x12, x18 ); + r4 = L_sub( x12, x18 ); + r3 = L_add( x14, x16 ); + r2 = L_sub( x14, x16 ); + t = Mpy_32_16_1( L_sub( r1, r3 ), FFT_C54 ); + r1 = L_add( r1, r3 ); + y10 = L_add( x10, r1 ); + r1 = L_add( y10, L_shl(Mpy_32_16_1(r1, FFT_C55), 1) ); + r3 = L_sub( r1, t ); + r1 = L_add( r1, t ); + t = Mpy_32_16_1( L_add( r4, r2 ), FFT_C51 ); + r4 = L_add( t, L_shl(Mpy_32_16_1( r4, FFT_C52 ), 1) ); + r2 = L_add( t, Mpy_32_16_1( r2, FFT_C53 ) ); + + s1 = L_add( x13, x19 ); + s4 = L_sub( x13, x19 ); + s3 = L_add( x15, x17 ); + s2 = L_sub( x15, x17 ); + t = Mpy_32_16_1( L_sub( s1, s3 ), FFT_C54 ); + s1 = L_add( s1, s3 ); + y11 = L_add( x11, s1 ); + s1 = L_add( y11, L_shl(Mpy_32_16_1(s1, FFT_C55), 1) ); + s3 = L_sub( s1, t ); + s1 = L_add( s1, t ); + t = Mpy_32_16_1( L_add( s4, s2 ), FFT_C51 ); + s4 = L_add( t, L_shl(Mpy_32_16_1( s4, FFT_C52 ), 1) ); + s2 = L_add( t, Mpy_32_16_1( s2, FFT_C53 ) ); + + y12 = L_add( r1, s2 ); + y18 = L_sub( r1, s2 ); + y14 = L_sub( r3, s4 ); + y16 = L_add( r3, s4 ); + + y13 = L_sub( s1, r2 ); + y19 = L_add( s1, r2 ); + y15 = L_add( s3, r4 ); + y17 = L_sub( s3, r4 ); + + r1 = L_add( x22, x28 ); + r4 = L_sub( x22, x28 ); + r3 = L_add( x24, x26 ); + r2 = L_sub( x24, x26 ); + t = Mpy_32_16_1( L_sub( r1, r3 ), FFT_C54 ); + r1 = L_add( r1, r3 ); + y20 = L_add( x20, r1 ); + r1 = L_add( y20, L_shl(Mpy_32_16_1(r1, FFT_C55), 1) ); + r3 = L_sub( r1, t ); + r1 = L_add( r1, t ); + t = Mpy_32_16_1( L_add( r4, r2 ), FFT_C51 ); + r4 = L_add( t, L_shl(Mpy_32_16_1( r4, FFT_C52 ), 1) ); + r2 = L_add( t, Mpy_32_16_1( r2, FFT_C53 ) ); + + s1 = L_add( x23, x29 ); + s4 = L_sub( x23, x29 ); + s3 = L_add( x25, x27 ); + s2 = L_sub( x25, x27 ); + t = Mpy_32_16_1( L_sub( s1, s3 ), FFT_C54 ); + s1 = L_add( s1, s3 ); + y21 = L_add( x21, s1 ); + s1 = L_add( y21, L_shl(Mpy_32_16_1(s1, FFT_C55), 1) ); + s3 = L_sub( s1, t ); + s1 = L_add( s1, t ); + t = Mpy_32_16_1( L_add( s4, s2 ), FFT_C51 ); + s4 = L_add( t, L_shl(Mpy_32_16_1( s4, FFT_C52 ), 1) ); + s2 = L_add( t, Mpy_32_16_1( s2, FFT_C53 ) ); + + y22 = L_add( r1, s2 ); + y28 = L_sub( r1, s2 ); + y24 = L_sub( r3, s4 ); + y26 = L_add( r3, s4 ); + + y23 = L_sub( s1, r2 ); + y29 = L_add( s1, r2 ); + y25 = L_add( s3, r4 ); + y27 = L_sub( s3, r4 ); + + r1 = L_add( y10, y20 ); + r2 = Mpy_32_16_1(L_sub( y10, y20 ), FFT_C31 ); + re[s * 0] = L_add( y00, r1 ); + r1 = L_sub( y00, L_shr(r1, 1)); + + s1 = L_add( y11, y21 ); + s2 = Mpy_32_16_1( L_sub( y11, y21 ), FFT_C31 ); + im[s * 0] = L_add( y01, s1 ); + s1 = L_sub( y01, L_shr(s1, 1) ); + + re[s * 10] = L_sub( r1, s2 ); + re[s * 5] = L_add( r1, s2 ); + im[s * 10] = L_add( s1, r2 ); + im[s * 5] = L_sub( s1, r2 ); + + r1 = L_add( y12, y22 ); + r2 = Mpy_32_16_1(L_sub( y12, y22 ), FFT_C31 ); + re[s * 6] = L_add( y02, r1 ); + r1 = L_sub( y02, L_shr(r1, 1) ); + + s1 = L_add( y13, y23 ); + s2 = Mpy_32_16_1( L_sub( y13, y23 ), FFT_C31 ); + im[s * 6] = L_add( y03, s1 ); + s1 = L_sub( y03, L_shr(s1, 1) ); + + re[s * 1] = L_sub( r1, s2 ); + re[s * 11] = L_add( r1, s2 ); + im[s * 1] = L_add( s1, r2 ); + im[s * 11] = L_sub( s1, r2 ); + + r1 = L_add( y14, y24 ); + r2 = Mpy_32_16_1(L_sub( y14, y24 ), FFT_C31 ); + re[s * 12] = L_add( y04, r1 ); + r1 = L_sub( y04, L_shr(r1, 1) ); + + s1 = L_add( y15, y25 ); + s2 = Mpy_32_16_1( L_sub( y15, y25 ), FFT_C31 ); + im[s * 12] = L_add( y05, s1 ); + s1 = L_sub( y05, L_shr(s1, 1) ); + + re[s * 7] = L_sub( r1, s2 ); + re[s * 2] = L_add( r1, s2 ); + im[s * 7] = L_add( s1, r2 ); + im[s * 2] = L_sub( s1, r2 ); + + r1 = L_add( y16, y26 ); + r2 = Mpy_32_16_1( L_sub( y16, y26 ), FFT_C31 ); + re[s * 3] = L_add( y06, r1 ); + r1 = L_sub( y06, L_shr(r1, 1) ); + + s1 = L_add( y17, y27 ); + s2 = Mpy_32_16_1(L_sub( y17, y27 ), FFT_C31 ); + im[s * 3] = L_add( y07, s1 ); + s1 = L_sub( y07, L_shr(s1, 1) ); + + re[s * 13] = L_sub( r1, s2 ); + re[s * 8] = L_add( r1, s2 ); + im[s * 13] = L_add( s1, r2 ); + im[s * 8] = L_sub( s1, r2 ); + + r1 = L_add( y18, y28 ); + r2 = Mpy_32_16_1( L_sub( y18, y28 ), FFT_C31 ); + re[s * 9] = L_add( y08, r1 ); + r1 = L_sub( y08, L_shr(r1, 1) ); + + s1 = L_add( y19, y29 ); + s2 = Mpy_32_16_1( L_sub( y19, y29 ), FFT_C31 ); + im[s * 9] = L_add( y09, s1 ); + s1 = L_sub( y09, L_shr(s1, 1)); + + re[s * 4] = L_sub( r1, s2 ); + re[s * 14] = L_add( r1, s2 ); + im[s * 4] = L_add( s1, r2 ); + im[s * 14] = L_sub( s1, r2 ); + + return; +} + +static void fft_len16( + Word32 *re, + Word32 *im, + const Word16 s ) +{ + Word32 x0, x1, x2, x3, x4, x5, x6, x7; + Word32 t0, t1, t2, t3, t4, t5, t6, t7; + Word32 y00, y01, y02, y03, y04, y05, y06, y07; + Word32 y08, y09, y10, y11, y12, y13, y14, y15; + Word32 y16, y17, y18, y19, y20, y21, y22, y23; + Word32 y24, y25, y26, y27, y28, y29, y30, y31; + + x0 = L_shr( re[s * 0], SCALEFACTOR16 ); + x1 = L_shr( im[s * 0], SCALEFACTOR16 ); + x2 = L_shr( re[s * 4], SCALEFACTOR16 ); + x3 = L_shr( im[s * 4], SCALEFACTOR16 ); + x4 = L_shr( re[s * 8], SCALEFACTOR16 ); + x5 = L_shr( im[s * 8], SCALEFACTOR16 ); + x6 = L_shr( re[s * 12], SCALEFACTOR16 ); + x7 = L_shr( im[s * 12], SCALEFACTOR16 ); + + t0 = L_add( x0, x4 ); + t2 = L_sub( x0, x4 ); + t1 = L_add( x1, x5 ); + t3 = L_sub( x1, x5 ); + t4 = L_add( x2, x6 ); + t7 = L_sub( x2, x6 ); + t5 = L_add( x7, x3 ); + t6 = L_sub( x7, x3 ); + + y00 = L_add( t0, t4 ); + y01 = L_add( t1, t5 ); + y02 = L_sub( t2, t6 ); + y03 = L_sub( t3, t7 ); + y04 = L_sub( t0, t4 ); + y05 = L_sub( t1, t5 ); + y06 = L_add( t2, t6 ); + y07 = L_add( t3, t7 ); + + x0 = L_shr( re[s * 1], SCALEFACTOR16 ); + x1 = L_shr( im[s * 1], SCALEFACTOR16 ); + x2 = L_shr( re[s * 5], SCALEFACTOR16 ); + x3 = L_shr( im[s * 5], SCALEFACTOR16 ); + x4 = L_shr( re[s * 9], SCALEFACTOR16 ); + x5 = L_shr( im[s * 9], SCALEFACTOR16 ); + x6 = L_shr( re[s * 13], SCALEFACTOR16 ); + x7 = L_shr( im[s * 13], SCALEFACTOR16 ); + + t0 = L_add( x0, x4 ); + t2 = L_sub( x0, x4 ); + t1 = L_add( x1, x5 ); + t3 = L_sub( x1, x5 ); + t4 = L_add( x2, x6 ); + t7 = L_sub( x2, x6 ); + t5 = L_add( x7, x3 ); + t6 = L_sub( x7, x3 ); + + y08 = L_add( t0, t4 ); + y09 = L_add( t1, t5 ); + y10 = L_sub( t2, t6 ); + y11 = L_sub( t3, t7 ); + y12 = L_sub( t0, t4 ); + y13 = L_sub( t1, t5 ); + y14 = L_add( t2, t6 ); + y15 = L_add( t3, t7 ); + + x0 = L_shr( re[s * 2], SCALEFACTOR16 ); + x1 = L_shr( im[s * 2], SCALEFACTOR16 ); + x2 = L_shr( re[s * 6], SCALEFACTOR16 ); + x3 = L_shr( im[s * 6], SCALEFACTOR16 ); + x4 = L_shr( re[s * 10], SCALEFACTOR16 ); + x5 = L_shr( im[s * 10], SCALEFACTOR16 ); + x6 = L_shr( re[s * 14], SCALEFACTOR16 ); + x7 = L_shr( im[s * 14], SCALEFACTOR16 ); + + t0 = L_add( x0, x4 ); + t2 = L_sub( x0, x4 ); + t1 = L_add( x1, x5 ); + t3 = L_sub( x1, x5 ); + t4 = L_add( x2, x6 ); + t7 = L_sub( x2, x6 ); + t5 = L_add( x7, x3 ); + t6 = L_sub( x7, x3 ); + + y16 = L_add( t0, t4 ); + y17 = L_add( t1, t5 ); + y18 = L_sub( t2, t6 ); + y19 = L_sub( t3, t7 ); + y20 = L_sub( t1, t5 ); + y21 = L_sub( t4, t0 ); + y22 = L_add( t2, t6 ); + y23 = L_add( t3, t7 ); + + x0 = L_shr( re[s * 3], SCALEFACTOR16 ); + x1 = L_shr( im[s * 3], SCALEFACTOR16 ); + x2 = L_shr( re[s * 7], SCALEFACTOR16 ); + x3 = L_shr( im[s * 7], SCALEFACTOR16 ); + x4 = L_shr( re[s * 11], SCALEFACTOR16 ); + x5 = L_shr( im[s * 11], SCALEFACTOR16 ); + x6 = L_shr( re[s * 15], SCALEFACTOR16 ); + x7 = L_shr( im[s * 15], SCALEFACTOR16 ); + + t0 = L_add( x0, x4 ); + t2 = L_sub( x0, x4 ); + t1 = L_add( x1, x5 ); + t3 = L_sub( x1, x5 ); + t4 = L_add( x2, x6 ); + t7 = L_sub( x2, x6 ); + t5 = L_add( x7, x3 ); + t6 = L_sub( x7, x3 ); + + y24 = L_add( t0, t4 ); + y25 = L_add( t1, t5 ); + y26 = L_sub( t2, t6 ); + y27 = L_sub( t3, t7 ); + y28 = L_sub( t0, t4 ); + y29 = L_sub( t1, t5 ); + y30 = L_add( t2, t6 ); + y31 = L_add( t3, t7 ); + + x0 = Mpy_32_16_1( y22, FFT_C162 ); + x1 = Mpy_32_16_1( y23, FFT_C162 ); + y22 = L_sub( x0, x1 ); + y23 = L_add( x0, x1 ); + + x0 = Mpy_32_16_1( y28, FFT_C162 ); + x1 = Mpy_32_16_1( y29, FFT_C162 ); + y28 = L_sub( x0, x1 ); + y29 = L_add( x0, x1 ); + + x0 = Mpy_32_16_1( y12, FFT_C161 ); + x1 = Mpy_32_16_1( y13, FFT_C161 ); + y12 = L_add( x0, x1 ); + y13 = L_sub( x1, x0 ); + + x0 = Mpy_32_16_1( y18, FFT_C161 ); + x1 = Mpy_32_16_1( y19, FFT_C161 ); + y18 = L_add( x0, x1 ); + y19 = L_sub( x1, x0 ); + + x0 = Mpy_32_16_1( y10, FFT_C163 ); + x1 = Mpy_32_16_1( y11, FFT_C166 ); + x2 = Mpy_32_16_1( y10, FFT_C166 ); + x3 = Mpy_32_16_1( y11, FFT_C163 ); + y10 = L_sub( x0, x1 ); + y11 = L_add( x2, x3 ); + + x0 = Mpy_32_16_1( y14, FFT_C165 ); + x1 = Mpy_32_16_1( y15, FFT_C164 ); + x2 = Mpy_32_16_1( y14, FFT_C164 ); + x3 = Mpy_32_16_1( y15, FFT_C165 ); + y14 = L_sub( x0, x1 ); + y15 = L_add( x2, x3 ); + + x0 = Mpy_32_16_1( y26, FFT_C165 ); + x1 = Mpy_32_16_1( y27, FFT_C164 ); + x2 = Mpy_32_16_1( y26, FFT_C164 ); + x3 = Mpy_32_16_1( y27, FFT_C165 ); + y26 = L_sub( x0, x1 ); + y27 = L_add( x2, x3 ); + + x0 = Mpy_32_16_1( y30, FFT_C164 ); + x1 = Mpy_32_16_1( y31, FFT_C165 ); + x2 = Mpy_32_16_1( y30, FFT_C165 ); + x3 = Mpy_32_16_1( y31, FFT_C164 ); + y30 = L_sub( x0, x1 ); + y31 = L_add( x2, x3 ); + + t0 = L_add( y00, y16 ); + t2 = L_sub( y00, y16 ); + t1 = L_add( y01, y17 ); + t3 = L_sub( y01, y17 ); + t4 = L_add( y08, y24 ); + t7 = L_sub( y08, y24 ); + t5 = L_add( y25, y09 ); + t6 = L_sub( y25, y09 ); + + re[s * 0] = L_add( t0, t4 ); + im[s * 0] = L_add( t1, t5 ); + re[s * 4] = L_sub( t2, t6 ); + im[s * 4] = L_sub( t3, t7 ); + re[s * 8] = L_sub( t0, t4 ); + im[s * 8] = L_sub( t1, t5 ); + re[s * 12] = L_add( t2, t6 ); + im[s * 12] = L_add( t3, t7 ); + + t0 = L_add( y02, y18 ); + t2 = L_sub( y02, y18 ); + t1 = L_add( y03, y19 ); + t3 = L_sub( y03, y19 ); + t4 = L_add( y10, y26 ); + t7 = L_sub( y10, y26 ); + t5 = L_add( y27, y11 ); + t6 = L_sub( y27, y11 ); + + re[s * 1] = L_add( t0, t4 ); + im[s * 1] = L_add( t1, t5 ); + re[s * 5] = L_sub( t2, t6 ); + im[s * 5] = L_sub( t3, t7 ); + re[s * 9] = L_sub( t0, t4 ); + im[s * 9] = L_sub( t1, t5 ); + re[s * 13] = L_add( t2, t6 ); + im[s * 13] = L_add( t3, t7 ); + + t0 = L_add( y04, y20 ); + t2 = L_sub( y04, y20 ); + t1 = L_add( y05, y21 ); + t3 = L_sub( y05, y21 ); + t4 = L_add( y12, y28 ); + t7 = L_sub( y12, y28 ); + t5 = L_add( y29, y13 ); + t6 = L_sub( y29, y13 ); + + re[s * 2] = L_add( t0, t4 ); + im[s * 2] = L_add( t1, t5 ); + re[s * 6] = L_sub( t2, t6 ); + im[s * 6] = L_sub( t3, t7 ); + re[s * 10] = L_sub( t0, t4 ); + im[s * 10] = L_sub( t1, t5 ); + re[s * 14] = L_add( t2, t6 ); + im[s * 14] = L_add( t3, t7 ); + + t0 = L_add( y06, y22 ); + t2 = L_sub( y06, y22 ); + t1 = L_add( y07, y23 ); + t3 = L_sub( y07, y23 ); + t4 = L_add( y14, y30 ); + t7 = L_sub( y14, y30 ); + t5 = L_add( y31, y15 ); + t6 = L_sub( y31, y15 ); + + re[s * 3] = L_add( t0, t4 ); + im[s * 3] = L_add( t1, t5 ); + re[s * 7] = L_sub( t2, t6 ); + im[s * 7] = L_sub( t3, t7 ); + re[s * 11] = L_sub( t0, t4 ); + im[s * 11] = L_sub( t1, t5 ); + re[s * 15] = L_add( t2, t6 ); + im[s * 15] = L_add( t3, t7 ); + + return; +} + +static void fft_len20_fx( + Word32 *re, + Word32 *im, + const Word16 s ) +{ + Word32 r1, r2, r3, r4; + Word32 s1, s2, s3, s4; + Word32 x0, x1, x2, x3, x4; + Word32 t, t0, t1, t2, t3, t4, t5, t6, t7; + Word32 y00, y01, y02, y03, y04, y05, y06, y07, y08, y09; + Word32 y10, y11, y12, y13, y14, y15, y16, y17, y18, y19; + Word32 y20, y21, y22, y23, y24, y25, y26, y27, y28, y29; + Word32 y30, y31, y32, y33, y34, y35, y36, y37, y38, y39; + + x0 = L_shr( re[s * 0], SCALEFACTOR20 ); + x1 = L_shr( re[s * 16], SCALEFACTOR20 ); + x2 = L_shr( re[s * 12], SCALEFACTOR20 ); + x3 = L_shr( re[s * 8], SCALEFACTOR20 ); + x4 = L_shr( re[s * 4], SCALEFACTOR20 ); + + r1 = L_add( x1, x4 ); + r4 = L_sub( x1, x4 ); + r3 = L_add( x2, x3 ); + r2 = L_sub( x2, x3 ); + t = Mpy_32_16_1( L_sub( r1, r3 ), FFT_C54 ); + r1 = L_add( r1, r3 ); + y00 = L_add( x0, r1 ); + r1 = L_add( y00, L_shl(Mpy_32_16_1(r1, FFT_C55), 1) ); + r3 = L_sub( r1, t ); + r1 = L_add( r1, t ); + t = Mpy_32_16_1( L_add( r4, r2 ), FFT_C51 ); + r4 = L_add( t, L_shl(Mpy_32_16_1( r4, FFT_C52 ), 1) ); + r2 = L_add( t, Mpy_32_16_1( r2, FFT_C53 ) ); + + x0 = L_shr(im[s * 0], SCALEFACTOR20 ); + x1 = L_shr(im[s * 16], SCALEFACTOR20); + x2 = L_shr(im[s * 12], SCALEFACTOR20); + x3 = L_shr(im[s * 8], SCALEFACTOR20); + x4 = L_shr(im[s * 4], SCALEFACTOR20); + + s1 = L_add( x1, x4 ); + s4 = L_sub( x1, x4 ); + s3 = L_add( x2, x3 ); + s2 = L_sub( x2, x3 ); + t = Mpy_32_16_1( L_sub( s1, s3 ), FFT_C54 ); + s1 = L_add( s1, s3 ); + y01 = L_add( x0, s1 ); + s1 = L_add( y01, L_shl(Mpy_32_16_1(s1, FFT_C55), 1) ); + s3 = L_sub( s1, t ); + s1 = L_add( s1, t ); + t = Mpy_32_16_1( L_add( s4, s2 ), FFT_C51 ); + s4 = L_add( t, L_shl(Mpy_32_16_1( s4, FFT_C52 ), 1) ); + s2 = L_add( t, Mpy_32_16_1( s2, FFT_C53 ) ); + + y08 = L_add( r1, s2 ); + y32 = L_sub( r1, s2 ); + y16 = L_sub( r3, s4 ); + y24 = L_add( r3, s4 ); + + y09 = L_sub( s1, r2 ); + y33 = L_add( s1, r2 ); + y17 = L_add( s3, r4 ); + y25 = L_sub( s3, r4 ); + + x0 = L_shr( re[s * 5], SCALEFACTOR20 ); + x1 = L_shr( re[s * 1], SCALEFACTOR20 ); + x2 = L_shr( re[s * 17], SCALEFACTOR20 ); + x3 = L_shr( re[s * 13], SCALEFACTOR20 ); + x4 = L_shr( re[s * 9], SCALEFACTOR20 ); + + r1 = L_add( x1, x4 ); + r4 = L_sub( x1, x4 ); + r3 = L_add( x2, x3 ); + r2 = L_sub( x2, x3 ); + t = Mpy_32_16_1( L_sub( r1, r3 ), FFT_C54 ); + r1 = L_add( r1, r3 ); + y02 = L_add( x0, r1 ); + r1 = L_add( y02, L_shl(Mpy_32_16_1(r1, FFT_C55), 1) ); + r3 = L_sub( r1, t ); + r1 = L_add( r1, t ); + t = Mpy_32_16_1( L_add( r4, r2 ), FFT_C51 ); + r4 = L_add( t, L_shl(Mpy_32_16_1( r4, FFT_C52 ), 1) ); + r2 = L_add( t, Mpy_32_16_1( r2, FFT_C53 ) ); + + x0 = L_shr( im[s * 5], SCALEFACTOR20 ); + x1 = L_shr( im[s * 1], SCALEFACTOR20 ); + x2 = L_shr( im[s * 17], SCALEFACTOR20 ); + x3 = L_shr( im[s * 13], SCALEFACTOR20 ); + x4 = L_shr( im[s * 9], SCALEFACTOR20 ); + + s1 = L_add( x1, x4 ); + s4 = L_sub( x1, x4 ); + s3 = L_add( x2, x3 ); + s2 = L_sub( x2, x3 ); + t = Mpy_32_16_1( L_sub( s1, s3 ), FFT_C54 ); + s1 = L_add( s1, s3 ); + y03 = L_add( x0, s1 ); + s1 = L_add( y03, L_shl(Mpy_32_16_1(s1, FFT_C55), 1) ); + s3 = L_sub( s1, t ); + s1 = L_add( s1, t ); + t = Mpy_32_16_1( L_add( s4, s2 ), FFT_C51 ); + s4 = L_add( t, L_shl(Mpy_32_16_1( s4, FFT_C52 ), 1) ); + s2 = L_add( t, Mpy_32_16_1( s2, FFT_C53 ) ); + + y10 = L_add( r1, s2 ); + y34 = L_sub( r1, s2 ); + y18 = L_sub( r3, s4 ); + y26 = L_add( r3, s4 ); + + y11 = L_sub( s1, r2 ); + y35 = L_add( s1, r2 ); + y19 = L_add( s3, r4 ); + y27 = L_sub( s3, r4 ); + + x0 = L_shr( re[s * 10], SCALEFACTOR20 ); + x1 = L_shr( re[s * 6], SCALEFACTOR20 ); + x2 = L_shr( re[s * 2], SCALEFACTOR20 ); + x3 = L_shr( re[s * 18], SCALEFACTOR20 ); + x4 = L_shr( re[s * 14], SCALEFACTOR20 ); + + r1 = L_add( x1, x4 ); + r4 = L_sub( x1, x4 ); + r3 = L_add( x2, x3 ); + r2 = L_sub( x2, x3 ); + t = Mpy_32_16_1( L_sub( r1, r3 ), FFT_C54 ); + r1 = L_add( r1, r3 ); + y04 = L_add( x0, r1 ); + r1 = L_add( y04, L_shl(Mpy_32_16_1(r1, FFT_C55), 1) ); + r3 = L_sub( r1, t ); + r1 = L_add( r1, t ); + t = Mpy_32_16_1( L_add( r4, r2 ), FFT_C51 ); + r4 = L_add( t, L_shl(Mpy_32_16_1( r4, FFT_C52 ), 1) ); + r2 = L_add( t, Mpy_32_16_1( r2, FFT_C53 ) ); + + x0 = L_shr( im[s * 10], SCALEFACTOR20 ); + x1 = L_shr( im[s * 6], SCALEFACTOR20 ); + x2 = L_shr( im[s * 2], SCALEFACTOR20 ); + x3 = L_shr( im[s * 18], SCALEFACTOR20 ); + x4 = L_shr( im[s * 14], SCALEFACTOR20 ); + + s1 = L_add( x1, x4 ); + s4 = L_sub( x1, x4 ); + s3 = L_add( x2, x3 ); + s2 = L_sub( x2, x3 ); + t = Mpy_32_16_1( L_sub( s1, s3 ), FFT_C54 ); + s1 = L_add( s1, s3 ); + y05 = L_add( x0, s1 ); + s1 = L_add( y05, L_shl(Mpy_32_16_1(s1, FFT_C55), 1) ); + s3 = L_sub( s1, t ); + s1 = L_add( s1, t ); + t = Mpy_32_16_1( L_add( s4, s2 ), FFT_C51 ); + s4 = L_add( t, L_shl(Mpy_32_16_1( s4, FFT_C52 ), 1) ); + s2 = L_add( t, Mpy_32_16_1( s2, FFT_C53 ) ); + + y12 = L_add( r1, s2 ); + y36 = L_sub( r1, s2 ); + y20 = L_sub( r3, s4 ); + y28 = L_add( r3, s4 ); + + y13 = L_sub( s1, r2 ); + y37 = L_add( s1, r2 ); + y21 = L_add( s3, r4 ); + y29 = L_sub( s3, r4 ); + + x0 = L_shr( re[s * 15], SCALEFACTOR20 ); + x1 = L_shr( re[s * 11], SCALEFACTOR20 ); + x2 = L_shr( re[s * 7], SCALEFACTOR20 ); + x3 = L_shr( re[s * 3], SCALEFACTOR20 ); + x4 = L_shr( re[s * 19], SCALEFACTOR20 ); + + r1 = L_add( x1, x4 ); + r4 = L_sub( x1, x4 ); + r3 = L_add( x2, x3 ); + r2 = L_sub( x2, x3 ); + t = Mpy_32_16_1( L_sub( r1, r3 ), FFT_C54 ); + r1 = L_add( r1, r3 ); + y06 = L_add( x0, r1 ); + r1 = L_add( y06, L_shl(Mpy_32_16_1(r1, FFT_C55), 1) ); + r3 = L_sub( r1, t ); + r1 = L_add( r1, t ); + t = Mpy_32_16_1( L_add( r4, r2 ), FFT_C51 ); + r4 = L_add( t, L_shl(Mpy_32_16_1( r4, FFT_C52 ), 1) ); + r2 = L_add( t, Mpy_32_16_1( r2, FFT_C53 ) ); + + x0 = L_shr( im[s * 15], SCALEFACTOR20 ); + x1 = L_shr( im[s * 11], SCALEFACTOR20 ); + x2 = L_shr( im[s * 7], SCALEFACTOR20 ); + x3 = L_shr( im[s * 3], SCALEFACTOR20 ); + x4 = L_shr( im[s * 19], SCALEFACTOR20 ); + + s1 = L_add( x1, x4 ); + s4 = L_sub( x1, x4 ); + s3 = L_add( x2, x3 ); + s2 = L_sub( x2, x3 ); + t = Mpy_32_16_1( L_sub( s1, s3 ), FFT_C54 ); + s1 = L_add( s1, s3 ); + y07 = L_add( x0, s1 ); + s1 = L_add( y07, L_shl(Mpy_32_16_1(s1, FFT_C55), 1) ); + s3 = L_sub( s1, t ); + s1 = L_add( s1, t ); + t = Mpy_32_16_1( L_add( s4, s2 ), FFT_C51 ); + s4 = L_add( t, L_shl(Mpy_32_16_1( s4, FFT_C52 ), 1) ); + s2 = L_add( t, Mpy_32_16_1( s2, FFT_C53 ) ); + + y14 = L_add( r1, s2 ); + y38 = L_sub( r1, s2 ); + y22 = L_sub( r3, s4 ); + y30 = L_add( r3, s4 ); + + y15 = L_sub( s1, r2 ); + y39 = L_add( s1, r2 ); + y23 = L_add( s3, r4 ); + y31 = L_sub( s3, r4 ); + + t0 = L_add( y00, y04 ); + t2 = L_sub( y00, y04 ); + t1 = L_add( y01, y05 ); + t3 = L_sub( y01, y05 ); + t4 = L_add( y02, y06 ); + t7 = L_sub( y02, y06 ); + t5 = L_add( y07, y03 ); + t6 = L_sub( y07, y03 ); + + re[s * 0] = L_add( t0, t4 ); + im[s * 0] = L_add( t1, t5 ); + re[s * 5] = L_sub( t2, t6 ); + im[s * 5] = L_sub( t3, t7 ); + re[s * 10] = L_sub( t0, t4 ); + im[s * 10] = L_sub( t1, t5 ); + re[s * 15] = L_add( t2, t6 ); + im[s * 15] = L_add( t3, t7 ); + + t0 = L_add( y08, y12 ); + t2 = L_sub( y08, y12 ); + t1 = L_add( y09, y13 ); + t3 = L_sub( y09, y13 ); + t4 = L_add( y10, y14 ); + t7 = L_sub( y10, y14 ); + t5 = L_add( y15, y11 ); + t6 = L_sub( y15, y11 ); + + re[s * 4] = L_add( t0, t4 ); + im[s * 4] = L_add( t1, t5 ); + re[s * 9] = L_sub( t2, t6 ); + im[s * 9] = L_sub( t3, t7 ); + re[s * 14] = L_sub( t0, t4 ); + im[s * 14] = L_sub( t1, t5 ); + re[s * 19] = L_add( t2, t6 ); + im[s * 19] = L_add( t3, t7 ); + + t0 = L_add( y16, y20 ); + t2 = L_sub( y16, y20 ); + t1 = L_add( y17, y21 ); + t3 = L_sub( y17, y21 ); + t4 = L_add( y18, y22 ); + t7 = L_sub( y18, y22 ); + t5 = L_add( y23, y19 ); + t6 = L_sub( y23, y19 ); + + re[s * 8] = L_add( t0, t4 ); + im[s * 8] = L_add( t1, t5 ); + re[s * 13] = L_sub( t2, t6 ); + im[s * 13] = L_sub( t3, t7 ); + re[s * 18] = L_sub( t0, t4 ); + im[s * 18] = L_sub( t1, t5 ); + re[s * 3] = L_add( t2, t6 ); + im[s * 3] = L_add( t3, t7 ); + + t0 = L_add( y24, y28 ); + t2 = L_sub( y24, y28 ); + t1 = L_add( y25, y29 ); + t3 = L_sub( y25, y29 ); + t4 = L_add( y26, y30 ); + t7 = L_sub( y26, y30 ); + t5 = L_add( y31, y27 ); + t6 = L_sub( y31, y27 ); + + re[s * 12] = L_add( t0, t4 ); + im[s * 12] = L_add( t1, t5 ); + re[s * 17] = L_sub( t2, t6 ); + im[s * 17] = L_sub( t3, t7 ); + re[s * 2] = L_sub( t0, t4 ); + im[s * 2] = L_sub( t1, t5 ); + re[s * 7] = L_add( t2, t6 ); + im[s * 7] = L_add( t3, t7 ); + + t0 = L_add( y32, y36 ); + t2 = L_sub( y32, y36 ); + t1 = L_add( y33, y37 ); + t3 = L_sub( y33, y37 ); + t4 = L_add( y34, y38 ); + t7 = L_sub( y34, y38 ); + t5 = L_add( y39, y35 ); + t6 = L_sub( y39, y35 ); + + re[s * 16] = L_add( t0, t4 ); + im[s * 16] = L_add( t1, t5 ); + re[s * 1] = L_sub( t2, t6 ); + im[s * 1] = L_sub( t3, t7 ); + re[s * 6] = L_sub( t0, t4 ); + im[s * 6] = L_sub( t1, t5 ); + re[s * 11] = L_add( t2, t6 ); + im[s * 11] = L_add( t3, t7 ); + + return; +} + +static void fft_len30( + Word32 *re, + Word32 *im, + const Word16 s ) +{ + Word32 t; + Word32 r1, r2, r3, r4; + Word32 s1, s2, s3, s4; + Word32 x00, x01, x02, x03, x04, x05, x06, x07, x08, x09; + Word32 x10, x11, x12, x13, x14, x15, x16, x17, x18, x19; + Word32 x20, x21, x22, x23, x24, x25, x26, x27, x28, x29; + + Word32 y00, y01, y02, y03, y04, y05, y06, y07, y08, y09; + Word32 y10, y11, y12, y13, y14, y15, y16, y17, y18, y19; + Word32 y20, y21, y22, y23, y24, y25, y26, y27, y28, y29; + + Word32 z00, z01, z02, z03, z04, z05, z06, z07, z08, z09; + Word32 z10, z11, z12, z13, z14, z15, z16, z17, z18, z19; + Word32 z20, z21, z22, z23, z24, z25, z26, z27, z28, z29; + Word32 z30, z31, z32, z33, z34, z35, z36, z37, z38, z39; + Word32 z40, z41, z42, z43, z44, z45, z46, z47, z48, z49; + Word32 z50, z51, z52, z53, z54, z55, z56, z57, z58, z59; + + Word32 *rel, *reh, *iml, *imh; + + rel = &re[s * 0]; + reh = &re[s * 15]; + iml = &im[s * 0]; + imh = &im[s * 15]; + + x00 = re[s * 0]; + x01 = im[s * 0]; + x02 = re[s * 18]; + x03 = im[s * 18]; + x04 = re[s * 6]; + x05 = im[s * 6]; + x06 = re[s * 24]; + x07 = im[s * 24]; + x08 = re[s * 12]; + x09 = im[s * 12]; + + x10 = re[s * 20]; + x11 = im[s * 20]; + x12 = re[s * 8]; + x13 = im[s * 8]; + x14 = re[s * 26]; + x15 = im[s * 26]; + x16 = re[s * 14]; + x17 = im[s * 14]; + x18 = re[s * 2]; + x19 = im[s * 2]; + + x20 = re[s * 10]; + x21 = im[s * 10]; + x22 = re[s * 28]; + x23 = im[s * 28]; + x24 = re[s * 16]; + x25 = im[s * 16]; + x26 = re[s * 4]; + x27 = im[s * 4]; + x28 = re[s * 22]; + x29 = im[s * 22]; + + r1 = L_add( x02, x08 ); + r4 = L_sub( x02, x08 ); + r3 = L_add( x04, x06 ); + r2 = L_sub( x04, x06 ); + t = Mpy_32_16_1( L_sub( r1, r3 ), FFT_C54 ); + r1 = L_add( r1, r3 ); + y00 = L_add( x00, r1 ); + r1 = L_add( y00, L_shl(Mpy_32_16_1(r1, FFT_C55), 1) ); + r3 = L_sub( r1, t ); + r1 = L_add( r1, t ); + t = Mpy_32_16_1( L_add( r4, r2 ), FFT_C51 ); + r4 = L_add( t, L_shl(Mpy_32_16_1( r4, FFT_C52 ), 1) ); + r2 = L_add( t, Mpy_32_16_1( r2, FFT_C53 ) ); + + s1 = L_add( x03, x09 ); + s4 = L_sub( x03, x09 ); + s3 = L_add( x05, x07 ); + s2 = L_sub( x05, x07 ); + t = Mpy_32_16_1( L_sub( s1, s3 ), FFT_C54 ); + s1 = L_add( s1, s3 ); + y01 = L_add( x01, s1 ); + s1 = L_add( y01, L_shl(Mpy_32_16_1(s1, FFT_C55), 1) ); + s3 = L_sub( s1, t ); + s1 = L_add( s1, t ); + t = Mpy_32_16_1( L_add( s4, s2 ), FFT_C51 ); + s4 = L_add( t, L_shl(Mpy_32_16_1( s4, FFT_C52 ), 1) ); + s2 = L_add( t, Mpy_32_16_1( s2, FFT_C53 ) ); + + y02 = L_add( r1, s2 ); + y08 = L_sub( r1, s2 ); + y04 = L_sub( r3, s4 ); + y06 = L_add( r3, s4 ); + + y03 = L_sub( s1, r2 ); + y09 = L_add( s1, r2 ); + y05 = L_add( s3, r4 ); + y07 = L_sub( s3, r4 ); + + r1 = L_add( x12, x18 ); + r4 = L_sub( x12, x18 ); + r3 = L_add( x14, x16 ); + r2 = L_sub( x14, x16 ); + t = Mpy_32_16_1( L_sub( r1, r3 ), FFT_C54 ); + r1 = L_add( r1, r3 ); + y10 = L_add( x10, r1 ); + r1 = L_add( y10, L_shl(Mpy_32_16_1(r1, FFT_C55), 1) ); + r3 = L_sub( r1, t ); + r1 = L_add( r1, t ); + t = Mpy_32_16_1( L_add( r4, r2 ) , FFT_C51 ); + r4 = L_add( t, L_shl(Mpy_32_16_1( r4, FFT_C52 ), 1) ); + r2 = L_add( t, Mpy_32_16_1( r2, FFT_C53 ) ); + + s1 = L_add( x13, x19 ); + s4 = L_sub( x13, x19 ); + s3 = L_add( x15, x17 ); + s2 = L_sub( x15, x17 ); + t = Mpy_32_16_1( L_sub( s1, s3 ), FFT_C54 ); + s1 = L_add( s1, s3 ); + y11 = L_add( x11, s1 ); + s1 = L_add( y11, L_shl(Mpy_32_16_1(s1, FFT_C55), 1) ); + s3 = L_sub( s1, t ); + s1 = L_add( s1, t ); + t = Mpy_32_16_1( L_add( s4, s2 ), FFT_C51 ); + s4 = L_add( t, L_shl(Mpy_32_16_1( s4, FFT_C52 ), 1) ); + s2 = L_add( t, Mpy_32_16_1( s2, FFT_C53 ) ); + + y12 = L_add( r1, s2 ); + y18 = L_sub( r1, s2 ); + y14 = L_sub( r3, s4 ); + y16 = L_add( r3, s4 ); + + y13 = L_sub( s1, r2 ); + y19 = L_add( s1, r2 ); + y15 = L_add( s3, r4 ); + y17 = L_sub( s3, r4 ); + + r1 = L_add( x22, x28 ); + r4 = L_sub( x22, x28 ); + r3 = L_add( x24, x26 ); + r2 = L_sub( x24, x26 ); + t = Mpy_32_16_1( L_sub( r1, r3 ), FFT_C54 ); + r1 = L_add( r1, r3 ); + y20 = L_add( x20, r1 ); + r1 = L_add( y20, L_shl(Mpy_32_16_1(r1, FFT_C55), 1) ); + r3 = L_sub( r1, t ); + r1 = L_add( r1, t ); + t = Mpy_32_16_1( L_add( r4, r2 ), FFT_C51 ); + r4 = L_add( t, L_shl(Mpy_32_16_1( r4, FFT_C52 ), 1) ); + r2 = L_add( t, Mpy_32_16_1( r2, FFT_C53 ) ); + + s1 = L_add( x23, x29 ); + s4 = L_sub( x23, x29 ); + s3 = L_add( x25, x27 ); + s2 = L_sub( x25, x27 ); + t = Mpy_32_16_1( L_sub( s1, s3 ), FFT_C54 ); + s1 = L_add( s1, s3 ); + y21 = L_add( x21, s1 ); + s1 = L_add( y21, L_shl(Mpy_32_16_1(s1, FFT_C55), 1) ); + s3 = L_sub( s1, t ); + s1 = L_add( s1, t ); + t = Mpy_32_16_1( L_add( s4, s2 ), FFT_C51 ); + s4 = L_add( t, L_shl(Mpy_32_16_1( s4, FFT_C52 ), 1) ); + s2 = L_add( t, Mpy_32_16_1( s2, FFT_C53 ) ); + + y22 = L_add( r1, s2 ); + y28 = L_sub( r1, s2 ); + y24 = L_sub( r3, s4 ); + y26 = L_add( r3, s4 ); + + y23 = L_sub( s1, r2 ); + y29 = L_add( s1, r2 ); + y25 = L_add( s3, r4 ); + y27 = L_sub( s3, r4 ); + + r1 = L_add( y10, y20 ); + r2 = Mpy_32_16_1( L_sub( y10, y20 ), FFT_C31 ); + z00 = L_add( y00, r1 ); + r1 = L_sub( y00, L_shr(r1, 1) ); + + s1 = L_add( y11, y21 ); + s2 = Mpy_32_16_1( L_sub( y11, y21 ), FFT_C31 ); + z01 = L_add( y01, s1 ); + s1 = L_sub( y01, L_shr(s1, 1) ); + + z20 = L_sub( r1, s2 ); + z10 = L_add( r1, s2 ); + z21 = L_add( s1, r2 ); + z11 = L_sub( s1, r2 ); + + r1 = L_add( y12, y22 ); + r2 = Mpy_32_16_1( L_sub( y12, y22 ), FFT_C31 ); + z12 = L_add( y02, r1 ); + r1 = L_sub( y02, L_shr(r1, 1) ); + + s1 = L_add( y13, y23 ); + s2 = Mpy_32_16_1( L_sub( y13, y23 ), FFT_C31 ); + z13 = L_add( y03, s1 ); + s1 = L_sub( y03, L_shr(s1, 1)); + + z02 = L_sub( r1, s2 ); + z22 = L_add( r1, s2 ); + z03 = L_add( s1, r2 ); + z23 = L_sub( s1, r2 ); + + r1 = L_add( y14, y24 ); + r2 = Mpy_32_16_1( L_sub( y14, y24 ), FFT_C31 ); + z24 = L_add( y04, r1 ); + r1 = L_sub( y04, L_shr(r1, 1) ); + + s1 = L_add( y15, y25 ); + s2 = Mpy_32_16_1( L_sub( y15, y25 ), FFT_C31 ); + z25 = L_add( y05, s1 ); + s1 = L_sub( y05, L_shr(s1, 1) ); + + z14 = L_sub( r1, s2 ); + z04 = L_add( r1, s2 ); + z15 = L_add( s1, r2 ); + z05 = L_sub( s1, r2 ); + + r1 = L_add( y16, y26 ); + r2 = Mpy_32_16_1( L_sub( y16, y26 ), FFT_C31 ); + z06 = L_add( y06, r1 ); + r1 = L_sub( y06, L_shr(r1, 1) ); + + s1 = L_add( y17, y27 ); + s2 = Mpy_32_16_1( L_sub( y17, y27 ), FFT_C31 ); + z07 = L_add( y07, s1 ); + s1 = L_sub( y07, L_shr(s1, 1) ); + + z26 = L_sub( r1, s2 ); + z16 = L_add( r1, s2 ); + z27 = L_add( s1, r2 ); + z17 = L_sub( s1, r2 ); + + r1 = L_add( y18, y28 ); + r2 = Mpy_32_16_1( L_sub( y18, y28 ), FFT_C31 ); + z18 = L_add( y08, r1 ); + r1 = L_sub( y08, L_shr(r1, 1) ); + + s1 = L_add( y19, y29 ); + s2 = Mpy_32_16_1( L_sub( y19, y29 ), FFT_C31 ); + z19 = L_add( y09, s1 ); + s1 = L_sub(y09, L_shr(s1, 1)); + + z08 = L_sub( r1, s2 ); + z28 = L_add( r1, s2 ); + z09 = L_add( s1, r2 ); + z29 = L_sub( s1, r2 ); + + x00 = re[s * 15]; + x01 = im[s * 15]; + x02 = re[s * 3]; + x03 = im[s * 3]; + x04 = re[s * 21]; + x05 = im[s * 21]; + x06 = re[s * 9]; + x07 = im[s * 9]; + x08 = re[s * 27]; + x09 = im[s * 27]; + + x10 = re[s * 5]; + x11 = im[s * 5]; + x12 = re[s * 23]; + x13 = im[s * 23]; + x14 = re[s * 11]; + x15 = im[s * 11]; + x16 = re[s * 29]; + x17 = im[s * 29]; + x18 = re[s * 17]; + x19 = im[s * 17]; + + x20 = re[s * 25]; + x21 = im[s * 25]; + x22 = re[s * 13]; + x23 = im[s * 13]; + x24 = re[s * 1]; + x25 = im[s * 1]; + x26 = re[s * 19]; + x27 = im[s * 19]; + x28 = re[s * 7]; + x29 = im[s * 7]; + + r1 = L_add( x02, x08 ); + r4 = L_sub( x02, x08 ); + r3 = L_add( x04, x06 ); + r2 = L_sub( x04, x06 ); + t = Mpy_32_16_1( L_sub( r1, r3 ), FFT_C54 ); + r1 = L_add( r1, r3 ); + y00 = L_add( x00, r1 ); + r1 = L_add( y00, L_shl(Mpy_32_16_1(r1, FFT_C55), 1) ); + r3 = L_sub( r1, t ); + r1 = L_add( r1, t ); + t = Mpy_32_16_1( L_add( r4, r2 ), FFT_C51 ); + r4 = L_add( t, L_shl(Mpy_32_16_1( r4, FFT_C52 ), 1) ); + r2 = L_add( t, Mpy_32_16_1( r2, FFT_C53 ) ); + + s1 = L_add( x03, x09 ); + s4 = L_sub( x03, x09 ); + s3 = L_add( x05, x07 ); + s2 = L_sub( x05, x07 ); + t = Mpy_32_16_1( L_sub( s1, s3 ), FFT_C54 ); + s1 = L_add( s1, s3 ); + y01 = L_add( x01, s1 ); + s1 = L_add( y01, L_shl(Mpy_32_16_1(s1, FFT_C55), 1) ); + s3 = L_sub( s1, t ); + s1 = L_add( s1, t ); + t = Mpy_32_16_1( L_add( s4, s2 ), FFT_C51 ); + s4 = L_add( t, L_shl(Mpy_32_16_1( s4, FFT_C52 ), 1) ); + s2 = L_add( t, Mpy_32_16_1( s2, FFT_C53 ) ); + + y02 = L_add( r1, s2 ); + y08 = L_sub( r1, s2 ); + y04 = L_sub( r3, s4 ); + y06 = L_add( r3, s4 ); + + y03 = L_sub( s1, r2 ); + y09 = L_add( s1, r2 ); + y05 = L_add( s3, r4 ); + y07 = L_sub( s3, r4 ); + + r1 = L_add( x12, x18 ); + r4 = L_sub( x12, x18 ); + r3 = L_add( x14, x16 ); + r2 = L_sub( x14, x16 ); + t = Mpy_32_16_1( L_sub( r1, r3 ), FFT_C54 ); + r1 = L_add( r1, r3 ); + y10 = L_add( x10, r1 ); + r1 = L_add( y10, L_shl(Mpy_32_16_1(r1, FFT_C55), 1) ); + r3 = L_sub( r1, t ); + r1 = L_add( r1, t ); + t = Mpy_32_16_1( L_add( r4, r2 ), FFT_C51 ); + r4 = L_add( t, L_shl(Mpy_32_16_1( r4, FFT_C52 ), 1) ); + r2 = L_add( t, Mpy_32_16_1( r2, FFT_C53 ) ); + + s1 = L_add( x13, x19 ); + s4 = L_sub( x13, x19 ); + s3 = L_add( x15, x17 ); + s2 = L_sub( x15, x17 ); + t = Mpy_32_16_1(L_sub( s1, s3 ), FFT_C54 ); + s1 = L_add( s1, s3 ); + y11 = L_add( x11, s1 ); + s1 = L_add( y11, L_shl(Mpy_32_16_1(s1, FFT_C55), 1) ); + s3 = L_sub( s1, t ); + s1 = L_add( s1, t ); + t = Mpy_32_16_1( L_add( s4, s2 ), FFT_C51 ); + s4 = L_add( t, L_shl(Mpy_32_16_1( s4, FFT_C52 ), 1) ); + s2 = L_add( t, Mpy_32_16_1( s2, FFT_C53 ) ); + + y12 = L_add( r1, s2 ); + y18 = L_sub( r1, s2 ); + y14 = L_sub( r3, s4 ); + y16 = L_add( r3, s4 ); + + y13 = L_sub( s1, r2 ); + y19 = L_add( s1, r2 ); + y15 = L_add( s3, r4 ); + y17 = L_sub( s3, r4 ); + + r1 = L_add( x22, x28 ); + r4 = L_sub( x22, x28 ); + r3 = L_add( x24, x26 ); + r2 = L_sub( x24, x26 ); + t = Mpy_32_16_1( L_sub( r1, r3 ), FFT_C54 ); + r1 = L_add( r1, r3 ); + y20 = L_add( x20, r1 ); + r1 = L_add( y20, L_shl(Mpy_32_16_1(r1, FFT_C55), 1) ); + r3 = L_sub( r1, t ); + r1 = L_add( r1, t ); + t = Mpy_32_16_1( L_add( r4, r2 ), FFT_C51 ); + r4 = L_add( t, L_shl(Mpy_32_16_1( r4, FFT_C52 ), 1) ); + r2 = L_add( t, Mpy_32_16_1( r2, FFT_C53 ) ); + + s1 = L_add( x23, x29 ); + s4 = L_sub( x23, x29 ); + s3 = L_add( x25, x27 ); + s2 = L_sub( x25, x27 ); + t = Mpy_32_16_1( L_sub( s1, s3 ), FFT_C54 ); + s1 = L_add( s1, s3 ); + y21 = L_add( x21, s1 ); + s1 = L_add( y21, L_shl(Mpy_32_16_1(s1, FFT_C55), 1) ); + s3 = L_sub( s1, t ); + s1 = L_add( s1, t ); + t = Mpy_32_16_1( L_add( s4, s2 ), FFT_C51 ); + s4 = L_add( t, L_shl(Mpy_32_16_1( s4, FFT_C52 ), 1) ); + s2 = L_add( t, Mpy_32_16_1( s2, FFT_C53 ) ); + + y22 = L_add( r1, s2 ); + y28 = L_sub( r1, s2 ); + y24 = L_sub( r3, s4 ); + y26 = L_add( r3, s4 ); + + y23 = L_sub( s1, r2 ); + y29 = L_add( s1, r2 ); + y25 = L_add( s3, r4 ); + y27 = L_sub( s3, r4 ); + + r1 = L_add( y10, y20 ); + r2 = Mpy_32_16_1( L_sub( y10, y20 ), FFT_C31 ); + z30 = L_add( y00, r1 ); + r1 = L_sub( y00, L_shr(r1, 1) ); + + s1 = L_add( y11, y21 ); + s2 = Mpy_32_16_1( L_sub( y11, y21 ), FFT_C31 ); + z31 = L_add( y01, s1 ); + s1 = L_sub( y01, L_shr(s1, 1) ); + + z50 = L_sub( r1, s2 ); + z40 = L_add( r1, s2 ); + z51 = L_add( s1, r2 ); + z41 = L_sub( s1, r2 ); + + r1 = L_add( y12, y22 ); + r2 = Mpy_32_16_1( L_sub( y12, y22 ), FFT_C31 ); + z42 = L_add( y02, r1 ); + r1 = L_sub( y02, L_shr(r1, 1) ); + + s1 = L_add( y13, y23 ); + s2 = Mpy_32_16_1( L_sub( y13, y23 ), FFT_C31 ); + z43 = L_add( y03, s1 ); + s1 = L_sub( y03, L_shr(s1, 1) ); + + z32 = L_sub( r1, s2 ); + z52 = L_add( r1, s2 ); + z33 = L_add( s1, r2 ); + z53 = L_sub( s1, r2 ); + + r1 = L_add( y14, y24 ); + r2 = Mpy_32_16_1( L_sub( y14, y24 ), FFT_C31 ); + z54 = L_add( y04, r1 ); + r1 = L_sub( y04, L_shr(r1, 1) ); + + s1 = L_add( y15, y25 ); + s2 = Mpy_32_16_1( L_sub( y15, y25 ), FFT_C31 ); + z55 = L_add( y05, s1 ); + s1 = L_sub( y05, L_shr(s1, 1) ); + + z44 = L_sub( r1, s2 ); + z34 = L_add( r1, s2 ); + z45 = L_add( s1, r2 ); + z35 = L_sub( s1, r2 ); + + r1 = L_add( y16, y26 ); + r2 = Mpy_32_16_1( L_sub( y16, y26 ), FFT_C31 ); + z36 = L_add( y06, r1 ); + r1 = L_sub( y06, L_shr(r1, 1) ); + + s1 = L_add( y17, y27 ); + s2 = Mpy_32_16_1( L_sub( y17, y27 ), FFT_C31 ); + z37 = L_add( y07, s1 ); + s1 = L_sub( y07, L_shr(s1, 1) ); + + z56 = L_sub( r1, s2 ); + z46 = L_add( r1, s2 ); + z57 = L_add( s1, r2 ); + z47 = L_sub( s1, r2 ); + + r1 = L_add( y18, y28 ); + r2 = Mpy_32_16_1( L_sub( y18, y28 ), FFT_C31 ); + z48 = L_add( y08, r1 ); + r1 = L_sub( y08, L_shr(r1, 1) ); + + s1 = L_add( y19, y29 ); + s2 = Mpy_32_16_1( L_sub( y19, y29 ), FFT_C31 ); + z49 = L_add( y09, s1 ); + s1 = L_sub( y09, L_shr(s1, 1) ); + + z38 = L_sub( r1, s2 ); + z58 = L_add( r1, s2 ); + z39 = L_add( s1, r2 ); + z59 = L_sub( s1, r2 ); + + r1 = z00; + r2 = z30; + r3 = z01; + r4 = z31; + *rel = L_add( r1, r2 ); + *reh = L_sub( r1, r2 ); + *iml = L_add( r3, r4 ); + *imh = L_sub( r3, r4 ); + rel += s, reh += s, iml += s; + imh += s; + + r1 = z16; + r2 = z46; + r3 = z17; + r4 = z47; + *reh = L_add( r1, r2 ); + *rel = L_sub( r1, r2 ); + *imh = L_add( r3, r4 ); + *iml = L_sub( r3, r4 ); + rel += s, reh += s, iml += s; + imh += s; + + r1 = z02; + r2 = z32; + r3 = z03; + r4 = z33; + *rel = L_add( r1, r2 ); + *reh = L_sub( r1, r2 ); + *iml = L_add( r3, r4 ); + *imh = L_sub( r3, r4 ); + rel += s, reh += s, iml += s; + imh += s; + + r1 = z18; + r2 = z48; + r3 = z19; + r4 = z49; + *reh = L_add( r1, r2 ); + *rel = L_sub( r1, r2 ); + *imh = L_add( r3, r4 ); + *iml = L_sub( r3, r4 ); + rel += s, reh += s, iml += s; + imh += s; + + r1 = z04; + r2 = z34; + r3 = z05; + r4 = z35; + *rel = L_add( r1, r2 ); + *reh = L_sub( r1, r2 ); + *iml = L_add( r3, r4 ); + *imh = L_sub( r3, r4 ); + rel += s, reh += s, iml += s; + imh += s; + + r1 = z20; + r2 = z50; + r3 = z21; + r4 = z51; + *reh = L_add( r1, r2 ); + *rel = L_sub( r1, r2 ); + *imh = L_add( r3, r4 ); + *iml = L_sub( r3, r4 ); + rel += s, reh += s, iml += s; + imh += s; + + r1 = z06; + r2 = z36; + r3 = z07; + r4 = z37; + *rel = L_add( r1, r2 ); + *reh = L_sub( r1, r2 ); + *iml = L_add( r3, r4 ); + *imh = L_sub( r3, r4 ); + rel += s, reh += s, iml += s; + imh += s; + + r1 = z22; + r2 = z52; + r3 = z23; + r4 = z53; + *reh = L_add( r1, r2 ); + *rel = L_sub( r1, r2 ); + *imh = L_add( r3, r4 ); + *iml = L_sub( r3, r4 ); + rel += s, reh += s, iml += s; + imh += s; + + r1 = z08; + r2 = z38; + r3 = z09; + r4 = z39; + *rel = L_add( r1, r2 ); + *reh = L_sub( r1, r2 ); + *iml = L_add( r3, r4 ); + *imh = L_sub( r3, r4 ); + rel += s, reh += s, iml += s; + imh += s; + + r1 = z24; + r2 = z54; + r3 = z25; + r4 = z55; + *reh = L_add( r1, r2 ); + *rel = L_sub( r1, r2 ); + *imh = L_add( r3, r4 ); + *iml = L_sub( r3, r4 ); + rel += s, reh += s, iml += s; + imh += s; + + r1 = z10; + r2 = z40; + r3 = z11; + r4 = z41; + *rel = L_add( r1, r2 ); + *reh = L_sub( r1, r2 ); + *iml = L_add( r3, r4 ); + *imh = L_sub( r3, r4 ); + rel += s, reh += s, iml += s; + imh += s; + + r1 = z26; + r2 = z56; + r3 = z27; + r4 = z57; + *reh = L_add( r1, r2 ); + *rel = L_sub( r1, r2 ); + *imh = L_add( r3, r4 ); + *iml = L_sub( r3, r4 ); + rel += s, reh += s, iml += s; + imh += s; + + r1 = z12; + r2 = z42; + r3 = z13; + r4 = z43; + *rel = L_add( r1, r2 ); + *reh = L_sub( r1, r2 ); + *iml = L_add( r3, r4 ); + *imh = L_sub( r3, r4 ); + rel += s, reh += s, iml += s; + imh += s; + + r1 = z28; + r2 = z58; + r3 = z29; + r4 = z59; + *reh = L_add( r1, r2 ); + *rel = L_sub( r1, r2 ); + *imh = L_add( r3, r4 ); + *iml = L_sub( r3, r4 ); + rel += s, reh += s, iml += s; + imh += s; + + r1 = z14; + r2 = z44; + r3 = z15; + r4 = z45; + *rel = L_add( r1, r2 ); + *reh = L_sub( r1, r2 ); + *iml = L_add( r3, r4 ); + *imh = L_sub( r3, r4 ); + rel += s, reh += s, iml += s; + imh += s; + + return; +} + +static void fft_len32( + Word32 *re, + Word32 *im, + const Word16 s ) +{ + Word32 as, bs; + Word32 x00, x01, x02, x03, x04, x05, x06, x07; + Word32 x08, x09, x10, x11, x12, x13, x14, x15; + Word32 t00, t01, t02, t03, t04, t05, t06, t07; + Word32 t08, t09, t10, t11, t12, t13, t14, t15; + Word32 s00, s01, s02, s03, s04, s05, s06, s07; + Word32 s08, s09, s10, s11, s12, s13, s14, s15; + + Word32 y00, y01, y02, y03, y04, y05, y06, y07; + Word32 y08, y09, y10, y11, y12, y13, y14, y15; + Word32 y16, y17, y18, y19, y20, y21, y22, y23; + Word32 y24, y25, y26, y27, y28, y29, y30, y31; + Word32 y32, y33, y34, y35, y36, y37, y38, y39; + Word32 y40, y41, y42, y43, y44, y45, y46, y47; + Word32 y48, y49, y50, y51, y52, y53, y54, y55; + Word32 y56, y57, y58, y59, y60, y61, y62, y63; + + x00 = re[s * 0]; + x01 = im[s * 0]; + x02 = re[s * 4]; + x03 = im[s * 4]; + x04 = re[s * 8]; + x05 = im[s * 8]; + x06 = re[s * 12]; + x07 = im[s * 12]; + x08 = re[s * 16]; + x09 = im[s * 16]; + x10 = re[s * 20]; + x11 = im[s * 20]; + x12 = re[s * 24]; + x13 = im[s * 24]; + x14 = re[s * 28]; + x15 = im[s * 28]; + + t00 = L_add( x00, x08 ); + t02 = L_sub( x00, x08 ); + t01 = L_add( x01, x09 ); + t03 = L_sub( x01, x09 ); + t04 = L_add( x02, x10 ); + t06 = L_sub( x02, x10 ); + t05 = L_add( x03, x11 ); + t07 = L_sub( x03, x11 ); + t08 = L_add( x04, x12 ); + t10 = L_sub( x04, x12 ); + t09 = L_add( x05, x13 ); + t11 = L_sub( x05, x13 ); + t12 = L_add( x06, x14 ); + t14 = L_sub( x06, x14 ); + t13 = L_add( x07, x15 ); + t15 = L_sub( x07, x15 ); + + s00 = L_add( t00, t08 ); + s04 = L_sub( t00, t08 ); + s01 = L_add( t01, t09 ); + s05 = L_sub( t01, t09 ); + s08 = L_sub( t02, t11 ); + s10 = L_add( t02, t11 ); + s09 = L_add( t03, t10 ); + s11 = L_sub( t03, t10 ); + s02 = L_add( t04, t12 ); + s07 = L_sub( t04, t12 ); + s03 = L_add( t05, t13 ); + s06 = L_sub( t13, t05 ); + t01 = L_add( t06, t14 ); + t02 = L_sub( t06, t14 ); + t00 = L_add( t07, t15 ); + t03 = L_sub( t07, t15 ); + + { + s12 = Mpy_32_16_1( L_add( t00, t02 ), FFT_C81 ); + s14 = Mpy_32_16_1( L_sub( t00, t02 ), FFT_C81 ); + s13 = Mpy_32_16_1( L_sub( t03, t01 ), FFT_C81 ); + s15 = Mpy_32_16_1( L_add( t01, t03 ), FFT_C82 ); + }; + + y00 = L_add( s00, s02 ); + y08 = L_sub( s00, s02 ); + y01 = L_add( s01, s03 ); + y09 = L_sub( s01, s03 ); + y04 = L_sub( s04, s06 ); + y12 = L_add( s04, s06 ); + y05 = L_sub( s05, s07 ); + y13 = L_add( s05, s07 ); + y06 = L_add( s08, s14 ); + y14 = L_sub( s08, s14 ); + y07 = L_add( s09, s15 ); + y15 = L_sub( s09, s15 ); + y02 = L_add( s10, s12 ); + y10 = L_sub( s10, s12 ); + y03 = L_add( s11, s13 ); + y11 = L_sub( s11, s13 ); + + x00 = re[s * 1]; + x01 = im[s * 1]; + x02 = re[s * 5]; + x03 = im[s * 5]; + x04 = re[s * 9]; + x05 = im[s * 9]; + x06 = re[s * 13]; + x07 = im[s * 13]; + x08 = re[s * 17]; + x09 = im[s * 17]; + x10 = re[s * 21]; + x11 = im[s * 21]; + x12 = re[s * 25]; + x13 = im[s * 25]; + x14 = re[s * 29]; + x15 = im[s * 29]; + + t00 = L_add( x00, x08 ); + t02 = L_sub( x00, x08 ); + t01 = L_add( x01, x09 ); + t03 = L_sub( x01, x09 ); + t04 = L_add( x02, x10 ); + t06 = L_sub( x02, x10 ); + t05 = L_add( x03, x11 ); + t07 = L_sub( x03, x11 ); + t08 = L_add( x04, x12 ); + t10 = L_sub( x04, x12 ); + t09 = L_add( x05, x13 ); + t11 = L_sub( x05, x13 ); + t12 = L_add( x06, x14 ); + t14 = L_sub( x06, x14 ); + t13 = L_add( x07, x15 ); + t15 = L_sub( x07, x15 ); + + s00 = L_add( t00, t08 ); + s04 = L_sub( t00, t08 ); + s01 = L_add( t01, t09 ); + s05 = L_sub( t01, t09 ); + s08 = L_sub( t02, t11 ); + s10 = L_add( t02, t11 ); + s09 = L_add( t03, t10 ); + s11 = L_sub( t03, t10 ); + s02 = L_add( t04, t12 ); + s07 = L_sub( t04, t12 ); + s03 = L_add( t05, t13 ); + s06 = L_sub( t13, t05 ); + t01 = L_add( t06, t14 ); + t02 = L_sub( t06, t14 ); + t00 = L_add( t07, t15 ); + t03 = L_sub( t07, t15 ); + + { + s12 = Mpy_32_16_1( L_add( t00, t02 ), FFT_C81 ); + s14 = Mpy_32_16_1( L_sub( t00, t02 ), FFT_C81 ); + s13 = Mpy_32_16_1( L_sub( t03, t01 ), FFT_C81 ); + s15 = Mpy_32_16_1( L_add( t01, t03 ), FFT_C82 ); + }; + + y16 = L_add( s00, s02 ); + y24 = L_sub( s00, s02 ); + y17 = L_add( s01, s03 ); + y25 = L_sub( s01, s03 ); + y20 = L_sub( s04, s06 ); + y28 = L_add( s04, s06 ); + y21 = L_sub( s05, s07 ); + y29 = L_add( s05, s07 ); + y22 = L_add( s08, s14 ); + y30 = L_sub( s08, s14 ); + y23 = L_add( s09, s15 ); + y31 = L_sub( s09, s15 ); + y18 = L_add( s10, s12 ); + y26 = L_sub( s10, s12 ); + y19 = L_add( s11, s13 ); + y27 = L_sub( s11, s13 ); + + x00 = re[s * 2]; + x01 = im[s * 2]; + x02 = re[s * 6]; + x03 = im[s * 6]; + x04 = re[s * 10]; + x05 = im[s * 10]; + x06 = re[s * 14]; + x07 = im[s * 14]; + x08 = re[s * 18]; + x09 = im[s * 18]; + x10 = re[s * 22]; + x11 = im[s * 22]; + x12 = re[s * 26]; + x13 = im[s * 26]; + x14 = re[s * 30]; + x15 = im[s * 30]; + + t00 = L_add( x00, x08 ); + t02 = L_sub( x00, x08 ); + t01 = L_add( x01, x09 ); + t03 = L_sub( x01, x09 ); + t04 = L_add( x02, x10 ); + t06 = L_sub( x02, x10 ); + t05 = L_add( x03, x11 ); + t07 = L_sub( x03, x11 ); + t08 = L_add( x04, x12 ); + t10 = L_sub( x04, x12 ); + t09 = L_add( x05, x13 ); + t11 = L_sub( x05, x13 ); + t12 = L_add( x06, x14 ); + t14 = L_sub( x06, x14 ); + t13 = L_add( x07, x15 ); + t15 = L_sub( x07, x15 ); + + s00 = L_add( t00, t08 ); + s04 = L_sub( t00, t08 ); + s01 = L_add( t01, t09 ); + s05 = L_sub( t01, t09 ); + s08 = L_sub( t02, t11 ); + s10 = L_add( t02, t11 ); + s09 = L_add( t03, t10 ); + s11 = L_sub( t03, t10 ); + s02 = L_add( t04, t12 ); + s07 = L_sub( t04, t12 ); + s03 = L_add( t05, t13 ); + s06 = L_sub( t13, t05 ); + t01 = L_add( t06, t14 ); + t02 = L_sub( t06, t14 ); + t00 = L_add( t07, t15 ); + t03 = L_sub( t07, t15 ); + + { + s12 = Mpy_32_16_1( L_add( t00, t02 ), FFT_C81 ); + s14 = Mpy_32_16_1( L_sub( t00, t02 ), FFT_C81 ); + s13 = Mpy_32_16_1( L_sub( t03, t01 ), FFT_C81 ); + s15 = Mpy_32_16_1( L_add( t01, t03 ), FFT_C82 ); + }; + + y32 = L_add( s00, s02 ); + y40 = L_sub( s00, s02 ); + y33 = L_add( s01, s03 ); + y41 = L_sub( s01, s03 ); + y36 = L_sub( s04, s06 ); + y44 = L_add( s04, s06 ); + y37 = L_sub( s05, s07 ); + y45 = L_add( s05, s07 ); + y38 = L_add( s08, s14 ); + y46 = L_sub( s08, s14 ); + y39 = L_add( s09, s15 ); + y47 = L_sub( s09, s15 ); + y34 = L_add( s10, s12 ); + y42 = L_sub( s10, s12 ); + y35 = L_add( s11, s13 ); + y43 = L_sub( s11, s13 ); + + x00 = re[s * 3]; + x01 = im[s * 3]; + x02 = re[s * 7]; + x03 = im[s * 7]; + x04 = re[s * 11]; + x05 = im[s * 11]; + x06 = re[s * 15]; + x07 = im[s * 15]; + x08 = re[s * 19]; + x09 = im[s * 19]; + x10 = re[s * 23]; + x11 = im[s * 23]; + x12 = re[s * 27]; + x13 = im[s * 27]; + x14 = re[s * 31]; + x15 = im[s * 31]; + + t00 = L_add( x00, x08 ); + t02 = L_sub( x00, x08 ); + t01 = L_add( x01, x09 ); + t03 = L_sub( x01, x09 ); + t04 = L_add( x02, x10 ); + t06 = L_sub( x02, x10 ); + t05 = L_add( x03, x11 ); + t07 = L_sub( x03, x11 ); + t08 = L_add( x04, x12 ); + t10 = L_sub( x04, x12 ); + t09 = L_add( x05, x13 ); + t11 = L_sub( x05, x13 ); + t12 = L_add( x06, x14 ); + t14 = L_sub( x06, x14 ); + t13 = L_add( x07, x15 ); + t15 = L_sub( x07, x15 ); + + s00 = L_add( t00, t08 ); + s04 = L_sub( t00, t08 ); + s01 = L_add( t01, t09 ); + s05 = L_sub( t01, t09 ); + s08 = L_sub( t02, t11 ); + s10 = L_add( t02, t11 ); + s09 = L_add( t03, t10 ); + s11 = L_sub( t03, t10 ); + s02 = L_add( t04, t12 ); + s07 = L_sub( t04, t12 ); + s03 = L_add( t05, t13 ); + s06 = L_sub( t13, t05 ); + t01 = L_add( t06, t14 ); + t02 = L_sub( t06, t14 ); + t00 = L_add( t07, t15 ); + t03 = L_sub( t07, t15 ); + + { + s12 = Mpy_32_16_1( L_add( t00, t02 ), FFT_C81 ); + s14 = Mpy_32_16_1( L_sub( t00, t02 ), FFT_C81 ); + s13 = Mpy_32_16_1( L_sub( t03, t01 ), FFT_C81 ); + s15 = Mpy_32_16_1( L_add( t01, t03 ), FFT_C82 ); + }; + + y48 = L_add( s00, s02 ); + y56 = L_sub( s00, s02 ); + y49 = L_add( s01, s03 ); + y57 = L_sub( s01, s03 ); + y52 = L_sub( s04, s06 ); + y60 = L_add( s04, s06 ); + y53 = L_sub( s05, s07 ); + y61 = L_add( s05, s07 ); + y54 = L_add( s08, s14 ); + y62 = L_sub( s08, s14 ); + y55 = L_add( s09, s15 ); + y63 = L_sub( s09, s15 ); + y50 = L_add( s10, s12 ); + y58 = L_sub( s10, s12 ); + y51 = L_add( s11, s13 ); + y59 = L_sub( s11, s13 ); + + + { + as = y18; + bs = y19; + y18 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 0 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 0 + 1] ) ); + y19 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 0 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 0 + 0] ) ); + }; + { + as = y20; + bs = y21; + y20 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 1 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 1 + 1] ) ); + y21 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 1 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 1 + 0] ) ); + }; + { + as = y22; + bs = y23; + y22 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 2 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 2 + 1] ) ); + y23 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 2 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 2 + 0] ) ); + }; + { + as = y24; + bs = y25; + y24 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 3 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 3 + 1] ) ); + y25 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 3 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 3 + 0] ) ); + }; + { + as = y26; + bs = y27; + y26 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 4 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 4 + 1] ) ); + y27 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 4 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 4 + 0] ) ); + }; + { + as = y28; + bs = y29; + y28 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 5 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 5 + 1] ) ); + y29 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 5 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 5 + 0] ) ); + }; + { + as = y30; + bs = y31; + y30 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 6 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 6 + 1] ) ); + y31 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 6 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 6 + 0] ) ); + }; + { + as = y34; + bs = y35; + y34 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 7 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 7 + 1] ) ); + y35 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 7 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 7 + 0] ) ); + }; + { + as = y36; + bs = y37; + y36 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 8 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 8 + 1] ) ); + y37 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 8 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 8 + 0] ) ); + }; + { + as = y38; + bs = y39; + y38 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 9 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 9 + 1] ) ); + y39 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 9 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 9 + 0] ) ); + }; + { + as = y42; + bs = y43; + y42 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 10 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 10 + 1] ) ); + y43 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 10 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 10 + 0] ) ); + }; + { + as = y44; + bs = y45; + y44 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 11 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 11 + 1] ) ); + y45 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 11 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 11 + 0] ) ); + }; + { + as = y46; + bs = y47; + y46 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 12 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 12 + 1] ) ); + y47 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 12 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 12 + 0] ) ); + }; + { + as = y50; + bs = y51; + y50 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 13 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 13 + 1] ) ); + y51 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 13 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 13 + 0] ) ); + }; + { + as = y52; + bs = y53; + y52 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 14 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 14 + 1] ) ); + y53 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 14 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 14 + 0] ) ); + }; + { + as = y54; + bs = y55; + y54 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 15 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 15 + 1] ) ); + y55 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 15 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 15 + 0] ) ); + }; + { + as = y56; + bs = y57; + y56 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 16 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 16 + 1] ) ); + y57 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 16 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 16 + 0] ) ); + }; + { + as = y58; + bs = y59; + y58 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 17 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 17 + 1] ) ); + y59 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 17 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 17 + 0] ) ); + }; + { + as = y60; + bs = y61; + y60 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 18 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 18 + 1] ) ); + y61 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 18 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 18 + 0] ) ); + }; + { + as = y62; + bs = y63; + y62 = L_sub( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 19 + 0] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 19 + 1] ) ); + y63 = L_add( Mpy_32_16_1( as, FFT_RotVector_32_fx[2 * 19 + 1] ), Mpy_32_16_1( bs, FFT_RotVector_32_fx[2 * 19 + 0] ) ); + }; + + t00 = L_add( y00, y32 ); + t02 = L_sub( y00, y32 ); + t01 = L_add( y01, y33 ); + t03 = L_sub( y01, y33 ); + t04 = L_add( y16, y48 ); + t07 = L_sub( y16, y48 ); + t05 = L_add( y49, y17 ); + t06 = L_sub( y49, y17 ); + + re[s * 0] = L_add( t00, t04 ); + im[s * 0] = L_add( t01, t05 ); + re[s * 8] = L_sub( t02, t06 ); + im[s * 8] = L_sub( t03, t07 ); + re[s * 16] = L_sub( t00, t04 ); + im[s * 16] = L_sub( t01, t05 ); + re[s * 24] = L_add( t02, t06 ); + im[s * 24] = L_add( t03, t07 ); + + t00 = L_add( y02, y34 ); + t02 = L_sub( y02, y34 ); + t01 = L_add( y03, y35 ); + t03 = L_sub( y03, y35 ); + t04 = L_add( y18, y50 ); + t07 = L_sub( y18, y50 ); + t05 = L_add( y51, y19 ); + t06 = L_sub( y51, y19 ); + + re[s * 1] = L_add( t00, t04 ); + im[s * 1] = L_add( t01, t05 ); + re[s * 9] = L_sub( t02, t06 ); + im[s * 9] = L_sub( t03, t07 ); + re[s * 17] = L_sub( t00, t04 ); + im[s * 17] = L_sub( t01, t05 ); + re[s * 25] = L_add( t02, t06 ); + im[s * 25] = L_add( t03, t07 ); + + t00 = L_add( y04, y36 ); + t02 = L_sub( y04, y36 ); + t01 = L_add( y05, y37 ); + t03 = L_sub( y05, y37 ); + t04 = L_add( y20, y52 ); + t07 = L_sub( y20, y52 ); + t05 = L_add( y53, y21 ); + t06 = L_sub( y53, y21 ); + + re[s * 2] = L_add( t00, t04 ); + im[s * 2] = L_add( t01, t05 ); + re[s * 10] = L_sub( t02, t06 ); + im[s * 10] = L_sub( t03, t07 ); + re[s * 18] = L_sub( t00, t04 ); + im[s * 18] = L_sub( t01, t05 ); + re[s * 26] = L_add( t02, t06 ); + im[s * 26] = L_add( t03, t07 ); + + t00 = L_add( y06, y38 ); + t02 = L_sub( y06, y38 ); + t01 = L_add( y07, y39 ); + t03 = L_sub( y07, y39 ); + t04 = L_add( y22, y54 ); + t07 = L_sub( y22, y54 ); + t05 = L_add( y55, y23 ); + t06 = L_sub( y55, y23 ); + + re[s * 3] = L_add( t00, t04 ); + im[s * 3] = L_add( t01, t05 ); + re[s * 11] = L_sub( t02, t06 ); + im[s * 11] = L_sub( t03, t07 ); + re[s * 19] = L_sub( t00, t04 ); + im[s * 19] = L_sub( t01, t05 ); + re[s * 27] = L_add( t02, t06 ); + im[s * 27] = L_add( t03, t07 ); + + t00 = L_add( y08, y41 ); + t02 = L_sub( y08, y41 ); + t01 = L_sub( y09, y40 ); + t03 = L_add( y09, y40 ); + t04 = L_add( y24, y56 ); + t07 = L_sub( y24, y56 ); + t05 = L_add( y57, y25 ); + t06 = L_sub( y57, y25 ); + + re[s * 4] = L_add( t00, t04 ); + im[s * 4] = L_add( t01, t05 ); + re[s * 12] = L_sub( t02, t06 ); + im[s * 12] = L_sub( t03, t07 ); + re[s * 20] = L_sub( t00, t04 ); + im[s * 20] = L_sub( t01, t05 ); + re[s * 28] = L_add( t02, t06 ); + im[s * 28] = L_add( t03, t07 ); + + t00 = L_add( y10, y42 ); + t02 = L_sub( y10, y42 ); + t01 = L_add( y11, y43 ); + t03 = L_sub( y11, y43 ); + t04 = L_add( y26, y58 ); + t07 = L_sub( y26, y58 ); + t05 = L_add( y59, y27 ); + t06 = L_sub( y59, y27 ); + + re[s * 5] = L_add( t00, t04 ); + im[s * 5] = L_add( t01, t05 ); + re[s * 13] = L_sub( t02, t06 ); + im[s * 13] = L_sub( t03, t07 ); + re[s * 21] = L_sub( t00, t04 ); + im[s * 21] = L_sub( t01, t05 ); + re[s * 29] = L_add( t02, t06 ); + im[s * 29] = L_add( t03, t07 ); + + t00 = L_add( y12, y44 ); + t02 = L_sub( y12, y44 ); + t01 = L_add( y13, y45 ); + t03 = L_sub( y13, y45 ); + t04 = L_add( y28, y60 ); + t07 = L_sub( y28, y60 ); + t05 = L_add( y61, y29 ); + t06 = L_sub( y61, y29 ); + + re[s * 6] = L_add( t00, t04 ); + im[s * 6] = L_add( t01, t05 ); + re[s * 14] = L_sub( t02, t06 ); + im[s * 14] = L_sub( t03, t07 ); + re[s * 22] = L_sub( t00, t04 ); + im[s * 22] = L_sub( t01, t05 ); + re[s * 30] = L_add( t02, t06 ); + im[s * 30] = L_add( t03, t07 ); + + t00 = L_add( y14, y46 ); + t02 = L_sub( y14, y46 ); + t01 = L_add( y15, y47 ); + t03 = L_sub( y15, y47 ); + t04 = L_add( y30, y62 ); + t07 = L_sub( y30, y62 ); + t05 = L_add( y63, y31 ); + t06 = L_sub( y63, y31 ); + + re[s * 7] = L_add( t00, t04 ); + im[s * 7] = L_add( t01, t05 ); + re[s * 15] = L_sub( t02, t06 ); + im[s * 15] = L_sub( t03, t07 ); + re[s * 23] = L_sub( t00, t04 ); + im[s * 23] = L_sub( t01, t05 ); + re[s * 31] = L_add( t02, t06 ); + im[s * 31] = L_add( t03, t07 ); + + return; +} + +static void fft_lenN( + Word32 *re, + Word32 *im, + const Word16 *W, + const Word16 len, + const Word16 dim1, + const Word16 dim2, + const Word16 sx, + const Word16 sc, + const Word16 Woff ) +{ + Word16 i, j; + Word32 x[L_FRAME_MAX * 2]; + + FOR ( i = 0; i < dim2; i++ ) + { + FOR ( j = 0; j < dim1; j++ ) + { + x[2 * i * dim1 + 2 * j] = re[sx * i + sx * j * dim2]; + x[2 * i * dim1 + 2 * j + 1] = im[sx * i + sx * j * dim2]; + } + } + + SWITCH ( dim1 ) + { + case 5: + FOR ( i = 0; i < dim2; i++ ) + { + fft_len5( &x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2 ); + } + BREAK; + + case 8: + FOR ( i = 0; i < dim2; i++ ) + { + fft_len8( &x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2 ); + } + BREAK; + + case 10: + FOR ( i = 0; i < dim2; i++ ) + { + fft_len10( &x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2 ); + } + BREAK; + + case 15: + FOR ( i = 0; i < dim2; i++ ) + { + fft_len15( &x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2 ); + } + BREAK; + + case 16: + FOR ( i = 0; i < dim2; i++ ) + { + fft_len16( &x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2 ); + } + BREAK; + + case 20: + FOR ( i = 0; i < dim2; i++ ) + { + fft_len20_fx( &x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2 ); + } + BREAK; + + case 30: + FOR ( i = 0; i < dim2; i++ ) + { + fft_len30( &x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2 ); + } + BREAK; + + case 32: + FOR ( i = 0; i < dim2; i++ ) + { + fft_len32( &x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2 ); + } + BREAK; + } + + SWITCH ( dim2 ) + { + + case 8: + { + Word32 x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, x11, x12, x13, x14, x15; + Word32 t00, t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13, t14, t15; + Word32 s00, s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15; + + IF (EQ_16(dim1, 30) || EQ_16(dim1, 20) || EQ_16(dim1, 15) || EQ_16(dim1, 10) || EQ_16(dim1, 5)) + { + FOR ( i = 0; i < dim1; i++ ) + { + { + x00 = x[2 * i + 2 * 0 * dim1]; + x01 = x[2 * i + 2 * 0 * dim1 + 1]; + }; + IF (EQ_16(i, 0)) + { + { + x02 = x[2 * i + 2 * 1 * dim1]; + x03 = x[2 * i + 2 * 1 * dim1 + 1]; + }; + { + x04 = x[2 * i + 2 * 2 * dim1]; + x05 = x[2 * i + 2 * 2 * dim1 + 1]; + }; + { + x06 = x[2 * i + 2 * 3 * dim1]; + x07 = x[2 * i + 2 * 3 * dim1 + 1]; + }; + { + x08 = x[2 * i + 2 * 4 * dim1]; + x09 = x[2 * i + 2 * 4 * dim1 + 1]; + }; + { + x10 = x[2 * i + 2 * 5 * dim1]; + x11 = x[2 * i + 2 * 5 * dim1 + 1]; + }; + { + x12 = x[2 * i + 2 * 6 * dim1]; + x13 = x[2 * i + 2 * 6 * dim1 + 1]; + }; + { + x14 = x[2 * i + 2 * 7 * dim1]; + x15 = x[2 * i + 2 * 7 * dim1 + 1]; + }; + } + ELSE + { + { + x02 = L_sub( Mpy_32_16_1(x[2 * i + 2 * 1 * dim1], W[sc * i + sc * 1 * dim1 * 2 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 1 * dim1 + 1], W[sc * i + sc * 1 * dim1 * 2 + 1 - Woff])); + x03 = L_add( Mpy_32_16_1(x[2 * i + 2 * 1 * dim1], W[sc * i + sc * 1 * dim1 * 2 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 1 * dim1 + 1], W[sc * i + sc * 1 * dim1 * 2 - Woff] )); + }; + { + x04 = L_sub( Mpy_32_16_1(x[2 * i + 2 * 2 * dim1], W[sc * i + sc * 2 * dim1 * 2 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 2 * dim1 + 1], W[sc * i + sc * 2 * dim1 * 2 + 1 - Woff])); + x05 = L_add( Mpy_32_16_1(x[2 * i + 2 * 2 * dim1], W[sc * i + sc * 2 * dim1 * 2 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 2 * dim1 + 1], W[sc * i + sc * 2 * dim1 * 2 - Woff] )); + }; + { + x06 = L_sub( Mpy_32_16_1(x[2 * i + 2 * 3 * dim1], W[sc * i + sc * 3 * dim1 * 2 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 3 * dim1 + 1], W[sc * i + sc * 3 * dim1 * 2 + 1 - Woff] )); + x07 = L_add( Mpy_32_16_1(x[2 * i + 2 * 3 * dim1], W[sc * i + sc * 3 * dim1 * 2 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 3 * dim1 + 1], W[sc * i + sc * 3 * dim1 * 2 - Woff] )); + }; + { + x08 = L_sub( Mpy_32_16_1(x[2 * i + 2 * 4 * dim1], W[sc * i + sc * 4 * dim1 * 2 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 4 * dim1 + 1], W[sc * i + sc * 4 * dim1 * 2 + 1 - Woff] )); + x09 = L_add( Mpy_32_16_1(x[2 * i + 2 * 4 * dim1], W[sc * i + sc * 4 * dim1 * 2 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 4 * dim1 + 1], W[sc * i + sc * 4 * dim1 * 2 - Woff] )); + }; + { + x10 = L_sub( Mpy_32_16_1(x[2 * i + 2 * 5 * dim1], W[sc * i + sc * 5 * dim1 * 2 - Woff]), + Mpy_32_16_1(x[2 * i + 2 * 5 * dim1 + 1], W[sc * i + sc * 5 * dim1 * 2 + 1 - Woff] )); + x11 = L_add( Mpy_32_16_1(x[2 * i + 2 * 5 * dim1], W[sc * i + sc * 5 * dim1 * 2 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 5 * dim1 + 1], W[sc * i + sc * 5 * dim1 * 2 - Woff] )); + }; + { + x12 = L_sub( Mpy_32_16_1(x[2 * i + 2 * 6 * dim1], W[sc * i + sc * 6 * dim1 * 2 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 6 * dim1 + 1], W[sc * i + sc * 6 * dim1 * 2 + 1 - Woff] )); + x13 = L_add( Mpy_32_16_1(x[2 * i + 2 * 6 * dim1], W[sc * i + sc * 6 * dim1 * 2 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 6 * dim1 + 1], W[sc * i + sc * 6 * dim1 * 2 - Woff] )); + }; + { + x14 = L_sub( Mpy_32_16_1(x[2 * i + 2 * 7 * dim1], W[sc * i + sc * 7 * dim1 * 2 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 7 * dim1 + 1], W[sc * i + sc * 7 * dim1 * 2 + 1 - Woff] )); + x15 = L_add( Mpy_32_16_1(x[2 * i + 2 * 7 * dim1], W[sc * i + sc * 7 * dim1 * 2 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 7 * dim1 + 1], W[sc * i + sc * 7 * dim1 * 2 - Woff] )); + }; + } + + t00 = L_add( x00, x08 ); + t02 = L_sub( x00, x08 ); + t01 = L_add( x01, x09 ); + t03 = L_sub( x01, x09 ); + t04 = L_add( x02, x10 ); + t06 = L_sub( x02, x10 ); + t05 = L_add( x03, x11 ); + t07 = L_sub( x03, x11 ); + t08 = L_add( x04, x12 ); + t10 = L_sub( x04, x12 ); + t09 = L_add( x05, x13 ); + t11 = L_sub( x05, x13 ); + t12 = L_add( x06, x14 ); + t14 = L_sub( x06, x14 ); + t13 = L_add( x07, x15 ); + t15 = L_sub( x07, x15 ); + + s00 = L_add( t00, t08 ); + s04 = L_sub( t00, t08 ); + s01 = L_add( t01, t09 ); + s05 = L_sub( t01, t09 ); + s08 = L_sub( t02, t11 ); + s10 = L_add( t02, t11 ); + s09 = L_add( t03, t10 ); + s11 = L_sub( t03, t10 ); + s02 = L_add( t04, t12 ); + s07 = L_sub( t04, t12 ); + s03 = L_add( t05, t13 ); + s06 = L_sub( t13, t05 ); + + t01 = L_add( t06, t14 ); + t02 = L_sub( t06, t14 ); + t00 = L_add( t07, t15 ); + t03 = L_sub( t07, t15 ); + + s12 = Mpy_32_16_1( L_add( t00, t02 ), FFT_C81 ); + s14 = Mpy_32_16_1( L_sub( t00, t02 ), FFT_C81 ); + s13 = Mpy_32_16_1( L_sub( t03, t01 ), FFT_C81 ); + s15 = Mpy_32_16_1( L_add( t01, t03 ), FFT_C82 ); + + re[sx * i + sx * 0 * dim1] = L_add( s00, s02 ); + im[sx * i + sx * 0 * dim1] = L_add( s01, s03 ); + re[sx * i + sx * 1 * dim1] = L_add( s10, s12 ); + im[sx * i + sx * 1 * dim1] = L_add( s11, s13 ); + re[sx * i + sx * 2 * dim1] = L_sub( s04, s06 ); + im[sx * i + sx * 2 * dim1] = L_sub( s05, s07 ); + re[sx * i + sx * 3 * dim1] = L_add( s08, s14 ); + im[sx * i + sx * 3 * dim1] = L_add( s09, s15 ); + re[sx * i + sx * 4 * dim1] = L_sub( s00, s02 ); + im[sx * i + sx * 4 * dim1] = L_sub( s01, s03 ); + re[sx * i + sx * 5 * dim1] = L_sub( s10, s12 ); + im[sx * i + sx * 5 * dim1] = L_sub( s11, s13 ); + re[sx * i + sx * 6 * dim1] = L_add( s04, s06 ); + im[sx * i + sx * 6 * dim1] = L_add( s05, s07 ); + re[sx * i + sx * 7 * dim1] = L_sub( s08, s14 ); + im[sx * i + sx * 7 * dim1] = L_sub( s09, s15 ); + } + } + ELSE + { + FOR ( i = 0; i < dim1; i++ ) + { + { + x00 = x[2 * i + 2 * 0 * dim1]; + x01 = x[2 * i + 2 * 0 * dim1 + 1]; + }; + IF (EQ_16(i, 0)) + { + { + x02 = x[2 * i + 2 * 1 * dim1]; + x03 = x[2 * i + 2 * 1 * dim1 + 1]; + }; + { + x04 = x[2 * i + 2 * 2 * dim1]; + x05 = x[2 * i + 2 * 2 * dim1 + 1]; + }; + { + x06 = x[2 * i + 2 * 3 * dim1]; + x07 = x[2 * i + 2 * 3 * dim1 + 1]; + }; + { + x08 = x[2 * i + 2 * 4 * dim1]; + x09 = x[2 * i + 2 * 4 * dim1 + 1]; + }; + { + x10 = x[2 * i + 2 * 5 * dim1]; + x11 = x[2 * i + 2 * 5 * dim1 + 1]; + }; + { + x12 = x[2 * i + 2 * 6 * dim1]; + x13 = x[2 * i + 2 * 6 * dim1 + 1]; + }; + { + x14 = x[2 * i + 2 * 7 * dim1]; + x15 = x[2 * i + 2 * 7 * dim1 + 1]; + }; + } + ELSE + { + { + x02 = L_sub( Mpy_32_16_1(x[2 * i + 2 * 1 * dim1], W[sc * i + sc * 1 * dim1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 1 * dim1 + 1], W[sc * i + sc * 1 * dim1 + 1 - Woff])); + x03 = L_add( Mpy_32_16_1(x[2 * i + 2 * 1 * dim1], W[sc * i + sc * 1 * dim1 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 1 * dim1 + 1], W[sc * i + sc * 1 * dim1 - Woff] )); + }; + { + x04 = L_sub( Mpy_32_16_1(x[2 * i + 2 * 2 * dim1], W[sc * i + sc * 2 * dim1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 2 * dim1 + 1], W[sc * i + sc * 2 * dim1 + 1 - Woff])); + x05 = L_add( Mpy_32_16_1(x[2 * i + 2 * 2 * dim1], W[sc * i + sc * 2 * dim1 + 1 - Woff] ), + Mpy_32_16_1( x[2 * i + 2 * 2 * dim1 + 1], W[sc * i + sc * 2 * dim1 - Woff])); + }; + { + x06 = L_sub( Mpy_32_16_1(x[2 * i + 2 * 3 * dim1], W[sc * i + sc * 3 * dim1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 3 * dim1 + 1], W[sc * i + sc * 3 * dim1 + 1 - Woff] )); + x07 = L_add( Mpy_32_16_1(x[2 * i + 2 * 3 * dim1], W[sc * i + sc * 3 * dim1 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 3 * dim1 + 1], W[sc * i + sc * 3 * dim1 - Woff] )); + }; + { + x08 = L_sub( Mpy_32_16_1(x[2 * i + 2 * 4 * dim1], W[sc * i + sc * 4 * dim1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 4 * dim1 + 1], W[sc * i + sc * 4 * dim1 + 1 - Woff])); + x09 = L_add( Mpy_32_16_1(x[2 * i + 2 * 4 * dim1], W[sc * i + sc * 4 * dim1 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 4 * dim1 + 1], W[sc * i + sc * 4 * dim1 - Woff] )); + }; + { + x10 = L_sub( Mpy_32_16_1(x[2 * i + 2 * 5 * dim1], W[sc * i + sc * 5 * dim1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 5 * dim1 + 1], W[sc * i + sc * 5 * dim1 + 1 - Woff] )); + x11 = L_add( Mpy_32_16_1(x[2 * i + 2 * 5 * dim1], W[sc * i + sc * 5 * dim1 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 5 * dim1 + 1], W[sc * i + sc * 5 * dim1 - Woff] )); + }; + { + x12 = L_sub( Mpy_32_16_1(x[2 * i + 2 * 6 * dim1], W[sc * i + sc * 6 * dim1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 6 * dim1 + 1], W[sc * i + sc * 6 * dim1 + 1 - Woff] )); + x13 = L_add( Mpy_32_16_1(x[2 * i + 2 * 6 * dim1], W[sc * i + sc * 6 * dim1 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 6 * dim1 + 1], W[sc * i + sc * 6 * dim1 - Woff] )); + }; + { + x14 = L_sub( Mpy_32_16_1(x[2 * i + 2 * 7 * dim1], W[sc * i + sc * 7 * dim1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 7 * dim1 + 1], W[sc * i + sc * 7 * dim1 + 1 - Woff] )); + x15 = L_add( Mpy_32_16_1(x[2 * i + 2 * 7 * dim1], W[sc * i + sc * 7 * dim1 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * 7 * dim1 + 1], W[sc * i + sc * 7 * dim1 - Woff] )); + }; + } + + t00 = L_add( x00, x08 ); + t02 = L_sub( x00, x08 ); + t01 = L_add( x01, x09 ); + t03 = L_sub( x01, x09 ); + t04 = L_add( x02, x10 ); + t06 = L_sub( x02, x10 ); + t05 = L_add( x03, x11 ); + t07 = L_sub( x03, x11 ); + t08 = L_add( x04, x12 ); + t10 = L_sub( x04, x12 ); + t09 = L_add( x05, x13 ); + t11 = L_sub( x05, x13 ); + t12 = L_add( x06, x14 ); + t14 = L_sub( x06, x14 ); + t13 = L_add( x07, x15 ); + t15 = L_sub( x07, x15 ); + + s00 = L_add( t00, t08 ); + s04 = L_sub( t00, t08 ); + s01 = L_add( t01, t09 ); + s05 = L_sub( t01, t09 ); + s08 = L_sub( t02, t11 ); + s10 = L_add( t02, t11 ); + s09 = L_add( t03, t10 ); + s11 = L_sub( t03, t10 ); + s02 = L_add( t04, t12 ); + s07 = L_sub( t04, t12 ); + s03 = L_add( t05, t13 ); + s06 = L_sub( t13, t05 ); + + t01 = L_add( t06, t14 ); + t02 = L_sub( t06, t14 ); + t00 = L_add( t07, t15 ); + t03 = L_sub( t07, t15 ); + + s12 = Mpy_32_16_1( L_add( t00, t02 ), FFT_C81 ); + s14 = Mpy_32_16_1( L_sub( t00, t02 ), FFT_C81 ); + s13 = Mpy_32_16_1( L_sub( t03, t01 ), FFT_C81 ); + s15 = Mpy_32_16_1( L_add( t01, t03 ), FFT_C82 ); + + re[sx * i + sx * 0 * dim1] = L_add( s00, s02 ); + im[sx * i + sx * 0 * dim1] = L_add( s01, s03 ); + re[sx * i + sx * 1 * dim1] = L_add( s10, s12 ); + im[sx * i + sx * 1 * dim1] = L_add( s11, s13 ); + re[sx * i + sx * 2 * dim1] = L_sub( s04, s06 ); + im[sx * i + sx * 2 * dim1] = L_sub( s05, s07 ); + re[sx * i + sx * 3 * dim1] = L_add( s08, s14 ); + im[sx * i + sx * 3 * dim1] = L_add( s09, s15 ); + re[sx * i + sx * 4 * dim1] = L_sub( s00, s02 ); + im[sx * i + sx * 4 * dim1] = L_sub( s01, s03 ); + re[sx * i + sx * 5 * dim1] = L_sub( s10, s12 ); + im[sx * i + sx * 5 * dim1] = L_sub( s11, s13 ); + re[sx * i + sx * 6 * dim1] = L_add( s04, s06 ); + im[sx * i + sx * 6 * dim1] = L_add( s05, s07 ); + re[sx * i + sx * 7 * dim1] = L_sub( s08, s14 ); + im[sx * i + sx * 7 * dim1] = L_sub( s09, s15 ); + } + } + BREAK; + } + + case 10: + { + Word32 y[2 * 10]; + FOR ( j = 0; j < dim2; j++ ) + { + { + y[2 * j] = x[2 * 0 + 2 * j * dim1]; + y[2 * j + 1] = x[2 * 0 + 2 * j * dim1 + 1]; + }; + } + fft_len10( &y[0], &y[1], 2 ); + FOR ( j = 0; j < dim2; j++ ) + { + re[sx * 0 + sx * j * dim1] = y[2 * j]; + im[sx * 0 + sx * j * dim1] = y[2 * j + 1]; + } + + FOR ( i = 1; i < dim1; i++ ) + { + { + y[2 * ( 0 + 0 )] = x[2 * i + 2 * ( 0 + 0 ) * dim1]; + y[2 * ( 0 + 0 ) + 1] = x[2 * i + 2 * ( 0 + 0 ) * dim1 + 1]; + } + + FOR ( j = 1; j < dim2; j++ ) + { + { + y[2 * ( j + 0 )] = L_sub( Mpy_32_16_1(x[2 * i + 2 * ( j + 0 ) * dim1], W[sc * i + sc * j * dim1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * ( j + 0 ) * dim1 + 1], W[sc * i + sc * j * dim1 + 1 - Woff] )); + y[2 * ( j + 0 ) + 1] = L_add( Mpy_32_16_1(x[2 * i + 2 * ( j + 0 ) * dim1], W[sc * i + sc * j * dim1 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * ( j + 0 ) * dim1 + 1], W[sc * i + sc * j * dim1 - Woff] )); + } + } + fft_len10( &y[0], &y[1], 2 ); + FOR ( j = 0; j < dim2; j++ ) + { + re[sx * i + sx * j * dim1] = y[2 * j]; + im[sx * i + sx * j * dim1] = y[2 * j + 1]; + } + } + BREAK; + } + + case 16: + { + Word32 y[2 * 16]; + FOR ( j = 0; j < dim2; j++ ) + { + { + y[2 * j] = x[2 * 0 + 2 * j * dim1]; + y[2 * j + 1] = x[2 * 0 + 2 * j * dim1 + 1]; + }; + } + fft_len16( &y[0], &y[1], 2 ); + FOR ( j = 0; j < dim2; j++ ) + { + re[sx * 0 + sx * j * dim1] = y[2 * j]; + im[sx * 0 + sx * j * dim1] = y[2 * j + 1]; + } + + FOR ( i = 1; i < dim1; i++ ) + { + { + y[2 * ( 0 + 0 )] = x[2 * i + 2 * ( 0 + 0 ) * dim1]; + y[2 * ( 0 + 0 ) + 1] = x[2 * i + 2 * ( 0 + 0 ) * dim1 + 1]; + } + + FOR ( j = 1; j < dim2; j++ ) + { + { + y[2 * ( j + 0 )] = L_sub( Mpy_32_16_1(x[2 * i + 2 * ( j + 0 ) * dim1], W[sc * i + sc * j * dim1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * ( j + 0 ) * dim1 + 1], W[sc * i + sc * j * dim1 + 1 - Woff] )); + y[2 * ( j + 0 ) + 1] = L_add( Mpy_32_16_1(x[2 * i + 2 * ( j + 0 ) * dim1], W[sc * i + sc * j * dim1 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * ( j + 0 ) * dim1 + 1], W[sc * i + sc * j * dim1 - Woff] )); + } + } + fft_len16( &y[0], &y[1], 2 ); + FOR ( j = 0; j < dim2; j++ ) + { + re[sx * i + sx * j * dim1] = y[2 * j]; + im[sx * i + sx * j * dim1] = y[2 * j + 1]; + } + } + BREAK; + } + + case 20: + { + Word32 y[2 * 20]; + FOR ( j = 0; j < dim2; j++ ) + { + { + y[2 * j] = x[2 * 0 + 2 * j * dim1]; + y[2 * j + 1] = x[2 * 0 + 2 * j * dim1 + 1]; + }; + } + fft_len20_fx( &y[0], &y[1], 2 ); + FOR ( j = 0; j < dim2; j++ ) + { + re[sx * 0 + sx * j * dim1] = y[2 * j]; + im[sx * 0 + sx * j * dim1] = y[2 * j + 1]; + } + + FOR ( i = 1; i < dim1; i++ ) + { + { + y[2 * ( 0 + 0 )] = x[2 * i + 2 * ( 0 + 0 ) * dim1]; + y[2 * ( 0 + 0 ) + 1] = x[2 * i + 2 * ( 0 + 0 ) * dim1 + 1]; + } + { + y[2 * ( 0 + 1 )] = L_sub( Mpy_32_16_1(x[2 * i + 2 * ( 0 + 1 ) * dim1], W[len + sc * i + 0 * dim1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * ( 0 + 1 ) * dim1 + 1], W[len + sc * i + 0 * dim1 + 1 - Woff])); + y[2 * ( 0 + 1 ) + 1] = L_add( Mpy_32_16_1(x[2 * i + 2 * ( 0 + 1 ) * dim1], W[len + sc * i + 0 * dim1 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * ( 0 + 1 ) * dim1 + 1], W[len + sc * i + 0 * dim1 - Woff])); + } + + FOR ( j = 2; j < dim2; j = j + 2 ) + { + { + y[2 * ( j + 0 )] = L_sub( Mpy_32_16_1(x[2 * i + 2 * ( j + 0 ) * dim1], W[sc * i + j * dim1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * ( j + 0 ) * dim1 + 1], W[sc * i + j * dim1 + 1 - Woff] )); + y[2 * ( j + 0 ) + 1] = L_add( Mpy_32_16_1(x[2 * i + 2 * ( j + 0 ) * dim1], W[sc * i + j * dim1 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * ( j + 0 ) * dim1 + 1], W[sc * i + j * dim1 - Woff] )); + } + { + y[2 * ( j + 1 )] = L_sub( Mpy_32_16_1(x[2 * i + 2 * ( j + 1 ) * dim1], W[len + sc * i + j * dim1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * ( j + 1 ) * dim1 + 1], W[len + sc * i + j * dim1 + 1 - Woff] )); + y[2 * ( j + 1 ) + 1] = L_add( Mpy_32_16_1(x[2 * i + 2 * ( j + 1 ) * dim1], W[len + sc * i + j * dim1 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * ( j + 1 ) * dim1 + 1], W[len + sc * i + j * dim1 - Woff] )); + } + } + fft_len20_fx( &y[0], &y[1], 2 ); + FOR ( j = 0; j < dim2; j++ ) + { + re[sx * i + sx * j * dim1] = y[2 * j]; + im[sx * i + sx * j * dim1] = y[2 * j + 1]; + } + } + BREAK; + } + + case 32: + { + Word32 y[2 * 32]; + FOR ( j = 0; j < dim2; j++ ) + { + { + y[2 * j] = x[2 * 0 + 2 * j * dim1]; + y[2 * j + 1] = x[2 * 0 + 2 * j * dim1 + 1]; + }; + } + fft_len32( &y[0], &y[1], 2 ); + FOR ( j = 0; j < dim2; j++ ) + { + re[sx * 0 + sx * j * dim1] = y[2 * j]; + im[sx * 0 + sx * j * dim1] = y[2 * j + 1]; + } + + FOR ( i = 1; i < dim1; i++ ) + { + { + y[2 * ( 0 + 0 )] = x[2 * i + 2 * ( 0 + 0 ) * dim1]; + y[2 * ( 0 + 0 ) + 1] = x[2 * i + 2 * ( 0 + 0 ) * dim1 + 1]; + } + { + y[2 * ( 0 + 1 )] = L_sub( Mpy_32_16_1(x[2 * i + 2 * ( 0 + 1 ) * dim1], W[len + sc * i + 0 * dim1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * ( 0 + 1 ) * dim1 + 1], W[len + sc * i + 0 * dim1 + 1 - Woff] )); + y[2 * ( 0 + 1 ) + 1] = L_add( Mpy_32_16_1(x[2 * i + 2 * ( 0 + 1 ) * dim1], W[len + sc * i + 0 * dim1 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * ( 0 + 1 ) * dim1 + 1], W[len + sc * i + 0 * dim1 - Woff] )); + } + + FOR ( j = 2; j < dim2; j = j + 2 ) + { + { + y[2 * ( j + 0 )] = L_sub( Mpy_32_16_1(x[2 * i + 2 * ( j + 0 ) * dim1], W[sc * i + j * dim1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * ( j + 0 ) * dim1 + 1], W[sc * i + j * dim1 + 1 - Woff] )); + y[2 * ( j + 0 ) + 1] = L_add( Mpy_32_16_1(x[2 * i + 2 * ( j + 0 ) * dim1], W[sc * i + j * dim1 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * ( j + 0 ) * dim1 + 1], W[sc * i + j * dim1 - Woff] )); + } + { + y[2 * ( j + 1 )] = L_sub( Mpy_32_16_1(x[2 * i + 2 * ( j + 1 ) * dim1], W[len + sc * i + j * dim1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * ( j + 1 ) * dim1 + 1], W[len + sc * i + j * dim1 + 1 - Woff] )); + y[2 * ( j + 1 ) + 1] = L_add( Mpy_32_16_1(x[2 * i + 2 * ( j + 1 ) * dim1], W[len + sc * i + j * dim1 + 1 - Woff] ), + Mpy_32_16_1(x[2 * i + 2 * ( j + 1 ) * dim1 + 1], W[len + sc * i + j * dim1 - Woff] )); + } + } + fft_len32( &y[0], &y[1], 2 ); + FOR ( j = 0; j < dim2; j++ ) + { + re[sx * i + sx * j * dim1] = y[2 * j]; + im[sx * i + sx * j * dim1] = y[2 * j + 1]; + } + } + BREAK; + } + } + + return; +} + + +/*-----------------------------------------------------------------* + * fft_fx() + * + * Complex-value FFT + *-----------------------------------------------------------------*/ + +void fft_fx( + Word32 *re, /* i/o: real part */ + Word32 *im, /* i/o: imag part */ + const Word16 length, /* i : length of fft */ + const Word16 s /* i : sign */ +) +{ + SWITCH ( length ) + { + case 20: + fft_len20_fx( re, im, s ); + BREAK; + case 40: + fft_lenN( re, im, FFT_RotVector_640_fx, 640, 5, 8, s, 8, 40 ); + BREAK; + case 64: + fft_lenN( re, im, FFT_RotVector_256_fx, 256, 8, 8, s, 8, 64 ); + BREAK; + case 80: + fft_lenN( re, im, FFT_RotVector_640_fx, 640, 10, 8, s, 4, 40 ); + BREAK; + case 100: + fft_lenN( re, im, FFT_RotVector_400_fx, 400, 10, 10, s, 4, 40 ); + BREAK; + case 120: + fft_lenN( re, im, FFT_RotVector_960_fx, 960, 15, 8, s, 4, 60 ); + BREAK; + case 128: + fft_lenN( re, im, FFT_RotVector_256_fx, 256, 16, 8, s, 4, 64 ); + BREAK; + case 160: + fft_lenN( re, im, FFT_RotVector_640_fx, 640, 20, 8, s, 2, 40 ); + BREAK; + case 200: + fft_lenN( re, im, FFT_RotVector_400_fx, 400, 20, 10, s, 2, 40 ); + BREAK; + case 240: + fft_lenN( re, im, FFT_RotVector_960_fx, 960, 30, 8, s, 2, 60 ); + BREAK; + case 256: + fft_lenN( re, im, FFT_RotVector_256_fx, 256, 32, 8, s, 2, 64 ); + BREAK; + case 320: + fft_lenN( re, im, FFT_RotVector_640_fx, 640, 20, 16, s, 2, 40 ); + BREAK; + case 400: + fft_lenN( re, im, FFT_RotVector_400_fx, 400, 20, 20, s, 2, 40 ); + BREAK; + case 480: + fft_lenN( re, im, FFT_RotVector_960_fx, 960, 30, 16, s, 2, 60 ); + BREAK; + case 600: + fft_lenN( re, im, FFT_RotVector_600_fx, 600, 30, 20, s, 2, 60 ); + BREAK; + case 640: + fft_lenN( re, im, FFT_RotVector_640_fx, 640, 20, 32, s, 2, 40 ); + BREAK; + case 960: + fft_lenN( re, im, FFT_RotVector_960_fx, 960, 30, 32, s, 2, 60 ); + BREAK; + default: + assert( !"fft length is not supported!" ); + } + + return; +} + +#define WMC_TOOL_SKIP + +#define SHC( x ) ( (Word16) x ) +#ifndef FFTC +#define FFTC( x ) WORD322WORD16( (Word32) x ) +#endif + +#define C81_FX ( FFTC( 0x5a82799a ) ) /* FL2WORD32( 7.071067811865475e-1) */ +#define C82_FX ( FFTC( 0xa57d8666 ) ) /* FL2WORD32(-7.071067811865475e-1) */ + +#define cplxMpy4_8_0( re, im, a, b, c, d ) \ + re = L_shr( L_sub( Mpy_32_16_1( a, c ), Mpy_32_16_1( b, d ) ), 1 ); \ + im = L_shr( L_add( Mpy_32_16_1( a, d ), Mpy_32_16_1( b, c ) ), 1 ); + +#define cplxMpy4_8_1( re, im, a, b ) \ + re = L_shr( a, 1 ); \ + im = L_shr( b, 1 ); + + +/** + * \brief Twiddle factors are unscaled + */ +static const Word16 RotVector_256[2 * ( 256 - 32 )] = { + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7ff6 ), SHC( 0xfcdc ), SHC( 0x7fd9 ), SHC( 0xf9b8 ), SHC( 0x7fa7 ), SHC( 0xf695 ), + SHC( 0x7f62 ), SHC( 0xf374 ), SHC( 0x7f0a ), SHC( 0xf055 ), SHC( 0x7e9d ), SHC( 0xed38 ), SHC( 0x7e1e ), SHC( 0xea1e ), + SHC( 0x7d8a ), SHC( 0xe707 ), SHC( 0x7ce4 ), SHC( 0xe3f4 ), SHC( 0x7c2a ), SHC( 0xe0e6 ), SHC( 0x7b5d ), SHC( 0xdddc ), + SHC( 0x7a7d ), SHC( 0xdad8 ), SHC( 0x798a ), SHC( 0xd7d9 ), SHC( 0x7885 ), SHC( 0xd4e1 ), SHC( 0x776c ), SHC( 0xd1ef ), + SHC( 0x7642 ), SHC( 0xcf04 ), SHC( 0x7505 ), SHC( 0xcc21 ), SHC( 0x73b6 ), SHC( 0xc946 ), SHC( 0x7255 ), SHC( 0xc673 ), + SHC( 0x70e3 ), SHC( 0xc3a9 ), SHC( 0x6f5f ), SHC( 0xc0e9 ), SHC( 0x6dca ), SHC( 0xbe32 ), SHC( 0x6c24 ), SHC( 0xbb85 ), + SHC( 0x6a6e ), SHC( 0xb8e3 ), SHC( 0x68a7 ), SHC( 0xb64c ), SHC( 0x66d0 ), SHC( 0xb3c0 ), SHC( 0x64e9 ), SHC( 0xb140 ), + SHC( 0x62f2 ), SHC( 0xaecc ), SHC( 0x60ec ), SHC( 0xac65 ), SHC( 0x5ed7 ), SHC( 0xaa0a ), SHC( 0x5cb4 ), SHC( 0xa7bd ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fd9 ), SHC( 0xf9b8 ), SHC( 0x7f62 ), SHC( 0xf374 ), SHC( 0x7e9d ), SHC( 0xed38 ), + SHC( 0x7d8a ), SHC( 0xe707 ), SHC( 0x7c2a ), SHC( 0xe0e6 ), SHC( 0x7a7d ), SHC( 0xdad8 ), SHC( 0x7885 ), SHC( 0xd4e1 ), + SHC( 0x7642 ), SHC( 0xcf04 ), SHC( 0x73b6 ), SHC( 0xc946 ), SHC( 0x70e3 ), SHC( 0xc3a9 ), SHC( 0x6dca ), SHC( 0xbe32 ), + SHC( 0x6a6e ), SHC( 0xb8e3 ), SHC( 0x66d0 ), SHC( 0xb3c0 ), SHC( 0x62f2 ), SHC( 0xaecc ), SHC( 0x5ed7 ), SHC( 0xaa0a ), + SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x55f6 ), SHC( 0xa129 ), SHC( 0x5134 ), SHC( 0x9d0e ), SHC( 0x4c40 ), SHC( 0x9930 ), + SHC( 0x471d ), SHC( 0x9592 ), SHC( 0x41ce ), SHC( 0x9236 ), SHC( 0x3c57 ), SHC( 0x8f1d ), SHC( 0x36ba ), SHC( 0x8c4a ), + SHC( 0x30fc ), SHC( 0x89be ), SHC( 0x2b1f ), SHC( 0x877b ), SHC( 0x2528 ), SHC( 0x8583 ), SHC( 0x1f1a ), SHC( 0x83d6 ), + SHC( 0x18f9 ), SHC( 0x8276 ), SHC( 0x12c8 ), SHC( 0x8163 ), SHC( 0x0c8c ), SHC( 0x809e ), SHC( 0x0648 ), SHC( 0x8027 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fa7 ), SHC( 0xf695 ), SHC( 0x7e9d ), SHC( 0xed38 ), SHC( 0x7ce4 ), SHC( 0xe3f4 ), + SHC( 0x7a7d ), SHC( 0xdad8 ), SHC( 0x776c ), SHC( 0xd1ef ), SHC( 0x73b6 ), SHC( 0xc946 ), SHC( 0x6f5f ), SHC( 0xc0e9 ), + SHC( 0x6a6e ), SHC( 0xb8e3 ), SHC( 0x64e9 ), SHC( 0xb140 ), SHC( 0x5ed7 ), SHC( 0xaa0a ), SHC( 0x5843 ), SHC( 0xa34c ), + SHC( 0x5134 ), SHC( 0x9d0e ), SHC( 0x49b4 ), SHC( 0x9759 ), SHC( 0x41ce ), SHC( 0x9236 ), SHC( 0x398d ), SHC( 0x8dab ), + SHC( 0x30fc ), SHC( 0x89be ), SHC( 0x2827 ), SHC( 0x8676 ), SHC( 0x1f1a ), SHC( 0x83d6 ), SHC( 0x15e2 ), SHC( 0x81e2 ), + SHC( 0x0c8c ), SHC( 0x809e ), SHC( 0x0324 ), SHC( 0x800a ), SHC( 0xf9b8 ), SHC( 0x8027 ), SHC( 0xf055 ), SHC( 0x80f6 ), + SHC( 0xe707 ), SHC( 0x8276 ), SHC( 0xdddc ), SHC( 0x84a3 ), SHC( 0xd4e1 ), SHC( 0x877b ), SHC( 0xcc21 ), SHC( 0x8afb ), + SHC( 0xc3a9 ), SHC( 0x8f1d ), SHC( 0xbb85 ), SHC( 0x93dc ), SHC( 0xb3c0 ), SHC( 0x9930 ), SHC( 0xac65 ), SHC( 0x9f14 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f62 ), SHC( 0xf374 ), SHC( 0x7d8a ), SHC( 0xe707 ), SHC( 0x7a7d ), SHC( 0xdad8 ), + SHC( 0x7642 ), SHC( 0xcf04 ), SHC( 0x70e3 ), SHC( 0xc3a9 ), SHC( 0x6a6e ), SHC( 0xb8e3 ), SHC( 0x62f2 ), SHC( 0xaecc ), + SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x5134 ), SHC( 0x9d0e ), SHC( 0x471d ), SHC( 0x9592 ), SHC( 0x3c57 ), SHC( 0x8f1d ), + SHC( 0x30fc ), SHC( 0x89be ), SHC( 0x2528 ), SHC( 0x8583 ), SHC( 0x18f9 ), SHC( 0x8276 ), SHC( 0x0c8c ), SHC( 0x809e ), + SHC( 0x0000 ), SHC( 0x8000 ), SHC( 0xf374 ), SHC( 0x809e ), SHC( 0xe707 ), SHC( 0x8276 ), SHC( 0xdad8 ), SHC( 0x8583 ), + SHC( 0xcf04 ), SHC( 0x89be ), SHC( 0xc3a9 ), SHC( 0x8f1d ), SHC( 0xb8e3 ), SHC( 0x9592 ), SHC( 0xaecc ), SHC( 0x9d0e ), + SHC( 0xa57e ), SHC( 0xa57e ), SHC( 0x9d0e ), SHC( 0xaecc ), SHC( 0x9592 ), SHC( 0xb8e3 ), SHC( 0x8f1d ), SHC( 0xc3a9 ), + SHC( 0x89be ), SHC( 0xcf04 ), SHC( 0x8583 ), SHC( 0xdad8 ), SHC( 0x8276 ), SHC( 0xe707 ), SHC( 0x809e ), SHC( 0xf374 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f0a ), SHC( 0xf055 ), SHC( 0x7c2a ), SHC( 0xe0e6 ), SHC( 0x776c ), SHC( 0xd1ef ), + SHC( 0x70e3 ), SHC( 0xc3a9 ), SHC( 0x68a7 ), SHC( 0xb64c ), SHC( 0x5ed7 ), SHC( 0xaa0a ), SHC( 0x539b ), SHC( 0x9f14 ), + SHC( 0x471d ), SHC( 0x9592 ), SHC( 0x398d ), SHC( 0x8dab ), SHC( 0x2b1f ), SHC( 0x877b ), SHC( 0x1c0c ), SHC( 0x831c ), + SHC( 0x0c8c ), SHC( 0x809e ), SHC( 0xfcdc ), SHC( 0x800a ), SHC( 0xed38 ), SHC( 0x8163 ), SHC( 0xdddc ), SHC( 0x84a3 ), + SHC( 0xcf04 ), SHC( 0x89be ), SHC( 0xc0e9 ), SHC( 0x90a1 ), SHC( 0xb3c0 ), SHC( 0x9930 ), SHC( 0xa7bd ), SHC( 0xa34c ), + SHC( 0x9d0e ), SHC( 0xaecc ), SHC( 0x93dc ), SHC( 0xbb85 ), SHC( 0x8c4a ), SHC( 0xc946 ), SHC( 0x8676 ), SHC( 0xd7d9 ), + SHC( 0x8276 ), SHC( 0xe707 ), SHC( 0x8059 ), SHC( 0xf695 ), SHC( 0x8027 ), SHC( 0x0648 ), SHC( 0x81e2 ), SHC( 0x15e2 ), + SHC( 0x8583 ), SHC( 0x2528 ), SHC( 0x8afb ), SHC( 0x33df ), SHC( 0x9236 ), SHC( 0x41ce ), SHC( 0x9b17 ), SHC( 0x4ec0 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7e9d ), SHC( 0xed38 ), SHC( 0x7a7d ), SHC( 0xdad8 ), SHC( 0x73b6 ), SHC( 0xc946 ), + SHC( 0x6a6e ), SHC( 0xb8e3 ), SHC( 0x5ed7 ), SHC( 0xaa0a ), SHC( 0x5134 ), SHC( 0x9d0e ), SHC( 0x41ce ), SHC( 0x9236 ), + SHC( 0x30fc ), SHC( 0x89be ), SHC( 0x1f1a ), SHC( 0x83d6 ), SHC( 0x0c8c ), SHC( 0x809e ), SHC( 0xf9b8 ), SHC( 0x8027 ), + SHC( 0xe707 ), SHC( 0x8276 ), SHC( 0xd4e1 ), SHC( 0x877b ), SHC( 0xc3a9 ), SHC( 0x8f1d ), SHC( 0xb3c0 ), SHC( 0x9930 ), + SHC( 0xa57e ), SHC( 0xa57e ), SHC( 0x9930 ), SHC( 0xb3c0 ), SHC( 0x8f1d ), SHC( 0xc3a9 ), SHC( 0x877b ), SHC( 0xd4e1 ), + SHC( 0x8276 ), SHC( 0xe707 ), SHC( 0x8027 ), SHC( 0xf9b8 ), SHC( 0x809e ), SHC( 0x0c8c ), SHC( 0x83d6 ), SHC( 0x1f1a ), + SHC( 0x89be ), SHC( 0x30fc ), SHC( 0x9236 ), SHC( 0x41ce ), SHC( 0x9d0e ), SHC( 0x5134 ), SHC( 0xaa0a ), SHC( 0x5ed7 ), + SHC( 0xb8e3 ), SHC( 0x6a6e ), SHC( 0xc946 ), SHC( 0x73b6 ), SHC( 0xdad8 ), SHC( 0x7a7d ), SHC( 0xed38 ), SHC( 0x7e9d ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7e1e ), SHC( 0xea1e ), SHC( 0x7885 ), SHC( 0xd4e1 ), SHC( 0x6f5f ), SHC( 0xc0e9 ), + SHC( 0x62f2 ), SHC( 0xaecc ), SHC( 0x539b ), SHC( 0x9f14 ), SHC( 0x41ce ), SHC( 0x9236 ), SHC( 0x2e11 ), SHC( 0x8894 ), + SHC( 0x18f9 ), SHC( 0x8276 ), SHC( 0x0324 ), SHC( 0x800a ), SHC( 0xed38 ), SHC( 0x8163 ), SHC( 0xd7d9 ), SHC( 0x8676 ), + SHC( 0xc3a9 ), SHC( 0x8f1d ), SHC( 0xb140 ), SHC( 0x9b17 ), SHC( 0xa129 ), SHC( 0xaa0a ), SHC( 0x93dc ), SHC( 0xbb85 ), + SHC( 0x89be ), SHC( 0xcf04 ), SHC( 0x831c ), SHC( 0xe3f4 ), SHC( 0x8027 ), SHC( 0xf9b8 ), SHC( 0x80f6 ), SHC( 0x0fab ), + SHC( 0x8583 ), SHC( 0x2528 ), SHC( 0x8dab ), SHC( 0x398d ), SHC( 0x9930 ), SHC( 0x4c40 ), SHC( 0xa7bd ), SHC( 0x5cb4 ), + SHC( 0xb8e3 ), SHC( 0x6a6e ), SHC( 0xcc21 ), SHC( 0x7505 ), SHC( 0xe0e6 ), SHC( 0x7c2a ), SHC( 0xf695 ), SHC( 0x7fa7 ), + SHC( 0x0c8c ), SHC( 0x7f62 ), SHC( 0x2224 ), SHC( 0x7b5d ), SHC( 0x36ba ), SHC( 0x73b6 ), SHC( 0x49b4 ), SHC( 0x68a7 ) +}; + +/*-----------------------------------------------------------------* + * BASOP_fft8() + * + * Function performs a complex 8-point FFT + * The FFT is performed inplace. The result of the FFT + * is scaled by SCALEFACTOR8 bits. + * + * WOPS with 32x16 bit multiplications: 108 cycles + *-----------------------------------------------------------------*/ + +static void BASOP_fft8( + Word32 *re, + Word32 *im, + Word16 s ) +{ + Word32 x00, x01, x02, x03, x04, x05, x06, x07; + Word32 x08, x09, x10, x11, x12, x13, x14, x15; + Word32 t00, t01, t02, t03, t04, t05, t06, t07; + Word32 t08, t09, t10, t11, t12, t13, t14, t15; + Word32 s00, s01, s02, s03, s04, s05, s06, s07; + Word32 s08, s09, s10, s11, s12, s13, s14, s15; + + + /* Pre-additions */ + + x00 = L_shr( re[s * 0], SCALEFACTOR8 ); + x01 = L_shr( im[s * 0], SCALEFACTOR8 ); + x02 = L_shr( re[s * 1], SCALEFACTOR8 ); + x03 = L_shr( im[s * 1], SCALEFACTOR8 ); + x04 = L_shr( re[s * 2], SCALEFACTOR8 ); + x05 = L_shr( im[s * 2], SCALEFACTOR8 ); + x06 = L_shr( re[s * 3], SCALEFACTOR8 ); + x07 = L_shr( im[s * 3], SCALEFACTOR8 ); + x08 = L_shr( re[s * 4], SCALEFACTOR8 ); + x09 = L_shr( im[s * 4], SCALEFACTOR8 ); + x10 = L_shr( re[s * 5], SCALEFACTOR8 ); + x11 = L_shr( im[s * 5], SCALEFACTOR8 ); + x12 = L_shr( re[s * 6], SCALEFACTOR8 ); + x13 = L_shr( im[s * 6], SCALEFACTOR8 ); + x14 = L_shr( re[s * 7], SCALEFACTOR8 ); + x15 = L_shr( im[s * 7], SCALEFACTOR8 ); + + t00 = L_add( x00, x08 ); + t02 = L_sub( x00, x08 ); + t01 = L_add( x01, x09 ); + t03 = L_sub( x01, x09 ); + t04 = L_add( x02, x10 ); + t06 = L_sub( x02, x10 ); + t05 = L_add( x03, x11 ); + t07 = L_sub( x03, x11 ); + t08 = L_add( x04, x12 ); + t10 = L_sub( x04, x12 ); + t09 = L_add( x05, x13 ); + t11 = L_sub( x05, x13 ); + t12 = L_add( x06, x14 ); + t14 = L_sub( x06, x14 ); + t13 = L_add( x07, x15 ); + t15 = L_sub( x07, x15 ); + + /* Pre-additions and core multiplications */ + + s00 = L_add( t00, t08 ); + s04 = L_sub( t00, t08 ); + s01 = L_add( t01, t09 ); + s05 = L_sub( t01, t09 ); + s08 = L_sub( t02, t11 ); + s10 = L_add( t02, t11 ); + s09 = L_add( t03, t10 ); + s11 = L_sub( t03, t10 ); + s02 = L_add( t04, t12 ); + s07 = L_sub( t04, t12 ); + s03 = L_add( t05, t13 ); + s06 = L_sub( t13, t05 ); + + t01 = L_add( t06, t14 ); + t02 = L_sub( t06, t14 ); + t00 = L_add( t07, t15 ); + t03 = L_sub( t07, t15 ); + + s12 = Mpy_32_16_1( L_add( t00, t02 ), C81_FX ); + s14 = Mpy_32_16_1( L_sub( t00, t02 ), C81_FX ); + s13 = Mpy_32_16_1( L_sub( t03, t01 ), C81_FX ); + s15 = Mpy_32_16_1( L_add( t01, t03 ), C82_FX ); + + /* Post-additions */ + + re[s * 0] = L_add( s00, s02 ); + move32(); + re[s * 4] = L_sub( s00, s02 ); + move32(); + im[s * 0] = L_add( s01, s03 ); + move32(); + im[s * 4] = L_sub( s01, s03 ); + move32(); + re[s * 2] = L_sub( s04, s06 ); + move32(); + re[s * 6] = L_add( s04, s06 ); + move32(); + im[s * 2] = L_sub( s05, s07 ); + move32(); + im[s * 6] = L_add( s05, s07 ); + move32(); + re[s * 3] = L_add( s08, s14 ); + move32(); + re[s * 7] = L_sub( s08, s14 ); + move32(); + im[s * 3] = L_add( s09, s15 ); + move32(); + im[s * 7] = L_sub( s09, s15 ); + move32(); + re[s * 1] = L_add( s10, s12 ); + move32(); + re[s * 5] = L_sub( s10, s12 ); + move32(); + im[s * 1] = L_add( s11, s13 ); + move32(); + im[s * 5] = L_sub( s11, s13 ); + move32(); + + return; +} + + +/*-----------------------------------------------------------------* + * fftN2() + * + * Combined FFT + *-----------------------------------------------------------------*/ + +static void BASOP_fftN2( + Word32 *re, /* i/o: real part */ + Word32 *im, /* i/o: imag part */ + const Word16 *W, /* i : rotation factor */ + Word16 dim1, /* i : length of fft1 */ + Word16 dim2, /* i : length of fft2 */ + Word16 sx, /* i : stride real and imag part */ + Word16 sc, /* i : stride phase rotation coefficients */ + Word32 *x, /* tmp: 32-bit workbuffer */ + Word16 Woff /* i : offset for addressing the rotation vector table */ +) +{ + Word16 i, j; + Word32 x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, x11, x12, x13, x14, x15; + Word32 t00, t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13, t14, t15; + Word32 s00, s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15; + + FOR( i = 0; i < dim2; i++ ) + { + FOR( j = 0; j < dim1; j++ ) + { + x[2 * i * dim1 + 2 * j] = re[sx * i + sx * j * dim2]; + move32(); + x[2 * i * dim1 + 2 * j + 1] = im[sx * i + sx * j * dim2]; + move32(); + } + } + + /* dim1 == 8 */ + FOR( i = 0; i < dim2; i++ ) + { + BASOP_fft8( &x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2 ); + } + + /* dim2 == 8 */ + FOR( i = 0; i < dim1; i++ ) + { + cplxMpy4_8_1( x00, x01, x[2 * i + 2 * 0 * dim1], x[2 * i + 2 * 0 * dim1 + 1] ); + + IF(EQ_16(i, 0)) + { + cplxMpy4_8_1( x02, x03, x[2 * i + 2 * 1 * dim1], x[2 * i + 2 * 1 * dim1 + 1] ); + cplxMpy4_8_1( x04, x05, x[2 * i + 2 * 2 * dim1], x[2 * i + 2 * 2 * dim1 + 1] ); + cplxMpy4_8_1( x06, x07, x[2 * i + 2 * 3 * dim1], x[2 * i + 2 * 3 * dim1 + 1] ); + cplxMpy4_8_1( x08, x09, x[2 * i + 2 * 4 * dim1], x[2 * i + 2 * 4 * dim1 + 1] ); + cplxMpy4_8_1( x10, x11, x[2 * i + 2 * 5 * dim1], x[2 * i + 2 * 5 * dim1 + 1] ); + cplxMpy4_8_1( x12, x13, x[2 * i + 2 * 6 * dim1], x[2 * i + 2 * 6 * dim1 + 1] ); + cplxMpy4_8_1( x14, x15, x[2 * i + 2 * 7 * dim1], x[2 * i + 2 * 7 * dim1 + 1] ); + } + ELSE + { + cplxMpy4_8_0( x02, x03, x[2 * i + 2 * 1 * dim1], x[2 * i + 2 * 1 * dim1 + 1], W[sc * i + sc * 1 * dim1 - Woff], W[sc * i + sc * 1 * dim1 + 1 - Woff] ); + cplxMpy4_8_0( x04, x05, x[2 * i + 2 * 2 * dim1], x[2 * i + 2 * 2 * dim1 + 1], W[sc * i + sc * 2 * dim1 - Woff], W[sc * i + sc * 2 * dim1 + 1 - Woff] ); + cplxMpy4_8_0( x06, x07, x[2 * i + 2 * 3 * dim1], x[2 * i + 2 * 3 * dim1 + 1], W[sc * i + sc * 3 * dim1 - Woff], W[sc * i + sc * 3 * dim1 + 1 - Woff] ); + cplxMpy4_8_0( x08, x09, x[2 * i + 2 * 4 * dim1], x[2 * i + 2 * 4 * dim1 + 1], W[sc * i + sc * 4 * dim1 - Woff], W[sc * i + sc * 4 * dim1 + 1 - Woff] ); + cplxMpy4_8_0( x10, x11, x[2 * i + 2 * 5 * dim1], x[2 * i + 2 * 5 * dim1 + 1], W[sc * i + sc * 5 * dim1 - Woff], W[sc * i + sc * 5 * dim1 + 1 - Woff] ); + cplxMpy4_8_0( x12, x13, x[2 * i + 2 * 6 * dim1], x[2 * i + 2 * 6 * dim1 + 1], W[sc * i + sc * 6 * dim1 - Woff], W[sc * i + sc * 6 * dim1 + 1 - Woff] ); + cplxMpy4_8_0( x14, x15, x[2 * i + 2 * 7 * dim1], x[2 * i + 2 * 7 * dim1 + 1], W[sc * i + sc * 7 * dim1 - Woff], W[sc * i + sc * 7 * dim1 + 1 - Woff] ); + } + t00 = L_shr( L_add( x00, x08 ), SCALEFACTORN2 - 1 ); + t02 = L_shr( L_sub( x00, x08 ), SCALEFACTORN2 - 1 ); + t01 = L_shr( L_add( x01, x09 ), SCALEFACTORN2 - 1 ); + t03 = L_shr( L_sub( x01, x09 ), SCALEFACTORN2 - 1 ); + t04 = L_shr( L_add( x02, x10 ), SCALEFACTORN2 - 1 ); + t06 = L_sub( x02, x10 ); + t05 = L_shr( L_add( x03, x11 ), SCALEFACTORN2 - 1 ); + t07 = L_sub( x03, x11 ); + t08 = L_shr( L_add( x04, x12 ), SCALEFACTORN2 - 1 ); + t10 = L_shr( L_sub( x04, x12 ), SCALEFACTORN2 - 1 ); + t09 = L_shr( L_add( x05, x13 ), SCALEFACTORN2 - 1 ); + t11 = L_shr( L_sub( x05, x13 ), SCALEFACTORN2 - 1 ); + t12 = L_shr( L_add( x06, x14 ), SCALEFACTORN2 - 1 ); + t14 = L_sub( x06, x14 ); + t13 = L_shr( L_add( x07, x15 ), SCALEFACTORN2 - 1 ); + t15 = L_sub( x07, x15 ); + + s00 = L_add( t00, t08 ); + s04 = L_sub( t00, t08 ); + s01 = L_add( t01, t09 ); + s05 = L_sub( t01, t09 ); + s08 = L_sub( t02, t11 ); + s10 = L_add( t02, t11 ); + s09 = L_add( t03, t10 ); + s11 = L_sub( t03, t10 ); + s02 = L_add( t04, t12 ); + s07 = L_sub( t04, t12 ); + s03 = L_add( t05, t13 ); + s06 = L_sub( t13, t05 ); + + t01 = L_shr( L_add( t06, t14 ), SCALEFACTORN2 - 1 ); + t02 = L_shr( L_sub( t06, t14 ), SCALEFACTORN2 - 1 ); + t00 = L_shr( L_add( t07, t15 ), SCALEFACTORN2 - 1 ); + t03 = L_shr( L_sub( t07, t15 ), SCALEFACTORN2 - 1 ); + + s12 = Mpy_32_16_1( L_add( t00, t02 ), C81_FX ); + s14 = Mpy_32_16_1( L_sub( t00, t02 ), C81_FX ); + s13 = Mpy_32_16_1( L_sub( t03, t01 ), C81_FX ); + s15 = Mpy_32_16_1( L_add( t01, t03 ), C82_FX ); + + re[sx * i + sx * 0 * dim1] = L_add( s00, s02 ); + move32(); + im[sx * i + sx * 0 * dim1] = L_add( s01, s03 ); + move32(); + re[sx * i + sx * 1 * dim1] = L_add( s10, s12 ); + move32(); + im[sx * i + sx * 1 * dim1] = L_add( s11, s13 ); + move32(); + re[sx * i + sx * 2 * dim1] = L_sub( s04, s06 ); + move32(); + im[sx * i + sx * 2 * dim1] = L_sub( s05, s07 ); + move32(); + re[sx * i + sx * 3 * dim1] = L_add( s08, s14 ); + move32(); + im[sx * i + sx * 3 * dim1] = L_add( s09, s15 ); + move32(); + re[sx * i + sx * 4 * dim1] = L_sub( s00, s02 ); + move32(); + im[sx * i + sx * 4 * dim1] = L_sub( s01, s03 ); + move32(); + re[sx * i + sx * 5 * dim1] = L_sub( s10, s12 ); + move32(); + im[sx * i + sx * 5 * dim1] = L_sub( s11, s13 ); + move32(); + re[sx * i + sx * 6 * dim1] = L_add( s04, s06 ); + move32(); + im[sx * i + sx * 6 * dim1] = L_add( s05, s07 ); + move32(); + re[sx * i + sx * 7 * dim1] = L_sub( s08, s14 ); + move32(); + im[sx * i + sx * 7 * dim1] = L_sub( s09, s15 ); + move32(); + } + + return; +} + + +/*-----------------------------------------------------------------* + * BASOP_cfft_fx() + * + * Complex valued FFT + *-----------------------------------------------------------------*/ + +void BASOP_cfft_fx( + Word32 *re, /* i/o: real part */ + Word32 *im, /* i/o: imag part */ + Word16 s, /* i : stride real and imag part */ + Word16 *scale /* i : scalefactor */ +) +{ + Word32 x[2 * 64]; + + /* FFT for len = FDNS_NPTS */ + BASOP_fftN2( re, im, RotVector_256, 8, 8, s, 8, x, 64 ); + s = add( *scale, SCALEFACTOR64 ); + + *scale = s; + move16(); + + return; +} + +#undef WMC_TOOL_SKIP diff --git a/lib_com/fft_rel.c b/lib_com/fft_rel.c index e45736be8..810c3a7e2 100644 --- a/lib_com/fft_rel.c +++ b/lib_com/fft_rel.c @@ -39,6 +39,8 @@ #include "prot.h" #include "rom_com.h" #include "wmc_auto.h" +#include "prot_fx1.h" +#include "prot_fx2.h" /*---------------------------------------------------------------------* * Local constants @@ -47,7 +49,8 @@ #define N_MAX_FFT 1024 #define N_MAX_DIV2 ( N_MAX_FFT >> 1 ) #define N_MAX_DIV4 ( N_MAX_DIV2 >> 1 ) - +#define INV_SQR2_FX 23170 +#define N_MAX_SAS 256 /*---------------------------------------------------------------------* * fft_rel() * @@ -298,3 +301,182 @@ void fft_rel( return; } + + +void fft_rel_fx( + Word16 x[], /* i/o: input/output vector */ + const Word16 n, /* i : vector length */ + const Word16 m /* i : log2 of vector length */ +) +{ + Word16 i, j, k, n1, n2, n4; + Word16 step; + Word16 xt, t1, t2; + Word16 *x0, *x1, *x2; + const Word16 *s, *c; + Word16 *xi2, *xi3, *xi4, *xi1; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + + /*-----------------------------------------------------------------* + * Digit reverse counter + *-----------------------------------------------------------------*/ + + j = 0; + move16(); + x0 = &x[0]; + move16(); + FOR(i = 0; i < n - 1; i++) + { + IF(LT_16(i, j)) + { + xt = x[j]; + move16(); + x[j] = *x0; + move16(); + *x0 = xt; + move16(); + } + x0++; + k = shr(n, 1); + WHILE(LE_16(k, j)) + { + j = sub(j, k); + k = shr(k, 1); + } + j = add(j, k); + } + + /*-----------------------------------------------------------------* + * Length two butterflies + *-----------------------------------------------------------------*/ + + x0 = &x[0]; + move16(); + x1 = &x[1]; + move16(); + FOR(i = 0; i < n / 2; i++) + { + xt = *x0; + move16(); +#ifdef BASOP_NOGLOB + *x0 = add_o(xt, *x1, &Overflow); +#else + *x0 = add(xt, *x1); +#endif + move16(); +#ifdef BASOP_NOGLOB + *x1 = sub_o(xt, *x1, &Overflow); +#else + *x1 = sub(xt, *x1); +#endif + move16(); + x0++; + x0++; + x1++; + x1++; + } + + /*-----------------------------------------------------------------* + * Other butterflies + * + * The implementation described in [1] has been changed by using + * table lookup for evaluating sine and cosine functions. The + * variable ind and its increment step are needed to access table + * entries. Note that this implementation assumes n4 to be so + * small that ind will never exceed the table. Thus the input + * argument n and the constant N_MAX_SAS must be set properly. + *-----------------------------------------------------------------*/ + + n2 = 1; + move16(); + /* step = N_MAX_SAS/4; */ + FOR(k = 2; k <= m; k++) + { + n4 = n2; + move16(); + n2 = shl(n4, 1); + n1 = shl(n2, 1); + + step = N_MAX_SAS / n1; + + x0 = x; + x1 = x + n2; + x2 = x + add(n2, n4); + FOR(i = 0; i < n; i += n1) + { + xt = *x0; + move16(); /* xt = x[i]; */ +#ifdef BASOP_NOGLOB + *x0 = add_o(xt, *x1, &Overflow); +#else /* BASOP_NOGLOB */ + *x0 = add(xt, *x1); +#endif /* BASOP_NOGLOB */ + move16(); /* x[i] = xt + x[i+n2]; */ +#ifdef BASOP_NOGLOB + *x1 = sub_o(xt, *x1, &Overflow); +#else /* BASOP_NOGLOB */ + *x1 = sub(xt, *x1); +#endif /* BASOP_NOGLOB */ + move16(); /* x[i+n2] = xt - x[i+n2]; */ + *x2 = negate(*x2); + move16(); /* x[i+n2+n4] = -x[i+n2+n4]; */ + + + s = sincos_t_fx + step; + c = s + 64; + xi1 = x + add(i, 1); + xi3 = xi1 + n2; + xi2 = xi3 - 2; + xi4 = xi1 + sub(n1, 2); + + FOR(j = 1; j < n4; j++) + { +#ifdef BASOP_NOGLOB + t1 = add_o(mult_r(*xi3, *c), mult_r(*xi4, *s), &Overflow); /* t1 = *xi3**(pt_c+ind) + *xi4**(pt_s+ind); */ + t2 = sub_o(mult_r(*xi3, *s), mult_r(*xi4, *c), &Overflow); /* t2 = *xi3**(pt_s+ind) - *xi4**(pt_c+ind); */ + *xi4 = sub_o(*xi2, t2, &Overflow); +#else /* BASOP_NOGLOB */ + t1 = add(mult_r(*xi3, *c), mult_r(*xi4, *s)); /* t1 = *xi3**(pt_c+ind) + *xi4**(pt_s+ind); */ + t2 = sub(mult_r(*xi3, *s), mult_r(*xi4, *c)); /* t2 = *xi3**(pt_s+ind) - *xi4**(pt_c+ind); */ + *xi4 = sub(*xi2, t2); +#endif /* BASOP_NOGLOB */ + move16(); +#ifdef BASOP_NOGLOB + *xi3 = negate(add_o(*xi2, t2, &Overflow)); +#else /* BASOP_NOGLOB */ + *xi3 = negate(add(*xi2, t2)); +#endif /* BASOP_NOGLOB */ + move16(); +#ifdef BASOP_NOGLOB + *xi2 = sub_o(*xi1, t1, &Overflow); +#else /* BASOP_NOGLOB */ + *xi2 = sub(*xi1, t1); +#endif /* BASOP_NOGLOB */ + move16(); +#ifdef BASOP_NOGLOB + *xi1 = add_o(*xi1, t1, &Overflow); +#else /* BASOP_NOGLOB */ + *xi1 = add(*xi1, t1); +#endif /* BASOP_NOGLOB */ + move16(); + + xi4--; + xi2--; + xi3++; + xi1++; + c += step; + s += step; /* autoincrement by ar0 */ + } + + x0 += n1; + x1 += n1; + x2 += n1; + } + /* step = shr(step, 1); */ + } + + return; +} \ No newline at end of file diff --git a/lib_com/fill_spectrum.c b/lib_com/fill_spectrum.c index 93d4cd572..df101a11f 100644 --- a/lib_com/fill_spectrum.c +++ b/lib_com/fill_spectrum.c @@ -40,6 +40,8 @@ #include "rom_com.h" #include "prot.h" #include "wmc_auto.h" +#include "prot_fx1.h" +#include "prot_fx2.h" /*--------------------------------------------------------------------------* * fill_spectrum() @@ -264,3 +266,264 @@ void fill_spectrum( return; } + + +void fill_spectrum_fx( + Word16 *coeff, /* i/o: normalized MLT spectrum / nf spectrum Q12 */ + Word32 *L_coeff_out, /* i/o: Noisefilled MLT spectrum Q12 */ + const Word16 *R, /* i : number of pulses per band Q0 */ + const Word16 is_transient, /* i : transient flag Q0 */ + Word16 norm[], /* i : quantization indices for norms Q0 */ + const Word16 *hq_generic_fenv, /* i : HQ GENERIC envelope Q1 */ + const Word16 hq_generic_offset, /* i : HQ GENERIC offset Q0 */ + const Word16 nf_idx, /* i : noise fill index Q0 */ + const Word16 length, /* i : Length of spectrum (32 or 48 kHz) Q0 */ + const Word16 env_stab, /* i : Envelope stability measure [0..1] Q15 */ + Word16 *no_att_hangover, /* i/o: Frame counter for attenuation hangover Q0 */ + Word32 *L_energy_lt, /* i/o: Long-term energy measure for transient detection Q13 */ + Word16 *bwe_seed, /* i/o: random seed for generating BWE input Q0 */ + const Word16 hq_generic_exc_clas, /* i : BWE excitation class Q0 */ + const Word16 core_sfm, /* i : index of the end band for core Q0 */ + const Word16 HQ_mode, /* i : HQ mode Q0 */ + Word16 noise_level[], /* i : noise levels for harmonic modes Q15 */ + const Word32 L_core_brate, /* i : target bit-rate Q0 */ + Word16 prev_noise_level[], /* i/o: noise factor in previous frame Q15 */ + Word16 *prev_R, /* i/o: bit allocation info. in previous frame Q0 */ + Word32 *prev_coeff_out, /* i/o: decoded spectrum in previous frame Q12 */ + const Word16 *peak_idx, /* i : peak indices for hvq Q0 */ + const Word16 Npeaks, /* i : number of peaks in hvq Q0 */ + const Word16 *npulses, /* i : number of pulses per band Q0 */ + const Word16 prev_is_transient, /* i : previous transient flag Q0 */ + Word32 *prev_normq, /* i/o: previous norms Q14 */ + Word32 *prev_env, /* i/o: previous noise envelopes Q(prev_env_Q) */ + const Word16 prev_bfi, /* i : previous bad frame indicator Q0 */ + const Word16 *sfmsize, /* i : Length of bands Q0 */ + const Word16 *sfm_start, /* i : Start of bands Q0 */ + const Word16 *sfm_end, /* i : End of bands Q0 */ + Word16 *prev_L_swb_norm, /* i/o: HVQ/Harmonic mode normalization length Q0 */ + const Word16 prev_hq_mode, /* i : Previous HQ mode Q0 */ + const Word16 num_sfm, /* i : Total number of bands Q0 */ + Word16 *prev_env_Q, + const Word16 num_env_bands, /* i : Number sub bands to be encoded for HQ_GEN Q0 */ + const Word16 element_mode /* i : IVAS element mode */ +) +{ + Word16 CodeBook[FREQ_LENGTH]; /* Q12 */ + Word16 cb_size; + Word16 last_sfm; + Word16 CodeBook_mod[FREQ_LENGTH]; /*Q12 */ + Word16 norm_adj[NB_SFM]; /*Q15 */ + Word16 high_sfm; + Word16 flag_32K_env_hangover; + Word16 bin_th; + Word16 peak_pos[L_HARMONIC_EXC]; + Word16 bwe_peaks[L_FRAME48k]; + Word32 L_normq_v[NB_SFM]; /*Q14 */ + Word16 coeff_fine[L_SPEC48k_EXT]; /*Q15 */ + Word32 L_coeff_out1[L_SPEC48k_EXT]; /*Q12 */ + set16_fx(peak_pos, 0, L_HARMONIC_EXC); + set16_fx(bwe_peaks, 0, L_FRAME48k); + set16_fx(norm_adj, 32767, num_sfm); /* 1.0, Q15 */ + cb_size = 0; + move16(); + bin_th = 0; + move16(); + high_sfm = 23; + move16(); + + test(); + IF(EQ_16(HQ_mode, HQ_TRANSIENT)) + { + last_sfm = sub(num_sfm, 1); + } + ELSE IF(EQ_16(HQ_mode, HQ_GEN_SWB) || EQ_16(HQ_mode, HQ_GEN_FB)) + { + last_sfm = s_max(core_sfm, sub(num_env_bands, 1)); + } + ELSE + { + last_sfm = core_sfm; + move16(); + } + + IF(EQ_16(HQ_mode, HQ_HARMONIC)) + { + /*high_sfm = (core_brate == HQ_BWE_CROSSOVER_BRATE) ? HVQ_THRES_SFM_24k-1 : HVQ_THRES_SFM_32k-3; */ + high_sfm = sub(HVQ_THRES_SFM_32k, 1); + if (LT_32(L_core_brate, HQ_BWE_CROSSOVER_BRATE)) + { + high_sfm = sub(HVQ_THRES_SFM_24k, 1); + } + + if (LT_16(last_sfm, high_sfm)) + { + last_sfm = high_sfm; + move16(); + } + } + ELSE if (EQ_16(HQ_mode, HQ_HVQ)) + { + bin_th = sfm_end[last_sfm]; + move16(); + } + + /* Transient analysis for envelope stability measure */ + IF(EQ_16(length, L_FRAME32k)) + { + env_stab_transient_detect_fx(is_transient, length, norm, no_att_hangover, L_energy_lt, HQ_mode, bin_th, L_coeff_out, 12); + } + + test(); + test(); + test(); + test(); + IF(EQ_16(length, L_FRAME16k) || + ((EQ_16(length, L_FRAME32k) && NE_16(HQ_mode, HQ_HARMONIC) && NE_16(HQ_mode, HQ_HVQ)) && *no_att_hangover == 0)) + { + /* Norm adjustment function */ + env_adj_fx(npulses, length, last_sfm, norm_adj, env_stab, sfmsize); + } + + /*flag_32K_env_hangover = ( length == L_FRAME32k && ( (env_stab < 0.5f && *no_att_hangover == 0) || HQ_mode == HQ_HVQ ) ); */ + flag_32K_env_hangover = 0; + move16(); + test(); + test(); + test(); + if (EQ_16(length, L_FRAME32k) && ((LT_16(env_stab, 16384) && *no_att_hangover == 0) || EQ_16(HQ_mode, HQ_HVQ))) + { + flag_32K_env_hangover = 1; + move16(); + } + + + /*----------------------------------------------------------------* + * Build noise-fill codebook + *----------------------------------------------------------------*/ + + IF(NE_16(HQ_mode, HQ_HVQ)) + { + cb_size = build_nf_codebook_fx(flag_32K_env_hangover, coeff, sfm_start, sfmsize, sfm_end, last_sfm, R, CodeBook, CodeBook_mod); + } + /*----------------------------------------------------------------* + * Prepare fine structure for Harmonic and HVQ + *----------------------------------------------------------------*/ + + IF(EQ_16(HQ_mode, HQ_HARMONIC)) + { + harm_bwe_fine_fx(R, last_sfm, high_sfm, num_sfm, norm, sfm_start, sfm_end, prev_L_swb_norm, coeff, L_coeff_out, coeff_fine); + } + ELSE IF(EQ_16(HQ_mode, HQ_HVQ)) + { + hvq_bwe_fine_fx(last_sfm, num_sfm, sfm_end, peak_idx, Npeaks, peak_pos, prev_L_swb_norm, L_coeff_out, bwe_peaks, coeff_fine); + } + + /*----------------------------------------------------------------* + * Apply noise-fill + *----------------------------------------------------------------*/ + + test(); + IF(NE_16(HQ_mode, HQ_HVQ) && cb_size > 0) + { + apply_noisefill_HQ_fx(R, length, flag_32K_env_hangover, L_core_brate, last_sfm, CodeBook, + CodeBook_mod, cb_size, sfm_start, sfm_end, sfmsize, coeff); + } + + /*----------------------------------------------------------------* + * Normal mode BWE + *----------------------------------------------------------------*/ + + IF(HQ_mode == HQ_NORMAL) + { + hq_fold_bwe_fx(last_sfm, sfm_end, num_sfm, coeff); + } + + /*----------------------------------------------------------------* + * Apply noise-fill adjustment + *----------------------------------------------------------------*/ + + test(); + test(); + test(); + IF((GE_16(length, L_FRAME32k) || GT_32(L_core_brate, HQ_32k) || LT_32(L_core_brate, HQ_24k40)) + && NE_16(HQ_mode, HQ_HVQ)) + { + apply_nf_gain_fx(nf_idx, last_sfm, R, sfm_start, sfm_end, coeff); + } + + /*----------------------------------------------------------------* + * Prepare fine strucutre for HQ GENERIC + *----------------------------------------------------------------*/ + test(); + IF(EQ_16(HQ_mode, HQ_GEN_SWB) || EQ_16(HQ_mode, HQ_GEN_FB)) + { + hq_generic_fine_fx(coeff, last_sfm, sfm_start, sfm_end, bwe_seed, coeff_fine); + } + + /*----------------------------------------------------------------* + * Apply envelope + *----------------------------------------------------------------*/ + + test(); + IF(NE_16(HQ_mode, HQ_HARMONIC) && NE_16(HQ_mode, HQ_HVQ)) + { + apply_envelope_fx(coeff, norm, norm_adj, num_sfm, last_sfm, HQ_mode, length, sfm_start, sfm_end, + L_normq_v, L_coeff_out, coeff_fine, L_coeff_out1); + } + + /*----------------------------------------------------------------* + * Harmonic BWE, HVQ BWE and HQ SWB BWE + *----------------------------------------------------------------*/ + test(); + IF(EQ_16(HQ_mode, HQ_HARMONIC)) + { + harm_bwe_fx(coeff_fine, coeff, num_sfm, sfm_start, sfm_end, last_sfm, R, prev_hq_mode, norm, noise_level, prev_noise_level, bwe_seed, L_coeff_out, element_mode); + } + ELSE IF(EQ_16(HQ_mode, HQ_HVQ)) + { + hvq_bwe_fx(L_coeff_out, coeff_fine, sfm_start, sfm_end, sfmsize, last_sfm, prev_hq_mode, bwe_peaks, bin_th, num_sfm, L_core_brate, R, norm, + noise_level, prev_noise_level, bwe_seed, L_coeff_out, 15, 12); + } + ELSE IF(EQ_16(HQ_mode, HQ_GEN_SWB) || EQ_16(HQ_mode, HQ_GEN_FB)) + { + hq_bwe_fx(HQ_mode, L_coeff_out1, hq_generic_fenv, L_coeff_out, hq_generic_offset, prev_L_swb_norm, hq_generic_exc_clas, sfm_end, num_sfm, num_env_bands, R); + } + + /*----------------------------------------------------------------* + * HQ WB BWE refinements + *----------------------------------------------------------------*/ + test(); + IF(EQ_16(length, L_FRAME16k) && LE_32(L_core_brate, HQ_32k)) + { + hq_wb_nf_bwe_fx(coeff, is_transient, prev_bfi, L_normq_v, num_sfm, sfm_start, sfm_end, sfmsize, last_sfm, R, + prev_is_transient, prev_normq, prev_env, bwe_seed, prev_coeff_out, prev_R, L_coeff_out, prev_env_Q); + } + + /*----------------------------------------------------------------* + * Update memories + *----------------------------------------------------------------*/ + + test(); + IF(NE_16(HQ_mode, HQ_HARMONIC) && NE_16(HQ_mode, HQ_HVQ)) + { + prev_noise_level[0] = 3277; + move16();/* 0.1 in Q15 */ + prev_noise_level[1] = 3277; + move16();/* 0.1 in Q15 */ + } + test(); + IF(!(EQ_16(length, L_FRAME16k) && LE_32(L_core_brate, HQ_32k))) + { + set32_fx(prev_env, 0, SFM_N_WB); + set32_fx(prev_normq, 0, SFM_N_WB); + } + + test(); + IF(EQ_16(length, L_FRAME32k) && LE_32(L_core_brate, HQ_32k)) + { + *prev_R = R[SFM_N_WB - 1]; + Copy32(L_coeff_out + L_FRAME16k - L_HQ_WB_BWE, prev_coeff_out, L_HQ_WB_BWE); + } + + return; +} diff --git a/lib_com/findpulse.c b/lib_com/findpulse.c index 3f8321160..5cc3253ce 100644 --- a/lib_com/findpulse.c +++ b/lib_com/findpulse.c @@ -40,6 +40,8 @@ #include "prot.h" #include "cnst.h" #include "wmc_auto.h" +#include "prot_fx1.h" +#include "prot_fx2.h" /*----------------------------------------------------------------------------------* * findpulse() @@ -138,3 +140,108 @@ int16_t findpulse( return ( maxi ); } + + +Word16 findpulse_fx( /* o : pulse position */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 res[], /* i : Residual signal <12 bits */ + const Word16 T0, /* i : Pitch estimation Q0 */ + const Word16 enc, /* i : enc = 1 -> encoder side; enc = 0 -> decoder side */ + Word16 *sign /* i/o: sign of the maximum */ +) +{ + const Word16 *ptr; + Word16 maxval; + Word16 i, maxi; + Word32 Ltmp; + Word16 resf[L_FRAME16k]; /* Low pass filtered residual */ + + IF(enc != DEC) + { + /*------------------------------------------------------------------------* + * 1. Very simple LP filter + *------------------------------------------------------------------------*/ + + /* resf[0] = 0.50f * res[0] + 0.25f * res[1] */ + Ltmp = L_mult(res[0], 16384); + resf[0] = mac_r(Ltmp, res[1], 8192); + move16(); + FOR(i = 1; i < L_frame - 1; i++) + { + /* resf[i] = 0.25f * res[i-1] + 0.5f * res[i] + 0.25f * res[i+1] */ + Ltmp = L_mult(8192, res[i - 1]); + Ltmp = L_mac(Ltmp, 16384, res[i]); + resf[i] = mac_r(Ltmp, 8192, res[i + 1]); + move16(); + } + + /* resf[L_frame-1] = 0.25f * res[L_frame-2] + 0.50f * res[L_frame-1] */ + Ltmp = L_mult(res[L_frame - 2], 8192); + resf[L_frame - 1] = mac_r(Ltmp, 16384, res[L_frame - 1]); + move16(); + + /*------------------------------------------------------------------------* + * 2. Find "biggest" pitch pulse + *------------------------------------------------------------------------*/ + + ptr = resf + L_frame - 1; + move16(); + maxi = 0; + move16(); + + FOR(i = 1; i < T0; i++) + { + Ltmp = L_mult0(ptr[-maxi], ptr[-maxi]); + if (L_msu0(Ltmp, ptr[-i], ptr[-i]) < 0) + { + maxi = i; + move16(); + } + } + /* + *sign = 1; move16(); + test(); + if (ptr[-maxi] >= 0) + { + *sign = 0; move16(); + }*/ + *sign = negate(shr(ptr[-maxi], 15)); + move16(); + } + ELSE + { + /*-----------------------------------------------------------------* + * 2. Find "biggest" pulse in the last pitch section according to the sign + *-----------------------------------------------------------------*/ + + maxval = 0; + move16(); + maxi = 0; + move16(); + + IF(*sign == 0) + { + FOR(i = 0; i < T0; i++) + { + if (GE_16(res[i], maxval)) + { + maxi = add(i, 1); + } + maxval = s_max(res[i], maxval); + } + } + ELSE + { + FOR(i = 0; i < T0; i++) + { + if (LE_16(res[i], maxval)) + { + maxi = add(i, 1); + } + maxval = s_min(res[i], maxval); + } + } + } + + return maxi; +} \ No newline at end of file diff --git a/lib_com/frame_ener.c b/lib_com/frame_ener.c index 1592c6e9f..721249fb6 100644 --- a/lib_com/frame_ener.c +++ b/lib_com/frame_ener.c @@ -40,7 +40,8 @@ #include "cnst.h" #include "prot.h" #include "wmc_auto.h" - +#include "prot_fx1.h" +#include "prot_fx2.h" /*----------------------------------------------------------------------------------* * fer_energy() * @@ -126,3 +127,223 @@ float frame_energy( return enern; } + + +#if 0 +//TO do rename to common name +#endif +/*----------------------------------------------------------------------------------* + * frame_ener() + * + * Estimation of pitch-synchronous (voiced) or mean half-frame (unvoiced) energy + *----------------------------------------------------------------------------------*/ +Word16 frame_ener_fx( + const Word16 L_frame, /* i : length of the frame */ + const Word16 clas, /* i : frame classification */ + const Word16 *synth, /* i : synthesized speech at Fs = 12k8 Hz Q_new */ + const Word16 pitch, /* i : pitch period Q0 */ + Word32 *enr_q, /* o : pitch-synchronous or half_frame energy Q0 */ + const Word16 offset, /* i : speech pointer offset (0 or L_FRAME) */ + const Word16 Q_new, /* i : Scaling factor */ + Word16 shift, /* i : Shift need to obtain 12 bits vectors */ + const Word16 enc /* i : Encoder/decoder */ +) +{ + Word16 len, exp_enrq, exp_tmp, pos; + Word16 i; + const Word16 *pt_synth; + Word32 Ltmp; + + exp_enrq = 0; + move16(); + test(); + test(); + IF((EQ_16(clas, VOICED_CLAS)) || (EQ_16(clas, ONSET)) || (EQ_16(clas, SIN_ONSET))) /* current frame is voiced */ + { + /* current frame is voiced */ + len = pitch; + move16(); /* pitch value at the end of frame */ + pt_synth = synth; + move16(); + if (offset != 0) + { + pt_synth = synth + sub(L_frame, len); + } + emaximum_fx(Q_new, pt_synth, len, enr_q); + move16();/* pitch synchronous E */ + IF(enc != 0) + { + exp_enrq = norm_l(*enr_q); + *enr_q = L_shl(*enr_q, exp_enrq); + move32(); + exp_enrq = sub(exp_enrq, 2); + } + } + ELSE + { + /* current frame is unvoiced */ + Word16 L_frame2, exp2, enr_q_tmp; + + L_frame2 = shr(L_frame,1); + pos = 0; + move16(); + + if (offset != 0) + { + pos = sub(L_frame, L_frame2); + } +#ifdef BASOP_NOGLOB + Ltmp = L_mult_sat(synth[pos], synth[pos]); +#else + Ltmp = L_mult(synth[pos], synth[pos]); +#endif + FOR(i = 1; i < L_frame2; i++) + { +#ifdef BASOP_NOGLOB + Ltmp = L_mac_sat(Ltmp, synth[pos + i], synth[pos + i]); +#else /* BASOP_NOGLOB */ + Ltmp = L_mac(Ltmp, synth[pos + i], synth[pos + i]); +#endif + } + test(); + IF(EQ_32(Ltmp, MAX_32) || enc != 0) + { + /* scale down when overflow occurs */ + *enr_q = Energy_scale(synth + pos, L_frame2, shift, &exp_enrq); + move32(); + } + ELSE + { + shift = 0; + move16(); + /* Normalize acc in Q31 (energy already calculated) */ + pos = norm_l(Ltmp); + Ltmp = L_shl(Ltmp, pos); + exp_enrq = sub(30, pos); /* exponent = 0..30 */ + *enr_q = Ltmp; + move32(); + } + + /* enr2 = 1.0f/L_FRAME2 * dot_product(synth, synth, L_FRAME2) */ + exp_enrq = sub(exp_enrq, shl(shift, 1)); + + IF(enc != 0) + { + assert(L_frame == 256 || L_frame == 320); + + exp_tmp = add(shl(Q_new, 1), -2 + 7); /* L_subfr == L_SUBFR */ + exp_enrq = sub(exp_enrq, exp_tmp); + exp_enrq = sub(31, exp_enrq); + + IF(EQ_16(L_frame, 320)) + { + *enr_q = Mult_32_16(*enr_q, 26214); /*x 0.8 to get /160*/ + i = norm_l(*enr_q); + *enr_q = L_shl(*enr_q, i); + exp_enrq = add(i, exp_enrq); + } + } + ELSE + { + exp_enrq = sub(exp_enrq, add(Q_new, Q_new)); + enr_q_tmp /*Q30 exp2+exp_enrq*/ = BASOP_Util_Divide3216_Scale(*enr_q /*Q31*/, L_frame2 /*Q0*/, &exp2); + *enr_q = L_shr(L_deposit_l(enr_q_tmp),sub(30,add(exp2,exp_enrq))); /*Q0*/ + *enr_q = L_add(*enr_q, 1); + move32(); + exp_enrq = 0; + move16(); + } + + + + + + + } + + return exp_enrq; +} + +/*------------------------------------------------------------------------* + * frame_energy() + * + * Compute pitch-synchronous energy at the frame end + *------------------------------------------------------------------------*/ +Word16 frame_energy_fx( /* o : Frame energy in Q8 */ + Word16 L_frame, + const Word16 *pitch, /* i : pitch values for each subframe Q6 */ + const Word16 *speech, /* i : pointer to speech signal for E computation Q_syn*/ + const Word16 lp_speech, /* i : long term active speech energy average Q8 */ + Word16 *frame_ener, /* o : pitch-synchronous energy at frame end Q8 */ + const Word16 Q_syn /* i : Synthesis scaling */ +) +{ + Word32 Ltmp; + const Word16 *pt1; + Word16 tmp16, exp1, exp2, tmp1, tmp2; + Word16 len, enern; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + + /* len = (0.5f * (pitch[2]/64.0 + pitch[3]/64.0) + 0.5f) */ +#ifdef BASOP_NOGLOB + len = mult_r(add_o(pitch[2], pitch[3], &Overflow), 256); +#else + len = mult_r(add(pitch[2], pitch[3]), 256); +#endif + + if (LT_16(len, L_SUBFR)) + { + len = shl(len, 1); + } + pt1 = speech + sub(L_frame, len); + + /* *frame_ener = 10.0f * log10(dot_product(pt1, pt1, len) / (float)len) */ + + tmp1 = norm_s(len); + tmp2 = shl(len, tmp1); + tmp1 = sub(15, tmp1); + + Ltmp = Dot_productSq16HQ(0, pt1, len, &exp1); + exp1 = sub(exp1, shl(Q_syn, 1)); + exp1 = sub(exp1, 1); /* compensation of leftshift caused by mac operation in dot_productSq16HQ */ + tmp16 = BASOP_Util_Divide3216_Scale(Ltmp, len, &exp2); + + exp1 = add(exp1, exp2); + exp1 = add(exp1, 1); /* compensate result of division Q-1 */ + + + tmp2 = norm_s(tmp16); + Ltmp = L_shl(L_deposit_h(tmp16), tmp2); /*Q16, (exp1-tmp2) = Q31, exp1-tmp2+15*/ + + Ltmp = BASOP_Util_Log2(Ltmp);/*Q(31-6) = Q25*/ + exp1 = sub(15 + exp1, tmp2); + + /*add ld(2^exp1)=exp1 but check format, first*/ + tmp16 = sub(sub(15, norm_s(exp1)), 5); /*factor to shift Ltmp and exp1 with (shr) to avoid overflows when adding*/ +#ifdef BASOP_NOGLOB + Ltmp = L_shr_o(Ltmp, tmp16, &Overflow); /*Q25, tmp16*/ +#else + Ltmp = L_shr(Ltmp, tmp16); /*Q25, tmp16*/ +#endif + exp2 = shr(exp1, tmp16); /*Q0 , tmp16*/ +#ifdef BASOP_NOGLOB + Ltmp = L_add_o(Ltmp, L_shl(L_deposit_l(exp2), 25), &Overflow); /*Q25, tmp16, normalized*/ +#else + Ltmp = L_add(Ltmp, L_shl(L_deposit_l(exp2), 25)); /*Q25, tmp16, normalized*/ +#endif + + /*make 10*log10 out of log2*/ + Ltmp = Mpy_32_16_1(Ltmp, LG10); /*Q25,tmp16 * Q13 = Q23, tmp16*/ +#ifdef BASOP_NOGLOB + * frame_ener = extract_h(L_shl_o(Ltmp, add(tmp16, 1), &Overflow));/*Q8*/ move16(); + enern = sub_o(*frame_ener, lp_speech, &Overflow); /*Q8*/ +#else + * frame_ener = extract_h(L_shl(Ltmp, add(tmp16, 1)));/*Q8*/ move16(); + enern = sub(*frame_ener, lp_speech); /*Q8*/ +#endif + + return enern; +} diff --git a/lib_com/get_gain.c b/lib_com/get_gain.c index 94e23a1c6..ca80ec21c 100644 --- a/lib_com/get_gain.c +++ b/lib_com/get_gain.c @@ -38,6 +38,8 @@ #include "options.h" #include "prot.h" #include "wmc_auto.h" +#include "prot_fx1.h" +#include "prot_fx2.h" /*----------------------------------------------------------------------------------* * get_gain() @@ -46,7 +48,7 @@ *----------------------------------------------------------------------------------*/ /*! r: codebook gain (adaptive or fixed) */ -float get_gain( +float get_gain_flt( const float x[], /* i : target signal */ const float y[], /* i : filtered codebook excitation */ const int16_t n, /* i : segment length */ @@ -69,3 +71,112 @@ float get_gain( return ( corr / ener ); } + +#if 0 +//Below is fixed implmentation +//TO DO rename get_gain_flt to get_gain once macro introduced +#endif + +Word32 get_gain( /* output: codebook gain (adaptive or fixed) Q16 */ + const Word16 x[], /* input : target signal */ + const Word16 y[], /* input : filtered codebook excitation */ + const Word16 n /* input : segment length */ +) +{ + Word32 tcorr, tener, Lgain; + Word16 exp_c, exp_e, exp, tmp; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + + tcorr = L_deposit_l(0); + tener = L_deposit_l(0); + + + + /*----------------------------------------------------------------* + * Find gain based on inter-correlation product + *----------------------------------------------------------------*/ + + tcorr = Dot_product16HQ(0, x, y, n, &exp_c); + tener = Dot_productSq16HQ(0, y, n, &exp_e); + +#ifdef BASOP_NOGLOB + BASOP_Util_Divide_MantExp(round_fx_o(tcorr, &Overflow), exp_c, s_max(round_fx_o(tener, &Overflow), 1), exp_e, &tmp, &exp); + Lgain = L_shl_o(L_deposit_l(tmp)/*Q15*/, add(1, exp), &Overflow)/*Q16*/; +#else + BASOP_Util_Divide_MantExp(round_fx(tcorr), exp_c, s_max(round_fx(tener), 1), exp_e, &tmp, &exp); + Lgain = L_shl(L_deposit_l(tmp)/*Q15*/, add(1, exp))/*Q16*/; +#endif + + return Lgain; +} + +Word32 get_gain2( /* output: codebook gain (adaptive or fixed) Q16 */ + const Word16 x[], /* input : target signal */ + const Word16 y[], /* input : filtered codebook excitation */ + const Word16 n /* input : segment length */ +) +{ + Word32 tcorr, tener, Lgain; + Word16 m_corr, m_ener, negative, Q_corr, Q_ener; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + negative = 0; + move16(); + + /*----------------------------------------------------------------* + * Find gain based on inter-correlation product + *----------------------------------------------------------------*/ + tcorr = Dot_product16HQ(0, x, y, n, &Q_corr); + tener = Dot_productSq16HQ(0, y, n, &Q_ener); + + tener = L_max(tener, 1); + + if (tcorr <= 0) + { + negative = 1; + move16(); + } + BASOP_SATURATE_WARNING_OFF_EVS /*tcorr max be negative maxvall - not critical*/ + tcorr = L_abs(tcorr); + BASOP_SATURATE_WARNING_ON_EVS + + m_corr = extract_h(tcorr); + + m_ener = extract_h(tener); + + IF(GT_16(m_corr, m_ener)) + { + m_corr = shr(m_corr, 1); + Q_corr = add(Q_corr, 1); + } + if (m_ener == 0) + { + move16(); + m_corr = 0x7FFF; + } + if (m_ener != 0) + { + m_corr = div_s(m_corr, m_ener); + } + + Q_corr = sub(Q_corr, Q_ener); + +#ifdef BASOP_NOGLOB + Lgain = L_shl_o(L_deposit_l(m_corr), add(Q_corr, 1), &Overflow); /* Lgain in Q16 */ +#else + Lgain = L_shl(L_deposit_l(m_corr), add(Q_corr, 1)); /* Lgain in Q16 */ +#endif + + if (negative != 0) + { + Lgain = L_negate(Lgain); /* Lgain in Q16 */ + } + + + return Lgain; +} diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c new file mode 100644 index 000000000..fd6d8855e --- /dev/null +++ b/lib_com/gs_gains_fx.c @@ -0,0 +1,727 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +/*==================================================================================== + EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 + ====================================================================================*/ + +#include "options.h" /* Compilation switches */ +#include "cnst.h" /* Common constants */ +#include "rom_com.h" /* Static table prototypes */ +#include "prot_fx1.h" +#include "prot_fx2.h" +#include "stl.h" + +static __inline Word16 L_Extract_lc(const Word32 L_32, Word16 *p_hi) +{ + *p_hi = extract_h(L_32); + return lshr(extract_l(L_32), 1); + +} +/*-------------------------------------------------------------------* + * Local constants + *-------------------------------------------------------------------*/ + +static Word16 VDQ_vec_fx( Word16 *Qvec_out_fx, const Word16 *mean_dic_fx, const Word16 *dic_fx, + const Word16 index_fx, const Word16 vec_en_fx ); + +/*========================================================================*/ +/* FUNCTION : void Comp_and_apply_gain_enc_fx */ +/*------------------------------------------------------------------------*/ +/* PURPOSE : Compute and apply the quantized per band gain */ +/*------------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* _ (Word16[]) Ener_per_bd_iQ : Target ener per band Q12 */ +/*------------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ (Word16[]) exc_diffQ : Quantized excitation Qexc */ +/* _ (Word16[]) Ener_per_bd_yQ : Ener per band for norm vectori->Q12/o->Q2*/ +/*------------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ None */ +/*------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ None */ +/*========================================================================*/ +void Comp_and_apply_gain_fx( + Word16 exc_diffQ[], /* i/o: Quantized excitation */ + Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */ + Word16 Ener_per_bd_yQ[], /* i/o : Ener per band for norm vector i->Q13/o->Q13 */ + Word16 Mbands_gn, /* i : number of bands */ + const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ + Word16 Qexc_diff, + Word16 Q_exc +) +{ + Word16 i, i_band; + Word16 StartBin, NB_Qbins; + Word16 y_gain; + Word16 L16, frac, exp1, tmp_exp; + Word32 L32; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + /* Recreate excitation for local synthesis and decoder */ + StartBin = 0; + move16(); + NB_Qbins = 0; + move16(); + + tmp_exp = add(14,sub(Q_exc,Qexc_diff)); /* In case of reuse, it can be computed outside the loop*/ + FOR( i_band = 0; i_band < Mbands_gn; i_band++ ) + { + StartBin = add(StartBin, NB_Qbins); + NB_Qbins = mfreq_bindiv_loc[i_band]; + move16(); + IF( EQ_16(ReUseGain,1)) + { + y_gain = Ener_per_bd_yQ[i_band]; + move16(); + + FOR(i = StartBin ; i < NB_Qbins + StartBin ; i++) + { +#ifdef BASOP_NOGLOB + L32 = L_shl_o(L_mult(exc_diffQ[i], y_gain),tmp_exp, &Overflow); /*Q_exc+16 */ + exc_diffQ[i] = round_fx_o(L32, &Overflow);/*Q_exc */ +#else /* BASOP_NOGLOB */ + L32 = L_shl(L_mult(exc_diffQ[i], y_gain),tmp_exp); /*Q_exc+16 */ + exc_diffQ[i] = round_fx(L32);/*Q_exc */ +#endif /* BASOP_NOGLOB */ + } + } + ELSE + { + /*-----------------------------------------------------------------* + * y_gain = pow(10.0, (Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band])) + * = pow(2, 3.321928*(Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band])) + *-----------------------------------------------------------------*/ + L16 = sub(Ener_per_bd_iQ[i_band], Ener_per_bd_yQ[i_band]);/*Q12 */ + L32 = L_mult(L16, 27213); /* 3.321928 in Q13 -> Q26 */ + L32 = L_shr(L32, 10); /* From Q26 to Q16 */ + frac = L_Extract_lc(L32, &exp1); /* Extract exponent of gcode0 */ + y_gain = extract_l(Pow2(14, frac));/* Put 14 as exponent so that */ + /* output of Pow2() will be: */ + /* 16384 < Pow2() <= 32767 */ +#ifdef BASOP_NOGLOB + Ener_per_bd_yQ[i_band] = shl_o(y_gain, sub(exp1, 13), &Overflow); +#else /* BASOP_NOGLOB */ + Ener_per_bd_yQ[i_band] = shl(y_gain, sub(exp1, 13)); +#endif /* BASOP_NOGLOB */ + move16();/*Q1 */ + tmp_exp = add(add(exp1,1),sub(Q_exc,Qexc_diff)); + + FOR(i = StartBin ; i < NB_Qbins + StartBin ; i++) + { + L32 = L_mult(exc_diffQ[i], y_gain); /*Qexc_diff+15 */ +#ifdef BASOP_NOGLOB + exc_diffQ[i] = round_fx_o(L_shl_o(L32,tmp_exp, &Overflow), &Overflow); /*Q_exc */ +#else /* BASOP_NOGLOB */ + exc_diffQ[i] = round_fx(L_shl(L32,tmp_exp)); /*Q_exc */ +#endif + } + } + } + + return; +} + + +/*========================================================================*/ +/* FUNCTION : Ener_per_band_comp_fx() */ +/*------------------------------------------------------------------------*/ +/* PURPOSE : Compute the energy per band in log domain for quantization */ +/* purposes. */ +/* Loops are decomposed to accomodate the PVQ quantization */ +/*------------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* _ (Word16*) edct_table_128_fx : edct table Q15 */ +/* _ (Word16*) Q_exc_diff : input format of exc_diff */ +/*------------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/*------------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16[]) y_gain4 : Energy per band to quantize Q12 */ +/* _ (Word32*) etmp14 : Energy band 14 Q_exc_diff*2+1 */ +/* _ (Word32*) etmp15 : Energy band 15 Q_exc_diff*2+1 */ +/*------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ None */ +/*========================================================================*/ +static Word16 Comp_band_log_ener( /* o : Band gain Q12 */ + const Word16 *pt_fx, /* i : Dct input Q_sc */ + const Word16 Len, /* i : Lenght en energy accumulation */ + const Word16 Q_sc, /* i : scaling of input */ + const Word16 E_sc /* i : Additional scaling factor for energy */ +) +{ + Word32 L_tmp; + Word16 e_tmp, f_tmp, tmp16, ener_exp; + + /*for(i = 0; i < 8; i++){etmp += (*pt * *pt);pt++;}*/ + L_tmp = Calc_Energy_Autoscaled(pt_fx, Q_sc, Len, &ener_exp); + + /*y_gain4[j] = (float)log10(sqrt(etmp< Q12 */ + } + ELSE IF (LE_32(core_brate,ACELP_8k00)) + { + Gain_off = 27034; + move16(); /* 6.6f -> Q12 */ + } + ELSE IF (LE_32(core_brate,ACELP_9k60)) + { + Gain_off = 19661; + move16(); /*4.8f-> Q12 */ + } + ELSE IF (LE_32(core_brate,ACELP_11k60)) + { + Gain_off = 14336; + move16(); /* 3.5f -> Q12 */ + } + ELSE IF (LE_32(core_brate,ACELP_13k20)) + { + Gain_off = 12288; + move16(); /* 3.0f -> Q12 dB */ + } + + /*mimic ACELP decay of energy for low rates*/ + FOR( i = 0; i < MBANDS_GN; i++ ) + { + old_y_gain[i] = y_gain_tmp[i]; + move16(); + /*y_gainQ[i] = y_gain_tmp[i]+mean_4g[0]-(i*(Gain_off/20.f)/((float) Mbands_gn));*/ + y_gainQ[i] = add(y_gain_tmp[i], sub(mean_g, i_mult2(i, mult_r(Gain_off, 102)))); + move16(); + } + } + + return; +} +/*==========================================================================*/ +/* FUNCTION : Word16 gsc_gaindec_fx () */ +/*--------------------------------------------------------------------------*/ +/* PURPOSE : Generic signal frequency band decoding and application */ +/*--------------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* _ (Word16) pvq_bits_fx : core used Q0 */ +/* _ (Word16) coder_type_fx : coding type Q0 */ +/* _ (Word16) core_fx : core used Q0 */ +/* _ (Word16) bwidth_fx : input signal bandwidth Q0 */ +/*--------------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16[]) y_gainQ_fx : quantized gain per band */ +/*--------------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ (Word16[]) old_y_gain_fx : AR gain quantizer for low rate */ +/*--------------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ (Word16) : average frequency gain */ +/*==========================================================================*/ +Word16 gsc_gaindec_fx( /* o : average frequency gain */ + Decoder_State_fx *st_fx, /* i/o: decoder state structure */ + Word16 y_gainQ_fx[], /* o : quantized gain per band */ + const Word32 core_brate_fx, /* i : core used */ + Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */ + const Word16 coder_type_fx, /* i : coding type */ + const Word16 bwidth_fx /* i : input signal bandwidth */ +) +{ + Word16 idx_g_fx, i; + Word16 mean_4g_fx; + Word16 y_gain_tmp3_fx[MBANDS_GN]; + + test(); + test(); + IF( (EQ_16(coder_type_fx,AUDIO)||EQ_16(coder_type_fx,INACTIVE))&&EQ_16(bwidth_fx,NB)) + { + idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 ); + VDQ_vec_fx(&mean_4g_fx, Gain_meanNB_fx, Gain_mean_dicNB_fx, idx_g_fx, 1 ); + + idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 ); + move16(); + VDQ_vec_fx(y_gainQ_fx, Mean_dic_NB_fx, Gain_dic1_NB_fx, idx_g_fx, 3 ); + + IF(LT_32(core_brate_fx,ACELP_9k60)) + { + idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); + VDQ_vec_fx(y_gainQ_fx+3, Mean_dic_NB_fx+3, Gain_dic2_NB_fx, idx_g_fx, 3 ); + + idx_g_fx = (Word16) get_next_indice_fx( st_fx, 4 ); + VDQ_vec_fx(y_gainQ_fx+6, Mean_dic_NB_fx+6, Gain_dic3_NB_fx, idx_g_fx, 4 ); + } + ELSE + { + idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 ); + VDQ_vec_fx(y_gainQ_fx+3, Mean_dic_NB_fx+3, Gain_dic2_NBHR_fx, idx_g_fx, 3 ); + + idx_g_fx = (Word16) get_next_indice_fx( st_fx, 7 ); + VDQ_vec_fx(y_gainQ_fx+6, Mean_dic_NB_fx+6, Gain_dic3_NBHR_fx, idx_g_fx, 4 ); + } + test(); + IF( LE_32(core_brate_fx,ACELP_9k60)&&EQ_16(coder_type_fx,INACTIVE)) + { + /* Some energy is needed in high band for stat_noise_uv_enc + to be functional in inactive speech */ + y_gainQ_fx[10] = mean_fx(y_gainQ_fx+6, 3); + move16(); + y_gainQ_fx[11] = mean_fx(y_gainQ_fx+7, 3); + move16(); + y_gainQ_fx[12] = mean_fx(y_gainQ_fx+8, 3); + move16(); + y_gainQ_fx[13] = mean_fx(y_gainQ_fx+9, 3); + move16(); + y_gainQ_fx[14] = mean_fx(y_gainQ_fx+10, 3); + move16(); + y_gainQ_fx[15] = mean_fx(y_gainQ_fx+11, 3); + move16(); + } + ELSE + { + set16_fx( y_gainQ_fx + 10, 0, MBANDS_GN - 10 ); + } + } + ELSE + { + idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 ); + + VDQ_vec_fx(&mean_4g_fx, mean_m_fx, mean_gain_dic_fx, idx_g_fx, 1 ); + + IF(LE_32(core_brate_fx,ACELP_9k60)) + { + /*--------------------------------------------------------------------------------------* + * UQ of the first 8 bands and half of the last 8 bands + *--------------------------------------------------------------------------------------*/ + idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); + VDQ_vec_fx(y_gainQ_fx, YGain_mean_LR_fx, YGain_dic1_LR_fx, idx_g_fx, 3 ); + + idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); + VDQ_vec_fx(y_gainQ_fx+3, YGain_mean_LR_fx+3, YGain_dic2_LR_fx, idx_g_fx, 4 ); + + /*----------------------------------------------------------------------* + * Interpolation of the last 4 Q bands to create bands 8-16 + * And scaling + *----------------------------------------------------------------------*/ + + idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); + + VDQ_vec_fx(y_gainQ_fx+7, YGain_mean_LR_fx+7, YGain_dic3_LR_fx, idx_g_fx, 5 ); + + Copy(y_gainQ_fx+8, y_gain_tmp3_fx, 4); + set16_fx(y_gainQ_fx+12, 0, 4); + + fft_rel_fx(y_gainQ_fx+8, 4, 2); + + y_gainQ_fx[15] = y_gainQ_fx[11]; + move16(); + y_gainQ_fx[11] = 0; + move16(); + ifft_rel_fx(y_gainQ_fx+8, 8, 3); + FOR(i = 8; i < 16; i++) + { + /*y_gainQ_fx[i] *= 1.41f;*/ + y_gainQ_fx[i] = round_fx(L_shl(L_mult(y_gainQ_fx[i] , 23101),1));/*Q12 */ + } + /*----------------------------------------------------------------------* + * Copy the true Q values in the specific bands + *----------------------------------------------------------------------*/ + y_gainQ_fx[8] = y_gain_tmp3_fx[0]; + move16(); + y_gainQ_fx[10]= y_gain_tmp3_fx[1]; + move16(); + y_gainQ_fx[12]= y_gain_tmp3_fx[2]; + move16(); + y_gainQ_fx[14]= y_gain_tmp3_fx[3]; + move16(); + } + ELSE + { + idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 ); + VDQ_vec_fx(y_gainQ_fx, YG_mean16_fx, YG_dicMR_1_fx, idx_g_fx, 4 ); + + idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); + VDQ_vec_fx(y_gainQ_fx+4, YG_mean16_fx+4, YG_dicMR_2_fx, idx_g_fx, 4 ); + + idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); + VDQ_vec_fx(y_gainQ_fx+8, YG_mean16_fx+8, YG_dicMR_3_fx, idx_g_fx, 4 ); + + idx_g_fx = (Word16) get_next_indice_fx( st_fx, 4 ); + VDQ_vec_fx(y_gainQ_fx+12, YG_mean16_fx+12, YG_dicMR_4_fx, idx_g_fx, 4 ); + } + } + + /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ + GSC_gain_adj(coder_type_fx, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx); + + return mean_4g_fx; + +} + + +/*-------------------------------------------------------------------* + * gsc_gainQ() + * + * Quantization of the energy per band + *-------------------------------------------------------------------*/ +Word16 gsc_gainQ_fx( /*Q12*/ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 y_gain4[], /* i : Energy per band Q12 */ + Word16 y_gainQ[], /* o : quantized energy per band Q12 */ + const Word32 core_brate, /* i : Core rate */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth /* i : input signal bandwidth */ +) +{ + Word16 y_gain_tmp[MBANDS_GN], y_gain_tmp2[MBANDS_GN]; + Word16 i, idx_g = 0; + Word16 mean_4g[1] = {0}, tmp16,tmp1, tmp2; + Word16 Mbands_gn = MBANDS_GN; + Word16 y_gain_tmp3[MBANDS_GN]; + Word16 cnt; + Word32 L_tmp; + + mean_4g[0] = 0; + + test(); + test(); + IF( (EQ_16(coder_type,AUDIO)||EQ_16(coder_type,INACTIVE))&&EQ_16(bwidth,NB)) + { + + /*ftmp1 = mean(y_gain4, 10)-0.6f;*/ + L_tmp = L_deposit_l(0); + FOR(cnt = 0 ; cnt < 10 ; cnt++) + { + L_tmp = L_mac(L_tmp,y_gain4[cnt], 3277); + } + tmp16 = sub(round_fx(L_tmp), 4915); + + FOR(i = 0; i < Mbands_gn; i++) + { + y_gain_tmp2[i] = y_gain4[i]; + move16(); + /*if(y_gain4[i] < ftmp1-0.6f)*/ + y_gain_tmp2[i] = s_max(y_gain_tmp2[i], tmp16); + move16(); + } + + L_tmp = L_deposit_l(0); + FOR(i = 0; i < 10; i++) + { + L_tmp = L_mac(L_tmp,y_gain_tmp2[i], 3277); + } + + /* Quantized mean gain without clipping */ + mean_4g[0] = round_fx(L_tmp); + idx_g = vquant_fx(mean_4g, Gain_meanNB_fx, mean_4g, Gain_mean_dicNB_fx, 1, 64); + push_indice_fx( hBstr, IND_MEAN_GAIN2, idx_g, 6 ); + + FOR(i = 0; i < Mbands_gn; i++) + { + y_gain_tmp[i] = sub(y_gain_tmp2[i],mean_4g[0]); + move16(); + } + /*if(y_gain_tmp[9] < -0.3f){y_gain_tmp[9] = -0.3f;}*/ + y_gain_tmp[9] = s_max(y_gain_tmp[9], -1229); + move16(); + set16_fx(y_gain_tmp+10, 0, MBANDS_GN-10); + idx_g = vquant_fx(y_gain_tmp, Mean_dic_NB_fx, y_gain_tmp, Gain_dic1_NB_fx, 3, 64); + push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); + + IF(LT_32(core_brate,ACELP_9k60)) + { + idx_g = vquant_fx(y_gain_tmp+3, Mean_dic_NB_fx+3, y_gain_tmp+3, Gain_dic2_NB_fx, 3, 32); + push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + idx_g = vquant_fx(y_gain_tmp+6, Mean_dic_NB_fx+6, y_gain_tmp+6, Gain_dic3_NB_fx, 4, 16); + push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 4 ); + } + ELSE + { + idx_g = vquant_fx(y_gain_tmp+3, Mean_dic_NB_fx+3, y_gain_tmp+3, Gain_dic2_NBHR_fx, 3, 64); + push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); + idx_g = vquant_fx(y_gain_tmp+6, Mean_dic_NB_fx+6, y_gain_tmp+6, Gain_dic3_NBHR_fx, 4, 128); + push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 7 ); + }/*add end */ + + test(); + IF( LE_32(core_brate,ACELP_9k60)&&EQ_16(coder_type,INACTIVE)) + { + /* Some energy is needed in high band for stat_noise_uv_enc + to be functional in inactive speech */ + y_gain_tmp[10] = round_fx(L_mac(L_mac(L_mult(y_gain_tmp[6],8192),y_gain_tmp[7],8192),y_gain_tmp[8],8192)); + y_gain_tmp[11] = round_fx(L_mac(L_mac(L_mult(y_gain_tmp[7],8192),y_gain_tmp[8],8192),y_gain_tmp[9],8192)); + + y_gain_tmp[12] = round_fx(L_mac(L_mac(L_mult(y_gain_tmp[8],8192),y_gain_tmp[9],8192),y_gain_tmp[10],8192)); + y_gain_tmp[13] = round_fx(L_mac(L_mac(L_mult(y_gain_tmp[9],8192),y_gain_tmp[10],8192),y_gain_tmp[11],8192)); + y_gain_tmp[14] = round_fx(L_mac(L_mac(L_mult(y_gain_tmp[10],8192),y_gain_tmp[11],8192),y_gain_tmp[12],8192)); + y_gain_tmp[15] = round_fx(L_mac(L_mac(L_mult(y_gain_tmp[11],8192),y_gain_tmp[12],8192),y_gain_tmp[13],8192)); + } + ELSE + { + set16_fx( y_gain_tmp + 10, 0, MBANDS_GN - 10 ); + } + } + ELSE + { + /*ftmp1 = mean(y_gain4, 16);*/ + + L_tmp =0; + FOR(cnt = 0 ; cnt < 16 ; cnt++) + { + L_tmp = L_mac(L_tmp,y_gain4[cnt], 2048); + } + tmp16 = round_fx(L_tmp); + + tmp1 = sub(tmp16,4915); + tmp2 = add(tmp16,4915); + L_tmp =0; + FOR(i = 0; i < 16; i++) + { + y_gain_tmp2[i] = y_gain4[i]; + move16(); + /*if(y_gain4[i] < ftmp1-0.6f)*/ + y_gain_tmp2[i] = s_max(y_gain_tmp2[i], tmp1); + move16(); + /*else if(y_gain4[i] > ftmp1+0.6f)*/ + y_gain_tmp2[i] = s_min(y_gain_tmp2[i], tmp2); + move16(); + L_tmp = L_mac(L_tmp,y_gain_tmp2[i], 2048); + } + FOR(; i < Mbands_gn; i++) + { + y_gain_tmp2[i] = y_gain4[i]; + /*if(y_gain4[i] < ftmp1-0.6f)*/ + y_gain_tmp2[i] = s_max(y_gain_tmp2[i], tmp1); /* Just the last move is needed, because s_max and s_min could be done in 1 line*/ + /*else if(y_gain4[i] > ftmp1+0.6f)*/ + y_gain_tmp2[i] = s_min(y_gain_tmp2[i], tmp2); + move16(); + } + + /* Quantized mean gain without clipping */ + mean_4g[0] = round_fx(L_tmp); + + + /*idx_g = (short)vquant(mean_4g, mean_m, mean_4g, mean_gain_dic, 1, 64);*/ + idx_g = vquant_fx(mean_4g, mean_m_fx, mean_4g, mean_gain_dic_fx, 1, 64); + push_indice_fx( hBstr, IND_MEAN_GAIN2, idx_g, 6 ); + + FOR(i = 0; i < Mbands_gn; i++) + { + y_gain_tmp[i] = sub(y_gain_tmp2[i],mean_4g[0]); + move16(); + } + + IF( LT_32(core_brate,ACELP_9k60)) + { + /*mvr2r(y_gain_tmp, y_gain_tmp2, 8); */ + Copy(y_gain_tmp, y_gain_tmp2, 8); + + y_gain_tmp2[8] = y_gain_tmp[8]; + move16(); + y_gain_tmp2[9] = y_gain_tmp[10]; + move16(); + y_gain_tmp2[10] =y_gain_tmp[12]; + move16(); + y_gain_tmp2[11] =y_gain_tmp[14]; + move16(); + + idx_g = 0; + + /*idx_g = (short)vquant(y_gain_tmp2, YGain_mean_LR, y_gain_tmp2, YGain_dic1_LR, 3, 32);*/ + idx_g = vquant_fx(y_gain_tmp2, YGain_mean_LR_fx, y_gain_tmp2, YGain_dic1_LR_fx, 3, 32 ); + push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + /*idx_g = (short)vquant(y_gain_tmp2+3, YGain_mean_LR+3, y_gain_tmp2+3, YGain_dic2_LR, 4, 32);*/ + idx_g = vquant_fx(y_gain_tmp2+3, YGain_mean_LR_fx+3, y_gain_tmp2+3, YGain_dic2_LR_fx, 4, 32 ); + push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + /*idx_g = (short)vquant(y_gain_tmp2+7, YGain_mean_LR+7, y_gain_tmp2+7, YGain_dic3_LR, 5, 32);*/ + idx_g = vquant_fx(y_gain_tmp2+7, YGain_mean_LR_fx+7, y_gain_tmp2+7, YGain_dic3_LR_fx, 5, 32); + push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + /*set_f(y_gain_tmp2+12, 0, MBANDS_GN-12);*/ + set16_fx(y_gain_tmp2+12, 0, MBANDS_GN-12); + + /* Update to quantized vector */ + Copy(y_gain_tmp2, y_gain_tmp, 8); + + Copy(y_gain_tmp2+8, y_gain_tmp3, 4); + set16_fx(y_gain_tmp+8, 0,8); + fft_rel_fx(y_gain_tmp2+8, 4, 2); + + Copy(y_gain_tmp2+8, y_gain_tmp+8, 3); + y_gain_tmp[15] = y_gain_tmp2[11]; + ifft_rel_fx(y_gain_tmp+8, 8, 3); + + FOR(i = 8; i < 16; i++) + { + /*y_gain_tmp[i] *= 1.41f;*/ + y_gain_tmp[i] = shl( mult_r(y_gain_tmp[i] , 23101),1) ; + move16(); + } + + y_gain_tmp[8] = y_gain_tmp3[0]; + move16(); + y_gain_tmp[10]= y_gain_tmp3[1]; + move16(); + y_gain_tmp[12]= y_gain_tmp3[2]; + move16(); + y_gain_tmp[14]= y_gain_tmp3[3]; + move16(); + } + ELSE + { + idx_g = vquant_fx(y_gain_tmp, YG_mean16_fx, y_gain_tmp, YG_dicMR_1_fx, 4, 64); + push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); + idx_g = vquant_fx(y_gain_tmp+4, YG_mean16_fx+4, y_gain_tmp+4, YG_dicMR_2_fx, 4, 32); + push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + idx_g = vquant_fx(y_gain_tmp+8, YG_mean16_fx+8, y_gain_tmp+8, YG_dicMR_3_fx, 4, 32); + push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + idx_g = vquant_fx(y_gain_tmp+12, YG_mean16_fx+12, y_gain_tmp+12, YG_dicMR_4_fx, 4, 16); + push_indice_fx( hBstr, IND_Y_GAIN_TMP, idx_g, 4 ); + } + } + + /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ + GSC_gain_adj(coder_type, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ); + + return mean_4g[0]; /*Q12*/ +} +/*-------------------------------------------------------------------* + * VDQ_vec() + * + * Return the dequantized vector of index + *-------------------------------------------------------------------*/ +static Word16 VDQ_vec_fx( + Word16 *Qvec_out_fx, /* o: Quanitzed vector */ + const Word16 *mean_dic_fx, /* i: average codebook */ + const Word16 *dic_fx, /* i: codebook */ + const Word16 index_fx, /* i: index of codebook*/ + const Word16 vec_en_fx /* i: vector length */ +) +{ + Word16 i, j; + + /*j = shr_r(extract_l(L_mult(index_fx,vec_en_fx)),1);*/ + j = i_mult2(index_fx,vec_en_fx); + FOR ( i = 0; i < vec_en_fx; i++) + { + Qvec_out_fx[i] = dic_fx[j++]; + move16(); + } + + FOR(i = 0; i < vec_en_fx; i++) + { + Qvec_out_fx[i] = add(Qvec_out_fx[i],mean_dic_fx[i]); + move16(); + } + + return index_fx; +} diff --git a/lib_com/gs_noisefill.c b/lib_com/gs_noisefill.c index f452dab7a..97223b535 100644 --- a/lib_com/gs_noisefill.c +++ b/lib_com/gs_noisefill.c @@ -41,6 +41,8 @@ #include "rom_com.h" #include "prot.h" #include "wmc_auto.h" +#include "prot_fx1.h" +#include "prot_fx2.h" /*-------------------------------------------------------------------* * gs_noisf() @@ -101,6 +103,72 @@ static void gs_noisf( return; } +static void gs_noisf_fx( + const Word16 Start_BIN, /* i : First bin for noise fill */ + const Word16 NB_Qbins, /* i : Number of bin per band */ + const Word16 Noise_fac, /* i : Noise level Q15 */ + const Word16 *y_norm, /* i : Quantized pulses Qn */ + Word16 *exc_diffQ, /* o : Quantized pulses with noise added Qn */ + Word16 *seed_tcx, /* i : Random generator seed */ + const Word16 coder_type, /* i : coder type */ + Word16 qNoise_fac +) +{ + Word32 ftmp; + Word16 i, k; + Word16 NB_zer; + Word32 const_1 = 1; + Word16 tmp; + + NB_zer = shr(NB_Qbins, 1); + + const_1 = L_shl(const_1, add(qNoise_fac, qNoise_fac)); + if (EQ_16(coder_type, INACTIVE)) + { + NB_zer = 2; + move16(); + } + + /*----------------------------------------------* + * noise fill-in on unquantized subvector * + * injected only from 1066Hz to 6400Hz. * + *----------------------------------------------*/ + + FOR(k = Start_BIN; k < NB_Qbins + Start_BIN; k += NB_zer) + { + ftmp = L_deposit_l(0); + FOR(i = k; i < k + NB_zer; i++) + { + exc_diffQ[i] = y_norm[i]; + move16(); + ftmp = L_mac0(ftmp, exc_diffQ[i], exc_diffQ[i]); + } + + IF(LT_32(L_shl(ftmp, 1), const_1)) + { + FOR(i = k; i < k + NB_zer; i++) + { + /*exc_diffQ[i] += Noise_fac*((float)own_random(seed_tcx)/32768.0f);*/ + tmp = mult(Noise_fac, Random(seed_tcx));/*Q15 */ + tmp = shr(tmp, sub(15, qNoise_fac));/*qNoise_fac */ + exc_diffQ[i] = add(exc_diffQ[i], tmp); + move16();/*Q */ + } + } + ELSE + { + /* This is added only to keep the seed in sync between different compilers */ + FOR(i = k; i < k + NB_zer; i++) + { + Random(seed_tcx); + } + } + + } + + return; +} + /*-------------------------------------------------------------------* * EstimateNoiseLevel_inner() * @@ -148,7 +216,50 @@ static void EstimateNoiseLevel_inner( return; } - +static void EstimateNoiseLevel_inner_fx( + Word16 *noisepb, /* o : Noise per band Q15 */ + const long bitrate, /* i : Bitrate of the codec */ + const Word16 i_band, /* i : First band to compute the noise */ + const Word16 Mbands_gn /* i : number of bands */ +) +{ + Word16 i; + Word16 noise_offset; + + noise_offset = 8192; + move16(); + /*0.25f * 32768 */ + IF(bitrate > ACELP_24k40) + { + noise_offset = 6554; + move16(); /*.2f * 32768 */ + } + ELSE IF(bitrate >= ACELP_22k60) + { + noise_offset = 9830; + move16();/*.3f * 32768 */ + } + ELSE IF(bitrate >= ACELP_9k60) + { + noise_offset = 11469; + move16(); /*0.35f * 32768 */ + } + ELSE + { + noise_offset = 13107; + move16(); /*.4f * 32768 */ + } + + set16_fx(noisepb + i_band, noise_offset, sub(Mbands_gn, i_band)); + + FOR(i = i_band; i < 5; i++) + { + noisepb[i] = s_min(noisepb[i], 6554); + move16(); + } + + return; +} /*-------------------------------------------------------------------* * EstimateNoiseLevel() * @@ -237,6 +348,94 @@ static void EstimateNoiseLevel( return; } +static void EstimateNoiseLevel_fx( + Word16 *noisepb, /* o : Noise per band */ + const Word32 bitrate, /* i : Bitrate of the codec */ + const Word16 Diff_len, /* i : number of bin before cut-off frequency */ + const Word16 Mbands_gn, /* i : number of bands */ + const Word16 coder_type, /* i : coder type */ + const Word16 noise_lev, /* i : pulses dynamic */ + const Word16 pit_band_idx, /* i : bin position of the cut-off frequency */ + Word16 last_bin, /* i : the last bin of bit allocation */ + Word16 bwidth, + const int16_t L_frame /* i : frame length */ +) +{ + Word16 i_band; + + i_band = 0; + move16(); + + IF(LT_16(Diff_len, L_frame)) + { + EstimateNoiseLevel_inner_fx(noisepb, bitrate, i_band, MBANDS_GN); + IF(coder_type != INACTIVE) + { + test(); + test(); + IF((EQ_32(bitrate, ACELP_8k00) && GT_16(last_bin, 8)) && NE_16(bwidth, NB)) + { + FOR(; Mbands_gn > i_band; i_band++) + { + noisepb[i_band] = add(noisepb[i_band], noisepb[i_band]); + move16(); + } + } + ELSE + { + FOR(; pit_band_idx > i_band; i_band++) + { + noisepb[i_band] = mult_r(noisepb[i_band], 16384); + move16();/* 1/2=0.5 in Q15 */ + } + } + } + } + test(); + IF((EQ_16(coder_type, INACTIVE) || GE_16(noise_lev, NOISE_LEVEL_SP3)) && EQ_16(L_frame, L_FRAME)) + { + FOR(i_band = 9; i_band < Mbands_gn; i_band++) + { + noisepb[i_band] = add(noisepb[i_band], mult_r(noisepb[i_band], 4915)); + move16();/*noisepb[i_band]*1.15=noisepb[i_band] *(1 + 0.15) */ + } + } + ELSE IF(EQ_16(L_frame, L_FRAME16k)) + { + IF(EQ_32(bitrate, ACELP_13k20)) + { + set16_fx(noisepb, 14746/*0.45*/, Mbands_gn); + } + + IF(EQ_16(coder_type, INACTIVE)) + { + FOR(; i_band < Mbands_gn; i_band++) + { + noisepb[i_band] = 13107/*.4f*/; + move16(); + } + } + ELSE IF(LE_16(noise_lev, NOISE_LEVEL_SP1) && GT_32(bitrate, ACELP_16k40)) + { + FOR(; i_band < sub(Mbands_gn, 4); i_band++) + { + noisepb[i_band] = mult_r(noisepb[i_band], 19661)/*.6f*/; + move16(); + } + } + ELSE IF(LE_16(noise_lev, NOISE_LEVEL_SP2) && GT_32(bitrate, ACELP_16k40)) + { + FOR(; i_band < sub(Mbands_gn, 4); i_band++) + { + noisepb[i_band] = mult_r(noisepb[i_band], 26214)/*.8f*/; + move16(); + } + } + } + + + return; +} /*-------------------------------------------------------------------* * Apply_NoiseFill() @@ -272,6 +471,39 @@ static void Apply_NoiseFill( return; } +static void Apply_NoiseFill_fx( + Word16 *exc_diffQ, /* i/o: Noise per band qexc_diffQ */ + Word16 *seed_tcx, /* i : Seed for noise */ + const Word16 *noisepb, /* i : Noise per band Q15 */ + const Word16 Diff_len, /* i : number of bin before cut-off frequency */ + const Word16 Mbands_gn, /* i : number of bands */ + const Word16 coder_type, /* i : coder type */ + const Word16 *freq_nsbin_per_band, /* i : bin per bands tables */ + Word16 qexc_diffQ +) +{ + Word16 StartBin, NB_Qbins, i_band; + StartBin = 0; + move16(); + NB_Qbins = 0; + move16(); + + FOR(i_band = 0; i_band < Mbands_gn; i_band++) + { + StartBin += NB_Qbins; + move16(); + NB_Qbins = freq_nsbin_per_band[i_band]; + move16(); + + IF(LT_16(Diff_len, L_FRAME)) + { + gs_noisf_fx(StartBin, NB_Qbins, noisepb[i_band], exc_diffQ, exc_diffQ, seed_tcx, coder_type, qexc_diffQ); + } + } + + return; +} + /*-------------------------------------------------------------------* * freq_dnw_scaling() @@ -363,6 +595,88 @@ void freq_dnw_scaling( return; } +void freq_dnw_scaling_fx( + const Word16 cor_strong_limit, /* i : HF correlation */ + const Word16 coder_type, /* i : coder type */ + const Word16 noise_lev, /* i : Noise level */ + const Word32 core_brate, /* i : Core bitrate */ + Word16 fy_norm[], /* i/o: Frequency quantized parameter */ + Word16 Qx, /* Q format of fy_norm*/ + const int16_t L_frame /* i : frame length */ + +) +{ + Word16 sc_dyn; + Word16 start_sc, i; + + sc_dyn = 32767; + move16(); /*Q15 */ + start_sc = L_frame; + move16(); + test(); + IF(LE_32(core_brate, ACELP_8k00) && EQ_16(coder_type, INACTIVE)) + { + sc_dyn = mult_r(sc_dyn, 4915); /*Q15 (0.15 in Q15) */ + start_sc = 64; + move16(); + } + ELSE IF(EQ_16(coder_type, INACTIVE)) + { + sc_dyn = mult_r(sc_dyn, 8192); /*Q15 (0.25 in Q15) */ + start_sc = 80; + move16(); + } + ELSE + { + /*sc_dyn = (float)(NOISE_LEVEL_SP3 - noise_lev)/10.0f + 0.4f;*/ + sc_dyn = extract_l(L_mac(13107, sub(NOISE_LEVEL_SP3, noise_lev), 1638)); /*Q0*Q14x2+Q15 =Q15*/ + start_sc = add(112, shl(sub(NOISE_LEVEL_SP3, noise_lev), 4)); + if (EQ_16(noise_lev,NOISE_LEVEL_SP0)) + { + start_sc = L_FRAME; + move16(); + } + } + + IF(EQ_16(L_frame, L_FRAME16k) && LE_32(core_brate, ACELP_24k40)) + { + /*sc_dyn += 0.125f;*/ + sc_dyn = add(sc_dyn, 4096); /* Saturates to 1.0 */ + } + + FOR(i = start_sc; i < L_frame; i++) + { + fy_norm[i] = mult_r(fy_norm[i], sc_dyn); + move16();/*Qx */ + } + + test(); + test(); + IF((LT_32(core_brate, ACELP_13k20) && cor_strong_limit == 0) || LT_32(core_brate, ACELP_9k60)) + { + FOR(i = 160; i < L_frame; i++) + { + fy_norm[i] = s_min(fy_norm[i], shl(1, Qx)); + move16(); + fy_norm[i] = s_max(fy_norm[i], shl(-1, Qx)); + move16(); + } + } + ELSE IF(LT_32(core_brate, ACELP_22k60)) + { + FOR(i = 160; i < L_frame; i++) + { + fy_norm[i] = s_min(fy_norm[i], shr_r(1536, sub(10, Qx))); + move16(); + fy_norm[i] = s_max(fy_norm[i], shr_r(-1536, sub(10, Qx))); + move16(); + } + } + + return; + +} + /*-------------------------------------------------------------------* * Decreas_freqPeak() @@ -444,6 +758,119 @@ static void Decreas_freqPeak( return; } +static void Decreas_freqPeak_fx( + const Word16 *lsf_new, /* i : ISFs at the end of the frame */ + Word16 *exc_diffQ, /* i/o: frequency coefficients of per band */ + Word16 rat /* i : threshold of ratio between consecutive lsf_new_diff */ +) +{ + Word16 i, j, k; + Word16 last_bin = 0; + Word16 pos = 0; + Word16 *src, max_val, avrg; + Word32 L_avrg, L_tmp; + Word16 lsf_new_diff[M]; + Word16 tmp, tmp1, exp; + Word16 tmp2; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + move16(); /*ptr init*/ + lsf_new_diff[0] = 0; /* prevent unitialized value */ + FOR(j = 1; j < (M - 1); j++) + { + lsf_new_diff[j] = sub(lsf_new[j], lsf_new[j - 1]);/*Qx2.56 */ + } + + avrg = 0; + move16(); + L_avrg = L_deposit_l(0); + max_val = 1; + move16(); + FOR(i = 160; i < L_FRAME; i++) + { + IF(GT_16(abs_s(exc_diffQ[i]), max_val)) + { + max_val = abs_s(exc_diffQ[i]); + pos = i; + move16(); + } + L_avrg = L_add(L_avrg, abs_s(exc_diffQ[i])); + } + /* avrg /= 96; */ + L_avrg = Mult_32_16(L_avrg, 21845);/*Q_exc+21 -15 ->Q_exc + 6 */ + avrg = round_fx(L_shl(L_avrg, 10));/*Q_exc */ + last_bin = M - 1; + move16(); /* When the search is false, should equate the end of the vector, not the beginning */ + FOR(i = 0; i < (M - 1); i++) + { + if (GT_16(lsf_new[i], 10240)) + { + last_bin = i; + move16(); + BREAK; + } + } + + FOR(i = last_bin; i < 14; i++) + { + tmp = mult_r(rat, lsf_new_diff[i - 1]);/*Qx2.56 */ + IF(GT_16(tmp, lsf_new_diff[i])) + { + src = &exc_diffQ[shl(sub(i, 1), 4)]; + move16(); + FOR(j = 0; j < 2; j++) + { + FOR(k = 0; k < 16; k++) + { + tmp = mult_r(16384, abs_s(*src)); + IF(GT_16(tmp, avrg)) + { + tmp = abs_s(*src); + exp = norm_s(max_val); + tmp1 = div_s(shl(1, sub(14, exp)), max_val);/*Q(29 - exp - Q_exc) */ + L_tmp = L_mult(tmp, tmp1);/*Q(30 - exp) */ +#ifdef BASOP_NOGLOB + tmp = round_fx_o(L_shl_o(L_tmp, exp, &Overflow), &Overflow);/*Q14 */ +#else + tmp = round_fx(L_shl(L_tmp, exp));/*Q14 */ +#endif + tmp = sub(32767, tmp);/*Q14 */ + L_tmp = L_mult(avrg, tmp);/*Q_exc +15 */ + + tmp = round_fx(L_shl(L_tmp, 1)); + tmp1 = negate(tmp); + + tmp2 = *src; + *(src) = tmp1; + move16(); + if (tmp2 > 0) + { + *(src) = tmp; + move16(); + } + + } + src++; + } + } + } + } + + tmp = mult_r(8192, max_val);/*Q_exc */ + test(); + IF(EQ_16(abs_s(exc_diffQ[pos]), max_val) && GT_16(tmp, avrg)) + { + FOR(i = pos - 1; i < pos + 2; i++) + { + exc_diffQ[pos] = mult_r(16384, exc_diffQ[pos]); + move16(); + } + } + + return; +} + /*-------------------------------------------------------------------* * envelop_modify() @@ -495,6 +922,145 @@ static void envelop_modify( return; } +static void envelop_modify_fx( + Word16 *exc_diffQ_fx, /* i/o: frequency coefficients of per band */ + Word16 *seed_tcx, /* i : Seed for noise */ + Word16 last_bin, /* i : last bin of bit allocation */ + Word16 *Ener_per_bd_iQ_fx, /* i : Quantized energy of targeted vector */ + Word16 Q_exc, + Word16 *Q_hb_exc +) +{ + Word16 i, j, end_band; + Word16 start_band; + Word32 Ener_fx; + Word16 Ener1_fx; + Word16 tmp, tmp1; + Word32 L_tmp; + Word16 exp, exp1, frac; + Word16 *src_fx; + Word16 weight_fx; + Word32 L_exc_diffQ_fx[L_FRAME16k], exc_diffQ_max; + Word16 Q_tmp; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + start_band = i_mult(last_bin, 16); + end_band = L_FRAME; + move16(); + Ener_fx = L_deposit_l(0); + FOR(i = start_band; i < end_band; i++) + { + L_tmp = L_mult0(exc_diffQ_fx[i], exc_diffQ_fx[i]); /*2*Q_exc */ + Ener_fx = L_add(Ener_fx, L_shr(L_tmp, 7)); /*2*Q_exc-7 */ + } + + tmp = sub(end_band, start_band); + tmp = div_s(1, tmp);/*Q15 */ + Ener_fx = Mult_32_16(Ener_fx, tmp); /*Q(2*Q_exc-7+15)->Q(2*Q_exc-7) */ + + exp1 = norm_l(Ener_fx); + Ener_fx = L_shl(Ener_fx, exp1); + exp1 = 31 - exp1 - sub(shl(Q_exc, 1), 7); + move16(); + Ener_fx = Isqrt_lc(Ener_fx, &exp1); /*Q(31-exp1) */ + + weight_fx = 16384; /*Q15 */ + src_fx = &exc_diffQ_fx[start_band]; /*Q_exc */ + FOR(i = last_bin; i < last_bin + 4; i++) + { + /*Ener1 = (float)(0.4f*pow(10, Ener_per_bd_iQ[i+1])); */ + L_tmp = L_shr(L_mult0(Ener_per_bd_iQ_fx[i + 1], 27213), 9); /* 3.321928 in Q13 -> Q16 */ + + frac = L_Extract_lc(L_tmp, &exp); /* Extract exponent of L_tmp */ + tmp = extract_l(Pow2(14, frac));/* Put 14 as exponent so that */ + /* output of Pow2() will be: */ + /* 16384 < Pow2() <= 32767 */ + exp = sub(exp, 14); +#ifdef BASOP_NOGLOB + Ener1_fx = mult_ro(13107, shl_o(tmp, exp, &Overflow), &Overflow); /*Q0 */ +#else /* BASOP_NOGLOB */ + Ener1_fx = mult_r(13107, shl(tmp, exp)); /*Q0 */ +#endif /* BASOP_NOGLOB */ + + FOR(j = 0; j < 16; j++) + { + /**src = Ener1*(weight*(*src)*Ener + (1.0f-weight)*own_random(seed_tcx)/32768.0f); */ + L_tmp = Mult_32_16(Ener_fx, *src_fx); /*Q(31-exp+Q_exc-15) -> Q(16-exp+Q_exc) */ + tmp = extract_l(L_shr(L_tmp, add(4, sub(Q_exc, exp1)))); /*Q12 */ + tmp = mult_r(weight_fx, tmp); /*Q12 */ + + L_tmp = L_mult0(sub(32767, weight_fx), Random(seed_tcx)); /*Q30 */ + tmp1 = round_fx(L_shr(L_tmp, 2)); + + L_exc_diffQ_fx[16 * i + j] = L_mult0(Ener1_fx, add(tmp, tmp1)); /*Q12 */ move32(); + src_fx++; + } + } + + /*Ener1 = (float)(0.4f*pow(10, Ener_per_bd_iQ[15])); */ + L_tmp = L_shr(L_mult0(Ener_per_bd_iQ_fx[15], 27213), 9); /* 3.321928 in Q13 -> Q16 */ + + frac = L_Extract_lc(L_tmp, &exp); /* Extract exponent of L_tmp */ + tmp = extract_l(Pow2(14, frac));/* Put 14 as exponent so that */ + /* output of Pow2() will be: */ + /* 16384 < Pow2() <= 32767 */ + exp = sub(exp, 14); +#ifdef BASOP_NOGLOB + Ener1_fx = mult_r(13107, shl_o(tmp, exp, &Overflow)); /*Q0 */ +#else /* BASOP_NOGLOB */ + Ener1_fx = mult_r(13107, shl(tmp, exp)); /*Q0 */ +#endif /* BASOP_NOGLOB */ + + src_fx = &exc_diffQ_fx[224]; + FOR(j = 0; j < 32; j++) + { + /**src = Ener1*(weight*(*src)*Ener + (1.0f-weight)*own_random(seed_tcx)/32768.0f); */ + L_tmp = Mult_32_16(Ener_fx, *src_fx); /*Q(31-exp+Q_exc-15) -> Q(16-exp+Q_exc) */ + tmp = extract_l(L_shr(L_tmp, add(4, sub(Q_exc, exp1)))); /*Q12 */ + tmp = mult_r(weight_fx, tmp); /*Q12 */ + + L_tmp = L_mult0(sub(32767, weight_fx), Random(seed_tcx)); /*Q30 */ + tmp1 = round_fx(L_shr(L_tmp, 2)); /*Q12 */ + + L_exc_diffQ_fx[16 * i + j] = L_mult0(Ener1_fx, add(tmp, tmp1)); /*Q12 */ move32(); + src_fx++; + } + + exc_diffQ_max = 0; + move16(); + FOR(i = start_band; i < L_FRAME; i++) + { + IF(GT_32(L_abs(L_exc_diffQ_fx[i]), exc_diffQ_max)) + { + exc_diffQ_max = L_abs(L_exc_diffQ_fx[i]); + } + } + exp = norm_l(exc_diffQ_max); + + IF(GT_16(exp, 16)) + { + *Q_hb_exc = 12; + move16(); + FOR(i = start_band; i < L_FRAME; i++) + { + exc_diffQ_fx[i] = extract_l(L_exc_diffQ_fx[i]); + } + } + ELSE + { + Q_tmp = sub(16, exp); + *Q_hb_exc = sub(12, Q_tmp); + FOR(i = start_band; i < L_FRAME; i++) + { + exc_diffQ_fx[i] = extract_l(L_shr(L_exc_diffQ_fx[i], Q_tmp)); + } + } + + return; +} + /*-------------------------------------------------------------------* * highband_exc_dct_in() @@ -841,3 +1407,445 @@ void highband_exc_dct_in( return; } + +void highband_exc_dct_in_fx( + const Word32 core_brate, /* i : core bitrate */ + const Word16 *mfreq_bindiv, /* i : bin per bands tables */ + Word16 last_bin, /* i : last bin of bit allocation */ + Word16 Diff_len, /* i : number of bin before cut-off frequency */ + Word16 noise_lev, /* i : pulses dynamic */ + Word16 pit_band_idx, /* i : bin position of the cut-off frequency */ + Word16 *exc_diffQ, /* i : frequency coefficients of per band */ + Word16 *seed_tcx, /* i : Seed for noise */ + Word16 *Ener_per_bd_iQ, /* i : Quantized energy of targeted vector */ + Word16 nb_subfr, /* i : Number of subframe considered */ + Word16 *exc_dct_in, /* o : dct of residual signal */ + Word16 last_coder_type, /* i : coding type of last frame */ + Word16 *bitallocation_band, /* i : bit allocation flag of each band */ + const Word16 *lsf_new, /* i : LSFs at the end of the frame */ + Word16 *last_exc_dct_in, /* i : dct of residual signal of last frame */ + Word16 *last_ener, /* i : frequency energy of last frame */ + Word16 *last_bitallocation_band, /* i : bit allocation flag of each band of last frame */ + Word16 *bitallocation_exc, /* i : flag of decoded coefficients */ + Word16 bfi, /* i : bad frame indicator */ + const Word16 coder_type, /* i : coder type */ + Word16 bwidth, + Word16 *exc_wo_nf, /* o : temporal excitation (in f domain) without noisefill */ + Word16 Qexc_diffQ, + Word16 Q_exc, + const Word16 GSC_noisy_speech + , Word16 *lt_ener_per_band_fx, /* i/o: Average per band energy */ + const int16_t L_frame, /* i : frame length */ + const int16_t element_mode, /* i : IVAS element mode */ + const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */ +) +{ + Word16 i, j, k; + Word16 MAX_Bin = 0; + Word16 last_bin_tmp, ener = 0; + Word16 noisepb[MBANDS_GN16k]; + Word16 Ener_per_bd_yQ[MBANDS_GN16k]; + Word16 *src, *dst; + Word32 L_tmp; + Word16 length_bin, bwe_flag = 0, tmp; + Word16 frac, exp, tmp1; + Word16 tmp2; + Word16 *end, Q_hb_exc; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + FOR(j = 10; j < MBANDS_GN; j++) + { + /* ener += (float)pow(10, Ener_per_bd_iQ[j]); + ener += (float)pow(2, 3.321928*Ener_per_bd_iQ[j]); */ + + L_tmp = L_mult(Ener_per_bd_iQ[j], 27213); /* 3.321928 in Q13 -> Q27 */ + L_tmp = L_shr(L_tmp, 10); /* From Q27 to Q16 */ + + frac = L_Extract_lc(L_tmp, &exp); /* Extract exponent of L_tmp */ + tmp = extract_l(Pow2(14, frac));/* Put 14 as exponent so that */ + /* output of Pow2() will be: */ + /* 16384 < Pow2() <= 32767 */ + exp = sub(exp, 14); +#ifdef BASOP_NOGLOB + tmp1 = shl_o(tmp, exp, &Overflow); +#else /* BASOP_NOGLOB */ + tmp1 = shl(tmp, exp); +#endif /* BASOP_NOGLOB */ + move16(); +#ifdef BASOP_NOGLOB + ener = add_o(tmp1, ener, &Overflow);/*Q0 */ +#else /* BASOP_NOGLOB */ + ener = add(tmp1, ener);/*Q0 */ +#endif /* BASOP_NOGLOB */ + } + + test(); + IF(EQ_32(core_brate, ACELP_8k00) && NE_16(bwidth, NB)) + { + if (NE_16(last_coder_type, AUDIO)) + { + *last_ener = ener; + move16(); + } + test(); + test(); + IF((GT_16(last_bin, 8) || Diff_len != 0) && EQ_16(last_coder_type, AUDIO)) + { + MAX_Bin = 10; + move16(); + bwe_flag = 1; + move16(); + } + ELSE + { + MAX_Bin = 15; + move16(); + } + + last_bin_tmp = last_bin; + move16(); + last_bin = s_max(last_bin, MAX_Bin); + last_bin = add(last_bin, 1); + } + ELSE + { + IF(EQ_16(L_frame, L_FRAME16k)) + { + last_bin = MBANDS_GN16k; + move16(); + } + ELSE + { + last_bin = MBANDS_GN; + move16(); + } + last_bin_tmp = last_bin; + move16(); + } + + IF(bfi || LT_32(core_brate, 6000) || (LT_32(core_brate, 8600) && EQ_16(coder_type, UNVOICED))) + { + set16_fx(noisepb, 13107, MBANDS_GN); /*0.4 in Q15 */ + } + ELSE IF(EQ_16(GSC_IVAS_mode, 3) || (GSC_IVAS_mode > 0 && EQ_16(GSC_noisy_speech, 1))) + { + set16_fx(noisepb, 13107/*0.4f*/, MBANDS_GN16k); + } + ELSE + { + EstimateNoiseLevel_fx(noisepb, core_brate, Diff_len, last_bin, coder_type, noise_lev, pit_band_idx, last_bin_tmp, bwidth, L_frame); + } + + IF(exc_wo_nf != NULL) + { + Copy(exc_diffQ, exc_wo_nf, L_frame); + } + + test(); + + IF(GSC_IVAS_mode == 0 && GSC_noisy_speech && !bfi && LE_16(element_mode, IVAS_SCE)) + { + set16_fx(noisepb, 3277, MBANDS_GN); + } + IF(LT_32(core_brate, 6000) && LE_16(coder_type, UNVOICED)) + { + FOR(i = 0; i < L_frame; i++) + { + IF(exc_diffQ[i] == 0) + { + //PMT("code below to be validated for IVAS use") + /* exc_diffQ[i] += 2.0f * noisepb[0] * ((float)own_random(seed_tcx) / PCM16_TO_FLT_FAC);*/ + tmp = mult(shl(noisepb[0], 1), Random(seed_tcx));/*Q15 */ + tmp = shr(tmp, sub(15, Qexc_diffQ));/*qNoise_fac */ + exc_diffQ[i] = add(exc_diffQ[i], tmp); + move16();/*Q */ + } + } + } + ELSE + { + Apply_NoiseFill_fx(exc_diffQ, seed_tcx, noisepb, Diff_len, last_bin, coder_type, mfreq_bindiv, Qexc_diffQ); + } + /*--------------------------------------------------------------------------------------* + * Quantize average gain + * Subtract Q averaged gain + * VQ of remaining gain per band + *--------------------------------------------------------------------------------------*/ + test(); + IF(EQ_32(core_brate, ACELP_8k00) && NE_16(bwidth, NB)) + { + Ener_per_band_comp_fx(exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, add(last_bin, 1), 0); + } + ELSE + { + Ener_per_band_comp_fx(exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, MBANDS_GN, 1); + + IF(LT_16(nb_subfr, 4) && LT_16(L_frame, L_FRAME16k)) + { + FOR(i = L_FRAME - 16; i < L_FRAME; i++) + { + /*exc_diffQ[i] *= 0.067f * i - 15.0f; = -15 - (-0.067f * i) */ + tmp = msu_r(-7680 * 65536, -17564, shl(i,6));/*-15 in Q9; -0.067 in Q18 and i in Q6= Q9 */ + L_tmp = L_mult(exc_diffQ[i],tmp); /*Q(Qexc_diffQ+10) */ + exc_diffQ[i] = round_fx(L_shl(L_tmp,16 - 10));/*Qexc_diffQ */ + } + } + } + /*--------------------------------------------------------------------------------------* + * Check potential energy excitation overshoot + *--------------------------------------------------------------------------------------*/ + IF(bfi) + { + test(); + IF(GSC_noisy_speech == 0 && GT_16(coder_type, UNVOICED)) /* Here coder_type == last_coder_type because of the bfi */ + { + FOR(i = 0; i < last_bin; i++) + { + Ener_per_bd_iQ[i] = s_min(Ener_per_bd_iQ[i], sub(sub(lt_ener_per_band_fx[i], 154), Ener_per_bd_yQ[i])); + move16(); + lt_ener_per_band_fx[i] = sub(lt_ener_per_band_fx[i], 77); + move16(); + } + FOR(; i < MBANDS_GN; i++) + { + Ener_per_bd_iQ[i] = s_min(Ener_per_bd_iQ[i], sub(lt_ener_per_band_fx[i], 154)); + move16(); + lt_ener_per_band_fx[i] = sub(lt_ener_per_band_fx[i], 77); + move16(); + } + } + ELSE + { + FOR(i = 0; i < last_bin; i++) + { + Ener_per_bd_iQ[i] = s_min(Ener_per_bd_iQ[i], sub(add(lt_ener_per_band_fx[i],1229), Ener_per_bd_yQ[i])); + move16(); + lt_ener_per_band_fx[i] = sub(lt_ener_per_band_fx[i], 77); + move16(); + } + FOR(; i < MBANDS_GN; i++) + { + Ener_per_bd_iQ[i] = s_min(Ener_per_bd_iQ[i], add(lt_ener_per_band_fx[i],1229)); + move16(); + lt_ener_per_band_fx[i] = sub(lt_ener_per_band_fx[i], 77); + move16(); + } + } + } + /*--------------------------------------------------------------------------------------* + * Apply decoded gain onto the difference signal + *--------------------------------------------------------------------------------------*/ +#ifdef ADD_LRTD + if (GSC_IVAS_mode >= 1) + { + float scale_factLF = 0.9f; + float scale_factHF = 0.9f; + + if (GSC_IVAS_mode == 1 && GSC_noisy_speech == 0) + { + scale_factHF = 0.8f; + } + else if (GSC_IVAS_mode == 2 || GSC_noisy_speech == 1) + { + scale_factHF = 0.71f; + } + else if (GSC_IVAS_mode == 3) + { + scale_factHF = 0.9f; + } + for (i = 0; i < pit_band_idx * 16; i++) + { + exc_diffQ[i] *= scale_factLF; + } + for (; i < L_frame; i++) + { + exc_diffQ[i] *= scale_factHF; + } + } + else if (GSC_noisy_speech) + { + float scale_fact = 0.9f; + + if (element_mode == IVAS_CPE_TD) + { + if (coder_type == INACTIVE) + { + scale_fact = 1.0f; + } + else + { + scale_fact = 0.95f; + } + } + else if (element_mode > IVAS_SCE) + { + scale_fact = 0.71f; + } + + for (i = 0; i < L_frame; i++) + { + exc_diffQ[i] *= scale_fact; + } + } + if (GSC_noisy_speech && element_mode > IVAS_SCE && core_brate < ACELP_7k20) + { + for (i = 80; i < L_frame; i++) + { + exc_diffQ[i] *= (+0.0024f * (float)i + 1.192f); + } + } +#else + IF(GSC_noisy_speech) + { + FOR(i = 0; i < L_frame; i++) + { + exc_diffQ[i] = mult_r(exc_diffQ[i], 29491); + move16(); + } + } +#endif + Comp_and_apply_gain_fx(exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, Q_exc); + + IF(exc_wo_nf != NULL) + { + Comp_and_apply_gain_fx(exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, Q_exc); + Vr_add(exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame); + } + /*--------------------------------------------------------------------------------------* + * add the correction layer to the LF bins, + * and add the quantized pulses or the noise for the higher part of the spectrum + * (non valuable temporal content already zeroed) + * DC is Zeroed + *--------------------------------------------------------------------------------------*/ + + Vr_add(exc_dct_in, exc_diffQ, exc_dct_in, L_frame); + test(); + IF(core_brate == ACELP_8k00 && bwidth != NB) + { + IF(EQ_16(bwe_flag, 1)) + { + last_bin = sub(last_bin, 1); + tmp = i_mult(MAX_Bin, 16); + tmp1 = i_mult(last_bin, 16); + src = &exc_diffQ[sub(L_FRAME, 1)]; + move16(); + dst = &exc_dct_in[sub(tmp, 1)]; + move16(); + end = &exc_diffQ[sub(tmp1, 1)]; + move16(); + + WHILE(src > end) + { + *src-- = *dst--; + move16(); + } + test(); + test(); + if ((bitallocation_exc[0] != 0 || bitallocation_exc[1] != 0) && EQ_32(core_brate, ACELP_8k00)) + { + exc_diffQ[160] = 0; + move16(); + } + + Q_hb_exc = 0; + move16(); + envelop_modify_fx(exc_diffQ, seed_tcx, last_bin, Ener_per_bd_iQ, Q_exc, &Q_hb_exc); + Copy_Scale_sig(&exc_diffQ[tmp1], &exc_dct_in[tmp1], sub(L_FRAME, tmp1), sub(Q_exc, Q_hb_exc)); /* from Q_hb_exc -> Q_exc as expected */ + } + + IF(LT_16(nb_subfr, 4)) + { + FOR(i = sub(L_FRAME, 16); i < L_FRAME; i++) + { + /*exc_dct_in[i] *= (0.067f*i-15.f); */ + tmp = mult_r(17564, shl(i, 6)); /*0.067 in Q18 and i in Q6= Q9 */ + tmp = sub(tmp, 7680); /*15 in Q9 = Q9 */ + L_tmp = L_mult(exc_dct_in[i], tmp);/*Q(Q_exc+10) */ +#ifdef BASOP_NOGLOB + exc_dct_in[i] = round_fx_o(L_shl_o(L_tmp, 6, &Overflow), &Overflow);/*Q_exc */ +#else /* BASOP_NOGLOB */ + exc_dct_in[i] = round_fx(L_shl(L_tmp, 6));/*Q_exc */ +#endif /* BASOP_NOGLOB */ + } + } + + tmp1 = mult_r(ener, 16384); + tmp1 = sub(*last_ener, tmp1); + tmp = mult_r(*last_ener, 16384); + tmp = sub(ener, tmp); + test(); + IF(tmp > 0 && tmp1 > 0) + { + length_bin = 6; + move16(); + IF(last_coder_type != AUDIO) + { + set16_fx(last_bitallocation_band, 0, 6); + Copy(&exc_dct_in[(4 + length_bin) * 16], &last_exc_dct_in[(4 + length_bin) * 16], length_bin * 16); + } + + FOR(i = 4; i < (4 + length_bin); i++) + { + test(); + IF(!(bitallocation_band[i] == 0 && last_bitallocation_band[i - 4] == 0)) + { + k = shl(add(i, length_bin), 4); + src = &exc_dct_in[k]; /*(i+length_bin)*16*/ + dst = &last_exc_dct_in[k]; + FOR(j = 0; j < 16; j++) + { + tmp = mult_r(10923, abs_s(*src)); + tmp1 = mult_r(10923, abs_s(*dst)); + + IF(GT_16(tmp, abs_s(*dst))) + { + tmp2 = *src; +#ifdef BASOP_NOGLOB + * src = mult_r(16384, sub_o(*src, abs_s(*dst), &Overflow)); /*Q_exc */ move16(); + tmp = mult_r(16384, add_o(tmp2, abs_s(*dst), &Overflow)); /*Q_exc */ +#else /* BASOP_NOGLOB */ + * src = mult_r(16384, sub(*src, abs_s(*dst))); /*Q_exc */ move16(); + tmp = mult_r(16384, add(tmp2, abs_s(*dst))); /*Q_exc */ +#endif + if (tmp2 > 0) + { + *src = tmp; + move16(); + } + } + ELSE IF(GT_16(tmp1, abs_s(*src))) + { + tmp = mult_r(*src, 22938); + tmp1 = mult_r(9830, abs_s(*dst)); + tmp2 = *src; + *src = sub(tmp, tmp1); /*Q_exc */ move16(); + if (tmp2 > 0) + { + *src = add(tmp, tmp1); /*Q_exc */ move16(); + } + } + src++; + dst++; + } + } + } + } + IF(EQ_16(bwe_flag, 1)) + { + Decreas_freqPeak_fx(lsf_new, exc_dct_in, 9830); + } + ELSE + { + Decreas_freqPeak_fx(lsf_new, exc_dct_in, 16384); + } + } + + Copy(&exc_dct_in[64], &last_exc_dct_in[64], L_frame - 64); + Copy(&bitallocation_band[4], last_bitallocation_band, 6); + *last_ener = ener; + move16(); + + return; +} diff --git a/lib_com/gs_preech.c b/lib_com/gs_preech.c index ae2bbf6f5..6ed7c12cd 100644 --- a/lib_com/gs_preech.c +++ b/lib_com/gs_preech.c @@ -41,6 +41,8 @@ #include "rom_com.h" #include "prot.h" #include "wmc_auto.h" +#include "prot_fx1.h" +#include "prot_fx2.h" /*-------------------------------------------------------------------* * Local constants @@ -70,7 +72,7 @@ void pre_echo_att( { float etmp; float etmp1; - float finc[ATT_LENGHT16k], ratio, inv_l_frame; + float finc[ATT_LENGHT16k], ratio_float, inv_l_frame; int16_t att_len; int16_t attack_pos, i; @@ -107,14 +109,14 @@ void pre_echo_att( etmp /= ( attack_pos * ATT_SEG_LEN ); /* Find the correction factor and apply it before the attack */ - ratio = (float) sqrt( *Last_frame_ener / etmp ); + ratio_float = (float) sqrt( *Last_frame_ener / etmp ); /* Pre-echo atttenuation should never increase the energy */ - ratio = min( ratio, 1.0f ); + ratio_float = min( ratio_float, 1.0f ); for ( i = 0; i < attack_pos * ATT_SEG_LEN; i++ ) { - exc[i] *= ratio; + exc[i] *= ratio_float; } } *Last_frame_ener = etmp1; @@ -137,3 +139,115 @@ void pre_echo_att( return; } + +void pre_echo_att_fx( + Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/ + Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/ + const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) */ + const Word16 Q_new, + const Word16 last_coder_type_fx, /* i : Last coding mode */ + const Word16 L_frame /* i : Frame length*/ +) +{ + Word32 etmp_fx; + Word32 finc_fx[ATT_LENGHT16k] = { 0 }; + Word16 ratio_fx; + Word16 attack_pos_fx, i; + Word32 L_tmp, L_tmp1; + Word16 tmp, n1, n2, exp, frac1, frac2; + Word32 etmp1_fx; + Word16 att_len; + + test(); + IF(GT_16(gsc_attack_flag_fx, 0) && EQ_16(last_coder_type_fx, AUDIO)) /*gsc_attack_flag_fx does not get set for all the test cases */ + { + /*-------------------------------------------------------------------------* + * Find where the onset (attack) occurs by computing the energy per section + * The inverse weighting aims to favor the first maxima in case of + * gradual onset + *-------------------------------------------------------------------------*/ + att_len = ATT_LENGHT; + if (L_frame == L_FRAME16k) + { + att_len = ATT_LENGHT16k; + } + FOR(i = 0; i < att_len; i++) + { + L_tmp = sum2_fx(&exc_fx[shl(i, 2)], ATT_SEG_LEN); /*2*Q_new+1, //ATT_SEG_LEN=(L_FRAME/ATT_LENGHT)=4(=shl(x,2))*/ + tmp = div_s(sub(att_len, i), att_len); /*Q15 */ + L_tmp = Mult_32_16(L_tmp, tmp); /*2*Q_new+1 */ + finc_fx[i] = L_tmp; + move32(); /*2*Q_new+1 */ + } + + attack_pos_fx = maximum_32_fx(finc_fx, att_len, &etmp_fx); + + /* Scaled the maximum energy and allowed 6 dB increase*/ + etmp_fx = L_shr(etmp_fx, add(2 + 1 - 4, shl(Q_new, 1)));/*2*Q_new+1 //INV_ATT_SEG_LEN=1/4(=shr(x,2)) -> Q4 */ + etmp1_fx = etmp_fx; + move32(); + *Last_frame_ener_fx = L_shl(*Last_frame_ener_fx, 2); + move32(); /*2*Q_new+1 */ + + /* If the maximum normalized energy > last frame energy + 6dB */ + test(); + IF(GT_32(etmp_fx, *Last_frame_ener_fx) && attack_pos_fx > 0) + { + /* Find the average energy before the attack */ + L_tmp = sum32_fx(finc_fx, attack_pos_fx); /*Q1 */ + L_tmp1 = L_shr(L_mult(attack_pos_fx, attack_pos_fx), 1); /*Q0 */ + tmp = round_fx(Isqrt(L_tmp1)); /*Q15 */ + L_tmp = L_shr(L_tmp, 2); /*Q1 ; ATT_SEG_LEN=4 */ + etmp_fx = Mult_32_16(L_tmp, tmp); /*Q1 */ + + etmp_fx = L_shr(etmp_fx, add(1 - 4, shl(Q_new, 1))); /* makes etmp i nQ4 as *Last_frame_ener_fx */ + /* Find the correction factor and apply it before the attack */ + /* ratio = (float)sqrt(*Last_frame_ener/etmp);*/ + /* = isqrt(etmp/(*Last_frame_ener)) */ + etmp_fx = L_max(etmp_fx, 1); + *Last_frame_ener_fx = L_max(*Last_frame_ener_fx, 1); + n1 = norm_l(etmp_fx); + n2 = norm_l(*Last_frame_ener_fx); + + n1 = sub(n1, 1); + exp = sub(n1, n2); + + frac1 = round_fx(L_shl(etmp_fx, n1)); + frac2 = round_fx(L_shl(*Last_frame_ener_fx, n2)); + + L_tmp = L_mult0(128, div_s(frac1, frac2)); /* s = gain_out / gain_in */ + L_tmp = L_shr(L_tmp, exp); /* add exponent */ + + L_tmp = Isqrt(L_tmp); + ratio_fx = round_fx(L_shl(L_tmp, 9)); + + /* Pre-echo atttenuation should never increase the energy */ + ratio_fx = s_min(ratio_fx, 8192); + FOR(i = 0; i < attack_pos_fx*ATT_SEG_LEN; i++) + { + /*exc_fx[i] *= ratio_fx;*/ + exc_fx[i] = round_fx(L_shl(L_mac(-8192, exc_fx[i], ratio_fx), 2)); + } + } + *Last_frame_ener_fx = etmp1_fx; + move32(); + } + ELSE + { + /*-------------------------------------------------------* + * In normal cases, just compute the energy of the frame + *-------------------------------------------------------*/ + + etmp_fx = sum2_fx(exc_fx, L_frame); /*2*Q_new+1 */ +#ifdef ADD_LRTD + PMTE() + etmp_fx = L_shr(etmp_fx, add(8 + 1 - 4, shl(Q_new, 1))); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/ +#else + etmp_fx = L_shr(etmp_fx,add(8 + 1 - 4, shl(Q_new,1))); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/ +#endif + *Last_frame_ener_fx = etmp_fx; + move32(); /*2*Q_new+1*/ + } + + return; +} diff --git a/lib_com/guided_plc_util.c b/lib_com/guided_plc_util.c index 884c2beeb..e638d0131 100644 --- a/lib_com/guided_plc_util.c +++ b/lib_com/guided_plc_util.c @@ -116,11 +116,11 @@ void getConcealedLP( const int16_t last_good, const int16_t L_frame ) { - float *lsf = memDecState->lsf_con; + float *lsf = memDecState->lsf_con_flt; float lsp[( NB_DIV + 1 ) * M]; int16_t k; - dlpc_bfi( L_frame, &lsf[0], memDecState->lsfold, last_good, 1 /* assumes packet loss */, memDecState->mem_MA, memDecState->mem_AR, &( memDecState->stab_fac ), memDecState->lsf_adaptive_mean, 1, NULL, 0, NULL, NULL, lsfBase ); + dlpc_bfi( L_frame, &lsf[0], memDecState->lsfold, last_good, 1 /* assumes packet loss */, memDecState->mem_MA, memDecState->mem_AR_flt, &( memDecState->stab_fac ), memDecState->lsf_adaptive_mean, 1, NULL, 0, NULL, NULL, lsfBase ); mvr2r( memDecState->lspold, lsp, M ); @@ -166,7 +166,7 @@ void RecLpcSpecPowDiffuseLc( lsfq[i] = st->mem_MA[i] + means[i]; } - v_sort( lsfq, 0, M - 1 ); + v_sort_float( lsfq, 0, M - 1 ); reorder_lsfs( lsfq, LSF_GAP, M, st->sr_core ); diff --git a/lib_com/hp50.c b/lib_com/hp50.c index b9268c8f9..37f8bb89b 100644 --- a/lib_com/hp50.c +++ b/lib_com/hp50.c @@ -38,7 +38,8 @@ #include "options.h" #include "prot.h" #include "wmc_auto.h" - +#include "prot_fx1.h" +#include "prot_fx2.h" /* * hp20 @@ -50,7 +51,7 @@ * void */ -void hp20( +void hp20_flt( Float32 signal[], const Word16 lg, Float32 mem[], @@ -128,3 +129,290 @@ void hp20( return; } + + +#if 0 +//Below is fixed implmentation +//TO DO rename hp20_flt to hp20 once macro introduced +#endif + + +#define HP20_COEFF_SCALE (2) + +/* + * hp20 + * + * Function: + * 2nd order high pass filter with nominal cut off frequency at 20 Hz. + * + * Returns: + * void + */ + +static Word32 HP50_Mode2_Mpy_32_16_fix(Word32 a, Word16 b) +{ + Word32 result = Mpy_32_16_1(a, b); + /* perform rounding towards lower value for negative results */ + if (result < 0) result = L_add(result, 1); + return result; +} + +static Word32 HP50_Mpy_32_32_fix(Word32 a, Word32 b) +{ + Word32 result = Mpy_32_32(a, b); + /* perform rounding towards lower value for negative results */ + if (result < 0) result = L_add(result, 1); + return result; +} + + +static void filter_2nd_order( + Word16 signal[], + const Word16 stride, + const Word16 prescale, + const Word16 lg, + Word32 mem[4], + Word32 a1, + Word32 a2, + Word32 b1, + Word32 b2 +) +{ + + Word16 i; + Word16 x2, x1; + Word32 L_sum, L_y1, L_y2; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + + /* + * Saturation: The states of the filter, namely L_y1 and L_y2 shall + * never saturate, because that causes error in the filter feedback. + * The final output written into signal[] might saturate because of + * unavoidable filter overshoot. + */ + + /* Execute first 2 iterations with 32-bit x anx y memory values */ + BASOP_SATURATE_ERROR_ON_EVS + L_sum = HP50_Mpy_32_32_fix(b2, mem[2]); /* b2*x2 */ + L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(b1, mem[3])); /* b1*x1 */ + x2 = shr(signal[0 * stride], prescale); + L_sum = L_add(L_sum, HP50_Mode2_Mpy_32_16_fix(b2, x2)); /* b2*x0 */ + L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(mem[0], a2)); /* y2*a2 */ + L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(mem[1], a1)); /* y1*a1 */ + +#ifdef BASOP_NOGLOB + L_y2 = L_shl_o(L_sum, HP20_COEFF_SCALE, &Overflow); +#else + L_y2 = L_shl(L_sum, HP20_COEFF_SCALE); +#endif + BASOP_SATURATE_ERROR_OFF_EVS + BASOP_SATURATE_WARNING_OFF_EVS +#ifdef BASOP_NOGLOB + signal[0 * stride] = round_fx_o(L_shl_o(L_y2, prescale, &Overflow), &Overflow); +#else /* BASOP_NOGLOB */ + signal[0 * stride] = round_fx(L_shl(L_y2, prescale)); +#endif /* BASOP_NOGLOB */ + BASOP_SATURATE_WARNING_ON_EVS + + BASOP_SATURATE_ERROR_ON_EVS + L_sum = HP50_Mpy_32_32_fix(b2, mem[3]); /* b2*x2 */ + L_sum = L_add(L_sum, HP50_Mode2_Mpy_32_16_fix(b1, x2)); /* b1*x1 */ + x1 = shr(signal[1 * stride], prescale); + L_sum = L_add(L_sum, HP50_Mode2_Mpy_32_16_fix(b2, x1)); /* b2*x0 */ + L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(mem[1], a2)); /* y2*a2 */ + L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(L_y2, a1)); /* y1*a1 */ + +#ifdef BASOP_NOGLOB + L_y1 = L_shl_o(L_sum, HP20_COEFF_SCALE, &Overflow); +#else + L_y1 = L_shl(L_sum, HP20_COEFF_SCALE); +#endif + BASOP_SATURATE_ERROR_OFF_EVS + BASOP_SATURATE_WARNING_OFF_EVS +#ifdef BASOP_NOGLOB + signal[1 * stride] = round_fx_o(L_shl_o(L_y1, prescale, &Overflow), &Overflow); +#else /* BASOP_NOGLOB */ + signal[1 * stride] = round_fx(L_shl(L_y1, prescale)); +#endif /* BASOP_NOGLOB */ + BASOP_SATURATE_WARNING_ON_EVS + + /* New we use a trick and toggle x1/x2 and L_y1/L_y2 to save a few cycles unrolling the loop by 2 */ + FOR(i = 2; i < lg; i += 2) + { + /* y[i+0] = b2*x[i-2] + b1*x[i-1] + b2*x[i-0] + a2*y[i-2] + a1*y[i-1]; */ + BASOP_SATURATE_ERROR_ON_EVS + L_sum = HP50_Mode2_Mpy_32_16_fix(b2, x2); + L_sum = L_add(L_sum, HP50_Mode2_Mpy_32_16_fix(b1, x1)); + x2 = shr(signal[i*stride], prescale); + L_sum = L_add(L_sum, HP50_Mode2_Mpy_32_16_fix(b2, x2)); + L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(L_y2, a2)); + L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(L_y1, a1)); + +#ifdef BASOP_NOGLOB + L_y2 = L_shl_o(L_sum, HP20_COEFF_SCALE, &Overflow); +#else + L_y2 = L_shl(L_sum, HP20_COEFF_SCALE); +#endif + BASOP_SATURATE_ERROR_OFF_EVS + BASOP_SATURATE_WARNING_OFF_EVS +#ifdef BASOP_NOGLOB + signal[i*stride] = round_fx_o(L_shl_o(L_y2, prescale, &Overflow), &Overflow); +#else /* BASOP_NOGLOB */ + signal[i*stride] = round_fx(L_shl(L_y2, prescale)); +#endif /* BASOP_NOGLOB */ + BASOP_SATURATE_WARNING_ON_EVS + /* y[i+1] = b2*x[i-1] + b1*x[i-0] + b2*x[i+1] + a2*y[i-1] + a1*y[i+0]; */ + BASOP_SATURATE_ERROR_ON_EVS + L_sum = HP50_Mode2_Mpy_32_16_fix(b2, x1); + L_sum = L_add(L_sum, HP50_Mode2_Mpy_32_16_fix(b1, x2)); + x1 = shr(signal[(i + 1)*stride], prescale); + L_sum = L_add(L_sum, HP50_Mode2_Mpy_32_16_fix(b2, x1)); + L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(L_y1, a2)); + L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(L_y2, a1)); + +#ifdef BASOP_NOGLOB + L_y1 = L_shl_o(L_sum, HP20_COEFF_SCALE, &Overflow); +#else + L_y1 = L_shl(L_sum, HP20_COEFF_SCALE); +#endif + BASOP_SATURATE_ERROR_OFF_EVS + BASOP_SATURATE_WARNING_OFF_EVS +#ifdef BASOP_NOGLOB + signal[(i + 1)*stride] = round_fx_o(L_shl_o(L_y1, prescale, &Overflow), &Overflow); +#else /* BASOP_NOGLOB */ + signal[(i + 1)*stride] = round_fx(L_shl(L_y1, prescale)); +#endif + BASOP_SATURATE_WARNING_ON_EVS + } + /* update static filter memory from variables */ + mem[0] = L_y2; + move32(); + mem[1] = L_y1; + move32(); + mem[2] = L_deposit_h(x2); + mem[3] = L_deposit_h(x1); + + + return; +} + + +void hp20(Word16 signal[], /* i/o: signal to filter any */ + const Word16 stride, /* i : stride to be applied accessing signal */ + const Word16 lg, /* i : length of signal (integer) Q0 */ + Word32 mem[5], /* i/o: static filter memory with this layout: */ + /* mem[0]: y[-2] (32-bit) */ + /* mem[1]; y[-1] (32-bit) */ + /* mem[2]: x[-2] << 16 */ + /* mem[3]: x[-1] << 16 */ + /* Note: mem[0..3] need to be scaled per frame */ + /* mem[4]: states scale */ + const Word32 sFreq) /* i : input sampling rate Q0 */ +{ + Word32 a1, b1, a2, b2; + Word16 prescale, prescaleOld, diff; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + + prescale = getScaleFactor16(signal, lg); + prescaleOld = extract_l(mem[4]); + diff = norm_l(L_shl(mem[2], prescaleOld)); + if (mem[2] != 0) + { + prescale = s_min(prescale, diff); + } +#ifdef BASOP_NOGLOB + diff = norm_l(L_shl_o(mem[3], prescaleOld, &Overflow)); +#else + diff = norm_l(L_shl(mem[3], prescaleOld)); +#endif + if (mem[3] != 0) + { + prescale = s_min(prescale, diff); + } + /* Take into account the left shift performed into the loop + 1 bit headroom*/ + prescale = s_max(-12, sub(1 + HP20_COEFF_SCALE, prescale)); + IF(prescale != prescaleOld) + { + diff = sub(prescale, prescaleOld); +#ifdef BASOP_NOGLOB + mem[0] = L_shr_o(mem[0], diff, &Overflow); + move32(); + mem[1] = L_shr_o(mem[1], diff, &Overflow); + move32(); + mem[2] = L_shr_o(mem[2], diff, &Overflow); + move32(); + mem[3] = L_shr_o(mem[3], diff, &Overflow); + move32(); +#else + mem[0] = L_shr(mem[0], diff); + move32(); + mem[1] = L_shr(mem[1], diff); + move32(); + mem[2] = L_shr(mem[2], diff); + move32(); + mem[3] = L_shr(mem[3], diff); + move32(); +#endif + mem[4] = L_deposit_l(prescale); + } + + IF(EQ_32(sFreq, 8000)) + { + /* hp filter 20Hz at 3dB for 8000 Hz input sampling rate + [b,a] = butter(2, 20.0/4000.0, 'high'); + b = [0.988954248067140 -1.977908496134280 0.988954248067140] + a = [1.000000000000000 -1.977786483776764 0.978030508491796]*/ + a1 = 1061816033l/* 1.977786483776764 Q29*/; move32(); + a2 = -525076131l/*-0.978030508491796 Q29*/; move32(); + b1 = -1061881538l/*-1.977908496134280 Q29*/; move32(); + b2 = 530940769l/* 0.988954248067140 Q29*/; move32(); + + } + ELSE IF(EQ_32(sFreq, 16000)) + { + /* hp filter 20Hz at 3dB for 16000KHz sampling rate + [b,a] = butter(2, 20.0/8000.0, 'high'); + b = [0.994461788958195 -1.988923577916390 0.994461788958195] + a = [1.000000000000000 -1.988892905899653 0.988954249933127] */ + a1 = 1067778748l/* 1.988892905899653 Q29*/; move32(); + a2 = -530940770l/*-0.988954249933127 Q29*/; move32(); + b1 = -1067795215l/*-1.988923577916390 Q29*/; move32(); + b2 = 533897608l/* 0.994461788958195 Q29*/; move32(); + + } + ELSE IF(EQ_32(sFreq, 32000)) + { + /* hp filter 20Hz at 3dB for 32000KHz sampling rate + [b,a] = butter(2, 20.0/16000.0, 'high'); + b = [0.997227049904470 -1.994454099808940 0.997227049904470] + a = [1.000000000000000 -1.994446410541927 0.994461789075954]*/ + a1 = 1070760263l/* 1.994446410541927 Q29*/; move32(); + a2 = -533897608l/*-0.994461789075954 Q29*/; move32(); + b1 = -1070764392l/*-1.994454099808940 Q29*/; move32(); + b2 = 535382196l/* 0.997227049904470 Q29*/; move32(); + } + ELSE + { + assert(sFreq == 48000); + /* hp filter 20Hz at 3dB for 48000KHz sampling rate + [b,a] = butter(2, 20.0/24000.0, 'high'); + b =[0.998150511190452 -1.996301022380904 0.998150511190452] + a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/ + a1 = 1071754114l/* 1.996297601769122 Q29*/; move32(); + a2 = -534886875l/*-0.996304442992686 Q29*/; move32(); + b1 = -1071755951l/*-1.996301022380904 Q29*/; move32(); + b2 = 535877975l/* 0.998150511190452 Q29*/; move32(); + } + + + filter_2nd_order(signal, stride, prescale, lg, + mem, a1, a2, b1, b2); + + return; +} diff --git a/lib_com/hq2_bit_alloc.c b/lib_com/hq2_bit_alloc.c index d471b170e..96f8eee57 100644 --- a/lib_com/hq2_bit_alloc.c +++ b/lib_com/hq2_bit_alloc.c @@ -636,11 +636,11 @@ void hq2_bit_alloc_har( Inv_p2a_bands_fx = div_s( 0x3fff, shl( p2a_bands_fx, exp_normd ) ); /* 14-exp_normd+15 */ QIpb = sub( 29, exp_normd ); - L_temp = L_shl( Mpy_32_16( L_Ravg_sub[GRP_SB - 1], Inv_p2a_bands_fx ), sub( SWB_BWE_LR_Qbe, sub( QIpb, 1 ) ) ); + L_temp = L_shl( Mpy_32_16_1( L_Ravg_sub[GRP_SB - 1], Inv_p2a_bands_fx ), sub( SWB_BWE_LR_Qbe, sub( QIpb, 1 ) ) ); L_norm_diff = L_sub( L_temp, L_norm_sum_avg ); /* Qbe */ - L_temp = Mpy_32_16( L_Ravg_sub[GRP_SB - 1], sub( GRP_SB, 1 ) ); /* Qbe+0+1 */ - L_temp = Mpy_32_16( L_temp, Inv_norm_sum_fx ); /* Qbe+1+QIpb+1 */ + L_temp = Mpy_32_16_1( L_Ravg_sub[GRP_SB - 1], sub( GRP_SB, 1 ) ); /* Qbe+0+1 */ + L_temp = Mpy_32_16_1( L_temp, Inv_norm_sum_fx ); /* Qbe+1+QIpb+1 */ #ifdef BASOP_NOGLOB lf_hf_ge_r_fx = round_fx_o( L_shl_o( L_temp, sub( 15 + 16, sub( add( SWB_BWE_LR_Qbe, QIns ), 30 ) ), &Overflow ), &Overflow ); Overflow = 0; /* reset BASOP Overflow */ @@ -668,7 +668,7 @@ void hq2_bit_alloc_har( /*allocate bits*/ /*Bits_grp[GRP_SB-1] = (int16_t)min((grp_bit_avg/p2a_bands + bits_allocweigh*norm_diff),10);*/ L_temp = L_mult( grp_bit_avg_fx, Inv_p2a_bands_fx ); /* Q0+QIpb+1 */ - L_temp2 = Mpy_32_16( L_norm_diff, bits_allocweigh_fx ); /* Qbe+Q15-15 */ + L_temp2 = Mpy_32_16_1( L_norm_diff, bits_allocweigh_fx ); /* Qbe+Q15-15 */ L_temp = L_shr( L_temp, add( QIpb, 1 ) ); L_temp = L_add( L_shl( L_temp, SWB_BWE_LR_Qbe ), L_temp2 ); @@ -692,24 +692,24 @@ void hq2_bit_alloc_har( IF( sub( final_gr_fact_pos_fx, 1 ) == 0 ) { - L_temp = Mpy_32_16( L_Ravg_sub[1], extract_h( L_mult( bits_fact_fx, B_norm_fx ) ) ); - L_temp = Mpy_32_16( L_temp, Inv_norm_sum_fx ); + L_temp = Mpy_32_16_1( L_Ravg_sub[1], extract_h( L_mult( bits_fact_fx, B_norm_fx ) ) ); + L_temp = Mpy_32_16_1( L_temp, Inv_norm_sum_fx ); Bits_grp_fx[1] = extract_h( L_shr( L_temp, exp_shift ) ); - L_temp = Mpy_32_16( L_Ravg_sub[2], extract_h( L_mult( bits_fact1_fx, B_norm_fx ) ) ); - L_temp = Mpy_32_16( L_temp, Inv_norm_sum_fx ); + L_temp = Mpy_32_16_1( L_Ravg_sub[2], extract_h( L_mult( bits_fact1_fx, B_norm_fx ) ) ); + L_temp = Mpy_32_16_1( L_temp, Inv_norm_sum_fx ); Bits_grp_fx[2] = extract_h( L_shr( L_temp, exp_shift ) ); Bits_grp_fx[0] = sub( sub( B_fx, Bits_grp_fx[1] ), Bits_grp_fx[2] ); } ELSE { - L_temp = Mpy_32_16( L_Ravg_sub[0], extract_h( L_mult( bits_fact_fx, B_norm_fx ) ) ); - L_temp = Mpy_32_16( L_temp, Inv_norm_sum_fx ); + L_temp = Mpy_32_16_1( L_Ravg_sub[0], extract_h( L_mult( bits_fact_fx, B_norm_fx ) ) ); + L_temp = Mpy_32_16_1( L_temp, Inv_norm_sum_fx ); Bits_grp_fx[0] = extract_h( L_shr( L_temp, exp_shift ) ); - L_temp = Mpy_32_16( L_Ravg_sub[2], extract_h( L_mult( bits_fact1_fx, B_norm_fx ) ) ); - L_temp = Mpy_32_16( L_temp, Inv_norm_sum_fx ); + L_temp = Mpy_32_16_1( L_Ravg_sub[2], extract_h( L_mult( bits_fact1_fx, B_norm_fx ) ) ); + L_temp = Mpy_32_16_1( L_temp, Inv_norm_sum_fx ); Bits_grp_fx[2] = extract_h( L_shr( L_temp, exp_shift ) ); Bits_grp_fx[1] = sub( sub( B_fx, Bits_grp_fx[0] ), Bits_grp_fx[2] ); @@ -890,7 +890,7 @@ void hq2_bit_alloc( { /*Rk[k] = ((float) *bit_budget / Rcnt + weight * (band_energy[k] - Ravg)); */ - L_tmp = Mpy_32_16( L_sub( L_shl( L_band_energy[k], sub( SWB_BWE_LR_QRk, SWB_BWE_LR_Qbe ) ), L_Ravg ), weight_fx ); /* SWB_BWE_LR_QRk + Q13 - 15 */ + L_tmp = Mpy_32_16_1( L_sub( L_shl( L_band_energy[k], sub( SWB_BWE_LR_QRk, SWB_BWE_LR_Qbe ) ), L_Ravg ), weight_fx ); /* SWB_BWE_LR_QRk + Q13 - 15 */ L_tmp = L_shl( L_tmp, 2 ); /* -> SWB_BWE_LR_QRk */ L_Rk[k] = L_add( L_shr( L_deposit_l( div_fx ), sub( Qdiv, SWB_BWE_LR_QRk ) ), L_tmp ); diff --git a/lib_com/hq2_bit_alloc_fx.c b/lib_com/hq2_bit_alloc_fx.c new file mode 100644 index 000000000..e52909a83 --- /dev/null +++ b/lib_com/hq2_bit_alloc_fx.c @@ -0,0 +1,213 @@ +#include +#include "options.h" +#include "prot_fx_2.h" + + +#define MIN_BITS_FIX 0 /* QRk=18 */ +#define HQ_16k40_BIT (HQ_16k40/50) /* 16400/50=328 */ +#define Qbf 14 /* Q value for bits_fact */ +#define C1_QRk (1< 0) + { + be_sum_fx = add(be_sum_fx, y_index_fx[k]); + } + } + QBavg = 0; + move16(); + + /*Ravg = (float) be_sum/be_cnt;*/ + Ravg_fx = 0; + move16(); + QRavg = 0; + move16(); + IF(be_cnt_fx != 0x0) + { + exp_normn = norm_s(be_sum_fx); + exp_normn = sub(exp_normn, 1); + exp_normd = norm_s(be_cnt_fx); + Ravg_fx = div_s(shl(be_sum_fx, exp_normn), shl(be_cnt_fx, exp_normd)); + + Ravg_fx = shr(Ravg_fx, 2); /* safe shift */ + QRavg = add(sub(exp_normn, exp_normd), 15 - 2); + } + + enr_diffcnt_fx = 0; + move16(); + th_5_fx = shl(5, QRavg); + FOR(j = 0; j < be_cnt_fx; j++) + { + if (GT_16(abs_s(sub(Ravg_fx, shl(y_index_fx[j], QRavg))), th_5_fx)) + { + enr_diffcnt_fx = add(enr_diffcnt_fx, 1); + } + } + + scale_fact_fx = 19661; + move16(); /* 0.60f 19660.8(Q15) */ + if (enr_diffcnt_fx > 0) + { + scale_fact_fx = 11468; + move16(); /* 0.35f 11468.8(Q15) */ + } + + /* Bits allocation to individual SB's in a group based on Band Energies */ + FOR(j = 0; j < be_cnt_fx; j++) + { + Rcnt_fx = add(i, 1); + + /* Ravg = (float) be_sum/Rcnt; */ + exp_normn = norm_s(be_sum_fx); + exp_normn = sub(exp_normn, 1); + exp_normd = norm_s(Rcnt_fx); + Ravg_fx = div_s(shl(be_sum_fx, exp_normn), shl(Rcnt_fx, exp_normd)); + Ravg_fx = shr(Ravg_fx, 2); /* safe shift */ + QRavg = add(sub(exp_normn, exp_normd), 15 - 2); + + if (be_sum_fx <= 0) + { + be_sum_fx = 1; + move16(); + } + + /* Bits_avg = (float) Bits/(be_sum+EPSILON); */ + Bits_avg_fx = 0; + move16(); + QBavg = 0; + move16(); + IF(Bits != 0) + { + exp_normn = norm_s(Bits); + exp_normn = sub(exp_normn, 1); + exp_normd = norm_s(be_sum_fx); + Bits_avg_fx = div_s(shl(Bits, exp_normn), shl(be_sum_fx, exp_normd)); + Bits_avg_fx = shr(Bits_avg_fx, 2); /* safe_shift */ + QBavg = add(sub(exp_normn, exp_normd), 15 - 2); + } + FOR(k = 0; k <= i; k++) + { + IF(L_R_temp[k] > 0) /* Rtemp -> SWB_BWE_LR_QRk */ + { + /* Allocate more bits to SB, if SB bandenergy is higher than average energy */ + /* R_temp[k] = (float)( Bits_avg * y_index[k]+( scale_fact * (y_index[k] - Ravg))); */ + L_temp1 = L_mult(Bits_avg_fx, y_index_fx[k]); /* QBavg+1 */ + L_temp2 = L_mult(scale_fact_fx, sub(shl(y_index_fx[k], QRavg), Ravg_fx)); /* 15+QRavg+1 */ + L_R_temp[k] = L_add(L_shr(L_temp1, sub(add(QBavg, 1), SWB_BWE_LR_QRk)), L_shr(L_temp2, sub(add(QRavg, 16), SWB_BWE_LR_QRk))); /* SWB_BWE_LR_QRk */ + } + } + IF(LT_32(L_R_temp[i], L_Bits_needed)) + { + L_R_temp[i] = L_deposit_l(0); + + p2aflags_fx_ptr[index_fx[i]] = 0; + move16(); + + /* be_sum -= y_index[i]; */ + be_sum_fx = sub(be_sum_fx, y_index_fx[i]); + + i = sub(i, 1); + } + ELSE + { + BREAK; + } + } + + /* Rearrange the bit allocation to align with original */ + FOR(k = 0; k < band_num_fx; k++) + { + j = index_fx[k]; + move16(); + L_R_ptr[j] = L_R_temp[k]; + move32(); + } + + return; +} + diff --git a/lib_com/hq2_core_com.c b/lib_com/hq2_core_com.c index 280d492ae..bd3119b37 100644 --- a/lib_com/hq2_core_com.c +++ b/lib_com/hq2_core_com.c @@ -229,11 +229,11 @@ void hq2_core_configure( *Ngq = xcore_config->Ngq; *p2a_bands = xcore_config->p2a_bands; - *p2a_th = xcore_config->p2a_th; + *p2a_th = xcore_config->p2a_th_float; - *pd_thresh = xcore_config->pd_thresh; - *ld_slope = xcore_config->ld_slope; - *ni_coef = xcore_config->ni_coef; + *pd_thresh = xcore_config->pd_thresh_float; + *ld_slope = xcore_config->ld_slope_float; + *ni_coef = xcore_config->ni_coef_float; *ni_pd_th = xcore_config->ni_pd_th; mvs2s( xcore_config->band_width, band_width, *bands ); diff --git a/lib_com/hq_conf.c b/lib_com/hq_conf.c index d0f793921..9150d472b 100644 --- a/lib_com/hq_conf.c +++ b/lib_com/hq_conf.c @@ -40,6 +40,8 @@ #include "rom_com.h" #include "prot.h" #include "wmc_auto.h" +#include "prot_fx1.h" +#include "prot_fx2.h" /*--------------------------------------------------------------------------* * hq_configure() @@ -101,7 +103,7 @@ void hq_configure( *nb_sfm = SFM_N_HARM_FB; *num_env_bands = SFM_N_HARM_FB; - p_sfmsize = band_len_harm; + p_sfmsize = band_len_harm_float; p_sfm_start = band_start_harm; p_sfm_end = band_end_harm; } @@ -122,7 +124,7 @@ void hq_configure( *start_norm = HVQ_THRES_SFM_32k; } - p_sfmsize = band_len_harm; + p_sfmsize = band_len_harm_float; p_sfm_start = band_start_harm; p_sfm_end = band_end_harm; } @@ -146,7 +148,7 @@ void hq_configure( *nb_sfm = SFM_N_HARM; *num_env_bands = SFM_N_HARM; - p_sfmsize = band_len_harm; + p_sfmsize = band_len_harm_float; p_sfm_start = band_start_harm; p_sfm_end = band_end_harm; } @@ -167,7 +169,7 @@ void hq_configure( *start_norm = HVQ_THRES_SFM_32k; } - p_sfmsize = band_len_harm; + p_sfmsize = band_len_harm_float; p_sfm_start = band_start_harm; p_sfm_end = band_end_harm; } @@ -253,3 +255,282 @@ void hq_configure( return; } + +void hq_configure_fx( + const Word16 length, /* i : Frame length Q0 */ + const Word16 hqswb_clas, /* i : HQ SWB class Q0 */ + const Word32 core_brate, /* i : Codec bitrate Q0 */ + Word16 *num_sfm, /* o : Total number of subbands Q0 */ + Word16 *nb_sfm, /* o : Total number of coded bands Q0 */ + Word16 *start_norm, /* o : First norm to be SDE encoded Q0 */ + Word16 *num_env_bands, /* o : Number coded envelope bands Q0 */ + Word16 *numnrmibits, /* o : Number of bits in fall-back norm encoding Q0 */ + Word16 *hq_generic_offset, /* o : Freq offset for HQ GENERIC Q0 */ + Word16 *sfmsize, /* o : Subband bandwidths Q0 */ + Word16 *sfm_start, /* o : Subband start coefficients Q0 */ + Word16 *sfm_end /* o : Subband end coefficients Q0 */ +) +{ + const Word16* p_sfmsize; + const Word16* p_sfm_start; + const Word16* p_sfm_end; + Word16 i, bw_ext; + + bw_ext = 0; + + *start_norm = 0; + move16(); + + IF(EQ_16(length, L_SPEC48k)) + { + IF(EQ_16(hqswb_clas, HQ_GEN_FB)) + { + *num_sfm = NB_SFM; + move16(); + p_sfmsize = band_len_HQ; + move16(); + p_sfm_start = band_start_HQ; + move16(); + p_sfm_end = band_end_HQ; + move16(); + + test(); + IF(GE_32(core_brate, HQ_32k)) + { + *hq_generic_offset = HQ_GENERIC_FOFFSET_32K; + move16(); + *num_env_bands = SFM_N_STA_10k; + move16(); + } + ELSE /*IF(EQ_32(core_brate, HQ_16k40) || EQ_32(core_brate, HQ_24k40))*/ + { + *hq_generic_offset = HQ_GENERIC_FOFFSET_24K4; + *num_env_bands = SFM_N_STA_8k; + move16(); + move16(); + } + *nb_sfm = *num_sfm; + move16(); + } + ELSE + { + IF(EQ_16(hqswb_clas, HQ_HARMONIC)) + { + *num_sfm = SFM_N_HARM_FB; + move16(); + *nb_sfm = SFM_N_HARM_FB; + move16(); + *num_env_bands = SFM_N_HARM_FB; + move16(); + + p_sfmsize = band_len_harm; + move16(); + p_sfm_start = band_start_harm; + move16(); + p_sfm_end = band_end_harm; + move16(); + } + ELSE IF(EQ_16(hqswb_clas, HQ_HVQ)) + { + IF(LT_32(core_brate, HQ_BWE_CROSSOVER_BRATE)) + { + *num_sfm = SFM_N_HARM_FB; + move16(); + *nb_sfm = HVQ_THRES_SFM_24k; + move16(); + *num_env_bands = sub(*num_sfm, *nb_sfm); + move16(); + *start_norm = HVQ_THRES_SFM_24k; + move16(); + } + ELSE + { + *num_sfm = SFM_N_HARM_FB; + move16(); + *nb_sfm = HVQ_THRES_SFM_32k; + move16(); + *num_env_bands = sub(*num_sfm, *nb_sfm); + move16(); + *start_norm = HVQ_THRES_SFM_32k; + move16(); + } + p_sfmsize = band_len_harm; + p_sfm_start = band_start_harm; + p_sfm_end = band_end_harm; + move16(); move16(); move16(); + } + ELSE + { + *num_sfm = NB_SFM; + move16(); + *nb_sfm = *num_sfm; + move16(); + *num_env_bands = NB_SFM; + move16(); + + p_sfmsize = band_len_HQ; + move16(); + p_sfm_start = band_start_HQ; + move16(); + p_sfm_end = band_end_HQ; + move16(); + } + } + } + ELSE IF(EQ_16(length, L_SPEC32k)) + { + IF(EQ_16(hqswb_clas, HQ_HARMONIC)) + { + *num_sfm = SFM_N_HARM; + move16(); + *nb_sfm = SFM_N_HARM; + move16(); + *num_env_bands = SFM_N_HARM; + move16(); + + p_sfmsize = band_len_harm; + move16(); + p_sfm_start = band_start_harm; + move16(); + p_sfm_end = band_end_harm; + move16(); + } + ELSE IF(EQ_16(hqswb_clas, HQ_HVQ)) + { + IF(LT_32(core_brate, HQ_BWE_CROSSOVER_BRATE)) + { + *num_sfm = SFM_N_HARM; + move16(); + *nb_sfm = HVQ_THRES_SFM_24k; + move16(); + *num_env_bands = sub(*num_sfm, *nb_sfm); + + *start_norm = HVQ_THRES_SFM_24k; + move16(); + } + ELSE + { + *num_sfm = SFM_N_HARM; + move16(); + *nb_sfm = HVQ_THRES_SFM_32k; + move16(); + *num_env_bands = sub(*num_sfm, *nb_sfm); + + *start_norm = HVQ_THRES_SFM_32k; + move16(); + } + p_sfmsize = band_len_harm; + move16(); + p_sfm_start = band_start_harm; + move16(); + p_sfm_end = band_end_harm; + move16(); + + } + ELSE IF(EQ_16(hqswb_clas, HQ_GEN_SWB)) + { + *num_sfm = SFM_N_SWB; + move16(); + p_sfmsize = band_len_HQ; + move16(); + p_sfm_start = band_start_HQ; + move16(); + p_sfm_end = band_end_HQ; + move16(); + + IF(GE_32(core_brate, HQ_32k)) + { + *hq_generic_offset = HQ_GENERIC_FOFFSET_32K; + move16(); + *num_env_bands = SFM_N_STA_10k; + move16(); + } + ELSE /*if( EQ_32(core_brate, HQ_24k40))*/ + { + *hq_generic_offset = HQ_GENERIC_FOFFSET_24K4; + move16(); + *num_env_bands = SFM_N_STA_8k; + move16(); + } + + *nb_sfm = *num_sfm; + move16(); + } + ELSE + { + /* HQ_NORMAL and HQ_TRANSIENT */ + *num_sfm = SFM_N_SWB; + move16(); + *nb_sfm = *num_sfm; + move16(); + *num_env_bands = SFM_N_SWB; + move16(); + + p_sfmsize = band_len_HQ; + move16(); + p_sfm_start = band_start_HQ; + move16(); + p_sfm_end = band_end_HQ; + move16(); + } + } + ELSE IF(EQ_16(length, L_SPEC48k_EXT)) + { + bw_ext = 1; + p_sfmsize = band_len_HQ; + p_sfm_start = band_start_HQ; + p_sfm_end = band_end_HQ; + *num_sfm = NB_SFM; + move16(); move16(); move16(); move16(); + } + ELSE IF(EQ_16(length, L_SPEC16k_EXT)) + { + bw_ext = 1; + p_sfmsize = band_len_wb; + p_sfm_start = band_start_wb; + p_sfm_end = band_end_wb; + *num_sfm = SFM_N_WB; + move16(); move16(); move16(); move16(); + } + ELSE + { + *num_sfm = SFM_N_WB; + move16(); + *nb_sfm = *num_sfm; + move16(); + *num_env_bands = SFM_N_WB; + move16(); + + p_sfmsize = band_len_wb; + move16(); + p_sfm_start = band_start_wb; + move16(); + p_sfm_end = band_end_wb; + move16(); + } + IF(bw_ext) + { + FOR(i = 0; i < *num_sfm; i++) + { + /*sfmsize[i] = (int16_t)(1.25f * p_sfmsize[i]);*/ + sfmsize[i] = mult_r(shl(p_sfmsize[i], 1), 20480); + /*sfm_start[i] = (int16_t)(1.25f * p_sfm_start[i]);*/ + sfm_start[i] = mult_r(shl(p_sfm_start[i], 1), 20480); + /*sfm_end[i] = (int16_t)(1.25f * p_sfm_end[i]);*/ + sfm_end[i] = mult_r(shl(p_sfm_end[i], 1), 20480); + } + *nb_sfm = *num_sfm; + *num_env_bands = *num_sfm; + move16(); move16(); + } + else + { + Copy(p_sfmsize, sfmsize, *num_sfm); + Copy(p_sfm_start, sfm_start, *num_sfm); + Copy(p_sfm_end, sfm_end, *num_sfm); + } + + *numnrmibits = extract_l(L_mult0(sub(*num_env_bands, 1), NORMI_BITS)); + + return; +} diff --git a/lib_com/hq_tools.c b/lib_com/hq_tools.c index df59ac172..ff5577693 100644 --- a/lib_com/hq_tools.c +++ b/lib_com/hq_tools.c @@ -1025,8 +1025,8 @@ void hvq_concat_bands( if ( k >= pvq_bands - n_sel_bnds ) { hvq_band_start[k] = hvq_band_end[k - 1]; - hvq_band_width[k] = band_len_harm[sel_bnds[s]]; - hvq_band_end[k] = hvq_band_end[k - 1] + band_len_harm[sel_bnds[s]]; + hvq_band_width[k] = band_len_harm_float[sel_bnds[s]]; + hvq_band_end[k] = hvq_band_end[k - 1] + band_len_harm_float[sel_bnds[s]]; s++; } else @@ -1114,7 +1114,7 @@ void map_hq_generic_fenv_norm( for ( i = num_env_bands; i < nb_sfm; ++i ) { idx = min( ynrm[i] + 10, 39 ); - normqlg2[i] = dicnlg2[idx]; + normqlg2[i] = dicnlg2_float[idx]; } return; @@ -1397,7 +1397,7 @@ void hq_wb_nf_bwe( sharp = EPSILON; for ( sfm = last_sfm; sfm >= 8; sfm-- ) { - if ( R[sfm] >= rat[sfm] * sfmsize[sfm] ) + if ( R[sfm] >= rat_flt[sfm] * sfmsize[sfm] ) { peak = 0.0f; mean = EPSILON; @@ -1784,7 +1784,7 @@ void apply_envelope_enc( * Ported from BASOP code to ensure interoperability *----------------------------------------------------------------------------*/ -void floating_point_add( +void floating_point_add_float( int32_t *mx, /* i/o: mantissa of the addend Q31 */ int16_t *ex, /* i/o: exponent of the addend Q0 */ const int32_t my, /* i : mantissa of the adder Q31 */ diff --git a/lib_com/hq_tools_fx.c b/lib_com/hq_tools_fx.c new file mode 100644 index 000000000..058c08df2 --- /dev/null +++ b/lib_com/hq_tools_fx.c @@ -0,0 +1,2433 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +/*==================================================================================== + EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 + ====================================================================================*/ +#include +#include +#include "options.h" /* Compilation switches */ +#include "rom_com.h" /* Static table prototypes FIP version */ +#include "stl.h" /* required for wmc_tool */ +#include "prot_fx2.h" + + /*--------------------------------------------------------------------------* + * Local function prototypes + *--------------------------------------------------------------------------*/ + +static void overlap_hq_bwe_fx(const Word32 *hq_swb_overlap_buf, Word32 *coeff_out, const Word16 n_swb_overlap_offset, + const Word16 n_swb_overlap, const Word16 *R, const Word16 num_env_bands, const Word16 num_sfm, const Word16 *sfm_end); + +static __inline Word16 L_Extract_lc(const Word32 L_32, Word16 *p_hi) +{ + *p_hi = extract_h(L_32); + return lshr(extract_l(L_32), 1); + +} + +/*--------------------------------------------------------------------------* +* hq_swb_harmonic_calc_norm_envelop() +* +* Calculate normalization envelop +*--------------------------------------------------------------------------*/ + +void hq_swb_harmonic_calc_norm_envelop_fx( + const Word32 *L_SWB_signal, /* i : input signal Q=12*/ + Word32 *L_envelope, /* o : output envelope Q=12*/ + const Word16 L_swb_norm, /* i : length of normaliztion */ + const Word16 SWB_flength /* i : length of input signal */ +) +{ + + Word16 lookback; + Word16 env_index; + Word16 n_freq; + Word16 n_lag_now; + Word16 n_lag; + Word16 i; + Word32 L_tmp; + + lookback = shr(L_swb_norm, 1); + env_index = 0; + move16(); + FOR(n_freq = 0; n_freq < lookback; n_freq++) + { + n_lag_now = add(lookback, n_freq); + + /* Apply MA filter */ + L_envelope[env_index] = EPSILLON_FX; + move16(); + + FOR(n_lag = 0; n_lag < n_lag_now; n_lag++) + { + L_tmp = L_abs(L_SWB_signal[n_lag]); + L_envelope[env_index] = L_add(L_envelope[env_index], L_tmp); + move32(); + } + env_index = add(env_index, 1); + } + + n_lag_now = L_swb_norm; + move16(); + + FOR(n_freq = 0; n_freq < SWB_flength - L_swb_norm; n_freq++) + { + /* Apply MA filter */ + L_envelope[env_index] = EPSILLON_FX; + move16(); + FOR(n_lag = 0; n_lag < n_lag_now; n_lag++) + { + L_tmp = L_abs(L_SWB_signal[add(n_freq, n_lag)]); + L_envelope[env_index] = L_add(L_envelope[env_index], L_tmp); + move32(); + } + env_index = add(env_index, 1); + } + + i = 0; + move16(); + FOR(n_freq = SWB_flength - L_swb_norm; n_freq < SWB_flength - lookback; n_freq++) + { + n_lag_now = sub(L_swb_norm, i); + + /* Apply MA filter */ + L_envelope[env_index] = L_deposit_l(EPSILLON_FX); + FOR(n_lag = 0; n_lag < n_lag_now; n_lag++) + { + L_tmp = L_abs(L_SWB_signal[add(n_freq, n_lag)]); + L_envelope[env_index] = L_add(L_envelope[env_index], L_tmp); + move32(); + } + env_index = add(env_index, 1); + i = add(i, 1); + } + + return; +} + + +/*--------------------------------------------------------------------------* +* noise_level_calc_fx() +* +* Calculate noise level and limited band +*--------------------------------------------------------------------------*/ + +void limit_band_noise_level_calc_fx( + const Word16 *wnorm, /* i : reordered norm of sub-vectors */ + Word16 *limit, /* o : highest band of bit allocation */ + const Word32 core_brate, /* i : bit rate */ + Word16 *noise_level /* o : noise level Q15 */ +) +{ + Word16 ener_limit, ener_sum; + Word16 i; + Word16 nb_sfm; + Word32 fact; + Word16 tmp; + + nb_sfm = *limit; + move16(); + ener_limit = 0; + move16(); + *noise_level = 0; + move16(); + FOR(i = 0; i < 10; i++) + { + ener_limit = add(ener_limit, wnorm[i]); + *noise_level = add(*noise_level, abs_s(sub(wnorm[i + 1], wnorm[i]))); + move16(); + + } + ener_sum = ener_limit; + move16(); + + tmp = sub(nb_sfm, 1); + FOR(i = 10; i < tmp; i++) + { + ener_sum = add(ener_sum, wnorm[i]); + *noise_level = add(*noise_level, abs_s(sub(wnorm[i + 1], wnorm[i]))); + move16(); + } + ener_sum = add(ener_sum, wnorm[nb_sfm - 1]); + + + fact = 2022929597; + move32(); + if (LT_32(core_brate, HQ_BWE_CROSSOVER_BRATE)) + { + fact = L_add(1900523029, 1); + } + + fact = Mult_32_16(fact, ener_sum); + i = 9; + move16(); + test(); + WHILE(LT_32(L_deposit_h(ener_limit), fact) && LT_16(add(i, 1), nb_sfm)) + { + ener_limit = add(ener_limit, wnorm[++i]); + test(); + } + *limit = i; + move16(); + + /* calculate noise level for spectrum filling */ + if (*noise_level < 0) + { + *noise_level = 0; + move16(); + } + + IF(GE_16(*noise_level, shr(ener_sum, 2))) + { + *noise_level = 0; + move16(); + } + ELSE + { + IF(ener_sum != 0) + { + *noise_level = sub(8192, div_s(*noise_level, ener_sum)); + } + ELSE + { + *noise_level = 8192; + } + move16(); + } + + return; +} + +/*--------------------------------------------------------------------------* + * build_nf_codebook_fx() + * + * Build noise-fill codebook for HQ mode + * NOTE: Q values preliminary + *--------------------------------------------------------------------------*/ + +Word16 build_nf_codebook_fx( /* o : Number of coefficients in nf codebook Q=0*/ + const Word16 flag_32K_env_ho, /* i : Envelope attenuation hangover flag Q=0*/ + const Word16 *coeff, /* i : Coded spectral coefficients Q=12*/ + const Word16 *sfm_start, /* i : Subband start indices Q=0*/ + const Word16 *sfmsize, /* i : Subband widths Q=0*/ + const Word16 *sfm_end, /* i : Subband end indices Q=0*/ + const Word16 last_sfm, /* i : Last coded band Q=0*/ + const Word16 *R, /* i : Per-band bit allocation Q=0*/ + Word16 *CodeBook, /* o : Noise-fill codebook Q=12*/ + Word16 *CodeBook_mod /* o : Densified noise-fill codebook Q=12*/ +) +{ + Word16 sfm_base; + Word16 sfm; + Word16 E_cb_vec; + Word16 i, j; + Word16 cb_size; + + /* Build codebook */ + + cb_size = 0; + move16(); + + FOR(sfm = 0; sfm <= last_sfm; sfm++) + { + IF(R[sfm] != 0) + { + IF(flag_32K_env_ho) + { + /* Build compressed (+/- 1) noise-fill codebook */ + sfm_base = sfm_start[sfm]; + move16(); + FOR(i = 0; i < sfmsize[sfm] / 8; i++) + { + E_cb_vec = 0; + move16(); + FOR(j = sfm_base + i * 8; j < sfm_base + (i + 1) * 8; j++) + { + IF(coeff[j] > 0) + { + CodeBook_mod[cb_size] = 1 << 12; + move16(); /* set to 1, Q value 12 */ + E_cb_vec = add(E_cb_vec, 1); + } + ELSE IF(coeff[j] < 0) + { + CodeBook_mod[cb_size] = -1 * (1 << 12); + move16(); /* set to -1, Q value 12 */ + E_cb_vec = add(E_cb_vec, 1); + } + ELSE + { + CodeBook_mod[cb_size] = 0; + move16(); + } + cb_size = add(cb_size, 1); + } + + if (E_cb_vec < 2) + { + cb_size = sub(cb_size, 8); + } + } + } + ELSE + { + FOR(j = sfm_start[sfm]; j < sfm_end[sfm]; j++) + { + CodeBook[cb_size] = coeff[j]; + move16(); + cb_size = add(cb_size,1); + } + } + } + } + + IF(flag_32K_env_ho) + { + FOR(j = 0; j < cb_size; j++) + { + IF(CodeBook_mod[j] != 0) + { + /* Densify codebook */ + CodeBook[j] = -4096; + move16(); /* -1 in Q12 */ + if (CodeBook_mod[j] > 0) + { + CodeBook[j] = 4096; + move16(); /* 1 in Q12 */ + } + + IF(CodeBook_mod[cb_size - j - 1] != 0) + { + CodeBook[j] = shl(CodeBook[j], 1); + move16(); /* Mult by 2 */ + } + } + ELSE + { + CodeBook[j] = CodeBook_mod[cb_size - j - 1]; + move16(); + } + } + } + + return cb_size; +} + + +/*--------------------------------------------------------------------------* +* find_last_band() +* +* Find the last band which has bits allocated +*--------------------------------------------------------------------------*/ + +Word16 find_last_band_fx( /* o : index of last band */ + const Word16 *bitalloc, /* i : bit allocation */ + const Word16 nb_sfm /* i : number of possibly coded bands */ +) +{ + Word16 sfm, core_sfm; + + core_sfm = sub(nb_sfm, 1); + + FOR(sfm = nb_sfm - 1; sfm >= 0; sfm--) + { + IF(bitalloc[sfm] != 0) + { + core_sfm = sfm; + move16(); + BREAK; + } + } + + return core_sfm; +} + +/*--------------------------------------------------------------------------* + * apply_noisefill_HQ() + * + * Inject noise in non-coded bands + *--------------------------------------------------------------------------*/ + +void apply_noisefill_HQ_fx( + const Word16 *R, /* i : bit allocation Q0 */ + const Word16 length, /* i : input frame length Q0 */ + const Word16 flag_32K_env_ho,/* i : envelope stability hangover flag Q0 */ + const Word32 L_core_brate, /* i : core bit rate Q0 */ + const Word16 last_sfm, /* i : last coded subband Q0 */ + const Word16 *CodeBook, /* i : Noise-fill codebook Q12 */ + const Word16 *CodeBook_mod, /* i : Densified noise-fill codebook Q12 */ + const Word16 cb_size, /* i : Codebook length Q0 */ + const Word16 *sfm_start, /* i : Subband start coefficient Q0 */ + const Word16 *sfm_end, /* i : Subband end coefficient Q0 */ + const Word16 *sfmsize, /* i : Subband band width Q0 */ + Word16 *coeff /* i/o: coded/noisefilled spectrum Q12 */ +) +{ + Word16 sfm; + Word16 cb_pos; + Word16 E_corr; + Word16 cb_buff[PVQ_MAX_BAND_SIZE]; + Word16 i, j; + Word16 istart; + UWord16 lsb; + Word32 L_E_cb_vec; + Word32 L_E_corr; + + test(); + test(); + IF((GE_16(length, L_FRAME32k)) || (NE_32(L_core_brate, HQ_32k))) + { + /* Read from codebook */ + cb_pos = 0; + move16(); + + FOR(sfm = 0; sfm <= last_sfm; sfm++) + { + IF(R[sfm] == 0) + { + IF(EQ_16(flag_32K_env_ho, 1)) + { + L_E_cb_vec = L_deposit_l(0); + IF(LT_16(sfm, 20)) + { + FOR(i = 0; i < sfmsize[sfm]; i++) + { + cb_buff[i] = CodeBook_mod[cb_pos++]; + move16(); + L_E_cb_vec = L_mac0(L_E_cb_vec, cb_buff[i], cb_buff[i]); /*Q24 (12+12) */ + + if (GE_16(cb_pos, cb_size)) + { + cb_pos = 0; + move16(); + } + } + } + ELSE + { + FOR(i = 0; i < sfmsize[sfm]; i++) + { + cb_buff[i] = CodeBook[cb_pos++]; + move16(); + L_E_cb_vec = L_mac0(L_E_cb_vec, cb_buff[i], cb_buff[i]); /*Q24 (12+12) */ + + if (GE_16(cb_pos, cb_size)) + { + cb_pos = 0; + move16(); + } + } + } + + /*E_corr = E_cb_vec / ((float) sfmsize[sfm]); */ + Mpy_32_16_ss(L_E_cb_vec, inv_tbl_fx[sfmsize[sfm]], &L_E_corr, &lsb); /*Q24 (24+15+1-16) */ + move16(); + + /*E_corr = 1.0f / (float)sqrt(E_corr); */ + L_E_corr = Isqrt(L_E_corr); /*Q19 (31-24/2) */ + E_corr = extract_h(L_shl(L_E_corr, 10)); /*Q13 (13-(19-16)) */ + + istart = sfm_start[sfm]; + move16(); + FOR(j = istart; j < sfm_end[sfm]; j++) + { + /*coeff[j] = cb_buff[j - istart] * E_corr; */ + coeff[j] = extract_h(L_shl(L_mult(cb_buff[j - istart], E_corr), 2)); /*Q12 (12+13+1+2-16) */ + } + } + ELSE + { + FOR(j = sfm_start[sfm]; j < sfm_end[sfm]; j++) + { + coeff[j] = CodeBook[cb_pos++]; + move16(); + if (GE_16(cb_pos, cb_size)) + { + cb_pos = 0; + move16(); + } + } + } + } + } + } + + return; +} + +/*--------------------------------------------------------------------------* + * harm_bwe_fine_fx() + * + * Prepare harmonic BWE fine structure + *--------------------------------------------------------------------------*/ + +void harm_bwe_fine_fx( + const Word16 *R, /* i : bit allocation */ + const Word16 last_sfm, /* i : last coded subband */ + const Word16 high_sfm, /* i : higher transition band to BWE */ + const Word16 num_sfm, /* i : total number of bands */ + const Word16 *norm, /* i : quantization indices for norms */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + Word16 *prev_L_swb_norm, /* i/o: last normalize length */ + Word16 *coeff, /* i/o: coded/noisefilled normalized spectrum */ + Word32 *coeff_out, /* o : coded/noisefilled spectrum */ + Word16 *coeff_fine /* o : BWE fine structure */ +) +{ + Word16 sfm; + Word16 i; + Word32 normq; + Word16 SWB_signal[L_HARMONIC_EXC]; + Word32 envelope[L_HARMONIC_EXC], L_signal[L_HARMONIC_EXC]; + Word16 enve_lo[L_HARMONIC_EXC], enve_hi[L_HARMONIC_EXC]; + Word16 *src, *dst, *end; + Word16 norm_signal; + + Word16 norm_width = 64; + move16(); + + /* shape the spectrum */ + FOR(sfm = 0; sfm <= last_sfm; sfm++) + { + IF(R[sfm] != 0) + { + normq = dicn_fx[norm[sfm]]; + move32(); + + FOR(i = sfm_start[sfm]; i < sfm_end[sfm]; i++) + { + coeff_out[i] = L_shl(Mult_32_16(normq, coeff[i]), 1); /*12 14+12+1+1-16 */ + move32(); + } + } + ELSE + { + FOR(i = sfm_start[sfm]; i < sfm_end[sfm]; i++) + { + coeff_out[i] = L_deposit_l(0); + } + } + } + + /* excitation replication */ + Copy32(coeff_out, L_signal, L_HARMONIC_EXC); + calc_normal_length_fx_32(HQ_CORE, coeff_out, HQ_HARMONIC, -1, &norm_width, prev_L_swb_norm); + hq_swb_harmonic_calc_norm_envelop_fx(L_signal, envelope, norm_width, L_HARMONIC_EXC); + + /* Normalize with envelope */ + FOR(i = 0; i < L_HARMONIC_EXC; i++) + { + IF(L_signal[i] > 0) + { + norm_signal = norm_l(envelope[i]); + enve_lo[i] = L_Extract_lc(L_shl(envelope[i], norm_signal), &enve_hi[i]); + L_signal[i] = Div_32(L_signal[i], enve_hi[i], enve_lo[i]); +#ifdef BASOP_NOGLOB + SWB_signal[i] = round_fx_sat(L_shl_sat(L_signal[i], norm_signal)); +#else + SWB_signal[i] = round_fx(L_shl(L_signal[i], norm_signal)); +#endif + move16(); + move16(); + move32(); + + } + ELSE + { + norm_signal = norm_l(envelope[i]); + enve_lo[i] = L_Extract_lc(L_shl(envelope[i], norm_signal), &enve_hi[i]); + L_signal[i] = L_negate(Div_32(L_negate(L_signal[i]), enve_hi[i], enve_lo[i])); +#ifdef BASOP_NOGLOB + SWB_signal[i] = round_fx_sat(L_shl_sat(L_signal[i], norm_signal)); +#else + SWB_signal[i] = round_fx(L_shl(L_signal[i], norm_signal)); +#endif + move16(); + move16(); + move32(); + + } + } + + dst = coeff_fine + sfm_end[last_sfm]; + end = coeff_fine + sfm_end[num_sfm - 1]; + + IF(LE_16(sub(sfm_end[last_sfm], sfm_end[high_sfm]), (L_HARMONIC_EXC - START_EXC))) + { + src = SWB_signal + START_EXC + sub(sfm_end[last_sfm], sfm_end[high_sfm]); + } + ELSE + { + src = SWB_signal + L_HARMONIC_EXC - 1; + } + + WHILE(dst < end) + { + logic32(); + WHILE(dst < end && src < &SWB_signal[L_HARMONIC_EXC]) + { + *dst++ = *src++; + move16(); + } + src--; + + logic32(); + WHILE(dst < end && src >= &SWB_signal[START_EXC]) + { + *dst++ = *src--; + move16(); + } + src++; + } + + return; +} + +/*--------------------------------------------------------------------------* + * hvq_bwe_fine() + * + * Prepare HVQ BWE fine structure + *--------------------------------------------------------------------------*/ + +void hvq_bwe_fine_fx( + const Word16 last_sfm, /* i : last coded subband Q0 */ + const Word16 num_sfm, /* i : total number of bands Q0 */ + const Word16 *sfm_end, /* i : Subband end coefficient Q0 */ + const Word16 *peak_idx, /* i : Peak index Q0 */ + const Word16 Npeaks, /* i : Number of peaks Q0 */ + Word16 *peak_pos, /* o : Peak positions Q0 */ + Word16 *prev_L_swb_norm, /* i/o: last normalize length Q0 */ + Word32 *L_coeff, /* i : coded/noisefilled normalized spectrum Q12 */ + Word16 *bwe_peaks, /* o : Positions of peaks in BWE Q0 */ + Word16 *coeff_fine /* o : HVQ BWE fine structure Q15 */ +) +{ + Word16 i, j; + Word16 SWB_signal[L_HARMONIC_EXC]; + Word32 L_envelope[L_HARMONIC_EXC]; + Word16 *src, *dst, *end; + Word16 *peak_dst, *peak_src; + Word16 norm_width = 64; + Word16 tmp; + Word16 shift, shift2; + Word32 L_tmp; + UWord16 lsb; + + calc_normal_length_fx_32(HQ_CORE, L_coeff, HQ_HVQ, -1, &norm_width, prev_L_swb_norm); + + hq_swb_harmonic_calc_norm_envelop_fx(L_coeff, L_envelope, norm_width, L_HARMONIC_EXC); + + /* Normalize with envelope */ + FOR(i = 0; i < L_HARMONIC_EXC; i++) + { + /*SWB_signal[i] = SWB_signal[i] / envelope[i]; */ + + shift = norm_l(L_envelope[i]); +#ifdef BASOP_NOGLOB + tmp = round_fx_sat(L_shl_sat(L_envelope[i], shift)); /* 12+s-16=Q(-4+s) */ +#else + tmp = round_fx(L_shl(L_envelope[i], shift)); /* 12+s-16=Q(-4+s) */ +#endif + /* Avoid division by zero */ + if (tmp == 0) + { + tmp = 1 << 14; + move16(); + } + + tmp = div_s(1 << 14, tmp); /* 15+14-(-4+s)=Q(33-s) */ + Mpy_32_16_ss(L_coeff[i], tmp, &L_tmp, &lsb); /* 12+33-s+1-16=Q(30-s) */ + shift2 = add(shift, 1); + tmp = round_fx(L_shl(L_tmp, shift2)); /* 30-s+s+1-16=Q(15) */ + SWB_signal[i] = add(tmp, lshr(lsb, sub(32, shift2))); + move16(); /* Q15 */ + /*SWB_signal[i] = round_fx(L_shl(L_tmp, add(shift, 1))); // 30-s+s+1-16=Q(15) */ + + } + + dst = coeff_fine; + end = coeff_fine + sfm_end[num_sfm - 1] - sfm_end[last_sfm]; + + src = SWB_signal + START_EXC; + peak_src = peak_pos + START_EXC; + + FOR(i = 0; i < Npeaks; i++) + { + if (LT_16(peak_idx[i], L_HARMONIC_EXC)) + { + peak_pos[peak_idx[i]] = 1; + move16(); + } + } + + i = sub(L_HARMONIC_EXC, 1); + WHILE(i-- > 0) + { + IF(EQ_16(peak_pos[i], 1)) + { + BREAK; + } + } + + if (LT_16(i, 180)) + { + i = 180; + move16(); + } + + FOR(j = L_HARMONIC_EXC - 1; j > i + 1; j--) + { + SWB_signal[j] = 0; + move16(); + } + + peak_dst = bwe_peaks + sfm_end[last_sfm]; + WHILE(dst < end) + { + test(); + WHILE(dst < end && src < &SWB_signal[L_HARMONIC_EXC]) + { + *dst++ = *src++; + move16(); + *peak_dst++ = *peak_src++; + move16(); + } + peak_src--; + src--; + + test(); + WHILE(dst < end && src >= &SWB_signal[START_EXC]) + { + *dst++ = *src--; + move16(); + *peak_dst++ = *peak_src--; + move16(); + } + peak_src++; + src++; + } + + return; +} + +/*--------------------------------------------------------------------------* + * hq_fold_bwe_fx() + * + * HQ mode folding BWE + *--------------------------------------------------------------------------*/ + +void hq_fold_bwe_fx( + const Word16 last_sfm, /* i : last coded subband Q0 */ + const Word16 *sfm_end, /* i : Subband end coefficient Q0 */ + const Word16 num_sfm, /* i : Number of subbands Q0 */ + Word16 *coeff /* i/o: coded/noisefilled normalized spectrum Q12 */ +) +{ + Word16 low_coeff; + Word16 first_coeff; + Word16 *src, *dst, *end; + + low_coeff = shr(sfm_end[last_sfm], 1); + src = coeff + sfm_end[last_sfm] - 1; + + first_coeff = sfm_end[last_sfm]; + dst = coeff + sfm_end[last_sfm]; + end = coeff + sfm_end[num_sfm - 1]; + + WHILE(dst < end) + { + WHILE(dst < end && src >= &coeff[low_coeff]) + { + *dst++ = *src--; + move16(); + } + + src++; + + WHILE(dst < end && src < &coeff[first_coeff]) + { + *dst++ = *src++; + move16(); + } + } + return; +} + +/*--------------------------------------------------------------------------* + * apply_nf_gain() + * + * Apply noise fill gain + *--------------------------------------------------------------------------*/ + +void apply_nf_gain_fx( + const Word16 nf_idx, /* i : noise fill gain index Q0 */ + const Word16 last_sfm, /* i : last coded subband Q0 */ + const Word16 *R, /* i : bit allocation Q0 */ + const Word16 *sfm_start, /* i : Subband start coefficient Q0 */ + const Word16 *sfm_end, /* i : Subband end coefficient Q0 */ + Word16 *coeff /* i/o: coded/noisefilled normalized spectrum Q12 */ +) +{ + Word16 sfm; + Word16 j; + + FOR(sfm = 0; sfm <= last_sfm; sfm++) + { + IF(R[sfm] == 0) + { + FOR(j = sfm_start[sfm]; j < sfm_end[sfm]; j++) + { + /* Scale NoiseFill */ + coeff[j] = shr(coeff[j], nf_idx); + move16(); + } + } + } + + return; +} + + +/*--------------------------------------------------------------------------* + * harm_bwe_fx() + * + * HQ Harmonic BWE + *--------------------------------------------------------------------------*/ + +void harm_bwe_fx( + const Word16 *coeff_fine, /* i : fine structure for BWE */ + const Word16 *coeff, /* i : coded/noisefilled normalized spectrum */ + const Word16 num_sfm, /* i : Number of subbands */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + const Word16 last_sfm, /* i : last coded subband */ + const Word16 *R, /* i : bit allocation */ + const Word16 prev_hq_mode, /* i : previous hq mode */ + Word16 *norm, /* i/o: quantization indices for norms */ + Word16 *noise_level, /* i/o: noise levels for harmonic modes */ + Word16 *prev_noise_level, /* i/o: noise factor in previous frame */ + Word16 *bwe_seed, /* i/o: random seed for generating BWE input */ + Word32 *coeff_out, /* o : coded/noisefilled spectrum */ + const Word16 element_mode /* i : IVAS element mode */ +) +{ + Word16 i, j; + Word16 sfm, band_width; + Word32 normq, L_tmp, L_tmp2; + Word32 E_L; + Word16 alfa = 16384; + Word16 tmp, tmp1, exp1; + Word16 beta; + Word32 *src, *dst; + + move16(); /* alfa */ + + FOR(sfm = 0; sfm <= last_sfm; sfm++) + { + IF(R[sfm] == 0) + { + normq = dicn_fx[norm[sfm]]; /*Q14 */ move16(); + + FOR(i = sfm_start[sfm]; i < sfm_end[sfm]; i++) + { + coeff_out[i] = L_shl(Mult_32_16(normq, coeff[i]), 1); + move32(); /*12 Q(14 +12+1-16 +1) */ + + } + } + } + noise_level[1] = noise_level[0]; + move16(); + + /* shaping the BWE spectrum further by envelopes and noise factors */ + L_tmp = L_mult(29491, prev_noise_level[0]); /* 15 +1 +15 */ + noise_level[0] = round_fx(L_mac(L_tmp, 3277, noise_level[0])); /*15 */ + + L_tmp = L_mult(29491, prev_noise_level[1]); + noise_level[1] = round_fx(L_mac(L_tmp, 3277, noise_level[1])); + + test(); + IF(prev_hq_mode == HQ_NORMAL || EQ_16(prev_hq_mode, HQ_GEN_SWB)) + { + IF(LT_16(noise_level[0], 8192)) + { + noise_level[0] = shl(noise_level[0], 2); + move16(); + } + + IF(LT_16(noise_level[1], 8192)) + { + noise_level[1] = shl(noise_level[1], 2); + move16(); + } + } + + FOR(i = add(last_sfm, 1); i < num_sfm; i++) + { + E_L = 1; + move32(); + FOR(j = sfm_start[i]; j < sfm_end[i]; j++) + { + L_tmp = L_mult0(coeff_fine[j], coeff_fine[j]);/*Q30 */ + E_L = L_add(E_L, L_shr(L_tmp, 6));/*Q24 */ + } + + normq = dicn_fx[norm[i]]; + move32(); + + alfa = noise_level[0]; + move16(); + if (GT_16(i, 27)) + { + alfa = noise_level[1]; + move16(); + } + + band_width = sub(sfm_end[i], sfm_start[i]); /* */ + exp1 = norm_l(E_L); + IF(exp1 == 0) + { + E_L = Mult_32_16(E_L, inv_tbl_fx[band_width]); /* Q24 (24+15+1-16) *//*24+15+1-16 */ + tmp = div_l(E_L, sub(32767, alfa)); /*Q24-15-1 =8 */ + tmp = s_max(1, tmp); + L_tmp = L_deposit_h(tmp); /*24 */ + E_L = Isqrt(L_tmp); /* Q19 (31-24/2) */ + } + ELSE + { + exp1 = sub(exp1,1); + E_L = Mult_32_16(L_shl(E_L,exp1), inv_tbl_fx[band_width]); /* Q24+exp1 (24+exp1+15+1-16) */ + tmp = div_l(E_L,sub(32767,alfa)); /*Q24+exp1-15-1 =8+exp1 */ + tmp = s_max(1,tmp); + L_tmp = L_shl(L_deposit_l(tmp),sub(16,exp1)); /*24 8+exp1+16-exp1 */ + E_L = Isqrt(L_tmp); /* Q19 (31-24/2) */ + } + + exp1 = norm_s(alfa); + tmp1 = shl(alfa, exp1); + if (EQ_16(element_mode, EVS_MONO)) + { + exp1 = add(1, exp1); + } +#ifdef DEBUGGING + else + { + PMT("VERIFY if this really matches IVAS float") + } +#endif + tmp1 = s_max(tmp1, 16384); + tmp1 = div_s(16384, tmp1); + L_tmp2 = L_deposit_h(tmp1); + L_tmp2 = Isqrt_lc(L_tmp2, &exp1); + beta = round_fx(L_shl(L_tmp2, exp1)); + beta = shr(beta, 1); /*Q15 */ + + + FOR(sfm = sfm_start[i]; sfm < sfm_end[i]; sfm++) + { + L_tmp = Mult_32_16(E_L, coeff_fine[sfm]); /*Q19 19 + 15 +1-16 */ +#ifdef BASOP_NOGLOB + L_tmp = L_shl_sat(L_tmp, 9);/*Q28 */ +#else + L_tmp = L_shl(L_tmp, 9);/*Q28 */ +#endif + tmp = Random(bwe_seed); /*Q15 */ + L_tmp2 = L_shr(L_mult(beta, tmp), 3);/* Q28 31-3 15+15 +1-3 */ +#ifdef BASOP_NOGLOB + L_tmp = L_add_sat(L_tmp, L_tmp2);/*Q28 */ + coeff_out[sfm] = L_shl_sat(Mult_32_32(L_tmp, normq), 1);/*Q12 28 +14 +1 -31 */ move32(); +#else + L_tmp = L_add(L_tmp, L_tmp2);/*Q28 */ + coeff_out[sfm] = L_shl(Mult_32_32(L_tmp, normq), 1);/*Q12 28 +14 +1 -31 */ move32(); +#endif + } + } + + prev_noise_level[0] = noise_level[0]; + move16(); + prev_noise_level[1] = noise_level[1]; + move16(); + + src = &coeff_out[add(sfm_end[last_sfm], L_HARMONIC_EXC - START_EXC)]; /*Q12 */ + + dst = src - 1; + FOR(i = 0; i < 16; i++) + { + *src = Mult_32_16(*src, hvq_bwe_fac_fx[i]); /* Q12 (12+15+1-16) */ move32(); + src++; + *dst = Mult_32_16(*dst, hvq_bwe_fac_fx[i]); /* Q12 (12+15+1-16) */ move32(); + dst--; + } + IF(EQ_16(num_sfm, 33)) + { + set32_fx(&coeff_out[800], 0, 160); + } + return; +} + +/*--------------------------------------------------------------------------* + * HVQ_bwe_fx() + * + * HQ HVQ BWE + *--------------------------------------------------------------------------*/ + +void hvq_bwe_fx( + const Word32 *L_coeff, /* i : coded/noisefilled normalized spectrum Q12 */ + const Word16 *coeff_fine, /* i : coded/noisefilled normalized spectrum Qin */ + const Word16 *sfm_start, /* i : Subband start coefficient Q0 */ + const Word16 *sfm_end, /* i : Subband end coefficient Q0 */ + const Word16 *sfm_len, /* i : Subband length Q0 */ + const Word16 last_sfm, /* i : last coded subband Q0 */ + const Word16 prev_hq_mode, /* i : previous hq mode Q0 */ + const Word16 *bwe_peaks, /* i : HVQ bwe peaks Q0 */ + const Word16 bin_th, /* i : HVQ transition bin Q0 */ + const Word16 num_sfm, /* i : Number of bands Q0 */ + const Word32 core_brate, /* i : Core bitrate Q0 */ + const Word16 *R, /* i : Bit allocation */ + Word16 *norm, /* i/o: quantization indices for norms Q0 */ + Word16 *noise_level, /* i/o: noise levels for harmonic modes Q15 */ + Word16 *prev_noise_level, /* i/o: noise factor in previous frame Q15 */ + Word16 *bwe_seed, /* i/o: random seed for generating BWE input Q0 */ + Word32 *L_coeff_out, /* o : coded/noisefilled spectrum Qout*/ + const Word16 qin, + const Word16 qout +) +{ + Word16 i, j; + Word16 N; + Word32 L_normq; + Word32 L_E; + Word32 L_tmp_norm = 0; + Word16 bwe_noise_th = 0; + Word16 peak_band, low, high, sel_norm; + Word16 norm_ind; + Word32 *L_src, *L_dst; + Word16 istart, iend; + Word16 offset = sfm_end[last_sfm]; + + /* Fx specific variables */ + Word32 L_tmp0, L_tmp1; + Word16 tmp, tmp2, band_size; + Word16 last_norm_ind; + Word16 shift, power_shift; + Word16 coeff_s[L_FRAME48k]; + Word16 j_N; + Word16 n_c; + UWord16 lsb; + + move32(); /* L_tmp_norm */ + move16(); /* bwe_noise_th */ + + bwe_noise_th = add(bin_th, shr(sub(sfm_end[sub(num_sfm, 1)], bin_th), 1)); + logqnorm_fx(&L_coeff_out[sfm_start[last_sfm]], qout, &norm[last_sfm], 40, sfm_len[last_sfm], 0); + move16(); + + /* shaping the BWE spectrum further by envelopes and noise factors */ + noise_level[0] = round_fx(L_mac(L_mult(29491, prev_noise_level[0]), 3277, noise_level[0])); /* Q15 (15+15+1-16) */ + noise_level[1] = round_fx(L_mac(L_mult(29491, prev_noise_level[1]), 3277, noise_level[1])); /* Q15 (15+15+1-16) */ + + test(); + IF(prev_hq_mode == HQ_NORMAL || EQ_16(prev_hq_mode, HQ_GEN_SWB)) + { + IF(LT_16(noise_level[0], 8192 /* 0.25f */)) + { + noise_level[0] = shl(noise_level[0], 2); + move16(); + } + + IF(LT_16(noise_level[1], 8192 /* 0.25f */)) + { + noise_level[1] = shl(noise_level[1], 2); + move16(); + } + } + + norm_ind = add(last_sfm, 1); + IF(LT_32(core_brate, HQ_BWE_CROSSOVER_BRATE)) + { + peak_band = 0; + move16(); + + tmp = 1; + move16(); + FOR(i = sfm_start[norm_ind]; i < sfm_end[norm_ind + 1]; i++) + { + tmp2 = abs_s(coeff_fine[i - offset]); + tmp = s_max(tmp, tmp2); + } + band_size = sub(sfm_end[norm_ind + 1], sfm_start[norm_ind]); + + /* Headroom for square and accumulate */ + shift = sub(norm_s(tmp), sqac_headroom_fx[band_size]); + L_E = L_deposit_l(1); + FOR(i = sfm_start[norm_ind]; i < sfm_end[norm_ind + 1]; i++) + { + if (bwe_peaks[i]) + { + peak_band = 1; + move16(); + } + /* E_L += coeff_fine[i-offset] * coeff_fine[i-offset]; */ + coeff_s[i] = shl(coeff_fine[i - offset], shift); + move16();/* Q15 + shift */ + L_E = L_mac0(L_E, coeff_s[i], coeff_s[i]); /* Q2*(qin + shift) */ + } + power_shift = shl(shift, 1); + + L_E = L_shr(L_E, sub(power_shift, 28 - 2 * qin)); /* Q28 */ + + /* E_L = (float)sqrt((sfm_end[norm_ind+1] - sfm_start[norm_ind])/E_L); */ + L_E = Mult_32_16(L_E, inv_tbl_fx[band_size]); /* Q28 (28+15+1-16) */ + /* To avoid overflow in Isqrt() */ + if (L_E == 0) + { + L_E = L_deposit_l(1); + } + L_E = Isqrt(L_E); /* Q17 (31-28/2) */ + + /* normq = 0.1f*dicn[norm[norm_ind-1]] + 0.8f*dicn[norm[norm_ind]] + 0.1f*dicn[norm[norm_ind+1]]; */ + /* tmp_norm = 0.1f*dicn[norm[norm_ind]] + 0.8f*dicn[norm[norm_ind+1]] + 0.1f*dicn[norm[norm_ind+2]]; */ + L_tmp0 = L_add(dicn_fx[norm[norm_ind]], 0); + L_tmp1 = L_add(dicn_fx[norm[norm_ind + 1]], 0); + L_normq = Madd_32_16(Madd_32_16(Mult_32_16(L_tmp0, 26214 /* Q15, 0.8f */), dicn_fx[norm[norm_ind - 1]], 3277 /* Q15, 0.1f */), L_tmp1, 3277 /* Q15, 0.1f */); /* Q14 (14+15+1-16) */ move16(); + L_tmp_norm = Madd_32_16(Madd_32_16(Mult_32_16(L_tmp1, 26214 /* Q15, 0.8f */), dicn_fx[norm[norm_ind + 2]], 3277 /* Q15, 0.1f */), L_tmp0, 3277 /* Q15, 0.1f */); /* Q14 (14+15+1-16) */ move16(); + + istart = sfm_start[norm_ind]; + move16(); + /* iend = istart + sfm_len[norm_ind]/2; */ + iend = 240; + move16(); + + noise_mix_fx(&coeff_fine[-offset], L_E, L_normq, bwe_seed, istart, iend, noise_level[0], L_coeff_out, qin, qout); + + j = 0; + move16(); + /* N = sfm_len[norm_ind]/2+sfm_len[norm_ind+1]/2-1; */ + N = 31; + move16(); + j_N = N; + move16(); + + istart = iend; + move16(); + /* iend = sfm_start[norm_ind+1] + sfm_len[norm_ind+1]/2; */ + iend = 272; + move16(); + + /* special case that is not handled by noise_mix_fx() */ + n_c = sub(MAX_16, noise_level[0]); /* Q15 */ + FOR(i = istart; i < iend; i++) + { + /* coeff_out[i] = ((float)(N-j)/N*normq + (float)j/N*tmp_norm)*((1.0f - noise_level[i/bwe_noise_th])*coeff_fine[i-offset]*E_L + noise_level[i/bwe_noise_th]*own_random(bwe_seed)/32768.0f); */ + L_tmp1 = Madd_32_16(Mult_32_16(L_normq, inv_N_fx[j_N]), L_tmp_norm, inv_N_fx[j]); /* Q14 (14+15+1-16) */ + j = add(j, 1); + j_N = sub(j_N, 1); + + Mpy_32_16_ss(L_E, coeff_fine[i - offset], &L_tmp0, &lsb); /* Qin+2 (17+qin+1-16) */ + Mpy_32_16_ss(L_tmp0, n_c, &L_tmp0, &lsb); /* Qin+2-15 (qin+2+15+1-16) */ + + IF(L_tmp0 != 0) + { + /* Normalize with 1 bit headroom for addition */ + tmp = 30 - (qin + 2); /* Assuming fixed Q values */ + tmp = s_min(norm_l(L_tmp0), tmp); + tmp = sub(tmp, 1); + + L_tmp0 = L_add(L_shl(L_tmp0, tmp), L_deposit_l(lshr(lsb, sub(16, tmp)))); /* Qin+2+tmp */ + + L_tmp0 = L_add(L_tmp0, L_shr(L_mult0(noise_level[0], Random(bwe_seed)), sub(30 - (qin + 2), tmp))); /* Qin+2+tmp */ + tmp = round_fx(L_shl(L_tmp0, 27 - (qin + 2) - tmp)); /* Q11 (Qin+2+tmp+27-qin-2-tmp-16) */ + + Mpy_32_16_ss(L_tmp1, tmp, &L_tmp0, &lsb); /* Q10 (14+11+1-16) */ + L_coeff_out[i] = L_add(L_shl(L_tmp0, qout - 10), L_deposit_l(lshr(lsb, 10 + 16 - qout))); + move32(); /* Qout (10+qout-10) */ + } + ELSE + { + L_tmp0 = L_mult0(noise_level[0], Random(bwe_seed)); /* Q30 (15+15) */ + tmp = round_fx(L_tmp0); /* Q14 (30-16) */ + Mpy_32_16_ss(L_tmp1, tmp, &L_tmp0, &lsb); /* Q13 (14+14+1-16) */ + L_coeff_out[i] = L_shr(L_tmp0,13 - qout); + move32();/* Qout (13-(13-qout)) */ + } + } + + istart = iend; + move16(); + iend = sfm_end[norm_ind + 1]; + move16(); + + noise_mix_fx(&coeff_fine[-offset], L_E, L_tmp_norm, bwe_seed, istart, iend, noise_level[0], L_coeff_out, qin, qout); + + norm_ind = add(norm_ind, 2); + } + + FOR(; norm_ind < num_sfm; norm_ind++) + { + IF(R[norm_ind] == 0) + { + peak_band = 0; + move16(); + + FOR(i = sfm_start[norm_ind]; i < sfm_end[norm_ind]; i++) + { + if (bwe_peaks[i]) + { + peak_band = 1; + move16(); + } + } + + istart = sfm_start[norm_ind]; + move16(); + iend = sfm_end[norm_ind]; + move16(); + + last_norm_ind = sub(num_sfm, 1); + test(); + test(); + IF(EQ_16(peak_band, 1) && GT_16(norm_ind, add(last_sfm, 1)) && LT_16(norm_ind, last_norm_ind)) + { + istart = sub(istart, shr(sfm_len[norm_ind - 1], 1)); + iend = add(iend, shr(sfm_len[norm_ind + 1], 1)); + } + + tmp = 1; + move16(); + FOR(i = istart; i < iend; i++) + { + tmp2 = abs_s(coeff_fine[i - offset]); + tmp = s_max(tmp, tmp2); + } + band_size = sub(iend, istart); + /* Headroom for square and accumulate */ + shift = sub(norm_s(tmp), sqac_headroom_fx[band_size]); + + L_E = 1L; + move32(); + FOR(i = istart; i < iend; i++) + { + /* E_L += coeff_fine[i-offset] * coeff_fine[i-offset]; */ + coeff_s[i] = shl(coeff_fine[i - offset], shift); + move16();/* Q15 + shift */ + L_E = L_mac0(L_E, coeff_s[i], coeff_s[i]); /* Q2*(15 + shift) */ + } + power_shift = shl(shift, 1); + + L_E = L_shr(L_E, sub(power_shift, 28 - 2 * qin)); /* Q28 */ + + /* E_L = (float)sqrt((iend - istart)/E_L); */ + L_E = Mult_32_16(L_E, inv_tbl_fx[band_size]); /* Q28 (28+15+1-16) */ + /* To avoid overflow in Isqrt() */ + if (L_E == 0) + { + L_E = 1L; + move32(); + } + L_E = Isqrt(L_E); /* Q17 (31-28/2) */ + + IF(peak_band) + { + IF(GT_16(add(norm_ind, 2), num_sfm)) + { + /* normq = 0.15f*dicn[norm[norm_ind-1]] + 0.85f*dicn[norm[norm_ind]]; */ + L_normq = Madd_32_16(Mult_32_16(dicn_fx[norm[norm_ind]], 27853 /* Q15, 0.85f */), dicn_fx[norm[norm_ind - 1]], 4915 /* Q15, 0.1f */); /* Q14 (14+15+1-16) */ move16(); + move16(); + } + ELSE + { + /* normq = 0.1f*dicn[norm[norm_ind-1]] + 0.8f*dicn[norm[norm_ind]] + 0.1f*dicn[norm[norm_ind+1]]; */ + L_normq = Madd_32_16(Madd_32_16(Mult_32_16(dicn_fx[norm[norm_ind]], 26214 /* Q15, 0.8f */), dicn_fx[norm[norm_ind + 1]], 3277 /* Q15, 0.1f */), dicn_fx[norm[norm_ind - 1]], 3277 /* Q15, 0.1f */); /* Q14 (14+15+1-16) */ move16(); + move16(); + move16(); + } + } + ELSE + { + low = norm_ind; + move16(); + high = s_min(add(norm_ind,1), last_norm_ind); + move16(); + sel_norm = norm[norm_ind - 1]; + move16(); + FOR(j = low; j <= high; j++) + { + if (GT_16(norm[j], sel_norm)) + { + sel_norm = norm[j]; + move16(); + } + } + L_normq = dicn_fx[sel_norm]; + move16(); + } + + iend = s_min(sfm_end[norm_ind], bwe_noise_th); + move16(); + IF(GT_16(iend, sfm_start[norm_ind])) + { + noise_mix_fx(&coeff_fine[-offset], L_E, L_normq, bwe_seed, sfm_start[norm_ind], iend, noise_level[0], L_coeff_out, qin, qout); + } + ELSE + { + iend = sfm_end[norm_ind]; + move16(); + noise_mix_fx(&coeff_fine[-offset], L_E, L_normq, bwe_seed, sfm_start[norm_ind], iend, noise_level[1], L_coeff_out, qin, qout); + } + /* Noisemix up to threshold done */ + IF(EQ_16(iend, bwe_noise_th)) + { + noise_mix_fx(&coeff_fine[-offset], L_E, L_normq, bwe_seed, iend, sfm_end[norm_ind], noise_level[1], L_coeff_out, qin, qout); + } + + } + ELSE /* R[norm_ind] > 0 */ + { + FOR(i = sfm_start[norm_ind]; i < sfm_end[norm_ind]; i++) + { + L_coeff_out[i] = L_coeff[i]; /* Scaling already applied */ move32(); + } + } + } + + prev_noise_level[0] = noise_level[0]; + move16(); + prev_noise_level[1] = noise_level[1]; + move16(); + L_src = &L_coeff_out[add(sfm_end[last_sfm], L_HARMONIC_EXC - START_EXC)]; /* Address initialization */ + L_dst = L_src - 1; /* Address computation */ + + FOR(i = 0; i < 16; i++) + { + *L_src = Mult_32_16(*L_src, hvq_bwe_fac_fx[i]); + L_src++; /* Qout (Qout+15+1-16) */ move32(); + *L_dst = Mult_32_16(*L_dst, hvq_bwe_fac_fx[i]); + L_dst--; /* Qout (Qout+15+1-16) */ move32(); + } + + return; +} + +/*-------------------------------------------------------------------* +* hvq_concat_bands_fx() +* +* Compute the band limits for concatenated bands for PVQ target signal in HVQ +*--------------------------------------------------------------------------*/ +void hvq_concat_bands_fx +( + const Word16 pvq_bands, /* i : Number of bands in concatenated PVQ target */ + const Word16 *sel_bnds, /* i : Array of selected high bands */ + const Word16 n_sel_bnds, /* i : Number of selected high bands */ + Word16 *hvq_band_start, /* i : Band start indices */ + Word16 *hvq_band_width, /* i : Band widths */ + Word16 *hvq_band_end /* i : Band end indices */ +) +{ + Word16 k, k_1; + const Word16 *pSelBnds; + + pSelBnds = sel_bnds; + FOR(k = 0; k < pvq_bands; k++) + { + + IF(GE_16(k, sub(pvq_bands, n_sel_bnds))) + { + k_1 = sub(k, 1); + hvq_band_start[k] = hvq_band_end[k_1]; + move16(); + hvq_band_width[k] = band_len_harm[*pSelBnds++]; + move16(); + move16(); + hvq_band_end[k] = add(hvq_band_end[k_1], hvq_band_width[k]); + move16(); + } + ELSE + { + hvq_band_start[k] = extract_l(L_mult0(k, HVQ_PVQ_COEFS)); + hvq_band_width[k] = HVQ_PVQ_COEFS; + move16(); + hvq_band_end[k] = add(hvq_band_start[k], HVQ_PVQ_COEFS); + move16(); + } + } + + return; +} +/*--------------------------------------------------------------------------* + * noise_mix_fx() + *--------------------------------------------------------------------------*/ + +void noise_mix_fx( + const Word16 *coeff_fine, /* i : normalized fine structure spectrum Qin */ + const Word32 L_E, /* i : normalization factor Q17 */ + const Word32 L_normq, /* i : quantized norm Q14 */ + Word16 *seed, /* i/o: random seed Q0 */ + const Word16 istart, /* i : start coefficient Q0 */ + const Word16 iend, /* i : end coefficient Q0 */ + const Word16 noise_level, /* i : noise_level Q0 */ + Word32 *L_coeff_out, /* o : noise mixed spectrum Qout */ + const Word16 qin, + const Word16 qout +) +{ + Word16 i, tmp, n_c; + Word32 L_tmp0; + UWord16 lsb; + + n_c = sub(MAX_16, noise_level); /* Q15 */ + FOR(i = istart; i < iend; i++) + { + /* L_coeff_out[i] = ((1.0f - noise_level)*coeff_fine[i]*L_E + noise_level*own_random(seed)/32768.0f)*normq; */ + Mpy_32_16_ss(L_E, coeff_fine[i], &L_tmp0, &lsb); /* Qin+qL_E-15 (qL_E+qin+1-16) */ + Mpy_32_16_ss(L_tmp0, n_c, &L_tmp0, &lsb); /* Qin+qL_E-15 (qin+qL_E-15+15+1-16) */ + + IF(L_tmp0 != 0) + { + /* Normalize with 1 bit headroom for addition */ + tmp = 30 - (qin + 2); /* Assuming fixed Q values */ + tmp = s_min(norm_l(L_tmp0), tmp); + tmp = sub(tmp, 1); + + L_tmp0 = L_add(L_shl(L_tmp0, tmp), L_deposit_l(lshr(lsb, sub(16, tmp)))); /* Qin+2+tmp */ + L_tmp0 = L_add(L_tmp0, L_shr(L_mult0(noise_level, Random(seed)), sub(30 - (qin + 2), tmp))); /* Qin+2+tmp */ + + tmp = round_fx(L_shl(L_tmp0, 27 - (qin + 2) - tmp)); /* Q11 (Qin+2+tmp+27-qin-2-tmp-16) */ + Mpy_32_16_ss(L_normq, tmp, &L_tmp0, &lsb); /* Q10 (14+11+1-16) */ + L_coeff_out[i] = L_add(L_shl(L_tmp0, qout - 10), L_deposit_l(lshr(lsb, 10 + 16 - qout))); + move32();/* Qout (10+qout-10) */ + } + ELSE + { + L_tmp0 = L_mult0(noise_level, Random(seed)); /* Q30 (15+15) */ + tmp = round_fx(L_tmp0); /* Q14 (30-16) */ + Mpy_32_16_ss(L_normq, tmp, &L_tmp0, &lsb); /* Q13 (14+14+1-16) */ + L_coeff_out[i] = L_shr(L_tmp0,13 - qout); + move32();/* Qout (13-(13-qout)) */ + } + } +} + + +/*--------------------------------------------------------------------------* + * hq_generic_fine_fx() + * + * Prepare HQ GENERIC HF fine structure + *--------------------------------------------------------------------------*/ +void hq_generic_fine_fx( + Word16 *coeff, /* i : coded/noisefilled normalized spectrum */ + const Word16 last_sfm, /* i : Last coded band */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + Word16 *bwe_seed, /* i/o: random seed for generating BWE input */ + Word16 *coeff_out1 /* o : HQ GENERIC input */ +) +{ + Word16 sfm; + Word16 i; + + FOR(sfm = 0; sfm <= last_sfm; sfm++) + { + FOR(i = sfm_start[sfm]; i < sfm_end[sfm]; i++) + { + IF(coeff[i] == 0) + { + coeff_out1[i] = -2048; + move16(); + if (Random(bwe_seed) > 0) + { + coeff_out1[i] = 2048; + move16(); + } + } + ELSE + { + coeff_out1[i] = coeff[i]; + move16(); + } + } + } + + return; +} + +/*--------------------------------------------------------------------------* + * overlap_hq_bwe_fx() + * + * Overlapping at the boundary between HQ core and BWE + *--------------------------------------------------------------------------*/ +static void overlap_hq_bwe_fx( + const Word32 *hq_swb_overlap_buf, /* i : spectrum from HQ core */ + Word32 *coeff_out, /* i/o: spectrum from BWE, overlapped output */ + const Word16 n_swb_overlap_offset, /* i : starting offset of overlapping */ + const Word16 n_swb_overlap, /* i : length of overlapping */ + const Word16 *R, + const Word16 num_env_bands, + const Word16 num_sfm, + const Word16 *sfm_end +) +{ + Word16 i; + Word16 weighting; + Word16 step; + Word16 exp, tmp, n_band; + + IF(R[sub(num_env_bands, 1)] != 0) + { + Copy32(hq_swb_overlap_buf, &coeff_out[n_swb_overlap_offset], n_swb_overlap); + } + ELSE + { + exp = norm_s(n_swb_overlap); + tmp = div_s(16384, shl(n_swb_overlap, exp));/*15 + 14 - exp */ + tmp = shr(tmp, sub(14, exp));/*15 */ + step = mult_r(tmp, 32767);/*15 */ + weighting = 32767; + move16(); + FOR(i = 0; i < n_swb_overlap; i++) + { + coeff_out[add(n_swb_overlap_offset,i)] = L_add(coeff_out[add(n_swb_overlap_offset,i)], + Mult_32_16(L_sub(hq_swb_overlap_buf[i], coeff_out[add(n_swb_overlap_offset,i)]), weighting)); + move32(); + weighting = sub(weighting, step); + } + } + + FOR(n_band = num_env_bands; n_band < num_sfm; n_band++) + { + IF(R[n_band] != 0) + { + FOR(i = sfm_end[sub(n_band, 1)]; i < sfm_end[n_band]; ++i) + { + coeff_out[i] = hq_swb_overlap_buf[sub(i, n_swb_overlap_offset)]; + move32(); + } + } + } + return; +} + +/*--------------------------------------------------------------------------* + * map_hq_generic_fenv_norm() + * + * mapping high frequency envelope to high band norm + *--------------------------------------------------------------------------*/ +void map_hq_generic_fenv_norm_fx( + const Word16 hqswb_clas, + const Word16 *hq_generic_fenv, /* Q1, frequency-domain BWE envelope */ + Word16 *ynrm, + Word16 *normqlg2, + const Word16 num_env_bands, + const Word16 nb_sfm, + const Word16 hq_generic_offset +) +{ + Word32 env_fl[17];/*Q10 */ + Word16 i; + + set32_fx(env_fl, 0, 17); + + IF(EQ_16(hq_generic_offset, 144)) + { + env_fl[0] = L_shl(hq_generic_fenv[1], 7); + move32(); + env_fl[1] = L_add(L_mult0(hq_generic_fenv[2], 85), L_mult0(hq_generic_fenv[3], 43)); + move32(); + env_fl[2] = L_add(L_mult0(hq_generic_fenv[3], 85), L_mult0(hq_generic_fenv[4], 43)); + move32(); + env_fl[3] = L_add(L_mult0(hq_generic_fenv[4], 43), L_mult0(hq_generic_fenv[5], 85)); + move32(); + env_fl[4] = L_add(L_mult0(hq_generic_fenv[5], 43), L_mult0(hq_generic_fenv[6], 85)); + move32(); + env_fl[5] = L_shl(hq_generic_fenv[7], 7); + move32(); + env_fl[6] = L_add(L_mult0(hq_generic_fenv[8], 96), L_mult0(hq_generic_fenv[9], 32)); + move32(); + env_fl[7] = L_add(L_mult0(hq_generic_fenv[9], 96), L_mult0(hq_generic_fenv[10], 32)); + move32(); + env_fl[8] = L_add(L_mult0(hq_generic_fenv[10], 32), L_mult0(hq_generic_fenv[11], 96)); + move32(); + } + ELSE + { + env_fl[0] = L_add(L_mult0(hq_generic_fenv[0],43),L_mult0(hq_generic_fenv[1],85)); + move32(); + env_fl[1] = L_add(L_mult0(hq_generic_fenv[1],43),L_mult0(hq_generic_fenv[2],85)); + move32(); + env_fl[2] = L_shl(hq_generic_fenv[3],7); + move32(); + env_fl[3] = L_add(L_mult0(hq_generic_fenv[4],85),L_mult0(hq_generic_fenv[5],43)); + move32(); + env_fl[4] = L_add(L_mult0(hq_generic_fenv[5],85),L_mult0(hq_generic_fenv[6],43)); + move32(); + env_fl[5] = L_add(L_mult0(hq_generic_fenv[6],43),L_mult0(hq_generic_fenv[7],85)); + move32(); + env_fl[6] = L_add(L_mult0(hq_generic_fenv[7],43),L_mult0(hq_generic_fenv[8],85)); + move32(); + env_fl[7] = L_add(L_mult0(hq_generic_fenv[8],43),L_mult0(hq_generic_fenv[9],85)); + move32(); + env_fl[8] = L_add(L_mult0(hq_generic_fenv[9],43),L_mult0(hq_generic_fenv[10],85)); + move32(); + env_fl[9] = L_add(L_mult0(hq_generic_fenv[10],32),L_mult0(hq_generic_fenv[11],96)); + move32(); + env_fl[10] = L_shl(hq_generic_fenv[12],7); + move32(); + env_fl[11] = L_shl(hq_generic_fenv[13],7); + move32(); + } + + IF(EQ_16(hqswb_clas, HQ_GEN_FB)) + { + IF(EQ_16(hq_generic_offset, 144)) + { + env_fl[9] = L_shl(hq_generic_fenv[12], 7); + move32(); + env_fl[10] = L_add(L_mult0(hq_generic_fenv[12], 32), L_mult0(hq_generic_fenv[13], 96)); + move32(); + env_fl[11] = L_add(L_mult0(hq_generic_fenv[13], 64), L_mult0(hq_generic_fenv[14], 64)); + move32(); + env_fl[12] = L_shl(hq_generic_fenv[12], 7); + move32(); + env_fl[13] = env_fl[12]; + move32(); + } + ELSE + { + env_fl[12] = L_shl(hq_generic_fenv[14],7); + move32(); + env_fl[13] = L_add(L_mult0(hq_generic_fenv[14],32),L_mult0(hq_generic_fenv[15],96)); + move32(); + env_fl[14] = L_add(L_mult0(hq_generic_fenv[15],64),L_mult0(hq_generic_fenv[16],64)); + move32(); + env_fl[15] = L_shl(hq_generic_fenv[16],7); + move32(); + env_fl[16] = env_fl[15]; + move32(); + } + } + + logqnorm_2_fx(env_fl, 40, num_env_bands, nb_sfm, ynrm + num_env_bands, normqlg2 + num_env_bands, thren_fx); + + FOR(i = num_env_bands; i < nb_sfm; ++i) + { + normqlg2[i] = dicnlg2[s_min(add(ynrm[i], 10), 39)]; + move16(); + } + return; +} + +static void update_rsubband_fx(const Word16 nb_sfm, + Word16 *Rsubband, /* Q3 */ + Word16 b_add_bits_denv +) +{ + Word16 i; + + /* updating bit allocation */ + WHILE(b_add_bits_denv > 0) + { + i = sub(nb_sfm, 1); + WHILE(b_add_bits_denv > 0 && i >= 0) + { + IF(GT_16(Rsubband[i], 24)) + { + Rsubband[i] = sub(Rsubband[i], 8); + move16(); + b_add_bits_denv = sub(b_add_bits_denv, 1); + } + i = sub(i, 1); + } + } + + return; +} + +Word16 get_nor_delta_hf_fx( + Decoder_State_fx *st, + Word16 *ynrm, + Word16 *Rsubband, /* Q3 */ + const Word16 num_env_bands, + const Word16 nb_sfm, + const Word16 core_sfm +) +{ + Word16 i; + Word16 delta, bitsforDelta, add_bits_denv; + + add_bits_denv = 0; + move16(); + IF(GE_16(core_sfm, num_env_bands)) + { + bitsforDelta = (Word16)get_next_indice_fx(st, 2); + bitsforDelta = add(bitsforDelta, 2); + add_bits_denv = add(add_bits_denv, 2); + + FOR(i = num_env_bands; i < nb_sfm; ++i) + { + IF(Rsubband[i] != 0) + { + delta = (Word16)get_next_indice_fx(st, bitsforDelta); + ynrm[i] = add(ynrm[i], sub(delta, (shl(1, sub(bitsforDelta, 1))))); + move16(); + + /* safety check in case of bit errors */ + test(); + if (ynrm[i] < 0 || GT_16(ynrm[i], 39)) + { + ynrm[i] = 39; + move16(); + st->BER_detect = 1; + move16(); + } + /*ynrm[i] += delta - (1<<(bitsforDelta-1));*/ + add_bits_denv = add(add_bits_denv, bitsforDelta); + } + } + update_rsubband_fx(nb_sfm, Rsubband, add_bits_denv); + } + return add_bits_denv; +} +/*-------------------------------------------------------------------* +* calc_nor_delta_hf() +* +* +*--------------------------------------------------------------------------*/ +Word16 calc_nor_delta_hf_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word32* t_audio, /* i : transform-domain coefficients */ + Word16* ynrm, /* i/o: norm indices */ + Word16* Rsubband, /* i/o: sub-band bit allocation */ + const Word16 num_env_bands, /* i : Number coded envelope bands */ + const Word16 nb_sfm, /* i : Number of envelope bands */ + const Word16* sfmsize, /* i : band length */ + const Word16* sfm_start, /* i : Start index of bands */ + const Word16 core_sfm /* i : index of the end band for core */ +) +{ + Word16 i; + Word16 ynrm_t[44], normqlg2_t[44]; + Word16 delta, max_delta, min_delta, bitsforDelta, add_bits_denv; + + max_delta = -100; + move16(); + calc_norm_fx(t_audio, 12, ynrm_t, normqlg2_t, 0, nb_sfm, sfmsize, sfm_start); + add_bits_denv = 0; + move16(); + FOR(i = num_env_bands; i < nb_sfm; ++i) + { + IF(Rsubband[i] != 0) + { + delta = sub(ynrm_t[i], ynrm[i]); + IF(delta > 0) + { + delta = add(delta, 1); + } + ELSE + { + delta = negate(delta); + } + if (GT_16(delta, max_delta)) + { + max_delta = delta; + move16(); + } + } + } + IF(GE_16(core_sfm, num_env_bands)) + { + IF(LT_16(max_delta, 16)) + { + bitsforDelta = 2; + move16(); + FOR(; max_delta >= 2; max_delta >>= 1) + { + bitsforDelta = add(bitsforDelta, 1); + } + } + ELSE + { + bitsforDelta = 5; + move16(); + } + max_delta = sub(shl(1, sub(bitsforDelta, 1)), 1); + min_delta = negate(add(max_delta, 1)); + + /* updating norm & storing delta norm */ + add_bits_denv = 2; + move16(); + push_indice_fx(hBstr, IND_DELTA_ENV_HQ, sub(bitsforDelta, 2), 2); + FOR(i = num_env_bands; i < nb_sfm; ++i) + { + IF(Rsubband[i] != 0) + { + delta = sub(ynrm_t[i], ynrm[i]); + IF(GT_16(delta, max_delta)) + { + delta = max_delta; + move16(); + } + ELSE if (LT_16(delta, min_delta)) + { + delta = min_delta; + move16(); + } + push_indice_fx(hBstr, IND_DELTA_ENV_HQ, delta - min_delta, bitsforDelta); + ynrm[i] = add(ynrm[i], delta); + move16(); + add_bits_denv = add(add_bits_denv, bitsforDelta); + } + } + + /* updating bit allocation */ + update_rsubband_fx(nb_sfm, Rsubband, add_bits_denv); + } + return add_bits_denv; +} + + +/*-------------------------------------------------------------------* +* hq_bwe_fx() +* +* HQ GENERIC +*--------------------------------------------------------------------------*/ +void hq_bwe_fx( + const Word16 HQ_mode, /* i : HQ mode */ + Word32* coeff_out1, /* i/o: BWE input & temporary buffer */ + const Word16* hq_generic_fenv, /* i : SWB frequency envelopes */ + Word32* coeff_out, /* o : SWB signal in MDCT domain */ + const Word16 hq_generic_offset, /* i : frequency offset for representing hq generic*/ + Word16* prev_L_swb_norm, /* i/o: last normalize length */ + const Word16 hq_generic_exc_clas, /* i : hq generic hf excitation class */ + const Word16* sfm_end, /* i : End of bands */ + const Word16 num_sfm, /* i : Number of bands */ + const Word16 num_env_bands, /* i : Number of coded envelope bands */ + const Word16* R /* i : Bit allocation */ +) +{ + Word16 n_swb_overlap_offset, n_swb_overlap; + Word32 hq_swb_overlap_buf_fx[L_FRAME32k]; + + n_swb_overlap_offset = add(swb_bwe_subband[0], hq_generic_offset); + n_swb_overlap = sub(sfm_end[sub(num_env_bands, 1)], n_swb_overlap_offset); + + + Copy32(&coeff_out[n_swb_overlap_offset], hq_swb_overlap_buf_fx, sub(add(n_swb_overlap, sfm_end[sub(num_sfm, 1)]), sfm_end[sub(num_env_bands, 1)])); + + hq_generic_decoding_fx(HQ_mode, coeff_out1, hq_generic_fenv, coeff_out, hq_generic_offset, prev_L_swb_norm, hq_generic_exc_clas, R); + + overlap_hq_bwe_fx(hq_swb_overlap_buf_fx, coeff_out, n_swb_overlap_offset, n_swb_overlap, R, num_env_bands, num_sfm, sfm_end); + + return; +} + +/*--------------------------------------------------------------------------* + * hq_wb_nf_bwe() + * + * HQ WB noisefill and BWE + *--------------------------------------------------------------------------*/ + +void hq_wb_nf_bwe_fx( + const Word16 *coeff_fx, /* i : coded/noisefilled normalized spectrum */ + const Word16 is_transient, + const Word16 prev_bfi, /* i : previous bad frame indicator */ + const Word32 *L_normq_v, + const Word16 num_sfm, /* i : Number of subbands */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + const Word16 *sfmsize, /* i : Subband band width */ + const Word16 last_sfm, /* i : last coded subband */ + const Word16 *R, /* i : bit allocation */ + const Word16 prev_is_transient, /* i : previous transient flag */ + Word32 *prev_normq_fx, /* i/o: previous norms */ + Word32 *prev_env_fx, /* i/o: previous noise envelopes */ + Word16 *bwe_seed, /* i/o: random seed for generating BWE input */ + Word32 *prev_coeff_out_fx, /* i/o: decoded spectrum in previous frame */ + Word16 *prev_R, /* i/o: bit allocation info. in previous frame */ + Word32 *L_coeff_out, /* o : coded/noisefilled spectrum */ + Word16 *prev_env_Q +) +{ + Word16 i; + Word16 sfm; + Word16 total_bit; + Word16 num; + Word32 env_fx, peak_fx, fabs_coeff_out_fx, min_coef_fx; + Word32 L_tmp1, L_tmp2 = 0, L_tmp3, L_tmp4; + Word16 tmp1, exp = 0, exp1, exp2, exp3, harm_para_fx, sharp_fx, step_fx, alfa_fx = 4096; + Word32 avrg_norm_fx, prev_avrg_norm_fx; + Word16 bitalloc_var_fx; + Word16 tmp; + Word32 L_tmp; + Word32 mean_fx; + + IF(is_transient == 0) + { + IF(EQ_16(prev_bfi, 1)) + { + Copy32(L_normq_v, prev_normq_fx, SFM_N_WB); + } + + /* the variance of bit allocation */ + total_bit = 0; + bitalloc_var_fx = 0; + FOR(sfm = 8; sfm <= last_sfm; sfm++) + { + tmp = abs_s(sub(R[sfm], R[sub(sfm, 1)])); + bitalloc_var_fx = add(bitalloc_var_fx, tmp); + total_bit = add(total_bit, R[sfm]); + } + test(); + IF(GT_16(last_sfm, 8) && total_bit > 0) + { + exp = norm_s(total_bit); + tmp = shl(total_bit, exp);/*Q(exp) */ + tmp = div_s(16384, tmp);/*Q(15+14-exp) */ + L_tmp = L_mult(tmp, bitalloc_var_fx); /*Q(29-exp+1) */ +#ifdef BASOP_NOGLOB + bitalloc_var_fx = round_fx_sat(L_shl_sat(L_tmp, exp));/*Q14 */ +#else + bitalloc_var_fx = round_fx(L_shl(L_tmp, exp));/*Q14 */ +#endif + } + ELSE + { + bitalloc_var_fx = 0; /*Q14 */ + } + /* calculate the peak-average ratio of saturable subbands */ + num = 0; + sharp_fx = 0; + FOR(sfm = last_sfm; sfm >= 8; sfm--) + { + tmp = shl(sfmsize[sfm], 9);/*Q9 */ + tmp = mult(rat_fx[sfm], tmp);/*Q(14+9-15=8) */ +#ifdef BASOP_NOGLOB + IF(GE_16(shl_sat(R[sfm], 8), tmp)) +#else + IF(GE_16(shl(R[sfm], 8), tmp)) +#endif + { + peak_fx = 0; + move16(); + mean_fx = 0; + move16(); + FOR(i = sfm_start[sfm]; i < sfm_end[sfm]; i++) + { + fabs_coeff_out_fx = L_abs(L_coeff_out[i]); +#ifdef BASOP_NOGLOB + mean_fx = L_add_sat(mean_fx, fabs_coeff_out_fx);/*Q12 */ +#else + mean_fx = L_add(mean_fx, fabs_coeff_out_fx);/*Q12 */ +#endif + if (GT_32(fabs_coeff_out_fx, peak_fx)) + { + peak_fx = fabs_coeff_out_fx;/*Q12 */ + move32(); + } + } + + IF(mean_fx != 0) + { + exp = norm_l(mean_fx); +#ifdef BASOP_NOGLOB + mean_fx = L_shl_sat(mean_fx, exp);/*Q(exp+12) */ + tmp = round_fx_sat(mean_fx);/*Q(exp-4) */ +#else + mean_fx = L_shl(mean_fx, exp);/*Q(exp+12) */ + tmp = round_fx(mean_fx);/*Q(exp-4) */ +#endif + tmp = div_s(16384, tmp); /*Q(15+14-exp+4 = 33-exp) */ + L_tmp = Mult_32_16(peak_fx, tmp);/*Q(12+33-exp-15 = 30-exp) */ + tmp = shl(sfmsize[sfm], 9);/*Q9 */ + L_tmp = Mult_32_16(L_tmp, tmp);/*Q(30-exp+9-15 = 24-exp) */ + tmp = round_fx(L_shl(L_tmp, exp));/*Q8 */ + sharp_fx = add(sharp_fx, tmp); + } + num = add(num, 1); + } + } + test(); + IF(num != 0 && sharp_fx != 0) + { + num = add(num, num); + exp = norm_s(sharp_fx); + sharp_fx = shl(sharp_fx, exp);/*Q(8+exp) */ + tmp = div_s(16384, sharp_fx);/*Q(21-exp) */ + L_tmp = L_mult(num, tmp);/*Q(22-exp) */ + sharp_fx = round_fx(L_shl(L_tmp, add(8, exp)));/*Q14 */ + } + ELSE + { + sharp_fx = 16384; + move16();/*Q14 = 1 */ + } + harm_para_fx = sharp_fx; + move16();/*Q14 */ + + IF(last_sfm == 0) + { + tmp = 0; + move16(); + } + ELSE + { + tmp = div_s(1,last_sfm);/*Q15 */ + } + + L_tmp = L_mult(5, sharp_fx);/*Q15 */ + L_tmp = Mult_32_16(L_tmp, tmp);/*Q15 */ +#ifdef BASOP_NOGLOB + step_fx = round_fx_sat(L_shl_sat(L_tmp, 16));/*Q15 */ +#else + step_fx = round_fx(L_shl(L_tmp, 16));/*Q15 */ +#endif + alfa_fx = 20480; + move16();/*Q13 = 2.5 */ + /* fill noise for the insaturable subbands */ + FOR(sfm = 0; sfm < num_sfm; sfm++) + { + env_fx = L_deposit_l(0); + L_tmp2 = L_deposit_l(0); + exp = 0; + move16(); + test(); + IF(R[sfm] != 0 && LT_16(R[sfm], shl(mult(24756, sfmsize[sfm]), 1))) + { + /* calculate the energy of the undecoded coefficients */ + env_fx = L_deposit_l(0); + exp1 = norm_l(L_normq_v[sfm]); + L_tmp4 = L_shl(L_normq_v[sfm], exp1); /*14+exp1 */ + L_tmp1 = Mult_32_32(L_tmp4, L_tmp4); /*2*exp1-3 14+exp1+14+exp1 -31 */ + L_tmp2 = L_deposit_l(0); + peak_fx = L_deposit_l(0); + min_coef_fx = 0x7fffffff; + move32(); + + FOR(i = sfm_start[sfm]; i < sfm_end[sfm]; i++) + { + fabs_coeff_out_fx = L_abs(L_coeff_out[i]); + test(); + if (LT_32(fabs_coeff_out_fx, min_coef_fx) && L_coeff_out[i] != 0) + { + min_coef_fx = fabs_coeff_out_fx; + move32(); + } + if (GT_32(fabs_coeff_out_fx, peak_fx)) + { + peak_fx = fabs_coeff_out_fx; + move32(); + } + } + + exp2 = norm_l(peak_fx); + FOR(i = sfm_start[sfm]; i < sfm_end[sfm]; i++) + { + L_tmp4 = L_shl(L_coeff_out[i], exp2); /*12+exp2 */ + L_tmp3 = L_shr(Mult_32_32(L_tmp4, L_tmp4), 4);/*2*exp2-7-4 12+exp2+12+exp2-31-4 */ + L_tmp2 = L_add(L_tmp2, L_tmp3); /*2*exp2-11 */ + } + + tmp1 = div_s(1, sfmsize[sfm]); /*15 */ + L_tmp4 = Mult_32_16(L_tmp2, tmp1);/*2*exp2-11 2*exp2-7+15+1-16 */ + + exp = norm_l(L_tmp1); + L_tmp1 = L_shl(L_tmp1, exp);/*exp + 2*exp1 - 3 */ + exp1 = sub(add(exp, shl(exp1, 1)), 3); + + exp = norm_l(L_tmp4); + L_tmp4 = L_shl(L_tmp4, exp);/*exp + 2*exp1 - 3 */ + exp2 = sub(add(exp, shl(exp2, 1)), 11); + exp = s_min(exp1, exp2); + + L_tmp1 = L_shl(L_tmp1, sub(exp, exp1)); + L_tmp4 = L_shl(L_tmp4, sub(exp, exp2)); + env_fx = L_sub(L_tmp1, L_tmp4); /*exp */ + exp1 = norm_l(env_fx); + env_fx = L_shl(env_fx, exp1);/*exp + exp1 */ + exp = add(exp, exp1); + + IF(env_fx > 0) + { + IF(sfm == 0) + { + avrg_norm_fx = L_add(L_shr(L_normq_v[0], 1), L_shr(L_normq_v[1], 1));/*13 */ + avrg_norm_fx = L_add(avrg_norm_fx, L_shr(L_normq_v[2], 1));/*13 */ + prev_avrg_norm_fx = L_add(L_shr(prev_normq_fx[0], 1), L_shr(prev_normq_fx[1], 1));/*13 */ + prev_avrg_norm_fx = L_add(prev_avrg_norm_fx, L_shr(prev_normq_fx[2], 1));/*13 */ + } + ELSE IF(EQ_16(sfm, 25)) + { + avrg_norm_fx = L_add(L_shr(L_normq_v[23], 1), L_shr(L_normq_v[24], 1));/*13 */ + avrg_norm_fx = L_add(avrg_norm_fx, L_shr(L_normq_v[25], 1));/*13 */ + prev_avrg_norm_fx = L_add(L_shr(prev_normq_fx[23], 1), L_shr(prev_normq_fx[24], 1));/*13 */ + prev_avrg_norm_fx = L_add(prev_avrg_norm_fx, L_shr(prev_normq_fx[25], 1));/*13 */ + } + ELSE + { + avrg_norm_fx = L_add(L_shr(L_normq_v[sub(sfm,1)],1),L_shr(L_normq_v[sfm],1));/*13 */ + avrg_norm_fx = L_add(avrg_norm_fx,L_shr(L_normq_v[sfm + 1],1));/*13 */ + prev_avrg_norm_fx = L_add(L_shr(prev_normq_fx[sub(sfm,1)],1),L_shr(prev_normq_fx[sfm],1));/*13 */ + prev_avrg_norm_fx = L_add(prev_avrg_norm_fx,L_shr(prev_normq_fx[add(sfm,1)],1));/*13 */ + } + + test(); + test(); + IF((GT_16(bitalloc_var_fx, 4915) || LT_32(L_normq_v[sfm], peak_fx)) && peak_fx != 0) + { + Word16 exp_p; + exp_p = norm_l(peak_fx); + exp = sub(31, exp); + env_fx = Isqrt_lc(env_fx, &exp); + L_tmp1 = Mult_32_32(env_fx, L_shl(peak_fx, exp_p));/*12+exp2-exp 31-exp+12+exp1-31 */ + L_tmp2 = Mult_32_16(avrg_norm_fx, harm_para_fx);/*12 13 + 14 + 1 -16 */ + exp1 = norm_l(L_tmp1); + L_tmp1 = L_shl(L_tmp1, exp1);/* 12+exp2-exp+exp1 */ + exp = add(sub(12, exp), add(exp1, exp_p)); + L_tmp2 = Div_32(L_tmp2, extract_h(L_tmp1), extract_l(L_tmp1)); + exp = sub(43, exp); + } + ELSE + { + L_tmp1 = Mult_32_16(L_normq_v[sfm],alfa_fx);/*12 13 + 14 + 1 -16 */ + IF(LT_32(L_tmp1,peak_fx)) + { + exp = sub(31,exp); + env_fx = Isqrt_lc(env_fx,&exp); + exp1 = norm_l(env_fx); + env_fx = L_shl(env_fx,exp1);/* 31-exp+exp1 */ + exp = add(sub(31,exp),exp1); + L_tmp1 = (Word32)sharp_fx; + L_tmp2 = Div_32(L_tmp1, extract_h(env_fx), extract_l(env_fx)); /* 45-exp 14 - exp + 31 //39-exp 8 - exp + 31 */ + exp = sub(45,exp); + exp1 = norm_l(peak_fx); + L_tmp1 = L_shl(peak_fx,exp1); /*12 + exp1 */ + L_tmp1 = Div_32(L_tmp2,extract_h(L_tmp1), extract_l(L_tmp1)); /* exp - (12 + exp1) +31 */ + L_tmp2 = Mult_32_32(L_tmp2,L_tmp1);/*2*exp+exp1-12 exp +exp - (12 + exp1) +31 - 31 */ + exp = sub(add(shl(exp,1),exp1),12); + } + ELSE + { + exp = sub(31,exp); + env_fx = Isqrt_lc(env_fx,&exp); + exp1 = norm_l(env_fx); + env_fx = L_shl(env_fx,exp1);/* 31-exp+exp1 */ + exp = add(sub(31,exp),exp1); + L_tmp1 = (Word32)(sharp_fx); + L_tmp2 = Div_32(L_tmp1, extract_h(env_fx), extract_l(env_fx)); /* 45-exp 14 - exp + 31 //39-exp 8 - exp + 31 */ + exp = sub(45,exp); + } + +#ifdef BASOP_NOGLOB + sharp_fx = add_sat(sharp_fx,shr(step_fx,1)); +#else + sharp_fx = add(sharp_fx,shr(step_fx,1)); +#endif + } + + IF(GT_32(L_tmp2, L_shl(min_coef_fx, sub(exp, 13))))/*exp */ + { + L_tmp2 = L_shr(min_coef_fx, 1); + exp = 12; + move16(); + } + + IF(EQ_16(prev_bfi, 1)) + { + prev_env_Q[sfm] = exp; + move16(); + prev_env_fx[sfm] = L_tmp2; + move32(); + } + /* smooth the noise magnitudes between inter-frame */ + test(); + test(); + IF(GT_32(prev_avrg_norm_fx, L_shr(avrg_norm_fx, 1)) && LT_32(prev_avrg_norm_fx, L_shl(avrg_norm_fx, 1)) && prev_is_transient == 0) + { + exp1 = norm_l(prev_env_fx[sfm]); + L_tmp1 = L_shl(prev_env_fx[sfm], exp1);/* prev_env_Q[sfm] +exp1 */ + + exp2 = norm_l(L_tmp2); + L_tmp3 = L_shl(L_tmp2, exp2);/* exp +exp2 */ + exp3 = s_min(add(prev_env_Q[sfm], exp1), add(exp, exp2)); + + L_tmp1 = L_shl(L_tmp1, sub(sub(exp3, prev_env_Q[sfm]), exp1)); /*exp3 */ + L_tmp3 = L_shl(L_tmp3, sub(sub(exp3, exp), exp2)); /*exp3 */ + L_tmp2 = L_add(L_shr(L_tmp1, 1), L_shr(L_tmp3, 1));/*exp3 */ + exp = exp3; + move16(); + } + FOR(i = sfm_start[sfm]; i < sfm_end[sfm]; i++) + { + IF(coeff_fx[i] == 0) + { + tmp1 = Random(bwe_seed);/*Q15 */ + L_tmp1 = Mult_32_16(L_tmp2, tmp1);/*exp exp+15+1 -16 */ + L_tmp1 = L_shl(L_tmp1, sub(12, exp)); + L_coeff_out[i] = L_tmp1; + move32(); + } + } + } + ELSE + { + exp = 0; + move16(); + L_tmp2 = L_deposit_l(0); + } + } + ELSE IF(R[sfm] == 0) + { + /* fill random noise for 0 bit subbands */ + FOR(i = sfm_start[sfm]; i < sfm_end[sfm]; i++) + { + IF(coeff_fx[i] == 0) + { + tmp1 = Random(bwe_seed);/*Q15 */ + L_tmp1 = Mult_32_16(L_normq_v[sfm], tmp1);/*14 14+15+1 -16 */ + L_tmp1 = L_shr(L_tmp1, 2);/* */ + L_coeff_out[i] = L_tmp1; + move32(); + } + } + L_tmp2 = L_normq_v[sfm]; + move32(); + exp = 14; + move16(); + } + + test(); + test(); + test(); + test(); + IF(EQ_16(sfm, sub(SFM_N_WB, 1)) && prev_is_transient == 0 && GT_32(prev_normq_fx[sfm], L_shr(L_normq_v[sfm], 1)) + && LT_32(prev_normq_fx[sfm], L_shl(L_normq_v[sfm], 1)) && LE_16(bitalloc_var_fx, 4915)) + { + Word32 *p_prev_coeff_out = prev_coeff_out_fx; + FOR(i = add(sfm_start[sfm], 12); i < sfm_end[sfm]; i++) + { + test(); + test(); + test(); + test(); + IF(GT_32(L_abs(L_coeff_out[i]), L_shl(L_abs(*p_prev_coeff_out), 2)) + || LT_32(L_abs(L_coeff_out[i]), L_shr(L_abs(*p_prev_coeff_out), 2)) + || ((R[sfm] == 0 || *prev_R == 0) && add(R[sfm], *prev_R) != 0)) + { + L_tmp = L_add(L_shr(L_abs(L_coeff_out[i]), 1), L_shr(L_abs(*p_prev_coeff_out), 1)); + + if (L_coeff_out[i] <= 0) + { + L_tmp = L_negate(L_tmp); + } + L_coeff_out[i] = L_tmp; + move32(); + } + p_prev_coeff_out++; + } + } + prev_env_Q[sfm] = exp; + move16(); + prev_env_fx[sfm] = L_tmp2; + move32(); + } + } + ELSE + { + /* fill random noise for 0 bit subbands of transient frame */ + FOR(sfm = 0; sfm < num_sfm; sfm++) + { + IF(R[sfm] == 0) + { + FOR(i = sfm_start[sfm]; i < sfm_end[sfm]; i++) + { + tmp1 = Random(bwe_seed);/*Q15 */ + L_tmp1 = Mult_32_16(L_normq_v[sfm],tmp1);/*14 14+15+1 -16 */ + L_tmp1 = L_shr(L_tmp1,2);/* */ + L_coeff_out[i] = L_tmp1; + move32(); + } + } + } + set16_fx(prev_env_Q, 0, SFM_N_WB); + set32_fx(prev_env_fx, 0, SFM_N_WB); + } + + Copy32(L_normq_v, prev_normq_fx, SFM_N_WB); + Copy32(L_coeff_out + L_FRAME16k - L_HQ_WB_BWE, prev_coeff_out_fx, L_HQ_WB_BWE); + *prev_R = R[SFM_N_WB - 1]; + + return; +} + +/*--------------------------------------------------------------------------* + * enforce_zero_for_min_envelope_fx() + * + * Detect minimum level of envelope and set corresponding bands to zero + *--------------------------------------------------------------------------*/ + +void enforce_zero_for_min_envelope_fx( + const Word16 hqswb_clas, /* i : HQ coding mode Q0 */ + const Word16 *ynrm, /* i : Envelope indices Q0 */ + Word32 *L_coefsq, /* i/o: Quantized spectrum/zeroed spectrum Q12 */ + const Word16 nb_sfm, /* i : Number of coded sub bands Q0 */ + const Word16 *sfm_start, /* i : Sub band start indices Q0 */ + const Word16 *sfm_end /* i : Sub band end indices Q0 */ +) +{ + Word16 i, j; + + /* prevent non-zero output for all-zero input */ + IF(NE_16(hqswb_clas, HQ_HVQ)) + { + IF(EQ_16(ynrm[0], 31)) + { + FOR(j = sfm_start[0]; j < sfm_end[0]; j++) + { + L_coefsq[j] = L_deposit_l(0); + } + } + + FOR(i = 1; i < nb_sfm; i++) + { + IF(EQ_16(ynrm[i], 39)) + { + FOR(j = sfm_start[i]; j < sfm_end[i]; j++) + { + L_coefsq[j] = L_deposit_l(0); + } + } + } + } + + return; +} + +/*--------------------------------------------------------------------------* + * apply_envelope() + * + * Apply spectral envelope with envelope adjustments + *--------------------------------------------------------------------------*/ + +void apply_envelope_fx( + const Word16 *coeff, /* i/o: Coded/noisefilled normalized spectrum Q12 */ + const Word16 *norm, /* i : Envelope Q0 */ + const Word16 *norm_adj, /* i : Envelope adjustment Q15 */ + const Word16 num_sfm, /* i : Total number of bands Q0 */ + const Word16 last_sfm, /* i : Last coded band Q0 */ + const Word16 HQ_mode, /* i : HQ mode Q0 */ + const Word16 length, /* i : Frame length Q0 */ + const Word16 *sfm_start, /* i : Sub band start indices Q0 */ + const Word16 *sfm_end, /* i : Sub band end indices Q0 */ + Word32 *normq_v, /* o : Envelope with adjustment Q14 */ + Word32 *coeff_out, /* o : coded/noisefilled spectrum Q12 */ + const Word16 *coeff1, /* i : coded/noisefilled spectrum Q12 */ + Word32 *coeff_out1 /* o : coded/noisefilled spectrum Q12 */ +) +{ + Word16 i; + Word16 sfm; + UWord16 lsb; + Word32 normq; + Word32 L_tmp; + Word16 len; + + len = num_sfm; + move16(); + test(); + if (EQ_16(HQ_mode, HQ_GEN_SWB) || EQ_16(HQ_mode, HQ_GEN_FB)) + { + len = add(last_sfm, 1); + } + + IF(EQ_16(length, L_FRAME16k)) + { + FOR(sfm = 0; sfm < num_sfm; sfm++) + { + normq_v[sfm] = dicn_fx[norm[sfm]]; + move16(); + move32(); + /*normq = normq_v[sfm] * norm_adj[sfm]; */ + Mpy_32_16_ss(normq_v[sfm], norm_adj[sfm], &normq, &lsb); /* Q14 (14+15+1-16) */ + + FOR(i = sfm_start[sfm]; i < sfm_end[sfm]; i++) + { + /*coeff_out[i] = coeff[i]*normq; */ + Mpy_32_16_ss(normq, coeff[i], &L_tmp, &lsb); + coeff_out[i] = L_add(L_shl(L_tmp, 1), lshr(lsb, 15)); + move32(); /* Q12 (14+12+1-16)+1 */ + } + } + } + ELSE + { + FOR(sfm = 0; sfm < len; sfm++) + { + normq_v[sfm] = dicn_fx[norm[sfm]]; + move16(); + move32(); + /*normq_v[sfm] *= norm_adj[sfm]; */ + Mpy_32_16_ss(normq_v[sfm], norm_adj[sfm], &normq_v[sfm], &lsb); + move32(); /* Q14 (14+15+1-16) */ + + normq = normq_v[sfm]; + move32(); + FOR(i = sfm_start[sfm]; i < sfm_end[sfm]; i++) + { + /*coeff_out[i] = coeff[i]*normq; */ + Mpy_32_16_ss(normq, coeff[i], &L_tmp, &lsb); + coeff_out[i] = L_add(L_shl(L_tmp, 1), lshr(lsb, 15)); + move32(); /* Q12 (14+12+1-16)+1 */ + } + } + + test(); + IF(EQ_16(HQ_mode, HQ_GEN_SWB) || EQ_16(HQ_mode,HQ_GEN_FB)) + { + FOR(sfm = 0; sfm <= last_sfm; sfm++) + { + normq = normq_v[sfm]; + move32(); + FOR(i = sfm_start[sfm]; i < sfm_end[sfm]; i++) + { + /*coeff_out1[i] = coeff_out1[i]*normq; */ + Mpy_32_16_ss(normq, coeff1[i], &L_tmp, &lsb); + coeff_out1[i] = L_add(L_shl(L_tmp, 1), lshr(lsb, 15)); + move32(); /* Q12 (14+12+1-16)+1 */ + } + } + } + } + + + return; +} + + diff --git a/lib_com/hvq_pvq_bitalloc.c b/lib_com/hvq_pvq_bitalloc.c index 5ff0d3344..daedd9723 100644 --- a/lib_com/hvq_pvq_bitalloc.c +++ b/lib_com/hvq_pvq_bitalloc.c @@ -147,13 +147,13 @@ int16_t hvq_pvq_bitalloc( } env_mean = 2 * ( env_mean * reciprocal ); - if ( band_len_harm[k_max] == 96 ) + if ( band_len_harm_float[k_max] == 96 ) { bit_cost = 61; } else { - QuantaPerDsDirac( band_len_harm[k_max], 1, hBitsN, &bit_cost ); + QuantaPerDsDirac( band_len_harm_float[k_max], 1, hBitsN, &bit_cost ); } diff --git a/lib_com/ifft_rel.c b/lib_com/ifft_rel.c index 597a5d173..1a08533e7 100644 --- a/lib_com/ifft_rel.c +++ b/lib_com/ifft_rel.c @@ -39,13 +39,15 @@ #include "prot.h" #include "rom_com.h" #include "wmc_auto.h" - +#include "prot_fx1.h" +#include "prot_fx2.h" /*-----------------------------------------------------------------* * Local constants *-----------------------------------------------------------------*/ #define N_MAX_FFT 1024 - +#define INV_SQR2_FX 23170 +#define N_MAX_SAS 256 /*---------------------------------------------------------------------* * ifft_rel() * @@ -285,3 +287,366 @@ void ifft_rel( return; } + + +void ifft_rel_fx( + Word16 io[], /* i/o: input/output vector */ + const Word16 n, /* i : vector length */ + const Word16 m /* i : log2 of vector length */ +) +{ + Word16 i, j, k; + Word16 step; + Word16 n2, n4, n8, i0; + Word16 is, id; + Word16 *x, *xi0, *xi1, *xi2, *xi3, *xi4, *xup1, *xdn6, *xup3, *xdn8; + Word16 xt; + Word16 r1; + Word16 t1, t2, t3, t4, t5; + const Word16 *s, *c, *s3, *c3; + + Word16 cc1, cc3, ss1, ss3; + Word16 tmp; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + + /*-----------------------------------------------------------------* + * ifft + *-----------------------------------------------------------------*/ + + x = &io[-1]; + move16(); + n2 = shl(n, 1); + FOR(k = 1; k < m; k++) + { + is = 0; + move16(); + id = n2; + move16(); + n2 = shr(n2, 1); + move16(); + n4 = shr(n2, 2); + move16(); + n8 = shr(n4, 1); + move16(); + tmp = sub(n, 1); + WHILE(LT_16(is, tmp)) + { + xi1 = x + is + 1; + move16(); + xi2 = xi1 + n4; + move16(); + xi3 = xi2 + n4; + move16(); + xi4 = xi3 + n4; + move16(); + + FOR(i = is; i < n; i += id) + { +#ifdef BASOP_NOGLOB + t1 = sub_o(*xi1, *xi3, &Overflow); + *xi1 = add_o(*xi1, *xi3, &Overflow); +#else /* BASOP_NOGLOB */ + t1 = sub(*xi1, *xi3); + *xi1 = add(*xi1, *xi3); +#endif /* BASOP_NOGLOB */ + move16(); +#ifdef BASOP_NOGLOB + *xi2 = shl_o(*xi2, 1, &Overflow); +#else /* BASOP_NOGLOB */ + *xi2 = shl(*xi2, 1); +#endif /* BASOP_NOGLOB */ + move16(); +#ifdef BASOP_NOGLOB + *xi3 = sub_o(t1, shl_o(*xi4, 1, &Overflow), &Overflow); +#else /* BASOP_NOGLOB */ + *xi3 = sub(t1, shl(*xi4, 1)); +#endif /* BASOP_NOGLOB */ + move16(); +#ifdef BASOP_NOGLOB + *xi4 = add_o(t1, shl_o(*xi4, 1, &Overflow), &Overflow); +#else /* BASOP_NOGLOB */ + *xi4 = add(t1, shl(*xi4, 1)); +#endif /* BASOP_NOGLOB */ + move16(); + + IF(NE_16(n4, 1)) + { +#ifdef BASOP_NOGLOB + t1 = mult_r(sub_o(*(xi2 + n8), *(xi1 + n8), &Overflow), INV_SQR2_FX); + t2 = mult_r(add_o(*(xi4 + n8), *(xi3 + n8), &Overflow), INV_SQR2_FX); +#else /* BASOP_NOGLOB */ + t1 = mult_r(sub(*(xi2 + n8), *(xi1 + n8)), INV_SQR2_FX); + t2 = mult_r(add(*(xi4 + n8), *(xi3 + n8)), INV_SQR2_FX); +#endif /* BASOP_NOGLOB */ + +#ifdef BASOP_NOGLOB + *(xi1 + n8) = add_o(*(xi1 + n8), *(xi2 + n8), &Overflow); +#else /* BASOP_NOGLOB */ + *(xi1 + n8) = add(*(xi1 + n8), *(xi2 + n8)); +#endif /* BASOP_NOGLOB */ + move16(); +#ifdef BASOP_NOGLOB + *(xi2 + n8) = sub_o(*(xi4 + n8), *(xi3 + n8), &Overflow); +#else /* BASOP_NOGLOB */ + *(xi2 + n8) = sub(*(xi4 + n8), *(xi3 + n8)); +#endif /* BASOP_NOGLOB */ + move16(); +#ifdef BASOP_NOGLOB + *(xi3 + n8) = negate(shl_o(add_o(t2, t1, &Overflow), 1, &Overflow)); +#else /* BASOP_NOGLOB */ + *(xi3 + n8) = negate(shl(add(t2, t1), 1)); +#endif /* BASOP_NOGLOB */ + move16(); +#ifdef BASOP_NOGLOB + *(xi4 + n8) = shl_o(sub_o(t1, t2, &Overflow), 1, &Overflow); +#else /* BASOP_NOGLOB */ + *(xi4 + n8) = shl(sub(t1, t2), 1); +#endif /* BASOP_NOGLOB */ + move16(); + } + xi1 += id; + move16(); + xi2 += id; + move16(); + xi3 += id; + move16(); + xi4 += id; + move16(); + } + is = sub(shl(id, 1), n2); + id = shl(id, 2); + } + /*Can be acheived with a shr */ + step = N_MAX_SAS / n2; + move16(); + + s = sincos_t_fx + step; + move16(); + c = s + 64; + move16(); + s3 = sincos_t_fx + i_mult2(step, 3); + move16(); + c3 = s3 + 64; + move16(); + FOR(j = 2; j <= n8; j++) + { + cc1 = *c; + move16(); + ss1 = *s; + move16(); + cc3 = *c3; + move16(); + ss3 = *s3; + move16(); + + is = 0; + move16(); + id = shl(n2, 1); + + c += step; + move16(); + s += step; + move16(); + + c3 += 3 * step; + move16(); + s3 += 3 * step; + move16(); + WHILE(LT_16(is, sub(n, 1))) + { + xup1 = x + j + is; + move16(); + xup3 = xup1 + shl(n4, 1); + move16(); + xdn6 = xup3 - shl(j, 1) + 2; + move16(); + + xdn8 = xdn6 + shl(n4, 1); + move16(); + + FOR(i = is; i < n; i += id) + { +#ifdef BASOP_NOGLOB + t1 = sub_o(*xup1, *xdn6, &Overflow); + *xup1 = add_o(*xup1, *xdn6, &Overflow); +#else /* BASOP_NOGLOB */ + t1 = sub(*xup1, *xdn6); + *xup1 = add(*xup1, *xdn6); +#endif /* BASOP_NOGLOB */ + move16(); + xup1 += n4; + move16(); + xdn6 -= n4; + move16(); + +#ifdef BASOP_NOGLOB + t2 = sub_o(*xdn6, *xup1, &Overflow); + *xdn6 = add_o(*xup1, *xdn6, &Overflow); +#else /* BASOP_NOGLOB */ + t2 = sub(*xdn6, *xup1); + *xdn6 = add(*xup1, *xdn6); +#endif /* BASOP_NOGLOB */ + move16(); + + xdn6 += n4; + move16(); +#ifdef BASOP_NOGLOB + t3 = add_o(*xdn8, *xup3, &Overflow); + *xdn6 = sub_o(*xdn8, *xup3, &Overflow); +#else /* BASOP_NOGLOB */ + t3 = add(*xdn8, *xup3); + *xdn6 = sub(*xdn8, *xup3); +#endif /* BASOP_NOGLOB */ + move16(); + + xup3 += n4; + move16(); + xdn8 -= n4; + move16(); + +#ifdef BASOP_NOGLOB + t4 = add_o(*xup3, *xdn8, &Overflow); + *xup1 = sub_o(*xup3, *xdn8, &Overflow); +#else /* BASOP_NOGLOB */ + t4 = add(*xup3, *xdn8); + *xup1 = sub(*xup3, *xdn8); +#endif /* BASOP_NOGLOB */ + move16(); + +#ifdef BASOP_NOGLOB + t5 = sub_o(t1, t4, &Overflow); + t1 = add_o(t1, t4, &Overflow); + t4 = sub_o(t2, t3, &Overflow); + t2 = add_o(t2, t3, &Overflow); + *xup3 = sub_o(mult_r(t1, cc3), mult_r(t2, ss3), &Overflow); +#else /* BASOP_NOGLOB */ + t5 = sub(t1, t4); + t1 = add(t1, t4); + t4 = sub(t2, t3); + t2 = add(t2, t3); + *xup3 = sub(mult_r(t1, cc3), mult_r(t2, ss3)); +#endif /* BASOP_NOGLOB */ + move16(); + xup3 -= n4; + move16(); +#ifdef BASOP_NOGLOB + *xup3 = add_o(mult_r(t5, cc1), mult_r(t4, ss1), &Overflow); +#else /* BASOP_NOGLOB */ + *xup3 = add(mult_r(t5, cc1), mult_r(t4, ss1)); +#endif /* BASOP_NOGLOB */ + move16(); +#ifdef BASOP_NOGLOB + *xdn8 = sub_o(mult_r(t5, ss1), mult_r(t4, cc1), &Overflow); +#else /* BASOP_NOGLOB */ + *xdn8 = sub(mult_r(t5, ss1), mult_r(t4, cc1)); +#endif /* BASOP_NOGLOB */ + move16(); + + xdn8 += n4; + move16(); +#ifdef BASOP_NOGLOB + *xdn8 = add_o(mult_r(t2, cc3), mult_r(t1, ss3), &Overflow); +#else /* BASOP_NOGLOB */ + *xdn8 = add(mult_r(t2, cc3), mult_r(t1, ss3)); +#endif /* BASOP_NOGLOB */ + move16(); + + xup1 -= n4; + move16(); + xup1 += id; + move16(); + xup3 += id; + move16(); + xdn6 += id; + move16(); + xdn8 += id; + move16(); + } + is = sub(shl(id, 1), n2); + id = shl(id, 2); + } + } + } + + /*-----------------------------------------------------------------* + * Length two butterflies + *-----------------------------------------------------------------*/ + + is = 1; + move16(); + id = 4; + move16(); + WHILE(is < n) + { + xi0 = x + is; + move16(); + xi1 = xi0 + 1; + move16(); + + FOR(i0 = is; i0 <= n; i0 += id) + { + r1 = *xi0; + move16(); +#ifdef BASOP_NOGLOB + *xi0 = add_o(r1, *xi1, &Overflow); +#else /* BASOP_NOGLOB */ + *xi0 = add(r1, *xi1); +#endif /* BASOP_NOGLOB */ + move16(); +#ifdef BASOP_NOGLOB + *xi1 = sub_o(r1, *xi1, &Overflow); +#else /* BASOP_NOGLOB */ + *xi1 = sub(r1, *xi1); +#endif + move16(); + xi0 += id; + move16(); + xi1 += id; + move16(); + } + is = sub(shl(id, 1), 1); + id = shl(id, 2); + } + + /*-----------------------------------------------------------------* + * Digit reverse counter + *-----------------------------------------------------------------*/ + + j = 1; + move16(); + FOR(i = 1; i < n; i++) + { + IF(LT_16(i, j)) + { + xt = x[j]; + move16(); + x[j] = x[i]; + move16(); + x[i] = xt; + move16(); + } + k = shr(n, 1); + WHILE(LT_16(k, j)) + { + j = sub(j, k); + k = shr(k, 1); + } + j = add(j, k); + } + + /*-----------------------------------------------------------------* + * Normalization + *-----------------------------------------------------------------*/ + + tmp = div_s(1, n); /*Q15 */ + FOR(i = 1; i <= n; i++) + { + x[i] = mult_r(x[i], tmp); + move16(); + } + + return; +} diff --git a/lib_com/igf_base.c b/lib_com/igf_base.c index 73f7228d0..8ce76a9ad 100644 --- a/lib_com/igf_base.c +++ b/lib_com/igf_base.c @@ -453,9 +453,9 @@ static void IGF_gridSetUp( case IGF_BITRATE_WB_9600: case IGF_BITRATE_WB_13200_CPE: case IGF_BITRATE_WB_16400_CPE: - hGrid->gFactor = 0.800f; - hGrid->fFactor = 0.70f; - hGrid->lFactor = 0.60f; + hGrid->gFactor_flt = 0.800f; + hGrid->fFactor_flt = 0.70f; + hGrid->lFactor_flt = 0.60f; break; case IGF_BITRATE_SWB_13200: case IGF_BITRATE_SWB_16400_CPE: @@ -463,9 +463,9 @@ static void IGF_gridSetUp( case IGF_BITRATE_SWB_16400: case IGF_BITRATE_FB_24400_CPE: case IGF_BITRATE_SWB_24400_CPE: - hGrid->gFactor = 0.930f; - hGrid->fFactor = 0.20f; - hGrid->lFactor = 0.85f; + hGrid->gFactor_flt = 0.930f; + hGrid->fFactor_flt = 0.20f; + hGrid->lFactor_flt = 0.85f; break; case IGF_BITRATE_FB_24400: case IGF_BITRATE_SWB_24400: @@ -475,9 +475,9 @@ static void IGF_gridSetUp( case IGF_BITRATE_SWB_32000: case IGF_BITRATE_SWB_48000_CPE: case IGF_BITRATE_SWB_64000_CPE: - hGrid->gFactor = 0.965f; - hGrid->fFactor = 0.20f; - hGrid->lFactor = 0.85f; + hGrid->gFactor_flt = 0.965f; + hGrid->fFactor_flt = 0.20f; + hGrid->lFactor_flt = 0.85f; break; case IGF_BITRATE_FB_48000: case IGF_BITRATE_SWB_48000: @@ -485,17 +485,17 @@ static void IGF_gridSetUp( case IGF_BITRATE_SWB_64000: case IGF_BITRATE_SWB_80000_CPE: case IGF_BITRATE_SWB_96000_CPE: - hGrid->gFactor = 1.000f; - hGrid->fFactor = 0.20f; - hGrid->lFactor = 1.000f; + hGrid->gFactor_flt = 1.000f; + hGrid->fFactor_flt = 0.20f; + hGrid->lFactor_flt = 1.000f; break; case IGF_BITRATE_SWB_9600: case IGF_BITRATE_SWB_13200_CPE: case IGF_BITRATE_RF_SWB_13200: default: - hGrid->gFactor = 1.000f; - hGrid->fFactor = 0.00f; - hGrid->lFactor = 1.000f; + hGrid->gFactor_flt = 1.000f; + hGrid->fFactor_flt = 0.00f; + hGrid->lFactor_flt = 1.000f; } for ( t = hGrid->nTiles + 1; t < IGF_MAX_TILES; t++ ) diff --git a/lib_com/int_lsp.c b/lib_com/int_lsp.c index 448a97e33..fe802e202 100644 --- a/lib_com/int_lsp.c +++ b/lib_com/int_lsp.c @@ -40,6 +40,8 @@ #include "prot.h" #include "rom_com.h" #include "wmc_auto.h" +#include "prot_fx1.h" +#include "prot_fx2.h" /*---------------------------------------------------------------------* * int_lsp() @@ -95,6 +97,63 @@ void int_lsp( return; } +void int_lsp_fx( + const Word16 L_frame, /* i : length of the frame */ + const Word16 lsp_old[], /* i : LSPs from past frame */ + const Word16 lsp_new[], /* i : LSPs from present frame */ + Word16 *Aq, /* o : LP coefficients in both subframes */ + const Word16 m, /* i : order of LP filter */ + const Word16 *int_coeffs, /* i : interpolation coefficients */ + const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ +) +{ + Word16 lsp[M], fnew, fold; + Word16 i, k; + const Word16 *pt_int_coeffs = NULL; + Word32 L_tmp; + Word16 tmp; + + tmp = shr(L_frame, 6); /*L_frame/L_SUBFR */ + + IF(EQ_16(L_frame, L_FRAME)) + { + pt_int_coeffs = int_coeffs; + move16(); + } + ELSE /* L_frame == L_FRAME16k */ + { + pt_int_coeffs = interpol_frac_16k_fx; + } + FOR(k = 0; k < tmp; k++) + { + fnew = pt_int_coeffs[k]; + move16(); + fold = sub(32767, fnew); /* 1.0 - fac_new */ + if (fold != 0) + fold = add(fold, 1); + FOR(i = 0; i < m; i++) + { + L_tmp = L_mult(lsp_old[i], fold); + L_tmp = L_mac(L_tmp, lsp_new[i], fnew); + if (fold == 0) + L_tmp = L_mac(L_tmp, lsp_new[i], 1); /* 'fnew' should have been 32768 */ + lsp[i] = round_fx(L_tmp); + } + IF(Opt_AMR_WB) + { + E_LPC_f_isp_a_conversion(lsp, Aq, m); + } + ELSE + { + E_LPC_f_lsp_a_conversion(lsp, Aq, m); + } + Aq += (m + 1); + } + + return; +} + + /*---------------------------------------------------------------------* * int_lsp4() * @@ -175,3 +234,80 @@ void int_lsp4( return; } + +void int_lsp4_fx( + const Word16 L_frame, /* i : length of the frame */ + const Word16 lsp_old[], /* i : LSPs from past frame Q15*/ + const Word16 lsp_mid[], /* i : LSPs from mid-frame Q15*/ + const Word16 lsp_new[], /* i : LSPs from present frame Q15*/ + Word16 *Aq, /* o : LP coefficients in both subframes Q12*/ + const Word16 m, /* i : order of LP filter */ + Word16 relax_prev_lsf_interp /* i : relax prev frame lsf interp after erasure */ +) +{ + Word16 lsp[M16k]; + Word16 i, j, k; + Word32 L_tmp; + const Word16 *pt_int_coeffs; + + IF(EQ_16(L_frame, L_FRAME)) + { + IF(EQ_16(relax_prev_lsf_interp, 1)) + { + pt_int_coeffs = interpol_frac_mid_relaxprev_12k8_fx; + } + ELSE IF(EQ_16(relax_prev_lsf_interp, 2)) + { + pt_int_coeffs = interpol_frac_mid_FEC_fx; + } + ELSE IF(EQ_16(relax_prev_lsf_interp, -1)) + { + pt_int_coeffs = interpol_frac_mid_relaxprev_pred_12k8_fx; + } + ELSE + { + pt_int_coeffs = interpol_frac_mid_fx; + } + } + ELSE /* L_frame == L_FRAME16k */ + { + IF(EQ_16(relax_prev_lsf_interp,1)) + { + pt_int_coeffs = interpol_frac_mid_relaxprev_16k_fx; + } + ELSE IF(EQ_16(relax_prev_lsf_interp,2)) + { + pt_int_coeffs = interpol_frac_mid_16k_FEC_fx; + } + ELSE IF(EQ_16(relax_prev_lsf_interp,-1)) + { + pt_int_coeffs = interpol_frac_mid_relaxprev_pred_16k_fx; + } + ELSE + { + pt_int_coeffs = interpol_frac_mid_16k_fx; + } + } + k = sub(shr(L_frame, 6), 1); + FOR(j = 0; j < k; j++) + { + FOR(i = 0; i < m; i++) + { + L_tmp = L_mult(lsp_old[i], *pt_int_coeffs); /*Q31 */ + L_tmp = L_mac(L_tmp, lsp_mid[i], *(pt_int_coeffs + 1)); /*Q31 */ + lsp[i] = mac_r(L_tmp, lsp_new[i], *(pt_int_coeffs + 2)); + move16(); + } + pt_int_coeffs += 3; + move16(); + + E_LPC_f_lsp_a_conversion(lsp, Aq, m); + Aq += (m + 1); + move16(); + } + + /* Last subframe */ + E_LPC_f_lsp_a_conversion(lsp_new, Aq, m); + + return; +} diff --git a/lib_com/interleave_spectrum.c b/lib_com/interleave_spectrum.c index 300295355..424d8acfd 100644 --- a/lib_com/interleave_spectrum.c +++ b/lib_com/interleave_spectrum.c @@ -40,6 +40,8 @@ #include "prot.h" #include "rom_com.h" #include "wmc_auto.h" +#include "prot_fx1.h" +#include "prot_fx2.h" /*--------------------------------------------------------------------------* * interleave_spectrum() @@ -123,6 +125,91 @@ void interleave_spectrum( return; } +void interleave_spectrum_fx( + Word32 *coefs, /* i/o: input and output coefficients Q12 */ + const Word16 length /* i : length of spectrum Q0 */ +) +{ + Word16 i, j, k; + Word32 *p1, *p2, *p3, *p4; + Word32 *p_out; + Word32 coefs_out[L_FRAME48k]; + Word16 sublen[3] = { 240, 160, 80 }; + Word16 grps; + const Word16 *bw; + const Word16 *cnt; + + /* Common inits */ + p1 = coefs; + p_out = coefs_out; +#ifdef SOLVED_COMP_ENC_DEC + IF(EQ_16(length, L_SPEC48k)) +#else + IF(EQ_16(length, L_FRAME48k)) +#endif + { + bw = intl_bw_48; + cnt = intl_cnt_48; + grps = N_INTL_GRP_48; + move16(); + p2 = p1 + sublen[0]; + p3 = p2 + sublen[0]; + p4 = p3 + sublen[0]; + } + ELSE IF(EQ_16(length, L_SPEC32k)) + { + bw = intl_bw_32; + cnt = intl_cnt_32; + grps = N_INTL_GRP_32; + move16(); + p2 = p1 + sublen[1]; + p3 = p2 + sublen[1]; + p4 = p3 + sublen[1]; + } + ELSE /* length == L_SPEC16k */ + { + bw = intl_bw_16; + cnt = intl_cnt_16; + grps = N_INTL_GRP_16; + move16(); + p2 = p1 + sublen[2]; + p3 = p2 + sublen[2]; + p4 = p3 + sublen[2]; + } + + FOR(i = 0; i < grps; i++) + { + FOR(j = 0; j < cnt[i]; j++) + { + FOR(k = 0; k < bw[i]; k++) + { + *p_out++ = *p1++; + move32(); + } + FOR(k = 0; k < bw[i]; k++) + { + *p_out++ = *p2++; + move32(); + } + FOR(k = 0; k < bw[i]; k++) + { + *p_out++ = *p3++; + move32(); + } + FOR(k = 0; k < bw[i]; k++) + { + *p_out++ = *p4++; + move32(); + } + } + } + + /* For FB the interleaved spectrum is 800 samples */ + Copy32(coefs_out, coefs, (Word16)(p_out - coefs_out)); + + return; +} + /*--------------------------------------------------------------------------* * de_interleave_spectrum() @@ -203,3 +290,99 @@ void de_interleave_spectrum( return; } + +void de_interleave_spectrum_fx( + Word32 *coefs, /* i/o: input and output coefficients Q12 */ + const Word16 length /* i : length of spectrum Q0 */ +) +{ + Word16 i, j, k; + Word32 *p1, *p2, *p3, *p4; + Word32 *p_in; + Word32 coefs_out[L_FRAME48k]; + Word16 sublen[] = { 80, 160, 240, 320, 480, 720 }; + Word16 grps; + Word16 l_frame; + const Word16 *bw; + const Word16 *cnt; + + /* common for all groups */ + p1 = coefs_out; + l_frame = length; + move16(); +#ifdef SOLVED_COMP_ENC_DEC + IF(EQ_16(length, L_SPEC48k)) +#else + IF(EQ_16(length, L_FRAME48k)) +#endif + { + bw = intl_bw_48; + cnt = intl_cnt_48; + grps = N_INTL_GRP_48; + move16(); +#ifdef SOLVED_COMP_ENC_DEC + l_frame = L_FRAME48k; + move16(); +#endif + p2 = coefs_out + sublen[2]; /* 240, length/4 */ + p3 = coefs_out + sublen[4]; /* 480, 2*length/4 */ + p4 = coefs_out + sublen[5]; /* 720, 3*length/4 */ + } + ELSE IF(EQ_16(length, L_SPEC32k)) + { + bw = intl_bw_32; + cnt = intl_cnt_32; + grps = N_INTL_GRP_32; + move16(); + + p2 = coefs_out + sublen[1]; /* 160 */ + p3 = coefs_out + sublen[3]; /* 320 */ + p4 = coefs_out + sublen[4]; /* 480 */ + } + ELSE /* length == L_SPEC16k */ + { + bw = intl_bw_16; + cnt = intl_cnt_16; + grps = N_INTL_GRP_16; + move16(); + + p2 = coefs_out + sublen[0]; /* 80 */ + p3 = coefs_out + sublen[1]; /* 160 */ + p4 = coefs_out + sublen[2]; /* 240 */ + } + + set32_fx(coefs_out, 0, L_FRAME48k); + p_in = coefs; + + FOR(i = 0; i < grps; i++) + { + FOR(j = 0; j < cnt[i]; j++) + { + FOR(k = 0; k < bw[i]; k++) + { + *p1++ = *p_in++; + move32(); + } + FOR(k = 0; k < bw[i]; k++) + { + *p2++ = *p_in++; + move32(); + } + FOR(k = 0; k < bw[i]; k++) + { + *p3++ = *p_in++; + move32(); + } + FOR(k = 0; k < bw[i]; k++) + { + *p4++ = *p_in++; + move32(); + } + } + } + + Copy32(coefs_out, coefs, l_frame); + + return; +} + diff --git a/lib_com/interpol.c b/lib_com/interpol.c index 332f34d54..310b4b18b 100644 --- a/lib_com/interpol.c +++ b/lib_com/interpol.c @@ -38,7 +38,9 @@ #include "options.h" #include "prot.h" #include "wmc_auto.h" - +#include "rom_com.h" +#include "prot_fx1.h" +#include "prot_fx2.h" /*-------------------------------------------------------------------* * interpolation() * @@ -75,3 +77,79 @@ float interpolation( return s; } + + +Word32 Interpol_lc_fx( /* o : interpolated value Qx+16 */ + const Word16 *x, /* i : input vector Q0 */ + const Word16 *win, /* i : interpolation window Q14 */ + const Word16 frac, /* i : fraction (0..up_samp) Q0 */ + const Word16 up_samp, /* i : upsampling factor Q0 */ + const Word16 nb_coef /* i : number of coefficients Q0 */ +) +{ + Word16 i; + const Word16 *c1, *c2, *x2; + Word32 L_sum; + + x2 = &x[1]; + c1 = &win[frac]; + c2 = &win[sub(up_samp, frac)]; + { + Word64 L_sum64 = 0; + move64(); + FOR(i = 0; i < nb_coef; i++) + { + /* Using L_mac0 limits the risk of saturation during the loop, saturation may occures after the loop */ + L_sum64 = W_mac0_16_16(L_sum64, *x, *c1); + --x; + L_sum64 = W_mac0_16_16(L_sum64, *x2, *c2); + ++x2; + c2 += up_samp; /* move16() not needed, since the coefficient can be rearrange in bit exact way */ + c1 += up_samp; + } + L_sum = W_sat_l(L_sum64); + } + L_sum = L_shl(L_sum, 1); + + return L_sum; +} + + +Word16 Interpol_4( /* o : interpolated value */ + Word16 * x, /* i : input vector */ + Word16 frac /* i : fraction (-4..+3) */ +) +{ + Word16 i; + Word32 L_sum; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + x = x - L_INTERPOL1 + 1; + + L_sum = L_mult(x[0], (inter4_1_fx + UP_SAMP - 1)[-frac]); + FOR(i = 1; i < 2 * L_INTERPOL1; i++) + { + /* + * Here, additions with UP_SAMP are not counted + * because, the window could easily be modified + * so that the values needed are contiguous. + */ + frac -= UP_SAMP; + L_sum = L_mac(L_sum, x[i], (inter4_1_fx + UP_SAMP - 1)[-frac]); + } + BASOP_SATURATE_WARNING_OFF_EVS + /* Here, saturation might occur by intention */ +#ifdef BASOP_NOGLOB + L_sum = L_shl_o(L_sum, 1, &Overflow); +#else /* BASOP_NOGLOB */ + L_sum = L_shl(L_sum, 1); +#endif /* BASOP_NOGLOB */ + BASOP_SATURATE_WARNING_ON_EVS +#ifdef BASOP_NOGLOB + return round_fx_o(L_sum, &Overflow); +#else /* BASOP_NOGLOB */ + return round_fx(L_sum); +#endif +} diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 7af0edb72..7dbe1f64a 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -404,7 +404,7 @@ void copy_decoder_config( ); void destroy_core_dec( - DEC_CORE_HANDLE hCoreCoder /* i/o: core decoder structure */ + DEC_CORE_HANDLE_FLOAT hCoreCoder /* i/o: core decoder structure */ ); void ivas_destroy_dec( @@ -773,7 +773,7 @@ float rand_triangular_signed( int16_t *seed ); void dtx_read_padding_bits( - DEC_CORE_HANDLE st, + DEC_CORE_HANDLE_FLOAT st, const int16_t num_bits ); @@ -1022,7 +1022,7 @@ ivas_error ivas_ism_metadata_dec( const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ int16_t *ism_extended_metadata_flag, /* i/o: Extended metadata active in renderer */ int16_t *ism_extmeta_cnt, /* i/o: Number of change frames observed */ - DEC_CORE_HANDLE st0 /* i : core-coder handle */ + DEC_CORE_HANDLE_FLOAT st0 /* i : core-coder handle */ ); diff --git a/lib_com/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c index 12c4853bc..7f1329e20 100644 --- a/lib_com/ivas_td_decorr.c +++ b/lib_com/ivas_td_decorr.c @@ -464,7 +464,7 @@ void ivas_td_decorr_process( /* Look-ahead delay */ mvr2r( pcm_in[0], ppOut_pcm[0], output_frame ); - delay_signal( ppOut_pcm[0], output_frame, hTdDecorr->look_ahead_buf, hTdDecorr->offset ); + delay_signal_float( ppOut_pcm[0], output_frame, hTdDecorr->look_ahead_buf, hTdDecorr->offset ); /* In ducking gains */ if ( hTdDecorr->ducking_flag ) diff --git a/lib_com/logqnorm.c b/lib_com/logqnorm.c index 04b822a14..1fe5a7e9b 100644 --- a/lib_com/logqnorm.c +++ b/lib_com/logqnorm.c @@ -153,7 +153,7 @@ void logqnorm_2( } *ynrm = j2; } - *normqlg2 = dicnlg2[*ynrm]; + *normqlg2 = dicnlg2_float[*ynrm]; normqlg2++; ynrm++; } @@ -184,13 +184,13 @@ void calc_norm( logqnorm( &x[band_start[start_band]], &nrm, 32, band_len[start_band], thren_HQ ); norm[start_band] = nrm; - normlg[start_band] = dicnlg2[nrm]; + normlg[start_band] = dicnlg2_float[nrm]; for ( band = start_band + 1; band < start_band + num_bands; band++ ) { logqnorm( &x[band_start[band]], &nrm, 40, band_len[band], thren_HQ ); norm[band] = nrm; - normlg[band] = dicnlg2[nrm]; + normlg[band] = dicnlg2_float[nrm]; } return; diff --git a/lib_com/logqnorm_fx.c b/lib_com/logqnorm_fx.c new file mode 100644 index 000000000..407c1b71f --- /dev/null +++ b/lib_com/logqnorm_fx.c @@ -0,0 +1,218 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" /* Compilation switches */ +#include "prot_fx2.h" /* Function prototypes */ +#include "rom_com.h" /* Static table prototypes */ +#include "ivas_cnst.h" /* Common constants */ + +#define THREN2POW 1518500250L + +void calc_norm_fx( + const Word32 *L_x, /* i : Input vector. Qx */ + const Word16 qx, /* i : Q value of input */ + Word16 *norm, /* o : Quantization indices for norms Q0 */ + Word16 *normlg, /* o : Quantized norms in log2 Q0 */ + const Word16 start_band, /* i : Indice of band to start coding Q0 */ + const Word16 num_bands, /* i : Number of bands Q0 */ + const Word16 *band_len, /* i : Length of bands Q0 */ + const Word16 *band_start /* i : Start of bands Q0 */ +) +{ + Word16 nrm; + Word16 band; + Word16 tmp; + + set16_fx(norm, 0, start_band); + logqnorm_fx(&L_x[band_start[start_band]], qx, &nrm, 32, band_len[start_band], 0); + norm[start_band] = nrm; + move16(); + normlg[start_band] = dicnlg2[nrm]; + move16(); + + tmp = add(start_band, num_bands); + FOR(band = add(start_band, 1); band < tmp; band++) + { + logqnorm_fx(&L_x[band_start[band]], qx, &nrm, 40, band_len[band], 0); + + norm[band] = nrm; + move16(); + normlg[band] = dicnlg2[nrm]; + move16(); + } + + return; +} + + + +/*--------------------------------------------------------------------------* + * logqnorm_fx + * + * Log quantization for norms of sub-vectors + *--------------------------------------------------------------------------*/ + +void logqnorm_fx( + const Word32 *L_x, /* i : coefficient vector Qx */ + const Word16 qx, /* i : Q value of input */ + Word16 *k, /* o : index Q0 */ + const Word16 L, /* i : codebook length Q0 */ + const Word16 N, /* i : sub-vector size Q0 */ + const Word16 hvq_flag /* i : HVQ flag Q0 */ +) +{ + Word16 i, m; + Word16 coefs_shift, power_shift, temp_shift; + Word32 L_temp, L_temp1, L_temp2; + Word16 coefs16[MAX_SFM_LEN_FX]; + UWord16 lsb; + + Word16 offset = add(3, shl(qx, 1)); /* 3 + 2*qx */ + + lsb = 0U; /* to avoid compilation warnings */ + + L_temp1 = L_deposit_l(1); + FOR(i = 0; i < N; i++) + { + L_temp2 = L_abs(L_x[i]); + L_temp1 = L_max(L_temp1, L_temp2); + } + coefs_shift = sub(norm_l(L_temp1), sqac_headroom_fx[N]); + L_temp = L_deposit_l(0); + + FOR(i = 0; i < N; i++) + { + coefs16[i] = extract_h(L_shl(L_x[i], coefs_shift)); + L_temp = L_mac0(L_temp, coefs16[i], coefs16[i]); + } + + if (GT_16(N, 1)) + { + Mpy_32_16_ss(L_temp, inv_tbl_fx[N], &L_temp, &lsb); + } + power_shift = shl(sub(coefs_shift, 16), 1); + + temp_shift = norm_l(L_temp); + m = add(temp_shift, power_shift); + + L_temp1 = L_add(L_shl(L_temp, temp_shift), lshr(lsb, sub(16, temp_shift))); + + m = add(offset, m); + test(); + IF(m < 5 && hvq_flag) + { + m = shl(m, 1); + IF(LT_32(L_temp1, 1276901417L /* 2^0.25 Q30 */)) + { + m = add(m, 2); + } + ELSE if (LT_32(L_temp1, 1805811301L /* 2^0.75 Q30 */)) + { + m = add(m, 1); + } + } + ELSE + { + if (LT_32(L_temp1, THREN2POW /* 2^0.5 Q30 */)) + { + m = add(m, 1); + } + if (hvq_flag) + { + m = add(m, 5); /* offset, 5 extra levels in HVQ codebook */ + } + } + *k = s_max(m, 0); + i = sub(L, 1); + *k = s_min(*k, i); + + return; +} + +void logqnorm_2_fx( + const Word32 *env_fl, /* o, Q10 : index */ + const Word16 L, /* i : codebook length */ + const Word16 n_env_band, /* i : sub-vector size */ + const Word16 nb_sfm, /* i : sub-vector size */ + Word16 *ynrm, /* o : norm indices */ + Word16* normqlg2, /* o : quantized norm values */ + const Word32 *thren /* i, Q10 : quantization thresholds */ +) +{ + Word16 i, j, j1, j2; + Word32 temp, power; + + FOR(i = n_env_band; i < nb_sfm; i++) + { + temp = env_fl[sub(i, n_env_band)]; + IF(LE_32(thren[0], temp)) + { + *ynrm = 0; + move16(); + } + ELSE IF(GT_32(thren[sub(L, 2)], temp)) + { + *ynrm = sub(L, 1); + } + ELSE + { + power = temp; + move16(); + j1 = 0; + move16(); + j2 = sub(L, 1); + WHILE(GT_16(sub(j2,j1),1)) + { + j = shr(add(j1 , j2), 1); + IF(GE_32(power,thren[j])) + { + j2 = j; + move16(); + } + ELSE + { + j1 = j; + move16(); + } + } + *ynrm = j2; + move16(); + } + *normqlg2 = dicnlg2[*ynrm]; + move16(); + normqlg2++; + ynrm++; + } + + return; +} \ No newline at end of file diff --git a/lib_com/lpc_tools.c b/lib_com/lpc_tools.c index 9c936da11..71255e451 100644 --- a/lib_com/lpc_tools.c +++ b/lib_com/lpc_tools.c @@ -200,7 +200,7 @@ int16_t lev_dur( * *---------------------------------------------------------------------*/ -void E_LPC_int_lpc_tcx( +void E_LPC_int_lpc_tcx_float( const float lsf_old[], /* i : LSFs from past frame */ const float lsf_new[], /* i : LSFs from present frame */ float a[] /* o : interpolated LP coefficients */ @@ -273,7 +273,7 @@ static void lsp_reorder( * Approximate unweighting *---------------------------------------------------------------------*/ -int16_t E_LPC_lsp_unweight( +int16_t E_LPC_lsp_unweight_float( const float lsp_w[], /* i : weighted lsp */ float lsp_uw[], /* o : unweighted lsp */ float lsf_uw[], /* o : unweighted lsf */ @@ -281,17 +281,17 @@ int16_t E_LPC_lsp_unweight( ) { float lsp_w_orig[M], lsp_w_diff[M], mean, step; - const lsp_unw_triplet *unw_coeffs = NULL; + const lsp_unw_triplet_flt *unw_coeffs = NULL; int16_t i; /* Table selection */ if ( (float) fabs( inv_gamma - 1.0f / 0.94f ) < 0.0001f ) { - unw_coeffs = p16_gamma0_94to1; + unw_coeffs = p16_gamma0_94to1_float; } else if ( (float) fabs( inv_gamma - 1.0f / 0.92f ) < 0.0001f ) { - unw_coeffs = p16_gamma0_92to1; + unw_coeffs = p16_gamma0_92to1_float; } else { diff --git a/lib_com/lpc_tools_fx.c b/lib_com/lpc_tools_fx.c new file mode 100644 index 000000000..f33986f60 --- /dev/null +++ b/lib_com/lpc_tools_fx.c @@ -0,0 +1,1107 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +/*==================================================================================== + EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 + ====================================================================================*/ + +#include +#include +#include "options.h" /* Compilation switches */ +#include "ivas_cnst.h" /* Common constants */ +#include "prot_fx2.h" /* Function prototypes */ +#include "rom_com.h" +#include "basop_mpy.h" +#include "basop_util.h" + + + /*-----------------------------------------------------------------* + * Local constants + *-----------------------------------------------------------------*/ + +#define MAX_LEN_LP 960 /* maximum length in samples of the LP analysis window */ + +/*-----------------------------------------------------------------* +* Local functions +*-----------------------------------------------------------------*/ + + +static __inline Word16 L_Extract_lc(const Word32 L_32, Word16 *p_hi) +{ + *p_hi = extract_h(L_32); + return lshr(extract_l(L_32), 1); + +} + + /*---------------------------------------------------------------------* + * autocorr() + * + * Compute autocorrelations of input signal + *---------------------------------------------------------------------*/ +void autocorr_fx( + const Word16 x[], /* i : Input signal */ + const Word16 m, /* i : LPC order Q0 */ + Word16 r_h[], /* o : Autocorrelations (msb) Q15 */ + Word16 r_l[], /* o : Autocorrelations (lsb) */ + Word16 *Q_r, /* o : normalisation shift of r Q0 */ + const Word16 len, /* i : Frame lenght */ + const Word16* wind, /* i : Window used */ + Word16 rev_flag, + const Word16 sym_flag /* i : symmetric window flag */ +) +{ + Word16 i, j, norm, shift, y[MAX_LEN_LP]; + Word16 fact; + Word32 L_sum, L_tmp; + + IF(EQ_16(rev_flag, 1)) + { + /* Windowing of signal */ + FOR(i = 0; i < len; i++) + { + y[i] = mult_r(x[i], wind[len - i - 1]); + move16(); + } + } + ELSE IF(EQ_16(sym_flag, 1)) + { + /* symmetric window of even length */ + FOR(i = 0; i < len / 2; i++) + { + y[i] = mult_r(x[i], wind[i]); + move16(); + } + FOR(; i < len; i++) + { + y[i] = mult_r(x[i], wind[len - i - 1]); + move16(); + } + } + ELSE /* assymetric window */ + { + FOR(i = 0; i < len; i++) + { + y[i] = mult_r(x[i], wind[i]); + move16(); + } + } + + + /* calculate energy of signal */ + L_sum = L_deposit_h(16); /* sqrt(256), avoid overflow after rounding */ + FOR(i = 0; i < len; i += 2) + { + L_tmp = L_mult0(y[i], y[i]); + L_tmp = L_and(L_tmp, ~(128 - 1)); + L_tmp = L_mac0(L_tmp, y[i + 1], y[i + 1]); + L_tmp = L_shr(L_tmp, 7); + L_sum = L_add(L_sum, L_tmp); + } + + /* scale signal to avoid overflow in autocorrelation */ + norm = norm_l(L_sum); + shift = sub(4, shr(norm, 1)); + + IF(shift > 0) + { + fact = lshr(-32768, shift); + FOR(i = 0; i < len; i++) + { + y[i] = mult_r(y[i], fact); + move16(); + } + } + ELSE + { + shift = 0; + move16(); + } + + /* Compute and normalize r[0] */ + L_sum = L_mac(1, y[0], y[0]); + FOR(i = 1; i < len; i++) + { + L_sum = L_mac(L_sum, y[i], y[i]); + } + norm = norm_l(L_sum); + L_sum = L_shl(L_sum, norm); + L_Extract(L_sum, &r_h[0], &r_l[0]); /* Put in DPF format (see oper_32b) */ + + /* Compute r[1] to r[m] */ + FOR(i = 1; i <= m; i++) + { + L_sum = L_mult(y[0], y[i]); + FOR(j = 1; j < len - i; j++) + { + L_sum = L_mac(L_sum, y[j], y[j + i]); + } + + L_sum = L_shl(L_sum, norm); + L_Extract(L_sum, &r_h[i], &r_l[i]); /* Put in DPF format (see oper_32b) */ + } + + *Q_r = sub(norm, shl(shift, 1)); + move16(); +} + +/***************************************************************************** + * * + * Function Name : Div_32_opt * + * * + * Purpose : * + * Fractional integer division of two 32 bit numbers. * + * L_num / L_denom. * + * L_num and L_denom must be positive and L_num < L_denom. * + * L_denom = denom_hi<<16 + denom_lo<<1 * + * denom_hi is a normalize number. * + * * + * Inputs : * + * * + * L_num * + * 32 bit long signed integer (Word32) whose value falls in the * + * range : 0x0000 0000 < L_num < L_denom * + * * + * L_denom = denom_hi<<16 + denom_lo<<1 (DPF) * + * * + * denom_hi * + * 16 bit positive normalized integer whose value falls in the * + * range : 0x4000 < hi < 0x7fff * + * denom_lo * + * 16 bit positive integer whose value falls in the * + * range : 0 < lo < 0x7fff * + * * + * Return Value : * + * * + * L_div * + * 32 bit long signed integer (Word32) whose value falls in the * + * range : 0x0000 0000 <= L_div <= 0x7fff ffff. * + * * + * Algorithm: * + * * + * - find = 1/L_denom. * + * First approximation: approx = 1 / denom_hi * + * 1/L_denom = approx * (2.0 - L_denom * approx ) * + * * + * - result = L_num * (1/L_denom) * + ***************************************************************************** +*/ +static +Word32 Div_32_opt(Word32 L_num, Word16 denom_hi, Word16 denom_lo) +{ + Word16 approx /*, hi, lo, n_hi , n_lo*/; + Word32 L_32; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + /* First approximation: 1 / L_denom = 1/denom_hi */ + + approx = div_s((Word16)0x3fff, denom_hi); + + /* 1/L_denom = approx * (2.0 - L_denom * approx) */ + + L_32 = Msu_32_16((Word32)0x7fffffffL, denom_hi, denom_lo, approx); + + L_32 = Mpy_32_16_1(L_32, approx); + + /* L_num * (1/L_denom) */ + + L_32 = Mpy_32_32(L_num, L_32); + +#ifdef BASOP_NOGLOB + L_32 = L_shl_o(L_32, 2, &Overflow); +#else /* BASOP_NOGLOB */ + L_32 = L_shl(L_32, 2); +#endif /* BASOP_NOGLOB */ + + return (L_32); +} + +/* + * E_LPC_lev_dur + * + * Parameters: + * Rh I: Rh[m+1] Vector of autocorrelations (msb) + * Rl I: Rl[m+1] Vector of autocorrelations (lsb) + * A O: A[m] LPC coefficients (m = 16) Qx (A[0] is always 1, so the format can be deduced in the caller with norm_s(A[0])) + * epsP O: error vector, msb + * order I: LPC order Q0 + * + * Function: + * Levinson-Durbin algorithm to compute + * the LPC parameters from the autocorrelations of speech. + * + * Returns: + * void + */ +Word16 E_LPC_lev_dur(const Word16 Rh[], const Word16 Rl[], Word16 A[], + Word32 epsP[], const Word16 order + , Word16 *mem +) +{ + return(E_LPC_lev_dur_stab(Rh, Rl, A, epsP, order, mem, 32750)); /* 0.99945 in Q15 */ +} + +Word16 E_LPC_lev_dur_stab(const Word16 Rh[], const Word16 Rl[], Word16 A[], + Word32 epsP[], const Word16 order, + Word16 *mem, Word16 k_max +) +{ + Word16 i, j, k; + Word16 hi, lo; + Word16 Kh, Kl; /* reflection coefficient; hi and lo */ + Word16 alp_h, alp_l, alp_exp; /* Prediction gain; hi lo and exponent */ + Word32 t0, t1, t2; /* temporary variables */ + Word16 flag; + Word16 Ah[TCXLTP_LTP_ORDER + 1], Al[TCXLTP_LTP_ORDER + 1]; /* LPC coef. in double prec. */ +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + + BASOP_SATURATE_WARNING_OFF + if (epsP != NULL) + { + epsP[0] = L_Comp(Rh[0], Rl[0]); + move32(); + } + + flag = 0; + move16(); + + /* K = A[1] = -R[1] / R[0] */ + t1 = L_Comp(Rh[1], Rl[1]); /* R[1] in Q31 */ + t2 = L_abs(t1); /* abs R[1] */ + t0 = L_deposit_l(0); + IF(Rh[0] != 0) + { + t0 = Div_32_opt(t2, Rh[0], Rl[0]); /* R[1]/R[0] in Q31 */ + /* Cause a difference in MODE1 due to different implementation of div32*/ + } + if (t1 > 0) + { + t0 = L_negate(t0); /* -R[1]/R[0] */ + } + Kl = L_Extract_lc(t0, &Kh); /* K in DPF */ + t0 = L_shr(t0, 4); /* A[1] in Q27 */ + L_Extract(t0, &Ah[1], &Al[1]); /* A[1] in DPF */ + + /* Alpha = R[0] * (1-K**2) */ + t0 = Sqr_32(Kh, Kl); /* K*K in Q31 */ + t0 = L_abs(t0); /* Some case <0 !! */ + t0 = L_sub((Word32)0x7fffffffL, t0); /* 1 - K*K in Q31 */ + lo = L_Extract_lc(t0, &hi); /* DPF format */ + t0 = Mpy_32(Rh[0], Rl[0], hi, lo); /* Alpha in Q31 */ + if (epsP != NULL) + { + epsP[1] = t0; + move32(); + } + + /* Normalize Alpha */ + alp_exp = norm_l(t0); + t0 = L_shl(t0, alp_exp); + alp_l = L_Extract_lc(t0, &alp_h); + /* DPF format */ + + /*--------------------------------------* + * ITERATIONS I=2 to m + *--------------------------------------*/ + + FOR(i = 2; i <= order; i++) + { + /* t0 = SUM(R[j]*A[i-j], j=1, i-1) + R[i] */ + t0 = L_deposit_l(0); + FOR(j = 1; j < i; j++) + { + t0 = Mac_32(t0, Rh[j], Rl[j], Ah[i - j], Al[i - j]); + } + +#ifdef BASOP_NOGLOB + t0 = L_shl_o(t0, 4, &Overflow); /* result in Q27 -> convert to Q31 */ +#else /* BASOP_NOGLOB */ + t0 = L_shl(t0, 4); /* result in Q27 -> convert to Q31 */ +#endif /* BASOP_NOGLOB */ + /* No overflow possible */ + + /* Compose and add R[i] in Q3 */ +#ifdef BASOP_NOGLOB + t0 = L_mac_o(t0, Rl[i], 1, &Overflow); + t0 = L_msu_o(t0, Rh[i], -32768, &Overflow); +#else /* BASOP_NOGLOB */ + t0 = L_mac(t0, Rl[i], 1); + t0 = L_msu(t0, Rh[i], -32768); +#endif /* BASOP_NOGLOB */ + + /* K = -t0 / Alpha */ + t1 = L_abs(t0); + t2 = L_deposit_l(0); + IF(alp_h != 0) + { + t2 = Div_32_opt(t1, alp_h, alp_l); /* abs(t0)/Alpha */ + /* Cause a difference in MODE1 due to different implementation of div32*/ + } + + if (t0 > 0) + { + t2 = L_negate(t2); /* K =-t0/Alpha */ + } +#ifdef BASOP_NOGLOB + t2 = L_shl_o(t2, alp_exp, &Overflow); /* denormalize; compare to Alpha */ +#else /* BASOP_NOGLOB */ + t2 = L_shl(t2, alp_exp); /* denormalize; compare to Alpha */ +#endif /* BASOP_NOGLOB */ + test(); + if ((mem != NULL) && ((GT_16(abs_s(extract_h(t2)), k_max)))) + { + flag = 1; + move16();/* Test for unstable filter. If unstable keep old A(z) */ + } + if ((mem != NULL) && ((LT_32(L_abs(t2), 5)))) + { + flag = 1; + move16(); /*R matrix not reliable (R saturated for many coeff), keep old A(z) */ + } + Kl = L_Extract_lc(t2, &Kh); /* K in DPF */ + + /*------------------------------------------* + * Compute new LPC coeff. -> An[i] + * An[j]= A[j] + K*A[i-j] , j=1 to i-1 + * An[i]= K + *------------------------------------------*/ + + k = mult_r(i, 16384); + FOR(j = 1; j < k; j++) + { + /* Do two Iterations Together to Allow Direct Update of Ah & Al */ + t0 = Mac_32(L_Comp(Ah[j], Al[j]), Kh, Kl, Ah[i - j], Al[i - j]); + t1 = Mac_32(L_Comp(Ah[i - j], Al[i - j]), Kh, Kl, Ah[j], Al[j]); + L_Extract(t0, &Ah[j], &Al[j]); + L_Extract(t1, &Ah[i - j], &Al[i - j]); + } + IF(s_and(i, 1) == 0) + { + t0 = Mac_32(L_Comp(Ah[j], Al[j]), Kh, Kl, Ah[i - j], Al[i - j]); + L_Extract(t0, &Ah[j], &Al[j]); + } + t2 = L_shr(t2, 4); /* t2 = K in Q31 ->convert to Q27 */ + L_Extract(t2, &Ah[i], &Al[i]); /* An[i] in Q27 */ + + /* Alpha = Alpha * (1-K**2) */ +#ifdef BASOP_NOGLOB + t1 = L_mult_o(Kh, Kh, &Overflow); /* K*K in Q31 */ +#else /* BASOP_NOGLOB */ + t1 = L_mult(Kh, Kh); /* K*K in Q31 */ +#endif /* BASOP_NOGLOB */ + t0 = L_mac(t1, mult(Kh, Kl), 2); + t0 = L_abs(t0); /* Some case <0 !! */ + t0 = L_sub((Word32)0x7fffffffL, t0); /* 1 - K*K in Q31 */ + lo = L_Extract_lc(t0, &hi); /* DPF format */ + t0 = Mpy_32(alp_h, alp_l, hi, lo); /* Alpha in Q31 */ + + + /* store denormalized alpha in epsP */ + t1 = L_shr(t0, alp_exp); + if (epsP != NULL) + { + epsP[i] = t1; + move32(); + } + + /* Normalize Alpha */ + j = norm_l(t0); + t0 = L_shl(t0, j); + alp_l = L_Extract_lc(t0, &alp_h);/* DPF format */ + alp_exp = add(alp_exp, j); /* Add normalization to alp_exp */ + } + + /* Adaptive scaling */ + t1 = L_deposit_l(0); + FOR(i = 1; i <= order; i++) + { + t0 = L_Comp(Ah[i], Al[i]); + t1 = L_max(t1, L_abs(t0)); + } + k = s_min(norm_l(t1), 3); + A[0] = shl(2048, k); + move16(); + FOR(i = 1; i <= order; i++) + { + t0 = L_Comp(Ah[i], Al[i]); +#ifdef BASOP_NOGLOB + A[i] = round_fx_o(L_shl_o(t0, k, &Overflow), &Overflow); +#else + A[i] = round_fx(L_shl(t0, k)); +#endif + } + + BASOP_SATURATE_WARNING_ON + IF(mem != NULL) + { + /* Enforce stable LPC filter - parcorr[0] and parcorr[1] are not LPC coeffiecients */ + IF(flag) + { + Copy(mem, A, order + 1); + } + ELSE /* If stable LPC filter, store into memories */ + { + Copy(A, mem, order + 1); + } + } + + + return(flag); +} + +/* + * E_LPC_a_add_tilt + * + * Parameters: + * a I: LP filter coefficients (m+1 coeffs) + * ap O: modified LP filter coefficients (m+2 coeffs) + * gamma I: tilt factor + * m I: order of LP filter + * + * Function: + * Modified LP filter by adding 1st order pre-premphasis, Ap(z)=A(z).(1-gamma.z^(-1)) + * + * Returns: + * void + */ +void E_LPC_a_add_tilt(const Word16 *a, Word16 *ap, Word16 gamma, Word16 m) +{ + Word16 i; + Word32 Amax, Atmp[M + 2]; + Word16 shift; + + + + + Amax = L_mult(16384, a[0]); + FOR(i = 1; i <= m; i++) + { + Atmp[i] = L_sub(L_mult(16384, a[i]), L_mult0(gamma, a[i - 1])); + move32(); + Amax = L_max(Amax, L_abs(Atmp[i])); + } + Atmp[m + 1] = L_negate(L_mult0(gamma, a[m])); + move32(); + Amax = L_max(Amax, L_abs(Atmp[m + 1])); + shift = norm_l(Amax); + ap[0] = shl(a[0], sub(shift, 1)); + move16(); + FOR(i = 1; i <= m; i++) + { + ap[i] = round_fx(L_shl(Atmp[i], shift)); + } + ap[m + 1] = round_fx(L_shl(Atmp[m + 1], shift)); + +} + +void E_LPC_int_lpc_tcx(const Word16 lsp_old[], /* input : LSPs from past frame Q15 */ + const Word16 lsp_new[], /* input : LSPs from present frame Q15 */ + Word16 a[] /* output: interpolated LP coefficients Q12 */ +) +{ + Word16 i, lsp[M]; + + + + FOR(i = 0; i < M; i++) + { + /*lsp[i] = lsp_old[i]*0.125f + lsp_new[i]*0.875f;*/ + lsp[i] = round_fx(L_mac(L_mult(lsp_old[i], 4096), lsp_new[i], 28672)); + } + E_LPC_f_lsp_a_conversion(lsp, a, M); + + + return; +} + +static void lsp_reorder( + Word16 *lsp, /* (I/O): LSP vector (acos() domain) Q13*1.2732 */ + Word16 min_dist, /* (I): minimum required distance Q13*1.2732 */ + Word16 lpcorder /* (I): LPC order Q0 */ +) +{ + Word16 i; + Word16 lsp_min, lsp_max; + + + /* Verify the LSF ordering and minimum GAP */ + lsp_min = min_dist; + move16(); + FOR(i = 0; i < lpcorder; ++i) + { + lsp[i] = s_max(lsp[i], lsp_min); + move16(); + lsp_min = add(lsp[i], min_dist); + } + + /* Reverify the LSF ordering and minimum GAP in the reverse order (security) */ + lsp_max = sub(32767, min_dist); + + /* If danger of unstable filter in case of resonance in HF */ + lpcorder = sub(lpcorder, 1); + IF(GT_16(lsp[lpcorder], lsp_max)) + { + /* Reverify the minimum LSF gap in the reverse sense */ + FOR(i = lpcorder; i >= 0; --i) + { + lsp[i] = s_min(lsp[i], lsp_max); + move16(); + lsp_max = sub(lsp[i], min_dist); + } + } + +} + +/* Approximate unweighting */ +Word16 E_LPC_lsp_unweight( + /* const */ Word16 lsp_w[], /* (I): weighted xSP Q15 */ + Word16 lsp_uw[], /* (O): unweighted xSP Q15 */ + Word16 lsf_uw[], /* (O): unweighted LSF Q1*1.28 */ + Word16 inv_gamma, /* (I): inverse weighting factor Q14 */ + Word16 lpcorder /* (I): prediction order Q0 */ +) +{ + Word16 lsp_w_orig[M], lsp_w_diff[M], mean, step; /* Q13*1.2732 */ + const lsp_unw_triplet *unw_coeffs = NULL; + Word16 i; + + step = 0; /* to avoid compilation warnings */ + + + assert(lpcorder == 16); + + /* Table selection */ + IF(EQ_16(inv_gamma, GAMMA16k_INV)) + { + unw_coeffs = p16_gamma0_94to1; + move16(); + } + ELSE IF(EQ_16(inv_gamma, GAMMA1_INV)) + { + unw_coeffs = p16_gamma0_92to1; + move16(); + } + ELSE + { + assert(0); + } + + /* step = M_PI/(float)(lpcorder+1); */ + step = 1927; + move16(); + mean = 0; + move16(); + + /* Apply acos() and get mean removed version */ + FOR(i = 0; i < lpcorder; ++i) + { + mean = add(mean, step); + lsp_w_orig[i] = shl(xsp_to_xsf(lsp_w[i]), 1); + move16(); + lsp_w_diff[i] = sub(lsp_w_orig[i], mean); + move16(); + } + + /* Approximate unweighting by 3-tap FIR */ + lsp_uw[0] = add(lsp_w_orig[0], round_fx(L_shl(L_mac0(L_mult0(unw_coeffs[0][1], lsp_w_diff[0]), unw_coeffs[0][2], lsp_w_diff[1]), 2))); + FOR(i = 1; i < lpcorder - 1; ++i) + { + lsp_uw[i] = add(lsp_w_orig[i], round_fx(L_shl(L_mac0(L_mac0(L_mult0(unw_coeffs[i][0], lsp_w_diff[i - 1]), unw_coeffs[i][1], lsp_w_diff[i]), unw_coeffs[i][2], lsp_w_diff[i + 1]), 2))); + move16(); + } + lsp_uw[i] = add(lsp_w_orig[i], round_fx(L_shl(L_mac0(L_mult0(unw_coeffs[i][0], lsp_w_diff[i - 1]), unw_coeffs[i][1], lsp_w_diff[i]), 2))); + move16(); + + /* Reorder */ + lsp_reorder(lsp_uw, 256, lpcorder); + + /* Convert to LSF, apply cos() */ + FOR(i = 0; i < lpcorder; ++i) + { + lsf_uw[i] = shr_r(lsp_uw[i], 1); + move16(); + lsp_uw[i] = xsf_to_xsp(lsf_uw[i]); + move16(); + } + + return 0; +} + + +/* + * E_LPC_schur + * + * Parameters: + * R I: Rh[M+1] Vector of autocorrelations (msb) + * reflCoeff O: rc[M] Reflection coefficients. Q15 + * epsP O: error vector + * + * Function: + * Schur algorithm to compute + * the LPC parameters from the autocorrelations of speech. + * + * Returns: + * void + */ +Word32 E_LPC_schur(Word32 r[], Word16 reflCoeff[], Word32 epsP[], const Word16 m) +{ + Word16 i, j, temp16, mM1, mMi, s; + Word32 g0[M], *g1, tmp32; + const Word32 min_epsP = 1; /* > 0.01f*2^27/2^30 */ + Word32 tmp_epsP; + + + + mM1 = sub(m, 1); + + s = getScaleFactor32(r, add(m, 1)); + IF(s != 0) + { + scale_sig32(r, add(m, 1), s); /* scale in-place */ + } + + g1 = r; + Copy32(r + 1, g0, m); + + /* compute g0[0]/g1[0], where g0[0] < g1[0] */ + temp16 = negate(divide3232(g0[0], g1[0])); + reflCoeff[0] = temp16; + move16(); + move32(); + epsP[0] = r[0]; + + + FOR(i = 0; i < mM1; i++) + { + /* g1[0] = g0[0]*temp16 + g1[0]; */ + tmp32 = Mpy_32_16_1(g0[0], temp16); + g1[0] = L_add(g1[0], tmp32); + move32(); + + mMi = sub(m, i); + FOR(j = 1; j < mMi; j++) + { + /* g0[j-1] = g0[j] + g1[j]*temp16; + g1[j] = g0[j]*temp16 + g1[j]; */ + g0[j - 1] = L_add(g0[j], Mpy_32_16_1(g1[j], temp16)); + move32(); + g1[j] = L_add(g1[j], Mpy_32_16_1(g0[j], temp16)); + move32(); + } + temp16 = negate(divide3232(g0[0], g1[0])); + reflCoeff[i + 1] = temp16; + move16(); + + /* Prediction errors */ + tmp_epsP = L_shr(g1[0], s); + if (tmp_epsP <= 0) + { + tmp_epsP = min_epsP; + move32(); + } + epsP[i + 1] = tmp_epsP; + move32(); + } + + /* epsP[i+1] = g0[0]*temp16 + g1[0]; */ + tmp_epsP = L_add(g1[0], Mpy_32_16_1(g0[0], temp16)); + tmp_epsP = L_shr(tmp_epsP, s); + if (tmp_epsP <= 0) + { + tmp_epsP = min_epsP; + move32(); + } + epsP[i + 1] = tmp_epsP; + move32(); + + /* prediction gain = divide3232(L_shr(epsP[0], PRED_GAIN_E), g1[0]); */ + + + + return g1[0]; +} + + +extern const PWord16 *w_a[7]; +extern const PWord16 w19N[127]; +extern const PWord16 w18N[127]; +extern void BASOP_getTables(const PWord16 **ptwiddle, const PWord16 **sin_twiddle, Word16 *psin_step, Word16 length); +static +void spec2isf( + Word16/*double*/ spec_r[], /* input spectrum real part (only left half + one zero)*/ + Word16/*double*/ spec_i[], /* input spectrum imag part (only left half+right halt with zeros)*/ + Word16/*short*/ speclen, /* length of spectrum (only left half)*/ + Word16 /*double*/ lsf[], /* locations of LSFs (buffer must be sufficiently long) */ /*15Q16*/ + const Word16 /*double*/ old_lsf[] /* locations of LSFs (buffer must be sufficiently long) */ /*15Q16*/ +) +{ + + /*spec_r[] needs a 0 in the end!*/ + Word16 s; + Word16 tmp, i; + Word16 specix, lsfix; + + move16(); + move16(); + specix = lsfix = 0; + move16(); + s = spec_r[specix++]; + + WHILE(LT_16(specix, speclen) && LE_16(lsfix, 15)) + { + + /*check for next zero crossing*/ + /*for (; s*spec_r[specix] >= 0; specix++);*/ + WHILE(mult(s, spec_r[specix]) >= 0) specix = add(specix, 1); + + tmp = divide1616(spec_r[specix - 1], sub(spec_r[specix - 1], spec_r[specix])); + move16(); + /*lsf[lsfix] = L_add(L_deposit_h(sub(specix,1)) , L_shl(L_deposit_l(tmp),1));*/ /*Q16*/ + lsf[lsfix] = add(shl(sub(specix, 1), 7), shr((tmp), 8)); /*7Q8*/ + + lsfix++; + + /*check for the next zero crossing*/ + /*for (; s*spec_i[specix] >= 0; specix++);*/ + + WHILE(mult(s, spec_i[specix]) >= 0) specix = add(specix, 1); + + tmp = divide1616(spec_i[specix - 1], sub(spec_i[specix - 1], spec_i[specix])); + move16(); + /*lsf[lsfix] = L_add(L_deposit_h(sub(specix,1)) , L_shl(L_deposit_l(tmp),1));*/ /*Q16*/ + lsf[lsfix] = add(shl(sub(specix, 1), 7), shr((tmp), 8)); /*7Q8*/ + + lsfix++; + + spec_r[speclen] = s; + move16(); + spec_i[speclen] = s; + move16(); + + s = negate(s); + } + + IF(LT_16(lsfix, 16)) + { + FOR(i = 0; i < 16; i++) + { + lsf[i] = old_lsf[i]; + move16(); + } + } + + return; +} + +void E_LPC_a_lsf_isf_conversion(Word16 *lpcCoeffs, Word16 *lsf, const Word16 *old_lsf, Word16 lpcOrder, Word8 lpcRep) +{ + Word32 RealFFT[128]; + Word32 ImagFFT[128]; + Word16 RealOut[130]; + Word16 ImagOut[130]; + Word32 *ptrReal; + Word32 *ptrImag; + Word16 n, i, j, step, scale; + const PWord16 *ptwiddle, *pwn17, *pwn17i; + PWord16 *pwn15, *pwn15i, tmpw15; + Word16 N = 256; + Word16 s[4]; + Word32 L_tmp, L_tmp1, L_tmp3; + Word16 lpc[19]; + +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + /* half length FFT */ + scale = add(norm_s(lpcCoeffs[0]), 1) + 5; + move16(); + + /*s = [sum(a) ((-1).^(1:length(a)))*a];*/ + L_tmp = L_deposit_h(0); + FOR(j = 0; j <= lpcOrder; j++) + { + L_tmp = L_mac(L_tmp, lpcCoeffs[j], 0x800); + } + /*s[1] = round_fx(L_tmp); move16();*/ + + L_tmp1 = L_deposit_h(0); + FOR(j = 0; j < lpcOrder / 2; j++) + { + L_tmp1 = L_msu(L_tmp1, lpcCoeffs[2 * j], 0x800); + L_tmp1 = L_mac(L_tmp1, lpcCoeffs[2 * j + 1], 0x800); + } + L_tmp1 = L_msu(L_tmp1, lpcCoeffs[2 * j], 0x800); + /*s[2] = round_fx(L_tmp1); move16();*/ + + + L_tmp3 = L_add(L_tmp1, L_tmp); + IF(L_tmp3 != 0) + { + s[1] = BASOP_Util_Divide3232_Scale(L_sub(L_tmp1, L_tmp), L_tmp3, &step); + move16(); + /*s[1] = BASOP_Util_Divide1616_Scale(sub(s[2],s[1]),add(s[2],s[1]), &step); move16();*/ + BASOP_SATURATE_WARNING_OFF + s[0] = negate(shr(-32768, step + 1)); + move16(); + s[2] = negate(shr(-32768, step + 1)); + move16(); + BASOP_SATURATE_WARNING_ON + } + ELSE + { + s[1] = 16384 / 4; + move16(); + s[0] = 0; + move16(); + s[2] = 0; + move16(); + } + s[0] = shr(s[0], 1); + s[1] = shr(s[1], 1); + s[2] = shr(s[2], 1); + lpc[0] = mult_r(lpcCoeffs[0], s[0]); + move16(); + L_tmp = L_mult(s[0], lpcCoeffs[1]); + lpc[1] = mac_r(L_tmp, lpcCoeffs[1 - 1], s[1]); + move16(); + + FOR(n = 2; n < 17; n++) + { + L_tmp = L_mult(s[0], lpcCoeffs[n]); + L_tmp = L_mac(L_tmp, lpcCoeffs[n - 1], s[1]); + lpc[n] = mac_r(L_tmp, lpcCoeffs[n - 2], s[2]); + move16(); + } + lpc[18] = mult_r(lpcCoeffs[16], s[0]); + move16(); + L_tmp = L_mult(s[0], lpcCoeffs[15]); + lpc[17] = mac_r(L_tmp, lpcCoeffs[16], s[1]); + move16(); + + scale = sub(getScaleFactor16(lpc, 19), SCALEFACTOR16_5); + + ptrReal = RealFFT; + ptrImag = ImagFFT; + + FOR(j = 0; j < 9; j++) + { + ptrReal[j * 8] = L_shl(L_deposit_h(lpc[2 * j]), scale); + ptrImag[j * 8] = L_shl(L_deposit_h(lpc[2 * j + 1]), scale); + } + ptrReal[j * 8] = L_shl(L_deposit_h(lpc[2 * j]), scale); + ptrImag[j * 8] = 0; + move16(); + j++; + + FOR(; j < 16; j++) + { + ptrReal[j * 8] = L_deposit_h(0); + ptrImag[j * 8] = L_deposit_h(0); + } + + //fft16(ptrReal, ptrImag, 8, 0); + + ptrReal++; + ptrImag++; + + FOR(i = 1; i < 8; i++) + { + ptwiddle = w_a[i - 1]; + + ptrReal[0] = L_shl(L_deposit_h(lpc[0]), scale); + ptrImag[0] = L_shl(L_deposit_h(lpc[1]), scale); + + FOR(j = 1; j < 9; j++) + { + ptrReal[j * 8] = L_shl(L_msu(L_mult(lpc[2 * j], ptwiddle->v.re), lpc[2 * j + 1], ptwiddle->v.im), scale); + move32(); + ptrImag[j * 8] = L_shl(L_mac(L_mult(lpc[2 * j + 1], ptwiddle->v.re), lpc[2 * j], ptwiddle->v.im), scale); + move32(); + ptwiddle++; + } + + ptrReal[j * 8] = L_shl(L_mac(0, lpc[2 * j], ptwiddle->v.re), scale); + move32(); + ptrImag[j * 8] = L_shl(L_mac(0, lpc[2 * j], ptwiddle->v.im), scale); + move32(); + ptwiddle++; + j++; + FOR(; j < 16; j++) + { + ptrReal[j * 8] = L_deposit_h(0); + ptrImag[j * 8] = L_deposit_h(0); + ptwiddle++; + } + + //fft16(ptrReal, ptrImag, 8, 0); + + ptrReal++; + ptrImag++; + + } + + /* pre-twiddle */ + BASOP_getTables(NULL, &ptwiddle, &step, 128); + IF(lpcRep != 0) + { + pwn17i = &w19N[126]; + pwn17 = w19N; + } + ELSE + { + pwn17i = &w18N[126]; + pwn17 = w18N; + } + + pwn15 = &tmpw15; + pwn15i = &tmpw15; + + RealOut[0] = round_fx(2 * L_add(RealFFT[0], ImagFFT[0])); + ImagOut[0] = 0; + move16(); + + RealOut[128] = 0; + move16(); + ImagOut[128] = round_fx(L_sub(L_add(RealFFT[0], RealFFT[0]), L_add(ImagFFT[0], ImagFFT[0]))); + + ptwiddle += 8; + FOR(i = 1; i <= N / 2 / 4; i++) + { + Word16 ReAr = extract_h(L_add(RealFFT[i], RealFFT[N / 2 - i])); + Word16 ReBr = extract_h(L_sub(RealFFT[N / 2 - i], RealFFT[i])); + Word16 ImAr = extract_h(L_sub(ImagFFT[i], ImagFFT[N / 2 - i])); + Word16 ImBr = extract_h(L_add(ImagFFT[i], ImagFFT[N / 2 - i])); + BASOP_SATURATE_WARNING_OFF +#ifdef BASOP_NOGLOB + tmpw15.v.re = mac_ro(L_mult(ptwiddle->v.re, pwn17->v.re), ptwiddle->v.im, pwn17->v.im, &Overflow); + tmpw15.v.im = msu_ro(L_mult(ptwiddle->v.re, pwn17->v.im), ptwiddle->v.im, pwn17->v.re, &Overflow); +#else /* BASOP_NOGLOB */ + tmpw15.v.re = mac_r(L_mult(ptwiddle->v.re, pwn17->v.re), ptwiddle->v.im, pwn17->v.im); + tmpw15.v.im = msu_r(L_mult(ptwiddle->v.re, pwn17->v.im), ptwiddle->v.im, pwn17->v.re); +#endif /* BASOP_NOGLOB */ + BASOP_SATURATE_WARNING_ON + RealOut[i] = mac_r(L_msu(L_msu(L_mult(ReAr, pwn17->v.re), ImAr, pwn17->v.im), ReBr, pwn15->v.im), ImBr, pwn15->v.re); + move16(); + ImagOut[i] = mac_r(L_mac(L_mac(L_mult(ReAr, pwn17->v.im), ImAr, pwn17->v.re), ReBr, pwn15->v.re), ImBr, pwn15->v.im); + move16(); + BASOP_SATURATE_WARNING_OFF +#ifdef BASOP_NOGLOB + tmpw15.v.re = msu_ro(L_mult(ptwiddle->v.im, pwn17i->v.im), ptwiddle->v.re, pwn17i->v.re, &Overflow); + tmpw15.v.im = mac_ro(L_mult(ptwiddle->v.re, pwn17i->v.im), ptwiddle->v.im, pwn17i->v.re, &Overflow); +#else /* BASOP_NOGLOB */ + tmpw15.v.re = msu_r(L_mult(ptwiddle->v.im, pwn17i->v.im), ptwiddle->v.re, pwn17i->v.re); + tmpw15.v.im = mac_r(L_mult(ptwiddle->v.re, pwn17i->v.im), ptwiddle->v.im, pwn17i->v.re); +#endif /* BASOP_NOGLOB */ + BASOP_SATURATE_WARNING_ON + RealOut[N / 2 - i] = msu_r(L_mac(L_mac(L_mult(ReAr, pwn17i->v.re), ImAr, pwn17i->v.im), ImBr, pwn15i->v.re), ReBr, pwn15i->v.im); + move16(); + ImagOut[N / 2 - i] = msu_r(L_msu(L_msu(L_mult(ReAr, pwn17i->v.im), ImAr, pwn17i->v.re), ReBr, pwn15i->v.re), ImBr, pwn15i->v.im); + move16(); + + ptwiddle += 8; + pwn17++; + pwn17i--; + } + + ptwiddle -= 16; + /*change real with imaginary for ptwiddle*/ + FOR(; i < N / 2 / 2; i++) + { + Word16 ReAr = extract_h(L_add(RealFFT[i], RealFFT[N / 2 - i])); + Word16 ReBr = extract_h(L_sub(RealFFT[N / 2 - i], RealFFT[i])); + Word16 ImAr = extract_h(L_sub(ImagFFT[i], ImagFFT[N / 2 - i])); + Word16 ImBr = extract_h(L_add(ImagFFT[i], ImagFFT[N / 2 - i])); + BASOP_SATURATE_WARNING_OFF +#ifdef BASOP_NOGLOB + tmpw15.v.re = mac_ro(L_mult(ptwiddle->v.im, pwn17->v.re), ptwiddle->v.re, pwn17->v.im, &Overflow); + tmpw15.v.im = msu_ro(L_mult(ptwiddle->v.im, pwn17->v.im), ptwiddle->v.re, pwn17->v.re, &Overflow); +#else /* BASOP_NOGLOB */ + tmpw15.v.re = mac_r(L_mult(ptwiddle->v.im, pwn17->v.re), ptwiddle->v.re, pwn17->v.im); + tmpw15.v.im = msu_r(L_mult(ptwiddle->v.im, pwn17->v.im), ptwiddle->v.re, pwn17->v.re); +#endif /* BASOP_NOGLOB */ + BASOP_SATURATE_WARNING_ON + RealOut[i] = mac_r(L_msu(L_msu(L_mult(ReAr, pwn17->v.re), ImAr, pwn17->v.im), ReBr, pwn15->v.im), ImBr, pwn15->v.re); + move16(); + ImagOut[i] = mac_r(L_mac(L_mac(L_mult(ReAr, pwn17->v.im), ImAr, pwn17->v.re), ReBr, pwn15->v.re), ImBr, pwn15->v.im); + move16(); + BASOP_SATURATE_WARNING_OFF +#ifdef BASOP_NOGLOB + tmpw15.v.re = msu_ro(L_mult(ptwiddle->v.re, pwn17i->v.im), ptwiddle->v.im, pwn17i->v.re, &Overflow); + tmpw15.v.im = mac_ro(L_mult(ptwiddle->v.im, pwn17i->v.im), ptwiddle->v.re, pwn17i->v.re, &Overflow); +#else /* BASOP_NOGLOB */ + tmpw15.v.re = msu_r(L_mult(ptwiddle->v.re, pwn17i->v.im), ptwiddle->v.im, pwn17i->v.re); + tmpw15.v.im = mac_r(L_mult(ptwiddle->v.im, pwn17i->v.im), ptwiddle->v.re, pwn17i->v.re); +#endif + BASOP_SATURATE_WARNING_ON + RealOut[N / 2 - i] = msu_r(L_mac(L_mac(L_mult(ReAr, pwn17i->v.re), ImAr, pwn17i->v.im), ImBr, pwn15i->v.re), ReBr, pwn15i->v.im); + move16(); + ImagOut[N / 2 - i] = msu_r(L_msu(L_msu(L_mult(ReAr, pwn17i->v.im), ImAr, pwn17i->v.re), ReBr, pwn15i->v.re), ImBr, pwn15i->v.im); + move16(); + + ptwiddle -= 8; + pwn17++; + pwn17i--; + } + ptwiddle += 0; + { + Word16 ReAr = extract_h(L_add(RealFFT[i], RealFFT[N / 2 - i])); + Word16 ReBr = extract_h(L_sub(RealFFT[N / 2 - i], RealFFT[i])); + Word16 ImAr = extract_h(L_sub(ImagFFT[i], ImagFFT[N / 2 - i])); + Word16 ImBr = extract_h((L_negate(L_add(ImagFFT[i], ImagFFT[N / 2 - i])))); + BASOP_SATURATE_WARNING_OFF + tmpw15.v.re = mac_r(L_mult(ptwiddle->v.im, pwn17->v.re), ptwiddle->v.re, pwn17->v.im); + tmpw15.v.im = msu_r(L_mult(ptwiddle->v.im, pwn17->v.im), ptwiddle->v.re, pwn17->v.re); + BASOP_SATURATE_WARNING_ON + RealOut[i] = msu_r(L_msu(L_msu(L_mult(ReAr, pwn17->v.re), ImAr, pwn17->v.im), ReBr, pwn15->v.im), ImBr, pwn15->v.re); + move16(); + ImagOut[i] = msu_r(L_mac(L_mac(L_mult(ReAr, pwn17->v.im), ImAr, pwn17->v.re), ReBr, pwn15->v.re), ImBr, pwn15->v.im); + move16(); + } + + spec2isf(RealOut, ImagOut, 128, lsf, old_lsf); + IF(lpcRep == 0) + { + lsf[lpcOrder - 1] = shl(lpcCoeffs[lpcOrder], add(norm_s(lpcCoeffs[0]), 1)); + move16(); /* From Qx to Q15 with saturation */ + lsf[lpcOrder - 1] = xsp_to_xsf(lsf[lpcOrder - 1]); + move16(); + lsf[lpcOrder - 1] = shr(lsf[lpcOrder - 1], 1); + move16(); + } + +} + diff --git a/lib_com/lsf_msvq_ma.c b/lib_com/lsf_msvq_ma.c index 940233e4c..c4ba58b7c 100644 --- a/lib_com/lsf_msvq_ma.c +++ b/lib_com/lsf_msvq_ma.c @@ -61,22 +61,22 @@ void midlsf_dec( const int16_t prev_bfi, const int16_t safety_net ) { - const float *ratio = NULL; + const float *ratio_float = NULL; int16_t j; int16_t bad_spacing = 0; /* Select codebook */ if ( coder_type == UNVOICED ) { - ratio = tbl_mid_unv_wb_5b; + ratio_float = tbl_mid_unv_wb_5b; } else { - ratio = tbl_mid_gen_wb_5b; + ratio_float = tbl_mid_gen_wb_5b; } for ( j = 0; j < N; j++ ) { - qlsf[j] = ( 1.0f - ratio[idx * N + j] ) * qlsf0[j] + ratio[idx * N + j] * qlsf1[j]; + qlsf[j] = ( 1.0f - ratio_float[idx * N + j] ) * qlsf0[j] + ratio_float[idx * N + j] * qlsf1[j]; } if ( mid_lsf_int != NULL ) /*at the decoder*/ diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index eaa94b506..7ed448a66 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -1178,7 +1178,7 @@ ivas_error lsf_allocate( * *----------------------------------------------------------------------------------*/ -ivas_error find_pred_mode( +ivas_error find_pred_mode_float( int16_t *predmode, const int16_t coder_type, const int16_t bwidth, @@ -1210,7 +1210,7 @@ ivas_error find_pred_mode( } } - *predmode = predmode_tab[idx][coder_type]; + *predmode = predmode_tab_float[idx][coder_type]; if ( idx <= 2 ) { @@ -1875,13 +1875,13 @@ void lsf_syn_mem_backup( /* back-up memories */ for ( i = 0; i < M; i++ ) { - mem_syn_bck[i] = hLPDmem->mem_syn[i]; + mem_syn_bck[i] = hLPDmem->mem_syn_flt[i]; } - *mem_w0_bck = hLPDmem->mem_w0; + *mem_w0_bck = hLPDmem->mem_w0_flt; - *btilt_code = hLPDmem->tilt_code; - *bgc_threshold = hLPDmem->gc_threshold; + *btilt_code = hLPDmem->tilt_code_flt; + *bgc_threshold = hLPDmem->gc_threshold_flt; mvr2r( st->clip_var, clip_var_bck, 6 ); *next_force_sf_bck = st->next_force_safety_net; @@ -1943,15 +1943,15 @@ void lsf_syn_mem_restore( } /* restoring memories */ - hLPDmem->mem_w0 = mem_w0_bck; + hLPDmem->mem_w0_flt = mem_w0_bck; for ( i = 0; i < M; i++ ) { - hLPDmem->mem_syn[i] = mem_syn_bck[i]; + hLPDmem->mem_syn_flt[i] = mem_syn_bck[i]; } - hLPDmem->tilt_code = btilt_code; - hLPDmem->gc_threshold = gc_threshold; + hLPDmem->tilt_code_flt = btilt_code; + hLPDmem->gc_threshold_flt = gc_threshold; mvr2r( clip_var_bck, st->clip_var, 6 ); st->next_force_safety_net = next_force_sf_bck; @@ -1965,7 +1965,7 @@ void lsf_syn_mem_restore( * *--------------------------------------------------------------------------*/ -void lsf_update_memory( +void lsf_update_memory_float( const int16_t narrowband, /* i : narrowband flag */ const float qlsf[], /* i : quantized lsf coefficients */ float old_mem_MA[], /* i : MA memory */ @@ -1976,7 +1976,7 @@ void lsf_update_memory( for ( i = 0; i < M; ++i ) { - mem_MA[i] = qlsf[i] - lsf_means[narrowband][i] - MU_MA * old_mem_MA[i]; + mem_MA[i] = qlsf[i] - lsf_means_float[narrowband][i] - MU_MA * old_mem_MA[i]; } return; @@ -1989,7 +1989,7 @@ void lsf_update_memory( *--------------------------------------------------------------------------*/ /*! r: codebook index */ -int16_t tcxlpc_get_cdk( +int16_t tcxlpc_get_cdk_float( const int16_t coder_type /* i : GC/VC indicator */ ) { @@ -2071,7 +2071,7 @@ void dec_FDCNG_MSVQ_stage1( * *--------------------------------------------------------------------------*/ -void msvq_dec( +void msvq_dec_float( const float *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */ const int16_t dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ const int16_t offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ @@ -2318,7 +2318,7 @@ void a2isf( for ( i = 1; i < 8; i++ ) { /*X=x(i:8:M/8) .* exp(-j*2*pi*i*(0:M/8-1)/M);*/ - ptwiddle = (const Pfloat *) w_a[i - 1]; + ptwiddle = (const Pfloat *) w_a_float[i - 1]; fftTmpRe[0] = lpc[0]; fftTmpIm[0] = lpc[1]; diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c new file mode 100644 index 000000000..863c551c5 --- /dev/null +++ b/lib_com/lsf_tools_fx.c @@ -0,0 +1,3900 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include +#include "options.h" /* Compilation switches */ +#include "basop_util.h" +#include "rom_com.h" +#include "ivas_cnst.h" +#include "prot_fx2.h" +#include "ivas_error.h" + + + /*-------------------------------------------------------------------* + * Local constants + *-------------------------------------------------------------------*/ +#define NC_MAX 8 +#define GUESS_TBL_SZ 256 + +#define depack_4_values(cbp, val0, val1, val2, val3) \ + val0 = shr((cbp)[0], 4); \ + val1 = shr((cbp)[1], 4); \ + val2 = shr((cbp)[2], 4); \ + val3 = add(add(shr(lshl((cbp)[2],12),4),lshr(lshl((cbp)[1],12),8)),s_and((cbp)[0],0xF)); + +#define SPC 0.0234952f +#define SPC_plus SPC * 1.001f + /*-------------------------------------------------------------------* + * Local functions + *-------------------------------------------------------------------*/ +Word16 root_search_fx(Word16 low, Word16 high, Word32 *v_low, Word32 *coef, Word16 order); +Word32 calc_weight(Word16 delta1, Word16 delta2, Word16 *n1); +Word32 polynomial_eval_fx(Word16 f, Word32 *coef, Word16 order); +void E_LPC_isf_isp_conversion(const Word16 isf[], Word16 isp[], const Word16 m); +void E_LPC_lsp_lsf_conversion(const Word16 lsp[], Word16 lsf[], const Word16 m); +Word16 E_LPC_f_lsp_pol_get(const Word16 lsp[], Word32 f[], const Word16 n, const Word16 past_Ovf, const Word16 isMODE1); + +static Word16 chebyshev(Word16 x, Word32 *f, const Word16 n, const Word16 shift) +{ + + Word16 cheb; + Word32 t0, b1, b2; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + cheb = norm_s(x); + if (cheb) + { + x = shl(x, 1); + } + t0 = Mpy_32_16_1(*f++, x); /* t0 = x*b2 */ + if (!cheb) + t0 = L_shl(t0, 1); /* t0 = 2*x*b2 */ + b1 = L_add(t0, *f++); /* b1 = 2*x*b2 + f[1] */ + + /* i = 2 */ + t0 = Mpy_32_16_1(b1, x); /* t0 = x*b1 */ + if (!cheb) + t0 = L_shl(t0, 1); /* t0 = 2*x*b1 */ + b2 = L_add(t0, *f++); /* b0 = 2*x*b1 - b2 + f[i] */ + + /* i = 3 */ + t0 = Mpy_32_16_1(b2, x); /* t0 = x*b1 */ + if (!cheb) + t0 = L_shl(t0, 1); /* t0 = 2*x*b1 */ + t0 = L_sub(t0, b1); /* t0 = 2*x*b1 - b2 */ + b1 = L_add(t0, *f++); /* b0 = 2*x*b1 - b2 + f[i] */ + + /* i = 4 */ + t0 = Mpy_32_16_1(b1, x); /* t0 = x*b1 */ + if (!cheb) + t0 = L_shl(t0, 1); /* t0 = 2*x*b1 */ + t0 = L_sub(t0, b2); /* t0 = 2*x*b1 - b2 */ + + /* If the LP order is greater than 10 */ + IF(GT_16(n, 5)) + { + b2 = L_add(t0, *f++); /* b0 = 2*x*b1 - b2 + f[i] */ + /* i = 5 */ + t0 = Mpy_32_16_1(b2, x); /* t0 = x*b1 */ + if (!cheb) +#ifdef BASOP_NOGLOB + t0 = L_shl_o(t0, 1, &Overflow); /* t0 = 2*x*b1 */ +#else /* BASOP_NOGLOB */ + t0 = L_shl(t0, 1); /* t0 = 2*x*b1 */ +#endif /* BASOP_NOGLOB */ + t0 = L_sub(t0, b1); /* t0 = 2*x*b1 - b2 */ + b1 = L_add(t0, *f++); /* b0 = 2*x*b1 - b2 + f[i] */ + + /* i = 6 */ + t0 = Mpy_32_16_1(b1, x); /* t0 = x*b1 */ + if (!cheb) +#ifdef BASOP_NOGLOB + t0 = L_shl_o(t0, 1, &Overflow); /* t0 = 2*x*b1 */ +#else /* BASOP_NOGLOB */ + t0 = L_shl(t0, 1); /* t0 = 2*x*b1 */ +#endif /* BASOP_NOGLOB */ + t0 = L_sub(t0, b2); /* t0 = 2*x*b1 - b2 */ + } + /* IF (sub(n,8) == 0) */ + IF(n == 8) + { + b2 = L_add(t0, *f++); /* b0 = 2*x*b1 - b2 + f[i] */ + /* i = 7 */ + t0 = Mpy_32_16_1(b2, x); /* t0 = x*b1 */ + if (!cheb) +#ifdef BASOP_NOGLOB + t0 = L_shl_o(t0, 1, &Overflow); /* t0 = 2*x*b1 */ +#else /* BASOP_NOGLOB */ + t0 = L_shl(t0, 1); /* t0 = 2*x*b1 */ +#endif /* BASOP_NOGLOB */ + t0 = L_sub(t0, b1); /* t0 = 2*x*b1 - b2 */ + /*b1 = L_add(b2,0);*/ + } + ELSE + { + b2 = b1; + move32(); + } + + t0/*b2*/ = L_add(t0, *f++); /* b0 = 2*x*b1 - b2 + f[i] */ + + t0 = Mpy_32_16_1(t0/*b2*/, x);/* t0 = x*b1 */ + if (cheb) + t0 = L_shr(t0, 1); + t0 = L_sub(t0, /*b1*/b2); /* t0 = x*b1 - b2 */ + t0 = L_add(t0, *f++); /* t0 = x*b1 - b2 + 0.5*f[n] */ + + + BASOP_SATURATE_WARNING_OFF +#ifdef BASOP_NOGLOB + t0 = L_shl_o(t0, shift, &Overflow); /* Qx to Q30 with saturation */ + cheb = round_fx_o(t0, &Overflow); /* Result in Q14 */ +#else /* BASOP_NOGLOB */ + t0 = L_shl(t0, shift); /* Qx to Q30 with saturation */ + cheb = round_fx(t0); /* Result in Q14 */ +#endif /* BASOP_NOGLOB */ + cheb = s_max(-32767, cheb); /* to avoid saturation */ + BASOP_SATURATE_WARNING_ON + return (cheb); +} + +void E_LPC_a_isp_conversion(const Word16 a[], Word16 isp[], const Word16 old_isp[], const Word16 m) +{ + Word16 i, nf, ip, order, nc; + Word16 xlow, ylow, xhigh, yhigh; + Word16 x, y, tmp, exp; + Word32 f[2][NC_MAX + 1]; + Word32 t0, t1; + Word16 scale = 1024; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + /*-------------------------------------------------------------* + * find the sum and diff polynomials F1(z) and F2(z) + * F1(z) = [A(z) + z^M A(z^-1)] + * F2(z) = [A(z) - z^M A(z^-1)]/(1-z^-2) + * + * for (i=0; i 1; i--) + { + /* f2[i] -= f2[i-2]; */ + f2[i] = L_sub(f2[i], f2[i - 2]); + move32(); + } + + /*----------------------------------------------------------* + * Scale F1(z) by (1+isp[m-1]) and F2(z) by (1-isp[m-1]) * + *----------------------------------------------------------*/ + + FOR(i = 0; i < nc; i++) + { + /* f1[i] *= (1.0 + isp[m-1]); */ + f1[i] = Madd_32_16(f1[i], f1[i], isp[m - 1]); + move32(); + + /* f2[i] *= (1.0 - isp[m-1]); */ + f2[i] = Msub_32_16(f2[i], f2[i], isp[m - 1]); + move32(); + } + + /*-----------------------------------------------------* + * A(z) = (F1(z)+F2(z))/2 * + * F1(z) is symmetric and F2(z) is antisymmetric * + *-----------------------------------------------------*/ + + /* Maximum LPC */ + tmax = L_deposit_l(1); + FOR(i = 1; i < nc; i++) + { + t0 = L_add(f1[i], f2[i]); + tmax = L_max(tmax, L_abs(t0)); + t0 = L_sub(f1[i], f2[i]); + tmax = L_max(tmax, L_abs(t0)); + } + q = s_min(norm_l(tmax), 6); + + DO + { + + /* a[0] = 1.0 */ + a[0] = shl(256,q); + move16(); + j = sub(m, 1); + FOR(i = 1; i < nc; i++) + { + /* a[i] = 0.5*(f1[i] + f2[i]) */ + t0 = L_add(f1[i], f2[i]); /* f1[i] + f2[i] */ + t0 = L_shl(t0, q); + a[i] = round_fx(t0); /* from Q23 to Q12 and * 0.5 */ + + /* a[j] = 0.5*(f1[i] - f2[i]) */ + t0 = L_sub(f1[i], f2[i]); /* f1[i] - f2[i] */ + t0 = L_shl(t0, q); + a[j] = round_fx(t0); /* from Q23 to Q12 and * 0.5 */ + + j = sub(j,1); + } + + /* a[NC] = 0.5*f1[NC]*(1.0 + isp[m-1]) */ + t0 = Madd_32_16(f1[nc], f1[nc], isp[m - 1]); + + BASOP_SATURATE_WARNING_OFF /*overflow handling in loop expression*/ + +#ifdef BASOP_NOGLOB + t0 = L_shl_o(t0, q, &Overflow); + t0n = L_sub_o(t0 , 0x7FFFFFFF, &Overflow); /*check for positive overflow*/ + t0p = L_sub_o(t0, 0x80000000, &Overflow); /*check for negative overflow*/ +#else /* BASOP_NOGLOB */ + t0 = L_shl(t0, q); + t0n = L_sub(t0 , 0x7FFFFFFF); /*check for positive overflow*/ + t0p = L_sub(t0, 0x80000000); /*check for negative overflow*/ +#endif /* BASOP_NOGLOB */ + BASOP_SATURATE_WARNING_ON + + q = sub(q,1); /*decrease q in case of overflow*/ + } WHILE(t0n == 0 || t0p == 0); /*in case of overflow, recalculate coefficients*/ + + a[nc] = round_fx(t0); /* from Q23 to Q12 and * 0.5 */ + + /* a[m] = isp[m-1] */ + t0 = L_mult(a[0], isp[m - 1]); /* from Q15 to Q12 */ + a[m] = round_fx(t0); + + + return; +} + +/*===================================================================*/ +/* FUNCTION : lpc2lsp_fx () */ +/*-------------------------------------------------------------------*/ +/* PURPOSE : Convert LPC coefficients to LSP coefficients */ +/*-------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* */ +/* _ (Word32 []) a : LPC coefficients, Q27 */ +/* _ (Word16 []) old_freq: Previous frame LSP coefficients, Q15 */ +/* _ (Word16 []) order: LPC order */ +/*-------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16 []) freq: LSP coefficients, Q15 */ +/*-------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ None */ +/*-------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ (Word16) flag: 1 means all 10 LSPs are found, 0 otherwise */ +/*===================================================================*/ +Word16 lpc2lsp_fx( + Word32* a, + Word16* freq, + Word16* old_freq, + Word16 order +) +{ + Word16 i; + Word16 rt, low, high, prev_rt, rc; + Word32 p[11], q[11]; /* Q26 */ + Word32 Ltemp, v_low; + Word32 Lacc; + Word16 tfreq[21]; + + /* First construct the P,Q polynomial */ + /* p[0] = q[0] = 1 */ + /* p[i] = -lpcCoeff[i] - lpcCoeff[11-i] - p[i-1] ( 1<=i<=5)*/ + /* q[i] = -lpcCoeff[i] + lpcCoeff[11-i] + q[i-1] ( 1<=i<=5)*/ + Ltemp = L_deposit_h(0x400); /* Ltemp is 1.0 in Q26 */ + + p[0] = Ltemp; + move32(); + q[0] = Ltemp; + move32(); + + FOR(i = 1; i < (order / 2) + 1; i++) + { + Lacc = a[order - i]; + move32();/* Q27 */ + Lacc = L_sub(Lacc, a[i - 1]); /* Lacc=-lpcCoeff[i-1] + lpcCoeff[order-i]//Q27 */ + q[i] = L_add(L_shr(Lacc, 1), q[i - 1]); + move32();/* Q26 */ + + Lacc = L_add(Lacc, L_shl(a[i - 1], 1));/* Lacc=lpcCoeff[i-1] + lpcCoeff[order-i]//Q27 */ + + p[i] = L_sub(L_negate(L_shr(Lacc, 1)), p[i - 1]); + move32();/* Q26 */ + } + + /* Search roots of the P and Q polynomials */ + + v_low = polynomial_eval_fx(0, p, order); /* Q25 */ + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + low = 0; + high = 8; + prev_rt = 0; + rc = 0; /* root counter */ + FOR(i = 0; i < 32; i++) + { + rt = root_search_fx(low, high, &v_low, p, order); + low = high; + move16(); + high = add(high, 8); + + IF(GE_16(rt, prev_rt)) + { + tfreq[rc] = rt; + move16(); + rc = add(rc, 2); + } + prev_rt = add(rt, 6); + } /* End for P roots */ + + tfreq[rc] = 0x3f80; + move16(); /* Set a high enough value as fake root for Q search */ + + IF(LT_16(rc, order)) + { + /* lost P root */ + /* copy from previous LSP and return */ + FOR(i = 0; i < order; i++) + { + move16(); + freq[i] = old_freq[i]; + } + return (0); + } + ELSE + { + /* Search for Q roots between P roots */ + v_low = L_deposit_h(0x800); /* Init a positive value for v_low */ + rc = 1; + move16(); + FOR(i = 0; i < order / 2; i++) + { + low = shr(tfreq[rc - 1], 6); + high = add(shr(tfreq[rc + 1], 6), 1); + rt = root_search_fx(low, high, &v_low, q, order); + + IF(rt < 0) + { + /* No Q root in this interval */ + /* copy from previous LSP and return */ + FOR(i = 0; i < order; i++) + { + move16(); + freq[i] = old_freq[i]; + } + return (0); + } + ELSE + { + move16(); + tfreq[rc] = rt; + rc = add(rc, 2); + } /* end else, find Q root */ + } /* end for */ + } /* end else */ + + FOR(i = 0; i < order; i++) + { + freq[i] = tfreq[i]; + move16(); + } + + return (1); +} + +/*===================================================================*/ +/* FUNCTION : lsp2lpc_fx () */ +/*-------------------------------------------------------------------*/ +/* PURPOSE : Convert LSP coefficients to LPC coefficients */ +/*-------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* */ +/* _ (Word16 []) freq: LSP coefficients, Q15 */ +/* _ (Word16 []) prev_a : previous frame LPC coefficients, Q12 */ +/* _ (Word16 []) order : LPC order */ +/*-------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16 []) a : LPC coefficients, Q12 */ +/*-------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ None */ +/*-------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ None */ +/*===================================================================*/ +void lsp2lpc_fx( + Word16 *a, + Word16 *freq, + Word16 *prev_a, + Word16 order +) +{ + Word16 i; + Word32 pq[LPC_SHB_ORDER]; + Word32 p[LPC_SHB_ORDER], q[LPC_SHB_ORDER]; + Word32 Ltemp; + Word32 Lacc; + Word16 tmp_pci[M + 1]; + Word16 giOverflow; + +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + FOR(i = 0; i < order; i++) + { + tmp_pci[i] = prev_a[i]; + move16(); + } + + compute_poly_product_fx(freq, pq, order); + /*This change is to get funtionality if L_sub_sat*/ + giOverflow = 0; + move16(); /* clear overflow flag */ + Overflow = 0; + move16(); + FOR(i = 0; i < order / 2; i++) + { +#ifdef BASOP_NOGLOB /* Critical Overflow */ + Ltemp = L_add_o(pq[i], pq[i + 1], &Overflow); +#else + Ltemp = L_add(pq[i], pq[i + 1]); +#endif + giOverflow = (Word16)Overflow; + move16(); + IF(EQ_16(giOverflow, 1)) + { + BREAK; + } + + p[i] = Ltemp; + move32(); + } + + IF(EQ_16(giOverflow, 1)) + { + FOR(i = 0; i < order; i++) + { + a[i] = mult_r(prev_a[i], pwAlpha[i]); + move16(); + } + return; + } + + compute_poly_product_fx(freq + 1, pq, order); + + + giOverflow = 0; + move16(); + Overflow = 0; + move16(); + + FOR(i = 0; i < order / 2; i++) + { +#ifdef BASOP_NOGLOB /* Critical Overflow */ + Ltemp = L_sub_o(pq[i + 1], pq[i], &Overflow); +#else + Ltemp = L_sub(pq[i + 1], pq[i]); +#endif + giOverflow = (Word16)Overflow; + move16(); + IF(EQ_16(giOverflow, 1)) + { + BREAK; + } + + q[i] = Ltemp; + move32(); + } + + IF(EQ_16(giOverflow, 1)) + { + FOR(i = 0; i < order; i++) + { + a[i] = mult_r(prev_a[i], pwAlpha[i]); + move16(); + } + } + ELSE + { + FOR(i = 0; i < order / 2; i++) + { + Overflow = 0; + move16(); +#ifdef BASOP_NOGLOB /* Critical Overflow */ + Lacc = L_add_o(p[i], q[i], &Overflow); /* p[i], q[i] in Q24 */ +#else + Lacc = L_add(p[i], q[i]); /* p[i], q[i] in Q24 */ +#endif + if (Overflow) + { + giOverflow = 1; + move16(); + } + + Lacc = L_negate(Lacc); /* Lacc=-(p[i]-q[i])/2 in Q25 */ + Overflow = 0; + move16(); +#ifdef BASOP_NOGLOB /* Critical Overflow */ + Lacc = L_add_o(L_shl_o(Lacc, 3, &Overflow), 0x08000, &Overflow); /* rounding */ +#else + Lacc = L_add(L_shl(Lacc, 3), 0x08000); /* rounding */ +#endif + if (Overflow) + { + giOverflow = 1; + move16(); + } + + a[i] = extract_h(Lacc); /* a[i] in Q12 */ + + IF(EQ_16(giOverflow,1)) + { + BREAK; + } + + } + FOR(i = 0; i < order / 2; i++) + { + Overflow = 0; + move16(); +#ifdef BASOP_NOGLOB /* Critical Overflow */ + Lacc = L_sub_o(q[i], p[i], &Overflow); /* p[i], q[i] in Q24 */ +#else + Lacc = L_sub(q[i], p[i]); /* p[i], q[i] in Q24 */ +#endif + if (Overflow) + { + giOverflow = 1; + move16(); + } + Overflow = 0; + move16(); +#ifdef BASOP_NOGLOB /* Critical Overflow */ + Lacc = L_add_o(L_shl_o(Lacc, 3, &Overflow), 0x08000, &Overflow); /* rounding */ +#else + Lacc = L_add(L_shl(Lacc, 3), 0x08000); /* rounding */ +#endif + if (Overflow) + { + giOverflow = 1; + move16(); + } + + a[order - 1 - i] = extract_h(Lacc); + + + IF(EQ_16(giOverflow,1)) + { + BREAK; + } + + } + } + + + IF(EQ_16(giOverflow, 1)) + { + FOR(i = 0; i < order; i++) + { + a[i] = mult_r(tmp_pci[i], pwAlpha[i]); + move16(); + } + } + +} + +/* + * E_LPC_f_lsp_pol_get + * + * Parameters: + * lsp/isp I: Line spectral pairs (cosine domaine) Q15 + * f O: the coefficients of F1 or F2 Q23 + * n I: no of coefficients (m/2) + * == NC for F1(z); == NC-1 for F2(z) + * fact I: scaling factor + * + *-----------------------------------------------------------* + * procedure E_LPC_f_lsp_pol_get: * + * ~~~~~~~~~~~ * + * Find the polynomial F1(z) or F2(z) from the LSPs. * + * This is performed by expanding the product polynomials: * + * * + * F1(z) = product ( 1 - 2 LSF_i z^-1 + z^-2 ) * + * i=0,2,4,6,8 * + * F2(z) = product ( 1 - 2 LSF_i z^-1 + z^-2 ) * + * i=1,3,5,7,9 * + * * + * where LSP_i are the LSPs in the cosine domain. * + * * + *-----------------------------------------------------------* + * R.A.Salami October 1990 * + *-----------------------------------------------------------* + */ +Word16 E_LPC_f_lsp_pol_get(const Word16 lsp[], Word32 f[], const Word16 n, const Word16 past_Ovf, const Word16 isMODE1) +{ + /* All computation in Q23 */ + const Word16 *plsp; + Word16 i, j; + Word16 b; + Word32 b32; + Word16 Ovf = 0; + Word16 Q_out; + Word16 m2; + +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + Q_out = 31 - 23; + move16(); + Ovf = past_Ovf; + move16(); + + test(); + if (past_Ovf && isMODE1) /* Currently this feature is implemented only in MODE1 */ + { + /* In some NB cases, overflow where detectected + in f1 or f2 polynomial computation when it + happen we reduce the precision of the computing + to limit the risk of saturation*/ + Q_out = add(Q_out, past_Ovf); + } + Overflow = 0; + move16(); + plsp = lsp; +#ifdef BASOP_NOGLOB /* Critical Overflow and all those below*/ + f[0] = L_shl_o(1, sub(31, Q_out), &Overflow); +#else + f[0] = L_shl(1, sub(31, Q_out)); +#endif + move32(); + /*b = -2.0f * *plsp;*/ + b = *plsp; + move16(); +#ifdef BASOP_NOGLOB /* Critical Overflow */ + m2 = shl_o(-2, sub(15, Q_out), &Overflow); + f[1] = L_mult_o(b, m2, &Overflow); +#else + m2 = shl(-2, sub(15, Q_out)); + f[1] = L_mult(b, m2); +#endif + move32(); + + FOR(i = 2; i <= n; i++) + { + plsp += 2; + /*b = 2.0f * *plsp;*/ + move16(); + b = *plsp; +#ifdef BASOP_NOGLOB /* Critical Overflow */ + b32 = L_mult_o(b, m2, &Overflow); +#else + b32 = L_mult(b, m2); +#endif + /*f[i] = -b*f[i-1] + 2.0f*f[i-2];*/ + move32(); +#ifdef BASOP_NOGLOB /* Critical Overflow */ + f[i] = L_shl_o(L_sub_o(f[i - 2], Mpy_32_16_1(f[i - 1], b), &Overflow), 1, &Overflow); +#else + f[i] = L_shl(L_sub(f[i - 2], Mpy_32_16_1(f[i - 1], b)), 1); +#endif + + FOR(j = i - 1; j > 1; j--) + { + /*f[j] += b*f[j-1] + f[j-2];*/ + move32(); +#ifdef BASOP_NOGLOB /* Critical Overflow */ + f[j] = L_add_o(f[j], L_sub_o(f[j - 2], L_shl_o(Mpy_32_16_1(f[j - 1], b), 1, &Overflow), &Overflow), &Overflow); +#else + f[j] = L_add(f[j], L_sub(f[j - 2], L_shl(Mpy_32_16_1(f[j - 1], b), 1))); +#endif + } + move32(); +#ifdef BASOP_NOGLOB /* Critical Overflow */ + f[1] = L_add_o(f[1], b32, &Overflow); +#else + f[1] = L_add(f[1], b32); +#endif + } + + + test(); + IF(Overflow > 0 && isMODE1) + { + /* If an overflow is detected, redo the computation with 1 bit less */ + Ovf = add(Ovf, 1); + Ovf = E_LPC_f_lsp_pol_get(lsp, f, n, Ovf, isMODE1); + } + return Ovf; +} + +void E_LPC_a_lsp_conversion( + const Word16 *a, /* input : LP filter coefficients (Qx) */ + Word16 *lsp, /* output: Line spectral pairs (in the cosine domain)(0Q15) */ + const Word16 *old_lsp, /* input : LSP vector from past frame (0Q15) */ + const Word16 m /* input : length of the LP filter coefficients */ +) +{ + Word16 i, nf, ip, nc; + Word16 xlow, ylow, xhigh, yhigh; + Word16 x, y, tmp, exp; + Word32 f[2][NC_MAX + 1]; + Word32 t0, t1; + Word32 sum, diff; + Word16 scale; + + + + nc = shr(m, 1); + + scale = shl(128, norm_s(a[0])); + + /*-------------------------------------------------------------* + * find the sum and diff polynomials F1(z) and F2(z) * + * F1(z) = [A(z) + z^11 A(z^-1)]/(1+z^-1) * + * F2(z) = [A(z) - z^11 A(z^-1)]/(1-z^-1) * + *-------------------------------------------------------------*/ + + f[0][0] = L_mult(a[0], scale); /*1.0f in Q23*/ move32(); + f[1][0] = L_mult(a[0], scale); /*1.0f in Q23*/ move32(); + FOR(i = 1; i < nc; i++) + { + t0 = L_mult(a[i], scale); /*Q23*/ + sum = L_mac(t0, a[m + 1 - i], scale); + diff = L_msu(t0, a[m + 1 - i], scale); + f[0][i] = L_sub(sum, f[0][i - 1]); + move32(); /*Q23*/ + f[1][i] = L_add(diff, f[1][i - 1]); + move32(); /*Q23*/ + } + t1 = L_mult0(a[i], scale); /*Q23-1*/ + sum = L_mac0(t1, a[m + 1 - i], scale); + diff = L_msu0(t1, a[m + 1 - i], scale); + f[0][nc] = L_sub(sum, L_shr(f[0][i - 1], 1)); + move32(); /*Q23-1*/ + f[1][nc] = L_add(diff, L_shr(f[1][i - 1], 1)); + move32(); /*Q23-1*/ + + /* Precalculate difference to index 0 for index 2 */ + f[0][2] = L_sub(f[0][2], f[0][0]); + move32(); + f[1][2] = L_sub(f[1][2], f[1][0]); + move32(); + + /*---------------------------------------------------------------------* + * Find the LSPs (roots of F1(z) and F2(z) ) using the * + * Chebyshev polynomial evaluation. * + * The roots of F1(z) and F2(z) are alternatively searched. * + * We start by finding the first root of F1(z) then we switch * + * to F2(z) then back to F1(z) and so on until all roots are found. * + * * + * - Evaluate Chebyshev pol. at grid points and check for sign change.* + * - If sign change track the root by subdividing the interval * + * 4 times and ckecking sign change. * + *---------------------------------------------------------------------*/ + nf = 0; + move16(); /* number of found frequencies */ + ip = 0; + move16(); /* indicator for f1 or f2 */ + + xlow = Grid[0]; + move16(); + ylow = chebyshev(xlow, f[ip], nc, 8); + + FOR(i = 1; i <= GRID100_POINTS; i++) + { + xhigh = xlow; + move16(); + yhigh = ylow; + move16(); + xlow = Grid[i]; + move16(); + ylow = chebyshev(xlow, f[ip], nc, 8); + + IF(L_mult(ylow, yhigh) <= 0) + { + t0 = L_mult(xhigh, 0x4000); + /* divide 2 times the interval */ + x = mac_r(t0, xlow, 0x4000); /* xmid = (xlow + xhigh)/2 */ + y = chebyshev(x, f[ip], nc, 8); + + IF(L_mult(ylow, y) <= 0) + { + yhigh = y; + move16(); + xhigh = x; + move16(); + y = ylow; + move16(); + x = xlow; + move16(); + /* 'xhigh' has changed, update 't0' */ + t0 = L_mult(xhigh, 0x4000); + } + xlow = mac_r(t0, x, 0x4000); /* xmid = (xlow + xhigh)/2 */ + ylow = chebyshev(xlow, f[ip], nc, 8); + + IF(L_mult(y, ylow) <= 0) + { + yhigh = ylow; + move16(); + xhigh = xlow; + move16(); + ylow = y; + move16(); + xlow = x; + move16(); + } + + /*--------------------------------------------------------* + * Linear interpolation + * xint = xlow - ylow*(xhigh-xlow)/(yhigh-ylow) + *--------------------------------------------------------*/ + y = msu_r(L_mult(yhigh, 0x4000), ylow, 0x4000); + + IF(y != 0) + { + x = sub(xhigh, xlow); + BASOP_SATURATE_WARNING_OFF + tmp = abs_s(y); + BASOP_SATURATE_WARNING_ON + exp = norm_s(tmp); + if (exp) + tmp = shl(tmp, exp); + tmp = div_s((Word16)16383 / 2, tmp); + t0 = L_mult(x, tmp); + t0 = L_shr(t0, sub(20, exp)); + tmp = extract_l(t0); /* y = (xhigh-xlow)/(yhigh-ylow) in Q11 */ + + /* Restore Sign */ + if (y < 0) + tmp = negate(tmp); + + t0 = L_mult(ylow, tmp); /* result in Q26 */ + t0 = L_shr(t0, 11); /* result in Q15 */ + xlow = sub(xlow, extract_l(t0));/* xint = xlow - ylow*y */ + } + lsp[nf++] = xlow; + move16(); + + IF(GE_16(nf, m)) + { + BREAK; + } + + ip = s_xor(ip, 1); + ylow = chebyshev(xlow, f[ip], nc, 8); + } + } + + /* Check if m roots found */ + /* if not use the LSPs from previous frame */ + + IF(LT_16(nf, m)) + { + FOR(i = 0; i < m; i++) + { + lsp[i] = old_lsp[i]; + move16(); + } + } + + + return; +} + +/* + * E_LPC_f_lsp_a_conversion + * + * Parameters: + * lsp I: Line spectral pairs Q15 + * a O: Predictor coefficients (order = m) Qx (The Q factor of the output to be deduced from a(0)) + * m I: order of LP filter + * + * Function: + * Convert ISPs to predictor coefficients a[] + * + * Returns: + * void + */ +void E_LPC_f_lsp_a_conversion(const Word16 *lsp, Word16 *a, const Word16 m) +{ + Word16 i, j, k; + Word32 f1[NC_MAX + 1], f2[NC_MAX + 1]; + Word16 nc; + Word32 t0; + Word16 Ovf, Ovf2; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + + /*-----------------------------------------------------* + * Find the polynomials F1(z) and F2(z) * + *-----------------------------------------------------*/ + + nc = shr(m, 1); + + assert(m == 16 || m == 10); + + Ovf = 0; + move16(); + Ovf = E_LPC_f_lsp_pol_get(&lsp[0], f1, nc, Ovf, 1); + Ovf2 = E_LPC_f_lsp_pol_get(&lsp[1], f2, nc, Ovf, 1); + IF(NE_16(Ovf2, Ovf)) + { + /* to ensure similar scaling for f1 and f2 in case + an overflow would be detected only in f2, + but this case never happen on my dtb */ + E_LPC_f_lsp_pol_get(&lsp[0], f1, nc, s_max(Ovf2, Ovf), 1); + } + /*-----------------------------------------------------* + * Multiply F1(z) by (1+z^-1) and F2(z) by (1-z^-1) * + *-----------------------------------------------------*/ + /*modification*/ + k = sub(nc, 1); + FOR(i = 0; i <= k; i++) + { + f1[nc - i] = L_add(f1[nc - i], f1[nc - i - 1]); + move32(); +#ifdef BASOP_NOGLOB + f2[nc - i] = L_sub_o(f2[nc - i], f2[nc - i - 1], &Overflow); +#else + f2[nc - i] = L_sub(f2[nc - i], f2[nc - i - 1]); +#endif + move32(); + } + + /*-----------------------------------------------------* + * A(z) = (F1(z)+F2(z))/2 * + * F1(z) is symmetric and F2(z) is antisymmetric * + *-----------------------------------------------------*/ + + t0 = L_deposit_l(0); + FOR(i = 1; i <= nc; i++) + { +#ifdef BASOP_NOGLOB + t0 = L_max(t0, L_abs(L_add_o(f1[i], f2[i], &Overflow))); +#else + t0 = L_max(t0, L_abs(L_add(f1[i], f2[i]))); +#endif + t0 = L_max(t0, L_abs(L_sub(f1[i], f2[i]))); + } + k = s_min(norm_l(t0), 6); + a[0] = shl(256, k); + move16(); + test(); + IF(Ovf || Ovf2) + { + a[0] = shl(256, sub(k, Ovf)); + move16(); + } + j = m; + FOR(i = 1; i <= nc; i++) + { + /* a[i] = 0.5*(f1[i] + f2[i]) */ +#ifdef BASOP_NOGLOB + t0 = L_add_o(f1[i], f2[i], &Overflow); +#else + t0 = L_add(f1[i], f2[i]); +#endif + t0 = L_shl(t0, k); +#ifdef BASOP_NOGLOB + a[i] = round_fx_o(t0, &Overflow); /* from Q23 to Qx and * 0.5 */ +#else + a[i] = round_fx(t0); /* from Q23 to Qx and * 0.5 */ +#endif + + /* a[j] = 0.5*(f1[i] - f2[i]) */ + t0 = L_sub(f1[i], f2[i]); + t0 = L_shl(t0, k); + a[j] = round_fx(t0); /* from Q23 to Qx and * 0.5 */ + j--; + } + + return; +} + +/*--------------------------------------------------------------------------- + * reorder_lsf() + * + * To make sure that the LSFs are properly ordered and to keep a certain + * minimum distance between consecutive LSFs. + *--------------------------------------------------------------------------*/ +void reorder_lsf_fx( + Word16 *lsf, /* i/o: LSFs in the frequency domain (0..0.5) Q(x2.56)*/ + const Word16 min_dist, /* i : minimum required distance x2.56*/ + const Word16 n, /* i : LPC order */ + const Word32 fs /* i : sampling frequency */ +) +{ + Word16 i, lsf_min, n_m_1; + Word16 lsf_max; + + lsf_min = min_dist; + move16(); + + /*-----------------------------------------------------------------------* + * Verify the LSF ordering and minimum GAP + *-----------------------------------------------------------------------*/ + + FOR(i = 0; i < n; i++) + { + if (LT_16(lsf[i], lsf_min)) + { + lsf[i] = lsf_min; + move16(); + } + lsf_min = add(lsf[i], min_dist); + } + + /*-----------------------------------------------------------------------* + * Reverify the LSF ordering and minimum GAP in the reverse order (security) + *-----------------------------------------------------------------------*/ + lsf_max = round_fx(L_sub(L_shr(L_mult0(extract_l(L_shr(fs, 1)), 1311), 9 - 16), L_deposit_h(min_dist))); /* Q0 + Q9 , 1311 is 2.56 in Q9 */ + n_m_1 = sub(n, 1); + IF(GT_16(lsf[n_m_1], lsf_max)) /* If danger of unstable filter in case of resonance in HF */ + { + FOR(i = n_m_1; i >= 0; i--) /* Reverify the minimum LSF gap in the reverse direction */ + { + if (GT_16(lsf[i], lsf_max)) + { + lsf[i] = lsf_max; + move16(); + } + lsf_max = sub(lsf[i], min_dist); + } + } +} + +void space_lsfs_fx( + Word16* lsfs, /* i/o: Line spectral frequencies */ + const Word16 order /* i : order of LP analysis */ +) +{ + Word16 delta; /* Q1.15 */ + Word16 i, flag = 1; + + WHILE(flag == 1) + { + flag = 0; + move16(); + FOR(i = 0; i <= order; i++) + { + IF(i == 0) + { + delta = lsfs[0]; + move16(); + } + ELSE + { + IF(EQ_16(i,order)) + { + delta = sub(HALF_POINT_FX, lsfs[i - 1]); + move16(); + } + ELSE + { + delta = sub(lsfs[i], lsfs[i - 1]); + move16(); + } + } + IF(LT_16(delta, SPC_FX)) + { + flag = 1; + move16(); + delta = sub(delta, SPC_PLUS_FX); + + IF(i == order) + { + lsfs[i - 1] = add(lsfs[i - 1], delta); + move16(); + } + ELSE + { + IF(i == 0) + { + lsfs[i] = sub(lsfs[i], delta); + move16(); + } + ELSE + { + delta = mult_r(delta, HALF_POINT_FX); + lsfs[i - 1] = add(lsfs[i - 1], delta); + move16(); + lsfs[i] = sub(lsfs[i], delta); + move16(); + } + } + } + } + } + + return; +} + +/*=================================================================== */ +/* FUNCTION : lsp_weights_fx () */ +/*------------------------------------------------------------------- */ +/* PURPOSE : This function computes the weights for the */ +/* given unquantized lsp vector */ +/*------------------------------------------------------------------- */ +/* INPUT ARGUMENTS : +_ (Word16 []) lsp_nq_fx: input unquantized lsp vector */ +/* _(Word16 Order) FilterOrder */ +/*------------------------------------------------------------------- */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16 []) w: weight vector Q(9-n_max) */ + +/*------------------------------------------------------------------- */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ None. */ +/*------------------------------------------------------------------- */ +/* RETURN ARGUMENTS : */ +/* _ None. */ +/*=================================================================== */ + +void lsp_weights_fx( + Word16 lsp_nq_fx[], + Word16 w[], + Word16 Order, + Word16* Qout +) +{ + Word16 lpcOrder = Order; + + Word16 i, n1, tmp_loop; + Word16 norm[20]; + Word32 Lsum1[20]; + Word16 delta1, delta2, temp; + Word16 n_max = -32768; + move16(); + + temp = 0; + move16(); + + tmp_loop = sub(lpcOrder, 1); + FOR(i = 0; i < tmp_loop; i++) + { + delta1 = sub(lsp_nq_fx[i], temp); + delta2 = sub(lsp_nq_fx[i + 1], lsp_nq_fx[i]); + Lsum1[i] = calc_weight(delta1, delta2, &n1); + move32();/* Q( 26-n1) */ + norm[i] = n1; + move16(); + + if (GT_16(norm[i], n_max)) + { + n_max = norm[i]; + move16(); + } + temp = lsp_nq_fx[i]; + move16(); + } + delta1 = sub(lsp_nq_fx[i], temp); + delta2 = sub(16384, lsp_nq_fx[i]); + + Lsum1[i] = calc_weight(delta1, delta2, &n1); + move32(); /* Q( 26-n1) */ + norm[i] = n1; + move16(); + + if (GT_16(norm[i], n_max)) + { + n_max = norm[i]; + move16(); + } + FOR(i = 0; i < lpcOrder; i++) + { + w[i] = round_fx(L_shl(Lsum1[i], sub(norm[i], n_max + 1))); /* Q( 9-n_max) */ + } + + IF(lpcOrder != LPC_SHB_ORDER_WB) + { + w[3] = round_fx(L_shl(L_mult(w[3], 18022), 1)); /* Q( 9-n_max) */ + w[4] = round_fx(L_shl(L_mult(w[4], 18022), 1)); /* Q( 9-n_max) */ + } + + *Qout = 9 - n_max; + move16(); +} + +/* + * E_LPC_isf_isp_conversion + * + * Parameters: + * isf I: isf[m] normalized (range: 0 <= val <= 0.5) 14Q1*1.28 + * isp O: isp[m] (range: -1 <= val < 1) Q15 + * m I: LPC order + * + * Function: + * Transformation isf to isp + * + * ISF are immitance spectral pair in frequency domain (0 to 6400). + * ISP are immitance spectral pair in cosine domain (-1 to 1). + * + * Returns: + * void + */ +void E_LPC_isf_isp_conversion(const Word16 isf[], Word16 isp[], const Word16 m) +{ + Word16 i; + + assert(m == 16 || m == 10); + + + FOR(i = 1; i < m; i++) + { + *isp++ = xsf_to_xsp(*isf++); + move16(); + } + *isp = xsf_to_xsp(shl(*isf, 1)); + move16(); + + + return; +} + +/* + * E_LPC_isp_isf_conversion + * + * Parameters: + * isp I: isp[m] (range: -1 <= val < 1) Q15 + * isf O: isf[m] normalized (range: 0 <= val <= 6400) x1.28 + * m I: LPC order + * + * Function: + * Transformation isp to isf + * + * ISP are immitance spectral pair in cosine domain (-1 to 1). + * ISF are immitance spectral pair in frequency domain (0 to 6400). + * + * Returns: + * energy of prediction error + */ +void E_LPC_isp_isf_conversion(const Word16 isp[], Word16 isf[], const Word16 m) +{ + Word16 i; + + assert(m == 16 || m == 10); + + + + FOR(i = 0; i < m; i++) + { + isf[i] = xsp_to_xsf(isp[i]); + move16(); + } + + isf[m - 1] = shr(isf[m - 1], 1); + move16(); + + + return; +} + + +Word16 xsf_to_xsp(Word16 lsf) +{ + /* lsp = cos(lsf * 3.1415/6400); */ + return getCosWord16R2(lsf); +} + +Word16 xsp_to_xsf(Word16 lsp) +{ + Word16 ind, tmp; + Word32 L_tmp; + + + /*------------------------------------------------------* + * find value in table that is just greater than lsp + *------------------------------------------------------*/ + + /* Retrieve Index Guess */ + /* Based on lsp */ + ind = mac_r(GUESS_TBL_SZ / 2 * 65536 - 0x8000, lsp, GUESS_TBL_SZ / 2); + ind = Ind_Guess[ind]; + move16(); + + /* Correct Index so that */ + /* cos_table_129[ind] > isp[i] */ + tmp = sub(lsp, cos_table_129[ind]); + /* + 69%: (Final Index - Index Guess) is <= 1 + 28%: (Final Index - Index Guess) is 2 + 2%: (Final Index - Index Guess) is >= 3 + <1%: ... + */ + IF(tmp > 0) /* possible range 0 to -5 (-1-2-2) */ + { + ind = sub(ind, 1); + tmp = sub(lsp, cos_table_129[ind]); + + IF(tmp > 0) + { + ind = sub(ind, 2); + tmp = sub(lsp, cos_table_129[ind]); + if (tmp > 0) + { + ind = sub(ind, 2); + } + tmp = sub(lsp, cos_table_129[ind + 1]); + if (tmp <= 0) + { + ind = add(ind, 1); + } + tmp = sub(lsp, cos_table_129[ind]); + } + } + + /* acos(lsp)= ind*128 + (lsp-cos_table_129[ind]) * acos_slope[ind] / 2048 */ + L_tmp = L_mac(1L << 11, tmp, acos_slope[ind]); + L_tmp = L_shr(L_tmp, 12); /* (lsp-cos_table_129[ind]) * acos_slope[ind]) >> 11 */ + L_tmp = L_mac0(L_tmp, ind, 128); + + + return extract_l(L_tmp); +} + +/*-------------------------------------------------------------------* + * a2rc() + * + * Convert from LPC to reflection coeff + *-------------------------------------------------------------------*/ + +void a2rc_fx(const Word16* a, /* i: can be any Q */ + Word16* refl, /* o: Q15 */ + Word16 lpcorder +) + +{ + Word16 f_fx[M]; + Word16 km_fx; + Word32 L_tmp1, L_tmp2; + Word16 tmp; + Word16 denom_mant, exp; + Word32 new_mant; + Word16 temp; + Word16 m, j, n; + Word16 q, q_a, q_a2, One_Qx; + Word32 One_Qx2; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + q = add(norm_s(a[-1]), 1); + q_a = sub(15, q); + q_a2 = add(shl(q_a, 1), 1); + /* copy into internal vars so they can be changed */ + + FOR(m = 0; m < lpcorder; m++) + { + /* f_fx[m] = p_fx[m]; */ + f_fx[m] = negate(a[m]); + move16(); + } + One_Qx = shl(1, q_a); + One_Qx2 = L_shl(1, q_a2); + FOR(m = lpcorder - 1; m >= 0; m--) + { + km_fx = f_fx[m]; + move16(); + + test(); + IF(LE_16(km_fx, negate(One_Qx)) || GE_16(km_fx, One_Qx)) + { + FOR(j = 0; j < lpcorder; j++) + { + refl[j] = 0; + move16(); + } + + return; + } + + refl[m] = negate(km_fx); + move16(); + L_tmp1 = One_Qx2; /* 1 in 2xq_a+1 */ + move32(); + L_tmp1 = L_msu(L_tmp1, km_fx, km_fx); /* 1-km*km in Q25 */ + + /* new_mant = invert_dp(L_tmp1,4, &tmp_denom_exp,1); sum in Q61-Q25-n=Q36-n */ + exp = norm_l(L_tmp1); + tmp = extract_h(L_shl(L_tmp1, exp)); + exp = sub(sub(30, exp), q_a2); + IF(tmp) + { + tmp = div_s(16384, tmp); /* 15+exp */ + } + ELSE + { + tmp = 0; + } + new_mant = L_deposit_h(tmp); + temp = round_fx(L_shl(new_mant, 0)); /* in Q14 */ + denom_mant = temp; + move16(); + L_tmp1 = L_mult(km_fx, denom_mant); /* km*denom. Q12*Q14 = Q27 */ + L_tmp1 = L_shl(L_tmp1, q); /* change to Q31. simulation showed no overflow */ + tmp = round_fx(L_tmp1); /* extract in Q15 */ + + FOR(j = 0; j < m / 2; j++) + { + n = sub(sub(m, (Word16)1), j); + L_tmp1 = L_mult(denom_mant, f_fx[j]); /* denom*f[j]. Q15*Q12 = Q28 (floating with exp) */ +#ifdef BASOP_NOGLOB + L_tmp1 = L_mac_o(L_tmp1, tmp, f_fx[n], &Overflow); /* denom*f[j]+km*denom*f[n] in Q28 (floating with exp) */ +#else + L_tmp1 = L_mac(L_tmp1, tmp, f_fx[n]); /* denom*f[j]+km*denom*f[n] in Q28 (floating with exp) */ +#endif + L_tmp2 = L_mult(denom_mant, f_fx[n]); /* denom*f[n]. Q15*Q12 = Q28 (floating with exp) */ +#ifdef BASOP_NOGLOB + L_tmp2 = L_mac_o(L_tmp2, tmp, f_fx[j], &Overflow); /* denom*f[n]+km*denom*f[j] in Q28 (floating with exp) */ + L_tmp1 = L_shr_o(L_tmp1, exp, &Overflow); /* bringing to true Q28 */ + L_tmp2 = L_shr_o(L_tmp2, exp, &Overflow); /* bringing to true Q28 */ + f_fx[j] = round_fx_o(L_tmp1, &Overflow); /* extracting in q_a */ + f_fx[n] = round_fx_o(L_tmp2, &Overflow); /* extracting in q_a */ +#else + L_tmp2 = L_mac(L_tmp2, tmp, f_fx[j]); /* denom*f[n]+km*denom*f[j] in Q28 (floating with exp) */ + L_tmp1 = L_shr(L_tmp1, exp); /* bringing to true Q28 */ + L_tmp2 = L_shr(L_tmp2, exp); /* bringing to true Q28 */ + f_fx[j] = round_fx(L_tmp1); /* extracting in q_a */ + f_fx[n] = round_fx(L_tmp2); /* extracting in q_a */ +#endif + } + + IF(m & 1) + { + L_tmp1 = L_mult(denom_mant, f_fx[j]); /* denom*f[j]. Q15*Q12 = Q28 (floating with exp) */ +#ifdef BASOP_NOGLOB + L_tmp1 = L_mac_o(L_tmp1, tmp, f_fx[j], &Overflow); /* denom*f[j]+km*denom*f[j] in Q28 (floating with exp) */ + L_tmp1 = L_shr_o(L_tmp1, exp, &Overflow); /* bringing to true Q28 */ + f_fx[j] = round_fx_o(L_tmp1, &Overflow); /* extracting in q_a */ +#else + L_tmp1 = L_mac(L_tmp1, tmp, f_fx[j]); /* denom*f[j]+km*denom*f[j] in Q28 (floating with exp) */ + L_tmp1 = L_shr(L_tmp1, exp); /* bringing to true Q28 */ + f_fx[j] = round_fx(L_tmp1); /* extracting in q_a */ +#endif + } + } + + FOR(j = 0; j < lpcorder; j++) + { + refl[j] = shl(refl[j], q); + move16(); + } + + + return; +} +Word16 vq_dec_lvq_fx( + Word16 sf_flag, /* i : safety net flag */ + Word16 x[], /* o : Decoded vector Q(x2.56)*/ + Word16 indices[], /* i : Indices */ + Word16 stages, /* i : Number of stages */ + Word16 N, /* i : Vector dimension */ + Word16 mode, /* (i): mode_lvq, or mode_lvq_p */ + Word16 no_bits, /* (i): no. bits for lattice */ + Word32 *p_offset_scale1, + Word32 *p_offset_scale2, + Word32 *p_offset_scale1_p, + Word32 *p_offset_scale2_p, + Word16 *p_no_scales, + Word16 *p_no_scales_p +) +{ + Word16 x_lvq[M]; + Word16 i, stagesm1; + Word16 pt_fx; + Word16 ber_flag; + + /* clear vector */ + set16_fx(x, 0, N); + + /*-----------------------------------------------* + * add contribution of each stage + *-----------------------------------------------*/ + stagesm1 = sub(stages, 1); + IF(EQ_16(sf_flag, 1)) + { + FOR(i = 0; i < stagesm1; i++) + { + pt_fx = i_mult2(indices[i], N); + Vr_add(x, &Quantizers_fx[CB_lsf[mode] + i][pt_fx], x, N); + } + + ber_flag = + deindex_lvq_fx(&indices[stagesm1], x_lvq, mode, sf_flag, no_bits, p_offset_scale1, p_offset_scale2, p_no_scales); + + } + ELSE + { + FOR(i = 0; i < stagesm1; i++) + { + pt_fx = i_mult2(indices[i], N); + Vr_add(x, &Quantizers_p_fx[CB_p_lsf[mode] + i][pt_fx], x, N); + } + + ber_flag = + deindex_lvq_fx(&indices[stagesm1], x_lvq, mode, sf_flag, no_bits, p_offset_scale1_p, p_offset_scale2_p, p_no_scales_p); + } + + Vr_add(x, x_lvq, x, N); + + return ber_flag; +} + +ivas_error lsf_allocate_fx( + const Word16 nBits, /* i : Number of bits to use for quantization */ + const Word16 framemode, /* i : ISF quantizer mode */ + const Word16 framemode_p, /* i : ISF quantizer mode predmode (mode_lvq_p) */ + Word16 *stages0, /* o : Number of stages for safety-net quantizer */ + Word16 *stages1, /* o : Number of stages for predictive quantizer */ + Word16 levels0[], /* o : Number of vectors for each stage for SFNET */ + Word16 levels1[], /* o : Number of vectors for each stage for pred */ + Word16 bits0[], /* o : Number of bits for each stage safety net */ + Word16 bits1[] /* o : Number of bits for each stage pred */ +) +{ + Word16 i; + Word16 cumleft; + Word16 bits_lvq, n_stages, nbits0; + ivas_error error; + + error = IVAS_ERR_OK; + + cumleft = nBits; + move16(); + + /*---------------------------------------------------* + * Calculate bit allocation for safety-net quantizer + *---------------------------------------------------*/ + + cumleft = BitsVQ[framemode]; + move16(); + bits_lvq = sub(nBits, cumleft); + nbits0 = CBbits[framemode]; + move16(); + IF(GT_16(nbits0, -1)) + { + IF(nbits0 > 0) + { + n_stages = 2; + move16(); + levels0[0] = CBsizes[nbits0]; + move16(); + bits0[0] = nbits0; + move16(); + bits0[1] = sub(cumleft, nbits0); + + IF(bits0[1] == 0) + { + n_stages = sub(n_stages, 1); + } + ELSE + { + levels0[1] = CBsizes[sub(cumleft,nbits0)]; + move16(); + } + } + ELSE /* no bits for VQ stage */ + { + n_stages = 0; + move16(); + } + + *stages0 = n_stages; + move16(); + IF(bits_lvq > 0) + { + bits0[n_stages] = bits_lvq; + move16(); + levels0[n_stages] = bits_lvq; + move16();/* this is number of bits, not levels */ + *stages0 = add(n_stages, 1); + move16(); + } + } + ELSE + { + *stages0 = 0; + move16(); + } + + /*---------------------------------------------------* + * Calculate bit allocation for predictive quantizer + *---------------------------------------------------*/ + IF(GT_16(framemode_p, -1)) + { + cumleft = BitsVQ_p[framemode_p]; + move16(); + bits_lvq = sub(nBits, cumleft); + nbits0 = CBbits_p[framemode_p]; + move16(); + + IF(GT_16(nbits0, -1)) + { + IF(nbits0 > 0) + { + IF(EQ_16(framemode_p, 7)) + { + /* for UNVOICED_WB only */ + n_stages = 3; + move16(); + FOR(i = 0; i < n_stages; i++) + { + levels1[i] = CBsizes[nbits0]; + move16(); + bits1[i] = nbits0; + move16(); + } + bits1[n_stages] = bits_lvq; + move16(); + levels1[n_stages] = bits_lvq; + move16(); + *stages1 = add(n_stages, 1); + } + ELSE + { + n_stages = 1; + move16(); + levels1[0] = CBsizes[nbits0]; + move16(); + bits1[0] = nbits0; + move16(); + nbits0 = sub(cumleft, nbits0); + IF(nbits0 > 0) + { + levels1[1] = CBsizes[nbits0]; + move16(); + bits1[1] = nbits0; + move16(); + n_stages = 2; + move16(); + } + + levels1[n_stages] = bits_lvq; + move16();/* this is number of bits, not levels */ + bits1[n_stages] = bits_lvq; + move16(); + *stages1 = add(n_stages ,1); + } + } + ELSE + { + *stages1 = 1; + move16(); + bits1[0] = bits_lvq; + move16(); + levels1[0] = bits_lvq; + move16(); + } + } +#ifdef DEBUGGING + ELSE + { + return IVAS_ERROR(IVAS_ERR_INTERNAL_FATAL, "lsf_allocate(): invalid number of bits in used predictive mode\n"); + } +#endif + } + + return error; +} + +ivas_error find_pred_mode( + Word16* predmode, /* o: prediction mode */ + const Word16 coder_type, /* i: coding type */ + const Word16 bwidth, /* i: bandwidth index */ + const Word32 int_fs, /* i: sampling frequency */ + Word16 * p_mode_lvq, /* o: index of LSF codebooks in safety net mode */ + Word16 * p_mode_lvq_p, /* o: index of LSF codebooks in predictive mode (AR or MA) */ + Word32 core_brate /* i: core bit rate */ +) +{ + Word16 idx; + ivas_error error; + + error = IVAS_ERR_OK; + + /* bwidth = 0(NB), 1 (WB), 2(WB2); line index in predmode_tab[][] */ + idx = bwidth; + move16(); + if (GT_16(idx, 1)) + { + idx = 1; + } + IF(EQ_32(int_fs, INT_FS_16k)) + { + /* WB2 is actually used if sampling frequency is 16kHz */ + idx = 2; + move16(); + } + ELSE + { + test(); + test(); + if ((GE_32(core_brate, GENERIC_MA_LIMIT)) && (EQ_16(coder_type,GENERIC)) && (EQ_16(idx,1))) + { + idx = 3; + move16(); + } + } + *predmode = predmode_tab[idx][coder_type]; + move16(); + IF(LE_16(idx, 2)) + { + *p_mode_lvq = add(i_mult2(NO_CODING_MODES, idx), coder_type); + IF(*predmode > 0) + { + *p_mode_lvq_p = *p_mode_lvq; + move16(); + } + ELSE + { + *p_mode_lvq_p = -1; + move16(); + } + } + ELSE /* WB 12.8 with MA pred in GENERIC*/ + { + *p_mode_lvq = add(NO_CODING_MODES, coder_type); + IF(EQ_16(coder_type, GENERIC)) + { + *p_mode_lvq_p = 18; + move16(); + } + ELSE + { + IF(*predmode > 0) + { + *p_mode_lvq_p = *p_mode_lvq; + } + ELSE + { + *p_mode_lvq_p = -1; + } + } + } +#ifdef DEBUGGING + if (*predmode == -1) + { + return IVAS_ERROR(IVAS_ERR_INTERNAL_FATAL, "\nfind_pred_mode(): incorrect coder_type specification: %d\n", coder_type); + } +#endif + + + return error; +} + +/*---------------------------------------------------------------------------* + * reorder_isf + * + * To make sure that the isfs are properly ordered and to keep a certain + * minimum distance between consecutive isfs. + *--------------------------------------------------------------------------*/ +void reorder_isf_fx( + Word16 *isf, /* i/o: ISFs in the frequency domain (0..0.5) */ + const Word16 min_dist, /* i : minimum required distance */ + const Word16 n, /* i : LPC order */ + const Word16 fs /* i : sampling frequency */ +) +{ + Word16 i, isf_min; + Word16 isf_max; + + isf_min = min_dist; + move16(); + + /*-----------------------------------------------------------------------* + * Verify the ISF ordering and minimum GAP + *-----------------------------------------------------------------------*/ + + FOR(i = 0; i < n - 1; i++) + { + if (LT_16(isf[i], isf_min)) + { + isf[i] = isf_min; + move16(); + } + isf_min = add(isf[i], min_dist); + } + + /*-----------------------------------------------------------------------* + * Reverify the ISF ordering and minimum GAP in the reverse order (security) + *-----------------------------------------------------------------------*/ + + /*isf_max = sub(shr(fs,1), min_dist);*/ + isf_max = sub(fs, min_dist); /* Fs already divide per 2 */ + + IF(GT_16(isf[n - 2], isf_max)) /* If danger of unstable filter in case of resonance in HF */ + { + FOR(i = sub(n, 2); i >= 0; i--) /* Reverify the minimum ISF gap in the reverse direction */ + { + if (GT_16(isf[i], isf_max)) + { + isf[i] = isf_max; + move16(); + } + isf_max = sub(isf[i], min_dist); + } + } +} + +/*========================================================================*/ +/* FUNCTION : lsf_stab_fx() */ +/*------------------------------------------------------------------------*/ +/* PURPOSE : Check LSF stability (distance between old LSFs and */ +/* current LSFs) */ +/*------------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode */ +/* _ (Word16*) lsf : LSPs from past frame Q(x2.56) */ +/* _ (Word16*) lsfold : LSPs from past frame Q(x2.56) */ +/*------------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/*------------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/*------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ (Word16) stab_fac_fx : LP filter stability Q15 */ +/*========================================================================*/ +Word16 lsf_stab_fx( /* o : LP filter stability Q15*/ + const Word16 *lsf, /* i : LSF vector Q(x2.56)*/ + const Word16 *lsfold, /* i : old LSF vector Q(x2.56)*/ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame /* i : frame length */ +) +{ + Word16 i, m; + Word32 L_tmp; + Word16 tmp, e; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + /*-------------------------------------------------------------------* + * Check stability on lsf: distance between old lsf and current lsf + *-------------------------------------------------------------------*/ + IF(Opt_AMR_WB) + { + m = M - 1; + move16(); + tmp = sub(lsf[0], lsfold[0]); + L_tmp = L_mult(tmp, tmp); /* Q1 */ + FOR(i = 1; i < m; i++) + { + tmp = sub(lsf[i], lsfold[i]); + L_tmp = L_mac(L_tmp, tmp, tmp); /* Q1 */ + } + } + ELSE + { + m = M; + move16(); + L_tmp = 0; + move32(); + FOR(i = 0; i < m; i++) + { + tmp = sub(lsf[i], lsfold[i]); + L_tmp = L_mac(L_tmp, tmp, tmp); /* Q1 */ + } + } + + e = norm_l(L_tmp); + L_tmp = L_shl(L_tmp, e); /*Q(1+e)*/ + + IF(L_frame == L_FRAME16k) + { + /*stab_fac = (float)(1.25f - (tmp/625000.0f));*/ + L_tmp = Mpy_32_16_1(L_tmp, 16777); /* 30-eQ(1+e)*-21Q36 = 30-21-eQ31-9+e */ + } + ELSE + { + /* stab_fac = (float)(1.25f - (tmp1/400000.0f*2.56=1024000)) */ + L_tmp = Mpy_32_16_1(L_tmp, 26214); /* 30-eQ(1+e)*-21Q36 = 30-21-eQ31-9+e */ + } + + e = sub(30 - 21 - 1, e); +#ifdef BASOP_NOGLOB + tmp = round_fx_o(L_shl_o(L_tmp, e, &Overflow), &Overflow); /*Q14*/ +#else /* BASOP_NOGLOB */ + tmp = round_fx(L_shl(L_tmp, e)); /*Q14*/ +#endif /* BASOP_NOGLOB */ + + tmp = sub(20480, tmp); /* 1.25 - tmp in Q14 */ +#ifdef BASOP_NOGLOB + tmp = shl_o(tmp, 1, &Overflow); /* Q14 -> Q15 with saturation */ +#else /* BASOP_NOGLOB */ + tmp = shl(tmp, 1); /* Q14 -> Q15 with saturation */ +#endif + + tmp = s_max(tmp, 0); + + return tmp; +} +/*-------------------------------------------------------------------* + * lsp2isp() + * + * Convert LSPs to ISPs via predictor coefficients A[] + *-------------------------------------------------------------------*/ + +void lsp2isp_fx( + const Word16 *lsp, /* i : LSP vector */ + Word16 *isp, /* o : ISP filter coefficients */ + Word16 *stable_isp, /* i/o: ISP filter coefficients */ + const Word16 m /* i : order of LP analysis */ +) +{ + Word16 a[M + 1]; + + /* LSP --> A */ + /*lsp2a_stab( lsp, a, m );*/ + E_LPC_f_lsp_a_conversion(lsp, a, m); + + /* A --> ISP */ + /*a2isp( a, isp, stable_isp, grid );*/ + E_LPC_a_isp_conversion(a, isp, stable_isp, m); + + /* Update to latest stable ISP */ + Copy(isp, stable_isp, M); +} +/*-------------------------------------------------------------------* + * isp2lsp() + * + * Convert ISPs to LSPs via predictor coefficients A[] + *-------------------------------------------------------------------*/ + +void isp2lsp_fx( + const Word16 *isp, /* i : LSP vector */ + Word16 *lsp, /* o : ISP filter coefficients */ + Word16 *stable_lsp, /* i/o: stable LSP filter coefficients */ + const Word16 m /* i : order of LP analysis */ +) +{ + Word16 a[M + 1]; + + /* ISP --> A */ + /*isp2a( isp, a, m );*/ + E_LPC_f_isp_a_conversion(isp, a, m); + /* A --> LSP */ + /*a2lsp_stab( a, lsp, stable_lsp, grid );*/ + E_LPC_a_lsp_conversion(a, lsp, stable_lsp, m); + /* Update to latest stable LSP */ + Copy(lsp, stable_lsp, M); +} + +/*-------------------------------------------------------------------* + * lsf2isf() + * + * Convert LSPs to ISPs + *-------------------------------------------------------------------*/ + +void lsf2isf_fx( + const Word16 *lsf, /* i : LSF vector */ + Word16 *isf, /* o : ISF vector */ + Word16 *stable_isp, /* i/o: stable ISP filter coefficients */ + const Word16 m /* i : order of LP analysis */ +) +{ + Word16 tmp_lsp[M]; + Word16 tmp_isp[M]; + + /* LSF --> LSP */ + /*lsf2lsp( lsf, tmp_lsp, m, int_fs );*/ + E_LPC_lsf_lsp_conversion(lsf, tmp_lsp, m); + + /* LSP --> ISP */ + lsp2isp_fx(tmp_lsp, tmp_isp, stable_isp, m); + + /* ISP --> ISF */ + /*isp2isf( tmp_isp, isf, m, int_fs );*/ + E_LPC_isp_isf_conversion(tmp_isp, isf, m); + + return; +} +/*-------------------------------------------------------------------* + * isf2lsf() + * + * Convert ISFs to LSFs + *-------------------------------------------------------------------*/ + +void isf2lsf_fx( + const Word16 *isf, /* i : ISF vector */ + Word16 *lsf, /* o : LSF vector */ + Word16 *stable_lsp /* i/o: stable LSP filter coefficients */ +) +{ + Word16 tmp_isp[M]; + Word16 tmp_lsp[M]; + + /* ISF --> ISP */ + /*isf2isp( isf, tmp_isp, m, int_fs );*/ + E_LPC_isf_isp_conversion(isf, tmp_isp, M); + /* ISP --> LSP */ + isp2lsp_fx(tmp_isp, tmp_lsp, stable_lsp, M); + + /* LSP --> LSF */ + /*lsp2lsf( tmp_lsp, lsf, m, int_fs );*/ + E_LPC_lsp_lsf_conversion(tmp_lsp, lsf, M); + return; +} +/*==========================================================================*/ +/* FUNCTION : void lsp2lsf_fx () */ +/*--------------------------------------------------------------------------*/ +/* PURPOSE : */ +/* * Transformation of LSPs to LSFs */ +/* * LSP are line spectral pair in cosine domain (-1 to 1). */ +/* * LSF are line spectral frequencies (0 to fs/2). */ +/*--------------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* Word16 lsp[] i : lsp[m] (range: -1<=val<1) Q15 */ +/* Word16 m i : LPC order Q0 */ +/*--------------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* Word16 lsf[] o : lsf[m] normalized (range: 0.0<=val<=0.5) Q(x2.56)*/ +/*--------------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/*--------------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ None */ +/*--------------------------------------------------------------------------*/ +/* CALLED FROM : */ +/*==========================================================================*/ +void lsp2lsf_fx( + const Word16 lsp[], /* i : lsp[m] (range: -1<=val<1) Q15*/ + Word16 lsf[], /* o : lsf[m] normalized (range: 0.0<=val<=0.5) Q(x2.56)*/ + const Word16 m, /* i : LPC order Q0*/ + const Word32 int_fs /* i : internal sampling frequency */ +) +{ + Word16 i; + Word32 L_tmp; + + FOR(i = 0; i < m; i++) + { + /*------------------------------------------------------* + * find value in table that is just greater than lsp[i] + *------------------------------------------------------*/ + + /* Retrieve Index Guess */ + /* Based on lsp[i] */ + L_tmp = sub_lsp2lsf_fx(lsp[i]); + IF(EQ_32(int_fs, INT_FS_16k_FX)) + { + L_tmp = L_shr(L_mult0(extract_l(L_tmp), 5), 2); + } + lsf[i] = extract_l(L_tmp); + } +} +/*===========================================================================*/ +/* FUNCTION : lsf2lsp_fx() */ +/*---------------------------------------------------------------------------*/ +/* PURPOSE : Transformation of LSFs to LSPs */ +/* LSP are line spectral pairs in cosine domain (-1 to 1). */ +/* LSF are line spectral frequencies (0 to fs/2). */ +/*---------------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* _ (Word16[]) lsf : lsf[m] normalized (range: 0.0<=val<=0.5) Q(x2.56) */ +/* _ (Word16) m : LPC order */ +/*---------------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16*) lsp : lsp[m] (range: -1<=val<1) Q15 */ +/*---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ None */ +/*===========================================================================*/ +void lsf2lsp_fx( + const Word16 lsf[], /* i : lsf[m] normalized (range: 0.0<=val<=0.5) x2.56 */ + Word16 lsp[], /* o : lsp[m] (range: -1<=val<1) Q15 */ + const Word16 m, /* i : LPC order Q0 */ + const Word32 int_fs /* i : internal sampling frequency */ +) +{ + Word16 i, ind, offset; + Word32 L_tmp; + Word16 c, ind2; + Word16 const add_prec = 4; + Word16 lsf_tmp; + + + /* 0.75 = (1<hLPDmem; + + *clip_var = st_fx->clip_var_fx[0]; + move16(); + + FOR(i = 0; i < M; i++) + { + mem_AR[i] = st_fx->mem_AR_fx[i]; + move16(); + mem_MA[i] = st_fx->mem_MA_fx[i]; + move16(); + lsp_new_bck[i] = lsp_new[i]; + move16(); + lsf_new_bck[i] = lsf_new[i]; + move16(); + lsp_mid_bck[i] = lsp_mid[i]; + move16(); + } + + *mCb1 = st_fx->mCb1_fx; + move16(); + *streaklimit = st_fx->streaklimit_fx; + move16(); + *pstreaklen = st_fx->pstreaklen_fx; + move16(); + + FOR(i = 0; i < L_FFT; i++) + { + Bin_E[i] = st_fx->Bin_E_fx[i]; + move32(); + } + + FOR(i = 0; i < (L_FFT / 2); i++) + { + Bin_E_old[i] = st_fx->Bin_E_old_fx[i]; + move32(); + } + + /* back-up memories */ + FOR(i = 0; i < M; i++) + { + mem_syn_bck[i] = hLPDmem->mem_syn[i]; + move16(); + } + + *mem_w0_bck = hLPDmem->mem_w0; + move16(); + + + *btilt_code_fx = hLPDmem->tilt_code; + *gc_threshold_fx = hLPDmem->gc_threshold; + Copy(st_fx->clip_var_fx, clip_var_bck_fx, 6); + *next_force_sf_bck_fx = st_fx->next_force_safety_net_fx; + + + return; +} + +void lsf_update_memory( + Word16 narrowband, /* i : narrowband flag */ + const Word16 qlsf[], /* i : quantized lsf coefficients */ + Word16 old_mem_MA[], /* i : MA memory */ + Word16 mem_MA[], /* o : updated MA memory */ + Word16 lpcorder /* i : LPC order */ +) +{ + Word16 i; + + FOR(i = 0; i < lpcorder; ++i) + { + move16(); + mem_MA[i] = sub(sub(qlsf[i], lsf_means[narrowband][i]), mult_r(MU_MA_FX, old_mem_MA[i])); + } + +} + +/*======================================================================*/ +/* FUNCTION : lsf_syn_mem_restore_fx */ +/*----------------------------------------------------------------------*/ +/* PURPOSE : restore synthesis filter memory and LSF quantizer memories*/ +/*----------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* _ (Word16) clip_var : pitch clipping state var */ +/* _ (Word16*) mem_AR : quantizer memory for AR model */ +/* _ (Word16*) mem_MA : quantizer memory for MA model */ +/* _ (Word16*) lsp_new_bck : LSP vector to quantize- backup */ +/* _ (Word16*) lsf_new_bck : quantized LSF vector - backup */ +/* _ (Word16*) lsp_mid_bck : mid-frame LSP vector - backup */ +/* _ (Word16) mCb1 :counter for stationary frame after a transition frame */ +/* _ (Word32*) Bin_E : FFT Bin energy 128 *2 sets */ +/* _ (Word32*) Bin_E_old : FFT Bin energy 128 *2 sets */ +/* _ (Word16*) mem_syn_bck : synthesis filter memory */ +/* _ (Word16) mem_w0_bck : memory of the weighting filter */ +/* _ (Word16) streaklimit : LSF quantizer */ +/* _ (Word16) pstreaklen : LSF quantizer */ +/*-----------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _None */ +/*-----------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16*) lsp_new : LSP vector to quantize */ +/* _ (Word16*) lsf_new : quantized LSF vector */ +/* _ (Word16*) lsp_mid : mid-frame LSP vector */ +/* _ (Encoder_State) st_fx : Encoder state Structure */ +/*-----------------------------------------------------------------------*/ + +/* _ None */ +/*-----------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ None */ +/*=======================================================================*/ +void lsf_syn_mem_restore_fx( + Encoder_State *st_fx, /* o: state structure */ + Word16 btilt_code_fx, /* i: */ + Word32 gc_threshold_fx, /* i: */ + Word16 *clip_var_bck_fx, /* i: */ + Word16 next_force_sf_bck_fx, /* i: */ + + Word16 *lsp_new, /* o: LSP vector to quantize */ + Word16 *lsf_new, /* o: quantized LSF vector */ + Word16 *lsp_mid, /* o: mid-frame LSP vector */ + Word16 clip_var, /* i: pitch clipping state var */ + Word16 *mem_AR, /* i: quantizer memory for AR model */ + Word16 *mem_MA, /* i: quantizer memory for MA model */ + Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup */ + Word16 *lsf_new_bck, /* i: quantized LSF vector - backup */ + Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup */ + Word16 mCb1, /* i: counter for stationary frame after a transition frame */ + Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets */ + Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets */ + Word16 *mem_syn_bck, /* i: synthesis filter memory */ + Word16 mem_w0_bck, /* i: memory of the weighting filter */ + Word16 streaklimit, /* i:LSF quantizer */ + Word16 pstreaklen /* i:LSF quantizer */ +) +{ + Word16 i; + LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; + + /* restore lsf memories */ + st_fx->clip_var_fx[0] = clip_var; + move16(); + + FOR(i = 0; i < M; i++) + { + st_fx->mem_AR_fx[i] = mem_AR[i]; + move16(); + st_fx->mem_MA_fx[i] = mem_MA[i]; + move16(); + lsp_new[i] = lsp_new_bck[i]; + move16(); + lsf_new[i] = lsf_new_bck[i]; + move16(); + lsp_mid[i] = lsp_mid_bck[i]; + move16(); + } + + st_fx->mCb1_fx = mCb1; + move16(); + st_fx->streaklimit_fx = streaklimit; + move16(); + st_fx->pstreaklen_fx = pstreaklen; + move16(); + + FOR(i = 0; i < L_FFT; i++) + { + st_fx->Bin_E_fx[i] = Bin_E[i]; + move16(); + } + + FOR(i = 0; i < (L_FFT / 2); i++) + { + st_fx->Bin_E_old_fx[i] = Bin_E_old[i]; + move32(); + } + + /* restoring memories */ + hLPDmem->mem_w0 = mem_w0_bck; + move16(); + + FOR(i = 0; i < M; i++) + { + hLPDmem->mem_syn[i] = mem_syn_bck[i]; + move16(); + } + + move16(); + move32(); + move16(); + hLPDmem->tilt_code = btilt_code_fx; + hLPDmem->gc_threshold = gc_threshold_fx; + Copy(clip_var_bck_fx, st_fx->clip_var_fx, 6); + st_fx->next_force_safety_net_fx = next_force_sf_bck_fx; + + return; +} + +/* Returns: codebook index */ +Word16 tcxlpc_get_cdk( + Word16 acelp_ext_mode /* (I) GC/VC indicator */ +) +{ + Word16 cdk; + + move16(); + cdk = 0; + if (EQ_16(acelp_ext_mode, VOICED)) + { + cdk = 1; + move16(); + } + + return cdk; +} + +#ifdef IVAS_MSVQ +/*--------------------------------------------------------------------------* + * dec_FDCNG_MSVQ_stage1() + * + * + *--------------------------------------------------------------------------*/ + +void dec_FDCNG_MSVQ_stage1( + int16_t j_full, /* i : index full range */ + int16_t n, /* i : dimension to generate */ + const float* invTrfMatrix, /* i : IDCT matrix for synthesis */ + const DCTTYPE idcttype, /* i : specify which IDCT */ + float* uq, /* o : synthesized stage1 vector */ + Word16* uq_ind /* o : synthesized stage1 vector in BASOP */ +) +{ + int16_t col, segm_ind, j; + float dct_vec[FDCNG_VQ_MAX_LEN]; + float idct_vec[FDCNG_VQ_MAX_LEN]; + const Word8* cbpW8; + const Word16* dct_col_shift_tab; + + assert(n <= FDCNG_VQ_MAX_LEN); + assert(n >= FDCNG_VQ_DCT_MINTRUNC); + + segm_ind = 0; + for (col = 1; col <= FDCNG_VQ_DCT_NSEGM; col++) + { + if (j_full >= cdk1_ivas_cum_entries_per_segment[col]) + { + segm_ind++; + } + } + + j = j_full - cdk1_ivas_cum_entries_per_segment[segm_ind]; /* j is the local segment index */ + + assert(j < cdk1_ivas_entries_per_segment[segm_ind]); + + /* Word8 column variable Qx storage*/ + cbpW8 = cdk_37bits_ivas_stage1_W8Qx_dct_sections[segm_ind]; /* Word8 storage fixed ptr_init */ + cbpW8 += j * cdk1_ivas_cols_per_segment[segm_ind]; /* adaptive ptr init */ + dct_col_shift_tab = stage1_dct_col_syn_shift[segm_ind]; + + for (col = 0; col < cdk1_ivas_cols_per_segment[segm_ind]; col++) + { + dct_vec[col] = (float)shl((Word16)cbpW8[col], dct_col_shift_tab[col]); + /* LOGIC( 1 ) , SHIFT( 1 ); + in BASOP: s_and(for W8->W16), shl() + */ + } + dctT2_N_apply_matrix((const float*)dct_vec, idct_vec, cdk1_ivas_cols_per_segment[segm_ind], n, invTrfMatrix, FDCNG_VQ_DCT_MAXTRUNC, idcttype); + + /*scale down to original fdcngvq domain and move to Q0 */ + v_multc(idct_vec, fdcng_dct_scaleF[1], idct_vec, n); + /* fdcng_dct_scaleF[1] --> 0.0625-->scale down from search Q4 domain to Q0 , + not really relevant for BASOP loop */ + + /*add common mid fdcng vector, in fdcng bands domain */ + v_add(idct_vec, cdk1r_tr_midQ_truncQ, uq, n); + assert(uq_ind == NULL); + + return; +} + +#endif +void msvq_dec +( + const Word16 *const*cb, /* i : Codebook (indexed cb[*stages][levels][p]) (14Q1*1.28)*/ + const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ + const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ + const Word16 stages, /* i : Number of stages */ + const Word16 N, /* i : Vector dimension */ + const Word16 maxN, /* i : Codebook dimension */ + const Word16 Idx[], /* i : Indices */ +#ifdef IVAS_MSVQ + const int16_t applyIDCT_flag, /* i : applyIDCT flag */ + const float* invTrfMatrix, /* i : matrix for IDCT synthesis */ +#endif + Word16 *uq /* o : quantized vector (14Q1*1.28)*/ +) +{ + Word16 i, j, offset; + Word16 N34; + Word16 n, maxn, start; + + + + set16_fx(uq, 0, N); + + FOR(i = 0; i < stages; i++) + { + n = N; + move16(); + maxn = maxN; + move16(); + if (dims) + { + n = dims[i]; + move16(); + } + if (dims) + { + maxn = n; + move16(); + } + + assert((maxn % 4) == 0); + N34 = mult(maxn, 24576/*0.75 Q15*/); + + start = 0; + move16(); + if (offs) + { + start = offs[i]; + move16(); + } +#ifdef IVAS_MSVQ + test(); + IF(i == 0 && applyIDCT_flag != 0) + { + assert(start == 0); + dec_FDCNG_MSVQ_stage1(Idx[0], N, invTrfMatrix, IDCT_T2_XX_24, uq, uq_ind); /* IDCT_T2 N=24 used for all synthesis */ + } + ELSE +#endif + { + /*vr_add( uq+start, cb[i]+Idx[i]*maxn, uq+start, n );, where uq = a zero vector*/ + offset = i_mult2(Idx[i], N34); + + FOR(j = 0; j < n; j += 4) + { + Word16 val0, val1, val2, val3; + + depack_4_values(cb[i] + offset + i_mult(3, (shr(j, 2))), val0, val1, val2, val3); + + uq[start + j + 0] = add(uq[start + j + 0], val0); + move16(); /*14Q1*1.28*/ + uq[start + j + 1] = add(uq[start + j + 1], val1); + move16(); /*14Q1*1.28*/ + uq[start + j + 2] = add(uq[start + j + 2], val2); + move16(); /*14Q1*1.28*/ + uq[start + j + 3] = add(uq[start + j + 3], val3); + move16(); /*14Q1*1.28*/ + } + } + } + + + return; +} + +/* + * E_LPC_lsp_lsf_conversion + * + * Parameters: + * lsp I: lsp[m] (range: -1 <= val < 1) Q15 + * lsf O: lsf[m] normalized (range: 0 <= val <= 6400) + * m I: LPC order + * + * Function: + * Transformation lsp to lsf + * + * LSP are line spectral pair in cosine domain (-1 to 1). (0Q15) + * LSF are line spectral pair in frequency domain (0 to 6400). + * + * Returns: + * energy of prediction error + */ +void E_LPC_lsp_lsf_conversion(const Word16 lsp[], Word16 lsf[], const Word16 m) +{ + Word16 i; + + assert(m == 16 || m == 10); + + + + FOR(i = 0; i < m; i++) + { + lsf[i] = xsp_to_xsf(lsp[i]); + move16(); + } + + + return; +} + +/* + * E_LPC_lsf_lsp_conversion + * + * Parameters: + * lsf I: lsf[m] normalized (range: 0 <= val <= 0.5) x2.56 + * lsp O: lsp[m] (range: -1 <= val < 1) Q15 + * m I: LPC order + * + * Function: + * Transformation lsf to lsp + * + * LSF are line spectral pair in frequency domain (0 to 6400). + * LSP are line spectral pair in cosine domain (-1 to 1). + * + * Returns: + * void + */ +void E_LPC_lsf_lsp_conversion(const Word16 lsf[], Word16 lsp[], const Word16 m) +{ + Word16 i; + + assert(m == 16 || m == 10); + + /* convert ISFs to the cosine domain */ + FOR(i = 0; i < m; i++) + { + *lsp++ = xsf_to_xsp(*lsf++); + move16(); + } + + + return; +} + +/*==========================================================================*/ +/* FUNCTION : void sub_lsp2lsf_fx () */ +/*--------------------------------------------------------------------------*/ +/* PURPOSE : */ +/* * Transformation of LSPs to LSFs */ +/* * LSP are line spectral pair in cosine domain (-1 to 1). */ +/* * LSF are line spectral frequencies (0 to fs/2). */ +/*--------------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* Word16 lsp_i i : lsp[m] (range: -1<=val<1) Q15 */ +/* Word16 m i : LPC order Q0 */ +/*--------------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* Word32 lsf[] o : lsf[m] normalized (range: 0.0<=val<=0.5) Q(x2.56)<<16 */ +/*--------------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/*--------------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ None */ +/*--------------------------------------------------------------------------*/ +/* CALLED FROM : */ +/*==========================================================================*/ +Word32 sub_lsp2lsf_fx( + const Word16 lsp_i /* i : lsp[m] (range: -1<=val<1) Q15*/ +) +{ + Word16 ind, tmp; + Word32 L_tmp; + + /*------------------------------------------------------* + * find value in table that is just greater than lsp[i] + *------------------------------------------------------*/ + + /* Retrieve Index Guess */ + /* Based on lsp[i] */ + ind = mac_r(GUESS_TBL_SZ / 2 * 65536 - 0x8000, lsp_i, GUESS_TBL_SZ / 2); + ind = Ind_Guess[ind]; + move16(); + + /* Correct Index so that */ + /* table[ind] > lsp[i] */ + tmp = sub(lsp_i, cos_table_129[ind]); + /* + 69%: (Final Index - Index Guess) is <= 1 + 28%: (Final Index - Index Guess) is 2 + 2%: (Final Index - Index Guess) is >= 3 + <1%: ... + */ + IF(tmp > 0) /* possible range 0 to -5 (-1-2-2) */ + { + ind = sub(ind, 1); + tmp = sub(lsp_i, cos_table_129[ind]); + IF(tmp > 0) + { + ind = sub(ind, 2); + tmp = sub(lsp_i, cos_table_129[ind]); + if (tmp > 0) + { + ind = sub(ind, 2); + } + tmp = sub(lsp_i, cos_table_129[ind + 1]); + if (tmp <= 0) + { + ind = add(ind, 1); + } + tmp = sub(lsp_i, cos_table_129[ind]); + } + } + + /* acos(lsp[i])= ind*128 + (lsp[i]-table[ind]) * acos_slope[ind] / 2048 */ + L_tmp = L_mac(1L << 11, tmp, acos_slope[ind]); + L_tmp = L_shr(L_tmp, 12); /* (lsp[i]-table[ind]) * acos_slope[ind]) >> 11 */ + L_tmp = L_mac0(L_tmp, ind, 128); + + return L_tmp; +} + +/*===================================================================*/ +/* FUNCTION : compute_poly_product_fx () */ +/*-------------------------------------------------------------------*/ +/* PURPOSE : Compute polynomial product for P(z) for LSP */ +/* to LPC conversion */ +/*-------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* _ (Word16[]) coef : LSP coefficients, Q15 */ +/* _ (Word16 []) order: LPC order */ +/*-------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ (Word32[]) p : output sequence, Q24 */ +/* 1st entry is always 1.0, Q24 */ +/*-------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ None */ +/*-------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ None */ +/*===================================================================*/ +/* NOTE: */ +/* P(z)=(1+z^-1)*PI(j=1to(order/2)) (1 - 2*z^-1*cos(2*pi*w(2j-1)) + z^-2) */ +/* Q(z)=(1-z^-1)*PI(j=1to(order/2)) (1 - 2*z^-1*cos(2*pi*w(2j)) + z^-2) */ +/*===================================================================*/ +void compute_poly_product_fx( + Word16* coef, /* i : LSP coefficients, Q15 */ + Word32* p, /* o : output sequence, Q24 */ + Word16 order /* i : order */ +) +{ + Word16 i, len; + Word32 lspcos[LPC_SHB_ORDER]; + Word32 p2[LPC_SHB_ORDER]; /* intermediate product, Q24*/ + Word32* p_in, *p_out, *p_temp; + + FOR(i = 0; i < order / 2; i++) + { + lspcos[i] = poscos_fx(coef[i * 2]); + move32(); /* lspcos =-cos(lsp) in Q30*/ + } + + /* Set up first polynomial for convolution (1 -2cos(w5) 1) */ + /* First element of output is 1, all in Q24 */ + p[0] = L_deposit_h(0x100); /* 1.0 in Q24 */ + p[2] = L_deposit_h(0x100); /* 1.0 in Q24 */ + p[1] = L_shr(lspcos[order / 2 - 1], 5); /* p2[1]=-2cos(w5), Q24 */ + p2[0] = L_deposit_h(0x100); /* 1.0 in Q24 */ + + len = 1; + move16(); + + len = 1; + p_in = p + 1; /* 2nd entry of input sequence */ + p_out = p2 + 1; /* 2nd entry of output sequence */ + FOR(i = 0; i < (order / 2 - 1); i++) + { + lsp_convolve_fx(L_shr(lspcos[i], 5), p_in, p_out, len); + + p_temp = p_in; + p_in = p_out; + p_out = p_temp; /* swap input/output buffer */ + len = add(len, 1); + } + + /* if((order/2 - 1)%2 != 0) */ + IF(s_and((order / 2 - 1), 1) != 0) + { + FOR(i = 1; i <= order / 2; i++) + { + p[i] = p_in[i - 1]; + move32(); + } + } + +} + +/*===================================================================*/ +/* FUNCTION : lsp_convolve_fx ( ) */ +/*-------------------------------------------------------------------*/ +/* PURPOSE : Convolution of LSP polynomial for LSP to LPC */ +/*-------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* _ ( Word32[]) p1 : 2nd entry of input sequence, Q24 */ +/* 1st entry is 1.0, Q24 */ +/* _ ( Word32) x : -2cos( w) in Q24 */ +/* _ ( Word16) len: length of output-2 */ +/*-------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ ( Word32[]) p2 : 2nd entry of output sequence, Q24 */ +/* 1st entry is 1.0, Q24 */ +/*-------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ None */ +/*-------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ None */ +/*===================================================================*/ +/* NOTE: Convolves ( 1 S 1) where S is the -2cos( w) value) with the */ +/* long sequence where the input long sequence on consecutive calls */ +/* is ( 1 X1 1), ( 1 X1 X2 X1), ( 1 X1 X2 X3 X2), ( 1 X1 X2 X3 X4 X3). */ +/* ( Since the sequence is symmetric, we only need to output one */ +/* entry beyond the center point for the next iteration). */ +/* The 1st entry of the convolution is 1, the 2nd is X1+S1, and */ +/* the rest have the form X( i-1) + X( i)*S + X( i+1). */ +/* Final output sequence is ( 1 X1 X2 X3 X4 X5 X4) */ +/*===================================================================*/ +void lsp_convolve_fx( + Word32 x, + Word32* p1, + Word32* p2, + Word16 len +) +{ + Word16 i, d1h, d1l, d2h, d2l; + Word32 Ltemp; + Word32 Lacc; + + d1h = extract_h(x); /* d1h in Q8 */ + d1l = extract_l(x); /* d1l in Q24 */ + + Ltemp = L_add(x, p1[0]); /* first output is p1[0]+x, Q24 */ + + p2[0] = Ltemp; + move32(); + Ltemp = L_deposit_h(0x100); /* Ltemp=1.0, Q24 */ + FOR(i = 0; i < len; i++) + { + Ltemp = L_add(Ltemp, p1[i + 1]); /* Ltemp2=p1[i-1]+p1[i+1], Q24 */ + d2h = extract_h(p1[i]); + d2l = extract_l(p1[i]); + + /* Lacc=L_mult_su( d1h,d2l); */ + Lacc = L_mult0(d1h, (UWord16)d2l); + Lacc = L_mac0(Lacc, d2h, d1l); + Lacc = L_add(L_shr(Lacc, 16), L_shr(L_mult(d1h, d2h), 1)); + /* Lacc=p1[i]* x, Q16 */ + Lacc = L_add(L_shl(Lacc, 8), Ltemp); /* Lacc=p1[i-1]+p1[i+1]+p1[i]*x, Q24 */ + + p2[i + 1] = Lacc; + move32(); + + Ltemp = p1[i]; + move32(); + } /* end for */ + + p2[i + 1] = p2[i - 1]; + move32(); +} + + + +/*===================================================================*/ +/* FUNCTION : poscos_fx ( ) */ +/*-------------------------------------------------------------------*/ +/* PURPOSE : Compute cosine by approximation */ +/*-------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* */ +/* _ ( Word16) w: angle in radians/pi, Q14 ( 0<=w<=16384) */ +/*-------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ None */ +/*-------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ None */ +/*-------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ ( Word32) : -cos( w) in Q30 */ +/*===================================================================*/ +/* NOTE: This function uses 4 coefficients in the approx formula */ +/* Approx Formula: cos( w) = z + c1*z^3 + c2*z^5 + c3*z^7 + c4*z^9 */ +/* where z = pi/2 - w, c1=-.1666665668, c2=.8333025139E-2, */ +/* c3=-.198074182E-3, and c4=.2601903036E-5 */ +/*===================================================================*/ + + +Word32 poscos_fx(Word16 w) +{ + Word16 a, z, z2, z3, z5, z7, z9; + Word32 Ltemp; + Word32 Lacc; + + IF(w == 0) + { + return (0xc0000004); /* -1.0 in Q30 */ + } + ELSE + { + z = 0x2000; + move16(); /* z=0.5 in Q14 */ + z = shl(sub(z, w), 2); /* z = 0.5-w in Q16 */ + + a = 0x6488; + move16(); /* a=pi in Q13 */ + z = mult_r(z, a); /* z=pi*( 0.5-w), Q14 */ + z2 = mult_r(z, z); /* z2=z^2, Q13 */ + z3 = round_fx(L_shl(L_mult0(z, z2), 0)); /* z3=z^3, Q11 */ + z5 = mult_r(z2, z3); /* z5=z^5, Q9 */ + z7 = round_fx(L_shl(L_mult0(z2, z5), 0)); /* z7=z^7, Q6 */ + z9 = round_fx(L_shl(L_mult0(z2, z7), 0)); /* z9=z^9, Q3 */ + + Lacc = L_mult(z9, cos_coef_new[0]); /* Lacc=c4*z^9, Q31, c4 in Q28 */ + Lacc = L_mac0(Lacc, z7, cos_coef_new[1]); /* c3 in Q25 */ + Ltemp = L_shl(L_mult(z3, cos_coef_new[3]), 1); /* Ltemp=c1*z^3, Q31, c1 in Q17 */ + Lacc = L_add(L_shr(Lacc, 1), Ltemp); /* Lacc=c1*z^3+c3*z^7+c4*^z9, Q30 */ + Lacc = L_add(Lacc, L_deposit_h(z)); + Ltemp = L_mult(z5, cos_coef_new[2]); /* Ltemp=-c2*z^5, Q29, cos_coef[2]=-c2 in Q19 */ + Lacc = L_sub(Lacc, L_shl(Ltemp, 1)); /* Lacc=cos( w) in Q30 */ + + return L_negate(Lacc); /* return -cos( w), Q30 */ + } /* end else */ +} +/*===================================================================*/ +/* FUNCTION : root_search_fx ( ) */ +/*-------------------------------------------------------------------*/ +/* PURPOSE : Search root of the P or Q polynomial in a given */ +/* interval using binary search */ +/*-------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* _ ( Word16) low : Low index of the interval, Q9 ( 0-511) */ +/* _ ( Word16) high : High index of the interval, Q9 ( 0-511) */ +/* _ ( Word32 []) coef: polynomial coefficients, Q26 */ +/* _ ( Word16) order : LPC order */ +/*-------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ None */ +/*-------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ ( Word32) v_low: Polynomial value at low index, Q25 */ +/*-------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ ( Word16) root in Q15, or 0xffff if no root is found */ +/*===================================================================*/ + +Word16 root_search_fx(Word16 low, + Word16 high, + Word32* v_low, + Word32* coef, + Word16 order +) +{ + Word16 f; + Word32 v_high, vh; + Word32 Ltemp, L_tmp1, L_tmp, Ltmp; + Word16 exp1, tmp; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + v_high = polynomial_eval_fx(high, coef, order); /* v_high has the value at high index */ + + IF(v_high != 0) + { + /* No exact root found */ + test(); + IF((v_high ^ (*v_low)) >= 0) + { + /* No root in this interval ( low high] */ + *v_low = v_high; + move32(); + return (-1); + } + ELSE + { + /* there is a root in this interval */ + /* Do binary search for root */ + vh = v_high; + move16(); + + WHILE(GE_16(sub(high, low), 2)) + { + /* high-low>=2 */ + f = shr(add(high, low), 1); /* f=( high+low)/2 */ + Ltemp = polynomial_eval_fx(f, coef, order); + IF(Ltemp == 0) + { + *v_low = v_high; + move32();/* Set low value for next root search call */ + return (shl(f, 6)); + } + ELSE + { + test(); + IF((Ltemp ^ (*v_low)) < 0) + { + /* root between f & low */ + high = f; + move16(); + vh = Ltemp; + move32(); + } + ELSE + { + *v_low = Ltemp; + move32(); + low = f; + move16(); + } + } + } /* end while */ + + /* do interpolation for root in between high and low */ + /* Lacc=divide_dp( *v_low, L_sub( *v_low,vh),2,1); // Lacc in Q31 */ + L_tmp = L_sub(*v_low, vh); + + if (LT_32(*v_low, vh)) + { + L_tmp = L_negate(L_tmp); + } + + exp1 = norm_l(L_tmp); + L_tmp1 = L_shl(L_tmp, exp1); + tmp = extract_h(L_tmp1); + exp1 = sub(30 - 25, exp1); + tmp = div_s(16384, tmp); /* 15+exp1 */ + Ltmp = Mult_32_16(*v_low, tmp); /* 15+exp1+25-15 */ +#ifdef BASOP_NOGLOB + Ltemp = L_shl_o(Ltmp, (6 - exp1), &Overflow); /* Q31 */ +#else + Ltemp = L_shl(Ltmp, (6 - exp1)); /* Q31 */ +#endif + if (LT_32(*v_low, vh)) + { + Ltemp = L_negate(Ltemp); + } + Ltemp = L_shr(Ltemp, 9); /* Ltemp =quotient*1.0 in Q31 */ + + *v_low = v_high; + move16(); + return (add(round_fx(Ltemp), shl(low, 6))); + } /* end else ( root in interval) */ + } /* end else ( exact root at high) */ + + /* find the exact root */ + *v_low = v_high; + move32(); /* Set low value for next root search call */ + return (shl(high, 6)); /* return exact root at high in Q15 */ +} + +/*===================================================================*/ +/* FUNCTION : calc_weight( ) */ +/*-------------------------------------------------------------------*/ +/* PURPOSE : This function computes the weight given delta1 +and delta2 */ +/*-------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* _ (Word16) delta1: (Q15) */ +/* _ (Word16) delta2: (Q15) */ +/*-------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16 *) n1: o/p weight is Q(31-n1) */ +/*-------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ None. */ +/*-------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ (Word32) Lsum1: computed weight Q(31-n1) */ +/* (alpha/(sqrt(delta1*delta2)) */ +/*===================================================================*/ + +Word32 calc_weight( + Word16 delta1, + Word16 delta2, + Word16* n1 +) +{ + Word16 n; + Word32 L_tmp; + Word16 alpha = 0x4F94; + move16(); /* ( 0.5*250/( 2*pi)) in Q10*/ + + L_tmp = L_mult0(delta1, delta2); /* Q30 */ + n = norm_l(L_tmp); + L_tmp = L_shl(L_tmp, n); + n = sub(1, n); + L_tmp = Isqrt_lc(L_tmp, &n); /* Q( 31-n)*/ + + L_tmp = Mult_32_16(L_tmp, alpha); /* Q( 26-n) */ + + *n1 = n; + move16(); + + return L_tmp; +} + +/*===================================================================*/ +/* FUNCTION : polynomial_eval_fx ( ) */ +/*-------------------------------------------------------------------*/ +/* PURPOSE : Evaluate P or Q polynomial at given frequency */ +/*-------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* _ (Word16) f : frequency used as index for cosine table lookup */ +/* Q9 */ +/* _ (Word32 []) coef: polynomial coefficients, Q26 */ +/* _ (Word16 []) order: LPC order */ +/*-------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ None */ +/*-------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ None */ +/*-------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ (Word32) polynomial value at given frequency f, Q25 */ +/*===================================================================*/ +/* Note: This function uses 512 entry cosine table cos_table[], Q15 */ +/*===================================================================*/ +/* if (K = order/2) */ +/* P(w)=cos(Kw)+p[1]*cos((K-1)w)+p[2]*cos((K-2)w)+...+p[(K-1)]*cos(w)+p[K]/2 */ +/* Q(w)=cos(Kw)+q[1]*cos((K-1)w)+q[2]*cos((K-2)w)+...+q[(K-1)]*cos(w)+q[K]/2 */ +/*===================================================================*/ + +/* 40-32 bit conversion */ +Word32 polynomial_eval_fx(Word16 f, + Word32* coef, + Word16 order +) +{ + Word16 i, idx; + Word16 dh, dl, coslut; + Word32 Ltemp, L_tmp1, L_tmp; + Word32 Lacc; + idx = f; + move16(); + dh = extract_h(coef[order / 2]); /* Q10 */ + dl = extract_l(coef[order / 2]); /* Q16 */ + + coslut = 0x4000; + move16(); /* coslut=0.5 in Q15 */ + Ltemp = L_mult0(coslut, dh); /* Ltemp=MSW, coef[5]/2 in Q25 */ + + Lacc = L_mult0(coslut, dl); /* Lacc=LSW, coef[5]/2 in Q41 //Q31 */ + Lacc = L_shr(Lacc, 1); /* Q30 */ + FOR(i = (order / 2) - 1; i > 0; i--) + { + coslut = cos_table[idx]; + move16(); /* coslut=cos( ( ( order/2)-i)f), Q15 */ + dh = extract_h(coef[i]);/* Q10 */ + dl = extract_l(coef[i]);/* Q16 */ + + Ltemp = L_add(Ltemp, L_mult0(dh, coslut)); /* Q25 */ + IF(dl < 0) + { + L_tmp1 = L_shl(L_add(65536, dl), 14); + L_tmp = Mult_32_16(L_tmp1, coslut); + Lacc = L_add(Lacc, L_tmp); + } + ELSE + { + Lacc = L_add(Lacc, L_shr(L_mult0(coslut, dl), 1));/* Q30 */ + } + + idx += f; + if (GE_16(idx, 512)) idx = sub(idx, 512); /* modulo of 512 */ + } + + coslut = cos_table[idx]; + move16(); /* coslut=cos( 5f), Q15 */ + Ltemp = L_add(Ltemp, L_mult0(0x400, coslut)); /* coef[0]=1.0, Q25 */ + + return (L_add(Ltemp, L_shr(Lacc, 15))); /* Q25 */ +} + +/*----------------------------------------------------------------------------------* +* v_sort: +* +* This is very fast with almost ordered vectors. The first 15 ISF values +* are almost always sorted. +*----------------------------------------------------------------------------------*/ +void v_sort( + Word16 *r, /* i/o: Vector to be sorted in place */ + const Word16 lo, /* i : Low limit of sorting range */ + const Word16 up /* I : High limit of sorting range */ +) +{ + Word16 i, j; + Word16 tempr; + + + FOR(i = sub(up, 1); i >= lo; i--) + { + tempr = r[i]; + move16(); + FOR(j = i; j < up; j++) + { + IF(LE_16(tempr, r[j + 1])) + { + BREAK; + } + r[j] = r[j + 1]; + move16(); + } + r[j] = tempr; + move16(); + } + + + return; +} +#ifdef IVAS_MSVQ + +/*-------------------------------------------------------------------* + * dctT2_N_apply_matrix() + * + * dct/idct truncated matrix appl. for DCT basis vector lengths of N + *-------------------------------------------------------------------*/ + +void dctT2_N_apply_matrix( + const float* input, /* i : input in fdcng or DCT(fdcng) domain */ + float* output, /* o : output in DCT(fdcng) or fdcng ordomain */ + const int16_t dct_dim, /* i : dct processing dim possibly truncated */ + const int16_t fdcngvq_dim, /* i : fdcng domain length */ + const float* matrix, /* i : IDCT matrix */ + const int16_t matrix_row_dim, /* i : */ + const DCTTYPE dcttype /* i : matrix operation type */ +) +{ + int16_t i, j, dim_in, dim_out; + int16_t mat_step_col, mat_step_row, mat_step_col_flag; + const float* pt_x, *pt_A; + float tmp_y[FDCNG_VQ_MAX_LEN]; + float* pt_y; + + /* non-square DCT_N and IDCT_N matrix application, + using a stored format of an IDCT_Nx(FDCNG_VQ_DCT_MAXTRUNC) matrix */ + /* efficiently parallelized in SIMD */ + + assert(dct_dim <= FDCNG_VQ_DCT_MAXTRUNC); + assert(fdcngvq_dim <= FDCNG_VQ_MAX_LEN); + + if ((dcttype & 1) == 0) /* even entries are DCTs */ + { + /* DCT_typeII 24,21 -> XX in worst case */ + dim_in = fdcngvq_dim; + dim_out = dct_dim; + mat_step_col = matrix_row_dim; /* matrix maximum storage size dependent, width of first row in matrix */ + mat_step_row = 0; + mat_step_col_flag = 1; + assert(dcttype == DCT_T2_21_XX || dcttype == DCT_T2_24_XX); + } + else + { + assert((dcttype & 1) != 0); /* idct */ + dim_in = dct_dim; + dim_out = fdcngvq_dim; + mat_step_col = 1; + mat_step_row = matrix_row_dim; + mat_step_col_flag = 0; + assert(dcttype == IDCT_T2_XX_24); + } + + pt_y = tmp_y; + for (i = 0; i < dim_out; i++) + { + pt_x = input; + *pt_y = 0; + + /* +i(DCT) or +i*maxTrunc(IDCT) */ +#define WMC_TOOL_SKIP + pt_A = &(matrix[i * (mat_step_row + mat_step_col_flag)]); /* ptr indexing */ + PTR_INIT(1); +#undef WMC_TOOL_SKIP + for (j = 0; j < dim_in; j++) + { +#define WMC_TOOL_SKIP + * pt_y += (*pt_x++) * (*pt_A); + pt_A += mat_step_col; /* step +maxtrunc or +1 */ /* ptr indexing*/ + MAC(1); +#undef WMC_TOOL_SKIP + } + pt_y++; + } + + mvr2r(tmp_y, output, dim_out); + + return; +} + + +/*-------------------------------------------------------------------* + * extend_dctN_input() + * + * (inputN, dctN) -> idct(N_ext) idct_N matrix application loop for + * extending, extrapolating a DCT basis vector length of N to N_ext + *-------------------------------------------------------------------*/ + +void extend_dctN_input( + const float* input, /* i : input in fdcng domain */ + const float* dct_input, /* i : input in dctN(fdcng) domain */ + const int16_t in_dim, /* i : in_dim == N */ + float* ext_sig, /* o : extended output in fdcng domain */ + const int16_t out_dim, /* i : output total dim */ + float* matrix, /* i : idct synthesis matrix N rows, n_cols columns */ + const int16_t n_cols, /* i : number of columns == DCT truncation length */ + const DCTTYPE dcttype /* i : matrix operation type */ +) +{ + int16_t i, j, i_rev; + const float(*ptr)[FDCNG_VQ_DCT_MAXTRUNC] = (void*)matrix; + + /* stored format is an IDCT_Nx(FDCNG_VQ_DCT_MAXTRUNC) matrix */ + assert(in_dim < FDCNG_VQ_MAX_LEN); + assert(out_dim <= FDCNG_VQ_MAX_LEN); + assert(out_dim > in_dim); + assert(n_cols == FDCNG_VQ_DCT_MAXTRUNC); /* for *ptr[MAX_TRUNC] adressing*/ + assert((dcttype & 1) != 0); /* idct tables always in use for this basis vector extension */ + + mvr2r(input, ext_sig, in_dim); /* copy initial part, i.e. only last/tail parts are extended */ + set_f(&(ext_sig[in_dim]), 0.0, out_dim - in_dim); + + i_rev = in_dim; /*ptr init*/ + for (i = in_dim; i < out_dim; i++) + { /* for each extension sample */ + /* i = 21 22 23; + i_rev = 20 19 18; for odd dctII reflect basis vector + */ + i_rev--; + + for (j = 0; j < n_cols; j++) /* for each available DCT coeff */ + { + /* DCTcoeff * reflected basis vector */ +#define WMC_TOOL_SKIP + /* pure ptr MAC operations */ + ext_sig[i] += dct_input[j] * ptr[i_rev][j]; /* sum up scaled and extended basis vector */ + MAC(1); +#undef WMC_TOOL_SKIP + } + } + + return; +} + + +/*-------------------------------------------------------------------* + * create_IDCT_N_Matrix() + * + * inititate idct24 FDCNG_VQ_DCT_MAXTRUNCx N matrix in + * RAM from a quantized compressed ROM format + *-------------------------------------------------------------------*/ + +void create_IDCT_N_Matrix( + float* inv_matrixFloatQ, /* i/o: RAM buffer */ + const int16_t N, /* i : DCT length, number of time samples */ + const int16_t n_cols, /* i : number of dct coeffs (as DCT may be truncated) */ + const int16_t alloc_size /* i : RAM buffer size in elements */ +) +{ + int16_t c, c1, r, r_flip, W16_val; + int16_t len; + int16_t mat_cpy_size; + const Word16* absval_ptr; + const Word8* idx_ptr; + Word16 idx; + float(*ptr)[FDCNG_VQ_DCT_MAXTRUNC] = (void*)inv_matrixFloatQ; /* fixed number of columns pointers, to simplifies adressing in ANSIC */ + + absval_ptr = unique_idctT2_24coeffsQ16; + idx_ptr = idctT2_24_compressed_idx; + len = FDCNG_VQ_MAX_LEN; + + if (N == FDCNG_VQ_MAX_LEN_WB) + { + absval_ptr = unique_idctT2_21coeffsQ16; + idx_ptr = idctT2_21_compressed_idx; + len = N; + } + + assert(alloc_size >= (n_cols * len)); /* enough space for the full expanded IDCT matrix */ + assert(N <= len); + + mat_cpy_size = (n_cols) * (len >> 1); /* NB integer division of "len" */ + + if ((len & 1) != 0) + { /* odd sized DCT with a non-reflected center row */ + mat_cpy_size += n_cols; + } + + for (c = 0; c < mat_cpy_size; c++) + { + idx = (Word16)(idx_ptr[c]); + W16_val = absval_ptr[abs(idx)]; + + if (idx < 0) + { + W16_val = -(W16_val); + } + inv_matrixFloatQ[c] = (+1.52587890625e-05f) * ((float)W16_val); /* 1.0/2.^16 scaling to a float-"Q0" , a scaling that is not done in BASOP */ + } + + /* for even number of coeffs DCT24, + flip symmetry for odd, even is used to save 50% IDCT Table ROM */ + /* for an odd DCT center is not flipped e.g for DCT21 */ + + assert(n_cols == FDCNG_VQ_DCT_MAXTRUNC); + assert((n_cols & 1) == 0); + + for (c = 0; c < (n_cols); c += 2) + { + c1 = c + 1; + r_flip = len - 1; + for (r = 0; r < (len / 2); r++, r_flip--) + { +#define WMC_TOOL_SKIP + ptr[r_flip][c] = ptr[r][c]; /* flipped */ + ptr[r_flip][c1] = -(ptr[r][c1]); /* flipped and sign swapped */ + MOVE(2); + MULT(1); /* for negate */ +#undef WMC_TOOL_SKIP + } + } + + return; +} +#endif diff --git a/lib_com/math_op.h b/lib_com/math_op.h new file mode 100644 index 000000000..fe5a85a92 --- /dev/null +++ b/lib_com/math_op.h @@ -0,0 +1,48 @@ +/*--------------------------------------------------------------------------* + * MATH_OP.H * + *--------------------------------------------------------------------------* + * Mathematical operations * + *--------------------------------------------------------------------------*/ +#include "oper_32b.h" +#include "log2.h" + +Word32 Isqrt( /* (o) Q31 : output value (range: 0<=val<1) */ + Word32 L_x /* (i) Q0 : input value (range: 0<=val<=7fffffff) */ +); +Word32 Isqrt_lc( + Word32 frac, /* (i/o) Q31: normalized value (1.0 < frac <= 0.5) */ + Word16 * exp /* (i/o) : exponent (value = frac x 2^exponent) */ +); + +Word32 Pow2( /* (o) Q0 : result (range: 0<=val<=0x7fffffff) */ + Word16 exponant, /* (i) Q0 : Integer part. (range: 0<=val<=30) */ + Word16 fraction /* (i) Q15 : Fractionnal part. (range: 0.0<=val<1.0) */ +); +Word32 Dot_product12( /* (o) Q31: normalized result (1 < val <= -1) */ + const Word16 x[], /* (i) 12bits: x vector */ + const Word16 y[], /* (i) 12bits: y vector */ + const Word16 lg, /* (i) : vector length */ + Word16 * exp /* (o) : exponent of result (0..+30) */ +); + +Word32 Energy_scale( /* (o) Q31: normalized result (1 < val <= -1) */ + const Word16 x[], /* (i) 12bits: x vector */ + const Word16 lg, /* (i) : vector length */ + Word16 expi, /* (i) : exponent of input */ + Word16 *exp /* (o) : exponent of result (0..+30) */ +); + +Word32 Sqrt_l(Word32 L_x, Word16 *exp); + +Word32 L_Frac_sqrtQ31( /* o : Square root if input */ + const Word32 x /* i : Input */ +); + +Word16 Frac_sqrt( /* o : Square root if input */ + const Word16 x /* i : Input */ +); + +Word16 i_mult2 (Word16 a, Word16 b); + + + diff --git a/lib_com/move.h b/lib_com/move.h index c7bee82cd..7d9f101a3 100644 --- a/lib_com/move.h +++ b/lib_com/move.h @@ -49,6 +49,11 @@ static __inline void move32( void ) { } +#ifdef ENH_64_BIT_OPERATOR +static __inline void move64(void) { +} +#endif /* #ifdef ENH_64_BIT_OPERATOR */ + static __inline void test( void ) { } diff --git a/lib_com/mslvq_com_fx.c b/lib_com/mslvq_com_fx.c new file mode 100644 index 000000000..d0ecef3d9 --- /dev/null +++ b/lib_com/mslvq_com_fx.c @@ -0,0 +1,660 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "options.h" +#include "prot_fx2.h" +#include "ivas_cnst.h" +#include "stl.h" +#include "rom_com.h" + +/*-----------------------------------------------------------------* + * Local functions + *-----------------------------------------------------------------*/ + +static void decode_comb_fx(Word32 index, Word16 *cv, Word16 idx_lead); +static void divide_64_32_fx(Word16 *xs, Word32 y, Word32 *result, Word32 *rem); +static void decode_leaders_fx(Word16 index, Word16 idx_lead, Word16 *cv); +static void decode_sign_pc1_fx(Word16 *c, Word16 idx_sign, Word16 parity); +static void idx2c_fx(Word16 n, Word16 *p, Word16 k, Word16 val); +static void put_value_fx(Word16 *cv, Word16 *p, Word16 val, Word16 dim, Word16 no_new_val); +static Word16 +decode_indexes_fx(Word16 * index, Word16 no_bits, const Word16 * p_scales, Word16 * p_no_scales, + Word32 * p_offset_scale1, Word32 * p_offset_scale2, Word16 * x_lvq, Word16 mode_glb, Word16 *scales); +static Word32 divide_32_32_fx(Word32 y, Word32 x, Word32 * rem); +static Word16 divide_16_16_fx(Word16 y, Word16 x, Word16 *rem); + +static void put_value_fx( + Word16 *cv, /* i/o : input codevector Q1*/ + Word16 *p, /* i : array with positions */ + Word16 val, /* i : value to be inserted Q1*/ + Word16 dim, /* i : vector dimension */ + Word16 no_new_val /* i : number of values to be inserted */ +) +{ + Word16 cv_out[LATTICE_DIM]; + Word16 i, occ[LATTICE_DIM], cnt, limit; + + limit = add(dim, no_new_val); + FOR(i = 0; i < limit; i++) + { + occ[i] = 0; + move16(); + } + + FOR(i = 0; i < no_new_val; i++) + { + cv_out[p[i]] = val; + move16(); + occ[p[i]] = 1; + move16(); + } + + cnt = 0; + move16(); + FOR(i = 0; i < limit; i++) + { + if (occ[i] == 0) + { + cv_out[i] = cv[cnt++]; + move16(); + } + } + + FOR(i = 0; i < limit; i++) + { + cv[i] = cv_out[i]; + move16(); + } + + return; +} + +static void idx2c_fx( + Word16 n, /* i : total number of positions (components)*/ + Word16 *p, /* o : array with positions of the k components */ + Word16 k, /* i : number of components whose position is to be determined */ + Word16 val /* i : index to be decoded */ +) +{ + Word16 i, skip, pos, k1; + + skip = 0; + move16(); + pos = 0; + move16(); + k1 = sub(k, 1); + move16(); + WHILE(LT_16(add(skip, sub(C_VQ[n - pos - 1][k1], 1)), val)) + { + skip = add(skip, C_VQ[n - pos - 1][k1]); + move16(); + pos++; + move16(); + } + + p[0] = pos; + move16(); + n = sub(n, add(pos, 1)); + val = sub(val, skip); + IF(EQ_16(k, 1)) + { + return; + } + + idx2c_fx(n, p + 1, k1, val); + + /* pos+1 */ + FOR(i = 1; i < k; i++) + { + p[i] = add(p[i], add(pos, 1)); + move16(); + } + + return; +} + +static Word16 divide_16_16_fx(Word16 y, /* i */ + Word16 x, /* i */ + Word16 *rem /* o */ +) +{ + Word16 result, t, tmp; + Word16 i, ny, nx, nyx; + + + IF(LT_32(y, x)) + { + result = 0; + move16(); + *rem = y; + move16(); + } + ELSE + { + + result = 0; + move16(); + IF(y == 0) + { + ny = 0; + move16(); + } + ELSE + { + ny = sub(15, norm_s(y)); + } + IF(x == 0) + { + nx = 0; + move16(); + } + ELSE + { + nx = sub(15, norm_s(x)); + } + + nyx = sub(ny,nx); + + t = s_and(shr(y, add(nyx,1)),sub(shl(1,sub(nx,1)),1)); + FOR(i = 0; i <= nyx; i++) + { + t = add(shl(t,1), s_and(shr(y,sub(nyx,i)),1)); /* L_and(y,L_shl(1, sub(nyx,i)))); */ + result = shl(result,1); + tmp = sub(t,x); + IF(tmp >= 0) + { + result = add(result,1); + t = tmp; + move16(); + } + } + *rem = t; + move16(); + } + return result; +} + +static Word32 divide_32_32_fx(Word32 y, /* i */ + Word32 x, /* i */ + Word32 *rem /* o */ +) +{ + Word32 result, t, L_tmp; + Word16 i, ny, nx, nyx; + + + IF(LT_32(y, x)) + { + result = L_deposit_l(0); + *rem = y; + move32(); + } + ELSE + { + + result = L_deposit_l(0); + IF(y == 0) + { + ny = 0; + move16(); + } + ELSE + { + ny = sub(31, norm_l(y)); + } + IF(x == 0) + { + nx = 0; + move16(); + } + ELSE + { + nx = sub(31, norm_l(x)); + } + + nyx = sub(ny,nx); + + /*t = L_and(L_shr(y, add(nyx,1)),sub(shl(1,sub(nx,1)),1)); */ + t = L_shr(y,add(nyx,1)); + FOR(i = 0; i <= nyx; i++) + { + t = L_add(L_shl(t,1), L_and(L_shr(y,sub(nyx,i)),1)); /* L_and(y,L_shl(1, sub(nyx,i)))); */ + result = L_shl(result,1); + L_tmp = L_sub(t,x); + IF(L_tmp >= 0) + { + result = L_add(result,1); + t = L_add(L_tmp, 0); + } + } + *rem = t; + move32(); + } + return result; +} + +static void decode_leaders_fx( + Word16 index, /* i : index to be decoded */ + Word16 idx_lead, /* i : leader class index */ + Word16 *cv /* o : decoded codevector Q1*/ +) +{ + Word16 i, no_vals_loc, no_vals_last, p[LATTICE_DIM], dim_loc, n_crt; + Word16 index1; + Word16 val_crt; + + no_vals_loc = no_vals[idx_lead]; + move16(); + val_crt = vals_fx[idx_lead][no_vals_loc - 1]; + move16(); /*Q1 */ + no_vals_last = no_vals_ind[idx_lead][no_vals_loc - 1]; + move16(); + + FOR(i = 0; i < no_vals_last; i++) + { + cv[i] = val_crt; + move16(); /*Q1 */ + } + + val_crt = 1; + move16(); + dim_loc = no_vals_last; + move16(); + + SWITCH(no_vals_loc) + { + case 1: + BREAK; + case 2: + idx2c_fx(LATTICE_DIM, p, no_vals_ind[idx_lead][0], index); + put_value_fx(cv, p, vals_fx[idx_lead][0], no_vals_last, no_vals_ind[idx_lead][0]); + BREAK; + case 4: + dim_loc = add(dim_loc, no_vals_ind[idx_lead][2]); + n_crt = no_vals_ind[idx_lead][2]; + index1 = divide_16_16_fx(index, C_VQ[dim_loc][n_crt], &index); /* index1 = index/C_VQ[dim_loc][n_crt]; */ + /*index = sub(index, i_mult2(index1, C_VQ[dim_loc][n_crt]) ); */ /* index-= index1*C_VQ[dim_loc][n_crt]; */ move16(); + idx2c_fx(dim_loc, p, n_crt, index); + put_value_fx(cv, p, vals_fx[idx_lead][2], no_vals_last, no_vals_ind[idx_lead][2]); /* Q1 */ + index = index1; + move16(); + /* no break */ + case 3: + dim_loc = add(dim_loc, no_vals_ind[idx_lead][1]); + n_crt = no_vals_ind[idx_lead][1]; + move16(); + index1 = divide_16_16_fx(index, C_VQ[dim_loc][n_crt], &index); + /*index = sub(index, i_mult2(index1, C_VQ[dim_loc][n_crt]));move16(); */ + idx2c_fx(dim_loc, p, n_crt, index); + put_value_fx(cv, p, vals_fx[idx_lead][1], sub(dim_loc, n_crt), n_crt); + idx2c_fx(LATTICE_DIM, p, no_vals_ind[idx_lead][0], index1); + move16(); + put_value_fx(cv, p, vals_fx[idx_lead][0], dim_loc, no_vals_ind[idx_lead][0]); + BREAK; + } + + return; +} + +void decode_sign_pc1_fx( + Word16 *c, /* o : decoded codevector Q1*/ + Word16 idx_sign, /* i : sign index */ + Word16 parity /* i : parity flag (+1/-1/0) */ +) +{ + Word16 i, len = LATTICE_DIM, cnt_neg = 1; + + if (parity) + { + len = sub(len, 1); + } + + FOR(i = 0; i < len; i++) + { + IF(c[i] > 0) + { + /*if (idx_sign % 2) */ + IF(s_and(idx_sign, 1)) + { + c[i] = negate(c[i]); + move16(); + cnt_neg = negate(cnt_neg); + move16(); + } + idx_sign = shr(idx_sign, 1); /* >>= 1; */ + } + } + + IF(LT_16(len, LATTICE_DIM)) + { + IF(NE_16(cnt_neg, parity)) + { + c[len] = negate(c[len]); + move16(); + } + } + + return; +} + +static void divide_64_32_fx( + Word16 *xs, /* i : denominator as array of two int32 */ + Word32 y, /* i : nominator on 32 bits */ + Word32 *result, /* o : integer division result on 32 bits */ + Word32 *rem /* o : integer division reminder on 32 bits */ +) +{ + Word16 nb_x1; + Word32 r, x_tmp, x[2], q, q1; + + x[0] = L_add(L_add(L_shl(L_deposit_l(s_and(xs[2], 1)), 2 * LEN_INDICE), L_shl(L_deposit_l(xs[1]), LEN_INDICE)), L_deposit_l(xs[0])); + move32(); + x[1] = L_shr(L_deposit_l(xs[2]), 1); + move32(); + + /*x[0] = (((xs[2])&(1)<<(LEN_INDICE*2)) + (xs[1]<>1; */ + + IF(x[1] == 0) + { + nb_x1 = 0; + move16(); + } + ELSE + { + nb_x1 = sub(31, norm_l(x[1])); /*get_no_bits_fx(x[1]); */ + } + /* take the first 31 bits */ + IF(nb_x1 > 0) + { + x_tmp = L_add(L_shl(x[1], sub(31, nb_x1)), L_shr(x[0], nb_x1)); + /* x_tmp = (x[1]<<(32-nb_x1)) + (x[0]>>nb_x1); */ + + q = divide_32_32_fx(x_tmp, y, &r); /* q = x_tmp/y, reminder r */ + r = L_add(L_shl(r, nb_x1), L_and(x[0], L_deposit_l(sub(shl(1, nb_x1), 1)))); /* this is the first reminder */ + /* r = (r< 0) + { + divide_64_32_fx(index, p_offset_scale2[tmp + p_no_scales[add(shl(mode_glb, 1), 1)]], &index1, &index2); + } + ELSE + { + index1 = L_deposit_l(index[0]); /* this is for very low bitrates, so there is no loss in truncation */ + index2 = L_deposit_l(0); + } + IF(index1 == 0) + { + FOR(i = 0; i < LATTICE_DIM; i++) + { + x_lvq[i] = 0; + move16(); + } + inp_scales[0] = 0; + } + ELSE + { + IF(GE_32(index1, p_offset_scale1[mode_glb*no_modes + p_no_scales[mode_glb * 2]])) + { + /* safety check in case of bit errors */ + set16_fx(x_lvq, 0, 2 * LATTICE_DIM); + inp_scales[0] = 0; + inp_scales[1] = 0; + return 1; + } + + /* find idx_scale */ + i = 1; + move16(); + WHILE(LE_16(i, p_no_scales[mode_glb * 2]) && GE_32(index1,p_offset_scale1[mode_glb*no_modes + i])) + { + i = add(i,1); + } + idx_scale = sub(i,1); + move16(); + index1 = L_sub(index1, p_offset_scale1[tmp + idx_scale]); + + /* find idx_leader */ + i = 1; + move16(); + + WHILE(GE_32(index1, table_no_cv[i])) + { + i = add(i, 1); + } + im1 = sub(i,1); + decode_comb_fx(L_sub(index1,table_no_cv[im1]), x_lvq, im1); + inp_scales[0] = p_scales[mode_glb*len_scales + idx_scale]; + } + + /* second subvector */ + IF(index2 == 0) + { + FOR(i = LATTICE_DIM; i < 2 * LATTICE_DIM; i++) + { + x_lvq[i] = 0; + move16(); + } + inp_scales[1] = 0; + move16(); + } + ELSE + { + /* find the index for the scale/truncation */ + i = 1; + move16(); + WHILE(GE_32(index2, p_offset_scale2[tmp + i])) + { + i = add(i, 1); + } + + idx_scale = sub(i,1); + index2 = L_sub(index2, p_offset_scale2[add(tmp,idx_scale)]); + /* find the index of the leader vector */ + i = 1; + move16(); + WHILE(GE_32(index2, table_no_cv[i])) + { + i = add(i, 1); + } + im1 = sub(i,1); + decode_comb_fx(index2 - table_no_cv[im1], &x_lvq[LATTICE_DIM], im1); + inp_scales[1] = p_scales[add(i_mult2(mode_glb,len_scales),add(MAX_NO_SCALES,idx_scale))]; + move16(); + } + + return 0; +} + +Word16 deindex_lvq_fx( + Word16 *index, /* i : index to be decoded, as an array of 3 Word16 */ + Word16 *x_lvq, /* o : decoded codevector Q(x2.56) */ + Word16 mode, /* i : LVQ coding mode/MSLVQ structure index (select scales & no_lead ), or idx_cv for CNG case */ + Word16 sf_flag, /* i : safety net flag */ + Word16 no_bits, /* i : number of bits for lattice */ + Word32 *p_offset_scale1, /* i : offset for first subvector */ + Word32 *p_offset_scale2, /* i : offset for the second subvector */ + Word16 *p_no_scales /* i : number of scales for each truncation and each MSLVQ structure */ +) +{ + Word16 i; + const Word16 * p_scales; + Word16 mode_glb; + Word32 L_tmp; + Word16 scales_arr[2]; + Word16 ber_flag; + + IF(EQ_16(sf_flag, 1)) + { + mode_glb = add(offset_lvq_modes_SN[mode], offset_in_lvq_mode_SN[mode][sub(no_bits, min_lat_bits_SN[mode])]); + p_scales = &scales_fx[0][0]; + move16(); + } + ELSE + { + mode_glb = add(offset_lvq_modes_pred_fx[mode], offset_in_lvq_mode_pred[mode][sub(no_bits,min_lat_bits_pred[mode])]); + p_scales = &scales_p_fx[0][0]; + move16(); + } + + /* decode the lattice index into the lattice codevectors for the two subvectors */ + ber_flag = + decode_indexes_fx(index, no_bits, p_scales, p_no_scales, p_offset_scale1, + p_offset_scale2, x_lvq, mode_glb, scales_arr); /* x_lvq is here Q1 */ + + + IF(EQ_16(sf_flag, 1)) + { + /* safety-net case*/ + IF(scales_arr[0]) + { + FOR(i = 0; i < LATTICE_DIM; i++) + { + L_tmp = L_mult(x_lvq[i], scales_arr[0]); /* Q1+Q11+Q1 = Q13 */ + /* Increase calculation accuracy by shifting more to the left and using rounding instead of truncation*/ + L_tmp = L_shl(Mult_32_16(L_tmp, shl(sigma_MSLVQ_fx[mode][i], 3)), 15); /* Q13 + Q2 +x2.56 -Q15 */ + x_lvq[i] = round_fx(L_tmp); + } + } + IF(scales_arr[1]) + { + FOR(i = LATTICE_DIM; i < 2 * LATTICE_DIM; i++) + { + L_tmp = L_mult(x_lvq[i], scales_arr[1]); /* Q1+Q11+Q1 = Q13 */ + L_tmp = L_shl(Mult_32_16(L_tmp, shl(sigma_MSLVQ_fx[mode][i], 3)), 15); /* Q13 + Q2 +x2.56 -Q15 */ + x_lvq[i] = round_fx(L_tmp); + } + } + } + ELSE + { + /* predictive mode AR or MA */ + IF(scales_arr[0]) + { + FOR(i = 0; i < LATTICE_DIM; i++) + { + L_tmp = L_mult(x_lvq[i],scales_arr[0]); /* Q1+Q11+Q1 = Q13 */ + L_tmp = L_shl(Mult_32_16(L_tmp,shl(sigma_p_fx[mode][i],3)),15); /* Q13 + Q2 +x2.56 -Q15 */ + x_lvq[i] = round_fx(L_tmp); + + } + } + IF(scales_arr[1]) + { + FOR(i = LATTICE_DIM; i < 2 * LATTICE_DIM; i++) + { + L_tmp = L_mult(x_lvq[i],scales_arr[1]); /* Q1+Q11+Q1 = Q13 */ + L_tmp = L_shl(Mult_32_16(L_tmp,shl(sigma_p_fx[mode][i],3)),15); /* Q13 + Q2 +x2.56 -Q15 */ + x_lvq[i] = round_fx(L_tmp); + } + } + } + + return ber_flag; +} \ No newline at end of file diff --git a/lib_com/oper_32b.c b/lib_com/oper_32b.c new file mode 100644 index 000000000..7753c9ae9 --- /dev/null +++ b/lib_com/oper_32b.c @@ -0,0 +1,414 @@ +/***************************************************************************** + * $Id: oper_32b.c 1094 2014-02-10 17:12:11Z jdr $ + * + * This file contains operations in double precision. * + * These operations are not standard double precision operations. * + * They are used where single precision is not enough but the full 32 bits * + * precision is not necessary. For example, the function Div_32() has a * + * 24 bits precision which is enough for our purposes. * + * * + * The double precision numbers use a special representation: * + * * + * L_32 = hi<<16 + lo<<1 * + * * + * L_32 is a 32 bit integer. * + * hi and lo are 16 bit signed integers. * + * As the low part also contains the sign, this allows fast multiplication. * + * * + * 0x8000 0000 <= L_32 <= 0x7fff fffe. * + * * + * We will use DPF (Double Precision Format) in this file to specify * + * this special format. * + ***************************************************************************** +*/ + +#include "stl.h" +#include "basop32.h" + +/***************************************************************************** + * * + * Function L_Extract() * + * * + * Extract from a 32 bit integer two 16 bit DPF. * + * * + * Arguments: * + * * + * L_32 : 32 bit integer. * + * 0x8000 0000 <= L_32 <= 0x7fff ffff. * + * hi : b16 to b31 of L_32 * + * lo : (L_32 - hi<<16)>>1 * + ***************************************************************************** +*/ + +void L_Extract (Word32 L_32, Word16 *hi, Word16 *lo) +{ + *hi = extract_h (L_32); + *lo = extract_l (L_msu (L_shr (L_32, 1), *hi, 16384)); + return; +} + +static __inline Word16 L_Extract_lc(const Word32 L_32, Word16 *p_hi) +{ + *p_hi = extract_h(L_32); + return lshr(extract_l(L_32), 1); + +} + +///***************************************************************************** +// * * +// * Function L_Extract_lc() * +// * * +// * Extract from a 32 bit integer two 16 bit DPF. * +// * (lo is returned, store to memory is not accounted for) * +// * * +// * Arguments: * +// * * +// * L_32 : 32 bit integer. * +// * 0x8000 0000 <= L_32 <= 0x7fff ffff. * +// * hi : b16 to b31 of L_32 * +// * lo : (L_32 - hi<<16)>>1 * +// ***************************************************************************** +//*/ +// +//Word16 L_Extract_lc (Word32 L_32, Word16 *hi) +//{ +// *hi = extract_h (L_32); +// +// return lshr(extract_l(L_32), 1); +//} + +/***************************************************************************** + * * + * Function L_Comp() * + * * + * Compose from two 16 bit DPF a 32 bit integer. * + * * + * L_32 = hi<<16 + lo<<1 * + * * + * Arguments: * + * * + * hi msb * + * lo lsf (with sign) * + * * + * Return Value : * + * * + * 32 bit long signed integer (Word32) whose value falls in the * + * range : 0x8000 0000 <= L_32 <= 0x7fff fff0. * + * * + ***************************************************************************** +*/ + +Word32 L_Comp (Word16 hi, Word16 lo) +{ + Word32 L_32; + + L_32 = L_deposit_h (hi); + return (L_mac (L_32, lo, 1)); /* = hi<<16 + lo<<1 */ +} + +/***************************************************************************** + * Function Mpy_32() * + * * + * Multiply two 32 bit integers (DPF). The result is divided by 2**31 * + * * + * L_32 = (hi1*hi2)<<1 + ( (hi1*lo2)>>15 + (lo1*hi2)>>15 )<<1 * + * * + * This operation can also be viewed as the multiplication of two Q31 * + * number and the result is also in Q31. * + * * + * Arguments: * + * * + * hi1 hi part of first number * + * lo1 lo part of first number * + * hi2 hi part of second number * + * lo2 lo part of second number * + * * + ***************************************************************************** +*/ + +Word32 Mpy_32 (Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2) +{ + Word32 L_32; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + +#ifdef BASOP_NOGLOB + L_32 = L_mult (hi1, hi2); + L_32 = L_mac_o (L_32, mult (hi1, lo2), 1, &Overflow); + L_32 = L_mac_o (L_32, mult (lo1, hi2), 1, &Overflow); +#else + L_32 = L_mult (hi1, hi2); + L_32 = L_mac (L_32, mult (hi1, lo2), 1); + L_32 = L_mac (L_32, mult (lo1, hi2), 1); +#endif + + return (L_32); +} + +/***************************************************************************** + * Function Mac_32() * + * * + * Multiply two 32 bit integers (DPF). The result is divided by 2**31 * + * Adds a 32 bit integer (non DFP) * + * * + * L_32 = L_num + (hi1*hi2)<<1 + ( (hi1*lo2)>>15 + (lo1*hi2)>>15 )<<1 * + * * + * This operation can also be viewed as the multiplication of two Q31 * + * number and the result is also in Q31. * + * * + * Arguments: * + * * + * hi1 hi part of first number * + * lo1 lo part of first number * + * hi2 hi part of second number * + * lo2 lo part of second number * + * * + ***************************************************************************** +*/ + +Word32 Mac_32 (Word32 L_num, Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2) +{ + Word32 L_32; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + +#ifdef BASOP_NOGLOB + L_32 = L_mac_o (L_num, hi1, hi2, &Overflow); + L_32 = L_mac_o(L_32, mult (hi1, lo2), 1, &Overflow); + L_32 = L_mac_o(L_32, mult (lo1, hi2), 1, &Overflow); +#else + L_32 = L_mac (L_num, hi1, hi2); + L_32 = L_mac (L_32, mult (hi1, lo2), 1); + L_32 = L_mac (L_32, mult (lo1, hi2), 1); +#endif + + return (L_32); +} + +/***************************************************************************** + * Function Sqr_32() * + * * + * Square one 32 bit integer (DPF). The result is divided by 2**31 * + * * + * L_32 = (hi*hi)<<1 + ( (hi*lo)>>15 *2)<<1 * + * * + * This operation can also be viewed as the square of one Q31 * + * number and the result is also in Q31. * + * * + * Arguments: * + * * + * hi1 hi part of first number * + * lo1 lo part of first number * + * hi2 hi part of second number * + * lo2 lo part of second number * + * * + ***************************************************************************** +*/ + +Word32 Sqr_32 (Word16 hi, Word16 lo) +{ + Word32 L_32; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + +#ifdef BASOP_NOGLOB + L_32 = L_mult_o (hi, hi, &Overflow); + L_32 = L_mac_o (L_32, mult (hi, lo), 2, &Overflow); +#else + L_32 = L_mult (hi, hi); + L_32 = L_mac (L_32, mult (hi, lo), 2); +#endif + + return (L_32); +} + +/***************************************************************************** + * Function Sad_32() * + * * + * Square one 32 bit integer (DPF). The result is divided by 2**31 * + * Adds a 32 bit integer (non DFP) * + * * + * L_32 = L_num + (hi*hi)<<1 + ( (hi*lo)>>15 *2)<<1 * + * * + * This operation can also be viewed as the square of one Q31 * + * number and the result is also in Q31. * + * * + * Arguments: * + * * + * hi1 hi part of first number * + * lo1 lo part of first number * + * hi2 hi part of second number * + * lo2 lo part of second number * + * * + ***************************************************************************** +*/ + +Word32 Sad_32 (Word32 L_num, Word16 hi, Word16 lo) +{ + Word32 L_32; + + L_32 = L_mac (L_num, hi, hi); + L_32 = L_mac (L_32, mult (hi, lo), 2); + + return (L_32); +} + +/***************************************************************************** + * Function Mpy_32_16() * + * * + * Multiply a 16 bit integer by a 32 bit (DPF). The result is divided * + * by 2**15 * + * * + * * + * L_32 = (hi1*lo2)<<1 + ((lo1*lo2)>>15)<<1 * + * * + * Arguments: * + * * + * hi hi part of 32 bit number. * + * lo lo part of 32 bit number. * + * n 16 bit number. * + * * + ***************************************************************************** +*/ + +Word32 Mpy_32_16 (Word16 hi, Word16 lo, Word16 n) +{ + Word32 L_32; + + L_32 = L_mult (hi, n); + L_32 = L_mac (L_32, mult (lo, n), 1); + + return (L_32); +} + +/***************************************************************************** + * Function Mac_32_16() * + * * + * Multiply a 16 bit integer by a 32 bit (DPF). The result is divided * + * by 2**15 * + * Adds a 32 bit integer (non DFP) * + * * + * * + * L_32 = L_num + (hi1*lo2)<<1 + ((lo1*lo2)>>15)<<1 * + * * + * Arguments: * + * * + * L_num 32 bit long signed integer (Word32) * + * hi hi part of 32 bit number. * + * lo lo part of 32 bit number. * + * n 16 bit number. * + * * + ***************************************************************************** +*/ + +Word32 Mac_32_16 (Word32 L_num, Word16 hi, Word16 lo, Word16 n) +{ + Word32 L_32; + + L_32 = L_mac (L_num, hi, n); + L_32 = L_mac (L_32, mult (lo, n), 1); + + return (L_32); +} + +/***************************************************************************** + * Function Msu_32_16() * + * * + * Substract a 32 bit integer (non DFP) * + * Multiply a 16 bit integer by a 32 bit (DPF). The result is divided * + * by 2**15 * + * * + * * + * L_32 = L_num - (hi1*lo2)<<1 + ((lo1*lo2)>>15)<<1 * + * * + * Arguments: * + * * + * L_num 32 bit long signed integer (Word32) * + * hi hi part of 32 bit number. * + * lo lo part of 32 bit number. * + * n 16 bit number. * + * * + ***************************************************************************** +*/ + +Word32 Msu_32_16 (Word32 L_num, Word16 hi, Word16 lo, Word16 n) +{ + Word32 L_32; + + L_32 = L_msu (L_num, hi, n); + L_32 = L_msu (L_32, mult (lo, n), 1); + + return (L_32); +} + +/***************************************************************************** + * * + * Function Name : Div_32 * + * * + * Purpose : * + * Fractional integer division of two 32 bit numbers. * + * L_num / L_denom. * + * L_num and L_denom must be positive and L_num < L_denom. * + * L_denom = denom_hi<<16 + denom_lo<<1 * + * denom_hi is a normalize number. * + * * + * Inputs : * + * * + * L_num * + * 32 bit long signed integer (Word32) whose value falls in the * + * range : 0x0000 0000 < L_num < L_denom * + * * + * L_denom = denom_hi<<16 + denom_lo<<1 (DPF) * + * * + * denom_hi * + * 16 bit positive normalized integer whose value falls in the * + * range : 0x4000 < hi < 0x7fff * + * denom_lo * + * 16 bit positive integer whose value falls in the * + * range : 0 < lo < 0x7fff * + * * + * Return Value : * + * * + * L_div * + * 32 bit long signed integer (Word32) whose value falls in the * + * range : 0x0000 0000 <= L_div <= 0x7fff ffff. * + * * + * Algorithm: * + * * + * - find = 1/L_denom. * + * First approximation: approx = 1 / denom_hi * + * 1/L_denom = approx * (2.0 - L_denom * approx ) * + * * + * - result = L_num * (1/L_denom) * + ***************************************************************************** +*/ + +Word32 Div_32 (Word32 L_num, Word16 denom_hi, Word16 denom_lo) +{ + Word16 approx, hi, lo, n_hi, n_lo; + Word32 L_32; + + /* First approximation: 1 / L_denom = 1/denom_hi */ + + approx = div_s ((Word16) 0x3fff, denom_hi); + + /* 1/L_denom = approx * (2.0 - L_denom * approx) */ + + L_32 = Msu_32_16 ((Word32) 0x7fffffffL, denom_hi, denom_lo, approx); + + lo = L_Extract_lc (L_32, &hi); + L_32 = Mpy_32_16 (hi, lo, approx); + + /* L_num * (1/L_denom) */ + + lo = L_Extract_lc (L_32, &hi); + n_lo = L_Extract_lc (L_num, &n_hi); + L_32 = Mpy_32 (n_hi, n_lo, hi, lo); + L_32 = L_shl (L_32, 2); + + return (L_32); +} + diff --git a/lib_com/oper_32b.h b/lib_com/oper_32b.h new file mode 100644 index 000000000..9fa3328ab --- /dev/null +++ b/lib_com/oper_32b.h @@ -0,0 +1,18 @@ +/* Double precision operations */ +/* $Id: oper_32b.h 1094 2014-02-10 17:12:11Z jdr $ */ +#ifndef _OPER_32b_H +#define _OPER_32b_H + +void L_Extract (Word32 L_32, Word16 *hi, Word16 *lo); +//Word16 L_Extract_lc (Word32 L_32, Word16 *hi); +Word32 L_Comp (Word16 hi, Word16 lo); +Word32 Mpy_32 (Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2); +Word32 Mac_32 (Word32 L_num, Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2); +Word32 Sqr_32 (Word16 hi, Word16 lo); +Word32 Sad_32 (Word32 L_num, Word16 hi, Word16 lo); +Word32 Mpy_32_16 (Word16 hi, Word16 lo, Word16 n); +Word32 Mac_32_16 (Word32 L_num, Word16 hi, Word16 lo, Word16 n); +Word32 Msu_32_16 (Word32 L_num, Word16 hi, Word16 lo, Word16 n); +Word32 Div_32 (Word32 L_num, Word16 denom_hi, Word16 denom_lo); + +#endif diff --git a/lib_com/options.h b/lib_com/options.h index 31d4cb855..d69536f2d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -44,8 +44,12 @@ /* #################### End compiler switches ######################### */ - -/* ################### Start DEBUGGING switches ########################### */ +#include "stl.h" +/* ################### Start compiler switches ######################## */ +/* */ +#ifdef _MSC_VER +#pragma warning(disable:4310) /* cast truncates constant value this affects mainly constants tables*/ +#endif /*#define WMOPS*/ /* Activate complexity and memory counters */ /*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ diff --git a/lib_com/ppp.c b/lib_com/ppp.c index d9e553124..a9e44dd1e 100644 --- a/lib_com/ppp.c +++ b/lib_com/ppp.c @@ -67,7 +67,7 @@ void Interpol_delay( * deemph_lpc() * * De-emphasis of LP coefficients - * convolve LPC with [1 -PREEMPH_FAC] to de-emphasise LPC + * convolve LPC with [1 -PREEMPH_FAC_FLT] to de-emphasise LPC *--------------------------------------------------------------------*/ void deemph_lpc( @@ -79,7 +79,7 @@ void deemph_lpc( { int16_t k; float b[M + 2]; - const float a[2] = { -PREEMPH_FAC, 1.0 }; + const float a[2] = { -PREEMPH_FAC_FLT, 1.0 }; b[0] = 1.0; for ( k = 0; k < M; k++ ) diff --git a/lib_com/prot.h b/lib_com/prot.h index d277cefb1..b5103bfaf 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -144,7 +144,7 @@ float log2_f( const float x /* i : input value of x */ ); -int16_t norm_ul( +int16_t norm_ul_float( uint32_t UL_var1 ); /*! r: sum of all vector elements */ @@ -396,7 +396,7 @@ float usdequant( const float delta /* i : quantization step */ ); -void v_sort( +void v_sort_float( float *r, /* i/o: Vector to be sorted in place */ const int16_t lo, /* i : Low limit of sorting range */ const int16_t up /* i : High limit of sorting range */ @@ -456,7 +456,7 @@ int16_t is_numeric_float( float x /* i : Input value which is checked if numeric or not */ ); -void delay_signal( +void delay_signal_float( float x[], /* i/o: signal to be delayed */ const int16_t len, /* i : length of the input signal */ float mem[], /* i/o: synchronization memory */ @@ -573,7 +573,7 @@ ivas_error write_indices_ivas( uint16_t *num_bits /* i/o: number of bits written to output */ ); -Word16 rate2EVSmode( +Word16 rate2EVSmode_float( const Word32 brate, /* i : bitrate */ int16_t *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ ); @@ -615,7 +615,7 @@ void mdct_switching_dec( Decoder_State *st /* i/o: decoder state structure */ ); -void evs_dec_previewFrame( +void evs_dec_previewFrame_float( uint8_t *bitstream, /* i : bitstream pointer */ int16_t bitstreamSize, /* i : bitstream size */ int16_t *partialCopyFrameType, /* o : frame type of the partial copy */ @@ -623,7 +623,7 @@ void evs_dec_previewFrame( ); -void getPartialCopyInfo( +void getPartialCopyInfo_float( Decoder_State *st, /* i : decoder state structure */ int16_t *sharpFlag ); @@ -1815,13 +1815,13 @@ uint32_t UMult_32_32( ); /*! r: inverse */ -uint32_t UL_inverse( +uint32_t UL_inverse_float( const uint32_t UL_val, /* i : input value Q_exp */ int16_t *exp /* i/o: input exp / result exp */ ); /*! r: ratio */ -Word16 ratio( +Word16 ratio_float( const Word32 numer, /* i : numerator */ const Word32 denom, /* i : denominator */ Word16 *expo /* i/o: input exp / result exp */ @@ -4514,7 +4514,7 @@ void updt_dec_common( ); void td_cng_dec_init( - DEC_CORE_HANDLE st /* i/o: decoder state structure */ + DEC_CORE_HANDLE_FLOAT st /* i/o: decoder state structure */ ); void CNG_dec( @@ -5543,7 +5543,7 @@ int16_t hvq_pvq_bitalloc( int16_t *n_sel_bands /* o : No. of selected bands for encoding */ ); -void floating_point_add( +void floating_point_add_float( int32_t *mx, /* i/o: mantissa of the addend Q31 */ int16_t *ex, /* i/o: exponent of the addend Q0 */ const int32_t my, /* i : mantissa of the adder Q31 */ @@ -5929,7 +5929,7 @@ void synthesise_fb_high_band( const float excitation_in[], /* i : full band excitation */ float output[], /* o : high band speech - 14.0 to 20 kHz */ const float fb_exc_energy, /* i : full band excitation energy */ - const float ratio, /* i : energy ratio */ + const float ratio_float, /* i : energy ratio */ const int16_t L_frame, /* i : ACELP frame length */ const int16_t bfi, /* i : BFI flag */ float *prev_fbbwe_ratio, /* o : previous frame energy for FEC */ @@ -6505,7 +6505,7 @@ void minimumStatistics( const int16_t buffSize /* i : buffer size */ ); -void E_LPC_int_lpc_tcx( +void E_LPC_int_lpc_tcx_float( const float lsf_old[], /* i : LSFs from past frame */ const float lsf_new[], /* i : LSFs from present frame */ float a[] /* o : interpolated LP coefficients */ @@ -6657,7 +6657,7 @@ void adapt_lag_wind( const int32_t sr_core /* i : core sampling rate */ ); -void hp20( +void hp20_flt( Float32 signal[], const Word16 lg, Float32 mem[], @@ -6816,7 +6816,7 @@ void core_signal_analysis_high_bitrate( ); /*! r: codebook gain (adaptive or fixed) */ -float get_gain( +float get_gain_flt( const float x[], /* i : target signal */ const float y[], /* i : filtered codebook excitation */ const int16_t n, /* i : segment length */ @@ -8019,7 +8019,7 @@ void msvq_enc( int16_t Idx[] /* o : Indices */ ); -void msvq_dec( +void msvq_dec_float( const float *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */ const int16_t dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ const int16_t offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ @@ -8138,7 +8138,7 @@ void con_tcx( ); /*! r: codebook index */ -int16_t tcxlpc_get_cdk( +int16_t tcxlpc_get_cdk_float( const int16_t coder_type /* i : GC/VC indicator */ ); @@ -8171,7 +8171,7 @@ int16_t D_lsf_tcxlpc( const float mem_MA[] /* i : MA memory */ ); -void lsf_update_memory( +void lsf_update_memory_float( const int16_t narrowband, /* i : narrowband flag */ const float qlsf[], /* i : quantized lsf coefficients */ float old_mem_MA[], /* i : MA memory */ @@ -8190,7 +8190,7 @@ int16_t Q_lsf_tcxlpc( const float *Bin_Ener /* i : Spectrum energy */ ); -int16_t E_LPC_lsp_unweight( +int16_t E_LPC_lsp_unweight_float( const float lsp_w[], /* i : weighted lsp */ float lsp_uw[], /* o : unweighted lsp */ float lsf_uw[], /* o : unweighted lsf */ @@ -8251,7 +8251,7 @@ void lsf_end_dec( const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ); -ivas_error find_pred_mode( +ivas_error find_pred_mode_float( int16_t *predmode, const int16_t coder_type, const int16_t bwidth, @@ -8671,7 +8671,7 @@ void deleteFdCngDec( HANDLE_FD_CNG_DEC *hFdCngDec ); void initFdCngDec( - DEC_CORE_HANDLE st /* i/o: decoder state structure */ + DEC_CORE_HANDLE_FLOAT st /* i/o: decoder state structure */ ); void configureFdCngDec( diff --git a/lib_com/prot_fx1.h b/lib_com/prot_fx1.h new file mode 100644 index 000000000..6bcd60344 --- /dev/null +++ b/lib_com/prot_fx1.h @@ -0,0 +1,441 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef PROT_FX1_H +#define PROT_FX1_H + +#include +#include +#include +#include "options.h" +#include "typedef.h" +#include "cnst.h" +#include "stl.h" + +Word32 Mult_32_16(Word32 a, Word16 b); + +int16_t norm_ul(uint32_t UL_var1); +Word16 usdequant_fx( /* Qx*/ + const Word16 idx, /* i: quantizer index Q0*/ + const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ + const Word16 delta /* i: quantization step Qy*/ +); + +Word16 usquant_fx( /* o: index of the winning codeword */ + const Word16 x, /* i: scalar value to quantize Qx*/ + Word16 *xq, /* o: quantized value Qx*/ + const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ + const Word16 delta, /* i: quantization step Qx-1*/ + const Word16 cbsize /* i: codebook size */ +); + +Word32 Dot_product( /* o : Sum */ + const Word16 x[], /* i : 12bits: x vector */ + const Word16 y[], /* i : 12bits: y vector */ + const Word16 lg /* i : vector length */ +); + +Word32 dotp_fx( /* o : dot product of x[] and y[] */ + const Word16 x[], /* i : vector x[] */ + const Word16 y[], /* i : vector y[] */ + const Word16 n, /* i : vector length */ + Word16 * exp /* (o) : exponent of result (0..+30) */ +); + +Word32 sum2_fx( /* o : sum of all squared vector elements Q(2x+1)*/ + const Word16 *vec, /* i : i vector Qx*/ + const Word16 lvec /* i : length of i vector */ +); + +Word32 sum2_fx_mod( /* o : sum of all squared vector elements Q(2x+1)*/ + const Word16 *vec, /* i : i vector Qx*/ + const Word16 lvec /* i : length of i vector */ +); + +void Copy( + const Word16 x[], /* i : i vector */ + Word16 y[], /* o : output vector */ + const Word16 L /* i : vector length */ +); + +void Copy32( + const Word32 x[], /* i : i vector */ + Word32 y[], /* o : output vector */ + const Word16 L /* i : vector length */ +); + +void set16_fx( + Word16 y[], /* i/o: Vector to set */ + const Word16 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ +); + +void set32_fx( + Word32 y[], /* i/o: Vector to set */ + const Word32 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ +); + +void Copy_Scale_sig( + const Word16 x[], /* i : signal to scale i Qx */ + Word16 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +void Copy_Scale_sig_16_32( + const Word16 x[], /* i : signal to scale i Qx */ + Word32 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +void Copy_Scale_sig_32_16( + const Word32 x[], /* i : signal to scale i Qx */ + Word16 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +void Scale_sig32( + Word32 x[], /* i/o: signal to scale Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +void Random_Fill( + Word16 *seed, /* i/o: random seed */ + Word16 n, /* i : number of values */ + Word16 *y, /* o : output values */ + Word16 scaling /* i : scaling of values */ +); + +void Scale_sig( + Word16 x[], /* i/o: signal to scale Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +Word16 mean_fx( /* o : mean of vector */ + const Word16 *vec_fx, /* i : i vector */ + const Word16 lvec_fx /* i : length of i vector */ +); + +void Vr_add( + const Word16 *in1, /* i : Input vector 1 */ + const Word16 *in2, /* i : Input vector 2 */ + Word16 *out, /* o : Output vector that contains vector 1 + vector 2 */ + Word16 Len /* i : Vector lenght */ +); +void sort_fx( + Word16 *r, /* i/o: Vector to be sorted in place */ + Word16 lo, /* i : Low limit of sorting range */ + Word16 up /* I : High limit of sorting range */ +); +void sort_32_fx( + Word32 *r, /* i/o: Vector to be sorted in place */ + const Word16 lo, /* i : Low limit of sorting range */ + const Word16 up /* I : High limit of sorting range */ +); +Word16 minimum_fx( /* o : index of the minimum value in the input vector */ + const Word16 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word16 *min_fx /* o : minimum value in the input vector */ +); +Word16 maximum_fx( /* o : index of the maximum value in the input vector */ + const Word16 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word16 *max_fx /* o : maximum value in the input vector */ +); +Word16 minimum_32_fx( /* o : index of the minimum value in the input vector */ + const Word32 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word32 *min_fx /* o : minimum value in the input vector */ +); +Word16 maximum_32_fx( /* o : index of the maximum value in the input vector */ + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ +); +Word16 Exp16Array( + const Word16 n, /* (i): Array size */ + const Word16 *sx /* (i): Data array */ +); +Word16 Exp32Array( + const Word16 n, /* (i): Array size */ + const Word32 *sx /* (i): Data array */ +); +Word32 sum16_32_fx( /* o : sum of all vector elements Qx*/ + const Word16 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ +); +Word32 var_fx_32( /* o: variance of vector Qx+16*/ + const Word16 *x, /* i: input vector Qx*/ + const Word16 Qx, + const Word16 len /* i: length of inputvector */ +); +Word16 var_fx( /* o: variance of vector Qx*/ + const Word16 *x, /* i: input vector Qx*/ + const Word16 Qx, + const Word16 len /* i: length of inputvector */ +); +Word16 std_fx( /* o: standard deviation */ + const Word16 x[], /* i: input vector */ + const Word16 len /* i: length of the input vector */ +); +Word32 dot_product_mat_fx( /* o : the dot product x'*A*x */ + const Word16 *x, /* i : vector x Q15 */ + const Word32 *A, /* i : matrix A Q0*/ + const Word16 m /* i : vector & matrix size */ + +); +void Vr_subt( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ + Word16 N /* i : Vector lenght */ +); +Word16 vquant_fx( /* o: index of the winning codevector */ + Word16 x[], /* i: vector to quantize Q13 */ + const Word16 x_mean[], /* i: vector mean to subtract (0 if none)Q13*/ + Word16 xq[], /* o: quantized vector Q13 */ + const Word16 cb[], /* i: codebook Q13 */ + const Word16 dim, /* i: dimension of codebook vectors */ + const Word16 cbsize /* i: codebook size */ +); +Word16 w_vquant_fx( + Word16 x[], /* i: vector to quantize in Q10 */ + Word16 Qx, + const Word16 weights[], /* i: error weights in Q0 */ + Word16 xq[], /* o: quantized vector in Q15 */ + const Word16 cb[], /* i: codebook in Q15 */ + const Word16 cbsize, /* i: codebook size */ + const Word16 rev_vect /* i: reverse codebook vectors */ +); +Word16 emaximum_fx( /* o : return index with max energy value in vector Q0 */ + const Word16 Qvec, /* i : Q of input vector Q0 */ + const Word16 *vec, /* i : input vector Qx */ + const Word16 lvec, /* i : length of input vector Q0 */ + Word32 *ener_max /* o : maximum energy value Q0 */ +); +Word32 Mean32( /* o : mean of the elements of the vector */ + const Word32 in[], /* i : input vector */ + const Word16 L /* i : length of input vector */ +); +Word32 sum32_fx( /* o : sum of all vector elements Qx*/ + const Word32 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ +); +Word16 sum16_fx( /* o : sum of all vector elements Qx*/ + const Word16 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ +); +Word16 Random( /* o : output random value */ + Word16 *seed /* i/o: random seed */ +); +Word16 own_random2_fx(Word16 seed); +void iDiv_and_mod_32( + const Word32 Numer, /* i : 32 bits numerator */ + const Word16 Denom, /* i : 16 bits denominator */ + Word32 * Int_quotient, /* o : integer result of the division (int)(num/den) */ + Word32 * Int_mod, /* o : modulo result of the division num-((int)(num/den)*den)*/ + const Word16 rshift /* i : 0 if no right shift / 1 if the denom is right shifted by 1 */ +); +void pz_filter_sp_fx( + const Word16 b[], + const Word16 a[], + Word16 x[], + Word16 y[], + Word16 buf[], + Word16 PNR, + Word16 PDR, + Word16 N, + Word16 Qa +); +Word32 root_a_fx( + Word32 a, + Word16 Q_a, + Word16* exp_out +); +Word32 root_a_over_b_fx( + Word32 a, + Word16 Q_a, + Word32 b, + Word16 Q_b, + Word16* exp_out +); +void fir_fx(const Word16 x[], /* i : input vector Qx*/ + const Word16 h[], /* i : impulse response of the FIR filter Q12*/ + Word16 y[], /* o : output vector (result of filtering) Qx*/ + Word16 mem[], /* i/o: memory of the input signal (L samples) Qx*/ + const Word16 L, /* i : input vector size */ + const Word16 K, /* i : order of the FIR filter (K+1 coefs.) */ + const Word16 upd /* i : 1 = update the memory, 0 = not */ + , Word16 shift /* i : difference between Q15 and scaling of h[] */ +); +Word16 squant_fx( /* o: index of the winning codeword */ + const Word16 x, /* i: scalar value to quantize */ + Word16* xq, /* o: quantized value */ + const Word16 cb[], /* i: codebook */ + const Word16 cbsize /* i: codebook size */ +); +void pz_filter_dp_fx( + const Word16 b[], + const Word16 a[], + Word16 x[], + Word16 y[], + Word32 buf[], + Word16 PNR, + Word16 PDR, + Word16 N, + Word16 Qa +); +void Copy_Scale_sig32_16( + const Word32 *src, /* i : signal to scale Qx */ + Word16 *dst, /* o : scaled signal Qx */ + Word16 len, /* i : size of x[] Q0 */ + Word16 exp0); /* i : exponent: x = round(x << exp) Qx ?exp */ + +void v_multc_att( + const Word16 x[], /* i : Input vector Qx */ + const Word16 att, /* i : Constant Q15, <= MAX_16 */ + Word16 y[], /* o : Output vector that contains att*x */ + const Word16 N /* i : Vector length */ +); +void v_multc_att32( + const Word32 x[], /* i : Input vector Qx */ + const Word16 att, /* i : Constant Q15, <= MAX_16 */ + Word32 y[], /* o : Output vector that contains att*x */ + const Word16 N /* i : Vector length */ +); +void add_vec_fx( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 Qx1, /* i : SCaling of input 1 */ + const Word16 x2[], /* i : Input vector 2 */ + const Word16 Qx2, /* i : SCaling of input 1 */ + Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 Qy, /* i : SCaling of output 1 */ + const Word16 N /* i : Vector lenght */ +); +Word32 Add_flt32_flt32(/* o: Result (Normalized) */ + Word32 a, /* i: 1st Value */ + Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ + Word32 b, /* i: 2nd Value */ + Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ + Word16 *exp_out /* o: Exponent of Result */ +); +Word32 Mul_flt32_Q15( /* o: Result (Normalized) */ + Word32 value, /* i: Pseudo_float Value */ + Word16 *exp_v, /*i/o: Exponent of Value (Q of Value) */ + Word16 frac /* i: Q15 value */ +); +Word32 Div_flt32_flt32(/* o: Result (Normalized) */ + Word32 a, /* i: 1st Value */ + Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ + Word32 b, /* i: 2nd Value */ + Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ + Word16 *exp_out /* o: Exponent of Result */ +); +Word32 Calc_Energy_Autoscaled(/* o: Result (Energy) */ + const Word16 *signal, /* i: Signal */ + Word16 signal_exp, /* i: Exponent of Signal (Q of Signal) */ + Word16 len, /* i: Frame Length */ + Word16 *energy_exp /* o: Exponent of Energy (Q of Energy) */ +); +Word16 Find_Max_Norm16(const Word16 *src, Word16 len); + +Word16 Find_Max_Norm32(const Word32 *src, Word16 len); + +Word32 Sqrt_Ratio32(/* o: Result in Q31 */ + Word32 L_val1, /* i: Mantisa of Val1 */ + Word16 exp1, /* i: Exp of Val1 (>0: Val was Left Shifted, <0:Right Shifted) */ + Word32 L_val2, /* i: Mantisa of Val2 */ + Word16 exp2, /* i: Exp of Val2 (same as exp1) */ + Word16 *exp /* o: Exp of Result (# of 'L_shl' Req to get to Final Value) */ +); + +Word16 Invert16( /* result in Q'15 + 'exp' */ + Word16 val, + Word16 *exp); + +Word16 find_rem(Word16 n, Word16 m, Word16 *r); +Word32 find_remd(Word32 n, Word32 m, Word32 *r); + +Word16 rint_new_fx( + Word32 x /*Q16 */ +); + +Word16 erb_diff_search_fx(Word16 *prev_erb, const Word16 *curr_erb, Word16 *dif_erb, + Word16 *pow_spec, const Word16 *cb_fx, + Word16 cb_size, Word16 cb_dim, Word16 offset); + +void Acelp_dec_total_exc( + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ + const Word16 gain_code16, /* i : Gain code Q0 */ + const Word16 gain_pit_fx, /* i ; Pitch gain in Q14 */ + const Word16 i_subfr, /* i ; subfr */ + const Word16 *code_fx, /* i : code in Q9 */ + const Word16 L_subfr /* i : Subframne lenght */ +); + +UWord32 UL_inverse(const UWord32 UL_val, Word16 *exp); + +UWord32 UL_div(const UWord32 UL_num, const UWord32 UL_den); + +Word16 ratio(const Word32 numer, const Word32 denom, Word16 *expo); + +void hp400_12k8_fx( + Word16 signal[], /* i/o: input signal / output is divided by 16 */ + const Word16 lg, /* i : lenght of signal */ + Word16 mem[] /* i/o: filter memory [6] */ +); + +Word16 dot_prod_satcontr(const Word16 *x, const Word16 *y, Word16 qx, Word16 qy, Word16 *qo, Word16 len); + +void E_UTIL_f_convolve(const Word16 x[], const Word16 h[], Word16 y[], const Word16 size); + +void floating_point_add( + Word32 *mx, /* io: mantissa of the addend Q31 */ + Word16 *ex, /* io: exponent of the addend Q0 */ + const Word32 my, /* i: mantissa of the adder Q31 */ + const Word16 ey /* i: exponent of the adder Q0 */ +); + +void delay_signal( + Word16 x[], /* i/o: signal to be delayed */ + const Word16 len, /* i : length of the input signal */ + Word16 mem[], /* i/o: synchronization memory */ + const Word16 delay /* i : delay in samples */ +); + +#endif \ No newline at end of file diff --git a/lib_com/prot_fx2.h b/lib_com/prot_fx2.h new file mode 100644 index 000000000..49ddc41fe --- /dev/null +++ b/lib_com/prot_fx2.h @@ -0,0 +1,1208 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef PROT_FX2_H +#define PROT_FX2_H + +#include "ivas_cnst.h" +#include "stat_enc.h" +#include "stat_dec.h" +#include "ivas_error.h" + +Word32 Mult_32_16( + Word32 a, + Word16 b); + +Word32 Mult_32_32( + Word32 a, + Word32 b); + +void Copy32( + const Word32 x[], /* i : i vector */ + Word32 y[], /* o : output vector */ + const Word16 L /* i : vector length */ +); + +void Vr_add( + const Word16 *in1, /* i : Input vector 1 */ + const Word16 *in2, /* i : Input vector 2 */ + Word16 *out, /* o : Output vector that contains vector 1 + vector 2 */ + Word16 Len /* i : Vector lenght */ +); + +void set16_fx( + Word16 y[], /* i/o: Vector to set */ + const Word16 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ +); + +void set32_fx( + Word32 y[], /* i/o: Vector to set */ + const Word32 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ +); + +//tools.c +Word16 Random( /* o : output random value */ + Word16 *seed /* i/o: random seed */ +); + +//tools.c +void Copy( + const Word16 x[], /* i : i vector */ + Word16 y[], /* o : output vector */ + const Word16 L /* i : vector length */ +); + +//tools.c +void Scale_sig( + Word16 x[], /* i/o: signal to scale Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +/*========================================================================================================/ +mslvq_com_fx.c +/========================================================================================================*/ + +//mslvq_com_fx +Word16 deindex_lvq_fx( + Word16 *index, /* i : index to be decoded, as an array of 3 short */ + Word16 *x_lvq, /* o : decoded codevector Q(x2.56)*/ + Word16 mode, /* i : LVQ coding mode (select scales & no_lead ), or idx_cv */ + Word16 sf_flag, /* i : safety net flag */ + Word16 no_bits, /* i : number of bits for lattice */ + Word32 *p_offset_scale1, /* i : offset for first subvector */ + Word32 *p_offset_scale2, /* i : offset for the second subvector */ + Word16 *p_no_scales +); + +/*========================================================================================================/ +swe_bwe_com_fx.c +/========================================================================================================*/ + +void calc_normal_length_fx_32( + const Word16 core, /* i : core : Q0 */ + const Word32 *sp, /* i : i signal : Q12 */ + const Word16 mode, /* i : i mode : Q0 */ + const Word16 extl, /* i : extension layer : Q0 */ + Word16 *L_swb_norm, /* o : normalize length : Q0 */ + Word16 *prev_L_swb_norm /*i/o : last normalize length : Q0 */ +); + + +void hq_generic_decoding_fx( + const Word16 HQ_mode, /* i : HQ mode */ + Word32 *coeff_out1_fx, /* i/o: BWE i & temporary buffer */ + const Word16 *hq_generic_fenv_fx, /* i : SWB frequency envelopes */ + Word32 *coeff_out_fx, /* o : SWB signal in MDCT domain */ + const Word16 hq_generic_offset, /* i : frequency offset for representing hq generic*/ + Word16 *prev_L_swb_norm, /* i/o: last normalize length */ + const Word16 hq_generic_exc_clas, /* i : bwe excitation class */ + const Word16 *R +); + +/*========================================================================================================/ +lognorm_fx.c +/========================================================================================================*/ + +void logqnorm_fx( + const Word32 *x, /* i : coefficient vector Qx */ + const Word16 qx, /* i : Q value of i */ + Word16 *k, /* o : index Q0 */ + const Word16 L, /* i : codebook length Q0 */ + const Word16 N, /* i : sub-vector size Q0 */ + const Word16 hvq_flag /* i : HVQ flag Q0 */ +); + +void logqnorm_2_fx( + const Word32 *env_fl, /* o : index */ + const Word16 L, /* i : codebook length */ + const Word16 n_env_band, /* i : sub-vector size */ + const Word16 nb_sfm, /* i : sub-vector size */ + Word16 *ynrm, + Word16 *normqlg2, + const Word32 *thren /* i : quantization thresholds */ +); + +void calc_norm_fx( + const Word32 *L_x, /* i : Input vector. Qx */ + const Word16 qx, /* i : Q value of i */ + Word16 *norm, /* o : Quantization indices for norms Q0 */ + Word16 *normlg, /* o : Quantized norms in log2 Q0 */ + const Word16 start_band, /* i : Indice of band to start coding Q0 */ + const Word16 num_bands, /* i : Number of bands Q0 */ + const Word16 *band_len, /* i : Length of bands Q0 */ + const Word16 *band_start /* i : Start of bands Q0 */ +); + +/*========================================================================================================/ +hq_tools_fx.c +/========================================================================================================*/ + +void hq_swb_harmonic_calc_norm_envelop_fx( + const Word32* L_SWB_signal, /* i : i signal Q=12*/ + Word32* L_envelope, /* o : output envelope Q=12*/ + const Word16 L_swb_norm, /* i : length of normaliztion */ + const Word16 SWB_flength /* i : length of i signal */ +); + +Word16 build_nf_codebook_fx( /* o : Number of coefficients in nf codebook */ + const Word16 flag_32K_env_ho, /* i : Envelope attenuation hangover flag */ + const Word16 *coeff, /* i : Coded spectral coefficients */ + const Word16 *sfm_start, /* i : Subband start indices */ + const Word16 *sfmsize, /* i : Subband widths */ + const Word16 *sfm_end, /* i : Subband end indices */ + const Word16 last_sfm, /* i : Last coded band */ + const Word16 *R, /* i : Per-band bit allocation */ + Word16 *CodeBook, /* o : Noise-fill codebook */ + Word16 *CodeBook_mod /* o : Densified noise-fill codebook */ +); + +void limit_band_noise_level_calc_fx( + const Word16 *wnorm, /* i : reordered norm of sub-vectors */ + Word16 *limit, /* o : highest band of bit allocation */ + const Word32 core_brate, /* i : bit rate */ + Word16 *noise_level /* o : noise level Q15 */ +); + +Word16 find_last_band_fx( /* o : index of last band */ + const Word16 *bitalloc, /* i : bit allocation */ + const Word16 nb_sfm /* i : number of possibly coded bands */ +); + +void apply_noisefill_HQ_fx( + const Word16 *R, /* i : bit allocation */ + const Word16 length, /* i : i frame length */ + const Word16 flag_32K_env_ho,/* i : envelope stability hangover flag*/ + const Word32 L_core_brate, /* i : core bit rate */ + const Word16 last_sfm, /* i : last coded subband */ + const Word16 *CodeBook, /* i : Noise-fill codebook */ + const Word16 *CodeBook_mod, /* i : Densified noise-fill codebook */ + const Word16 cb_size, /* i : Codebook length */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + const Word16 *sfmsize, /* i : Subband band width */ + Word16 *coeff /* i/o: coded/noisefilled spectrum */ +); + +void harm_bwe_fine_fx( + const Word16 *R, /* i : bit allocation */ + const Word16 last_sfm, /* i : last coded subband */ + const Word16 high_sfm, /* i : higher transition band to BWE */ + const Word16 num_sfm, /* i : total number of bands */ + const Word16 *norm, /* i : quantization indices for norms */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + Word16 *prev_L_swb_norm, /* i/o: last normalize length */ + Word16 *coeff, /* i/o: coded/noisefilled normalized spectrum */ + Word32 *coeff_out, /* o : coded/noisefilled spectrum */ + Word16 *coeff_fine /* o : BWE fine structure */ +); + +void hvq_bwe_fine_fx( + const Word16 last_sfm, /* i : last coded subband */ + const Word16 num_sfm, /* i : total number of bands */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + const Word16 *peak_idx, /* i : Peak index */ + const Word16 Npeaks, /* i : Number of peaks */ + Word16 *peak_pos, /* o : Peak positions */ + Word16 *prev_L_swb_norm, /* i/o: last normalize length */ + Word32 *L_coeff, /* i/o: coded/noisefilled normalized spectrum */ + Word16 *bwe_peaks, /* o : Positions of peaks in BWE */ + Word16 *coeff_fine /* o : HVQ BWE fine structure */ +); + +void harm_bwe_fx( + const Word16* coeff_fine, /* i : fine structure for BWE */ + const Word16* coeff, /* i : coded/noisefilled normalized spectrum */ + const Word16 num_sfm, /* i : Number of subbands */ + const Word16* sfm_start, /* i : Subband start coefficient */ + const Word16* sfm_end, /* i : Subband end coefficient */ + const Word16 last_sfm, /* i : last coded subband */ + const Word16* R, /* i : bit allocation */ + const Word16 prev_hq_mode, /* i : previous hq mode */ + Word16* norm, /* i/o: quantization indices for norms */ + Word16* noise_level, /* i/o: noise levels for harmonic modes */ + Word16* prev_noise_level, /* i/o: noise factor in previous frame */ + Word16* bwe_seed, /* i/o: random seed for generating BWE i */ + Word32* coeff_out, /* o : coded/noisefilled spectrum */ + const Word16 element_mode /* i : IVAS element mode */ +); + +void hq_fold_bwe_fx( + const Word16 last_sfm, /* i : last coded subband Q0 */ + const Word16 *sfm_end, /* i : Subband end coefficient Q0 */ + const Word16 num_sfm, /* i : Number of subbands Q0 */ + Word16 *coeff /* i/o: coded/noisefilled normalized spectrum Q12 */ +); + +void apply_nf_gain_fx( + const Word16 nf_idx, /* i : noise fill gain index Q0 */ + const Word16 last_sfm, /* i : last coded subband Q0 */ + const Word16 *R, /* i : bit allocation Q0 */ + const Word16 *sfm_start, /* i : Subband start coefficient Q0 */ + const Word16 *sfm_end, /* i : Subband end coefficient Q0 */ + Word16 *coeff /* i/o: coded/noisefilled normalized spectrum Q12 */ +); + +void hvq_bwe_fx( + const Word32 *coeff, + const Word16 *coeff_fine, /* i : coded/noisefilled normalized spectrum Qin */ + const Word16 *sfm_start, /* i : Subband start coefficient Q0 */ + const Word16 *sfm_end, /* i : Subband end coefficient Q0 */ + const Word16 *sfm_len, /* i : Subband length Q0 */ + const Word16 last_sfm, /* i : last coded subband Q0 */ + const Word16 prev_hq_mode, /* i : previous hq mode Q0 */ + const Word16 *bwe_peaks, /* i : HVQ bwe peaks Q0 */ + const Word16 bin_th, /* i : HVQ transition bin Q0 */ + const Word16 num_sfm, /* i : Number of bands Q0 */ + const Word32 core_brate, /* i : Core bit-rate Q0 */ + const Word16 *R, /* i : Bit allocation */ + Word16 *norm, /* i/o: quantization indices for norms Q0 */ + Word16 *noise_level, /* i/o: noise levels for harmonic modes Q15 */ + Word16 *prev_noise_level, /* i/o: noise factor in previous frame Q15 */ + Word16 *bwe_seed, /* i/o: random seed for generating BWE i Q0 */ + Word32 *L_coeff_out, /* o : coded/noisefilled spectrum Qout*/ + const Word16 qin, + const Word16 qout +); + +void hvq_concat_bands_fx +( + const Word16 pvq_bands, /* i : Number of bands in concatenated PVQ target */ + const Word16 *sel_bnds, /* i : Array of selected high bands */ + const Word16 n_sel_bnds, /* i : Number of selected high bands */ + Word16 *hvq_band_start, /* i : Band start indices */ + Word16 *hvq_band_width, /* i : Band widths */ + Word16 *hvq_band_end /* i : Band end indices */ +); + +void noise_mix_fx( + const Word16 *coeff_fine, /* i : normalized fine structure spectrum Qin */ + const Word32 L_E, /* i : normalization factor Q17 */ + const Word32 L_normq, /* i : quantized norm Q14 */ + Word16 *seed, /* i/o: random seed Q0 */ + const Word16 istart, /* i : start coefficient Q0 */ + const Word16 iend, /* i : end coefficient Q0 */ + const Word16 noise_level, /* i : noise_level Q0 */ + Word32 *L_coeff_out, /* o : noisemixed spectrum Qout */ + const Word16 qin, + const Word16 qout +); + +void hq_generic_fine_fx( + Word16 *coeff, /* i : coded/noisefilled normalized spectrum */ + const Word16 last_sfm, /* i : Last coded band */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + Word16 *bwe_seed, /* i/o: random seed for generating BWE i */ + Word16 *coeff_out1 /* o : HQ Generic i */ +); + +void map_hq_generic_fenv_norm_fx( + const Word16 hqswb_clas, + const Word16 *hq_generic_fenv, /* Q1, frequency-domain BWE envelope */ + Word16 *ynrm, + Word16 *normqlg2, + const Word16 num_env_bands, + const Word16 nb_sfm, + const Word16 hq_generic_offset +); + +Word16 get_nor_delta_hf_fx( + Decoder_State_fx *st, + Word16 *ynrm, + Word16 *Rsubband, /* Q3 */ + const Word16 num_env_bands, + const Word16 nb_sfm, + const Word16 core_sfm +); + +Word16 calc_nor_delta_hf_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word32* t_audio, /* i : transform-domain coefficients */ + Word16* ynrm, /* i/o: norm indices */ + Word16* Rsubband, /* i/o: sub-band bit allocation */ + const Word16 num_env_bands, /* i : Number coded envelope bands */ + const Word16 nb_sfm, /* i : Number of envelope bands */ + const Word16* sfmsize, /* i : band length */ + const Word16* sfm_start, /* i : Start index of bands */ + const Word16 core_sfm /* i : index of the end band for core */ +); + +void hq_bwe_fx( + const Word16 HQ_mode, /* i : HQ mode */ + Word32 *coeff_out1, /* i/o: BWE i & temporary buffer */ + const Word16 *hq_generic_fenv, /* i : SWB frequency envelopes */ + Word32 *coeff_out, /* o : SWB signal in MDCT domain */ + const Word16 hq_generic_offset, /* i : frequency offset for representing hq generic bwe*/ + Word16 *prev_L_swb_norm, /*i/o : last normalize length */ + const Word16 hq_generic_exc_clas,/* i : bwe excitation class */ + const Word16 *sfm_end, /* i : End of bands */ + const Word16 num_sfm, + const Word16 num_env_bands, + const Word16 *R +); + +void hq_wb_nf_bwe_fx( + const Word16 *coeff_fx, /* i : coded/noisefilled normalized spectrum */ + const Word16 is_transient, + const Word16 prev_bfi, /* i : previous bad frame indicator */ + const Word32 *L_normq_v, + const Word16 num_sfm, /* i : Number of subbands */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + const Word16 *sfmsize, /* i : Subband band width */ + const Word16 last_sfm, /* i : last coded subband */ + const Word16 *R, /* i : bit allocation */ + const Word16 prev_is_transient, /* i : previous transient flag */ + Word32 *prev_normq_fx, /* i/o: previous norms */ + Word32 *prev_env_fx, /* i/o: previous noise envelopes */ + Word16 *bwe_seed, /* i/o: random seed for generating BWE i */ + Word32 *prev_coeff_out_fx, /* i/o: decoded spectrum in previous frame */ + Word16 *prev_R, /* i/o: bit allocation info. in previous frame */ + Word32 *L_coeff_out, /* o : coded/noisefilled spectrum */ + Word16 *prev_env_Q +); + +void enforce_zero_for_min_envelope_fx( + const Word16 hqswb_clas, /* i : HQ coding mode Q0 */ + const Word16 *ynrm, /* i : Envelope indices Q0 */ + Word32 *L_coefsq, /* i/o: Quantized spectrum/zeroed spectrum Q12 */ + const Word16 nb_sfm, /* i : Number of coded sub bands Q0 */ + const Word16 *sfm_start, /* i : Sub band start indices Q0 */ + const Word16 *sfm_end /* i : Sub band end indices Q0 */ +); + +void apply_envelope_fx( + const Word16 *coeff, /* i : Coded/noisefilled normalized spectrum Q12 */ + const Word16 *norm, /* i : Envelope */ + const Word16 *norm_adj, /* i : Envelope adjustment Q15 */ + const Word16 num_sfm, /* i : Total number of bands */ + const Word16 last_sfm, /* i : Last coded band */ + const Word16 HQ_mode, /* i : HQ mode */ + const Word16 length, /* i : Frame length */ + const Word16 *sfm_start, /* i : Sub band start indices */ + const Word16 *sfm_end, /* i : Sub band end indices */ + Word32 *normq_v, /* o : Envelope with adjustment Q14 */ + Word32 *coeff_out, /* o : coded/noisefilled spectrum */ + const Word16 *coeff1, /* i : coded/noisefilled spectrum Q12 */ + Word32 *coeff_out1 /* o : coded/noisefilled spectrum Q12 */ +); + +/*========================================================================================================/ +lsf_tools_fx.c +/========================================================================================================*/ + +void compute_poly_product_fx(Word16 *coef, Word32 *p, Word16 order); + +Word16 xsp_to_xsf( + Word16 lsp +); + +Word16 xsf_to_xsp( + Word16 lsf +); + +void lsp_convolve_fx(Word32 x, Word32 *p1, Word32 *p2, Word16 len); +Word32 poscos_fx(Word16 w); + +Word32 sub_lsp2lsf_fx( + const Word16 lsp_i /* i : lsp[m] (range: -1<=val<1) Q15*/ +); + +void E_LPC_lsp_lsf_conversion( + const Word16 lsp[], /* i : lsp[m] (range: -1<=val<1) */ + Word16 lsf[], /* output : lsf[m] normalized (range: 0<=val<=6400) */ + const Word16 m /* i : LPC order */ +); +void E_LPC_lsf_lsp_conversion( + const Word16 lsf[], /* i : lsf[m] normalized (range: 0<=val<=6400) */ + Word16 lsp[], /* o : lsp[m] (range: -1<=val<1) */ + const Word16 m /* i : LPC order */ +); + +void E_LPC_f_lsp_a_conversion(const Word16 *lsp, Word16 *a, const Word16 m); +void E_LPC_a_isp_conversion( + const Word16 *a, /* i : LP filter coefficients */ + Word16 *isp, /* o : Line spectral pairs (in the cosine domain) */ + const Word16 *old_isp,/* i : LSP vector from past frame */ + const Word16 m /* i : LPC order */ +); +void E_LPC_isp_isf_conversion(const Word16 isp[], Word16 isf[], const Word16 m); +void E_LPC_isf_isp_conversion(const Word16 isf[], Word16 isp[], const Word16 m); +void E_LPC_f_isp_a_conversion(const Word16 *isp, Word16 *a, const Word16 m); + +void E_LPC_a_lsp_conversion( + const Word16 *a, /* i : LP filter coefficients */ + Word16 *lsp, /* o : Line spectral pairs (in the cosine domain) */ + const Word16 *old_lsp, /* i : LSP vector from past frame */ + const Word16 m /* i : LPC order */ +); + +Word16 lpc2lsp_fx( + Word32 *a, + Word16 *freq, + Word16 *old_freq, + Word16 order +); + +void lsp2lpc_fx( + Word16 *a, + Word16 *freq, + Word16 *prev_a, + Word16 order +); + +void E_LPC_a_lsp_conversion( + const Word16 *a, /* i : LP filter coefficients */ + Word16 *lsp, /* o : Line spectral pairs (in the cosine domain) */ + const Word16 *old_lsp, /* i : LSP vector from past frame */ + const Word16 m /* i : LPC order */ +); + +void v_sort(Word16 *r, const Word16 lo, const Word16 up); + +void compute_poly_product_fx(Word16 *coef, Word32 *p, Word16 order); + +void msvq_dec +( + const Word16 *const*cb, /* i : Codebook (indexed cb[*stages][levels][p]) (0Q15) */ + const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ + const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ + const Word16 stages, /* i : Number of stages */ + const Word16 N, /* i : Vector dimension */ + const Word16 maxN, /* i : Codebook dimension */ + const Word16 Idx[], /* i : Indices */ +#ifdef IVAS_MSVQ + const int16_t applyIDCT_flag, /* i : applyIDCT flag */ + const float* invTrfMatrix, /* i : matrix for IDCT synthesis */ +#endif + Word16 *uq /* o : quantized vector (3Q12) */ +); + +Word16 tcxlpc_get_cdk( + Word16 coder_type /* (I) VOICED indicator */ +); + +void lsf_syn_mem_restore_fx( + Encoder_State *st_fx, /* o: state structure */ + Word16 btilt_code_fx, /* i: */ + Word32 gc_threshold_fx, /* i: */ + Word16 *clip_var_bck_fx, /* i: */ + Word16 next_force_sf_bck_fx, /* i: */ + Word16 *lsp_new, /* o: LSP vector to quantize */ + Word16 *lsf_new, /* o: quantized LSF vector */ + Word16 *lsp_mid, /* o: mid-frame LSP vector */ + Word16 clip_var, /* i: pitch clipping state var */ + Word16 *mem_AR, /* i: quantizer memory for AR model */ + Word16 *mem_MA, /* i: quantizer memory for MA model */ + Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup */ + Word16 *lsf_new_bck, /* i: quantized LSF vector - backup */ + Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup */ + Word16 mCb1, /* i: counter for stationary frame after a transition frame */ + Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets */ + Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets */ + Word16 *mem_syn_bck, /* i: synthesis filter memory */ + Word16 mem_w0_bck, /* i: memory of the weighting filter */ + Word16 streaklimit, /* i:LSF quantizer */ + Word16 pstreaklen /* i:LSF quantizer */ +); + +void lsf_update_memory( + Word16 narrowband, /* i : narrowband flag */ + const Word16 qisf[], /* i : quantized xSF coefficients */ + Word16 old_mem_MA[], /* i : MA memory */ + Word16 mem_MA[], /* o : updated MA memory */ + Word16 lpcorder /* i : LPC order */ +); + +void lsf_syn_mem_backup_fx( + Encoder_State *st_fx, /* i: state structure */ + Word16 *btilt_code, /* i: tilt code */ + Word32 *bgc_threshold, /* i: */ + Word16 *clip_var_bck, /* o: */ + Word16 *next_force_sf_bck, /* o: */ + Word16 *lsp_new, /* i: LSP vector to quantize */ + Word16 *lsf_new, /* i: quantized LSF vector */ + Word16 *lsp_mid, /* i: mid-frame LSP vector */ + Word16 *clip_var, /* o: pitch clipping state var */ + Word16 *mem_AR, /* o: quantizer memory for AR model */ + Word16 *mem_MA, /* o: quantizer memory for AR model */ + Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup */ + Word16 *lsf_new_bck, /* o: quantized LSF vector - backup */ + Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup */ + Word16 *mCb1, /* o: counter for stationary frame after a transition frame */ + Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets */ + Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets */ + Word16 *mem_syn_bck, /* o: synthesis filter memory */ + Word16 *mem_w0_bck, /* o: memory of the weighting filter */ + Word16 *streaklimit, + Word16 *pstreaklen +); + +void tcvq_Dec_fx( + Word16* ind, + Word16* d_out_fx, + const Word16 safety_net +); + +Word16 qlsf_ARSN_tcvq_Dec_16k_fx( + Word16 *y_fx, /* o : Quantized LSF vector */ + Word16 *indice, /* i : Indices */ + const Word16 nBits /* i : number of bits */ +); + +void lsf2lsp_fx( + const Word16 lsf[], /* i : lsf[m] normalized (range: 0.0<=val<=0.5) x2.56 */ + Word16 lsp[], /* o : lsp[m] (range: -1<=val<1) Q15 */ + const Word16 m, /* i : LPC order Q0 */ + const Word32 int_fs /* i : internal sampling frequency */ +); + +void lsp2lsf_fx( + const Word16 lsp[], /* i : lsp[m] (range: -1<=val<1) Q15*/ + Word16 lsf[], /* o : lsf[m] normalized (range: 0.0<=val<=0.5) Q(x2.56)*/ + const Word16 m, /* i : LPC order Q0*/ + const Word32 int_fs /* i : internal sampling frequency */ +); + +void isf2lsf_fx( + const Word16 *isf, /* i : ISF vector */ + Word16 *lsf, /* o : LSF vector */ + Word16 *stable_lsp /* i/o: stable LSP filter coefficients */ +); + +void lsf2isf_fx( + const Word16 *lsf, /* i : LSF vector */ + Word16 *isf, /* o : ISF vector */ + Word16 *stable_isp, /* i/o: stable ISP filter coefficients */ + const Word16 m /* i : order of LP analysis */ +); + +void isp2lsp_fx( + const Word16 *isp, /* i : LSP vector */ + Word16 *lsp, /* o : ISP filter coefficients */ + Word16 *stable_lsp, /* i/o: stable LSP filter coefficients */ + const Word16 m /* i : order of LP analysis */ +); + +void lsp2isp_fx( + const Word16 *lsp, /* i : LSP vector */ + Word16 *isp, /* o : ISP filter coefficients */ + Word16 *stable_isp, /* i/o: ISP filter coefficients */ + const Word16 m /* i : order of LP analysis */ +); + +Word16 lsf_stab_fx( /* o : LP filter stability Q15*/ + const Word16 *lsf, /* i : LSF vector Q(x2.56)*/ + const Word16 *lsfold, /* i : old LSF vector Q(x2.56)*/ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame /* i : frame length */ +); + +void reorder_isf_fx( + Word16 *isf, /* i/o: ISFs in the frequency domain (0..0.5) */ + const Word16 min_dist, /* i : minimum required distance */ + const Word16 n, /* i : LPC order */ + const Word16 fs /* i : sampling frequency */ +); + +ivas_error find_pred_mode( + Word16* predmode, /* o: prediction mode */ + const Word16 coder_type, /* i: coding type */ + const Word16 bwidth, /* i: bandwidth index */ + const Word32 int_fs, /* i: sampling frequency */ + Word16* p_mode_lvq, /* o: index of LSF codebooks in safety net mode */ + Word16* p_mode_lvq_p, /* o: index of LSF codebooks in predictive mode (AR or MA) */ + Word32 core_brate /* i: core bit rate */ +); + +ivas_error lsf_allocate_fx( + const Word16 nBits, /* i : Number of bits to use for quantization */ + const Word16 framemode, /* i : ISF quantizer mode */ + const Word16 framemode_p, /* i : ISF quantizer mode predmode (mode_lvq_p) */ + Word16* stages0, /* o : Number of stages for safety-net quantizer */ + Word16* stages1, /* o : Number of stages for predictive quantizer */ + Word16 levels0[], /* o : Number of vectors for each stage for SFNET */ + Word16 levels1[], /* o : Number of vectors for each stage for pred */ + Word16 bits0[], /* o : Number of bits for each stage safety net */ + Word16 bits1[] /* o : Number of bits for each stage pred */ +); + +Word16 vq_dec_lvq_fx( + Word16 sf_flag, /* i : safety net flag */ + Word16 x[], /* o : Decoded vector Q(x2.56)*/ + Word16 indices[], /* i : Indices */ + Word16 stages, /* i : Number of stages */ + Word16 N, /* i : Vector dimension */ + Word16 mode, /* (i): mode_lvq, or mode_lvq_p */ + Word16 no_bits, /* (i): no. bits for lattice */ + Word32 *p_offset_scale1, + Word32 *p_offset_scale2, + Word32 *p_offset_scale1_p, + Word32 *p_offset_scale2_p, + Word16 *p_no_scales, + Word16 *p_no_scales_p +); + +void a2rc_fx(const Word16 *a, Word16 *refl, Word16 lpcorder); + +void lsp_weights_fx( + Word16 lsp_nq_fx[], + Word16 w[], + Word16 Order, + Word16 *Qout +); + +void space_lsfs_fx( + Word16 *lsfs, /* i/o: Line spectral frequencies */ + const Word16 order /* i : order of LP analysis */ +); + +void reorder_lsf_fx( + Word16 *lsf, /* i/o: LSFs in the frequency domain (0..0.5) Q(x2.56)*/ + const Word16 min_dist, /* i : minimum required distance x2.56*/ + const Word16 n, /* i : LPC order */ + const Word32 fs /* i : sampling frequency */ +); + +/*========================================================================================================/ +lpc_tools_fx.c +/========================================================================================================*/ + +void autocorr_fx( + const Word16 x[], /* i : Input signal */ + const Word16 m, /* i : LPC order Q0 */ + Word16 r_h[], /* o : Autocorrelations (msb) Q15 */ + Word16 r_l[], /* o : Autocorrelations (lsb) */ + Word16 *Q_r, /* o : normailsation shift of r Q0 */ + const Word16 len, /* i : Frame lenght */ + const Word16* wind, /* i : Window used */ + Word16 rev_flag, + const Word16 sym_flag /* i : symmetric window flag */ +); + +Word16 E_LPC_lev_dur(const Word16 Rh[], const Word16 Rl[], Word16 A[], + Word32 epsP[], const Word16 order, Word16 *parcorr +); +Word16 E_LPC_lev_dur_stab(const Word16 Rh[], const Word16 Rl[], Word16 A[], + Word32 epsP[], const Word16 order, Word16 *parcorr, Word16 k_max +); +void E_LPC_a_add_tilt(const Word16 *a, Word16 *ap, Word16 gamma, Word16 m); +void E_LPC_int_lpc_tcx(const Word16 lsp_old[], /* i : LSPs from past frame (1Q14) */ + const Word16 lsp_new[], /* i : LSPs from present frame (1Q14) */ + Word16 a[] /* o : interpolated LP coefficients (4Q11) */ +); + +Word16 E_LPC_lsp_unweight( + /* const */ Word16 xsp_w[], /* (I): weighted xSP */ + Word16 xsp_uw[], /* (O): unweighted xSP */ + Word16 xsf_uw[], /* (O): unweighted xSF */ + Word16 inv_gamma, /* (I): inverse weighting factor */ + Word16 lpcorder /* (I): prediction order */ +); + +Word32 E_LPC_schur(Word32 r[], Word16 reflCoeff[], Word32 epsP[], const Word16 m); +void E_LPC_a_lsf_isf_conversion(Word16 *lpcCoeffs, Word16 *lsf, const Word16 *old_lsf, Word16 lpcOrder, Word8 lpcRep); + + +/*========================================================================================================/ +bitstream_fx.c +/========================================================================================================*/ + +UWord16 get_next_indice_fx( /* o : value of the indice */ + Decoder_State_fx *st_fx, /* i/o: decoder state structure */ + Word16 nb_bits /* i : number of bits that were used to quantize the indice */ +); + +void push_indice_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 id, /* i : ID of the indice */ + UWord16 value, /* i : value of the quantized indice */ + Word16 nb_bits /* i : number of bits used to quantize the indice */ +); + +void push_next_indice_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + UWord16 value, /* i : value of the quantized indice */ + Word16 nb_bits /* i : number of bits used to quantize the indice */ +); + +Word16 rate2EVSmode( + const Word32 brate, /* i : bitrate */ + Word16* is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ +); + +void push_next_bits_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 bits[], /* i : bit buffer to pack, sequence of single bits */ + Word16 nb_bits /* i : number of bits to pack */ +); + +UWord16 get_next_indice_fx( /* o : value of the indice */ + Decoder_State_fx *st_fx, /* i/o: decoder state structure */ + Word16 nb_bits /* i : number of bits that were used to quantize the indice */ +); + +UWord16 get_next_indice_1_fx( /* o : value of the indice */ + Decoder_State_fx *st_fx /* i/o: decoder state structure */ +); + +void get_next_indice_tmp_fx( + Decoder_State_fx *st_fx, /* i/o: decoder state structure */ + Word16 nb_bits /* i : number of bits that were used to quantize the indice */ +); + +UWord16 get_indice_fx( /* o : value of the indice */ + Decoder_State_fx *st_fx, /* i/o: decoder state structure */ + Word16 pos, /* i : absolute position in the bitstream */ + Word16 nb_bits /* i : number of bits that were used to quantize the indice */ +); + +UWord16 get_indice_1_fx( /* o : value of the indice */ + Decoder_State_fx *st_fx, /* i/o: decoder state structure */ + Word16 pos /* i : absolute position in the bitstream */ +); + +void reset_indices_enc_fx( + BSTR_ENC_HANDLE hBstr /* i/o: encoder state structure */ +); + +void reset_indices_dec_fx( + Decoder_State_fx *st_fx /* i/o: decoder state structure */ +); + +void write_indices_fx( + Encoder_State* st_fx, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ + FILE* file /* i : output bitstream file */ + , UWord8* pFrame, /* i: byte array with bit packet and byte aligned coded speech data */ + Word16 pFrame_size /* i: size of the binary encoded access unit [bits] */ +); + +void indices_to_serial( + const Encoder_State* st_fx, /* i: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ + UWord8* pFrame, /* o: byte array with bit packet and byte aligned coded speech data */ + Word16* pFrame_size /* o: size of the binary encoded access unit [bits] */ +); + +void indices_to_serial_generic( + const Indice *ind_list, /* i: indices list */ + const Word16 num_indices, /* i: number of indices to write */ + UWord8 *pFrame, /* o: byte array with bit packet and byte aligned coded speech data */ + Word16 *pFrame_size /* i/o: number of bits in the binary encoded access unit [bits] */ +); + +void dec_prm_core( + Decoder_State_fx *st +); + +void decision_matrix_core_dec( + Decoder_State_fx *st /* i/o: decoder state structure */ +); + +Word16 BRATE2IDX_fx(Word32 brate); +Word16 BRATE2IDX16k_fx(Word32 brate); + +Word32 BIT_ALLOC_IDX_fx(Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc); +Word32 BIT_ALLOC_IDX_16KHZ_fx(Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc); + +Word16 read_indices_fx( /* o : 1 = OK, 0 = something wrong */ + Decoder_State_fx *st_fx, /* i/o: decoder state structure */ + FILE *file, /* i : bitstream file */ + Word16 rew_flag /* i : rewind flag (rewind file after reading) */ +); + +Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem */ + Decoder_State_fx *st, /* i/o: decoder state structure */ + FILE *file, /* i : bitstream file */ + Word16 rew_flag /* i : rewind flag (rewind file after reading)*/ +); + +void getPartialCopyInfo( + Decoder_State_fx *st, /* i : decoder state structure */ + Word16 *coder_type, + Word16 *sharpFlag +); + +void get_rfFlag( + Decoder_State_fx *st, /* i : decoder state structure */ + Word16 *rf_flag, /* o : check for the RF flag */ + Word16 *nBits, + Word16 *ind +); + +void get_rfFrameType( + Decoder_State_fx *st, /* i : decoder state structure */ + Word16 *rf_frame_type /* o : RF frame type */ +); + +void get_rf_fec_offset( + Decoder_State_fx *st, /* i : decoder state structure */ + Word16 *rf_fec_offset /* o : RF fec offset */ +); + +void get_rfTargetBits( + Word16 rf_frame_type, /* i : RF frame type */ + Word16 *rf_target_bits /* o : Number of RF target bits */ +); + +void get_NextCoderType_fx( + UWord8 *bitsteam, /* i : bitstream */ + Word16 *next_coder_type /* o : next coder type */ +); + +void read_indices_from_djb_fx( + Decoder_State_fx *st, /* i/o: decoder state structure */ + UWord8 *pt_stream, /* i : bitstream file */ + Word16 nbits /* i : number of bits */ + , Word16 isAMRWB_IOmode + , Word16 core_mode + , Word16 qbit + , Word16 partialframe /* i : partial frame information */ + , Word16 next_coder_type /* i : next coder type information */ +); + +void evs_dec_previewFrame( + UWord8 *bitstream, /* i : bitstream pointer */ + Word16 bitstreamSize, /* i : bitstream size */ + Word16 *partialCopyFrameType, /* o : frame type of the partial copy */ + Word16 *partialCopyOffset /* o : offset of the partial copy relative to the primary copy */ +); + +/*========================================================================================================/ +scale_mem_fx.c +/========================================================================================================*/ + +Word16 Rescale_exc( + Word16 dct_post_old_exc_fx[], /* i/o: Music post processing memory */ + Word16 exc[], /* i/o: excitation to rescale Q_exc */ + Word16 bwe_exc[], + Word16 *last_exc_dct_in, + Word16 lg, /* i : frame size */ + Word16 lg32, + Word32 L_gain_code, /* i : decoded codebook gain Q16 */ + Word16 *sQ_exc, /* i/o: Excitation scaling factor */ + Word16 *sQsubfr, /* i/o: Past excitation scaling factors */ + Word16 exc2[], /* o : local excitation vector */ + Word16 i_subfr, /* i : subframe number */ + const Word16 coder_type +); + +void Rescale_mem( + const Word16 Q_exc, /* i : current excitation scaling (>=0) */ + Word16 *prev_Q_syn, /* i/o : scaling factor of previous frame */ + Word16 *Q_syn, /* i/o : scaling factor of frame */ + Word16 *mem_syn2, /* i/o : modified synthesis memory */ + Word16 *mem_syn_clas_estim_fx, /* i/o : old 12k8 core memory for classification */ + const Word16 MaxScaling, /* i: Minimal difference between excitation scaling and synthesis scaling */ + Word16 *mem_deemph, /* i/o: speech deemph filter memory */ + Word16 *pst_old_syn, /* i/o: psfiler */ + Word16 *pst_mem_deemp_err, /* i/o: psfiler */ + Word16 *mem_agc, + PFSTAT_HANDLE hPFstat, /* i/o: All memories related to NB post filter */ + const Word16 Vad_flag, + const Word16 Cna_flag, + const Word16 *tmp_buffer /* tmp_buffer in Q-1 */ +); + +void scale_sig32( + Word32 x[], /* i/o: signal to scale Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx xx exp */ +); + +Word16 rescale_mem( + const Word16 *Q_exc, /* i : current excitation scaling (>=0) */ + Word16 *prev_Q_syn, /* i/o : scaling factor of previous frame */ + Word16 *Q_syn, /* i/o : scaling factor of frame */ + Word16 *mem_syn2, /* i/o : modified synthesis memory */ + Word16 *syn, /* i/o : synthesis to rescale Q_syn */ + Word16 mem_len, /* i : lenght of modified synthesis memory */ + Word16 i_subfr /* i : subframe number */ +); + +//hq_conf.c +void hq_configure_fx( + const Word16 length, /* i : Frame length Q0 */ + const Word16 hqswb_clas, /* i : HQ SWB class Q0 */ + const Word32 core_brate, /* i : Codec bitrate Q0 */ + Word16 *num_sfm, /* o : Total number of subbands Q0 */ + Word16 *nb_sfm, /* o : Total number of coded bands Q0 */ + Word16 *start_norm, /* o : First norm to be SDE encoded Q0 */ + Word16 *num_env_bands, /* o : Number coded envelope bands Q0 */ + Word16 *numnrmibits, /* o : Number of bits in fall-back norm encoding Q0 */ + Word16 *hq_generic_offset, /* o : Freq offset for HQ GENERIC Q0 */ + Word16 *sfmsize, /* o : Subband bandwidths Q0 */ + Word16 *sfm_start, /* o : Subband start coefficients Q0 */ + Word16 *sfm_end /* o : Subband end coefficients Q0 */ +); + + +//hp50.c +void hp20(Word16 signal[], /* i/o: signal to filter any */ + const Word16 stride, /* i : stride to be applied accessing signal */ + const Word16 lg, /* i : length of signal (integer) Q0 */ + Word32 mem[5], /* i/o: static filter memory with this layout: */ + /* mem[0]: y[-2] (32-bit) */ + /* mem[1]; y[-1] (32-bit) */ + /* mem[2]: x[-2] << 16 */ + /* mem[3]: x[-1] << 16 */ + /* Note: mem[0..3] need to be scaled per frame */ + /* mem[4]: states scale */ + const Word32 sFreq); + +//get_gain.c +Word32 get_gain( /* encoder side; enc = 0 -> decoder side */ + Word16 *sign /* i/o: sign of the maximum */ +); + +//env_stab_trans.c +void env_stab_transient_detect_fx( + const Word16 is_transient, /* i: Transient flag */ + const Word16 length, /* i : Length of spectrum (32 or 48 kHz) */ + const Word16 norm[], /* i : quantization indices for norms */ + Word16 *no_att_hangover, /* i/o: Frame counter for attenuation hangover (Q0) */ + Word32 *L_energy_lt, /* i/o: Long-term energy measure for transient detection (Q13) */ + const Word16 HQ_mode, /* i : HQ coding mode */ + const Word16 bin_th, /* i : HVQ cross-over frequency bin */ + const Word32 *L_coeff, /* i : Coded spectral coefficients */ + const Word16 Qcoeff /* i : Q of coded spectral coefficients */ +); + + +//env_adj.c +void env_adj_fx +( + const Word16 *pulses, /* i : number of pulses per band Q0 */ + const Word16 length, /* i : length of spectrum Q0 */ + const Word16 last_sfm, /* i : index of the last band Q0 */ + Word16 *adj, /* o : adjustment factors for the envelope Q15 */ + const Word16 env_stab, /* i : envelope stability Q15 */ + const Word16 *sfmsize /* i : subband sizes Q0 */ +); + + +//env_stab.c + +Word16 env_stability_fx( /* in Q15 */ + const Word16 *ynrm, /*i: Norm vector for current frame */ + const Word16 nb_sfm, /*i: Number of sub-bands */ + Word16 *mem_norm, /*i/o: Norm vector memory from past frame */ + Word16 *mem_env_delta, /*i/o: Envelope stability memory for smoothing in Q11 */ + const Word16 core_switching_flag/* i : Core switching flag */ +); + +Word16 env_stab_smo_fx( /* Q0 */ + Word16 env_stab, /*i : env_stab value Q15 */ + Word16 *env_stab_state_p, /*i/o: env_stab state probabilities Q15 */ + Word16 *ho_cnt /*i/o: hangover counter for speech state */ +); + +//enr_1_az.c +Word16 Enr_1_Az_fx( /* o : impulse response energy Q3 */ + const Word16 Aq[], /* i : LP filter coefs Qx based on the fact that Aq[0] == 1.0 */ + const Word16 len /* i : impulse response length Q0 */ +); +#ifdef BASOP_NOGLOB +Word16 Enr_1_Az_fx_o( /* o : impulse response energy Q3 */ + const Word16 Aq[], /* i : LP filter coefs Qx based on the fact that Aq[0] == 1.0 */ + const Word16 len, /* i : impulse response length Q0 */ + Flag* Overflow_out /* o : propagating the Overflow flag to upper level */ +); +#endif + +//gs_gains_fx.c +void Ener_per_band_comp_fx( + const Word16 exc_diff[], /* i : target signal Q_exc_diff */ + Word16 y_gain4[], /* o : Energy per band to quantize Q12 */ + const Word16 Q_exc_diff, + const Word16 Mband, /* i : Max band */ + const Word16 Eflag +); + +void Comp_and_apply_gain_fx( + Word16 exc_diffQ[], /* i/o: Quantized excitation */ + Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */ + Word16 Ener_per_bd_yQ[], /* i/o : Ener per band for norm vector i->Q13/o->Q13 */ + Word16 Mbands_gn, /* i : number of bands */ + const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ + Word16 Qexc_diff, + Word16 Q_exc +); + +//gs_preech.c +void pre_echo_att_fx( + Word32* Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/ + Word16* exc_fx, /* i/o: Excitation of the current frame Q_new*/ + const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) */ + const Word16 Q_new, + const Word16 last_coder_type_fx, /* i : Last coding mode */ + const Word16 L_frame /* i : Frame length*/ +); + +#endif \ No newline at end of file diff --git a/lib_com/pvq_com.c b/lib_com/pvq_com.c index 7a13fe3f5..f31c4dc7d 100644 --- a/lib_com/pvq_com.c +++ b/lib_com/pvq_com.c @@ -740,20 +740,20 @@ static uint32_t UL_div( /*-------------------------------------------------------------------* - * UL_inverse() + * UL_inverse_float() * * Calculate inverse of UL_val. Output in Q_exp. *-------------------------------------------------------------------*/ /*! r: inverse */ -uint32_t UL_inverse( +uint32_t UL_inverse_float( const uint32_t UL_val, /* i : input value Q_exp */ int16_t *exp /* i/o: input exp / result exp */ ) { uint32_t UL_tmp; - *exp = norm_ul( UL_val ); /* aligned to BASOP */ + *exp = norm_ul_float( UL_val ); /* aligned to BASOP */ UL_tmp = UL_val << ( *exp ); /* Q32*/ *exp = 32 + 31 - *exp; @@ -768,7 +768,7 @@ uint32_t UL_inverse( *----------------------------------------------------------------------------*/ /*! r: ratio */ -Word16 ratio( +Word16 ratio_float( const Word32 numer, /* i : numerator */ const Word32 denom, /* i : denominator */ Word16 *expo /* i/o: input exp / result exp */ @@ -816,7 +816,7 @@ Word16 atan2_fx( { return 25736; /* EVS_PI/2 in Q14 */ } - man = ratio( y, x, &expo ); /* man in Q14 */ + man = ratio_float( y, x, &expo ); /* man in Q14 */ expo = sub( expo, ( 15 - 14 ) ); /* Now, man is considered in Q15 */ arg = L_shr( (Word32) man, expo ); diff --git a/lib_com/range_com.c b/lib_com/range_com.c index 7b3ca8d5e..abe5bb77d 100644 --- a/lib_com/range_com.c +++ b/lib_com/range_com.c @@ -54,7 +54,7 @@ int16_t rc_get_bits2( ) { int16_t tmp; - tmp = N + 2 + norm_ul( range ); /* aligned to BASOP */ + tmp = N + 2 + norm_ul_float( range ); /* aligned to BASOP */ return tmp; } @@ -75,7 +75,7 @@ void rangeCoderFinalizationFBits( uint16_t Bq15ui16, B, E; int16_t k; - B = 30 - norm_ul( INTrc ); /* aligned to BASOP */ + B = 30 - norm_ul_float( INTrc ); /* aligned to BASOP */ #define RCF_INIT_SHIFTp1 ( RCF_INIT_SHIFT + 1 ) #define RCF_FINALIZE_LIMIT ( ( 1L << 16 ) - 1 ) diff --git a/lib_com/recovernorm.c b/lib_com/recovernorm.c index 5b02843c0..897803eb3 100644 --- a/lib_com/recovernorm.c +++ b/lib_com/recovernorm.c @@ -76,7 +76,7 @@ void recovernorm( for ( i = 0; i < nb_sfm; i++ ) { ynrm[order[i]] = idxbuf[i]; - normqlg2[order[i]] = dicnlg2[idxbuf[i]]; + normqlg2[order[i]] = dicnlg2_float[idxbuf[i]]; } return; diff --git a/lib_com/rom_basop_util.c b/lib_com/rom_basop_util.c new file mode 100644 index 000000000..b0c91f723 --- /dev/null +++ b/lib_com/rom_basop_util.c @@ -0,0 +1,816 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "rom_basop_util.h" +#include "stl.h" +#include +#include +#include "options.h" + + +#define STC(x) WORD322WORD16(x) + +#define STCP(a,b) { { STC(a), STC(b) } } + +const PWord16 SineTable512[] = +{ + STCP(0x7fffffff, 0x00000000), STCP(0x7fffd886, 0x006487e3), STCP(0x7fff6216, 0x00c90f88), STCP(0x7ffe9cb2, 0x012d96b1), + STCP(0x7ffd885a, 0x01921d20), STCP(0x7ffc250f, 0x01f6a297), STCP(0x7ffa72d1, 0x025b26d7), STCP(0x7ff871a2, 0x02bfa9a4), + STCP(0x7ff62182, 0x03242abf), STCP(0x7ff38274, 0x0388a9ea), STCP(0x7ff09478, 0x03ed26e6), STCP(0x7fed5791, 0x0451a177), + STCP(0x7fe9cbc0, 0x04b6195d), STCP(0x7fe5f108, 0x051a8e5c), STCP(0x7fe1c76b, 0x057f0035), STCP(0x7fdd4eec, 0x05e36ea9), + STCP(0x7fd8878e, 0x0647d97c), STCP(0x7fd37153, 0x06ac406f), STCP(0x7fce0c3e, 0x0710a345), STCP(0x7fc85854, 0x077501be), + STCP(0x7fc25596, 0x07d95b9e), STCP(0x7fbc040a, 0x083db0a7), STCP(0x7fb563b3, 0x08a2009a), STCP(0x7fae7495, 0x09064b3a), + STCP(0x7fa736b4, 0x096a9049), STCP(0x7f9faa15, 0x09cecf89), STCP(0x7f97cebd, 0x0a3308bd), STCP(0x7f8fa4b0, 0x0a973ba5), + STCP(0x7f872bf3, 0x0afb6805), STCP(0x7f7e648c, 0x0b5f8d9f), STCP(0x7f754e80, 0x0bc3ac35), STCP(0x7f6be9d4, 0x0c27c389), + STCP(0x7f62368f, 0x0c8bd35e), STCP(0x7f5834b7, 0x0cefdb76), STCP(0x7f4de451, 0x0d53db92), STCP(0x7f434563, 0x0db7d376), + STCP(0x7f3857f6, 0x0e1bc2e4), STCP(0x7f2d1c0e, 0x0e7fa99e), STCP(0x7f2191b4, 0x0ee38766), STCP(0x7f15b8ee, 0x0f475bff), + STCP(0x7f0991c4, 0x0fab272b), STCP(0x7efd1c3c, 0x100ee8ad), STCP(0x7ef05860, 0x1072a048), STCP(0x7ee34636, 0x10d64dbd), + STCP(0x7ed5e5c6, 0x1139f0cf), STCP(0x7ec8371a, 0x119d8941), STCP(0x7eba3a39, 0x120116d5), STCP(0x7eabef2c, 0x1264994e), + STCP(0x7e9d55fc, 0x12c8106f), STCP(0x7e8e6eb2, 0x132b7bf9), STCP(0x7e7f3957, 0x138edbb1), STCP(0x7e6fb5f4, 0x13f22f58), + STCP(0x7e5fe493, 0x145576b1), STCP(0x7e4fc53e, 0x14b8b17f), STCP(0x7e3f57ff, 0x151bdf86), STCP(0x7e2e9cdf, 0x157f0086), + STCP(0x7e1d93ea, 0x15e21445), STCP(0x7e0c3d29, 0x16451a83), STCP(0x7dfa98a8, 0x16a81305), STCP(0x7de8a670, 0x170afd8d), + STCP(0x7dd6668f, 0x176dd9de), STCP(0x7dc3d90d, 0x17d0a7bc), STCP(0x7db0fdf8, 0x183366e9), STCP(0x7d9dd55a, 0x18961728), + STCP(0x7d8a5f40, 0x18f8b83c), STCP(0x7d769bb5, 0x195b49ea), STCP(0x7d628ac6, 0x19bdcbf3), STCP(0x7d4e2c7f, 0x1a203e1b), + STCP(0x7d3980ec, 0x1a82a026), STCP(0x7d24881b, 0x1ae4f1d6), STCP(0x7d0f4218, 0x1b4732ef), STCP(0x7cf9aef0, 0x1ba96335), + STCP(0x7ce3ceb2, 0x1c0b826a), STCP(0x7ccda169, 0x1c6d9053), STCP(0x7cb72724, 0x1ccf8cb3), STCP(0x7ca05ff1, 0x1d31774d), + STCP(0x7c894bde, 0x1d934fe5), STCP(0x7c71eaf9, 0x1df5163f), STCP(0x7c5a3d50, 0x1e56ca1e), STCP(0x7c4242f2, 0x1eb86b46), + STCP(0x7c29fbee, 0x1f19f97b), STCP(0x7c116853, 0x1f7b7481), STCP(0x7bf88830, 0x1fdcdc1b), STCP(0x7bdf5b94, 0x203e300d), + STCP(0x7bc5e290, 0x209f701c), STCP(0x7bac1d31, 0x21009c0c), STCP(0x7b920b89, 0x2161b3a0), STCP(0x7b77ada8, 0x21c2b69c), + STCP(0x7b5d039e, 0x2223a4c5), STCP(0x7b420d7a, 0x22847de0), STCP(0x7b26cb4f, 0x22e541af), STCP(0x7b0b3d2c, 0x2345eff8), + STCP(0x7aef6323, 0x23a6887f), STCP(0x7ad33d45, 0x24070b08), STCP(0x7ab6cba4, 0x24677758), STCP(0x7a9a0e50, 0x24c7cd33), + STCP(0x7a7d055b, 0x25280c5e), STCP(0x7a5fb0d8, 0x2588349d), STCP(0x7a4210d8, 0x25e845b6), STCP(0x7a24256f, 0x26483f6c), + STCP(0x7a05eead, 0x26a82186), STCP(0x79e76ca7, 0x2707ebc7), STCP(0x79c89f6e, 0x27679df4), STCP(0x79a98715, 0x27c737d3), + STCP(0x798a23b1, 0x2826b928), STCP(0x796a7554, 0x288621b9), STCP(0x794a7c12, 0x28e5714b), STCP(0x792a37fe, 0x2944a7a2), + STCP(0x7909a92d, 0x29a3c485), STCP(0x78e8cfb2, 0x2a02c7b8), STCP(0x78c7aba2, 0x2a61b101), STCP(0x78a63d11, 0x2ac08026), + STCP(0x78848414, 0x2b1f34eb), STCP(0x786280bf, 0x2b7dcf17), STCP(0x78403329, 0x2bdc4e6f), STCP(0x781d9b65, 0x2c3ab2b9), + STCP(0x77fab989, 0x2c98fbba), STCP(0x77d78daa, 0x2cf72939), STCP(0x77b417df, 0x2d553afc), STCP(0x7790583e, 0x2db330c7), + STCP(0x776c4edb, 0x2e110a62), STCP(0x7747fbce, 0x2e6ec792), STCP(0x77235f2d, 0x2ecc681e), STCP(0x76fe790e, 0x2f29ebcc), + STCP(0x76d94989, 0x2f875262), STCP(0x76b3d0b4, 0x2fe49ba7), STCP(0x768e0ea6, 0x3041c761), STCP(0x76680376, 0x309ed556), + STCP(0x7641af3d, 0x30fbc54d), STCP(0x761b1211, 0x3158970e), STCP(0x75f42c0b, 0x31b54a5e), STCP(0x75ccfd42, 0x3211df04), + STCP(0x75a585cf, 0x326e54c7), STCP(0x757dc5ca, 0x32caab6f), STCP(0x7555bd4c, 0x3326e2c3), STCP(0x752d6c6c, 0x3382fa88), + STCP(0x7504d345, 0x33def287), STCP(0x74dbf1ef, 0x343aca87), STCP(0x74b2c884, 0x34968250), STCP(0x7489571c, 0x34f219a8), + STCP(0x745f9dd1, 0x354d9057), STCP(0x74359cbd, 0x35a8e625), STCP(0x740b53fb, 0x36041ad9), STCP(0x73e0c3a3, 0x365f2e3b), + STCP(0x73b5ebd1, 0x36ba2014), STCP(0x738acc9e, 0x3714f02a), STCP(0x735f6626, 0x376f9e46), STCP(0x7333b883, 0x37ca2a30), + STCP(0x7307c3d0, 0x382493b0), STCP(0x72db8828, 0x387eda8e), STCP(0x72af05a7, 0x38d8fe93), STCP(0x72823c67, 0x3932ff87), + STCP(0x72552c85, 0x398cdd32), STCP(0x7227d61c, 0x39e6975e), STCP(0x71fa3949, 0x3a402dd2), STCP(0x71cc5626, 0x3a99a057), + STCP(0x719e2cd2, 0x3af2eeb7), STCP(0x716fbd68, 0x3b4c18ba), STCP(0x71410805, 0x3ba51e29), STCP(0x71120cc5, 0x3bfdfecd), + STCP(0x70e2cbc6, 0x3c56ba70), STCP(0x70b34525, 0x3caf50da), STCP(0x708378ff, 0x3d07c1d6), STCP(0x70536771, 0x3d600d2c), + STCP(0x7023109a, 0x3db832a6), STCP(0x6ff27497, 0x3e10320d), STCP(0x6fc19385, 0x3e680b2c), STCP(0x6f906d84, 0x3ebfbdcd), + STCP(0x6f5f02b2, 0x3f1749b8), STCP(0x6f2d532c, 0x3f6eaeb8), STCP(0x6efb5f12, 0x3fc5ec98), STCP(0x6ec92683, 0x401d0321), + STCP(0x6e96a99d, 0x4073f21d), STCP(0x6e63e87f, 0x40cab958), STCP(0x6e30e34a, 0x4121589b), STCP(0x6dfd9a1c, 0x4177cfb1), + STCP(0x6dca0d14, 0x41ce1e65), STCP(0x6d963c54, 0x42244481), STCP(0x6d6227fa, 0x427a41d0), STCP(0x6d2dd027, 0x42d0161e), + STCP(0x6cf934fc, 0x4325c135), STCP(0x6cc45698, 0x437b42e1), STCP(0x6c8f351c, 0x43d09aed), STCP(0x6c59d0a9, 0x4425c923), + STCP(0x6c242960, 0x447acd50), STCP(0x6bee3f62, 0x44cfa740), STCP(0x6bb812d1, 0x452456bd), STCP(0x6b81a3cd, 0x4578db93), + STCP(0x6b4af279, 0x45cd358f), STCP(0x6b13fef5, 0x4621647d), STCP(0x6adcc964, 0x46756828), STCP(0x6aa551e9, 0x46c9405c), + STCP(0x6a6d98a4, 0x471cece7), STCP(0x6a359db9, 0x47706d93), STCP(0x69fd614a, 0x47c3c22f), STCP(0x69c4e37a, 0x4816ea86), + STCP(0x698c246c, 0x4869e665), STCP(0x69532442, 0x48bcb599), STCP(0x6919e320, 0x490f57ee), STCP(0x68e06129, 0x4961cd33), + STCP(0x68a69e81, 0x49b41533), STCP(0x686c9b4b, 0x4a062fbd), STCP(0x683257ab, 0x4a581c9e), STCP(0x67f7d3c5, 0x4aa9dba2), + STCP(0x67bd0fbd, 0x4afb6c98), STCP(0x67820bb7, 0x4b4ccf4d), STCP(0x6746c7d8, 0x4b9e0390), STCP(0x670b4444, 0x4bef092d), + STCP(0x66cf8120, 0x4c3fdff4), STCP(0x66937e91, 0x4c9087b1), STCP(0x66573cbb, 0x4ce10034), STCP(0x661abbc5, 0x4d31494b), + STCP(0x65ddfbd3, 0x4d8162c4), STCP(0x65a0fd0b, 0x4dd14c6e), STCP(0x6563bf92, 0x4e210617), STCP(0x6526438f, 0x4e708f8f), + STCP(0x64e88926, 0x4ebfe8a5), STCP(0x64aa907f, 0x4f0f1126), STCP(0x646c59bf, 0x4f5e08e3), STCP(0x642de50d, 0x4faccfab), + STCP(0x63ef3290, 0x4ffb654d), STCP(0x63b0426d, 0x5049c999), STCP(0x637114cc, 0x5097fc5e), STCP(0x6331a9d4, 0x50e5fd6d), + STCP(0x62f201ac, 0x5133cc94), STCP(0x62b21c7b, 0x518169a5), STCP(0x6271fa69, 0x51ced46e), STCP(0x62319b9d, 0x521c0cc2), + STCP(0x61f1003f, 0x5269126e), STCP(0x61b02876, 0x52b5e546), STCP(0x616f146c, 0x53028518), STCP(0x612dc447, 0x534ef1b5), + STCP(0x60ec3830, 0x539b2af0), STCP(0x60aa7050, 0x53e73097), STCP(0x60686ccf, 0x5433027d), STCP(0x60262dd6, 0x547ea073), + STCP(0x5fe3b38d, 0x54ca0a4b), STCP(0x5fa0fe1f, 0x55153fd4), STCP(0x5f5e0db3, 0x556040e2), STCP(0x5f1ae274, 0x55ab0d46), + STCP(0x5ed77c8a, 0x55f5a4d2), STCP(0x5e93dc1f, 0x56400758), STCP(0x5e50015d, 0x568a34a9), STCP(0x5e0bec6e, 0x56d42c99), + STCP(0x5dc79d7c, 0x571deefa), STCP(0x5d8314b1, 0x57677b9d), STCP(0x5d3e5237, 0x57b0d256), STCP(0x5cf95638, 0x57f9f2f8), + STCP(0x5cb420e0, 0x5842dd54), STCP(0x5c6eb258, 0x588b9140), STCP(0x5c290acc, 0x58d40e8c), STCP(0x5be32a67, 0x591c550e), + STCP(0x5b9d1154, 0x59646498), STCP(0x5b56bfbd, 0x59ac3cfd), STCP(0x5b1035cf, 0x59f3de12), STCP(0x5ac973b5, 0x5a3b47ab), + STCP(0x5a82799a, 0x5a82799a), +}; + +const PWord16 SineTable320[] = +{ + STCP(0x7fffffff, 0x00000000), STCP(0x7fff9aef, 0x00a0d951), + STCP(0x7ffe6bbf, 0x0141b1a5), STCP(0x7ffc726f, 0x01e287fc), + STCP(0x7ff9af04, 0x02835b5a), STCP(0x7ff62182, 0x03242abf), + STCP(0x7ff1c9ef, 0x03c4f52f), STCP(0x7feca851, 0x0465b9aa), + STCP(0x7fe6bcb0, 0x05067734), STCP(0x7fe00716, 0x05a72ccf), + STCP(0x7fd8878e, 0x0647d97c), STCP(0x7fd03e23, 0x06e87c3f), + STCP(0x7fc72ae2, 0x07891418), STCP(0x7fbd4dda, 0x0829a00c), + STCP(0x7fb2a71b, 0x08ca1f1b), STCP(0x7fa736b4, 0x096a9049), + STCP(0x7f9afcb9, 0x0a0af299), STCP(0x7f8df93c, 0x0aab450d), + STCP(0x7f802c52, 0x0b4b86a8), STCP(0x7f719611, 0x0bebb66c), + STCP(0x7f62368f, 0x0c8bd35e), STCP(0x7f520de6, 0x0d2bdc80), + STCP(0x7f411c2f, 0x0dcbd0d5), STCP(0x7f2f6183, 0x0e6baf61), + STCP(0x7f1cde01, 0x0f0b7727), STCP(0x7f0991c4, 0x0fab272b), + STCP(0x7ef57cea, 0x104abe71), STCP(0x7ee09f95, 0x10ea3bfd), + STCP(0x7ecaf9e5, 0x11899ed3), STCP(0x7eb48bfb, 0x1228e5f8), + STCP(0x7e9d55fc, 0x12c8106f), STCP(0x7e85580c, 0x13671d3d), + STCP(0x7e6c9251, 0x14060b68), STCP(0x7e5304f2, 0x14a4d9f4), + STCP(0x7e38b017, 0x154387e6), STCP(0x7e1d93ea, 0x15e21445), + STCP(0x7e01b096, 0x16807e15), STCP(0x7de50646, 0x171ec45c), + STCP(0x7dc79529, 0x17bce621), STCP(0x7da95d6c, 0x185ae269), + STCP(0x7d8a5f40, 0x18f8b83c), STCP(0x7d6a9ad5, 0x199666a0), + STCP(0x7d4a105d, 0x1a33ec9c), STCP(0x7d28c00c, 0x1ad14938), + STCP(0x7d06aa16, 0x1b6e7b7a), STCP(0x7ce3ceb2, 0x1c0b826a), + STCP(0x7cc02e15, 0x1ca85d12), STCP(0x7c9bc87a, 0x1d450a78), + STCP(0x7c769e18, 0x1de189a6), STCP(0x7c50af2b, 0x1e7dd9a4), + STCP(0x7c29fbee, 0x1f19f97b), STCP(0x7c02849f, 0x1fb5e836), + STCP(0x7bda497d, 0x2051a4dd), STCP(0x7bb14ac5, 0x20ed2e7b), + STCP(0x7b8788ba, 0x2188841a), STCP(0x7b5d039e, 0x2223a4c5), + STCP(0x7b31bbb2, 0x22be8f87), STCP(0x7b05b13d, 0x2359436c), + STCP(0x7ad8e482, 0x23f3bf7e), STCP(0x7aab55ca, 0x248e02cb), + STCP(0x7a7d055b, 0x25280c5e), STCP(0x7a4df380, 0x25c1db44), + STCP(0x7a1e2082, 0x265b6e8a), STCP(0x79ed8cad, 0x26f4c53e), + STCP(0x79bc384d, 0x278dde6e), STCP(0x798a23b1, 0x2826b928), + STCP(0x79574f28, 0x28bf547b), STCP(0x7923bb01, 0x2957af74), + STCP(0x78ef678f, 0x29efc925), STCP(0x78ba5524, 0x2a87a09d), + STCP(0x78848414, 0x2b1f34eb), STCP(0x784df4b3, 0x2bb68522), + STCP(0x7816a759, 0x2c4d9050), STCP(0x77de9c5b, 0x2ce45589), + STCP(0x77a5d413, 0x2d7ad3de), STCP(0x776c4edb, 0x2e110a62), + STCP(0x77320d0d, 0x2ea6f827), STCP(0x76f70f05, 0x2f3c9c40), + STCP(0x76bb5521, 0x2fd1f5c1), STCP(0x767edfbe, 0x306703bf), + STCP(0x7641af3d, 0x30fbc54d), STCP(0x7603c3fd, 0x31903982), + STCP(0x75c51e61, 0x32245f72), STCP(0x7585becb, 0x32b83634), + STCP(0x7545a5a0, 0x334bbcde), STCP(0x7504d345, 0x33def287), + STCP(0x74c34820, 0x3471d647), STCP(0x74810499, 0x35046736), + STCP(0x743e0918, 0x3596a46c), STCP(0x73fa5607, 0x36288d03), + STCP(0x73b5ebd1, 0x36ba2014), STCP(0x7370cae2, 0x374b5cb9), + STCP(0x732af3a7, 0x37dc420c), STCP(0x72e4668f, 0x386ccf2a), + STCP(0x729d2409, 0x38fd032d), STCP(0x72552c85, 0x398cdd32), + STCP(0x720c8075, 0x3a1c5c57), STCP(0x71c3204c, 0x3aab7fb7), + STCP(0x71790c7e, 0x3b3a4672), STCP(0x712e457f, 0x3bc8afa5), + STCP(0x70e2cbc6, 0x3c56ba70), STCP(0x70969fca, 0x3ce465f3), + STCP(0x7049c203, 0x3d71b14d), STCP(0x6ffc32eb, 0x3dfe9ba1), + STCP(0x6fadf2fc, 0x3e8b240e), STCP(0x6f5f02b2, 0x3f1749b8), + STCP(0x6f0f6289, 0x3fa30bc1), STCP(0x6ebf12ff, 0x402e694c), + STCP(0x6e6e1492, 0x40b9617d), STCP(0x6e1c67c4, 0x4143f379), + STCP(0x6dca0d14, 0x41ce1e65), STCP(0x6d770506, 0x4257e166), + STCP(0x6d23501b, 0x42e13ba4), STCP(0x6cceeed8, 0x436a2c45), + STCP(0x6c79e1c2, 0x43f2b271), STCP(0x6c242960, 0x447acd50), + STCP(0x6bcdc639, 0x45027c0c), STCP(0x6b76b8d6, 0x4589bdcf), + STCP(0x6b1f01c0, 0x461091c2), STCP(0x6ac6a180, 0x4696f710), + STCP(0x6a6d98a4, 0x471cece7), STCP(0x6a13e7b8, 0x47a27271), + STCP(0x69b98f48, 0x482786dc), STCP(0x695e8fe5, 0x48ac2957), + STCP(0x6902ea1d, 0x4930590f), STCP(0x68a69e81, 0x49b41533), + STCP(0x6849ada3, 0x4a375cf5), STCP(0x67ec1817, 0x4aba2f84), + STCP(0x678dde6e, 0x4b3c8c12), STCP(0x672f013f, 0x4bbe71d1), + STCP(0x66cf8120, 0x4c3fdff4), STCP(0x666f5ea6, 0x4cc0d5ae), + STCP(0x660e9a6a, 0x4d415234), STCP(0x65ad3505, 0x4dc154bb), + STCP(0x654b2f10, 0x4e40dc79), STCP(0x64e88926, 0x4ebfe8a5), + STCP(0x648543e4, 0x4f3e7875), STCP(0x64215fe5, 0x4fbc8b22), + STCP(0x63bcddc7, 0x503a1fe5), STCP(0x6357be2a, 0x50b735f8), + STCP(0x62f201ac, 0x5133cc94), STCP(0x628ba8ef, 0x51afe2f6), + STCP(0x6224b495, 0x522b7859), STCP(0x61bd253f, 0x52a68bfb), + STCP(0x6154fb91, 0x53211d18), STCP(0x60ec3830, 0x539b2af0), + STCP(0x6082dbc1, 0x5414b4c1), STCP(0x6018e6eb, 0x548db9cb), + STCP(0x5fae5a55, 0x55063951), STCP(0x5f4336a7, 0x557e3292), + STCP(0x5ed77c8a, 0x55f5a4d2), STCP(0x5e6b2ca8, 0x566c8f55), + STCP(0x5dfe47ad, 0x56e2f15d), STCP(0x5d90ce45, 0x5758ca31), + STCP(0x5d22c11c, 0x57ce1917), STCP(0x5cb420e0, 0x5842dd54), + STCP(0x5c44ee40, 0x58b71632), STCP(0x5bd529eb, 0x592ac2f7), + STCP(0x5b64d492, 0x599de2ee), STCP(0x5af3eee6, 0x5a107561), + STCP(0x5a82799a, 0x5a82799a) +}; + +#define WTC(x) WORD322WORD16(x) + +#define WTCP(a,b) { { WTC(a), WTC(b) } } + +const PWord16 SineWindow10[5] = +{ + WTCP(0x7f9afcb9, 0x0a0af299), WTCP(0x7c769e18, 0x1de189a6), WTCP(0x7641af3d, 0x30fbc54d), WTCP(0x6d23501b, 0x42e13ba4), + WTCP(0x6154fb91, 0x53211d18), +}; + +const PWord16 SineWindow16[8] = +{ + WTCP(0x7fd8878e, 0x0647d97c), WTCP(0x7e9d55fc, 0x12c8106f), WTCP(0x7c29fbee, 0x1f19f97b), WTCP(0x78848414, 0x2b1f34eb), + WTCP(0x73b5ebd1, 0x36ba2014), WTCP(0x6dca0d14, 0x41ce1e65), WTCP(0x66cf8120, 0x4c3fdff4), WTCP(0x5ed77c8a, 0x55f5a4d2), +}; + +const PWord16 SineWindow20[10] = +{ + WTCP(0x7fe6bcb0, 0x05067734), WTCP(0x7f1cde01, 0x0f0b7727), WTCP(0x7d8a5f40, 0x18f8b83c), WTCP(0x7b31bbb2, 0x22be8f87), + WTCP(0x7816a759, 0x2c4d9050), WTCP(0x743e0918, 0x3596a46c), WTCP(0x6fadf2fc, 0x3e8b240e), WTCP(0x6a6d98a4, 0x471cece7), + WTCP(0x648543e4, 0x4f3e7875), WTCP(0x5dfe47ad, 0x56e2f15d), +}; + +const PWord16 SineWindow30[15] = +{ + WTCP(0x7ff4c56f, 0x0359c428), WTCP(0x7f9afcb9, 0x0a0af299), WTCP(0x7ee7aa4c, 0x10b5150f), WTCP(0x7ddb4bfc, 0x17537e63), + WTCP(0x7c769e18, 0x1de189a6), WTCP(0x7aba9ae6, 0x245a9d65), WTCP(0x78a879f4, 0x2aba2ee4), WTCP(0x7641af3d, 0x30fbc54d), + WTCP(0x7387ea23, 0x371afcd5), WTCP(0x707d1443, 0x3d1389cb), WTCP(0x6d23501b, 0x42e13ba4), WTCP(0x697cf78a, 0x487fffe4), + WTCP(0x658c9a2d, 0x4debe4fe), WTCP(0x6154fb91, 0x53211d18), WTCP(0x5cd91140, 0x581c00b3), +}; + +const PWord16 SineWindow32[16] = +{ + WTCP(0x7ff62182, 0x03242abf), WTCP(0x7fa736b4, 0x096a9049), WTCP(0x7f0991c4, 0x0fab272b), WTCP(0x7e1d93ea, 0x15e21445), + WTCP(0x7ce3ceb2, 0x1c0b826a), WTCP(0x7b5d039e, 0x2223a4c5), WTCP(0x798a23b1, 0x2826b928), WTCP(0x776c4edb, 0x2e110a62), + WTCP(0x7504d345, 0x33def287), WTCP(0x72552c85, 0x398cdd32), WTCP(0x6f5f02b2, 0x3f1749b8), WTCP(0x6c242960, 0x447acd50), + WTCP(0x68a69e81, 0x49b41533), WTCP(0x64e88926, 0x4ebfe8a5), WTCP(0x60ec3830, 0x539b2af0), WTCP(0x5cb420e0, 0x5842dd54) +}; + +const PWord16 SineWindow40[20] = +{ + WTCP(0x7ff9af04, 0x02835b5a), WTCP(0x7fc72ae2, 0x07891418), WTCP(0x7f62368f, 0x0c8bd35e), WTCP(0x7ecaf9e5, 0x11899ed3), + WTCP(0x7e01b096, 0x16807e15), WTCP(0x7d06aa16, 0x1b6e7b7a), WTCP(0x7bda497d, 0x2051a4dd), WTCP(0x7a7d055b, 0x25280c5e), + WTCP(0x78ef678f, 0x29efc925), WTCP(0x77320d0d, 0x2ea6f827), WTCP(0x7545a5a0, 0x334bbcde), WTCP(0x732af3a7, 0x37dc420c), + WTCP(0x70e2cbc6, 0x3c56ba70), WTCP(0x6e6e1492, 0x40b9617d), WTCP(0x6bcdc639, 0x45027c0c), WTCP(0x6902ea1d, 0x4930590f), + WTCP(0x660e9a6a, 0x4d415234), WTCP(0x62f201ac, 0x5133cc94), WTCP(0x5fae5a55, 0x55063951), WTCP(0x5c44ee40, 0x58b71632), +}; + +const PWord16 SineWindow48[24] = +{ + WTCP(0x7ffb9d15, 0x02182427), WTCP(0x7fd8878e, 0x0647d97c), WTCP(0x7f92661d, 0x0a75d60e), WTCP(0x7f294bfd, 0x0ea0f48c), + WTCP(0x7e9d55fc, 0x12c8106f), WTCP(0x7deeaa7a, 0x16ea0646), WTCP(0x7d1d7958, 0x1b05b40f), WTCP(0x7c29fbee, 0x1f19f97b), + WTCP(0x7b1474fd, 0x2325b847), WTCP(0x79dd3098, 0x2727d486), WTCP(0x78848414, 0x2b1f34eb), WTCP(0x770acdec, 0x2f0ac320), + WTCP(0x757075ac, 0x32e96c09), WTCP(0x73b5ebd1, 0x36ba2014), WTCP(0x71dba9ab, 0x3a7bd382), WTCP(0x6fe2313c, 0x3e2d7eb1), + WTCP(0x6dca0d14, 0x41ce1e65), WTCP(0x6b93d02e, 0x455cb40c), WTCP(0x694015c3, 0x48d84609), WTCP(0x66cf8120, 0x4c3fdff4), + WTCP(0x6442bd7e, 0x4f9292dc), WTCP(0x619a7dce, 0x52cf758f), WTCP(0x5ed77c8a, 0x55f5a4d2), WTCP(0x5bfa7b82, 0x590443a7) +}; + +const PWord16 SineWindow60[60] = +{ + WTCP(0x7ffd3154, 0x01aceb7c), WTCP(0x7fe6bcb0, 0x05067734), WTCP(0x7fb9d759, 0x085f2137), WTCP(0x7f76892f, 0x0bb65336), + WTCP(0x7f1cde01, 0x0f0b7727), WTCP(0x7eace58a, 0x125df75b), WTCP(0x7e26b371, 0x15ad3e9a), WTCP(0x7d8a5f40, 0x18f8b83c), + WTCP(0x7cd80464, 0x1c3fd045), WTCP(0x7c0fc22a, 0x1f81f37c), WTCP(0x7b31bbb2, 0x22be8f87), WTCP(0x7a3e17f2, 0x25f51307), + WTCP(0x793501a9, 0x2924edac), WTCP(0x7816a759, 0x2c4d9050), WTCP(0x76e33b3f, 0x2f6e6d16), WTCP(0x759af34c, 0x3286f779), + WTCP(0x743e0918, 0x3596a46c), WTCP(0x72ccb9db, 0x389cea72), WTCP(0x71474660, 0x3b9941b1), WTCP(0x6fadf2fc, 0x3e8b240e), + WTCP(0x6e010780, 0x41720d46), WTCP(0x6c40cf2c, 0x444d7aff), WTCP(0x6a6d98a4, 0x471cece7), WTCP(0x6887b5e2, 0x49dfe4c2), + WTCP(0x668f7c25, 0x4c95e688), WTCP(0x648543e4, 0x4f3e7875), WTCP(0x626968be, 0x51d92321), WTCP(0x603c496c, 0x54657194), + WTCP(0x5dfe47ad, 0x56e2f15d), WTCP(0x5bafc837, 0x595132a2), +}; + +const PWord16 SineWindow64[32] = +{ + WTCP(0x7ffd885a, 0x01921d20), WTCP(0x7fe9cbc0, 0x04b6195d), WTCP(0x7fc25596, 0x07d95b9e), WTCP(0x7f872bf3, 0x0afb6805), + WTCP(0x7f3857f6, 0x0e1bc2e4), WTCP(0x7ed5e5c6, 0x1139f0cf), WTCP(0x7e5fe493, 0x145576b1), WTCP(0x7dd6668f, 0x176dd9de), + WTCP(0x7d3980ec, 0x1a82a026), WTCP(0x7c894bde, 0x1d934fe5), WTCP(0x7bc5e290, 0x209f701c), WTCP(0x7aef6323, 0x23a6887f), + WTCP(0x7a05eead, 0x26a82186), WTCP(0x7909a92d, 0x29a3c485), WTCP(0x77fab989, 0x2c98fbba), WTCP(0x76d94989, 0x2f875262), + WTCP(0x75a585cf, 0x326e54c7), WTCP(0x745f9dd1, 0x354d9057), WTCP(0x7307c3d0, 0x382493b0), WTCP(0x719e2cd2, 0x3af2eeb7), + WTCP(0x7023109a, 0x3db832a6), WTCP(0x6e96a99d, 0x4073f21d), WTCP(0x6cf934fc, 0x4325c135), WTCP(0x6b4af279, 0x45cd358f), + WTCP(0x698c246c, 0x4869e665), WTCP(0x67bd0fbd, 0x4afb6c98), WTCP(0x65ddfbd3, 0x4d8162c4), WTCP(0x63ef3290, 0x4ffb654d), + WTCP(0x61f1003f, 0x5269126e), WTCP(0x5fe3b38d, 0x54ca0a4b), WTCP(0x5dc79d7c, 0x571deefa), WTCP(0x5b9d1154, 0x59646498), +}; + +const PWord16 SineWindow80[40] = +{ + WTCP(0x7ffe6bbf, 0x0141b1a5), WTCP(0x7ff1c9ef, 0x03c4f52f), WTCP(0x7fd8878e, 0x0647d97c), WTCP(0x7fb2a71b, 0x08ca1f1b), + WTCP(0x7f802c52, 0x0b4b86a8), WTCP(0x7f411c2f, 0x0dcbd0d5), WTCP(0x7ef57cea, 0x104abe71), WTCP(0x7e9d55fc, 0x12c8106f), + WTCP(0x7e38b017, 0x154387e6), WTCP(0x7dc79529, 0x17bce621), WTCP(0x7d4a105d, 0x1a33ec9c), WTCP(0x7cc02e15, 0x1ca85d12), + WTCP(0x7c29fbee, 0x1f19f97b), WTCP(0x7b8788ba, 0x2188841a), WTCP(0x7ad8e482, 0x23f3bf7e), WTCP(0x7a1e2082, 0x265b6e8a), + WTCP(0x79574f28, 0x28bf547b), WTCP(0x78848414, 0x2b1f34eb), WTCP(0x77a5d413, 0x2d7ad3de), WTCP(0x76bb5521, 0x2fd1f5c1), + WTCP(0x75c51e61, 0x32245f72), WTCP(0x74c34820, 0x3471d647), WTCP(0x73b5ebd1, 0x36ba2014), WTCP(0x729d2409, 0x38fd032d), + WTCP(0x71790c7e, 0x3b3a4672), WTCP(0x7049c203, 0x3d71b14d), WTCP(0x6f0f6289, 0x3fa30bc1), WTCP(0x6dca0d14, 0x41ce1e65), + WTCP(0x6c79e1c2, 0x43f2b271), WTCP(0x6b1f01c0, 0x461091c2), WTCP(0x69b98f48, 0x482786dc), WTCP(0x6849ada3, 0x4a375cf5), + WTCP(0x66cf8120, 0x4c3fdff4), WTCP(0x654b2f10, 0x4e40dc79), WTCP(0x63bcddc7, 0x503a1fe5), WTCP(0x6224b495, 0x522b7859), + WTCP(0x6082dbc1, 0x5414b4c1), WTCP(0x5ed77c8a, 0x55f5a4d2), WTCP(0x5d22c11c, 0x57ce1917), WTCP(0x5b64d492, 0x599de2ee), +}; + +const PWord16 SineWindow70[35] = +{ + WTCP(0x7ffdeffe, 0x016fa5fd), WTCP(0x7fed7058, 0x044ec292), WTCP(0x7fcc732b, 0x072d5101), WTCP(0x7f9afcb9, 0x0a0af299), + WTCP(0x7f591361, 0x0ce748ca), WTCP(0x7f06bfa3, 0x0fc1f52d), WTCP(0x7ea40c1b, 0x129a9991), WTCP(0x7e310583, 0x1570d80b), + WTCP(0x7dadbaaf, 0x184452fd), WTCP(0x7d1a3c8a, 0x1b14ad24), WTCP(0x7c769e18, 0x1de189a6), WTCP(0x7bc2f470, 0x20aa8c19), + WTCP(0x7aff56bc, 0x236f5896), WTCP(0x7a2bde32, 0x262f93be), WTCP(0x7948a614, 0x28eae2cb), WTCP(0x7855cbae, 0x2ba0eb97), + WTCP(0x77536e4c, 0x2e5154ac), WTCP(0x7641af3d, 0x30fbc54d), WTCP(0x7520b1ca, 0x339fe582), WTCP(0x73f09b33, 0x363d5e23), + WTCP(0x72b192ac, 0x38d3d8e3), WTCP(0x7163c154, 0x3b63005e), WTCP(0x70075233, 0x3dea8020), WTCP(0x6e9c7233, 0x406a04b2), + WTCP(0x6d23501b, 0x42e13ba4), WTCP(0x6b9c1c87, 0x454fd398), WTCP(0x6a0709e6, 0x47b57c4e), WTCP(0x68644c6e, 0x4a11e6aa), + WTCP(0x66b41a1a, 0x4c64c4c4), WTCP(0x64f6aa9f, 0x4eadc9ee), WTCP(0x632c3769, 0x50ecaabd), WTCP(0x6154fb91, 0x53211d18), + WTCP(0x5f7133d4, 0x554ad83c), WTCP(0x5d811e90, 0x576994c8), WTCP(0x5b84fbb6, 0x597d0cc7) +}; + +const PWord16 SineWindow96[48] = +{ + WTCP(0x7ffee744, 0x010c1460), WTCP(0x7ff62182, 0x03242abf), WTCP(0x7fe49698, 0x053c0a01), WTCP(0x7fca47b9, 0x07538d6b), + WTCP(0x7fa736b4, 0x096a9049), WTCP(0x7f7b65ef, 0x0b80edf1), WTCP(0x7f46d86c, 0x0d9681c2), WTCP(0x7f0991c4, 0x0fab272b), + WTCP(0x7ec3962a, 0x11beb9aa), WTCP(0x7e74ea6a, 0x13d114d0), WTCP(0x7e1d93ea, 0x15e21445), WTCP(0x7dbd98a4, 0x17f193c5), + WTCP(0x7d54ff2e, 0x19ff6f2a), WTCP(0x7ce3ceb2, 0x1c0b826a), WTCP(0x7c6a0ef2, 0x1e15a99a), WTCP(0x7be7c847, 0x201dc0ef), + WTCP(0x7b5d039e, 0x2223a4c5), WTCP(0x7ac9ca7a, 0x2427319d), WTCP(0x7a2e26f2, 0x26284422), WTCP(0x798a23b1, 0x2826b928), + WTCP(0x78ddcbf5, 0x2a226db5), WTCP(0x78292b8d, 0x2c1b3efb), WTCP(0x776c4edb, 0x2e110a62), WTCP(0x76a742d1, 0x3003ad85), + WTCP(0x75da14ef, 0x31f30638), WTCP(0x7504d345, 0x33def287), WTCP(0x74278c72, 0x35c750bc), WTCP(0x73424fa0, 0x37abff5d), + WTCP(0x72552c85, 0x398cdd32), WTCP(0x71603361, 0x3b69c947), WTCP(0x706374ff, 0x3d42a2ec), WTCP(0x6f5f02b2, 0x3f1749b8), + WTCP(0x6e52ee52, 0x40e79d8c), WTCP(0x6d3f4a40, 0x42b37e96), WTCP(0x6c242960, 0x447acd50), WTCP(0x6b019f1a, 0x463d6a87), + WTCP(0x69d7bf57, 0x47fb3757), WTCP(0x68a69e81, 0x49b41533), WTCP(0x676e5183, 0x4b67e5e4), WTCP(0x662eedc3, 0x4d168b8b), + WTCP(0x64e88926, 0x4ebfe8a5), WTCP(0x639b3a0b, 0x5063e008), WTCP(0x62471749, 0x520254ef), WTCP(0x60ec3830, 0x539b2af0), + WTCP(0x5f8ab487, 0x552e4605), WTCP(0x5e22a487, 0x56bb8a90), WTCP(0x5cb420e0, 0x5842dd54), WTCP(0x5b3f42ae, 0x59c42381) +}; + +const PWord16 SineWindow112[56] = +{ + WTCP(0x7fff31bf, 0x00e5c87e), WTCP(0x7ff8bfc7, 0x02b14de9), WTCP(0x7febdc2a, 0x047cb09e), WTCP(0x7fd8878e, 0x0647d97c), + WTCP(0x7fbec2ec, 0x0812b164), WTCP(0x7f9e8f91, 0x09dd213a), WTCP(0x7f77ef1c, 0x0ba711ea), WTCP(0x7f4ae37e, 0x0d706c64), + WTCP(0x7f176efc, 0x0f3919a0), WTCP(0x7edd942d, 0x110102a0), WTCP(0x7e9d55fc, 0x12c8106f), WTCP(0x7e56b7a4, 0x148e2c22), + WTCP(0x7e09bcb4, 0x16533edc), WTCP(0x7db6690c, 0x181731cd), WTCP(0x7d5cc0df, 0x19d9ee32), WTCP(0x7cfcc8af, 0x1b9b5d5a), + WTCP(0x7c968552, 0x1d5b68a2), WTCP(0x7c29fbee, 0x1f19f97b), WTCP(0x7bb731fb, 0x20d6f969), WTCP(0x7b3e2d40, 0x22925203), + WTCP(0x7abef3d5, 0x244becf6), WTCP(0x7a398c22, 0x2603b406), WTCP(0x79adfcdf, 0x27b9910e), WTCP(0x791c4d13, 0x296d6e00), + WTCP(0x78848414, 0x2b1f34eb), WTCP(0x77e6a986, 0x2ccecff7), WTCP(0x7742c55c, 0x2e7c2969), WTCP(0x7698dfd8, 0x30272ba0), + WTCP(0x75e90186, 0x31cfc11e), WTCP(0x75333343, 0x3375d481), WTCP(0x74777e35, 0x35195088), WTCP(0x73b5ebd1, 0x36ba2014), + WTCP(0x72ee85d5, 0x38582e27), WTCP(0x7221564d, 0x39f365e9), WTCP(0x714e678c, 0x3b8bb2a3), WTCP(0x7075c433, 0x3d20ffc8), + WTCP(0x6f977729, 0x3eb338ef), WTCP(0x6eb38ba1, 0x404249d5), WTCP(0x6dca0d14, 0x41ce1e65), WTCP(0x6cdb0745, 0x4356a2ad), + WTCP(0x6be6863c, 0x44dbc2ec), WTCP(0x6aec9649, 0x465d6b89), WTCP(0x69ed4403, 0x47db8918), WTCP(0x68e89c43, 0x4956085b), + WTCP(0x67deac2c, 0x4accd644), WTCP(0x66cf8120, 0x4c3fdff4), WTCP(0x65bb28c7, 0x4daf12ba), WTCP(0x64a1b10b, 0x4f1a5c1a), + WTCP(0x6383281a, 0x5081a9c9), WTCP(0x625f9c5f, 0x51e4e9ae), WTCP(0x61371c8b, 0x534409e8), WTCP(0x6009b78a, 0x549ef8c6), + WTCP(0x5ed77c8a, 0x55f5a4d2), WTCP(0x5da07af6, 0x5747fcca), WTCP(0x5c64c278, 0x5895efa4), WTCP(0x5b2462f5, 0x59df6c8f) +}; + +const PWord16 SineWindow120[60] = +{ + WTCP(0x7fff4c54, 0x00d676eb), WTCP(0x7ff9af04, 0x02835b5a), WTCP(0x7fee74a2, 0x0430238f), WTCP(0x7fdd9dad, 0x05dcbcbe), + WTCP(0x7fc72ae2, 0x07891418), WTCP(0x7fab1d3d, 0x093516d4), WTCP(0x7f8975f9, 0x0ae0b22c), WTCP(0x7f62368f, 0x0c8bd35e), + WTCP(0x7f3560b9, 0x0e3667ad), WTCP(0x7f02f66f, 0x0fe05c64), WTCP(0x7ecaf9e5, 0x11899ed3), WTCP(0x7e8d6d91, 0x13321c53), + WTCP(0x7e4a5426, 0x14d9c245), WTCP(0x7e01b096, 0x16807e15), WTCP(0x7db3860f, 0x18263d36), WTCP(0x7d5fd801, 0x19caed29), + WTCP(0x7d06aa16, 0x1b6e7b7a), WTCP(0x7ca80038, 0x1d10d5c2), WTCP(0x7c43de8e, 0x1eb1e9a7), WTCP(0x7bda497d, 0x2051a4dd), + WTCP(0x7b6b45a5, 0x21eff528), WTCP(0x7af6d7e6, 0x238cc85d), WTCP(0x7a7d055b, 0x25280c5e), WTCP(0x79fdd35c, 0x26c1af22), + WTCP(0x7979477d, 0x28599eb0), WTCP(0x78ef678f, 0x29efc925), WTCP(0x7860399e, 0x2b841caf), WTCP(0x77cbc3f2, 0x2d168792), + WTCP(0x77320d0d, 0x2ea6f827), WTCP(0x76931bae, 0x30355cdd), WTCP(0x75eef6ce, 0x31c1a43b), WTCP(0x7545a5a0, 0x334bbcde), + WTCP(0x74972f92, 0x34d3957e), WTCP(0x73e39c49, 0x36591cea), WTCP(0x732af3a7, 0x37dc420c), WTCP(0x726d3dc6, 0x395cf3e9), + WTCP(0x71aa82f7, 0x3adb21a1), WTCP(0x70e2cbc6, 0x3c56ba70), WTCP(0x701620f5, 0x3dcfadb0), WTCP(0x6f448b7e, 0x3f45ead8), + WTCP(0x6e6e1492, 0x40b9617d), WTCP(0x6d92c59b, 0x422a0154), WTCP(0x6cb2a837, 0x4397ba32), WTCP(0x6bcdc639, 0x45027c0c), + WTCP(0x6ae429ae, 0x466a36f9), WTCP(0x69f5dcd3, 0x47cedb31), WTCP(0x6902ea1d, 0x4930590f), WTCP(0x680b5c33, 0x4a8ea111), + WTCP(0x670f3df3, 0x4be9a3db), WTCP(0x660e9a6a, 0x4d415234), WTCP(0x65097cdb, 0x4e959d08), WTCP(0x63fff0ba, 0x4fe6756a), + WTCP(0x62f201ac, 0x5133cc94), WTCP(0x61dfbb8a, 0x527d93e6), WTCP(0x60c92a5a, 0x53c3bcea), WTCP(0x5fae5a55, 0x55063951), + WTCP(0x5e8f57e2, 0x5644faf4), WTCP(0x5d6c2f99, 0x577ff3da), WTCP(0x5c44ee40, 0x58b71632), WTCP(0x5b19a0c8, 0x59ea5454), +}; + +const PWord16 SineWindow128[64] = +{ + WTCP(0x7fff6216, 0x00c90f88), WTCP(0x7ffa72d1, 0x025b26d7), WTCP(0x7ff09478, 0x03ed26e6), WTCP(0x7fe1c76b, 0x057f0035), + WTCP(0x7fce0c3e, 0x0710a345), WTCP(0x7fb563b3, 0x08a2009a), WTCP(0x7f97cebd, 0x0a3308bd), WTCP(0x7f754e80, 0x0bc3ac35), + WTCP(0x7f4de451, 0x0d53db92), WTCP(0x7f2191b4, 0x0ee38766), WTCP(0x7ef05860, 0x1072a048), WTCP(0x7eba3a39, 0x120116d5), + WTCP(0x7e7f3957, 0x138edbb1), WTCP(0x7e3f57ff, 0x151bdf86), WTCP(0x7dfa98a8, 0x16a81305), WTCP(0x7db0fdf8, 0x183366e9), + WTCP(0x7d628ac6, 0x19bdcbf3), WTCP(0x7d0f4218, 0x1b4732ef), WTCP(0x7cb72724, 0x1ccf8cb3), WTCP(0x7c5a3d50, 0x1e56ca1e), + WTCP(0x7bf88830, 0x1fdcdc1b), WTCP(0x7b920b89, 0x2161b3a0), WTCP(0x7b26cb4f, 0x22e541af), WTCP(0x7ab6cba4, 0x24677758), + WTCP(0x7a4210d8, 0x25e845b6), WTCP(0x79c89f6e, 0x27679df4), WTCP(0x794a7c12, 0x28e5714b), WTCP(0x78c7aba2, 0x2a61b101), + WTCP(0x78403329, 0x2bdc4e6f), WTCP(0x77b417df, 0x2d553afc), WTCP(0x77235f2d, 0x2ecc681e), WTCP(0x768e0ea6, 0x3041c761), + WTCP(0x75f42c0b, 0x31b54a5e), WTCP(0x7555bd4c, 0x3326e2c3), WTCP(0x74b2c884, 0x34968250), WTCP(0x740b53fb, 0x36041ad9), + WTCP(0x735f6626, 0x376f9e46), WTCP(0x72af05a7, 0x38d8fe93), WTCP(0x71fa3949, 0x3a402dd2), WTCP(0x71410805, 0x3ba51e29), + WTCP(0x708378ff, 0x3d07c1d6), WTCP(0x6fc19385, 0x3e680b2c), WTCP(0x6efb5f12, 0x3fc5ec98), WTCP(0x6e30e34a, 0x4121589b), + WTCP(0x6d6227fa, 0x427a41d0), WTCP(0x6c8f351c, 0x43d09aed), WTCP(0x6bb812d1, 0x452456bd), WTCP(0x6adcc964, 0x46756828), + WTCP(0x69fd614a, 0x47c3c22f), WTCP(0x6919e320, 0x490f57ee), WTCP(0x683257ab, 0x4a581c9e), WTCP(0x6746c7d8, 0x4b9e0390), + WTCP(0x66573cbb, 0x4ce10034), WTCP(0x6563bf92, 0x4e210617), WTCP(0x646c59bf, 0x4f5e08e3), WTCP(0x637114cc, 0x5097fc5e), + WTCP(0x6271fa69, 0x51ced46e), WTCP(0x616f146c, 0x53028518), WTCP(0x60686ccf, 0x5433027d), WTCP(0x5f5e0db3, 0x556040e2), + WTCP(0x5e50015d, 0x568a34a9), WTCP(0x5d3e5237, 0x57b0d256), WTCP(0x5c290acc, 0x58d40e8c), WTCP(0x5b1035cf, 0x59f3de12), +}; + +const PWord16 SineWindow140[70] = +{ + WTCP(0x7fff7bff, 0x00b7d3bc), WTCP(0x7ffb5c00, 0x02277547), WTCP(0x7ff31c25, 0x0397050d), WTCP(0x7fe6bcb0, 0x05067734), + WTCP(0x7fd63e09, 0x0675bfe7), WTCP(0x7fc1a0b6, 0x07e4d34d), WTCP(0x7fa8e564, 0x0953a594), WTCP(0x7f8c0cdc, 0x0ac22ae8), + WTCP(0x7f6b180f, 0x0c30577a), WTCP(0x7f46080a, 0x0d9e1f7d), WTCP(0x7f1cde01, 0x0f0b7727), WTCP(0x7eef9b46, 0x107852b2), + WTCP(0x7ebe414f, 0x11e4a65c), WTCP(0x7e88d1b4, 0x13506668), WTCP(0x7e4f4e2c, 0x14bb871b), WTCP(0x7e11b894, 0x1625fcc3), + WTCP(0x7dd012e6, 0x178fbbb1), WTCP(0x7d8a5f40, 0x18f8b83c), WTCP(0x7d409fe1, 0x1a60e6c3), WTCP(0x7cf2d72b, 0x1bc83baa), + WTCP(0x7ca1079d, 0x1d2eab5d), WTCP(0x7c4b33dc, 0x1e942a4d), WTCP(0x7bf15eac, 0x1ff8acf7), WTCP(0x7b938af1, 0x215c27dc), + WTCP(0x7b31bbb2, 0x22be8f87), WTCP(0x7acbf416, 0x241fd88e), WTCP(0x7a623764, 0x257ff78e), WTCP(0x79f48904, 0x26dee12c), + WTCP(0x7982ec80, 0x283c8a1b), WTCP(0x790d6581, 0x2998e716), WTCP(0x7893f7d1, 0x2af3ece2), WTCP(0x7816a759, 0x2c4d9050), + WTCP(0x77957822, 0x2da5c63e), WTCP(0x77106e58, 0x2efc8393), WTCP(0x76878e43, 0x3051bd43), WTCP(0x75fadc4d, 0x31a56850), + WTCP(0x756a5cff, 0x32f779c7), WTCP(0x74d61500, 0x3447e6c3), WTCP(0x743e0918, 0x3596a46c), WTCP(0x73a23e2d, 0x36e3a7fa), + WTCP(0x7302b945, 0x382ee6b0), WTCP(0x725f7f84, 0x397855e1), WTCP(0x71b8962b, 0x3abfeaf1), WTCP(0x710e029e, 0x3c059b4f), + WTCP(0x705fca59, 0x3d495c7e), WTCP(0x6fadf2fc, 0x3e8b240e), WTCP(0x6ef88241, 0x3fcae7a1), WTCP(0x6e3f7e01, 0x41089ce8), + WTCP(0x6d82ec32, 0x424439a6), WTCP(0x6cc2d2e9, 0x437db3b0), WTCP(0x6bff3855, 0x44b500eb), WTCP(0x6b3822c6, 0x45ea1750), + WTCP(0x6a6d98a4, 0x471cece7), WTCP(0x699fa078, 0x484d77ce), WTCP(0x68ce40e4, 0x497bae33), WTCP(0x67f980a8, 0x4aa7865b), + WTCP(0x6721669f, 0x4bd0f69b), WTCP(0x6645f9c0, 0x4cf7f55d), WTCP(0x6567411d, 0x4e1c791f), WTCP(0x648543e4, 0x4f3e7875), + WTCP(0x63a0095c, 0x505dea05), WTCP(0x62b798ea, 0x517ac48c), WTCP(0x61cbfa0b, 0x5294fedd), WTCP(0x60dd3457, 0x53ac8fde), + WTCP(0x5feb4f7f, 0x54c16e8e), WTCP(0x5ef6534f, 0x55d391ff), WTCP(0x5dfe47ad, 0x56e2f15d), WTCP(0x5d033497, 0x57ef83e9), + WTCP(0x5c052224, 0x58f940fa), WTCP(0x5b041885, 0x5a002001) +}; + +const PWord16 SineWindow160[80] = +{ + WTCP(0x7fff9aef, 0x00a0d951), WTCP(0x7ffc726f, 0x01e287fc), WTCP(0x7ff62182, 0x03242abf), WTCP(0x7feca851, 0x0465b9aa), + WTCP(0x7fe00716, 0x05a72ccf), WTCP(0x7fd03e23, 0x06e87c3f), WTCP(0x7fbd4dda, 0x0829a00c), WTCP(0x7fa736b4, 0x096a9049), + WTCP(0x7f8df93c, 0x0aab450d), WTCP(0x7f719611, 0x0bebb66c), WTCP(0x7f520de6, 0x0d2bdc80), WTCP(0x7f2f6183, 0x0e6baf61), + WTCP(0x7f0991c4, 0x0fab272b), WTCP(0x7ee09f95, 0x10ea3bfd), WTCP(0x7eb48bfb, 0x1228e5f8), WTCP(0x7e85580c, 0x13671d3d), + WTCP(0x7e5304f2, 0x14a4d9f4), WTCP(0x7e1d93ea, 0x15e21445), WTCP(0x7de50646, 0x171ec45c), WTCP(0x7da95d6c, 0x185ae269), + WTCP(0x7d6a9ad5, 0x199666a0), WTCP(0x7d28c00c, 0x1ad14938), WTCP(0x7ce3ceb2, 0x1c0b826a), WTCP(0x7c9bc87a, 0x1d450a78), + WTCP(0x7c50af2b, 0x1e7dd9a4), WTCP(0x7c02849f, 0x1fb5e836), WTCP(0x7bb14ac5, 0x20ed2e7b), WTCP(0x7b5d039e, 0x2223a4c5), + WTCP(0x7b05b13d, 0x2359436c), WTCP(0x7aab55ca, 0x248e02cb), WTCP(0x7a4df380, 0x25c1db44), WTCP(0x79ed8cad, 0x26f4c53e), + WTCP(0x798a23b1, 0x2826b928), WTCP(0x7923bb01, 0x2957af74), WTCP(0x78ba5524, 0x2a87a09d), WTCP(0x784df4b3, 0x2bb68522), + WTCP(0x77de9c5b, 0x2ce45589), WTCP(0x776c4edb, 0x2e110a62), WTCP(0x76f70f05, 0x2f3c9c40), WTCP(0x767edfbe, 0x306703bf), + WTCP(0x7603c3fd, 0x31903982), WTCP(0x7585becb, 0x32b83634), WTCP(0x7504d345, 0x33def287), WTCP(0x74810499, 0x35046736), + WTCP(0x73fa5607, 0x36288d03), WTCP(0x7370cae2, 0x374b5cb9), WTCP(0x72e4668f, 0x386ccf2a), WTCP(0x72552c85, 0x398cdd32), + WTCP(0x71c3204c, 0x3aab7fb7), WTCP(0x712e457f, 0x3bc8afa5), WTCP(0x70969fca, 0x3ce465f3), WTCP(0x6ffc32eb, 0x3dfe9ba1), + WTCP(0x6f5f02b2, 0x3f1749b8), WTCP(0x6ebf12ff, 0x402e694c), WTCP(0x6e1c67c4, 0x4143f379), WTCP(0x6d770506, 0x4257e166), + WTCP(0x6cceeed8, 0x436a2c45), WTCP(0x6c242960, 0x447acd50), WTCP(0x6b76b8d6, 0x4589bdcf), WTCP(0x6ac6a180, 0x4696f710), + WTCP(0x6a13e7b8, 0x47a27271), WTCP(0x695e8fe5, 0x48ac2957), WTCP(0x68a69e81, 0x49b41533), WTCP(0x67ec1817, 0x4aba2f84), + WTCP(0x672f013f, 0x4bbe71d1), WTCP(0x666f5ea6, 0x4cc0d5ae), WTCP(0x65ad3505, 0x4dc154bb), WTCP(0x64e88926, 0x4ebfe8a5), + WTCP(0x64215fe5, 0x4fbc8b22), WTCP(0x6357be2a, 0x50b735f8), WTCP(0x628ba8ef, 0x51afe2f6), WTCP(0x61bd253f, 0x52a68bfb), + WTCP(0x60ec3830, 0x539b2af0), WTCP(0x6018e6eb, 0x548db9cb), WTCP(0x5f4336a7, 0x557e3292), WTCP(0x5e6b2ca8, 0x566c8f55), + WTCP(0x5d90ce45, 0x5758ca31), WTCP(0x5cb420e0, 0x5842dd54), WTCP(0x5bd529eb, 0x592ac2f7), WTCP(0x5af3eee6, 0x5a107561), +}; + +const PWord16 SineWindow180[90] = +{ + WTCP(0x7fffb026, 0x008efa17), WTCP(0x7ffd3154, 0x01aceb7c), WTCP(0x7ff833bd, 0x02cad485), WTCP(0x7ff0b77a, 0x03e8af9e), + WTCP(0x7fe6bcb0, 0x05067734), WTCP(0x7fda4391, 0x062425b6), WTCP(0x7fcb4c5b, 0x0741b592), WTCP(0x7fb9d759, 0x085f2137), + WTCP(0x7fa5e4e1, 0x097c6313), WTCP(0x7f8f7559, 0x0a997598), WTCP(0x7f76892f, 0x0bb65336), WTCP(0x7f5b20df, 0x0cd2f660), + WTCP(0x7f3d3cf4, 0x0def598a), WTCP(0x7f1cde01, 0x0f0b7727), WTCP(0x7efa04a8, 0x102749af), WTCP(0x7ed4b198, 0x1142cb98), + WTCP(0x7eace58a, 0x125df75b), WTCP(0x7e82a146, 0x1378c774), WTCP(0x7e55e59e, 0x1493365f), WTCP(0x7e26b371, 0x15ad3e9a), + WTCP(0x7df50bab, 0x16c6daa6), WTCP(0x7dc0ef44, 0x17e00505), WTCP(0x7d8a5f40, 0x18f8b83c), WTCP(0x7d515caf, 0x1a10eed3), + WTCP(0x7d15e8ad, 0x1b28a351), WTCP(0x7cd80464, 0x1c3fd045), WTCP(0x7c97b109, 0x1d56703c), WTCP(0x7c54efdc, 0x1e6c7dc7), + WTCP(0x7c0fc22a, 0x1f81f37c), WTCP(0x7bc8294d, 0x2096cbf1), WTCP(0x7b7e26aa, 0x21ab01c0), WTCP(0x7b31bbb2, 0x22be8f87), + WTCP(0x7ae2e9e4, 0x23d16fe8), WTCP(0x7a91b2c7, 0x24e39d85), WTCP(0x7a3e17f2, 0x25f51307), WTCP(0x79e81b06, 0x2705cb19), + WTCP(0x798fbdb0, 0x2815c06a), WTCP(0x793501a9, 0x2924edac), WTCP(0x78d7e8b6, 0x2a334d96), WTCP(0x787874a7, 0x2b40dae2), + WTCP(0x7816a759, 0x2c4d9050), WTCP(0x77b282b3, 0x2d5968a3), WTCP(0x774c08ab, 0x2e645ea1), WTCP(0x76e33b3f, 0x2f6e6d16), + WTCP(0x76781c7a, 0x30778ed2), WTCP(0x760aae73, 0x317fbeab), WTCP(0x759af34c, 0x3286f779), WTCP(0x7528ed32, 0x338d341b), + WTCP(0x74b49e5f, 0x34926f74), WTCP(0x743e0918, 0x3596a46c), WTCP(0x73c52fab, 0x3699cdf2), WTCP(0x734a1475, 0x379be6f6), + WTCP(0x72ccb9db, 0x389cea72), WTCP(0x724d224f, 0x399cd362), WTCP(0x71cb504e, 0x3a9b9cca), WTCP(0x71474660, 0x3b9941b1), + WTCP(0x70c10718, 0x3c95bd26), WTCP(0x70389514, 0x3d910a3c), WTCP(0x6fadf2fc, 0x3e8b240e), WTCP(0x6f212385, 0x3f8405bc), + WTCP(0x6e92296e, 0x407baa6a), WTCP(0x6e010780, 0x41720d46), WTCP(0x6d6dc08f, 0x42672981), WTCP(0x6cd8577a, 0x435afa54), + WTCP(0x6c40cf2c, 0x444d7aff), WTCP(0x6ba72a98, 0x453ea6c7), WTCP(0x6b0b6cbd, 0x462e78f9), WTCP(0x6a6d98a4, 0x471cece7), + WTCP(0x69cdb162, 0x4809fdeb), WTCP(0x692bba14, 0x48f5a767), WTCP(0x6887b5e2, 0x49dfe4c2), WTCP(0x67e1a7ff, 0x4ac8b16b), + WTCP(0x673993a9, 0x4bb008d9), WTCP(0x668f7c25, 0x4c95e688), WTCP(0x65e364c4, 0x4d7a45fe), WTCP(0x653550e2, 0x4e5d22c6), + WTCP(0x648543e4, 0x4f3e7875), WTCP(0x63d34137, 0x501e42a5), WTCP(0x631f4c54, 0x50fc7cfb), WTCP(0x626968be, 0x51d92321), + WTCP(0x61b19a00, 0x52b430c9), WTCP(0x60f7e3b0, 0x538da1ae), WTCP(0x603c496c, 0x54657194), WTCP(0x5f7ecedd, 0x553b9c45), + WTCP(0x5ebf77b5, 0x56101d94), WTCP(0x5dfe47ad, 0x56e2f15d), WTCP(0x5d3b428c, 0x57b41384), WTCP(0x5c766c1c, 0x58837ff4), + WTCP(0x5bafc837, 0x595132a2), WTCP(0x5ae75ab9, 0x5a1d278d), +}; + + +const PWord16 SineWindow224[112] = +{ + WTCP(0x7fffcc70, 0x0072e46e), WTCP(0x7ffe2fee, 0x0158abd6), WTCP(0x7ffaf6f1, 0x023e6ee8), WTCP(0x7ff62182, 0x03242abf), + WTCP(0x7fefafb1, 0x0409dc76), WTCP(0x7fe7a192, 0x04ef8129), WTCP(0x7fddf741, 0x05d515f5), WTCP(0x7fd2b0da, 0x06ba97f4), + WTCP(0x7fc5ce84, 0x07a00445), WTCP(0x7fb75068, 0x08855802), WTCP(0x7fa736b4, 0x096a9049), WTCP(0x7f95819c, 0x0a4faa38), + WTCP(0x7f82315a, 0x0b34a2ec), WTCP(0x7f6d462b, 0x0c197784), WTCP(0x7f56c053, 0x0cfe251d), WTCP(0x7f3ea01a, 0x0de2a8d7), + WTCP(0x7f24e5cf, 0x0ec6ffd1), WTCP(0x7f0991c4, 0x0fab272b), WTCP(0x7eeca451, 0x108f1c07), WTCP(0x7ece1dd3, 0x1172db86), + WTCP(0x7eadfeae, 0x125662c9), WTCP(0x7e8c4748, 0x1339aef3), WTCP(0x7e68f80e, 0x141cbd28), WTCP(0x7e441171, 0x14ff8a8c), + WTCP(0x7e1d93ea, 0x15e21445), WTCP(0x7df57ff3, 0x16c45777), WTCP(0x7dcbd60e, 0x17a6514a), WTCP(0x7da096c2, 0x1887fee6), + WTCP(0x7d73c299, 0x19695d74), WTCP(0x7d455a24, 0x1a4a6a1c), WTCP(0x7d155df9, 0x1b2b220b), WTCP(0x7ce3ceb2, 0x1c0b826a), + WTCP(0x7cb0acef, 0x1ceb8869), WTCP(0x7c7bf954, 0x1dcb3134), WTCP(0x7c45b48d, 0x1eaa79fa), WTCP(0x7c0ddf47, 0x1f895fed), + WTCP(0x7bd47a36, 0x2067e03e), WTCP(0x7b998614, 0x2145f81f), WTCP(0x7b5d039e, 0x2223a4c5), WTCP(0x7b1ef397, 0x2300e366), + WTCP(0x7adf56c8, 0x23ddb139), WTCP(0x7a9e2dfd, 0x24ba0b76), WTCP(0x7a5b7a09, 0x2595ef56), WTCP(0x7a173bc2, 0x26715a16), + WTCP(0x79d17405, 0x274c48f2), WTCP(0x798a23b1, 0x2826b928), WTCP(0x79414bae, 0x2900a7f9), WTCP(0x78f6ece5, 0x29da12a7), + WTCP(0x78ab0847, 0x2ab2f674), WTCP(0x785d9ec8, 0x2b8b50a5), WTCP(0x780eb161, 0x2c631e82), WTCP(0x77be4111, 0x2d3a5d53), + WTCP(0x776c4edb, 0x2e110a62), WTCP(0x7718dbc8, 0x2ee722fb), WTCP(0x76c3e8e3, 0x2fbca46d), WTCP(0x766d773f, 0x30918c08), + WTCP(0x761587f3, 0x3165d71c), WTCP(0x75bc1c1a, 0x323982ff), WTCP(0x756134d4, 0x330c8d05), WTCP(0x7504d345, 0x33def287), + WTCP(0x74a6f899, 0x34b0b0df), WTCP(0x7447a5fc, 0x3581c569), WTCP(0x73e6dca3, 0x36522d83), WTCP(0x73849dc5, 0x3721e68d), + WTCP(0x7320ea9f, 0x37f0edea), WTCP(0x72bbc472, 0x38bf40ff), WTCP(0x72552c85, 0x398cdd32), WTCP(0x71ed2421, 0x3a59bfee), + WTCP(0x7183ac96, 0x3b25e69e), WTCP(0x7118c739, 0x3bf14eaf), WTCP(0x70ac7560, 0x3cbbf594), WTCP(0x703eb86a, 0x3d85d8bd), + WTCP(0x6fcf91b9, 0x3e4ef5a1), WTCP(0x6f5f02b2, 0x3f1749b8), WTCP(0x6eed0cc0, 0x3fded27c), WTCP(0x6e79b152, 0x40a58d69), + WTCP(0x6e04f1dd, 0x416b7801), WTCP(0x6d8ecfd8, 0x42308fc4), WTCP(0x6d174cc0, 0x42f4d237), WTCP(0x6c9e6a16, 0x43b83ce3), + WTCP(0x6c242960, 0x447acd50), WTCP(0x6ba88c28, 0x453c810d), WTCP(0x6b2b93fd, 0x45fd55a9), WTCP(0x6aad4270, 0x46bd48b7), + WTCP(0x6a2d9919, 0x477c57cb), WTCP(0x69ac9994, 0x483a807f), WTCP(0x692a4580, 0x48f7c06d), WTCP(0x68a69e81, 0x49b41533), + WTCP(0x6821a640, 0x4a6f7c74), WTCP(0x679b5e68, 0x4b29f3d1), WTCP(0x6713c8ac, 0x4be378f4), WTCP(0x668ae6bf, 0x4c9c0985), + WTCP(0x6600ba5b, 0x4d53a332), WTCP(0x6575453d, 0x4e0a43ab), WTCP(0x64e88926, 0x4ebfe8a5), WTCP(0x645a87dd, 0x4f748fd4), + WTCP(0x63cb432a, 0x502836f4), WTCP(0x633abcdc, 0x50dadbc1), WTCP(0x62a8f6c4, 0x518c7bfb), WTCP(0x6215f2b9, 0x523d1567), + WTCP(0x6181b292, 0x52eca5ca), WTCP(0x60ec3830, 0x539b2af0), WTCP(0x60558573, 0x5448a2a5), WTCP(0x5fbd9c41, 0x54f50abb), + WTCP(0x5f247e83, 0x55a06106), WTCP(0x5e8a2e27, 0x564aa35d), WTCP(0x5deead1f, 0x56f3cf9d), WTCP(0x5d51fd5e, 0x579be3a4), + WTCP(0x5cb420e0, 0x5842dd54), WTCP(0x5c15199f, 0x58e8ba94), WTCP(0x5b74e99d, 0x598d794c), WTCP(0x5ad392de, 0x5a31176a) +}; + + +const PWord16 SineWindow256[128] = +{ + WTCP(0x7fffd886, 0x006487e3), WTCP(0x7ffe9cb2, 0x012d96b1), WTCP(0x7ffc250f, 0x01f6a297), WTCP(0x7ff871a2, 0x02bfa9a4), + WTCP(0x7ff38274, 0x0388a9ea), WTCP(0x7fed5791, 0x0451a177), WTCP(0x7fe5f108, 0x051a8e5c), WTCP(0x7fdd4eec, 0x05e36ea9), + WTCP(0x7fd37153, 0x06ac406f), WTCP(0x7fc85854, 0x077501be), WTCP(0x7fbc040a, 0x083db0a7), WTCP(0x7fae7495, 0x09064b3a), + WTCP(0x7f9faa15, 0x09cecf89), WTCP(0x7f8fa4b0, 0x0a973ba5), WTCP(0x7f7e648c, 0x0b5f8d9f), WTCP(0x7f6be9d4, 0x0c27c389), + WTCP(0x7f5834b7, 0x0cefdb76), WTCP(0x7f434563, 0x0db7d376), WTCP(0x7f2d1c0e, 0x0e7fa99e), WTCP(0x7f15b8ee, 0x0f475bff), + WTCP(0x7efd1c3c, 0x100ee8ad), WTCP(0x7ee34636, 0x10d64dbd), WTCP(0x7ec8371a, 0x119d8941), WTCP(0x7eabef2c, 0x1264994e), + WTCP(0x7e8e6eb2, 0x132b7bf9), WTCP(0x7e6fb5f4, 0x13f22f58), WTCP(0x7e4fc53e, 0x14b8b17f), WTCP(0x7e2e9cdf, 0x157f0086), + WTCP(0x7e0c3d29, 0x16451a83), WTCP(0x7de8a670, 0x170afd8d), WTCP(0x7dc3d90d, 0x17d0a7bc), WTCP(0x7d9dd55a, 0x18961728), + WTCP(0x7d769bb5, 0x195b49ea), WTCP(0x7d4e2c7f, 0x1a203e1b), WTCP(0x7d24881b, 0x1ae4f1d6), WTCP(0x7cf9aef0, 0x1ba96335), + WTCP(0x7ccda169, 0x1c6d9053), WTCP(0x7ca05ff1, 0x1d31774d), WTCP(0x7c71eaf9, 0x1df5163f), WTCP(0x7c4242f2, 0x1eb86b46), + WTCP(0x7c116853, 0x1f7b7481), WTCP(0x7bdf5b94, 0x203e300d), WTCP(0x7bac1d31, 0x21009c0c), WTCP(0x7b77ada8, 0x21c2b69c), + WTCP(0x7b420d7a, 0x22847de0), WTCP(0x7b0b3d2c, 0x2345eff8), WTCP(0x7ad33d45, 0x24070b08), WTCP(0x7a9a0e50, 0x24c7cd33), + WTCP(0x7a5fb0d8, 0x2588349d), WTCP(0x7a24256f, 0x26483f6c), WTCP(0x79e76ca7, 0x2707ebc7), WTCP(0x79a98715, 0x27c737d3), + WTCP(0x796a7554, 0x288621b9), WTCP(0x792a37fe, 0x2944a7a2), WTCP(0x78e8cfb2, 0x2a02c7b8), WTCP(0x78a63d11, 0x2ac08026), + WTCP(0x786280bf, 0x2b7dcf17), WTCP(0x781d9b65, 0x2c3ab2b9), WTCP(0x77d78daa, 0x2cf72939), WTCP(0x7790583e, 0x2db330c7), + WTCP(0x7747fbce, 0x2e6ec792), WTCP(0x76fe790e, 0x2f29ebcc), WTCP(0x76b3d0b4, 0x2fe49ba7), WTCP(0x76680376, 0x309ed556), + WTCP(0x761b1211, 0x3158970e), WTCP(0x75ccfd42, 0x3211df04), WTCP(0x757dc5ca, 0x32caab6f), WTCP(0x752d6c6c, 0x3382fa88), + WTCP(0x74dbf1ef, 0x343aca87), WTCP(0x7489571c, 0x34f219a8), WTCP(0x74359cbd, 0x35a8e625), WTCP(0x73e0c3a3, 0x365f2e3b), + WTCP(0x738acc9e, 0x3714f02a), WTCP(0x7333b883, 0x37ca2a30), WTCP(0x72db8828, 0x387eda8e), WTCP(0x72823c67, 0x3932ff87), + WTCP(0x7227d61c, 0x39e6975e), WTCP(0x71cc5626, 0x3a99a057), WTCP(0x716fbd68, 0x3b4c18ba), WTCP(0x71120cc5, 0x3bfdfecd), + WTCP(0x70b34525, 0x3caf50da), WTCP(0x70536771, 0x3d600d2c), WTCP(0x6ff27497, 0x3e10320d), WTCP(0x6f906d84, 0x3ebfbdcd), + WTCP(0x6f2d532c, 0x3f6eaeb8), WTCP(0x6ec92683, 0x401d0321), WTCP(0x6e63e87f, 0x40cab958), WTCP(0x6dfd9a1c, 0x4177cfb1), + WTCP(0x6d963c54, 0x42244481), WTCP(0x6d2dd027, 0x42d0161e), WTCP(0x6cc45698, 0x437b42e1), WTCP(0x6c59d0a9, 0x4425c923), + WTCP(0x6bee3f62, 0x44cfa740), WTCP(0x6b81a3cd, 0x4578db93), WTCP(0x6b13fef5, 0x4621647d), WTCP(0x6aa551e9, 0x46c9405c), + WTCP(0x6a359db9, 0x47706d93), WTCP(0x69c4e37a, 0x4816ea86), WTCP(0x69532442, 0x48bcb599), WTCP(0x68e06129, 0x4961cd33), + WTCP(0x686c9b4b, 0x4a062fbd), WTCP(0x67f7d3c5, 0x4aa9dba2), WTCP(0x67820bb7, 0x4b4ccf4d), WTCP(0x670b4444, 0x4bef092d), + WTCP(0x66937e91, 0x4c9087b1), WTCP(0x661abbc5, 0x4d31494b), WTCP(0x65a0fd0b, 0x4dd14c6e), WTCP(0x6526438f, 0x4e708f8f), + WTCP(0x64aa907f, 0x4f0f1126), WTCP(0x642de50d, 0x4faccfab), WTCP(0x63b0426d, 0x5049c999), WTCP(0x6331a9d4, 0x50e5fd6d), + WTCP(0x62b21c7b, 0x518169a5), WTCP(0x62319b9d, 0x521c0cc2), WTCP(0x61b02876, 0x52b5e546), WTCP(0x612dc447, 0x534ef1b5), + WTCP(0x60aa7050, 0x53e73097), WTCP(0x60262dd6, 0x547ea073), WTCP(0x5fa0fe1f, 0x55153fd4), WTCP(0x5f1ae274, 0x55ab0d46), + WTCP(0x5e93dc1f, 0x56400758), WTCP(0x5e0bec6e, 0x56d42c99), WTCP(0x5d8314b1, 0x57677b9d), WTCP(0x5cf95638, 0x57f9f2f8), + WTCP(0x5c6eb258, 0x588b9140), WTCP(0x5be32a67, 0x591c550e), WTCP(0x5b56bfbd, 0x59ac3cfd), WTCP(0x5ac973b5, 0x5a3b47ab), +}; + +const PWord16 SineWindow280[140] = +{ + WTCP(0x7fffdf00, 0x005be9f6), WTCP(0x7ffed6ff, 0x0113bd23), WTCP(0x7ffcc6ff, 0x01cb8e18), WTCP(0x7ff9af04, 0x02835b5a), + WTCP(0x7ff58f15, 0x033b236c), WTCP(0x7ff0673a, 0x03f2e4d4), WTCP(0x7fea377e, 0x04aa9e17), WTCP(0x7fe2ffee, 0x05624dba), + WTCP(0x7fdac098, 0x0619f243), WTCP(0x7fd1798e, 0x06d18a36), WTCP(0x7fc72ae2, 0x07891418), WTCP(0x7fbbd4aa, 0x08408e70), + WTCP(0x7faf76fe, 0x08f7f7c3), WTCP(0x7fa211f6, 0x09af4e96), WTCP(0x7f93a5af, 0x0a66916f), WTCP(0x7f843246, 0x0b1dbed5), + WTCP(0x7f73b7da, 0x0bd4d54d), WTCP(0x7f62368f, 0x0c8bd35e), WTCP(0x7f4fae88, 0x0d42b78f), WTCP(0x7f3c1fec, 0x0df98066), + WTCP(0x7f278ae1, 0x0eb02c6a), WTCP(0x7f11ef95, 0x0f66ba22), WTCP(0x7efb4e31, 0x101d2817), WTCP(0x7ee3a6e7, 0x10d374cf), + WTCP(0x7ecaf9e5, 0x11899ed3), WTCP(0x7eb1475f, 0x123fa4ab), WTCP(0x7e968f8b, 0x12f584e0), WTCP(0x7e7ad29e, 0x13ab3dfa), + WTCP(0x7e5e10d3, 0x1460ce82), WTCP(0x7e404a65, 0x15163503), WTCP(0x7e217f90, 0x15cb7006), WTCP(0x7e01b096, 0x16807e15), + WTCP(0x7de0ddb6, 0x17355dba), WTCP(0x7dbf0736, 0x17ea0d81), WTCP(0x7d9c2d5a, 0x189e8bf6), WTCP(0x7d78506a, 0x1952d7a3), + WTCP(0x7d5370b2, 0x1a06ef15), WTCP(0x7d2d8e7b, 0x1abad0d8), WTCP(0x7d06aa16, 0x1b6e7b7a), WTCP(0x7cdec3d2, 0x1c21ed87), + WTCP(0x7cb5dc00, 0x1cd5258f), WTCP(0x7c8bf2f7, 0x1d88221e), WTCP(0x7c61090b, 0x1e3ae1c5), WTCP(0x7c351e96, 0x1eed6311), + WTCP(0x7c0833f3, 0x1f9fa494), WTCP(0x7bda497d, 0x2051a4dd), WTCP(0x7bab5f93, 0x2103627d), WTCP(0x7b7b7697, 0x21b4dc06), + WTCP(0x7b4a8eeb, 0x2266100a), WTCP(0x7b18a8f4, 0x2316fd1b), WTCP(0x7ae5c518, 0x23c7a1cc), WTCP(0x7ab1e3c2, 0x2477fcb1), + WTCP(0x7a7d055b, 0x25280c5e), WTCP(0x7a472a51, 0x25d7cf68), WTCP(0x7a105313, 0x26874464), WTCP(0x79d88013, 0x273669e9), + WTCP(0x799fb1c2, 0x27e53e8e), WTCP(0x7965e897, 0x2893c0e9), WTCP(0x792b2508, 0x2941ef93), WTCP(0x78ef678f, 0x29efc925), + WTCP(0x78b2b0a7, 0x2a9d4c38), WTCP(0x787500ce, 0x2b4a7766), WTCP(0x78365881, 0x2bf7494a), WTCP(0x77f6b844, 0x2ca3c07f), + WTCP(0x77b62098, 0x2d4fdba2), WTCP(0x77749203, 0x2dfb9950), WTCP(0x77320d0d, 0x2ea6f827), WTCP(0x76ee923e, 0x2f51f6c4), + WTCP(0x76aa2222, 0x2ffc93c9), WTCP(0x7664bd46, 0x30a6cdd3), WTCP(0x761e6439, 0x3150a385), WTCP(0x75d7178c, 0x31fa1381), + WTCP(0x758ed7d2, 0x32a31c68), WTCP(0x7545a5a0, 0x334bbcde), WTCP(0x74fb818e, 0x33f3f387), WTCP(0x74b06c33, 0x349bbf09), + WTCP(0x7464662c, 0x35431e09), WTCP(0x74177014, 0x35ea0f2e), WTCP(0x73c98a8a, 0x36909120), WTCP(0x737ab630, 0x3736a287), + WTCP(0x732af3a7, 0x37dc420c), WTCP(0x72da4395, 0x38816e5b), WTCP(0x7288a69f, 0x3926261e), WTCP(0x72361d6e, 0x39ca6802), + WTCP(0x71e2a8ad, 0x3a6e32b4), WTCP(0x718e4907, 0x3b1184e2), WTCP(0x7138ff2a, 0x3bb45d3b), WTCP(0x70e2cbc6, 0x3c56ba70), + WTCP(0x708baf8d, 0x3cf89b31), WTCP(0x7033ab34, 0x3d99fe31), WTCP(0x6fdabf6e, 0x3e3ae223), WTCP(0x6f80ecf4, 0x3edb45ba), + WTCP(0x6f26347f, 0x3f7b27ac), WTCP(0x6eca96ca, 0x401a86b0), WTCP(0x6e6e1492, 0x40b9617d), WTCP(0x6e10ae96, 0x4157b6ca), + WTCP(0x6db26597, 0x41f58552), WTCP(0x6d533a56, 0x4292cbcf), WTCP(0x6cf32d99, 0x432f88fc), WTCP(0x6c924024, 0x43cbbb97), + WTCP(0x6c3072c1, 0x4467625d), WTCP(0x6bcdc639, 0x45027c0c), WTCP(0x6b6a3b58, 0x459d0766), WTCP(0x6b05d2ea, 0x4637032c), + WTCP(0x6aa08dbf, 0x46d06e1f), WTCP(0x6a3a6ca8, 0x47694703), WTCP(0x69d37078, 0x48018c9e), WTCP(0x696b9a02, 0x48993db5), + WTCP(0x6902ea1d, 0x4930590f), WTCP(0x689961a1, 0x49c6dd74), WTCP(0x682f0167, 0x4a5cc9af), WTCP(0x67c3ca4c, 0x4af21c89), + WTCP(0x6757bd2b, 0x4b86d4cf), WTCP(0x66eadae5, 0x4c1af14f), WTCP(0x667d2459, 0x4cae70d6), WTCP(0x660e9a6a, 0x4d415234), + WTCP(0x659f3dfc, 0x4dd3943b), WTCP(0x652f0ff4, 0x4e6535bd), WTCP(0x64be113a, 0x4ef6358d), WTCP(0x644c42b8, 0x4f869280), + WTCP(0x63d9a556, 0x50164b6d), WTCP(0x63663a03, 0x50a55f2c), WTCP(0x62f201ac, 0x5133cc94), WTCP(0x627cfd41, 0x51c19281), + WTCP(0x62072db3, 0x524eafce), WTCP(0x619093f5, 0x52db2357), WTCP(0x611930fc, 0x5366ebfc), WTCP(0x60a105be, 0x53f2089b), + WTCP(0x60281333, 0x547c7817), WTCP(0x5fae5a55, 0x55063951), WTCP(0x5f33dc1d, 0x558f4b2d), WTCP(0x5eb8998a, 0x5617ac90), + WTCP(0x5e3c9399, 0x569f5c62), WTCP(0x5dbfcb4a, 0x5726598b), WTCP(0x5d42419f, 0x57aca2f3), WTCP(0x5cc3f79a, 0x58323787), + WTCP(0x5c44ee40, 0x58b71632), WTCP(0x5bc52696, 0x593b3de2), WTCP(0x5b44a1a5, 0x59bead87), WTCP(0x5ac36076, 0x5a416413) +}; + +const PWord16 SineWindow320[160] = +{ + WTCP(0x7fffe6bc, 0x00506cb9), WTCP(0x7fff1c9b, 0x00f145ab), WTCP(0x7ffd885a, 0x01921d20), WTCP(0x7ffb29fd, 0x0232f21a), + WTCP(0x7ff80186, 0x02d3c39b), WTCP(0x7ff40efa, 0x037490a5), WTCP(0x7fef5260, 0x0415583b), WTCP(0x7fe9cbc0, 0x04b6195d), + WTCP(0x7fe37b22, 0x0556d30f), WTCP(0x7fdc608f, 0x05f78453), WTCP(0x7fd47c14, 0x06982c2b), WTCP(0x7fcbcdbc, 0x0738c998), + WTCP(0x7fc25596, 0x07d95b9e), WTCP(0x7fb813b0, 0x0879e140), WTCP(0x7fad081b, 0x091a597e), WTCP(0x7fa132e8, 0x09bac35d), + WTCP(0x7f949429, 0x0a5b1dde), WTCP(0x7f872bf3, 0x0afb6805), WTCP(0x7f78fa5b, 0x0b9ba0d5), WTCP(0x7f69ff76, 0x0c3bc74f), + WTCP(0x7f5a3b5e, 0x0cdbda79), WTCP(0x7f49ae2a, 0x0d7bd954), WTCP(0x7f3857f6, 0x0e1bc2e4), WTCP(0x7f2638db, 0x0ebb962c), + WTCP(0x7f1350f8, 0x0f5b5231), WTCP(0x7effa069, 0x0ffaf5f6), WTCP(0x7eeb274d, 0x109a807e), WTCP(0x7ed5e5c6, 0x1139f0cf), + WTCP(0x7ebfdbf5, 0x11d945eb), WTCP(0x7ea909fc, 0x12787ed8), WTCP(0x7e917000, 0x13179a9b), WTCP(0x7e790e25, 0x13b69836), + WTCP(0x7e5fe493, 0x145576b1), WTCP(0x7e45f371, 0x14f43510), WTCP(0x7e2b3ae8, 0x1592d257), WTCP(0x7e0fbb22, 0x16314d8e), + WTCP(0x7df3744b, 0x16cfa5b9), WTCP(0x7dd6668f, 0x176dd9de), WTCP(0x7db8921c, 0x180be904), WTCP(0x7d99f721, 0x18a9d231), + WTCP(0x7d7a95cf, 0x1947946c), WTCP(0x7d5a6e57, 0x19e52ebb), WTCP(0x7d3980ec, 0x1a82a026), WTCP(0x7d17cdc2, 0x1b1fe7b3), + WTCP(0x7cf5550e, 0x1bbd046c), WTCP(0x7cd21707, 0x1c59f557), WTCP(0x7cae13e4, 0x1cf6b97c), WTCP(0x7c894bde, 0x1d934fe5), + WTCP(0x7c63bf2f, 0x1e2fb79a), WTCP(0x7c3d6e13, 0x1ecbefa4), WTCP(0x7c1658c5, 0x1f67f70b), WTCP(0x7bee7f85, 0x2003ccdb), + WTCP(0x7bc5e290, 0x209f701c), WTCP(0x7b9c8226, 0x213adfda), WTCP(0x7b725e8a, 0x21d61b1e), WTCP(0x7b4777fe, 0x227120f3), + WTCP(0x7b1bcec4, 0x230bf065), WTCP(0x7aef6323, 0x23a6887f), WTCP(0x7ac23561, 0x2440e84d), WTCP(0x7a9445c5, 0x24db0edb), + WTCP(0x7a659496, 0x2574fb36), WTCP(0x7a362220, 0x260eac6a), WTCP(0x7a05eead, 0x26a82186), WTCP(0x79d4fa89, 0x27415996), + WTCP(0x79a34602, 0x27da53a9), WTCP(0x7970d165, 0x28730ecd), WTCP(0x793d9d03, 0x290b8a12), WTCP(0x7909a92d, 0x29a3c485), + WTCP(0x78d4f634, 0x2a3bbd37), WTCP(0x789f846b, 0x2ad37338), WTCP(0x78695428, 0x2b6ae598), WTCP(0x783265c0, 0x2c021369), + WTCP(0x77fab989, 0x2c98fbba), WTCP(0x77c24fdb, 0x2d2f9d9f), WTCP(0x77892910, 0x2dc5f829), WTCP(0x774f4581, 0x2e5c0a6b), + WTCP(0x7714a58b, 0x2ef1d377), WTCP(0x76d94989, 0x2f875262), WTCP(0x769d31d9, 0x301c863f), WTCP(0x76605edb, 0x30b16e23), + WTCP(0x7622d0ef, 0x31460922), WTCP(0x75e48874, 0x31da5651), WTCP(0x75a585cf, 0x326e54c7), WTCP(0x7565c962, 0x3302039b), + WTCP(0x75255392, 0x339561e1), WTCP(0x74e424c5, 0x34286eb3), WTCP(0x74a23d62, 0x34bb2927), WTCP(0x745f9dd1, 0x354d9057), + WTCP(0x741c467b, 0x35dfa35a), WTCP(0x73d837ca, 0x3671614b), WTCP(0x7393722a, 0x3702c942), WTCP(0x734df607, 0x3793da5b), + WTCP(0x7307c3d0, 0x382493b0), WTCP(0x72c0dbf3, 0x38b4f45d), WTCP(0x72793edf, 0x3944fb7e), WTCP(0x7230ed07, 0x39d4a82f), + WTCP(0x71e7e6dc, 0x3a63f98d), WTCP(0x719e2cd2, 0x3af2eeb7), WTCP(0x7153bf5d, 0x3b8186ca), WTCP(0x71089ef2, 0x3c0fc0e6), + WTCP(0x70bccc09, 0x3c9d9c28), WTCP(0x70704718, 0x3d2b17b3), WTCP(0x7023109a, 0x3db832a6), WTCP(0x6fd52907, 0x3e44ec22), + WTCP(0x6f8690db, 0x3ed14349), WTCP(0x6f374891, 0x3f5d373e), WTCP(0x6ee750a8, 0x3fe8c724), WTCP(0x6e96a99d, 0x4073f21d), + WTCP(0x6e4553ef, 0x40feb74f), WTCP(0x6df35020, 0x418915de), WTCP(0x6da09eb1, 0x42130cf0), WTCP(0x6d4d4023, 0x429c9bab), + WTCP(0x6cf934fc, 0x4325c135), WTCP(0x6ca47dbf, 0x43ae7cb7), WTCP(0x6c4f1af2, 0x4436cd58), WTCP(0x6bf90d1d, 0x44beb240), + WTCP(0x6ba254c7, 0x45462a9a), WTCP(0x6b4af279, 0x45cd358f), WTCP(0x6af2e6bc, 0x4653d24b), WTCP(0x6a9a321d, 0x46d9fff8), + WTCP(0x6a40d527, 0x475fbdc3), WTCP(0x69e6d067, 0x47e50ad8), WTCP(0x698c246c, 0x4869e665), WTCP(0x6930d1c4, 0x48ee4f98), + WTCP(0x68d4d900, 0x497245a1), WTCP(0x68783ab1, 0x49f5c7ae), WTCP(0x681af76a, 0x4a78d4f0), WTCP(0x67bd0fbd, 0x4afb6c98), + WTCP(0x675e843e, 0x4b7d8dd8), WTCP(0x66ff5584, 0x4bff37e2), WTCP(0x669f8425, 0x4c8069ea), WTCP(0x663f10b7, 0x4d012324), + WTCP(0x65ddfbd3, 0x4d8162c4), WTCP(0x657c4613, 0x4e012800), WTCP(0x6519f010, 0x4e80720e), WTCP(0x64b6fa66, 0x4eff4025), + WTCP(0x645365b2, 0x4f7d917c), WTCP(0x63ef3290, 0x4ffb654d), WTCP(0x638a619e, 0x5078bad1), WTCP(0x6324f37d, 0x50f59141), + WTCP(0x62bee8cc, 0x5171e7d9), WTCP(0x6258422c, 0x51edbdd4), WTCP(0x61f1003f, 0x5269126e), WTCP(0x618923a9, 0x52e3e4e6), + WTCP(0x6120ad0d, 0x535e3479), WTCP(0x60b79d10, 0x53d80065), WTCP(0x604df459, 0x545147eb), WTCP(0x5fe3b38d, 0x54ca0a4b), + WTCP(0x5f78db56, 0x554246c6), WTCP(0x5f0d6c5b, 0x55b9fc9e), WTCP(0x5ea16747, 0x56312b17), WTCP(0x5e34ccc3, 0x56a7d174), + WTCP(0x5dc79d7c, 0x571deefa), WTCP(0x5d59da1e, 0x579382ee), WTCP(0x5ceb8355, 0x58088c96), WTCP(0x5c7c99d1, 0x587d0b3b), + WTCP(0x5c0d1e41, 0x58f0fe23), WTCP(0x5b9d1154, 0x59646498), WTCP(0x5b2c73bb, 0x59d73de3), WTCP(0x5abb4629, 0x5a498950), +}; + + +const PWord16 SineWindow420[210] = +{ + WTCP(0x7ffff155, 0x003d46a7), WTCP(0x7fff7bff, 0x00b7d3bc), WTCP(0x7ffe9154, 0x01326029), WTCP(0x7ffd3154, 0x01aceb7c), + WTCP(0x7ffb5c00, 0x02277547), WTCP(0x7ff9115b, 0x02a1fd18), WTCP(0x7ff65166, 0x031c8280), WTCP(0x7ff31c25, 0x0397050d), + WTCP(0x7fef7199, 0x0411844f), WTCP(0x7feb51c6, 0x048bffd7), WTCP(0x7fe6bcb0, 0x05067734), WTCP(0x7fe1b25b, 0x0580e9f6), + WTCP(0x7fdc32cc, 0x05fb57ac), WTCP(0x7fd63e09, 0x0675bfe7), WTCP(0x7fcfd415, 0x06f02235), WTCP(0x7fc8f4f7, 0x076a7e27), + WTCP(0x7fc1a0b6, 0x07e4d34d), WTCP(0x7fb9d759, 0x085f2137), WTCP(0x7fb198e5, 0x08d96773), WTCP(0x7fa8e564, 0x0953a594), + WTCP(0x7f9fbcdc, 0x09cddb27), WTCP(0x7f961f57, 0x0a4807be), WTCP(0x7f8c0cdc, 0x0ac22ae8), WTCP(0x7f818577, 0x0b3c4435), + WTCP(0x7f76892f, 0x0bb65336), WTCP(0x7f6b180f, 0x0c30577a), WTCP(0x7f5f3221, 0x0caa5092), WTCP(0x7f52d771, 0x0d243e0d), + WTCP(0x7f46080a, 0x0d9e1f7d), WTCP(0x7f38c3f7, 0x0e17f471), WTCP(0x7f2b0b45, 0x0e91bc79), WTCP(0x7f1cde01, 0x0f0b7727), + WTCP(0x7f0e3c36, 0x0f85240a), WTCP(0x7eff25f3, 0x0ffec2b3), WTCP(0x7eef9b46, 0x107852b2), WTCP(0x7edf9c3c, 0x10f1d398), + WTCP(0x7ecf28e5, 0x116b44f6), WTCP(0x7ebe414f, 0x11e4a65c), WTCP(0x7eace58a, 0x125df75b), WTCP(0x7e9b15a6, 0x12d73784), + WTCP(0x7e88d1b4, 0x13506668), WTCP(0x7e7619c3, 0x13c98397), WTCP(0x7e62ede5, 0x14428ea2), WTCP(0x7e4f4e2c, 0x14bb871b), + WTCP(0x7e3b3aaa, 0x15346c93), WTCP(0x7e26b371, 0x15ad3e9a), WTCP(0x7e11b894, 0x1625fcc3), WTCP(0x7dfc4a26, 0x169ea69e), + WTCP(0x7de6683a, 0x17173bbd), WTCP(0x7dd012e6, 0x178fbbb1), WTCP(0x7db94a3c, 0x1808260c), WTCP(0x7da20e53, 0x18807a5f), + WTCP(0x7d8a5f40, 0x18f8b83c), WTCP(0x7d723d18, 0x1970df36), WTCP(0x7d59a7f1, 0x19e8eedd), WTCP(0x7d409fe1, 0x1a60e6c3), + WTCP(0x7d272501, 0x1ad8c67c), WTCP(0x7d0d3767, 0x1b508d98), WTCP(0x7cf2d72b, 0x1bc83baa), WTCP(0x7cd80464, 0x1c3fd045), + WTCP(0x7cbcbf2d, 0x1cb74afa), WTCP(0x7ca1079d, 0x1d2eab5d), WTCP(0x7c84ddcf, 0x1da5f0ff), WTCP(0x7c6841db, 0x1e1d1b73), + WTCP(0x7c4b33dc, 0x1e942a4d), WTCP(0x7c2db3ee, 0x1f0b1d1f), WTCP(0x7c0fc22a, 0x1f81f37c), WTCP(0x7bf15eac, 0x1ff8acf7), + WTCP(0x7bd28991, 0x206f4923), WTCP(0x7bb342f3, 0x20e5c793), WTCP(0x7b938af1, 0x215c27dc), WTCP(0x7b7361a7, 0x21d2698f), + WTCP(0x7b52c733, 0x22488c42), WTCP(0x7b31bbb2, 0x22be8f87), WTCP(0x7b103f43, 0x233472f3), WTCP(0x7aee5205, 0x23aa361a), + WTCP(0x7acbf416, 0x241fd88e), WTCP(0x7aa92596, 0x249559e6), WTCP(0x7a85e6a5, 0x250ab9b4), WTCP(0x7a623764, 0x257ff78e), + WTCP(0x7a3e17f2, 0x25f51307), WTCP(0x7a198872, 0x266a0bb5), WTCP(0x79f48904, 0x26dee12c), WTCP(0x79cf19cb, 0x27539302), + WTCP(0x79a93ae9, 0x27c820ca), WTCP(0x7982ec80, 0x283c8a1b), WTCP(0x795c2eb5, 0x28b0ce8a), WTCP(0x793501a9, 0x2924edac), + WTCP(0x790d6581, 0x2998e716), WTCP(0x78e55a62, 0x2a0cba5e), WTCP(0x78bce070, 0x2a80671b), WTCP(0x7893f7d1, 0x2af3ece2), + WTCP(0x786aa0a9, 0x2b674b49), WTCP(0x7840db1f, 0x2bda81e6), WTCP(0x7816a759, 0x2c4d9050), WTCP(0x77ec057d, 0x2cc0761e), + WTCP(0x77c0f5b3, 0x2d3332e5), WTCP(0x77957822, 0x2da5c63e), WTCP(0x77698cf3, 0x2e182fbe), WTCP(0x773d344d, 0x2e8a6efd), + WTCP(0x77106e58, 0x2efc8393), WTCP(0x76e33b3f, 0x2f6e6d16), WTCP(0x76b59b2a, 0x2fe02b1e), WTCP(0x76878e43, 0x3051bd43), + WTCP(0x765914b5, 0x30c3231d), WTCP(0x762a2eaa, 0x31345c44), WTCP(0x75fadc4d, 0x31a56850), WTCP(0x75cb1dca, 0x321646d9), + WTCP(0x759af34c, 0x3286f779), WTCP(0x756a5cff, 0x32f779c7), WTCP(0x75395b10, 0x3367cd5d), WTCP(0x7507edac, 0x33d7f1d3), + WTCP(0x74d61500, 0x3447e6c3), WTCP(0x74a3d13a, 0x34b7abc6), WTCP(0x74712288, 0x35274076), WTCP(0x743e0918, 0x3596a46c), + WTCP(0x740a8519, 0x3605d743), WTCP(0x73d696bb, 0x3674d894), WTCP(0x73a23e2d, 0x36e3a7fa), WTCP(0x736d7b9f, 0x3752450f), + WTCP(0x73384f41, 0x37c0af6d), WTCP(0x7302b945, 0x382ee6b0), WTCP(0x72ccb9db, 0x389cea72), WTCP(0x72965134, 0x390aba4f), + WTCP(0x725f7f84, 0x397855e1), WTCP(0x722844fb, 0x39e5bcc5), WTCP(0x71f0a1cc, 0x3a52ee96), WTCP(0x71b8962b, 0x3abfeaf1), + WTCP(0x7180224b, 0x3b2cb170), WTCP(0x71474660, 0x3b9941b1), WTCP(0x710e029e, 0x3c059b4f), WTCP(0x70d45738, 0x3c71bde8), + WTCP(0x709a4465, 0x3cdda919), WTCP(0x705fca59, 0x3d495c7e), WTCP(0x7024e94b, 0x3db4d7b5), WTCP(0x6fe9a16f, 0x3e201a5b), + WTCP(0x6fadf2fc, 0x3e8b240e), WTCP(0x6f71de2a, 0x3ef5f46c), WTCP(0x6f35632e, 0x3f608b13), WTCP(0x6ef88241, 0x3fcae7a1), + WTCP(0x6ebb3b9a, 0x403509b4), WTCP(0x6e7d8f72, 0x409ef0ed), WTCP(0x6e3f7e01, 0x41089ce8), WTCP(0x6e010780, 0x41720d46), + WTCP(0x6dc22c28, 0x41db41a5), WTCP(0x6d82ec32, 0x424439a6), WTCP(0x6d4347da, 0x42acf4e8), WTCP(0x6d033f58, 0x4315730c), + WTCP(0x6cc2d2e9, 0x437db3b0), WTCP(0x6c8202c6, 0x43e5b676), WTCP(0x6c40cf2c, 0x444d7aff), WTCP(0x6bff3855, 0x44b500eb), + WTCP(0x6bbd3e7f, 0x451c47dc), WTCP(0x6b7ae1e6, 0x45834f72), WTCP(0x6b3822c6, 0x45ea1750), WTCP(0x6af5015c, 0x46509f16), + WTCP(0x6ab17de7, 0x46b6e668), WTCP(0x6a6d98a4, 0x471cece7), WTCP(0x6a2951d2, 0x4782b236), WTCP(0x69e4a9ae, 0x47e835f7), + WTCP(0x699fa078, 0x484d77ce), WTCP(0x695a366f, 0x48b2775d), WTCP(0x69146bd3, 0x49173448), WTCP(0x68ce40e4, 0x497bae33), + WTCP(0x6887b5e2, 0x49dfe4c2), WTCP(0x6840cb0e, 0x4a43d799), WTCP(0x67f980a8, 0x4aa7865b), WTCP(0x67b1d6f3, 0x4b0af0ae), + WTCP(0x6769ce2f, 0x4b6e1637), WTCP(0x6721669f, 0x4bd0f69b), WTCP(0x66d8a085, 0x4c33917f), WTCP(0x668f7c25, 0x4c95e688), + WTCP(0x6645f9c0, 0x4cf7f55d), WTCP(0x65fc199a, 0x4d59bda3), WTCP(0x65b1dbf8, 0x4dbb3f02), WTCP(0x6567411d, 0x4e1c791f), + WTCP(0x651c494d, 0x4e7d6ba2), WTCP(0x64d0f4ce, 0x4ede1631), WTCP(0x648543e4, 0x4f3e7875), WTCP(0x643936d4, 0x4f9e9214), + WTCP(0x63eccde5, 0x4ffe62b6), WTCP(0x63a0095c, 0x505dea05), WTCP(0x6352e980, 0x50bd27a7), WTCP(0x63056e98, 0x511c1b47), + WTCP(0x62b798ea, 0x517ac48c), WTCP(0x626968be, 0x51d92321), WTCP(0x621ade5c, 0x523736ae), WTCP(0x61cbfa0b, 0x5294fedd), + WTCP(0x617cbc14, 0x52f27b58), WTCP(0x612d24c0, 0x534fabcb), WTCP(0x60dd3457, 0x53ac8fde), WTCP(0x608ceb22, 0x5409273e), + WTCP(0x603c496c, 0x54657194), WTCP(0x5feb4f7f, 0x54c16e8e), WTCP(0x5f99fda4, 0x551d1dd5), WTCP(0x5f485426, 0x55787f17), + WTCP(0x5ef6534f, 0x55d391ff), WTCP(0x5ea3fb6c, 0x562e563a), WTCP(0x5e514cc8, 0x5688cb75), WTCP(0x5dfe47ad, 0x56e2f15d), + WTCP(0x5daaec6a, 0x573cc79f), WTCP(0x5d573b49, 0x57964de9), WTCP(0x5d033497, 0x57ef83e9), WTCP(0x5caed8a2, 0x5848694d), + WTCP(0x5c5a27b8, 0x58a0fdc3), WTCP(0x5c052224, 0x58f940fa), WTCP(0x5bafc837, 0x595132a2), WTCP(0x5b5a1a3d, 0x59a8d26a), + WTCP(0x5b041885, 0x5a002001), WTCP(0x5aadc35e, 0x5a571b18) +}; + + +const PWord16 *const windowSlopes[1][2][8] = +{ + { /* Sine */ + { /* Radix 2 */ + NULL, + NULL, + SineWindow16, + SineWindow32, + SineWindow64, + SineWindow128, + SineWindow256, + NULL + }, + { /* 640 raster */ + NULL, /* 2.5 */ + NULL, /* 5 */ + SineWindow10, + SineWindow20, + SineWindow40, + SineWindow80, + SineWindow160, + SineWindow320 + }, + } +}; + +#define DCTIV_SINETABLE SineTable512 +#define DCTIV_SINETABLE_SIZE_LD 9 + +#define DCTIV_SINETABLE320 SineTable320 +#define DCTIV_SINETABLE320_SIZE_LD 8 + +void BASOP_getTables(const PWord16 **ptwiddle, const PWord16 **sin_twiddle, Word16 *psin_step, Word16 length) +{ + const PWord16 *twiddle; + const PWord16 *sine; + Word16 ld2_length, sin_step; + + /* Get ld2 of length - 2 + 1 + -2: because first table entry is window of size 4 + +1: because we already include +1 because of ceil(log2(length)) */ + ld2_length = sub(16 - 1 - 1, norm_s(length)); + + /* Extract sort of "eigenvalue" (the 5 left most bits) of length. */ + SWITCH((unsigned short)lshl(length, sub(15, ld2_length))) + { + case 0xa000: /* 640 */ + move16(); + move16(); + sine = DCTIV_SINETABLE320; + sin_step = shl(1, sub(DCTIV_SINETABLE320_SIZE_LD + 1, ld2_length)); + twiddle = windowSlopes[0][1][sub(ld2_length, 1)]; + BREAK; + + case 0x8000: /* radix 2 */ + move16(); + move16(); + sine = DCTIV_SINETABLE; + sin_step = shl(1, sub(DCTIV_SINETABLE_SIZE_LD + 1, ld2_length)); + twiddle = windowSlopes[0][0][sub(ld2_length, 2)]; + BREAK; + + default: /* not instrumented, probably obsolete */ + sine = NULL; + sin_step = 0; + twiddle = NULL; + BREAK; + } + + if (ptwiddle != NULL) + { + assert(twiddle != NULL || length == 0); + move16(); + *ptwiddle = twiddle; + } + + if (sin_twiddle != NULL) + { + move16(); + *sin_twiddle = sine; + } + if (psin_step != NULL) + { + assert(sin_step > 0 || length == 0); + move16(); + *psin_step = sin_step; + } +} + +const PWord16* getSineWindowTable(Word16 length) +{ + const PWord16 *p = NULL; + + switch (length) + { + case 10: + p = SineWindow10; + BREAK; + case 16: + p = SineWindow16; + BREAK; + case 20: + p = SineWindow20; + BREAK; + case 30: + p = SineWindow30; + BREAK; + case 32: + p = SineWindow32; + BREAK; + case 40: + p = SineWindow40; + BREAK; + case 48: + p = SineWindow48; + BREAK; + case 60: + p = SineWindow60; + BREAK; + case 70: + p = SineWindow70; + BREAK; + case 96: + p = SineWindow96; + BREAK; + case 112: + p = SineWindow112; + BREAK; + case 120: + p = SineWindow120; + BREAK; + case 140: + p = SineWindow140; + BREAK; + case 180: + p = SineWindow180; + BREAK; + case 224: + p = SineWindow224; + BREAK; + case 280: + p = SineWindow280; + BREAK; + case 420: + p = SineWindow420; + BREAK; + } + + assert(p != NULL); + + return p; +} \ No newline at end of file diff --git a/lib_com/rom_basop_util.h b/lib_com/rom_basop_util.h new file mode 100644 index 000000000..18c4bf701 --- /dev/null +++ b/lib_com/rom_basop_util.h @@ -0,0 +1,54 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +/*==================================================================================== + EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 + ====================================================================================*/ + +#ifndef __BASOP_UTIL_ROM_H__ +#define __BASOP_UTIL_ROM_H__ + +#include "typedef.h" +#include "basop_util.h" + + +extern const PWord16 SineTable512[257]; +extern const PWord16 SineTable320[161]; + +/** + * \ brief Lookup for sine tables and windows. + */ + +void BASOP_getTables(const PWord16 **ptwiddle, const PWord16 **sin_twiddle, Word16 *sin_step, Word16 length); +const PWord16* getSineWindowTable(Word16 length); + +#endif diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 2282b0b3d..903657fe1 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -61,6 +61,20 @@ const int32_t brate_intermed_tbl[SIZE_BRATE_INTERMED_TBL] = ACELP_30k40, ACELP_32k, ACELP_48k, ACELP_64k, HQ_96k, HQ_128k }; +const Word16 bit_rates_div50[] = /* bit rate values / 50 to Fit in a Word16 */ +{ + ACELP_5k00 / 50, ACELP_6k15 / 50, ACELP_7k20 / 50, ACELP_8k00 / 50, ACELP_9k60 / 50, ACELP_11k60 / 50, ACELP_12k15 / 50, + ACELP_12k85 / 50, ACELP_13k20 / 50, ACELP_14k80 / 50, ACELP_16k40 / 50, ACELP_22k60 / 50, + ACELP_24k40 / 50, ACELP_29k00 / 50, ACELP_29k20 / 50, ACELP_30k20 / 50, ACELP_30k40 / 50, + ACELP_32k / 50, ACELP_48k / 50, ACELP_64k / 50, HQ_96k / 50, HQ_128k / 50 +}; + +const Word16 bit_rates_16k_div50[] = /* bit rate values / 50 to Fit in a Word16 */ +{ + ACELP_8k00 / 50, ACELP_14k80 / 50, ACELP_22k60 / 50, ACELP_24k40 / 50, ACELP_29k00 / 50, + ACELP_29k20 / 50, ACELP_30k20 / 50, ACELP_30k40 / 50, ACELP_32k / 50, ACELP_48k / 50, ACELP_64k / 50 +}; + /*----------------------------------------------------------------------------------* * Frame size and mode configuration tables *----------------------------------------------------------------------------------*/ @@ -516,6 +530,122 @@ const float inv_tbl[130] = 0.0077519380f /* last val = 1/129 */ }; +const Word16 inv_tbl_fx[146] = +{ + 0, 32767, 16384, 10923, 8192, 6554, 5462, 4681, + 4096, 3641, 3277, 2979, 2731, 2521, 2341, 2185, + 2048, 1928, 1820, 1725, 1638, 1560, 1489, 1425, + 1365, 1311, 1260, 1214, 1170, 1130, 1092, 1057, + 1024, 993, 964, 936, 910, 886, 862, 840, + 819, 799, 780, 762, 745, 728, 712, 697, + 683, 669, 655, 643, 630, 618, 607, 596, + 585, 575, 565, 555, 546, 537, 529, 520, + 512, 504, 496, 489, 482, 475, 468, 462, + 455, 449, 443, 437, 431, 426, 420, 415, + 410, 405, 400, 395, 390, 386, 381, 377, + 372, 368, 364, 360, 356, 352, 349, 345, + 341, 338, 334, 331, 328, 324, 321, 318, + 315, 312, 309, 306, 303, 301, 298, 295, + 293, 290, 287, 285, 282, 280, 278, 275, + 273, 271, 269, 266, 264, 262, 260, 258, + 256, 254, 252, 250, 248, 246, 245, 243, + 241, 239, 237, 236, 234, 232, 231, 229, + 228, 226 +}; + +const Word32 dicn_fx[40] = /* Q=14 */ +{ + 2147483647, 1518500224, + 1073741824, 759250112, + 536870912, 379625056, + 268435456, 189812528, + 134217728, 94906264, + 67108864, 47453132, + 33554432, 23726566, + 16777216, 11863283, + 8388608, 5931642, + 4194304, 2965821, + 2097152, 1482910, + 1048576, 741455, + 524288, 370728, + 262144, 185364, + 131072, 92682, + 65536, 46341, + 32768, 23170, + 16384, 11585, + 8192, 5793, + 4096, 2896 +}; + +const Word16 hvq_bwe_fac_fx[16] = /* Q15 */ +{ + 16384, 17408, 18432, 19456, + 20480, 21504, 22528, 23552, + 24576, 25600, 26624, 27648, + 28672, 29696, 30720, 31744 +}; + +const Word16 sqac_headroom_fx[146] = /* Q0 */ +{ + 0 /*not used */, 0, 0, 1, 1, 1, 1, 1, 1, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4 +}; + +const Word16 inv_N_fx[32] = /* Q15 */ +{ + 0, 1056, 2113, 3170, + 4227, 5284, 6341, 7398, + 8455, 9512, 10569, 11626, + 12683, 13740, 14797, 15854, + 16912, 17969, 19026, 20083, + 21140, 22197, 23254, 24311, + 25368, 26425, 27482, 28539, + 29596, 30653, 31710, 32767 +}; + +const Word16 band_len_harm[SFM_N_HARM_FB] = +{ + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 16, 16, 16, 16, 16, 16, 32, 32, 32, 48, 48, 48, 48, 64, 64, 64, 96 +}; + +const Word32 thren_fx[39] = /* Q8 */ +{ + 28215802, 19951584, 14107901, + 9975792, 7053951, 4987896, + 3526975, 2493948, 1763488, + 1246974, 881744, 623487, + 440872, 311744, 220436, + 155872, 110218, 77936, + 55109, 38968, 27554, + 19484, 13777, 9742, + 6889, 4871, 3444, + 2435, 1722, 1218, + 861, 609, 431, + 304, 215, 152, + 108, 76, 54 +}; + +const Word16 dicnlg2[40] = +{ + 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, + 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, + 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, + 4, 3, 2, 1, 0, -1, -2, -3, -4, -5 +}; /*----------------------------------------------------------------------------------* * LD music post-filter @@ -603,6 +733,28 @@ const float filter5_39s320_120[121] = 0.000002f }; +const Word16 filter5_39s320_120_fx[121] = /* Q15 */ +{ + 19968, 19480, 18061, 15834, 12993, 9779, 6458, 3290, + 506, -1713, -3253, -4075, -4212, -3762, -2873, -1720, + -488, 654, 1568, 2160, 2389, 2263, 1838, 1201, + 460, -275, -903, -1348, -1566, -1546, -1312, -914, + -422, 90, 547, 891, 1083, 1108, 975, 716, + 376, 9, -331, -599, -762, -805, -732, -562, + -325, -61, 192, 399, 533, 582, 546, 435, + 272, 83, -103, -259, -366, -413, -398, -328, + -218, -86, 46, 161, 243, 283, 280, 238, + 166, 77, -14, -94, -153, -185, -188, -163, + -119, -62, -3, 50, 90, 113, 117, 104, + 78, 44, 9, -23, -47, -62, -65, -58, + -45, -27, -8, 9, 21, 28, 30, 27, + 20, 13, 5, -2, -7, -9, -9, -8, + -6, -3, -1, 0, 1, 1, 1, 0, + 0 + +}; + + /*----------------------------------------------------------------------------------* * LP analysis windows *----------------------------------------------------------------------------------*/ @@ -982,6 +1134,45 @@ const float sincos_t[161] = -0.6343932747840881300f, -0.6531728506088256800f, -0.6715589761734008800f, -0.6895405650138855000f, -0.7071067690849304200f }; +const Word16 sincos_t_fx[161] = +{ + /*Q15 */ + 0, + 804, 1607, 2410, 3211, 4011, + 4808, 5602, 6392, 7179, 7961, + 8739, 9512, 10278, 11039, 11793, + 12539, 13278, 14010, 14732, 15446, + 16151, 16846, 17530, 18204, 18868, + 19519, 20159, 20787, 21403, 22005, + 22594, 23170, 23732, 24279, 24812, + 25330, 25832, 26319, 26790, 27245, + 27684, 28106, 28511, 28898, 29269, + 29621, 29956, 30273, 30572, 30852, + 31114, 31357, 31581, 31785, 31971, + 32138, 32285, 32413, 32521, 32610, + 32679, 32728, 32758, 32767, 32758, + 32728, 32679, 32610, 32521, 32413, + 32285, 32138, 31971, 31785, 31581, + 31357, 31114, 30852, 30572, 30273, + 29956, 29621, 29269, 28898, 28511, + 28106, 27684, 27245, 26790, 26319, + 25832, 25330, 24812, 24279, 23732, + 23170, 22594, 22005, 21403, 20787, + 20159, 19519, 18868, 18204, 17530, + 16846, 16151, 15446, 14732, 14010, + 13278, 12539, 11793, 11039, 10278, + 9512, 8739, 7961, 7179, 6392, + 5602, 4808, 4011, 3211, 2410, + 1607, 804, 0, -804, -1607, + -2410, -3211, -4011, -4808, -5602, + -6392, -7179, -7961, -8739, -9512, + -10278, -11039, -11793, -12539, -13278, + -14010, -14732, -15446, -16151, -16846, + -17530, -18204, -18868, -19519, -20159, + -20787, -21403, -22005, -22594, -23170, +}; + + /*----------------------------------------------------------------------------------* * Sinus & Cosinus - table for the FFT and IFFT of 1024 points, value range [0 ... sin(-5pi/4)] * dimension of the table = 641=4*256*(5/8)+1 @@ -1260,6 +1451,75 @@ static const float filter_LP12_180H[] = /* Sincfilt.m: N=180*2+1, Fmin=0, Fmax 0.00000000f }; +const Word16 filter_LP12_180H_fx[] = /* Sincfilt.m: N=180*2+1, Fmin=0, Fmax=1/12, hann( N )' */ +{ + 16384, 16196, 15641, 14741, 13533, 12067, + 10402, 8604, 6742, 4887, 3105, 1459, + 0, -1230, -2202, -2900, -3322, -3478, + -3392, -3095, -2628, -2037, -1371, -676, + 0, 618, 1143, 1550, 1822, 1954, + 1946, 1811, 1565, 1233, 842, 421, + 0, -394, -736, -1008, -1196, -1294, + -1299, -1217, -1059, -839, -576, -290, + 0, 274, 514, 707, 842, 913, + 920, 865, 755, 600, 413, 208, + 0, -197, -371, -511, -609, -662, + -667, -627, -548, -436, -300, -151, + 0, 143, 270, 371, 443, 481, + 485, 456, 398, 316, 217, 109, + 0, -104, -195, -268, -319, -346, + -348, -326, -284, -225, -155, -78, + 0, 73, 137, 189, 224, 242, + 243, 227, 198, 156, 107, 54, + 0, -50, -94, -128, -151, -163, + -163, -152, -131, -103, -70, -35, + 0, 32, 60, 82, 96, 103, + 102, 95, 81, 64, 43, 21, + 0, -19, -36, -48, -56, -59, + -58, -53, -45, -35, -23, -11, + 0, 10, 18, 24, 28, 29, + 28, 25, 21, 16, 10, 5, + 0, -4, -7, -9, -10, -10, + -9, -8, -6, -5, -3, -1, + 0, 1, 1, 2, 2, 1, + 1, 1, 0, 0, 0, 0, + 0 +}; +const Word16 filter_LP12_180H_13b_fx[] = /*Q13 Sincfilt.m: N=180*2+1, Fmin=0, Fmax=1/12, hann( N )*/ +{ + 8192, 8098, 7820, 7370, 6766, 6033, + 5201, 4302, 3371, 2443, 1553, 729, + 0, -615, -1101, -1450, -1661, -1739, + -1696, -1547, -1314, -1019, -685, -338, + 0, 309, 571, 775, 911, 977, + 973, 905, 783, 616, 421, 210, + 0, -197, -368, -504, -598, -647, + -649, -608, -529, -420, -288, -145, + 0, 137, 257, 353, 421, 457, + 460, 432, 377, 300, 206, 104, + 0, -99, -185, -255, -305, -331, + -333, -314, -274, -218, -150, -76, + 0, 72, 135, 186, 221, 240, + 242, 228, 199, 158, 109, 55, + 0, -52, -97, -134, -159, -173, + -174, -163, -142, -113, -77, -39, + 0, 37, 69, 94, 112, 121, + 121, 114, 99, 78, 53, 27, + 0, -25, -47, -64, -76, -81, + -81, -76, -66, -52, -35, -18, + 0, 16, 30, 41, 48, 52, + 51, 47, 41, 32, 21, 11, + 0, -10, -18, -24, -28, -30, + -29, -27, -23, -17, -12, -6, + 0, 5, 9, 12, 14, 14, + 14, 13, 10, 8, 5, 2, + 0, -2, -4, -5, -5, -5, + -5, -4, -3, -2, -1, -1, + 0, 0, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, + 0 +}; + static const float filter_LP15_180H[] = /* Sincfilt.m: N=180*2+1, Fmin=0, Fmax=1/15, hann( N )' */ { 1.00000000f, 0.99262960f, 0.97071645f, 0.93484826f, 0.88598337f, @@ -1301,6 +1561,76 @@ static const float filter_LP15_180H[] = /* Sincfilt.m: N=180*2+1, Fmin=0, Fmax -0.00000000f }; +const Word16 filter_LP15_180H_fx[] = /* Sincfilt.m: N=180*2+1, Fmin=0, Fmax=1/15, hann( N )' */ +{ + 16384, 16263, 15904, 15317, 14516, 13524, + 12366, 11073, 9678, 8216, 6723, 5236, + 3790, 2416, 1144, 0, -997, -1831, + -2492, -2976, -3285, -3425, -3408, -3248, + -2966, -2583, -2123, -1610, -1070, -526, + 0, 487, 919, 1281, 1564, 1761, + 1869, 1891, 1830, 1695, 1496, 1244, + 954, 641, 318, 0, -300, -569, + -799, -982, -1113, -1188, -1209, -1176, + -1094, -969, -809, -623, -420, -209, + 0, 198, 377, 531, 653, 741, + 793, 807, 786, 732, 649, 543, + 418, 282, 140, 0, -133, -253, + -356, -438, -497, -531, -540, -526, + -489, -433, -362, -278, -187, -93, + 0, 88, 167, 234, 288, 325, + 347, 352, 342, 317, 280, 233, + 179, 120, 59, 0, -56, -105, + -147, -180, -203, -215, -217, -210, + -194, -170, -141, -107, -72, -35, + 0, 33, 61, 85, 103, 116, + 122, 122, 117, 107, 93, 76, + 58, 38, 19, 0, -17, -31, + -43, -51, -57, -59, -58, -55, + -49, -42, -34, -25, -16, -8, + 0, 7, 12, 16, 19, 20, + 21, 20, 18, 16, 13, 10, + 7, 4, 2, 0, -1, -2, + -3, -3, -3, -3, -2, -2, + -1, -1, 0, 0, 0, 0, + 0 +}; + +const Word16 filter_LP15_180H_13b_fx[6 * 31] = /*Q13 Sincfilt.m: N=180*2+1, Fmin=0, Fmax=1/12, hann( N )'*/ +{ + 8192, 8132, 7952, 7658, 7258, 6762, + 6183, 5536, 4839, 4108, 3362, 2618, + 1895, 1208, 572, 0, -498, -915, + -1246, -1488, -1643, -1713, -1704, -1624, + -1483, -1291, -1061, -805, -535, -263, + 0, 244, 459, 640, 782, 880, + 935, 945, 915, 848, 748, 622, + 477, 320, 159, 0, -150, -285, + -400, -491, -556, -594, -604, -588, + -547, -485, -405, -312, -210, -104, + 0, 99, 189, 265, 327, 371, + 396, 404, 393, 366, 325, 271, + 209, 141, 70, 0, -66, -127, + -178, -219, -248, -266, -270, -263, + -245, -217, -181, -139, -94, -46, + 0, 44, 83, 117, 144, 163, + 173, 176, 171, 158, 140, 116, + 89, 60, 30, 0, -28, -53, + -74, -90, -101, -108, -109, -105, + -97, -85, -70, -54, -36, -18, + 0, 16, 31, 43, 52, 58, + 61, 61, 58, 53, 47, 38, + 29, 19, 9, 0, -8, -16, + -21, -26, -28, -29, -29, -27, + -25, -21, -17, -13, -8, -4, + 0, 3, 6, 8, 10, 10, + 10, 10, 9, 8, 6, 5, + 3, 2, 1, 0, -1, -1, + -1, -2, -2, -1, -1, -1, + -1, 0, 0, 0, 0, 0, + 0 +}; + static const float filter_LP24_90H[] = { 0.62500000f, 0.62302684f, 0.61713239f, 0.60739135f, 0.59392688f, @@ -1326,6 +1656,59 @@ static const float filter_LP24_90H[] = { -0.00000000f }; +const Word16 filter_LP24_90H_fx[] = +{ + + 10240, 10208, 10111, 9951, 9731, + 9452, 9119, 8734, 8304, 7834, + 7328, 6794, 6237, 5664, 5081, + 4495, 3913, 3339, 2780, 2241, + 1727, 1242, 791, 376, 0, + -335, -629, -880, -1089, -1256, + -1383, -1471, -1523, -1540, -1527, + -1487, -1422, -1337, -1235, -1119, + -994, -862, -727, -592, -460, + -333, -212, -101, 0, 90, + 167, 232, 285, 325, 354, + 371, 378, 376, 366, 349, + 326, 299, 269, 236, 203, + 171, 139, 109, 81, 56, + 34, 15, 0, -12, -21, + -27, -30, -31, -31, -29, + -26, -22, -18, -14, -10, + -7, -4, -2, -1, 0, + 0, 0, 0, 0, 0, + 0, + 0 + +}; + +const Word16 filter_LP24_90H_13b_fx[] = +{ + + 5120, 5104, 5056, 4976, 4865, + 4726, 4559, 4367, 4152, 3917, + 3664, 3397, 3119, 2832, 2541, + 2248, 1956, 1669, 1390, 1120, + 863, 621, 396, 188, 0, + -168, -315, -440, -545, -628, + -691, -735, -761, -770, -764, + -743, -711, -668, -617, -560, + -497, -431, -364, -296, -230, + -166, -106, -51, 0, 45, + 84, 116, 143, 163, 177, + 186, 189, 188, 183, 174, + 163, 149, 134, 118, 102, + 85, 69, 54, 40, 28, + 17, 8, 0, -6, -10, + -13, -15, -16, -15, -14, + -13, -11, -9, -7, -5, + -3, -2, -1, 0, 0, + 0, 0, 0, 0, 0, + 0, + 0 +}; + static const float filter_LP3_90H[] = /* Sincfilt.m: N=90*2+1, Fmin=0, Fmax=1/3, hann( N )' */ { @@ -1347,6 +1730,26 @@ static const float filter_LP3_90H[] = /* Sincfilt.m: N=90*2+1, Fmin=0, Fmax=1/ -0.00000000f }; +const Word16 filter_LP3_90H_fx[] = /* Sincfilt.m: N=90*2+1, Fmin=0, Fmax=1/3, hann( N )' */ +{ + 16384, 13545, 6766, 0, -3371, -2689, + 0, 1907, 1661, 0, -1314, -1187, + 0, 990, 911, 0, -783, -729, + 0, 638, 598, 0, -529, -499, + 0, 445, 421, 0, -377, -357, + 0, 321, 305, 0, -274, -260, + 0, 234, 221, 0, -199, -188, + 0, 169, 159, 0, -142, -134, + 0, 119, 112, 0, -99, -93, + 0, 81, 76, 0, -66, -61, + 0, 52, 48, 0, -41, -37, + 0, 31, 28, 0, -23, -20, + 0, 16, 14, 0, -10, -9, + 0, 6, 5, 0, -3, -2, + 0, 1, 1, 0, 0, 0, + 0 +}; + static const float filter_LP15_360H[] = /* Sincfilt.m: N=360*2+1, Fmin=0, Fmax=1/15, hann( N )' */ { 1.00000000f, 0.99268640f, 0.97093867f, 0.93532989f, 0.88679510f, 0.82660196f, 0.75631099f, 0.67772690f, @@ -1397,6 +1800,58 @@ static const float filter_LP15_360H[] = /* Sincfilt.m: N=360*2+1, Fmin=0, Fmax -0.00000000f }; +const Word16 filter_LP15_360H_13b_fx[] = /* Sincfilt.m: N=360*2+1, Fmin=0, Fmax=1/15, hann( N )' */ +{ + + 8192, 8132, 7954, 7662, 7265, 6772, 6196, 5552, + 4857, 4127, 3381, 2636, 1911, 1220, 579, 0, + -506, -931, -1269, -1519, -1681, -1757, -1752, -1674, + -1533, -1339, -1104, -840, -560, -276, 0, 258, + 488, 682, 836, 946, 1008, 1024, 996, 927, + 821, 687, 529, 357, 178, 0, -170, -325, + -458, -567, -646, -694, -710, -696, -652, -581, + -489, -379, -257, -129, 0, 124, 238, 338, + 420, 481, 518, 533, 523, 492, 440, 372, + 289, 197, 99, 0, -96, -184, -262, -326, + -374, -405, -417, -410, -386, -346, -293, -228, + -156, -78, 0, 76, 147, 209, 260, 299, + 324, 334, 329, 310, 279, 236, 184, 125, + 63, 0, -62, -119, -169, -211, -243, -263, + -271, -268, -252, -227, -192, -150, -102, -52, + 0, 50, 97, 138, 173, 198, 215, 222, + 219, 207, 186, 157, 123, 84, 42, 0, + -41, -80, -113, -142, -163, -176, -182, -180, + -170, -152, -129, -101, -69, -35, 0, 34, + 65, 93, 116, 133, 144, 149, 147, 139, + 125, 106, 82, 56, 28, 0, -28, -53, + -76, -95, -109, -118, -121, -120, -113, -101, + -86, -67, -46, -23, 0, 22, 43, 61, + 77, 88, 95, 98, 97, 91, 82, 69, + 54, 37, 19, 0, -18, -35, -49, -61, + -70, -76, -78, -77, -73, -65, -55, -43, + -29, -15, 0, 14, 27, 39, 48, 55, + 60, 62, 61, 57, 51, 43, 33, 23, + 11, 0, -11, -21, -30, -37, -43, -46, + -48, -47, -44, -39, -33, -26, -17, -9, + 0, 8, 16, 23, 28, 32, 35, 36, + 35, 33, 29, 25, 19, 13, 6, 0, + -6, -12, -17, -21, -24, -25, -26, -25, + -24, -21, -18, -14, -9, -5, 0, 4, + 8, 12, 14, 16, 18, 18, 17, 16, + 14, 12, 9, 6, 3, 0, -3, -6, + -8, -10, -11, -11, -12, -11, -10, -9, + -8, -6, -4, -2, 0, 2, 3, 5, + 6, 6, 7, 7, 7, 6, 5, 4, + 3, 2, 1, 0, -1, -2, -3, -3, + -3, -3, -3, -3, -3, -3, -2, -2, + -1, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0 + +}; + static const float filter_LP30_300K[LFE_PLC_FDEL + 1] = /* 800/24000 LP filter, Kaiser(5)-windowed sinc */ { 1.000674458058088f, 0.998821736068880f, 0.993276134431268f, 0.984075242985249f, @@ -1440,40 +1895,62 @@ static const float filter_LP30_300K[LFE_PLC_FDEL + 1] = /* 800/24000 LP filter -0.000000000000000f }; -const Resampling_cfg resampling_cfg_tbl[] = +static const Word16 filter_LP30_300K_fx[LFE_PLC_FDEL + 1] = { - /* fin fout up.fact. filter coefs. filter length/2 */ - { 8000, 12800, 8, filter5_39s320_120, 15, RS_INV_FAC }, - { 12800, 8000, 5, filter5_39s320_120, L_FILT_UP8k, RS_INV_FAC }, - { 16000, 8000, 6, filter_LP12_180H, 180/6, 0 }, - { 12800, 16000, 15, filter_LP15_180H, L_FILT_UP16k, 0 }, - { 12800, 32000, 15, filter_LP15_180H, L_FILT_UP32k, 0 }, - { 12800, 48000, 15, filter_LP15_180H, L_FILT_UP48k, 0 }, - - { 16000, 12800, 12, filter_LP15_180H, L_FILT16k, 0 }, - { 16000, 32000, 12, filter_LP12_180H, L_FILT16k, 0 }, - { 16000, 48000, 12, filter_LP12_180H, L_FILT16k, 0 }, - - { 32000, 12800, 6, filter_LP15_180H, L_FILT32k, 0 }, - { 32000, 16000, 6, filter_LP12_180H, L_FILT32k, 0 }, - { 32000, 25600, 12, filter_LP15_360H, L_FILT32k, 0 }, - { 32000, 48000, 3, filter_LP3_90H, L_FILT32k, 0 }, - - { 48000, 12800, 4, filter_LP15_180H, L_FILT48k, 0 }, - { 48000, 16000, 4, filter_LP12_180H, L_FILT48k, 0 }, - { 48000, 25600, 8, filter_LP15_360H, L_FILT48k, 0 }, - { 48000, 32000, 2, filter_LP3_90H, L_FILT48k, 0 }, - - /* configs with NB 4kHz low-pass */ - { 16000, 12800, 12, filter_LP24_90H, L_FILT16k, 0 }, - { 32000, 12800, 6, filter_LP24_90H, L_FILT32k, 0 }, - { 48000, 12800, 4, filter_LP24_90H, L_FILT48k, 0 }, +16395,16364,16273,16123,15913,15646,15323,14947,14520,14045,13524,12963,12363,11730,11067,10379,9669, +8943,8205,7460,6712,5965,5225,4495,3779,3082,2408,1759,1140,552,0,-515,-991,-1426,-1819,-2169,-2475, +-2736,-2953,-3126,-3257,-3345,-3392,-3400,-3371,-3307,-3210,-3083,-2928,-2749,-2547,-2327,-2091,-1842, +-1584,-1319,-1051,-782,-515,-254,0,244,476,695,897,1083,1249,1397,1523,1628,1712,1774,1815,1834,1833, +1811,1771,1712,1637,1546,1442,1325,1197,1060,916,767,614,459,304,150,0,-145,-285,-417,-541,-655,-758, +-850,-930,-997,-1051,-1092,-1119,-1134,-1136,-1125,-1102,-1068,-1023,-968,-904,-832,-753,-668,-578, +-484,-388,-290,-192,-95,0,92,181,266,345,418,484,543,594,638,672,699,717,727,728,721,707,685,656,621,580, +534,483,428,371,311,249,186,123,61,0,-59,-116,-170,-220,-267,-309,-347,-379,-407,-429,-445,-456,-462,-463, +-458,-448,-434,-416,-393,-367,-337,-305,-270,-233,-195,-156,-117,-77,-38,0,37,72,106,137,166,192,215,234,251, +264,274,280,283,283,280,274,264,253,238,222,204,184,162,140,117,93,69,46,22,0,-21,-42,-62,-80,-97,-112,-125,-136, +-146,-153,-158,-161,-163,-162,-160,-156,-150,-143,-135,-125,-114,-103,-91,-78,-65,-51,-38,-25,-12,0,11,23,33,43, +52,59,66,72,76,80,82,84,84,83,82,79,76,72,67,62,57,51,44,38,31,25,18,12,5,0,-5,-10,-15,-19,-23,-27,-29,-32,-34, +-35,-36,-36,-36,-35,-34,-33,-31,-29,-27,-24,-22,-19,-17,-14,-11,-9,-6,-4,-2,0 + +}; + +const Resampling_cfg resampling_cfg_tbl[] = +{ + /* fin fout up.fact. den.fac. len.out filter coefs. filter length/2 filter mem./2 flags */ + { 8000, 8000, 12800, 12800, 8, 8, 5, 256, filter5_39s320_120, filter5_39s320_120_fx, 15, 15, RS_INV_FAC, RS_INV_FAC }, + { 12800, 12800, 8000, 8000, 5, 5, 8, 160, filter5_39s320_120, filter5_39s320_120_fx, L_FILT_UP8k, L_FILT_UP8k, RS_INV_FAC, RS_INV_FAC }, + { 16000, 16000, 8000, 8000, 6, 6, 12, 160, filter_LP12_180H, filter_LP12_180H_fx, 180 / 6, 180 / 6, 0, 0 }, + { 12800, 12800, 16000, 16000, 15, 15, 12, 320, filter_LP15_180H, filter_LP15_180H_fx, L_FILT_UP16k, L_FILT_UP16k, 0, 0 }, + { 12800, 12800, 32000, 32000, 15, 15, 6, 640, filter_LP15_180H, filter_LP15_180H_fx, L_FILT_UP32k, L_FILT_UP32k, 0, 0 }, + { 12800, 12800, 48000, 48000, 15, 15, 4, 960, filter_LP15_180H, filter_LP15_180H_fx, L_FILT_UP48k, L_FILT_UP48k, 0, 0 }, + + { 16000, 16000, 12800, 12800, 12, 12, 15, 256, filter_LP15_180H, filter_LP15_180H_fx, L_FILT16k, L_FILT16k, 0, 0 }, + { 16000, 16000, 32000, 32000, 12, 12, 6, 640, filter_LP12_180H, filter_LP12_180H_fx, L_FILT16k, L_FILT16k, 0, 0 }, + { 16000, 16000, 48000, 48000, 12, 12, 4, 960, filter_LP12_180H, filter_LP12_180H_fx, L_FILT16k, L_FILT16k, 0, 0 }, + + { 32000, 32000, 12800, 12800, 6, 6, 15, 256, filter_LP15_180H, filter_LP15_180H_13b_fx, L_FILT32k, L_FILT32k, 0, 0 }, + { 32000, 32000, 16000, 16000, 6, 6, 12, 320, filter_LP12_180H, filter_LP12_180H_13b_fx, L_FILT32k, L_FILT32k, 0, 0 }, + { 32000, 32000, 25600, 25600, 12, 12, 15, 512, filter_LP15_360H, filter_LP15_360H_13b_fx, L_FILT32k, L_FILT32k, 0, 0 }, + { 32000, 32000, 48000, 48000, 3, 3, 2, 960, filter_LP3_90H, filter_LP3_90H_fx, L_FILT32k, L_FILT32k, 0, 0 }, + + { 48000, 48000, 12800, 12800, 4, 4, 15, 256, filter_LP15_180H, filter_LP15_180H_13b_fx, L_FILT48k, L_FILT48k, 0, 0 }, + { 48000, 48000, 16000, 16000, 4, 4, 12, 320, filter_LP12_180H, filter_LP12_180H_13b_fx, L_FILT48k, L_FILT48k, 0, 0 }, + { 48000, 48000, 25600, 25600, 8, 8, 15, 512, filter_LP15_360H, filter_LP15_360H_13b_fx, L_FILT48k, L_FILT48k, 0, 0 }, + { 48000, 48000, 32000, 32000, 2, 2, 3, 640, filter_LP3_90H, filter_LP3_90H_fx, L_FILT48k, L_FILT48k, 0, 0 }, + + /* configs with NB 4kHz low-pass */ + { 16000, 16000, 12800, 12800, 12, 12, 15, 256, filter_LP24_90H, filter_LP24_90H_fx, L_FILT16k, L_FILT16k, 0, 0 }, + { 32000, 32000, 12800, 12800, 6, 6, 15, 256, filter_LP24_90H, filter_LP24_90H_13b_fx, L_FILT32k, L_FILT32k, 0, 0 }, + { 48000, 48000, 12800, 12800, 4, 4, 15, 256, filter_LP24_90H, filter_LP24_90H_13b_fx, L_FILT48k, L_FILT48k, 0, 0 }, /* entry for LFE PLC */ - { 1600, 48000, 30, filter_LP30_300K, LFE_PLC_FDEL/30, 0 }, - { 0, 0, 0, 0, 0, 0 } /* trailing entry (just to calculate the length of this table) */ + { 1600, 1600, 48000, 48000, 30, 30, 1, 960, filter_LP30_300K, filter_LP30_300K_fx, LFE_PLC_FDEL/30,LFE_PLC_FDEL / 30, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } /* trailing entry (just to calculate the length of this table) */ }; +//den fac value for last entry is calculated as den.fac = (num.fac*fin)/fout +//lg_out value for last entry is calculated as = fout/50 = ((fin/50)*num.fac)/den.fac +//filter_LP30_300K_fx has been calculated with Q14 + /*----------------------------------------------------------------------------------* * LSP interpolation coefficients *----------------------------------------------------------------------------------*/ @@ -1501,12 +1978,19 @@ const float interpol_frac_16k[NB_SUBFR16k] = { 0.2f, 0.4f, 0.6f, 0.8f, 1.0f }; +const Word16 interpol_frac_16k_fx[NB_SUBFR16k] = { 6554, 13107, 19661, 26214, 32767 }; + const float interpol_frac_mid[NB_SUBFR*3] = { 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f }; +const Word16 interpol_frac_mid_fx[NB_SUBFR * 3] = { 16384, 16384, 0, + 0, 32767, 0, + 0, 16384, 16384, + 0, 0, 32767 +}; const float interpol_frac_mid_16k[NB_SUBFR16k*3] = { 0.55f, 0.45f, 0.0f, @@ -1515,7 +1999,12 @@ const float interpol_frac_mid_16k[NB_SUBFR16k*3] = { 0.0f, 0.35f, 0.65f, 0.0f, 0.0f, 1.0f }; - +const Word16 interpol_frac_mid_16k_fx[NB_SUBFR16k * 3] = { 18022, 14746, 0, + 4915, 27853, 0, + 0, 24576, 8192, + 0, 11469, 21299, + 0, 0, 32767 +}; const float interpol_frac_mid_relaxprev_12k8[NB_SUBFR*3] = { 0.0f, 0.7f, 0.3f, 0.0f, 0.0f, 1.0f, @@ -1523,12 +2012,23 @@ const float interpol_frac_mid_relaxprev_12k8[NB_SUBFR*3] = { 0.0f, 0.0f, 1.0f }; +const Word16 interpol_frac_mid_relaxprev_12k8_fx[NB_SUBFR * 3] = { 0, 22938, 9830, + 0, 0, 32767, + 0, 0, 32767, + 0, 0, 32767 +}; const float interpol_frac_mid_FEC[NB_SUBFR*3] = { 0.25f, 0.55f, 0.20f, 0.00f, 0.70f, 0.30f, 0.00f, 0.45f, 0.55f, 0.00f, 0.00f, 1.00f }; +const Word16 interpol_frac_mid_FEC_fx[NB_SUBFR * 3] = { 8192, 18022, 6554, + 0, 22938, 9830, + 0, 14746, 18022, + 0, 0, 32767 +}; + const float interpol_frac_mid_relaxprev_pred_12k8[NB_SUBFR*3] = { 0.15f, 0.70f, 0.15f, @@ -1536,6 +2036,11 @@ const float interpol_frac_mid_relaxprev_pred_12k8[NB_SUBFR*3] = { 0.00f, 0.50f, 0.50f, 0.00f, 0.0f, 1.00f }; +const Word16 interpol_frac_mid_relaxprev_pred_12k8_fx[NB_SUBFR * 3] = { 4915, 22938, 4915, + 1638, 21299, 9830, + 0, 16384, 16384, + 0, 0, 32767 +}; const float interpol_frac_mid_relaxprev_16k[NB_SUBFR16k*3] = { 0.0f, 0.7f, 0.3f, @@ -1544,6 +2049,13 @@ const float interpol_frac_mid_relaxprev_16k[NB_SUBFR16k*3] = { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f }; +const Word16 interpol_frac_mid_relaxprev_16k_fx[NB_SUBFR16k * 3] = { 0, 22938, 9830, + 0, 0, 32767, + 0, 0, 32767, + 0, 0, 32767, + 0, 0, 32767 +}; + const float interpol_frac_mid_16k_FEC[NB_SUBFR16k*3] = { 0.4f, 0.40f, 0.2f, @@ -1552,6 +2064,12 @@ const float interpol_frac_mid_16k_FEC[NB_SUBFR16k*3] = { 0.0f, 0.15f, 0.85f, 0.0f, 0.00f, 1.00f }; +const Word16 interpol_frac_mid_16k_FEC_fx[NB_SUBFR16k * 3] = { 13107, 13107, 6554, + 0, 26214, 6554, + 0, 21299, 11469, + 0, 4915, 27853, + 0, 0, 32767 +}; const float interpol_frac_mid_relaxprev_pred_16k[NB_SUBFR16k*3] = { 0.15f, 0.70f, 0.15f, @@ -1560,6 +2078,12 @@ const float interpol_frac_mid_relaxprev_pred_16k[NB_SUBFR16k*3] = { 0.00f, 0.15f, 0.85f, 0.00f, 0.0f, 1.00f }; +const Word16 interpol_frac_mid_relaxprev_pred_16k_fx[NB_SUBFR16k * 3] = { 4915, 22938, 4915, + 1638, 21299, 9830, + 0, 16384, 16384, + 0, 4915, 27853, + 0, 0, 32767 +}; /*----------------------------------------------------------------------------------* * Innovative codebook @@ -1572,47 +2096,47 @@ const PulseConfig PulseConfTable[] = * ---> "fixed" + "tried-pair-pos"*2 = pulses & 0xfe * ---> tracks with pulses % 3 == 0, have always TRACKPOS_FIXED_FIRST */ /* bits,iter,alp,pulses,fixed,tried-pair-pos,codetrack */ - { 7, 4, 2.0f, 1, 0, {8}, TRACKPOS_FREE_ONE }, /* 7 bits, 1 pulses, 4 tracks, 1000 free track */ - { 10, 4, 2.0f, 2, 0, {8}, TRACKPOS_FIXED_EVEN }, /* 10 bits, 2 pulses, 4 tracks 1010 (used only even tracks designed for NB) */ - { 12, 4, 2.0f, 2, 0, {8}, TRACKPOS_FIXED_TWO }, /* 12 bits, 2 pulses, 2 tracks 11 used all tracks ala AMR-WB 6.6 */ - { 15, 4, 2.0f, 3, 0, {8}, TRACKPOS_FIXED_FIRST }, /* 15 bits, 3 pulses, 4 tracks 1110 fixed track to first ? */ - { 17, 6, 2.0f, 3, 0, {8}, TRACKPOS_FREE_THREE }, /* 17 bits, 3 pulses, 4 tracks (used all tracks) - 1110, 1101, 1011, 0111 */ - { 20, 4, 2.0f, 4, 0, {4, 8}, TRACKPOS_FIXED_FIRST }, /* 20 bits, 4 pulses, 4 tracks 1111 */ - { 24, 4, 2.0f, 5, 0, {4, 8}, TRACKPOS_FIXED_FIRST }, /* 24 bits, 5 pulses, 4 tracks 2111 fixed track to first */ - { 26, 4, 2.0f, 5, 0, {4, 8}, TRACKPOS_FREE_ONE }, /* 26 bits, 5 pulses, 4 tracks 2111 one free track ? */ - { 28, 4, 1.5f, 6, 0, {4, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 28 bits, 6 pulses, 4 tracks 2211 */ - { 30, 4, 1.5f, 6, 0, {4, 8, 8}, TRACKPOS_FIXED_TWO }, /* 30 bits, 6 pulses, 4 tracks 2211 free consecutive track positions ? */ - { 32, 4, 1.5f, 7, 0, {4, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 32 bits, 6 pulses, 4 tracks 2221 fixed ?*/ - { 34, 4, 1.5f, 7, 0, {4, 8, 8}, TRACKPOS_FREE_THREE }, /* 34 bits, 6 pulses, 4 tracks 2221 free track positions ? */ - { 36, 4, 1.0f, 8, 2, {4, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 36 bits, 8 pulses, 4 tracks 2222 */ - { 40, 4, 1.0f, 9, 2, {4, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 40 bits, 9 pulses, 4 tracks 3222 fixed ?*/ - { 43, 4, 1.0f, 10, 2, {4, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 44 bits, 10 pulses, 4 tracks 3322 */ - { 46, 4, 1.0f, 10, 2, {4, 6, 8, 8}, TRACKPOS_FIXED_TWO }, /* 46 bits, 10 pulses, 4 tracks 3322 free consecutive tracks ? */ - { 47, 4, 1.0f, 11, 2, {4, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 47 bits, 10 pulses, 4 tracks 3332 fixed ? */ - { 49, 4, 1.0f, 11, 2, {4, 6, 8, 8}, TRACKPOS_FREE_THREE }, /* 49 bits, 10 pulses, 4 tracks 3332 free three track positions ? */ - { 50, 4, 1.0f, 12, 4, {4, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 50 bits, 12 pulses, 4 tracks 3333 */ - { 53, 4, 1.0f, 13, 4, {4, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 53 bits, 13 pulses, 4 tracks 4333 fixed ? */ - { 55, 4, 1.0f, 13, 4, {4, 6, 8, 8}, TRACKPOS_FREE_ONE }, /* 55 bits, 13 pulses, 4 tracks 4333 free one ? */ - { 56, 4, 1.0f, 14, 4, {4, 6, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 56 bits, 14 pulses, 4 tracks 4433 fixed ?!?! */ - { 58, 4, 1.0f, 14, 4, {4, 6, 6, 8, 8}, TRACKPOS_FIXED_TWO }, /* 58 bits, 14 pulses, 4 tracks 4433 free consecutive ? */ - { 59, 4, 1.0f, 15, 4, {4, 6, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 59 bits, 15 pulses, 4 tracks 4443 fixed ? */ - { 61, 4, 1.0f, 15, 4, {4, 6, 6, 8, 8}, TRACKPOS_FREE_THREE }, /* 61 bits, 15 pulses, 4 tracks 4443 free ? */ - { 62, 3, 0.8f, 16, 4, {4, 4, 6, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 62 bits, 16 pulses, 4 tracks 4444 */ - { 65, 3, 0.8f, 17, 4, {4, 4, 6, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 65 bits, 17 pulses, 4 tracks 5444 fixed ?*/ - { 68, 3, 0.75f, 18, 4, {2, 3, 4, 5, 6, 7, 8}, TRACKPOS_FIXED_FIRST }, /* 68 bits, 18 pulses, 4 tracks 5544 */ - { 70, 3, 0.75f, 19, 4, {2, 3, 4, 5, 6, 7, 8}, TRACKPOS_FIXED_FIRST }, /* 70 bits, 19 pulses, 4 tracks 5554 fixed ? */ - { 73, 3, 0.75f, 20, 4, {2, 3, 4, 5, 6, 7, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 73 bits, 20 pulses, 4 tracks 5555 fixed ? */ - { 75, 3, 0.75f, 21, 4, {2, 3, 4, 5, 6, 7, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 75 bits, 21 pulses, 4 tracks 6555 fixed ? */ - { 78, 3, 0.75f, 22, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 78 bits, 22 pulses, 4 tracks 6655 fixed ? */ - { 80, 3, 0.75f, 23, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 80 bits, 23 pulses, 4 tracks 6665 fixed ? */ - { 83, 2, 0.30f, 24, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 83 bits, 24 pulses, 4 tracks 6666 */ - { 85, 2, 0.30f, 25, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 85 bits, 25 pulses, 4 tracks 7666 */ - { 87, 2, 0.25f, 26, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 87 bits, 26 pulses, 4 tracks 7766 */ - { 89, 2, 0.25f, 27, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 89 bits, 27 pulses, 4 tracks 7776 */ - { 92, 2, 0.25f, 28, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 92 bits, 28 pulses, 4 tracks 7777 */ - { 94, 2, 0.25f, 29, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 94 bits, 29 pulses, 4 tracks 8777 */ - { 96, 1, 0.20f, 30, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 96 bits, 30 pulses, 4 tracks 8877 */ - { 98, 1, 0.20f, 31, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 98 bits, 31 pulses, 4 tracks 8887 */ + { 7, 4, 2.0f, 16384/*2.0f Q13*/, 1, 0, {8}, TRACKPOS_FREE_ONE }, /* 7 bits, 1 pulses, 4 tracks, 1000 free track */ + { 10, 4, 2.0f, 16384/*2.0f Q13*/, 2, 0, {8}, TRACKPOS_FIXED_EVEN }, /* 10 bits, 2 pulses, 4 tracks 1010 (used only even tracks designed for NB) */ + { 12, 4, 2.0f, 16384/*2.0f Q13*/, 2, 0, {8}, TRACKPOS_FIXED_TWO }, /* 12 bits, 2 pulses, 2 tracks 11 used all tracks ala AMR-WB 6.6 */ + { 15, 4, 2.0f, 16384/*2.0f Q13*/, 3, 0, {8}, TRACKPOS_FIXED_FIRST }, /* 15 bits, 3 pulses, 4 tracks 1110 fixed track to first ? */ + { 17, 6, 2.0f, 16384/*2.0f Q13*/, 3, 0, {8}, TRACKPOS_FREE_THREE }, /* 17 bits, 3 pulses, 4 tracks (used all tracks) - 1110, 1101, 1011, 0111 */ + { 20, 4, 2.0f, 16384/*2.0f Q13*/, 4, 0, {4, 8}, TRACKPOS_FIXED_FIRST }, /* 20 bits, 4 pulses, 4 tracks 1111 */ + { 24, 4, 2.0f, 16384/*2.0f Q13*/, 5, 0, {4, 8}, TRACKPOS_FIXED_FIRST }, /* 24 bits, 5 pulses, 4 tracks 2111 fixed track to first */ + { 26, 4, 2.0f, 16384/*2.0f Q13*/, 5, 0, {4, 8}, TRACKPOS_FREE_ONE }, /* 26 bits, 5 pulses, 4 tracks 2111 one free track ? */ + { 28, 4, 1.5f, 12288/*1.5f Q13*/, 6, 0, {4, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 28 bits, 6 pulses, 4 tracks 2211 */ + { 30, 4, 1.5f, 12288/*1.5f Q13*/, 6, 0, {4, 8, 8}, TRACKPOS_FIXED_TWO }, /* 30 bits, 6 pulses, 4 tracks 2211 free consecutive track positions ? */ + { 32, 4, 1.5f, 12288/*1.5f Q13*/, 7, 0, {4, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 32 bits, 6 pulses, 4 tracks 2221 fixed ?*/ + { 34, 4, 1.5f, 12288/*1.5f Q13*/, 7, 0, {4, 8, 8}, TRACKPOS_FREE_THREE }, /* 34 bits, 6 pulses, 4 tracks 2221 free track positions ? */ + { 36, 4, 1.0f, 8192/*1.0f Q13*/, 8, 2, {4, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 36 bits, 8 pulses, 4 tracks 2222 */ + { 40, 4, 1.0f, 8192/*1.0f Q13*/, 9, 2, {4, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 40 bits, 9 pulses, 4 tracks 3222 fixed ?*/ + { 43, 4, 1.0f, 8192/*1.0f Q13*/, 10, 2, {4, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 44 bits, 10 pulses, 4 tracks 3322 */ + { 46, 4, 1.0f, 8192/*1.0f Q13*/, 10, 2, {4, 6, 8, 8}, TRACKPOS_FIXED_TWO }, /* 46 bits, 10 pulses, 4 tracks 3322 free consecutive tracks ? */ + { 47, 4, 1.0f, 8192/*1.0f Q13*/, 11, 2, {4, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 47 bits, 10 pulses, 4 tracks 3332 fixed ? */ + { 49, 4, 1.0f, 8192/*1.0f Q13*/, 11, 2, {4, 6, 8, 8}, TRACKPOS_FREE_THREE }, /* 49 bits, 10 pulses, 4 tracks 3332 free three track positions ? */ + { 50, 4, 1.0f, 8192/*1.0f Q13*/, 12, 4, {4, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 50 bits, 12 pulses, 4 tracks 3333 */ + { 53, 4, 1.0f, 8192/*1.0f Q13*/, 13, 4, {4, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 53 bits, 13 pulses, 4 tracks 4333 fixed ? */ + { 55, 4, 1.0f, 8192/*1.0f Q13*/, 13, 4, {4, 6, 8, 8}, TRACKPOS_FREE_ONE }, /* 55 bits, 13 pulses, 4 tracks 4333 free one ? */ + { 56, 4, 1.0f, 8192/*1.0f Q13*/, 14, 4, {4, 6, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 56 bits, 14 pulses, 4 tracks 4433 fixed ?!?! */ + { 58, 4, 1.0f, 8192/*1.0f Q13*/, 14, 4, {4, 6, 6, 8, 8}, TRACKPOS_FIXED_TWO }, /* 58 bits, 14 pulses, 4 tracks 4433 free consecutive ? */ + { 59, 4, 1.0f, 8192/*1.0f Q13*/, 15, 4, {4, 6, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 59 bits, 15 pulses, 4 tracks 4443 fixed ? */ + { 61, 4, 1.0f, 8192/*1.0f Q13*/, 15, 4, {4, 6, 6, 8, 8}, TRACKPOS_FREE_THREE }, /* 61 bits, 15 pulses, 4 tracks 4443 free ? */ + { 62, 3, 0.8f, 6554/*0.8f Q13*/, 16, 4, {4, 4, 6, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 62 bits, 16 pulses, 4 tracks 4444 */ + { 65, 3, 0.8f, 6554/*0.8f Q13*/, 17, 4, {4, 4, 6, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 65 bits, 17 pulses, 4 tracks 5444 fixed ?*/ + { 68, 3, 0.75f, 6144/*0.75f Q13*/, 18, 4, {2, 3, 4, 5, 6, 7, 8}, TRACKPOS_FIXED_FIRST }, /* 68 bits, 18 pulses, 4 tracks 5544 */ + { 70, 3, 0.75f, 6144/*0.75f Q13*/, 19, 4, {2, 3, 4, 5, 6, 7, 8}, TRACKPOS_FIXED_FIRST }, /* 70 bits, 19 pulses, 4 tracks 5554 fixed ? */ + { 73, 3, 0.75f, 6144/*0.75f Q13*/, 20, 4, {2, 3, 4, 5, 6, 7, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 73 bits, 20 pulses, 4 tracks 5555 fixed ? */ + { 75, 3, 0.75f, 6144/*0.75f Q13*/, 21, 4, {2, 3, 4, 5, 6, 7, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 75 bits, 21 pulses, 4 tracks 6555 fixed ? */ + { 78, 3, 0.75f, 6144/*0.75f Q13*/, 22, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 78 bits, 22 pulses, 4 tracks 6655 fixed ? */ + { 80, 3, 0.75f, 6144/*0.75f Q13*/, 23, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 80 bits, 23 pulses, 4 tracks 6665 fixed ? */ + { 83, 2, 0.30f, 2458/*0.30f Q13*/, 24, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 83 bits, 24 pulses, 4 tracks 6666 */ + { 85, 2, 0.30f, 2458/*0.30f Q13*/, 25, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 85 bits, 25 pulses, 4 tracks 7666 */ + { 87, 2, 0.25f, 2048/*0.25f Q13*/, 26, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 87 bits, 26 pulses, 4 tracks 7766 */ + { 89, 2, 0.25f, 2048/*0.25f Q13*/, 27, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 89 bits, 27 pulses, 4 tracks 7776 */ + { 92, 2, 0.25f, 2048/*0.25f Q13*/, 28, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 92 bits, 28 pulses, 4 tracks 7777 */ + { 94, 2, 0.25f, 2048/*0.25f Q13*/, 29, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 94 bits, 29 pulses, 4 tracks 8777 */ + { 96, 1, 0.20f, 1638/*0.20f Q13*/, 30, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 96 bits, 30 pulses, 4 tracks 8877 */ + { 98, 1, 0.20f, 1638/*0.20f Q13*/, 31, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 98 bits, 31 pulses, 4 tracks 8887 */ }; @@ -5910,93 +6434,97 @@ const float msNoiseSlopeMax[4] = { 2.f, 1.6f, 1.3f, 1.1f }; const SCALE_SETUP scaleTableStereo[SIZE_SCALE_TABLE_STEREO] = { - { 1, 0, 8000, -5.5f }, - { 1, 8000, 9600, -5.0f }, - { 1, 9600, 13200, -4.0f }, - { 1, 13200, 16400, -3.0f }, - { 1, 16400, 24400, -1.6f }, - { 1, 24400, 32000, -0.2f }, - { 1, 32000,512001, 0.0f }, - - { 2, 0, 8000, -0.9f }, - { 2, 8000, 9600, -0.65f}, - { 2, 9600, 13200, -2.0f }, - { 2, 13200, 16400, -3.0f }, - { 2, 16400, 24400, -0.8f }, - { 2, 24400, 32000, -0.25f}, - { 2, 32000,512001, 0.0f } -}; - + { 1, 0, 8000, -5.5f, -704/*-5.5f Q7*/ }, + { 1, 8000, 9600, -5.0f, -640/*-5.0f Q7*/ }, + { 1, 9600, 13200, -4.0f, -512/*-4.0f Q7*/ }, + { 1, 13200, 16400, -3.0f, -384/*-3.0f Q7*/ }, + { 1, 16400, 24400, -1.6f, -204/*-1.6f Q7*/ }, + { 1, 24400, 32000, -0.2f, -26/*-1.6f Q7*/ }, + { 1, 32000,512001, 0.0f, 0 /*0.0f Q7*/ }, + + { 2, 0, 8000, -0.9f , -115/*-0.9f Q7*/}, + { 2, 8000, 9600, -0.65f, -83/*-0.65f Q7*/}, + { 2, 9600, 13200, -2.0f , -256/*-2.0f Q7*/}, + { 2, 13200, 16400, -3.0f , -384/*-3.0f Q7*/}, + { 2, 16400, 24400, -0.8f , -102/*-0.8f Q7*/}, + { 2, 24400, 32000, -0.25f, -32/*-0.25f Q7*/}, + { 2, 32000,512001, 0.0f , 0/* 0.0f Q7*/} +}; +#if 0 +//scaleTableStereo recheck extended from scaleTableMono +#endif const SCALE_SETUP scaleTableMono[SIZE_SCALE_TABLE_MONO] = { - { 0, 0, 8000, -5.5f }, - { 0, 8000, 9600, -5.0f }, - { 0, 9600, 13200, -4.0f }, - { 0, 13200, 16400, -3.0f }, - { 0, 16400, 24400, -1.5f }, - { 0, 24400,128001, -0.5f }, - - { 1, 0, 8000, -5.5f }, - { 1, 8000, 9600, -5.0f }, - { 1, 9600, 13200, -1.55f}, - { 1, 13200, 16400, -3.0f }, - { 1, 16400, 24400, -0.6f }, - { 1, 24400, 32000, -0.2f }, - { 1, 32000,128001, 0.0f }, - - { 2, 0, 8000, -0.9f }, - { 2, 8000, 9600, -0.65f}, - { 2, 9600, 13200, -2.0f }, - { 2, 13200, 16400, -3.0f }, - { 2, 16400, 24400, -0.8f }, - { 2, 24400, 32000, -0.25f}, - { 2, 32000,128001, 0.0f } + { 0, 0, 8000, -5.5f, -704/*-5.5f Q7*/ }, + { 0, 8000, 9600, -5.0f, -640/*-5.0f Q7*/ }, + { 0, 9600, 13200, -4.0f, -512/*-4.0f Q7*/ }, + { 0, 13200, 16400, -3.0f, -384/*-3.0f Q7*/ }, + { 0, 16400, 24400, -1.5f, -192/*-1.5f Q7*/ }, + { 0, 24400,128001, -0.5f, -64/*-0.5f Q7*/ }, + + { 1, 0, 8000, -5.5f , -704/*-5.5f Q7*/}, + { 1, 8000, 9600, -5.0f , -640/*-5.0f Q7*/}, + { 1, 9600, 13200, -1.55f, -198/*-1.55f Q7*/}, + { 1, 13200, 16400, -3.0f , -384/*-3.0f Q7*/}, + { 1, 16400, 24400, -0.6f , -77/*-0.6f Q7*/}, + { 1, 24400, 32000, -0.2f , -26/*-0.2f Q7*/}, + { 1, 32000,128001, 0.0f , 0/* 0.0f Q7*/}, + + { 2, 0, 8000, -0.9f , -115/*-0.9f Q7*/}, + { 2, 8000, 9600, -0.65f, -83/*-0.65f Q7*/}, + { 2, 9600, 13200, -2.0f , -256/*-2.0f Q7*/}, + { 2, 13200, 16400, -3.0f , -384/*-3.0f Q7*/}, + { 2, 16400, 24400, -0.8f , -102/*-0.8f Q7*/}, + { 2, 24400, 32000, -0.25f, -32/*-0.25f Q7*/}, + { 2, 32000,128001, 0.0f , 0/* 0.0f Q7*/} }; const SCALE_SETUP scaleTable_cn_only[SIZE_SCALE_TABLE_CN] = { - { 0, 0, 8000, -3.5f }, - { 0, 8000, 9600, -3.0f }, - { 0, 9600, 13200, -2.5f }, - { 0, 13200, 16400, -2.0f }, - { 0, 16400,128001, 0.0f }, - - { 1, 0, 8000, -3.0f }, - { 1, 8000, 9600, -2.5f }, - { 1, 9600, 13200, -1.5f }, - { 1, 13200, 16400, -2.5f }, - { 1, 16400, 24400, -0.5f }, - { 1, 24400,128001, 0.0f }, - - { 2, 0, 8000, -2.5f }, - { 2, 8000, 9600, -2.5f }, - { 2, 9600, 13200, -2.0f }, - { 2, 13200, 16400, -1.0f }, - - { 2, 16400, 24400, -0.5f }, - { 2, 24400, 32000, 0.0f }, - { 2, 32000,128001, 0.0f } -}; - + { 0, 0, 8000, -3.5f, 20295/*1.2387211385 Q14*/ /*-3.5f*/ }, + { 0, 8000, 9600, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/ }, + { 0, 9600, 13200, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/ }, + { 0, 13200, 16400, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/ }, + { 0, 16400,128001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/ }, + + { 1, 0, 8000, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/ }, + { 1, 8000, 9600, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/ }, + { 1, 9600, 13200, -1.5f, 6759/*0.4125375748 Q14*/ /*-1.5f*/ }, + { 1, 13200, 16400, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/ }, + { 1, 16400, 24400, -0.5f, 1999/*0.1220184565 Q14*/ /*-0.5f*/ }, + { 1, 24400,128001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/ }, + + { 2, 0, 8000, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/ }, + { 2, 8000, 9600, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/ }, + { 2, 9600, 13200, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/ }, + { 2, 13200, 16400, -1.0f, 4242/*0.2589254379 Q14*/ /*-1.0f*/ }, + + { 2, 16400, 24400, -0.5f, 1999/*0.1220184565 Q14*/ /*-0.5f*/ }, + { 2, 24400, 32000, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/ }, + { 2, 32000,128001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/ } +}; +#if 0 + //scaleTable_cn_dirac recheck extended from scaleTable_cn_only +#endif const SCALE_SETUP scaleTable_cn_dirac[15] = { - { 0, 0, 13200, -3.0f }, - { 0, 13200, 16400, -2.5f }, - { 0, 16400, 24400, -2.0f }, - { 0, 24400, 32000, -1.5f }, - { 0, 32000,512001, 0.0f }, + { 0, 0, 13200, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/ }, + { 0, 13200, 16400, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/ }, + { 0, 16400, 24400, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/ }, + { 0, 24400, 32000, -1.5f, 6759/*0.4125375748 Q14*/ /*-1.5f*/ }, + { 0, 32000,512001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/ }, - { 1, 0, 13200, -3.0f }, - { 1, 13200, 16400, -2.5f }, - { 1, 16400, 24400, -2.0f }, - { 1, 24400, 32000, -1.5f }, - { 1, 32000,512001, 0.0f }, + { 1, 0, 13200, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/ }, + { 1, 13200, 16400, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/ }, + { 1, 16400, 24400, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/ }, + { 1, 24400, 32000, -1.5f, 6759/*0.4125375748 Q14*/ /*-1.5f*/ }, + { 1, 32000,512001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/ }, - { 2, 0, 13200, -3.0f }, - { 2, 13200, 16400, -2.5f }, - { 2, 16400, 24400, -2.0f }, - { 2, 24400, 32000, -1.5f }, - { 2, 32000,512001, 0.0f } + { 2, 0, 13200, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/ }, + { 2, 13200, 16400, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/ }, + { 2, 16400, 24400, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/ }, + { 2, 24400, 32000, -1.5f, 6759/*0.4125375748 Q14*/ /*-1.5f*/ }, + { 2, 32000,512001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/ } }; const float scaleTable_cn_only_amrwbio[SIZE_SCALE_TABLE_CN_AMRWB][2] = { @@ -8915,10 +9443,14 @@ const float dico5_ns_28b[32*4] = 527.5430f, 471.6736f, 394.4862f, 127.2615f }; +const Word16 means_nb_31bits_ma_lsf[16] = { 861 /*336.3281f*1.28f Q1*/, 1360 /*531.2500f*1.28f Q1*/, 2270 /*886.7188f*1.28f Q1*/, 3243 /*1266.7969f*1.28f Q1*/, 4171 /*1629.2969f*1.28f Q1*/, 5052 /*1973.4375f*1.28f Q1*/, 6012 /*2348.4375f*1.28f Q1*/, 6776 /*2646.8750f*1.28f Q1*/, 7676 /*2998.4375f*1.28f Q1*/, 8428 /*3292.1875f*1.28f Q1*/, 9194 /*3591.4062f*1.28f Q1*/, 9744 /*3806.2500f*1.28f Q1*/, 10580 /*4132.8125f*1.28f Q1*/, 11911 /*4652.7344f*1.28f Q1*/, 13440 /*5250.0000f*1.28f Q1*/, 15061 /*5883.2031f*1.28f Q1*/ }; +const Word16 means_wb_31bits_ma_lsf[16] = { 818 /*319.5312f*1.28f Q1*/, 1403 /*548.0469f*1.28f Q1*/, 2392 /*934.3750f*1.28f Q1*/, 3465 /*1353.5156f*1.28f Q1*/, 4429 /*1730.0781f*1.28f Q1*/, 5428 /*2120.3125f*1.28f Q1*/, 6414 /*2505.4688f*1.28f Q1*/, 7323 /*2860.5469f*1.28f Q1*/, 8304 /*3243.7500f*1.28f Q1*/, 9221 /*3601.9531f*1.28f Q1*/, 10162 /*3969.5312f*1.28f Q1*/, 11091 /*4332.4219f*1.28f Q1*/, 12125 /*4736.3281f*1.28f Q1*/, 13153 /*5137.8906f*1.28f Q1*/, 14241 /*5562.8906f*1.28f Q1*/, 15266 /*5963.2812f*1.28f Q1*/ }; + -const float * const lsf_means[2] = { means_wb_31bits_ma_lsf, means_nb_31bits_ma_lsf }; +const Word16 *lsf_means[2] = { means_wb_31bits_ma_lsf, means_nb_31bits_ma_lsf }; +const float * const lsf_means_float[2] = { means_wb_31bits_ma_lsf_float, means_nb_31bits_ma_lsf_float }; -const lsp_unw_triplet p16_gamma0_92to1[16] = +const lsp_unw_triplet_flt p16_gamma0_92to1_float[16] = { { 0.00000f, 1.19764f, -0.59173f }, { -0.91173f, 1.79182f, -0.80921f }, @@ -8938,7 +9470,7 @@ const lsp_unw_triplet p16_gamma0_92to1[16] = { -0.47730f, 0.90959f, 0.00000f } }; -const lsp_unw_triplet p16_gamma0_94to1[16] = +const lsp_unw_triplet_flt p16_gamma0_94to1_float[16] = { { 0.00000f, 0.78925f, -0.38537f }, { -0.57154f, 1.19486f, -0.54136f }, @@ -8958,6 +9490,46 @@ const lsp_unw_triplet p16_gamma0_94to1[16] = { -0.33404f, 0.62528f, 0.00000f } }; +const lsp_unw_triplet p16_gamma0_92to1[16] = /* Q14 */ +{ + { 0, 19622, -9695 }, + { -14938, 29357, -13258 }, + { -8483, 23708, -13414 }, + { -7350, 22410, -12305 }, + { -7397, 21417, -12160 }, + { -7071, 19878, -11229 }, + { -7144, 19877, -11326 }, + { -6423, 17194, -9613 }, + { -7407, 18024, -9695 }, + { -6972, 16339, -8191 }, + { -8220, 17625, -8422 }, + { -8159, 17459, -8289 }, + { -8700, 19066, -9508 }, + { -7986, 17629, -8607 }, + { -8503, 17203, -8109 }, + { -7820, 14903, 0 } +}; + +const lsp_unw_triplet p16_gamma0_94to1[16] = /* Q14 */ +{ + { 0, 12931, -6314 }, + { -9364, 19577, -8870 }, + { -5512, 16236, -9305 }, + { -4892, 15366, -8398 }, + { -4869, 14631, -8275 }, + { -4631, 13358, -7540 }, + { -4575, 13271, -7599 }, + { -4151, 11403, -6385 }, + { -4859, 11947, -6371 }, + { -4504, 10805, -5407 }, + { -5346, 11618, -5515 }, + { -5418, 11578, -5424 }, + { -5806, 12711, -6226 }, + { -5205, 11592, -5606 }, + { -5745, 11498, -5188 }, + { -5473, 10245, 0 } +}; + const float dico_lsf_abs_8b[256*M] = { 377.3749f, 688.0079f, 1147.3799f, 1461.0438f, 1786.7794f, 2143.6711f, 2522.1946f, 2889.7402f, 3263.6023f, 3628.4624f, 4005.4351f, 4379.4170f, 4783.9556f, 5157.1753f, 5555.1797f, 5926.6816f, @@ -10696,8 +11268,8 @@ const float * const ModeMeans[] = {IANB_Ave, UVNB_Ave, SVNB_Ave, GENB_Ave, TRNB_ const float * const Predictors[] = {Predictor6, NULL, Predictor1, Predictor3, NULL, Predictor6,Predictor5, NULL, Predictor0, Predictor2, NULL, Predictor5, Predictor7, NULL, Predictor8, Predictor4, NULL, Predictor7 }; -const float means_nb_31bits_ma_lsf[16] = {336.3281f , 531.2500f , 886.7188f , 1266.7969f , 1629.2969f , 1973.4375f , 2348.4375f , 2646.8750f , 2998.4375f , 3292.1875f , 3591.4062f , 3806.2500f , 4132.8125f , 4652.7344f , 5250.0000f , 5883.2031f}; -const float means_wb_31bits_ma_lsf[16] = {319.5312f , 548.0469f , 934.3750f , 1353.5156f , 1730.0781f , 2120.3125f , 2505.4688f , 2860.5469f , 3243.7500f , 3601.9531f , 3969.5312f , 4332.4219f , 4736.3281f , 5137.8906f , 5562.8906f , 5963.2812f}; +const float means_nb_31bits_ma_lsf_float[16] = {336.3281f , 531.2500f , 886.7188f , 1266.7969f , 1629.2969f , 1973.4375f , 2348.4375f , 2646.8750f , 2998.4375f , 3292.1875f , 3591.4062f , 3806.2500f , 4132.8125f , 4652.7344f , 5250.0000f , 5883.2031f}; +const float means_wb_31bits_ma_lsf_float[16] = {319.5312f , 548.0469f , 934.3750f , 1353.5156f , 1730.0781f , 2120.3125f , 2505.4688f , 2860.5469f , 3243.7500f , 3601.9531f , 3969.5312f , 4332.4219f , 4736.3281f , 5137.8906f , 5562.8906f , 5963.2812f}; const int16_t CBsizes[] = @@ -10803,7 +11375,7 @@ const int16_t BitsVQ_p[]= }; -const int16_t predmode_tab[][6] = +const int16_t predmode_tab_float[][6] = { {1,1,2,2,0,2}, {1,1,2,2,0,2}, @@ -10811,11 +11383,613 @@ const int16_t predmode_tab[][6] = {1,1,2,1,0,1} /* should check how is the cb for audio mode at 13.2*/ }; +const Word16 predmode_tab[][6] = +{ + {1,1,2,2,0,2}, + {1,1,2,2,0,2}, + {1,-1,2,1,0,1}, + {1,1,2,1,0,2} /* should check how is the cb for audio mode at 13.2*/ +}; + const float * const Quantizers[] = {SVNB_SN1, SVNB_SN2, GETRNB_SN1, GETRNB_SN2, AUNB_SN1,SVWB_SN1, SVWB_SN2, GETRWB_SN1, GETRWB_SN2, AUWB_SN1,TRWB2_SN1, TRWB2_SN2, AUWB2_SN1, CNG_SN1, SVWB2_SN1, SVWB2_SN2 }; const float * const Quantizers_p[] = {IAA_MA1, UVD_MA1, UVD_MA2, UVWB_MA3, GESVNB_AR1, GESVNB_AR2, GESVWB_AR1, GESVWB_AR2, GEWB2_MA1,GEWB_MA1, AUWB2_MA1, SVWB2_AR1, SVWB2_AR2 }; + + +const Word16 SVNB_SN1_fx[256] = +{ + 135, 109, 135, -153, -549, 214, 416, 195, 291, 247, 100, -127, -579, -160, -66, -32, + -107, -150, -274, -149, 642, 594, 338, 183, 81, -31, -14, -150, -387, -40, -44, -18, + 73, 42, 171, 339, 213, 42, -137, -277, -379, -441, -440, -478, 270, 126, -4, 6, + -307, -479, -636, -596, -100, 83, 167, 200, 260, 376, 523, 1051, 1142, 490, 249, 108, + -148, -215, -324, -570, -917, -685, -208, 127, 285, 353, 441, 940, 1100, 458, 229, 100, + 427, 432, 548, 426, 133, 13, -9, -141, -108, -144, -195, -419, -733, -144, -109, -45, + -115, -220, -194, 661, 896, 688, 489, 351, 211, 258, 147, 30, -746, -784, -156, -95, + 16, -48, -88, -430, -798, 36, 204, 68, 174, 162, 20, 61, 627, 266, 102, 48, + -252, -370, -630, -614, 680, 1024, 869, 598, 419, 259, 193, 27, 90, 156, 53, 27, + -48, 33, 26, -227, -556, -766, -391, 231, 413, 282, 226, 89, 194, 187, 44, 30, + -204, -291, -345, -131, 125, 72, 16, -29, -106, -49, -27, 183, 714, 277, 114, 49, + -11, 205, 285, 69, -58, -207, -301, -160, -30, -2, 12, -99, -580, -178, -80, -41, + 120, 189, 281, 427, 234, 138, 124, 126, 50, 205, 121, 76, -797, -1204, -235, -133, + 63, -18, 146, 666, 480, 236, 134, -39, -97, -130, -175, -378, -746, -159, -106, -46, + 386, 399, 415, 157, -175, -282, -315, -318, -222, -225, -267, -342, 317, 152, 15, 14, + 39, 56, 71, -95, -387, -509, -595, -466, -395, -186, -24, 421, 814, 292, 127, 52 +}; + +/* An 16-by-16 matrix in Scale = 2.56f */ +const Word16 SVNB_SN2_fx[256] = +{ + -16, 111, 111, -89, -115, -404, -514, 162, 277, 41, -94, -89, 15, 31, 2, 2, + -82, -99, -25, -287, -464, 204, 18, -123, -38, 56, 109, 198, 160, 96, 41, 19, + -95, -62, -242, -415, 318, 118, -121, 44, 74, 40, 85, 114, 52, 36, 21, 8, + 29, 40, 43, 23, -202, -149, 288, 149, -20, -109, -186, -275, -127, 18, -25, -6, + 20, 36, -97, -228, 565, 508, 134, 42, -70, -237, -258, -259, -123, -9, -29, -10, + -72, -169, 492, 463, 193, 204, -13, -75, -82, -125, -181, -230, -181, -10, -40, -12, + -108, -221, -229, 648, 575, 288, 146, 1, -14, -4, -51, -120, -81, -14, -17, -5, + -199, -264, -309, 209, 8, -128, 24, -47, 87, 257, 240, 185, 93, 70, 34, 16, + 25, 82, -60, -155, -407, -615, 29, 100, -113, 32, 207, 258, 203, 111, 49, 21, + 37, 127, 95, 4, 112, -45, -217, -158, -277, -407, -304, -152, 72, 52, -6, 0, + -30, -81, -116, -416, -219, 677, 538, 328, 213, 60, -60, -109, -78, 0, -5, 0, + 9, -15, 26, 75, -175, -336, -673, -586, 238, 310, 198, 189, 212, 126, 48, 24, + -18, -4, -80, 102, 130, -116, -268, -471, -567, -104, 205, 221, 143, 81, 29, 12, + 4, 39, 65, 115, 88, 189, 136, 124, 49, 106, 37, 89, -375, -626, -114, -73, + 540, 525, 472, 221, 118, -31, 15, 7, -71, -139, -108, -93, -13, -4, -13, -8, + -44, -44, -143, -272, -525, -365, 479, 502, 312, 225, 161, 72, 28, 42, 26, 12 +}; + +const Word16 GETRNB_SN1_fx[512] = +{ + -119, -271, -427, 447, 321, 58, 37, -105, -65, 99, 106, 21, -277, 53, 9, -6, + -93, -241, -433, -826, -1028, 17, 180, 138, 320, 234, 152, 235, 973, 594, 199, 96, + -300, -474, -553, -497, -374, -231, -224, -170, -145, 51, 154, 714, 1338, 690, 271, 118, + -115, -228, -248, 9, -27, -196, -240, -269, -293, -310, -276, -254, 769, 481, 117, 59, + 172, 58, 469, 585, 512, 336, 145, -52, -167, -344, -379, -487, 285, 377, 27, 27, + 81, 34, 574, 859, 818, 702, 521, 344, 177, 23, -116, -274, -611, -78, -61, -35, + 76, 19, -104, -388, -687, 54, 279, 144, 237, 223, 110, 9, -335, 4, 3, -10, + 115, 380, 486, 446, 389, 316, 239, 249, 197, 207, 162, 141, -435, -1516, -409, -136, + -146, -348, -425, 645, 998, 790, 609, 468, 282, 287, 153, 87, -461, -592, -88, -64, + -249, -471, -835, -642, 589, 960, 887, 637, 442, 286, 242, 132, 142, 299, 99, 44, + 128, 37, -120, -314, -571, -730, -868, -558, -259, -109, 8, 413, 1145, 593, 210, 92, + 151, 331, 267, 130, -24, -89, -133, -43, -75, 57, 19, 94, -469, -796, -124, -90, + -339, -468, -292, -34, 76, 179, 231, 269, 259, 281, 275, 204, -93, 157, 53, 16, + 33, 176, 25, -201, -311, -497, -509, -242, -47, 6, 86, 48, -165, 176, 24, 8, + 27, 223, 461, 500, 479, 475, 489, 560, 635, 741, 924, 1347, 1546, 806, 277, 54, + 510, 464, 402, 114, -80, -285, -290, -321, -283, -368, -325, -424, 388, 402, 52, 38, + 521, 614, 732, 549, 428, 278, 180, 81, 14, -110, -204, -355, -649, -32, -56, -36, + 72, 26, 262, 263, 159, 113, 60, -10, -73, -121, -201, -329, -768, -61, -60, -39, + 85, 57, 116, -40, -78, -159, -154, -247, -220, -366, -331, -532, -35, 344, 0, 25, + 527, 919, 1339, 1225, 1190, 1023, 774, 577, 393, 160, -4, -184, -281, 29, -21, -12, + -230, -283, -338, -379, -313, -293, -163, -122, 15, 97, 243, 168, 361, 449, 102, 61, + 378, 369, 369, 136, 42, -72, -73, -154, -155, -260, -270, -444, -562, 173, -36, -9, + 168, 108, -36, -347, -559, -436, -254, -263, -236, -227, -247, -238, 796, 488, 123, 62, + -151, -118, 163, 452, 430, 484, 456, 418, 377, 363, 256, 183, -403, -1429, -382, -126, + -204, -366, -652, -512, 428, 353, 182, 88, -10, -94, -54, -11, 801, 527, 151, 76, + 60, 79, -169, -465, -789, -844, -55, 181, 209, 172, 210, 107, 260, 399, 91, 52, + -69, -205, -377, -164, 647, 584, 302, 151, 32, -135, -136, -223, -269, 170, 4, 5, + 38, 418, 885, 979, 990, 1027, 870, 804, 669, 537, 360, 241, -336, -1281, -338, -111, + -420, -700, -912, -622, -337, -51, 67, 173, 326, 554, 766, 1395, 1656, 894, 390, 178, + -141, -252, -507, -822, -1084, -845, -280, 20, 149, 242, 393, 951, 1428, 740, 303, 135, + -120, -37, 31, 105, 72, 99, 53, 117, 59, 171, 120, 177, -414, -993, -160, -98, + -382, -612, -631, -167, 4, 104, 130, 141, 242, 325, 348, 430, 1048, 651, 222, 109 +}; + +/* An 16-by-16 matrix in Scale = 2.56f */ +const Word16 GETRNB_SN2_fx[256] = +{ + -27, 71, 45, -4, 28, 69, 25, 94, 45, 90, 45, 87, -177, -567, -116, -59, + -208, -147, 531, 399, 199, 113, -21, -28, -34, -38, -48, -46, -47, 18, -1, -1, + 69, -20, -115, -355, -380, 388, 379, 193, 134, 37, -42, -60, -35, 29, 6, 5, + 107, 89, -98, -189, 379, 289, 68, 22, -71, -179, -187, -192, -137, 4, -17, -7, + -44, -81, -371, -448, 226, 75, -52, 43, 40, 36, 79, 120, 130, 76, 36, 15, + 131, 115, 192, 177, 25, -7, -23, -95, -132, -184, -206, -245, -200, -12, -29, -11, + 45, -25, -249, 50, -189, -358, 253, 145, -39, 27, 34, -20, -52, 13, 1, 2, + -254, -155, 23, -89, -30, 23, -23, -21, -45, -86, -92, -109, -48, 52, 3, 3, + -248, -233, 139, 213, 232, 361, 349, 401, 373, 301, 230, 207, 204, 101, 32, 14, + 491, 546, 409, 147, 34, -18, 52, 59, 48, 27, 14, 7, -1, -37, -16, -9, + 36, 41, 0, -21, -29, -64, -207, -346, -516, -355, -64, 73, 156, 94, 30, 11, + -28, -173, -278, 506, 427, 164, 111, 21, -33, -61, -78, -90, -32, 39, 4, 4, + -44, -60, -215, -373, -485, -270, 12, 151, 271, 265, 215, 178, 153, 71, 32, 17, + 110, 155, -29, -259, -218, -183, -175, -132, -85, -98, -87, -93, -77, 0, -9, -4, + -116, -14, 235, 1, -238, -398, -419, -55, 109, 77, 62, 74, 73, 47, 16, 8, + -20, -108, -219, 246, 20, -184, -328, -449, -67, 142, 125, 110, 91, 74, 28, 13 +}; + +/* An 16-by-16 matrix in Scale = 2.56f */ +const Word16 AUNB_SN1_fx[256] = +{ + -180, -79, -51, 39, 66, 99, 48, 108, 56, 127, 34, 46, -470, -845, -141, -90, + -212, 82, 284, 422, 416, 416, 313, 289, 233, 210, 108, 55, -439, -1323, -336, -123, + -9, 405, 532, 659, 710, 798, 844, 971, 1072, 1181, 1464, 1913, 2028, 1232, 549, 265, + 75, 49, 330, 493, 448, 329, 204, 67, -18, -134, -235, -400, -605, -30, -67, -36, + -9, -7, -95, -222, -322, -421, -321, -233, -110, -86, 67, -19, 3, 345, 41, 30, + 153, 34, -172, -386, -500, -548, -503, -420, -317, -207, -114, 183, 1096, 661, 198, 94, + 616, 501, 471, 220, 157, 55, 4, -161, -178, -314, -267, -389, 216, 429, 46, 38, + -559, -854, -789, -369, -153, 64, 146, 296, 388, 520, 574, 958, 1481, 898, 340, 164, + 131, 137, 116, 57, 64, -21, -38, -112, -123, -199, -214, -379, -641, 83, -53, -21, + -101, -324, -648, -801, -835, -737, -501, -296, -86, 144, 400, 1025, 1501, 861, 322, 151, + -231, -397, -512, -506, -308, -200, -127, -91, -18, 17, 94, 114, 798, 625, 161, 88, + -518, -617, -201, 103, 258, 279, 273, 267, 281, 251, 214, 114, 58, 270, 70, 31, + 17, -86, -78, -82, -22, -73, -171, -299, -334, -431, -422, -526, 517, 511, 71, 53, + 276, 182, -40, -336, -461, -93, 342, 267, 166, 18, -43, -196, -146, 236, 18, 14, + 227, 338, 224, 188, 107, 80, 57, 92, 34, 80, -5, -4, -515, -927, -174, -100, + 731, 744, 797, 675, 590, 438, 328, 215, 144, 24, -96, -239, -486, -175, -65, -41 +}; + +const Word16 SVWB_SN1_fx[256] = +{ + -71, -61, -170, -563, -962, -845, 186, 421, 282, 344, 260, 155, 186, 52, -18, -11, + -107, -139, -289, -270, 788, 615, 249, 174, -1, -24, 159, 106, -46, -183, -187, -107, + -144, -221, -215, 359, 192, -34, -186, -326, -256, -124, -49, 84, 214, 237, 186, 91, + 218, 332, 335, 41, -191, -394, -614, -543, -415, -379, -285, -153, -86, -101, -69, -13, + 587, 616, 732, 419, 270, 252, 102, 40, 53, -35, -57, -34, 19, -14, -15, -120, + -76, -222, -127, 1216, 1188, 815, 532, 320, 311, 228, 34, -59, -96, -86, -44, -38, + -176, -282, -507, -455, 1122, 1359, 965, 742, 610, 448, 474, 412, 185, 127, 127, -24, + -156, -225, 16, 458, 423, 438, 393, 400, 525, 658, 682, 681, 612, 438, 267, 68, + 89, 120, 172, 355, 195, -8, -22, -67, -110, -40, -93, -163, -382, -685, -926, -468, + -227, -362, -452, -577, -213, -22, 56, 82, 132, 216, 348, 420, 358, 299, 257, 143, + 38, -77, 117, 856, 486, 282, 16, -154, -130, -315, -618, -783, -892, -545, -88, 59, + 218, 324, 232, -162, -583, -552, 126, 62, -40, -27, -227, -348, -334, -324, -238, -65, + 82, 16, -20, -539, -787, 604, 340, 259, 260, -53, -251, -211, -12, 127, 171, 99, + -24, 168, 202, -142, -223, -448, -282, 122, 148, 155, 363, 380, 347, 263, 124, -68, + 165, 150, 226, 95, -172, -257, -413, -510, -533, -734, -1014, -1206, -834, -162, 6, 97, + -78, -72, -81, -322, -605, -731, -740, -564, -356, -219, -151, 11, 200, 237, 212, 170 +}; + +const Word16 SVWB_SN2_fx[256] = +{ + -126, -152, -342, -423, 311, 95, 3, 29, -93, 4, 227, 193, 142, 120, 93, 62, + 190, 258, 382, 310, 166, -11, -77, -67, -217, -327, -330, -378, -461, -309, -142, -47, + -16, -58, -77, -339, -534, 469, 399, 237, 290, 135, 34, 86, -14, -77, -30, 10, + 13, -4, 644, 572, 412, 438, 272, 286, 234, 177, 118, 147, 131, 138, 127, 38, + -73, -88, -112, 42, 36, 141, 424, 386, 504, 576, 523, 483, 431, 328, 233, 59, + -120, -169, -270, -445, -593, -268, -133, -138, -11, 56, 133, 210, 166, 116, 122, 137, + 282, 370, 255, 76, -89, -191, 139, 80, 12, 176, 185, 145, 244, 253, 173, -18, + 13, 14, -43, 73, -59, -270, -448, -622, -59, 374, 353, 293, 189, -54, -199, -122, + -75, -106, -281, -312, 585, 405, 185, 62, -176, -319, -330, -400, -418, -162, -4, 78, + -31, -11, -79, -83, -88, -274, -343, -431, -623, -518, -148, -11, -17, -21, 21, 90, + -101, -173, -240, 444, 303, 121, 104, -37, 185, 134, -45, -136, -164, 4, 153, 114, + -8, 40, 107, -76, -254, -551, -673, 288, 318, 25, 14, -62, -97, -2, 13, -20, + 87, 127, 80, 216, 336, 147, 188, 165, -10, 125, 193, 87, -126, -396, -736, -669, + 2, 4, 96, 185, 6, 62, -37, -136, -177, -250, -227, 201, 744, 651, 351, 74, + -16, -39, -82, -177, -380, -183, -24, -109, -194, -407, -641, -615, -157, 146, 191, 167, + -21, -12, -39, -63, -159, -128, 20, 6, 16, 39, -60, -243, -594, -733, -364, 46 +}; + +const Word16 GETRWB_SN1_fx[512] = +{ + -232, -191, 282, 248, 344, 390, 428, 490, 538, 592, 620, 607, 533, 372, 261, 136, + -59, -227, -418, -288, -247, -448, -501, -644, -760, -922, -1112, -1204, -523, -130, 12, 131, + 139, 838, 1402, 1327, 1465, 1391, 1371, 1342, 1220, 1147, 1041, 910, 733, 518, 335, 181, + 211, 148, -94, -275, -484, -586, -541, -634, -583, -511, -424, -322, -285, -299, -194, -87, + 410, 362, 337, 73, -36, -113, -180, -274, -373, -493, -501, -473, -393, -361, -271, -251, + -85, -366, -819, -532, 753, 688, 414, 203, 24, -43, 129, 60, -100, -123, -97, -114, + 4, 37, 484, 514, 340, 225, 89, 59, 40, 3, -5, -1, -11, -49, -43, -48, + -223, -471, -661, -567, -496, -519, -464, -542, -484, -343, -276, -185, -43, 17, 84, 133, + -106, -312, -668, -741, 385, 329, 121, -157, -423, -710, -957, -1280, -1143, -330, -20, 131, + 250, 157, 71, -310, -552, -740, -745, -778, -827, -1064, -1336, -1629, -788, -195, -44, 131, + 140, 633, 970, 864, 867, 761, 683, 648, 572, 544, 516, 469, 383, 238, 143, 55, + 116, 143, 229, 134, -25, -120, -232, -333, -535, -642, -985, -1259, -1873, -1727, -330, -10, + -64, -82, -62, -232, -308, -346, -296, -272, -153, -26, 108, 205, 232, 158, 129, 53, + 82, -92, -309, -791, -1128, -259, -243, -405, -367, -637, -903, -1084, -675, -199, 17, 146, + -247, -569, -886, -758, -334, -206, -158, -150, -64, 57, 190, 252, 261, 210, 163, 129, + -23, -319, -458, 791, 718, 400, 233, -81, -174, -400, -758, -1048, -1338, -1038, -288, -6, + 50, 462, 303, -47, -122, -134, 15, 137, 179, 222, 266, 249, 219, 123, 80, 30, + -116, -332, -650, -1104, -1367, -691, -376, -295, -178, -199, -170, -24, 125, 95, 125, 168, + -66, -314, -526, 325, 156, -56, -114, -287, -126, -185, -292, -298, -189, -81, 1, 23, + 147, -30, -291, -771, -939, 262, 182, 126, 127, -100, -163, -134, -91, -95, -52, -19, + -225, -496, -449, -61, 46, 135, 182, 247, 324, 404, 457, 464, 420, 305, 209, 106, + 418, 312, 415, 74, -156, -345, -400, -634, -769, -1057, -1362, -1841, -1848, -471, -147, 87, + 38, 19, -232, -552, -698, -941, -483, 119, 54, -34, 70, -68, -144, -192, -253, -236, + 80, -30, -214, -157, -292, -312, -283, -347, -384, -372, -487, -503, -746, -950, -1372, -644, + 44, 55, 124, 181, 125, 109, 61, 29, -73, -54, -206, -278, -638, -929, -1563, -1742, + 802, 823, 726, 353, 272, 122, 117, 94, 80, 40, 68, 47, 42, -19, -26, -69, + 50, -97, -306, -666, -918, -1109, -1124, -776, -710, -728, -675, -486, -150, -3, 93, 160, + 81, -144, -131, 319, 227, -96, -236, -517, -711, -949, -1231, -1644, -1625, -444, -117, 86, + -230, -237, 586, 799, 931, 1023, 1077, 1179, 1133, 1101, 1027, 909, 731, 515, 330, 171, + 448, 632, 1047, 782, 631, 390, 155, -82, -342, -685, -1103, -1520, -1779, -931, -214, 34, + -77, -352, -353, 787, 938, 677, 513, 352, 284, 278, 247, 181, 141, 73, 8, -39, + 54, 42, -67, -298, -465, -593, -533, -547, -626, -741, -977, -1317, -1665, -613, -119, 80 +}; + +const Word16 GETRWB_SN2_fx[256] = +{ + -202, -246, -356, -356, -232, -164, -79, 4, 78, 130, 152, 165, 170, 141, 90, 70, + 38, 78, -72, -185, -446, -552, 269, 295, 104, 77, -54, -184, -168, -72, -32, -2, + 69, 93, 39, 116, 100, 46, 50, -1, -2, 62, 8, -105, -404, -656, -494, -224, + -285, -305, 263, 97, 29, 33, -24, 54, 35, 25, -4, -6, -30, 13, 20, 21, + -28, -70, -160, 34, 5, -145, -264, -425, -539, -329, -19, 228, 411, 280, 141, 51, + 244, 245, 19, -319, -461, -184, -10, 47, 220, 293, 309, 330, 281, 140, 71, 12, + -128, -251, -374, 424, 279, 68, 35, -68, 13, 45, -6, -41, -73, -17, 8, 27, + -55, -7, 438, 500, 493, 442, 286, 211, 68, -39, -117, -167, -180, -131, -75, -63, + 30, 31, 69, 114, -172, -407, -596, -391, 102, 169, 158, 131, 46, 4, -6, -3, + 69, 76, 33, 238, 164, 119, 160, 165, 273, 342, 383, 419, 456, 378, 262, 96, + -55, 43, -59, -273, -200, -286, -287, -221, -247, -245, -194, -160, -129, -36, -31, 3, + -35, -46, -272, -357, 484, 246, -11, 21, -123, -197, -102, -94, -96, -22, 6, 6, + -117, -188, -252, -227, 0, 460, 506, 526, 501, 389, 250, 131, -28, -32, 24, 17, + 399, 511, 390, 146, 80, -84, -81, -57, -123, -138, -95, -82, -51, -33, -14, -45, + -9, 12, 300, 304, 182, 27, -197, -258, -344, -393, -384, -318, -140, -5, -6, 6, + 64, 25, -7, -256, -306, 381, 243, 96, -17, -190, -285, -246, -65, 48, 37, 29 +}; + +const Word16 AUWB_SN1_fx[256] = +{ + 328, 137, 358, 330, 184, 145, -60, -294, -555, -784, -945, -872, -601, -337, -155, -33, + 32, -212, -488, -651, -752, -877, -892, -886, -853, -795, -705, -549, -330, -224, -127, -9, + 372, 327, 197, 33, 13, -55, -87, -124, -125, -148, -144, -168, -175, -184, -127, -125, + 752, 727, 623, 519, 449, 350, 309, 289, 272, 252, 185, 124, 118, 35, 22, -20, + 14, 144, 296, 432, 416, 325, 177, 166, 151, 123, 109, 104, 47, -22, -45, -49, + 310, 112, -141, -529, -654, -53, 162, -33, -297, -551, -772, -817, -540, -287, -95, -7, + -158, 241, 443, 543, 559, 579, 566, 606, 610, 622, 602, 578, 485, 331, 197, 104, + -471, -530, 37, 272, 397, 442, 466, 523, 561, 592, 608, 576, 485, 348, 222, 133, + 162, 0, -87, -85, -151, -331, -410, -603, -767, -1030, -1348, -1812, -1735, -678, -284, -6, + -156, 36, 15, 26, 41, 118, 201, 265, 339, 382, 420, 435, 377, 264, 159, 84, + -69, -274, -411, -158, 60, -56, -190, -305, -371, -389, -411, -407, -338, -276, -173, -99, + 0, -26, -196, -379, -369, -327, -193, -148, -77, -10, 63, 98, 98, 49, 40, -5, + -149, -432, -729, -923, -927, -766, -568, -455, -333, -219, -122, -29, 11, 9, 20, 54, + 177, 64, -60, -232, -411, -552, -557, -550, -509, -464, -380, -331, -297, -288, -215, -170, + -16, 439, 971, 1104, 1209, 1323, 1339, 1374, 1317, 1223, 1107, 983, 781, 535, 315, 151, + -432, -727, -686, -340, -156, -40, 18, 102, 169, 257, 306, 335, 296, 213, 137, 97 +}; + +/* An 16-by-16 matrix in Scale = 2.56f */ +const Word16 TRWB2_SN1_fx[256] = +{ + -74, -384, -764, -964, -1122, -912, -819, -740, -728, -572, -379, -317, -250, -51, -67, 85, + -311, -618, -439, -108, 156, 257, 404, 543, 643, 729, 732, 572, 446, 329, 236, 164, + 523, 1549, 1557, 1476, 1374, 1192, 1068, 923, 901, 788, 717, 401, 262, 6, -100, -368, + -13, -80, -189, -386, -486, -357, -216, -63, 65, 189, 248, 194, 218, 219, 205, 169, + -104, -519, -772, 492, 224, 18, -203, -244, -126, -220, -362, -417, -271, -71, -34, -50, + -202, 124, 811, 975, 1326, 1468, 1613, 1527, 1474, 1366, 1220, 906, 700, 509, 351, 207, + -57, -196, -238, -281, -267, -239, -190, -137, -27, 4, 77, -178, -256, -553, -669, -1105, + -183, -211, 804, 789, 685, 529, 479, 403, 371, 313, 279, 49, -19, -156, -179, -335, + 758, 848, 608, 313, 271, 176, 177, 73, 106, 61, 59, -159, -203, -287, -268, -343, + 199, 70, 95, -29, -245, -411, -745, -1009, -1473, -1921, -2633, -1648, -537, -284, -87, 207, + 82, -217, -460, -646, -718, -821, -983, -1282, -1580, -2108, -1863, -609, -407, -122, -50, 243, + -132, 364, 364, 340, 489, 496, 596, 606, 704, 756, 777, 616, 521, 409, 305, 211, + 123, -189, -91, -306, -319, -407, -600, -679, -911, -855, -566, -249, -65, -1, -65, -25, + 79, -58, -103, -150, -268, -265, -426, -479, -614, -671, -1005, -1378, -2027, -1547, -568, -52, + -275, -669, -1070, -1097, -688, -433, -340, -148, -27, 194, 309, 277, 229, 188, 82, 127, + 397, 1343, 1482, 1729, 1978, 2012, 1969, 1852, 1729, 1574, 1407, 1087, 848, 636, 431, 278 +}; + +/* An 16-by-16 matrix in Scale = 2.56f */ +const Word16 TRWB2_SN2_fx[256] = +{ + 50, -66, -486, -850, 504, 345, 261, 10, -207, -218, -174, -18, 72, 69, 3, 24, + -171, -439, -632, 390, 143, -89, -292, -314, -227, -157, 33, 181, 185, 204, 128, 167, + 458, 459, 78, -250, -365, -381, -353, -382, -327, -284, -191, -18, 3, 37, 29, 95, + -169, -227, -423, -448, -485, -426, -364, -284, -238, -184, -228, -190, -145, 17, 65, 145, + -4, -120, -170, -333, -677, -782, -719, -391, -112, 232, 464, 392, 275, 215, 121, 139, + -94, -130, 453, 295, -45, -286, -444, -473, -519, -428, -268, -40, -12, 46, 39, 118, + -189, -245, 805, 815, 518, 293, 162, 110, -67, -158, -223, -120, -36, 15, 26, 60, + 23, 130, 107, 0, -31, -66, 33, 22, 101, -10, -32, -232, -281, -590, -672, -1089, + 51, 106, 157, 132, 40, 11, -73, -66, -165, -294, -561, -770, -742, -489, -202, 4, + 25, 230, 286, 179, 75, 18, 15, 24, 109, 187, 310, 334, 328, 291, 237, 212, + -238, -492, -550, 563, 764, 610, 542, 427, 373, 261, 166, 171, 122, 34, -21, -92, + -359, -462, -10, 22, -42, -2, 78, 167, 154, 155, 74, 73, 66, 94, 89, 126, + -5, -110, -374, -546, -386, -136, 95, 305, 437, 570, 615, 558, 463, 335, 209, 151, + 23, 376, 292, 235, 485, 519, 657, 549, 478, 338, 186, 7, -28, -155, -95, -188, + 166, 139, -277, -716, -822, 234, 319, 326, 234, 36, -155, -317, -247, -80, 49, 117, + 431, 853, 745, 512, 325, 139, 83, -31, -25, -47, -17, -12, -24, -43, -5, 13 +}; + +/* An 16-by-16 matrix in Scale = 2.56f */ +const Word16 AUWB2_SN1_fx[256] = +{ + -107, -446, -835, -1041, -1152, -1161, -1146, -969, -828, -533, -251, -242, -139, 172, 95, 466, + 1052, 1008, 1052, 875, 864, 748, 783, 690, 754, 715, 688, 342, 195, -32, -251, -509, + -311, -170, 366, 632, 748, 863, 983, 1042, 1118, 1188, 1133, 895, 728, 621, 460, 418, + 608, 525, 322, 30, -237, -483, -862, -1178, -1651, -2184, -2770, -1349, -430, -28, 128, 562, + 296, 171, -192, -429, -488, -470, -492, -473, -448, -352, -242, -309, -337, -210, -265, -182, + 831, 703, 456, 217, 165, 65, 17, -53, -67, -78, -38, -222, -340, -329, -349, -391, + 162, -13, -158, -335, -526, -705, -986, -1245, -1640, -2149, -2754, -1344, -372, -12, 134, 564, + -79, -389, -569, -699, -811, -940, -1058, -1299, -1534, -2077, -1953, -507, -216, 143, 191, 607, + -106, -116, -210, -225, -323, -330, -494, -491, -700, -757, -1057, -1424, -2222, -1509, -259, 348, + -366, -748, -1177, -1216, -1017, -698, -444, -154, 10, 285, 361, 284, 255, 359, 187, 365, + 77, 447, 418, 475, 453, 459, 475, 515, 562, 648, 658, 452, 367, 334, 244, 204, + 10, 197, 170, 166, 144, 60, 52, -2, -20, -40, 18, -238, -279, -434, -451, -807, + -460, -713, -547, -153, 64, 243, 386, 492, 620, 752, 759, 536, 445, 324, 151, -32, + -246, -396, -413, -371, -354, -317, -307, -228, -195, -101, -36, -174, -197, -162, -261, -349, + -329, -240, 326, 462, 428, 344, 405, 374, 439, 434, 467, 127, 85, -154, -248, -683, + -12, 15, -222, -227, -31, 124, 200, 294, 357, 541, 607, 459, 376, 352, 282, 283 +}; + +/* An 16-by-16 matrix */ +const short CNG_SN1_fx[256] = +{ + 600, 1640, 3039, 4257, 5512, 6740, 7989, 9169, 10393, 11612, 12880, 14100, 15378, 16554, 17816, 18918, + 1188, 2487, 3746, 4903, 6103, 7261, 8437, 9587, 10776, 11954, 13172, 14355, 15564, 16712, 17913, 19012, + 346, 799, 2259, 3555, 4876, 6175, 7516, 8803, 10073, 11323, 12631, 13938, 15282, 16553, 17817, 19039, + 439, 1616, 3446, 4743, 6073, 7288, 8553, 9726, 10947, 12106, 13312, 14474, 15650, 16773, 17894, 18977, + 921, 1800, 2976, 4007, 5105, 6137, 7178, 8150, 9057, 9914, 11009, 12545, 13671, 15502, 17428, 18927, + 896, 1899, 3035, 4128, 5301, 6429, 7604, 8719, 9886, 11059, 12417, 13621, 14962, 16135, 17475, 18460, + 722, 1507, 2537, 3437, 4328, 5190, 6018, 6841, 7587, 8343, 8925, 9511, 9919, 11075, 13613, 15021, + 315, 612, 1671, 2910, 3990, 5083, 6120, 7170, 8188, 9173, 10148, 11186, 12250, 13262, 14290, 15284, + 885, 1928, 3010, 3973, 4952, 5900, 6848, 7769, 8701, 9609, 10581, 11540, 12508, 13450, 14412, 15349, + 338, 1020, 2657, 3736, 4839, 5791, 6806, 7760, 8738, 9659, 10627, 11567, 12534, 13468, 14416, 15334, + 1126, 1964, 2999, 3855, 4764, 5608, 6482, 7286, 8109, 8827, 9570, 10649, 11999, 13125, 14223, 15252, + 385, 815, 2000, 2939, 3906, 4879, 5793, 6734, 7661, 8526, 9309, 10146, 11597, 12955, 14106, 15241, + 633, 1445, 2400, 3293, 4235, 5171, 6143, 7084, 8057, 8980, 9924, 10924, 11987, 12998, 14016, 15058, + 584, 1248, 2250, 3131, 4050, 4920, 5811, 6652, 7471, 8244, 8913, 9480, 10188, 12225, 13871, 15123, + 1157, 1820, 2745, 3505, 4354, 5097, 5932, 6648, 7408, 8034, 8635, 9083, 9977, 12228, 13819, 15108, + 572, 1401, 2514, 3501, 4503, 5465, 6469, 7435, 8416, 9328, 10306, 11309, 12328, 13303, 14306, 15261, +}; + +/* An 16-by-32 matrix */ +const Word16 IAA_MA1_fx[512] = +{ + -175, -490, -520, -631, -645, -614, -610, -548, -503, -432, -353, -301, -238, -141, -67, 26, + 301, 407, 227, 96, -12, -18, -13, 2, 39, 107, 124, 92, 83, 100, 62, 72, + -280, -737, -569, -164, -9, 100, 141, 211, 252, 281, 274, 217, 206, 219, 117, 106, + -266, -753, -841, -587, -487, -345, -263, -167, -114, -30, 8, 32, 34, 61, 55, 104, + -91, -137, -293, -349, -352, -326, -268, -247, -178, -129, -56, -96, -11, 219, 49, 56, + -18, 1, -33, -14, -19, -5, -22, -14, -43, -37, -104, -143, -375, -770, -190, -100, + 72, -22, -121, -220, -320, -378, -500, -587, -729, -795, -1056, -1305, -1691, -1090, -452, -60, + 19, -279, -453, -580, -588, -739, -858, -1044, -1281, -1614, -921, -376, -273, -84, -2, 187, + 853, 759, 591, 376, 260, 122, 39, -71, -133, -184, -209, -297, -299, -171, -124, -83, + 266, 34, -182, -367, -516, -686, -881, -1121, -1414, -1834, -2110, -997, -519, -274, -109, 137, + -2, -8, 42, 91, 172, 211, 298, 336, 433, 409, 546, 1043, 1499, 1038, 410, 189, + 86, 254, 259, 254, 246, 219, 184, 122, 79, 11, -55, -170, -363, -934, -371, -188, + 168, 167, -122, -244, -325, -340, -359, -343, -331, -291, -278, -270, -272, -162, -101, -46, + -244, -459, -367, -340, -295, -220, -173, -107, -22, 53, 103, 293, 1084, 807, 260, 117, + -319, -650, -685, -427, -290, -105, 25, 161, 303, 418, 587, 1074, 1563, 1085, 400, 170, + 146, 257, 282, 295, 303, 294, 297, 262, 237, 193, 92, 341, 1220, 884, 315, 144, + -291, -558, 147, 201, 282, 280, 310, 302, 313, 306, 292, 239, 198, 188, 106, 94, + -11, -8, -156, -204, -231, -250, -265, -289, -269, -316, -322, -450, -488, -676, -778, -973, + -117, -27, 4, 96, 174, 229, 271, 310, 344, 362, 344, 273, 209, 180, 109, 106, + -260, -290, 151, 269, 406, 442, 551, 590, 679, 681, 900, 1293, 1631, 1132, 477, 221, + -37, 374, 394, 414, 419, 395, 345, 313, 282, 255, 211, 126, 84, 51, -10, -53, + 404, 327, 174, 28, -124, -290, -490, -695, -1011, -1111, -529, -288, -183, -69, -7, 142, + 563, 752, 585, 555, 512, 478, 424, 396, 376, 343, 300, 194, 193, 162, 78, 46, + -59, -131, -35, 49, 54, -12, -92, -185, -243, -289, -288, -344, -326, 0, -38, 6, + 496, 582, 564, 514, 521, 490, 486, 436, 432, 320, 456, 1060, 1523, 1058, 419, 194, + 174, 77, 18, -89, -112, -196, -165, -247, -222, -326, -332, -494, 499, 617, 121, 60, + 315, 299, 229, 137, 78, -3, -40, -138, -198, -307, -375, -502, -515, -25, -88, -49, + -232, -29, 353, 399, 485, 487, 523, 526, 556, 559, 520, 415, 328, 283, 187, 166, + 182, 385, 403, 453, 515, 572, 635, 691, 787, 852, 1154, 1483, 1779, 1231, 524, 246, + -273, -492, -185, -97, -52, -51, -17, -27, 13, 20, 45, -20, 52, 244, 58, 56, + 20, -3, -241, -267, -194, -86, 4, 75, 140, 191, 200, 154, 137, 146, 85, 77, + 92, 628, 611, 708, 706, 716, 672, 694, 655, 619, 550, 432, 354, 284, 204, 172 +}; + +/* An 16-by-16 matrix in Scale = 2.56f */ +const Word16 UVD_MA1_fx[256] = +{ + -301, -503, -426, -187, -131, -64, -45, -20, 11, 56, 63, 90, 110, 175, 97, 33, + 161, 353, 474, 502, 709, 782, 794, 765, 632, 532, 406, 285, 230, 145, 97, 52, + -37, -5, 205, 323, 412, 349, 221, 91, -6, -59, -86, -112, -32, 209, 73, 23, + -273, -615, -820, -794, -834, -838, -822, -819, -751, -701, -641, -562, -391, -271, -184, -63, + 262, 168, 104, -9, -78, -163, -141, -199, -191, -249, -245, -317, -168, 535, 109, 33, + -410, -675, -681, -611, -500, -396, -273, -183, -47, 60, 194, 357, 1044, 1080, 335, 140, + 154, 185, 256, 238, 203, 238, 280, 260, 300, 267, 258, 196, 121, -618, -263, -60, + 345, 705, 859, 786, 743, 584, 425, 267, 168, 105, 74, 28, 119, 267, 105, 39, + -39, -166, -230, -196, -255, -276, -318, -349, -387, -438, -539, -613, -752, -956, -1353, -1628, + 498, 479, 414, 231, 98, 5, -18, -41, -60, -78, -91, -96, -81, 72, 30, -8, + 41, 120, 65, 141, 117, 186, 249, 299, 418, 520, 566, 618, 692, 579, 321, 166, + -236, -278, -69, 13, 113, 362, 445, 539, 503, 387, 269, 172, 120, -21, 1, 4, + -103, -46, -137, -132, -108, -97, -67, -37, -8, 41, 82, 107, 43, -605, -189, -56, + -220, -315, -482, -516, -489, -445, -415, -362, -304, -205, -136, -68, -7, 131, 70, 25, + -10, -121, -210, -237, -224, -302, -246, -310, -271, -343, -285, -364, 28, 703, 135, 54, + 118, 50, -67, -166, -349, -416, -442, -446, -439, -420, -382, -319, -245, -209, -140, -82 +}; + +/* An 16-by-16 matrix in Scale = 2.56f */ +const Word16 UVD_MA2_fx[256] = +{ + -75, -64, -150, -231, -272, -278, -248, -194, -156, -107, -74, -43, -92, -21, 9, 5, + 393, 275, -12, -156, -208, -215, -162, -132, -115, -109, -94, -85, -104, -10, 5, -1, + -297, -389, -99, -78, -66, -19, -12, 8, 0, -3, -15, -22, -113, -82, -16, 2, + 59, -11, 5, -33, -11, -61, -70, -139, -143, -239, -207, -223, 711, 701, 143, 68, + -195, 406, 222, 49, -6, -23, -6, 9, 0, 13, 26, 49, -44, -129, -18, -7, + 23, -30, -141, 79, -18, -76, -55, -14, 44, 98, 88, 86, -96, -351, -112, -39, + 380, 329, 235, 173, 141, 72, 25, -4, -6, -19, -21, -33, -55, -23, 3, -1, + -81, -210, -284, 158, 396, 290, 163, 59, -25, -22, -10, -6, -46, -32, 9, 5, + 9, 34, -15, 5, 23, -48, -127, -243, -347, -421, -455, -475, -495, -449, -294, -163, + -13, -171, -416, -414, -245, -25, 69, 102, 104, 84, 50, 33, -38, -4, 0, 5, + 50, 118, 68, 37, 147, 319, 371, 355, 291, 204, 130, 81, 21, 46, 36, 22, + -95, -108, 311, 214, -28, -153, -226, -192, -129, -69, -42, -11, -48, -17, 13, 2, + -185, -223, -104, 26, 53, 89, 132, 181, 258, 346, 397, 445, 392, 241, 125, 58, + 83, 33, -9, -81, 40, 99, 56, 8, -51, -85, -106, -124, -196, 5, 5, 0, + 143, 148, 19, -121, -247, -211, -67, 83, 198, 268, 290, 300, 240, 164, 86, 37, + -198, -136, 370, 372, 300, 240, 156, 113, 79, 60, 44, 29, -35, -38, 6, 7 +}; + +/* An 16-by-16 matrix in Scale = 2.56f */ +const Word16 UVWB_MA3_fx[256] = +{ + -26, 23, 7, -6, -1, 3, 40, 35, -43, -24, 56, 157, 265, 423, 382, 260, + 61, -300, -130, -101, -8, 106, 108, 114, 88, 43, -2, -33, -56, 67, 29, 13, + -31, 47, 45, -121, 46, 22, 111, 233, -256, -252, -123, -71, -31, 54, 56, 33, + 20, -154, 67, 198, -232, -167, -86, -12, 79, 116, 88, 78, 44, 75, 27, -7, + -14, 153, -166, 21, 107, 64, 233, -223, -147, -27, -1, 43, 61, 70, 50, 18, + 3, -115, -8, 143, 192, 193, -124, -195, -198, -162, -75, 14, 45, 83, 79, 49, + 12, -57, 25, -29, -11, 12, -7, -13, -12, 31, 74, 99, -10, -421, -209, -111, + -25, 115, 119, -19, -117, -164, -203, -237, -206, -169, -110, -41, -11, 15, 1, -7, + -13, 170, -143, -128, -224, -94, 1, 96, 144, 102, 29, 2, -37, 46, 7, -12, + -11, 10, -34, 38, 24, 86, 149, 211, 240, 279, 247, 218, 154, 161, 74, 15, + -24, 64, 110, 125, -24, 123, 161, 166, 177, 18, -112, -116, -141, -117, -113, -91, + -4, -20, -17, -11, -27, 13, -15, -40, -58, -157, -252, -283, -288, -186, -162, -112, + -20, 2, 32, 44, -31, -49, 8, 13, 55, -59, -162, -212, -61, 384, 115, 36, + -4, 42, -75, 92, 268, -203, -125, 10, 52, 121, 72, -43, -109, -47, -66, -76, + -39, 76, 268, -254, -28, 87, 2, 91, 85, 68, 89, 96, 42, 90, 39, 4, + 2, 2, -56, 7, 67, -31, -219, -192, -24, 146, 249, 269, 209, 199, 106, 31 +}; + +/* An 16-by-8 matrix in Scale = 2.56f */ +const Word16 GESVNB_AR1_fx[128] = +{ + -25, -64, -140, -118, 270, 240, 127, 70, 20, -40, -56, -111, -82, 64, 2, 5, + 81, 104, 71, 70, 0, -49, -54, -73, -59, -92, -102, -201, -404, -52, -40, -15, + -112, -217, -251, -202, -34, 57, 58, 62, 79, 127, 177, 306, 524, 315, 112, 53, + 17, -6, 34, 66, 14, -26, -174, -196, -142, -131, -102, -97, 180, 154, 29, 17, + 5, -27, -107, -197, -343, -333, -182, -143, -91, -17, 43, 120, 383, 267, 83, 40, + -1, -15, -35, -56, -169, -145, 86, 101, 77, 48, 29, 78, -9, 68, 15, 9, + 3, 9, 320, 450, 385, 348, 215, 155, 105, 45, -13, -75, -272, -129, -52, -23, + 4, 49, 54, 90, 92, 101, 59, 69, 20, 70, 23, 43, -280, -624, -114, -55 +}; + +/* An 16-by-8 matrix in Scale = 2.56f */ +const Word16 GESVNB_AR2_fx[128] = +{ + -22, -35, -31, -166, -164, 217, 212, 155, 166, 123, 67, 33, -21, -41, -3, -1, + -14, -20, -16, -70, -77, -53, 23, -7, -98, -123, -99, -49, 357, 114, 36, 19, + -57, -119, -303, -215, -33, -103, -97, -117, -105, -102, -67, -134, -176, 113, 16, 8, + -12, 14, 30, -37, -112, -226, -206, -25, 125, 134, 99, 83, 55, -4, 9, 4, + -19, 23, 171, 57, 13, -15, -26, -42, -65, -69, -77, -169, -351, -105, -49, -21, + -14, -10, 8, 35, 161, 104, -74, -102, -135, -47, 45, 264, 52, -69, -1, -5, + 213, 284, 230, 121, 50, 12, 43, 48, 27, -7, -24, -39, 75, 1, -9, -3, + -75, -137, -89, 275, 164, 65, 125, 91, 86, 91, 56, 10, 9, -10, 0, 0 +}; + +/* An 16-by-8 matrix in Scale = 2.56f */ +const Word16 GESVWB_AR1_fx[128] = +{ + -3, -16, -31, 2, -81, -123, -226, -260, -196, -122, -20, 78, 178, 145, 84, 46, + 55, 42, 15, 32, -48, -81, -109, -137, -187, -264, -330, -387, -363, -176, -38, 37, + -32, -70, -144, -269, -337, -183, 59, 58, 44, 49, 42, 51, 72, 50, 26, 38, + -18, -58, -79, 125, 352, 291, 180, 118, 72, 25, -23, -82, -185, -167, -33, 6, + -10, 135, 544, 517, 517, 561, 515, 528, 500, 472, 413, 383, 318, 219, 118, 57, + -54, -280, -614, -548, -521, -522, -448, -479, -457, -438, -377, -355, -318, -271, -222, -89, + -62, -96, -86, -10, 104, 155, 120, 112, 190, 264, 291, 272, 232, 166, 95, 27, + 33, 61, 155, 121, 9, -28, 6, 103, 64, 17, 4, -2, -31, -88, -209, -206 +}; + +/* An 16-by-8 matrix in Scale = 2.56f */ +const Word16 GESVWB_AR2_fx[128] = +{ + -147, -326, -421, -91, -22, -25, -14, -21, 32, 76, 104, 102, 65, 47, 50, 41, + -39, -16, 61, -13, -38, -56, 47, 153, 195, 213, 212, 220, 245, 245, 209, 86, + -34, -73, 82, 387, 199, 71, 56, -18, -33, -56, -88, -79, -5, 59, 55, 29, + -7, -21, -21, -158, -123, 304, 226, 168, 124, 8, -75, -91, -54, -5, 37, 30, + -26, -22, -67, -225, 107, 38, -82, -113, -213, -205, -62, 28, 89, 95, 52, 17, + 227, 404, 325, 134, 45, -16, 3, -15, -55, -65, -55, -54, -18, -8, 1, -14, + 19, 30, 12, 28, 48, 13, 2, -47, -38, 41, 29, -8, -154, -315, -411, -242, + 8, 24, 29, -61, -215, -329, -237, -106, -12, -12, -64, -118, -167, -119, 8, 52 +}; + +/* An 16-by-32 matrix in Scale = 2.56f */ +const Word16 GEWB2_MA1_fx[512] = +{ + 659, 1694, 1634, 1513, 1305, 1098, 933, 805, 733, 624, 525, 339, 239, 50, -35, -215, + 6, 65, 125, 55, -85, -126, -272, -316, -507, -586, -1010, -1278, -1941, -1910, -426, 78, + 281, 315, 236, -4, -102, -171, -232, -335, -362, -425, -488, -603, -669, -736, -648, -593, + 29, -251, -582, -871, -969, -897, -991, -1077, -1275, -1480, -998, -393, -247, -9, 28, 271, + -60, -361, 401, 552, 236, 35, -196, -215, -496, -683, -911, -820, -576, -299, -240, -141, + 416, 574, 662, 350, 133, -160, -431, -781, -1200, -1652, -2035, -1092, -449, -192, -11, 263, + -206, -609, -931, 28, -229, -358, -543, -462, -377, -360, -336, -251, -105, 35, 26, 80, + 369, 1256, 1380, 1571, 1726, 1727, 1644, 1521, 1350, 1156, 984, 748, 580, 395, 254, 108, + -147, -479, -330, -73, -272, -441, -685, -837, -1139, -1458, -1370, -414, -208, -12, 14, 213, + -50, 100, -82, -253, -7, 119, 294, 392, 494, 578, 589, 523, 462, 383, 300, 249, + -94, -362, -575, -770, -987, -999, -922, -697, -582, -305, -135, -31, -8, 23, -33, 62, + 29, -64, -4, -123, -344, -414, -679, -767, -1152, -1401, -2105, -1905, -582, -300, -64, 223, + 428, 990, 1019, 809, 681, 470, 366, 179, 126, -26, -141, -363, -423, -536, -437, -545, + -133, -357, 364, 241, -39, -227, -334, -305, -426, -292, -102, 87, 159, 182, 160, 190, + 560, 764, 531, 156, 22, -18, 23, -20, 19, 0, 13, -61, -35, -44, -12, -48, + 33, -235, -634, -1093, 136, -31, -68, -285, -529, -535, -462, -249, -95, -53, -116, -61, + -188, -628, -894, 702, 700, 373, 196, 51, 95, -56, -191, -181, -173, -132, -116, -218, + 37, -188, -661, -1087, -1322, -258, -186, -181, -238, -372, -418, -508, -433, -197, -73, 28, + -231, -222, 911, 875, 669, 440, 363, 301, 257, 192, 147, 68, 77, 43, 57, 17, + -4, -187, -356, -410, -569, -499, -584, -568, -660, -703, -965, -1201, -1540, -708, -252, 87, + 220, 64, -67, -357, -572, -744, -913, -1176, -1439, -1894, -2152, -762, -419, -146, -10, 281, + -253, -627, -1075, -1206, -721, -398, -337, -188, -118, 50, 125, 198, 200, 190, 96, 164, + -348, -741, -854, -357, -163, -103, -26, 143, 231, 318, 335, 325, 274, 233, 167, 190, + -143, -256, -191, -280, -250, -191, -82, 37, 126, 102, 67, -130, -202, -430, -495, -810, + 232, 107, -22, -341, -497, -523, -607, -646, -746, -690, -478, -295, -160, -77, -53, -7, + -33, -98, -258, -501, -589, -438, -316, -168, -58, 82, 175, 219, 249, 259, 237, 226, + -393, -665, -19, 185, 249, 266, 378, 468, 499, 508, 464, 388, 310, 238, 186, 145, + -240, -99, 408, 480, 693, 761, 946, 943, 951, 893, 782, 613, 482, 351, 260, 163, + -23, 523, 885, 903, 1172, 1287, 1482, 1491, 1476, 1402, 1240, 1005, 787, 604, 433, 292, + 262, 988, 904, 732, 734, 665, 715, 656, 673, 615, 541, 372, 284, 139, 68, -84, + -119, 446, 1118, 1215, 1372, 1280, 1208, 989, 881, 675, 557, 319, 227, 23, -39, -256, + -102, 178, 379, 252, 365, 319, 455, 377, 413, 278, 225, -36, -67, -351, -375, -772 +}; + +/* An 16-by-32 matrix in Scale = 2.56f */ +const Word16 GEWB_MA1_fx[512] = +{ + 269, 268, 416, 287, 157, 7, -132, -276, -482, -701, -1025, -1350, -1642, -982, -321, -49, + 237, 949, 1374, 1228, 1337, 1219, 1123, 1016, 852, 752, 664, 559, 448, 306, 194, 83, + -6, -176, -373, -111, -221, -387, -483, -639, -753, -786, -774, -655, -328, -114, -25, 27, + 135, 164, -4, -181, -364, -528, -464, -424, -393, -314, -242, -185, -104, -61, -32, -37, + 15, -218, -322, 668, 597, 343, 196, -5, -46, -159, -359, -524, -629, -548, -308, -95, + 242, 463, 767, 661, 558, 403, 268, 191, 71, -4, -51, -103, -141, -176, -161, -142, + -179, -147, 715, 865, 970, 932, 822, 763, 602, 514, 436, 370, 285, 189, 106, 36, + -49, -227, -589, -933, -1172, -700, -248, -175, -132, -132, -125, -103, -47, -49, -12, 60, + -7, -227, -404, 272, 83, -50, -165, -319, -343, -501, -731, -939, -1013, -607, -202, -2, + -76, -271, -661, -582, 296, 86, -60, -166, -335, -314, -213, -285, -324, -280, -164, -39, + -264, -452, -111, 171, 229, 357, 355, 461, 509, 517, 489, 441, 347, 246, 158, 75, + 67, -49, -340, -546, -758, -919, -876, -727, -658, -567, -492, -400, -234, -140, -63, 36, + -142, 94, 514, 400, 406, 389, 379, 413, 391, 377, 354, 314, 245, 156, 94, 34, + 97, -47, -316, -620, -874, -179, -206, -290, -304, -514, -690, -723, -503, -252, -73, 39, + 485, 674, 532, 195, 38, -60, 17, 52, 63, 74, 85, 62, 35, -10, -22, -51, + -105, -23, 287, 394, 469, 609, 706, 860, 933, 933, 874, 789, 638, 465, 297, 148, + -223, -499, -837, -813, -391, -231, -178, -182, -81, 2, 84, 113, 131, 142, 127, 107, + -64, 269, 879, 849, 1013, 1157, 1250, 1337, 1263, 1176, 1048, 900, 703, 502, 318, 165, + 61, 1, -198, -209, -345, -417, -280, -280, -307, -272, -341, -418, -604, -738, -887, -394, + 45, 77, 124, 152, 99, 43, 20, -4, -91, -85, -192, -280, -544, -754, -1176, -1296, + 173, 69, -49, -226, -344, -479, -489, -618, -727, -909, -1122, -1446, -1292, -492, -205, 10, + -80, -80, 338, 285, 123, 48, -76, -80, -105, -118, -108, -80, -58, -28, -9, -8, + 74, -79, -292, -618, -756, 345, 216, 180, 143, -73, -186, -223, -200, -143, -52, -21, + -253, -519, -578, -188, -96, -35, -7, 27, 133, 218, 258, 258, 231, 180, 120, 70, + 273, 740, 950, 736, 701, 635, 611, 602, 566, 533, 494, 447, 350, 230, 131, 42, + -100, -345, -702, -352, 709, 682, 485, 324, 161, 112, 148, 25, -88, -106, -86, -101, + 307, 265, 253, 65, -63, -75, -169, -282, -390, -501, -550, -532, -406, -296, -186, -132, + -26, 70, 50, -84, -89, 28, 106, 199, 305, 391, 450, 469, 419, 301, 191, 80, + 22, 39, -154, -426, -597, -497, -159, -69, 41, 95, 114, 114, 99, 33, -7, -40, + -162, -356, -511, -461, -475, -513, -477, -485, -395, -249, -136, -71, -4, 33, 54, 64, + -82, -295, -562, 241, 65, -163, -227, -384, -237, -229, -266, -223, -94, 10, 41, 31, + -104, -323, -302, 733, 646, 418, 271, 149, 155, 154, 119, 99, 89, 63, 13, -16 +}; + +/* An 16-by-32 matrix in Scale = 2.56f */ +const Word16 AUWB2_MA1_fx[512] = +{ + 391, 298, 179, -37, -225, -387, -627, -864, -1216, -1644, -2108, -804, -277, -5, 121, 468, + 351, 213, 141, -75, -130, -164, -332, -410, -524, -573, -575, -474, -331, -103, -22, 201, + 81, 874, 1137, 1223, 1242, 1262, 1238, 1185, 1141, 1085, 993, 733, 570, 424, 256, 145, + -6, -25, -105, -147, -327, -342, -587, -620, -954, -1143, -1878, -2059, -356, -100, 134, 477, + -197, -505, -826, -1043, -863, -485, -296, -103, -6, 178, 269, 245, 231, 320, 243, 413, + -518, -605, 282, 430, 532, 596, 676, 748, 808, 861, 834, 681, 534, 498, 293, 337, + -244, -563, -720, -599, -500, -494, -627, -739, -1028, -1219, -297, 9, 71, 272, 285, 563, + -448, -854, -916, -518, -287, -52, 56, 245, 347, 524, 557, 497, 416, 452, 321, 437, + 150, 113, 28, -26, 1, -80, -177, -226, -193, -156, -62, -227, -240, -383, -535, -809, + -240, -246, -174, -66, 80, 149, 244, 284, 413, 434, 473, 158, 56, -167, -326, -723, + 131, -11, 141, 32, 24, -122, -397, -610, -888, -812, 30, 232, 306, 371, 341, 446, + -158, -545, -529, 151, 142, -101, -426, -716, -1031, -1479, -1550, -352, -132, 145, 187, 517, + 148, -104, -445, -841, -31, 183, -86, -316, -615, -660, -231, 84, 192, 275, 201, 311, + -183, -220, -243, -182, -237, -176, -266, -233, -336, -339, -650, -1019, -1652, -846, -52, 387, + -104, -117, -254, -332, -191, 1, 64, 182, 317, 495, 626, 574, 519, 508, 456, 505, + -151, -237, 492, 479, 273, 139, 36, -60, -119, 74, 174, 188, 298, 366, 347, 478, + 158, 23, -210, -450, -673, -637, -423, -331, -133, 14, 128, 69, 62, 143, 171, 313, + 501, 394, 37, -57, 67, 70, 46, 35, 92, 120, 337, 258, 276, 283, 368, 500, + 42, -157, -398, -600, -742, -780, -781, -980, -1166, -1629, -968, -149, -99, 188, 209, 529, + -240, 190, 465, 543, 575, 565, 605, 596, 653, 599, 583, 279, 203, -51, -186, -589, + 316, 371, 417, 372, 293, 189, 230, 154, 184, 91, 94, -175, -198, -358, -454, -736, + 72, -159, -362, -499, -633, -690, -794, -739, -662, -456, -360, -338, -251, -6, 50, 346, + -202, -332, -428, -462, -508, -440, -552, -647, -885, -1217, -1733, -619, -162, 95, 202, 510, + -91, -391, -709, -884, -1012, -1001, -936, -714, -509, -198, 42, 99, 119, 261, 238, 496, + -370, 92, 476, 604, 681, 762, 826, 893, 934, 1001, 954, 783, 629, 590, 412, 467, + -193, -22, -28, 46, 214, 387, 502, 643, 728, 864, 859, 723, 581, 569, 435, 483, + 223, 291, 633, 508, 350, 141, -156, -476, -930, -1417, -1809, -764, -206, 77, 191, 515, + -475, -791, -417, 75, 201, 343, 408, 549, 612, 707, 686, 572, 463, 457, 321, 373, + 842, 716, 669, 593, 419, 423, 373, 321, 273, 280, 354, 217, 193, 232, 175, 294, + 116, -60, -144, -299, -421, -551, -732, -952, -1203, -1662, -1996, -537, -240, 55, 138, 486, + -323, -665, -686, -214, -201, -260, -373, -329, -333, -165, 66, 96, 175, 310, 291, 486, + -19, 43, 35, 40, 42, 55, 63, 101, 133, 194, 222, 152, 117, 145, 133, 213 +}; + + +const Word16 *const Quantizers_fx[] = { SVNB_SN1_fx, SVNB_SN2_fx, GETRNB_SN1_fx, GETRNB_SN2_fx, AUNB_SN1_fx,SVWB_SN1_fx, SVWB_SN2_fx, GETRWB_SN1_fx, + GETRWB_SN2_fx, AUWB_SN1_fx,/* U13, */ + TRWB2_SN1_fx, TRWB2_SN2_fx, AUWB2_SN1_fx, CNG_SN1_fx +}; + +const Word16 *const Quantizers_p_fx[] = { IAA_MA1_fx, UVD_MA1_fx, UVD_MA2_fx, UVWB_MA3_fx, GESVNB_AR1_fx, GESVNB_AR2_fx, GESVWB_AR1_fx, GESVWB_AR2_fx, + GEWB2_MA1_fx,GEWB_MA1_fx, AUWB2_MA1_fx +}; + const float vals[NO_LEADERS][MAX_NO_VALS]= { {1.0f, 0.0f, 0.0f, 0.0f}, @@ -10868,6 +12042,58 @@ const float vals[NO_LEADERS][MAX_NO_VALS]= {2.5f, 1.5f, 0.5f, 0.0f}, {3.5f, 1.5f, 0.5f, 0.0f} }; +const Word16 vals_fx[NO_LEADERS][MAX_NO_VALS] = /*Q1 */ +{ + {2, 0, 0, 0}, + {1, 0, 0, 0}, + {2, 0, 0, 0}, + {4, 0, 0, 0}, + {3, 1, 0, 0}, + {2, 0, 0, 0}, + {4, 2, 0, 0}, + {3, 1, 0, 0}, + {2, 0, 0, 0}, + {4, 2, 0, 0}, + {4, 0, 0, 0}, + {3, 1, 0, 0}, + {5, 1, 0, 0}, + {4, 2, 0, 0}, + {4, 2, 0, 0}, + {6, 2, 0, 0}, + {3, 1, 0, 0}, + {5, 3, 1, 0}, + {4, 2, 0, 0}, + {4, 0, 0, 0}, + {6, 2, 0, 0}, + {3, 1, 0, 0}, + {5, 3, 1, 0}, + {4, 2, 0, 0}, + {4, 2, 0, 0}, + {6, 2, 0, 0}, + {6, 4, 2, 0}, + {3, 1, 0, 0}, + {5, 3, 1, 0}, + {5, 1, 0, 0}, + {7, 1, 0, 0}, + {4, 2, 0, 0}, + {4, 0, 0, 0}, + {6, 2, 0, 0}, + {6, 4, 2, 0}, + {8, 0, 0, 0}, + {3, 1, 0, 0}, + {5, 3, 1, 0}, + {5, 3, 1, 0}, + {7, 3, 1, 0}, + {4, 2, 0, 0}, + {6, 4, 2, 0}, + {6, 4, 2, 0}, + {6, 0, 0, 0}, + {8, 2, 0, 0}, + {3, 0, 0, 0}, + {5, 3, 1, 0}, + {5, 3, 1, 0}, + {7, 3, 1, 0}, +}; const int16_t no_vals[NO_LEADERS]= {2,1,2,2,2,2,3,2,1,3,2,2,2,3,3,3,2,3,3,2,3,2,3,2,3,3,4,2,3,2,2,3,2,2,4,2,2,3,3,3,3,4,4,2,3,1,3,3,3}; @@ -11482,6 +12708,315 @@ const float scales_p[][MAX_NO_SCALES*2]= /* 2 subvectors 20 modes */ {0.787f, 1.257f, 0.596f, 1.106f, 0.735f, 1.659f, }, /* 37 (36.961) */ /* AUDIO 16k */ }; +const Word16 scales_fx[][6] = +{ + {3129, 0, 0, 3138, 0, 0, }, /* 14 */ + {3287, 0, 0, 3138, 0, 0, }, /* 15 */ + {2611, 5034, 0, 3138, 0, 0, }, + {2611, 5034, 0, 3340, 0, 0, }, + {2165, 3674, 5931, 2363, 3809, 6281, }, + {1898, 2986, 4745, 2116, 3668, 7045, }, /* 28 */ /* mode 0 UV WB*/ + {2630, 5480, 0, 2972, 0, 0, }, + {2802, 0, 0, 2869, 5073, 0, }, + {1763, 2546, 3723, 2515, 4559, 21109, }, + {2195, 3961, 7440, 2501, 6017, 21961, }, + {1841, 2902, 1386, 2116, 3762, 22309, }, + {1700, 2710, 1288, 1866, 3246, 20660, }, /* 32 */ /* mode 1 UV NB*/ + + + {3222, 0, 0, 3391, 0, 0, }, + {2537, 4923, 0, 3187, 0, 0, }, + {2161, 3482, 9091, 3391, 0, 0, }, + {2560, 4923, 8462, 2775, 4835, 0, }, + {2163, 3656, 9263, 2699, 5296, 0, }, + {2040, 3082, 6871, 2427, 3637, 5587, }, + {1903, 2841, 6875, 2212, 3484, 5908, }, + {1888, 3058, 6900, 2212, 3484, 5908, }, + {1888, 3058, 6900, 2183, 3469, 6420, }, + {1888, 3058, 6900, 1970, 3174, 8081, }, + {1528, 2269, 5876, 1964, 3033, 8002, }, + {1577, 2445, 5782, 1858, 2871, 4334, }, + + {1532, 2259, 5870, 2421, 1661, 6824, }, /* 34 */ + + {1386, 1972, 4356, 1487, 2216, 4514, }, /* 37 */ /* mode 2 V WB*/ + {3357, 0, 0, 2494, 4426, 0, }, + {2634, 5009, 0, 2888, 0, 0, }, + {2224, 3539, 7696, 2494, 4426, 0, }, + {2120, 3226, 9861, 2494, 4426, 0, }, + {1974, 3140, 10121, 2494, 4426, 0, }, + {1722, 2454, 4059, 2494, 4426, 0, }, + {1839, 2658, 4473, 2490, 5456, 0, }, + {1722, 2533, 4581, 2038, 3394, 5808, }, + + {1427, 2009, 4184, 1915, 3082, 1350, }, + {1370, 1862, 2720, 2017, 1339, 3914, }, /* 37 */ /* mode 3 V NB */ + + {2482, 3885, 0, 0, 0, 0, }, + {3346, 0, 0, 3418, 0, 0, }, + {2638, 4962, 0, 3418, 0, 0, }, + {2482, 3885, 0, 3418, 0, 0, }, + {2218, 3617, 6502, 3418, 0, 0, }, + {2124, 3295, 8659, 3418, 0, 0, }, + {2243, 3398, 5562, 2693, 5132, 0, }, + {1927, 2839, 4549, 2693, 5132, 0, }, + {1860, 2675, 3893, 2703, 5372, 0, }, + {2202, 3619, 1618, 2703, 5372, 0, }, + {2093, 3135, 1554, 2273, 3594, 5313, }, + {2202, 3619, 1618, 2238, 3895, 6173, }, + {1829, 3015, 1382, 2259, 3625, 5820, }, + {1864, 3170, 1403, 2114, 3381, 5147, }, + {1692, 2572, 1294, 2009, 3158, 4540, }, /* 32 (31.995) */ /* G WB*/ + {2425, 3707, 5655, 0, 0, 0, }, + {3299, 0, 0, 3314, 0, 0, }, + {2425, 3707, 5655, 3174, 0, 0, }, + {2425, 3707, 5655, 3314, 0, 0, }, + {2177, 3557, 6113, 3314, 0, 0, }, + {2208, 3738, 6476, 3009, 4606, 0, }, + {2816, 1874, 4264, 3009, 4606, 0, }, + {1966, 2914, 1434, 2683, 4366, 0, }, + {2302, 1626, 3895, 2628, 4714, 0, }, + {2206, 3537, 1571, 2560, 3996, 6105, }, + {1911, 3013, 1403, 2560, 3996, 6105, }, + {1898, 3277, 1380, 2363, 3637, 5845, }, + {2144, 1479, 3656, 2163, 3363, 5532, }, + {1989, 1409, 3090, 2136, 3543, 6003, }, + {1882, 1356, 2800, 2165, 3703, 6285, }, /* 32 (31.987) */ /* G NB*/ + {3312, 0, 0, 3394, 0, 0, }, + {2611, 4706, 0, 3201, 0, 0, }, + {2679, 4821, 0, 2841, 0, 0, }, + {2644, 4952, 0, 2775, 5003, 0, }, + {2210, 3623, 6169, 2841, 0, 0, }, + {2210, 3623, 6169, 2714, 5233, 0, }, + {1837, 2744, 5333, 2191, 3459, 5175, }, + {1837, 2744, 5333, 1923, 2978, 4266, }, + {1853, 2718, 5323, 2271, 1591, 3492, }, + {1561, 2255, 4831, 1923, 2978, 4266, }, + {1626, 2511, 6513, 2271, 1591, 3492, }, /* 33 */ + /* mode 6 T WB */ + {3336, 0, 0, 2439, 4528, 0, }, + {2615, 5237, 0, 2800, 0, 0, }, + {2216, 3607, 8047, 2439, 4528, 0, }, + {2085, 3144, 5751, 2439, 4528, 0, }, + {1933, 3025, 5659, 2439, 4528, 0, }, + {1864, 3572, 6793, 2439, 4528, 0, }, + {1884, 3375, 6283, 1985, 3447, 8096, }, + {1513, 2275, 5517, 1800, 2890, 4721, }, + {1452, 2114, 5564, 1659, 2550, 3736, }, /* 32 */ /* mode 7 T NB */ + + {1552, 2286, 4022, 2497, 4139, 1634,}, + {1432, 2118, 4051, 2497, 4139, 1634, }, /* 32 */ /* mode 8 G 16k */ + + {1487, 2150, 3779, 2775, 1761, 4516, }, + {1386, 2042, 3418, 2775, 1761, 4516, }, /* 33 (32.983) */ /* T 16k */ + + {3371, 0, 0, 2568, 5036, 0, }, + {2198, 3815, 6617, 3437, 0, 0, }, + {2198, 3815, 6617, 2568, 5036, 0, }, + {1948, 3056, 5112, 2570, 6085, 0, }, + {2351, 3770, 1665, 2570, 6085, 0, }, /* 26 */ + {1233, 1780, 2904, 2589, 1565, 4542, }, /* 36 */ /* mode 10 AUDIO_WB 36 + 4 + 1 */ + + {1747, 3623, 9062, 0, 0, 0, }, + {2071, 3406, 9017, 3232, 0, 0, }, + {2071, 3406, 9017, 2462, 4964, 0, }, + {1804, 3314, 8471, 2462, 4964, 0, }, + {1735, 3668, 9146, 2462, 4964, 0, }, /* 27 */ /* AUDIO_NB */ + {1372, 2277, 4893, 2462, 4964, 0, }, /* 28 */ /* AUDIO_NB */ + {2316, 3717, 1630, 2591, 5722, 0, }, + {1167, 1647, 2451, 2380, 3992, 1491, }, /* 36 */ /* mode 12 AUDIO_WB 16k 15-36 + 4 + 1*/ + {2140, 3248, 7688, 3418, 0, 0, }, + {1802, 2621, 5784, 2251, 3553, 0, }, + {1702, 2488, 5994, 2230, 3498, 5077, }, + {1782, 2718, 5951, 2183, 3521, 5480, }, + + {1581, 2298, 4815, 2961, 1933, 4243, }, + + {1436, 2001, 3559, 1939, 2976, 4264, }, + + {1473, 2091, 3484, 2292, 1626, 3473, }, + + {1311, 1810, 3547, 1546, 2232, 3170, }, /* 37 (36.995) */ /* VOICED 16k */ + {2494, 1630, 4676, 2642, 6810, 0, }, + {3256, 1710, 9085, 2247, 6287, 0, }, + + {2036, 5360, 0, 2234, 4573, 7080, }, + {1817, 3222, 7256, 2228, 3742, 6281, }, + {1714, 2535, 3897, 2658, 5728, 0, }, + {2331, 5788, 0, 2265, 5726, 8993, }, + {1927, 3955, 9161, 1395, 2593, 4768, }, + {2769, 8872, 0, 1679, 3164, 8550, }, + {2750, 7387, 0, 1759, 2976, 5304, }, + {2474, 5612, 0, 1554, 2540, 4469, }, + {2300, 5603, 0, 1790, 3068, 5296, }, + {1882, 5061, 0, 1260, 2195, 4293, }, + {3170, 9232, 0, 1690, 4461, 8817, }, + {2492, 5935, 0, 1509, 2492, 3953, }, + + {1999, 4485, 11706, 3084, 1315, 8624, }, + {2267, 5315, 0, 2666, 1237, 1802}, /* CNG */ + +};/* An 6-by-146 matrix in Scale = 2048.00f */ +const Word16 scales_p_fx[][6] = +{ + {2998, 4862, 0, 0, 0, 0, }, + {2591, 5251, 0, 3355, 0, 0, }, + {2177, 3488, 5745, 2650, 4819, 0, }, + {2177, 3926, 6273, 2796, 0, 0, }, + {1872, 2892, 4553, 2650, 4819, 0, }, + {1806, 2869, 4919, 2689, 4999, 0, }, + {2777, 1776, 4868, 2191, 3453, 5214, }, + {1733, 2761, 5214, 2204, 3568, 5444, }, + {1731, 2824, 5255, 2087, 3230, 5003, }, + {1548, 2435, 5732, 2220, 3695, 5648, }, + {1546, 2494, 5777, 1933, 2935, 4041, }, + {1483, 2529, 6025, 2570, 1737, 4096, }, + {1407, 2279, 4788, 1747, 2720, 3981, }, + {1327, 2107, 3760, 1749, 2777, 4016, }, + {1327, 2107, 3760, 1407, 2167, 3891, }, /* 39 (38.488) */ /* V WB*/ /* 14 */ + {3303, 0, 0, 0, 0, 0, }, + {2595, 5069, 0, 3316, 0, 0, }, + {2077, 3338, 5046, 2632, 4405, 0, }, + {1829, 2847, 4739, 3000, 4708, 0, }, + {1905, 2869, 4403, 2621, 4616, 0, }, + {1829, 2847, 4739, 2613, 4518, 6111, }, + {1829, 2847, 4739, 2122, 3371, 5061, }, + {1755, 2738, 5046, 2136, 3543, 5376, }, + {1567, 2497, 3181, 2122, 3371, 5061, }, + {1616, 2720, 3383, 2154, 3654, 5542, }, + {1565, 2507, 3185, 1884, 2955, 4168, }, + {1358, 2173, 2535, 2824, 1839, 3996, }, + {1378, 2261, 2675, 2578, 1696, 4002, }, + {1364, 2193, 2558, 1645, 2542, 3541, }, + {1348, 2128, 2486, 1946, 1333, 2927, }, /* 39 (38.512) */ /* V NB*/ /* 29 */ + {3277, 0, 0, 3181, 0, 0, }, + {2322, 4067, 6748, 3181, 0, 0, }, + {2021, 3662, 5446, 3373, 0, 0, }, + {1841, 3281, 5282, 3373, 0, 0, }, + {1632, 2650, 4383, 3373, 0, 0, }, + {1632, 2650, 4383, 2734, 4557, 0, }, + {1518, 2357, 3719, 2734, 4557, 0, }, + {1632, 2650, 4383, 2429, 3957, 0, }, + {1518, 2357, 3719, 2384, 3734, 5671, }, + {1450, 2306, 4000, 2204, 3543, 5687, }, + {1352, 2148, 3217, 2204, 3543, 5687, }, + {1356, 2101, 3183, 2200, 3918, 6189, }, + {1352, 2148, 3217, 2947, 1896, 4364, }, + {1290, 1978, 3117, 2687, 1804, 4520, }, + {1264, 1886, 2963, 2114, 3172, 1548, }, /* 35 (34.994) */ /* G WB*/ /* 44 */ + {3267, 0, 0, 3076, 0, 0, }, + {2300, 3985, 7643, 3076, 0, 0, }, + {2116, 4250, 8886, 2906, 5009, 0, }, + {2017, 3672, 12216, 2623, 4760, 0, }, + {1804, 3289, 14326, 2906, 5009, 0, }, + {1729, 3240, 14377, 2623, 4760, 0, }, + {1616, 3113, 14752, 2623, 4760, 0, }, + {1780, 3168, 14326, 2109, 3592, 6353, }, + {1673, 3056, 14582, 2109, 3592, 6353, }, + {1546, 2830, 14608, 2109, 3592, 6353, }, + {1446, 2693, 14797, 2109, 3592, 6353, }, + {1411, 2654, 14930, 2081, 3840, 6633, }, + {1430, 2611, 14764, 1872, 3170, 4983, }, + {1391, 2693, 14930, 2517, 3779, 1665, }, + {1391, 2693, 14930, 2433, 1581, 4004, }, /* 35 (34.952) */ /* G NB*/ /* 59 */ + + {2070, 3639, 5652, 3305, 0,0,}, + {1747, 2830, 4231, 2550, 5487, 0,}, + {2472, 1593, 4522, 2550, 5487, 0,}, + {2472, 1593, 4522, 2075, 3752, 6253}, + {2472, 1593, 4522, 2908, 1786, 4772,}, + {1075, 1577, 2198, 1669, 2533, 1161}, /* 40 (39.990) */ /* AUDIO_WB */ /* 65 */ + + {2191, 3668, 7993, 3275, 0, 0, }, + {1679, 2492, 4278, 2570, 4690, 0, }, + {1597, 2394, 5110, 2570, 4690, 0, }, + {2202, 1481, 4835, 2273, 4016, 7150, }, + + {1415, 2107, 4786, 2118, 3668, 8200, }, /* 31 */ /*AUDIO_NB */ /* 70 */ + {1374, 2204, 5337, 1956, 3168, 5149, }, /* 32 */ /*AUDIO_NB */ /* 71 */ + {2425, 4336, 1589,3420, 2165, 1380, }, + {1067, 1530, 2116, 1630, 2730, 1110,}, /* 40 */ /* mode AUDIO_WB 16k */ /* 73*/ + + {3439, 0, 0, 2626, 5061, 0, }, + {2228, 3787, 6543, 3455, 0, 0, }, + {2228, 3787, 6543, 2626, 5061, 0, }, + {2306, 3459, 1618, 2626, 5061, 0, }, + {1905, 2830, 1397, 2626, 5061, 0, }, + {2284, 1626, 3793, 2623, 6212, 0, }, + {1720, 2818, 1276, 1638, 2900, 8724, }, /* 36 (35.998) */ /* INACTIVE NB */ + {1640, 2351, 3690, 0, 0, 0, }, + {2230, 3711, 6496, 3434, 0, 0, }, + {2230, 3899, 6597, 3115, 5396, 0, }, + {1731, 2482, 3961, 2689, 4954, 0, }, + {1595, 2243, 3482, 2689, 4954, 0, }, + {1481, 2079, 3408, 2689, 4954, 0, }, + {1829, 1335, 2945, 2204, 1475, 3674, }, /* 36 (35.929) */ /* INACTIVE WB*/ + {2783, 4723, 0, 3418, 0, 0, }, + {2206, 3946, 7262, 3418, 0, 0, }, + {2206, 4162, 7328, 2927, 5552, 0, }, + {1706, 2566, 4311, 2628, 5235, 0, }, + {1589, 2359, 3805, 2628, 5235, 0, }, + {1473, 2183, 3547, 2628, 5235, 0, }, + {1927, 1333, 3205, 1479, 2437, 3973, }, /* 36 (35.915) */ /* INACTIVE 16k*/ + + {2646, 5077, 0, 3156, 0, 0, }, + {2462, 3897, 0, 3156, 0, 0, }, + {2105, 3361, 5028, 3375, 0, 0, }, + {2554, 1798, 4770, 3375, 0, 0, }, + {1767, 2781, 5165, 3375, 0, 0, }, + {1673, 2503, 4116, 2200, 3656, 5597, }, + {1669, 1253, 2623, 2161, 3531, 6046, }, /* 32 (31.990) */ /* UNVOICED NB*/ + + {3164, 0, 0, 3170, 0, 0, }, + {3359, 0, 0, 3170, 0, 0, }, + {2636, 5630, 0, 3170, 0, 0, }, + {2636, 5630, 0, 3387, 0, 0, }, + {2437, 4149, 0, 3387, 0, 0, }, + {1907, 2986, 5018, 2650, 5616, 0, }, + {1796, 2859, 5605, 2214, 3719, 6881, }, /* 28 (27.996) */ /* UNVOICED WB */ + {2316, 3351, 0, 2808, 0, 0, }, + {1913, 2615, 1491, 2370, 3475, 0, }, + {1706, 2380, 1348, 2357, 3455, 0, }, + {1538, 2114, 1225, 2357, 3455, 0, }, + {1452, 2058, 1167, 2171, 3629, 5569, }, + {1528, 2050, 1231, 2056, 3693, 5923, }, + {1522, 2048, 1227, 1917, 3811, 5886, }, + {1587, 1257, 2124, 1630, 2671, 3901, }, /* 39 (38.301) */ /* VOICED 16k */ + {1831, 2742, 5220, 2679, 5327, 0, }, + {1475, 2073, 3273, 3097, 1896, 4377, }, + {1395, 1993, 3377, 2828, 1794, 4360, }, + {1401, 1974, 3359, 2392, 3637, 1612, }, + {1368, 1915, 3176, 2081, 3109, 1458, }, + {1350, 1866, 2918, 2738, 1821, 1315, }, + {1350, 1866, 2918, 1718, 2636, 1243, }, /* 37 (36.989) */ /* GENERIC 16k*/ + {3344, 0, 0, 3455, 0, 0, }, + {2204, 3666, 6025, 3455, 0, 0, }, + {1708, 2517, 3871, 3455, 0, 0, }, + {1921, 2875, 4409, 2675, 5386, 0, }, + {2744, 1815, 4751, 2675, 5386, 0, }, + {1706, 2560, 3908, 2675, 5386, 0, }, + {1706, 2484, 3836, 2304, 3766, 5773, }, + {1567, 2380, 3461, 2097, 3559, 5812, }, + {1485, 2150, 3668, 3031, 1888, 6357, }, + {1458, 2073, 3172, 3060, 1849, 6889, }, + {1350, 1898, 2779, 3060, 1849, 6889, }, + {1683, 1257, 2638, 1864, 3090, 4618, }, + {1722, 1278, 2617, 2378, 1561, 3703, }, + {1716, 1274, 2593, 2212, 1456, 3502, }, + {1704, 1268, 2611, 1921, 2929, 1319, }, /* 37 (36.971) */ /* GENERIC 12.8k MA*/ + {1810, 2763, 5263, 2691, 5343, 0, }, + {1456, 2085, 3308, 3035, 1886, 7027, }, + + {1391, 1995, 3398, 1942, 3172, 7062, }, + + {1702, 1266, 3033, 1911, 3101, 4731, }, + {1671, 1249, 2871, 2920, 1796, 4639, }, + {1612, 2574, 1221, 1759, 2963, 4979, }, + {1612, 2574, 1221, 2265, 1505, 3398}, /* 37 (36.993) */ /* AUDIO 16k */ + +}; + + /* An 16-by-34 matrix in Scale = 20.48f */ const float sigma_MSLVQ[][16] = { @@ -11520,6 +13055,43 @@ const float sigma_MSLVQ[][16] = {97.1679688f, 101.0253906f, 104.3945313f, 110.4003906f, 108.7890625f, 107.4707031f, 97.8515625f, 92.6757813f, 79.1503906f, 81.6406250f, 77.1972656f, 108.8867188f, 212.2070313f, 198.8281250f, 47.4609375f, 35.3515625f }, {74.8535156f, 97.3632813f, 100.1464844f, 91.6992188f, 90.3808594f, 89.6484375f, 83.2031250f, 84.0820313f, 81.9335938f, 96.4355469f, 110.9863281f, 92.6757813f, 83.4960938f, 82.1289063f, 77.8808594f, 70.8984375f} }; +const Word16 sigma_MSLVQ_fx[][16] = +{ + {3}, + {3}, + {107, 113, 160, 185, 202, 211, 219, 222, 222, 217, 218, 270, 327, 176, 66, 43}, + {125, 130, 182, 185, 191, 199, 204, 207, 205, 191, 179, 227, 305, 261, 95, 64}, + {123, 123, 176, 197, 207, 218, 228, 235, 232, 218, 209, 272, 342, 216, 89, 68}, + {219, 212, 255, 271, 273, 274, 260, 255, 250, 248, 249, 302, 328, 394, 85, 37}, + {3}, + {3}, + {113, 134, 220, 253, 260, 275, 274, 287, 304, 323, 321, 325, 349, 350, 376, 332}, + {158, 179, 242, 248, 246, 259, 257, 267, 278, 274, 276, 289, 309, 309, 312, 306}, + {146, 146, 222, 256, 261, 278, 290, 302, 318, 313, 323, 352, 394, 407, 415, 399}, + {217, 227, 287, 303, 316, 310, 296, 304, 303, 305, 317, 327, 355, 321, 305, 279}, + {3}, + {3}, + {193, 216, 283, 320, 343, 359, 375, 408, 413, 445, 479, 489, 502, 466, 456, 479}, + {230, 238, 312, 330, 334, 329, 339, 357, 353, 358, 391, 403, 441, 459, 379, 497}, + {231, 277, 304, 322, 347, 353, 366, 372, 373, 397, 438, 451, 424, 413, 381, 447}, + {264, 287, 364, 386, 384, 373, 382, 373, 393, 403, 448, 438, 403, 430, 401, 586}, + {224, 298, 262, 264, 258, 244, 260, 283, 313, 295, 275, 279, 260, 286, 286, 399}, + {411, 314, 301, 332, 335, 343, 356, 409, 430, 413, 363, 364, 338, 332, 315, 412}, + {136, 269, 343, 367, 405, 430, 411, 421, 444, 466, 435, 423, 328, 247, 235, 240}, + {178, 433, 305, 268, 258, 252, 253, 246, 250, 250, 245, 256, 242, 273, 300, 371}, + {349, 334, 335, 341, 336, 331, 343, 425, 505, 722, 783, 655,1006, 862, 346, 248}, + {315, 306, 323, 306, 300, 278, 276, 287, 380, 394, 327, 333, 339, 382, 370, 626}, + {236, 250, 241, 231, 241, 245, 238, 221, 215, 190, 181, 178, 183, 428, 184, 55}, + {113, 189, 360, 312, 332, 326, 296, 268, 272, 282, 320, 275, 219, 203, 179, 143}, + {273, 255, 245, 237, 242, 236, 214, 217, 223, 260, 233, 193, 187, 183, 174, 163}, + {111, 321, 275, 219, 213, 207, 202, 205, 205, 225, 239, 208, 192, 187, 168, 152}, + {383, 326, 300, 287, 290, 292, 276, 251, 258, 291, 430, 521, 397, 305, 274, 269}, + {152, 221, 271, 291, 344, 310, 308, 257, 252, 256, 339, 491, 499, 199, 179, 107}, + {226, 237, 236, 239, 250, 238, 228, 223, 227, 241, 311, 312, 299, 313, 421, 360}, + {221, 238, 214, 220, 246, 244, 232, 221, 210, 208, 200, 229, 368, 431, 106, 71}, + {249, 259, 267, 283, 278, 275, 251, 237, 203, 209, 198, 279, 543, 509, 122, 90}, + {192, 249, 256, 235, 231, 230, 213, 215, 210, 247, 284, 237, 214, 210, 199, 181}, +}; /* An 16-by-34 matrix in Scale = 20.48f */ const float inv_sigma_MSLVQ[][16] = @@ -11606,6 +13178,28 @@ const float inv_sigma_p[][16] = {0.0181399f, 0.0142124f, 0.0120329f, 0.0114670f, 0.0110464f, 0.0109343f, 0.0105567f, 0.0106834f, 0.0102451f, 0.0101286f, 0.0095522f, 0.0100343f, 0.0104597f, 0.0109110f, 0.0113024f, 0.0127840f },/* NOT USED ! AU 16k */ {0.0143820f, 0.0124726f, 0.0098699f, 0.0099081f, 0.0093902f, 0.0089943f, 0.0092922f, 0.0088505f, 0.0085690f, 0.0085333f, 0.0082681f, 0.0079938f, 0.0076475f, 0.0077693f, 0.0081045f, 0.0095300f} /* G WB for MA*/ }; +const Word16 sigma_p_fx[][16] = +{ + {152, 164, 179, 170, 172, 176, 171, 169, 169, 174, 175, 216, 247, 304, 113, 110}, + {131, 171, 178, 176, 174, 178, 178, 178, 135, 166, 167, 176, 183, 197, 199, 206}, + {84, 89, 120, 142, 154, 175, 184, 186, 189, 181, 178, 198, 245, 190, 54, 28}, + {138, 157, 200, 194, 189, 208, 207, 206, 214, 197, 186, 222, 311, 302, 103, 43}, + {3}, + {146, 165, 183, 194, 197, 202, 191, 190, 187, 186, 171, 189, 281, 311, 61, 34}, + {142, 168, 184, 183, 187, 190, 187, 188, 189, 193, 200, 212, 231, 245, 169, 177}, + {174, 164, 168, 197, 300, 372, 199, 59, 208, 208, 209, 218, 231, 246, 237, 232}, + {91, 101, 147, 165, 174, 195, 207, 210, 218, 230, 230, 244, 268, 272, 269, 250}, + {157, 192, 226, 210, 211, 228, 228, 241, 245, 246, 248, 263, 274, 275, 270, 251}, + {3}, + {131, 160, 183, 193, 202, 205, 203, 212, 212, 213, 217, 220, 229, 214, 203, 200}, + {187, 221, 231, 229, 237, 232, 232, 236, 249, 259, 286, 284, 250, 238, 238, 296}, + {3}, + {140, 173, 241, 320, 314, 315, 304, 295, 329, 359, 369, 357, 388, 354, 359, 396}, + {248, 300, 339, 344, 360, 350, 363, 361, 368, 391, 431, 433, 406, 400, 377, 467}, + {3}, + {141, 180, 213, 223, 232, 234, 242, 240, 250, 253, 268, 255, 245, 235, 227, 200}, + {178, 205, 259, 258, 273, 285, 275, 289, 299, 300, 310, 320, 335, 329, 316, 269}, +}; const Word8 leaders_short[][MAX_NO_SCALES] = {{ 0, 0, 0}, @@ -12305,6 +13899,8 @@ const int16_t offset_lvq_modes_SN[] = {-1,-1,33,64,96, 129,-1,-1,12,43,79,109,-1 }; /* CNG */ const int16_t offset_lvq_modes_pred[] = {119, 153, 31, 67, -1, 102, 126, 160, 0, 46, -1, 82, 146, -1, 175, 191, -1, 225, 203}; +const Word16 offset_lvq_modes_pred_fx[] = { 74, 95, 15, 45, -1, 66, 81, 102, 0, 30, -1, 60, 88, -1, 109, 117, -1, 139, 124 }; + const int16_t offset_in_lvq_mode_SN[][21] = { {0}, /* I NB */ @@ -12398,7 +13994,34 @@ const float SN_IntraCoeff[N_STAGE_VQ-1][2][2] = {{-0.023860f, 0.611144f}, {-0.162706f, 0.576228f}} }; +const Word16 SN_IntraCoeff_fx[N_STAGE_VQ - 1][2][2] = /* Q15 */ +{ + {{-14822, 26501}, {-17180, 10012}}, + {{ 317, 19858}, { -432, 13799}}, + {{ 4747, 22069}, { 2653, 19016}}, + {{ 6823, 20747}, { 7077, 19154}}, + {{ 1665, 25161}, { 2519, 13654}}, + {{ 166, 18043}, { -221, 9732}}, + {{ -781, 20026}, { -5332, 18882}} +}; + +const Word16 AR_IntraCoeff_fx[N_STAGE_VQ - 1][2][2] = /* Q15 */ +{ + {{-9584, 22162}, {-13849, 7127}}, + {{ 1604, 16400}, { 2861, 9414}}, + {{ 6537, 16475}, { 3498, 13792}}, + {{ 7879, 14434}, { 7021, 12992}}, + {{ 6329, 16215}, { 5200, 10052}}, + {{ 3062, 12146}, { 2147, 4857}}, + {{ 1226, 11040}, { -794, 6137}} +}; + const float scale_ARSN[M] = {1.8307f, 1.8404f, 1.8009f, 1.7416f, 1.7240f, 1.7467f, 1.6106f, 1.6497f, 1.5702f, 1.5548f, 1.5745f, 1.6199f, 1.5633f, 1.5239f, 1.5796f, 1.5615f}; +const Word16 scale_ARSN_fx[M] = /* Q14 */ +{ + 29994, 30153, 29506, 28534, 28246, 28618, 26388, 27029, + 25726, 25474, 25797, 26540, 25613, 24968, 25880, 25584 +}; const float scale_inv_ARSN[M] = {0.5462f, 0.5434f, 0.5553f, 0.5742f, 0.5800f, 0.5725f, 0.6209f, 0.6062f, 0.6369f, 0.6432f, 0.6351f, 0.6173f, 0.6397f, 0.6562f, 0.6331f, 0.6404f}; /* TCVQ Codebook */ @@ -12499,6 +14122,97 @@ const float AR_TCVQ_CB_SUB3[4][32][2] = } }; +const Word16 AR_TCVQ_CB_SUB1_fx[2][128][2] = /* x2.65 */ +{ + { + {-435 , -434}, {-233 , 124}, {-381 , 44}, {-274 , -88}, {-332 , -224}, {-563 , -600}, {-332 , 134}, { 53 , -739}, + {-567 , 0}, { 149 , 316}, {-191 , 541}, {-123 , 317}, {-493 , -634}, {-528 , 268}, {-321 , -386}, {-432 , -220}, + {-244 , -230}, { -33 , 454}, {-188 , -642}, {-131 , -215}, {-676 , 263}, {-472 , -403}, {-312 , -159}, {-340 , 297}, + {-121 , -217}, { -6 , 241}, {-203 , -211}, {-126 , -15}, {-734 , -374}, {-458 , -6}, {-297 , -27}, {-307 , -553}, + {-177 , 3}, {-175 , -273}, { 63 , 363}, { 133 , 527}, {-133 , -185}, {-449 , -1206}, {-287 , -281}, {-131 , 869}, + {-100 , -105}, { -75 , -179}, {-141 , 131}, { -32 , 108}, { -81 , 161}, {-446 , -230}, {-283 , -884}, {-128 , -165}, + {-153 , -451}, {-177 , -114}, {-113 , -127}, {-223 , -355}, {-246 , -447}, {-396 , -705}, {-280 , 329}, { -37 , -64}, + {-118 , 208}, { -82 , 64}, {-339 , -367}, { -58 , -132}, {-458 , 644}, {-381 , -543}, {-272 , 557}, { 62 , 75}, + {-307 , -829}, { 310 , 445}, { 73 , -26}, { 95 , 219}, { 223 , 611}, { 279 , 195}, { 430 , 575}, { 424 , 221}, + { -25 , 2}, { 323 , 236}, {-100 , -310}, { 11 , -35}, { 83 , -3}, { 281 , 738}, { 495 , 393}, { 89 , 1284}, + { 32 , 136}, { 29 , 34}, { 491 , 575}, { 105 , -188}, { 15 , -440}, { 285 , 10}, { 516 , -105}, { 313 , 704}, + { -6 , -274}, { -62 , -64}, { -12 , -127}, { 170 , 2387}, { 162 , 196}, { 336 , 413}, { 543 , 210}, { 231 , -70}, + { -2 , 691}, { 98 , 134}, { 25 , 141}, { 261 , 305}, { 312 , -322}, { 336 , 228}, { 561 , 781}, { 766 , 514}, + { -14 , -117}, { 166 , 905}, { -50 , 1}, { 471 , 369}, { 345 , 247}, { 347 , -383}, { 561 , 1128}, { 513 , 1030}, + { 100 , -15}, { 185 , 70}, { 167 , 131}, { 122 , 36}, { 561 , 743}, { 401 , 111}, { 595 , -579}, { 674 , 215}, + { 191 , 189}, { 38 , -78}, { 428 , 0}, { 261 , 136}, { -29 , -99}, { 405 , 308}, { 614 , 574}, {1682 , 1704} + }, + { + {-942 , -168}, {-262 , -361}, { -53 , -171}, {-245 , 472}, {-2145 , -2315}, {-1307 , 1261}, {-870 , -1940}, { -652 , -564}, + {-500 , 447}, {-578 , -198}, {-554 , 111}, { -98 , -84}, {-1315 , 0}, {-1229 , -1618}, {-868 , 230}, { -385 , 1061}, + {-768 , -998}, {-202 , -60}, {-283 , -197}, {-142 , -325}, { -558 , 755}, {-1217 , 456}, {-803 , 766}, { -982 , 743}, + {-415 , -357}, { -28 , 1054}, { 114 , -246}, { 81 , 732}, { -804 , -506}, {-1126 , -112}, {-797 , -132}, { -289 , -204}, + {-347 , -29}, { -37 , -259}, {-142 , -438}, {-249 , 87}, { -874 , 341}, {-1074 , -2635}, {-668 , -1552}, {-1140 , -764}, + {-245 , -513}, { -48 , 526}, { 14 , 395}, {-452 , -646}, { -441 , -969}, { -953 , -1284}, {-645 , -387}, { -736 , 111}, + {-163 , 305}, {-349 , 224}, {-225 , 736}, { 94 , -85}, { -302 , -549}, { -937 , -892}, {-605 , -1089}, { -64 , -101}, + {-161 , -211}, {-392 , -1299}, {-148 , 125}, { 14 , 131}, { -432 , -127}, { -920 , -510}, {-598 , -730}, { 85 , 154}, + { 25 , -155}, { -57 , 238}, { 471 , 276}, { 421 , 680}, { -173 , 316}, { 597 , 1805}, { 906 , -673}, { 538 , 450}, + {-267 , -805}, { 2 , -19}, { 222 , 219}, { 185 , 352}, { -33 , -178}, { 606 , 118}, { 959 , -70}, { 350 , -91}, + { -87 , 42}, { 727 , 905}, { 54 , 33}, { 316 , 44}, { 251 , 15}, { 610 , -122}, { 990 , 1436}, { 82 , 1480}, + { 181 , 535}, { 177 , 130}, { 700 , 565}, { 626 , 331}, { 279 , 551}, { 680 , 707}, {1012 , 727}, { 1057 , 766}, + { -13 , -396}, { 364 , 412}, { 442 , -181}, { 202 , -386}, { 565 , 1397}, { 740 , 2621}, {1080 , 361}, { 1118 , 191}, + { 81 , 266}, { 217 , -130}, { 349 , 1009}, { 678 , -476}, { 1361 , 878}, { 795 , 472}, {1267 , 1034}, { 1040 , 1255}, + { 351 , 201}, { -69 , -633}, { -36 , -1046}, { 808 , 30}, { 1300 , -198}, { 803 , 1026}, {1390 , -326}, { 2291 , 2479}, + { 166 , 13}, { 521 , 84}, { 255 , -717}, { 987 , 448}, { 777 , 220}, { 811 , 208}, {1395 , 2021}, { 1499 , 417} + } +}; +const Word16 AR_TCVQ_CB_SUB2_fx[2][64][2] = +{ + { + {-357 , -53}, {-525 , 167}, {-232 , 255}, {-132 , -359}, {-940 , -221}, { -260 , -1296}, {-1197 , -455}, { -833 , 49}, + {-132 , -1}, {-401 , -280}, {-212 , -217}, {-194 , 92}, {-580 , -710}, { -862 , -750}, { -669 , 430}, { -521 , 719}, + {-620 , -454}, {-239 , 509}, { -15 , -575}, { 389 , 704}, {-890 , 518}, {-1154 , 84}, { -632 , -1023}, { -620 , -1263}, + {-268 , -470}, {-326 , -738}, { 44 , 635}, { 73 , 362}, {-226 , -22}, { -625 , -106}, { -720 , -114}, {-1114 , -1070}, + { 19 , -250}, { 83 , 99}, { 35 , -16}, { 263 , -316}, { 472 , 1096}, { -52 , -328}, { -249 , 971}, { 1387 , 876}, + { 10 , 203}, { 869 , 649}, { 225 , 170}, { 301 , 83}, {1256 , 482}, { 391 , -777}, { 1064 , -320}, { 52 , 1207}, + { 309 , 375}, { 469 , 226}, { 619 , 400}, { 60 , -93}, { 335 , 244}, { 316 , -65}, { -45 , -987}, { 648 , -294}, + { 218 , -66}, {-108 , -133}, { 500 , -19}, { 824 , 163}, { 483 , -443}, { 1297 , 240}, { 1000 , 1205}, { 623 , 1347} + }, + { + {-424 , -965}, { -46 , -194}, { 20 , 298}, {-333 , -278}, {-797 , -522}, {-868 , -60}, { -20 , -140}, {-1085 , -904}, + {-615 , -243}, {-367 , 22}, {-261 , -519}, {-111 , -27}, {-745 , 142}, {-484 , -1519}, { -329 , 13}, {-1077 , 92}, + {-529 , 218}, {-519 , -597}, {-276 , -72}, { -87 , -398}, { -51 , -1257}, {-291 , 409}, { -883 , 611}, { 176 , -401}, + {-134 , -245}, { 37 , 506}, { 23 , -10}, {-225 , 293}, {-913 , -1324}, {-174 , -290}, {-1086 , -386}, { -139 , -78}, + {-123 , 125}, { -26 , -738}, { 113 , -344}, { 175 , 182}, { 754 , -446}, {1207 , 529}, { 932 , 990}, { 136 , 122}, + { 267 , 327}, { 382 , -182}, { 718 , 471}, { 738 , 108}, { 158 , 130}, { 437 , 401}, { 358 , -667}, { 1380 , 836}, + { 184 , -17}, { 435 , 231}, { 403 , 63}, { 151 , -125}, {-109 , -237}, { 692 , -241}, { 1247 , 193}, { 885 , 324}, + {-283 , 661}, { 44 , 105}, { 156 , 911}, { 387 , 588}, { 690 , 1459}, { 664 , 1057}, { -38 , 1455}, { 645 , 909} + } +}; +const Word16 AR_TCVQ_CB_SUB3_fx[4][32][2] = +{ + { + {-487 , 9}, {-456 , -400}, { 96 , 451}, {-239 , 422}, {-685 , -1309}, { 68 , -709}, {-302 , -1185}, { 481 , -287}, + {-287 , -697}, {-194 , 73}, {-159 , -132}, {-161 , -312}, {-809 , 417}, {-860 , -926}, { -26 , -71}, {-1052 , -432}, + { 53 , 134}, { 106 , -140}, { 336 , -18}, { 404 , 735}, {-109 , -516}, { 719 , -65}, { -34 , 1336}, { -171 , 905}, + { 52 , -347}, { 359 , 266}, { 715 , 351}, { 100 , 133}, { 87 , 130}, { 975 , 999}, {1257 , 547}, { 738 , 1372} + }, + { + {-340 , -464}, {-216 , -779}, { 104 , -403}, { -92 , -221}, {-760 , -602}, {-914 , -811}, {-661 , -895}, {-1292 , -290}, + {-317 , 131}, {-575 , -154}, {-228 , -129}, {-257 , 487}, {-286 , -1354}, { -93 , -259}, {-798 , 179}, { -815 , -1368}, + { 215 , 570}, { -2 , 73}, { 545 , 167}, { 250 , 188}, { 76 , 48}, {-943 , 587}, { 379 , 1232}, { 1070 , 112}, + { 117 , -27}, { 389 , -142}, { 18 , 214}, { 735 , 581}, {1098 , 1244}, { 451 , 408}, {1482 , 650}, { -174 , 1160} + }, + { + {-256 , -485}, { -67 , 571}, { -5 , 161}, {-171 , 153}, {-1188 , -440}, {-1081 , 110}, {-641 , -921}, {-232 , -96}, + {-511 , 146}, {-288 , -93}, { 484 , 665}, {-610 , -366}, { -357 , -899}, { -861 , -1088}, { -78 , -105}, {-265 , -845}, + { 15 , 18}, { 79 , -383}, {-205 , -258}, { 306 , 264}, { 28 , 69}, { 34 , 65}, {1170 , 669}, { 133 , 74}, + { 521 , 183}, { 132 , 84}, { 362 , -90}, { 57 , -181}, { 894 , 456}, { 1147 , 742}, { 212 , 274}, { 891 , 262} + }, + { + { 94 , 464}, { 8 , 138}, {-365 , -640}, {-399 , 172}, {-249 , -109}, { -94 , -316}, {-163 , -250}, {-598 , -704}, + {-185 , 36}, {-470 , -199}, { 65 , 241}, {-104 , -362}, {-220 , -801}, {-866 , -66}, {-931 , -400}, {-172 , -132}, + {-148 , -494}, { 465 , 251}, {-179 , -72}, { 439 , 287}, { 824 , 559}, { 33 , 134}, { 59 , 134}, { 88 , 146}, + { 186 , 43}, { 69 , -261}, { 267 , -96}, { 40 , 79}, { 84 , 130}, { 678 , 378}, { 811 , 448}, { 920 , 541} + } +}; + + const float SN_TCVQ_CB_SUB1[2][128][2] = { { @@ -12596,6 +14310,96 @@ const float SN_TCVQ_CB_SUB3[4][32][2] = } }; +const Word16 SN_TCVQ_CB_SUB1_fx[2][128][2] = +{ + { + {-639 , 105}, {-488 , -449}, {-530 , -811}, {-419 , -634}, {-781 , -1061}, {-585 , 386}, {-501 , -737}, {-489 , -728}, + {-702 , -685}, {-510 , -762}, {-390 , -287}, {-379 , -379}, {-573 , -848}, {-583 , -778}, {-500 , -810}, {-671 , -420}, + {-516 , 802}, {-265 , -492}, {-523 , -568}, {-195 , 2882}, {-600 , -172}, {-568 , -869}, {-497 , 663}, {-643 , -929}, + {-346 , -378}, {-253 , -313}, {-418 , 595}, {-240 , -465}, {-424 , -546}, {-556 , -305}, {-497 , 2453}, {-451 , -235}, + {-452 , -670}, {-368 , -624}, {-379 , -662}, {-305 , -85}, {-549 , 399}, {-546 , -644}, {-484 , -426}, {-387 , -546}, + {-325 , -550}, {-229 , 118}, { -83 , 1004}, {-120 , 465}, {-289 , -222}, {-516 , 155}, {-480 , 1494}, {-415 , 138}, + {-419 , -100}, {-347 , 1091}, {-434 , 76}, {-138 , -291}, {-434 , -719}, {-514 , 945}, {-473 , -26}, {-144 , -320}, + {-376 , 1505}, {-329 , 374}, {-316 , -504}, { -58 , -6}, {-270 , -466}, {-507 , -540}, {-466 , -181}, {-256 , -518}, + {-196 , 726}, { -88 , -356}, {-186 , -394}, { 31 , -201}, { -77 , -319}, { 408 , 136}, { 630 , 680}, { 875 , 1365}, + {-200 , -190}, { 166 , 1289}, { 600 , 1085}, { 276 , 464}, { 567 , 1575}, { 425 , 278}, { 666 , 377}, {1209 , 2344}, + {-182 , -409}, { -95 , -141}, { 65 , 507}, { 127 , 212}, { 340 , 235}, { 481 , 408}, { 721 , 1203}, {1112 , 756}, + { 162 , 362}, { 138 , 753}, {-169 , -128}, { 187 , -32}, { 68 , -93}, { 528 , 2866}, { 786 , 789}, {1247 , 1468}, + {-476 , 2428}, { 20 , 133}, { 2 , -236}, { 426 , 799}, { 393 , 590}, { 532 , 1562}, { 807 , 534}, {1410 , 1051}, + { -14 , -263}, { 83 , -158}, { 158 , -38}, { 616 , 550}, { 845 , 543}, { 536 , 238}, { 912 , 1521}, {1635 , 1344}, + { 115 , -55}, { 263 , 87}, {-126 , 234}, { 376 , 191}, { 459 , 2644}, { 542 , 927}, { 941 , 948}, {1896 , 1528}, + { -19 , 1853}, { 455 , 366}, { 545 , 283}, { 831 , 835}, {1217 , 846}, { 560 , 542}, {1013 , 650}, {1905 , 2343} + }, + { + {-528 , -246}, {-631 , 56}, {-717 , -277}, { -40 , 1327}, {-1011 , -688}, {-827 , -341}, {-656 , -1599}, { -992 , -1559}, + {-450 , 933}, {-540 , 2109}, {-598 , -1267}, {-387 , -512}, {-1100 , -1979}, {-812 , -617}, {-649 , -147}, { -874 , 586}, + {-720 , -601}, {-281 , -279}, {-578 , 635}, { 169 , 80}, {-1020 , -134}, {-794 , 259}, {-638 , 821}, { -907 , 42}, + {-709 , -1525}, {-482 , 1340}, {-232 , -979}, { 104 , 2314}, { -918 , -1179}, {-790 , 1284}, {-609 , 2259}, { -854 , -978}, + {-624 , 326}, {-194 , 1705}, { -88 , 1060}, { 383 , 1190}, { -415 , 15}, {-789 , -1145}, {-604 , 407}, { -869 , 1136}, + {-503 , -1047}, {-545 , -794}, {-128 , 471}, { 84 , 638}, { -591 , -1509}, {-699 , 1746}, {-600 , -369}, { -784 , 1642}, + {-221 , -668}, {-223 , 261}, { -82 , -446}, {-378 , -1215}, { -741 , 969}, {-689 , -863}, {-569 , -595}, {-1012 , -403}, + {-331 , 518}, {-175 , 787}, {-220 , -3}, { -46 , -841}, { -960 , 297}, {-666 , 68}, {-565 , -1364}, { -265 , -21}, + { 649 , 767}, { 255 , 360}, { 338 , -342}, {1664 , 1627}, { 205 , -226}, { 967 , 31}, {1217 , 928}, { 1697 , 1233}, + { 322 , 1445}, { 320 , 1790}, { 413 , 212}, { 994 , 209}, { 766 , 264}, { 974 , 883}, {1228 , 241}, { 1679 , 801}, + { 75 , 312}, { 754 , 1425}, { 348 , 621}, { 644 , 474}, { 1008 , 763}, {1036 , 2024}, {1354 , 530}, { 1611 , 2129}, + { 162 , 931}, { 883 , 822}, { 990 , 488}, { 615 , -203}, { 1929 , 1234}, {1059 , 1375}, {1382 , 1426}, { 2048 , 1599}, + { 602 , 162}, { 380 , 820}, { 709 , 1064}, {1168 , 1374}, { 549 , 583}, {1062 , 470}, {1415 , 1092}, { 2095 , 2234}, + { 187 , -630}, { 118 , -493}, { 714 , 1787}, {1298 , 673}, { 957 , 1258}, {1082 , 1124}, {1460 , 786}, { 2124 , 1205}, + { 34 , -189}, { 54 , -35}, { 798 , 0}, { 747 , 2378}, { 1420 , 1152}, {1118 , 1673}, {1492 , 2287}, { 2416 , 1618}, + {1159 , 1795}, { 389 , -126}, {1194 , 1003}, {1578 , 1002}, { 1294 , 366}, {1148 , 694}, {1513 , 1791}, { 2746 , 2096} + } +}; + +const Word16 SN_TCVQ_CB_SUB2_fx[2][64][2] = +{ + { + {-709 , -609}, {-615 , -1025}, {-430 , -321}, { -44 , 1032}, {-1050 , -32}, {-1028 , -1856}, {-970 , -109}, { -572 , -1426}, + {-568 , 154}, {-142 , -189}, { -80 , 533}, { -38 , -632}, { -391 , 1275}, { -986 , -732}, {-479 , -510}, { -966 , 96}, + {-847 , -1387}, {-895 , 607}, {-368 , -930}, {-386 , 352}, { -290 , 10}, { -833 , 94}, {-528 , 1718}, { -210 , 115}, + {-529 , 857}, {-727 , -230}, {-128 , 31}, { 133 , 76}, { -275 , -777}, { -615 , -1367}, {-339 , -13}, {-1035 , 1231}, + { 448 , 851}, { 599 , 106}, {1103 , 1112}, { 635 , 1249}, { 761 , 774}, { 531 , -71}, { 722 , 473}, { 767 , 413}, + { 258 , 276}, { 346 , -380}, { 487 , 504}, {1114 , 122}, { 882 , 1553}, { 1983 , 1239}, {2126 , 1217}, { 1742 , 1262}, + { 135 , -252}, { 216 , 545}, { 500 , -125}, {1379 , 1910}, { 304 , 76}, { 1509 , 609}, {1543 , 1385}, { 542 , 1831}, + {-240 , -467}, { 771 , 652}, { 913 , 280}, {1307 , 716}, { 1834 , 1029}, { 1049 , 491}, {1624 , 733}, { 2495 , 1944} + }, + { + {-729 , -852}, {-590 , 306}, {-398 , 295}, { -31 , 13}, {-659 , -75}, {-604 , -1229}, {-519 , -675}, {-823 , 47}, + {-755 , -207}, {-818 , -424}, {-705 , -1285}, {-258 , -828}, {-807 , -707}, {-182 , -712}, {-928 , 3}, {-455 , -1149}, + {-844 , 422}, {-596 , -1008}, {-504 , -470}, {-459 , 737}, {-338 , -728}, {-836 , 1028}, {-613 , 1242}, {-609 , 1292}, + {-285 , 36}, {-280 , -424}, { 100 , 126}, {-459 , -135}, {-159 , -151}, {-287 , 190}, { 56 , -262}, {-264 , -317}, + { -8 , 603}, { 63 , 301}, { 537 , -155}, { 289 , 569}, { 193 , -412}, { 864 , 79}, { 686 , 399}, { 842 , 1657}, + { 115 , -211}, { 608 , 340}, { 12 , -650}, { 711 , 1103}, { 101 , 510}, { 358 , -416}, {1266 , 453}, { 532 , 612}, + {-256 , -680}, { 41 , 1163}, { 597 , 793}, { 484 , -61}, { 476 , 256}, {1729 , 1246}, {1209 , 1483}, {1472 , 1113}, + { 389 , 330}, { 176 , -388}, {1025 , 317}, {1049 , 732}, {1480 , 1108}, {1285 , 616}, {1730 , 999}, {2001 , 1669} + } +}; +const Word16 SN_TCVQ_CB_SUB3_fx[4][32][2] = +{ + { + {-377 , -872}, {-407 , 801}, {-611 , -449}, {-397 , -87}, {-476 , -1063}, {-797 , -249}, {-263 , -662}, {-473 , 1508}, + {-716 , 310}, {-616 , -982}, {-742 , -1326}, { 197 , 327}, {-894 , -1556}, {-871 , -1259}, {-708 , -1380}, {-789 , -848}, + { 64 , -313}, { -59 , -547}, { -2 , 67}, { 363 , -167}, { 633 , 1840}, { 232 , -357}, {1243 , 1492}, {1640 , 973}, + { 203 , 518}, { 511 , 946}, { 612 , 241}, {1085 , 724}, { 811 , 326}, { 863 , 241}, { 556 , 534}, {1956 , 2087} + }, + { + {-948 , 28}, {-827 , -1180}, {-348 , -331}, { -36 , 216}, {-1453 , -1162}, {-682 , -639}, {-747 , -1517}, {-704 , 1228}, + {-535 , -988}, {-550 , -109}, {-478 , 580}, {-310 , -699}, {-1308 , -225}, {-775 , -1581}, {-831 , -613}, {-120 , -222}, + { 32 , 200}, { 120 , -221}, { 470 , 466}, { 808 , 313}, { 950 , 711}, { 430 , -576}, {1984 , 1405}, {1645 , 887}, + { 131 , 1148}, { 286 , 508}, { 342 , -236}, {1003 , 1202}, { 317 , -726}, {1493 , 732}, {1336 , 694}, {2382 , 1772} + }, + { + {-874 , -374}, {-237 , 26}, { 15 , 870}, {-710 , 433}, { 40 , -769}, {-1059 , -1350}, { 65 , 208}, {-1012 , -1369}, + { -79 , -459}, {-671 , -942}, { -12 , 56}, {-162 , -431}, {-820 , -1073}, { -886 , -136}, {-327 , -501}, { -55 , -14}, + { 652 , 647}, { 365 , 411}, { 614 , 252}, { 154 , 215}, { 12 , 62}, { 226 , 177}, {1689 , 1213}, { 751 , 179}, + { 31 , 182}, { 281 , -291}, {-354 , -642}, { 939 , 924}, { 619 , 90}, { 1675 , 1130}, { 827 , 272}, { 1550 , 1446} + }, + { + {-366 , -916}, {-346 , -234}, {-518 , -140}, { 26 , 305}, {-254 , -92}, {-634 , -976}, {-493 , -1076}, {-334 , -913}, + {-566 , 68}, { 102 , 216}, {-296 , -927}, {-501 , -1030}, {-437 , -1006}, {-146 , -145}, {-211 , -202}, { 62 , 359}, + { 163 , -122}, { 759 , 553}, { 82 , 207}, {-177 , -243}, { 163 , 343}, {1152 , 929}, { 197 , 248}, { 43 , -147}, + { 169 , 371}, {-468 , -1043}, { 686 , 418}, { 563, 245}, {1052 , 843}, { 259 , 341}, {1063 , 637}, { 865 , 654} + } +}; const float AR_SVQ_CB1[32][8] = @@ -12654,6 +14458,61 @@ const float AR_SVQ_CB2[16][8] = {-2.572755F, -7.192194F, -2.623712F, -2.309371F, 14.2487590F, -21.16166F, 68.2372970F, -68.92265F}, }; +const Word16 AR_SVQ_CB1_fx[32][8] = /* x2.56 */ +{ + { -1, 4, 16, 4, 45, -110, 10, 167, }, + { -3, 2, 8, -12, -7, 23, 279, -46, }, + { 0, 2, 1, 8, -73, -40, 71, -97, }, + { 0, 2, 42, 74, -39, 72, 27, 8, }, + { 0, 1, 9, -6, 40, -65, -55, -128, }, + { 0, 0, 8, -10, -43, 105, -5, -126, }, + { 0, 0, 12, -3, -98, -18, -88, -73, }, + { 0, 1, -6, -12, -49, -179, -30, -15, }, + { -1, 0, 24, 78, 25, -69, -26, -14, }, + { 0, 1, -1, -29, 23, -65, -126, 34, }, + { 2, -4, -23, -7, -13, -2, -22, -4, }, + { -1, 1, -2, 44, -54, -58, 107, 60, }, + { 0, 1, -3, -15, -54, 97, -100, 41, }, + { 0, -2, -81, 93, -13, 18, -31, -75, }, + { -1, 2, 0, -5, 166, -64, -48, 8, }, + { -2, 0, -27, -108, 36, 3, 12, -80, }, + { 0, 0, 0, 4, 82, -1, 79, 54, }, + { 1, -4, 5, -9, -38, 289, 16, 16, }, + { -1, 2, 6, -68, 61, 67, -31, 100, }, + { 3, -6, 2, -2, -1, -6, -217, 273, }, + { 0, 1, -43, -62, -7, -60, 28, 78, }, + { -1, 2, 10, 0, 76, 84, -55, -45, }, + { -1, -2, 4, 5, -32, 75, 70, 176, }, + { 2, -1, 0, 6, 27, 29, -220, -97, }, + { -1, 1, 90, -56, -10, -16, 29, 8, }, + { -1, 3, -10, 0, 2, -24, 49, -336, }, + { -1, 1, -8, -9, 55, -134, 105, -44, }, + { 0, 1, -16, 69, 51, 40, -51, 98, }, + { 0, 2, -12, -32, -140, 49, 50, 26, }, + { 0, 3, 8, 29, 77, 24, 76, -103, }, + { -1, 2, -24, -18, 7, 100, 94, 5, }, + { 0, -1, 10, 26, -87, -34, -56, 103, } +}; + +const Word16 AR_SVQ_CB2_fx[16][8] = /* x2.56 */ +{ + { -37, -59, 208, -88, 54, 58, -16, -24, }, + { 0, -98, 9, -65, -182, -21, 19, 9, }, + { -1, 110, -8, 59, 201, 9, -38, -22, }, + { -1, 40, -22, -183, 46, -162, -38, -6, }, + { 12, 2, -193, 64, -43, -48, 11, 9, }, + { -83, 175, -8, -55, -65, 66, 26, 6, }, + { 29, 3, 2, -10, -100, 293, 75, -12, }, + { 7, -54, -76, -91, 63, 119, -84, -84, }, + { 3, 7, 6, 6, -30, 15, -176, 168, }, + { -10, 45, 26, 57, -92, -68, -117, -134, }, + { 0, -37, -34, -69, 106, 54, 121, 131, }, + { -25, -64, 7, 205, 1, 93, 27, 6, }, + { 64, 28, 51, 8, -7, 18, 27, 0, }, + { -20, 44, 57, 78, -55, -170, 88, 93, }, + { 12, -125, 12, 56, 100, -160, -87, -3, }, + { -7, -18, -7, -6, 36, -54, 175, -176, } +}; const float W_DTX_HO[HO_HIST_SIZE] = @@ -13924,15 +15783,18 @@ const float F_2_5[64] = const int16_t swb_bwe_trans_subband[SWB_FENV_TRANS+1] = {240, 316, 392, 476, 560}; const int16_t swb_bwe_trans_subband_width[SWB_FENV_TRANS] = {76, 76, 84, 84}; const int16_t swb_bwe_subband[SWB_FENV+1] = {240, 256, 280, 296, 320, 336, 360, 376, 400, 424, 448, 472, 496, 528, 560}; +const Word16 fb_bwe_subband[DIM_FB + 1] = { 640, 680, 720, 800 }; +const Word16 fb_bwe_sm_subband[DIM_FB] = { 656, 696, 760 }; const float swb_inv_bwe_subband_width[SWB_FENV] = {0.0625f, 0.04167f, 0.0625f, 0.04167f, 0.0625f, 0.04167f, 0.0625f, 0.04167f, 0.04167f, 0.04167f, 0.04167f, 0.04167f, 0.03125f, 0.03125f}; const int16_t swb_bwe_sm_subband[SWB_FENV] = {248, 268, 288, 308, 328, 348, 368, 388, 412, 436, 460, 484, 512, 544}; const float smooth_factor[SWB_FENV-1] = {0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.0417f, 0.0417f, 0.0417f, 0.0417f, 0.03125f, 0.03125f}; +const Word16 smooth_factor_fx[SWB_FENV - 1] = { 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1366, 1366, 1366, 1366, 1024, 1024 }; -const int16_t fb_bwe_subband[DIM_FB+1] = {640, 680, 720, 800}; +const int16_t fb_bwe_subband_float[DIM_FB+1] = {640, 680, 720, 800}; const float fb_inv_bwe_subband_width[DIM_FB] = {0.0250f, 0.0250f, 0.0125f}; -const int16_t fb_bwe_sm_subband[DIM_FB] = {656, 696, 760}; +const int16_t fb_bwe_sm_subband_float[DIM_FB] = {656, 696, 760}; const float fb_smooth_factor[DIM_FB] = {0.03125f, 0.0250f, 0.015625f}; - +const Word16 fb_smooth_factor_fx[DIM_FB] = { 1024, 819, 512 }; const float EnvCdbk11 [N_CB11 * DIM11] = { -8.6703f, 0.1116f, 4.5639f, 8.2950f, 8.5148f, 4.7195f, 2.8963f, @@ -14815,7 +16677,7 @@ const int16_t pgain_huffsizn[32] = 4, 4, 4, 4, 4, 4, 5, 5, 6, 7, 7, 8, 10, 10, 12, 12 }; -const int16_t dicnlg2[40] = +const int16_t dicnlg2_float[40] = { 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, @@ -14894,7 +16756,7 @@ const int16_t band_len_wb[26] = 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 32, 32 }; -const Word16 band_len_harm[SFM_N_HARM_FB] = +const Word16 band_len_harm_float[SFM_N_HARM_FB] = { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 32, 32, 32, 48, 48, 48, 48, 64, 64, 64, 96 @@ -14913,9 +16775,12 @@ const Word16 band_end_harm[SFM_N_HARM_FB] = }; -const float rat[SFM_N_WB] = {1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, +const float rat_flt[SFM_N_WB] = {1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.8f, 0.8f }; +const Word16 rat_fx[SFM_N_WB] = { 24576, 24576, 24576, 24576, 24576, 24576, 24576, 24576, 24576, 24576, 24576, 24576, 24576, 24576, 24576, 24576, + 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 13107, 13107 +}; const int16_t sfm_width[20] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 8}; const int16_t a_map[20] = {8, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 7, 11}; @@ -15514,6 +17379,15 @@ const float gain_att[MAX_P_ATT] = 0.9767067f, 0.9778463f, 0.9789108f, 0.9799438f, 0.9808353f, 0.9816967f, 0.9825032f, 0.9832868f }; +const Word16 gain_att_fx[40] = /* Q=15 */ +{ + 15711, 19367, 21781, 23743, 24899, 25929, 26758, 27514, + 28059, 28562, 28994, 29398, 29693, 29970, 30213, 30442, + 30619, 30786, 30936, 31077, 31190, 31298, 31395, 31488, + 31564, 31637, 31704, 31768, 31822, 31873, 31920, 31966, + 32005, 32042, 32077, 32111, 32140, 32168, 32195, 32220 +}; + const Word16 stab_trans_fx[10] = /* Q15 */ { 16384, 11381, 7232, 4292, 2433, @@ -15531,8 +17405,19 @@ const float env_stab_tp[2][2] = {0.001f, 0.5f} }; +const Word16 env_stab_tp_fx[2][2] = /* Q15 */ +{ + {32735, 16384}, + {33, 16384} +}; + const float att_step[NB_G] = { 4.0000000f, 2.0000000f, 1.3333333f, 1.0000000f}; +const Word16 att_step_fx[4] = /* Q=13 */ +{ + 32767, 16384, 10923, 8192 +}; + const Word32 table_logcum_fx[563] = { 0, 0, 0, 65536, 169408, 300480, 452650, 622058, 806041, @@ -16079,28 +17964,28 @@ const int16_t band_width_568_22_6_2_0_0[22] = { 6, 6, 6, 6, 6, 6, 7, 8, 9, 10, 1 const int16_t band_width_640_24_6_4_0_0[24] = { 6, 6, 6, 6, 6, 6, 7,7,8,9,10,11,13,15,18,21,26,32,39,48,59, 74,92,115}; /* LR-MDCT: NB configuration tables */ -const Xcore_Config xcore_config_8kHz_007200bps_long = { 13, L_FRAME8k, band_width_160_13_6_2_0_0, 536870912L, 24576, 13107, 2, 2, 0, 0.0f, 0.40f, 0.13f, 1.2f, 0.32f }; -const Xcore_Config xcore_config_8kHz_008000bps_long = { 14, L_FRAME8k, band_width_160_14_6_3_0_0, 536870912L, 24576, 13107, 2, 2, 0, 0.0f, 0.40f, 0.13f, 1.2f, 0.32f }; -const Xcore_Config xcore_config_8kHz_013200bps_long = { 17, L_FRAME8k, band_width_160_17_6_3_0_0, 429496730L, 24576, 13107, 2, 4, 2, 12.0f, 0.40f, 0.13f, 1.2f, 0.32f }; -const Xcore_Config xcore_config_8kHz_016400bps_long = { 18, L_FRAME8k, band_width_160_18_6_4_0_0, 322122547L, 24576, 13107, 2, 2, 0, 0.0f, 0.40f, 0.13f, 1.2f, 0.32f }; +const Xcore_Config xcore_config_8kHz_007200bps_long = { 13, L_FRAME8k, band_width_160_13_6_2_0_0, 536870912L, 24576, 24576/*eref*/, 13107, 13107/*bit_alloc_weight*/, 2, 2, 0, 0.0f, 0 /*p2a_th*/, 0.40f, 13107/*pd_thresh*/, 0.13f, 4260/*ld_slope*/, 1.2f, 19661/*ni_coef*/, 0.32f }; +const Xcore_Config xcore_config_8kHz_008000bps_long = { 14, L_FRAME8k, band_width_160_14_6_3_0_0, 536870912L, 24576, 24576/*eref*/, 13107, 13107/*bit_alloc_weight*/, 2, 2, 0, 0.0f, 0 /*p2a_th*/, 0.40f, 13107/*pd_thresh*/, 0.13f, 4260/*ld_slope*/, 1.2f, 19661/*ni_coef*/, 0.32f }; +const Xcore_Config xcore_config_8kHz_013200bps_long = { 17, L_FRAME8k, band_width_160_17_6_3_0_0, 429496730L, 24576, 24576/*eref*/, 13107, 13107/*bit_alloc_weight*/, 2, 4, 2, 12.0f, 24576/*p2a_th*/, 0.40f, 13107/*pd_thresh*/, 0.13f, 4260/*ld_slope*/, 1.2f, 19661/*ni_coef*/, 0.32f }; +const Xcore_Config xcore_config_8kHz_016400bps_long = { 18, L_FRAME8k, band_width_160_18_6_4_0_0, 322122547L, 24576, 24576/*eref*/, 13107, 13107/*bit_alloc_weight*/, 2, 2, 0, 0.0f, 0 /*p2a_th*/, 0.40f, 13107/*pd_thresh*/, 0.13f, 4260/*ld_slope*/, 1.2f, 19661/*ni_coef*/, 0.32f }; -const Xcore_Config xcore_config_8kHz_007200bps_short = { 4, L_FRAME8k / NUM_TIME_SWITCHING_BLOCKS, band_width_40_4_6_0_0_0, 966367642L, 24576, 13107, 2, 2, 0, 0.0f, 0.30f, 0.09f, 1.2f, 0.32f }; -const Xcore_Config xcore_config_8kHz_008000bps_short = { 4, L_FRAME8k / NUM_TIME_SWITCHING_BLOCKS, band_width_40_4_6_0_0_0, 1181116006L, 24576, 13107, 2, 4, 0, 0.0f, 0.30f, 0.09f, 1.2f, 0.32f }; -const Xcore_Config xcore_config_8kHz_013200bps_short = { 5, L_FRAME8k / NUM_TIME_SWITCHING_BLOCKS, band_width_40_5_6_0_0_0, 751619276L, 24576, 11469, 2, 4, 0, 0.0f, 0.70f, 0.11f, 1.2f, 0.32f }; -const Xcore_Config xcore_config_8kHz_016400bps_short = { 5, L_FRAME8k / NUM_TIME_SWITCHING_BLOCKS, band_width_40_5_6_0_0_0, 536870912L, 24576, 11469, 2, 6, 0, 0.0f, 0.90f, 0.11f, 1.2f, 0.32f }; +const Xcore_Config xcore_config_8kHz_007200bps_short = { 4, L_FRAME8k / NUM_TIME_SWITCHING_BLOCKS, band_width_40_4_6_0_0_0, 966367642L, 24576, 24576/*eref*/, 13107, 13107/*bit_alloc_weight*/, 2, 2, 0, 0.0f, 0/*p2a_th*/, 0.30f, 9830 /*pd_thresh*/, 0.09f, 2949/*ld_slope*/, 1.2f, 19661/*ni_coef*/, 0.32f }; +const Xcore_Config xcore_config_8kHz_008000bps_short = { 4, L_FRAME8k / NUM_TIME_SWITCHING_BLOCKS, band_width_40_4_6_0_0_0, 1181116006L, 24576, 24576/*eref*/, 13107, 13107/*bit_alloc_weight*/, 2, 4, 0, 0.0f, 0/*p2a_th*/, 0.30f, 9830 /*pd_thresh*/, 0.09f, 2949/*ld_slope*/, 1.2f, 19661/*ni_coef*/, 0.32f }; +const Xcore_Config xcore_config_8kHz_013200bps_short = { 5, L_FRAME8k / NUM_TIME_SWITCHING_BLOCKS, band_width_40_5_6_0_0_0, 751619276L, 24576, 24576/*eref*/, 11469, 11469/*bit_alloc_weight*/, 2, 4, 0, 0.0f, 0/*p2a_th*/, 0.70f, 22938/*pd_thresh*/, 0.11f, 3604/*ld_slope*/, 1.2f, 19661/*ni_coef*/, 0.32f }; +const Xcore_Config xcore_config_8kHz_016400bps_short = { 5, L_FRAME8k / NUM_TIME_SWITCHING_BLOCKS, band_width_40_5_6_0_0_0, 536870912L, 24576, 24576/*eref*/, 11469, 11469/*bit_alloc_weight*/, 2, 6, 0, 0.0f, 0/*p2a_th*/, 0.90f, 22491/*pd_thresh*/, 0.11f, 3604/*ld_slope*/, 1.2f, 19661/*ni_coef*/, 0.32f }; /* LR-MDCT: WB configuration tables */ -const Xcore_Config xcore_config_16kHz_013200bps_long = { 18, L_FRAME16k, band_width_320_18_6_3_0_0, 429496730L, 24576, 13106, 2, 6, 3, 12.0f, 0.40f, 0.12f, 1.1f, 0.32f }; -const Xcore_Config xcore_config_16kHz_016400bps_long = { 20, L_FRAME16k, band_width_320_20_6_3_0_0, 429496730L, 24576, 13106, 2, 6, 3, 12.0f, 0.40f, 0.12f, 1.2f, 0.32f }; +const Xcore_Config xcore_config_16kHz_013200bps_long = { 18, L_FRAME16k, band_width_320_18_6_3_0_0, 429496730L, 24576, 24576/*eref*/, 13106, 13106/*bit_alloc_weight*/, 2, 6, 3, 12.0f, 24576/*p2a_th*/, 0.40f, 13107/*pd_thresh*/, 0.12f, 3932/*ld_slope*/, 1.1f, 18022/*ni_coef*/, 0.32f }; +const Xcore_Config xcore_config_16kHz_016400bps_long = { 20, L_FRAME16k, band_width_320_20_6_3_0_0, 429496730L, 24576, 24576/*eref*/, 13106, 13106/*bit_alloc_weight*/, 2, 6, 3, 12.0f, 24576/*p2a_th*/, 0.40f, 13107/*pd_thresh*/, 0.12f, 3932/*ld_slope*/, 1.2f, 19660/*ni_coef*/, 0.32f }; -const Xcore_Config xcore_config_16kHz_013200bps_short = { 7, L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS, band_width_80_7_6_0_0_0, 966367642L, 24576, 9830, 2, 4, 0, 0.0f, 0.30f, 0.13f, 1.1f, 0.32f }; -const Xcore_Config xcore_config_16kHz_016400bps_short = { 7, L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS, band_width_80_7_6_0_0_0, 966367642L, 24576, 11468, 2, 8, 0, 0.0f, 0.30f, 0.13f, 1.2f, 0.32f }; +const Xcore_Config xcore_config_16kHz_013200bps_short = { 7, L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS, band_width_80_7_6_0_0_0, 966367642L, 24576, 24576/*eref*/, 9830, 9830/*bit_alloc_weight*/, 2, 4, 0, 0.0f, 0 /*p2a_th*/, 0.30f, 9830 /*pd_thresh*/, 0.13f, 4258/*ld_slope*/, 1.1f, 18022/*ni_coef*/, 0.32f }; +const Xcore_Config xcore_config_16kHz_016400bps_short = { 7, L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS, band_width_80_7_6_0_0_0, 966367642L, 24576, 24576/*eref*/, 11468, 11468/*bit_alloc_weight*/, 2, 8, 0, 0.0f, 0 /*p2a_th*/, 0.30f, 9830 /*pd_thresh*/, 0.13f, 4258/*ld_slope*/, 1.2f, 19660/*ni_coef*/, 0.32f }; /* LR-MDCT: SWB configuration tables */ -const Xcore_Config xcore_config_32kHz_013200bps_long = { 22, 568, band_width_568_22_6_2_0_0, 322122547L, 24576, 6554, 2, 4, 5, 14.0f, 0.40f, 0.13f, 1.2f, 0.26f }; -const Xcore_Config xcore_config_32kHz_016400bps_long = { 24, 640, band_width_640_24_6_4_0_0, 322122547L, 24576, 8192, 2, 4, 5, 14.0f, 0.40f, 0.13f, 1.2f, 0.26f }; -const Xcore_Config xcore_config_32kHz_013200bps_short = { 8, 568 / NUM_TIME_SWITCHING_BLOCKS, band_width_142_8_8_0_0_0, 1610612736L, 24576, 13107, 2, 4, 0, 0.0f, 0.50f, 0.11f, 1.2f, 0.48f }; -const Xcore_Config xcore_config_32kHz_016400bps_short = { 8, 640 / NUM_TIME_SWITCHING_BLOCKS, band_width_160_8_8_0_0_0, 644245094L, 24576, 8192, 2, 4, 0, 0.0f, 0.30f, 0.13f, 1.2f, 0.32f }; +const Xcore_Config xcore_config_32kHz_013200bps_long = { 22, 568, band_width_568_22_6_2_0_0, 322122547L, 24576, 24576/*eref*/, 6554, 6554/*bit_alloc_weight*/, 2, 4, 5, 14.0f, 28672/*p2a_th*/, 0.40f, 13107 /*pd_thresh*/, 0.13f, 4260/*ld_slope*/, 1.2f, 19661/*ni_coef*/, 0.26f }; +const Xcore_Config xcore_config_32kHz_016400bps_long = { 24, 640, band_width_640_24_6_4_0_0, 322122547L, 24576, 24576/*eref*/, 8192, 8192/*bit_alloc_weight*/, 2, 4, 5, 14.0f, 28672/*p2a_th*/, 0.40f, 13107 /*pd_thresh*/, 0.13f, 4260/*ld_slope*/, 1.2f, 19661/*ni_coef*/, 0.26f }; +const Xcore_Config xcore_config_32kHz_013200bps_short = { 8, 568 / NUM_TIME_SWITCHING_BLOCKS, band_width_142_8_8_0_0_0, 1610612736L, 24576, 24576/*eref*/, 13107, 13107/*bit_alloc_weight*/, 2, 4, 0, 0.0f, 0 /*p2a_th*/, 0.50f, 16384 /*pd_thresh*/, 0.11f, 3604/*ld_slope*/, 1.2f, 19661/*ni_coef*/, 0.48f }; +const Xcore_Config xcore_config_32kHz_016400bps_short = { 8, 640 / NUM_TIME_SWITCHING_BLOCKS, band_width_160_8_8_0_0_0, 644245094L, 24576, 24576/*eref*/, 8192, 8192/*bit_alloc_weight*/, 2, 4, 0, 0.0f, 0 /*p2a_th*/, 0.30f, 9830 /*pd_thresh*/, 0.13f, 4260/*ld_slope*/, 1.2f, 19661/*ni_coef*/, 0.32f }; /* bandwidths */ const int16_t Nb[ NB_SFM] = @@ -16187,6 +18072,10 @@ const float dic_gp[] = }; const float Gain_meanNB[] = { 2.4052f }; +const Word16 Gain_meanNB_fx[] = +{ + 9852, +};/* Q12 */ const float Gain_mean_dicNB[] = { @@ -16208,13 +18097,28 @@ const float Gain_mean_dicNB[] = 0.4192f, 0.3303f, -2.0750f, -2.3558f, }; - +const Word16 Gain_mean_dicNB_fx[1 * 64] = /*Q12 */ +{ + -1309, -931, -568, -396, -54, 807, 1174, 1533, + 1901, 2092, 2286, 2493, 2698, 3130, 2909, 286, + -748, 990, 631, -1119, -1697, -2114, -2788, -5399, + -9841, -1902, -3270, -7975, -7438, -6926, -7192, -2325, + -1504, -2549, -3022, -3532, -3818, -4136, -4751, -5071, + -5756, -6093, -8998, -6389, -8765, -9438, 3369, 3917, + 3619, 4684, -8264, 4255, -4433, -6662, -9230, -7678, + 5859, 118, 457, -227, 1717, 1353, -8499, -9649 +}; const float Mean_dic_NB[] = { -0.1084f, -0.0243f, -0.0292f, -0.0091f, 0.0061f, 0.0171f, 0.0362f, 0.0153f, 0.0416f, 0.0558f, }; +const Word16 Mean_dic_NB_fx[1 * 10] = /*Q12 */ +{ + -444, -100, -120, -37, 25, + 70, 148, 63, 170, 229 +}; const float Gain_dic1_NB[] = { @@ -16340,6 +18244,130 @@ const float Gain_dic3_NB[] = 0.1665f, 0.1661f, 0.2222f, 0.1193f, }; +const Word16 Gain_dic1_NB_fx[3 * 64] = /*Q12 */ +{ + -606, -92, 5, + -1965, 294, 666, + -440, 119, 661, + -106, 267, 108, + -1213, 345, -136, + -1251, 618, 566, + -1905, -750, 648, + -1043, -360, -498, + -18, -322, 96, + 334, 116, -247, + -1929, 660, 23, + -1845, 1178, 485, + -180, 836, 167, + -1892, -922, -321, + 416, -437, -344, + 595, -548, 158, + -265, -807, -338, + -1065, -1015, -20, + -626, 595, -333, + -569, 1090, 651, + 27, 587, -331, + -184, -85, -503, + -1902, -1807, 326, + -1861, -159, -989, + -666, 143, -1163, + -1718, 1031, -744, + 847, 301, -59, + 720, -1001, -216, + 1380, -866, -969, + 803, -4, -608, + 233, 408, -998, + 1459, 87, 263, + 345, -615, -1026, + 877, -148, -7, + 68, -1075, 270, + 802, 329, 475, + -1923, -126, -38, + 1275, -419, -349, + 401, 926, 575, + 846, -233, 547, + 693, -1880, 356, + -362, -1683, -219, + 231, -339, 598, + 1227, -616, 267, + 1116, 91, -1316, + -551, -650, 530, + 444, 32, 181, + -384, 1207, -775, + -993, 1163, 41, + 784, -1018, 538, + 635, 636, -424, + 1373, -1367, 149, + 1442, 401, -444, + 1094, 888, 123, + 874, 1113, -1082, + -646, -1112, -1103, + 539, -1632, -683, + 402, 571, 99, + -1778, -1809, -849, + -732, -1691, 700, + -678, 526, 274, + 320, 1227, -118, + -1222, -180, 454, + 173, 349, 530 +}; + +const Word16 Gain_dic2_NB_fx[3 * 32] = /*Q12 */ +{ + 28, 0, -66, + -557, 4, 206, + 281, -642, 36, + -417, 81, -494, + -380, 684, 450, + 521, -1544, 258, + -1119, 613, -1151, + 514, 24, 797, + 292, -84, -526, + 296, 418, -231, + -419, -68, 976, + 2, -308, 398, + -456, -1007, 263, + -1221, -371, 446, + -221, -390, -181, + -1210, 588, 751, + -1093, 528, -174, + 590, 372, -1271, + -79, -251, -1241, + -1016, -487, -512, + 542, 581, 338, + -265, 456, -105, + 490, -71, 89, + 42, 235, 379, + 31, 1194, -202, + 173, -839, 850, + -46, 500, -802, + 152, 933, 1073, + 980, 345, -263, + 807, -580, -521, + -23, -992, -585, + 876, -576, 411 +}; + +const Word16 Gain_dic3_NB_fx[4 * 16] = /*Q12 */ +{ + -16, 65, -227, 11, + -214, 553, 366, 185, + 137, -338, -300, -625, + -122, 82, 538, -797, + 160, 285, -1103, 35, + -594, 312, -379, -423, + 169, -642, -395, 363, + 351, -1166, 630, -261, + -1190, 217, 416, 187, + -577, 244, -636, 858, + 580, 482, -220, 635, + 475, -188, 372, 27, + -65, -369, 504, 910, + -423, -442, 124, -40, + 480, 575, -41, -651, + 682, 680, 910, 489 +}; + const float Gain_dic2_NBHR[] = { 0.0070f, 0.0001f, -0.0229f, @@ -16540,6 +18568,206 @@ const float Gain_dic3_NBHR[] = -0.3133f, 0.1780f, -0.3883f, 0.2519f, }; +const Word16 Gain_dic2_NBHR_fx[3 * 64] = /*Q12 */ +{ + 29, 0, -94, + -605, -202, -174, + 324, -380, -163, + -126, -301, -306, + -288, 124, 112, + -86, 524, -115, + 234, 18, -464, + -55, -281, 179, + 161, 446, 632, + 366, -82, 97, + 228, -1149, 270, + 293, 286, -143, + -123, -35, -896, + -540, -675, 175, + 331, -483, -687, + -779, 204, -668, + -492, 768, -510, + -1215, -620, -483, + 681, -76, -296, + -671, 396, -45, + -759, 298, 564, + -284, 589, 321, + -1366, -592, 496, + -448, -585, -712, + 12, -756, -90, + 513, 167, -927, + -1172, 1060, -1198, + -477, 748, 1006, + 42, 103, 1277, + -940, 1049, 138, + -924, -14, -1469, + 684, 679, -1580, + 417, -374, -1572, + 607, 270, 256, + 567, 778, 843, + 1414, -223, -542, + 97, 200, 251, + 222, 1074, -547, + -714, -285, 1046, + 386, -684, 984, + 338, 674, 116, + -274, 171, -368, + 581, -1871, 342, + 94, 442, -597, + -293, -1205, 851, + -127, 501, -1247, + 175, 1700, 1357, + -24, 1224, 285, + 707, -952, -293, + 668, 492, -407, + 1164, 751, 201, + 381, -595, 288, + -1570, 481, -531, + -597, -160, 326, + -578, -1311, -40, + -118, -523, 576, + -1513, 527, 757, + -184, 40, 609, + -1215, 98, 68, + -65, -1324, -836, + 821, -299, 204, + 796, 21, 840, + 310, -133, 542, + 1042, -974, 537 +}; + +const Word16 Gain_dic3_NBHR_fx[4 * 128] = /*Q12 */ +{ + 293, 7, -202, -95, + 535, 110, 542, -512, + -578, 65, -560, -345, + 206, 332, 10, -533, + -76, 356, -14, 83, + 149, -372, -195, -490, + -478, -241, -55, 113, + -293, -470, -606, 62, + 797, -1448, 625, -1128, + 173, 464, -1686, -49, + -392, -295, -159, -464, + -715, 420, -146, -984, + -36, 28, -484, 119, + 472, 272, -729, -116, + 68, -87, -628, -429, + 429, -918, -158, -191, + -545, 230, -435, 261, + -128, 15, -791, 612, + 268, -387, -1258, 102, + 378, 238, 301, 3, + -494, 149, 131, -124, + 634, -308, 99, 24, + 572, 711, 754, -1137, + -1109, 400, 1093, 369, + -831, -423, 1583, 1089, + -83, 156, -105, 1078, + -930, 476, 152, 380, + 776, 1162, 788, -43, + 279, 50, 408, 597, + 476, 483, 73, 749, + 903, 686, 80, -411, + 195, -768, 280, 344, + -263, -999, -46, -284, + -66, 263, 315, -1239, + 435, 578, -234, -1169, + 199, -1669, 188, 114, + -57, 419, -509, -633, + 98, -119, 129, -816, + -157, -365, -249, 537, + 67, -624, 121, 1153, + 1444, 142, -584, 38, + 1086, -84, 162, 994, + 392, -384, -124, 533, + 252, 183, -1161, -885, + -431, -829, 102, 432, + -708, 987, -1021, -644, + -64, 120, -1684, 985, + 210, -494, -906, 1302, + 50, -186, 177, 185, + -256, 872, -1004, 387, + 564, -80, -679, 515, + -763, -40, -1174, 228, + -1029, 199, -59, -297, + 30, -47, 198, -264, + -396, -1435, 913, -1018, + -141, 962, 36, 458, + 36, -388, 776, -1000, + -74, 489, 1137, 140, + -970, -766, 666, -117, + 90, 599, 1665, 1405, + -313, -685, -764, -615, + 563, -462, -627, -768, + 792, 560, -1445, 556, + -581, 721, -559, 1137, + -699, -273, 274, -846, + 940, -690, 747, -253, + -177, -541, 1355, -217, + -586, 427, 1196, -868, + 147, 532, -550, 405, + 258, 677, -245, -166, + 772, 1062, -331, 482, + 388, 1870, -576, 1585, + 462, 865, 454, 1212, + 570, 528, -681, 1229, + -386, 607, 599, 865, + -154, -20, -211, -231, + 96, 736, 408, -259, + 763, -1533, 1094, 249, + 705, -1132, 1757, -1082, + 310, -481, 329, -395, + 194, -781, 59, -954, + -933, -957, -25, 1866, + -852, -224, -482, 822, + -1438, 490, 221, 1281, + 392, 677, 539, 347, + 884, -614, 1844, 678, + -773, 484, -928, 2477, + -274, -461, 378, -263, + -283, -312, 583, 342, + 453, -1541, 378, 1266, + 778, 1095, 1290, 824, + -958, -443, -208, -71, + 985, -1001, -123, 473, + 56, -1003, -513, 474, + -259, 1435, 975, 315, + -59, -169, 724, 961, + -210, 1030, 341, -977, + 1054, 2917, -7, -877, + -852, -228, 330, 625, + 9, -524, -97, -14, + 16, -50, 476, 2406, + 264, -238, 768, 56, + 187, 108, -169, 446, + 673, 238, 992, 671, + -218, 285, 485, 181, + 669, -526, 639, 571, + 650, 20, -188, -516, + 1031, 165, 526, 136, + -333, 307, 102, -569, + -157, 309, -934, -121, + -336, 141, 39, 536, + 662, 364, -133, 222, + -1284, 637, -636, 77, + 1241, 846, 467, 638, + 842, 328, 1330, -320, + 152, -1009, 550, -215, + -772, 13, 594, -122, + 336, -410, -547, -2, + 869, -106, 321, -1180, + 516, 1247, -828, -577, + -670, 873, 367, -132, + -415, 630, -287, -164, + -105, 138, 657, -441, + -160, -1085, 940, 704, + -128, -68, -369, -1052, + -1434, 594, 546, -665, + -1849, 75, 175, 174, + -1283, 729, -1590, 1032 +}; + const float YG_mean16[] = { -0.0968f, -0.0468f, -0.0409f, -0.0332f, @@ -16547,7 +18775,11 @@ const float YG_mean16[] = 0.0293f, 0.0198f, 0.0219f, 0.0164f, 0.0358f, 0.0083f, 0.0398f, 0.0448f, }; - +const Word16 YG_mean16_fx[1 * 16] = /*Q12 */ +{ + -396, -192, -168, -136, -60, -17, 45, 39, + 120, 81, 90, 67, 147, 34, 163, 184 +}; const float YG_dicMR_1[] = { -0.4588f, 0.2016f, 0.1315f, -0.0513f, @@ -16708,8 +18940,169 @@ const float YG_dicMR_4[] = -0.2039f, 0.0593f, 0.0207f, -0.0256f, }; -const float mean_m[] = { 2.8717f }; +const Word16 YG_dicMR_1_fx[4 * 64] = /*Q12 */ +{ + -1879, 826, 539, -210, + -120, 267, -137, -142, + -798, -473, 434, 243, + 297, -896, 369, 307, + -1883, -1333, 416, 510, + -1955, -660, -471, 224, + -905, -804, -517, 433, + -961, 20, -258, -224, + 209, 977, -213, -17, + 536, -244, 159, 97, + -265, 775, 412, -327, + 337, -391, -237, -472, + -1962, -1836, -692, 471, + 625, 173, -463, -15, + -965, 263, 62, 600, + -782, 889, -433, 211, + -1791, 852, -453, -776, + -182, -177, -1078, 80, + -364, 350, 280, 293, + -902, 1119, 295, -1194, + 16, 440, -342, 459, + -1825, -1584, -1382, -798, + 723, 57, -1235, -661, + 888, -1638, 277, 234, + 340, 345, 141, -610, + 1280, -23, 17, 144, + -639, -852, -520, -553, + 1032, 843, 149, 435, + 581, 783, 519, -196, + 457, 945, 498, -1289, + -1897, -41, 425, 514, + 787, 161, 506, 385, + -559, 1079, 319, 515, + 500, 340, 60, 106, + 251, -997, -1163, -960, + 261, -1288, -631, 335, + 1241, -620, -387, -662, + 167, 194, 476, 67, + 830, -261, 430, -1201, + -479, -123, 71, -1162, + 225, -1482, 132, -802, + 680, 763, -1010, 429, + 200, -125, 261, 590, + 771, -740, -183, 229, + -1860, -348, 278, -549, + -1768, 967, 281, 594, + -1727, -1697, 87, -764, + 1169, 631, -114, -471, + -1636, -101, -1324, -91, + 821, -745, 458, -264, + 1014, -576, 390, 470, + 1041, -517, -1018, 367, + 826, 17, 426, -326, + -467, -1641, 201, 325, + -1906, 428, -338, 222, + -1021, 630, 419, -75, + -86, -379, -203, 234, + 659, 527, -491, -1507, + -564, -1745, -979, -173, + -1764, -433, -743, -1090, + 242, 709, 269, 497, + 716, 74, -208, 618, + -297, 645, -864, -805, + -46, -326, 412, -296 +}; +const Word16 YG_dicMR_2_fx[4 * 32] = /*Q12 */ +{ + 93, 217, -122, 37, + -13, -83, 105, -491, + -398, -592, 399, -160, + 543, -81, -470, 408, + 394, -630, -94, -258, + -665, 133, -136, -125, + 397, -351, 630, -148, + -1166, 406, -865, 554, + -136, -302, -263, 81, + -674, -657, -571, -691, + -206, 381, -699, 122, + 272, -1506, 356, 15, + 451, -961, 638, -1133, + 316, -787, 165, 585, + 312, -144, 185, 274, + 39, -706, -997, 250, + -915, -871, -114, 458, + -834, 348, 364, -1188, + 450, 723, -256, 412, + 369, 468, -1371, 416, + 344, 164, 290, -1094, + 664, 122, 34, -218, + 555, 254, 559, 825, + 312, 492, 496, -27, + -399, 315, 690, -330, + -458, 710, 206, 415, + 290, 89, -662, -467, + -72, 593, -108, -460, + -217, 46, 319, 189, + -1366, 199, 365, 62, + -552, -166, 772, 861, + -159, 120, -215, 775 +}; +const Word16 YG_dicMR_3_fx[4 * 32] = /*Q12 */ +{ + -103, -143, -85, -19, + -404, 182, -795, 84, + 398, -594, -55, -256, + 283, 128, -472, 279, + -246, -628, 281, 297, + -853, 468, 358, -915, + 272, 149, 209, -443, + -168, -504, 452, -525, + 624, -427, 779, 117, + 1079, 404, -98, 80, + 136, 165, 142, -1394, + 513, -566, -150, 822, + 124, 646, 199, 272, + -165, -702, -615, 165, + 333, 810, -457, 1038, + -360, 105, -110, 537, + -224, 125, 562, -26, + 699, -1105, 809, -1323, + -1229, 841, -767, 571, + -310, 437, -114, -230, + -1045, 630, 564, 322, + 282, 1170, -723, -306, + -328, -247, -251, -598, + 354, 332, -1593, 499, + 332, -23, 219, 304, + 325, -1511, 378, 299, + -94, -54, 679, 956, + 507, 830, 861, -739, + -895, -135, 16, -34, + 677, 650, 961, 714, + 816, -665, -1741, -671, + 274, 93, -617, -433 +}; +const Word16 YG_dicMR_4_fx[4 * 16] = /*Q12 */ +{ + -163, -44, -108, 32, + 556, 153, 115, 120, + 617, 818, 802, 719, + -639, -665, 122, 664, + 353, -555, -352, -86, + -1162, 833, -1034, 326, + -511, -406, -478, -523, + 491, -1473, 404, -21, + 148, 288, -45, -544, + -61, 172, -791, -44, + 715, -449, 861, 504, + -108, 263, 610, 118, + 962, 826, -1013, -37, + -32, -495, 362, -214, + -37, 661, -75, 289, + -835, 243, 85, -105 +}; + +const float mean_m[] = { 2.8717f }; +const Word16 mean_m_fx[1 * 1] = /*Q12 */ +{ + 11762 +}; const float mean_gain_dic[] = { -0.1804f, -0.1267f, -0.0185f, 0.0358f, @@ -16729,14 +19122,28 @@ const float mean_gain_dic[] = -2.4168f, -2.2389f, -2.6467f, -2.7259f, 1.3428f, 1.2399f, 1.4988f, 1.7072f, }; - +const Word16 mean_gain_dic_fx[1 * 64] = +{ + -739, -519, -76, 147, 574, 779, 983, 1185, + 1384, 1580, 1784, 1989, 2204, 2643, 2864, 2422, + 362, -295, -1197, -1936, -2757, -11755, -8216, 3083, + 3311, -1434, -1682, -3341, -9284, -9057, -8616, -7783, + -7359, -6964, -6592, -6233, -5470, -5050, -4651, -3954, + -2470, -963, -2199, -3042, -3643, -4292, -5854, -10199, + 4103, 3548, 4390, 4717, 3817, -10525, -11521, -9570, + -9899, -9171, -10841, -11165, 5500, 5079, 6139, 6993 +}; /* Q12 */ const float YGain_mean_LR[] = { -0.0940f, -0.0435f, -0.0348f, -0.0284f, -0.0113f, -0.0029f, 0.0156f, 0.0123f, 0.0288f, 0.0167f, 0.0324f, 0.0369f, }; - +const Word16 YGain_mean_LR_fx[1 * 12] = +{ + -385, -178, -143, -116, -46, -12, + 64, 50, 118, 68, 133, 151 +}; const float YGain_dic1_LR[] = { -0.4660f, 0.0389f, -0.0220f, @@ -16845,6 +19252,114 @@ const float YGain_dic3_LR[] = 0.0647f, 0.0207f, 0.0148f, -0.2710f, 0.0109f, }; +const Word16 YGain_dic1_LR_fx[3 * 32] = /*Q12 */ +{ + -1909, 159, -90, + -155, 416, -15, + -99, -84, 396, + -1832, -848, -320, + -779, 1024, 45, + -1860, -1761, 273, + 81, -341, -309, + -819, -3, -315, + 483, 215, -194, + 242, 937, -76, + -1830, -1753, -1102, + -1589, 868, -657, + -911, 389, 421, + -1834, 915, 390, + -144, 564, -869, + 878, -1544, 301, + 446, 332, 376, + -540, -822, -1001, + 548, -192, 232, + 920, -589, -175, + 869, 717, -564, + 797, -103, -1047, + -335, -1732, -186, + -1840, -345, 566, + 1205, 109, 43, + 985, -456, 570, + 650, -1223, -874, + 928, 752, 390, + -124, 833, 575, + -1811, -249, -1142, + -711, -767, 185, + 344, -876, 267, +}; + +const Word16 YGain_dic2_LR_fx[4 * 32] = /*Q12 */ +{ + -294, -73, -41, 11, + 276, 330, -1316, 173, + 26, -712, 86, 1, + -841, -539, 246, -479, + 43, -207, 709, 116, + 104, -197, 227, -548, + 261, -228, 165, 606, + 613, 403, -122, -420, + 14, 182, -544, -669, + -734, 392, -492, -131, + -1316, 274, 116, 331, + -1339, 535, -1261, 608, + -346, 277, -426, 729, + -1067, -836, -571, 388, + 643, 503, 484, 532, + -148, 447, 120, -392, + -600, 263, 519, -75, + 686, -346, 379, 23, + 130, 239, 376, -1366, + 68, 656, -361, 92, + 608, 286, -405, 487, + -1031, 507, 523, -971, + 51, -44, -521, 172, + -573, -500, 398, 632, + 240, 147, 104, 51, + -319, -680, -890, -398, + -195, 503, 306, 459, + 335, 368, 662, -389, + 378, -788, -537, 680, + 433, -1129, 472, -883, + 472, -312, -301, -207, + 378, -1346, 433, 408, +}; + +const Word16 YGain_dic3_LR_fx[5 * 32] = /*Q12 */ +{ + -332, -191, -122, -455, -210, + 364, -48, -664, 408, 225, + -576, -342, 367, 52, 270, + -392, -157, -77, 625, -224, + -183, -652, -406, 99, 266, + 24, 65, 74, 525, 613, + -805, 306, -383, -21, 247, + 16, 133, -416, -4, -567, + 294, -750, 443, -367, 228, + 536, 816, 767, 562, 594, + -54, 200, -1108, -582, 227, + 123, -43, 414, -376, -649, + 592, -652, -674, -386, -356, + 100, -58, -45, -108, 103, + -727, -194, -1170, 931, 1096, + 512, 758, -440, -769, -1051, + 362, 787, -276, -139, 149, + -218, 387, 457, -414, 265, + -202, 663, -1104, 882, -338, + -57, 405, 269, 257, -221, + 335, 864, 1164, -611, -618, + 1275, 494, -1783, 119, 1222, + 752, 76, 270, 73, -57, + 376, -1255, 145, 724, 603, + -989, 618, 659, 675, 560, + 128, -147, -138, -368, 963, + 140, -170, 866, 538, 127, + 122, -616, 166, 236, -396, + 374, 279, 407, 650, -1269, + -861, 613, -755, -1334, -972, + -922, 314, 416, -114, -648, + 265, 85, 61, -1110, 45 +}; + const float YG_mean16HR[] = { -0.0968f, -0.0468f, -0.0409f, -0.0332f, @@ -19697,6 +22212,58 @@ const float sincos_t_rad3[T_SIN_PI_2+1] = 0.999464587476366f, 0.999590066212200f, 0.999698818696204f, 0.999790843108610f, 0.999866137909562f, 0.999924701839145f, 0.999966533917401f, 0.999991633444351f, 1.000000000000000f }; +const Word16 sincos_t_rad3_fx[T_SIN_PI_2 + 1] = +{ + 0, 134, 268, 402, 536, 670, 804, 938, + 1072, 1206, 1340, 1474, 1608, 1742, 1876, 2009, + 2143, 2277, 2411, 2544, 2678, 2811, 2945, 3078, + 3212, 3345, 3479, 3612, 3745, 3878, 4011, 4144, + 4277, 4410, 4543, 4675, 4808, 4941, 5073, 5205, + 5338, 5470, 5602, 5734, 5866, 5998, 6130, 6261, + 6393, 6524, 6655, 6787, 6918, 7049, 7180, 7310, + 7441, 7571, 7702, 7832, 7962, 8092, 8222, 8351, + 8481, 8610, 8740, 8869, 8998, 9127, 9255, 9384, + 9512, 9640, 9768, 9896, 10024, 10151, 10279, 10406, + 10533, 10660, 10786, 10913, 11039, 11165, 11291, 11417, + 11543, 11668, 11793, 11918, 12043, 12167, 12292, 12416, + 12540, 12664, 12787, 12910, 13033, 13156, 13279, 13401, + 13524, 13646, 13767, 13889, 14010, 14131, 14252, 14373, + 14493, 14613, 14733, 14852, 14972, 15091, 15210, 15328, + 15447, 15565, 15683, 15800, 15917, 16035, 16151, 16268, + 16384, 16500, 16616, 16731, 16846, 16961, 17075, 17190, + 17304, 17417, 17531, 17644, 17757, 17869, 17981, 18093, + 18205, 18316, 18427, 18538, 18648, 18758, 18868, 18978, + 19087, 19195, 19304, 19412, 19520, 19627, 19735, 19841, + 19948, 20054, 20160, 20265, 20371, 20475, 20580, 20684, + 20788, 20891, 20994, 21097, 21199, 21301, 21403, 21504, + 21605, 21706, 21806, 21906, 22006, 22105, 22204, 22302, + 22400, 22498, 22595, 22692, 22788, 22884, 22980, 23076, + 23170, 23265, 23359, 23453, 23546, 23640, 23732, 23824, + 23916, 24008, 24099, 24189, 24279, 24369, 24459, 24548, + 24636, 24724, 24812, 24900, 24986, 25073, 25159, 25245, + 25330, 25415, 25499, 25583, 25667, 25750, 25833, 25915, + 25997, 26078, 26159, 26239, 26320, 26399, 26478, 26557, + 26635, 26713, 26791, 26868, 26944, 27020, 27096, 27171, + 27246, 27320, 27394, 27467, 27540, 27612, 27684, 27756, + 27827, 27897, 27967, 28037, 28106, 28175, 28243, 28311, + 28378, 28445, 28511, 28577, 28642, 28707, 28771, 28835, + 28899, 28962, 29024, 29086, 29148, 29209, 29269, 29329, + 29389, 29448, 29506, 29564, 29622, 29679, 29736, 29792, + 29847, 29902, 29957, 30011, 30064, 30118, 30170, 30222, + 30274, 30325, 30375, 30425, 30475, 30524, 30572, 30620, + 30668, 30715, 30761, 30807, 30853, 30897, 30942, 30986, + 31029, 31072, 31114, 31156, 31197, 31238, 31278, 31318, + 31357, 31396, 31434, 31471, 31508, 31545, 31581, 31617, + 31651, 31686, 31720, 31753, 31786, 31818, 31850, 31881, + 31912, 31942, 31972, 32001, 32029, 32058, 32085, 32112, + 32138, 32164, 32190, 32214, 32239, 32262, 32286, 32308, + 32330, 32352, 32373, 32393, 32413, 32433, 32452, 32470, + 32488, 32505, 32522, 32538, 32553, 32568, 32583, 32597, + 32610, 32623, 32635, 32647, 32658, 32669, 32679, 32689, + 32698, 32706, 32714, 32722, 32729, 32735, 32741, 32746, + 32750, 32755, 32758, 32761, 32764, 32766, 32767, 32767, + 32767 +}; /*----------------------------------------------------------------------------------* * TCX @@ -19833,20 +22400,19 @@ const TCX_LTP_FILTER tcxLtpFilters[12] = const SCALE_TCX_SETUP scaleTcxTable[SIZE_SCALE_TABLE_TCX] = { - { 0, 0, 8000, 0.67f }, - { 0, 8000, 9600, 0.70f }, - { 0, 9600, 13200, 0.76f }, - { 0, 13200, 16400, 0.86f }, - { 0, 16400, 24400, 0.90f }, - { 0, 24400, 64000, 0.96f }, - - { 1, 0, 8000, 1.f }, - { 1, 8000, 9600, 1.f }, - { 1, 9600, 13200, 1.f }, - { 1, 13200, 16400, 0.85f /*0.85f*/ }, - { 1, 16400, 24400, 0.88f /*0.90*/}, - { 1, 24400, 32000, 0.90f /*0.90*/}, - { 1, 32000, 32400, 0.95f /*0.91f*/}, + { 0, 0, 8000, 0.67f , 21955/*0.67f Q15*/ }, + { 0, 8000, 9600, 0.70f , 22938/*0.70f Q15*/ }, + { 0, 9600, 13200, 0.76f , 24904/*0.76f Q15*/ }, + { 0, 13200, 16400, 0.86f , 28180/*0.86f Q15*/ }, + { 0, 16400, 24400, 0.90f , 29491/*0.90f Q15*/ }, + { 0, 24400, 64000, 0.96f , 31457/*0.96f Q15*/ }, + { 1, 0, 8000, 1.f , 32767/*1.f Q15*/ }, + { 1, 8000, 9600, 1.f , 32767/*1.f Q15*/ }, + { 1, 9600, 13200, 1.f , 32767/*1.f Q15*/ }, + { 1, 13200, 16400, 0.85f /*0.85f*/, 27853/*0.85f Q15*/ }, + { 1, 16400, 24400, 0.88f /*0.90*/ , 28836/*0.88f Q15*/ }, + { 1, 24400, 32000, 0.90f /*0.90*/ , 29491/*0.90f Q15*/ }, + { 1, 32000, 32400, 0.95f /*0.91f*/, 31130/*0.95f Q15*/ }, }; @@ -20804,42 +23370,42 @@ const Word16 qGains[2][1 << kTcxHmNumGainBits] = const struct TnsParameters tnsParametersIGF32kHz_LowBR[1] = { - { 600, 3, 1.85f, 0.075f, 4.4f } + { 600, 3, 1.85f, 0.075f, 4.4f, 237/*1.85f Q7*/, 2458/*0.075f Q15*/ } }; const struct TnsParameters tnsParameters32kHz[2] = { - { 4500, 3, 1.35f, 0.0300f, 1.0f }, - { 600, 1, 1.75f, 0.0625f, 4.4f } + { 4500, 3, 1.35f, 0.0300f, 1.0f ,173/*1.35f Q7*/, 983/*0.0300f Q15*/}, + { 600, 1, 1.75f, 0.0625f, 4.4f ,224/*1.75f Q7*/, 2048/*0.0625f Q15*/} }; const struct TnsParameters tnsParameters32kHz_grouped[2] = { - { 8400, 3, 1.375f, 0.03125f, 1.0f }, - { 800, 3, 1.375f, 0.03125f, 1.0f } + { 8400, 3, 1.375f, 0.03125f, 1.0f , 176/*1.375f Q7*/, 1024/*0.03125f Q15*/ }, + { 800, 3, 1.375f, 0.03125f, 1.0f , 176/*1.375f Q7*/, 1024/*0.03125f Q15*/ } }; const struct TnsParameters tnsParameters16kHz[1] = { - { 600, 3, 1.5f, 0.05f, 4.4f } + { 600, 3, 1.5f, 0.05f, 4.4f, 192/*1.5f Q7*/, 1638/*0.05f Q15*/ } }; const struct TnsParameters tnsParameters16kHz_grouped[2] = { - { 4400, 3, 1.5f, 0.05f, 1.0f }, - { 800, 3, 1.5f, 0.05f, 1.0f } + { 4400, 3, 1.5f, 0.05f, 1.0f, 192/*1.5f Q7*/, 1638/*0.05f Q15*/ }, + { 800, 3, 1.5f, 0.05f, 1.0f, 192/*1.5f Q7*/, 1638/*0.05f Q15*/ } }; const struct TnsParameters tnsParameters48kHz_grouped[2] = { - { 10400, 3, 1.375f, 0.03125f, 1.0f }, - { 800, 3, 1.375f, 0.03125f, 1.0f } + { 10400, 3, 1.375f, 0.03125f, 1.0f, 176/*1.375f Q7*/, 1024/*0.03125f Q15*/ }, + { 800, 3, 1.375f, 0.03125f, 1.0f, 176/*1.375f Q7*/, 1024/*0.03125f Q15*/ } }; const struct TnsParameters tnsParameters32kHz_Stereo[2]= { - { 4500, 3, 1.35f, 0.0300f, 1.0f }, - { 600, 3, 1.75f, 0.0625f, 4.4f } + { 4500, 3, 1.35f, 0.0300f, 1.0f ,173/*1.35f Q7*/, 983/*0.0300f Q15*/}, + { 600, 3, 1.75f, 0.0625f, 4.4f ,224/*1.75f Q7*/, 2048/*0.0625f Q15*/} }; const float tnsAcfWindow[TNS_MAX_FILTER_ORDER] = @@ -22061,14 +24627,14 @@ const float normReciprocal[CHEAP_NORM_SIZE] = 0.0f, 1.0000000000f, 0.5000000000f, 0.3333333333f, 0.2500000000f, 0.2000000000f, 0.1666666667f, 0.1428571429f, 0.1250000000f, 0.1111111111f, 0.1000000000f, 0.0909090909f, 0.0833333333f, 0.0769230769f, 0.0714285714f, 0.0666666667f, 0.0625000000f, 0.0588235294f, 0.0555555556f, 0.0526315789f, 0.0500000000f, 0.0476190476f, 0.0454545455f, 0.0434782609f, 0.0416666667f, 0.0400000000f, 0.0384615385f, 0.0370370370f, 0.0357142857f, 0.0344827586f, 0.0333333333f, 0.0322580645f, 0.0312500000f, 0.0303030303f, 0.0294117647f, 0.0285714286f, 0.0277777778f, 0.0270270270f, 0.0263157895f, 0.0256410256f, 0.0250000000f, 0.0243902439f, 0.0238095238f, 0.0232558140f, 0.0227272727f, 0.0222222222f, 0.0217391304f, 0.0212765957f, 0.0208333333f, 0.0204081633f, 0.0200000000f, 0.0196078431f, 0.0192307692f, 0.0188679245f, 0.0185185185f, 0.0181818182f, 0.0178571429f, 0.0175438596f, 0.0172413793f, 0.0169491525f, 0.0166666667f, 0.0163934426f, 0.0161290323f, 0.0158730159f, 0.0156250000f, 0.0153846154f, 0.0151515152f, 0.0149253731f, 0.0147058824f, 0.0144927536f, 0.0142857143f, 0.0140845070f, 0.0138888889f, 0.0136986301f, 0.0135135135f, 0.0133333333f, 0.0131578947f, 0.0129870130f, 0.0128205128f, 0.0126582278f, 0.0125000000f, 0.0123456790f, 0.0121951220f, 0.0120481928f, 0.0119047619f, 0.0117647059f, 0.0116279070f, 0.0114942529f, 0.0113636364f, 0.0112359551f, 0.0111111111f, 0.0109890110f, 0.0108695652f, 0.0107526882f, 0.0106382979f, 0.0105263158f, 0.0104166667f, 0.0103092784f, 0.0102040816f, 0.0101010101f, 0.0100000000f, 0.0099009901f, 0.0098039216f, 0.0097087379f, 0.0096153846f, 0.0095238095f, 0.0094339623f, 0.0093457944f, 0.0092592593f, 0.0091743119f, 0.0090909091f, 0.0090090090f, 0.0089285714f, 0.0088495575f, 0.0087719298f, 0.0086956522f, 0.0086206897f, 0.0085470085f, 0.0084745763f, 0.0084033613f, 0.0083333333f, 0.0082644628f, 0.0081967213f, 0.0081300813f, 0.0080645161f, 0.0080000000f, 0.0079365079f, 0.0078740157f, 0.0078125000f, 0.0077519380f, 0.0076923077f, 0.0076335878f, 0.0075757576f, 0.0075187970f, 0.0074626866f, 0.0074074074f, 0.0073529412f, 0.0072992701f, 0.0072463768f, 0.0071942446f, 0.0071428571f, 0.0070921986f, 0.0070422535f, 0.0069930070f, 0.0069444444f, 0.0068965517f, 0.0068493151f, 0.0068027211f, 0.0067567568f, 0.0067114094f, 0.0066666667f, 0.0066225166f, 0.0065789474f, 0.0065359477f, 0.0064935065f, 0.0064516129f, 0.0064102564f, 0.0063694268f, 0.0063291139f, 0.0062893082f, 0.0062500000f }; -const float w1N8[30] = {0.998795f, -0.049068f, 0.995185f, -0.098017f, 0.989177f, -0.146730f, 0.980785f, -0.195090f, 0.970031f, -0.242980f, 0.956940f, -0.290285f, 0.941544f, -0.336890f, 0.923880f, -0.382683f, 0.903989f, -0.427555f, 0.881921f, -0.471397f, 0.857729f, -0.514103f, 0.831470f, -0.555570f, 0.803208f, -0.595699f, 0.773010f, -0.634393f, 0.740951f, -0.671559f}; -const float w2N8[30] = {0.995185f, -0.098017f, 0.980785f, -0.195090f, 0.956940f, -0.290285f, 0.923880f, -0.382683f, 0.881921f, -0.471397f, 0.831470f, -0.555570f, 0.773010f, -0.634393f, 0.707107f, -0.707107f, 0.634393f, -0.773010f, 0.555570f, -0.831470f, 0.471397f, -0.881921f, 0.382683f, -0.923880f, 0.290285f, -0.956940f, 0.195090f, -0.980785f, 0.098017f, -0.995185f}; -const float w3N8[30] = {0.989177f, -0.146730f, 0.956940f, -0.290285f, 0.903989f, -0.427555f, 0.831470f, -0.555570f, 0.740951f, -0.671559f, 0.634393f, -0.773010f, 0.514103f, -0.857729f, 0.382683f, -0.923880f, 0.242980f, -0.970031f, 0.098017f, -0.995185f, -0.049068f, -0.998795f, -0.195090f, -0.980785f, -0.336890f, -0.941544f, -0.471397f, -0.881921f, -0.595699f, -0.803208f}; -const float w4N8[30] = {0.980785f, -0.195090f, 0.923880f, -0.382683f, 0.831470f, -0.555570f, 0.707107f, -0.707107f, 0.555570f, -0.831470f, 0.382683f, -0.923880f, 0.195090f, -0.980785f, 0.000000f, -1.000000f, -0.195090f, -0.980785f, -0.382683f, -0.923880f, -0.555570f, -0.831470f, -0.707107f, -0.707107f, -0.831470f, -0.555570f, -0.923880f, -0.382683f, -0.980785f, -0.195090f}; -const float w5N8[30] = {0.970031f, -0.242980f, 0.881921f, -0.471397f, 0.740951f, -0.671559f, 0.555570f, -0.831470f, 0.336890f, -0.941544f, 0.098017f, -0.995185f, -0.146730f, -0.989177f, -0.382683f, -0.923880f, -0.595699f, -0.803208f, -0.773010f, -0.634393f, -0.903989f, -0.427555f, -0.980785f, -0.195090f, -0.998795f, 0.049068f, -0.956940f, 0.290285f, -0.857729f, 0.514103f}; -const float w6N8[30] = {0.956940f, -0.290285f, 0.831470f, -0.555570f, 0.634393f, -0.773010f, 0.382683f, -0.923880f, 0.098017f, -0.995185f, -0.195090f, -0.980785f, -0.471397f, -0.881921f, -0.707107f, -0.707107f, -0.881921f, -0.471397f, -0.980785f, -0.195090f, -0.995185f, 0.098017f, -0.923880f, 0.382683f, -0.773010f, 0.634393f, -0.555570f, 0.831470f, -0.290285f, 0.956940f}; -const float w7N8[30] = {0.941544f, -0.336890f, 0.773010f, -0.634393f, 0.514103f, -0.857729f, 0.195090f, -0.980785f, -0.146730f, -0.989177f, -0.471397f, -0.881921f, -0.740951f, -0.671559f, -0.923880f, -0.382683f, -0.998795f, -0.049068f, -0.956940f, 0.290285f, -0.803208f, 0.595699f, -0.555570f, 0.831470f, -0.242980f, 0.970031f, 0.098017f, 0.995185f, 0.427555f, 0.903989f}; -const float * const w_a[7] = {w1N8, w2N8, w3N8, w4N8, w5N8, w6N8, w7N8}; +const float w1N8_float[30] = {0.998795f, -0.049068f, 0.995185f, -0.098017f, 0.989177f, -0.146730f, 0.980785f, -0.195090f, 0.970031f, -0.242980f, 0.956940f, -0.290285f, 0.941544f, -0.336890f, 0.923880f, -0.382683f, 0.903989f, -0.427555f, 0.881921f, -0.471397f, 0.857729f, -0.514103f, 0.831470f, -0.555570f, 0.803208f, -0.595699f, 0.773010f, -0.634393f, 0.740951f, -0.671559f}; +const float w2N8_float[30] = {0.995185f, -0.098017f, 0.980785f, -0.195090f, 0.956940f, -0.290285f, 0.923880f, -0.382683f, 0.881921f, -0.471397f, 0.831470f, -0.555570f, 0.773010f, -0.634393f, 0.707107f, -0.707107f, 0.634393f, -0.773010f, 0.555570f, -0.831470f, 0.471397f, -0.881921f, 0.382683f, -0.923880f, 0.290285f, -0.956940f, 0.195090f, -0.980785f, 0.098017f, -0.995185f}; +const float w3N8_float[30] = {0.989177f, -0.146730f, 0.956940f, -0.290285f, 0.903989f, -0.427555f, 0.831470f, -0.555570f, 0.740951f, -0.671559f, 0.634393f, -0.773010f, 0.514103f, -0.857729f, 0.382683f, -0.923880f, 0.242980f, -0.970031f, 0.098017f, -0.995185f, -0.049068f, -0.998795f, -0.195090f, -0.980785f, -0.336890f, -0.941544f, -0.471397f, -0.881921f, -0.595699f, -0.803208f}; +const float w4N8_float[30] = {0.980785f, -0.195090f, 0.923880f, -0.382683f, 0.831470f, -0.555570f, 0.707107f, -0.707107f, 0.555570f, -0.831470f, 0.382683f, -0.923880f, 0.195090f, -0.980785f, 0.000000f, -1.000000f, -0.195090f, -0.980785f, -0.382683f, -0.923880f, -0.555570f, -0.831470f, -0.707107f, -0.707107f, -0.831470f, -0.555570f, -0.923880f, -0.382683f, -0.980785f, -0.195090f}; +const float w5N8_float[30] = {0.970031f, -0.242980f, 0.881921f, -0.471397f, 0.740951f, -0.671559f, 0.555570f, -0.831470f, 0.336890f, -0.941544f, 0.098017f, -0.995185f, -0.146730f, -0.989177f, -0.382683f, -0.923880f, -0.595699f, -0.803208f, -0.773010f, -0.634393f, -0.903989f, -0.427555f, -0.980785f, -0.195090f, -0.998795f, 0.049068f, -0.956940f, 0.290285f, -0.857729f, 0.514103f}; +const float w6N8_float[30] = {0.956940f, -0.290285f, 0.831470f, -0.555570f, 0.634393f, -0.773010f, 0.382683f, -0.923880f, 0.098017f, -0.995185f, -0.195090f, -0.980785f, -0.471397f, -0.881921f, -0.707107f, -0.707107f, -0.881921f, -0.471397f, -0.980785f, -0.195090f, -0.995185f, 0.098017f, -0.923880f, 0.382683f, -0.773010f, 0.634393f, -0.555570f, 0.831470f, -0.290285f, 0.956940f}; +const float w7N8_float[30] = {0.941544f, -0.336890f, 0.773010f, -0.634393f, 0.514103f, -0.857729f, 0.195090f, -0.980785f, -0.146730f, -0.989177f, -0.471397f, -0.881921f, -0.740951f, -0.671559f, -0.923880f, -0.382683f, -0.998795f, -0.049068f, -0.956940f, 0.290285f, -0.803208f, 0.595699f, -0.555570f, 0.831470f, -0.242980f, 0.970031f, 0.098017f, 0.995185f, 0.427555f, 0.903989f}; +const float * const w_a_float[7] = {w1N8_float, w2N8_float, w3N8_float, w4N8_float, w5N8_float, w6N8_float, w7N8_float}; #define STCP( a, b ) {{ WORD322WORD16( a ), WORD322WORD16( b ) }} @@ -22425,4 +24991,1102 @@ const int16_t config_LSF_BWE[] = { 3, 8, 0 /* 16 */ }; +//basops +const Word32 BASOP_util_normReciprocal[CHEAP_NORM_SIZE] = +{ + 0l/*0.0 Q31*/, 2147483647l/*1.0000000000 Q31*/, 1073741824l/*0.5000000000 Q31*/, 715827883l/*0.3333333333 Q31*/, 536870912l/*0.2500000000 Q31*/, 429496730l/*0.2000000000 Q31*/, + 357913941l/*0.1666666667 Q31*/, 306783378l/*0.1428571429 Q31*/, 268435456l/*0.1250000000 Q31*/, 238609294l/*0.1111111111 Q31*/, 214748365l/*0.1000000000 Q31*/, 195225786l/*0.0909090909 Q31*/, + 178956971l/*0.0833333333 Q31*/, 165191050l/*0.0769230769 Q31*/, 153391689l/*0.0714285714 Q31*/, 143165577l/*0.0666666667 Q31*/, 134217728l/*0.0625000000 Q31*/, 126322568l/*0.0588235294 Q31*/, + 119304647l/*0.0555555556 Q31*/, 113025455l/*0.0526315789 Q31*/, 107374182l/*0.0500000000 Q31*/, 102261126l/*0.0476190476 Q31*/, 97612893l/*0.0454545455 Q31*/, 93368854l/*0.0434782609 Q31*/, + 89478485l/*0.0416666667 Q31*/, 85899346l/*0.0400000000 Q31*/, 82595525l/*0.0384615385 Q31*/, 79536431l/*0.0370370370 Q31*/, 76695845l/*0.0357142857 Q31*/, 74051160l/*0.0344827586 Q31*/, + 71582788l/*0.0333333333 Q31*/, 69273666l/*0.0322580645 Q31*/, 67108864l/*0.0312500000 Q31*/, 65075262l/*0.0303030303 Q31*/, 63161284l/*0.0294117647 Q31*/, 61356676l/*0.0285714286 Q31*/, + 59652324l/*0.0277777778 Q31*/, 58040099l/*0.0270270270 Q31*/, 56512728l/*0.0263157895 Q31*/, 55063683l/*0.0256410256 Q31*/, 53687091l/*0.0250000000 Q31*/, 52377650l/*0.0243902439 Q31*/, + 51130563l/*0.0238095238 Q31*/, 49941480l/*0.0232558140 Q31*/, 48806446l/*0.0227272727 Q31*/, 47721859l/*0.0222222222 Q31*/, 46684427l/*0.0217391304 Q31*/, 45691141l/*0.0212765957 Q31*/, + 44739243l/*0.0208333333 Q31*/, 43826197l/*0.0204081633 Q31*/, 42949673l/*0.0200000000 Q31*/, 42107522l/*0.0196078431 Q31*/, 41297762l/*0.0192307692 Q31*/, 40518559l/*0.0188679245 Q31*/, + 39768216l/*0.0185185185 Q31*/, 39045157l/*0.0181818182 Q31*/, 38347922l/*0.0178571429 Q31*/, 37675152l/*0.0175438596 Q31*/, 37025580l/*0.0172413793 Q31*/, 36398028l/*0.0169491525 Q31*/, + 35791394l/*0.0166666667 Q31*/, 35204650l/*0.0163934426 Q31*/, 34636833l/*0.0161290323 Q31*/, 34087042l/*0.0158730159 Q31*/, 33554432l/*0.0156250000 Q31*/, 33038210l/*0.0153846154 Q31*/, + 32537631l/*0.0151515152 Q31*/, 32051995l/*0.0149253731 Q31*/, 31580642l/*0.0147058824 Q31*/, 31122951l/*0.0144927536 Q31*/, 30678338l/*0.0142857143 Q31*/, 30246248l/*0.0140845070 Q31*/, + 29826162l/*0.0138888889 Q31*/, 29417584l/*0.0136986301 Q31*/, 29020049l/*0.0135135135 Q31*/, 28633115l/*0.0133333333 Q31*/, 28256364l/*0.0131578947 Q31*/, 27889398l/*0.0129870130 Q31*/, + 27531842l/*0.0128205128 Q31*/, 27183337l/*0.0126582278 Q31*/, 26843546l/*0.0125000000 Q31*/, 26512144l/*0.0123456790 Q31*/, 26188825l/*0.0121951220 Q31*/, 25873297l/*0.0120481928 Q31*/, + 25565282l/*0.0119047619 Q31*/, 25264514l/*0.0117647059 Q31*/, 24970740l/*0.0116279070 Q31*/, 24683720l/*0.0114942529 Q31*/, 24403223l/*0.0113636364 Q31*/, 24129030l/*0.0112359551 Q31*/, + 23860929l/*0.0111111111 Q31*/, 23598721l/*0.0109890110 Q31*/, 23342214l/*0.0108695652 Q31*/, 23091222l/*0.0107526882 Q31*/, 22845571l/*0.0106382979 Q31*/, 22605091l/*0.0105263158 Q31*/, + 22369621l/*0.0104166667 Q31*/, 22139007l/*0.0103092784 Q31*/, 21913098l/*0.0102040816 Q31*/, 21691754l/*0.0101010101 Q31*/, 21474836l/*0.0100000000 Q31*/, 21262214l/*0.0099009901 Q31*/, + 21053761l/*0.0098039216 Q31*/, 20849356l/*0.0097087379 Q31*/, 20648881l/*0.0096153846 Q31*/, 20452225l/*0.0095238095 Q31*/, 20259280l/*0.0094339623 Q31*/, 20069941l/*0.0093457944 Q31*/, + 19884108l/*0.0092592593 Q31*/, 19701685l/*0.0091743119 Q31*/, 19522579l/*0.0090909091 Q31*/, 19346700l/*0.0090090090 Q31*/, 19173961l/*0.0089285714 Q31*/, 19004280l/*0.0088495575 Q31*/, + 18837576l/*0.0087719298 Q31*/, 18673771l/*0.0086956522 Q31*/, 18512790l/*0.0086206897 Q31*/, 18354561l/*0.0085470085 Q31*/, 18199014l/*0.0084745763 Q31*/, 18046081l/*0.0084033613 Q31*/, + 17895697l/*0.0083333333 Q31*/, 17747799l/*0.0082644628 Q31*/, 17602325l/*0.0081967213 Q31*/, 17459217l/*0.0081300813 Q31*/, 17318416l/*0.0080645161 Q31*/, 17179869l/*0.0080000000 Q31*/, + 17043521l/*0.0079365079 Q31*/, 16909320l/*0.0078740157 Q31*/, 16777216l/*0.0078125000 Q31*/, 16647160l/*0.0077519380 Q31*/, 16519105l/*0.0076923077 Q31*/, 16393005l/*0.0076335878 Q31*/, + 16268816l/*0.0075757576 Q31*/, 16146494l/*0.0075187970 Q31*/, 16025997l/*0.0074626866 Q31*/, 15907286l/*0.0074074074 Q31*/, 15790321l/*0.0073529412 Q31*/, 15675063l/*0.0072992701 Q31*/, + 15561476l/*0.0072463768 Q31*/, 15449523l/*0.0071942446 Q31*/, 15339169l/*0.0071428571 Q31*/, 15230381l/*0.0070921986 Q31*/, 15123124l/*0.0070422535 Q31*/, 15017368l/*0.0069930070 Q31*/, + 14913081l/*0.0069444444 Q31*/, 14810232l/*0.0068965517 Q31*/, 14708792l/*0.0068493151 Q31*/, 14608732l/*0.0068027211 Q31*/, 14510025l/*0.0067567568 Q31*/, 14412642l/*0.0067114094 Q31*/, + 14316558l/*0.0066666667 Q31*/, 14221746l/*0.0066225166 Q31*/, 14128182l/*0.0065789474 Q31*/, 14035841l/*0.0065359477 Q31*/, 13944699l/*0.0064935065 Q31*/, 13854733l/*0.0064516129 Q31*/, + 13765921l/*0.0064102564 Q31*/, 13678240l/*0.0063694268 Q31*/, 13591669l/*0.0063291139 Q31*/, 13506187l/*0.0062893082 Q31*/, 13421773l/*0.0062500000 Q31*/ +}; + +const Word16 f_atan_expand_range[MAXSFTAB - (MINSFTAB - 1)] = +{ + /***************************************************************************** + * + * Table holds fixp_atan() output values which are outside of input range + * of fixp_atan() to improve SNR of fixp_atan2(). + * + * This Table might also be used in fixp_atan() [todo] so there a wider input + * range can be covered, too. + * + * Matlab (generate table): + * for scl = 7:25 % MINSFTAB .. MAXSFTAB + * at=atan(0.5 *(2^scl)); % 0.5 because get in 'middle' area of current scale level 'scl' + * at/2 % div at by ATO_SCALE + * end + * + * Table divided by 2=ATO_SCALE <-- SF=ATO_SF + *****************************************************************************/ + 25480/*7.775862990872099e-001 Q15*/, 25608/*7.814919928673978e-001 Q15*/, 25672/*7.834450483314648e-001 Q15*/, + 25704/*7.844216021392089e-001 Q15*/, 25720/*7.849098823026687e-001 Q15*/, 25728/*7.851540227918509e-001 Q15*/, + 25732/*7.852760930873737e-001 Q15*/, 25734/*7.853371282415015e-001 Q15*/, 25735/*7.853676458193612e-001 Q15*/, + 25735/*7.853829046083906e-001 Q15*/, 25736/*7.853905340029177e-001 Q15*/, 25736/*7.853943487001828e-001 Q15*/, + 25736/*7.853962560488155e-001 Q15*/, 25736/*7.853972097231319e-001 Q15*/, 25736/*7.853976865602901e-001 Q15*/, + 25736/*7.853979249788692e-001 Q15*/, 25736/*7.853980441881587e-001 Q15*/, 25736/*7.853981037928035e-001 Q15*/, + 25736/*7.853981335951259e-001 Q15*/ + /* pi/4 = 0.785398163397448 = pi/2/ATO_SCALE */ +}; + +const Word16 shift_Isqrt_lc[] = { 9,10 }; + +const Word16 Grid[GRID100_POINTS + 1] = +{ + 32767, 32751, 32703, 32622, 32509, 32364, + 32187, 31978, 31738, 31466, 31164, 30830, + 30466, 30072, 29649, 29196, 28714, 28204, + 27666, 27101, 26509, 25891, 25248, 24579, + 23886, 23170, 22431, 21669, 20887, 20083, + 19260, 18418, 17557, 16680, 15786, 14876, + 13951, 13013, 12062, 11099, 10125, 9141, + 8149, 7148, 6140, 5126, 4106, 3083, + 2057, 1029, 0, -1029, -2057, -3083, + -4106, -5126, -6140, -7148, -8149, -9141, + -10125, -11099, -12062, -13013, -13951, -14876, + -15786, -16680, -17557, -18418, -19260, -20083, + -20887, -21669, -22431, -23170, -23886, -24579, + -25248, -25891, -26509, -27101, -27666, -28204, + -28714, -29196, -29649, -30072, -30466, -30830, + -31164, -31466, -31738, -31978, -32187, -32364, + -32509, -32622, -32703, -32751, -32760 +}; + +const Word16 pwAlpha[10] = { 0x6666, 0x51ec, 0x4189, 0x346e, 0x29f1, + 0x218e, 0x1ad8, 0x157a, 0x112e, 0x0dbe +}; + +/* Used in 'lsp2lsf_fx.c' */ +const Word8 Ind_Guess[256] = +{ + 126, 122, 120, 119, 117, 116, 115, 114, + 113, 112, 111, 110, 110, 109, 108, 108, + 107, 106, 106, 105, 104, 104, 103, 103, + 102, 102, 101, 101, 100, 100, 99, 99, + 98, 98, 97, 97, 96, 96, 95, 95, + 94, 94, 94, 93, 93, 92, 92, 91, + 91, 91, 90, 90, 89, 89, 89, 88, + 88, 87, 87, 87, 86, 86, 86, 85, + 85, 84, 84, 84, 83, 83, 83, 82, + 82, 82, 81, 81, 81, 80, 80, 80, + 79, 79, 78, 78, 78, 77, 77, 77, + 76, 76, 76, 75, 75, 75, 74, 74, + 74, 73, 73, 73, 72, 72, 72, 72, + 71, 71, 71, 70, 70, 70, 69, 69, + 69, 68, 68, 68, 67, 67, 67, 66, + 66, 66, 65, 65, 65, 64, 64, 64, + 64, 63, 63, 63, 62, 62, 62, 61, + 61, 61, 60, 60, 60, 59, 59, 59, + 58, 58, 58, 57, 57, 57, 56, 56, + 56, 55, 55, 55, 55, 54, 54, 54, + 53, 53, 53, 52, 52, 52, 51, 51, + 51, 50, 50, 50, 49, 49, 49, 48, + 48, 47, 47, 47, 46, 46, 46, 45, + 45, 45, 44, 44, 44, 43, 43, 43, + 42, 42, 41, 41, 41, 40, 40, 40, + 39, 39, 38, 38, 38, 37, 37, 36, + 36, 36, 35, 35, 34, 34, 33, 33, + 33, 32, 32, 31, 31, 30, 30, 29, + 29, 28, 28, 27, 27, 26, 26, 25, + 25, 24, 24, 23, 23, 22, 21, 21, + 20, 19, 19, 18, 17, 17, 16, 15, + 14, 13, 12, 11, 10, 8, 7, 5 +}; + +const Word16 cos_table_129[129] = +{ + 32767, + 32758, 32729, 32679, 32610, 32522, 32413, 32286, 32138, + 31972, 31786, 31581, 31357, 31114, 30853, 30572, 30274, + 29957, 29622, 29269, 28899, 28511, 28106, 27684, 27246, + 26791, 26320, 25833, 25330, 24812, 24279, 23732, 23170, + 22595, 22006, 21403, 20788, 20160, 19520, 18868, 18205, + 17531, 16846, 16151, 15447, 14733, 14010, 13279, 12540, + 11793, 11039, 10279, 9512, 8740, 7962, 7180, 6393, + 5602, 4808, 4011, 3212, 2411, 1608, 804, 0, + -804, -1608, -2411, -3212, -4011, -4808, -5602, -6393, + -7180, -7962, -8740, -9512, -10279, -11039, -11793, -12540, + -13279, -14010, -14733, -15447, -16151, -16846, -17531, -18205, + -18868, -19520, -20160, -20788, -21403, -22006, -22595, -23170, + -23732, -24279, -24812, -25330, -25833, -26320, -26791, -27246, + -27684, -28106, -28511, -28899, -29269, -29622, -29957, -30274, + -30572, -30853, -31114, -31357, -31581, -31786, -31972, -32138, + -32286, -32413, -32522, -32610, -32679, -32729, -32758, -32768 +}; + +const Word16 acos_slope[128] = +{ + -26214, -9039, -5243, -3799, -2979, -2405, -2064, -1771, + -1579, -1409, -1279, -1170, -1079, -1004, -933, -880, + -827, -783, -743, -708, -676, -647, -621, -599, + -576, -557, -538, -521, -506, -492, -479, -466, + -456, -445, -435, -426, -417, -410, -402, -395, + -389, -383, -377, -372, -367, -363, -359, -355, + -351, -348, -345, -342, -340, -337, -335, -333, + -331, -330, -329, -328, -327, -326, -326, -326, + -326, -326, -326, -327, -328, -329, -330, -331, + -333, -335, -337, -340, -342, -345, -348, -351, + -355, -359, -363, -367, -372, -377, -383, -389, + -395, -402, -410, -417, -426, -435, -445, -456, + -466, -479, -492, -506, -521, -538, -557, -576, + -599, -621, -647, -676, -708, -743, -783, -827, + -880, -933, -1004, -1079, -1170, -1279, -1409, -1579, + -1771, -2064, -2405, -2979, -3799, -5243, -9039,-26214 +}; +#define SHC(x) ((Word16)x) + +const Word16 cos_coef_new[4] = { SHC(0x02BA), SHC(0xE60A), SHC(0xEEEF), SHC(0xAAAB) }; + +const Word16 cos_table[512] = +{ + SHC(0x7fff), + SHC(0x7ffe), + SHC(0x7ff6), + SHC(0x7fea), + SHC(0x7fd9), + SHC(0x7fc2), + SHC(0x7fa7), + SHC(0x7f87), + SHC(0x7f62), + SHC(0x7f38), + SHC(0x7f0a), + SHC(0x7ed6), + SHC(0x7e9d), + SHC(0x7e60), + SHC(0x7e1e), + SHC(0x7dd6), + SHC(0x7d8a), + SHC(0x7d3a), + SHC(0x7ce4), + SHC(0x7c89), + SHC(0x7c2a), + SHC(0x7bc6), + SHC(0x7b5d), + SHC(0x7aef), + SHC(0x7a7d), + SHC(0x7a06), + SHC(0x798a), + SHC(0x790a), + SHC(0x7885), + SHC(0x77fb), + SHC(0x776c), + SHC(0x76d9), + SHC(0x7642), + SHC(0x75a6), + SHC(0x7505), + SHC(0x7460), + SHC(0x73b6), + SHC(0x7308), + SHC(0x7255), + SHC(0x719e), + SHC(0x70e3), + SHC(0x7023), + SHC(0x6f5f), + SHC(0x6e97), + SHC(0x6dca), + SHC(0x6cf9), + SHC(0x6c24), + SHC(0x6b4b), + SHC(0x6a6e), + SHC(0x698c), + SHC(0x68a7), + SHC(0x67bd), + SHC(0x66d0), + SHC(0x65de), + SHC(0x64e9), + SHC(0x63ef), + SHC(0x62f2), + SHC(0x61f1), + SHC(0x60ec), + SHC(0x5fe4), + SHC(0x5ed7), + SHC(0x5dc8), + SHC(0x5cb4), + SHC(0x5b9d), + SHC(0x5a82), + SHC(0x5964), + SHC(0x5843), + SHC(0x571e), + SHC(0x55f6), + SHC(0x54ca), + SHC(0x539b), + SHC(0x5269), + SHC(0x5134), + SHC(0x4ffb), + SHC(0x4ec0), + SHC(0x4d81), + SHC(0x4c40), + SHC(0x4afb), + SHC(0x49b4), + SHC(0x486a), + SHC(0x471d), + SHC(0x45cd), + SHC(0x447b), + SHC(0x4326), + SHC(0x41ce), + SHC(0x4074), + SHC(0x3f17), + SHC(0x3db8), + SHC(0x3c57), + SHC(0x3af3), + SHC(0x398d), + SHC(0x3825), + SHC(0x36ba), + SHC(0x354e), + SHC(0x33df), + SHC(0x326e), + SHC(0x30fc), + SHC(0x2f87), + SHC(0x2e11), + SHC(0x2c99), + SHC(0x2b1f), + SHC(0x29a4), + SHC(0x2827), + SHC(0x26a8), + SHC(0x2528), + SHC(0x23a7), + SHC(0x2224), + SHC(0x209f), + SHC(0x1f1a), + SHC(0x1d93), + SHC(0x1c0c), + SHC(0x1a83), + SHC(0x18f9), + SHC(0x176e), + SHC(0x15e2), + SHC(0x1455), + SHC(0x12c8), + SHC(0x113a), + SHC(0xfab), + SHC(0xe1c), + SHC(0xc8c), + SHC(0xafb), + SHC(0x96b), + SHC(0x7d9), + SHC(0x648), + SHC(0x4b6), + SHC(0x324), + SHC(0x192), + SHC(0x0), + SHC(0xfe6e), + SHC(0xfcdc), + SHC(0xfb4a), + SHC(0xf9b8), + SHC(0xf827), + SHC(0xf695), + SHC(0xf505), + SHC(0xf374), + SHC(0xf1e4), + SHC(0xf055), + SHC(0xeec6), + SHC(0xed38), + SHC(0xebab), + SHC(0xea1e), + SHC(0xe892), + SHC(0xe707), + SHC(0xe57d), + SHC(0xe3f4), + SHC(0xe26d), + SHC(0xe0e6), + SHC(0xdf61), + SHC(0xdddc), + SHC(0xdc59), + SHC(0xdad8), + SHC(0xd958), + SHC(0xd7d9), + SHC(0xd65c), + SHC(0xd4e1), + SHC(0xd367), + SHC(0xd1ef), + SHC(0xd079), + SHC(0xcf04), + SHC(0xcd92), + SHC(0xcc21), + SHC(0xcab2), + SHC(0xc946), + SHC(0xc7db), + SHC(0xc673), + SHC(0xc50d), + SHC(0xc3a9), + SHC(0xc248), + SHC(0xc0e9), + SHC(0xbf8c), + SHC(0xbe32), + SHC(0xbcda), + SHC(0xbb85), + SHC(0xba33), + SHC(0xb8e3), + SHC(0xb796), + SHC(0xb64c), + SHC(0xb505), + SHC(0xb3c0), + SHC(0xb27f), + SHC(0xb140), + SHC(0xb005), + SHC(0xaecc), + SHC(0xad97), + SHC(0xac65), + SHC(0xab36), + SHC(0xaa0a), + SHC(0xa8e2), + SHC(0xa7bd), + SHC(0xa69c), + SHC(0xa57e), + SHC(0xa463), + SHC(0xa34c), + SHC(0xa238), + SHC(0xa129), + SHC(0xa01c), + SHC(0x9f14), + SHC(0x9e0f), + SHC(0x9d0e), + SHC(0x9c11), + SHC(0x9b17), + SHC(0x9a22), + SHC(0x9930), + SHC(0x9843), + SHC(0x9759), + SHC(0x9674), + SHC(0x9592), + SHC(0x94b5), + SHC(0x93dc), + SHC(0x9307), + SHC(0x9236), + SHC(0x9169), + SHC(0x90a1), + SHC(0x8fdd), + SHC(0x8f1d), + SHC(0x8e62), + SHC(0x8dab), + SHC(0x8cf8), + SHC(0x8c4a), + SHC(0x8ba0), + SHC(0x8afb), + SHC(0x8a5a), + SHC(0x89be), + SHC(0x8927), + SHC(0x8894), + SHC(0x8805), + SHC(0x877b), + SHC(0x86f6), + SHC(0x8676), + SHC(0x85fa), + SHC(0x8583), + SHC(0x8511), + SHC(0x84a3), + SHC(0x843a), + SHC(0x83d6), + SHC(0x8377), + SHC(0x831c), + SHC(0x82c6), + SHC(0x8276), + SHC(0x822a), + SHC(0x81e2), + SHC(0x81a0), + SHC(0x8163), + SHC(0x812a), + SHC(0x80f6), + SHC(0x80c8), + SHC(0x809e), + SHC(0x8079), + SHC(0x8059), + SHC(0x803e), + SHC(0x8027), + SHC(0x8016), + SHC(0x800a), + SHC(0x8002), + SHC(0x8001), + SHC(0x8002), + SHC(0x800a), + SHC(0x8016), + SHC(0x8027), + SHC(0x803e), + SHC(0x8059), + SHC(0x8079), + SHC(0x809e), + SHC(0x80c8), + SHC(0x80f6), + SHC(0x812a), + SHC(0x8163), + SHC(0x81a0), + SHC(0x81e2), + SHC(0x822a), + SHC(0x8276), + SHC(0x82c6), + SHC(0x831c), + SHC(0x8377), + SHC(0x83d6), + SHC(0x843a), + SHC(0x84a3), + SHC(0x8511), + SHC(0x8583), + SHC(0x85fa), + SHC(0x8676), + SHC(0x86f6), + SHC(0x877b), + SHC(0x8805), + SHC(0x8894), + SHC(0x8927), + SHC(0x89be), + SHC(0x8a5a), + SHC(0x8afb), + SHC(0x8ba0), + SHC(0x8c4a), + SHC(0x8cf8), + SHC(0x8dab), + SHC(0x8e62), + SHC(0x8f1d), + SHC(0x8fdd), + SHC(0x90a1), + SHC(0x9169), + SHC(0x9236), + SHC(0x9307), + SHC(0x93dc), + SHC(0x94b5), + SHC(0x9592), + SHC(0x9674), + SHC(0x9759), + SHC(0x9843), + SHC(0x9930), + SHC(0x9a22), + SHC(0x9b17), + SHC(0x9c11), + SHC(0x9d0e), + SHC(0x9e0f), + SHC(0x9f14), + SHC(0xa01c), + SHC(0xa129), + SHC(0xa238), + SHC(0xa34c), + SHC(0xa463), + SHC(0xa57e), + SHC(0xa69c), + SHC(0xa7bd), + SHC(0xa8e2), + SHC(0xaa0a), + SHC(0xab36), + SHC(0xac65), + SHC(0xad97), + SHC(0xaecc), + SHC(0xb005), + SHC(0xb140), + SHC(0xb27f), + SHC(0xb3c0), + SHC(0xb505), + SHC(0xb64c), + SHC(0xb796), + SHC(0xb8e3), + SHC(0xba33), + SHC(0xbb85), + SHC(0xbcda), + SHC(0xbe32), + SHC(0xbf8c), + SHC(0xc0e9), + SHC(0xc248), + SHC(0xc3a9), + SHC(0xc50d), + SHC(0xc673), + SHC(0xc7db), + SHC(0xc946), + SHC(0xcab2), + SHC(0xcc21), + SHC(0xcd92), + SHC(0xcf04), + SHC(0xd079), + SHC(0xd1ef), + SHC(0xd367), + SHC(0xd4e1), + SHC(0xd65c), + SHC(0xd7d9), + SHC(0xd958), + SHC(0xdad8), + SHC(0xdc59), + SHC(0xdddc), + SHC(0xdf61), + SHC(0xe0e6), + SHC(0xe26d), + SHC(0xe3f4), + SHC(0xe57d), + SHC(0xe707), + SHC(0xe892), + SHC(0xea1e), + SHC(0xebab), + SHC(0xed38), + SHC(0xeec6), + SHC(0xf055), + SHC(0xf1e4), + SHC(0xf374), + SHC(0xf505), + SHC(0xf695), + SHC(0xf827), + SHC(0xf9b8), + SHC(0xfb4a), + SHC(0xfcdc), + SHC(0xfe6e), + SHC(0x0), + SHC(0x192), + SHC(0x324), + SHC(0x4b6), + SHC(0x648), + SHC(0x7d9), + SHC(0x96b), + SHC(0xafb), + SHC(0xc8c), + SHC(0xe1c), + SHC(0xfab), + SHC(0x113a), + SHC(0x12c8), + SHC(0x1455), + SHC(0x15e2), + SHC(0x176e), + SHC(0x18f9), + SHC(0x1a83), + SHC(0x1c0c), + SHC(0x1d93), + SHC(0x1f1a), + SHC(0x209f), + SHC(0x2224), + SHC(0x23a7), + SHC(0x2528), + SHC(0x26a8), + SHC(0x2827), + SHC(0x29a4), + SHC(0x2b1f), + SHC(0x2c99), + SHC(0x2e11), + SHC(0x2f87), + SHC(0x30fc), + SHC(0x326e), + SHC(0x33df), + SHC(0x354e), + SHC(0x36ba), + SHC(0x3825), + SHC(0x398d), + SHC(0x3af3), + SHC(0x3c57), + SHC(0x3db8), + SHC(0x3f17), + SHC(0x4074), + SHC(0x41ce), + SHC(0x4326), + SHC(0x447b), + SHC(0x45cd), + SHC(0x471d), + SHC(0x486a), + SHC(0x49b4), + SHC(0x4afb), + SHC(0x4c40), + SHC(0x4d81), + SHC(0x4ec0), + SHC(0x4ffb), + SHC(0x5134), + SHC(0x5269), + SHC(0x539b), + SHC(0x54ca), + SHC(0x55f6), + SHC(0x571e), + SHC(0x5843), + SHC(0x5964), + SHC(0x5a82), + SHC(0x5b9d), + SHC(0x5cb4), + SHC(0x5dc8), + SHC(0x5ed7), + SHC(0x5fe4), + SHC(0x60ec), + SHC(0x61f1), + SHC(0x62f2), + SHC(0x63ef), + SHC(0x64e9), + SHC(0x65de), + SHC(0x66d0), + SHC(0x67bd), + SHC(0x68a7), + SHC(0x698c), + SHC(0x6a6e), + SHC(0x6b4b), + SHC(0x6c24), + SHC(0x6cf9), + SHC(0x6dca), + SHC(0x6e97), + SHC(0x6f5f), + SHC(0x7023), + SHC(0x70e3), + SHC(0x719e), + SHC(0x7255), + SHC(0x7308), + SHC(0x73b6), + SHC(0x7460), + SHC(0x7505), + SHC(0x75a6), + SHC(0x7642), + SHC(0x76d9), + SHC(0x776c), + SHC(0x77fb), + SHC(0x7885), + SHC(0x790a), + SHC(0x798a), + SHC(0x7a06), + SHC(0x7a7d), + SHC(0x7aef), + SHC(0x7b5d), + SHC(0x7bc6), + SHC(0x7c2a), + SHC(0x7c89), + SHC(0x7ce4), + SHC(0x7d3a), + SHC(0x7d8a), + SHC(0x7dd6), + SHC(0x7e1e), + SHC(0x7e60), + SHC(0x7e9d), + SHC(0x7ed6), + SHC(0x7f0a), + SHC(0x7f38), + SHC(0x7f62), + SHC(0x7f87), + SHC(0x7fa7), + SHC(0x7fc2), + SHC(0x7fd9), + SHC(0x7fea), + SHC(0x7ff6), + SHC(0x7ffe) +}; + +const PWord16 w1N8[15] = +{ + {{ 32729/*0.998795 Q15*/, -1608/*-0.049068 Q15*/}}, + {{ 32610/*0.995185 Q15*/, -3212/*-0.098017 Q15*/}}, + {{ 32413/*0.989177 Q15*/, -4808/*-0.146730 Q15*/}}, + {{ 32138/*0.980785 Q15*/, -6393/*-0.195090 Q15*/}}, + {{ 31786/*0.970031 Q15*/, -7962/*-0.242980 Q15*/}}, + {{ 31357/*0.956940 Q15*/, -9512/*-0.290285 Q15*/}}, + {{ 30853/*0.941544 Q15*/, -11039/*-0.336890 Q15*/}}, + {{ 30274/*0.923880 Q15*/, -12540/*-0.382683 Q15*/}}, + {{ 29622/*0.903989 Q15*/, -14010/*-0.427555 Q15*/}}, + {{ 28899/*0.881921 Q15*/, -15447/*-0.471397 Q15*/}}, + {{ 28106/*0.857729 Q15*/, -16846/*-0.514103 Q15*/}}, + {{ 27246/*0.831470 Q15*/, -18205/*-0.555570 Q15*/}}, + {{ 26320/*0.803208 Q15*/, -19520/*-0.595699 Q15*/}}, + {{ 25330/*0.773010 Q15*/, -20788/*-0.634393 Q15*/}}, + {{ 24279/*0.740951 Q15*/, -22006/*-0.671559 Q15*/}} +}; + +const PWord16 w2N8[15] = +{ + {{ 32610/*0.995185 Q15*/, -3212/*-0.098017 Q15*/}}, + {{ 32138/*0.980785 Q15*/, -6393/*-0.195090 Q15*/}}, + {{ 31357/*0.956940 Q15*/, -9512/*-0.290285 Q15*/}}, + {{ 30274/*0.923880 Q15*/, -12540/*-0.382683 Q15*/}}, + {{ 28899/*0.881921 Q15*/, -15447/*-0.471397 Q15*/}}, + {{ 27246/*0.831470 Q15*/, -18205/*-0.555570 Q15*/}}, + {{ 25330/*0.773010 Q15*/, -20788/*-0.634393 Q15*/}}, + {{ 23170/*0.707107 Q15*/, -23170/*-0.707107 Q15*/}}, + {{ 20788/*0.634393 Q15*/, -25330/*-0.773010 Q15*/}}, + {{ 18205/*0.555570 Q15*/, -27246/*-0.831470 Q15*/}}, + {{ 15447/*0.471397 Q15*/, -28899/*-0.881921 Q15*/}}, + {{ 12540/*0.382683 Q15*/, -30274/*-0.923880 Q15*/}}, + {{ 9512/*0.290285 Q15*/, -31357/*-0.956940 Q15*/}}, + {{ 6393/*0.195090 Q15*/, -32138/*-0.980785 Q15*/}}, + {{ 3212/*0.098017 Q15*/, -32610/*-0.995185 Q15*/}} +}; + +const PWord16 w3N8[15] = +{ + {{ 32413/*0.989177 Q15*/, -4808/*-0.146730 Q15*/}}, + {{ 31357/*0.956940 Q15*/, -9512/*-0.290285 Q15*/}}, + {{ 29622/*0.903989 Q15*/, -14010/*-0.427555 Q15*/}}, + {{ 27246/*0.831470 Q15*/, -18205/*-0.555570 Q15*/}}, + {{ 24279/*0.740951 Q15*/, -22006/*-0.671559 Q15*/}}, + {{ 20788/*0.634393 Q15*/, -25330/*-0.773010 Q15*/}}, + {{ 16846/*0.514103 Q15*/, -28106/*-0.857729 Q15*/}}, + {{ 12540/*0.382683 Q15*/, -30274/*-0.923880 Q15*/}}, + {{ 7962/*0.242980 Q15*/, -31786/*-0.970031 Q15*/}}, + {{ 3212/*0.098017 Q15*/, -32610/*-0.995185 Q15*/}}, + {{ -1608/*-0.049068 Q15*/, -32729/*-0.998795 Q15*/}}, + {{ -6393/*-0.195090 Q15*/, -32138/*-0.980785 Q15*/}}, + {{-11039/*-0.336890 Q15*/, -30853/*-0.941544 Q15*/}}, + {{-15447/*-0.471397 Q15*/, -28899/*-0.881921 Q15*/}}, + {{-19520/*-0.595699 Q15*/, -26320/*-0.803208 Q15*/}} +}; + +const PWord16 w4N8[15] = +{ + {{ 32138/*0.980785 Q15*/, -6393/*-0.195090 Q15*/}}, + {{ 30274/*0.923880 Q15*/, -12540/*-0.382683 Q15*/}}, + {{ 27246/*0.831470 Q15*/, -18205/*-0.555570 Q15*/}}, + {{ 23170/*0.707107 Q15*/, -23170/*-0.707107 Q15*/}}, + {{ 18205/*0.555570 Q15*/, -27246/*-0.831470 Q15*/}}, + {{ 12540/*0.382683 Q15*/, -30274/*-0.923880 Q15*/}}, + {{ 6393/*0.195090 Q15*/, -32138/*-0.980785 Q15*/}}, + {{ 0/*0.000000 Q15*/, -32768/*-1.000000 Q15*/}}, + {{ -6393/*-0.195090 Q15*/, -32138/*-0.980785 Q15*/}}, + {{-12540/*-0.382683 Q15*/, -30274/*-0.923880 Q15*/}}, + {{-18205/*-0.555570 Q15*/, -27246/*-0.831470 Q15*/}}, + {{-23170/*-0.707107 Q15*/, -23170/*-0.707107 Q15*/}}, + {{-27246/*-0.831470 Q15*/, -18205/*-0.555570 Q15*/}}, + {{-30274/*-0.923880 Q15*/, -12540/*-0.382683 Q15*/}}, + {{-32138/*-0.980785 Q15*/, -6393/*-0.195090 Q15*/}} +}; + +const PWord16 w5N8[15] = +{ + {{ 31786/*0.970031 Q15*/, -7962/*-0.242980 Q15*/}}, + {{ 28899/*0.881921 Q15*/, -15447/*-0.471397 Q15*/}}, + {{ 24279/*0.740951 Q15*/, -22006/*-0.671559 Q15*/}}, + {{ 18205/*0.555570 Q15*/, -27246/*-0.831470 Q15*/}}, + {{ 11039/*0.336890 Q15*/, -30853/*-0.941544 Q15*/}}, + {{ 3212/*0.098017 Q15*/, -32610/*-0.995185 Q15*/}}, + {{ -4808/*-0.146730 Q15*/, -32413/*-0.989177 Q15*/}}, + {{-12540/*-0.382683 Q15*/, -30274/*-0.923880 Q15*/}}, + {{-19520/*-0.595699 Q15*/, -26320/*-0.803208 Q15*/}}, + {{-25330/*-0.773010 Q15*/, -20788/*-0.634393 Q15*/}}, + {{-29622/*-0.903989 Q15*/, -14010/*-0.427555 Q15*/}}, + {{-32138/*-0.980785 Q15*/, -6393/*-0.195090 Q15*/}}, + {{-32729/*-0.998795 Q15*/, 1608/*0.049068 Q15*/}}, + {{-31357/*-0.956940 Q15*/, 9512/*0.290285 Q15*/}}, + {{-28106/*-0.857729 Q15*/, 16846/*0.514103 Q15*/}} +}; + +const PWord16 w6N8[15] = +{ + {{ 31357/*0.956940 Q15*/, -9512/*-0.290285 Q15*/}}, + {{ 27246/*0.831470 Q15*/, -18205/*-0.555570 Q15*/}}, + {{ 20788/*0.634393 Q15*/, -25330/*-0.773010 Q15*/}}, + {{ 12540/*0.382683 Q15*/, -30274/*-0.923880 Q15*/}}, + {{ 3212/*0.098017 Q15*/, -32610/*-0.995185 Q15*/}}, + {{ -6393/*-0.195090 Q15*/, -32138/*-0.980785 Q15*/}}, + {{-15447/*-0.471397 Q15*/, -28899/*-0.881921 Q15*/}}, + {{-23170/*-0.707107 Q15*/, -23170/*-0.707107 Q15*/}}, + {{-28899/*-0.881921 Q15*/, -15447/*-0.471397 Q15*/}}, + {{-32138/*-0.980785 Q15*/, -6393/*-0.195090 Q15*/}}, + {{-32610/*-0.995185 Q15*/, 3212/*0.098017 Q15*/}}, + {{-30274/*-0.923880 Q15*/, 12540/*0.382683 Q15*/}}, + {{-25330/*-0.773010 Q15*/, 20788/*0.634393 Q15*/}}, + {{-18205/*-0.555570 Q15*/, 27246/*0.831470 Q15*/}}, + {{ -9512/*-0.290285 Q15*/, 31357/*0.956940 Q15*/}} +}; + +const PWord16 w7N8[15] = +{ + {{ 30853/*0.941544 Q15*/, -11039/*-0.336890 Q15*/}}, + {{ 25330/*0.773010 Q15*/, -20788/*-0.634393 Q15*/}}, + {{ 16846/*0.514103 Q15*/, -28106/*-0.857729 Q15*/}}, + {{ 6393/*0.195090 Q15*/, -32138/*-0.980785 Q15*/}}, + {{ -4808/*-0.146730 Q15*/, -32413/*-0.989177 Q15*/}}, + {{-15447/*-0.471397 Q15*/, -28899/*-0.881921 Q15*/}}, + {{-24279/*-0.740951 Q15*/, -22006/*-0.671559 Q15*/}}, + {{-30274/*-0.923880 Q15*/, -12540/*-0.382683 Q15*/}}, + {{-32729/*-0.998795 Q15*/, -1608/*-0.049068 Q15*/}}, + {{-31357/*-0.956940 Q15*/, 9512/*0.290285 Q15*/}}, + {{-26320/*-0.803208 Q15*/, 19520/*0.595699 Q15*/}}, + {{-18205/*-0.555570 Q15*/, 27246/*0.831470 Q15*/}}, + {{ -7962/*-0.242980 Q15*/, 31786/*0.970031 Q15*/}}, + {{ 3212/*0.098017 Q15*/, 32610/*0.995185 Q15*/}}, + {{ 14010/*0.427555 Q15*/, 29622/*0.903989 Q15*/}} +}; + +const PWord16 *w_a[7] = { w1N8, w2N8, w3N8, w4N8, w5N8, w6N8, w7N8 }; + +const PWord16 w19N[127] = +{ + {{ 31881/*0.972940 Q15*/, 7571/*0.231058 Q15*/}}, + {{ 29269/*0.893224 Q15*/, 14733/*0.449611 Q15*/}}, + {{ 25073/*0.765167 Q15*/, 21097/*0.643832 Q15*/}}, + {{ 19520/*0.595699 Q15*/, 26320/*0.803208 Q15*/}}, + {{ 12910/*0.393992 Q15*/, 30118/*0.919114 Q15*/}}, + {{ 5602/*0.170962 Q15*/, 32286/*0.985278 Q15*/}}, + {{ -2009/*-0.061321 Q15*/, 32706/*0.998118 Q15*/}}, + {{ -9512/*-0.290285 Q15*/, 31357/*0.956940 Q15*/}}, + {{-16500/*-0.503538 Q15*/, 28311/*0.863973 Q15*/}}, + {{-22595/*-0.689541 Q15*/, 23732/*0.724247 Q15*/}}, + {{-27467/*-0.838225 Q15*/, 17869/*0.545325 Q15*/}}, + {{-30853/*-0.941544 Q15*/, 11039/*0.336890 Q15*/}}, + {{-32568/*-0.993907 Q15*/, 3612/*0.110222 Q15*/}}, + {{-32522/*-0.992480 Q15*/, -4011/*-0.122411 Q15*/}}, + {{-30715/*-0.937339 Q15*/, -11417/*-0.348419 Q15*/}}, + {{-27246/*-0.831470 Q15*/, -18205/*-0.555570 Q15*/}}, + {{-22302/*-0.680601 Q15*/, -24008/*-0.732654 Q15*/}}, + {{-16151/*-0.492898 Q15*/, -28511/*-0.870087 Q15*/}}, + {{ -9127/*-0.278520 Q15*/, -31471/*-0.960431 Q15*/}}, + {{ -1608/*-0.049068 Q15*/, -32729/*-0.998795 Q15*/}}, + {{ 5998/*0.183040 Q15*/, -32214/*-0.983105 Q15*/}}, + {{ 13279/*0.405241 Q15*/, -29957/*-0.914210 Q15*/}}, + {{ 19841/*0.605511 Q15*/, -26078/*-0.795837 Q15*/}}, + {{ 25330/*0.773010 Q15*/, -20788/*-0.634393 Q15*/}}, + {{ 29448/*0.898674 Q15*/, -14373/*-0.438616 Q15*/}}, + {{ 31972/*0.975702 Q15*/, -7180/*-0.219101 Q15*/}}, + {{ 32766/*0.999925 Q15*/, 402/*0.012272 Q15*/}}, + {{ 31786/*0.970031 Q15*/, 7962/*0.242980 Q15*/}}, + {{ 29086/*0.887640 Q15*/, 15091/*0.460539 Q15*/}}, + {{ 24812/*0.757209 Q15*/, 21403/*0.653173 Q15*/}}, + {{ 19195/*0.585798 Q15*/, 26557/*0.810457 Q15*/}}, + {{ 12540/*0.382683 Q15*/, 30274/*0.923880 Q15*/}}, + {{ 5205/*0.158858 Q15*/, 32352/*0.987301 Q15*/}}, + {{ -2411/*-0.073565 Q15*/, 32679/*0.997290 Q15*/}}, + {{ -9896/*-0.302006 Q15*/, 31238/*0.953306 Q15*/}}, + {{-16846/*-0.514103 Q15*/, 28106/*0.857729 Q15*/}}, + {{-22884/*-0.698376 Q15*/, 23453/*0.715731 Q15*/}}, + {{-27684/*-0.844854 Q15*/, 17531/*0.534998 Q15*/}}, + {{-30986/*-0.945607 Q15*/, 10660/*0.325310 Q15*/}}, + {{-32610/*-0.995185 Q15*/, 3212/*0.098017 Q15*/}}, + {{-32470/*-0.990903 Q15*/, -4410/*-0.134581 Q15*/}}, + {{-30572/*-0.932993 Q15*/, -11793/*-0.359895 Q15*/}}, + {{-27020/*-0.824589 Q15*/, -18538/*-0.565732 Q15*/}}, + {{-22006/*-0.671559 Q15*/, -24279/*-0.740951 Q15*/}}, + {{-15800/*-0.482184 Q15*/, -28707/*-0.876070 Q15*/}}, + {{ -8740/*-0.266713 Q15*/, -31581/*-0.963776 Q15*/}}, + {{ -1206/*-0.036807 Q15*/, -32746/*-0.999322 Q15*/}}, + {{ 6393/*0.195090 Q15*/, -32138/*-0.980785 Q15*/}}, + {{ 13646/*0.416430 Q15*/, -29792/*-0.909168 Q15*/}}, + {{ 20160/*0.615232 Q15*/, -25833/*-0.788346 Q15*/}}, + {{ 25583/*0.780737 Q15*/, -20475/*-0.624859 Q15*/}}, + {{ 29622/*0.903989 Q15*/, -14010/*-0.427555 Q15*/}}, + {{ 32057/*0.978317 Q15*/, -6787/*-0.207111 Q15*/}}, + {{ 32758/*0.999699 Q15*/, 804/*0.024541 Q15*/}}, + {{ 31686/*0.966976 Q15*/, 8351/*0.254866 Q15*/}}, + {{ 28899/*0.881921 Q15*/, 15447/*0.471397 Q15*/}}, + {{ 24548/*0.749136 Q15*/, 21706/*0.662416 Q15*/}}, + {{ 18868/*0.575808 Q15*/, 26791/*0.817585 Q15*/}}, + {{ 12167/*0.371317 Q15*/, 30425/*0.928506 Q15*/}}, + {{ 4808/*0.146730 Q15*/, 32413/*0.989177 Q15*/}}, + {{ -2811/*-0.085797 Q15*/, 32647/*0.996313 Q15*/}}, + {{-10279/*-0.313682 Q15*/, 31114/*0.949528 Q15*/}}, + {{-17190/*-0.524590 Q15*/, 27897/*0.851355 Q15*/}}, + {{-23170/*-0.707107 Q15*/, 23170/*0.707107 Q15*/}}, + {{-27897/*-0.851355 Q15*/, 17190/*0.524590 Q15*/}}, + {{-31114/*-0.949528 Q15*/, 10279/*0.313682 Q15*/}}, + {{-32647/*-0.996313 Q15*/, 2811/*0.085797 Q15*/}}, + {{-32413/*-0.989177 Q15*/, -4808/*-0.146730 Q15*/}}, + {{-30425/*-0.928506 Q15*/, -12167/*-0.371317 Q15*/}}, + {{-26791/*-0.817585 Q15*/, -18868/*-0.575808 Q15*/}}, + {{-21706/*-0.662416 Q15*/, -24548/*-0.749136 Q15*/}}, + {{-15447/*-0.471397 Q15*/, -28899/*-0.881921 Q15*/}}, + {{ -8351/*-0.254866 Q15*/, -31686/*-0.966976 Q15*/}}, + {{ -804/*-0.024541 Q15*/, -32758/*-0.999699 Q15*/}}, + {{ 6787/*0.207111 Q15*/, -32057/*-0.978317 Q15*/}}, + {{ 14010/*0.427555 Q15*/, -29622/*-0.903989 Q15*/}}, + {{ 20475/*0.624859 Q15*/, -25583/*-0.780737 Q15*/}}, + {{ 25833/*0.788346 Q15*/, -20160/*-0.615232 Q15*/}}, + {{ 29792/*0.909168 Q15*/, -13646/*-0.416430 Q15*/}}, + {{ 32138/*0.980785 Q15*/, -6393/*-0.195090 Q15*/}}, + {{ 32746/*0.999322 Q15*/, 1206/*0.036807 Q15*/}}, + {{ 31581/*0.963776 Q15*/, 8740/*0.266713 Q15*/}}, + {{ 28707/*0.876070 Q15*/, 15800/*0.482184 Q15*/}}, + {{ 24279/*0.740951 Q15*/, 22006/*0.671559 Q15*/}}, + {{ 18538/*0.565732 Q15*/, 27020/*0.824589 Q15*/}}, + {{ 11793/*0.359895 Q15*/, 30572/*0.932993 Q15*/}}, + {{ 4410/*0.134581 Q15*/, 32470/*0.990903 Q15*/}}, + {{ -3212/*-0.098017 Q15*/, 32610/*0.995185 Q15*/}}, + {{-10660/*-0.325310 Q15*/, 30986/*0.945607 Q15*/}}, + {{-17531/*-0.534998 Q15*/, 27684/*0.844854 Q15*/}}, + {{-23453/*-0.715731 Q15*/, 22884/*0.698376 Q15*/}}, + {{-28106/*-0.857729 Q15*/, 16846/*0.514103 Q15*/}}, + {{-31238/*-0.953306 Q15*/, 9896/*0.302006 Q15*/}}, + {{-32679/*-0.997290 Q15*/, 2411/*0.073565 Q15*/}}, + {{-32352/*-0.987301 Q15*/, -5205/*-0.158858 Q15*/}}, + {{-30274/*-0.923880 Q15*/, -12540/*-0.382683 Q15*/}}, + {{-26557/*-0.810457 Q15*/, -19195/*-0.585798 Q15*/}}, + {{-21403/*-0.653173 Q15*/, -24812/*-0.757209 Q15*/}}, + {{-15091/*-0.460539 Q15*/, -29086/*-0.887640 Q15*/}}, + {{ -7962/*-0.242980 Q15*/, -31786/*-0.970031 Q15*/}}, + {{ -402/*-0.012272 Q15*/, -32766/*-0.999925 Q15*/}}, + {{ 7180/*0.219101 Q15*/, -31972/*-0.975702 Q15*/}}, + {{ 14373/*0.438616 Q15*/, -29448/*-0.898674 Q15*/}}, + {{ 20788/*0.634393 Q15*/, -25330/*-0.773010 Q15*/}}, + {{ 26078/*0.795837 Q15*/, -19841/*-0.605511 Q15*/}}, + {{ 29957/*0.914210 Q15*/, -13279/*-0.405241 Q15*/}}, + {{ 32214/*0.983105 Q15*/, -5998/*-0.183040 Q15*/}}, + {{ 32729/*0.998795 Q15*/, 1608/*0.049068 Q15*/}}, + {{ 31471/*0.960431 Q15*/, 9127/*0.278520 Q15*/}}, + {{ 28511/*0.870087 Q15*/, 16151/*0.492898 Q15*/}}, + {{ 24008/*0.732654 Q15*/, 22302/*0.680601 Q15*/}}, + {{ 18205/*0.555570 Q15*/, 27246/*0.831470 Q15*/}}, + {{ 11417/*0.348419 Q15*/, 30715/*0.937339 Q15*/}}, + {{ 4011/*0.122411 Q15*/, 32522/*0.992480 Q15*/}}, + {{ -3612/*-0.110222 Q15*/, 32568/*0.993907 Q15*/}}, + {{-11039/*-0.336890 Q15*/, 30853/*0.941544 Q15*/}}, + {{-17869/*-0.545325 Q15*/, 27467/*0.838225 Q15*/}}, + {{-23732/*-0.724247 Q15*/, 22595/*0.689541 Q15*/}}, + {{-28311/*-0.863973 Q15*/, 16500/*0.503538 Q15*/}}, + {{-31357/*-0.956940 Q15*/, 9512/*0.290285 Q15*/}}, + {{-32706/*-0.998118 Q15*/, 2009/*0.061321 Q15*/}}, + {{-32286/*-0.985278 Q15*/, -5602/*-0.170962 Q15*/}}, + {{-30118/*-0.919114 Q15*/, -12910/*-0.393992 Q15*/}}, + {{-26320/*-0.803208 Q15*/, -19520/*-0.595699 Q15*/}}, + {{-21097/*-0.643832 Q15*/, -25073/*-0.765167 Q15*/}}, + {{-14733/*-0.449611 Q15*/, -29269/*-0.893224 Q15*/}}, + {{ -7571/*-0.231058 Q15*/, -31881/*-0.972940 Q15*/}} +}; + +const PWord16 w18N[127] = +{ + {{ 31972/*0.975702 Q15*/, 7180/*0.219101 Q15*/}}, + {{ 29622/*0.903989 Q15*/, 14010/*0.427555 Q15*/}}, + {{ 25833/*0.788346 Q15*/, 20160/*0.615232 Q15*/}}, + {{ 20788/*0.634393 Q15*/, 25330/*0.773010 Q15*/}}, + {{ 14733/*0.449611 Q15*/, 29269/*0.893224 Q15*/}}, + {{ 7962/*0.242980 Q15*/, 31786/*0.970031 Q15*/}}, + {{ 804/*0.024541 Q15*/, 32758/*0.999699 Q15*/}}, + {{ -6393/*-0.195090 Q15*/, 32138/*0.980785 Q15*/}}, + {{-13279/*-0.405241 Q15*/, 29957/*0.914210 Q15*/}}, + {{-19520/*-0.595699 Q15*/, 26320/*0.803208 Q15*/}}, + {{-24812/*-0.757209 Q15*/, 21403/*0.653173 Q15*/}}, + {{-28899/*-0.881921 Q15*/, 15447/*0.471397 Q15*/}}, + {{-31581/*-0.963776 Q15*/, 8740/*0.266713 Q15*/}}, + {{-32729/*-0.998795 Q15*/, 1608/*0.049068 Q15*/}}, + {{-32286/*-0.985278 Q15*/, -5602/*-0.170962 Q15*/}}, + {{-30274/*-0.923880 Q15*/, -12540/*-0.382683 Q15*/}}, + {{-26791/*-0.817585 Q15*/, -18868/*-0.575808 Q15*/}}, + {{-22006/*-0.671559 Q15*/, -24279/*-0.740951 Q15*/}}, + {{-16151/*-0.492898 Q15*/, -28511/*-0.870087 Q15*/}}, + {{ -9512/*-0.290285 Q15*/, -31357/*-0.956940 Q15*/}}, + {{ -2411/*-0.073565 Q15*/, -32679/*-0.997290 Q15*/}}, + {{ 4808/*0.146730 Q15*/, -32413/*-0.989177 Q15*/}}, + {{ 11793/*0.359895 Q15*/, -30572/*-0.932993 Q15*/}}, + {{ 18205/*0.555570 Q15*/, -27246/*-0.831470 Q15*/}}, + {{ 23732/*0.724247 Q15*/, -22595/*-0.689541 Q15*/}}, + {{ 28106/*0.857729 Q15*/, -16846/*-0.514103 Q15*/}}, + {{ 31114/*0.949528 Q15*/, -10279/*-0.313682 Q15*/}}, + {{ 32610/*0.995185 Q15*/, -3212/*-0.098017 Q15*/}}, + {{ 32522/*0.992480 Q15*/, 4011/*0.122411 Q15*/}}, + {{ 30853/*0.941544 Q15*/, 11039/*0.336890 Q15*/}}, + {{ 27684/*0.844854 Q15*/, 17531/*0.534998 Q15*/}}, + {{ 23170/*0.707107 Q15*/, 23170/*0.707107 Q15*/}}, + {{ 17531/*0.534998 Q15*/, 27684/*0.844854 Q15*/}}, + {{ 11039/*0.336890 Q15*/, 30853/*0.941544 Q15*/}}, + {{ 4011/*0.122411 Q15*/, 32522/*0.992480 Q15*/}}, + {{ -3212/*-0.098017 Q15*/, 32610/*0.995185 Q15*/}}, + {{-10279/*-0.313682 Q15*/, 31114/*0.949528 Q15*/}}, + {{-16846/*-0.514103 Q15*/, 28106/*0.857729 Q15*/}}, + {{-22595/*-0.689541 Q15*/, 23732/*0.724247 Q15*/}}, + {{-27246/*-0.831470 Q15*/, 18205/*0.555570 Q15*/}}, + {{-30572/*-0.932993 Q15*/, 11793/*0.359895 Q15*/}}, + {{-32413/*-0.989177 Q15*/, 4808/*0.146730 Q15*/}}, + {{-32679/*-0.997290 Q15*/, -2411/*-0.073565 Q15*/}}, + {{-31357/*-0.956940 Q15*/, -9512/*-0.290285 Q15*/}}, + {{-28511/*-0.870087 Q15*/, -16151/*-0.492898 Q15*/}}, + {{-24279/*-0.740951 Q15*/, -22006/*-0.671559 Q15*/}}, + {{-18868/*-0.575808 Q15*/, -26791/*-0.817585 Q15*/}}, + {{-12540/*-0.382683 Q15*/, -30274/*-0.923880 Q15*/}}, + {{ -5602/*-0.170962 Q15*/, -32286/*-0.985278 Q15*/}}, + {{ 1608/*0.049068 Q15*/, -32729/*-0.998795 Q15*/}}, + {{ 8740/*0.266713 Q15*/, -31581/*-0.963776 Q15*/}}, + {{ 15447/*0.471397 Q15*/, -28899/*-0.881921 Q15*/}}, + {{ 21403/*0.653173 Q15*/, -24812/*-0.757209 Q15*/}}, + {{ 26320/*0.803208 Q15*/, -19520/*-0.595699 Q15*/}}, + {{ 29957/*0.914210 Q15*/, -13279/*-0.405241 Q15*/}}, + {{ 32138/*0.980785 Q15*/, -6393/*-0.195090 Q15*/}}, + {{ 32758/*0.999699 Q15*/, 804/*0.024541 Q15*/}}, + {{ 31786/*0.970031 Q15*/, 7962/*0.242980 Q15*/}}, + {{ 29269/*0.893224 Q15*/, 14733/*0.449611 Q15*/}}, + {{ 25330/*0.773010 Q15*/, 20788/*0.634393 Q15*/}}, + {{ 20160/*0.615232 Q15*/, 25833/*0.788346 Q15*/}}, + {{ 14010/*0.427555 Q15*/, 29622/*0.903989 Q15*/}}, + {{ 7180/*0.219101 Q15*/, 31972/*0.975702 Q15*/}}, + {{ 0/*0.000000 Q15*/, 32767/*1.000000 Q15*/}}, + {{ -7180/*-0.219101 Q15*/, 31972/*0.975702 Q15*/}}, + {{-14010/*-0.427555 Q15*/, 29622/*0.903989 Q15*/}}, + {{-20160/*-0.615232 Q15*/, 25833/*0.788346 Q15*/}}, + {{-25330/*-0.773010 Q15*/, 20788/*0.634393 Q15*/}}, + {{-29269/*-0.893224 Q15*/, 14733/*0.449611 Q15*/}}, + {{-31786/*-0.970031 Q15*/, 7962/*0.242980 Q15*/}}, + {{-32758/*-0.999699 Q15*/, 804/*0.024541 Q15*/}}, + {{-32138/*-0.980785 Q15*/, -6393/*-0.195090 Q15*/}}, + {{-29957/*-0.914210 Q15*/, -13279/*-0.405241 Q15*/}}, + {{-26320/*-0.803208 Q15*/, -19520/*-0.595699 Q15*/}}, + {{-21403/*-0.653173 Q15*/, -24812/*-0.757209 Q15*/}}, + {{-15447/*-0.471397 Q15*/, -28899/*-0.881921 Q15*/}}, + {{ -8740/*-0.266713 Q15*/, -31581/*-0.963776 Q15*/}}, + {{ -1608/*-0.049068 Q15*/, -32729/*-0.998795 Q15*/}}, + {{ 5602/*0.170962 Q15*/, -32286/*-0.985278 Q15*/}}, + {{ 12540/*0.382683 Q15*/, -30274/*-0.923880 Q15*/}}, + {{ 18868/*0.575808 Q15*/, -26791/*-0.817585 Q15*/}}, + {{ 24279/*0.740951 Q15*/, -22006/*-0.671559 Q15*/}}, + {{ 28511/*0.870087 Q15*/, -16151/*-0.492898 Q15*/}}, + {{ 31357/*0.956940 Q15*/, -9512/*-0.290285 Q15*/}}, + {{ 32679/*0.997290 Q15*/, -2411/*-0.073565 Q15*/}}, + {{ 32413/*0.989177 Q15*/, 4808/*0.146730 Q15*/}}, + {{ 30572/*0.932993 Q15*/, 11793/*0.359895 Q15*/}}, + {{ 27246/*0.831470 Q15*/, 18205/*0.555570 Q15*/}}, + {{ 22595/*0.689541 Q15*/, 23732/*0.724247 Q15*/}}, + {{ 16846/*0.514103 Q15*/, 28106/*0.857729 Q15*/}}, + {{ 10279/*0.313682 Q15*/, 31114/*0.949528 Q15*/}}, + {{ 3212/*0.098017 Q15*/, 32610/*0.995185 Q15*/}}, + {{ -4011/*-0.122411 Q15*/, 32522/*0.992480 Q15*/}}, + {{-11039/*-0.336890 Q15*/, 30853/*0.941544 Q15*/}}, + {{-17531/*-0.534998 Q15*/, 27684/*0.844854 Q15*/}}, + {{-23170/*-0.707107 Q15*/, 23170/*0.707107 Q15*/}}, + {{-27684/*-0.844854 Q15*/, 17531/*0.534998 Q15*/}}, + {{-30853/*-0.941544 Q15*/, 11039/*0.336890 Q15*/}}, + {{-32522/*-0.992480 Q15*/, 4011/*0.122411 Q15*/}}, + {{-32610/*-0.995185 Q15*/, -3212/*-0.098017 Q15*/}}, + {{-31114/*-0.949528 Q15*/, -10279/*-0.313682 Q15*/}}, + {{-28106/*-0.857729 Q15*/, -16846/*-0.514103 Q15*/}}, + {{-23732/*-0.724247 Q15*/, -22595/*-0.689541 Q15*/}}, + {{-18205/*-0.555570 Q15*/, -27246/*-0.831470 Q15*/}}, + {{-11793/*-0.359895 Q15*/, -30572/*-0.932993 Q15*/}}, + {{ -4808/*-0.146730 Q15*/, -32413/*-0.989177 Q15*/}}, + {{ 2411/*0.073565 Q15*/, -32679/*-0.997290 Q15*/}}, + {{ 9512/*0.290285 Q15*/, -31357/*-0.956940 Q15*/}}, + {{ 16151/*0.492898 Q15*/, -28511/*-0.870087 Q15*/}}, + {{ 22006/*0.671559 Q15*/, -24279/*-0.740951 Q15*/}}, + {{ 26791/*0.817585 Q15*/, -18868/*-0.575808 Q15*/}}, + {{ 30274/*0.923880 Q15*/, -12540/*-0.382683 Q15*/}}, + {{ 32286/*0.985278 Q15*/, -5602/*-0.170962 Q15*/}}, + {{ 32729/*0.998795 Q15*/, 1608/*0.049068 Q15*/}}, + {{ 31581/*0.963776 Q15*/, 8740/*0.266713 Q15*/}}, + {{ 28899/*0.881921 Q15*/, 15447/*0.471397 Q15*/}}, + {{ 24812/*0.757209 Q15*/, 21403/*0.653173 Q15*/}}, + {{ 19520/*0.595699 Q15*/, 26320/*0.803208 Q15*/}}, + {{ 13279/*0.405241 Q15*/, 29957/*0.914210 Q15*/}}, + {{ 6393/*0.195090 Q15*/, 32138/*0.980785 Q15*/}}, + {{ -804/*-0.024541 Q15*/, 32758/*0.999699 Q15*/}}, + {{ -7962/*-0.242980 Q15*/, 31786/*0.970031 Q15*/}}, + {{-14733/*-0.449611 Q15*/, 29269/*0.893224 Q15*/}}, + {{-20788/*-0.634393 Q15*/, 25330/*0.773010 Q15*/}}, + {{-25833/*-0.788346 Q15*/, 20160/*0.615232 Q15*/}}, + {{-29622/*-0.903989 Q15*/, 14010/*0.427555 Q15*/}}, + {{-31972/*-0.975702 Q15*/, 7180/*0.219101 Q15*/}} +}; + +/*-------------------------------------------------------------------* + * 1/4 resolution interpolation filter (-3 dB at 0.791*fs/2) + * for fractional pitch search + * Used in lib_enc\pit_enc.c Q14 + *-------------------------------------------------------------------*/ +const Word16 inter4_1_fx[32] = +{ + -12, -26, 32, 206, + 420, 455, 73, -766, + -1732, -2142,-1242, 1376, + 5429, 9910,13418,14746, + 13418, 9910, 5429, 1376, + -1242, -2142,-1732, -766, + 73, 455, 420, 206, + 32, -26, -12, 0 +}; + /* clang-format on */ diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index f5e2eef1d..bee23e92d 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -44,14 +44,32 @@ #include "stl.h" #include "basop_util.h" +#define MINSFTAB 7 +#define MAXSFTAB 25 typedef struct { int32_t fin; /* input frequency */ - int32_t fout; /* output frequency */ - int16_t fac_num; /* numerator of resampling factor */ - const float *filter; /* resampling filter coefficients */ - int16_t filt_len; /* number of filter coeff. */ - uint16_t flags; /* flags from config. table */ + Word32 fin_fx; /* input frequency Q0 */ + + int32_t fout; /* output frequency */ + Word32 fout_fx; /* output frequency Q0 */ + + int16_t fac_num; /* numerator of resampling factor */ + Word16 fac_num_fx; /* numerator of resampling factor Q0 */ + + Word16 fac_den_fx; /* denominator of resampling factor Q0 */ + Word16 lg_out; /* denominator of resampling factor Q15 */ + + const float *filter; /* resampling filter coefficients */ + const Word16 *filter_fx; /* resampling filter coefficients Q14 */ + + int16_t filt_len; /* number of filter coeff. */ + Word16 filt_len_fx; /* number of filter coeff. Q0 */ + + uint16_t flags; /* flags from config. table */ + UWord16 flags_fx; /* flags from config. table Q0 */ + //UNS_Word16 flags_fx; /* flags from config. table Q0 */ + } Resampling_cfg; typedef struct @@ -60,18 +78,42 @@ typedef struct int16_t bw; const int16_t *band_width; Word32 L_qint; - Word16 eref_fx; - Word16 bit_alloc_weight_fx; + + Word16 eref_fx; + Word16 eref; + + Word16 bit_alloc_weight_fx; + Word16 bit_alloc_weight; + int16_t gqlevs; int16_t Ngq; int16_t p2a_bands; - float p2a_th; - float pd_thresh; - float ld_slope; - float ni_coef; - float ni_pd_th; + + float p2a_th_float; + Word16 p2a_th; + + float pd_thresh_float; + Word16 pd_thresh; + + float ld_slope_float; + Word16 ld_slope; + + float ni_coef_float; + Word16 ni_coef; + + float ni_pd_th; + } Xcore_Config; + +extern const Word16 filter_LP15_180H_fx[]; /* Sincfilt.m: N=180*2+1, Fmin=0, Fmax=1/15, hann( N )' */ +extern const Word16 filter_LP3_90H_fx[]; /* Sincfilt.m: N=90*2+1, Fmin=0, Fmax=1/3, hann( N )' */ +extern const Word16 filter_LP12_180H_13b_fx[]; /* Sincfilt.m: N=180*2+1, Fmin=0, Fmax=1/12, hann( N )' */ +extern const Word16 filter_LP15_180H_13b_fx[]; /* Sincfilt.m: N=180*2+1, Fmin=0, Fmax=1/15, hann( N )' */ +extern const Word16 filter_LP15_360H_13b_fx[]; /* Sincfilt.m: N=360*2+1, Fmin=0, Fmax=1/15, hann( N )' */ +extern const Word16 filter_LP24_90H_13b_fx[]; +extern const Word16 filter_LP24_90H_fx[]; + /*-----------------------------------------------------------------* * Table of bitrates *-----------------------------------------------------------------*/ @@ -122,6 +164,20 @@ extern const uint8_t ACELP_BPF_BITS[3]; *----------------------------------------------------------------------------------*/ extern const float inv_tbl[]; /* Table of 1/x values */ +extern const Word16 inv_tbl_fx[]; +extern const Word32 dicn_fx[40]; + +extern const Word16 hvq_bwe_fac_fx[16]; +extern const Word16 sqac_headroom_fx[146]; +extern const Word16 inv_N_fx[32]; +extern const Word16 band_len_harm[]; + +/* PVQ tables */ + +extern const Word32 thren_fx[39]; + +/* Band structure */ +extern const Word16 dicnlg2[40]; extern const Resampling_cfg resampling_cfg_tbl[]; /* table of resampling configurations */ extern const FrameSizeParams FrameSizeConfig[FRAME_SIZE_NB]; @@ -129,8 +185,10 @@ extern const FrameSizeParams FrameSizeConfig[FRAME_SIZE_NB]; extern const float h_high[]; /* HP filter for filtering random part of excitation in FEC */ extern const float crit_bands[]; /* Table of critical bands */ extern const float sincos_t[]; /* FFT - sinus and cosinus tables */ +extern const Word16 sincos_t_fx[161]; extern const float sincos_t_ext[]; extern const float sincos_t_rad3[]; +extern const Word16 sincos_t_rad3_fx[]; extern const int16_t fft256_read_indexes[]; /* FFT */ extern const float inter4_2[]; /* 1/4 resolution interpolation filter */ extern const float LP_assym_window[]; /* Assymetric window for LP analysis @12.8kHz */ @@ -143,6 +201,8 @@ extern const float grid100[]; /* Table of 100 grid points for eval extern const float wind_sss[LEN_WIN_SSS]; /* window for modify_sf ana */ extern const float filter5_39s320_120[]; /* LP FIR filter for 8kHz signal resampling */ +extern const Word16 filter5_39s320_120_fx[]; + extern const float lag_window_8k[17]; extern const float lag_window_12k8[][17]; extern const float lag_window_16k[][17]; @@ -154,14 +214,23 @@ extern const float interpol_frac2_mid[]; /* LPC interpolation coef extern const float interpol_frac_12k8[]; /* LPC interpolation coefficients */ extern const float interpol_isp_amr_wb[]; /* LPC interpolation coefficients for AMR-WB interoperable mode */ extern const float interpol_frac_16k[]; /* LPC interpolation coefficients @ 16kHz */ +extern const Word16 interpol_frac_16k_fx[NB_SUBFR16k]; extern const float interpol_frac_mid[]; /* LPC interpolation coefficients with mid-ISFs */ +extern const Word16 interpol_frac_mid_fx[NB_SUBFR * 3]; extern const float interpol_frac_mid_16k[]; /* LPC interpolation coefficients with mid-ISFs @ 16kHz */ +extern const Word16 interpol_frac_mid_16k_fx[NB_SUBFR16k * 3]; extern const float interpol_frac_mid_relaxprev_12k8[]; /* LPC interpolation coefficients with mid-ISFs @ 16kHz - relaxed prev frame interp */ +extern const Word16 interpol_frac_mid_relaxprev_12k8_fx[NB_SUBFR * 3]; extern const float interpol_frac_mid_FEC[]; /* LPC interpolation coefficients with mid-ISFs - FEC */ +extern const Word16 interpol_frac_mid_FEC_fx[NB_SUBFR * 3]; extern const float interpol_frac_mid_relaxprev_16k[]; /* LPC interpolation coefficients with mid-ISFs @ 16kHz - relaxed prev frame interp */ +extern const Word16 interpol_frac_mid_relaxprev_16k_fx[NB_SUBFR16k * 3]; extern const float interpol_frac_mid_16k_FEC[]; /* LPC interpolation coefficients with mid-ISFs @ 16kHz - FEC */ +extern const Word16 interpol_frac_mid_16k_FEC_fx[NB_SUBFR16k * 3]; extern const float interpol_frac_mid_relaxprev_pred_12k8[]; +extern const Word16 interpol_frac_mid_relaxprev_pred_12k8_fx[NB_SUBFR * 3]; extern const float interpol_frac_mid_relaxprev_pred_16k[]; +extern const Word16 interpol_frac_mid_relaxprev_pred_16k_fx[NB_SUBFR16k * 3]; extern const float inter6_2[PIT_FIR_SIZE6_2]; extern const float inter4_2tcx2[4][4]; @@ -354,6 +423,7 @@ extern const int16_t CBbits[]; extern const int16_t CBbits_p[]; extern const float vals[NO_LEADERS][MAX_NO_VALS]; +extern const Word16 vals_fx[NO_LEADERS][MAX_NO_VALS]; extern const int16_t no_vals[NO_LEADERS]; extern const int16_t no_vals_ind[NO_LEADERS][MAX_NO_VALS]; extern const int16_t C_VQ[LATTICE_DIM + 1][LATTICE_DIM + 1]; @@ -363,18 +433,25 @@ extern const UWord8 no_lead_idx[][2]; extern const UWord8 no_lead_p_idx[][2]; extern const Word8 leaders_short[][MAX_NO_SCALES]; extern const float sigma_MSLVQ[][16]; +extern const Word16 sigma_MSLVQ_fx[][16]; extern const float sigma_p[][16]; +extern const Word16 sigma_p_fx[][16]; extern const float inv_sigma_MSLVQ[][16]; extern const float inv_sigma_p[][16]; extern const float scales[][MAX_NO_SCALES * 2]; extern const float scales_p[][MAX_NO_SCALES * 2]; -extern const int16_t predmode_tab[][6]; +extern const Word16 scales_fx[][MAX_NO_SCALES * 2]; +extern const Word16 scales_p_fx[][MAX_NO_SCALES * 2]; +extern const int16_t predmode_tab_float[][6]; +extern const Word16 predmode_tab[][6]; extern const float pl_HQ[]; extern const int16_t pi0[]; extern const UWord32 table_no_cv[]; extern const int16_t pl_par[]; extern const float *const Quantizers[]; extern const float *const Quantizers_p[]; +extern const Word16 * const Quantizers_p_fx[]; +extern const Word16 * const Quantizers_fx[]; extern const int16_t cng_sort[]; extern const int16_t perm_MSLVQ[][4]; extern const int16_t min_lat_bits_SN[]; @@ -383,6 +460,7 @@ extern const int16_t offset_in_lvq_mode_SN[][21]; extern const int16_t offset_in_lvq_mode_pred[][32]; extern const int16_t offset_lvq_modes_SN[]; extern const int16_t offset_lvq_modes_pred[]; +extern const Word16 offset_lvq_modes_pred_fx[]; /*-----------------------------------------------------------------* * LSF quantization - BC-TCVQ tables @@ -397,20 +475,31 @@ extern const int16_t NTRANS2[4][16]; extern const float AR_IntraCoeff[N_STAGE_VQ - 1][2][2]; extern const float SN_IntraCoeff[N_STAGE_VQ - 1][2][2]; +extern const Word16 AR_IntraCoeff_fx[N_STAGE_VQ - 1][2][2]; +extern const Word16 SN_IntraCoeff_fx[N_STAGE_VQ - 1][2][2]; extern const float scale_ARSN[]; +extern const Word16 scale_ARSN_fx[]; extern const float scale_inv_ARSN[]; extern const float AR_TCVQ_CB_SUB1[2][128][2]; extern const float AR_TCVQ_CB_SUB2[2][64][2]; extern const float AR_TCVQ_CB_SUB3[4][32][2]; +extern const Word16 AR_TCVQ_CB_SUB1_fx[2][128][2]; +extern const Word16 AR_TCVQ_CB_SUB2_fx[2][64][2]; +extern const Word16 AR_TCVQ_CB_SUB3_fx[4][32][2]; extern const float SN_TCVQ_CB_SUB1[2][128][2]; extern const float SN_TCVQ_CB_SUB2[2][64][2]; extern const float SN_TCVQ_CB_SUB3[4][32][2]; +extern const Word16 SN_TCVQ_CB_SUB1_fx[2][128][2]; +extern const Word16 SN_TCVQ_CB_SUB2_fx[2][64][2]; +extern const Word16 SN_TCVQ_CB_SUB3_fx[4][32][2]; extern const float AR_SVQ_CB1[32][8]; extern const float AR_SVQ_CB2[16][8]; +extern const Word16 AR_SVQ_CB1_fx[32][8]; +extern const Word16 AR_SVQ_CB2_fx[16][8]; extern const int16_t uniform_model[]; @@ -435,9 +524,13 @@ extern const float tbl_mid_voi_wb_5b[]; *-----------------------------------------------------------------*/ extern const float lsf_init[16]; -extern const float means_wb_31bits_ma_lsf[16]; -extern const float means_nb_31bits_ma_lsf[16]; -extern const float *const lsf_means[2]; +extern const float means_wb_31bits_ma_lsf_float[16]; +extern const float means_nb_31bits_ma_lsf_float[16]; +extern const float *const lsf_means_float[2]; +extern const Word16 means_nb_31bits_ma_lsf[16]; +extern const Word16 means_wb_31bits_ma_lsf[16]; +extern const Word16 *lsf_means[2]; + extern const float *const lsf_codebook[2][2][TCXLPC_NUMSTAGES]; extern const int16_t lsf_numbits[TCXLPC_NUMSTAGES]; extern const int16_t lsf_dims[TCXLPC_NUMSTAGES]; @@ -469,11 +562,13 @@ extern const int16_t lsf_ind_dims[TCXLPC_IND_NUMSTAGES]; extern const int16_t lsf_ind_offs[TCXLPC_IND_NUMSTAGES]; extern const Word16 min_distance_thr[2][2]; -typedef float lsp_unw_triplet[3]; +typedef float lsp_unw_triplet_flt[3]; +extern const lsp_unw_triplet_flt p16_gamma0_92to1_float[16]; +extern const lsp_unw_triplet_flt p16_gamma0_94to1_float[16]; + +typedef Word16 lsp_unw_triplet[3]; extern const lsp_unw_triplet p16_gamma0_92to1[16]; extern const lsp_unw_triplet p16_gamma0_94to1[16]; - - /*------------------------------------------------------------------------------* * AVQ - RE8 tables *------------------------------------------------------------------------------*/ @@ -568,13 +663,17 @@ extern const float F_2_5[64]; extern const int16_t swb_bwe_trans_subband[]; extern const int16_t swb_bwe_trans_subband_width[]; extern const int16_t swb_bwe_subband[]; +extern const Word16 fb_bwe_subband[]; +extern const Word16 fb_bwe_sm_subband[]; extern const float swb_inv_bwe_subband_width[]; extern const int16_t swb_bwe_sm_subband[]; extern const float smooth_factor[]; -extern const int16_t fb_bwe_subband[]; +extern const Word16 smooth_factor_fx[]; +extern const int16_t fb_bwe_subband_float[]; extern const float fb_inv_bwe_subband_width[]; -extern const int16_t fb_bwe_sm_subband[]; +extern const int16_t fb_bwe_sm_subband_float[]; extern const float fb_smooth_factor[]; +extern const Word16 fb_smooth_factor_fx[]; extern const float EnvCdbk11[]; extern const float EnvCdbk1st[]; extern const float EnvCdbk2nd[]; @@ -634,11 +733,11 @@ extern const int16_t band_end_HQ[]; extern const int16_t band_len_wb[]; extern const int16_t band_start_wb[]; extern const int16_t band_end_wb[]; -extern const int16_t band_len_harm[]; +extern const int16_t band_len_harm_float[]; extern const int16_t band_start_harm[]; extern const int16_t band_end_harm[]; -extern const float rat[SFM_N_WB]; - +extern const float rat_flt[SFM_N_WB]; +extern const Word16 rat_fx[SFM_N_WB]; extern const int16_t intl_bw_16[N_INTL_GRP_16]; extern const int16_t intl_bw_32[N_INTL_GRP_32]; extern const int16_t intl_bw_48[N_INTL_GRP_48]; @@ -659,7 +758,7 @@ extern const float thren_pg[44]; extern const float dicn[40]; extern const float dicn_inv[40]; extern const float thren_HQ[39]; -extern const int16_t dicnlg2[40]; +extern const int16_t dicnlg2_float[40]; extern const int16_t huffnorm[32]; extern const int16_t huffsizn[32]; extern const int16_t huffcoef[60]; @@ -833,13 +932,15 @@ extern const int16_t fg_inv_tbl_fx[13]; extern const uint32_t exactdivodd[ODD_DIV_SIZE]; extern const float gain_att[]; +extern const Word16 gain_att_fx[40]; extern const float att_step[]; +extern const Word16 att_step_fx[4]; extern const float gain_qlow[]; extern const int16_t gain_cb_size[]; extern const float stab_trans[]; extern const Word16 stab_trans_fx[]; extern const float env_stab_tp[2][2]; - +extern const Word16 env_stab_tp_fx[2][2]; /*----------------------------------------------------------------------------------* * SWB BWE for LR MDCT core *----------------------------------------------------------------------------------*/ @@ -945,20 +1046,33 @@ extern const float Gain_mean_dic[]; extern const float Gain_mean_dicHR[]; extern const float YG_mean16[]; +extern const Word16 YG_mean16_fx[]; extern const float YG_dicMR_1[]; extern const float YG_dicMR_2[]; extern const float YG_dicMR_3[]; extern const float YG_dicMR_4[]; +extern const Word16 YG_dicMR_1_fx[]; +extern const Word16 YG_dicMR_2_fx[]; +extern const Word16 YG_dicMR_3_fx[]; +extern const Word16 YG_dicMR_4_fx[]; extern const float mean_m[]; +extern const Word16 mean_m_fx[]; extern const float mean_gain_dic[]; +extern const Word16 mean_gain_dic_fx[]; extern const float YGain_mean_LR[]; +extern const Word16 YGain_mean_LR_fx[]; extern const float YGain_dic1_LR[]; extern const float YGain_dic2_LR[]; extern const float YGain_dic3_LR[]; +extern const Word16 YGain_dic1_LR_fx[]; +extern const Word16 YGain_dic2_LR_fx[];/*Q13 */ +extern const Word16 YGain_dic3_LR_fx[];/*Q13 */ extern const float Gain_dic2_NBHR[]; extern const float Gain_dic3_NBHR[]; +extern const Word16 Gain_dic3_NBHR_fx[]; +extern const Word16 Gain_dic2_NBHR_fx[]; extern const float YG_mean16HR[]; extern const float YG_dicHR_1[]; extern const float YG_dicHR_2[]; @@ -971,12 +1085,17 @@ extern const int16_t GSC_freq_bits[]; extern const int16_t GSC_freq_DL0_bits[]; extern const int16_t Compl_GSC_freq_bits[]; extern const float Gain_meanNB[]; +extern const Word16 Gain_meanNB_fx[]; extern const float Gain_mean_dicNB[]; +extern const Word16 Gain_mean_dicNB_fx[]; extern const float Mean_dic_NB[]; +extern const Word16 Mean_dic_NB_fx[]; extern const float Gain_dic1_NB[]; extern const float Gain_dic2_NB[]; extern const float Gain_dic3_NB[]; - +extern const Word16 Gain_dic1_NB_fx[]; +extern const Word16 Gain_dic2_NB_fx[]; +extern const Word16 Gain_dic3_NB_fx[]; /*------------------------------------------------------------------------------* * FFT transform @@ -1326,7 +1445,7 @@ extern const uint16_t cf_se10_tab[IGF_SYMBOLS_IN_TABLE + 1]; extern const uint16_t cf_se11_tab[IGF_CTX_COUNT][IGF_CTX_COUNT][IGF_SYMBOLS_IN_TABLE + 1]; extern const float normReciprocal[CHEAP_NORM_SIZE]; -extern const float *const w_a[7]; +extern const float *const w_a_float[7]; extern const PWord16 SineTable512_fx[]; extern const Word16 ldCoeff[7]; @@ -1364,4 +1483,18 @@ extern const float LastCoefPred_0bit[18]; extern const float LastCoefPred_1bit[36]; extern const int16_t config_LSF_BWE[]; + +//basops +extern const Word32 BASOP_util_normReciprocal[CHEAP_NORM_SIZE]; +extern const Word16 f_atan_expand_range[MAXSFTAB - (MINSFTAB - 1)]; +extern const Word16 shift_Isqrt_lc[]; + +extern const Word16 Grid[]; +extern const Word16 pwAlpha[10]; +extern const Word8 Ind_Guess[256]; +extern const Word16 cos_table_129[129]; +extern const Word16 acos_slope[128]; +extern const Word16 cos_coef_new[4]; +extern const Word16 cos_table[512]; +extern const Word16 inter4_1_fx[]; #endif diff --git a/lib_com/rom_com_fx.c b/lib_com/rom_com_fx.c new file mode 100644 index 000000000..7c749975f --- /dev/null +++ b/lib_com/rom_com_fx.c @@ -0,0 +1,877 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +/*==================================================================================== + 3GPP TS26.258 Aug 24, 2023. IVAS Codec Version IVAS-FL-1.0 + ====================================================================================*/ + +/*==================================================================================== + EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 + ====================================================================================*/ + +#include "prot.h" +#include "basop_util.h" +#include "wmc_auto.h" +#include "rom_com_fx.h" + +#define SHC( x ) ( (Word16) x ) + +const Word16 w_fft4_fx[ 2 ] = { + SHC( 0x7fff ), SHC( 0x0000 ), +}; +const Word16 w_fft8_fx[ 8 ] = { + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x5a82 ), SHC( 0x5a82 ), SHC( 0x0000 ), SHC( 0x0000 ), SHC( 0x0000 ), SHC( 0x0000 ), + +}; +const Word16 w_fft16_fx[ 8 ] = { + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x5a82 ), SHC( 0x5a82 ), SHC( 0x7641 ), SHC( 0x30fb ), SHC( 0x30fb ), SHC( 0x7641 ), + +}; +const Word16 w_fft32_fx[ 16 ] = { + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x5a82 ), SHC( 0x5a82 ), SHC( 0x7641 ), SHC( 0x30fb ), SHC( 0x30fb ), SHC( 0x7641 ), + SHC( 0x7d8a ), SHC( 0x18f8 ), SHC( 0x471c ), SHC( 0x6a6d ), SHC( 0x6a6d ), SHC( 0x471c ), SHC( 0x18f8 ), SHC( 0x7d8a ), + +}; +const Word16 w_fft64_fx[ 32 ] = { + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x5a82 ), SHC( 0x5a82 ), SHC( 0x7641 ), SHC( 0x30fb ), SHC( 0x30fb ), SHC( 0x7641 ), + SHC( 0x7d8a ), SHC( 0x18f8 ), SHC( 0x471c ), SHC( 0x6a6d ), SHC( 0x6a6d ), SHC( 0x471c ), SHC( 0x18f8 ), SHC( 0x7d8a ), + SHC( 0x7f62 ), SHC( 0x0c8b ), SHC( 0x5133 ), SHC( 0x62f2 ), SHC( 0x70e2 ), SHC( 0x3c56 ), SHC( 0x2528 ), SHC( 0x7a7d ), + SHC( 0x7a7d ), SHC( 0x2528 ), SHC( 0x3c56 ), SHC( 0x70e2 ), SHC( 0x62f2 ), SHC( 0x5133 ), SHC( 0x0c8b ), SHC( 0x7f62 ), + +}; +const Word16 w_fft128_fx[ 64 ] = { + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x5a82 ), SHC( 0x5a82 ), SHC( 0x7641 ), SHC( 0x30fb ), SHC( 0x30fb ), SHC( 0x7641 ), + SHC( 0x7d8a ), SHC( 0x18f8 ), SHC( 0x471c ), SHC( 0x6a6d ), SHC( 0x6a6d ), SHC( 0x471c ), SHC( 0x18f8 ), SHC( 0x7d8a ), + SHC( 0x7f62 ), SHC( 0x0c8b ), SHC( 0x5133 ), SHC( 0x62f2 ), SHC( 0x70e2 ), SHC( 0x3c56 ), SHC( 0x2528 ), SHC( 0x7a7d ), + SHC( 0x7a7d ), SHC( 0x2528 ), SHC( 0x3c56 ), SHC( 0x70e2 ), SHC( 0x62f2 ), SHC( 0x5133 ), SHC( 0x0c8b ), SHC( 0x7f62 ), + SHC( 0x7fd8 ), SHC( 0x0647 ), SHC( 0x55f5 ), SHC( 0x5ed7 ), SHC( 0x73b5 ), SHC( 0x36ba ), SHC( 0x2b1f ), SHC( 0x7884 ), + SHC( 0x7c29 ), SHC( 0x1f19 ), SHC( 0x41ce ), SHC( 0x6dca ), SHC( 0x66cf ), SHC( 0x4c3f ), SHC( 0x12c8 ), SHC( 0x7e9d ), + SHC( 0x7e9d ), SHC( 0x12c8 ), SHC( 0x4c3f ), SHC( 0x66cf ), SHC( 0x6dca ), SHC( 0x41ce ), SHC( 0x1f19 ), SHC( 0x7c29 ), + SHC( 0x7884 ), SHC( 0x2b1f ), SHC( 0x36ba ), SHC( 0x73b5 ), SHC( 0x5ed7 ), SHC( 0x55f5 ), SHC( 0x0647 ), SHC( 0x7fd8 ), + +}; +const Word16 w_fft256_fx[ 128 ] = { + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x5a82 ), SHC( 0x5a82 ), SHC( 0x7641 ), SHC( 0x30fb ), SHC( 0x30fb ), SHC( 0x7641 ), + SHC( 0x7d8a ), SHC( 0x18f8 ), SHC( 0x471c ), SHC( 0x6a6d ), SHC( 0x6a6d ), SHC( 0x471c ), SHC( 0x18f8 ), SHC( 0x7d8a ), + SHC( 0x7f62 ), SHC( 0x0c8b ), SHC( 0x5133 ), SHC( 0x62f2 ), SHC( 0x70e2 ), SHC( 0x3c56 ), SHC( 0x2528 ), SHC( 0x7a7d ), + SHC( 0x7a7d ), SHC( 0x2528 ), SHC( 0x3c56 ), SHC( 0x70e2 ), SHC( 0x62f2 ), SHC( 0x5133 ), SHC( 0x0c8b ), SHC( 0x7f62 ), + SHC( 0x7fd8 ), SHC( 0x0647 ), SHC( 0x55f5 ), SHC( 0x5ed7 ), SHC( 0x73b5 ), SHC( 0x36ba ), SHC( 0x2b1f ), SHC( 0x7884 ), + SHC( 0x7c29 ), SHC( 0x1f19 ), SHC( 0x41ce ), SHC( 0x6dca ), SHC( 0x66cf ), SHC( 0x4c3f ), SHC( 0x12c8 ), SHC( 0x7e9d ), + SHC( 0x7e9d ), SHC( 0x12c8 ), SHC( 0x4c3f ), SHC( 0x66cf ), SHC( 0x6dca ), SHC( 0x41ce ), SHC( 0x1f19 ), SHC( 0x7c29 ), + SHC( 0x7884 ), SHC( 0x2b1f ), SHC( 0x36ba ), SHC( 0x73b5 ), SHC( 0x5ed7 ), SHC( 0x55f5 ), SHC( 0x0647 ), SHC( 0x7fd8 ), + SHC( 0x7ff6 ), SHC( 0x0324 ), SHC( 0x5842 ), SHC( 0x5cb4 ), SHC( 0x7504 ), SHC( 0x33de ), SHC( 0x2e11 ), SHC( 0x776c ), + SHC( 0x7ce3 ), SHC( 0x1c0b ), SHC( 0x447a ), SHC( 0x6c24 ), SHC( 0x68a6 ), SHC( 0x49b4 ), SHC( 0x15e2 ), SHC( 0x7e1d ), + SHC( 0x7f09 ), SHC( 0x0fab ), SHC( 0x4ebf ), SHC( 0x64e8 ), SHC( 0x6f5f ), SHC( 0x3f17 ), SHC( 0x2223 ), SHC( 0x7b5d ), + SHC( 0x798a ), SHC( 0x2826 ), SHC( 0x398c ), SHC( 0x7255 ), SHC( 0x60ec ), SHC( 0x539b ), SHC( 0x096a ), SHC( 0x7fa7 ), + SHC( 0x7fa7 ), SHC( 0x096a ), SHC( 0x539b ), SHC( 0x60ec ), SHC( 0x7255 ), SHC( 0x398c ), SHC( 0x2826 ), SHC( 0x798a ), + SHC( 0x7b5d ), SHC( 0x2223 ), SHC( 0x3f17 ), SHC( 0x6f5f ), SHC( 0x64e8 ), SHC( 0x4ebf ), SHC( 0x0fab ), SHC( 0x7f09 ), + SHC( 0x7e1d ), SHC( 0x15e2 ), SHC( 0x49b4 ), SHC( 0x68a6 ), SHC( 0x6c24 ), SHC( 0x447a ), SHC( 0x1c0b ), SHC( 0x7ce3 ), + SHC( 0x776c ), SHC( 0x2e11 ), SHC( 0x33de ), SHC( 0x7504 ), SHC( 0x5cb4 ), SHC( 0x5842 ), SHC( 0x0324 ), SHC( 0x7ff6 ), + +}; +const Word16 w_fft512_fx[ 256 ] = { + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x5a82 ), SHC( 0x5a82 ), SHC( 0x7641 ), SHC( 0x30fb ), SHC( 0x30fb ), SHC( 0x7641 ), + SHC( 0x7d8a ), SHC( 0x18f8 ), SHC( 0x471c ), SHC( 0x6a6d ), SHC( 0x6a6d ), SHC( 0x471c ), SHC( 0x18f8 ), SHC( 0x7d8a ), + SHC( 0x7f62 ), SHC( 0x0c8b ), SHC( 0x5133 ), SHC( 0x62f2 ), SHC( 0x70e2 ), SHC( 0x3c56 ), SHC( 0x2528 ), SHC( 0x7a7d ), + SHC( 0x7a7d ), SHC( 0x2528 ), SHC( 0x3c56 ), SHC( 0x70e2 ), SHC( 0x62f2 ), SHC( 0x5133 ), SHC( 0x0c8b ), SHC( 0x7f62 ), + SHC( 0x7fd8 ), SHC( 0x0647 ), SHC( 0x55f5 ), SHC( 0x5ed7 ), SHC( 0x73b5 ), SHC( 0x36ba ), SHC( 0x2b1f ), SHC( 0x7884 ), + SHC( 0x7c29 ), SHC( 0x1f19 ), SHC( 0x41ce ), SHC( 0x6dca ), SHC( 0x66cf ), SHC( 0x4c3f ), SHC( 0x12c8 ), SHC( 0x7e9d ), + SHC( 0x7e9d ), SHC( 0x12c8 ), SHC( 0x4c3f ), SHC( 0x66cf ), SHC( 0x6dca ), SHC( 0x41ce ), SHC( 0x1f19 ), SHC( 0x7c29 ), + SHC( 0x7884 ), SHC( 0x2b1f ), SHC( 0x36ba ), SHC( 0x73b5 ), SHC( 0x5ed7 ), SHC( 0x55f5 ), SHC( 0x0647 ), SHC( 0x7fd8 ), + SHC( 0x7ff6 ), SHC( 0x0324 ), SHC( 0x5842 ), SHC( 0x5cb4 ), SHC( 0x7504 ), SHC( 0x33de ), SHC( 0x2e11 ), SHC( 0x776c ), + SHC( 0x7ce3 ), SHC( 0x1c0b ), SHC( 0x447a ), SHC( 0x6c24 ), SHC( 0x68a6 ), SHC( 0x49b4 ), SHC( 0x15e2 ), SHC( 0x7e1d ), + SHC( 0x7f09 ), SHC( 0x0fab ), SHC( 0x4ebf ), SHC( 0x64e8 ), SHC( 0x6f5f ), SHC( 0x3f17 ), SHC( 0x2223 ), SHC( 0x7b5d ), + SHC( 0x798a ), SHC( 0x2826 ), SHC( 0x398c ), SHC( 0x7255 ), SHC( 0x60ec ), SHC( 0x539b ), SHC( 0x096a ), SHC( 0x7fa7 ), + SHC( 0x7fa7 ), SHC( 0x096a ), SHC( 0x539b ), SHC( 0x60ec ), SHC( 0x7255 ), SHC( 0x398c ), SHC( 0x2826 ), SHC( 0x798a ), + SHC( 0x7b5d ), SHC( 0x2223 ), SHC( 0x3f17 ), SHC( 0x6f5f ), SHC( 0x64e8 ), SHC( 0x4ebf ), SHC( 0x0fab ), SHC( 0x7f09 ), + SHC( 0x7e1d ), SHC( 0x15e2 ), SHC( 0x49b4 ), SHC( 0x68a6 ), SHC( 0x6c24 ), SHC( 0x447a ), SHC( 0x1c0b ), SHC( 0x7ce3 ), + SHC( 0x776c ), SHC( 0x2e11 ), SHC( 0x33de ), SHC( 0x7504 ), SHC( 0x5cb4 ), SHC( 0x5842 ), SHC( 0x0324 ), SHC( 0x7ff6 ), + SHC( 0x7ffd ), SHC( 0x0192 ), SHC( 0x5964 ), SHC( 0x5b9d ), SHC( 0x75a5 ), SHC( 0x326e ), SHC( 0x2f87 ), SHC( 0x76d9 ), + SHC( 0x7d39 ), SHC( 0x1a82 ), SHC( 0x45cd ), SHC( 0x6b4a ), SHC( 0x698c ), SHC( 0x4869 ), SHC( 0x176d ), SHC( 0x7dd6 ), + SHC( 0x7f38 ), SHC( 0x0e1b ), SHC( 0x4ffb ), SHC( 0x63ef ), SHC( 0x7023 ), SHC( 0x3db8 ), SHC( 0x23a6 ), SHC( 0x7aef ), + SHC( 0x7a05 ), SHC( 0x26a8 ), SHC( 0x3af2 ), SHC( 0x719e ), SHC( 0x61f1 ), SHC( 0x5269 ), SHC( 0x0afb ), SHC( 0x7f87 ), + SHC( 0x7fc2 ), SHC( 0x07d9 ), SHC( 0x54ca ), SHC( 0x5fe3 ), SHC( 0x7307 ), SHC( 0x3824 ), SHC( 0x29a3 ), SHC( 0x7909 ), + SHC( 0x7bc5 ), SHC( 0x209f ), SHC( 0x4073 ), SHC( 0x6e96 ), SHC( 0x65dd ), SHC( 0x4d81 ), SHC( 0x1139 ), SHC( 0x7ed5 ), + SHC( 0x7e5f ), SHC( 0x1455 ), SHC( 0x4afb ), SHC( 0x67bd ), SHC( 0x6cf9 ), SHC( 0x4325 ), SHC( 0x1d93 ), SHC( 0x7c89 ), + SHC( 0x77fa ), SHC( 0x2c98 ), SHC( 0x354d ), SHC( 0x745f ), SHC( 0x5dc7 ), SHC( 0x571d ), SHC( 0x04b6 ), SHC( 0x7fe9 ), + SHC( 0x7fe9 ), SHC( 0x04b6 ), SHC( 0x571d ), SHC( 0x5dc7 ), SHC( 0x745f ), SHC( 0x354d ), SHC( 0x2c98 ), SHC( 0x77fa ), + SHC( 0x7c89 ), SHC( 0x1d93 ), SHC( 0x4325 ), SHC( 0x6cf9 ), SHC( 0x67bd ), SHC( 0x4afb ), SHC( 0x1455 ), SHC( 0x7e5f ), + SHC( 0x7ed5 ), SHC( 0x1139 ), SHC( 0x4d81 ), SHC( 0x65dd ), SHC( 0x6e96 ), SHC( 0x4073 ), SHC( 0x209f ), SHC( 0x7bc5 ), + SHC( 0x7909 ), SHC( 0x29a3 ), SHC( 0x3824 ), SHC( 0x7307 ), SHC( 0x5fe3 ), SHC( 0x54ca ), SHC( 0x07d9 ), SHC( 0x7fc2 ), + SHC( 0x7f87 ), SHC( 0x0afb ), SHC( 0x5269 ), SHC( 0x61f1 ), SHC( 0x719e ), SHC( 0x3af2 ), SHC( 0x26a8 ), SHC( 0x7a05 ), + SHC( 0x7aef ), SHC( 0x23a6 ), SHC( 0x3db8 ), SHC( 0x7023 ), SHC( 0x63ef ), SHC( 0x4ffb ), SHC( 0x0e1b ), SHC( 0x7f38 ), + SHC( 0x7dd6 ), SHC( 0x176d ), SHC( 0x4869 ), SHC( 0x698c ), SHC( 0x6b4a ), SHC( 0x45cd ), SHC( 0x1a82 ), SHC( 0x7d39 ), + SHC( 0x76d9 ), SHC( 0x2f87 ), SHC( 0x326e ), SHC( 0x75a5 ), SHC( 0x5b9d ), SHC( 0x5964 ), SHC( 0x0192 ), SHC( 0x7ffd ), + +}; +const Word16 FFT_RotVector_960_fx[ 1860 ] = { + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7ffd ), SHC( 0xfe54 ), SHC( 0x7ff4 ), SHC( 0xfca7 ), SHC( 0x7fe6 ), SHC( 0xfafa ), + SHC( 0x7fd3 ), SHC( 0xf94e ), SHC( 0x7fb9 ), SHC( 0xf7a1 ), SHC( 0x7f9a ), SHC( 0xf5f6 ), SHC( 0x7f76 ), SHC( 0xf44a ), + SHC( 0x7f4c ), SHC( 0xf29f ), SHC( 0x7f1c ), SHC( 0xf0f5 ), SHC( 0x7ee7 ), SHC( 0xef4b ), SHC( 0x7eac ), SHC( 0xeda3 ), + SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x7e26 ), SHC( 0xea53 ), SHC( 0x7ddb ), SHC( 0xe8ad ), SHC( 0x7d8a ), SHC( 0xe708 ), + SHC( 0x7d33 ), SHC( 0xe564 ), SHC( 0x7cd8 ), SHC( 0xe3c1 ), SHC( 0x7c76 ), SHC( 0xe21f ), SHC( 0x7c0f ), SHC( 0xe07f ), + SHC( 0x7ba3 ), SHC( 0xdee0 ), SHC( 0x7b31 ), SHC( 0xdd42 ), SHC( 0x7aba ), SHC( 0xdba6 ), SHC( 0x7a3e ), SHC( 0xda0b ), + SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x7935 ), SHC( 0xd6dc ), SHC( 0x78a8 ), SHC( 0xd546 ), SHC( 0x7816 ), SHC( 0xd3b3 ), + SHC( 0x777f ), SHC( 0xd221 ), SHC( 0x76e3 ), SHC( 0xd092 ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7ff4 ), SHC( 0xfca7 ), + SHC( 0x7fd3 ), SHC( 0xf94e ), SHC( 0x7f9a ), SHC( 0xf5f6 ), SHC( 0x7f4c ), SHC( 0xf29f ), SHC( 0x7ee7 ), SHC( 0xef4b ), + SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x7ddb ), SHC( 0xe8ad ), SHC( 0x7d33 ), SHC( 0xe564 ), SHC( 0x7c76 ), SHC( 0xe21f ), + SHC( 0x7ba3 ), SHC( 0xdee0 ), SHC( 0x7aba ), SHC( 0xdba6 ), SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x78a8 ), SHC( 0xd546 ), + SHC( 0x777f ), SHC( 0xd221 ), SHC( 0x7641 ), SHC( 0xcf05 ), SHC( 0x74ef ), SHC( 0xcbf1 ), SHC( 0x7387 ), SHC( 0xc8e6 ), + SHC( 0x720c ), SHC( 0xc5e4 ), SHC( 0x707d ), SHC( 0xc2ed ), SHC( 0x6ed9 ), SHC( 0xc000 ), SHC( 0x6d23 ), SHC( 0xbd1f ), + SHC( 0x6b59 ), SHC( 0xba4a ), SHC( 0x697c ), SHC( 0xb780 ), SHC( 0x678d ), SHC( 0xb4c4 ), SHC( 0x658c ), SHC( 0xb215 ), + SHC( 0x6379 ), SHC( 0xaf73 ), SHC( 0x6154 ), SHC( 0xacdf ), SHC( 0x5f1f ), SHC( 0xaa5a ), SHC( 0x5cd9 ), SHC( 0xa7e4 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fe6 ), SHC( 0xfafa ), SHC( 0x7f9a ), SHC( 0xf5f6 ), SHC( 0x7f1c ), SHC( 0xf0f5 ), + SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x7d8a ), SHC( 0xe708 ), SHC( 0x7c76 ), SHC( 0xe21f ), SHC( 0x7b31 ), SHC( 0xdd42 ), + SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x7816 ), SHC( 0xd3b3 ), SHC( 0x7641 ), SHC( 0xcf05 ), SHC( 0x743e ), SHC( 0xca6a ), + SHC( 0x720c ), SHC( 0xc5e4 ), SHC( 0x6fad ), SHC( 0xc175 ), SHC( 0x6d23 ), SHC( 0xbd1f ), SHC( 0x6a6d ), SHC( 0xb8e4 ), + SHC( 0x678d ), SHC( 0xb4c4 ), SHC( 0x6485 ), SHC( 0xb0c2 ), SHC( 0x6154 ), SHC( 0xacdf ), SHC( 0x5dfe ), SHC( 0xa91e ), + SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x56e2 ), SHC( 0xa202 ), SHC( 0x5321 ), SHC( 0x9eac ), SHC( 0x4f3e ), SHC( 0x9b7b ), + SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x471c ), SHC( 0x9593 ), SHC( 0x42e1 ), SHC( 0x92dd ), SHC( 0x3e8b ), SHC( 0x9053 ), + SHC( 0x3a1c ), SHC( 0x8df4 ), SHC( 0x3596 ), SHC( 0x8bc2 ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fd3 ), SHC( 0xf94e ), + SHC( 0x7f4c ), SHC( 0xf29f ), SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x7d33 ), SHC( 0xe564 ), SHC( 0x7ba3 ), SHC( 0xdee0 ), + SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x777f ), SHC( 0xd221 ), SHC( 0x74ef ), SHC( 0xcbf1 ), SHC( 0x720c ), SHC( 0xc5e4 ), + SHC( 0x6ed9 ), SHC( 0xc000 ), SHC( 0x6b59 ), SHC( 0xba4a ), SHC( 0x678d ), SHC( 0xb4c4 ), SHC( 0x6379 ), SHC( 0xaf73 ), + SHC( 0x5f1f ), SHC( 0xaa5a ), SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x55a6 ), SHC( 0xa0e1 ), SHC( 0x508d ), SHC( 0x9c87 ), + SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x45b6 ), SHC( 0x94a7 ), SHC( 0x4000 ), SHC( 0x9127 ), SHC( 0x3a1c ), SHC( 0x8df4 ), + SHC( 0x340f ), SHC( 0x8b11 ), SHC( 0x2ddf ), SHC( 0x8881 ), SHC( 0x278d ), SHC( 0x8644 ), SHC( 0x2120 ), SHC( 0x845d ), + SHC( 0x1a9c ), SHC( 0x82cd ), SHC( 0x1406 ), SHC( 0x8194 ), SHC( 0x0d61 ), SHC( 0x80b4 ), SHC( 0x06b2 ), SHC( 0x802d ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fb9 ), SHC( 0xf7a1 ), SHC( 0x7ee7 ), SHC( 0xef4b ), SHC( 0x7d8a ), SHC( 0xe708 ), + SHC( 0x7ba3 ), SHC( 0xdee0 ), SHC( 0x7935 ), SHC( 0xd6dc ), SHC( 0x7641 ), SHC( 0xcf05 ), SHC( 0x72cc ), SHC( 0xc764 ), + SHC( 0x6ed9 ), SHC( 0xc000 ), SHC( 0x6a6d ), SHC( 0xb8e4 ), SHC( 0x658c ), SHC( 0xb215 ), SHC( 0x603c ), SHC( 0xab9b ), + SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x5465 ), SHC( 0x9fc4 ), SHC( 0x4deb ), SHC( 0x9a74 ), SHC( 0x471c ), SHC( 0x9593 ), + SHC( 0x4000 ), SHC( 0x9127 ), SHC( 0x389c ), SHC( 0x8d34 ), SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0x2924 ), SHC( 0x86cb ), + SHC( 0x2120 ), SHC( 0x845d ), SHC( 0x18f8 ), SHC( 0x8276 ), SHC( 0x10b5 ), SHC( 0x8119 ), SHC( 0x085f ), SHC( 0x8047 ), + SHC( 0x0000 ), SHC( 0x8000 ), SHC( 0xf7a1 ), SHC( 0x8047 ), SHC( 0xef4b ), SHC( 0x8119 ), SHC( 0xe708 ), SHC( 0x8276 ), + SHC( 0xdee0 ), SHC( 0x845d ), SHC( 0xd6dc ), SHC( 0x86cb ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f9a ), SHC( 0xf5f6 ), + SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x7c76 ), SHC( 0xe21f ), SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x7641 ), SHC( 0xcf05 ), + SHC( 0x720c ), SHC( 0xc5e4 ), SHC( 0x6d23 ), SHC( 0xbd1f ), SHC( 0x678d ), SHC( 0xb4c4 ), SHC( 0x6154 ), SHC( 0xacdf ), + SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x5321 ), SHC( 0x9eac ), SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x42e1 ), SHC( 0x92dd ), + SHC( 0x3a1c ), SHC( 0x8df4 ), SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0x278d ), SHC( 0x8644 ), SHC( 0x1de1 ), SHC( 0x838a ), + SHC( 0x1406 ), SHC( 0x8194 ), SHC( 0x0a0a ), SHC( 0x8066 ), SHC( 0x0000 ), SHC( 0x8000 ), SHC( 0xf5f6 ), SHC( 0x8066 ), + SHC( 0xebfa ), SHC( 0x8194 ), SHC( 0xe21f ), SHC( 0x838a ), SHC( 0xd873 ), SHC( 0x8644 ), SHC( 0xcf05 ), SHC( 0x89bf ), + SHC( 0xc5e4 ), SHC( 0x8df4 ), SHC( 0xbd1f ), SHC( 0x92dd ), SHC( 0xb4c4 ), SHC( 0x9873 ), SHC( 0xacdf ), SHC( 0x9eac ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f76 ), SHC( 0xf44a ), SHC( 0x7ddb ), SHC( 0xe8ad ), SHC( 0x7b31 ), SHC( 0xdd42 ), + SHC( 0x777f ), SHC( 0xd221 ), SHC( 0x72cc ), SHC( 0xc764 ), SHC( 0x6d23 ), SHC( 0xbd1f ), SHC( 0x668f ), SHC( 0xb36b ), + SHC( 0x5f1f ), SHC( 0xaa5a ), SHC( 0x56e2 ), SHC( 0xa202 ), SHC( 0x4deb ), SHC( 0x9a74 ), SHC( 0x444d ), SHC( 0x93c0 ), + SHC( 0x3a1c ), SHC( 0x8df4 ), SHC( 0x2f6e ), SHC( 0x891d ), SHC( 0x245a ), SHC( 0x8546 ), SHC( 0x18f8 ), SHC( 0x8276 ), + SHC( 0x0d61 ), SHC( 0x80b4 ), SHC( 0x01ac ), SHC( 0x8003 ), SHC( 0xf5f6 ), SHC( 0x8066 ), SHC( 0xea53 ), SHC( 0x81da ), + SHC( 0xdee0 ), SHC( 0x845d ), SHC( 0xd3b3 ), SHC( 0x87ea ), SHC( 0xc8e6 ), SHC( 0x8c79 ), SHC( 0xbe8e ), SHC( 0x91ff ), + SHC( 0xb4c4 ), SHC( 0x9873 ), SHC( 0xab9b ), SHC( 0x9fc4 ), SHC( 0xa327 ), SHC( 0xa7e4 ), SHC( 0x9b7b ), SHC( 0xb0c2 ), + SHC( 0x94a7 ), SHC( 0xba4a ), SHC( 0x8eb9 ), SHC( 0xc467 ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f4c ), SHC( 0xf29f ), + SHC( 0x7d33 ), SHC( 0xe564 ), SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x74ef ), SHC( 0xcbf1 ), SHC( 0x6ed9 ), SHC( 0xc000 ), + SHC( 0x678d ), SHC( 0xb4c4 ), SHC( 0x5f1f ), SHC( 0xaa5a ), SHC( 0x55a6 ), SHC( 0xa0e1 ), SHC( 0x4b3c ), SHC( 0x9873 ), + SHC( 0x4000 ), SHC( 0x9127 ), SHC( 0x340f ), SHC( 0x8b11 ), SHC( 0x278d ), SHC( 0x8644 ), SHC( 0x1a9c ), SHC( 0x82cd ), + SHC( 0x0d61 ), SHC( 0x80b4 ), SHC( 0x0000 ), SHC( 0x8000 ), SHC( 0xf29f ), SHC( 0x80b4 ), SHC( 0xe564 ), SHC( 0x82cd ), + SHC( 0xd873 ), SHC( 0x8644 ), SHC( 0xcbf1 ), SHC( 0x8b11 ), SHC( 0xc000 ), SHC( 0x9127 ), SHC( 0xb4c4 ), SHC( 0x9873 ), + SHC( 0xaa5a ), SHC( 0xa0e1 ), SHC( 0xa0e1 ), SHC( 0xaa5a ), SHC( 0x9873 ), SHC( 0xb4c4 ), SHC( 0x9127 ), SHC( 0xc000 ), + SHC( 0x8b11 ), SHC( 0xcbf1 ), SHC( 0x8644 ), SHC( 0xd873 ), SHC( 0x82cd ), SHC( 0xe564 ), SHC( 0x80b4 ), SHC( 0xf29f ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f1c ), SHC( 0xf0f5 ), SHC( 0x7c76 ), SHC( 0xe21f ), SHC( 0x7816 ), SHC( 0xd3b3 ), + SHC( 0x720c ), SHC( 0xc5e4 ), SHC( 0x6a6d ), SHC( 0xb8e4 ), SHC( 0x6154 ), SHC( 0xacdf ), SHC( 0x56e2 ), SHC( 0xa202 ), + SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x3e8b ), SHC( 0x9053 ), SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0x22be ), SHC( 0x84cf ), + SHC( 0x1406 ), SHC( 0x8194 ), SHC( 0x0506 ), SHC( 0x801a ), SHC( 0xf5f6 ), SHC( 0x8066 ), SHC( 0xe708 ), SHC( 0x8276 ), + SHC( 0xd873 ), SHC( 0x8644 ), SHC( 0xca6a ), SHC( 0x8bc2 ), SHC( 0xbd1f ), SHC( 0x92dd ), SHC( 0xb0c2 ), SHC( 0x9b7b ), + SHC( 0xa57e ), SHC( 0xa57e ), SHC( 0x9b7b ), SHC( 0xb0c2 ), SHC( 0x92dd ), SHC( 0xbd1f ), SHC( 0x8bc2 ), SHC( 0xca6a ), + SHC( 0x8644 ), SHC( 0xd873 ), SHC( 0x8276 ), SHC( 0xe708 ), SHC( 0x8066 ), SHC( 0xf5f6 ), SHC( 0x801a ), SHC( 0x0506 ), + SHC( 0x8194 ), SHC( 0x1406 ), SHC( 0x84cf ), SHC( 0x22be ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7ee7 ), SHC( 0xef4b ), + SHC( 0x7ba3 ), SHC( 0xdee0 ), SHC( 0x7641 ), SHC( 0xcf05 ), SHC( 0x6ed9 ), SHC( 0xc000 ), SHC( 0x658c ), SHC( 0xb215 ), + SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x4deb ), SHC( 0x9a74 ), SHC( 0x4000 ), SHC( 0x9127 ), SHC( 0x30fb ), SHC( 0x89bf ), + SHC( 0x2120 ), SHC( 0x845d ), SHC( 0x10b5 ), SHC( 0x8119 ), SHC( 0x0000 ), SHC( 0x8000 ), SHC( 0xef4b ), SHC( 0x8119 ), + SHC( 0xdee0 ), SHC( 0x845d ), SHC( 0xcf05 ), SHC( 0x89bf ), SHC( 0xc000 ), SHC( 0x9127 ), SHC( 0xb215 ), SHC( 0x9a74 ), + SHC( 0xa57e ), SHC( 0xa57e ), SHC( 0x9a74 ), SHC( 0xb215 ), SHC( 0x9127 ), SHC( 0xc000 ), SHC( 0x89bf ), SHC( 0xcf05 ), + SHC( 0x845d ), SHC( 0xdee0 ), SHC( 0x8119 ), SHC( 0xef4b ), SHC( 0x8000 ), SHC( 0x0000 ), SHC( 0x8119 ), SHC( 0x10b5 ), + SHC( 0x845d ), SHC( 0x2120 ), SHC( 0x89bf ), SHC( 0x30fb ), SHC( 0x9127 ), SHC( 0x4000 ), SHC( 0x9a74 ), SHC( 0x4deb ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7eac ), SHC( 0xeda3 ), SHC( 0x7aba ), SHC( 0xdba6 ), SHC( 0x743e ), SHC( 0xca6a ), + SHC( 0x6b59 ), SHC( 0xba4a ), SHC( 0x603c ), SHC( 0xab9b ), SHC( 0x5321 ), SHC( 0x9eac ), SHC( 0x444d ), SHC( 0x93c0 ), + SHC( 0x340f ), SHC( 0x8b11 ), SHC( 0x22be ), SHC( 0x84cf ), SHC( 0x10b5 ), SHC( 0x8119 ), SHC( 0xfe54 ), SHC( 0x8003 ), + SHC( 0xebfa ), SHC( 0x8194 ), SHC( 0xda0b ), SHC( 0x85c2 ), SHC( 0xc8e6 ), SHC( 0x8c79 ), SHC( 0xb8e4 ), SHC( 0x9593 ), + SHC( 0xaa5a ), SHC( 0xa0e1 ), SHC( 0x9d97 ), SHC( 0xae27 ), SHC( 0x92dd ), SHC( 0xbd1f ), SHC( 0x8a66 ), SHC( 0xcd7a ), + SHC( 0x845d ), SHC( 0xdee0 ), SHC( 0x80e4 ), SHC( 0xf0f5 ), SHC( 0x800c ), SHC( 0x0359 ), SHC( 0x81da ), SHC( 0x15ad ), + SHC( 0x8644 ), SHC( 0x278d ), SHC( 0x8d34 ), SHC( 0x389c ), SHC( 0x9684 ), SHC( 0x4880 ), SHC( 0xa202 ), SHC( 0x56e2 ), + SHC( 0xaf73 ), SHC( 0x6379 ), SHC( 0xbe8e ), SHC( 0x6e01 ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7e6c ), SHC( 0xebfa ), + SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x720c ), SHC( 0xc5e4 ), SHC( 0x678d ), SHC( 0xb4c4 ), SHC( 0x5a82 ), SHC( 0xa57e ), + SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x3a1c ), SHC( 0x8df4 ), SHC( 0x278d ), SHC( 0x8644 ), SHC( 0x1406 ), SHC( 0x8194 ), + SHC( 0x0000 ), SHC( 0x8000 ), SHC( 0xebfa ), SHC( 0x8194 ), SHC( 0xd873 ), SHC( 0x8644 ), SHC( 0xc5e4 ), SHC( 0x8df4 ), + SHC( 0xb4c4 ), SHC( 0x9873 ), SHC( 0xa57e ), SHC( 0xa57e ), SHC( 0x9873 ), SHC( 0xb4c4 ), SHC( 0x8df4 ), SHC( 0xc5e4 ), + SHC( 0x8644 ), SHC( 0xd873 ), SHC( 0x8194 ), SHC( 0xebfa ), SHC( 0x8000 ), SHC( 0x0000 ), SHC( 0x8194 ), SHC( 0x1406 ), + SHC( 0x8644 ), SHC( 0x278d ), SHC( 0x8df4 ), SHC( 0x3a1c ), SHC( 0x9873 ), SHC( 0x4b3c ), SHC( 0xa57e ), SHC( 0x5a82 ), + SHC( 0xb4c4 ), SHC( 0x678d ), SHC( 0xc5e4 ), SHC( 0x720c ), SHC( 0xd873 ), SHC( 0x79bc ), SHC( 0xebfa ), SHC( 0x7e6c ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7e26 ), SHC( 0xea53 ), SHC( 0x78a8 ), SHC( 0xd546 ), SHC( 0x6fad ), SHC( 0xc175 ), + SHC( 0x6379 ), SHC( 0xaf73 ), SHC( 0x5465 ), SHC( 0x9fc4 ), SHC( 0x42e1 ), SHC( 0x92dd ), SHC( 0x2f6e ), SHC( 0x891d ), + SHC( 0x1a9c ), SHC( 0x82cd ), SHC( 0x0506 ), SHC( 0x801a ), SHC( 0xef4b ), SHC( 0x8119 ), SHC( 0xda0b ), SHC( 0x85c2 ), + SHC( 0xc5e4 ), SHC( 0x8df4 ), SHC( 0xb36b ), SHC( 0x9971 ), SHC( 0xa327 ), SHC( 0xa7e4 ), SHC( 0x9593 ), SHC( 0xb8e4 ), + SHC( 0x8b11 ), SHC( 0xcbf1 ), SHC( 0x83f1 ), SHC( 0xe07f ), SHC( 0x8066 ), SHC( 0xf5f6 ), SHC( 0x808a ), SHC( 0x0bb6 ), + SHC( 0x845d ), SHC( 0x2120 ), SHC( 0x8bc2 ), SHC( 0x3596 ), SHC( 0x9684 ), SHC( 0x4880 ), SHC( 0xa451 ), SHC( 0x5951 ), + SHC( 0xb4c4 ), SHC( 0x678d ), SHC( 0xc764 ), SHC( 0x72cc ), SHC( 0xdba6 ), SHC( 0x7aba ), SHC( 0xf0f5 ), SHC( 0x7f1c ), + SHC( 0x06b2 ), SHC( 0x7fd3 ), SHC( 0x1c3f ), SHC( 0x7cd8 ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7ddb ), SHC( 0xe8ad ), + SHC( 0x777f ), SHC( 0xd221 ), SHC( 0x6d23 ), SHC( 0xbd1f ), SHC( 0x5f1f ), SHC( 0xaa5a ), SHC( 0x4deb ), SHC( 0x9a74 ), + SHC( 0x3a1c ), SHC( 0x8df4 ), SHC( 0x245a ), SHC( 0x8546 ), SHC( 0x0d61 ), SHC( 0x80b4 ), SHC( 0xf5f6 ), SHC( 0x8066 ), + SHC( 0xdee0 ), SHC( 0x845d ), SHC( 0xc8e6 ), SHC( 0x8c79 ), SHC( 0xb4c4 ), SHC( 0x9873 ), SHC( 0xa327 ), SHC( 0xa7e4 ), + SHC( 0x94a7 ), SHC( 0xba4a ), SHC( 0x89bf ), SHC( 0xcf05 ), SHC( 0x82cd ), SHC( 0xe564 ), SHC( 0x800c ), SHC( 0xfca7 ), + SHC( 0x8194 ), SHC( 0x1406 ), SHC( 0x8758 ), SHC( 0x2aba ), SHC( 0x9127 ), SHC( 0x4000 ), SHC( 0x9eac ), SHC( 0x5321 ), + SHC( 0xaf73 ), SHC( 0x6379 ), SHC( 0xc2ed ), SHC( 0x707d ), SHC( 0xd873 ), SHC( 0x79bc ), SHC( 0xef4b ), SHC( 0x7ee7 ), + SHC( 0x06b2 ), SHC( 0x7fd3 ), SHC( 0x1de1 ), SHC( 0x7c76 ), SHC( 0x340f ), SHC( 0x74ef ), SHC( 0x4880 ), SHC( 0x697c ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7d8a ), SHC( 0xe708 ), SHC( 0x7641 ), SHC( 0xcf05 ), SHC( 0x6a6d ), SHC( 0xb8e4 ), + SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x471c ), SHC( 0x9593 ), SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0x18f8 ), SHC( 0x8276 ), + SHC( 0x0000 ), SHC( 0x8000 ), SHC( 0xe708 ), SHC( 0x8276 ), SHC( 0xcf05 ), SHC( 0x89bf ), SHC( 0xb8e4 ), SHC( 0x9593 ), + SHC( 0xa57e ), SHC( 0xa57e ), SHC( 0x9593 ), SHC( 0xb8e4 ), SHC( 0x89bf ), SHC( 0xcf05 ), SHC( 0x8276 ), SHC( 0xe708 ), + SHC( 0x8000 ), SHC( 0x0000 ), SHC( 0x8276 ), SHC( 0x18f8 ), SHC( 0x89bf ), SHC( 0x30fb ), SHC( 0x9593 ), SHC( 0x471c ), + SHC( 0xa57e ), SHC( 0x5a82 ), SHC( 0xb8e4 ), SHC( 0x6a6d ), SHC( 0xcf05 ), SHC( 0x7641 ), SHC( 0xe708 ), SHC( 0x7d8a ), + SHC( 0x0000 ), SHC( 0x7fff ), SHC( 0x18f8 ), SHC( 0x7d8a ), SHC( 0x30fb ), SHC( 0x7641 ), SHC( 0x471c ), SHC( 0x6a6d ), + SHC( 0x5a82 ), SHC( 0x5a82 ), SHC( 0x6a6d ), SHC( 0x471c ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fff ), SHC( 0xff2a ), + SHC( 0x7ffd ), SHC( 0xfe54 ), SHC( 0x7ff9 ), SHC( 0xfd7d ), SHC( 0x7ff4 ), SHC( 0xfca7 ), SHC( 0x7fee ), SHC( 0xfbd0 ), + SHC( 0x7fe6 ), SHC( 0xfafa ), SHC( 0x7fdd ), SHC( 0xfa24 ), SHC( 0x7fd3 ), SHC( 0xf94e ), SHC( 0x7fc7 ), SHC( 0xf877 ), + SHC( 0x7fb9 ), SHC( 0xf7a1 ), SHC( 0x7fab ), SHC( 0xf6cb ), SHC( 0x7f9a ), SHC( 0xf5f6 ), SHC( 0x7f89 ), SHC( 0xf520 ), + SHC( 0x7f76 ), SHC( 0xf44a ), SHC( 0x7f62 ), SHC( 0xf375 ), SHC( 0x7f4c ), SHC( 0xf29f ), SHC( 0x7f35 ), SHC( 0xf1ca ), + SHC( 0x7f1c ), SHC( 0xf0f5 ), SHC( 0x7f02 ), SHC( 0xf020 ), SHC( 0x7ee7 ), SHC( 0xef4b ), SHC( 0x7eca ), SHC( 0xee77 ), + SHC( 0x7eac ), SHC( 0xeda3 ), SHC( 0x7e8d ), SHC( 0xecce ), SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x7e4a ), SHC( 0xeb27 ), + SHC( 0x7e26 ), SHC( 0xea53 ), SHC( 0x7e01 ), SHC( 0xe980 ), SHC( 0x7ddb ), SHC( 0xe8ad ), SHC( 0x7db3 ), SHC( 0xe7da ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7ff9 ), SHC( 0xfd7d ), SHC( 0x7fe6 ), SHC( 0xfafa ), SHC( 0x7fc7 ), SHC( 0xf877 ), + SHC( 0x7f9a ), SHC( 0xf5f6 ), SHC( 0x7f62 ), SHC( 0xf375 ), SHC( 0x7f1c ), SHC( 0xf0f5 ), SHC( 0x7eca ), SHC( 0xee77 ), + SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x7e01 ), SHC( 0xe980 ), SHC( 0x7d8a ), SHC( 0xe708 ), SHC( 0x7d06 ), SHC( 0xe492 ), + SHC( 0x7c76 ), SHC( 0xe21f ), SHC( 0x7bda ), SHC( 0xdfaf ), SHC( 0x7b31 ), SHC( 0xdd42 ), SHC( 0x7a7d ), SHC( 0xdad8 ), + SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x78ef ), SHC( 0xd611 ), SHC( 0x7816 ), SHC( 0xd3b3 ), SHC( 0x7732 ), SHC( 0xd15a ), + SHC( 0x7641 ), SHC( 0xcf05 ), SHC( 0x7545 ), SHC( 0xccb5 ), SHC( 0x743e ), SHC( 0xca6a ), SHC( 0x732a ), SHC( 0xc824 ), + SHC( 0x720c ), SHC( 0xc5e4 ), SHC( 0x70e2 ), SHC( 0xc3aa ), SHC( 0x6fad ), SHC( 0xc175 ), SHC( 0x6e6e ), SHC( 0xbf47 ), + SHC( 0x6d23 ), SHC( 0xbd1f ), SHC( 0x6bcd ), SHC( 0xbafe ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fee ), SHC( 0xfbd0 ), + SHC( 0x7fb9 ), SHC( 0xf7a1 ), SHC( 0x7f62 ), SHC( 0xf375 ), SHC( 0x7ee7 ), SHC( 0xef4b ), SHC( 0x7e4a ), SHC( 0xeb27 ), + SHC( 0x7d8a ), SHC( 0xe708 ), SHC( 0x7ca8 ), SHC( 0xe2f0 ), SHC( 0x7ba3 ), SHC( 0xdee0 ), SHC( 0x7a7d ), SHC( 0xdad8 ), + SHC( 0x7935 ), SHC( 0xd6dc ), SHC( 0x77cb ), SHC( 0xd2ea ), SHC( 0x7641 ), SHC( 0xcf05 ), SHC( 0x7497 ), SHC( 0xcb2d ), + SHC( 0x72cc ), SHC( 0xc764 ), SHC( 0x70e2 ), SHC( 0xc3aa ), SHC( 0x6ed9 ), SHC( 0xc000 ), SHC( 0x6cb2 ), SHC( 0xbc69 ), + SHC( 0x6a6d ), SHC( 0xb8e4 ), SHC( 0x680b ), SHC( 0xb572 ), SHC( 0x658c ), SHC( 0xb215 ), SHC( 0x62f2 ), SHC( 0xaecd ), + SHC( 0x603c ), SHC( 0xab9b ), SHC( 0x5d6c ), SHC( 0xa881 ), SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x577f ), SHC( 0xa294 ), + SHC( 0x5465 ), SHC( 0x9fc4 ), SHC( 0x5133 ), SHC( 0x9d0e ), SHC( 0x4deb ), SHC( 0x9a74 ), SHC( 0x4a8e ), SHC( 0x97f5 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fdd ), SHC( 0xfa24 ), SHC( 0x7f76 ), SHC( 0xf44a ), SHC( 0x7eca ), SHC( 0xee77 ), + SHC( 0x7ddb ), SHC( 0xe8ad ), SHC( 0x7ca8 ), SHC( 0xe2f0 ), SHC( 0x7b31 ), SHC( 0xdd42 ), SHC( 0x7979 ), SHC( 0xd7a7 ), + SHC( 0x777f ), SHC( 0xd221 ), SHC( 0x7545 ), SHC( 0xccb5 ), SHC( 0x72cc ), SHC( 0xc764 ), SHC( 0x7016 ), SHC( 0xc231 ), + SHC( 0x6d23 ), SHC( 0xbd1f ), SHC( 0x69f5 ), SHC( 0xb832 ), SHC( 0x668f ), SHC( 0xb36b ), SHC( 0x62f2 ), SHC( 0xaecd ), + SHC( 0x5f1f ), SHC( 0xaa5a ), SHC( 0x5b19 ), SHC( 0xa616 ), SHC( 0x56e2 ), SHC( 0xa202 ), SHC( 0x527d ), SHC( 0x9e21 ), + SHC( 0x4deb ), SHC( 0x9a74 ), SHC( 0x4930 ), SHC( 0x96fe ), SHC( 0x444d ), SHC( 0x93c0 ), SHC( 0x3f45 ), SHC( 0x90bc ), + SHC( 0x3a1c ), SHC( 0x8df4 ), SHC( 0x34d3 ), SHC( 0x8b69 ), SHC( 0x2f6e ), SHC( 0x891d ), SHC( 0x29ef ), SHC( 0x8711 ), + SHC( 0x245a ), SHC( 0x8546 ), SHC( 0x1eb1 ), SHC( 0x83bd ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fc7 ), SHC( 0xf877 ), + SHC( 0x7f1c ), SHC( 0xf0f5 ), SHC( 0x7e01 ), SHC( 0xe980 ), SHC( 0x7c76 ), SHC( 0xe21f ), SHC( 0x7a7d ), SHC( 0xdad8 ), + SHC( 0x7816 ), SHC( 0xd3b3 ), SHC( 0x7545 ), SHC( 0xccb5 ), SHC( 0x720c ), SHC( 0xc5e4 ), SHC( 0x6e6e ), SHC( 0xbf47 ), + SHC( 0x6a6d ), SHC( 0xb8e4 ), SHC( 0x660e ), SHC( 0xb2bf ), SHC( 0x6154 ), SHC( 0xacdf ), SHC( 0x5c44 ), SHC( 0xa749 ), + SHC( 0x56e2 ), SHC( 0xa202 ), SHC( 0x5133 ), SHC( 0x9d0e ), SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x4502 ), SHC( 0x9433 ), + SHC( 0x3e8b ), SHC( 0x9053 ), SHC( 0x37dc ), SHC( 0x8cd6 ), SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0x29ef ), SHC( 0x8711 ), + SHC( 0x22be ), SHC( 0x84cf ), SHC( 0x1b6e ), SHC( 0x82fa ), SHC( 0x1406 ), SHC( 0x8194 ), SHC( 0x0c8b ), SHC( 0x809e ), + SHC( 0x0506 ), SHC( 0x801a ), SHC( 0xfd7d ), SHC( 0x8007 ), SHC( 0xf5f6 ), SHC( 0x8066 ), SHC( 0xee77 ), SHC( 0x8136 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fab ), SHC( 0xf6cb ), SHC( 0x7eac ), SHC( 0xeda3 ), SHC( 0x7d06 ), SHC( 0xe492 ), + SHC( 0x7aba ), SHC( 0xdba6 ), SHC( 0x77cb ), SHC( 0xd2ea ), SHC( 0x743e ), SHC( 0xca6a ), SHC( 0x7016 ), SHC( 0xc231 ), + SHC( 0x6b59 ), SHC( 0xba4a ), SHC( 0x660e ), SHC( 0xb2bf ), SHC( 0x603c ), SHC( 0xab9b ), SHC( 0x59ea ), SHC( 0xa4e7 ), + SHC( 0x5321 ), SHC( 0x9eac ), SHC( 0x4be9 ), SHC( 0x98f1 ), SHC( 0x444d ), SHC( 0x93c0 ), SHC( 0x3c56 ), SHC( 0x8f1e ), + SHC( 0x340f ), SHC( 0x8b11 ), SHC( 0x2b84 ), SHC( 0x87a0 ), SHC( 0x22be ), SHC( 0x84cf ), SHC( 0x19ca ), SHC( 0x82a1 ), + SHC( 0x10b5 ), SHC( 0x8119 ), SHC( 0x0789 ), SHC( 0x8039 ), SHC( 0xfe54 ), SHC( 0x8003 ), SHC( 0xf520 ), SHC( 0x8077 ), + SHC( 0xebfa ), SHC( 0x8194 ), SHC( 0xe2f0 ), SHC( 0x8358 ), SHC( 0xda0b ), SHC( 0x85c2 ), SHC( 0xd15a ), SHC( 0x88ce ), + SHC( 0xc8e6 ), SHC( 0x8c79 ), SHC( 0xc0bb ), SHC( 0x90bc ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f89 ), SHC( 0xf520 ), + SHC( 0x7e26 ), SHC( 0xea53 ), SHC( 0x7bda ), SHC( 0xdfaf ), SHC( 0x78a8 ), SHC( 0xd546 ), SHC( 0x7497 ), SHC( 0xcb2d ), + SHC( 0x6fad ), SHC( 0xc175 ), SHC( 0x69f5 ), SHC( 0xb832 ), SHC( 0x6379 ), SHC( 0xaf73 ), SHC( 0x5c44 ), SHC( 0xa749 ), + SHC( 0x5465 ), SHC( 0x9fc4 ), SHC( 0x4be9 ), SHC( 0x98f1 ), SHC( 0x42e1 ), SHC( 0x92dd ), SHC( 0x395c ), SHC( 0x8d93 ), + SHC( 0x2f6e ), SHC( 0x891d ), SHC( 0x2528 ), SHC( 0x8583 ), SHC( 0x1a9c ), SHC( 0x82cd ), SHC( 0x0fe0 ), SHC( 0x80fe ), + SHC( 0x0506 ), SHC( 0x801a ), SHC( 0xfa24 ), SHC( 0x8023 ), SHC( 0xef4b ), SHC( 0x8119 ), SHC( 0xe492 ), SHC( 0x82fa ), + SHC( 0xda0b ), SHC( 0x85c2 ), SHC( 0xcfcb ), SHC( 0x896d ), SHC( 0xc5e4 ), SHC( 0x8df4 ), SHC( 0xbc69 ), SHC( 0x934e ), + SHC( 0xb36b ), SHC( 0x9971 ), SHC( 0xaafa ), SHC( 0xa052 ), SHC( 0xa327 ), SHC( 0xa7e4 ), SHC( 0x9c01 ), SHC( 0xb01a ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f62 ), SHC( 0xf375 ), SHC( 0x7d8a ), SHC( 0xe708 ), SHC( 0x7a7d ), SHC( 0xdad8 ), + SHC( 0x7641 ), SHC( 0xcf05 ), SHC( 0x70e2 ), SHC( 0xc3aa ), SHC( 0x6a6d ), SHC( 0xb8e4 ), SHC( 0x62f2 ), SHC( 0xaecd ), + SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x5133 ), SHC( 0x9d0e ), SHC( 0x471c ), SHC( 0x9593 ), SHC( 0x3c56 ), SHC( 0x8f1e ), + SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0x2528 ), SHC( 0x8583 ), SHC( 0x18f8 ), SHC( 0x8276 ), SHC( 0x0c8b ), SHC( 0x809e ), + SHC( 0x0000 ), SHC( 0x8000 ), SHC( 0xf375 ), SHC( 0x809e ), SHC( 0xe708 ), SHC( 0x8276 ), SHC( 0xdad8 ), SHC( 0x8583 ), + SHC( 0xcf05 ), SHC( 0x89bf ), SHC( 0xc3aa ), SHC( 0x8f1e ), SHC( 0xb8e4 ), SHC( 0x9593 ), SHC( 0xaecd ), SHC( 0x9d0e ), + SHC( 0xa57e ), SHC( 0xa57e ), SHC( 0x9d0e ), SHC( 0xaecd ), SHC( 0x9593 ), SHC( 0xb8e4 ), SHC( 0x8f1e ), SHC( 0xc3aa ), + SHC( 0x89bf ), SHC( 0xcf05 ), SHC( 0x8583 ), SHC( 0xdad8 ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f35 ), SHC( 0xf1ca ), + SHC( 0x7cd8 ), SHC( 0xe3c1 ), SHC( 0x78ef ), SHC( 0xd611 ), SHC( 0x7387 ), SHC( 0xc8e6 ), SHC( 0x6cb2 ), SHC( 0xbc69 ), + SHC( 0x6485 ), SHC( 0xb0c2 ), SHC( 0x5b19 ), SHC( 0xa616 ), SHC( 0x508d ), SHC( 0x9c87 ), SHC( 0x4502 ), SHC( 0x9433 ), + SHC( 0x389c ), SHC( 0x8d34 ), SHC( 0x2b84 ), SHC( 0x87a0 ), SHC( 0x1de1 ), SHC( 0x838a ), SHC( 0x0fe0 ), SHC( 0x80fe ), + SHC( 0x01ac ), SHC( 0x8003 ), SHC( 0xf375 ), SHC( 0x809e ), SHC( 0xe564 ), SHC( 0x82cd ), SHC( 0xd7a7 ), SHC( 0x8687 ), + SHC( 0xca6a ), SHC( 0x8bc2 ), SHC( 0xbdd6 ), SHC( 0x926e ), SHC( 0xb215 ), SHC( 0x9a74 ), SHC( 0xa749 ), SHC( 0xa3bc ), + SHC( 0x9d97 ), SHC( 0xae27 ), SHC( 0x951c ), SHC( 0xb996 ), SHC( 0x8df4 ), SHC( 0xc5e4 ), SHC( 0x8835 ), SHC( 0xd2ea ), + SHC( 0x83f1 ), SHC( 0xe07f ), SHC( 0x8136 ), SHC( 0xee77 ), SHC( 0x800c ), SHC( 0xfca7 ), SHC( 0x8077 ), SHC( 0x0ae0 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f02 ), SHC( 0xf020 ), SHC( 0x7c0f ), SHC( 0xe07f ), SHC( 0x7732 ), SHC( 0xd15a ), + SHC( 0x707d ), SHC( 0xc2ed ), SHC( 0x680b ), SHC( 0xb572 ), SHC( 0x5dfe ), SHC( 0xa91e ), SHC( 0x527d ), SHC( 0x9e21 ), + SHC( 0x45b6 ), SHC( 0x94a7 ), SHC( 0x37dc ), SHC( 0x8cd6 ), SHC( 0x2924 ), SHC( 0x86cb ), SHC( 0x19ca ), SHC( 0x82a1 ), + SHC( 0x0a0a ), SHC( 0x8066 ), SHC( 0xfa24 ), SHC( 0x8023 ), SHC( 0xea53 ), SHC( 0x81da ), SHC( 0xdad8 ), SHC( 0x8583 ), + SHC( 0xcbf1 ), SHC( 0x8b11 ), SHC( 0xbdd6 ), SHC( 0x926e ), SHC( 0xb0c2 ), SHC( 0x9b7b ), SHC( 0xa4e7 ), SHC( 0xa616 ), + SHC( 0x9a74 ), SHC( 0xb215 ), SHC( 0x9192 ), SHC( 0xbf47 ), SHC( 0x8a66 ), SHC( 0xcd7a ), SHC( 0x850a ), SHC( 0xdc74 ), + SHC( 0x8194 ), SHC( 0xebfa ), SHC( 0x8012 ), SHC( 0xfbd0 ), SHC( 0x808a ), SHC( 0x0bb6 ), SHC( 0x82fa ), SHC( 0x1b6e ), + SHC( 0x8758 ), SHC( 0x2aba ), SHC( 0x8d93 ), SHC( 0x395c ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7eca ), SHC( 0xee77 ), + SHC( 0x7b31 ), SHC( 0xdd42 ), SHC( 0x7545 ), SHC( 0xccb5 ), SHC( 0x6d23 ), SHC( 0xbd1f ), SHC( 0x62f2 ), SHC( 0xaecd ), + SHC( 0x56e2 ), SHC( 0xa202 ), SHC( 0x4930 ), SHC( 0x96fe ), SHC( 0x3a1c ), SHC( 0x8df4 ), SHC( 0x29ef ), SHC( 0x8711 ), + SHC( 0x18f8 ), SHC( 0x8276 ), SHC( 0x0789 ), SHC( 0x8039 ), SHC( 0xf5f6 ), SHC( 0x8066 ), SHC( 0xe492 ), SHC( 0x82fa ), + SHC( 0xd3b3 ), SHC( 0x87ea ), SHC( 0xc3aa ), SHC( 0x8f1e ), SHC( 0xb4c4 ), SHC( 0x9873 ), SHC( 0xa749 ), SHC( 0xa3bc ), + SHC( 0x9b7b ), SHC( 0xb0c2 ), SHC( 0x9192 ), SHC( 0xbf47 ), SHC( 0x89bf ), SHC( 0xcf05 ), SHC( 0x8426 ), SHC( 0xdfaf ), + SHC( 0x80e4 ), SHC( 0xf0f5 ), SHC( 0x8007 ), SHC( 0x0283 ), SHC( 0x8194 ), SHC( 0x1406 ), SHC( 0x8583 ), SHC( 0x2528 ), + SHC( 0x8bc2 ), SHC( 0x3596 ), SHC( 0x9433 ), SHC( 0x4502 ), SHC( 0x9eac ), SHC( 0x5321 ), SHC( 0xaafa ), SHC( 0x5fae ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7e8d ), SHC( 0xecce ), SHC( 0x7a3e ), SHC( 0xda0b ), SHC( 0x732a ), SHC( 0xc824 ), + SHC( 0x697c ), SHC( 0xb780 ), SHC( 0x5d6c ), SHC( 0xa881 ), SHC( 0x4f3e ), SHC( 0x9b7b ), SHC( 0x3f45 ), SHC( 0x90bc ), + SHC( 0x2ddf ), SHC( 0x8881 ), SHC( 0x1b6e ), SHC( 0x82fa ), SHC( 0x085f ), SHC( 0x8047 ), SHC( 0xf520 ), SHC( 0x8077 ), + SHC( 0xe21f ), SHC( 0x838a ), SHC( 0xcfcb ), SHC( 0x896d ), SHC( 0xbe8e ), SHC( 0x91ff ), SHC( 0xaecd ), SHC( 0x9d0e ), + SHC( 0xa0e1 ), SHC( 0xaa5a ), SHC( 0x951c ), SHC( 0xb996 ), SHC( 0x8bc2 ), SHC( 0xca6a ), SHC( 0x850a ), SHC( 0xdc74 ), + SHC( 0x8119 ), SHC( 0xef4b ), SHC( 0x8007 ), SHC( 0x0283 ), SHC( 0x81da ), SHC( 0x15ad ), SHC( 0x8687 ), SHC( 0x2859 ), + SHC( 0x8df4 ), SHC( 0x3a1c ), SHC( 0x97f5 ), SHC( 0x4a8e ), SHC( 0xa451 ), SHC( 0x5951 ), SHC( 0xb2bf ), SHC( 0x660e ), + SHC( 0xc2ed ), SHC( 0x707d ), SHC( 0xd47c ), SHC( 0x7860 ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7e4a ), SHC( 0xeb27 ), + SHC( 0x7935 ), SHC( 0xd6dc ), SHC( 0x70e2 ), SHC( 0xc3aa ), SHC( 0x658c ), SHC( 0xb215 ), SHC( 0x577f ), SHC( 0xa294 ), + SHC( 0x471c ), SHC( 0x9593 ), SHC( 0x34d3 ), SHC( 0x8b69 ), SHC( 0x2120 ), SHC( 0x845d ), SHC( 0x0c8b ), SHC( 0x809e ), + SHC( 0xf7a1 ), SHC( 0x8047 ), SHC( 0xe2f0 ), SHC( 0x8358 ), SHC( 0xcf05 ), SHC( 0x89bf ), SHC( 0xbc69 ), SHC( 0x934e ), + SHC( 0xab9b ), SHC( 0x9fc4 ), SHC( 0x9d0e ), SHC( 0xaecd ), SHC( 0x9127 ), SHC( 0xc000 ), SHC( 0x8835 ), SHC( 0xd2ea ), + SHC( 0x8276 ), SHC( 0xe708 ), SHC( 0x8012 ), SHC( 0xfbd0 ), SHC( 0x8119 ), SHC( 0x10b5 ), SHC( 0x8583 ), SHC( 0x2528 ), + SHC( 0x8d34 ), SHC( 0x389c ), SHC( 0x97f5 ), SHC( 0x4a8e ), SHC( 0xa57e ), SHC( 0x5a82 ), SHC( 0xb572 ), SHC( 0x680b ), + SHC( 0xc764 ), SHC( 0x72cc ), SHC( 0xdad8 ), SHC( 0x7a7d ), SHC( 0xef4b ), SHC( 0x7ee7 ), SHC( 0x0430 ), SHC( 0x7fee ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7e01 ), SHC( 0xe980 ), SHC( 0x7816 ), SHC( 0xd3b3 ), SHC( 0x6e6e ), SHC( 0xbf47 ), + SHC( 0x6154 ), SHC( 0xacdf ), SHC( 0x5133 ), SHC( 0x9d0e ), SHC( 0x3e8b ), SHC( 0x9053 ), SHC( 0x29ef ), SHC( 0x8711 ), + SHC( 0x1406 ), SHC( 0x8194 ), SHC( 0xfd7d ), SHC( 0x8007 ), SHC( 0xe708 ), SHC( 0x8276 ), SHC( 0xd15a ), SHC( 0x88ce ), + SHC( 0xbd1f ), SHC( 0x92dd ), SHC( 0xaafa ), SHC( 0xa052 ), SHC( 0x9b7b ), SHC( 0xb0c2 ), SHC( 0x8f1e ), SHC( 0xc3aa ), + SHC( 0x8644 ), SHC( 0xd873 ), SHC( 0x8136 ), SHC( 0xee77 ), SHC( 0x801a ), SHC( 0x0506 ), SHC( 0x82fa ), SHC( 0x1b6e ), + SHC( 0x89bf ), SHC( 0x30fb ), SHC( 0x9433 ), SHC( 0x4502 ), SHC( 0xa202 ), SHC( 0x56e2 ), SHC( 0xb2bf ), SHC( 0x660e ), + SHC( 0xc5e4 ), SHC( 0x720c ), SHC( 0xdad8 ), SHC( 0x7a7d ), SHC( 0xf0f5 ), SHC( 0x7f1c ), SHC( 0x0789 ), SHC( 0x7fc7 ), + SHC( 0x1de1 ), SHC( 0x7c76 ), SHC( 0x334b ), SHC( 0x7545 ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7db3 ), SHC( 0xe7da ), + SHC( 0x76e3 ), SHC( 0xd092 ), SHC( 0x6bcd ), SHC( 0xbafe ), SHC( 0x5cd9 ), SHC( 0xa7e4 ), SHC( 0x4a8e ), SHC( 0x97f5 ), + SHC( 0x3596 ), SHC( 0x8bc2 ), SHC( 0x1eb1 ), SHC( 0x83bd ), SHC( 0x06b2 ), SHC( 0x802d ), SHC( 0xee77 ), SHC( 0x8136 ), + SHC( 0xd6dc ), SHC( 0x86cb ), SHC( 0xc0bb ), SHC( 0x90bc ), SHC( 0xacdf ), SHC( 0x9eac ), SHC( 0x9c01 ), SHC( 0xb01a ), + SHC( 0x8eb9 ), SHC( 0xc467 ), SHC( 0x8583 ), SHC( 0xdad8 ), SHC( 0x80b4 ), SHC( 0xf29f ), SHC( 0x8077 ), SHC( 0x0ae0 ), + SHC( 0x84cf ), SHC( 0x22be ), SHC( 0x8d93 ), SHC( 0x395c ), SHC( 0x9a74 ), SHC( 0x4deb ), SHC( 0xaafa ), SHC( 0x5fae ), + SHC( 0xbe8e ), SHC( 0x6e01 ), SHC( 0xd47c ), SHC( 0x7860 ), SHC( 0xebfa ), SHC( 0x7e6c ), SHC( 0x0430 ), SHC( 0x7fee ), + SHC( 0x1c3f ), SHC( 0x7cd8 ), SHC( 0x334b ), SHC( 0x7545 ), SHC( 0x4880 ), SHC( 0x697c ), SHC( 0x5b19 ), SHC( 0x59ea ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7d5f ), SHC( 0xe636 ), SHC( 0x759a ), SHC( 0xcd7a ), SHC( 0x6902 ), SHC( 0xb6d0 ), + SHC( 0x581c ), SHC( 0xa327 ), SHC( 0x4397 ), SHC( 0x934e ), SHC( 0x2c4d ), SHC( 0x87ea ), SHC( 0x1332 ), SHC( 0x8173 ), + SHC( 0xf94e ), SHC( 0x802d ), SHC( 0xdfaf ), SHC( 0x8426 ), SHC( 0xc764 ), SHC( 0x8d34 ), SHC( 0xb16b ), SHC( 0x9af7 ), + SHC( 0x9eac ), SHC( 0xacdf ), SHC( 0x8fea ), SHC( 0xc231 ), SHC( 0x85c2 ), SHC( 0xda0b ), SHC( 0x809e ), SHC( 0xf375 ), + SHC( 0x80b4 ), SHC( 0x0d61 ), SHC( 0x8603 ), SHC( 0x26c1 ), SHC( 0x9053 ), SHC( 0x3e8b ), SHC( 0x9f37 ), SHC( 0x53c3 ), + SHC( 0xb215 ), SHC( 0x658c ), SHC( 0xc824 ), SHC( 0x732a ), SHC( 0xe07f ), SHC( 0x7c0f ), SHC( 0xfa24 ), SHC( 0x7fdd ), + SHC( 0x1406 ), SHC( 0x7e6c ), SHC( 0x2d16 ), SHC( 0x77cb ), SHC( 0x444d ), SHC( 0x6c40 ), SHC( 0x58b7 ), SHC( 0x5c44 ), + SHC( 0x697c ), SHC( 0x4880 ), SHC( 0x75ee ), SHC( 0x31c1 ), +}; + +const Word16 FFT_RotVector_640_fx[ 1240 ] = { + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7ff9 ), SHC( 0xfd7d ), SHC( 0x7fe6 ), SHC( 0xfafa ), SHC( 0x7fc7 ), SHC( 0xf877 ), + SHC( 0x7f9a ), SHC( 0xf5f6 ), SHC( 0x7f62 ), SHC( 0xf375 ), SHC( 0x7f1c ), SHC( 0xf0f5 ), SHC( 0x7eca ), SHC( 0xee77 ), + SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x7e01 ), SHC( 0xe980 ), SHC( 0x7d8a ), SHC( 0xe708 ), SHC( 0x7d06 ), SHC( 0xe492 ), + SHC( 0x7c76 ), SHC( 0xe21f ), SHC( 0x7bda ), SHC( 0xdfaf ), SHC( 0x7b31 ), SHC( 0xdd42 ), SHC( 0x7a7d ), SHC( 0xdad8 ), + SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x78ef ), SHC( 0xd611 ), SHC( 0x7816 ), SHC( 0xd3b3 ), SHC( 0x7732 ), SHC( 0xd15a ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fe6 ), SHC( 0xfafa ), SHC( 0x7f9a ), SHC( 0xf5f6 ), SHC( 0x7f1c ), SHC( 0xf0f5 ), + SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x7d8a ), SHC( 0xe708 ), SHC( 0x7c76 ), SHC( 0xe21f ), SHC( 0x7b31 ), SHC( 0xdd42 ), + SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x7816 ), SHC( 0xd3b3 ), SHC( 0x7641 ), SHC( 0xcf05 ), SHC( 0x743e ), SHC( 0xca6a ), + SHC( 0x720c ), SHC( 0xc5e4 ), SHC( 0x6fad ), SHC( 0xc175 ), SHC( 0x6d23 ), SHC( 0xbd1f ), SHC( 0x6a6d ), SHC( 0xb8e4 ), + SHC( 0x678d ), SHC( 0xb4c4 ), SHC( 0x6485 ), SHC( 0xb0c2 ), SHC( 0x6154 ), SHC( 0xacdf ), SHC( 0x5dfe ), SHC( 0xa91e ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fc7 ), SHC( 0xf877 ), SHC( 0x7f1c ), SHC( 0xf0f5 ), SHC( 0x7e01 ), SHC( 0xe980 ), + SHC( 0x7c76 ), SHC( 0xe21f ), SHC( 0x7a7d ), SHC( 0xdad8 ), SHC( 0x7816 ), SHC( 0xd3b3 ), SHC( 0x7545 ), SHC( 0xccb5 ), + SHC( 0x720c ), SHC( 0xc5e4 ), SHC( 0x6e6e ), SHC( 0xbf47 ), SHC( 0x6a6d ), SHC( 0xb8e4 ), SHC( 0x660e ), SHC( 0xb2bf ), + SHC( 0x6154 ), SHC( 0xacdf ), SHC( 0x5c44 ), SHC( 0xa749 ), SHC( 0x56e2 ), SHC( 0xa202 ), SHC( 0x5133 ), SHC( 0x9d0e ), + SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x4502 ), SHC( 0x9433 ), SHC( 0x3e8b ), SHC( 0x9053 ), SHC( 0x37dc ), SHC( 0x8cd6 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f9a ), SHC( 0xf5f6 ), SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x7c76 ), SHC( 0xe21f ), + SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x7641 ), SHC( 0xcf05 ), SHC( 0x720c ), SHC( 0xc5e4 ), SHC( 0x6d23 ), SHC( 0xbd1f ), + SHC( 0x678d ), SHC( 0xb4c4 ), SHC( 0x6154 ), SHC( 0xacdf ), SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x5321 ), SHC( 0x9eac ), + SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x42e1 ), SHC( 0x92dd ), SHC( 0x3a1c ), SHC( 0x8df4 ), SHC( 0x30fb ), SHC( 0x89bf ), + SHC( 0x278d ), SHC( 0x8644 ), SHC( 0x1de1 ), SHC( 0x838a ), SHC( 0x1406 ), SHC( 0x8194 ), SHC( 0x0a0a ), SHC( 0x8066 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f62 ), SHC( 0xf375 ), SHC( 0x7d8a ), SHC( 0xe708 ), SHC( 0x7a7d ), SHC( 0xdad8 ), + SHC( 0x7641 ), SHC( 0xcf05 ), SHC( 0x70e2 ), SHC( 0xc3aa ), SHC( 0x6a6d ), SHC( 0xb8e4 ), SHC( 0x62f2 ), SHC( 0xaecd ), + SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x5133 ), SHC( 0x9d0e ), SHC( 0x471c ), SHC( 0x9593 ), SHC( 0x3c56 ), SHC( 0x8f1e ), + SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0x2528 ), SHC( 0x8583 ), SHC( 0x18f8 ), SHC( 0x8276 ), SHC( 0x0c8b ), SHC( 0x809e ), + SHC( 0x0000 ), SHC( 0x8000 ), SHC( 0xf375 ), SHC( 0x809e ), SHC( 0xe708 ), SHC( 0x8276 ), SHC( 0xdad8 ), SHC( 0x8583 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f1c ), SHC( 0xf0f5 ), SHC( 0x7c76 ), SHC( 0xe21f ), SHC( 0x7816 ), SHC( 0xd3b3 ), + SHC( 0x720c ), SHC( 0xc5e4 ), SHC( 0x6a6d ), SHC( 0xb8e4 ), SHC( 0x6154 ), SHC( 0xacdf ), SHC( 0x56e2 ), SHC( 0xa202 ), + SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x3e8b ), SHC( 0x9053 ), SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0x22be ), SHC( 0x84cf ), + SHC( 0x1406 ), SHC( 0x8194 ), SHC( 0x0506 ), SHC( 0x801a ), SHC( 0xf5f6 ), SHC( 0x8066 ), SHC( 0xe708 ), SHC( 0x8276 ), + SHC( 0xd873 ), SHC( 0x8644 ), SHC( 0xca6a ), SHC( 0x8bc2 ), SHC( 0xbd1f ), SHC( 0x92dd ), SHC( 0xb0c2 ), SHC( 0x9b7b ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7eca ), SHC( 0xee77 ), SHC( 0x7b31 ), SHC( 0xdd42 ), SHC( 0x7545 ), SHC( 0xccb5 ), + SHC( 0x6d23 ), SHC( 0xbd1f ), SHC( 0x62f2 ), SHC( 0xaecd ), SHC( 0x56e2 ), SHC( 0xa202 ), SHC( 0x4930 ), SHC( 0x96fe ), + SHC( 0x3a1c ), SHC( 0x8df4 ), SHC( 0x29ef ), SHC( 0x8711 ), SHC( 0x18f8 ), SHC( 0x8276 ), SHC( 0x0789 ), SHC( 0x8039 ), + SHC( 0xf5f6 ), SHC( 0x8066 ), SHC( 0xe492 ), SHC( 0x82fa ), SHC( 0xd3b3 ), SHC( 0x87ea ), SHC( 0xc3aa ), SHC( 0x8f1e ), + SHC( 0xb4c4 ), SHC( 0x9873 ), SHC( 0xa749 ), SHC( 0xa3bc ), SHC( 0x9b7b ), SHC( 0xb0c2 ), SHC( 0x9192 ), SHC( 0xbf47 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x720c ), SHC( 0xc5e4 ), + SHC( 0x678d ), SHC( 0xb4c4 ), SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x3a1c ), SHC( 0x8df4 ), + SHC( 0x278d ), SHC( 0x8644 ), SHC( 0x1406 ), SHC( 0x8194 ), SHC( 0x0000 ), SHC( 0x8000 ), SHC( 0xebfa ), SHC( 0x8194 ), + SHC( 0xd873 ), SHC( 0x8644 ), SHC( 0xc5e4 ), SHC( 0x8df4 ), SHC( 0xb4c4 ), SHC( 0x9873 ), SHC( 0xa57e ), SHC( 0xa57e ), + SHC( 0x9873 ), SHC( 0xb4c4 ), SHC( 0x8df4 ), SHC( 0xc5e4 ), SHC( 0x8644 ), SHC( 0xd873 ), SHC( 0x8194 ), SHC( 0xebfa ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7e01 ), SHC( 0xe980 ), SHC( 0x7816 ), SHC( 0xd3b3 ), SHC( 0x6e6e ), SHC( 0xbf47 ), + SHC( 0x6154 ), SHC( 0xacdf ), SHC( 0x5133 ), SHC( 0x9d0e ), SHC( 0x3e8b ), SHC( 0x9053 ), SHC( 0x29ef ), SHC( 0x8711 ), + SHC( 0x1406 ), SHC( 0x8194 ), SHC( 0xfd7d ), SHC( 0x8007 ), SHC( 0xe708 ), SHC( 0x8276 ), SHC( 0xd15a ), SHC( 0x88ce ), + SHC( 0xbd1f ), SHC( 0x92dd ), SHC( 0xaafa ), SHC( 0xa052 ), SHC( 0x9b7b ), SHC( 0xb0c2 ), SHC( 0x8f1e ), SHC( 0xc3aa ), + SHC( 0x8644 ), SHC( 0xd873 ), SHC( 0x8136 ), SHC( 0xee77 ), SHC( 0x801a ), SHC( 0x0506 ), SHC( 0x82fa ), SHC( 0x1b6e ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7d8a ), SHC( 0xe708 ), SHC( 0x7641 ), SHC( 0xcf05 ), SHC( 0x6a6d ), SHC( 0xb8e4 ), + SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x471c ), SHC( 0x9593 ), SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0x18f8 ), SHC( 0x8276 ), + SHC( 0x0000 ), SHC( 0x8000 ), SHC( 0xe708 ), SHC( 0x8276 ), SHC( 0xcf05 ), SHC( 0x89bf ), SHC( 0xb8e4 ), SHC( 0x9593 ), + SHC( 0xa57e ), SHC( 0xa57e ), SHC( 0x9593 ), SHC( 0xb8e4 ), SHC( 0x89bf ), SHC( 0xcf05 ), SHC( 0x8276 ), SHC( 0xe708 ), + SHC( 0x8000 ), SHC( 0x0000 ), SHC( 0x8276 ), SHC( 0x18f8 ), SHC( 0x89bf ), SHC( 0x30fb ), SHC( 0x9593 ), SHC( 0x471c ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7d06 ), SHC( 0xe492 ), SHC( 0x743e ), SHC( 0xca6a ), SHC( 0x660e ), SHC( 0xb2bf ), + SHC( 0x5321 ), SHC( 0x9eac ), SHC( 0x3c56 ), SHC( 0x8f1e ), SHC( 0x22be ), SHC( 0x84cf ), SHC( 0x0789 ), SHC( 0x8039 ), + SHC( 0xebfa ), SHC( 0x8194 ), SHC( 0xd15a ), SHC( 0x88ce ), SHC( 0xb8e4 ), SHC( 0x9593 ), SHC( 0xa3bc ), SHC( 0xa749 ), + SHC( 0x92dd ), SHC( 0xbd1f ), SHC( 0x8711 ), SHC( 0xd611 ), SHC( 0x80e4 ), SHC( 0xf0f5 ), SHC( 0x809e ), SHC( 0x0c8b ), + SHC( 0x8644 ), SHC( 0x278d ), SHC( 0x9192 ), SHC( 0x40b9 ), SHC( 0xa202 ), SHC( 0x56e2 ), SHC( 0xb6d0 ), SHC( 0x6902 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7c76 ), SHC( 0xe21f ), SHC( 0x720c ), SHC( 0xc5e4 ), SHC( 0x6154 ), SHC( 0xacdf ), + SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0x1406 ), SHC( 0x8194 ), SHC( 0xf5f6 ), SHC( 0x8066 ), + SHC( 0xd873 ), SHC( 0x8644 ), SHC( 0xbd1f ), SHC( 0x92dd ), SHC( 0xa57e ), SHC( 0xa57e ), SHC( 0x92dd ), SHC( 0xbd1f ), + SHC( 0x8644 ), SHC( 0xd873 ), SHC( 0x8066 ), SHC( 0xf5f6 ), SHC( 0x8194 ), SHC( 0x1406 ), SHC( 0x89bf ), SHC( 0x30fb ), + SHC( 0x9873 ), SHC( 0x4b3c ), SHC( 0xacdf ), SHC( 0x6154 ), SHC( 0xc5e4 ), SHC( 0x720c ), SHC( 0xe21f ), SHC( 0x7c76 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7bda ), SHC( 0xdfaf ), SHC( 0x6fad ), SHC( 0xc175 ), SHC( 0x5c44 ), SHC( 0xa749 ), + SHC( 0x42e1 ), SHC( 0x92dd ), SHC( 0x2528 ), SHC( 0x8583 ), SHC( 0x0506 ), SHC( 0x801a ), SHC( 0xe492 ), SHC( 0x82fa ), + SHC( 0xc5e4 ), SHC( 0x8df4 ), SHC( 0xaafa ), SHC( 0xa052 ), SHC( 0x9593 ), SHC( 0xb8e4 ), SHC( 0x8711 ), SHC( 0xd611 ), + SHC( 0x8066 ), SHC( 0xf5f6 ), SHC( 0x81ff ), SHC( 0x1680 ), SHC( 0x8bc2 ), SHC( 0x3596 ), SHC( 0x9d0e ), SHC( 0x5133 ), + SHC( 0xb4c4 ), SHC( 0x678d ), SHC( 0xd15a ), SHC( 0x7732 ), SHC( 0xf0f5 ), SHC( 0x7f1c ), SHC( 0x1189 ), SHC( 0x7eca ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7b31 ), SHC( 0xdd42 ), SHC( 0x6d23 ), SHC( 0xbd1f ), SHC( 0x56e2 ), SHC( 0xa202 ), + SHC( 0x3a1c ), SHC( 0x8df4 ), SHC( 0x18f8 ), SHC( 0x8276 ), SHC( 0xf5f6 ), SHC( 0x8066 ), SHC( 0xd3b3 ), SHC( 0x87ea ), + SHC( 0xb4c4 ), SHC( 0x9873 ), SHC( 0x9b7b ), SHC( 0xb0c2 ), SHC( 0x89bf ), SHC( 0xcf05 ), SHC( 0x80e4 ), SHC( 0xf0f5 ), + SHC( 0x8194 ), SHC( 0x1406 ), SHC( 0x8bc2 ), SHC( 0x3596 ), SHC( 0x9eac ), SHC( 0x5321 ), SHC( 0xb8e4 ), SHC( 0x6a6d ), + SHC( 0xd873 ), SHC( 0x79bc ), SHC( 0xfafa ), SHC( 0x7fe6 ), SHC( 0x1de1 ), SHC( 0x7c76 ), SHC( 0x3e8b ), SHC( 0x6fad ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7a7d ), SHC( 0xdad8 ), SHC( 0x6a6d ), SHC( 0xb8e4 ), SHC( 0x5133 ), SHC( 0x9d0e ), + SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0x0c8b ), SHC( 0x809e ), SHC( 0xe708 ), SHC( 0x8276 ), SHC( 0xc3aa ), SHC( 0x8f1e ), + SHC( 0xa57e ), SHC( 0xa57e ), SHC( 0x8f1e ), SHC( 0xc3aa ), SHC( 0x8276 ), SHC( 0xe708 ), SHC( 0x809e ), SHC( 0x0c8b ), + SHC( 0x89bf ), SHC( 0x30fb ), SHC( 0x9d0e ), SHC( 0x5133 ), SHC( 0xb8e4 ), SHC( 0x6a6d ), SHC( 0xdad8 ), SHC( 0x7a7d ), + SHC( 0x0000 ), SHC( 0x7fff ), SHC( 0x2528 ), SHC( 0x7a7d ), SHC( 0x471c ), SHC( 0x6a6d ), SHC( 0x62f2 ), SHC( 0x5133 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7ffe ), SHC( 0xfebf ), SHC( 0x7ff9 ), SHC( 0xfd7d ), SHC( 0x7ff1 ), SHC( 0xfc3c ), + SHC( 0x7fe6 ), SHC( 0xfafa ), SHC( 0x7fd8 ), SHC( 0xf9b9 ), SHC( 0x7fc7 ), SHC( 0xf877 ), SHC( 0x7fb2 ), SHC( 0xf736 ), + SHC( 0x7f9a ), SHC( 0xf5f6 ), SHC( 0x7f80 ), SHC( 0xf4b5 ), SHC( 0x7f62 ), SHC( 0xf375 ), SHC( 0x7f41 ), SHC( 0xf235 ), + SHC( 0x7f1c ), SHC( 0xf0f5 ), SHC( 0x7ef5 ), SHC( 0xefb6 ), SHC( 0x7eca ), SHC( 0xee77 ), SHC( 0x7e9d ), SHC( 0xed38 ), + SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x7e38 ), SHC( 0xeabd ), SHC( 0x7e01 ), SHC( 0xe980 ), SHC( 0x7dc7 ), SHC( 0xe844 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7ff1 ), SHC( 0xfc3c ), SHC( 0x7fc7 ), SHC( 0xf877 ), SHC( 0x7f80 ), SHC( 0xf4b5 ), + SHC( 0x7f1c ), SHC( 0xf0f5 ), SHC( 0x7e9d ), SHC( 0xed38 ), SHC( 0x7e01 ), SHC( 0xe980 ), SHC( 0x7d4a ), SHC( 0xe5cd ), + SHC( 0x7c76 ), SHC( 0xe21f ), SHC( 0x7b87 ), SHC( 0xde78 ), SHC( 0x7a7d ), SHC( 0xdad8 ), SHC( 0x7957 ), SHC( 0xd741 ), + SHC( 0x7816 ), SHC( 0xd3b3 ), SHC( 0x76bb ), SHC( 0xd02f ), SHC( 0x7545 ), SHC( 0xccb5 ), SHC( 0x73b5 ), SHC( 0xc946 ), + SHC( 0x720c ), SHC( 0xc5e4 ), SHC( 0x7049 ), SHC( 0xc28f ), SHC( 0x6e6e ), SHC( 0xbf47 ), SHC( 0x6c79 ), SHC( 0xbc0e ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fd8 ), SHC( 0xf9b9 ), SHC( 0x7f62 ), SHC( 0xf375 ), SHC( 0x7e9d ), SHC( 0xed38 ), + SHC( 0x7d8a ), SHC( 0xe708 ), SHC( 0x7c29 ), SHC( 0xe0e7 ), SHC( 0x7a7d ), SHC( 0xdad8 ), SHC( 0x7884 ), SHC( 0xd4e1 ), + SHC( 0x7641 ), SHC( 0xcf05 ), SHC( 0x73b5 ), SHC( 0xc946 ), SHC( 0x70e2 ), SHC( 0xc3aa ), SHC( 0x6dca ), SHC( 0xbe32 ), + SHC( 0x6a6d ), SHC( 0xb8e4 ), SHC( 0x66cf ), SHC( 0xb3c1 ), SHC( 0x62f2 ), SHC( 0xaecd ), SHC( 0x5ed7 ), SHC( 0xaa0b ), + SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x55f5 ), SHC( 0xa129 ), SHC( 0x5133 ), SHC( 0x9d0e ), SHC( 0x4c3f ), SHC( 0x9931 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fb2 ), SHC( 0xf736 ), SHC( 0x7eca ), SHC( 0xee77 ), SHC( 0x7d4a ), SHC( 0xe5cd ), + SHC( 0x7b31 ), SHC( 0xdd42 ), SHC( 0x7884 ), SHC( 0xd4e1 ), SHC( 0x7545 ), SHC( 0xccb5 ), SHC( 0x7179 ), SHC( 0xc4c6 ), + SHC( 0x6d23 ), SHC( 0xbd1f ), SHC( 0x6849 ), SHC( 0xb5c9 ), SHC( 0x62f2 ), SHC( 0xaecd ), SHC( 0x5d22 ), SHC( 0xa832 ), + SHC( 0x56e2 ), SHC( 0xa202 ), SHC( 0x503a ), SHC( 0x9c44 ), SHC( 0x4930 ), SHC( 0x96fe ), SHC( 0x41ce ), SHC( 0x9236 ), + SHC( 0x3a1c ), SHC( 0x8df4 ), SHC( 0x3224 ), SHC( 0x8a3b ), SHC( 0x29ef ), SHC( 0x8711 ), SHC( 0x2188 ), SHC( 0x8479 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f80 ), SHC( 0xf4b5 ), SHC( 0x7e01 ), SHC( 0xe980 ), SHC( 0x7b87 ), SHC( 0xde78 ), + SHC( 0x7816 ), SHC( 0xd3b3 ), SHC( 0x73b5 ), SHC( 0xc946 ), SHC( 0x6e6e ), SHC( 0xbf47 ), SHC( 0x6849 ), SHC( 0xb5c9 ), + SHC( 0x6154 ), SHC( 0xacdf ), SHC( 0x599d ), SHC( 0xa49c ), SHC( 0x5133 ), SHC( 0x9d0e ), SHC( 0x4827 ), SHC( 0x9647 ), + SHC( 0x3e8b ), SHC( 0x9053 ), SHC( 0x3471 ), SHC( 0x8b3d ), SHC( 0x29ef ), SHC( 0x8711 ), SHC( 0x1f19 ), SHC( 0x83d7 ), + SHC( 0x1406 ), SHC( 0x8194 ), SHC( 0x08ca ), SHC( 0x804e ), SHC( 0xfd7d ), SHC( 0x8007 ), SHC( 0xf235 ), SHC( 0x80bf ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f41 ), SHC( 0xf235 ), SHC( 0x7d06 ), SHC( 0xe492 ), SHC( 0x7957 ), SHC( 0xd741 ), + SHC( 0x743e ), SHC( 0xca6a ), SHC( 0x6dca ), SHC( 0xbe32 ), SHC( 0x660e ), SHC( 0xb2bf ), SHC( 0x5d22 ), SHC( 0xa832 ), + SHC( 0x5321 ), SHC( 0x9eac ), SHC( 0x4827 ), SHC( 0x9647 ), SHC( 0x3c56 ), SHC( 0x8f1e ), SHC( 0x2fd1 ), SHC( 0x8945 ), + SHC( 0x22be ), SHC( 0x84cf ), SHC( 0x1543 ), SHC( 0x81c8 ), SHC( 0x0789 ), SHC( 0x8039 ), SHC( 0xf9b9 ), SHC( 0x8028 ), + SHC( 0xebfa ), SHC( 0x8194 ), SHC( 0xde78 ), SHC( 0x8479 ), SHC( 0xd15a ), SHC( 0x88ce ), SHC( 0xc4c6 ), SHC( 0x8e87 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7ef5 ), SHC( 0xefb6 ), SHC( 0x7bda ), SHC( 0xdfaf ), SHC( 0x76bb ), SHC( 0xd02f ), + SHC( 0x6fad ), SHC( 0xc175 ), SHC( 0x66cf ), SHC( 0xb3c1 ), SHC( 0x5c44 ), SHC( 0xa749 ), SHC( 0x503a ), SHC( 0x9c44 ), + SHC( 0x42e1 ), SHC( 0x92dd ), SHC( 0x3471 ), SHC( 0x8b3d ), SHC( 0x2528 ), SHC( 0x8583 ), SHC( 0x1543 ), SHC( 0x81c8 ), + SHC( 0x0506 ), SHC( 0x801a ), SHC( 0xf4b5 ), SHC( 0x8080 ), SHC( 0xe492 ), SHC( 0x82fa ), SHC( 0xd4e1 ), SHC( 0x877c ), + SHC( 0xc5e4 ), SHC( 0x8df4 ), SHC( 0xb7d9 ), SHC( 0x9647 ), SHC( 0xaafa ), SHC( 0xa052 ), SHC( 0x9f7e ), SHC( 0xabec ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7e9d ), SHC( 0xed38 ), SHC( 0x7a7d ), SHC( 0xdad8 ), SHC( 0x73b5 ), SHC( 0xc946 ), + SHC( 0x6a6d ), SHC( 0xb8e4 ), SHC( 0x5ed7 ), SHC( 0xaa0b ), SHC( 0x5133 ), SHC( 0x9d0e ), SHC( 0x41ce ), SHC( 0x9236 ), + SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0x1f19 ), SHC( 0x83d7 ), SHC( 0x0c8b ), SHC( 0x809e ), SHC( 0xf9b9 ), SHC( 0x8028 ), + SHC( 0xe708 ), SHC( 0x8276 ), SHC( 0xd4e1 ), SHC( 0x877c ), SHC( 0xc3aa ), SHC( 0x8f1e ), SHC( 0xb3c1 ), SHC( 0x9931 ), + SHC( 0xa57e ), SHC( 0xa57e ), SHC( 0x9931 ), SHC( 0xb3c1 ), SHC( 0x8f1e ), SHC( 0xc3aa ), SHC( 0x877c ), SHC( 0xd4e1 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7e38 ), SHC( 0xeabd ), SHC( 0x78ef ), SHC( 0xd611 ), SHC( 0x7049 ), SHC( 0xc28f ), + SHC( 0x6485 ), SHC( 0xb0c2 ), SHC( 0x55f5 ), SHC( 0xa129 ), SHC( 0x4502 ), SHC( 0x9433 ), SHC( 0x3224 ), SHC( 0x8a3b ), + SHC( 0x1de1 ), SHC( 0x838a ), SHC( 0x08ca ), SHC( 0x804e ), SHC( 0xf375 ), SHC( 0x809e ), SHC( 0xde78 ), SHC( 0x8479 ), + SHC( 0xca6a ), SHC( 0x8bc2 ), SHC( 0xb7d9 ), SHC( 0x9647 ), SHC( 0xa749 ), SHC( 0xa3bc ), SHC( 0x9931 ), SHC( 0xb3c1 ), + SHC( 0x8df4 ), SHC( 0xc5e4 ), SHC( 0x85e2 ), SHC( 0xd9a5 ), SHC( 0x8136 ), SHC( 0xee77 ), SHC( 0x800f ), SHC( 0x03c4 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7dc7 ), SHC( 0xe844 ), SHC( 0x7732 ), SHC( 0xd15a ), SHC( 0x6c79 ), SHC( 0xbc0e ), + SHC( 0x5dfe ), SHC( 0xa91e ), SHC( 0x4c3f ), SHC( 0x9931 ), SHC( 0x37dc ), SHC( 0x8cd6 ), SHC( 0x2188 ), SHC( 0x8479 ), + SHC( 0x0a0a ), SHC( 0x8066 ), SHC( 0xf235 ), SHC( 0x80bf ), SHC( 0xdad8 ), SHC( 0x8583 ), SHC( 0xc4c6 ), SHC( 0x8e87 ), + SHC( 0xb0c2 ), SHC( 0x9b7b ), SHC( 0x9f7e ), SHC( 0xabec ), SHC( 0x9192 ), SHC( 0xbf47 ), SHC( 0x877c ), SHC( 0xd4e1 ), + SHC( 0x8194 ), SHC( 0xebfa ), SHC( 0x800f ), SHC( 0x03c4 ), SHC( 0x82fa ), SHC( 0x1b6e ), SHC( 0x8a3b ), SHC( 0x3224 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7d4a ), SHC( 0xe5cd ), SHC( 0x7545 ), SHC( 0xccb5 ), SHC( 0x6849 ), SHC( 0xb5c9 ), + SHC( 0x56e2 ), SHC( 0xa202 ), SHC( 0x41ce ), SHC( 0x9236 ), SHC( 0x29ef ), SHC( 0x8711 ), SHC( 0x104a ), SHC( 0x810b ), + SHC( 0xf5f6 ), SHC( 0x8066 ), SHC( 0xdc0d ), SHC( 0x8528 ), SHC( 0xc3aa ), SHC( 0x8f1e ), SHC( 0xadd5 ), SHC( 0x9ddc ), + SHC( 0x9b7b ), SHC( 0xb0c2 ), SHC( 0x8d63 ), SHC( 0xc703 ), SHC( 0x8426 ), SHC( 0xdfaf ), SHC( 0x8028 ), SHC( 0xf9b9 ), + SHC( 0x8194 ), SHC( 0x1406 ), SHC( 0x885b ), SHC( 0x2d7a ), SHC( 0x9433 ), SHC( 0x4502 ), SHC( 0xa49c ), SHC( 0x599d ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7cc0 ), SHC( 0xe358 ), SHC( 0x732a ), SHC( 0xc824 ), SHC( 0x63bc ), SHC( 0xafc6 ), + SHC( 0x4f3e ), SHC( 0x9b7b ), SHC( 0x36ba ), SHC( 0x8c4b ), SHC( 0x1b6e ), SHC( 0x82fa ), SHC( 0xfebf ), SHC( 0x8002 ), + SHC( 0xe21f ), SHC( 0x838a ), SHC( 0xc703 ), SHC( 0x8d63 ), SHC( 0xaecd ), SHC( 0x9d0e ), SHC( 0x9ab5 ), SHC( 0xb1c0 ), + SHC( 0x8bc2 ), SHC( 0xca6a ), SHC( 0x82b6 ), SHC( 0xe5cd ), SHC( 0x8007 ), SHC( 0x0283 ), SHC( 0x83d7 ), SHC( 0x1f19 ), + SHC( 0x8df4 ), SHC( 0x3a1c ), SHC( 0x9ddc ), SHC( 0x522b ), SHC( 0xb2bf ), SHC( 0x660e ), SHC( 0xcb8f ), SHC( 0x74c3 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7c29 ), SHC( 0xe0e7 ), SHC( 0x70e2 ), SHC( 0xc3aa ), SHC( 0x5ed7 ), SHC( 0xaa0b ), + SHC( 0x471c ), SHC( 0x9593 ), SHC( 0x2b1f ), SHC( 0x877c ), SHC( 0x0c8b ), SHC( 0x809e ), SHC( 0xed38 ), SHC( 0x8163 ), + SHC( 0xcf05 ), SHC( 0x89bf ), SHC( 0xb3c1 ), SHC( 0x9931 ), SHC( 0x9d0e ), SHC( 0xaecd ), SHC( 0x8c4b ), SHC( 0xc946 ), + SHC( 0x8276 ), SHC( 0xe708 ), SHC( 0x8028 ), SHC( 0x0647 ), SHC( 0x8583 ), SHC( 0x2528 ), SHC( 0x9236 ), SHC( 0x41ce ), + SHC( 0xa57e ), SHC( 0x5a82 ), SHC( 0xbe32 ), SHC( 0x6dca ), SHC( 0xdad8 ), SHC( 0x7a7d ), SHC( 0xf9b9 ), SHC( 0x7fd8 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7b87 ), SHC( 0xde78 ), SHC( 0x6e6e ), SHC( 0xbf47 ), SHC( 0x599d ), SHC( 0xa49c ), + SHC( 0x3e8b ), SHC( 0x9053 ), SHC( 0x1f19 ), SHC( 0x83d7 ), SHC( 0xfd7d ), SHC( 0x8007 ), SHC( 0xdc0d ), SHC( 0x8528 ), + SHC( 0xbd1f ), SHC( 0x92dd ), SHC( 0xa2de ), SHC( 0xa832 ), SHC( 0x8f1e ), SHC( 0xc3aa ), SHC( 0x8340 ), SHC( 0xe358 ), + SHC( 0x801a ), SHC( 0x0506 ), SHC( 0x85e2 ), SHC( 0x265b ), SHC( 0x9433 ), SHC( 0x4502 ), SHC( 0xaa0b ), SHC( 0x5ed7 ), + SHC( 0xc5e4 ), SHC( 0x720c ), SHC( 0xe5cd ), SHC( 0x7d4a ), SHC( 0x0789 ), SHC( 0x7fc7 ), SHC( 0x28bf ), SHC( 0x7957 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7ad8 ), SHC( 0xdc0d ), SHC( 0x6bcd ), SHC( 0xbafe ), SHC( 0x5414 ), SHC( 0x9f7e ), + SHC( 0x3596 ), SHC( 0x8bc2 ), SHC( 0x12c8 ), SHC( 0x8163 ), SHC( 0xee77 ), SHC( 0x8136 ), SHC( 0xcb8f ), SHC( 0x8b3d ), + SHC( 0xacdf ), SHC( 0x9eac ), SHC( 0x94e1 ), SHC( 0xb9f0 ), SHC( 0x8583 ), SHC( 0xdad8 ), SHC( 0x8002 ), SHC( 0xfebf ), + SHC( 0x84cf ), SHC( 0x22be ), SHC( 0x9387 ), SHC( 0x43f2 ), SHC( 0xaafa ), SHC( 0x5fae ), SHC( 0xc946 ), SHC( 0x73b5 ), + SHC( 0xebfa ), SHC( 0x7e6c ), SHC( 0x104a ), SHC( 0x7ef5 ), SHC( 0x334b ), SHC( 0x7545 ), SHC( 0x522b ), SHC( 0x6224 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7a1e ), SHC( 0xd9a5 ), SHC( 0x6902 ), SHC( 0xb6d0 ), SHC( 0x4e40 ), SHC( 0x9ab5 ), + SHC( 0x2c4d ), SHC( 0x87ea ), SHC( 0x0647 ), SHC( 0x8028 ), SHC( 0xdfaf ), SHC( 0x8426 ), SHC( 0xbc0e ), SHC( 0x9387 ), + SHC( 0x9eac ), SHC( 0xacdf ), SHC( 0x8a3b ), SHC( 0xcddc ), SHC( 0x809e ), SHC( 0xf375 ), SHC( 0x82b6 ), SHC( 0x1a33 ), + SHC( 0x9053 ), SHC( 0x3e8b ), SHC( 0xa832 ), SHC( 0x5d22 ), SHC( 0xc824 ), SHC( 0x732a ), SHC( 0xed38 ), SHC( 0x7e9d ), + SHC( 0x1406 ), SHC( 0x7e6c ), SHC( 0x38fd ), SHC( 0x729d ), SHC( 0x58b7 ), SHC( 0x5c44 ), SHC( 0x7049 ), SHC( 0x3d71 ), +}; + +const Word16 FFT_RotVector_600_fx[ 1140 ] = { + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7ff8 ), SHC( 0xfd52 ), SHC( 0x7fe3 ), SHC( 0xfaa4 ), SHC( 0x7fbf ), SHC( 0xf7f7 ), + SHC( 0x7f8d ), SHC( 0xf54b ), SHC( 0x7f4c ), SHC( 0xf29f ), SHC( 0x7efd ), SHC( 0xeff6 ), SHC( 0x7ea0 ), SHC( 0xed4e ), + SHC( 0x7e35 ), SHC( 0xeaa8 ), SHC( 0x7dbb ), SHC( 0xe804 ), SHC( 0x7d33 ), SHC( 0xe564 ), SHC( 0x7c9e ), SHC( 0xe2c6 ), + SHC( 0x7bfa ), SHC( 0xe02b ), SHC( 0x7b48 ), SHC( 0xdd95 ), SHC( 0x7a89 ), SHC( 0xdb02 ), SHC( 0x79bc ), SHC( 0xd873 ), + SHC( 0x78e1 ), SHC( 0xd5e8 ), SHC( 0x77f8 ), SHC( 0xd362 ), SHC( 0x7702 ), SHC( 0xd0e2 ), SHC( 0x75ff ), SHC( 0xce66 ), + SHC( 0x74ef ), SHC( 0xcbf1 ), SHC( 0x73d1 ), SHC( 0xc981 ), SHC( 0x72a6 ), SHC( 0xc717 ), SHC( 0x716f ), SHC( 0xc4b3 ), + SHC( 0x702a ), SHC( 0xc256 ), SHC( 0x6ed9 ), SHC( 0xc000 ), SHC( 0x6d7c ), SHC( 0xbdb2 ), SHC( 0x6c12 ), SHC( 0xbb6b ), + SHC( 0x6a9d ), SHC( 0xb92b ), SHC( 0x691b ), SHC( 0xb6f3 ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fe3 ), SHC( 0xfaa4 ), + SHC( 0x7f8d ), SHC( 0xf54b ), SHC( 0x7efd ), SHC( 0xeff6 ), SHC( 0x7e35 ), SHC( 0xeaa8 ), SHC( 0x7d33 ), SHC( 0xe564 ), + SHC( 0x7bfa ), SHC( 0xe02b ), SHC( 0x7a89 ), SHC( 0xdb02 ), SHC( 0x78e1 ), SHC( 0xd5e8 ), SHC( 0x7702 ), SHC( 0xd0e2 ), + SHC( 0x74ef ), SHC( 0xcbf1 ), SHC( 0x72a6 ), SHC( 0xc717 ), SHC( 0x702a ), SHC( 0xc256 ), SHC( 0x6d7c ), SHC( 0xbdb2 ), + SHC( 0x6a9d ), SHC( 0xb92b ), SHC( 0x678d ), SHC( 0xb4c4 ), SHC( 0x6450 ), SHC( 0xb07f ), SHC( 0x60e5 ), SHC( 0xac5d ), + SHC( 0x5d4e ), SHC( 0xa861 ), SHC( 0x598e ), SHC( 0xa48d ), SHC( 0x55a6 ), SHC( 0xa0e1 ), SHC( 0x5197 ), SHC( 0x9d60 ), + SHC( 0x4d63 ), SHC( 0x9a0c ), SHC( 0x490d ), SHC( 0x96e5 ), SHC( 0x4495 ), SHC( 0x93ee ), SHC( 0x4000 ), SHC( 0x9127 ), + SHC( 0x3b4d ), SHC( 0x8e91 ), SHC( 0x367f ), SHC( 0x8c2f ), SHC( 0x319a ), SHC( 0x8a01 ), SHC( 0x2c9e ), SHC( 0x8808 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fbf ), SHC( 0xf7f7 ), SHC( 0x7efd ), SHC( 0xeff6 ), SHC( 0x7dbb ), SHC( 0xe804 ), + SHC( 0x7bfa ), SHC( 0xe02b ), SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x7702 ), SHC( 0xd0e2 ), SHC( 0x73d1 ), SHC( 0xc981 ), + SHC( 0x702a ), SHC( 0xc256 ), SHC( 0x6c12 ), SHC( 0xbb6b ), SHC( 0x678d ), SHC( 0xb4c4 ), SHC( 0x62a0 ), SHC( 0xae69 ), + SHC( 0x5d4e ), SHC( 0xa861 ), SHC( 0x579f ), SHC( 0xa2b2 ), SHC( 0x5197 ), SHC( 0x9d60 ), SHC( 0x4b3c ), SHC( 0x9873 ), + SHC( 0x4495 ), SHC( 0x93ee ), SHC( 0x3daa ), SHC( 0x8fd6 ), SHC( 0x367f ), SHC( 0x8c2f ), SHC( 0x2f1e ), SHC( 0x88fe ), + SHC( 0x278d ), SHC( 0x8644 ), SHC( 0x1fd5 ), SHC( 0x8406 ), SHC( 0x17fc ), SHC( 0x8245 ), SHC( 0x100a ), SHC( 0x8103 ), + SHC( 0x0809 ), SHC( 0x8041 ), SHC( 0x0000 ), SHC( 0x8000 ), SHC( 0xf7f7 ), SHC( 0x8041 ), SHC( 0xeff6 ), SHC( 0x8103 ), + SHC( 0xe804 ), SHC( 0x8245 ), SHC( 0xe02b ), SHC( 0x8406 ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f8d ), SHC( 0xf54b ), + SHC( 0x7e35 ), SHC( 0xeaa8 ), SHC( 0x7bfa ), SHC( 0xe02b ), SHC( 0x78e1 ), SHC( 0xd5e8 ), SHC( 0x74ef ), SHC( 0xcbf1 ), + SHC( 0x702a ), SHC( 0xc256 ), SHC( 0x6a9d ), SHC( 0xb92b ), SHC( 0x6450 ), SHC( 0xb07f ), SHC( 0x5d4e ), SHC( 0xa861 ), + SHC( 0x55a6 ), SHC( 0xa0e1 ), SHC( 0x4d63 ), SHC( 0x9a0c ), SHC( 0x4495 ), SHC( 0x93ee ), SHC( 0x3b4d ), SHC( 0x8e91 ), + SHC( 0x319a ), SHC( 0x8a01 ), SHC( 0x278d ), SHC( 0x8644 ), SHC( 0x1d3a ), SHC( 0x8362 ), SHC( 0x12b2 ), SHC( 0x8160 ), + SHC( 0x0809 ), SHC( 0x8041 ), SHC( 0xfd52 ), SHC( 0x8008 ), SHC( 0xf29f ), SHC( 0x80b4 ), SHC( 0xe804 ), SHC( 0x8245 ), + SHC( 0xdd95 ), SHC( 0x84b8 ), SHC( 0xd362 ), SHC( 0x8808 ), SHC( 0xc981 ), SHC( 0x8c2f ), SHC( 0xc000 ), SHC( 0x9127 ), + SHC( 0xb6f3 ), SHC( 0x96e5 ), SHC( 0xae69 ), SHC( 0x9d60 ), SHC( 0xa672 ), SHC( 0xa48d ), SHC( 0x9f1b ), SHC( 0xac5d ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f4c ), SHC( 0xf29f ), SHC( 0x7d33 ), SHC( 0xe564 ), SHC( 0x79bc ), SHC( 0xd873 ), + SHC( 0x74ef ), SHC( 0xcbf1 ), SHC( 0x6ed9 ), SHC( 0xc000 ), SHC( 0x678d ), SHC( 0xb4c4 ), SHC( 0x5f1f ), SHC( 0xaa5a ), + SHC( 0x55a6 ), SHC( 0xa0e1 ), SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x4000 ), SHC( 0x9127 ), SHC( 0x340f ), SHC( 0x8b11 ), + SHC( 0x278d ), SHC( 0x8644 ), SHC( 0x1a9c ), SHC( 0x82cd ), SHC( 0x0d61 ), SHC( 0x80b4 ), SHC( 0x0000 ), SHC( 0x8000 ), + SHC( 0xf29f ), SHC( 0x80b4 ), SHC( 0xe564 ), SHC( 0x82cd ), SHC( 0xd873 ), SHC( 0x8644 ), SHC( 0xcbf1 ), SHC( 0x8b11 ), + SHC( 0xc000 ), SHC( 0x9127 ), SHC( 0xb4c4 ), SHC( 0x9873 ), SHC( 0xaa5a ), SHC( 0xa0e1 ), SHC( 0xa0e1 ), SHC( 0xaa5a ), + SHC( 0x9873 ), SHC( 0xb4c4 ), SHC( 0x9127 ), SHC( 0xc000 ), SHC( 0x8b11 ), SHC( 0xcbf1 ), SHC( 0x8644 ), SHC( 0xd873 ), + SHC( 0x82cd ), SHC( 0xe564 ), SHC( 0x80b4 ), SHC( 0xf29f ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7efd ), SHC( 0xeff6 ), + SHC( 0x7bfa ), SHC( 0xe02b ), SHC( 0x7702 ), SHC( 0xd0e2 ), SHC( 0x702a ), SHC( 0xc256 ), SHC( 0x678d ), SHC( 0xb4c4 ), + SHC( 0x5d4e ), SHC( 0xa861 ), SHC( 0x5197 ), SHC( 0x9d60 ), SHC( 0x4495 ), SHC( 0x93ee ), SHC( 0x367f ), SHC( 0x8c2f ), + SHC( 0x278d ), SHC( 0x8644 ), SHC( 0x17fc ), SHC( 0x8245 ), SHC( 0x0809 ), SHC( 0x8041 ), SHC( 0xf7f7 ), SHC( 0x8041 ), + SHC( 0xe804 ), SHC( 0x8245 ), SHC( 0xd873 ), SHC( 0x8644 ), SHC( 0xc981 ), SHC( 0x8c2f ), SHC( 0xbb6b ), SHC( 0x93ee ), + SHC( 0xae69 ), SHC( 0x9d60 ), SHC( 0xa2b2 ), SHC( 0xa861 ), SHC( 0x9873 ), SHC( 0xb4c4 ), SHC( 0x8fd6 ), SHC( 0xc256 ), + SHC( 0x88fe ), SHC( 0xd0e2 ), SHC( 0x8406 ), SHC( 0xe02b ), SHC( 0x8103 ), SHC( 0xeff6 ), SHC( 0x8000 ), SHC( 0x0000 ), + SHC( 0x8103 ), SHC( 0x100a ), SHC( 0x8406 ), SHC( 0x1fd5 ), SHC( 0x88fe ), SHC( 0x2f1e ), SHC( 0x8fd6 ), SHC( 0x3daa ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7ea0 ), SHC( 0xed4e ), SHC( 0x7a89 ), SHC( 0xdb02 ), SHC( 0x73d1 ), SHC( 0xc981 ), + SHC( 0x6a9d ), SHC( 0xb92b ), SHC( 0x5f1f ), SHC( 0xaa5a ), SHC( 0x5197 ), SHC( 0x9d60 ), SHC( 0x424e ), SHC( 0x9284 ), + SHC( 0x319a ), SHC( 0x8a01 ), SHC( 0x1fd5 ), SHC( 0x8406 ), SHC( 0x0d61 ), SHC( 0x80b4 ), SHC( 0xfaa4 ), SHC( 0x801d ), + SHC( 0xe804 ), SHC( 0x8245 ), SHC( 0xd5e8 ), SHC( 0x871f ), SHC( 0xc4b3 ), SHC( 0x8e91 ), SHC( 0xb4c4 ), SHC( 0x9873 ), + SHC( 0xa672 ), SHC( 0xa48d ), SHC( 0x9a0c ), SHC( 0xb29d ), SHC( 0x8fd6 ), SHC( 0xc256 ), SHC( 0x8808 ), SHC( 0xd362 ), + SHC( 0x82cd ), SHC( 0xe564 ), SHC( 0x8041 ), SHC( 0xf7f7 ), SHC( 0x8073 ), SHC( 0x0ab5 ), SHC( 0x8362 ), SHC( 0x1d3a ), + SHC( 0x88fe ), SHC( 0x2f1e ), SHC( 0x9127 ), SHC( 0x4000 ), SHC( 0x9bb0 ), SHC( 0x4f81 ), SHC( 0xa861 ), SHC( 0x5d4e ), + SHC( 0xb6f3 ), SHC( 0x691b ), SHC( 0xc717 ), SHC( 0x72a6 ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7e35 ), SHC( 0xeaa8 ), + SHC( 0x78e1 ), SHC( 0xd5e8 ), SHC( 0x702a ), SHC( 0xc256 ), SHC( 0x6450 ), SHC( 0xb07f ), SHC( 0x55a6 ), SHC( 0xa0e1 ), + SHC( 0x4495 ), SHC( 0x93ee ), SHC( 0x319a ), SHC( 0x8a01 ), SHC( 0x1d3a ), SHC( 0x8362 ), SHC( 0x0809 ), SHC( 0x8041 ), + SHC( 0xf29f ), SHC( 0x80b4 ), SHC( 0xdd95 ), SHC( 0x84b8 ), SHC( 0xc981 ), SHC( 0x8c2f ), SHC( 0xb6f3 ), SHC( 0x96e5 ), + SHC( 0xa672 ), SHC( 0xa48d ), SHC( 0x9873 ), SHC( 0xb4c4 ), SHC( 0x8d5a ), SHC( 0xc717 ), SHC( 0x8577 ), SHC( 0xdb02 ), + SHC( 0x8103 ), SHC( 0xeff6 ), SHC( 0x801d ), SHC( 0x055c ), SHC( 0x82cd ), SHC( 0x1a9c ), SHC( 0x88fe ), SHC( 0x2f1e ), + SHC( 0x9284 ), SHC( 0x424e ), SHC( 0x9f1b ), SHC( 0x53a3 ), SHC( 0xae69 ), SHC( 0x62a0 ), SHC( 0xc000 ), SHC( 0x6ed9 ), + SHC( 0xd362 ), SHC( 0x77f8 ), SHC( 0xe804 ), SHC( 0x7dbb ), SHC( 0xfd52 ), SHC( 0x7ff8 ), SHC( 0x12b2 ), SHC( 0x7ea0 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7dbb ), SHC( 0xe804 ), SHC( 0x7702 ), SHC( 0xd0e2 ), SHC( 0x6c12 ), SHC( 0xbb6b ), + SHC( 0x5d4e ), SHC( 0xa861 ), SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x367f ), SHC( 0x8c2f ), SHC( 0x1fd5 ), SHC( 0x8406 ), + SHC( 0x0809 ), SHC( 0x8041 ), SHC( 0xeff6 ), SHC( 0x8103 ), SHC( 0xd873 ), SHC( 0x8644 ), SHC( 0xc256 ), SHC( 0x8fd6 ), + SHC( 0xae69 ), SHC( 0x9d60 ), SHC( 0x9d60 ), SHC( 0xae69 ), SHC( 0x8fd6 ), SHC( 0xc256 ), SHC( 0x8644 ), SHC( 0xd873 ), + SHC( 0x8103 ), SHC( 0xeff6 ), SHC( 0x8041 ), SHC( 0x0809 ), SHC( 0x8406 ), SHC( 0x1fd5 ), SHC( 0x8c2f ), SHC( 0x367f ), + SHC( 0x9873 ), SHC( 0x4b3c ), SHC( 0xa861 ), SHC( 0x5d4e ), SHC( 0xbb6b ), SHC( 0x6c12 ), SHC( 0xd0e2 ), SHC( 0x7702 ), + SHC( 0xe804 ), SHC( 0x7dbb ), SHC( 0x0000 ), SHC( 0x7fff ), SHC( 0x17fc ), SHC( 0x7dbb ), SHC( 0x2f1e ), SHC( 0x7702 ), + SHC( 0x4495 ), SHC( 0x6c12 ), SHC( 0x579f ), SHC( 0x5d4e ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7ffe ), SHC( 0xfea9 ), + SHC( 0x7ff8 ), SHC( 0xfd52 ), SHC( 0x7fef ), SHC( 0xfbfb ), SHC( 0x7fe3 ), SHC( 0xfaa4 ), SHC( 0x7fd3 ), SHC( 0xf94e ), + SHC( 0x7fbf ), SHC( 0xf7f7 ), SHC( 0x7fa8 ), SHC( 0xf6a1 ), SHC( 0x7f8d ), SHC( 0xf54b ), SHC( 0x7f6e ), SHC( 0xf3f5 ), + SHC( 0x7f4c ), SHC( 0xf29f ), SHC( 0x7f26 ), SHC( 0xf14a ), SHC( 0x7efd ), SHC( 0xeff6 ), SHC( 0x7ed0 ), SHC( 0xeea1 ), + SHC( 0x7ea0 ), SHC( 0xed4e ), SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x7e35 ), SHC( 0xeaa8 ), SHC( 0x7dfa ), SHC( 0xe956 ), + SHC( 0x7dbb ), SHC( 0xe804 ), SHC( 0x7d79 ), SHC( 0xe6b4 ), SHC( 0x7d33 ), SHC( 0xe564 ), SHC( 0x7cea ), SHC( 0xe414 ), + SHC( 0x7c9e ), SHC( 0xe2c6 ), SHC( 0x7c4e ), SHC( 0xe178 ), SHC( 0x7bfa ), SHC( 0xe02b ), SHC( 0x7ba3 ), SHC( 0xdee0 ), + SHC( 0x7b48 ), SHC( 0xdd95 ), SHC( 0x7aea ), SHC( 0xdc4b ), SHC( 0x7a89 ), SHC( 0xdb02 ), SHC( 0x7a24 ), SHC( 0xd9ba ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fef ), SHC( 0xfbfb ), SHC( 0x7fbf ), SHC( 0xf7f7 ), SHC( 0x7f6e ), SHC( 0xf3f5 ), + SHC( 0x7efd ), SHC( 0xeff6 ), SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x7dbb ), SHC( 0xe804 ), SHC( 0x7cea ), SHC( 0xe414 ), + SHC( 0x7bfa ), SHC( 0xe02b ), SHC( 0x7aea ), SHC( 0xdc4b ), SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x786e ), SHC( 0xd4a5 ), + SHC( 0x7702 ), SHC( 0xd0e2 ), SHC( 0x7578 ), SHC( 0xcd2b ), SHC( 0x73d1 ), SHC( 0xc981 ), SHC( 0x720c ), SHC( 0xc5e4 ), + SHC( 0x702a ), SHC( 0xc256 ), SHC( 0x6e2c ), SHC( 0xbed8 ), SHC( 0x6c12 ), SHC( 0xbb6b ), SHC( 0x69dd ), SHC( 0xb80e ), + SHC( 0x678d ), SHC( 0xb4c4 ), SHC( 0x6523 ), SHC( 0xb18d ), SHC( 0x62a0 ), SHC( 0xae69 ), SHC( 0x6003 ), SHC( 0xab5b ), + SHC( 0x5d4e ), SHC( 0xa861 ), SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x579f ), SHC( 0xa2b2 ), SHC( 0x54a5 ), SHC( 0x9ffd ), + SHC( 0x5197 ), SHC( 0x9d60 ), SHC( 0x4e73 ), SHC( 0x9add ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fd3 ), SHC( 0xf94e ), + SHC( 0x7f4c ), SHC( 0xf29f ), SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x7d33 ), SHC( 0xe564 ), SHC( 0x7ba3 ), SHC( 0xdee0 ), + SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x777f ), SHC( 0xd221 ), SHC( 0x74ef ), SHC( 0xcbf1 ), SHC( 0x720c ), SHC( 0xc5e4 ), + SHC( 0x6ed9 ), SHC( 0xc000 ), SHC( 0x6b59 ), SHC( 0xba4a ), SHC( 0x678d ), SHC( 0xb4c4 ), SHC( 0x6379 ), SHC( 0xaf73 ), + SHC( 0x5f1f ), SHC( 0xaa5a ), SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x55a6 ), SHC( 0xa0e1 ), SHC( 0x508d ), SHC( 0x9c87 ), + SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x45b6 ), SHC( 0x94a7 ), SHC( 0x4000 ), SHC( 0x9127 ), SHC( 0x3a1c ), SHC( 0x8df4 ), + SHC( 0x340f ), SHC( 0x8b11 ), SHC( 0x2ddf ), SHC( 0x8881 ), SHC( 0x278d ), SHC( 0x8644 ), SHC( 0x2120 ), SHC( 0x845d ), + SHC( 0x1a9c ), SHC( 0x82cd ), SHC( 0x1406 ), SHC( 0x8194 ), SHC( 0x0d61 ), SHC( 0x80b4 ), SHC( 0x06b2 ), SHC( 0x802d ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fa8 ), SHC( 0xf6a1 ), SHC( 0x7ea0 ), SHC( 0xed4e ), SHC( 0x7cea ), SHC( 0xe414 ), + SHC( 0x7a89 ), SHC( 0xdb02 ), SHC( 0x777f ), SHC( 0xd221 ), SHC( 0x73d1 ), SHC( 0xc981 ), SHC( 0x6f83 ), SHC( 0xc12b ), + SHC( 0x6a9d ), SHC( 0xb92b ), SHC( 0x6523 ), SHC( 0xb18d ), SHC( 0x5f1f ), SHC( 0xaa5a ), SHC( 0x5898 ), SHC( 0xa39e ), + SHC( 0x5197 ), SHC( 0x9d60 ), SHC( 0x4a25 ), SHC( 0x97aa ), SHC( 0x424e ), SHC( 0x9284 ), SHC( 0x3a1c ), SHC( 0x8df4 ), + SHC( 0x319a ), SHC( 0x8a01 ), SHC( 0x28d3 ), SHC( 0x86b0 ), SHC( 0x1fd5 ), SHC( 0x8406 ), SHC( 0x16aa ), SHC( 0x8206 ), + SHC( 0x0d61 ), SHC( 0x80b4 ), SHC( 0x0405 ), SHC( 0x8011 ), SHC( 0xfaa4 ), SHC( 0x801d ), SHC( 0xf14a ), SHC( 0x80da ), + SHC( 0xe804 ), SHC( 0x8245 ), SHC( 0xdee0 ), SHC( 0x845d ), SHC( 0xd5e8 ), SHC( 0x871f ), SHC( 0xcd2b ), SHC( 0x8a88 ), + SHC( 0xc4b3 ), SHC( 0x8e91 ), SHC( 0xbc8d ), SHC( 0x9337 ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f6e ), SHC( 0xf3f5 ), + SHC( 0x7dbb ), SHC( 0xe804 ), SHC( 0x7aea ), SHC( 0xdc4b ), SHC( 0x7702 ), SHC( 0xd0e2 ), SHC( 0x720c ), SHC( 0xc5e4 ), + SHC( 0x6c12 ), SHC( 0xbb6b ), SHC( 0x6523 ), SHC( 0xb18d ), SHC( 0x5d4e ), SHC( 0xa861 ), SHC( 0x54a5 ), SHC( 0x9ffd ), + SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x4128 ), SHC( 0x91d4 ), SHC( 0x367f ), SHC( 0x8c2f ), SHC( 0x2b5b ), SHC( 0x8792 ), + SHC( 0x1fd5 ), SHC( 0x8406 ), SHC( 0x1406 ), SHC( 0x8194 ), SHC( 0x0809 ), SHC( 0x8041 ), SHC( 0xfbfb ), SHC( 0x8011 ), + SHC( 0xeff6 ), SHC( 0x8103 ), SHC( 0xe414 ), SHC( 0x8316 ), SHC( 0xd873 ), SHC( 0x8644 ), SHC( 0xcd2b ), SHC( 0x8a88 ), + SHC( 0xc256 ), SHC( 0x8fd6 ), SHC( 0xb80e ), SHC( 0x9623 ), SHC( 0xae69 ), SHC( 0x9d60 ), SHC( 0xa57e ), SHC( 0xa57e ), + SHC( 0x9d60 ), SHC( 0xae69 ), SHC( 0x9623 ), SHC( 0xb80e ), SHC( 0x8fd6 ), SHC( 0xc256 ), SHC( 0x8a88 ), SHC( 0xcd2b ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f26 ), SHC( 0xf14a ), SHC( 0x7c9e ), SHC( 0xe2c6 ), SHC( 0x786e ), SHC( 0xd4a5 ), + SHC( 0x72a6 ), SHC( 0xc717 ), SHC( 0x6b59 ), SHC( 0xba4a ), SHC( 0x62a0 ), SHC( 0xae69 ), SHC( 0x5898 ), SHC( 0xa39e ), + SHC( 0x4d63 ), SHC( 0x9a0c ), SHC( 0x4128 ), SHC( 0x91d4 ), SHC( 0x340f ), SHC( 0x8b11 ), SHC( 0x2646 ), SHC( 0x85dc ), + SHC( 0x17fc ), SHC( 0x8245 ), SHC( 0x095f ), SHC( 0x8058 ), SHC( 0xfaa4 ), SHC( 0x801d ), SHC( 0xebfa ), SHC( 0x8194 ), + SHC( 0xdd95 ), SHC( 0x84b8 ), SHC( 0xcfa3 ), SHC( 0x897e ), SHC( 0xc256 ), SHC( 0x8fd6 ), SHC( 0xb5db ), SHC( 0x97aa ), + SHC( 0xaa5a ), SHC( 0xa0e1 ), SHC( 0x9ffd ), SHC( 0xab5b ), SHC( 0x96e5 ), SHC( 0xb6f3 ), SHC( 0x8f32 ), SHC( 0xc384 ), + SHC( 0x88fe ), SHC( 0xd0e2 ), SHC( 0x845d ), SHC( 0xdee0 ), SHC( 0x8160 ), SHC( 0xed4e ), SHC( 0x8011 ), SHC( 0xfbfb ), + SHC( 0x8073 ), SHC( 0x0ab5 ), SHC( 0x8287 ), SHC( 0x194c ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7ed0 ), SHC( 0xeea1 ), + SHC( 0x7b48 ), SHC( 0xdd95 ), SHC( 0x7578 ), SHC( 0xcd2b ), SHC( 0x6d7c ), SHC( 0xbdb2 ), SHC( 0x6379 ), SHC( 0xaf73 ), + SHC( 0x579f ), SHC( 0xa2b2 ), SHC( 0x4a25 ), SHC( 0x97aa ), SHC( 0x3b4d ), SHC( 0x8e91 ), SHC( 0x2b5b ), SHC( 0x8792 ), + SHC( 0x1a9c ), SHC( 0x82cd ), SHC( 0x095f ), SHC( 0x8058 ), SHC( 0xf7f7 ), SHC( 0x8041 ), SHC( 0xe6b4 ), SHC( 0x8287 ), + SHC( 0xd5e8 ), SHC( 0x871f ), SHC( 0xc5e4 ), SHC( 0x8df4 ), SHC( 0xb6f3 ), SHC( 0x96e5 ), SHC( 0xa95d ), SHC( 0xa1c8 ), + SHC( 0x9d60 ), SHC( 0xae69 ), SHC( 0x9337 ), SHC( 0xbc8d ), SHC( 0x8b11 ), SHC( 0xcbf1 ), SHC( 0x8516 ), SHC( 0xdc4b ), + SHC( 0x8160 ), SHC( 0xed4e ), SHC( 0x8002 ), SHC( 0xfea9 ), SHC( 0x8103 ), SHC( 0x100a ), SHC( 0x845d ), SHC( 0x2120 ), + SHC( 0x8a01 ), SHC( 0x319a ), SHC( 0x91d4 ), SHC( 0x4128 ), SHC( 0x9bb0 ), SHC( 0x4f81 ), SHC( 0xa768 ), SHC( 0x5c62 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x720c ), SHC( 0xc5e4 ), + SHC( 0x678d ), SHC( 0xb4c4 ), SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x3a1c ), SHC( 0x8df4 ), + SHC( 0x278d ), SHC( 0x8644 ), SHC( 0x1406 ), SHC( 0x8194 ), SHC( 0x0000 ), SHC( 0x8000 ), SHC( 0xebfa ), SHC( 0x8194 ), + SHC( 0xd873 ), SHC( 0x8644 ), SHC( 0xc5e4 ), SHC( 0x8df4 ), SHC( 0xb4c4 ), SHC( 0x9873 ), SHC( 0xa57e ), SHC( 0xa57e ), + SHC( 0x9873 ), SHC( 0xb4c4 ), SHC( 0x8df4 ), SHC( 0xc5e4 ), SHC( 0x8644 ), SHC( 0xd873 ), SHC( 0x8194 ), SHC( 0xebfa ), + SHC( 0x8000 ), SHC( 0x0000 ), SHC( 0x8194 ), SHC( 0x1406 ), SHC( 0x8644 ), SHC( 0x278d ), SHC( 0x8df4 ), SHC( 0x3a1c ), + SHC( 0x9873 ), SHC( 0x4b3c ), SHC( 0xa57e ), SHC( 0x5a82 ), SHC( 0xb4c4 ), SHC( 0x678d ), SHC( 0xc5e4 ), SHC( 0x720c ), + SHC( 0xd873 ), SHC( 0x79bc ), SHC( 0xebfa ), SHC( 0x7e6c ), SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7dfa ), SHC( 0xe956 ), + SHC( 0x77f8 ), SHC( 0xd362 ), SHC( 0x6e2c ), SHC( 0xbed8 ), SHC( 0x60e5 ), SHC( 0xac5d ), SHC( 0x508d ), SHC( 0x9c87 ), + SHC( 0x3daa ), SHC( 0x8fd6 ), SHC( 0x28d3 ), SHC( 0x86b0 ), SHC( 0x12b2 ), SHC( 0x8160 ), SHC( 0xfbfb ), SHC( 0x8011 ), + SHC( 0xe564 ), SHC( 0x82cd ), SHC( 0xcfa3 ), SHC( 0x897e ), SHC( 0xbb6b ), SHC( 0x93ee ), SHC( 0xa95d ), SHC( 0xa1c8 ), + SHC( 0x9a0c ), SHC( 0xb29d ), SHC( 0x8df4 ), SHC( 0xc5e4 ), SHC( 0x8577 ), SHC( 0xdb02 ), SHC( 0x80da ), SHC( 0xf14a ), + SHC( 0x8041 ), SHC( 0x0809 ), SHC( 0x83b2 ), SHC( 0x1e88 ), SHC( 0x8b11 ), SHC( 0x340f ), SHC( 0x9623 ), SHC( 0x47f2 ), + SHC( 0xa48d ), SHC( 0x598e ), SHC( 0xb5db ), SHC( 0x6856 ), SHC( 0xc981 ), SHC( 0x73d1 ), SHC( 0xdee0 ), SHC( 0x7ba3 ), + SHC( 0xf54b ), SHC( 0x7f8d ), SHC( 0x0c0b ), SHC( 0x7f6e ), SHC( 0x226b ), SHC( 0x7b48 ), SHC( 0x37b5 ), SHC( 0x733d ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7d79 ), SHC( 0xe6b4 ), SHC( 0x75ff ), SHC( 0xce66 ), SHC( 0x69dd ), SHC( 0xb80e ), + SHC( 0x598e ), SHC( 0xa48d ), SHC( 0x45b6 ), SHC( 0x94a7 ), SHC( 0x2f1e ), SHC( 0x88fe ), SHC( 0x16aa ), SHC( 0x8206 ), + SHC( 0xfd52 ), SHC( 0x8008 ), SHC( 0xe414 ), SHC( 0x8316 ), SHC( 0xcbf1 ), SHC( 0x8b11 ), SHC( 0xb5db ), SHC( 0x97aa ), + SHC( 0xa2b2 ), SHC( 0xa861 ), SHC( 0x9337 ), SHC( 0xbc8d ), SHC( 0x8808 ), SHC( 0xd362 ), SHC( 0x8194 ), SHC( 0xebfa ), + SHC( 0x801d ), SHC( 0x055c ), SHC( 0x83b2 ), SHC( 0x1e88 ), SHC( 0x8c2f ), SHC( 0x367f ), SHC( 0x993e ), SHC( 0x4c51 ), + SHC( 0xaa5a ), SHC( 0x5f1f ), SHC( 0xbed8 ), SHC( 0x6e2c ), SHC( 0xd5e8 ), SHC( 0x78e1 ), SHC( 0xeea1 ), SHC( 0x7ed0 ), + SHC( 0x0809 ), SHC( 0x7fbf ), SHC( 0x2120 ), SHC( 0x7ba3 ), SHC( 0x38e9 ), SHC( 0x72a6 ), SHC( 0x4e73 ), SHC( 0x6523 ), + SHC( 0x60e5 ), SHC( 0x53a3 ), SHC( 0x6f83 ), SHC( 0x3ed5 ), +}; + +const Word16 FFT_RotVector_400_fx[ 760 ] = { + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fef ), SHC( 0xfbfb ), SHC( 0x7fbf ), SHC( 0xf7f7 ), SHC( 0x7f6e ), SHC( 0xf3f5 ), + SHC( 0x7efd ), SHC( 0xeff6 ), SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x7dbb ), SHC( 0xe804 ), SHC( 0x7cea ), SHC( 0xe414 ), + SHC( 0x7bfa ), SHC( 0xe02b ), SHC( 0x7aea ), SHC( 0xdc4b ), SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x786e ), SHC( 0xd4a5 ), + SHC( 0x7702 ), SHC( 0xd0e2 ), SHC( 0x7578 ), SHC( 0xcd2b ), SHC( 0x73d1 ), SHC( 0xc981 ), SHC( 0x720c ), SHC( 0xc5e4 ), + SHC( 0x702a ), SHC( 0xc256 ), SHC( 0x6e2c ), SHC( 0xbed8 ), SHC( 0x6c12 ), SHC( 0xbb6b ), SHC( 0x69dd ), SHC( 0xb80e ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fbf ), SHC( 0xf7f7 ), SHC( 0x7efd ), SHC( 0xeff6 ), SHC( 0x7dbb ), SHC( 0xe804 ), + SHC( 0x7bfa ), SHC( 0xe02b ), SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x7702 ), SHC( 0xd0e2 ), SHC( 0x73d1 ), SHC( 0xc981 ), + SHC( 0x702a ), SHC( 0xc256 ), SHC( 0x6c12 ), SHC( 0xbb6b ), SHC( 0x678d ), SHC( 0xb4c4 ), SHC( 0x62a0 ), SHC( 0xae69 ), + SHC( 0x5d4e ), SHC( 0xa861 ), SHC( 0x579f ), SHC( 0xa2b2 ), SHC( 0x5197 ), SHC( 0x9d60 ), SHC( 0x4b3c ), SHC( 0x9873 ), + SHC( 0x4495 ), SHC( 0x93ee ), SHC( 0x3daa ), SHC( 0x8fd6 ), SHC( 0x367f ), SHC( 0x8c2f ), SHC( 0x2f1e ), SHC( 0x88fe ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f6e ), SHC( 0xf3f5 ), SHC( 0x7dbb ), SHC( 0xe804 ), SHC( 0x7aea ), SHC( 0xdc4b ), + SHC( 0x7702 ), SHC( 0xd0e2 ), SHC( 0x720c ), SHC( 0xc5e4 ), SHC( 0x6c12 ), SHC( 0xbb6b ), SHC( 0x6523 ), SHC( 0xb18d ), + SHC( 0x5d4e ), SHC( 0xa861 ), SHC( 0x54a5 ), SHC( 0x9ffd ), SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x4128 ), SHC( 0x91d4 ), + SHC( 0x367f ), SHC( 0x8c2f ), SHC( 0x2b5b ), SHC( 0x8792 ), SHC( 0x1fd5 ), SHC( 0x8406 ), SHC( 0x1406 ), SHC( 0x8194 ), + SHC( 0x0809 ), SHC( 0x8041 ), SHC( 0xfbfb ), SHC( 0x8011 ), SHC( 0xeff6 ), SHC( 0x8103 ), SHC( 0xe414 ), SHC( 0x8316 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7efd ), SHC( 0xeff6 ), SHC( 0x7bfa ), SHC( 0xe02b ), SHC( 0x7702 ), SHC( 0xd0e2 ), + SHC( 0x702a ), SHC( 0xc256 ), SHC( 0x678d ), SHC( 0xb4c4 ), SHC( 0x5d4e ), SHC( 0xa861 ), SHC( 0x5197 ), SHC( 0x9d60 ), + SHC( 0x4495 ), SHC( 0x93ee ), SHC( 0x367f ), SHC( 0x8c2f ), SHC( 0x278d ), SHC( 0x8644 ), SHC( 0x17fc ), SHC( 0x8245 ), + SHC( 0x0809 ), SHC( 0x8041 ), SHC( 0xf7f7 ), SHC( 0x8041 ), SHC( 0xe804 ), SHC( 0x8245 ), SHC( 0xd873 ), SHC( 0x8644 ), + SHC( 0xc981 ), SHC( 0x8c2f ), SHC( 0xbb6b ), SHC( 0x93ee ), SHC( 0xae69 ), SHC( 0x9d60 ), SHC( 0xa2b2 ), SHC( 0xa861 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x720c ), SHC( 0xc5e4 ), + SHC( 0x678d ), SHC( 0xb4c4 ), SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x3a1c ), SHC( 0x8df4 ), + SHC( 0x278d ), SHC( 0x8644 ), SHC( 0x1406 ), SHC( 0x8194 ), SHC( 0x0000 ), SHC( 0x8000 ), SHC( 0xebfa ), SHC( 0x8194 ), + SHC( 0xd873 ), SHC( 0x8644 ), SHC( 0xc5e4 ), SHC( 0x8df4 ), SHC( 0xb4c4 ), SHC( 0x9873 ), SHC( 0xa57e ), SHC( 0xa57e ), + SHC( 0x9873 ), SHC( 0xb4c4 ), SHC( 0x8df4 ), SHC( 0xc5e4 ), SHC( 0x8644 ), SHC( 0xd873 ), SHC( 0x8194 ), SHC( 0xebfa ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7dbb ), SHC( 0xe804 ), SHC( 0x7702 ), SHC( 0xd0e2 ), SHC( 0x6c12 ), SHC( 0xbb6b ), + SHC( 0x5d4e ), SHC( 0xa861 ), SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x367f ), SHC( 0x8c2f ), SHC( 0x1fd5 ), SHC( 0x8406 ), + SHC( 0x0809 ), SHC( 0x8041 ), SHC( 0xeff6 ), SHC( 0x8103 ), SHC( 0xd873 ), SHC( 0x8644 ), SHC( 0xc256 ), SHC( 0x8fd6 ), + SHC( 0xae69 ), SHC( 0x9d60 ), SHC( 0x9d60 ), SHC( 0xae69 ), SHC( 0x8fd6 ), SHC( 0xc256 ), SHC( 0x8644 ), SHC( 0xd873 ), + SHC( 0x8103 ), SHC( 0xeff6 ), SHC( 0x8041 ), SHC( 0x0809 ), SHC( 0x8406 ), SHC( 0x1fd5 ), SHC( 0x8c2f ), SHC( 0x367f ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7cea ), SHC( 0xe414 ), SHC( 0x73d1 ), SHC( 0xc981 ), SHC( 0x6523 ), SHC( 0xb18d ), + SHC( 0x5197 ), SHC( 0x9d60 ), SHC( 0x3a1c ), SHC( 0x8df4 ), SHC( 0x1fd5 ), SHC( 0x8406 ), SHC( 0x0405 ), SHC( 0x8011 ), + SHC( 0xe804 ), SHC( 0x8245 ), SHC( 0xcd2b ), SHC( 0x8a88 ), SHC( 0xb4c4 ), SHC( 0x9873 ), SHC( 0x9ffd ), SHC( 0xab5b ), + SHC( 0x8fd6 ), SHC( 0xc256 ), SHC( 0x8516 ), SHC( 0xdc4b ), SHC( 0x8041 ), SHC( 0xf7f7 ), SHC( 0x8194 ), SHC( 0x1406 ), + SHC( 0x88fe ), SHC( 0x2f1e ), SHC( 0x9623 ), SHC( 0x47f2 ), SHC( 0xa861 ), SHC( 0x5d4e ), SHC( 0xbed8 ), SHC( 0x6e2c ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7bfa ), SHC( 0xe02b ), SHC( 0x702a ), SHC( 0xc256 ), SHC( 0x5d4e ), SHC( 0xa861 ), + SHC( 0x4495 ), SHC( 0x93ee ), SHC( 0x278d ), SHC( 0x8644 ), SHC( 0x0809 ), SHC( 0x8041 ), SHC( 0xe804 ), SHC( 0x8245 ), + SHC( 0xc981 ), SHC( 0x8c2f ), SHC( 0xae69 ), SHC( 0x9d60 ), SHC( 0x9873 ), SHC( 0xb4c4 ), SHC( 0x88fe ), SHC( 0xd0e2 ), + SHC( 0x8103 ), SHC( 0xeff6 ), SHC( 0x8103 ), SHC( 0x100a ), SHC( 0x88fe ), SHC( 0x2f1e ), SHC( 0x9873 ), SHC( 0x4b3c ), + SHC( 0xae69 ), SHC( 0x62a0 ), SHC( 0xc981 ), SHC( 0x73d1 ), SHC( 0xe804 ), SHC( 0x7dbb ), SHC( 0x0809 ), SHC( 0x7fbf ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7aea ), SHC( 0xdc4b ), SHC( 0x6c12 ), SHC( 0xbb6b ), SHC( 0x54a5 ), SHC( 0x9ffd ), + SHC( 0x367f ), SHC( 0x8c2f ), SHC( 0x1406 ), SHC( 0x8194 ), SHC( 0xeff6 ), SHC( 0x8103 ), SHC( 0xcd2b ), SHC( 0x8a88 ), + SHC( 0xae69 ), SHC( 0x9d60 ), SHC( 0x9623 ), SHC( 0xb80e ), SHC( 0x8644 ), SHC( 0xd873 ), SHC( 0x8011 ), SHC( 0xfbfb ), + SHC( 0x8406 ), SHC( 0x1fd5 ), SHC( 0x91d4 ), SHC( 0x4128 ), SHC( 0xa861 ), SHC( 0x5d4e ), SHC( 0xc5e4 ), SHC( 0x720c ), + SHC( 0xe804 ), SHC( 0x7dbb ), SHC( 0x0c0b ), SHC( 0x7f6e ), SHC( 0x2f1e ), SHC( 0x7702 ), SHC( 0x4e73 ), SHC( 0x6523 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7ffb ), SHC( 0xfdfe ), SHC( 0x7fef ), SHC( 0xfbfb ), SHC( 0x7fdb ), SHC( 0xf9f9 ), + SHC( 0x7fbf ), SHC( 0xf7f7 ), SHC( 0x7f9a ), SHC( 0xf5f6 ), SHC( 0x7f6e ), SHC( 0xf3f5 ), SHC( 0x7f3a ), SHC( 0xf1f5 ), + SHC( 0x7efd ), SHC( 0xeff6 ), SHC( 0x7eb9 ), SHC( 0xedf7 ), SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x7e18 ), SHC( 0xe9ff ), + SHC( 0x7dbb ), SHC( 0xe804 ), SHC( 0x7d57 ), SHC( 0xe60c ), SHC( 0x7cea ), SHC( 0xe414 ), SHC( 0x7c76 ), SHC( 0xe21f ), + SHC( 0x7bfa ), SHC( 0xe02b ), SHC( 0x7b76 ), SHC( 0xde3a ), SHC( 0x7aea ), SHC( 0xdc4b ), SHC( 0x7a57 ), SHC( 0xda5d ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fdb ), SHC( 0xf9f9 ), SHC( 0x7f6e ), SHC( 0xf3f5 ), SHC( 0x7eb9 ), SHC( 0xedf7 ), + SHC( 0x7dbb ), SHC( 0xe804 ), SHC( 0x7c76 ), SHC( 0xe21f ), SHC( 0x7aea ), SHC( 0xdc4b ), SHC( 0x7919 ), SHC( 0xd68a ), + SHC( 0x7702 ), SHC( 0xd0e2 ), SHC( 0x74a8 ), SHC( 0xcb54 ), SHC( 0x720c ), SHC( 0xc5e4 ), SHC( 0x6f2f ), SHC( 0xc095 ), + SHC( 0x6c12 ), SHC( 0xbb6b ), SHC( 0x68b9 ), SHC( 0xb667 ), SHC( 0x6523 ), SHC( 0xb18d ), SHC( 0x6154 ), SHC( 0xacdf ), + SHC( 0x5d4e ), SHC( 0xa861 ), SHC( 0x5913 ), SHC( 0xa415 ), SHC( 0x54a5 ), SHC( 0x9ffd ), SHC( 0x5007 ), SHC( 0x9c1b ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f9a ), SHC( 0xf5f6 ), SHC( 0x7e6c ), SHC( 0xebfa ), SHC( 0x7c76 ), SHC( 0xe21f ), + SHC( 0x79bc ), SHC( 0xd873 ), SHC( 0x7641 ), SHC( 0xcf05 ), SHC( 0x720c ), SHC( 0xc5e4 ), SHC( 0x6d23 ), SHC( 0xbd1f ), + SHC( 0x678d ), SHC( 0xb4c4 ), SHC( 0x6154 ), SHC( 0xacdf ), SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x5321 ), SHC( 0x9eac ), + SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x42e1 ), SHC( 0x92dd ), SHC( 0x3a1c ), SHC( 0x8df4 ), SHC( 0x30fb ), SHC( 0x89bf ), + SHC( 0x278d ), SHC( 0x8644 ), SHC( 0x1de1 ), SHC( 0x838a ), SHC( 0x1406 ), SHC( 0x8194 ), SHC( 0x0a0a ), SHC( 0x8066 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f3a ), SHC( 0xf1f5 ), SHC( 0x7cea ), SHC( 0xe414 ), SHC( 0x7919 ), SHC( 0xd68a ), + SHC( 0x73d1 ), SHC( 0xc981 ), SHC( 0x6d23 ), SHC( 0xbd1f ), SHC( 0x6523 ), SHC( 0xb18d ), SHC( 0x5beb ), SHC( 0xa6ed ), + SHC( 0x5197 ), SHC( 0x9d60 ), SHC( 0x4646 ), SHC( 0x9505 ), SHC( 0x3a1c ), SHC( 0x8df4 ), SHC( 0x2d3e ), SHC( 0x8844 ), + SHC( 0x1fd5 ), SHC( 0x8406 ), SHC( 0x1209 ), SHC( 0x8147 ), SHC( 0x0405 ), SHC( 0x8011 ), SHC( 0xf5f6 ), SHC( 0x8066 ), + SHC( 0xe804 ), SHC( 0x8245 ), SHC( 0xda5d ), SHC( 0x85a9 ), SHC( 0xcd2b ), SHC( 0x8a88 ), SHC( 0xc095 ), SHC( 0x90d1 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7eb9 ), SHC( 0xedf7 ), SHC( 0x7aea ), SHC( 0xdc4b ), SHC( 0x74a8 ), SHC( 0xcb54 ), + SHC( 0x6c12 ), SHC( 0xbb6b ), SHC( 0x6154 ), SHC( 0xacdf ), SHC( 0x54a5 ), SHC( 0x9ffd ), SHC( 0x4646 ), SHC( 0x9505 ), + SHC( 0x367f ), SHC( 0x8c2f ), SHC( 0x25a3 ), SHC( 0x85a9 ), SHC( 0x1406 ), SHC( 0x8194 ), SHC( 0x0202 ), SHC( 0x8005 ), + SHC( 0xeff6 ), SHC( 0x8103 ), SHC( 0xde3a ), SHC( 0x848a ), SHC( 0xcd2b ), SHC( 0x8a88 ), SHC( 0xbd1f ), SHC( 0x92dd ), + SHC( 0xae69 ), SHC( 0x9d60 ), SHC( 0xa154 ), SHC( 0xa9db ), SHC( 0x9623 ), SHC( 0xb80e ), SHC( 0x8d0e ), SHC( 0xc7b1 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7e18 ), SHC( 0xe9ff ), SHC( 0x786e ), SHC( 0xd4a5 ), SHC( 0x6f2f ), SHC( 0xc095 ), + SHC( 0x62a0 ), SHC( 0xae69 ), SHC( 0x5321 ), SHC( 0x9eac ), SHC( 0x4128 ), SHC( 0x91d4 ), SHC( 0x2d3e ), SHC( 0x8844 ), + SHC( 0x17fc ), SHC( 0x8245 ), SHC( 0x0202 ), SHC( 0x8005 ), SHC( 0xebfa ), SHC( 0x8194 ), SHC( 0xd68a ), SHC( 0x86e7 ), + SHC( 0xc256 ), SHC( 0x8fd6 ), SHC( 0xaff9 ), SHC( 0x9c1b ), SHC( 0x9ffd ), SHC( 0xab5b ), SHC( 0x92dd ), SHC( 0xbd1f ), + SHC( 0x88fe ), SHC( 0xd0e2 ), SHC( 0x82a9 ), SHC( 0xe60c ), SHC( 0x8011 ), SHC( 0xfbfb ), SHC( 0x8147 ), SHC( 0x1209 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7d57 ), SHC( 0xe60c ), SHC( 0x7578 ), SHC( 0xcd2b ), SHC( 0x68b9 ), SHC( 0xb667 ), + SHC( 0x579f ), SHC( 0xa2b2 ), SHC( 0x42e1 ), SHC( 0x92dd ), SHC( 0x2b5b ), SHC( 0x8792 ), SHC( 0x1209 ), SHC( 0x8147 ), + SHC( 0xf7f7 ), SHC( 0x8041 ), SHC( 0xde3a ), SHC( 0x848a ), SHC( 0xc5e4 ), SHC( 0x8df4 ), SHC( 0xaff9 ), SHC( 0x9c1b ), + SHC( 0x9d60 ), SHC( 0xae69 ), SHC( 0x8ee1 ), SHC( 0xc41b ), SHC( 0x8516 ), SHC( 0xdc4b ), SHC( 0x8066 ), SHC( 0xf5f6 ), + SHC( 0x8103 ), SHC( 0x100a ), SHC( 0x86e7 ), SHC( 0x2976 ), SHC( 0x91d4 ), SHC( 0x4128 ), SHC( 0xa154 ), SHC( 0x5625 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7c76 ), SHC( 0xe21f ), SHC( 0x720c ), SHC( 0xc5e4 ), SHC( 0x6154 ), SHC( 0xacdf ), + SHC( 0x4b3c ), SHC( 0x9873 ), SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0x1406 ), SHC( 0x8194 ), SHC( 0xf5f6 ), SHC( 0x8066 ), + SHC( 0xd873 ), SHC( 0x8644 ), SHC( 0xbd1f ), SHC( 0x92dd ), SHC( 0xa57e ), SHC( 0xa57e ), SHC( 0x92dd ), SHC( 0xbd1f ), + SHC( 0x8644 ), SHC( 0xd873 ), SHC( 0x8066 ), SHC( 0xf5f6 ), SHC( 0x8194 ), SHC( 0x1406 ), SHC( 0x89bf ), SHC( 0x30fb ), + SHC( 0x9873 ), SHC( 0x4b3c ), SHC( 0xacdf ), SHC( 0x6154 ), SHC( 0xc5e4 ), SHC( 0x720c ), SHC( 0xe21f ), SHC( 0x7c76 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7b76 ), SHC( 0xde3a ), SHC( 0x6e2c ), SHC( 0xbed8 ), SHC( 0x5913 ), SHC( 0xa415 ), + SHC( 0x3daa ), SHC( 0x8fd6 ), SHC( 0x1de1 ), SHC( 0x838a ), SHC( 0xfbfb ), SHC( 0x8011 ), SHC( 0xda5d ), SHC( 0x85a9 ), + SHC( 0xbb6b ), SHC( 0x93ee ), SHC( 0xa154 ), SHC( 0xa9db ), SHC( 0x8df4 ), SHC( 0xc5e4 ), SHC( 0x82a9 ), SHC( 0xe60c ), + SHC( 0x8041 ), SHC( 0x0809 ), SHC( 0x86e7 ), SHC( 0x2976 ), SHC( 0x9623 ), SHC( 0x47f2 ), SHC( 0xacdf ), SHC( 0x6154 ), + SHC( 0xc981 ), SHC( 0x73d1 ), SHC( 0xe9ff ), SHC( 0x7e18 ), SHC( 0x0c0b ), SHC( 0x7f6e ), SHC( 0x2d3e ), SHC( 0x77bc ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7a57 ), SHC( 0xda5d ), SHC( 0x69dd ), SHC( 0xb80e ), SHC( 0x5007 ), SHC( 0x9c1b ), + SHC( 0x2f1e ), SHC( 0x88fe ), SHC( 0x0a0a ), SHC( 0x8066 ), SHC( 0xe414 ), SHC( 0x8316 ), SHC( 0xc095 ), SHC( 0x90d1 ), + SHC( 0xa2b2 ), SHC( 0xa861 ), SHC( 0x8d0e ), SHC( 0xc7b1 ), SHC( 0x8194 ), SHC( 0xebfa ), SHC( 0x8147 ), SHC( 0x1209 ), + SHC( 0x8c2f ), SHC( 0x367f ), SHC( 0xa154 ), SHC( 0x5625 ), SHC( 0xbed8 ), SHC( 0x6e2c ), SHC( 0xe21f ), SHC( 0x7c76 ), + SHC( 0x0809 ), SHC( 0x7fbf ), SHC( 0x2d3e ), SHC( 0x77bc ), SHC( 0x4e73 ), SHC( 0x6523 ), SHC( 0x68b9 ), SHC( 0x4999 ), +}; + +const Word16 FFT_RotVector_256_fx[ 448 ] = { + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7ff6 ), SHC( 0xfcdc ), SHC( 0x7fd8 ), SHC( 0xf9b9 ), SHC( 0x7fa7 ), SHC( 0xf696 ), + SHC( 0x7f62 ), SHC( 0xf375 ), SHC( 0x7f09 ), SHC( 0xf055 ), SHC( 0x7e9d ), SHC( 0xed38 ), SHC( 0x7e1d ), SHC( 0xea1e ), + SHC( 0x7d8a ), SHC( 0xe708 ), SHC( 0x7ce3 ), SHC( 0xe3f5 ), SHC( 0x7c29 ), SHC( 0xe0e7 ), SHC( 0x7b5d ), SHC( 0xdddd ), + SHC( 0x7a7d ), SHC( 0xdad8 ), SHC( 0x798a ), SHC( 0xd7da ), SHC( 0x7884 ), SHC( 0xd4e1 ), SHC( 0x776c ), SHC( 0xd1ef ), + SHC( 0x7641 ), SHC( 0xcf05 ), SHC( 0x7504 ), SHC( 0xcc22 ), SHC( 0x73b5 ), SHC( 0xc946 ), SHC( 0x7255 ), SHC( 0xc674 ), + SHC( 0x70e2 ), SHC( 0xc3aa ), SHC( 0x6f5f ), SHC( 0xc0e9 ), SHC( 0x6dca ), SHC( 0xbe32 ), SHC( 0x6c24 ), SHC( 0xbb86 ), + SHC( 0x6a6d ), SHC( 0xb8e4 ), SHC( 0x68a6 ), SHC( 0xb64c ), SHC( 0x66cf ), SHC( 0xb3c1 ), SHC( 0x64e8 ), SHC( 0xb141 ), + SHC( 0x62f2 ), SHC( 0xaecd ), SHC( 0x60ec ), SHC( 0xac65 ), SHC( 0x5ed7 ), SHC( 0xaa0b ), SHC( 0x5cb4 ), SHC( 0xa7be ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fd8 ), SHC( 0xf9b9 ), SHC( 0x7f62 ), SHC( 0xf375 ), SHC( 0x7e9d ), SHC( 0xed38 ), + SHC( 0x7d8a ), SHC( 0xe708 ), SHC( 0x7c29 ), SHC( 0xe0e7 ), SHC( 0x7a7d ), SHC( 0xdad8 ), SHC( 0x7884 ), SHC( 0xd4e1 ), + SHC( 0x7641 ), SHC( 0xcf05 ), SHC( 0x73b5 ), SHC( 0xc946 ), SHC( 0x70e2 ), SHC( 0xc3aa ), SHC( 0x6dca ), SHC( 0xbe32 ), + SHC( 0x6a6d ), SHC( 0xb8e4 ), SHC( 0x66cf ), SHC( 0xb3c1 ), SHC( 0x62f2 ), SHC( 0xaecd ), SHC( 0x5ed7 ), SHC( 0xaa0b ), + SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x55f5 ), SHC( 0xa129 ), SHC( 0x5133 ), SHC( 0x9d0e ), SHC( 0x4c3f ), SHC( 0x9931 ), + SHC( 0x471c ), SHC( 0x9593 ), SHC( 0x41ce ), SHC( 0x9236 ), SHC( 0x3c56 ), SHC( 0x8f1e ), SHC( 0x36ba ), SHC( 0x8c4b ), + SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0x2b1f ), SHC( 0x877c ), SHC( 0x2528 ), SHC( 0x8583 ), SHC( 0x1f19 ), SHC( 0x83d7 ), + SHC( 0x18f8 ), SHC( 0x8276 ), SHC( 0x12c8 ), SHC( 0x8163 ), SHC( 0x0c8b ), SHC( 0x809e ), SHC( 0x0647 ), SHC( 0x8028 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7fa7 ), SHC( 0xf696 ), SHC( 0x7e9d ), SHC( 0xed38 ), SHC( 0x7ce3 ), SHC( 0xe3f5 ), + SHC( 0x7a7d ), SHC( 0xdad8 ), SHC( 0x776c ), SHC( 0xd1ef ), SHC( 0x73b5 ), SHC( 0xc946 ), SHC( 0x6f5f ), SHC( 0xc0e9 ), + SHC( 0x6a6d ), SHC( 0xb8e4 ), SHC( 0x64e8 ), SHC( 0xb141 ), SHC( 0x5ed7 ), SHC( 0xaa0b ), SHC( 0x5842 ), SHC( 0xa34c ), + SHC( 0x5133 ), SHC( 0x9d0e ), SHC( 0x49b4 ), SHC( 0x975a ), SHC( 0x41ce ), SHC( 0x9236 ), SHC( 0x398c ), SHC( 0x8dab ), + SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0x2826 ), SHC( 0x8676 ), SHC( 0x1f19 ), SHC( 0x83d7 ), SHC( 0x15e2 ), SHC( 0x81e3 ), + SHC( 0x0c8b ), SHC( 0x809e ), SHC( 0x0324 ), SHC( 0x800a ), SHC( 0xf9b9 ), SHC( 0x8028 ), SHC( 0xf055 ), SHC( 0x80f7 ), + SHC( 0xe708 ), SHC( 0x8276 ), SHC( 0xdddd ), SHC( 0x84a3 ), SHC( 0xd4e1 ), SHC( 0x877c ), SHC( 0xcc22 ), SHC( 0x8afc ), + SHC( 0xc3aa ), SHC( 0x8f1e ), SHC( 0xbb86 ), SHC( 0x93dc ), SHC( 0xb3c1 ), SHC( 0x9931 ), SHC( 0xac65 ), SHC( 0x9f14 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f62 ), SHC( 0xf375 ), SHC( 0x7d8a ), SHC( 0xe708 ), SHC( 0x7a7d ), SHC( 0xdad8 ), + SHC( 0x7641 ), SHC( 0xcf05 ), SHC( 0x70e2 ), SHC( 0xc3aa ), SHC( 0x6a6d ), SHC( 0xb8e4 ), SHC( 0x62f2 ), SHC( 0xaecd ), + SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x5133 ), SHC( 0x9d0e ), SHC( 0x471c ), SHC( 0x9593 ), SHC( 0x3c56 ), SHC( 0x8f1e ), + SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0x2528 ), SHC( 0x8583 ), SHC( 0x18f8 ), SHC( 0x8276 ), SHC( 0x0c8b ), SHC( 0x809e ), + SHC( 0x0000 ), SHC( 0x8000 ), SHC( 0xf375 ), SHC( 0x809e ), SHC( 0xe708 ), SHC( 0x8276 ), SHC( 0xdad8 ), SHC( 0x8583 ), + SHC( 0xcf05 ), SHC( 0x89bf ), SHC( 0xc3aa ), SHC( 0x8f1e ), SHC( 0xb8e4 ), SHC( 0x9593 ), SHC( 0xaecd ), SHC( 0x9d0e ), + SHC( 0xa57e ), SHC( 0xa57e ), SHC( 0x9d0e ), SHC( 0xaecd ), SHC( 0x9593 ), SHC( 0xb8e4 ), SHC( 0x8f1e ), SHC( 0xc3aa ), + SHC( 0x89bf ), SHC( 0xcf05 ), SHC( 0x8583 ), SHC( 0xdad8 ), SHC( 0x8276 ), SHC( 0xe708 ), SHC( 0x809e ), SHC( 0xf375 ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7f09 ), SHC( 0xf055 ), SHC( 0x7c29 ), SHC( 0xe0e7 ), SHC( 0x776c ), SHC( 0xd1ef ), + SHC( 0x70e2 ), SHC( 0xc3aa ), SHC( 0x68a6 ), SHC( 0xb64c ), SHC( 0x5ed7 ), SHC( 0xaa0b ), SHC( 0x539b ), SHC( 0x9f14 ), + SHC( 0x471c ), SHC( 0x9593 ), SHC( 0x398c ), SHC( 0x8dab ), SHC( 0x2b1f ), SHC( 0x877c ), SHC( 0x1c0b ), SHC( 0x831d ), + SHC( 0x0c8b ), SHC( 0x809e ), SHC( 0xfcdc ), SHC( 0x800a ), SHC( 0xed38 ), SHC( 0x8163 ), SHC( 0xdddd ), SHC( 0x84a3 ), + SHC( 0xcf05 ), SHC( 0x89bf ), SHC( 0xc0e9 ), SHC( 0x90a1 ), SHC( 0xb3c1 ), SHC( 0x9931 ), SHC( 0xa7be ), SHC( 0xa34c ), + SHC( 0x9d0e ), SHC( 0xaecd ), SHC( 0x93dc ), SHC( 0xbb86 ), SHC( 0x8c4b ), SHC( 0xc946 ), SHC( 0x8676 ), SHC( 0xd7da ), + SHC( 0x8276 ), SHC( 0xe708 ), SHC( 0x8059 ), SHC( 0xf696 ), SHC( 0x8028 ), SHC( 0x0647 ), SHC( 0x81e3 ), SHC( 0x15e2 ), + SHC( 0x8583 ), SHC( 0x2528 ), SHC( 0x8afc ), SHC( 0x33de ), SHC( 0x9236 ), SHC( 0x41ce ), SHC( 0x9b18 ), SHC( 0x4ebf ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7e9d ), SHC( 0xed38 ), SHC( 0x7a7d ), SHC( 0xdad8 ), SHC( 0x73b5 ), SHC( 0xc946 ), + SHC( 0x6a6d ), SHC( 0xb8e4 ), SHC( 0x5ed7 ), SHC( 0xaa0b ), SHC( 0x5133 ), SHC( 0x9d0e ), SHC( 0x41ce ), SHC( 0x9236 ), + SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0x1f19 ), SHC( 0x83d7 ), SHC( 0x0c8b ), SHC( 0x809e ), SHC( 0xf9b9 ), SHC( 0x8028 ), + SHC( 0xe708 ), SHC( 0x8276 ), SHC( 0xd4e1 ), SHC( 0x877c ), SHC( 0xc3aa ), SHC( 0x8f1e ), SHC( 0xb3c1 ), SHC( 0x9931 ), + SHC( 0xa57e ), SHC( 0xa57e ), SHC( 0x9931 ), SHC( 0xb3c1 ), SHC( 0x8f1e ), SHC( 0xc3aa ), SHC( 0x877c ), SHC( 0xd4e1 ), + SHC( 0x8276 ), SHC( 0xe708 ), SHC( 0x8028 ), SHC( 0xf9b9 ), SHC( 0x809e ), SHC( 0x0c8b ), SHC( 0x83d7 ), SHC( 0x1f19 ), + SHC( 0x89bf ), SHC( 0x30fb ), SHC( 0x9236 ), SHC( 0x41ce ), SHC( 0x9d0e ), SHC( 0x5133 ), SHC( 0xaa0b ), SHC( 0x5ed7 ), + SHC( 0xb8e4 ), SHC( 0x6a6d ), SHC( 0xc946 ), SHC( 0x73b5 ), SHC( 0xdad8 ), SHC( 0x7a7d ), SHC( 0xed38 ), SHC( 0x7e9d ), + SHC( 0x7fff ), SHC( 0x0000 ), SHC( 0x7e1d ), SHC( 0xea1e ), SHC( 0x7884 ), SHC( 0xd4e1 ), SHC( 0x6f5f ), SHC( 0xc0e9 ), + SHC( 0x62f2 ), SHC( 0xaecd ), SHC( 0x539b ), SHC( 0x9f14 ), SHC( 0x41ce ), SHC( 0x9236 ), SHC( 0x2e11 ), SHC( 0x8894 ), + SHC( 0x18f8 ), SHC( 0x8276 ), SHC( 0x0324 ), SHC( 0x800a ), SHC( 0xed38 ), SHC( 0x8163 ), SHC( 0xd7da ), SHC( 0x8676 ), + SHC( 0xc3aa ), SHC( 0x8f1e ), SHC( 0xb141 ), SHC( 0x9b18 ), SHC( 0xa129 ), SHC( 0xaa0b ), SHC( 0x93dc ), SHC( 0xbb86 ), + SHC( 0x89bf ), SHC( 0xcf05 ), SHC( 0x831d ), SHC( 0xe3f5 ), SHC( 0x8028 ), SHC( 0xf9b9 ), SHC( 0x80f7 ), SHC( 0x0fab ), + SHC( 0x8583 ), SHC( 0x2528 ), SHC( 0x8dab ), SHC( 0x398c ), SHC( 0x9931 ), SHC( 0x4c3f ), SHC( 0xa7be ), SHC( 0x5cb4 ), + SHC( 0xb8e4 ), SHC( 0x6a6d ), SHC( 0xcc22 ), SHC( 0x7504 ), SHC( 0xe0e7 ), SHC( 0x7c29 ), SHC( 0xf696 ), SHC( 0x7fa7 ), + SHC( 0x0c8b ), SHC( 0x7f62 ), SHC( 0x2223 ), SHC( 0x7b5d ), SHC( 0x36ba ), SHC( 0x73b5 ), SHC( 0x49b4 ), SHC( 0x68a6 ), +}; + +const Word16 FFT_RotVector_32_fx[ 40 ] = { + SHC( 0x7d8a ), SHC( 0xe708 ), SHC( 0x7641 ), SHC( 0xcf05 ), SHC( 0x6a6d ), SHC( 0xb8e4 ), SHC( 0x5a82 ), SHC( 0xa57e ), + SHC( 0x471c ), SHC( 0x9593 ), SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0x18f8 ), SHC( 0x8276 ), SHC( 0x7641 ), SHC( 0xcf05 ), + SHC( 0x5a82 ), SHC( 0xa57e ), SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0xcf05 ), SHC( 0x89bf ), SHC( 0xa57e ), SHC( 0xa57e ), + SHC( 0x89bf ), SHC( 0xcf05 ), SHC( 0x6a6d ), SHC( 0xb8e4 ), SHC( 0x30fb ), SHC( 0x89bf ), SHC( 0xe708 ), SHC( 0x8276 ), + SHC( 0xa57e ), SHC( 0xa57e ), SHC( 0x8276 ), SHC( 0xe708 ), SHC( 0x89bf ), SHC( 0x30fb ), SHC( 0xb8e4 ), SHC( 0x6a6d ), +}; + +const Word16 cos_twiddle_table_25_5_5[ 25 ] = { + SHC( 0x7fff ), SHC( 0x7fff ), SHC( 0x7fff ), SHC( 0x7fff ), SHC( 0x7fff ), + SHC( 0x7fff ), SHC( 0x7bfa ), SHC( 0x702a ), SHC( 0x5d4e ), SHC( 0x4495 ), + SHC( 0x7fff ), SHC( 0x702a ), SHC( 0x4495 ), SHC( 0x0809 ), SHC( 0xc981 ), + SHC( 0x7fff ), SHC( 0x5d4e ), SHC( 0x0809 ), SHC( 0xae69 ), SHC( 0x8103 ), + SHC( 0x7fff ), SHC( 0x4495 ), SHC( 0xc981 ), SHC( 0x8103 ), SHC( 0xae69 ), +}; +const Word16 sin_twiddle_table_25_5_5[ 25 ] = { + SHC( 0x0000 ), SHC( 0x0000 ), SHC( 0x0000 ), SHC( 0x0000 ), SHC( 0x0000 ), + SHC( 0x0000 ), SHC( 0xe02b ), SHC( 0xc256 ), SHC( 0xa861 ), SHC( 0x93ee ), + SHC( 0x0000 ), SHC( 0xc256 ), SHC( 0x93ee ), SHC( 0x8041 ), SHC( 0x8c2f ), + SHC( 0x0000 ), SHC( 0xa861 ), SHC( 0x8041 ), SHC( 0x9d60 ), SHC( 0xeff6 ), + SHC( 0x0000 ), SHC( 0x93ee ), SHC( 0x8c2f ), SHC( 0xeff6 ), SHC( 0x62a0 ), +}; +const Word16 cos_twiddle_table_16_8_2[ 16 ] = { + SHC( 0x7fff ), SHC( 0x7fff ), + SHC( 0x7fff ), SHC( 0x7641 ), + SHC( 0x7fff ), SHC( 0x5a82 ), + SHC( 0x7fff ), SHC( 0x30fb ), + SHC( 0x7fff ), SHC( 0x0000 ), + SHC( 0x7fff ), SHC( 0xcf05 ), + SHC( 0x7fff ), SHC( 0xa57e ), + SHC( 0x7fff ), SHC( 0x89bf ), +}; +const Word16 sin_twiddle_table_16_8_2[ 16 ] = { + SHC( 0x0000 ), SHC( 0x0000 ), + SHC( 0x0000 ), SHC( 0xcf05 ), + SHC( 0x0000 ), SHC( 0xa57e ), + SHC( 0x0000 ), SHC( 0x89bf ), + SHC( 0x0000 ), SHC( 0x8000 ), + SHC( 0x0000 ), SHC( 0x89bf ), + SHC( 0x0000 ), SHC( 0xa57e ), + SHC( 0x0000 ), SHC( 0xcf05 ), +}; + + + diff --git a/lib_com/rom_com_fx.h b/lib_com/rom_com_fx.h new file mode 100644 index 000000000..62fd8d250 --- /dev/null +++ b/lib_com/rom_com_fx.h @@ -0,0 +1,70 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +/*==================================================================================== + 3GPP TS26.258 Aug 24, 2023. IVAS Codec Version IVAS-FL-1.0 + ====================================================================================*/ + +/*==================================================================================== + EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 + ====================================================================================*/ + +#ifndef ROM_COM_FX_H +#define ROM_COM_FX_H +/*------------------------------------------------------------------------------* + * FFT transform + *------------------------------------------------------------------------------*/ + +extern const Word16 w_fft64_fx[32]; +extern const Word16 w_fft32_fx[16]; +extern const Word16 w_fft16_fx[8]; +extern const Word16 w_fft8_fx[8]; +extern const Word16 w_fft128_fx[64]; +extern const Word16 w_fft256_fx[128]; +extern const Word16 w_fft512_fx[256]; +extern const Word16 w_fft4_fx[2]; + +extern const Word16 FFT_RotVector_960_fx[1860]; +extern const Word16 FFT_RotVector_640_fx[1240]; +extern const Word16 FFT_RotVector_600_fx[1140]; +extern const Word16 FFT_RotVector_400_fx[760]; +extern const Word16 FFT_RotVector_256_fx[448]; +extern const Word16 FFT_RotVector_32_fx[40]; + +extern const Word16 sincos_t_rad3_fx[T_SIN_PI_2 + 1]; + +extern const Word16 cos_twiddle_table_25_5_5[ 25 ]; +extern const Word16 sin_twiddle_table_25_5_5[ 25 ]; +extern const Word16 cos_twiddle_table_16_8_2[ 16 ]; +extern const Word16 sin_twiddle_table_16_8_2[ 16 ]; + +#endif diff --git a/lib_com/scale_mem_fx.c b/lib_com/scale_mem_fx.c new file mode 100644 index 000000000..1b7f34b37 --- /dev/null +++ b/lib_com/scale_mem_fx.c @@ -0,0 +1,378 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +/*==================================================================================== + EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 + ====================================================================================*/ + +#include "options.h" /* Common prototypes */ +#include "prot_fx2.h" /* Common prototypes */ +#include "ivas_cnst.h" +#include "stl.h" + + /*-------------------------------------------------------------------* + * Rescale_exc: + * + * Find absolute maximum of excitation + * Fin scaling factor to apply the excitation and its related memory + * Scale excitation and total excitation (exc2) + *-------------------------------------------------------------------*/ +Word16 Rescale_exc( + Word16 dct_post_old_exc_fx[], /* i/o: Music post processing memory */ + Word16 exc[], /* i/o: excitation to rescale Q_exc */ + Word16 bwe_exc[], + Word16 *last_exc_dct_in, + Word16 lg, /* i : frame size */ + Word16 lg32, + Word32 L_gain_code, /* i : decoded codebook gain Q16 */ + Word16 *sQ_exc, /* i/o: Excitation scaling factor */ + Word16 *sQsubfr, /* i/o: Past excitation scaling factors */ + Word16 exc2[], /* o : local excitation vector */ + Word16 i_subfr, /* i : subframe number */ + const Word16 coder_type +) +{ + Word16 i, tmp, max, new_Q; + + /*------------------------------------------- + * find maximum of absolute excitation + *-------------------------------------------*/ + max = s_max(abs_s(exc[0]), 1); + FOR(i = 1; i < lg; i++) + { + tmp = abs_s(exc[i]); + max = s_max(max, tmp); + } + + /*---------------------------------------------- + * find scaling (tmp) to set max = [2048..4096[ + *----------------------------------------------*/ + tmp = sub(add(norm_s(max), *sQ_exc), 3); + tmp = s_min(tmp, 12); + + /*---------------------------------------------- + * find scaling (new_Q) to keep gain_code < 2048 + *----------------------------------------------*/ + + new_Q = add(tmp, 1); + tmp = sub(norm_l(L_or(L_gain_code, 1)), 3); /* to get to 0x08000000L (L_or with 1 to avoid norm_l(0)) */ + tmp = s_min(tmp, new_Q); + tmp = s_max(tmp, 0); + tmp = sub(tmp, 1); + + /*#define REMOVE_EXCITATION_PER_FRAME_SCALING */ + + /*---------------------------------------------- + * new_Q = smallest Q since 4 subframes (20ms) + *----------------------------------------------*/ + IF(EQ_16(coder_type, TRANSITION)) + { + tmp = s_min(tmp, 7); + } + ELSE IF(EQ_16(coder_type, INACTIVE)) + { + tmp = s_min(tmp, 13); + } + ELSE IF(GT_16(lg, L_SUBFR))/* --> can only happen in AUDIO mode */ + { + tmp = s_min(tmp, 4); /* Limitation of the scaling gain because the frequency domain will add much more energy to the excitation*/ + if (GE_32(L_abs(L_gain_code), 3276800)) /*(1-gain_pit)*past gain code*4 > 50 */ + { + tmp = s_min(tmp, 2); /* Limitation of the scaling gain because the frequency domain might add much more energy to the excitation*/ + } + } + + new_Q = s_min(tmp, sQsubfr[0]); + IF(EQ_16(lg, L_SUBFR)) + { + FOR(i = L_Q_MEM - 1; i >= 1; i--) + { + new_Q = s_min(new_Q, sQsubfr[i]); + sQsubfr[i] = sQsubfr[i - 1]; + move16(); + } + } + ELSE + { + IF(EQ_16(lg, 2 * L_SUBFR)) + { + new_Q = s_min(new_Q, sQsubfr[L_Q_MEM - 1]); + FOR(i = L_Q_MEM - 1; i >= 2; i--) + { + sQsubfr[i] = sQsubfr[1]; + move16(); + } + sQsubfr[1] = tmp; + move16(); + sQsubfr[0] = tmp; + move16(); + } + ELSE + { + set16_fx(sQsubfr, tmp, L_Q_MEM); + } + } + sQsubfr[0] = tmp; + move16(); + + /*---------------------------------------------- + * rescale excitation and associated memories + *----------------------------------------------*/ + + tmp = sub(new_Q, *sQ_exc); + + IF(tmp != 0) + { + + Scale_sig(exc - L_EXC_MEM_DEC, add(L_EXC_MEM_DEC, lg), tmp); + IF(last_exc_dct_in != NULL) + { + Scale_sig(last_exc_dct_in, L_FRAME, tmp); + } + IF(bwe_exc != NULL) + { + Scale_sig(bwe_exc - PIT16k_MAX * 2, add(PIT16k_MAX * 2, lg32), tmp); + } + IF(exc2 != NULL) + { + Scale_sig(exc2, i_subfr, tmp); + } + IF(dct_post_old_exc_fx != NULL) + { + Scale_sig(dct_post_old_exc_fx, DCT_L_POST - OFFSET2, tmp); + } + } + + /* scaling factor of excitation (-1..12) */ + *sQ_exc = new_Q; + move16(); + + return tmp; +} + +/*-------------------------------------------------------------------* + * Rescale_mem: + * + * this function should be called after excitation update (4 subfr) and before frame synthesis + * Rescale excitation related memories + *-------------------------------------------------------------------*/ +void Rescale_mem( + const Word16 Q_exc, /* i : current excitation scaling (>=0) */ + Word16 *prev_Q_syn, /* i/o : scaling factor of previous frame */ + Word16 *Q_syn, /* i/o : scaling factor of frame */ + Word16 *mem_syn2, /* i/o : modified synthesis memory */ + Word16 *mem_syn_clas_estim_fx, /* i/o : old 12k8 core memory for classification */ + const Word16 MaxScaling, /* i: Minimal difference between excitation scaling and synthesis scaling */ + Word16 *mem_deemph, /* i/o: speech deemph filter memory */ + Word16 *pst_old_syn, /* i/o: psfiler */ + Word16 *pst_mem_deemp_err, /* i/o: psfiler */ + Word16 *mem_agc, + PFSTAT_HANDLE hPFstat, /* i/o: All memories related to NB post filter */ + const Word16 Vad_flag, + const Word16 Cna_flag, + const Word16 *tmp_buffer /* tmp_buffer in Q-1 */ +) +{ + Word16 exp_scale, new_Q, tmp, i; + + /*-------------------------------------------------------------------* + * find scaling of synthesis (based on min of current frame and last frame) + * scaling factor of synthesis (-1..6) + *-------------------------------------------------------------------*/ + new_Q = sub(Q_exc, MaxScaling); + tmp = 1; + move16(); + IF(tmp_buffer != NULL) + { + /* use the temporary synthesis in Q-1 to estimate the scaling */ + FOR(i = 0; i < L_FRAME; i++) + { + tmp = s_max(abs_s(tmp_buffer[i]), tmp); + } + /* we add Q_syn which represents the actual scaling of the memories prev_Q_syn represents the last potential scaling */ + tmp = sub(add(norm_s(tmp), -1), 3); /* -2 ... 12 */ + } + ELSE + { + FOR(i = 0; i < M; i++) + { + tmp = s_max(abs_s(mem_syn2[i]), tmp); + tmp = s_max(abs_s(pst_old_syn[i]), tmp); + tmp = s_max(abs_s(mem_syn_clas_estim_fx[i]), tmp); + } + FOR(; i < L_SUBFR; i++) + { + tmp = s_max(abs_s(pst_old_syn[i]), tmp); + tmp = s_max(abs_s(mem_syn_clas_estim_fx[i]), tmp); + } + FOR(; i < L_SYN_MEM_CLAS_ESTIM; i++) + { + tmp = s_max(abs_s(mem_syn_clas_estim_fx[i]), tmp); + tmp = s_max(abs_s(pst_old_syn[i]), tmp); + } + FOR(; i < NBPSF_PIT_MAX; i++) + { + tmp = s_max(abs_s(pst_old_syn[i]), tmp); + } + /* we add Q_syn which represents the actual scaling of the memories prev_Q_syn represents the last potential scaling */ + tmp = sub(add(norm_s(tmp), *Q_syn), 2); /* -2 ... 12 */ + } + + + IF(Vad_flag != 0) + { + new_Q = s_min(sub(Q_exc, 2), tmp); + } + ELSE IF(Cna_flag != 0) + { + new_Q = s_min(Q_exc, sub(tmp, 2)); + } + ELSE + { + new_Q = s_min(Q_exc, tmp); + } + new_Q = s_min(new_Q, 12); /* */ + new_Q = s_max(new_Q, -1); /* */ + + /*#define REMOVE_SYNTHESIS_PER_FRAME_SCALING */ + tmp = s_min(new_Q, *prev_Q_syn); + *prev_Q_syn = new_Q; + move16(); + + exp_scale = sub(tmp, *Q_syn); + *Q_syn = tmp; + move16(); + + /* rescale synthesis memory (mem_syn2) */ + Scale_sig(mem_syn2, M, exp_scale); + Scale_sig(mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM, exp_scale); + /*Scale_sig(core_old_syn, L_SYN_MEM, exp_scale);*/ + Scale_sig(mem_deemph, 1, exp_scale); + Scale_sig(pst_old_syn, NBPSF_PIT_MAX, exp_scale); + Scale_sig(pst_mem_deemp_err, 1, exp_scale); + Scale_sig(hPFstat->mem_pf_in, L_SUBFR, exp_scale); /* NB post_filter mem */ + Scale_sig(hPFstat->mem_res2, DECMEM_RES2, exp_scale); /* NB post_filter mem */ + Scale_sig(hPFstat->mem_stp, L_SUBFR, exp_scale); /* NB post_filter mem */ + Scale_sig(mem_agc, 1, exp_scale); /* NB post_filter mem */ + return; +} + +/*-------------------------------------------------------------------* + * Scale_sig32 + * Note: In order to save complexity, call function only, if exp0 != 0 + * Up/down scale a 32 bits vector + *-------------------------------------------------------------------*/ +void scale_sig32( + Word32 x[], /* i/o: signal to scale Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx exp */ +) +{ + Word16 i; + + FOR(i = 0; i < lg; i++) + { + /* saturation can occur here */ + x[i] = L_shl(x[i], exp0); + move32(); + } +} + + +/*-------------------------------------------------------------------* + * Rescale_mem: + * + * this function should be called after excitation update (4 subfr) and before frame synthesis + * Rescale excitation related memories + *-------------------------------------------------------------------*/ +Word16 rescale_mem( + const Word16 *Q_exc, /* i : current excitation scaling (>=0) */ + Word16 *prev_Q_syn, /* i/o : scaling factor of previous frame */ + Word16 *Q_syn, /* i/o : scaling factor of frame */ + Word16 *mem_syn2, /* i/o : modified synthesis memory */ + Word16 *syn, /* i/o : synthesis to rescale Q_syn */ + Word16 mem_len, /* i : lenght of modified synthesis memory */ + Word16 i_subfr /* i : subframe number */ +) +{ + Word16 exp_scale, new_Q, tmp; + Word16 i, max16, max_scale; + + max16 = 0; + move16(); + FOR(i = 0; i < mem_len; i++) + { + max16 = s_max(max16, abs_s(mem_syn2[i])); + } + IF(syn != NULL) + { + FOR(i = 0; i < i_subfr; i++) + { + max16 = s_max(max16, abs_s(syn[i])); + } + } + max_scale = 15; + move16(); + IF(max16 > 0) + { + max_scale = add(norm_s(max16), -3); + } + + /*-------------------------------------------------------------------* + * find scaling of synthesis (based on min of current frame and last frame) + * scaling factor of synthesis (-1..6) + *-------------------------------------------------------------------*/ + new_Q = sub(*Q_exc, 3); + new_Q = s_max(new_Q, -1); + + tmp = add(max_scale, *Q_syn); + if (GT_16(s_min(new_Q, *prev_Q_syn), tmp)) + { + new_Q = s_max(tmp, -1); + } + + tmp = s_min(new_Q, *prev_Q_syn); + *prev_Q_syn = new_Q; + move16(); + + exp_scale = sub(tmp, *Q_syn); + *Q_syn = tmp; + move16(); + /* rescale synthesis memory (mem_syn2) */ + Scale_sig(mem_syn2, mem_len, exp_scale); + IF(syn != NULL) + { + Scale_sig(syn, i_subfr, exp_scale); + } + + return exp_scale; +} diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index a3e139c18..4ac58a89a 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -42,6 +42,7 @@ #include "options.h" #include "typedef.h" #include "cnst.h" +#include "basop_util.h" /* Forward declaration of Decoder_State */ struct Decoder_State; @@ -55,11 +56,15 @@ typedef struct { float a[MAXLAG_WI]; float b[MAXLAG_WI]; + Word16 a_fx[MAXLAG_WI]; + Word16 b_fx[MAXLAG_WI]; int16_t lag; int16_t nH; int16_t nH_4kHz; float upper_cut_off_freq_of_interest; float upper_cut_off_freq; + Word16 upper_cut_off_freq_of_interest_fx; + Word16 upper_cut_off_freq_fx; int32_t sampling_rate; } DTFS_STRUCTURE; @@ -116,8 +121,10 @@ typedef struct int16_t voice_tilt; /*Flag for triggering new voice factor tilt*/ - float formant_enh_num; - float formant_enh_den; + float formant_enh_num_flt; + float formant_enh_den_flt; + Word16 formant_enh_num; + Word16 formant_enh_den; int16_t bpf_mode; @@ -149,7 +156,8 @@ typedef struct { int16_t bits; /* bits per subframe */ int16_t nbiter; /* number of iterations */ - float alp; /* initial energy of all fixed pulses */ + float alp_flt; /* initial energy of all fixed pulses */ + Word16 alp; /* initial energy of all fixed pulses, exponent = ALP_E */ int16_t nb_pulse; /* number of pulses */ int16_t fixedpulses; /* number of pulses whose position is determined from correlation and not by iteration */ int16_t nbpos[13]; /* number of positions tried in the pair-wise search */ @@ -177,9 +185,12 @@ typedef struct TNS_filter_structure int16_t spectrumLength; /* Number of subbands covered by the filter. */ int16_t order; /* Filter order. */ int16_t coefIndex[TNS_MAX_FILTER_ORDER]; /* Quantized filter coefficients. */ - float predictionGain; /* Prediction gain. The ratio of a signal and TNS residual energy. */ - float avgSqrCoef; /* Average squared filter coefficient. */ - + float predictionGain_flt; /* Prediction gain. The ratio of a signal and TNS residual energy. */ + float avgSqrCoef_flt; /* Average squared filter coefficient. */ + /** Prediction gain. The ratio of a signal and TNS residual energy. */ + Word16 predictionGain; /* exponent = PRED_GAIN_E */ + /** Average squared filter coefficient. */ + Word16 avgSqrCoef; /* exponent = 0 */ } STnsFilter; typedef struct /* TNS data describing all active filters. */ @@ -211,15 +222,15 @@ typedef struct typedef struct TCX_config_structure { /* TCX mdct window */ - float tcx_mdct_window[L_MDCT_OVLP_MAX_CORE_FS]; /* Sine window for OL decision and DTX transitions*/ - float tcx_aldo_window_1[L_ALDO_WIN1_MAX_CORE_FS]; /* ALDO window long slope */ - float tcx_aldo_window_2[L_MDCT_OVLP_MAX_CORE_FS]; /* ALDO window short slope */ - float *tcx_aldo_window_1_trunc; /* ALDO window truncated long slope */ + float tcx_mdct_window_flt[L_MDCT_OVLP_MAX_CORE_FS]; /* Sine window for OL decision and DTX transitions*/ + float tcx_aldo_window_1_flt[L_ALDO_WIN1_MAX_CORE_FS]; /* ALDO window long slope */ + float tcx_aldo_window_2_flt[L_MDCT_OVLP_MAX_CORE_FS]; /* ALDO window short slope */ + float *tcx_aldo_window_1_trunc_flt; /* ALDO window truncated long slope */ int16_t last_aldo; - float tcx_mdct_window_half[L_MDCT_HALF_OVLP_MAX_CORE_FS]; - float tcx_mdct_window_minimum[L_MDCT_MIN_OVLP_MAX_CORE_FS]; - float tcx_mdct_window_trans[L_MDCT_MIN_OVLP_MAX_CORE_FS]; /* transition window for ACELP->TCX */ + float tcx_mdct_window_half_flt[L_MDCT_HALF_OVLP_MAX_CORE_FS]; + float tcx_mdct_window_minimum_flt[L_MDCT_MIN_OVLP_MAX_CORE_FS]; + float tcx_mdct_window_trans_flt[L_MDCT_MIN_OVLP_MAX_CORE_FS]; /* transition window for ACELP->TCX */ int16_t tcx5Size; /* Size of the TCX5 spectrum in number of samples. Always 5ms. */ @@ -234,14 +245,23 @@ typedef struct TCX_config_structure int16_t tcx_mdct_window_delay; /* length of window delay */ int16_t tcx_offset; /* Offset of the folding point relative to the end of the previous synthetised frame */ int16_t tcx_mdct_window_length_old; /* for keeping old value for sample rate switching */ - float tcx_mdct_windowFB[L_MDCT_OVLP_MAX]; - float tcx_aldo_window_1_FB[L_ALDO_WIN1_FB_MAX]; /* ALDO window long slope */ - float tcx_aldo_window_2_FB[L_MDCT_OVLP_MAX]; /* ALDO window short slope */ - float *tcx_aldo_window_1_FB_trunc; /* ALDO window truncated long slope */ - - float tcx_mdct_window_halfFB[L_MDCT_HALF_OVLP_MAX]; - float tcx_mdct_window_minimumFB[L_MDCT_MIN_OVLP_MAX]; - float tcx_mdct_window_transFB[L_MDCT_TRANS_OVLP_MAX]; /* transition window for ACELP->TCX */ + float tcx_mdct_windowFB_flt[L_MDCT_OVLP_MAX]; + float tcx_aldo_window_1_FB_flt[L_ALDO_WIN1_FB_MAX]; /* ALDO window long slope */ + float tcx_aldo_window_2_FB_flt[L_MDCT_OVLP_MAX]; /* ALDO window short slope */ + float *tcx_aldo_window_1_FB_trunc_flt; /* ALDO window truncated long slope */ + + float tcx_mdct_window_halfFB_flt[L_MDCT_HALF_OVLP_MAX]; + float tcx_mdct_window_minimumFB_flt[L_MDCT_MIN_OVLP_MAX]; + float tcx_mdct_window_transFB_flt[L_MDCT_TRANS_OVLP_MAX]; /* transition window for ACELP->TCX */ + + /* TCX mdct window */ + const PWord16 *tcx_mdct_windowFB; + const PWord16 *tcx_mdct_window_halfFB; + const PWord16 *tcx_mdct_window_minimumFB; + const PWord16 *tcx_mdct_window_transFB; + Word16 tcx_aldo_window_1_FB[L_FRAME_MAX * 9 / 32]; + PWord16 tcx_aldo_window_1_FB_trunc[L_FRAME_MAX * 7 / 32]; + PWord16 tcx_aldo_window_2_FB[L_FRAME_MAX * 7 / 32]; int16_t tcx5SizeFB; /* Size of the TCX5 spectrum in number of samples. Always 5ms. */ @@ -265,21 +285,27 @@ typedef struct TCX_config_structure STnsConfig const *pCurrentTnsConfig; /*Quantization*/ - float sq_rounding; /*set the sq deadzone (no deadzone=0.5f)*/ + float sq_rounding_flt; /*set the sq deadzone (no deadzone=0.5f)*/ + Word16 sq_rounding; /*set the sq deadzone (no deadzone=0.5f)*/ int16_t tcxRateLoopOpt; /*Bandwidth*/ - float preemph_fac; /* preemphasis factor */ - float bandwidth; + float preemph_fac_flt; /* preemphasis factor */ + float bandwidth_flt; + Word16 preemph_fac; /*preemphasis factor*/ + Word16 bandwidth; /* Context HM - Residual Quantization*/ int16_t ctx_hm; /* Flag for enabling Context HM */ int16_t resq; /* Flag for enabling Residual Quantization */ int16_t coder_type; /* GC,VC,UC */ - float na_scale; + float na_scale_flt; + + float SFM2_flt; + Word16 na_scale; - float SFM2; + Word32 SFM2; /* Psychoacoustic parameters for LPC in TCX */ PsychoacousticParameters psychParamsTCX10; @@ -320,7 +346,8 @@ typedef struct int32_t bitrateFrom; int32_t bitrateTo; - float scale; + float scale_flt; + Word16 scale; } SCALE_SETUP; @@ -519,7 +546,7 @@ typedef struct ParamsBitMap /** Number of parameters in params. */ int16_t nParams; /** Definition of the mapping for each parameter. */ - ParamBitMap params[10]; + ParamBitMap params[NPARAMS_MAX]; } ParamsBitMap; struct TnsParameters @@ -527,9 +554,11 @@ struct TnsParameters /* Parameters for each TNS filter */ int16_t startLineFrequency; /* Starting lower frequency of the TNS filter [20..16000] */ int16_t nSubdivisions; /* Number of spectrum subdivisions in which the filter operates [1..8) */ - float minPredictionGain; /* Minimum prediction gain required to turn on the TNS filter */ - float minAvgSqrCoef; /* Minimum average square of coefficients required to turn on the TNS filter */ - float minEnergyChange; /* Minimum energy change required to turn on the TNS filter */ + float minPredictionGain_flt; /* Minimum prediction gain required to turn on the TNS filter */ + float minAvgSqrCoef_flt; /* Minimum average square of coefficients required to turn on the TNS filter */ + float minEnergyChange_flt; /* Minimum energy change required to turn on the TNS filter */ + Word16 minPredictionGain; /* Minimum prediction gain required to turn on the TNS filter. Exponent = PRED_GAIN_E */ + Word16 minAvgSqrCoef; /* Minimum average square of coefficients required to turn on the TNS filter. Exponent = 0 */ }; /**********************************************/ @@ -552,7 +581,8 @@ typedef struct int32_t bitrateFrom; int32_t bitrateTo; - float scale; + float scale_flt; + Word16 scale; } SCALE_TCX_SETUP; @@ -575,12 +605,19 @@ typedef struct cldfb_filter_bank_struct int16_t no_channels; int16_t no_col; int16_t p_filter_length; + Word16 lsb; /*!< Top of low subbands */ + Word16 usb; /*!< Top of high subbands */ + Word16 zeros; /*!< number of zeros in filter coefficients */ + UWord16 flags; /*!< flags */ + CLDFB_TYPE type; int16_t ds; /* delay synthesis */ int16_t da; /* delay analysis */ CLDFB_PROTOTYPE prototype; - const float *p_filter; + const float *p_filter_flt; + const Word16 *p_filter; /*!< Pointer to filter coefficients */ + /* rotation vectors */ const float *rot_vec_ana_re; @@ -594,8 +631,28 @@ typedef struct cldfb_filter_bank_struct const float *rot_vec_syn_delay_re; const float *rot_vec_syn_delay_im; + //Fix variables + Word16 *FilterStates; /*!< Pointer to buffer of filter states */ + Word16 FilterStates_e[CLDFB_NO_COL_MAX + 9]; /*!< Filter states time slot exponents */ + Word16 FilterStates_eg; /*!< Filter states current exponent */ + + const Word16 *rRotVctr; /*!< Modulation tables. */ + const Word16 *iRotVctr; + Word16 filterScale; /*!< filter scale */ + + Word16 synGain; /*!< gain for synthesis filterbank */ + Word16 anaScalefactor; /*!< Scale factor of analysis cldfb */ + Word16 synScalefactor; /*!< Scale factor of synthesis cldfb */ + Word16 outScalefactor; /*!< Scale factor of output data (syn only) */ + Word16 synFilterHeadroom; /*!< Headroom for states in synthesis cldfb filterbank */ + + /* memory helper states */ - float *memory; + float *memory_flt; + Word16 *memory; +#if 0 + //Can be deleted +#endif uint16_t memory_length; /* main filter state */ @@ -604,7 +661,10 @@ typedef struct cldfb_filter_bank_struct /* other parameters */ int16_t bandsToZero; /* bands not synthesized */ int16_t nab; /* number of active bands */ - float scale; /* scaling of frequency domain */ + Word16 filtermode; + + float scale_flt; /* scaling of frequency domain */ + Word16 scale; } CLDFB_FILTER_BANK, *HANDLE_CLDFB_FILTER_BANK; @@ -633,6 +693,48 @@ typedef enum /*---------------------------------------------------------------* * IGF * *---------------------------------------------------------------*/ + /*----------------------------------------------------------------------------------* + * NB postfilter / formant postfilter static variables + *----------------------------------------------------------------------------------*/ +typedef struct pfstat_structure +{ + int16_t on; /* On/off flag */ + int16_t reset; /* reset flag */ + float mem_pf_in_flt[L_SUBFR]; /* Input memory */ + float mem_stp_flt[L_SUBFR]; /* 1/A(gamma1) memory */ + float mem_res2_flt[DECMEM_RES2]; /* A(gamma2) residual */ + float mem_zero_flt[M]; /* null memory to compute i.r. of A(gamma2)/A(gamma1) */ + float gain_prec_flt; /* for gain adjustment */ + Word16 mem_pf_in[L_SUBFR]; /* Input memory */ + Word16 mem_stp[L_SUBFR]; /* 1/A(gamma1) memory */ + Word16 mem_res2[DECMEM_RES2]; /* A(gamma2) residual */ + Word16 mem_zero[M]; /* null memory to compute i.r. of A(gamma2)/A(gamma1) */ + Word16 gain_prec; /* for gain adjustment */ + +} PFSTAT, *PFSTAT_HANDLE; + + +typedef struct +{ + Word16 pGainTemp_m[CLDFB_NO_COL_MAX]; + Word16 pGainTemp_e[CLDFB_NO_COL_MAX]; + Word16 loBuffer[CLDFB_NO_COL_MAX + MAX_TEC_SMOOTHING_DEG]; + + Word16 cldfbExp; + Word16 lastCldfbExp; +} TEMPORAL_ENVELOPE_CODING_DECODER_FX; +typedef TEMPORAL_ENVELOPE_CODING_DECODER_FX* HANDLE_TEC_DEC_FX; + + +typedef struct +{ + Word16 lb_scale; /*!< Scale of low band area */ + Word16 lb_scale16; /*!< Scale of low band area */ + Word16 ov_lb_scale; /*!< Scale of adjusted overlap low band area */ + Word16 hb_scale; /*!< Scale of high band area */ + Word16 ov_hb_scale; /*!< Scale of adjusted overlap high band area */ +} CLDFB_SCALE_FACTOR; + typedef struct igf_grid_struct { @@ -653,9 +755,13 @@ typedef struct igf_grid_struct int16_t infoIsRefined; int16_t infoGranuleLen; float whiteningThreshold[2][IGF_MAX_TILES]; - float gFactor; - float fFactor; - float lFactor; + float gFactor_flt; + float fFactor_flt; + float lFactor_flt; + Word16 gFactor; /* 1Q14 */ + Word16 fFactor; /* 1Q14 */ + Word16 lFactor; /* 1Q14 */ + } IGF_GRID, *H_IGF_GRID; typedef struct IGF_INFO_struct diff --git a/lib_com/stl.h b/lib_com/stl.h index c9ca42280..3d05e5d80 100644 --- a/lib_com/stl.h +++ b/lib_com/stl.h @@ -57,14 +57,25 @@ #ifndef _STL_H #define _STL_H +//#define ENH_U_32_BIT_OPERATOR +#define COMPLEX_OPERATOR +#define CONTROL_CODE_OPS +//#define ENH_32_BIT_OPERATOR +#define ENH_64_BIT_OPERATOR +#define BASOP_NOGLOB +#if defined BASOP_NOGLOB && !defined BASOP_NOGLOB_DEV_USE_GLOBALS +#define BASOP_NOGLOB_DECLARE_LOCAL +#endif + #include "options.h" /* note: needed until BASOP_NOGLOB is accepted */ #include "typedef.h" #include "basop32.h" #include "move.h" #include "control.h" +#include "oper_32b.h" #include "enh1632.h" #include "enh40.h" - +#include "enh64.h" #endif /* ifndef _STL_H */ diff --git a/lib_com/swb_bwe_com.c b/lib_com/swb_bwe_com.c index f879d274b..84bd7f736 100644 --- a/lib_com/swb_bwe_com.c +++ b/lib_com/swb_bwe_com.c @@ -1359,11 +1359,11 @@ void hq_generic_hf_decoding( { if ( hq_generic_offset <= HQ_GENERIC_FOFFSET_24K4 ) { - mvr2r( coeff_out1 + HQ_GENERIC_LOW0 + HQ_GENERIC_END_FREQ - HQ_GENERIC_HIGH2, &coeff_out[fb_bwe_subband[0]], 160 ); + mvr2r( coeff_out1 + HQ_GENERIC_LOW0 + HQ_GENERIC_END_FREQ - HQ_GENERIC_HIGH2, &coeff_out[fb_bwe_subband_float[0]], 160 ); } else { - mvr2r( coeff_out1 + HQ_GENERIC_OFFSET + HQ_GENERIC_LEN0, &coeff_out[fb_bwe_subband[0]], 160 ); + mvr2r( coeff_out1 + HQ_GENERIC_OFFSET + HQ_GENERIC_LEN0, &coeff_out[fb_bwe_subband_float[0]], 160 ); } } tmp1 = EPSILON; @@ -1470,7 +1470,7 @@ void hq_generic_hf_decoding( if ( hq_generic_fenv[nenv - 1] - hq_generic_fenv[nenv] > 15.f || hq_generic_fenv[nenv] < 5.f ) { wfenv = hq_generic_fenv[nenv - 1]; - for ( i = 0; n_freq < fb_bwe_subband[0]; n_freq++, i++ ) + for ( i = 0; n_freq < fb_bwe_subband_float[0]; n_freq++, i++ ) { coeff_out[n_freq] *= wfenv; } @@ -1478,7 +1478,7 @@ void hq_generic_hf_decoding( for ( n_band = 0; n_band < DIM_FB; n_band++ ) { wfenv = hq_generic_fenv[n_band + nenv]; - for ( i = 0; n_freq < fb_bwe_subband[n_band + 1]; n_freq++, i++ ) + for ( i = 0; n_freq < fb_bwe_subband_float[n_band + 1]; n_freq++, i++ ) { coeff_out[n_freq] *= wfenv; } @@ -1490,7 +1490,7 @@ void hq_generic_hf_decoding( { wfenv = hq_generic_fenv[n_band + nenv - 1]; - for ( i = 0; n_freq < fb_bwe_sm_subband[n_band]; n_freq++, i++ ) + for ( i = 0; n_freq < fb_bwe_sm_subband_float[n_band]; n_freq++, i++ ) { factor = i * fb_smooth_factor[n_band]; coeff_out[n_freq] *= ( ( 1 - factor ) * hq_generic_fenv[n_band + nenv] + factor * wfenv ); @@ -1499,7 +1499,7 @@ void hq_generic_hf_decoding( wfenv = hq_generic_fenv[tenv - 1]; - for ( ; n_freq < fb_bwe_subband[DIM_FB]; n_freq++ ) + for ( ; n_freq < fb_bwe_subband_float[DIM_FB]; n_freq++ ) { coeff_out[n_freq] *= wfenv; } diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c new file mode 100644 index 000000000..3e685fd3f --- /dev/null +++ b/lib_com/swb_bwe_com_fx.c @@ -0,0 +1,789 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#include "prot_fx2.h" +#include "basop_util.h" +#include "rom_com.h" + + +/*-------------------------------------------------------------------* +* calc_norm_envelop_lf_fx() +* +* calc_envelope of low frequency spectrum +*-------------------------------------------------------------------*/ +static +void calc_norm_envelop_lf_fx( + const Word32 SWB_signal[], /* i : SWB spectrum */ /* Q12 */ + Word32 *envelope, /* o : normalized envelope */ /* Q12 */ + Word16 *L_swb_norm, /* i/o : length of envelope */ + const Word16 HQ_mode, /* i : HQ mode */ /* Q0 */ + const Word16 hq_generic_offset, /* i : frequency offset for representing hq generic */ /* Q0 */ + Word16 *sfreq, /* i : starting frequency index */ + Word16 *efreq /* i : ending frequency index */ +) +{ + Word16 lookback, env_index, n_freq, n_lag_now, n_lag; + + *sfreq = 2; + move16(); + IF(EQ_16(hq_generic_offset, HQ_GENERIC_FOFFSET_24K4)) + { + *efreq = 146; + move16(); + if (EQ_16(HQ_mode, HQ_GEN_FB)) + { + *efreq = 306; + move16(); + } + IF(LT_16(add(shl(sub(328, *efreq), 1), 1), *L_swb_norm)) + { + *L_swb_norm = add(shl(sub(328, *efreq), 1), 1); + } + } + ELSE + { + *efreq = 130; + move16(); + if (EQ_16(HQ_mode, HQ_GEN_FB)) + { + *efreq = 290; + move16(); + } + IF(LT_16(add(shl(sub(400,*efreq),1),1),*L_swb_norm)) + { + *L_swb_norm = add(shl(sub(400,*efreq),1),1); + } + } + lookback = shr(*L_swb_norm, 1); + env_index = 0; + move16(); + n_lag_now = *L_swb_norm; + move16(); + + FOR(n_freq = 0; n_freq < lookback; n_freq++) + { + Word16 tmp; + Word32 L_tmp; + + L_tmp = L_deposit_l(1); + tmp = add(lookback, n_freq); + FOR(n_lag = 0; n_lag < tmp; n_lag++) + { + L_tmp = L_add(L_tmp, L_abs(SWB_signal[n_lag])); + } + envelope[env_index] = L_tmp; + move32(); + env_index = add(env_index, 1); + } + + FOR(; n_freq < *efreq; n_freq++) + { + /* Apply MA filter */ + Word32 L_tmp = L_deposit_l(1); + FOR(n_lag = 0; n_lag < n_lag_now; n_lag++) + { + L_tmp = L_add(L_tmp, L_abs(SWB_signal[add(sub(n_freq, lookback), n_lag)])); + } + + envelope[env_index] = L_tmp; + move32(); + env_index = add(env_index, 1); + } + + return; +} + +void calc_normal_length_fx_32( + const Word16 core, /* i : core : Q0 */ + const Word32 *sp, /* i : input signal : Q12 */ + const Word16 mode, /* i : input mode : Q0 */ + const Word16 extl, /* i : extension layer : Q0 */ + Word16 *L_swb_norm, /* o : normalize length : Q0 */ + Word16 *prev_L_swb_norm /*i/o : last normalize length : Q0 */ +) +{ + Word16 i, n_freq, n_band, THRES; + Word16 L_swb_norm_trans, L_swb_norm_norm, L_swb_norm_harm, L_swb_norm_cur; + Word16 N; + + const Word32 *pit; + Word32 peak, mean, mag; + Word32 L_tmp1, L_tmp2; + + THRES = 4; + move16(); + test(); + test(); + if (EQ_16(core, HQ_CORE) || EQ_16(extl, SWB_BWE) || EQ_16(extl, FB_BWE)) + { + THRES = 8; + move16(); + } + + N = 16; + move16(); + test(); + test(); + if (EQ_16(core, HQ_CORE) && (EQ_16(mode, HQ_HARMONIC) || EQ_16(mode, HQ_HVQ))) + { + N = 13; + move16(); + } + + n_band = 0; + move16(); + pit = sp; + move16(); + FOR(i = 0; i < N; i++) + { + peak = 0; + move16(); + mean = 0; + move16(); + + FOR(n_freq = 0; n_freq < 16; n_freq++) + { + mag = L_abs(*pit); + if (GT_32(mag, peak)) + { + peak = mag; + move16(); + } + mean = L_add(mean, mag); + pit++; + } + + L_tmp1 = Mult_32_16(peak, shl(15 + THRES, 10)); + L_tmp2 = Mult_32_16(mean, shl(THRES, 10)); + test(); + if (GT_32(L_tmp1, L_tmp2) && GT_32(peak, 40960)) + { + n_band = add(n_band, 1); + } + } + + IF(EQ_16(core, ACELP_CORE)) + { + L_swb_norm_trans = add(4, shr(n_band, 2)); + L_swb_norm_norm = add(8, shr(n_band, 1)); + L_swb_norm_harm = s_max(add(32, shl(n_band, 1)), 24); + + IF(mode == HARMONIC) + { + L_swb_norm_cur = L_swb_norm_harm; + move16(); + } + ELSE IF(mode == NORMAL) + { + L_swb_norm_cur = L_swb_norm_norm; + move16(); + } + ELSE + { + L_swb_norm_cur = L_swb_norm_trans; + move16(); + } + + *L_swb_norm = shr(add(L_swb_norm_cur, *prev_L_swb_norm), 1); + move16(); + *prev_L_swb_norm = L_swb_norm_cur; + move16(); + } + ELSE + { + test(); + IF(mode == HQ_HARMONIC || mode == HQ_HVQ) + { + L_swb_norm_cur = add(32, add(shl(n_band, 1), shr(n_band, 1))); + } + ELSE + { + L_swb_norm_cur = add(8, shr(n_band, 1)); + } + + *L_swb_norm = extract_h(L_add(L_mac(L_mult(L_swb_norm_cur, 3276), *prev_L_swb_norm, 29491),32768)); + *prev_L_swb_norm = L_swb_norm_cur; + move16(); + } + + return; +} + +void hq_generic_decoding_fx( + const Word16 HQ_mode, /* i : HQ mode : Q0 */ + Word32 *coeff_out1_fx, /* i/o: BWE input & temporary buffer : Q12 */ + const Word16 *hq_generic_fenv_fx, /* i : SWB frequency envelopes : Q1 */ + Word32 *coeff_out_fx, /* o : SWB signal in MDCT domain : Q12 */ + const Word16 hq_generic_offset, /* i : frequency offset for representing hq generci : Q0 */ + Word16 *prev_L_swb_norm, /* i/o: last normalize length : Q0 */ + const Word16 hq_generic_exc_clas, /* i : bwe excitation class " Q0 */ + const Word16 *R +) +{ + Word16 i, n_freq, n_band, L_swb_norm; + Word16 k; + Word16 nenv; + Word16 tenv; + + Word16 exp, exp1, exp2, frac, tmp, tmp2, cs; + Word32 L_tmp, L_tmp1, L_tmp2, max_coeff_fx; + Word16 fenvL_fx, wfenv_fx, factor_fx; + Word32* pit1_fx; + Word16 tmp1_fx, tmp2_fx, tmp3_fx, tmp4_fx; + Word32 energy_fx; + + Word32 envelope_fx[L_FRAME16k]; + Word32 mean_vector_fx[20]; + Word16 rn_weight0_fx; + Word16 s; + Word16 blen, nband_lf, sfidx, efidx; + Word16 bwe_seed; + Word16 signum[L_FRAME16k]; + + nenv = sub(SWB_FENV, 2); + if (LE_16(hq_generic_offset, HQ_GENERIC_FOFFSET_24K4)) + { + nenv = SWB_FENV; + move16(); + } + + tenv = nenv; + move16(); + if (EQ_16(HQ_mode, HQ_GEN_FB)) + { + tenv = add(nenv, DIM_FB); + } + + max_coeff_fx = 0; + move16(); + tmp = add(swb_bwe_subband[0], hq_generic_offset); + FOR(n_freq = add(HQ_GENERIC_ST_FREQ, hq_generic_offset); n_freq < tmp; n_freq++) + { + max_coeff_fx = L_max(max_coeff_fx, L_abs(coeff_out1_fx[n_freq])); + } + cs = norm_l(max_coeff_fx); + + L_tmp = 0; + move16(); + tmp2 = add(swb_bwe_subband[0], hq_generic_offset); + FOR(n_freq = add(HQ_GENERIC_ST_FREQ, hq_generic_offset); n_freq < tmp2; n_freq++) + { + tmp = extract_h(L_shl(coeff_out1_fx[n_freq], cs));/*12 + cs - 16 */ + L_tmp1 = L_mult0(tmp, tmp);/*2*(cs-2) */ + L_tmp = L_add(L_tmp, L_shr(L_tmp1, 5));/*2*(cs-2) - 5 */ + } + cs = sub(shl(cs, 1), 9); + fenvL_fx = 0; + move16(); + IF(L_tmp != 0) + { + exp = norm_l(L_tmp); + frac = round_fx(L_shl(L_tmp, exp));/*cs+exp-16 */ + tmp = div_s(16384, frac);/*15 + 14 - (cs+exp-16) */ + exp = sub(add(cs, exp), 30); + L_tmp = Isqrt_lc(L_deposit_h(tmp), &exp);/*Q31 - exp */ + fenvL_fx = round_fx(L_shl(L_tmp, sub(exp, 14)));/*Q1 */ + } + + calc_normal_length_fx_32(HQ_CORE, coeff_out1_fx, HQ_GEN_SWB, -1, &L_swb_norm, prev_L_swb_norm); + + calc_norm_envelop_lf_fx(coeff_out1_fx, envelope_fx, &L_swb_norm, HQ_mode, hq_generic_offset, &sfidx, &efidx); + + blen = 16; + move16(); + + IF(EQ_16(hq_generic_exc_clas, HQ_GENERIC_EXC0)) + { + rn_weight0_fx = 819; + move16();/* 0.8 Q10 */ + } + ELSE IF(EQ_16(hq_generic_exc_clas, HQ_GENERIC_EXC1)) + { + rn_weight0_fx = 51; + move16();/* 0.05 Q10*/ + } + ELSE + { + rn_weight0_fx = 205; + move16();/* 0.02 Q10 */ + } + + tmp = sub(efidx, sfidx); + IF(EQ_16(tmp, 0)) + { + nband_lf = 0; + } + ELSE + { + exp = norm_s(tmp); + nband_lf = shl(tmp,sub(exp,1)); + exp1 = norm_s(blen); + tmp = shl(blen,exp1); + nband_lf = shr(div_s(nband_lf,tmp), add(sub(14,exp1),exp));/* 15 + exp-1 - exp1, Q0*/ + } + + FOR(n_freq = sfidx; n_freq < efidx; n_freq++) + { + IF(coeff_out1_fx[n_freq] < 0) + { + signum[n_freq] = -1; + move16(); + coeff_out1_fx[n_freq] = L_negate(coeff_out1_fx[n_freq]); + move32(); + } + ELSE + { + signum[n_freq] = 1; + move16(); + } + } + + /* applying whitening */ + FOR(n_freq = sfidx; n_freq < efidx; n_freq++) + { + exp = norm_l(coeff_out1_fx[n_freq]) - 1; + exp1 = norm_l(envelope_fx[n_freq]); + + L_tmp = L_shl(coeff_out1_fx[n_freq], exp); + L_tmp1 = L_shl(envelope_fx[n_freq], exp1); + + logic16(); + coeff_out1_fx[n_freq] = Div_32(L_tmp, extract_h(L_tmp1), extract_l(L_shr(L_tmp1, 1)) & 0x00007fff); + move32();/*31 + exp1 - exp2*/ + + exp = add(31, sub(exp, exp1)); + coeff_out1_fx[n_freq] = L_shl(coeff_out1_fx[n_freq], sub(20, exp)); + move32();/*Q12->Q20*/ + } + + /* mean vector generation for controlling dynamic range */ + FOR(k = 0; k < nband_lf; ++k) + { + energy_fx = 1; + move16(); + + tmp = add(i_mult2(add(k, 1), blen), sfidx); + FOR(i = add(i_mult2(k, blen), sfidx); i < tmp; ++i) + { + energy_fx = L_add(energy_fx, coeff_out1_fx[i]); + } + exp = sub(norm_l(energy_fx), 1); + L_tmp = L_shl(energy_fx, exp); + exp1 = norm_l(L_and(blen, 0x00007fff)); + L_tmp1 = L_shl(blen, exp1); + logic16(); + mean_vector_fx[k] = Div_32(L_tmp, extract_h(L_tmp1), extract_l(L_shr(L_tmp1, 1)) & 0x00007fff); + move32();/*31 + 20 + exp1 - exp2*/ + exp = add(51, sub(exp, exp1)); + mean_vector_fx[k] = L_shl(mean_vector_fx[k], sub(20, exp)); + move32();/*Q12->Q20*/ + } + + /* dynamics control */ + FOR(k = 0; k < nband_lf; ++k) + { + tmp = add(i_mult2(add(k, 1), blen), sfidx); + FOR(i = add(i_mult2(k, blen), sfidx); i < tmp; ++i) + { + L_tmp = L_sub(coeff_out1_fx[i], mean_vector_fx[k]); + exp = norm_l(L_tmp); + L_tmp = L_shl(L_tmp, exp); /* exp+12*/ + exp1 = norm_l(rn_weight0_fx); + L_tmp1 = L_shl(rn_weight0_fx, exp1); /* exp1+10*/ + L_tmp = L_mult(extract_h(L_tmp), extract_h(L_tmp1)); + L_tmp = L_shr(L_tmp, add(exp, sub(exp1, 21))); /* Q20*/ + coeff_out1_fx[i] = L_sub(coeff_out1_fx[i], L_tmp); + move32(); + } + } + + IF(EQ_16(hq_generic_exc_clas, HQ_GENERIC_EXC0)) + { + bwe_seed = add(add(shl(R[0], 3), shl(R[1], 2)), add(shl(R[2], 1), R[3])); + + FOR(n_freq = sfidx; n_freq < efidx; n_freq++) + { + IF(signum[n_freq] < 0) + { + coeff_out1_fx[n_freq] = L_negate(coeff_out1_fx[n_freq]); + move32(); + } + + IF(Random(&bwe_seed) < 0) + { + coeff_out1_fx[n_freq] = L_negate(coeff_out1_fx[n_freq]); + move32(); + } + } + } + ELSE + { + FOR(n_freq = sfidx; n_freq < efidx; n_freq++) + { + IF(signum[n_freq] < 0) + { + coeff_out1_fx[n_freq] = L_negate(coeff_out1_fx[n_freq]); + move32(); + } + } + } + + /* normalizing modified low frequency spectrum */ + FOR(k = 0; k < nband_lf; ++k) + { + energy_fx = 1; + move16(); + tmp = add(i_mult2(add(k, 1), blen), sfidx); + FOR(i = add((i_mult2(k, blen)), sfidx); i < tmp; ++i) + { + exp = norm_l(coeff_out1_fx[i]); + L_tmp1 = L_shl(coeff_out1_fx[i], exp);/* exp + 12*/ + + L_tmp = Mult_32_32(L_tmp1, L_tmp1); + L_tmp = L_shr(L_tmp, sub(i_mult2(2, exp), 11));/*Q20 */ + energy_fx = L_add(energy_fx, L_tmp); + } + + exp = norm_l(energy_fx); + L_tmp = L_shl(energy_fx, sub(exp, 1)); + exp1 = norm_s(blen); + L_tmp1 = L_shl((Word32)blen, add(exp1, 16)); + + L_tmp = Div_32(L_tmp, extract_h(L_tmp1), extract_l(L_shr(L_tmp1, 1)) & 0x00007fff); + exp = sub(add(34, exp), exp1); + L_tmp = L_shr(L_tmp, sub(exp, 31)); + exp = 31; + move16(); + + exp = sub(31, exp); + IF(exp & 0x1) + { + L_tmp = L_shr(L_tmp, 1); + exp = add(exp, 1); + } + L_tmp = Sqrt_l(L_tmp, &exp1); + exp = add(31, sub(shr(exp1, 1), shr(exp, 1))); + energy_fx = L_shl(L_tmp, sub(31, exp)); /*Q31*/ + + tmp = add(i_mult2(add(k, 1), blen), sfidx); + FOR(i = add((i_mult2(k, blen)), sfidx); i < tmp; ++i) + { + IF(NE_32(L_abs(coeff_out1_fx[i]), coeff_out1_fx[i])) + { + s = -1; + move16(); + coeff_out1_fx[i] = L_abs(coeff_out1_fx[i]); + move32(); + } + ELSE + { + s = 0; + move16(); + } + exp = norm_l(coeff_out1_fx[i]); + L_tmp = L_shl(coeff_out1_fx[i], sub(exp, 1)); + exp1 = norm_l(energy_fx); + L_tmp1 = L_shl((Word32)energy_fx, exp1); + logic16(); + L_tmp = Div_32(L_tmp, extract_h(L_tmp1), extract_l(L_shr(L_tmp1, 1)) & 0x00007fff); + exp = add(sub(19, exp1), exp); + coeff_out1_fx[i] = L_shl(L_tmp, add(sub(12, exp), 15)); + move32(); /* Q12 -> Q27 */ + IF(s) + { + coeff_out1_fx[i] = L_negate(coeff_out1_fx[i]); + move32(); + } + } + } + + Copy32(&coeff_out1_fx[HQ_GENERIC_OFFSET], &coeff_out_fx[add(HQ_GENERIC_HIGH0, hq_generic_offset)], HQ_GENERIC_LEN0); + Copy32(&coeff_out1_fx[HQ_GENERIC_OFFSET], &coeff_out_fx[add(HQ_GENERIC_HIGH1, hq_generic_offset)], HQ_GENERIC_LEN0); + + IF(LE_16(hq_generic_offset, HQ_GENERIC_FOFFSET_24K4)) + { + Copy32(&coeff_out1_fx[HQ_GENERIC_LOW0], &coeff_out_fx[add(HQ_GENERIC_HIGH2, hq_generic_offset)], sub(HQ_GENERIC_END_FREQ, HQ_GENERIC_HIGH2)); + } + + IF(EQ_16(HQ_mode, HQ_GEN_FB)) + { + IF(LE_16(hq_generic_offset, HQ_GENERIC_FOFFSET_24K4)) + { + Copy32(&coeff_out1_fx[sub(add(HQ_GENERIC_LOW0, HQ_GENERIC_END_FREQ), HQ_GENERIC_HIGH2)], &coeff_out_fx[fb_bwe_subband[0]], 160); + } + ELSE + { + Copy32(&coeff_out1_fx[add(HQ_GENERIC_OFFSET , HQ_GENERIC_LEN0)], &coeff_out_fx[fb_bwe_subband[0]], 160); + } + } + + + L_tmp1 = L_deposit_l(0); + L_tmp2 = L_deposit_l(0); + FOR(i = 0; i < 5; ++i) + { + L_tmp1 = L_add(L_tmp1, L_abs(coeff_out_fx[add(add(HQ_GENERIC_HIGH1, hq_generic_offset), i)])); + L_tmp2 = L_add(L_tmp2, L_abs(coeff_out_fx[sub(add(sub(HQ_GENERIC_HIGH1, 2), hq_generic_offset), i)])); + } + + pit1_fx = &coeff_out_fx[add(HQ_GENERIC_HIGH1, hq_generic_offset)]; + L_tmp1 = L_max(L_tmp1, 1); + L_tmp2 = L_max(L_tmp2, 1); + exp1 = norm_l(L_tmp1); + exp2 = sub(norm_l(L_tmp2), 1); + tmp1_fx = extract_h(L_shl(L_tmp1, exp1)); + tmp2_fx = extract_h(L_shl(L_tmp2, exp2)); + tmp3_fx = div_s(tmp2_fx, tmp1_fx);/*15 + exp2 + 15 - (exp1 + 15) */ + tmp3_fx = shr(tmp3_fx, add(5, sub(exp2, exp1)));/*10 */ + + if (LT_16(tmp3_fx, 307)) + { + tmp3_fx = 307; + move16(); + } + FOR(; tmp3_fx < 1024; tmp3_fx += 102) + { + *pit1_fx = Mult_32_16(*pit1_fx, shl(tmp3_fx, 5)); + move32();/*15 + 5 + 10 -15 */ + pit1_fx++; + } + + pit1_fx = &coeff_out_fx[add(sub(HQ_GENERIC_HIGH1, 1), hq_generic_offset)]; + + exp1 = sub(norm_l(L_tmp1), 1); + exp2 = norm_l(L_tmp2); + tmp1_fx = extract_h(L_shl(L_tmp1, exp1)); + tmp2_fx = extract_h(L_shl(L_tmp2, exp2)); + tmp3_fx = div_s(tmp1_fx, tmp2_fx);/*15 + exp2 + 15 - (exp1 + 15) */ + tmp3_fx = shr(tmp3_fx, add(5, sub(exp1, exp2)));/*10 */ + + IF(GT_16(tmp3_fx, 5120)) + { + FOR(tmp3_fx = 5120; tmp3_fx > 1024; tmp3_fx -= 512) + { + L_tmp1 = Mult_32_16(L_shl(*pit1_fx, 5), tmp3_fx); /*15 + 5 + 10 -15 */ + *pit1_fx-- = L_tmp1; + move32(); + } + } + + IF(LE_16(hq_generic_offset, HQ_GENERIC_FOFFSET_24K4)) + { + L_tmp1 = L_add(L_abs(coeff_out_fx[add(HQ_GENERIC_HIGH2, hq_generic_offset)]), L_abs(coeff_out_fx[add(add(HQ_GENERIC_HIGH2, 1), hq_generic_offset)])); + L_tmp2 = L_add(L_abs(coeff_out_fx[add(sub(HQ_GENERIC_HIGH2, 4), hq_generic_offset)]), L_add(L_abs(coeff_out_fx[add(sub(HQ_GENERIC_HIGH2, 3), hq_generic_offset)]), + L_add(L_abs(coeff_out_fx[add(sub(HQ_GENERIC_HIGH2, 2), hq_generic_offset)]), L_abs(coeff_out_fx[add(sub(HQ_GENERIC_HIGH2, 1), hq_generic_offset)])))); + + pit1_fx = &coeff_out_fx[add(HQ_GENERIC_HIGH2, hq_generic_offset)]; + + L_tmp1 = L_max(L_tmp1, 1); + L_tmp2 = L_max(L_tmp2, 1); + exp1 = norm_l(L_tmp1); + exp2 = sub(norm_l(L_tmp2), 1); + tmp1_fx = extract_h(L_shl(L_tmp1, exp1)); + tmp2_fx = extract_h(L_shl(L_tmp2, exp2)); + tmp3_fx = div_s(tmp2_fx, tmp1_fx);/*15 + exp2 + 15 - (exp1 + 15) */ + tmp3_fx = shr(tmp3_fx, add(5, sub(exp2, exp1)));/*10 */ + + if (LT_16(tmp3_fx, 307)) + { + tmp3_fx = 307; + move16(); + } + FOR(; tmp3_fx < 1024; tmp3_fx += 102) + { + L_tmp = L_shl(Mult_32_16(*pit1_fx, tmp3_fx), 5); /*15 + 5 + 10 -15 */ + *pit1_fx++ = L_tmp; + move32(); + } + + pit1_fx = &coeff_out_fx[add(sub(HQ_GENERIC_HIGH2, 1), hq_generic_offset)]; + + exp1 = sub(norm_l(L_tmp1), 1); + exp2 = norm_l(L_tmp2); + tmp1_fx = extract_h(L_shl(L_tmp1, exp1)); + tmp2_fx = extract_h(L_shl(L_tmp2, exp2)); + tmp3_fx = div_s(tmp1_fx, tmp2_fx);/*15 + exp2 + 15 - (exp1 + 15) */ + tmp3_fx = shr(tmp3_fx, add(5, sub(exp1, exp2)));/*10 */ + tmp3_fx = shr(tmp3_fx, 1); + tmp4_fx = mult_r(tmp3_fx, 1638); + WHILE(tmp3_fx > 1024) + { + L_tmp1 = Mult_32_16(L_shl(*pit1_fx, 5), tmp3_fx); /*15 + 5 + 10 -15 */ + *pit1_fx-- = L_tmp1; + move32(); + tmp3_fx = sub(tmp3_fx, tmp4_fx); + } + } + + + wfenv_fx = hq_generic_fenv_fx[0]; + move16();/*1 */ + i = 0; + move16(); + tmp2 = add(add(swb_bwe_subband[0], hq_generic_offset), 8); + FOR(n_freq = add(swb_bwe_subband[0], hq_generic_offset); n_freq < tmp2; n_freq++) + { + factor_fx = shl(i, 12);/*15 */ + L_tmp1 = L_mult(sub(32767, factor_fx), fenvL_fx);/*17 */ + L_tmp2 = L_mult(factor_fx, wfenv_fx);/*17 */ + L_tmp1 = L_add(L_tmp1, L_tmp2);/*17 */ + + cs = norm_l(L_tmp1); + tmp = extract_h(L_shl(L_tmp1, cs));/*17 + cs - 16 */ + L_tmp = Mult_32_16(coeff_out_fx[n_freq], tmp);/*12 + 15 + 17 + cs - 16 - 15 */ + coeff_out_fx[n_freq] = L_shr(L_tmp, add(1, cs)); + move32();/*12 */ + i++; + move16(); + } + + k = sub(nenv, 2); + FOR(n_band = 0; n_band < k; n_band++) + { + wfenv_fx = hq_generic_fenv_fx[add(n_band, 1)]; + move16();/*1 */ + + tmp2 = swb_bwe_sm_subband[add(n_band, 1)] + hq_generic_offset; + FOR(i = 0; n_freq < tmp2; i++) + { + L_tmp1 = L_mult(sub(wfenv_fx, hq_generic_fenv_fx[n_band]), smooth_factor_fx[n_band]);/*17 */ + L_tmp1 = Mult_32_16(L_tmp1, shl(i, 10));/*17 + 10 - 15 */ + L_tmp1 = L_add(L_tmp1, L_shl(hq_generic_fenv_fx[n_band], 11));/*12 */ + + cs = norm_l(L_tmp1); + tmp = extract_h(L_shl(L_tmp1, cs));/*12 + cs - 16 */ + L_tmp = Mult_32_16(coeff_out_fx[n_freq], tmp);/*12 + 15 + 12 + cs - 16 - 15 */ + coeff_out_fx[n_freq] = L_shl(L_tmp, sub(4, cs)); + move32();/*12 */ + n_freq++; + } + } + + wfenv_fx = hq_generic_fenv_fx[sub(nenv, 1)]; + move16();/*1 */ + tmp2 = add(swb_bwe_sm_subband[sub(nenv, 1)], hq_generic_offset); + FOR(i = 0; n_freq < tmp2; i++) + { + L_tmp1 = L_mult(sub(wfenv_fx, hq_generic_fenv_fx[sub(nenv, 2)]), smooth_factor_fx[sub(nenv, 2)]);/*17 */ + L_tmp1 = Mult_32_16(L_tmp1, shl(i, 10));/*17 + 10 - 15 */ + L_tmp1 = L_add(L_tmp1, L_shl(hq_generic_fenv_fx[sub(nenv, 2)], 11));/*12 */ + + cs = norm_l(L_tmp1); + tmp = extract_h(L_shl(L_tmp1, cs));/*12 + cs - 16 */ + L_tmp = Mult_32_16(coeff_out_fx[n_freq], tmp);/*12 + 15 + 12 + cs - 16 - 15 */ + coeff_out_fx[n_freq] = L_shl(L_tmp, sub(4, cs)); + move32();/*12 */ + n_freq++; + } + + IF(EQ_16(HQ_mode, HQ_GEN_SWB)) + { + FOR(n_band = sub(nenv, 1); n_band < nenv; ++n_band) + { + wfenv_fx = hq_generic_fenv_fx[n_band]; + move16();/*1 */ + tmp2 = add(swb_bwe_subband[add(n_band, 1)], hq_generic_offset); + FOR(; n_freq < tmp2; n_freq++) + { + L_tmp = Mult_32_16(coeff_out_fx[n_freq], wfenv_fx);/*15 + 12 + 1 - 15 */ + coeff_out_fx[n_freq] = L_shr(L_tmp, 1); + move32();/*12 */ + } + } + } + ELSE + { + test(); + IF(hq_generic_fenv_fx[sub(nenv,1)] - hq_generic_fenv_fx[nenv] > 30 || hq_generic_fenv_fx[nenv] < 10) + { + wfenv_fx = hq_generic_fenv_fx[sub(nenv,1)]; + move16();/*1 */ + FOR(i = 0; n_freq < fb_bwe_subband[0]; i++) + { + L_tmp = Mult_32_16(coeff_out_fx[n_freq], wfenv_fx);/*15 + 12 + 1 - 15 */ + coeff_out_fx[n_freq] = L_shr(L_tmp, 1); + move32();/*12 */ + n_freq++; + } + + FOR(n_band = 0; n_band < DIM_FB; n_band++) + { + wfenv_fx = hq_generic_fenv_fx[add(n_band , nenv)]; + move16();/*1 */ + tmp2 = fb_bwe_subband[add(n_band,1)]; + FOR(i = 0; n_freq < tmp2; i++) + { + L_tmp = Mult_32_16(coeff_out_fx[n_freq], wfenv_fx);/*15 + 12 + 1 - 15 */ + coeff_out_fx[n_freq] = L_shr(L_tmp, 1); + move32();/*12 */ + n_freq++; + } + } + } + ELSE + { + FOR(n_band = 0; n_band < DIM_FB; n_band++) + { + wfenv_fx = hq_generic_fenv_fx[sub(add(n_band,nenv),1)]; + move16();/*1 */ + + FOR(i = 0; n_freq < fb_bwe_sm_subband[n_band]; i++) + { + L_tmp1 = L_mult(sub(wfenv_fx, hq_generic_fenv_fx[add(n_band,nenv)]), fb_smooth_factor_fx[n_band]);/*17 */ + L_tmp1 = Mult_32_16(L_tmp1, shl(i, 9));/*17 + 9 - 15 */ + L_tmp1 = L_add(L_tmp1, L_shl(hq_generic_fenv_fx[add(n_band,nenv)], 10));/*11 */ + + cs = norm_l(L_tmp1); + tmp = extract_h(L_shl(L_tmp1, cs));/*11 + cs - 16 */ + L_tmp = Mult_32_16(coeff_out_fx[n_freq] , tmp);/*12 + 15 + 11 + cs - 16 - 15 */ + coeff_out_fx[n_freq] = L_shl(L_tmp, sub(5, cs)); + move32();/*12 */ + n_freq++; + } + } + + wfenv_fx = hq_generic_fenv_fx[sub(tenv,1)]; + move16();/*1 */ + + FOR(; n_freq < fb_bwe_subband[DIM_FB]; n_freq++) + { + L_tmp = Mult_32_16(coeff_out_fx[n_freq], wfenv_fx);/*15 + 12 + 1 - 15 */ + coeff_out_fx[n_freq] = L_shr(L_tmp, 1); + move32();/*12 */ + } + } + } + + return; +} \ No newline at end of file diff --git a/lib_com/swb_tbe_com.c b/lib_com/swb_tbe_com.c index fb1382ae4..b99ba26cb 100644 --- a/lib_com/swb_tbe_com.c +++ b/lib_com/swb_tbe_com.c @@ -1022,7 +1022,7 @@ void GenShapedSHBExcitation( } mvr2r( White_exc16k, White_exc16k_FB, L_FRAME16k ); - deemph( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph ); + deemph( White_exc16k, PREEMPH_FAC_FLT, L_FRAME16k, tbe_demph ); if ( extl_brate == SWB_TBE_1k10 || extl_brate == SWB_TBE_1k75 ) { @@ -1054,7 +1054,7 @@ void GenShapedSHBExcitation( exc16kWhtnd[k] = (float) new_fact * White_exc16k[k] + (float) ( 1 - new_fact ) * exc16kWhtnd[k]; } } - preemph( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); + preemph( exc16kWhtnd, PREEMPH_FAC_FLT, L_FRAME16k, tbe_premph ); } else { @@ -1070,7 +1070,7 @@ void GenShapedSHBExcitation( exc16kWhtnd[k] = White_exc16k[k] * scale; } - preemph( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); + preemph( exc16kWhtnd, PREEMPH_FAC_FLT, L_FRAME16k, tbe_premph ); } else { @@ -1108,7 +1108,7 @@ void GenShapedSHBExcitation( } temp = (float) sqrt( 1.0f - voice_factors[i] ); - temp = PREEMPH_FAC * temp / ( temp1 + temp ); + temp = PREEMPH_FAC_FLT * temp / ( temp1 + temp ); preemph( &exc16kWhtnd[i * L_FRAME16k / nbSubFr], temp, L_FRAME16k / nbSubFr, tbe_premph ); } @@ -1763,7 +1763,7 @@ void synthesise_fb_high_band( const float excitation_in[], /* i : full band excitation */ float output[], /* o : high band speech - 14.0 to 20 kHz */ const float fb_exc_energy, /* i : full band excitation energy */ - const float ratio, /* i : energy ratio */ + const float ratio_float, /* i : energy ratio */ const int16_t L_frame, /* i : ACELP frame length */ const int16_t bfi, /* i : BFI flag */ float *prev_fbbwe_ratio, /* o : previous frame energy for FEC */ @@ -1795,15 +1795,15 @@ void synthesise_fb_high_band( elliptic_bpf_48k_generic( excitation_in_interp3, tmp, bpf_memory, full_band_bpf_1 ); } temp1 = sum2_f( tmp, L_FRAME48k ) + 0.001f; - ratio2 = (float) ( ratio * sqrt( fb_exc_energy / temp1 ) ); + ratio2 = (float) ( ratio_float * sqrt( fb_exc_energy / temp1 ) ); if ( !bfi ) { - *prev_fbbwe_ratio = ratio; + *prev_fbbwe_ratio = ratio_float; } else { - *prev_fbbwe_ratio = ratio * 0.5f; + *prev_fbbwe_ratio = ratio_float * 0.5f; } for ( i = 0; i < L_FRAME48k; i++ ) { diff --git a/lib_com/tcq_position_arith.c b/lib_com/tcq_position_arith.c index a1a2d39ab..ee8ab03d9 100644 --- a/lib_com/tcq_position_arith.c +++ b/lib_com/tcq_position_arith.c @@ -53,17 +53,18 @@ static int32_t ar_decode( PARCODEC arInst, const int16_t *model ); static void ar_encode( PARCODEC arInst, const int16_t *model, int32_t symbol ); static void ar_encode_uniform( PARCODEC arInst, uint16_t data, const int16_t bits ); +//already defined in tools_fx.c /* 32x16 multiply: */ -Word32 Mult_32_16( Word32 a, Word16 b ) -{ - Word32 result; - UWord16 lo; - /* use Mpy_32_16_ss(): */ - Mpy_32_16_ss( a, b, &result, &lo ); - - return result; -} +//Word32 Mult_32_16( Word32 a, Word16 b ) +//{ +// Word32 result; +// UWord16 lo; +// /* use Mpy_32_16_ss(): */ +// Mpy_32_16_ss( a, b, &result, &lo ); +// +// return result; +//} /* 32x32 multiply: */ Word32 Mult_32_32( Word32 a, Word32 b ) diff --git a/lib_com/tcx_ltp.c b/lib_com/tcx_ltp.c index 4ea3f1106..ca2aa7933 100644 --- a/lib_com/tcx_ltp.c +++ b/lib_com/tcx_ltp.c @@ -850,7 +850,7 @@ void tcx_ltp_post( bfi = st->bfi; pitch_int = hTcxLtpDec->tcxltp_pitch_int; pitch_fr = hTcxLtpDec->tcxltp_pitch_fr; - gain = hTcxLtpDec->tcxltp_gain; + gain = hTcxLtpDec->tcxltp_gain_float; } /******** Init ********/ @@ -862,17 +862,17 @@ void tcx_ltp_post( /* Input buffer */ sig_in = buf_in + tcx_buf_len; - mvr2r( hTcxLtpDec->tcxltp_mem_in, buf_in, tcx_buf_len ); + mvr2r( hTcxLtpDec->tcxltp_mem_in_float, buf_in, tcx_buf_len ); mvr2r( sig, buf_in + tcx_buf_len, output_frame ); if ( core > ACELP_CORE ) { mvr2r( tcx_buf, sig_in + output_frame, tcx_buf_len ); } - mvr2r( sig + output_frame - tcx_buf_len, hTcxLtpDec->tcxltp_mem_in, tcx_buf_len ); + mvr2r( sig + output_frame - tcx_buf_len, hTcxLtpDec->tcxltp_mem_in_float, tcx_buf_len ); /* Output buffer */ sig_out = buf_out + output_frame; - mvr2r( hTcxLtpDec->tcxltp_mem_out, buf_out, output_frame ); + mvr2r( hTcxLtpDec->tcxltp_mem_out_float, buf_out, output_frame ); /* TCX-LTP parameters: integer pitch, fractional pitch, gain */ @@ -926,7 +926,7 @@ void tcx_ltp_post( { pitch_int = hTcxLtpDec->tcxltp_pitch_int_post_prev; pitch_fr = hTcxLtpDec->tcxltp_pitch_fr_post_prev; - gain = hTcxLtpDec->tcxltp_gain_post_prev * st->hTcxDec->damping; + gain = hTcxLtpDec->tcxltp_gain_post_prev_float * st->hTcxDec->damping_float; } else { @@ -939,7 +939,7 @@ void tcx_ltp_post( gain = 0.f; if ( bfi ) { - hTcxLtpDec->tcxltp_gain_post_prev = 0.f; + hTcxLtpDec->tcxltp_gain_post_prev_float = 0.f; } } gain2 = gain; @@ -1014,28 +1014,28 @@ void tcx_ltp_post( /******** Previous-frame part ********/ - tcx_ltp_synth_filter( sig_out, sig_in, delay, hTcxLtpDec->tcxltp_pitch_int_post_prev, hTcxLtpDec->tcxltp_pitch_fr_post_prev, hTcxLtpDec->tcxltp_gain_post_prev, st->pit_res_max_past, hTcxLtpDec->tcxltp_filt_idx_prev ); + tcx_ltp_synth_filter( sig_out, sig_in, delay, hTcxLtpDec->tcxltp_pitch_int_post_prev, hTcxLtpDec->tcxltp_pitch_fr_post_prev, hTcxLtpDec->tcxltp_gain_post_prev_float, st->pit_res_max_past, hTcxLtpDec->tcxltp_filt_idx_prev ); /******** Transition part - initial subinterval ********/ if ( st->element_mode != EVS_MONO ) { - if ( gain == 0.f && hTcxLtpDec->tcxltp_gain_post_prev == 0.f ) + if ( gain == 0.f && hTcxLtpDec->tcxltp_gain_post_prev_float == 0.f ) { /* The filtering is deactivated, just copy input to the output */ mvr2r( sig_in + delay, sig_out + delay, L_transition ); } - else if ( gain == 0.f && hTcxLtpDec->tcxltp_gain_post_prev != 0.f ) + else if ( gain == 0.f && hTcxLtpDec->tcxltp_gain_post_prev_float != 0.f ) { /* Filtering with the first filter unit */ - tcx_ltp_synth_filter_10( sig_out + delay, sig_in + delay, L_transition, hTcxLtpDec->tcxltp_pitch_int_post_prev, hTcxLtpDec->tcxltp_pitch_fr_post_prev, hTcxLtpDec->tcxltp_gain_post_prev, st->pit_res_max_past, hTcxLtpDec->tcxltp_filt_idx_prev ); + tcx_ltp_synth_filter_10( sig_out + delay, sig_in + delay, L_transition, hTcxLtpDec->tcxltp_pitch_int_post_prev, hTcxLtpDec->tcxltp_pitch_fr_post_prev, hTcxLtpDec->tcxltp_gain_post_prev_float, st->pit_res_max_past, hTcxLtpDec->tcxltp_filt_idx_prev ); } - else if ( gain != 0.f && hTcxLtpDec->tcxltp_gain_post_prev == 0.f ) + else if ( gain != 0.f && hTcxLtpDec->tcxltp_gain_post_prev_float == 0.f ) { /* Filtering with the second filter unit */ tcx_ltp_synth_filter_01( sig_out + delay, sig_in + delay, L_transition, pitch_int, pitch_fr, gain, st->pit_res_max, filtIdx ); } - else if ( gain == hTcxLtpDec->tcxltp_gain_post_prev && pitch_int == hTcxLtpDec->tcxltp_pitch_int_post_prev && pitch_fr == hTcxLtpDec->tcxltp_pitch_fr_post_prev && st->pit_res_max == st->pit_res_max_past && filtIdx == hTcxLtpDec->tcxltp_filt_idx_prev ) + else if ( gain == hTcxLtpDec->tcxltp_gain_post_prev_float && pitch_int == hTcxLtpDec->tcxltp_pitch_int_post_prev && pitch_fr == hTcxLtpDec->tcxltp_pitch_fr_post_prev && st->pit_res_max == st->pit_res_max_past && filtIdx == hTcxLtpDec->tcxltp_filt_idx_prev ) { tcx_ltp_synth_filter( sig_out + delay, sig_in + delay, L_transition, pitch_int, pitch_fr, gain, st->pit_res_max, filtIdx ); } @@ -1043,24 +1043,24 @@ void tcx_ltp_post( { /* Filtering with the first filter unit, followed by the filtering with the second filter unit */ tcx_ltp_synth_filter_11_unequal_pitch( sig_out + delay, sig_in + delay, L_transition, pitch_int, pitch_fr, gain, st->pit_res_max, filtIdx, - hTcxLtpDec->tcxltp_pitch_int_post_prev, hTcxLtpDec->tcxltp_pitch_fr_post_prev, hTcxLtpDec->tcxltp_gain_post_prev, st->pit_res_max_past, hTcxLtpDec->tcxltp_filt_idx_prev ); + hTcxLtpDec->tcxltp_pitch_int_post_prev, hTcxLtpDec->tcxltp_pitch_fr_post_prev, hTcxLtpDec->tcxltp_gain_post_prev_float, st->pit_res_max_past, hTcxLtpDec->tcxltp_filt_idx_prev ); } } else { - if ( gain == 0.f && hTcxLtpDec->tcxltp_gain_post_prev == 0.f ) + if ( gain == 0.f && hTcxLtpDec->tcxltp_gain_post_prev_float == 0.f ) { mvr2r( sig_in + delay, sig_out + delay, L_transition ); } - else if ( hTcxLtpDec->tcxltp_gain_post_prev == 0.f ) + else if ( hTcxLtpDec->tcxltp_gain_post_prev_float == 0.f ) { tcx_ltp_synth_filter_fadein( sig_out + delay, sig_in + delay, L_transition, pitch_int, pitch_fr, gain, st->pit_res_max, filtIdx ); } else if ( gain == 0.f ) { - tcx_ltp_synth_filter_fadeout( sig_out + delay, sig_in + delay, L_transition, hTcxLtpDec->tcxltp_pitch_int_post_prev, hTcxLtpDec->tcxltp_pitch_fr_post_prev, hTcxLtpDec->tcxltp_gain_post_prev, st->pit_res_max_past, hTcxLtpDec->tcxltp_filt_idx_prev ); + tcx_ltp_synth_filter_fadeout( sig_out + delay, sig_in + delay, L_transition, hTcxLtpDec->tcxltp_pitch_int_post_prev, hTcxLtpDec->tcxltp_pitch_fr_post_prev, hTcxLtpDec->tcxltp_gain_post_prev_float, st->pit_res_max_past, hTcxLtpDec->tcxltp_filt_idx_prev ); } - else if ( gain == hTcxLtpDec->tcxltp_gain_post_prev && pitch_int == hTcxLtpDec->tcxltp_pitch_int_post_prev && pitch_fr == hTcxLtpDec->tcxltp_pitch_fr_post_prev ) + else if ( gain == hTcxLtpDec->tcxltp_gain_post_prev_float && pitch_int == hTcxLtpDec->tcxltp_pitch_int_post_prev && pitch_fr == hTcxLtpDec->tcxltp_pitch_fr_post_prev ) { tcx_ltp_synth_filter( sig_out + delay, sig_in + delay, L_transition, pitch_int, pitch_fr, gain, st->pit_res_max, filtIdx ); } @@ -1085,10 +1085,10 @@ void tcx_ltp_post( /* Update */ hTcxLtpDec->tcxltp_pitch_int_post_prev = pitch_int; hTcxLtpDec->tcxltp_pitch_fr_post_prev = pitch_fr; - hTcxLtpDec->tcxltp_gain_post_prev = gain2; + hTcxLtpDec->tcxltp_gain_post_prev_float = gain2; hTcxLtpDec->tcxltp_filt_idx_prev = filtIdx; st->pit_res_max_past = st->pit_res_max; - mvr2r( sig_out, hTcxLtpDec->tcxltp_mem_out, output_frame ); + mvr2r( sig_out, hTcxLtpDec->tcxltp_mem_out_float, output_frame ); return; } diff --git a/lib_com/tcx_utils.c b/lib_com/tcx_utils.c index a96c19e11..0747a7572 100644 --- a/lib_com/tcx_utils.c +++ b/lib_com/tcx_utils.c @@ -67,22 +67,22 @@ void tcx_get_windows( { /* ACELP->TCX transition */ *left_overlap = hTcxCfg->tcx_mdct_window_trans_length; - *left_win = hTcxCfg->tcx_mdct_window_trans; + *left_win = hTcxCfg->tcx_mdct_window_trans_flt; } else if ( left_mode == MIN_OVERLAP ) { *left_overlap = hTcxCfg->tcx_mdct_window_min_length; - *left_win = hTcxCfg->tcx_mdct_window_minimum; + *left_win = hTcxCfg->tcx_mdct_window_minimum_flt; } else if ( left_mode == HALF_OVERLAP ) { *left_overlap = hTcxCfg->tcx_mdct_window_half_length; - *left_win = hTcxCfg->tcx_mdct_window_half; + *left_win = hTcxCfg->tcx_mdct_window_half_flt; } else if ( left_mode == FULL_OVERLAP ) { *left_overlap = hTcxCfg->tcx_mdct_window_length; - *left_win = hTcxCfg->tcx_aldo_window_1_trunc; + *left_win = hTcxCfg->tcx_aldo_window_1_trunc_flt; } else { @@ -94,17 +94,17 @@ void tcx_get_windows( if ( right_mode == MIN_OVERLAP ) { *right_overlap = hTcxCfg->tcx_mdct_window_min_length; - *right_win = hTcxCfg->tcx_mdct_window_minimum; + *right_win = hTcxCfg->tcx_mdct_window_minimum_flt; } else if ( right_mode == HALF_OVERLAP ) { *right_overlap = hTcxCfg->tcx_mdct_window_half_length; - *right_win = hTcxCfg->tcx_mdct_window_half; + *right_win = hTcxCfg->tcx_mdct_window_half_flt; } else if ( right_mode == FULL_OVERLAP ) { *right_overlap = hTcxCfg->tcx_mdct_window_delay; - *right_win = hTcxCfg->tcx_aldo_window_2; + *right_win = hTcxCfg->tcx_aldo_window_2_flt; } else { @@ -119,17 +119,17 @@ void tcx_get_windows( { /* ACELP->TCX transition */ *left_overlap = hTcxCfg->tcx_mdct_window_trans_lengthFB; - *left_win = hTcxCfg->tcx_mdct_window_transFB; + *left_win = hTcxCfg->tcx_mdct_window_transFB_flt; } else if ( left_mode == MIN_OVERLAP ) { *left_overlap = hTcxCfg->tcx_mdct_window_min_lengthFB; - *left_win = hTcxCfg->tcx_mdct_window_minimumFB; + *left_win = hTcxCfg->tcx_mdct_window_minimumFB_flt; } else if ( left_mode == HALF_OVERLAP ) { *left_overlap = hTcxCfg->tcx_mdct_window_half_lengthFB; - *left_win = hTcxCfg->tcx_mdct_window_halfFB; + *left_win = hTcxCfg->tcx_mdct_window_halfFB_flt; } else if ( left_mode == RECTANGULAR_OVERLAP ) { @@ -139,7 +139,7 @@ void tcx_get_windows( else if ( left_mode == FULL_OVERLAP ) { *left_overlap = hTcxCfg->tcx_mdct_window_lengthFB; - *left_win = hTcxCfg->tcx_aldo_window_1_FB_trunc; + *left_win = hTcxCfg->tcx_aldo_window_1_FB_trunc_flt; } else { @@ -151,12 +151,12 @@ void tcx_get_windows( if ( right_mode == MIN_OVERLAP ) { *right_overlap = hTcxCfg->tcx_mdct_window_min_lengthFB; - *right_win = hTcxCfg->tcx_mdct_window_minimumFB; + *right_win = hTcxCfg->tcx_mdct_window_minimumFB_flt; } else if ( right_mode == HALF_OVERLAP ) { *right_overlap = hTcxCfg->tcx_mdct_window_half_lengthFB; - *right_win = hTcxCfg->tcx_mdct_window_halfFB; + *right_win = hTcxCfg->tcx_mdct_window_halfFB_flt; } else if ( right_mode == RECTANGULAR_OVERLAP ) { @@ -166,7 +166,7 @@ void tcx_get_windows( else if ( right_mode == FULL_OVERLAP ) { *right_overlap = hTcxCfg->tcx_mdct_window_delayFB; - *right_win = hTcxCfg->tcx_aldo_window_2_FB; + *right_win = hTcxCfg->tcx_aldo_window_2_FB_flt; } else { @@ -276,11 +276,11 @@ void WindowSignal( /* fade truncated ALDO window to avoid discontinuities */ if ( !fullband ) { - v_mult( out, hTcxCfg->tcx_mdct_window_minimum, out, hTcxCfg->tcx_mdct_window_min_length ); + v_mult( out, hTcxCfg->tcx_mdct_window_minimum_flt, out, hTcxCfg->tcx_mdct_window_min_length ); } else { - v_mult( out, hTcxCfg->tcx_mdct_window_minimumFB, out, hTcxCfg->tcx_mdct_window_min_lengthFB ); + v_mult( out, hTcxCfg->tcx_mdct_window_minimumFB_flt, out, hTcxCfg->tcx_mdct_window_min_lengthFB ); } } diff --git a/lib_com/tec_com.c b/lib_com/tec_com.c index 346d38292..a22886b28 100644 --- a/lib_com/tec_com.c +++ b/lib_com/tec_com.c @@ -678,14 +678,14 @@ void resetTecEnc( { if ( flag == 0 ) { - set_f( hTecEnc->loBuffer, 0.f, CLDFB_NO_COL_MAX + MAX_TEC_SMOOTHING_DEG + DELAY_TEMP_ENV_BUFF_TEC ); - set_f( hTecEnc->hiTempEnv, 0.f, CLDFB_NO_COL_MAX + DELAY_TEMP_ENV_BUFF_TEC + EXT_DELAY_HI_TEMP_ENV ); - set_f( hTecEnc->loTempEnv, 0.f, CLDFB_NO_COL_MAX ); - set_f( hTecEnc->loTempEnv_ns, 0.f, CLDFB_NO_COL_MAX ); + set_f( hTecEnc->loBuffer_flt, 0.f, CLDFB_NO_COL_MAX + MAX_TEC_SMOOTHING_DEG + DELAY_TEMP_ENV_BUFF_TEC ); + set_f( hTecEnc->hiTempEnv_flt, 0.f, CLDFB_NO_COL_MAX + DELAY_TEMP_ENV_BUFF_TEC + EXT_DELAY_HI_TEMP_ENV ); + set_f( hTecEnc->loTempEnv_flt, 0.f, CLDFB_NO_COL_MAX ); + set_f( hTecEnc->loTempEnv_ns_flt, 0.f, CLDFB_NO_COL_MAX ); } else { - set_f( hTecEnc->loBuffer, 0.f, MAX_TEC_SMOOTHING_DEG ); + set_f( hTecEnc->loBuffer_flt, 0.f, MAX_TEC_SMOOTHING_DEG ); } return; @@ -747,7 +747,7 @@ void calcLoEnvCheckCorrHiLo( int16_t i; float corrCoef; int16_t bandOffsetBottom = lowSubband - BW_LO; - float ratio; + float ratio_float; float hiVar, loVar; float hiSum, loSum; int16_t code = 0; /* SET TENTATIVELY */ @@ -870,9 +870,9 @@ void calcLoEnvCheckCorrHiLo( /* calc correlation coefficient between loTempEnv and hiTempEnv */ corrCoef = calcCorrelationCoefficient2( hiTempEnv, loTempEnv, noCols, hiVar, loVar, hiSum, loSum ); - ratio = hiVar / ( loVar + EPS ); + ratio_float = hiVar / ( loVar + EPS ); - if ( corrCoef >= thCorrCoef && ratio > thRatio && ratio < thRatio2 ) + if ( corrCoef >= thCorrCoef && ratio_float > thRatio && ratio_float < thRatio2 ) { *corrFlag = 1; } diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c index 20e679c31..d38f032b6 100644 --- a/lib_com/tns_base.c +++ b/lib_com/tns_base.c @@ -494,8 +494,8 @@ void ResetTnsData( { STnsFilter *const pTnsFilter = &pTnsData->filter[iFilter]; pTnsFilter->spectrumLength = 0; - pTnsFilter->predictionGain = 1.0f; - pTnsFilter->avgSqrCoef = 0; + pTnsFilter->predictionGain_flt = 1.0f; + pTnsFilter->avgSqrCoef_flt = 0; pTnsFilter->filterType = TNS_FILTER_OFF; ClearTnsFilterCoefficients( pTnsFilter ); } diff --git a/lib_com/tools.c b/lib_com/tools.c index a30895bac..8004fcf3c 100644 --- a/lib_com/tools.c +++ b/lib_com/tools.c @@ -89,7 +89,7 @@ float log2_f( return (float) ( log( x ) / log( 2.0f ) ); } -int16_t norm_ul( uint32_t UL_var1 ) +int16_t norm_ul_float( uint32_t UL_var1 ) { int16_t var_out; @@ -1250,7 +1250,7 @@ int16_t w_vquant( * Sorting of vectors. This is very fast with almost ordered vectors. *----------------------------------------------------------------------------------*/ -void v_sort( +void v_sort_float( float *r, /* i/o: Vector to be sorted in place */ const int16_t lo, /* i : Low limit of sorting range */ const int16_t up /* I : High limit of sorting range */ @@ -1700,12 +1700,12 @@ int16_t is_numeric_float( } /*-------------------------------------------------------------------* - * delay_signal() + * delay_signal_float() * * Delay buffer by defined number of samples *-------------------------------------------------------------------*/ -void delay_signal( +void delay_signal_float( float x[], /* i/o: signal to be delayed */ const int16_t len, /* i : length of the input signal */ float mem[], /* i/o: synchronization memory */ diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c new file mode 100644 index 000000000..98c8fbeeb --- /dev/null +++ b/lib_com/tools_fx.c @@ -0,0 +1,3054 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +/*==================================================================================== + 3GPP TS26.258 Aug 24, 2023. IVAS Codec Version IVAS-FL-1.0 + ====================================================================================*/ + +/*==================================================================================== + EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 + ====================================================================================*/ + +#include +#include +#include +#include "options.h" +#include "stl.h" +#include +#include "cnst.h" +#include "prot_fx1.h" +#include "basop_util.h" +#include "wmc_auto.h" + +#define INV_BANDS10 3277 /* 1/10 in Q15 */ +#define INV_BANDS9 3641 /* 1/9 in Q15 */ +#define INV_BANDS3 10923 /* 1/9 in Q15 */ +const Word16 b_hp400_fx[3] = { 3660, -7320, 3660 }; /* Q12 (/4) */ +const Word16 a_hp400_fx[3] = { 16384, 29280, -14160 }; +//basic functions +Word32 Mult_32_16(Word32 a, Word16 b) +{ + Word32 result; + UWord16 lo; + /* use Mpy_32_16_ss(): */ + Mpy_32_16_ss(a, b, &result, &lo); + + return result; +} + +static __inline Word16 L_Extract_lc(const Word32 L_32, Word16 *p_hi) +{ + *p_hi = extract_h(L_32); + return lshr(extract_l(L_32), 1); + +} + +int16_t norm_ul(uint32_t UL_var1) +{ + int16_t var_out; + + if (UL_var1 == 0) + { + var_out = 0; + } + else + { + for (var_out = 0; UL_var1 < (uint32_t)0x80000000U; var_out++) + { + UL_var1 <<= 1; + } + } + BASOP_CHECK(); + + return (var_out); +} + +/*-------------------------------------------------------------------* + * usdequant_fx() + * + * Uniform scalar de-quantizer routine + * + * Applies de-quantization based on scale and round operations. + *-------------------------------------------------------------------*/ +Word16 usdequant_fx( /* Qx*/ + const Word16 idx, /* i: quantizer index Q0*/ + const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ + const Word16 delta /* i: quantization step Qx-1*/ +) +{ + Word16 g; + Word32 L_tmp; + + /*g = idx * delta + qlow;*/ + L_tmp = L_deposit_l(qlow);/*Qx */ + L_tmp = L_mac(L_tmp,idx,delta);/*Qx */ +#ifdef BASOP_NOGLOB + g = round_fx_sat(L_shl_sat(L_tmp,16)); /*Qx */ +#else + g = round_fx(L_shl(L_tmp,16)); /*Qx */ +#endif + return( g ); +} + +/*-------------------------------------------------------------------* + * usquant() + * + * Uniform scalar quantizer according to MMSE criterion + * (nearest neighbour in Euclidean space) + * + * Applies quantization based on scale and round operations. + * Index of the winning codeword and the winning codeword itself are returned. + *-------------------------------------------------------------------*/ +Word16 usquant_fx( /* o: index of the winning codeword */ + const Word16 x, /* i: scalar value to quantize Qx*/ + Word16 *xq, /* o: quantized value Qx*/ + const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ + const Word16 delta, /* i: quantization step Qx-1*/ + const Word16 cbsize /* i: codebook size */ +) +{ + Word16 idx; + Word16 tmp, exp; + Word32 L_tmp; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + /* idx = (short)( (x - qlow)/delta + 0.5f); */ + exp = norm_s(delta); + tmp = div_s(shl(1,sub(14,exp)),delta); /*Q(29-exp-(Qx-1))->Q(30-exp-Qx) */ +#ifdef BASOP_NOGLOB + L_tmp = L_mult(sub_o(x, qlow, &Overflow), tmp); /*Q(31-exp) */ + idx = extract_l(L_shr_r(L_add(L_tmp,shl_o(1,sub(30,exp), &Overflow)),sub(31,exp))); /*Q0 */ +#else /* BASOP_NOGLOB */ + L_tmp = L_mult(sub(x, qlow), tmp); /*Q(31-exp) */ + idx = extract_l(L_shr_r(L_add(L_tmp,shl(1,sub(30,exp))),sub(31,exp))); /*Q0 */ +#endif /* BASOP_NOGLOB */ + + idx = s_min(idx,sub(cbsize,1)); + idx = s_max( idx, 0); + + /* *xq = idx*delta + qlow; */ + L_tmp = L_deposit_l(qlow);/*Qx */ + L_tmp = L_mac(L_tmp,idx,delta);/*Qx */ +#ifdef BASOP_NOGLOB + *xq = round_fx_o(L_shl_o(L_tmp,16, &Overflow), &Overflow);/*Qx */ +#else + *xq = round_fx(L_shl(L_tmp,16));/*Qx */ +#endif + return idx; +} +/*-------------------------------------------------------------------* +* Dot_product: +* +* Compute scalar product of using accumulator. +* Performs no normalization, as opposed to Dot_product12() +*-------------------------------------------------------------------*/ +Word32 Dot_product( /* o : Sum */ + const Word16 x[], /* i : 12bits: x vector */ + const Word16 y[], /* i : 12bits: y vector */ + const Word16 lg /* i : vector length */ +) +{ + Word16 i; + Word32 L_sum; + Word64 L64_sum; + + L64_sum = 1; + FOR (i = 0; i < lg; i++) + { + L64_sum = W_mac_16_16(L64_sum, x[i], y[i]); + } + L_sum = W_sat_l(L64_sum); + return L_sum; +} +/*---------------------------------------------------------------------* + * dotp_fx() + * + * Dot product of vector x[] and vector y[] + *---------------------------------------------------------------------*/ + +Word32 dotp_fx( /* o : dot product of x[] and y[] */ + const Word16 x[], /* i : vector x[] */ + const Word16 y[], /* i : vector y[] */ + const Word16 n, /* i : vector length */ + Word16 *exp /* (o) : exponent of result (0..+30) */ +) +{ + Word16 sft; + Word32 L_sum; + + assert(*exp == 0); + + L_sum = L_add(L_shr(Dot_product(x, y, n), 1), 1); + + /* Normalize acc in Q31 */ + + sft = norm_l(L_sum); + L_sum = L_shl(L_sum, sft); + + *exp = sub(30, sft); + move16(); /* exponent = 0..30 */ + + return L_sum; +} + +Word32 sum2_fx( /* o : sum of all squared vector elements Q(2x+1)*/ + const Word16 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ +) +{ + Word16 i; + Word32 L_tmp; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + L_tmp = L_deposit_l(0); + FOR( i=0; i= 0; i--) + { + y[i] = x[i]; + move16(); + } + } +} + +/*-------------------------------------------------------------------* + * Copy32: + * + * Copy vector x[] to y[] (32 bits) + *-------------------------------------------------------------------*/ +void Copy32( + const Word32 x[], /* i : input vector */ + Word32 y[], /* o : output vector */ + const Word16 L /* i : vector length */ +) +{ + Word16 i; + IF(y < x) + { + FOR (i = 0; i < L; i++) + { + y[i] = x[i]; + move32(); + } + } + ELSE + { + FOR (i = L-1; i >= 0; i--) + { + y[i] = x[i]; + move32(); + } + } +} +/*-------------------------------------------------------------------* + * set16_fx() + * set32_fx() + * + * Set the vector elements to a value + *-------------------------------------------------------------------*/ +void set16_fx( + Word16 y[], /* i/o: Vector to set */ + const Word16 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ +) +{ + Word16 i; + + FOR (i=0 ; i 0) + { + FOR (i = 0; i < lg; i++) + { +#ifdef BASOP_NOGLOB + x[i] = shl_sat(x[i], exp0); +#else /* BASOP_NOGLOB */ + x[i] = shl(x[i], exp0); +#endif /* BASOP_NOGLOB */ + move16(); /* saturation can occur here */ + } + return; + } + IF (exp0 < 0) + { +#ifdef BASOP_NOGLOB + tmp = shl_sat(-32768, exp0); /* we use negative to correctly represent 1.0 */ +#else + BASOP_SATURATE_WARNING_OFF_EVS + tmp = shl(-32768, exp0); /* we use negative to correctly represent 1.0 */ + BASOP_SATURATE_WARNING_ON_EVS +#endif + FOR (i = 0; i < lg; i++) + { +#ifdef BASOP_NOGLOB + x[i] = msu_r_sat(0, x[i], tmp); +#else + x[i] = msu_r(0, x[i], tmp); +#endif + move16(); /* msu instead of mac because factor is negative */ + } + return; + } +} + +/*---------------------------------------------------------------------* + * mean() + * + *---------------------------------------------------------------------*/ +Word16 mean_fx( /* o : mean of vector */ + const Word16 *vec_fx, /* i : input vector */ + const Word16 lvec_fx /* i : length of input vector */ +) +{ + Word16 tmp; + printf("TBV : this function could be written differently to minimize the risk of saturation"); + tmp = sum16_fx(vec_fx,lvec_fx); + tmp = mult_r(tmp,div_s(1,lvec_fx)); + + return tmp; +} +/*-------------------------------------------------------------------* + * Vr_add + * + * Add two Word16 vectors together integer by integer + *-------------------------------------------------------------------*/ +void Vr_add( + const Word16 *in1, /* i : Input vector 1 */ + const Word16 *in2, /* i : Input vector 2 */ + Word16 *out, /* o : Output vector that contains vector 1 + vector 2 */ + Word16 Len /* i : Vector lenght */ +) +{ + Word16 i; + + FOR (i=0; i=lo; i--) + { + i1 = add(i, 1); + tempr = r[i]; + move16(); + move16(); /*supplementary move for the j-1 PTR initialization*/ + FOR (j=i1; j<=up; j++) + { + IF (LE_16(tempr, r[j])) + { + BREAK; + } + + r[j-1] = r[j]; + move16(); + } + r[j-1] = tempr; + move16(); + } +} + +void sort_32_fx( + Word32 *r, /* i/o: Vector to be sorted in place */ + const Word16 lo, /* i : Low limit of sorting range */ + const Word16 up /* I : High limit of sorting range */ +) +{ + Word16 i, j; + Word32 tempr; + FOR ( i=sub(up, 1); i>=lo; i-- ) + { + tempr = r[i]; + move32(); + FOR ( j=add(i, 1); j<=up; j++ ) + { + IF (LE_32(tempr,r[j])) + { + BREAK; + } + r[j-1] = r[j]; + move32(); + } + + r[j-1] = tempr; + move32(); + } + + return; +} + +Word16 minimum_fx( /* o : index of the minimum value in the input vector */ + const Word16 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word16 *min_fx /* o : minimum value in the input vector */ +) +{ + Word16 j, ind; + Word16 tmp; + ind = 0; + move16(); + tmp = vec_fx[0]; + move16(); + + FOR ( j=1 ; j 0) + { + ind = j; + move16(); + } + emax = L_max(emax, L_tmp); + } + +#ifdef BASOP_NOGLOB + *ener_max = L_shr_sat(emax, add(Qvec, Qvec)); +#else /* BASOP_NOGLOB */ + *ener_max = L_shr(emax, add(Qvec, Qvec)); +#endif /* BASOP_NOGLOB */ + move32(); + + return ind; +} +/*-------------------------------------------------------------------* + * mean32: + * + * Find the mean of a 32 bits vector + *-------------------------------------------------------------------*/ +Word32 Mean32( /* o : mean of the elements of the vector */ + const Word32 in[], /* i : input vector */ + const Word16 L /* i : length of input vector */ +) +{ + Word32 Ltmp; + Word16 inv_L; + + inv_L = INV_BANDS9; + move16(); + if (EQ_16(L, 10)) + { + inv_L = INV_BANDS10; + move16(); + } + + Ltmp = sum32_fx(in, L); + + Ltmp = Mult_32_16(Ltmp, inv_L); + + return Ltmp; +} +Word32 sum32_fx( /* o : sum of all vector elements Qx*/ + const Word32 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ +) +{ + Word16 i; + Word32 tmp; + + tmp = L_deposit_l(0); + FOR( i=0; i= 0) + { + expA = sub(expA, 1); + } + N = L_shl(Numer, expA); + + /* Perform Approximation of the Division + * Since 'lo' part is '0' AND 'denom' is supposed to be constant in the targeted usage + * one could import the Div32 code and pre-calc the div_s and eliminate all calcs + * with 'lo' to save some complexity */ + + Quotient = Div_32_optmz(N, D); /* takes 36 clocks */ + /* Bring Back to Q0 (minus 2 because we removed the left shift by 2 in the Div32_optmz) */ + IF(rshift) + { + Quotient = L_shr(Quotient, add(15-2, sub(expA, sub(expB,1)))); + } + ELSE + { + Quotient = L_shr(Quotient, add(15-2, sub(expA, expB))); + } + + /* Cross Check (do Quotient x Divisor) + * The Quotient is unsigned but we cannot just use extract_h because + * extract_l on the low part will get the sign of the bit #15. + * In a 32 bits value, what is in bits 0-15 is un unsigned 16 bits value. + * So, we shift left by 1, extract the hi part and mult it by 32768 (hence the L_shl by 16-1. + * Then we take 15 bits left (mask the others) and multiply by Denom. + * Technically this could overflow. But since we are mutiplying to get + * back to the Numer value that fitted in a 32 bits, doing Divisor x Quotient + * must necessarily fit in a 32 bits + * It is assumed that all are positive values. If not, one could + * check the sign of the numer and denom, turn them into abs values + * and restore the sign after*/ + TEMP = L_shl(L_mult0(extract_h(L_shl(Quotient, 1)), Denom), 16-1); + TEMP = L_mac0(TEMP, extract_l(L_and(0x7FFF, Quotient)), Denom); + + + + /* Here we test to see if the previous "Quotient x Divisor" (or TEMP) is too small + * that is the "Numer" minus TEMP is bigger or Equal to the Divisor. + * If it is then the quotient is too small. We need to increase it by 1. + * That is caused by our Div32 fractionnal division that can be off by 1 + * sometimes. + * In some cases, when the divisor is very small (like 10 or something) + * the quotient could be off by more than 1 and we would need a loop + * to check again. That is not the case here with the current divisor */ + IF(rshift) + { + TEMP = L_shl(TEMP, 1); + WHILE (L_msu0(L_sub(Numer, TEMP), 2, Denom) >= 0) + { + Quotient = L_add(Quotient, 1); + TEMP = L_shl(L_mult0(extract_h(L_shl(Quotient, 1)), Denom), 16-1); + TEMP = L_mac0(TEMP, extract_l(L_and(0x7FFF, Quotient)), Denom); + TEMP = L_shl(TEMP, 1); + } + } + ELSE + { + WHILE (L_msu0(L_sub(Numer, TEMP), 1, Denom) >= 0) + { + Quotient = L_add(Quotient, 1); + TEMP = L_shl(L_mult0(extract_h(L_shl(Quotient, 1)), Denom), 16-1); + TEMP = L_mac0(TEMP, extract_l(L_and(0x7FFF, Quotient)), Denom); + } + } + *Int_quotient = Quotient; + move32(); + IF(L_msu0(L_sub(Numer, TEMP), 1, Denom) == 0) + { + *Int_mod = 0L; + move32(); + } + ELSE + { + *Int_mod = L_sub(Numer, TEMP); + move32(); + } + + +} + +/*===================================================================*/ +/* FUNCTION : pz_filter_sp_fx () */ +/*-------------------------------------------------------------------*/ +/* PURPOSE : Generic pole-zero filter routine, with single */ +/* precision memory */ +/*-------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* */ +/* _ (Word16 []) b : zero filter coefficients (Qc). */ +/* _ (Word16 []) a : pole filter coefficients (Qc), a(0)=1 in Qc */ +/* _ (Word16 []) x : input signal (Qn). */ +/* _ (Word16) PNR : NR filter order */ +/* _ (Word16) PDR : DR filter order */ +/* _ (Word16) N : number of input samples. */ +/* _ (Word16) Qa : Q factor compensation (Qa=16-Qc) */ +/*-------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* */ +/* _ (Word16 []) y : output signal (Qn) */ +/*-------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* */ +/* _ (Word16 []) buf : filter memory (Qn-Qa). */ +/*-------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : _ None. */ +/*===================================================================*/ + +void pz_filter_sp_fx ( + const Word16 b [], + const Word16 a [], + Word16 x [], + Word16 y [], + Word16 buf [], + Word16 PNR, + Word16 PDR, + Word16 N, + Word16 Qa +) +{ + Word16 i, j; + Word16 s; + Word16 s_mem; + Word32 Ltemp1; + Word32 Lacc; + s = negate( Qa ); + s = add( s, s ); /* s=-2Qa*/ + s = add( s, 1 ); + FOR ( i = 0; i < N; i++ ) + { + Lacc = L_deposit_h( x[i] ); /* Lacc in Q(16+Qn)*/ + Lacc = L_shl( Lacc, s ); /* Lacc=x[i] in Q(16+Qn-2Qa+1)*/ + FOR ( j = PDR - 1; j >= 0; j-- ) + Lacc = L_msu( Lacc, buf[j], a[j + 1] ); /*Q(16+Qn-2Qa+1)*/ + + + + Lacc = L_shr( Lacc, 1 ); +#ifdef BASOP_NOGLOB + Ltemp1 = L_add_sat( L_shl_sat( Lacc, Qa), 0x08000); +#else + Ltemp1 = L_add( L_shl( Lacc, Qa ), 0x08000 ); +#endif + s_mem = extract_h( Ltemp1 ); + + Lacc = L_deposit_l(0); + FOR ( j = PNR - 1; j >= 0; j-- ) + Lacc = L_mac( Lacc, buf[j], b[j + 1] ); + Lacc = L_mac( Lacc, s_mem, b[0] ); + /* Lacc in Q(1+Qc+Qn-Qa)*/ + + FOR ( j = s_max(PDR, PNR ) - 1; j > 0; j-- ) + { + /* Update filter memory */ + buf[j] = buf[j - 1]; + move16(); + } + buf[0] = s_mem; + move16(); + +#ifdef BASOP_NOGLOB + Ltemp1 = L_add_sat( L_shr_sat( Lacc, s ), 0x08000 ); /* Ltemp1 in Qc+Qa+Qn=Q(Qn) */ +#else + Ltemp1 = L_add( L_shr( Lacc, s ), 0x08000 ); /* Ltemp1 in Qc+Qa+Qn=Q(Qn) */ +#endif + y[i] = extract_h( Ltemp1 ); /* y[i] in Qn */ + } +} + + + +Word32 root_a_fx( + Word32 a, + Word16 Q_a, + Word16* exp_out +) +{ + Word16 exp, tmp; + Word32 L_tmp; + + if ( a <= 0 ) + { + *exp_out = 0; + return 0; + } + + exp = norm_l( a ); + tmp = extract_h( L_shl( a, exp ) ); + exp = sub( exp, sub(30, Q_a) ); + tmp = div_s( 16384, tmp ); + L_tmp = L_deposit_h( tmp ); + L_tmp = Isqrt_lc( L_tmp, &exp ); + + *exp_out = exp; + move16(); + + return L_tmp; +} + + +Word32 root_a_over_b_fx( + Word32 a, + Word16 Q_a, + Word32 b, + Word16 Q_b, + Word16* exp_out +) +{ + Word16 tmp, num, den, scale; + Word16 exp, exp_num, exp_den; + Word32 L_tmp; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + test(); + if ( ( a <= 0 ) || ( b <= 0 ) ) + { + *exp_out = 0; + move16(); + return 0; + } + + exp_num = norm_l( b ); +#ifdef BASOP_NOGLOB + num = round_fx_o( L_shl_o( b, exp_num, &Overflow ), &Overflow); +#else + num = round_fx( L_shl( b, exp_num ) ); +#endif + exp_num = sub( sub( 30, exp_num ), Q_b ); + + exp_den = norm_l( a ); +#ifdef BASOP_NOGLOB + den = round_fx_o( L_shl_o( a, exp_den , &Overflow) , &Overflow); +#else /* BASOP_NOGLOB */ + den = round_fx( L_shl( a, exp_den ) ); +#endif /* BASOP_NOGLOB */ + exp_den = sub( sub( 30, exp_den ), Q_a ); + + scale = shr( sub( den, num ), 15 ); +#ifdef BASOP_NOGLOB + num = shl_o( num, scale, &Overflow ); +#else + num = shl( num, scale ); +#endif + exp_num = sub( exp_num, scale ); + + tmp = div_s( num, den ); + exp = sub( exp_num, exp_den ); + + L_tmp = L_deposit_h( tmp ); + L_tmp = Isqrt_lc( L_tmp, &exp ); + + *exp_out = exp; + move16(); + + return L_tmp; +} + +/*===================================================================*/ +/* FUNCTION : fir_fx () */ +/*-------------------------------------------------------------------*/ +/* PURPOSE : Generic FIR filter routine */ +/*-------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* */ +/* _ (Word16 []) b : filter coefficients (Qc). */ +/* _ (Word16 []) x : input signal (Qn). */ +/* _ (Word16) P : filter order. */ +/* _ (Word16) N : number of input samples. */ +/* _ (Word16) Qa : Q factor compensation (Qa=16-Qc) */ +/*-------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* */ +/* _ (Word16 []) y : output signal (Qn) */ +/*-------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* */ +/* _ : None */ +/*-------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : _ None. */ +/*===================================================================*/ +void fir_fx( const Word16 x[], /* i : input vector Qx*/ + const Word16 h[], /* i : impulse response of the FIR filter Q12*/ + Word16 y[], /* o : output vector (result of filtering) Qx*/ + Word16 mem[], /* i/o: memory of the input signal (L samples) Qx*/ + const Word16 L, /* i : input vector size */ + const Word16 K, /* i : order of the FIR filter (K+1 coefs.) */ + const Word16 upd /* i : 1 = update the memory, 0 = not */ + , Word16 shift /* i : difference between Q15 and scaling of h[] */ + ) +{ + + Word16 buf_in[L_FRAME32k+L_FILT_MAX]; + Word16 i, j; + Word32 s; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + /* prepare the input buffer (copy and update memory) */ + Copy( mem, buf_in, K ); + Copy( x, buf_in + K, L ); + IF ( upd ) + { + Copy( buf_in + L, mem, K ); + } + + /* do the filtering */ + FOR ( i = 0; i < L; i++ ) + { +#ifdef BASOP_NOGLOB + s = L_mult_o( buf_in[K + i], h[0], &Overflow ); + + FOR ( j = 1; j <= K; j++ ) + { + s = L_mac_o( s, h[j], buf_in[K + i - j], &Overflow); + } + s = L_shl_o( s, shift, &Overflow); + y[i] = round_fx_o( s, &Overflow); /*Qx */ +#else + s = L_mult( buf_in[K + i], h[0] ); + + FOR ( j = 1; j <= K; j++ ) + { + s = L_mac( s, h[j], buf_in[K + i - j] ); + } + s = L_shl( s, shift ); + y[i] = round_fx( s ); /*Qx */ +#endif + } +} + + +/*--------------------------------------------------------------------------------*/ +/* squant_fx() */ +/*--------------------------------------------------------------------------------*/ +Word16 squant_fx( /* o: index of the winning codeword */ + const Word16 x, /* i: scalar value to quantize */ + Word16* xq, /* o: quantized value */ + const Word16 cb[], /* i: codebook */ + const Word16 cbsize /* i: codebook size */ +) +{ + Word16 tmp; + Word16 c, idx; + Word32 L_mindist, L_dist; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + idx = 0; + move16(); + L_mindist = MAX_32; + move32(); + + FOR ( c = 0; c < cbsize; c++ ) + { + L_dist = L_deposit_l(0); +#ifdef BASOP_NOGLOB + tmp = sub_o( x, cb[c] , &Overflow); +#else /* BASOP_NOGLOB */ + tmp = sub( x, cb[c] ); +#endif /* BASOP_NOGLOB */ + + /*dist += tmp*tmp; */ +#ifdef BASOP_NOGLOB + L_dist = L_mac_o( L_dist, tmp, tmp , &Overflow); +#else /* BASOP_NOGLOB */ + L_dist = L_mac( L_dist, tmp, tmp ); +#endif /* BASOP_NOGLOB */ + + if ( LT_32( L_dist, L_mindist )) + { + idx = c; + move16(); + } + L_mindist = L_min(L_mindist, L_dist); + } + + *xq = cb[idx]; + move16(); + + return idx; +} + + +/*===================================================================*/ +/* FUNCTION : pz_filter_dp_fx () */ +/*-------------------------------------------------------------------*/ +/* PURPOSE : Generic pole-zero filter routine, with double */ +/* precision memory, transposed direct form II */ +/*-------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* */ +/* _ (Word16 []) b : zero filter coefficients (Qc). */ +/* _ (Word16 []) a : pole filter coefficients (Qc), a(0)=1 */ +/* _ (Word16 []) x : input signal (Qx). */ +/* _ (Word16) P : filter order. */ +/* _ (Word16) N : number of input samples. */ +/* _ (Word16) Qa : Q factor compensation (Qa=16-Qc) */ +/*-------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* */ +/* _ (Word16 []) y : output signal (Qx) */ +/*-------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* */ +/* _ (Word32 []) buf : filter memory (Qx+Qc) */ +/*-------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : _ None. */ +/*===================================================================*/ + +void pz_filter_dp_fx ( + const Word16 b [], + const Word16 a [], + Word16 x [], + Word16 y [], + Word32 buf [], + Word16 PNR, + Word16 PDR, + Word16 N, + Word16 Qa +) +{ + Word16 i, j; + Word16 s; + Word32 s_mem; + Word32 Ltemp1; + Word32 Lacc; + + s = negate( Qa ); + s = add( s, s ); /* s=-2Qa */ + s = add( s, 1 ); + FOR ( i = 0; i < N; i++ ) + { + Lacc = L_deposit_h( x[i] ); /* Lacc in Q(16+Qn)*/ + Lacc = L_shl( Lacc, s ); /* Lacc=x[i] in Q(16+Qn-2Qa+1)*/ + FOR ( j = PDR - 1; j >= 0; j-- ) + Lacc = Msub_32_16( Lacc, buf[j], a[j + 1] ); /*Q(16+Qn-2Qa+1)*/ + + s_mem = L_shl( Lacc, sub( Qa, 1 ) ); /*Qn-Qa+16=Qn+Qc*/ + + Lacc = L_deposit_l(0); + FOR ( j = PNR - 1; j >= 0; j-- ) + Lacc = Madd_32_16( Lacc, buf[j], b[j + 1] ); + Lacc = Madd_32_16( Lacc, s_mem, b[0] ); + /* Lacc in Q(1+Qc+Qn-Qa) */ + + FOR ( j = s_max( PDR, PNR ) - 1; j > 0; j-- ) + { + /* Update filter memory */ + buf[j] = buf[j - 1]; + move16(); + } + buf[0] = s_mem; + move16(); + + Ltemp1 = L_shr( Lacc, s ); /* Ltemp1 in Qc+Qa+Qn=Q(16+Qn) */ + y[i] = extract_h( Ltemp1 ); /* y[i] in Qn */ + } +} + +/*-------------------------------------------------------------------* + * Copy_Scale_sig32_16 + * + * Up/down scale a 32 bits vector and round to 16 bits vector + *-------------------------------------------------------------------*/ +void Copy_Scale_sig32_16( + const Word32 *src, /* i : signal to scale Qx */ + Word16 *dst, /* o : scaled signal Qx */ + Word16 len, /* i : size of x[] Q0 */ + Word16 exp0) /* i : exponent: x = round(x << exp) Qx ?exp */ +{ + Word16 i; + Word32 L_temp; + + IF (exp0 == 0) + { + FOR (i = 0; i < len; i++ ) + { + *dst++ = round_fx(*src++); + } + return; + } + + FOR (i = 0; i < len; i++ ) + { + L_temp = L_shl(*src++, exp0); + + *dst++ = round_fx(L_temp); + } +} + +/*-------------------------------------------------------------------* + * v_multc_att() + * + * Attenuation of a vector,, attenuation factor in Q15 + *-------------------------------------------------------------------*/ + +void v_multc_att( + const Word16 x[], /* i : Input vector Qx */ + const Word16 att, /* i : Constant Q15, <= MAX_16 */ + Word16 y[], /* o : Output vector that contains att*x */ + const Word16 N /* i : Vector length */ +) +{ + Word16 i; + IF(LT_16(att, 32767)) + { + FOR(i = 0; i < N; i++) + { + y[i] = mult_r(x[i], att); + move16(); + } + } +}/*-------------------------------------------------------------------* + * v_multc_att32() + * + * Attenuation of a vector,, attenuation factor in Q15 + *-------------------------------------------------------------------*/ + +void v_multc_att32( + const Word32 x[], /* i : Input vector Qx */ + const Word16 att, /* i : Constant Q15, <= MAX_16 */ + Word32 y[], /* o : Output vector that contains att*x */ + const Word16 N /* i : Vector length */ +) +{ + Word16 i; + IF(LT_16(att, 32767)) + { + FOR(i = 0; i < N; i++) + { + y[i] = Mpy_32_16_r(x[i], att); + move32(); + } + } +} +/*-------------------------------------------------------------------* + * add_vec() + * + * Addition of two vectors sample by sample + *-------------------------------------------------------------------*/ + +void add_vec_fx( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 Qx1, /* i : SCaling of input 1 */ + const Word16 x2[], /* i : Input vector 2 */ + const Word16 Qx2, /* i : SCaling of input 1 */ + Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 Qy, /* i : SCaling of output 1 */ + const Word16 N /* i : Vector lenght */ +) +{ + Word16 i, Qyx1, Qyx2; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + Qyx1 = sub(Qx1,Qy); + Qyx2 = sub(Qx2,Qy); + IF (Qyx1 == 0) + { + FOR (i=0 ; i0: Val was Left Shifted, <0:Right Shifted) */ + Word32 L_val2, /* i: Mantisa of Val2 */ + Word16 exp2, /* i: Exp of Val2 (same as exp1) */ + Word16 *exp /* o: Exp of Result (# of 'L_shl' Req to get to Final Value) */ +) +{ + Word16 temp; + + /* Normalize Energy #1 */ + temp = norm_l(L_val1); + L_val1 = L_shl(L_val1, temp); + /* Adjust Exponent of Energy #1 */ + exp1 = add(exp1, temp); + + /* Normalize Energy #2 */ + temp = norm_l(L_val2); + L_val2 = L_shl(L_val2, temp); + /* Adjust Exponent of Energy #1 */ + exp2 = add(exp2, temp); + + /* Prepare for Inverse */ +#ifdef BASOP_NOGLOB + temp = round_fx_sat(L_val1); +#else + temp = round_fx(L_val1); +#endif + temp = div_s(16384, temp); + /* Mult Now */ + L_val2 = Mult_32_16(L_val2, temp); + exp1 = add(sub(exp2, exp1), 15*2); + + /* Here Result of ('L_val2' / 2^'exp2') / ('L_val1' / 2^'exp1') is */ + /* 'L_val2' / 2^'exp1' */ + /* Which is val2/val1 instead of val1/val2 because we will use Inverted Square Root */ + /* Normalize before Square Root */ + temp = norm_l(L_val2); + L_val2 = L_shl(L_val2, temp); + exp1 = add(temp, exp1); + /* Do Sqrt */ + temp = sub(31, exp1); + L_val1 = Isqrt_lc(L_val2, &temp); + + *exp = temp; + move16(); + + return L_val1; +} + +Word16 Invert16( /* result in Q'15 + 'exp' */ + Word16 val, + Word16 *exp) +{ + Word16 temp; + + /* prevent 0 input */ + val = s_max(val,1); + /* Normalize Value */ + temp = norm_s(val); + val = shl(val, temp); + + *exp = sub(sub(15-1, *exp), temp); + move16();/* -1 because of 0x4000 is 1.0 in Q14 (and not Q15) */ + + temp = div_s(0x4000, val); + + return temp; +} + +Word16 find_rem(Word16 n, Word16 m, Word16 *r) +{ + Word16 i, q1, q2, qd; + Word32 Ltemp2; + Word32 Lacc; + + test(); + test(); + IF (n<=0 || m<=0 || n=0) + { + Lacc=L_add(L_shl(Lacc,1),1); + } + ELSE + { + Lacc=L_add(Lacc,Ltemp2); + Lacc=L_shl(Lacc,1); + } + } + q1=extract_l(Lacc); + Ltemp2=L_shr(Lacc,q2); + *r=extract_h(Ltemp2); + return(q1); +} + + +Word32 find_remd(Word32 n, Word32 m, Word32 *r) +{ + Word16 i, q1, q2, qd; + Word32 Ltemp2, qo; + Word32 Lacc; + + test(); + test(); + IF (n<=0 || m<=0 || n=0) + { + Lacc=L_shl(Lacc,1); + qo=L_add(qo,1); + } + ELSE + { + Lacc=L_add(Lacc,Ltemp2); + Lacc=L_shl(Lacc,1); + } + } + *r=L_shr(Lacc,q2); + return(qo); +} + +Word16 rint_new_fx ( + Word32 x /*Q16 */ +) +{ + Word16 a; + Word32 L_tmp; + Word16 frac, tmp; + + /* middle value point test */ + frac = lshr(extract_l(x),1); /*Q15 */ + tmp = sub(frac,0x4000); + + IF (!tmp) + { + a = add(extract_h(x),1); + + if (s_and(a,1) == 0) + { + return a; + } + if (s_and(a,1) != 0) + { + return extract_h(x); + } + return extract_h(x); + } + ELSE + { + L_tmp = L_add(x,32768); /*Q16 */ + return extract_h(L_tmp); + } +} + + +/*===================================================================*/ +/* FUNCTION : erb_diff_search_fx () */ +/*-------------------------------------------------------------------*/ +/* PURPOSE : erb amplitude VQ search for QPPP */ +/*-------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* _ (Word16 []) prev_erb : Previous erb amplitude, Q13 */ +/* _ (Word16 []) curr_erb : Current erb amplitude, Q13 */ +/* _ (Word16 []) dif_erb: erb differential, Q13 */ +/* _ (Word16 []) pow_spec : LPC power spectrum, Q7 */ +/* _ (Word16 [][]) cb_fx : differential erb codebook, Q13 */ +/* _ (Word16) cb_size : codebook size */ +/* _ (Word16) cb_dim : codebook dimension */ +/* _ (Word16) offset : index to current segment of erb array */ +/* for quantization */ +/*-------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ None */ +/*-------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ None */ +/*-------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ (Word16) index: best codebook index */ +/*-------------------------------------------------------------------*/ +/* CALLED FROM : TX */ +/*===================================================================*/ + +Word16 erb_diff_search_fx(Word16 *prev_erb, const Word16 *curr_erb, Word16 *dif_erb, + Word16 *pow_spec, const Word16 *cb_fx, + Word16 cb_size, Word16 cb_dim, Word16 offset) +{ + Word16 i, j, mmseindex ; + Word16 dh, dl; + Word32 mmse; + Word32 Ltemp1; + Word32 Lacc; + + mmse = EVS_LW_MAX; + move32(); + mmseindex = -1; + move16(); + FOR (j=0; j b[3] = {0.893554687, -1.787109375, 0.893554687}; * + * a[3] = {1.000000000, 1.787109375, -0.864257812}; * + *-----------------------------------------------------------------------*/ +void hp400_12k8_fx( + Word16 signal[], /* i/o: input signal / output is divided by 16 */ + const Word16 lg, /* i : lenght of signal */ + Word16 mem[] /* i/o: filter memory [6] */ +) +{ + Word16 i; + Word16 y1_hi, y1_lo; + Word32 L_tmp, L_tmp2, L_tmp3; + + y1_hi = mem[2]; + move16(); + y1_lo = mem[3]; + move16(); + + L_tmp3 = L_mac(16384L, mem[1], a_hp400_fx[2]); /* rounding to maximize precision */ + L_tmp3 = L_mac(L_tmp3, y1_lo, a_hp400_fx[1]); + L_tmp3 = L_shr(L_tmp3, 15); + L_tmp2 = L_mac(L_tmp3, mem[0], a_hp400_fx[2]); + L_tmp2 = L_mac(L_tmp2, mem[5], b_hp400_fx[2]); + L_tmp2 = L_mac(L_tmp2, mem[4], b_hp400_fx[1]); + L_tmp3 = L_mult(mem[4], b_hp400_fx[2]); + + mem[5] = signal[lg-2]; + + FOR (i = 1; i < lg; i++) + { + /* y[i] = b[0]*x[i] + b[1]*x[i-1] + b[2]*x[i-2] */ + /* + a[1]*y[i-1] + a[2] * y[i-2] */ + + L_tmp = L_mac(L_tmp2, y1_hi, a_hp400_fx[1]); + L_tmp = L_mac(L_tmp, *signal, b_hp400_fx[0]); + + L_tmp = L_shl(L_tmp, 1); /* coeff Q12 --> Q13 */ + + L_tmp2 = L_mac(L_tmp3, y1_hi, a_hp400_fx[2]); + L_tmp2 = L_mac(L_tmp2, *signal, b_hp400_fx[1]); + L_tmp3 = L_mac(16384L, y1_lo, a_hp400_fx[2]); /* rounding to maximize precision */ + + y1_lo = L_Extract_lc(L_tmp, &y1_hi); + + L_tmp3 = L_mac(L_tmp3, y1_lo, a_hp400_fx[1]); + L_tmp3 = L_shr(L_tmp3, 15); + + L_tmp2 = L_add(L_tmp3, L_tmp2); + + L_tmp3 = L_mult(*signal, b_hp400_fx[2]); + + /* signal is divided by 16 to avoid overflow in energy computation */ + *signal++ = round_fx(L_tmp); + } + + /* y[i] = b[0]*x[i] + b[1]*x[i-1] + b[2]*x[i-2] */ + /* + a[1]*y[i-1] + a[2] * y[i-2] */ + + L_tmp = L_mac(L_tmp2, y1_hi, a_hp400_fx[1]); + + mem[4] = *signal; + move16(); + L_tmp = L_mac(L_tmp, mem[4], b_hp400_fx[0]); + + L_tmp = L_shl(L_tmp, 1); /* coeff Q12 --> Q13 */ + + mem[0] = y1_hi; + move16(); + mem[1] = y1_lo; + move16(); + L_Extract(L_tmp, &mem[2], &mem[3]); + + /* signal is divided by 16 to avoid overflow in energy computation */ + *signal++ = round_fx(L_tmp); + + return; +} + + +Word16 dot_prod_satcontr(const Word16 *x, const Word16 *y, Word16 qx, Word16 qy, Word16 *qo, Word16 len) +{ + Word16 tmp_tab_x[L_FRAME16k]; + Word16 tmp_tab_y[L_FRAME16k]; + Word16 shift, q, ener, i; + Word32 L_tmp; + Word16 *pt1, *pt2; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + + Copy( x, tmp_tab_x, len ); /* OPTIMIZE !!!!! the copy into local table is not necessary */ + Copy( y, tmp_tab_y, len ); /* could be reworked to do a 1st iteration with the original x[] and y[] */ + /* then check if there is an overflow and do a more complex 2nd, 3rd, ... processing */ + shift = 0; + move16(); + BASOP_SATURATE_WARNING_OFF_EVS + DO + { + Overflow = 0; + move16(); +#ifdef BASOP_NOGLOB /* Critical Overflow and all those below*/ + L_tmp = L_shl_o(1, s_max(sub(add(add(qx, qy), 7), shift), 0), &Overflow); +#else /* BASOP_NOGLOB */ + L_tmp = L_shl(1, s_max(sub(add(add(qx, qy), 7), shift), 0)); +#endif /* BASOP_NOGLOB */ + pt1 = tmp_tab_x; + pt2 = tmp_tab_y; + FOR ( i = 0; i < len; i++ ) + { +#ifdef BASOP_NOGLOB + L_tmp = L_mac0_o(L_tmp, *pt1++, *pt2++, &Overflow); /*Q(qx+qy-shift) */ +#else /* BASOP_NOGLOB */ + L_tmp = L_mac0(L_tmp, *pt1++, *pt2++); /*Q(qx+qy-shift) */ +#endif + } + + IF(Overflow != 0) + { + Scale_sig(tmp_tab_x, len, -2); + Scale_sig(tmp_tab_y, len, -2); + shift = add(shift, 4); + } + } + WHILE(Overflow != 0); + BASOP_SATURATE_WARNING_ON_EVS + + q = norm_l(L_tmp); + L_tmp = L_shl(L_tmp, q); /*Q(qx+qy-shift+q) */ + ener = extract_h(L_tmp); /*Q(qx+qy-shift+q-16) */ + q = add(q, add(qx, qy)); + *qo = sub(q, add(shift, 16)); + + return ener; +} + + +/* + * E_UTIL_f_convolve + * + * Parameters: + * x I: input vector <14bits + * h I: impulse response (or second input vector) (1Q14) + * y O: output vetor (result of convolution) + * + * Function: + * Perform the convolution between two vectors x[] and h[] and + * write the result in the vector y[]. All vectors are of length L. + * Only the first L samples of the convolution are considered. + * Vector size = L_SUBFR + * + * Returns: + * void + */ +void E_UTIL_f_convolve(const Word16 x[], const Word16 h[], Word16 y[], const Word16 size) +{ + Word16 i, n; + Word32 L_sum; + Word64 L64_sum; + + FOR (n = 0; n < size; n++) + { + L64_sum = 0; + FOR (i = 0; i < n; i++) + { + L64_sum = W_mac_16_16(L64_sum, x[i], h[n - i]); + } + L_sum = W_sat_l(L64_sum); + y[n] = mac_r(L_sum, x[i], h[0]); + } + return; +} + +/*----------------------------------------------------------------------------- + * floating_point_add: + * + * Add two floating point numbers: x <- x + y. + *----------------------------------------------------------------------------*/ +void floating_point_add( + Word32 *mx, /* io: mantissa of the addend Q31 */ + Word16 *ex, /* io: exponent of the addend Q0 */ + const Word32 my, /* i: mantissa of the adder Q31 */ + const Word16 ey /* i: exponent of the adder Q0 */ +) +{ + Word32 accX, accY; + Word16 align, expo; + /* NB: This function will not work properly if the mantissa is zero and the exponent is not 32. + It is up to the caller function to avoid this condition. */ + /* Ensure 1 bit headroom before addition. */ + accX = L_shr(*mx, 1); + accY = L_shr(my, 1); + /* First, align the Q-points of the two operands. Then, add. */ + align = sub(*ex, ey); + test(); + IF (align < 0) + { + accX = L_add(accX, L_shl(accY, align)); + } + ELSE + { + accX = L_add(accY, L_shr(accX, align)); + *ex = ey; + move16(); + } + /* Normalize the result and update the mantissa and exponent. */ + expo = norm_l(accX); + *mx = L_shl(accX, expo); + *ex = sub(add(*ex, expo), 1); /* Subtract 1 due to 1-bit down-shift above ensuring 1 bit headroom before addition. */ + return; +} +/*-------------------------------------------------------------------* + * delay_signal() + * + * Delay buffer by defined number of samples + *-------------------------------------------------------------------*/ + +void delay_signal( + Word16 x[], /* i/o: signal to be delayed */ + const Word16 len, /* i : length of the input signal */ + Word16 mem[], /* i/o: synchronization memory */ + const Word16 delay /* i : delay in samples */ +) +{ + Word16 tmp_buffer[L_FRAME48k]; + + Copy(mem, tmp_buffer, delay); + Copy(x + len - delay, mem, delay); + Copy(x, x + delay, len - delay); + Copy(tmp_buffer, x, delay); + + return; +} diff --git a/lib_com/typedef.h b/lib_com/typedef.h index 9b1ed7bc9..7b17aed92 100644 --- a/lib_com/typedef.h +++ b/lib_com/typedef.h @@ -62,7 +62,7 @@ | Basic types. | |_____________________| */ - +#define ENH_64_BIT_OPERATOR #ifndef TYPEDEF_H #define TYPEDEF_H @@ -118,6 +118,14 @@ typedef int Flag; #define TYPEDEF_INITIALIZED #endif +/* Definition of Word64 */ +#ifdef ENH_64_BIT_OPERATOR +#define Word64 long long int +#endif /* #ifdef ENH_64_BIT_OPERATOR */ + +/* Definition of Word40 was missing 10/06/2013 */ +#define Word40 long long + typedef float Float32; #ifndef TYPEDEF_INITIALIZED diff --git a/lib_com/typedefs.h b/lib_com/typedefs.h new file mode 100644 index 000000000..c0e7645a7 --- /dev/null +++ b/lib_com/typedefs.h @@ -0,0 +1,218 @@ +/* + =========================================================================== + File: TYPEDEFS.H v.2.3 - 30.Nov.2009 + =========================================================================== + + ITU-T STL BASIC OPERATORS + + NEW TYPE DEFINITION PROTOTYPES + + History: + 03 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control + operators for the ITU-T Standard Tool Library as + described in Geneva, 20-30 January 2004 WP 3/16 Q10/16 + TD 11 document and subsequent discussions on the + wp3audio@yahoogroups.com email reflector. + + Editor comment : + This file is not yet used or validated since + ORIGINAL_TYPEDEF_H compilation flag is defined in + typedef.h. This file is incorporated for future + reference / usage. + + ============================================================================ +*/ + + +/****************************************************************************** + * + * File : typedefs.h + * Description : Definition of platform independent data + * types and constants + * + * + * The following platform independent data types and corresponding + * preprocessor (#define) constants are defined: + * + * defined type meaning corresponding constants + * ---------------------------------------------------------- + * Char character (none) + * Bool boolean true, false + * Word8 8-bit signed minWord8, maxWord8 + * UWord8 8-bit unsigned minUWord8, maxUWord8 + * Word16 16-bit signed minWord16, maxWord16 + * UWord16 16-bit unsigned minUWord16, maxUWord16 + * Word32 32-bit signed minWord32, maxWord32 + * UWord32 32-bit unsigned minUWord32, maxUWord32 + * Float floating point minFloat, maxFloat + * + * + * The following compile switches are #defined: + * + * PLATFORM string indicating platform progam is compiled on + * possible values: "OSF", "PC", "SUN" + * + * OSF only defined if the current platform is an Alpha + * PC only defined if the current platform is a PC + * SUN only defined if the current platform is a Sun + * + * LSBFIRST is defined if the byte order on this platform is + * "least significant byte first" -> defined on DEC Alpha + * and PC, undefined on Sun + * + *****************************************************************************/ + + +#ifndef _TYPEDEFS_H +#define _TYPEDEFS_H "$Id $" + +/***************************************************************************** + * INCLUDE FILES + *****************************************************************************/ +#include +#include + +#define ENH_64_BIT_OPERATOR + +/***************************************************************************** + * DEFINITION OF CONSTANTS + *****************************************************************************/ +/* + ********* define char type + */ +typedef char Char; + +typedef unsigned short int UNS_Word16; /* 16 bit "register" (sw*) */ +#ifdef UNS_Word16 +#pragma message ("UNS_Word16 is defined but not officially part of STL2009@") +#endif + +/* + ********* define 8 bit signed/unsigned types & constants + */ +#if SCHAR_MAX == 127 +typedef signed char Word8; +#define minWord8 SCHAR_MIN +#define maxWord8 SCHAR_MAX + +typedef unsigned char UWord8; +#define minUWord8 0 +#define maxUWord8 UCHAR_MAX +#else +#error cannot find 8-bit type +#endif + + +/* + ********* define 16 bit signed/unsigned types & constants + */ +#if INT_MAX == 32767 +typedef int Word16; +#define minWord16 INT_MIN +#define maxWord16 INT_MAX +typedef unsigned int UWord16; +#define minUWord16 0 +#define maxUWord16 UINT_MAX +#elif SHRT_MAX == 32767 +typedef short Word16; +#define minWord16 SHRT_MIN +#define maxWord16 SHRT_MAX +typedef unsigned short UWord16; +#define minUWord16 0 +#define maxUWord16 USHRT_MAX +#else +#error cannot find 16-bit type +#endif + +/* Definition of Word64 */ +#ifdef ENH_64_BIT_OPERATOR +#define Word64 long long int +#endif /* #ifdef ENH_64_BIT_OPERATOR */ + +/* Definition of Word40 was missing 10/06/2013 */ +#define Word40 long long + +/* + ********* define 32 bit signed/unsigned types & constants + */ +#if INT_MAX == 2147483647 +typedef int Word32; +#define minWord32 INT_MIN +#define maxWord32 INT_MAX +typedef unsigned int UWord32; +#define minUWord32 0 +#define maxUWord32 UINT_MAX +#elif LONG_MAX == 2147483647 +typedef long Word32; +#define minWord32 LONG_MIN +#define maxWord32 LONG_MAX +typedef unsigned long UWord32; +#define minUWord32 0 +#define maxUWord32 ULONG_MAX +#else +#error cannot find 32-bit type +#endif + +/* + ********* define floating point type & constants + */ +/* use "if 0" below if Float should be double; + use "if 1" below if Float should be float + */ +#if 0 +typedef float Float; +#define maxFloat FLT_MAX +#define minFloat FLT_MIN +#else +typedef double Float; +#define maxFloat DBL_MAX +#define minFloat DBL_MIN +#endif + +/* + ********* define complex type + */ +typedef struct { + Float r; /* real part */ + Float i; /* imaginary part */ +} CPX; + +/* + ********* define boolean type + */ +typedef int Bool; +#define false 0 +#define true 1 + +/* + ********* Check current platform + */ +#if defined (__MSDOS__) +#define PC +#define PLATFORM "PC" +#define LSBFIRST +#elif defined (__osf__) +#define OSF +#define PLATFORM "OSF" +#define LSBFIRST +#elif defined (__sun__) || defined (__sun) +#define SUN +#define PLATFORM "SUN" +#undef LSBFIRST +#elif defined (linux) && defined (i386) +#define PC +#define PLATFORM "PC" +#define LSBFIRST +#else +/*#error "can't determine architecture; adapt typedefs.h to your platform"*/ +/* for MSVC 2008 10/06/2013 */ +#define PC +#define PLATFORM "PC" +#define LSBFIRST +#endif + + +#endif /* ifndef _TYPEDEFS_H */ + + +/* end of file */ diff --git a/lib_debug/debug.c b/lib_debug/debug.c new file mode 100644 index 000000000..736f35d43 --- /dev/null +++ b/lib_debug/debug.c @@ -0,0 +1,978 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include "options.h" +#ifdef DEBUGGING +#include "debug.h" +#ifdef DEBUG_MODE_INFO +#ifdef DEBUG_MODE_INFO_TWEAK +#include +#include +#endif +#endif +#endif +#include "cnst.h" +#include +#include +#include +#ifdef _WIN32 +#include +#else +#endif +#ifdef DBG_WAV_WRITER +#include "tinywaveout_c.h" +#endif +#include "wmc_auto.h" + + +/*-------------------------------------------------------------------* + * Global variables used for debugging but not under DEBUGGING flag + *--------------------------------------------------------------------*/ + +#ifdef DEBUGGING +uint16_t g_nPrintedLines = 0; + +int16_t g_verbose = 0; /* global variable for debugging */ +#ifdef DEBUG_MODE_INFO +#ifdef DEBUG_MODE_INFO_TWEAK +char infoFolder[FILENAME_MAX]; +#endif +#endif +#endif + +FILE *DJB_delay = NULL; /* per-frame de-jitter buffer delay dump out file */ + +#ifdef DEBUGGING +int16_t debug_level = 0; +#endif + +/*-------------------------------------------------------------------* + * Read/write I/O tool + *--------------------------------------------------------------------*/ + +#ifdef DEBUGGING +#define N_FILEPTR 500 +#define N_DBGFLAG 100 +#define N_DBGVAL 100 +#define N_TYPES 6 + +static FILE *in_fileptr[N_FILEPTR]; +static FILE *out_fileptr[N_FILEPTR]; +#ifdef DBG_WAV_WRITER +static WAVEFILEOUT *out_wavfileptr[N_FILEPTR]; +#endif +static char *in_filename[N_FILEPTR]; +static char *out_filename[N_FILEPTR]; +#ifdef DBG_WAV_WRITER +static char *out_wavfilename[N_FILEPTR]; +#endif +static int16_t in_count = 0; +static int16_t out_count = 0; +#ifdef DBG_WAV_WRITER +static int16_t out_wav_count = 0; +#endif + +static int16_t flag_count = 0; +static char *flag_name[N_DBGFLAG]; +static int16_t val_count = 0; +static char *val_name[N_DBGVAL]; +static char *val[N_DBGVAL]; + +static char *type_list[N_TYPES] = { "char", "short", "int", "long", "float", "double" }; + +static void setvalue( + const char *value_name, /* i : Value name */ + const char *value /* i : Value as string */ +); + +static int16_t make_dirs( const char *const pathname ); + +/*-------------------------------------------------------------------* + * dbgwrite() + * + * Writes the buffer content to the specified file. If the file is not in the + * debug file list, it is opened before write. + *--------------------------------------------------------------------*/ + +int16_t dbgwrite( + const void *const buffer, /* i : Write buffer */ + const int16_t size, /* i : Element size */ + const int16_t count, /* i : Number of elements */ + const int16_t repeat, /* i : Number of times the elements are repeated */ +#ifdef DEBUG_MODE_INFO_TWEAK + const char *filename /* i : Output file name */ +#else + const char *const filename +#endif +) +{ + int16_t index, i; + void *tmp_buf; + +#ifdef DEBUG_MODE_INFO +#ifdef DEBUG_MODE_INFO_TWEAK + char filename_mod[FILENAME_MAX]; + int16_t textmode = 0; + int16_t x = *(const int16_t *const) buffer; /* currently the textmode is only defined with "short" as input */ + memset( filename_mod, 0, FILENAME_MAX ); + tweakdbgfolder( filename, filename_mod, &textmode ); + if ( filename_mod[0] != 0 ) + { + filename = filename_mod; + } +#endif +#endif + + index = lookup( filename, (const char *const *) out_filename, out_count ); + + if ( index == -1 ) + { + if ( make_dirs( filename ) != 0 ) + { + fprintf( stderr, "dbgwrite: Could not create directory structure for %s. Exiting..\n", filename ); + exit( -1 ); + } + + index = out_count; + out_fileptr[index] = fopen( filename, "wb" ); + out_filename[index] = malloc( sizeof( char ) * ( strlen( filename ) + 1 ) ); + strcpy( out_filename[index], filename ); + out_count++; + } + + if ( out_fileptr[index] != NULL ) + { + tmp_buf = calloc( count * repeat, size ); + if ( buffer != NULL ) + { + for ( i = 0; i < repeat; i++ ) + { + memcpy( (char *) tmp_buf + i * size * count, buffer, size * count ); + } + } +#ifdef DEBUG_MODE_INFO +#ifdef DEBUG_MODE_INFO_TWEAK + if ( 1 == textmode && 2 == size ) + { /* currently the textmode is only defined with "short" as input */ + fprintf( out_fileptr[index], "%d\n", x ); + } + else + { +#endif +#endif + fwrite( tmp_buf, size * count * repeat, 1, out_fileptr[index] ); +#ifdef DEBUG_MODE_INFO +#ifdef DEBUG_MODE_INFO_TWEAK + } +#endif +#endif + free( tmp_buf ); + } + else + { + fprintf( stderr, "dbgwrite: Could not write to file: %s. Exiting..\n", filename ); + exit( -1 ); + } + + return 0; +} + + +/*-------------------------------------------------------------------* + * dbgwrite_mat_repeat() + * + * Writes buffer a buffer containing a column-wise ordered matrix + * to the specified file. If the file is not in the + * debug file list, it is opened before write. + *--------------------------------------------------------------------*/ + +void dbgwrite_mat_repeat( float *buffer, /* i : write buffer */ + int16_t nRow, /* i : matrix size (rows) */ + int16_t mCol, /* i : matrix size (columns) */ + int16_t row_repeat, /* i : number of times rows are repeated */ + int16_t col_repeat, /* i : number of times columns are repeated */ +#ifdef DEBUG_MODE_INFO_TWEAK + const char *filename /* i : Output file name */ +#else + const char *const filename +#endif +) +{ + float *copy_buffer = calloc( nRow * row_repeat * mCol * col_repeat, sizeof( float ) ); + int16_t r, c, rr, cc; + float *cp = ©_buffer[0]; + float *colp; + for ( c = 0; c < mCol; c++ ) + { + for ( cc = 0; cc < col_repeat; cc++ ) + { + colp = buffer + c * nRow; + for ( r = 0; r < nRow; r++ ) + { + for ( rr = 0; rr < row_repeat; rr++ ) + { + *( cp++ ) = *colp; + } + colp++; + } + } + } + + dbgwrite( copy_buffer, sizeof( float ), nRow * row_repeat * mCol * col_repeat, 1, filename ); + free( copy_buffer ); +} + + +/*-------------------------------------------------------------------* + * dbgappend() + * + * Appends the buffer content to the specified file. If the file is not in the + * debug file list, it is opened before first write. + *--------------------------------------------------------------------*/ + +int16_t dbgappend( + const void *const buffer, /* i : Append buffer */ + const int16_t size, /* i : Element size */ + const int16_t count, /* i : Number of elements */ + const int16_t repeat, /* i : Number of times the elements are repeated */ +#ifdef DEBUG_MODE_INFO_TWEAK + const char *filename /* i : Output file name */ +#else + const char *const filename +#endif +) +{ + int16_t index, i; + +#ifdef DEBUG_MODE_INFO +#ifdef DEBUG_MODE_INFO_TWEAK + char filename_mod[FILENAME_MAX]; + int16_t textmode = 0; /* textmode is only implemented in dbgwrite() currently */ + memset( filename_mod, 0, FILENAME_MAX ); + tweakdbgfolder( filename, filename_mod, &textmode ); + if ( filename_mod[0] != 0 ) + { + filename = filename_mod; + } +#endif +#endif + index = lookup( filename, (const char *const *) out_filename, out_count ); + + if ( index == -1 ) + { + if ( make_dirs( filename ) != 0 ) + { + fprintf( stderr, "dbgwrite: Could not create directory structure for %s. Exiting..\n", filename ); + exit( -1 ); + } + + index = out_count; + out_fileptr[index] = fopen( filename, "ab" ); + out_filename[index] = malloc( sizeof( char ) * ( strlen( filename ) + 1 ) ); + strcpy( out_filename[index], filename ); + out_count++; + } + + if ( out_fileptr[index] != NULL ) + { + for ( i = 0; i < repeat; i++ ) + { + fwrite( buffer, size, count, out_fileptr[index] ); + } + } + else + { + fprintf( stderr, "dbgappend: Could not write to file: %s. Exiting..\n", filename ); + exit( -1 ); + } + + return 0; +} + +/*-------------------------------------------------------------------* + * dbgread() + * + * Reads data from the specified file. If the file is not open, it will be + * opened. + *--------------------------------------------------------------------*/ + +int16_t dbgread( + void *const buffer, /* o : Read buffer */ + const int16_t size, /* i : Element size */ + const int16_t count, /* i : Number of elements */ +#ifdef DEBUG_MODE_INFO_TWEAK + const char *filename /* i : Input file name */ +#else + const char *const filename +#endif +) +{ + int16_t index; + +#ifdef DEBUG_MODE_INFO +#ifdef DEBUG_MODE_INFO_TWEAK + char filename_mod[FILENAME_MAX]; + int16_t textmode = 0; /* textmode is only implemented in dbgwrite() currently */ + memset( filename_mod, 0, FILENAME_MAX ); + tweakdbgfolder( filename, filename_mod, &textmode ); + if ( filename_mod[0] != 0 ) + { + filename = filename_mod; + } +#endif +#endif + + index = lookup( filename, (const char *const *) in_filename, in_count ); + + if ( index == -1 ) + { + index = in_count; + in_fileptr[index] = fopen( filename, "rb" ); + in_filename[index] = malloc( sizeof( char ) * ( strlen( filename ) + 1 ) ); + strcpy( in_filename[index], filename ); + in_count++; + } + + if ( in_fileptr[index] != NULL ) + { + fread( buffer, size, count, in_fileptr[index] ); + } + else + { + fprintf( stderr, "dbgread: Could not read from file: %s. Exiting..\n", filename ); + exit( -1 ); + } + + return 0; +} + +/*-------------------------------------------------------------------* + * dbgclose() + * + * Closes opened files and frees allocated memory + *--------------------------------------------------------------------*/ + +void dbgclose( void ) +{ + int16_t i; + + for ( i = 0; i < in_count; i++ ) + { + fclose( in_fileptr[i] ); + free( in_filename[i] ); + } + + for ( i = 0; i < out_count; i++ ) + { + fclose( out_fileptr[i] ); + free( out_filename[i] ); + } + +#ifdef DBG_WAV_WRITER + for ( i = 0; i < out_wav_count; i++ ) + { + CloseWav( out_wavfileptr[i] ); + free( out_wavfilename[i] ); + } +#endif + for ( i = 0; i < snr_count; i++ ) + { + free( snr_name[i] ); + } + + for ( i = 0; i < flag_count; i++ ) + { + free( flag_name[i] ); + } + + for ( i = 0; i < val_count; i++ ) + { + free( val_name[i] ); + free( val[i] ); + } + + return; +} + + +/*-------------------------------------------------------------------* + * dbgflag() + * + * Checks if a debug flag is set. The flag is identified with a string. + *--------------------------------------------------------------------*/ + +int16_t dbgflag( + const char *flagname /* i : Flag name */ +) +{ + int16_t result; + + result = lookup( flagname, (const char *const *) flag_name, flag_count ); + + return ( result != -1 ); +} + +/*-------------------------------------------------------------------* + * setflag() + * + * Sets the flag with the specified string + *--------------------------------------------------------------------*/ + +void setflag( + const char *flagname /* i : Flag name */ +) +{ + int16_t result; + + result = lookup( flagname, (const char *const *) flag_name, flag_count ); + + if ( result == -1 ) + { + flag_name[flag_count] = malloc( sizeof( char ) * ( strlen( flagname ) + 1 ) ); + strcpy( flag_name[flag_count], flagname ); + flag_count++; + } + + return; +} + +/*----------------------------------------------------------------------------* + * dbgargs() + * + * N.B. Should be run before existing command line interpretation + * + * Command line interpreter for debug arguments. Removes the debug + * arguments after interpretation so that existing command line interpretation + * may be run afterwards. + * + * Arguments: + * -D flag_name Sets the debug flag labelled flag_name. + * The function dbgflag("flag_name") will return 1. + * + * -V val_name val Sets the debug value labelled val_name to val. + * dbgvalue("type","val_name",&value) will retrieve the value + * + *-----------------------------------------------------------------------------*/ + +/*! r: No. debug arguments */ +int16_t dbgargs( + int32_t *argc, /* i/o: No. input arguments / No. arguments without dbg arguments */ + char *argv[] /* i/o: Input arguments / Input arguments without dbg arguments */ +) +{ + int16_t i, j, dbgargs; + + i = 0; + dbgargs = 0; + while ( i < *argc ) + { + if ( strcmp( argv[i], "-D" ) == 0 ) + { + j = i; + dbgargs++; + i++; + setflag( argv[i] ); + for ( ; j < *argc - 2; j++ ) + { + argv[j] = argv[j + 2]; + } + *argc -= 2; + i -= 2; + } + + if ( strcmp( argv[i], "-V" ) == 0 ) + { + j = i; + dbgargs++; + i++; + setvalue( argv[i], argv[i + 1] ); + for ( ; j < *argc - 3; j++ ) + { + argv[j] = argv[j + 3]; + } + *argc -= 3; + i -= 3; + } + i++; + } + + return dbgargs; +} + +/*-------------------------------------------------------------------* + * dbgvalue() + * + * Lookup a debug value + * + * Allowed typestr values: + * "char","short","int","long","float","double" + * + * If the value is not set, the output value is not assigned + * + *-------------------------------------------------------------------*/ + +/*! r: Returns 1 if value is assigned, otherwise 0 */ +int16_t dbgvalue( + const char *typestr, /* i : Type as string:"int","char",... */ + const char *value_name, /* i : Value tag name given on command line */ + ... /* o : Output variable, type: pointer to "typestr" */ +) +{ + int16_t index; + char *value; + int16_t assigned; + char *c; + int16_t *sh; + int *i; + int32_t *l; + float *f; + double *d; + va_list ap; + va_start( ap, value_name ); + + index = lookup( value_name, (const char *const *) val_name, val_count ); + + if ( index != -1 ) + { + value = val[index]; + index = lookup( typestr, (const char *const *) type_list, N_TYPES ); + switch ( index ) + { + case 0: + c = va_arg( ap, char * ); + sscanf( value, "%c", c ); + break; + case 1: + sh = va_arg( ap, int16_t * ); + sscanf( value, "%hi", sh ); + break; + case 2: + i = va_arg( ap, int * ); + sscanf( value, "%i", i ); + break; + case 3: + l = va_arg( ap, int32_t * ); + sscanf( value, "%i", l ); + break; + case 4: + f = va_arg( ap, float * ); + sscanf( value, "%f", f ); + break; + case 5: + d = va_arg( ap, double * ); + sscanf( value, "%lf", d ); + break; + default: + fprintf( stderr, "dbgvalue::Unsupported type string %s. Exiting...\n", typestr ); + exit( -1 ); + } + assigned = 1; + } + else + { + assigned = 0; + } + + va_end( ap ); + + return assigned; +} + +/*-------------------------------------------------------------------* + * lookup() + * + * Returns the index of the given string, or -1 if not found + *--------------------------------------------------------------------*/ + +/*! r: Index of string, -1 if not found */ +int16_t lookup( + const char *const str, /* i : String to lookup */ + const char *const *const list, /* i : List of strings */ + const int16_t n_elem /* i : Number of elements */ +) +{ + int16_t i, result; + + result = -1; + i = 0; + while ( i < n_elem && result == -1 ) + { + if ( strcmp( str, list[i] ) == 0 ) + { + result = i; + } + i++; + } + + return result; +} + +/*-------------------------------------------------------------------* + * setvalue() + * + * Sets the debug name value pair + *--------------------------------------------------------------------*/ + +static void setvalue( + const char *value_name, /* i : Value name */ + const char *value ) /* i : Value as string */ + +{ + int16_t result; + + result = lookup( value_name, (const char *const *) val_name, val_count ); + + if ( result == -1 ) + { + val_name[val_count] = malloc( sizeof( char ) * ( strlen( value_name ) + 1 ) ); + strcpy( val_name[val_count], value_name ); + val[val_count] = malloc( sizeof( char ) * ( strlen( value ) + 1 ) ); + strcpy( val[val_count], value ); + val_count++; + fprintf( stdout, "\nDebug value set: %s = %s\n", value_name, value ); + } + else + { + fprintf( stdout, "\n*** Value %s already set: %s\n", value_name, val[result] ); + } + + return; +} + +#ifdef DEBUG_MODE_INFO +#ifdef DEBUG_MODE_INFO_TWEAK +/*-------------------------------------------------------------------* + * tweakdbgfolder() + * + * in: filename + * out: filename_mod + * + * returns modified path to debug files for reading and writing functions. + * creates in "./res" if given on command line + * with switch -info . + * + *--------------------------------------------------------------------*/ + +int16_t tweakdbgfolder( const char *filename, char *filename_mod, int16_t *textmode ) +{ + int16_t i, j; + char *p_infoFolder = infoFolder; + char *p_filename_mod = filename_mod; + int16_t n_prefix = 0; + char *suffix; + + /* if debug folder name given on command line, write debug info to sub folder */ + if ( infoFolder[0] != 0 ) + { + if ( filename[0] == '.' ) + { + n_prefix = 5; + } + else if ( filename[0] == 'r' ) + { + n_prefix = 3; + } + else + { + fprintf( stderr, "tweakdbgfolder: Unexpected debug folder. Exiting..\n" ); + exit( -1 ); + } + for ( i = 0; i <= n_prefix; i++ ) + { + p_filename_mod[i] = filename[i]; + } + j = i; + while ( *p_infoFolder != 0 ) + { + p_filename_mod[i] = *p_infoFolder; + i++; + p_infoFolder++; + } + p_filename_mod[i] = '/'; + i++; + + while ( filename[j] != 0 ) + { + p_filename_mod[i] = filename[j]; + i++; + j++; + } + /* detect textmode, only working with given debug folder name, otherwise no counter available for length of filename */ + suffix = &p_filename_mod[i - 4]; + if ( strncmp( suffix, ".txt", 4 ) == 0 ) + { + *textmode = 1; + } + else + { + *textmode = 0; + } + } + + + return 0; +} +#endif +#endif + + +#ifdef DEBUG_MODE_INFO +/*-------------------------------------------------------------------* + * fname() + * + * returns file name (string) that identifies - parameter/signal to be outputted + - channel ID (0 or 1) + - element ID (0, 1, etc.) + *--------------------------------------------------------------------*/ + +char debug_dir[6] = "res/"; + +char tmp_fname[FILENAME_MAX]; + +char *fname( + char *dir, + char *file, + const int16_t n, + const int16_t id, + const int16_t enc_dec ) +{ + char idd[5] = ".idX"; + idd[3] = (char) ( id + '0' ); + + strcpy( tmp_fname, dir ); + strcat( tmp_fname, file ); + + if ( enc_dec == DEC ) + strcat( tmp_fname, ".dec" ); + if ( id > 0 ) + strcat( tmp_fname, idd ); + if ( n > 0 ) + strcat( tmp_fname, ".ch2" ); + + return tmp_fname; +} +#endif + + +/*-------------------------------------------------------------------* + * make_dirs() + * + * extract path(s) form the pathname and create them if not existing + *--------------------------------------------------------------------*/ + +int16_t make_dirs( const char *const pathname ) +{ + const char *p; + char *temp; + char sep = 0; +#ifdef _WIN32 + struct _stat s = { 0 }; +#else + struct stat s = { 0 }; +#endif + /* find path separator */ + if ( strchr( pathname, '\\' ) != NULL ) + { + sep = '\\'; + } + else if ( strchr( pathname, '/' ) != NULL ) + { + sep = '/'; + } + + if ( sep != 0 ) + { + temp = calloc( 1, strlen( pathname ) + 1 ); + p = pathname; + while ( ( p = strchr( p, sep ) ) != NULL ) + { + /* skip consecutive separators and '.', '..' symbols */ + if ( p != pathname && ( *( p - 1 ) == sep || *( p - 1 ) == '.' ) ) + { + p++; + continue; + } + + /* put the path up to this point into a temp dir */ + memcpy( temp, pathname, p - pathname ); + temp[p - pathname] = '\0'; + p++; + + /* check if path exists and create it with mkdir() if not */ +#ifdef _WIN32 + if ( _stat( temp, &s ) == -1 ) + { + if ( _mkdir( temp ) != 0 ) + { + if ( errno != 0 ) + { + return 1; + } + } + } +#else + if ( stat( temp, &s ) == -1 ) + { + if ( mkdir( temp, 0755 ) != 0 ) + { + if ( errno != 0 ) + { + return 1; + } + } + } +#endif + } + + free( temp ); + } + + return 0; +} + +#ifdef DBG_WAV_WRITER +int16_t dbgwrite_wav( + const float *buffer[], /* i : Write buffer */ + const int16_t count_per_ch, /* i : Number of elements */ + const char *const filename, + int32_t fs, + int16_t num_chs ) +{ + int16_t index, i; + int16_t *tmp_buf; + + index = lookup( filename, (const char *const *) out_wavfilename, out_wav_count ); + + if ( index == -1 ) + { + if ( make_dirs( filename ) != 0 ) + { + fprintf( stderr, "dbgwrite: Could not create directory structure for %s. Exiting..\n", filename ); + exit( -1 ); + } + + index = out_wav_count; + out_wavfileptr[index] = CreateWav( (const char *) filename, fs, num_chs, 16 /* const uint32_t writeWaveExt */ ); + out_wavfilename[index] = malloc( sizeof( char ) * ( strlen( filename ) + 1 ) ); + strcpy( out_wavfilename[index], filename ); + out_wav_count++; + } + + if ( out_wavfileptr[index] != NULL ) + { + int16_t j, k; + float tmp; + tmp_buf = (int16_t *) calloc( count_per_ch * num_chs, sizeof( int16_t ) ); + k = 0; + for ( j = 0; j < count_per_ch; j++ ) + { + for ( i = 0; i < num_chs; i++, k++ ) + { + tmp = roundf( buffer[i][j] ); + tmp_buf[k] = ( tmp > MAX16B_FLT ) ? MAX16B : ( tmp < MIN16B_FLT ) ? MIN16B + : (short) tmp; + } + } + WriteWavShort( out_wavfileptr[index], tmp_buf, count_per_ch * num_chs ); + free( tmp_buf ); + } + else + { + fprintf( stderr, "dbgwrite_wav: Could not write to file: %s. Exiting..\n", filename ); + exit( -1 ); + } + + return 0; +} + + +int16_t dbgwrite_txt( + const float *buffer, /* i : Write buffer */ + const int16_t count, /* i : Number of elements */ + const char *const filename, + const char *const msg_opt ) +{ + int16_t index, i; + + index = lookup( filename, (const char *const *) out_filename, out_count ); + + if ( index == -1 ) + { + if ( make_dirs( filename ) != 0 ) + { + fprintf( stderr, "dbgwrite: Could not create directory structure for %s. Exiting..\n", filename ); + exit( -1 ); + } + + index = out_count; + out_fileptr[index] = fopen( filename, "w" ); + out_filename[index] = malloc( sizeof( char ) * ( strlen( filename ) + 1 ) ); + strcpy( out_filename[index], filename ); + out_count++; + } + + if ( out_fileptr[index] != NULL ) + { + if ( buffer != NULL ) + { + if ( msg_opt == NULL ) + { + for ( i = 0; i < count; i++ ) + { + fprintf( out_fileptr[index], "%f\n", buffer[i] ); + } + } + else + { + for ( i = 0; i < count; i++ ) + { + fprintf( out_fileptr[index], "%s %f\n", msg_opt, buffer[i] ); + } + } + } + } + else + { + fprintf( stderr, "dbgwrite_txt: Could not write to file: %s. Exiting..\n", filename ); + exit( -1 ); + } + + return 0; +} +#endif +#endif /* DEBUGGING */ diff --git a/lib_debug/debug.h b/lib_debug/debug.h new file mode 100644 index 000000000..ac2ac689b --- /dev/null +++ b/lib_debug/debug.h @@ -0,0 +1,257 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef DEBUG_H +#define DEBUG_H + +#include "options.h" +#include +#include +#ifdef DEBUG_SBA +#include "sba_debug.h" +#endif + +/*------------------------------------------------------------------------------------------* + * Global variables used for debugging + *------------------------------------------------------------------------------------------*/ + +#ifdef DEBUGGING +extern int32_t frame; +#endif + +#ifdef DEBUGGING +extern uint16_t g_nPrintedLines; +extern int16_t g_verbose; +#endif + +#ifdef DEBUGGING +extern int16_t debug_level; +#define DEBUG_LINE( level ) if ( ( level ) <= debug_level ) +#else +#define DEBUG_LINE( level ) if ( 0 ) +#endif + +#ifdef DEBUG_MODE_INFO +extern char tmp_fname[]; +extern char debug_dir[6]; +char *fname( char *dir, char *file, const int16_t n, const int16_t id, const int16_t enc_dec ); +#endif + +/*------------------------------------------------------------------------------------------* + * Read/write I/O tool + *------------------------------------------------------------------------------------------*/ + +#ifdef DEBUGGING + +int16_t lookup( + const char *const str, + const char *const *const list, + const int16_t n_elem ); + +#ifdef DEBUG_MODE_INFO +#ifdef DEBUG_MODE_INFO_TWEAK +int16_t tweakdbgfolder( + const char *filename, + char *filename_mod, + int16_t *textmode ); +#endif +#endif + +int16_t dbgwrite( + const void *const buffer, + const int16_t size, + const int16_t count, + const int16_t repeat, +#ifdef DEBUG_MODE_INFO_TWEAK + const char *filename +#else + const char *const filename +#endif +); + +#ifdef DBG_WAV_WRITER +int16_t dbgwrite_wav( + const float *buffer[], /* i : Write buffer */ + const int16_t count_per_ch, /* i : Number of elements */ + const char *const filename, + int32_t fs, + int16_t num_chs ); +int16_t dbgwrite_txt( + const float *buffer, /* i : Write buffer */ + const int16_t count, /* i : Number of elements */ + const char *const filename, + const char *const msg_opt ); +#endif +void dbgwrite_mat_repeat( + float *buffer, /* i : write buffer */ + int16_t nRow, /* i : matrix size (rows) */ + int16_t mCol, /* i : matrix size (columns) */ + int16_t row_repeat, /* i : number of times rows are repeated */ + int16_t col_repeat, /* i : number of times columns are repeated */ +#ifdef DEBUG_MODE_INFO_TWEAK + const char *filename /* i : Output file name */ +#else + const char *const filename +#endif +); + +int16_t dbgappend( + const void *const buffer, + const int16_t size, + const int16_t count, + const int16_t repeat, +#ifdef DEBUG_MODE_INFO_TWEAK + const char *filename +#else + const char *const filename +#endif +); + +int16_t dbgread( + void *const buffer, + const int16_t size, + const int16_t count, +#ifdef DEBUG_MODE_INFO_TWEAK + const char *filename +#else + const char *const filename +#endif +); + +void dbgclose( void ); + +int16_t dbgflag( + const char *flagname ); + +void setflag( + const char *flagname ); + +int16_t dbgargs( + int32_t *argc, + char *argv[] ); + +int16_t dbgvalue( + const char *typestr, + const char *value_name, + ... ); + +extern FILE *DJB_delay; + +extern FILE *FEC_pattern; + +#endif /* DEBUGGING */ + +/*------------------------------------------------------------------------------------------* + * SNR measurement tool + *------------------------------------------------------------------------------------------*/ + +#ifdef DEBUGGING + +extern int16_t snr_count; +extern char *snr_name[]; + +void snr( + const float *const signal, + const float *const noise, + const int16_t length, + const char *const name ); + +void snr_diff( + const float *const clean, + const float *const degraded, + const int16_t length, + const int16_t delay, + const char *const name ); + +void snr_celp( + const int16_t L_frame, + const int16_t L_subfr, + const float gamma, + const float tilt_fac, + const int16_t vad_flag, + const int16_t coder_type, + const float *input, + const float *output, + const float *A, + const int16_t idchan, + const char *name ); + +void print_snr( void ); + +#else + +#define print_snr( void ) + +#endif + +/*------------------------------------------------------------------------------------------* + * SD analysis tool + *------------------------------------------------------------------------------------------*/ + +#ifdef DEBUGGING + +/*! r: SD in a given frequency range */ +float sd_range( + const float lsf[], /* i : vector of unquantized LSF values */ + const float lsf_q[], /* i : vector of quantized LSF values */ + const int16_t order, /* i : dimension of the vectors */ + const int32_t fs, /* i : sampling frequency */ + const float min_freq, /* i : minimum frequency of interest */ + const float max_freq, /* i : maximum frequency of interest */ + const char *const name, /* i : string for SD entry in the global table */ + const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ +); + +/*! r: SD respecting critical bands */ +float sd_crit( + const float lsf[], /* i : vector of unquantized LSF values */ + const float lsf_q[], /* i : vector of quantized LSF values */ + const int16_t order, /* i : dimension of the vectors */ + const int32_t fs, /* i : sampling frequency */ + const float min_freq, /* i : minimal frequency */ + const float max_freq, /* i : maximal frequency */ + int16_t *min_band, /* o : minimal critical band */ + int16_t *max_band, /* o : maximal critical band */ + float sd_bands[], /* i/o: SD in critical bands */ + const char *const name, /* i : string for SD entry in the global table */ + const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ +); + +void print_sd( void ); + +#else + +#define print_sd( void ) + +#endif + +#endif /* DEBUG_H */ diff --git a/lib_debug/sba_debug.c b/lib_debug/sba_debug.c new file mode 100644 index 000000000..de4b549aa --- /dev/null +++ b/lib_debug/sba_debug.c @@ -0,0 +1,431 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include +#include +#include +#include +#include "options.h" +#include "ivas_cnst.h" +#include "sba_debug.h" +#include +#include "wmc_auto.h" +#ifdef DEBUG_SBA +#include +#include "tinywaveout_c.h" + +/*-------------------------------------------------------------------* + * Global variables used for debugging but not under DEBUGGING flag + *--------------------------------------------------------------------*/ + +#define MAX_IN_FILE_LEN ( 1000 ) +#define MAX_PLUG_IN_FILE_LEN ( MAX_IN_FILE_LEN ) +#define MAX_DEBUG_TAG_LEN ( 50 ) +#define NUM_DEBUG_FILES ( 5 ) +#define MAX_TAG_LEN ( 200 ) + +WAVEFILEOUT *spar_foa_enc_wav[3]; +WAVEFILEOUT *spar_foa_dec_wav[NUM_DEBUG_FILES]; +float max_diff = 0; +int32_t dbg_frm_num; +int32_t dbg_band; +int32_t dbg_type; +int32_t iter_max = 0; +FILE *fFb_pcm = NULL; +int8_t file_names[NUM_DEBUG_FILES][MAX_TAG_LEN + MAX_DEBUG_TAG_LEN]; + + +#ifdef DEBUG_AGC +FILE *agcOut = NULL; /* temporary AGC bitstream */ +#endif + +/*-----------------------------------------------------------------------------------------* + * Function description + * cstrcpy() - Custom implementation of strcpy + * + * Inputs: + * const char* _Source -> Source buffer + * _SizeInBytes -> Destination buffer size in bytes + * + * Outputs: + * char* _Destination -> Destination buffer + *-----------------------------------------------------------------------------------------*/ + +static void cstrcpy( char *_Destination, size_t _SizeInBytes, const char *_Source ) +{ + size_t SourceSizeInBytes = strlen( _Source ); + if ( _SizeInBytes > SourceSizeInBytes ) + { + strcpy( _Destination, _Source ); + } + else + { + assert( 0 ); + } + + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function description + * cstrcat() - Custom implementation of strcat + * + * Inputs: + * const char* _Source -> Source buffer + * _SizeInBytes -> Destination buffer size in bytes + * + * Outputs: + * char* _Destination -> Destination buffer + *-----------------------------------------------------------------------------------------*/ + +static void cstrcat( char *_Destination, size_t _SizeInBytes, const char *_Source ) +{ + size_t SourceSizeInBytes = strlen( _Source ); + size_t DestSizeInBytes = _SizeInBytes - strlen( _Destination ); + if ( DestSizeInBytes > SourceSizeInBytes ) + { + strcat( _Destination, _Source ); + } + else + { + assert( 0 ); + } + + return; +} + + +#ifdef DEBUG_AGC +void ivas_close_agc_debug_files( void ) +{ + if ( agcOut != NULL ) + { + fclose( agcOut ); + agcOut = NULL; + } + + return; +} + +void ivas_open_agc_debug_files( int16_t agc ) +{ + /* Temporary AGC file */ + if ( agc > 0 ) + { + char agcFilename[50] = "agcBitstream.bin"; + if ( ( agcOut = fopen( agcFilename, "wb" ) ) == NULL ) + { + fprintf( stderr, "Error: Gain Control bitstream file %s could not be opened\n\n", agcFilename ); + exit( -1 ); + } + fprintf( stdout, "Temporary gain control bitstream file %s is opened\n", agcFilename ); + } + + return; +} +#endif + +static void UpdateWave( + const uint32_t sampleRate, + const uint32_t numChannels, + const uint32_t bps, + WAVEFILEOUT *spar_wav ) +{ + uint32_t blockAlignment = 0; + uint16_t writeValue16; + uint32_t writeValue32; + + writeValue16 = LittleEndian16( (int16_t) numChannels ); + /*Fseek to number of channel writing position*/ + fseek( spar_wav->theFile, 22, SEEK_SET ); + fwrite( &writeValue16, sizeof( writeValue16 ), 1, spar_wav->theFile ); + blockAlignment = numChannels * ( bps >> 3 ); + writeValue16 = LittleEndian16( (int16_t) blockAlignment ); + fseek( spar_wav->theFile, 4, SEEK_CUR ); + writeValue32 = LittleEndian32( sampleRate * blockAlignment ); + fwrite( &writeValue32, sizeof( writeValue32 ), 1, spar_wav->theFile ); + fwrite( &writeValue16, sizeof( writeValue16 ), 1, spar_wav->theFile ); + + return; +} + + +void ivas_spar_dump_signal_wav( + const int16_t input_frame, + float **ppPcm, + float pcm_array[IVAS_SPAR_MAX_CH][L_FRAME48k], + const int16_t no_channel, + WAVEFILEOUT *wave_file, + char *location ) +{ + float tmp_value; + int16_t pcm_value, i, j, k; + int16_t debug_tmp[IVAS_SPAR_MAX_CH * L_FRAME48k * 2]; + + k = 0; + int16_t Clipping = 0; + float largest_value = 0; + float db_value = 0; + + for ( j = 0; j < input_frame; j++ ) + { + for ( i = 0; i < no_channel; i++, k++ ) + { + if ( ppPcm ) + { + tmp_value = roundf( ppPcm[i][j] ); + } + else + { + tmp_value = roundf( pcm_array[i][j] ); + } + + if ( tmp_value > MAX16B_FLT ) + { + largest_value = (float) fabs( tmp_value ) > largest_value ? (float) fabs( tmp_value ) : largest_value; + tmp_value = MAX16B; + Clipping++; + } + else if ( tmp_value < MIN16B_FLT ) + { + largest_value = (float) fabs( tmp_value ) > largest_value ? (float) fabs( tmp_value ) : largest_value; + tmp_value = MIN16B; + Clipping++; + } + pcm_value = (int16_t) tmp_value; + /*pcm_value = (tmp_value > MAX16B_FLT) ? MAX16B : (tmp_value < MIN16B_FLT) ? MIN16B + : (short)tmp_value;*/ + debug_tmp[k] = pcm_value; + } + } + if ( Clipping ) + { + db_value = 20.f * (float) log( largest_value ); + fprintf( stderr, "%d\t Clipping detected ", Clipping ); + } + + WriteWavShort( wave_file, debug_tmp, ( no_channel * input_frame ) ); + + if ( db_value ) + { + fprintf( stderr, "\t In %s largest clipped sample in dB %f \n", location, db_value ); + } + + return; +} + + +void ivas_close_sba_decoder_debug_files( + const int32_t fs, + const int16_t n_ch, + const int16_t n_transport, + const int16_t pca_ingest_channels ) +{ + if ( spar_foa_dec_wav[0] != NULL ) + { + UpdateWave( fs, n_transport, 32, spar_foa_dec_wav[0] ); + CloseWav( spar_foa_dec_wav[0] ); + } + if ( spar_foa_dec_wav[1] != NULL ) + { + UpdateWave( fs, n_transport, 16, spar_foa_dec_wav[1] ); + CloseWav( spar_foa_dec_wav[1] ); + } + if ( spar_foa_dec_wav[2] != NULL ) + { + UpdateWave( fs, pca_ingest_channels, 16, spar_foa_dec_wav[2] ); + CloseWav( spar_foa_dec_wav[2] ); + } + if ( spar_foa_dec_wav[3] != NULL ) + { + UpdateWave( fs, n_ch, 16, spar_foa_dec_wav[3] ); + CloseWav( spar_foa_dec_wav[3] ); + } + + if ( spar_foa_dec_wav[4] != NULL ) + { + UpdateWave( fs, n_ch, 16, spar_foa_dec_wav[4] ); + CloseWav( spar_foa_dec_wav[4] ); + } + + return; +} + + +void ivas_close_sba_encoder_debug_files( void ) +{ + + if ( spar_foa_enc_wav[0] != NULL ) + { + CloseWav( spar_foa_enc_wav[0] ); + } + if ( spar_foa_enc_wav[1] != NULL ) + { + CloseWav( spar_foa_enc_wav[1] ); + } + if ( spar_foa_enc_wav[2] != NULL ) + { + CloseWav( spar_foa_enc_wav[2] ); + } + + /* Enable print max diff to a file */ + + /* FILE *fp = fopen("max_diff.txt", "a"); + fprintf(fp, "%s\n", file_names[0]); + fprintf(fp, "max diff = %0.15f\n frame_no = %d\n band num = %d\n coeff type %d\n", max_diff, dbg_frm_num, dbg_band, dbg_type); + fclose(fp); */ + + /* Enable print max eig iters to a file */ + + /*FILE *fp = fopen("max_iters.txt", "a"); + fprintf(fp, "%s\n", file_names[0]); + fprintf(fp, "%d\n", iter_max); + fclose(fp); */ + + return; +} + + +void ivas_open_sba_decoder_debug_files( + const int32_t fs, + const int16_t n_ch, + const int16_t n_transport ) +{ + int8_t fb_wav_dump_path[NUM_DEBUG_FILES][MAX_PLUG_IN_FILE_LEN] = { "", "", "", "", "" }; + + cstrcat( (char *) fb_wav_dump_path[0], sizeof( fb_wav_dump_path[0] ), "dec_out.wav" ); + spar_foa_dec_wav[0] = CreateWav( (const char *) fb_wav_dump_path[0], fs, n_ch, 32 /* const uint32_t writeWaveExt */ ); + + cstrcat( (char *) fb_wav_dump_path[1], sizeof( fb_wav_dump_path[1] ), "agc_dec_out.wav" ); + spar_foa_dec_wav[1] = CreateWav( (const char *) fb_wav_dump_path[1], fs, n_transport, 16 /* const uint32_t writeWaveExt */ ); + + cstrcat( (char *) fb_wav_dump_path[2], sizeof( fb_wav_dump_path[2] ), "pca_dec.wav" ); + spar_foa_dec_wav[2] = CreateWav( (const char *) fb_wav_dump_path[2], fs, n_transport, 16 /* const uint32_t writeWaveExt */ ); + + cstrcat( (char *) fb_wav_dump_path[3], sizeof( fb_wav_dump_path[3] ), "cldfbSynthesis.wav" ); + spar_foa_dec_wav[3] = CreateWav( (const char *) fb_wav_dump_path[3], fs, n_transport, 16 /* const uint32_t writeWaveExt */ ); + + cstrcat( (char *) fb_wav_dump_path[4], sizeof( fb_wav_dump_path[4] ), "cldfbAnalysis.wav" ); + spar_foa_dec_wav[4] = CreateWav( (const char *) fb_wav_dump_path[4], fs, n_transport, 16 /* const uint32_t writeWaveExt */ ); + + return; +} + + +void ivas_open_sba_encoder_debug_files( + const int32_t fs, + const int16_t n_transport, + const char *file_tag, + const int32_t ivas_total_brate, + const int16_t dtx_on ) +{ + int8_t fb_wav_dump_path[3][MAX_PLUG_IN_FILE_LEN] = { "spar_foa_enc", "spar_foa_enc", "spar_foa_enc" }; + + if ( file_tag != NULL ) + { + cstrcpy( (char *) file_names[0], sizeof( file_names[0] ), (const char *) file_tag ); + } + + /* ivas_total_brate */ + switch ( ivas_total_brate ) + { + case IVAS_24k4: + cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr24k" ); + break; + case IVAS_32k: + cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr32k" ); + break; + case IVAS_48k: + cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr48k" ); + break; + case IVAS_64k: + cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr64k" ); + break; + case IVAS_80k: + cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr80k" ); + break; + case IVAS_96k: + cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr96k" ); + break; + case IVAS_128k: + cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr128k" ); + break; + case IVAS_160k: + cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr160k" ); + break; + case IVAS_192k: + cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr192k" ); + break; + case IVAS_256k: + cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr256k" ); + break; + case IVAS_384k: + cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr384k" ); + break; + case IVAS_512k: + cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr512k" ); + break; + } + + /* DTX */ + if ( dtx_on ) + { + cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_DTX1" ); + } + else + { + cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_DTX0" ); + } + + cstrcpy( (char *) file_names[1], sizeof( file_names[1] ), (const char *) file_names[0] ); + cstrcpy( (char *) file_names[2], sizeof( file_names[2] ), (const char *) file_names[0] ); + cstrcpy( (char *) file_names[3], sizeof( file_names[3] ), (const char *) file_names[0] ); + cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_pcm.txt" ); + + cstrcat( (char *) fb_wav_dump_path[0], sizeof( fb_wav_dump_path[0] ), (const char *) file_names[2] ); + cstrcat( (char *) fb_wav_dump_path[0], sizeof( fb_wav_dump_path[0] ), "_pca_enc.wav" ); + spar_foa_enc_wav[0] = CreateWav( (const char *) fb_wav_dump_path[0], fs, n_transport, 16 /* const uint32_t writeWaveExt */ ); + + cstrcat( (char *) fb_wav_dump_path[1], sizeof( fb_wav_dump_path[1] ), (const char *) file_names[2] ); + cstrcat( (char *) fb_wav_dump_path[1], sizeof( fb_wav_dump_path[1] ), "_fb_mixer_enc.wav" ); + spar_foa_enc_wav[1] = CreateWav( (const char *) fb_wav_dump_path[1], fs, n_transport, 16 /* const uint32_t writeWaveExt */ ); + + cstrcat( (char *) fb_wav_dump_path[2], sizeof( fb_wav_dump_path[2] ), (const char *) file_names[2] ); + cstrcat( (char *) fb_wav_dump_path[2], sizeof( fb_wav_dump_path[2] ), "_agc_enc.wav" ); + spar_foa_enc_wav[2] = CreateWav( (const char *) fb_wav_dump_path[2], fs, n_transport, 16 /* const uint32_t writeWaveExt */ ); + + return; +} + +#endif /* DEBUG_SBA */ diff --git a/lib_debug/sba_debug.h b/lib_debug/sba_debug.h new file mode 100644 index 000000000..a314d1568 --- /dev/null +++ b/lib_debug/sba_debug.h @@ -0,0 +1,61 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef SBA_DEBUG_H +#define SBA_DEBUG_H + +#include "options.h" +#include +#include +#ifdef DEBUG_SBA +#include "cnst.h" +#include "ivas_cnst.h" +#include "tinywaveout_c.h" + + +#ifdef DEBUG_SBA_AUDIO_DUMP +extern WAVEFILEOUT *spar_foa_enc_wav[3]; +extern WAVEFILEOUT *spar_foa_dec_wav[5]; +#endif + +#ifdef DEBUG_AGC +void ivas_close_agc_debug_files( void ); +void ivas_open_agc_debug_files( int16_t agc ); +#endif +void ivas_spar_dump_signal_wav( const int16_t input_frame, float **ppPcm, float pcm_array[IVAS_SPAR_MAX_CH][L_FRAME48k], const int16_t no_channel, WAVEFILEOUT *wave_file, char *location ); +void ivas_close_sba_encoder_debug_files( void ); +void ivas_open_sba_encoder_debug_files( const int32_t fs, const int16_t n_transport, const char *file_tag, const int32_t ivas_total_brate, const int16_t dtx_on ); +void ivas_close_sba_decoder_debug_files( const int32_t fs, const int16_t n_ch, const int16_t n_transport, const int16_t pca_ingest_channels ); +void ivas_open_sba_decoder_debug_files( const int32_t fs, const int16_t n_ch, const int16_t n_transport ); +#endif + +#endif /* SBA_DEBUG_H */ diff --git a/lib_debug/snr.c b/lib_debug/snr.c new file mode 100644 index 000000000..3e817287c --- /dev/null +++ b/lib_debug/snr.c @@ -0,0 +1,465 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include +#include +#include +#include "wmc_auto.h" +#include "cnst.h" +#include "ivas_cnst.h" + +#ifdef DEBUGGING + +/*-------------------------------------------------------------------* + * Local constants + *--------------------------------------------------------------------*/ + +#define N_SNRPTR 100 +#define MAX_SIGNAL_LENGTH 1024 +#define MAX_DELAY 320 + +/*-------------------------------------------------------------------* + * Global variables + *--------------------------------------------------------------------*/ + +int16_t snr_count = 0; +char *snr_name[N_SNRPTR] = { 0 }; + +#ifdef DEBUG_MODE_INFO +float snr_[2][320]; +#endif + +/*-------------------------------------------------------------------* + * Local variables + *--------------------------------------------------------------------*/ + +static double signal_energy[N_SNRPTR]; +static double noise_energy[N_SNRPTR]; +static double acc_seg_snr[N_SNRPTR]; +static int32_t seg_count[N_SNRPTR]; +static double acc_wseg_snr[N_SNRPTR]; +static double wseg_count[N_SNRPTR]; +static float *mem_delay_comp[N_SNRPTR] = { 0 }; +static float mem_deemph_x[MAX_INPUT_CHANNELS] = { 0 }; +static float mem_deemph_y[MAX_INPUT_CHANNELS] = { 0 }; +static float mem_synth_snr[MAX_INPUT_CHANNELS][M]; + + +/*-------------------------------------------------------------------* + * Local functions - they are copies of functions declared in prot.h but + here we do not want to include prot.h due to its dependencies + *--------------------------------------------------------------------*/ + +#ifdef DEBUG_MODE_INFO +static void set_f( + float y[], /* i/o: Vector to set */ + const float a, /* i : Value to set the vector to */ + const int16_t N /* i : Lenght of the vector */ +) +{ + int16_t i; + + for ( i = 0; i < N; i++ ) + { + y[i] = a; + } + + return; +} +#endif + +static float sum2_f( + const float *vec, /* i : input vector */ + const int16_t lvec /* i : length of input vector */ +) +{ + int16_t i; + float tmp; + + tmp = 0.0f; + for ( i = 0; i < lvec; i++ ) + { + tmp += vec[i] * vec[i]; + } + + return tmp; +} + + +static void mvr2r( + const float x[], /* i : input vector */ + float y[], /* o : output vector */ + const int16_t n /* i : vector size */ +) +{ + int16_t i; + + if ( n <= 0 ) + { + /* cannot transfer vectors with size 0 */ + return; + } + + if ( y < x ) + { + for ( i = 0; i < n; i++ ) + { + y[i] = x[i]; + } + } + else + { + for ( i = n - 1; i >= 0; i-- ) + { + y[i] = x[i]; + } + } + + return; +} + +static void residu( + const float *a, /* i : LP filter coefficients */ + const int16_t m, /* i : order of LP filter */ + const float *x, /* i : input signal (usually speech) */ + float *y, /* o : output signal (usually residual) */ + const int16_t l /* i : size of filtering */ +) +{ + float s; + int16_t i, j; + + for ( i = 0; i < l; i++ ) + { + s = x[i]; + for ( j = 1; j <= m; j++ ) + { + s += a[j] * x[i - j]; + } + y[i] = s; + } + + return; +} + +static void deemph( + float *signal, /* i/o: signal */ + const float mu, /* i : deemphasis factor */ + const int16_t L, /* i : vector size */ + float *mem /* i/o: memory (y[-1]) */ +) +{ + int16_t i; + + signal[0] = signal[0] + mu * ( *mem ); + for ( i = 1; i < L; i++ ) + { + signal[i] = signal[i] + mu * signal[i - 1]; + } + + *mem = signal[L - 1]; + + if ( ( *mem < 1e-10 ) & ( *mem > -1e-10 ) ) + { + *mem = 0; + } + + return; +} + +static void weight_a( + const float *a, /* i : LP filter coefficients */ + float *ap, /* o : weighted LP filter coefficients */ + const float gamma, /* i : weighting factor */ + const int16_t m /* i : order of LP filter */ +) +{ + float f; + int16_t i; + + ap[0] = a[0]; + f = gamma; + + for ( i = 1; i <= m; i++ ) + { + ap[i] = f * a[i]; + f *= gamma; + } + + return; +} + + +/*-------------------------------------------------------------------* + * snr() + * + * Calculates and accumulates SNR values for a signal specified with a + * certain string. The signal is input in segments having certain length, + * for which a global SNR, segmental SNR and weighted segmental SNR is computed. + *--------------------------------------------------------------------*/ + +void snr( + const float *const signal, + const float *const noise, + const int16_t length, + const char *const name ) +{ + int16_t index; + double signal_sumsq, noise_sumsq, frame_snr, seg_en; + + index = lookup( name, (const char *const *) snr_name, snr_count ); + if ( index == -1 ) + { + index = snr_count; + signal_energy[index] = 0; + noise_energy[index] = 0; + acc_seg_snr[index] = 0; + seg_count[index] = 0; + acc_wseg_snr[index] = 0; + wseg_count[index] = 0; + snr_name[index] = malloc( sizeof( char ) * ( strlen( name ) + 1 ) ); + strcpy( snr_name[index], name ); + snr_count++; + } + + signal_sumsq = sum2_f( signal, length ) + 0.001f; + noise_sumsq = sum2_f( noise, length ) + 0.001f; + if ( signal_sumsq < noise_sumsq ) + signal_sumsq = noise_sumsq; + frame_snr = 10 * log10( signal_sumsq / noise_sumsq ); + seg_en = 10 * log10( signal_sumsq / length ); + if ( seg_en < 0.0 ) + seg_en = 0.0; + + signal_energy[index] += signal_sumsq; + noise_energy[index] += noise_sumsq; + acc_seg_snr[index] += frame_snr; + seg_count[index]++; + acc_wseg_snr[index] += frame_snr * seg_en; + wseg_count[index] += seg_en; + + return; +} + + +/*-------------------------------------------------------------------* + * snr_diff() + * + * Calculates and accumulates SNR values for a signal specified with a + * certain string. The signal is input in segments having certain length, + * for which a global SNR, segmental SNR and weighted segmental SNR is computed. + * A delay between both signals is taken into account + * and compensated for (positive value means degraded signal is delayed). + *--------------------------------------------------------------------*/ + +void snr_diff( + const float *const clean, + const float *const degraded, + const int16_t length, + const int16_t delay, + const char *const name ) +{ + int16_t i, index; + float noise[MAX_SIGNAL_LENGTH], comp_buf[MAX_SIGNAL_LENGTH + MAX_DELAY]; + + if ( length > MAX_SIGNAL_LENGTH ) + { + fprintf( stdout, "snr_diff::Input segment too long. Exiting...\n" ); + exit( -1 ); + } + + if ( delay < 0 ) + { + fprintf( stdout, "snr_diff::Degraded signal cannot have negative delay. Exiting...\n" ); + exit( -1 ); + } + + /* search for the name in the database */ + index = (int16_t) lookup( name, (const char *const *) snr_name, snr_count ); + if ( index == -1 ) + { + index = (int16_t) snr_count; + signal_energy[index] = 0.0f; + noise_energy[index] = 0.0f; + acc_seg_snr[index] = 0.0f; + seg_count[index] = 0; + acc_wseg_snr[index] = 0.001f; + wseg_count[index] = 0.001f; + snr_name[index] = malloc( sizeof( char ) * ( strlen( name ) + 1 ) ); + mem_delay_comp[index] = calloc( delay, sizeof( float ) ); + strcpy( snr_name[index], name ); + snr_count++; + } + + /* delay compensation - introduction of delay to the clean signal */ + mvr2r( mem_delay_comp[index], comp_buf, delay ); + mvr2r( clean, comp_buf + delay, length ); + mvr2r( comp_buf + length, mem_delay_comp[index], delay ); + + for ( i = 0; i < length; i++ ) + { + noise[i] = comp_buf[i] - degraded[i]; + } + + snr( comp_buf, noise, length, name ); + + return; +} + + +/*-------------------------------------------------------------------* + * snr_celp() + * + * Calculates SNR, segmental SNR and weighted segmental SNR values for active + * frames (GENERIC, VOICED, TRANSITION and AUDIO) of CELP-coded signals. Both, the input and output + * signals are first converted to the perceptually weighted domain, subtracted to + * obtain the noise signal and de-emphasized. + *--------------------------------------------------------------------*/ + +void snr_celp( + const int16_t L_frame, + const int16_t L_subfr, + const float gamma, + const float tilt_fac, + const int16_t vad_flag, + const int16_t coder_type, + const float *input, + const float *output, + const float *A, + const int16_t idchan, + const char *name ) +{ + int16_t i; + float noise[L_FRAME16k], Ap[M + 1], x[L_FRAME16k], y[L_FRAME16k], synth_buf[M + L_FRAME16k], *synth; + const float *p_A; + int16_t j; +#ifdef DEBUG_MODE_INFO + float signal2, noise2, subframe_snr; +#endif + + synth = synth_buf + M; + mvr2r( mem_synth_snr[idchan], synth_buf, M ); + mvr2r( output, synth, L_frame ); + mvr2r( synth_buf + L_frame, mem_synth_snr[idchan], M ); + + p_A = A; + for ( i = 0; i < L_frame; i += L_subfr ) + { + weight_a( p_A, Ap, gamma, M ); + residu( Ap, M, &input[i], &x[i], L_subfr ); + residu( Ap, M, &synth[i], &y[i], L_subfr ); + p_A += ( M + 1 ); + + deemph( &x[i], tilt_fac, L_subfr, &mem_deemph_x[idchan] ); + deemph( &y[i], tilt_fac, L_subfr, &mem_deemph_y[idchan] ); + + for ( j = 0; j < L_subfr; j++ ) + { + noise[i + j] = x[i + j] - y[i + j]; + } + +#ifdef DEBUG_MODE_INFO + signal2 = sum2_f( &x[i], L_subfr ) + 0.001f; + noise2 = sum2_f( &noise[i], L_subfr ) + 0.001f; + if ( signal2 < noise2 ) + signal2 = noise2; + subframe_snr = 10.0f * log10f( signal2 / noise2 ); + + if ( L_frame == L_FRAME ) + { + set_f( snr_[idchan] + i * 5 / 4, subframe_snr, L_subfr * 5 / 4 ); + } + else + { + set_f( snr_[idchan] + i, subframe_snr, L_subfr ); + } +#endif + } + + if ( vad_flag == 1 && ( coder_type == GENERIC || coder_type == VOICED || coder_type == TRANSITION || coder_type == AUDIO ) ) + { + snr( x, noise, L_frame, name ); + } + + return; +} + +/*-------------------------------------------------------------------* + * print_snr() + * + * Finalizes and presents accumulated SNR data + *--------------------------------------------------------------------*/ + +void print_snr( void ) +{ + int16_t i; + double snr, segsnr, wsegsnr; + + if ( snr_count > 0 ) + { + fprintf( stdout, "\n --- SNR report --- \n" ); + + for ( i = 0; i < snr_count; i++ ) + { + snr = 10 * log10( signal_energy[i] / ( noise_energy[i] + 0.0001f ) ); + segsnr = acc_seg_snr[i] / ( seg_count[i] + 0.0001f ); + wsegsnr = acc_wseg_snr[i] / ( wseg_count[i] + 0.0001f ); + fprintf( stdout, "%-22s %6.3f dB SNR %6.3f dB SegSNR %6.3f dB WSegSNR\n", snr_name[i], snr, segsnr, wsegsnr ); + } + fprintf( stdout, "\n" ); + } + + /* free allocated memory */ + for ( i = 0; i < N_SNRPTR; i++ ) + { + if ( snr_name[i] ) + { + free( snr_name[i] ); + snr_name[i] = NULL; + } + + if ( mem_delay_comp[i] ) + { + free( mem_delay_comp[i] ); + mem_delay_comp[i] = NULL; + } + } + + return; +} + +#endif diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c index 49e363608..68be15b94 100644 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ b/lib_dec/FEC_HQ_phase_ecu.c @@ -338,7 +338,7 @@ static void trans_ana( { set_f( alpha, 1.0f, LGW_MAX ); set_f( beta, 0.0f, LGW_MAX ); - *beta_mute = BETA_MUTE_FAC_INI; + *beta_mute = BETA_MUTE_FAC_INI_FLT; /* apply hamming window */ v_mult( xfp, w_hamm, xfp_left, Ltrana_2 ); diff --git a/lib_dec/TonalComponentDetection.c b/lib_dec/TonalComponentDetection.c index f3b73bf8c..8955abd7a 100644 --- a/lib_dec/TonalComponentDetection.c +++ b/lib_dec/TonalComponentDetection.c @@ -265,13 +265,13 @@ static void getEnvelope( sum = 0; for ( i = 0; i < n2; i++ ) { - sum += LEVEL_ABOVE_ENVELOPE * powerSpec[i]; + sum += LEVEL_ABOVE_ENVELOPE_FLT * powerSpec[i]; } /* No need for PTR_INIT for powerSpec[i+n2] as we continue from the previous loop */ for ( i = 0; i < n1; i++ ) { - sum += LEVEL_ABOVE_ENVELOPE * powerSpec[i + n2]; + sum += LEVEL_ABOVE_ENVELOPE_FLT * powerSpec[i + n2]; /* 1/(i+nSecondHalfFilterLength) needs to be stored in a table for each filter length */ envelope[i] = (float) sum / ( i + nSecondHalfFilterLength ); } @@ -280,7 +280,7 @@ static void getEnvelope( /* No need for PTR_INIT for powerSpec[i+n2] as we continue from the previous loop */ for ( i = n1; i < nSamples - n2; i++ ) { - sum += LEVEL_ABOVE_ENVELOPE * ( powerSpec[i + n2] - powerSpec[i - n1] ) / nFilterLength; /* LEVEL_ABOVE_ENVELOPE/nFilterLength is from a table */ + sum += LEVEL_ABOVE_ENVELOPE_FLT * ( powerSpec[i + n2] - powerSpec[i - n1] ) / nFilterLength; /* LEVEL_ABOVE_ENVELOPE_FLT/nFilterLength is from a table */ envelope[i] = (float) sum; } sum *= nFilterLength; @@ -288,7 +288,7 @@ static void getEnvelope( /* No need for PTR_INIT for powerSpec[i-n1] as we continue from the previous loop */ for ( i = nSamples - n2; i < nSamples; i++ ) { - sum -= LEVEL_ABOVE_ENVELOPE * powerSpec[i - n1]; + sum -= LEVEL_ABOVE_ENVELOPE_FLT * powerSpec[i - n1]; /* 1/(nSamples-(i-nHalfFilterLength)) needs to be stored in a table for each filter length */ envelope[i] = (float) sum / ( nSamples - ( i - nHalfFilterLength ) ); } @@ -602,7 +602,7 @@ static void findCandidates( calcPseudoSpec( MDCTSpectrum, nSamples, floorPowerSpectrum, powerSpectrum ); getEnvelope( nSamples, powerSpectrum, 0, envelope, smoothedSpectrum ); - set_f( thresholdModificationNew, UNREACHABLE_THRESHOLD, nSamples ); + set_f( thresholdModificationNew, UNREACHABLE_THRESHOLD_FLT, nSamples ); for ( k = GROUP_LENGTH / 2; k <= nSamples - ( GROUP_LENGTH - GROUP_LENGTH / 2 ); k++ ) { if ( smoothedSpectrum[k] > envelope[k] ) @@ -619,14 +619,14 @@ static void findCandidates( if ( powerSpectrum[upperIdx] < powerSpectrum[upperIdx + 1] ) { /* Side lobes may increase for certain ammount */ - if ( ALLOWED_SIDE_LOBE_FLUCTUATION * powerSpectrum[upperIdx] < powerSpectrum[upperIdx + 1] ) + if ( ALLOWED_SIDE_LOBE_FLUCTUATION_FLT * powerSpectrum[upperIdx] < powerSpectrum[upperIdx + 1] ) { break; } /* Check for further decrease after a side lobe increase */ for ( j = upperIdx + 1; j < nSamples - 1; j++ ) { - if ( powerSpectrum[j] < ALLOWED_SIDE_LOBE_FLUCTUATION * powerSpectrum[j + 1] ) + if ( powerSpectrum[j] < ALLOWED_SIDE_LOBE_FLUCTUATION_FLT * powerSpectrum[j + 1] ) { break; } @@ -646,14 +646,14 @@ static void findCandidates( if ( powerSpectrum[lowerIdx] < powerSpectrum[lowerIdx - 1] ) { /* Side lobes may increase for certain ammount */ - if ( ALLOWED_SIDE_LOBE_FLUCTUATION * powerSpectrum[lowerIdx] < powerSpectrum[lowerIdx - 1] ) + if ( ALLOWED_SIDE_LOBE_FLUCTUATION_FLT * powerSpectrum[lowerIdx] < powerSpectrum[lowerIdx - 1] ) { break; } /* Check for further decrease after a side lobe increase */ for ( j = lowerIdx - 1; j > 0; j-- ) { - if ( powerSpectrum[j] < ALLOWED_SIDE_LOBE_FLUCTUATION * powerSpectrum[j - 1] ) + if ( powerSpectrum[j] < ALLOWED_SIDE_LOBE_FLUCTUATION_FLT * powerSpectrum[j - 1] ) { break; } @@ -682,11 +682,11 @@ static void findCandidates( { if ( smoothedSpectrum[j] > envelope[j] ) { - thresholdModificationNew[j] = SMALL_THRESHOLD; + thresholdModificationNew[j] = SMALL_THRESHOLD_FLT; } else { - thresholdModificationNew[j] = BIG_THRESHOLD; + thresholdModificationNew[j] = BIG_THRESHOLD_FLT; } } /* Jump to the next foot of the peak. */ @@ -762,14 +762,14 @@ static void findTonalComponents( if ( powerSpectrum[upperIdx] < powerSpectrum[upperIdx + 1] ) { /* Side lobes may increase for certain ammount */ - if ( ALLOWED_SIDE_LOBE_FLUCTUATION * powerSpectrum[upperIdx] < powerSpectrum[upperIdx + 1] ) + if ( ALLOWED_SIDE_LOBE_FLUCTUATION_FLT * powerSpectrum[upperIdx] < powerSpectrum[upperIdx + 1] ) { break; } /* Check for further decrease after a side lobe increase */ for ( j = upperIdx + 1; j < nSamples - 1; j++ ) { - if ( powerSpectrum[j] < ALLOWED_SIDE_LOBE_FLUCTUATION * powerSpectrum[j + 1] ) + if ( powerSpectrum[j] < ALLOWED_SIDE_LOBE_FLUCTUATION_FLT * powerSpectrum[j + 1] ) { break; } @@ -789,14 +789,14 @@ static void findTonalComponents( if ( powerSpectrum[lowerIdx] < powerSpectrum[lowerIdx - 1] ) { /* Side lobes may increase for certain ammount */ - if ( ALLOWED_SIDE_LOBE_FLUCTUATION * powerSpectrum[lowerIdx] < powerSpectrum[lowerIdx - 1] ) + if ( ALLOWED_SIDE_LOBE_FLUCTUATION_FLT * powerSpectrum[lowerIdx] < powerSpectrum[lowerIdx - 1] ) { break; } /* Check for further decrease after a side lobe increase */ for ( j = lowerIdx - 1; j > 0; j-- ) { - if ( powerSpectrum[j] < ALLOWED_SIDE_LOBE_FLUCTUATION * powerSpectrum[j - 1] ) + if ( powerSpectrum[j] < ALLOWED_SIDE_LOBE_FLUCTUATION_FLT * powerSpectrum[j - 1] ) { break; } diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c index 5218f6010..73ba7b138 100644 --- a/lib_dec/acelp_core_dec.c +++ b/lib_dec/acelp_core_dec.c @@ -268,14 +268,14 @@ ivas_error acelp_core_dec( if ( st->L_frame == L_FRAME ) { - st->gamma = GAMMA1; - st->preemph_fac = PREEMPH_FAC; + st->gamma = GAMMA1_FLT; + st->preemph_fac = PREEMPH_FAC_FLT; int_fs = INT_FS_12k8; } else { - st->gamma = GAMMA16k; - st->preemph_fac = PREEMPH_FAC_16k; + st->gamma = GAMMA16k_FLT; + st->preemph_fac = PREEMPH_FAC_16k_FLT; int_fs = INT_FS_16k; } @@ -319,8 +319,8 @@ ivas_error acelp_core_dec( mem_syn_r_size_old = (int16_t) ( 1.25 * st->last_L_frame / 20.f ); mem_syn_r_size_new = (int16_t) ( 1.25 * st->L_frame / 20.f ); - lerp( st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); - lerp( st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + lerp( st->hPFstat->mem_stp_flt + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp_flt + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + lerp( st->hPFstat->mem_pf_in_flt + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in_flt + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); } /* convert quantized LSP vector */ @@ -1068,7 +1068,7 @@ ivas_error acelp_core_dec( if ( st->hTcxDec != NULL ) { - mvr2r( syn + st->L_frame / 2, st->hTcxDec->old_syn_Overl, st->L_frame / 2 ); + mvr2r( syn + st->L_frame / 2, st->hTcxDec->old_syn_Overl_float, st->L_frame / 2 ); } mvr2r( syn + st->L_frame - M - 1, st->syn, M + 1 ); @@ -1087,11 +1087,11 @@ ivas_error acelp_core_dec( { if ( st->hPFstat->on ) { - mvr2r( st->hPFstat->mem_pf_in + L_SYN_MEM - M, temp_buf, M ); + mvr2r( st->hPFstat->mem_pf_in_flt + L_SYN_MEM - M, temp_buf, M ); mvr2r( syn, temp_buf + M, L_SUBFR ); residu( Aq, M, temp_buf + M, temp_buf + M + L_SUBFR, L_SUBFR ); - syn_filt( Aq, M, temp_buf + M + L_SUBFR, temp_buf, L_SUBFR, st->hPFstat->mem_stp + L_SYN_MEM - M, 0 ); - scale_st( syn, temp_buf, &st->hPFstat->gain_prec, L_SUBFR, -1 ); + syn_filt( Aq, M, temp_buf + M + L_SUBFR, temp_buf, L_SUBFR, st->hPFstat->mem_stp_flt + L_SYN_MEM - M, 0 ); + scale_st( syn, temp_buf, &st->hPFstat->gain_prec_flt, L_SUBFR, -1 ); mvr2r( temp_buf, syn, L_SUBFR / 2 ); blend_subfr2( temp_buf + L_SUBFR / 2, syn + L_SUBFR / 2, syn + L_SUBFR / 2 ); } @@ -1119,7 +1119,7 @@ ivas_error acelp_core_dec( if ( st->idchan == 0 ) { - st->lp_noise = st->hFdCngDec->lp_noise; + st->lp_noise = st->hFdCngDec->lp_noise_float; } if ( st->element_mode != IVAS_CPE_TD && !st->cng_ism_flag ) diff --git a/lib_dec/acelp_core_switch_dec.c b/lib_dec/acelp_core_switch_dec.c index 96e6bec4e..3269f3278 100644 --- a/lib_dec/acelp_core_switch_dec.c +++ b/lib_dec/acelp_core_switch_dec.c @@ -181,22 +181,22 @@ ivas_error acelp_core_switch_dec( if ( L_frame_for_cs == L_FRAME ) { - deemph( synth_intFreq, PREEMPH_FAC, 2 * L_SUBFR, &st->mem_deemph ); + deemph( synth_intFreq, PREEMPH_FAC_FLT, 2 * L_SUBFR, &st->mem_deemph ); } else { - deemph( synth_intFreq, PREEMPH_FAC_16k, 2 * L_SUBFR, &st->mem_deemph ); + deemph( synth_intFreq, PREEMPH_FAC_16k_FLT, 2 * L_SUBFR, &st->mem_deemph ); } AGC_dec( synth_intFreq, st->agc_mem2, 2 * L_SUBFR ); if ( st->hPFstat->on && st->last_bwidth != NB ) { - mvr2r( st->hPFstat->mem_pf_in + L_SYN_MEM - M, bpf_error_signal, M ); /*bpf_error_signal used as temporary buffer*/ + mvr2r( st->hPFstat->mem_pf_in_flt + L_SYN_MEM - M, bpf_error_signal, M ); /*bpf_error_signal used as temporary buffer*/ mvr2r( synth_intFreq, bpf_error_signal + M, L_SUBFR ); residu( Aq, M, bpf_error_signal + M, old_exc, L_SUBFR ); - syn_filt( Aq, M, old_exc, bpf_error_signal, L_SUBFR, st->hPFstat->mem_stp + L_SYN_MEM - M, 0 ); - scale_st( synth_intFreq, bpf_error_signal, &st->hPFstat->gain_prec, L_SUBFR, -1 ); + syn_filt( Aq, M, old_exc, bpf_error_signal, L_SUBFR, st->hPFstat->mem_stp_flt + L_SYN_MEM - M, 0 ); + scale_st( synth_intFreq, bpf_error_signal, &st->hPFstat->gain_prec_flt, L_SUBFR, -1 ); mvr2r( bpf_error_signal, synth_intFreq, L_SUBFR / 2 ); blend_subfr2( bpf_error_signal + L_SUBFR / 2, synth_intFreq + L_SUBFR / 2, synth_intFreq + L_SUBFR / 2 ); } @@ -473,11 +473,11 @@ ivas_error acelp_core_switch_dec_bfi( mvr2r( &( st->mem_deemph ), tmp_float, 1 ); if ( st->L_frame == L_FRAME ) { - deemph( syn, PREEMPH_FAC, L_FRAME, tmp_float ); + deemph( syn, PREEMPH_FAC_FLT, L_FRAME, tmp_float ); } else { - deemph( syn, PREEMPH_FAC_16k, L_FRAME16k, tmp_float ); + deemph( syn, PREEMPH_FAC_16k_FLT, L_FRAME16k, tmp_float ); } /*----------------------------------------------------------------* diff --git a/lib_dec/amr_wb_dec.c b/lib_dec/amr_wb_dec.c index b585eecf9..3c0c7c56e 100644 --- a/lib_dec/amr_wb_dec.c +++ b/lib_dec/amr_wb_dec.c @@ -197,7 +197,7 @@ ivas_error amr_wb_dec( * PLC: overlapping part needs to be attenuated for first good frame */ if ( !st->bfi && st->prev_bfi && ( st->last_codec_mode == MODE2 ) && ( st->last_core_bfi == TCX_20_CORE || st->last_core_bfi == TCX_10_CORE ) ) { - v_multc( st->hHQ_core->old_out, st->hPlcInfo->recovery_gain, st->hHQ_core->old_out, st->hTcxDec->L_frameTCX ); + v_multc( st->hHQ_core->old_out, st->hPlcInfo->recovery_gain_float, st->hHQ_core->old_out, st->hTcxDec->L_frameTCX ); } /*-----------------------------------------------------------------* @@ -216,8 +216,8 @@ ivas_error amr_wb_dec( mem_syn_r_size_old = (int16_t) ( 1.25 * st->last_L_frame / 20.f ); mem_syn_r_size_new = (int16_t) ( 1.25 * st->L_frame / 20.f ); - lerp( st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); - lerp( st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + lerp( st->hPFstat->mem_stp_flt + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp_flt + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + lerp( st->hPFstat->mem_pf_in_flt + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in_flt + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); } /* convert old quantized LSP vector */ @@ -588,11 +588,11 @@ ivas_error amr_wb_dec( mvr2r( syn + L_FRAME - L_SYN_MEM, st->mem_syn_r, L_SYN_MEM ); - deemph( syn, PREEMPH_FAC, L_FRAME, &( st->mem_deemph ) ); + deemph( syn, PREEMPH_FAC_FLT, L_FRAME, &( st->mem_deemph ) ); AGC_dec( syn, st->agc_mem2, L_FRAME ); if ( st->hTcxDec != NULL ) { - mvr2r( syn + L_FRAME / 2, st->hTcxDec->old_syn_Overl, L_FRAME / 2 ); + mvr2r( syn + L_FRAME / 2, st->hTcxDec->old_syn_Overl_float, L_FRAME / 2 ); } mvr2r( syn + L_FRAME - M - 1, st->syn, M + 1 ); @@ -626,7 +626,7 @@ ivas_error amr_wb_dec( noisy_speech_detection( st->hFdCngDec, st->VAD, syn ); st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = 0.99f * st->hFdCngDec->hFdCngCom->likelihood_noisy_speech + 0.01f * (float) st->hFdCngDec->hFdCngCom->flag_noisy_speech; - st->lp_noise = st->hFdCngDec->lp_noise; + st->lp_noise = st->hFdCngDec->lp_noise_float; if ( st->flag_cna && ( st->psf_lp_noise >= 15.f ) ) { @@ -781,7 +781,7 @@ ivas_error amr_wb_dec( if ( output_frame >= L_FRAME16k ) { tmps = NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ); - delay_signal( synth_out, output_frame, st->prev_synth_buffer, tmps ); + delay_signal_float( synth_out, output_frame, st->prev_synth_buffer, tmps ); } if ( waveadj_rec ) @@ -791,11 +791,11 @@ ivas_error amr_wb_dec( { tmps = NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS ); } - waveform_adj2( st->hPlcInfo, st->hTonalMDCTConc->secondLastPcmOut, synth_out + tmps, tmps, st->hPlcInfo->nbLostCmpt + 1, st->bfi ); + waveform_adj2( st->hPlcInfo, st->hTonalMDCTConc->secondLastPcmOut_float, synth_out + tmps, tmps, st->hPlcInfo->nbLostCmpt + 1, st->bfi ); } /* HP filter */ - hp20( synth_out, output_frame, mem_hp20_out, st->output_Fs ); + hp20_flt( synth_out, output_frame, mem_hp20_out, st->output_Fs ); /* save synthesis for core switching */ mvr2r( synth_out + NS2SA( st->output_Fs, ACELP_LOOK_NS + DELAY_BWE_TOTAL_NS ), st->old_synth_sw, NS2SA( st->output_Fs, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ) ); diff --git a/lib_dec/ari_hm_dec.c b/lib_dec/ari_hm_dec.c index 3ba6a886f..9a8f03c89 100644 --- a/lib_dec/ari_hm_dec.c +++ b/lib_dec/ari_hm_dec.c @@ -58,7 +58,7 @@ int16_t DecodeIndex( TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; TCX_DEC_HANDLE hTcxDec = st->hTcxDec; - if ( ( hTcxDec->tcx_hm_LtpPitchLag > 0 ) && ( hTcxLtpDec->tcxltp_gain > kLtpHmGainThr ) ) + if ( ( hTcxDec->tcx_hm_LtpPitchLag > 0 ) && ( hTcxLtpDec->tcxltp_gain_float > kLtpHmGainThr_FLT ) ) { int16_t LtpPitchIndex = ( ( hTcxDec->tcx_hm_LtpPitchLag + ( 1 << ( kLtpHmFractionalResolution - 1 ) ) ) >> kLtpHmFractionalResolution ) - 2; *PeriodicityIndex = kLtpHmFlag; diff --git a/lib_dec/arith_coder_dec.c b/lib_dec/arith_coder_dec.c index 82f35846c..f9fe8da68 100644 --- a/lib_dec/arith_coder_dec.c +++ b/lib_dec/arith_coder_dec.c @@ -168,7 +168,7 @@ void tcx_arith_decode_envelope( gamma_uw = 1.0f / st->gamma; #define WMC_TOOL_SKIP - tcx_arith_render_envelope( A_ind, L_frame, L_spec, FL2WORD16( hTcxCfg->preemph_fac ), FL2WORD16( gamma_w ), FL2WORD16( 0.5f * gamma_uw ), env ); + tcx_arith_render_envelope( A_ind, L_frame, L_spec, FL2WORD16( hTcxCfg->preemph_fac_flt), FL2WORD16( gamma_w ), FL2WORD16( 0.5f * gamma_uw ), env ); #undef WMC_TOOL_SKIP if ( use_hm ) diff --git a/lib_dec/cng_dec.c b/lib_dec/cng_dec.c index 486d2d857..833eba5ec 100644 --- a/lib_dec/cng_dec.c +++ b/lib_dec/cng_dec.c @@ -37,8 +37,9 @@ #include #include "options.h" #include -#include "cnst.h" +#include "ivas_cnst.h" #include "prot.h" +#include "prot_fx1.h" #include "rom_com.h" #include "wmc_auto.h" @@ -765,7 +766,7 @@ static void shb_CNG_decod( *-------------------------------------------------------------------*/ void td_cng_dec_init( - DEC_CORE_HANDLE st /* i/o: decoder state structure */ + DEC_CORE_HANDLE_FLOAT st /* i/o: decoder state structure */ ) { int16_t i; diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c index eed6fc8c0..eeff41b76 100644 --- a/lib_dec/core_dec_init.c +++ b/lib_dec/core_dec_init.c @@ -132,28 +132,28 @@ void open_decoder_LPD( /*Preemphasis param*/ if ( st->fscale < ( 16000 * FSCALE_DENOM ) / 12800 ) { - st->preemph_fac = PREEMPH_FAC; /*NB*/ + st->preemph_fac = PREEMPH_FAC_FLT; /*NB*/ } else if ( st->fscale < ( 24000 * FSCALE_DENOM ) / 12800 ) { - st->preemph_fac = PREEMPH_FAC_16k; /*WB*/ + st->preemph_fac = PREEMPH_FAC_16k_FLT; /*WB*/ } else { - st->preemph_fac = PREEMPH_FAC_SWB; /*SWB*/ + st->preemph_fac = PREEMPH_FAC_SWB_FLT; /*SWB*/ } if ( st->sr_core == INT_FS_16k ) { - st->gamma = GAMMA16k; + st->gamma = GAMMA16k_FLT; } else if ( st->sr_core > INT_FS_16k && st->element_mode == IVAS_CPE_MDCT ) { - st->gamma = GAMMA16k; + st->gamma = GAMMA16k_FLT; } else { - st->gamma = GAMMA1; + st->gamma = GAMMA1_FLT; } /* LPC quantization */ @@ -223,8 +223,8 @@ void open_decoder_LPD( { reset_tcx_overl_buf( st->hTcxDec ); - set_zero( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2 ); - set_zero( st->hTcxDec->old_synth, OLD_SYNTH_INTERNAL_DEC ); + set_zero( st->hTcxDec->syn_OverlFB_float, L_FRAME_MAX / 2 ); + set_zero( st->hTcxDec->old_synth_float, OLD_SYNTH_INTERNAL_DEC ); set_zero( st->hTcxDec->synth_history, L_PROT48k + L_FRAME_MAX ); } @@ -243,7 +243,7 @@ void open_decoder_LPD( /* Reset old_synth in case of core sampling rate switching and Mode 1/2 switching*/ if ( st->hTcxDec != NULL && ( ( st->L_frame != st->last_L_frame ) || ( st->last_codec_mode == MODE1 && st->element_mode == EVS_MONO ) ) ) { - set_zero( st->hTcxDec->old_synth, OLD_SYNTH_INTERNAL_DEC ); + set_zero( st->hTcxDec->old_synth_float, OLD_SYNTH_INTERNAL_DEC ); } /*Compute size of old and new memories*/ @@ -312,7 +312,7 @@ void open_decoder_LPD( if ( st->hTcxCfg != NULL ) { - mvr2r( st->hHQ_core->old_out + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->syn_OverlFB, st->hTcxCfg->tcx_mdct_window_lengthFB ); + mvr2r( st->hHQ_core->old_out + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->syn_OverlFB_float, st->hTcxCfg->tcx_mdct_window_lengthFB ); st->hTcxCfg->last_aldo = 1; /*It was previously ALDO*/ st->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; } @@ -412,21 +412,21 @@ void open_decoder_LPD( { if ( st->hPFstat->on ) { - lerp( st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); - lerp( st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + lerp( st->hPFstat->mem_stp_flt + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp_flt + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + lerp( st->hPFstat->mem_pf_in_flt + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in_flt + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); } else { - set_zero( st->hPFstat->mem_stp, L_SYN_MEM ); - set_zero( st->hPFstat->mem_pf_in, L_SYN_MEM ); + set_zero( st->hPFstat->mem_stp_flt, L_SYN_MEM ); + set_zero( st->hPFstat->mem_pf_in_flt, L_SYN_MEM ); st->hPFstat->reset = 1; - st->hPFstat->gain_prec = 1.f; + st->hPFstat->gain_prec_flt = 1.f; } } else if ( st->hPFstat->on ) { - lerp( st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); - lerp( st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + lerp( st->hPFstat->mem_stp_flt + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp_flt + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + lerp( st->hPFstat->mem_pf_in_flt + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in_flt + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); } } else @@ -442,8 +442,8 @@ void open_decoder_LPD( if ( st->hPFstat->on != 0 ) { st->hPFstat->reset = 0; - lerp( st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); - lerp( st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + lerp( st->hPFstat->mem_stp_flt + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp_flt + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + lerp( st->hPFstat->mem_pf_in_flt + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in_flt + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); } } } @@ -452,7 +452,7 @@ void open_decoder_LPD( /*feed last value old_synth as it is used for pre-emphasis mem*/ if ( st->hTcxDec != NULL ) { - st->hTcxDec->old_synth[st->hTcxDec->old_synth_len - 1] = st->syn[M]; + st->hTcxDec->old_synth_float[st->hTcxDec->old_synth_len - 1] = st->syn[M]; } if ( st->hBPF != NULL ) { @@ -492,7 +492,7 @@ void open_decoder_LPD( st->last_concealed_gain_syn_deemph = 1.f; if ( hTcxDec != NULL ) { - hTcxDec->conceal_eof_gain = 1.0f; + hTcxDec->conceal_eof_gain_float = 1.0f; } } /* Post processing */ @@ -550,13 +550,13 @@ void open_decoder_LPD( if ( is_init || MCT_flag || !( st->element_mode == IVAS_CPE_MDCT && st->element_mode == last_element_mode ) ) { - st->hTcxDec->CngLevelBackgroundTrace_bfi = PLC_MIN_CNG_LEV; + st->hTcxDec->CngLevelBackgroundTrace_bfi = PLC_MIN_CNG_LEV_FLT; st->hTcxDec->NoiseLevelIndex_bfi = PLC_MIN_STAT_BUFF_SIZE - 1; st->hTcxDec->CurrLevelIndex_bfi = 0; - st->hTcxDec->LastFrameLevel_bfi = PLC_MIN_CNG_LEV; - set_f( st->hTcxDec->NoiseLevelMemory_bfi, PLC_MIN_CNG_LEV, PLC_MIN_STAT_BUFF_SIZE ); + st->hTcxDec->LastFrameLevel_bfi = PLC_MIN_CNG_LEV_FLT; + set_f( st->hTcxDec->NoiseLevelMemory_bfi, PLC_MIN_CNG_LEV_FLT, PLC_MIN_STAT_BUFF_SIZE ); - st->hTcxDec->cummulative_damping_tcx = 1.0f; + st->hTcxDec->cummulative_damping_tcx_float = 1.0f; } } @@ -596,7 +596,7 @@ void open_decoder_LPD( if ( st->ini_frame == 0 || ( st->last_codec_mode == MODE1 && st->element_mode == EVS_MONO ) ) { - hTcxDec->tcxltp_last_gain_unmodified = 0.f; + hTcxDec->tcxltp_last_gain_unmodified_float = 0.f; } /* TCX */ @@ -658,7 +658,7 @@ void open_decoder_LPD( { st->hTonalMDCTConc->nScaleFactors = 0; st->hTonalMDCTConc->nSamples = 0; - st->hTonalMDCTConc->lastPcmOut = 0x0; + st->hTonalMDCTConc->lastPcmOut_float = 0x0; st->hTonalMDCTConc->lastBlockData.tonalConcealmentActive = 0; st->hTonalMDCTConc->lastBlockData.nSamples = 0; @@ -676,8 +676,8 @@ void open_decoder_LPD( } if ( hTcxDec != NULL ) { - hTcxDec->tcxltp_second_last_pitch = st->old_fpitch; - hTcxDec->tcxltp_third_last_pitch = st->old_fpitch; + hTcxDec->tcxltp_second_last_pitch_float = st->old_fpitch; + hTcxDec->tcxltp_third_last_pitch_float = st->old_fpitch; } if ( ( total_brate == ACELP_9k60 || total_brate == ACELP_16k40 || total_brate == ACELP_24k40 ) && st->element_mode == EVS_MONO ) @@ -696,14 +696,14 @@ void open_decoder_LPD( { hTcxDec->enableTcxLpc = 1; - hTcxDec->old_gaintcx_bfi = 0.0f; + hTcxDec->old_gaintcx_bfi_float = 0.0f; hTcxDec->tcx_hm_LtpPitchLag = -1; } if ( st->hTcxCfg != NULL ) { - st->hTcxCfg->na_scale = 1.f; + st->hTcxCfg->na_scale_flt = 1.f; } return; @@ -723,7 +723,7 @@ void tcxltp_dec_init( const int16_t pit_max, const int32_t sr_core ) { - hTcxLtpDec->tcxltp_gain = 0.0f; + hTcxLtpDec->tcxltp_gain_float = 0.0f; hTcxLtpDec->tcxltp = getTcxLtp( sr_core ); @@ -735,11 +735,11 @@ void tcxltp_dec_init( if ( ini_frame == 0 ) { - set_f( hTcxLtpDec->tcxltp_mem_in, 0.0f, TCXLTP_MAX_DELAY ); - set_f( hTcxLtpDec->tcxltp_mem_out, 0.0f, L_FRAME48k ); + set_f( hTcxLtpDec->tcxltp_mem_in_float, 0.0f, TCXLTP_MAX_DELAY ); + set_f( hTcxLtpDec->tcxltp_mem_out_float, 0.0f, L_FRAME48k ); hTcxLtpDec->tcxltp_pitch_int_post_prev = 0; hTcxLtpDec->tcxltp_pitch_fr_post_prev = 0; - hTcxLtpDec->tcxltp_gain_post_prev = 0.f; + hTcxLtpDec->tcxltp_gain_post_prev_float = 0.f; hTcxLtpDec->tcxltp_filt_idx_prev = -1; } } @@ -757,10 +757,10 @@ void reset_tcx_overl_buf( TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */ ) { - set_zero( hTcxDec->old_syn_Overl, L_FRAME32k / 2 ); - set_zero( hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2 ); - set_zero( hTcxDec->syn_Overl, L_FRAME32k / 2 ); - set_zero( hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2 ); + set_zero( hTcxDec->old_syn_Overl_float, L_FRAME32k / 2 ); + set_zero( hTcxDec->syn_Overl_TDAC_float, L_FRAME32k / 2 ); + set_zero( hTcxDec->syn_Overl_float, L_FRAME32k / 2 ); + set_zero( hTcxDec->syn_Overl_TDACFB_float, L_FRAME_MAX / 2 ); return; } @@ -784,13 +784,13 @@ void acelp_plc_mdct_transition( if ( st->prev_bfi != 0 && st->hTcxCfg != NULL ) { W1 = st->hTcxCfg->tcx_mdct_window_lengthFB; - w = st->hTcxCfg->tcx_mdct_windowFB; + w = st->hTcxCfg->tcx_mdct_windowFB_flt; nz = NS2SA( st->output_Fs, N_ZERO_MDCT_NS ); delay_comp = NS2SA( st->output_Fs, DELAY_CLDFB_NS ); /*CLDFB delay*/ - mvr2r( st->hHQ_core->fer_samples + delay_comp, st->hTcxDec->syn_OverlFB, st->hTcxDec->L_frameTCX / 2 ); - lerp( st->hHQ_core->fer_samples + delay_comp, st->hTcxDec->syn_Overl, st->L_frame / 2, st->hTcxDec->L_frameTCX / 2 ); /*ACELP(bfi)->TCX(rect)*/ + mvr2r( st->hHQ_core->fer_samples + delay_comp, st->hTcxDec->syn_OverlFB_float, st->hTcxDec->L_frameTCX / 2 ); + lerp( st->hHQ_core->fer_samples + delay_comp, st->hTcxDec->syn_Overl_float, st->L_frame / 2, st->hTcxDec->L_frameTCX / 2 ); /*ACELP(bfi)->TCX(rect)*/ /*old_out needed for MODE1 routine and syn_Overl_TDAC for MODE2 routine*/ set_f( st->hHQ_core->old_out, 0, nz ); mvr2r( st->hHQ_core->fer_samples + delay_comp, st->hHQ_core->old_out + nz, W1 ); @@ -803,9 +803,9 @@ void acelp_plc_mdct_transition( lerp( st->hHQ_core->old_out, st->hHQ_core->old_outLB, st->L_frame, st->hTcxDec->L_frameTCX ); - mvr2r( st->hHQ_core->old_out + nz, st->hTcxDec->syn_Overl_TDACFB, st->hTcxDec->L_frameTCX / 2 ); + mvr2r( st->hHQ_core->old_out + nz, st->hTcxDec->syn_Overl_TDACFB_float, st->hTcxDec->L_frameTCX / 2 ); nz = NS2SA( st->sr_core, N_ZERO_MDCT_NS ); - mvr2r( st->hHQ_core->old_outLB + nz, st->hTcxDec->syn_Overl_TDAC, st->L_frame / 2 ); + mvr2r( st->hHQ_core->old_outLB + nz, st->hTcxDec->syn_Overl_TDAC_float, st->L_frame / 2 ); } return; diff --git a/lib_dec/core_dec_reconf.c b/lib_dec/core_dec_reconf.c index ffbcfca95..f05cf8e57 100644 --- a/lib_dec/core_dec_reconf.c +++ b/lib_dec/core_dec_reconf.c @@ -81,8 +81,8 @@ void reconfig_decoder_LPD( st->acelp_cfg_rf.formant_enh = 1; st->acelp_cfg_rf.formant_tilt = 1; st->acelp_cfg_rf.voice_tilt = 1; - st->acelp_cfg_rf.formant_enh_num = FORMANT_SHARPENING_G1; - st->acelp_cfg_rf.formant_enh_den = FORMANT_SHARPENING_G2; + st->acelp_cfg_rf.formant_enh_num_flt = FORMANT_SHARPENING_G1_FLT; + st->acelp_cfg_rf.formant_enh_den_flt = FORMANT_SHARPENING_G2_FLT; if ( st->element_mode != IVAS_SCE ) { @@ -98,7 +98,7 @@ void reconfig_decoder_LPD( /*Scale TCX for non-active frames to adjust loudness with ACELP*/ if ( st->hTcxCfg != NULL ) { - st->hTcxCfg->na_scale = 1.f; + st->hTcxCfg->na_scale_flt = 1.f; if ( bwidth < SWB && !( st->tcxonly ) ) { @@ -112,7 +112,7 @@ void reconfig_decoder_LPD( { i--; } - st->hTcxCfg->na_scale = scaleTcxTable[i].scale; + st->hTcxCfg->na_scale_flt = scaleTcxTable[i].scale_flt; break; } } @@ -138,12 +138,12 @@ void reconfig_decoder_LPD( if ( st->hTcxDec != NULL ) { - lerp( st->hTcxDec->old_syn_Overl, st->hTcxDec->old_syn_Overl, newLen, oldLen ); - lerp( st->hTcxDec->syn_Overl, st->hTcxDec->syn_Overl, newLen, oldLen ); + lerp( st->hTcxDec->old_syn_Overl_float, st->hTcxDec->old_syn_Overl_float, newLen, oldLen ); + lerp( st->hTcxDec->syn_Overl_float, st->hTcxDec->syn_Overl_float, newLen, oldLen ); if ( st->prev_bfi && st->last_core_bfi == ACELP_CORE ) { - lerp( st->hTcxDec->syn_Overl_TDAC, st->hTcxDec->syn_Overl_TDAC, newLen, oldLen ); + lerp( st->hTcxDec->syn_Overl_TDAC_float, st->hTcxDec->syn_Overl_TDAC_float, newLen, oldLen ); } } } diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index 2625d59a6..a7e1f9313 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -147,7 +147,7 @@ ivas_error core_switching_pre_dec( if ( st->element_mode == EVS_MONO ) { st->last_core = HQ_CORE; - mvr2r( st->hTcxDec->FBTCXdelayBuf, st->prev_synth_buffer, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); + mvr2r( st->hTcxDec->FBTCXdelayBuf_float, st->prev_synth_buffer, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); } if ( st->hHQ_core != NULL ) @@ -194,7 +194,7 @@ ivas_error core_switching_pre_dec( return error; } - cldfbAnalysis( st->hTcxDec->syn_Overl, realBuffer, imagBuffer, delay_comp, st->cldfbAna ); + cldfbAnalysis( st->hTcxDec->syn_Overl_float, realBuffer, imagBuffer, delay_comp, st->cldfbAna ); cldfb_restore_memory( st->cldfbAna ); /* CLDFB synthesis of the combined signal */ @@ -209,7 +209,7 @@ ivas_error core_switching_pre_dec( if ( !st->last_con_tcx && st->last_core_bfi == ACELP_CORE && st->core == HQ_CORE ) { - lerp( st->hTcxDec->syn_Overl, st->hHQ_core->fer_samples + delay_comp, output_frame / 2, st->last_L_frame / 2 ); + lerp( st->hTcxDec->syn_Overl_float, st->hHQ_core->fer_samples + delay_comp, output_frame / 2, st->last_L_frame / 2 ); /*Set to zero the remaining part*/ set_f( st->hHQ_core->fer_samples + delay_comp + output_frame / 2, 0, ( output_frame / 2 ) - delay_comp ); } @@ -288,7 +288,7 @@ ivas_error core_switching_pre_dec( if ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && nchan_out == 2 && st->core_brate > SID_2k40 && ( last_core_brate_st0 == FRAME_NO_DATA || last_core_brate_st0 == SID_2k40 ) && st->hTcxDec != NULL ) { /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */ - set_f( st->hTcxDec->old_syn_Overl, 0.0f, L_FRAME32k / 2 ); + set_f( st->hTcxDec->old_syn_Overl_float, 0.0f, L_FRAME32k / 2 ); set_f( st->hFdCngDec->hFdCngCom->olapBufferAna, 0.0f, FFTLEN ); } @@ -627,7 +627,7 @@ ivas_error core_switching_post_dec( } /* delay HQ synthesis to synchronize with ACELP synthesis */ - delay_signal( synth, output_frame, st->delay_buf_out, delay_comp ); + delay_signal_float( synth, output_frame, st->delay_buf_out, delay_comp ); if ( st->element_mode == EVS_MONO && st->core == HQ_CORE ) /* ACELP->HQ-CORE */ { @@ -786,7 +786,7 @@ ivas_error core_switching_post_dec( { for ( i = 0; i < NS2SA( st->output_Fs, 3000000 ); i++ ) { - synth[i + delay_comp] = ( 1 - tmpF * (float) i ) * st->hHQ_core->old_out[i + nZeros] * st->hTcxDec->conceal_eof_gain + tmpF * (float) i * synth[i + delay_comp]; + synth[i + delay_comp] = ( 1 - tmpF * (float) i ) * st->hHQ_core->old_out[i + nZeros] * st->hTcxDec->conceal_eof_gain_float + tmpF * (float) i * synth[i + delay_comp]; } } else diff --git a/lib_dec/dec_LPD.c b/lib_dec/dec_LPD.c index e3d0561c2..558a0f1c2 100644 --- a/lib_dec/dec_LPD.c +++ b/lib_dec/dec_LPD.c @@ -119,7 +119,7 @@ void decoder_LPD( /* Initialize pointers */ synth = synth_buf + st->hTcxDec->old_synth_len; synthFB = synth_bufFB + st->hTcxDec->old_synth_lenFB; - mvr2r( st->hTcxDec->old_synth, synth_buf, st->hTcxDec->old_synth_len ); + mvr2r( st->hTcxDec->old_synth_float, synth_buf, st->hTcxDec->old_synth_len ); mvr2r( st->hTcxDec->old_synthFB, synth_bufFB, st->hTcxDec->old_synth_lenFB ); set_zero( synth, L_FRAME_PLUS + M ); set_zero( synthFB, L_FRAME_PLUS + M ); @@ -221,7 +221,7 @@ void decoder_LPD( /* quantized lsf from two stages */ v_add( lsf_q_1st_rf, lsf_q_diff_cb_8b_rf + M * param_lpc[1], lsf_q_rf, M ); - v_sort( lsf_q_rf, 0, M - 1 ); + v_sort_float( lsf_q_rf, 0, M - 1 ); reorder_lsf( lsf_q_rf, LSF_GAP, M, st->sr_core ); /* current n-th ACELP frame and its corresponding partial copy */ @@ -245,7 +245,7 @@ void decoder_LPD( } /* update mem_MA and mem_AR memories */ - lsf_update_memory( st->narrowBand, &lsf[M], st->mem_MA, st->mem_MA ); + lsf_update_memory_float( st->narrowBand, &lsf[M], st->mem_MA, st->mem_MA ); mvr2r( &lsf[M], st->mem_AR, M ); for ( k = 0; k < st->numlpc; ++k ) @@ -260,11 +260,11 @@ void decoder_LPD( if ( bfi && st->use_partial_copy && st->rf_frame_type == RF_TCXFD ) { - tcx_lpc_cdk = tcxlpc_get_cdk( GENERIC ); + tcx_lpc_cdk = tcxlpc_get_cdk_float( GENERIC ); } else { - tcx_lpc_cdk = tcxlpc_get_cdk( st->coder_type ); + tcx_lpc_cdk = tcxlpc_get_cdk_float( st->coder_type ); } mvr2r( st->lsf_old, &lsf[0], M ); @@ -274,11 +274,11 @@ void decoder_LPD( lsf2lsp( &lsf[M], &lsp[M], M, st->sr_core ); - lsf_update_memory( st->narrowBand, &lsf[M], st->mem_MA, st->mem_MA ); + lsf_update_memory_float( st->narrowBand, &lsf[M], st->mem_MA, st->mem_MA ); mvr2r( &lsf[M], st->mem_AR, M ); hTcxDec->envWeighted = 1; - E_LPC_lsp_unweight( &lsp[M], lspnew_uw, lsfnew_uw, 1.0f / st->gamma ); + E_LPC_lsp_unweight_float( &lsp[M], lspnew_uw, lsfnew_uw, 1.0f / st->gamma ); } else { @@ -534,7 +534,7 @@ void decoder_LPD( { st->second_last_tns_active = st->last_tns_active; st->last_tns_active = 0; - hTcxDec->tcxltp_last_gain_unmodified = 0.0f; + hTcxDec->tcxltp_last_gain_unmodified_float = 0.0f; } } @@ -573,7 +573,7 @@ void decoder_LPD( else { /* LPC Interpolation for TCX */ - E_LPC_int_lpc_tcx( &lsp[0], &lsp[M], Aq ); + E_LPC_int_lpc_tcx_float( &lsp[0], &lsp[M], Aq ); } } else @@ -669,7 +669,7 @@ void decoder_LPD( /* note: the classifier needs the pitch only for tcx_only == 0, i.e. not for TCX10 */ pitch_C[0] = pitch_C[1] = pitch_C[2] = pitch_C[3] = (float) floor( st->old_fpitch + 0.5f ); - FEC_clas_estim( synth, pitch_C, st->L_frame, st->tcxonly ? GENERIC : st->core_ext_mode, st->codec_mode, st->mem_syn_clas_estim, &st->clas_dec, &st->lp_ener_bfi, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, hTcxLtpDec->tcxltp ? hTcxDec->tcxltp_last_gain_unmodified : -1.0f, st->narrowBand, CLASSIFIER_TCX, bfi, st->preemph_fac, st->tcxonly, st->last_core_brate, -1 ); + FEC_clas_estim( synth, pitch_C, st->L_frame, st->tcxonly ? GENERIC : st->core_ext_mode, st->codec_mode, st->mem_syn_clas_estim, &st->clas_dec, &st->lp_ener_bfi, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, hTcxLtpDec->tcxltp ? hTcxDec->tcxltp_last_gain_unmodified_float : -1.0f, st->narrowBand, CLASSIFIER_TCX, bfi, st->preemph_fac, st->tcxonly, st->last_core_brate, -1 ); } } @@ -680,7 +680,7 @@ void decoder_LPD( if ( bfi && st->last_core != ACELP_CORE ) { /* Update FEC_scale_syn parameters */ - if ( hTcxLtpDec->tcxltp_gain == 0 ) + if ( hTcxLtpDec->tcxltp_gain_float == 0 ) { fer_energy( L_frame, UNVOICED, synth, (float) ( L_frame / 2 ), &st->enr_old, L_frame ); } @@ -708,7 +708,7 @@ void decoder_LPD( /* Update */ - mvr2r( synth_buf + L_frame, st->hTcxDec->old_synth, st->hTcxDec->old_synth_len ); + mvr2r( synth_buf + L_frame, st->hTcxDec->old_synth_float, st->hTcxDec->old_synth_len ); mvr2r( st->hTcxDec->old_synthFB + L_frameTCX - NS2SA( st->output_Fs, PH_ECU_MEM_NS ), st->hTcxDec->synth_history, NS2SA( st->output_Fs, PH_ECU_MEM_NS ) ); mvr2r( synth_bufFB + L_frameTCX, st->hTcxDec->old_synthFB, st->hTcxDec->old_synth_lenFB ); mvr2r( st->hHQ_core->old_out + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB + st->hTcxDec->old_synth_lenFB, NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); diff --git a/lib_dec/dec_ace.c b/lib_dec/dec_ace.c index 1012b8e77..527baafd8 100644 --- a/lib_dec/dec_ace.c +++ b/lib_dec/dec_ace.c @@ -154,15 +154,15 @@ void decoder_acelp( if ( st->last_con_tcx && st->old_enr_LP ) { - float enr_LP, ratio; + float enr_LP, ratio_float; /* rescale excitation buffer if LPC energies differs too much */ enr_LP = enr_1_Az( A, L_SUBFR ); - ratio = st->old_enr_LP / enr_LP; - if ( ratio < 0.8 ) + ratio_float = st->old_enr_LP / enr_LP; + if ( ratio_float < 0.8 ) { - v_multc( st->old_exc, ratio, st->old_exc, L_EXC_MEM_DEC ); + v_multc( st->old_exc, ratio_float, st->old_exc, L_EXC_MEM_DEC ); } } @@ -327,7 +327,7 @@ void decoder_acelp( * - Add the fixed-gain pitch contribution to code[]. * *-------------------------------------------------------*/ - cb_shape( acelp_cfg.pre_emphasis, acelp_cfg.pitch_sharpening, acelp_cfg.phase_scrambling, acelp_cfg.formant_enh, acelp_cfg.formant_tilt, acelp_cfg.formant_enh_num, acelp_cfg.formant_enh_den, p_A, code, st->tilt_code, pitch_buf[i_subfr / L_SUBFR], L_SUBFR ); + cb_shape( acelp_cfg.pre_emphasis, acelp_cfg.pitch_sharpening, acelp_cfg.phase_scrambling, acelp_cfg.formant_enh, acelp_cfg.formant_tilt, acelp_cfg.formant_enh_num_flt, acelp_cfg.formant_enh_den_flt, p_A, code, st->tilt_code, pitch_buf[i_subfr / L_SUBFR], L_SUBFR ); } /*-------------------------------------------------------* @@ -336,7 +336,7 @@ void decoder_acelp( if ( acelp_cfg.gains_mode[i_subfr / L_SUBFR] == 7 && !st->use_partial_copy ) { - gaus_L2_dec( code2, st->tilt_code, p_A, acelp_cfg.formant_enh_num, &( st->seed_acelp ) ); + gaus_L2_dec( code2, st->tilt_code, p_A, acelp_cfg.formant_enh_num_flt, &( st->seed_acelp ) ); } else { @@ -509,7 +509,7 @@ void decoder_acelp( tmp = st->syn[M]; deemph( syn, st->preemph_fac, L_frame, &tmp ); - mvr2r( syn + L_frame - ( L_frame / 2 ), st->hTcxDec->old_syn_Overl, L_frame / 2 ); + mvr2r( syn + L_frame - ( L_frame / 2 ), st->hTcxDec->old_syn_Overl_float, L_frame / 2 ); mvr2r( syn + L_frame - M - 1, st->syn, M + 1 ); mvr2r( syn, synth, L_frame ); @@ -528,14 +528,14 @@ void decoder_acelp( } /* Update TCX-LTP */ - hTcxDec->tcxltp_last_gain_unmodified = 0.f; + hTcxDec->tcxltp_last_gain_unmodified_float = 0.f; /*Update MODE1*/ mvr2r( p_A - ( M + 1 ), st->old_Aq_12_8, M + 1 ); st->old_Es_pred = Es_pred; - hTcxDec->tcxltp_third_last_pitch = hTcxDec->tcxltp_second_last_pitch; - hTcxDec->tcxltp_second_last_pitch = st->old_fpitch; + hTcxDec->tcxltp_third_last_pitch_float = hTcxDec->tcxltp_second_last_pitch_float; + hTcxDec->tcxltp_second_last_pitch_float = st->old_fpitch; st->old_fpitch = pitch_buf[( L_frame / L_SUBFR ) - 1]; return; diff --git a/lib_dec/dec_post.c b/lib_dec/dec_post.c index 6116539e9..99c3b4041 100644 --- a/lib_dec/dec_post.c +++ b/lib_dec/dec_post.c @@ -87,19 +87,19 @@ void Init_post_filter( hPFstat->reset = 0; /* Initialize arrays and pointers */ - set_zero( hPFstat->mem_pf_in, L_SUBFR ); + set_zero( hPFstat->mem_pf_in_flt, L_SUBFR ); /* res2 = A(gamma2) residual */ - set_zero( hPFstat->mem_res2, DECMEM_RES2 ); + set_zero( hPFstat->mem_res2_flt, DECMEM_RES2 ); /* 1/A(gamma1) memory */ - set_zero( hPFstat->mem_stp, L_SUBFR ); + set_zero( hPFstat->mem_stp_flt, L_SUBFR ); /* null memory to compute i.r. of A(gamma2)/A(gamma1) */ - set_zero( hPFstat->mem_zero, M ); + set_zero( hPFstat->mem_zero_flt, M ); /* for gain adjustment */ - hPFstat->gain_prec = 1.0f; + hPFstat->gain_prec_flt = 1.0f; return; } @@ -144,18 +144,18 @@ void nb_post_filt( if ( hPFstat->reset ) { - set_zero( hPFstat->mem_res2, DECMEM_RES2 ); - mvr2r( &synth[L_frame - L_SYN_MEM], hPFstat->mem_pf_in, L_SYN_MEM ); - mvr2r( &synth[L_frame - L_SYN_MEM], hPFstat->mem_stp, L_SYN_MEM ); - hPFstat->gain_prec = 1.0f; + set_zero( hPFstat->mem_res2_flt, DECMEM_RES2 ); + mvr2r( &synth[L_frame - L_SYN_MEM], hPFstat->mem_pf_in_flt, L_SYN_MEM ); + mvr2r( &synth[L_frame - L_SYN_MEM], hPFstat->mem_stp_flt, L_SYN_MEM ); + hPFstat->gain_prec_flt = 1.0f; hPFstat->reset = 0; return; } pf_in = &pf_in_buffer[M]; - mvr2r( hPFstat->mem_pf_in + L_SYN_MEM - M, &pf_in[-M], M ); + mvr2r( hPFstat->mem_pf_in_flt + L_SYN_MEM - M, &pf_in[-M], M ); mvr2r( synth, pf_in, L_frame ); - mvr2r( &synth[L_frame - L_SYN_MEM], hPFstat->mem_pf_in, L_SYN_MEM ); + mvr2r( &synth[L_frame - L_SYN_MEM], hPFstat->mem_pf_in_flt, L_SYN_MEM ); /* deactivation of the post filter in case of AUDIO because it causes problems to singing sequences */ if ( coder_type == AUDIO ) @@ -206,7 +206,7 @@ void formant_post_filt( if ( L_frame == L_FRAME ) { post_G2 = 0.7f; - if ( lp_noise < LP_NOISE_THRESH ) /* Clean speech */ + if ( lp_noise < LP_NOISE_THRESH_FLT) /* Clean speech */ { if ( brate < ACELP_13k20 ) /*Low rates*/ { @@ -236,7 +236,7 @@ void formant_post_filt( else { post_G2 = 0.76f; - if ( lp_noise >= LP_NOISE_THRESH ) + if ( lp_noise >= LP_NOISE_THRESH_FLT) { post_G1 = 0.76f; } @@ -268,17 +268,17 @@ void formant_post_filt( if ( hPFstat->reset ) { hPFstat->reset = 0; - mvr2r( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_pf_in, L_SYN_MEM ); - mvr2r( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_stp, L_SYN_MEM ); - hPFstat->gain_prec = 1.f; + mvr2r( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_pf_in_flt, L_SYN_MEM ); + mvr2r( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_stp_flt, L_SYN_MEM ); + hPFstat->gain_prec_flt = 1.f; mvr2r( synth_in, synth_out, L_frame ); return; } /* input memory*/ - mvr2r( hPFstat->mem_pf_in, synth_in - L_SYN_MEM, L_SYN_MEM ); - mvr2r( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_pf_in, L_SYN_MEM ); + mvr2r( hPFstat->mem_pf_in_flt, synth_in - L_SYN_MEM, L_SYN_MEM ); + mvr2r( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_pf_in_flt, L_SYN_MEM ); /* run the post filter */ p_Aq = Aq; @@ -341,8 +341,8 @@ static void Dec_postfilt( /* Init pointers and restore memories */ res2_ptr = res2 + DECMEM_RES2; - ptr_mem_stp = pfstat->mem_stp + L_SYN_MEM - 1; - mvr2r( pfstat->mem_res2, res2, DECMEM_RES2 ); + ptr_mem_stp = pfstat->mem_stp_flt + L_SYN_MEM - 1; + mvr2r( pfstat->mem_res2_flt, res2, DECMEM_RES2 ); /* Compute weighted LPC coefficients */ weight_a( coeff, apond1, gamma1, M ); @@ -369,19 +369,19 @@ static void Dec_postfilt( sig_ltp[0] = *ptr_mem_stp; /* Controls short term pst filter gain and compute parcor0 */ - calc_st_filt( apond2, apond1, &parcor0, sig_ltp_ptr, pfstat->mem_zero, L_subfr, -1 ); + calc_st_filt( apond2, apond1, &parcor0, sig_ltp_ptr, pfstat->mem_zero_flt, L_subfr, -1 ); - syn_filt( apond1, M, sig_ltp_ptr, sig_ltp_ptr, L_subfr, pfstat->mem_stp + L_SYN_MEM - M, 0 ); - mvr2r( sig_ltp_ptr + L_SUBFR - L_SYN_MEM, pfstat->mem_stp, L_SYN_MEM ); + syn_filt( apond1, M, sig_ltp_ptr, sig_ltp_ptr, L_subfr, pfstat->mem_stp_flt + L_SYN_MEM - M, 0 ); + mvr2r( sig_ltp_ptr + L_SUBFR - L_SYN_MEM, pfstat->mem_stp_flt, L_SYN_MEM ); /* Tilt filtering */ filt_mu( sig_ltp, sig_out, parcor0, L_subfr, -1 ); /* Gain control */ - scale_st( signal_ptr, sig_out, &( pfstat->gain_prec ), L_subfr, -1 ); + scale_st( signal_ptr, sig_out, &( pfstat->gain_prec_flt), L_subfr, -1 ); /* Update for next subframe */ - mvr2r( &res2[L_subfr], pfstat->mem_res2, DECMEM_RES2 ); + mvr2r( &res2[L_subfr], pfstat->mem_res2_flt, DECMEM_RES2 ); return; } @@ -430,20 +430,20 @@ static void Dec_formant_postfilt( residu( apond2, M, signal_ptr, res2, l_subfr ); /* Controls short term pst filter gain and compute parcor0 */ - calc_st_filt( apond2, apond1, &parcor0, res2, hPFstat->mem_zero, l_subfr, -1 ); + calc_st_filt( apond2, apond1, &parcor0, res2, hPFstat->mem_zero_flt, l_subfr, -1 ); /* 1/A(gamma1) filtering, mem_stp is updated */ - resynth[0] = *( hPFstat->mem_stp + L_SYN_MEM - 1 ); + resynth[0] = *( hPFstat->mem_stp_flt + L_SYN_MEM - 1 ); - syn_filt( apond1, M, res2, &( resynth[1] ), l_subfr, hPFstat->mem_stp + L_SYN_MEM - M, 0 ); + syn_filt( apond1, M, res2, &( resynth[1] ), l_subfr, hPFstat->mem_stp_flt + L_SYN_MEM - M, 0 ); - mvr2r( &( resynth[1] ) + l_subfr - L_SYN_MEM, hPFstat->mem_stp, L_SYN_MEM ); + mvr2r( &( resynth[1] ) + l_subfr - L_SYN_MEM, hPFstat->mem_stp_flt, L_SYN_MEM ); /* Tilt filtering */ filt_mu( resynth, sig_out, parcor0, l_subfr, -1 ); /* Gain control */ - scale_st( signal_ptr, sig_out, &hPFstat->gain_prec, l_subfr, -1 ); + scale_st( signal_ptr, sig_out, &hPFstat->gain_prec_flt, l_subfr, -1 ); return; } diff --git a/lib_dec/dec_prm.c b/lib_dec/dec_prm.c index 347abd25e..db690f6a9 100644 --- a/lib_dec/dec_prm.c +++ b/lib_dec/dec_prm.c @@ -297,7 +297,7 @@ void getLPCparam( if ( st->hTcxDec->enableTcxLpc && st->core != ACELP_CORE ) { int16_t tcx_lpc_cdk; - tcx_lpc_cdk = tcxlpc_get_cdk( st->coder_type ); + tcx_lpc_cdk = tcxlpc_get_cdk_float( st->coder_type ); dec_lsf_tcxlpc( st0, ¶m_lpc, st->narrowBand, tcx_lpc_cdk ); } else @@ -471,9 +471,9 @@ void getTCXparam( tcxltp_prm_1 = prm[j + 1]; tcxltp_prm_2 = prm[j + 2]; } - st->BER_detect = st->BER_detect | tcx_ltp_decode_params( &prm[j], &( hTcxLtpDec->tcxltp_pitch_int ), &( hTcxLtpDec->tcxltp_pitch_fr ), &( hTcxLtpDec->tcxltp_gain ), st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max ); + st->BER_detect = st->BER_detect | tcx_ltp_decode_params( &prm[j], &( hTcxLtpDec->tcxltp_pitch_int ), &( hTcxLtpDec->tcxltp_pitch_fr ), &( hTcxLtpDec->tcxltp_gain_float ), st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max ); - hTcxDec->tcxltp_last_gain_unmodified = hTcxLtpDec->tcxltp_gain; + hTcxDec->tcxltp_last_gain_unmodified_float = hTcxLtpDec->tcxltp_gain_float; if ( core == TCX_20_CORE && !st->tcxonly && hTcxLtpDec->tcxltp_pitch_int < st->L_frame ) { @@ -775,7 +775,7 @@ void dec_prm( if ( hTcxDec != NULL ) { hTcxDec->tcx_hm_LtpPitchLag = -1; - hTcxLtpDec->tcxltp_gain = 0.0f; + hTcxLtpDec->tcxltp_gain_float = 0.0f; } /*--------------------------------------------------------------------------------* @@ -1074,7 +1074,7 @@ void dec_prm( if ( st->rf_frame_type == RF_TCXFD ) { /* TCX Gain */ - hTcxDec->old_gaintcx_bfi = get_next_indice( st, NBITS_TCX_GAIN ); + hTcxDec->old_gaintcx_bfi_float = get_next_indice( st, NBITS_TCX_GAIN ); } else { @@ -1090,9 +1090,9 @@ void dec_prm( if ( !st->prev_bfi ) { st->BER_detect = st->BER_detect | - tcx_ltp_decode_params( &prm_ltp[0], &( hTcxLtpDec->tcxltp_pitch_int ), &( hTcxLtpDec->tcxltp_pitch_fr ), &( hTcxLtpDec->tcxltp_gain ), st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max ); + tcx_ltp_decode_params( &prm_ltp[0], &( hTcxLtpDec->tcxltp_pitch_int ), &( hTcxLtpDec->tcxltp_pitch_fr ), &( hTcxLtpDec->tcxltp_gain_float ), st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max ); - hTcxDec->tcxltp_last_gain_unmodified = hTcxLtpDec->tcxltp_gain; + hTcxDec->tcxltp_last_gain_unmodified_float = hTcxLtpDec->tcxltp_gain_float; } } } diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 2e131391e..b4ee39eee 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -133,14 +133,14 @@ void decoder_tcx_post( /* first TCX frame after ACELP; overwrite ltp initialization done during acelp PLC */ if ( !bfi && st->prev_bfi && !st->last_core ) { - hTcxDec->tcxltp_last_gain_unmodified = 0.0f; + hTcxDec->tcxltp_last_gain_unmodified_float = 0.0f; } if ( st->hTcxLtpDec != NULL && st->element_mode > EVS_MONO && ( st->clas_dec == UNVOICED_CLAS || st->clas_dec == INACTIVE_CLAS ) ) { /* deactivate TCX LTP for non-voiced frames */ st->hTcxLtpDec->tcxltp = 0; - st->hTcxLtpDec->tcxltp_gain = 0.0f; + st->hTcxLtpDec->tcxltp_gain_float = 0.0f; } if ( bfi && !st->use_partial_copy ) @@ -148,8 +148,8 @@ void decoder_tcx_post( /* run lpc gain compensation not for waveform adjustment */ if ( !st->enablePlcWaveadjust || ( st->hPlcInfo != NULL && st->hPlcInfo->concealment_method == TCX_TONAL ) ) { - float gainHelperFB = hTcxDec->gainHelper; - float stepCompensateFB = hTcxDec->stepCompensate * st->L_frame / hTcxDec->L_frameTCX; + float gainHelperFB = hTcxDec->gainHelper_float; + float stepCompensateFB = hTcxDec->stepCompensate_float * st->L_frame / hTcxDec->L_frameTCX; for ( i = 0; i < hTcxDec->L_frameTCX; i++ ) { @@ -160,8 +160,8 @@ void decoder_tcx_post( for ( i = 0; i < st->L_frame; i++ ) { - xn_buf[i] *= hTcxDec->gainHelper; - hTcxDec->gainHelper -= hTcxDec->stepCompensate; + xn_buf[i] *= hTcxDec->gainHelper_float; + hTcxDec->gainHelper_float -= hTcxDec->stepCompensate_float; } } @@ -173,7 +173,7 @@ void decoder_tcx_post( * PLC: update or retrieve the background level */ if ( bfi == 0 && st->tcxonly && ( st->element_mode != IVAS_CPE_MDCT || MCT_flag ) && st->clas_dec == UNVOICED_CLAS ) { - minimumStatistics( hTcxDec->NoiseLevelMemory_bfi, &hTcxDec->NoiseLevelIndex_bfi, &hTcxDec->CurrLevelIndex_bfi, &hTcxDec->CngLevelBackgroundTrace_bfi, &hTcxDec->LastFrameLevel_bfi, level_syn, PLC_MIN_CNG_LEV, PLC_MIN_STAT_BUFF_SIZE ); + minimumStatistics( hTcxDec->NoiseLevelMemory_bfi, &hTcxDec->NoiseLevelIndex_bfi, &hTcxDec->CurrLevelIndex_bfi, &hTcxDec->CngLevelBackgroundTrace_bfi, &hTcxDec->LastFrameLevel_bfi, level_syn, PLC_MIN_CNG_LEV_FLT, PLC_MIN_STAT_BUFF_SIZE ); } /* PLC: [TCX: Fade-out] @@ -204,13 +204,13 @@ void decoder_tcx_post( } if ( st->nbLostCmpt == 1 ) { - hTcxDec->conceal_eof_gain = 1.0f; + hTcxDec->conceal_eof_gain_float = 1.0f; } - step = ( hTcxDec->conceal_eof_gain - ( hTcxDec->conceal_eof_gain * hTcxDec->damping + gainCNG * ( 1 - hTcxDec->damping ) ) ) / st->L_frame; + step = ( hTcxDec->conceal_eof_gain_float - ( hTcxDec->conceal_eof_gain_float * hTcxDec->damping_float + gainCNG * ( 1 - hTcxDec->damping_float ) ) ) / st->L_frame; { float stepFB = step * st->L_frame / hTcxDec->L_frameTCX; - conceal_eof_gainFB = hTcxDec->conceal_eof_gain; + conceal_eof_gainFB = hTcxDec->conceal_eof_gain_float; for ( i = 0; i < hTcxDec->L_frameTCX; i++ ) { @@ -221,8 +221,8 @@ void decoder_tcx_post( for ( i = 0; i < st->L_frame; i++ ) { - xn_buf[i] *= hTcxDec->conceal_eof_gain; - hTcxDec->conceal_eof_gain -= step; + xn_buf[i] *= hTcxDec->conceal_eof_gain_float; + hTcxDec->conceal_eof_gain_float -= step; } /* run lpc gain compensation not for waveform adjustment */ @@ -230,11 +230,11 @@ void decoder_tcx_post( { if ( ( !st->enablePlcWaveadjust || st->hPlcInfo->concealment_method == TCX_TONAL ) && !st->use_partial_copy ) { - st->hPlcInfo->recovery_gain = conceal_eof_gainFB * st->last_concealed_gain_syn_deemph; + st->hPlcInfo->recovery_gain_float = conceal_eof_gainFB * st->last_concealed_gain_syn_deemph; } else { - st->hPlcInfo->recovery_gain = conceal_eof_gainFB; + st->hPlcInfo->recovery_gain_float = conceal_eof_gainFB; } st->hPlcInfo->step_concealgain = step * st->L_frame / hTcxDec->L_frameTCX; } @@ -263,7 +263,7 @@ void decoder_tcx_post( for ( i = 0; i < st->nb_subfr; i++ ) { st->mem_pitch_gain[2 * st->nb_subfr - 1 - i] = st->mem_pitch_gain[st->nb_subfr - 1 - i]; - st->mem_pitch_gain[st->nb_subfr - 1 - i] = hTcxDec->tcxltp_last_gain_unmodified; + st->mem_pitch_gain[st->nb_subfr - 1 - i] = hTcxDec->tcxltp_last_gain_unmodified_float; } return; @@ -317,7 +317,7 @@ void IMDCT( if ( st->element_mode != EVS_MONO && frame_cnt == 0 && !bfi && st->prev_bfi && ( st->last_core_bfi == TCX_20_CORE || st->last_core_bfi == TCX_10_CORE ) && !hTcxCfg->last_aldo ) { - v_multc( old_syn_overl, hTcxDec->conceal_eof_gain * st->last_concealed_gain_syn_deemph, old_syn_overl, overlap ); + v_multc( old_syn_overl, hTcxDec->conceal_eof_gain_float * st->last_concealed_gain_syn_deemph, old_syn_overl, overlap ); } if ( ( L_frameTCX == hTcxDec->L_frameTCX >> 1 ) && st->tcxonly ) @@ -361,7 +361,7 @@ void IMDCT( TCX_MDCT_Inverse( x + w * L_spec_TCX5, win, L_ola, L_win - L_ola, L_ola, st->element_mode ); } - tcx_windowing_synthesis_current_frame( win, tcx_aldo_window_2, tcx_mdct_window_half, tcx_mdct_window_minimum, L_ola, tcx_mdct_window_half_length, tcx_mdct_window_min_length, ( w > 0 ) ? 0 : left_rect, ( w > 0 ) || ( w == 0 && index == 2 ) ? MIN_OVERLAP : hTcxCfg->tcx_last_overlap_mode, acelp_zir, hTcxDec->old_syn_Overl, syn_Overl_TDAC, st->old_Aq_12_8, tcx_mdct_window_trans, L_win, tcx_offset < 0 ? -tcx_offset : 0, ( w > 0 ) || ( frame_cnt > 0 ) ? 1 : st->last_core, ( w > 0 ) || ( frame_cnt > 0 ) ? 0 : st->last_is_cng, fullbandScale ); + tcx_windowing_synthesis_current_frame( win, tcx_aldo_window_2, tcx_mdct_window_half, tcx_mdct_window_minimum, L_ola, tcx_mdct_window_half_length, tcx_mdct_window_min_length, ( w > 0 ) ? 0 : left_rect, ( w > 0 ) || ( w == 0 && index == 2 ) ? MIN_OVERLAP : hTcxCfg->tcx_last_overlap_mode, acelp_zir, hTcxDec->old_syn_Overl_float, syn_Overl_TDAC, st->old_Aq_12_8, tcx_mdct_window_trans, L_win, tcx_offset < 0 ? -tcx_offset : 0, ( w > 0 ) || ( frame_cnt > 0 ) ? 1 : st->last_core, ( w > 0 ) || ( frame_cnt > 0 ) ? 0 : st->last_is_cng, fullbandScale ); if ( w > 0 ) { @@ -423,7 +423,7 @@ void IMDCT( } tcx_windowing_synthesis_current_frame( win, tcx_aldo_window_2, tcx_mdct_window_half, tcx_mdct_window_minimum, L_ola, tcx_mdct_window_half_length, tcx_mdct_window_min_length, 0, - /* left_rect */ MIN_OVERLAP, /* left_mode */ acelp_zir, hTcxDec->old_syn_Overl, syn_Overl_TDAC, st->old_Aq_12_8, tcx_mdct_window_trans, L_win, tcx_offset < 0 ? -tcx_offset : 0, 1, /* st->last_mode_bfi */ 0, /* st->last_is_cng */ fullbandScale ); + /* left_rect */ MIN_OVERLAP, /* left_mode */ acelp_zir, hTcxDec->old_syn_Overl_float, syn_Overl_TDAC, st->old_Aq_12_8, tcx_mdct_window_trans, L_win, tcx_offset < 0 ? -tcx_offset : 0, 1, /* st->last_mode_bfi */ 0, /* st->last_is_cng */ fullbandScale ); tcx_windowing_synthesis_past_frame( xn_buf + ( overlap >> 1 ) + L_win - ( L_ola >> 1 ), tcx_aldo_window_1_trunc, tcx_mdct_window_half, tcx_mdct_window_minimum, L_ola, tcx_mdct_window_half_length, tcx_mdct_window_min_length, 2 ); @@ -448,7 +448,7 @@ void IMDCT( xn_buf[overlap - 1 - w] = -1.0f * xn_buf[w]; } } - tcx_windowing_synthesis_current_frame( xn_buf, tcx_aldo_window_2, tcx_mdct_window_half, tcx_mdct_window_minimum, overlap, tcx_mdct_window_half_length, tcx_mdct_window_min_length, left_rect, 0, /* left_mode */ acelp_zir, hTcxDec->old_syn_Overl, syn_Overl_TDAC, st->old_Aq_12_8, tcx_mdct_window_trans, 2 * L_win, tcx_offset < 0 ? -tcx_offset : 0, st->last_core_bfi, st->last_is_cng, fullbandScale ); + tcx_windowing_synthesis_current_frame( xn_buf, tcx_aldo_window_2, tcx_mdct_window_half, tcx_mdct_window_minimum, overlap, tcx_mdct_window_half_length, tcx_mdct_window_min_length, left_rect, 0, /* left_mode */ acelp_zir, hTcxDec->old_syn_Overl_float, syn_Overl_TDAC, st->old_Aq_12_8, tcx_mdct_window_trans, 2 * L_win, tcx_offset < 0 ? -tcx_offset : 0, st->last_core_bfi, st->last_is_cng, fullbandScale ); } else { @@ -466,7 +466,7 @@ void IMDCT( TCX_MDCT_Inverse( x, xn_buf, overlap, L_frame - overlap, overlap, st->element_mode ); } - tcx_windowing_synthesis_current_frame( xn_buf, tcx_aldo_window_2, tcx_mdct_window_half, tcx_mdct_window_minimum, overlap, tcx_mdct_window_half_length, tcx_mdct_window_min_length, left_rect, !bfi && ( frame_cnt > 0 ) && ( index == 0 ) && ( st->last_core != ACELP_CORE ) ? MIN_OVERLAP : index, acelp_zir, hTcxDec->old_syn_Overl, syn_Overl_TDAC, st->old_Aq_12_8, tcx_mdct_window_trans, L_frame_glob >> 1, tcx_offset < 0 ? -tcx_offset : 0, ( frame_cnt > 0 /*|| (st->last_con_tcx )*/ ) ? 1 : st->last_core_bfi, ( frame_cnt > 0 ) ? 0 : st->last_is_cng, fullbandScale ); + tcx_windowing_synthesis_current_frame( xn_buf, tcx_aldo_window_2, tcx_mdct_window_half, tcx_mdct_window_minimum, overlap, tcx_mdct_window_half_length, tcx_mdct_window_min_length, left_rect, !bfi && ( frame_cnt > 0 ) && ( index == 0 ) && ( st->last_core != ACELP_CORE ) ? MIN_OVERLAP : index, acelp_zir, hTcxDec->old_syn_Overl_float, syn_Overl_TDAC, st->old_Aq_12_8, tcx_mdct_window_trans, L_frame_glob >> 1, tcx_offset < 0 ? -tcx_offset : 0, ( frame_cnt > 0 /*|| (st->last_con_tcx )*/ ) ? 1 : st->last_core_bfi, ( frame_cnt > 0 ) ? 0 : st->last_is_cng, fullbandScale ); } /* tcx_last_overlap_mode != FULL_OVERLAP */ } @@ -538,7 +538,7 @@ void IMDCT( } /* Window current frame */ - tcx_windowing_synthesis_current_frame( xn_buf, tcx_aldo_window_2, tcx_mdct_window_half, tcx_mdct_window_minimum, overlap, tcx_mdct_window_half_length, tcx_mdct_window_min_length, left_rect, hTcxCfg->tcx_last_overlap_mode, acelp_zir, hTcxDec->old_syn_Overl, syn_Overl_TDAC, st->old_Aq_12_8, tcx_mdct_window_trans, L_frame_glob >> 1, acelp_mem_len, st->last_core_bfi, st->last_is_cng, fullbandScale ); + tcx_windowing_synthesis_current_frame( xn_buf, tcx_aldo_window_2, tcx_mdct_window_half, tcx_mdct_window_minimum, overlap, tcx_mdct_window_half_length, tcx_mdct_window_min_length, left_rect, hTcxCfg->tcx_last_overlap_mode, acelp_zir, hTcxDec->old_syn_Overl_float, syn_Overl_TDAC, st->old_Aq_12_8, tcx_mdct_window_trans, L_frame_glob >> 1, acelp_mem_len, st->last_core_bfi, st->last_is_cng, fullbandScale ); } } /* TCX-20 and TCX-only */ @@ -651,7 +651,7 @@ void IMDCT( for ( i = 0; i < tcx_mdct_window_half_length; i++ ) { xn_buf[i + overlap / 2 - tcx_offset] *= tcx_mdct_window_half[i]; - xn_buf[i + overlap / 2 - tcx_offset] += hTcxDec->syn_OverlFB[i] * tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i] * tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i]; + xn_buf[i + overlap / 2 - tcx_offset] += hTcxDec->syn_OverlFB_float[i] * tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i] * tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i]; } } else @@ -659,7 +659,7 @@ void IMDCT( for ( i = 0; i < tcx_mdct_window_half_length; i++ ) { xn_buf[i + overlap / 2 - tcx_offset] *= tcx_mdct_window_half[i]; - xn_buf[i + overlap / 2 - tcx_offset] += hTcxDec->syn_Overl[i] * tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i] * tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i]; + xn_buf[i + overlap / 2 - tcx_offset] += hTcxDec->syn_Overl_float[i] * tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i] * tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i]; } } } @@ -861,7 +861,7 @@ void decoder_tcx_invQ( } } - hTcxDec->damping = 0.f; + hTcxDec->damping_float = 0.f; if ( bfi == 0 ) { @@ -882,9 +882,9 @@ void decoder_tcx_invQ( *gain_tcx = (float) pow( 10.0f, index / 28.0f ) * (float) sqrt( (float) NORM_MDCT_FACTOR / (float) L_spec ); } - hTcxDec->old_gaintcx_bfi = *gain_tcx; + hTcxDec->old_gaintcx_bfi_float = *gain_tcx; - hTcxDec->cummulative_damping_tcx = 1.0f; + hTcxDec->cummulative_damping_tcx_float = 1.0f; } else /* bfi = 1 */ { @@ -894,23 +894,23 @@ void decoder_tcx_invQ( { if ( st->rf_frame_type == RF_TCXFD ) { - *gain_tcx = (float) pow( 10.0f, (int16_t) hTcxDec->old_gaintcx_bfi / 28.0f ) * (float) sqrt( (float) NORM_MDCT_FACTOR / (float) L_spec ); - hTcxDec->old_gaintcx_bfi = *gain_tcx; + *gain_tcx = (float) pow( 10.0f, (int16_t) hTcxDec->old_gaintcx_bfi_float / 28.0f ) * (float) sqrt( (float) NORM_MDCT_FACTOR / (float) L_spec ); + hTcxDec->old_gaintcx_bfi_float = *gain_tcx; } else { - *gain_tcx = hTcxDec->old_gaintcx_bfi; + *gain_tcx = hTcxDec->old_gaintcx_bfi_float; } - hTcxDec->damping = 1; + hTcxDec->damping_float = 1; } else { - *gain_tcx = hTcxDec->old_gaintcx_bfi; - hTcxDec->damping = Damping_fact( st->coder_type, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), st->last_core ); + *gain_tcx = hTcxDec->old_gaintcx_bfi_float; + hTcxDec->damping_float = Damping_fact( st->coder_type, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), st->last_core ); } - hTcxDec->cummulative_damping_tcx *= hTcxDec->damping; + hTcxDec->cummulative_damping_tcx_float *= hTcxDec->damping_float; } if ( bfi ) @@ -929,11 +929,11 @@ void decoder_tcx_invQ( if ( hTcxDec->enableTcxLpc ) { - gamma = hTcxDec->cummulative_damping_tcx * ( st->gamma - 1 ) + 1; + gamma = hTcxDec->cummulative_damping_tcx_float * ( st->gamma - 1 ) + 1; } else { - gamma = hTcxDec->cummulative_damping_tcx * ( gamma1 - 1 ) + 1; + gamma = hTcxDec->cummulative_damping_tcx_float * ( gamma1 - 1 ) + 1; } if ( st->element_mode != IVAS_CPE_MDCT ) @@ -966,8 +966,8 @@ void decoder_tcx_invQ( } /*for avoiding compiler warnings*/ - hTcxDec->gainHelper = 1.f; - hTcxDec->stepCompensate = 0.f; + hTcxDec->gainHelper_float = 1.f; + hTcxDec->stepCompensate_float = 0.f; } else if ( st->core == TCX_20_CORE || frame_cnt == 1 ) { @@ -982,13 +982,13 @@ void decoder_tcx_invQ( if ( st->nbLostCmpt == 1 ) { - hTcxDec->stepCompensate = ( 1.f - gainCompensate ) / st->L_frame; - hTcxDec->gainHelper = 1.f; + hTcxDec->stepCompensate_float = ( 1.f - gainCompensate ) / st->L_frame; + hTcxDec->gainHelper_float = 1.f; } else { - hTcxDec->stepCompensate = ( st->last_concealed_gain_syn_deemph - gainCompensate ) / st->L_frame; - hTcxDec->gainHelper = st->last_concealed_gain_syn_deemph; + hTcxDec->stepCompensate_float = ( st->last_concealed_gain_syn_deemph - gainCompensate ) / st->L_frame; + hTcxDec->gainHelper_float = st->last_concealed_gain_syn_deemph; } st->last_concealed_gain_syn_deemph = gainCompensate; } @@ -1004,19 +1004,19 @@ void decoder_tcx_invQ( /* envelope based arithmetic coder */ const int16_t *prm_resq; prm_resq = prm_sqQ + *prm_target /* = targetBits */ - hTcxDec->resQBits[frame_cnt]; - i = tcx_ari_res_invQ_spec( x, L_spec, prm_resq, hTcxDec->resQBits[frame_cnt], 0, hTcxCfg->sq_rounding, xn_buf /* LF deemphasis factors */ ); + i = tcx_ari_res_invQ_spec( x, L_spec, prm_resq, hTcxDec->resQBits[frame_cnt], 0, hTcxCfg->sq_rounding_flt, xn_buf /* LF deemphasis factors */ ); } else { /* context based arithmetic coder */ i = tcx_res_invQ_gain( gain_tcx, &prm_sqQ[L_spec], hTcxDec->resQBits[frame_cnt] ); - tcx_res_invQ_spec( x, L_spec, &prm_sqQ[L_spec], hTcxDec->resQBits[frame_cnt], i, hTcxCfg->sq_rounding, st->tcxonly ? NULL : xn_buf /* LF deemphasis factors */ ); + tcx_res_invQ_spec( x, L_spec, &prm_sqQ[L_spec], hTcxDec->resQBits[frame_cnt], i, hTcxCfg->sq_rounding_flt, st->tcxonly ? NULL : xn_buf /* LF deemphasis factors */ ); } } if ( !bfi && st->tcxonly && st->element_mode != IVAS_CPE_MDCT ) { - if ( hTcxLtpDec->tcxltp && ( hTcxLtpDec->tcxltp_gain > 0.0f ) && !( *fUseTns ) ) + if ( hTcxLtpDec->tcxltp && ( hTcxLtpDec->tcxltp_gain_float > 0.0f ) && !( *fUseTns ) ) { PsychAdaptLowFreqDeemph( x, gainlpc2, NULL ); } @@ -1041,7 +1041,7 @@ void decoder_tcx_invQ( if ( st->VAD == 0 ) { - *gain_tcx *= hTcxCfg->na_scale; + *gain_tcx *= hTcxCfg->na_scale_flt; } if ( st->element_mode != IVAS_CPE_MDCT ) @@ -1123,15 +1123,15 @@ void decoder_tcx_noisefilling( if ( frame_cnt == 0 ) { mvr2r( hTcxDec->ltpGainMemory, &hTcxDec->ltpGainMemory[1], N_LTP_GAIN_MEMS - 1 ); - hTcxDec->ltpGainMemory[0] = hTcxLtpDec->tcxltp_gain; + hTcxDec->ltpGainMemory[0] = hTcxLtpDec->tcxltp_gain_float; } smooth_gain = dotp( hTcxDec->ltpGainMemory, nf_tw_smoothing_coeffs, N_LTP_GAIN_MEMS ); - noiseTransWidth = HOLE_SIZE_FROM_LTP( max( smooth_gain, ( hTcxCfg->ctx_hm && st->last_core != ACELP_CORE ) ? 0.3125f * st->last_ctx_hm_enabled : 0 ) ); + noiseTransWidth = HOLE_SIZE_FROM_LTP_FLT( max( smooth_gain, ( hTcxCfg->ctx_hm && st->last_core != ACELP_CORE ) ? 0.3125f * st->last_ctx_hm_enabled : 0 ) ); } else { - noiseTransWidth = HOLE_SIZE_FROM_LTP( max( hTcxLtpDec->tcxltp_gain, ( hTcxCfg->ctx_hm && st->last_core != ACELP_CORE ) ? 0.3125f * st->last_ctx_hm_enabled : 0 ) ); + noiseTransWidth = HOLE_SIZE_FROM_LTP_FLT( max( hTcxLtpDec->tcxltp_gain_float, ( hTcxCfg->ctx_hm && st->last_core != ACELP_CORE ) ? 0.3125f * st->last_ctx_hm_enabled : 0 ) ); } if ( L_frame == st->L_frame >> 1 ) @@ -1224,7 +1224,7 @@ void decoder_tcx_noisefilling( } else { - f = hTcxDec->cummulative_damping_tcx; + f = hTcxDec->cummulative_damping_tcx_float; } if ( ( frame_cnt == 0 ) && ( L_frameTCX == hTcxDec->L_frameTCX >> 1 ) && ( st->tcxonly ) && ( !st->tonal_mdct_plc_active ) && ( st->nbLostCmpt == 1 ) && ( hTcxCfg->tcx_last_overlap_mode != FULL_OVERLAP ) && ( hTcxCfg->tcx_curr_overlap_mode != FULL_OVERLAP ) ) @@ -1234,16 +1234,16 @@ void decoder_tcx_noisefilling( { for ( i = 0; i < L_frameTCX; i = i + 2 ) { - E_2ndlast += st->hTonalMDCTConc->lastBlockData.spectralData[i] * st->hTonalMDCTConc->lastBlockData.spectralData[i]; - E_last += st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] * st->hTonalMDCTConc->lastBlockData.spectralData[i + 1]; + E_2ndlast += st->hTonalMDCTConc->lastBlockData.spectralData_float[i] * st->hTonalMDCTConc->lastBlockData.spectralData_float[i]; + E_last += st->hTonalMDCTConc->lastBlockData.spectralData_float[i + 1] * st->hTonalMDCTConc->lastBlockData.spectralData_float[i + 1]; } } else { for ( i = 0; i < infoIGFStartLine; i = i + 2 ) { - E_2ndlast += st->hTonalMDCTConc->lastBlockData.spectralData[i] * st->hTonalMDCTConc->lastBlockData.spectralData[i]; - E_last += st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] * st->hTonalMDCTConc->lastBlockData.spectralData[i + 1]; + E_2ndlast += st->hTonalMDCTConc->lastBlockData.spectralData_float[i] * st->hTonalMDCTConc->lastBlockData.spectralData_float[i]; + E_last += st->hTonalMDCTConc->lastBlockData.spectralData_float[i + 1] * st->hTonalMDCTConc->lastBlockData.spectralData_float[i + 1]; } } tmp2 = E_2ndlast / E_last; @@ -1255,14 +1255,14 @@ void decoder_tcx_noisefilling( { for ( i = 0; i < L_frameTCX; i = i + 2 ) { - st->hTonalMDCTConc->lastBlockData.spectralData[i] = st->hTonalMDCTConc->lastBlockData.spectralData[i + 1]; + st->hTonalMDCTConc->lastBlockData.spectralData_float[i] = st->hTonalMDCTConc->lastBlockData.spectralData_float[i + 1]; } } else { for ( i = 0; i < infoIGFStartLine; i = i + 2 ) { - st->hTonalMDCTConc->lastBlockData.spectralData[i] = st->hTonalMDCTConc->lastBlockData.spectralData[i + 1]; + st->hTonalMDCTConc->lastBlockData.spectralData_float[i] = st->hTonalMDCTConc->lastBlockData.spectralData_float[i + 1]; } } } @@ -1272,14 +1272,14 @@ void decoder_tcx_noisefilling( { for ( i = 0; i < L_frameTCX; i = i + 2 ) { - st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] = st->hTonalMDCTConc->lastBlockData.spectralData[i]; + st->hTonalMDCTConc->lastBlockData.spectralData_float[i + 1] = st->hTonalMDCTConc->lastBlockData.spectralData_float[i]; } } else { for ( i = 0; i < infoIGFStartLine; i = i + 2 ) { - st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] = st->hTonalMDCTConc->lastBlockData.spectralData[i]; + st->hTonalMDCTConc->lastBlockData.spectralData_float[i + 1] = st->hTonalMDCTConc->lastBlockData.spectralData_float[i]; } } } @@ -1411,7 +1411,7 @@ void decoder_tcx_noiseshaping_igf( if ( st->hTonalMDCTConc != NULL && st->element_mode != IVAS_CPE_MDCT ) { - TonalMDCTConceal_UpdateState( st->hTonalMDCTConc, L_frameTCX, ( hTcxDec->tcxltp_last_gain_unmodified > 0 ) ? st->old_fpitch : 0, bfi, bfi && st->tonal_mdct_plc_active ); + TonalMDCTConceal_UpdateState( st->hTonalMDCTConc, L_frameTCX, ( hTcxDec->tcxltp_last_gain_unmodified_float > 0 ) ? st->old_fpitch : 0, bfi, bfi && st->tonal_mdct_plc_active ); } if ( st->enablePlcWaveadjust ) @@ -1644,7 +1644,7 @@ void decoder_tcx_imdct( if ( st->hIGFDec->flag_sparse[j - IGF_START_MN] == 2 ) { x_itf[j - IGF_START_MN] = x[j]; - x[j] = st->hIGFDec->virtualSpec[j - IGF_START_MN]; + x[j] = st->hIGFDec->virtualSpec_float[j - IGF_START_MN]; } } @@ -1697,8 +1697,9 @@ void decoder_tcx_imdct( if ( st->element_mode != IVAS_CPE_DFT && !sba_dirac_stereo_flag ) { - IMDCT( xn_bufFB, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, - hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, + + IMDCT( xn_bufFB, hTcxDec->syn_Overl_float, hTcxDec->syn_Overl_TDAC_float, xn_buf, hTcxCfg->tcx_aldo_window_1_trunc_flt, hTcxCfg->tcx_aldo_window_2_flt, + hTcxCfg->tcx_mdct_window_half_flt, hTcxCfg->tcx_mdct_window_minimum_flt, hTcxCfg->tcx_mdct_window_trans_flt, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_outLB, 0, st, 0, acelp_zir ); } @@ -1712,19 +1713,22 @@ void decoder_tcx_imdct( { mvr2r( x, xn_bufFB, max( L_spec, max( L_frame, L_frameTCX ) ) ); - IMDCT( xn_bufFB, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, + + IMDCT( xn_bufFB, hTcxDec->syn_Overl_float, hTcxDec->syn_Overl_TDAC_float, xn_buf, hTcxCfg->tcx_aldo_window_1_trunc_flt, hTcxCfg->tcx_aldo_window_2_flt, hTcxCfg->tcx_mdct_window_half_flt, hTcxCfg->tcx_mdct_window_minimum_flt, hTcxCfg->tcx_mdct_window_trans_flt, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_outLB, 0, st, 0, acelp_zir ); } if ( st->element_mode != EVS_MONO ) { - IMDCT( x_tmp, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, - hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, + + IMDCT( x_tmp, hTcxDec->syn_OverlFB_float, hTcxDec->syn_Overl_TDACFB_float, xn_bufFB, hTcxCfg->tcx_aldo_window_1_FB_trunc_flt, hTcxCfg->tcx_aldo_window_2_FB_flt, + hTcxCfg->tcx_mdct_window_halfFB_flt, hTcxCfg->tcx_mdct_window_minimumFB_flt, hTcxCfg->tcx_mdct_window_transFB_flt, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out, 1, st, FSCALE_DENOM * L_frameTCX_glob / L_frame_glob, acelp_zir ); } else { - IMDCT( x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, + + IMDCT( x, hTcxDec->syn_OverlFB_float, hTcxDec->syn_Overl_TDACFB_float, xn_bufFB, hTcxCfg->tcx_aldo_window_1_FB_trunc_flt, hTcxCfg->tcx_aldo_window_2_FB_flt, hTcxCfg->tcx_mdct_window_halfFB_flt, hTcxCfg->tcx_mdct_window_minimumFB_flt, hTcxCfg->tcx_mdct_window_transFB_flt, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out, 1, st, FSCALE_DENOM * L_frameTCX_glob / L_frame_glob, acelp_zir ); } @@ -1733,8 +1737,8 @@ void decoder_tcx_imdct( { st->second_last_tns_active = st->last_tns_active; st->last_tns_active = hTcxCfg->fIsTNSAllowed & fUseTns; - hTcxDec->tcxltp_third_last_pitch = hTcxDec->tcxltp_second_last_pitch; - hTcxDec->tcxltp_second_last_pitch = st->old_fpitch; + hTcxDec->tcxltp_third_last_pitch_float = hTcxDec->tcxltp_second_last_pitch_float; + hTcxDec->tcxltp_second_last_pitch_float = st->old_fpitch; st->old_fpitch = hTcxLtpDec->tcxltp_pitch_int + hTcxLtpDec->tcxltp_pitch_fr / (float) st->pit_res_max; if ( st->element_mode == IVAS_CPE_MDCT ) @@ -1755,8 +1759,8 @@ void decoder_tcx_imdct( /* Update old_syn_overl */ if ( !hTcxCfg->last_aldo ) { - mvr2r( xn_buf + L_frame, hTcxDec->syn_Overl, overlap ); - mvr2r( xn_bufFB + L_frameTCX, hTcxDec->syn_OverlFB, overlapFB ); + mvr2r( xn_buf + L_frame, hTcxDec->syn_Overl_float, overlap ); + mvr2r( xn_bufFB + L_frameTCX, hTcxDec->syn_OverlFB_float, overlapFB ); } /* Output */ diff --git a/lib_dec/dec_uv.c b/lib_dec/dec_uv.c index 63c4b1d3b..dc4cc3069 100644 --- a/lib_dec/dec_uv.c +++ b/lib_dec/dec_uv.c @@ -113,7 +113,7 @@ void decod_unvoiced( * Generate Gaussian excitation * *-------------------------------------------------------*/ - gaus_L2_dec( code2, st->tilt_code, p_Aq, FORMANT_SHARPENING_G1, &( st->seed_acelp ) ); + gaus_L2_dec( code2, st->tilt_code, p_Aq, FORMANT_SHARPENING_G1_FLT, &( st->seed_acelp ) ); /*-----------------------------------------------------------------* * Gain encoding diff --git a/lib_dec/er_dec_acelp.c b/lib_dec/er_dec_acelp.c index 5fdce1773..b87a84687 100644 --- a/lib_dec/er_dec_acelp.c +++ b/lib_dec/er_dec_acelp.c @@ -72,7 +72,7 @@ void con_acelp( float pc = 0.f; int16_t extrapolationFailed, tmpSeed, Tc; float *pt1_exc; - float *w = st->hTcxCfg->tcx_mdct_window; + float *w = st->hTcxCfg->tcx_mdct_window_flt; int16_t W1, W2, j; int16_t l_fir_fer = L_FIR_FER; float lpFiltAdapt[3]; @@ -655,17 +655,17 @@ void con_acelp( deemph( syn, st->preemph_fac, L_frame + L_frame / 2, &tmp_deemph ); mvr2r( syn, synth, L_frame ); - mvr2r( syn + L_frame - L_frame / 2, st->hTcxDec->old_syn_Overl, L_frame / 2 ); + mvr2r( syn + L_frame - L_frame / 2, st->hTcxDec->old_syn_Overl_float, L_frame / 2 ); /* save last half frame if next frame is TCX */ - mvr2r( syn + L_frame, st->hTcxDec->syn_Overl_TDAC, L_frame / 2 ); + mvr2r( syn + L_frame, st->hTcxDec->syn_Overl_TDAC_float, L_frame / 2 ); mvr2r( syn + L_frame - M - 1, st->syn, 1 + M ); /* update old_Aq */ mvr2r( p_A - ( M + 1 ), st->old_Aq_12_8, M + 1 ); - mvr2r( syn + L_frame, st->hTcxDec->syn_Overl, L_frame / 2 ); + mvr2r( syn + L_frame, st->hTcxDec->syn_Overl_float, L_frame / 2 ); W1 = st->hTcxCfg->tcx_mdct_window_length; W2 = st->hTcxCfg->tcx_mdct_window_length / 2; @@ -687,27 +687,27 @@ void con_acelp( for ( i = 0; i < W1; i++ ) { - buf[i] = st->hTcxDec->syn_Overl_TDAC[i] * w[W1 - 1 - i]; + buf[i] = st->hTcxDec->syn_Overl_TDAC_float[i] * w[W1 - 1 - i]; } for ( i = 0; i < W2; i++ ) { - st->hTcxDec->syn_Overl_TDAC[i] = buf[i] + buf[W1 - 1 - i]; /* A-D */ + st->hTcxDec->syn_Overl_TDAC_float[i] = buf[i] + buf[W1 - 1 - i]; /* A-D */ } for ( i = 0; i < W2; i++ ) { - st->hTcxDec->syn_Overl_TDAC[W2 + i] = buf[W2 + i] + buf[W1 - 1 - W2 - i]; /* B-C */ + st->hTcxDec->syn_Overl_TDAC_float[W2 + i] = buf[W2 + i] + buf[W1 - 1 - W2 - i]; /* B-C */ } for ( i = 0; i < W1; i++ ) { - st->hTcxDec->syn_Overl_TDAC[i] *= w[W1 - 1 - i]; + st->hTcxDec->syn_Overl_TDAC_float[i] *= w[W1 - 1 - i]; } /* update memory for full band */ - lerp( st->hTcxDec->syn_Overl_TDAC, st->hTcxDec->syn_Overl_TDACFB, st->hTcxDec->L_frameTCX / 2, L_frame / 2 ); - lerp( st->hTcxDec->syn_Overl, st->hTcxDec->syn_OverlFB, st->hTcxDec->L_frameTCX / 2, L_frame / 2 ); + lerp( st->hTcxDec->syn_Overl_TDAC_float, st->hTcxDec->syn_Overl_TDACFB_float, st->hTcxDec->L_frameTCX / 2, L_frame / 2 ); + lerp( st->hTcxDec->syn_Overl_float, st->hTcxDec->syn_OverlFB_float, st->hTcxDec->L_frameTCX / 2, L_frame / 2 ); lerp( st->hHQ_core->old_outLB, st->hHQ_core->old_out, st->hTcxDec->L_frameTCX, L_frame ); /* copy total excitation exc2 as 16kHz for acelp mode1 decoding */ diff --git a/lib_dec/er_dec_tcx.c b/lib_dec/er_dec_tcx.c index bf2fbe9c2..cac126d12 100644 --- a/lib_dec/er_dec_tcx.c +++ b/lib_dec/er_dec_tcx.c @@ -86,7 +86,7 @@ void con_tcx( /* Framing parameters */ L_frame = hTcxDec->L_frameTCX; L_subfr = hTcxDec->L_frameTCX / st->nb_subfr; - w = st->hTcxCfg->tcx_mdct_windowFB; + w = st->hTcxCfg->tcx_mdct_windowFB_flt; W1 = st->hTcxCfg->tcx_mdct_window_lengthFB; W2 = st->hTcxCfg->tcx_mdct_window_lengthFB / 2; @@ -111,7 +111,7 @@ void con_tcx( preemph( &synth[-( L_frame / 2 + hTcxDec->pit_max_TCX + 2 * M )], st->preemph_fac, L_frame / 2 + hTcxDec->pit_max_TCX + 2 * M, &mem ); st->lp_gainc = 0.0f; - st->lp_gainp = get_gain( synth - 2 * L_subfr, synth - 2 * L_subfr - Tc, 2 * L_subfr, NULL ); + st->lp_gainp = get_gain_flt( synth - 2 * L_subfr, synth - 2 * L_subfr - Tc, 2 * L_subfr, NULL ); if ( st->lp_gainp < 0.0f ) { @@ -593,7 +593,7 @@ void con_tcx( mvr2r( syn + L_frame - M - 1, st->syn, 1 + M ); - lerp( syn + L_frame - L_frame / 2, st->hTcxDec->old_syn_Overl, st->L_frame / 2, L_frame / 2 ); + lerp( syn + L_frame - L_frame / 2, st->hTcxDec->old_syn_Overl_float, st->L_frame / 2, L_frame / 2 ); mvr2r( syn + L_frame - n, st->hHQ_core->old_out, L_frame - n ); for ( i = 0; i < W1; i++ ) @@ -604,7 +604,7 @@ void con_tcx( mvr2r( syn, synth, L_frame ); - mvr2r( syn + L_frame, st->hTcxDec->syn_OverlFB, L_frame / 2 ); + mvr2r( syn + L_frame, st->hTcxDec->syn_OverlFB_float, L_frame / 2 ); /* copy total excitation exc2 as 16kHz for ACELP MODE1 decoding */ if ( st->hWIDec != NULL ) @@ -616,34 +616,34 @@ void con_tcx( st->bfi_pitch_frame = st->L_frame; /* create aliasing and windowing need for transition to TCX10/5 */ - mvr2r( syn + L_frame, st->hTcxDec->syn_Overl_TDACFB, L_frame / 2 ); + mvr2r( syn + L_frame, st->hTcxDec->syn_Overl_TDACFB_float, L_frame / 2 ); for ( i = 0; i < W1; i++ ) { - buf[i] = st->hTcxDec->syn_Overl_TDACFB[i] * w[W1 - 1 - i]; + buf[i] = st->hTcxDec->syn_Overl_TDACFB_float[i] * w[W1 - 1 - i]; } for ( i = 0; i < W2; i++ ) { - st->hTcxDec->syn_Overl_TDACFB[i] = buf[i] + buf[W1 - 1 - i]; /* A-D */ + st->hTcxDec->syn_Overl_TDACFB_float[i] = buf[i] + buf[W1 - 1 - i]; /* A-D */ } for ( i = 0; i < W2; i++ ) { - st->hTcxDec->syn_Overl_TDACFB[W2 + i] = buf[W2 + i] + buf[W1 - 1 - W2 - i]; /* B-C */ + st->hTcxDec->syn_Overl_TDACFB_float[W2 + i] = buf[W2 + i] + buf[W1 - 1 - W2 - i]; /* B-C */ } for ( i = 0; i < W1; i++ ) { - st->hTcxDec->syn_Overl_TDACFB[i] *= w[W1 - 1 - i]; + st->hTcxDec->syn_Overl_TDACFB_float[i] *= w[W1 - 1 - i]; } st->hTcxCfg->tcx_curr_overlap_mode = FULL_OVERLAP; synth[-1] = pre_emph_buf; /* update memory for low band */ - lerp( st->hTcxDec->syn_OverlFB, st->hTcxDec->syn_Overl, st->L_frame / 2, L_frame / 2 ); - lerp( st->hTcxDec->syn_Overl_TDACFB, st->hTcxDec->syn_Overl_TDAC, st->L_frame / 2, L_frame / 2 ); + lerp( st->hTcxDec->syn_OverlFB_float, st->hTcxDec->syn_Overl_float, st->L_frame / 2, L_frame / 2 ); + lerp( st->hTcxDec->syn_Overl_TDACFB_float, st->hTcxDec->syn_Overl_TDAC_float, st->L_frame / 2, L_frame / 2 ); lerp( st->hHQ_core->old_out, st->hHQ_core->old_outLB, st->L_frame, L_frame ); st->old_enr_LP = enr_1_Az( A_local, L_SUBFR ); diff --git a/lib_dec/er_util.c b/lib_dec/er_util.c index 965b527a7..c599ad2a4 100644 --- a/lib_dec/er_util.c +++ b/lib_dec/er_util.c @@ -267,7 +267,7 @@ int16_t GetPLCModeDecision( st->old_pitch_buf[2 * st->nb_subfr + 1] = (float) st->guidedT0; st->mem_pitch_gain[0] = st->mem_pitch_gain[1] = 1.f; } - if ( ( st->last_core > ACELP_CORE && hTcxDec->tcxltp_last_gain_unmodified != 0 ) || ( st->flagGuidedAcelp == 1 ) ) + if ( ( st->last_core > ACELP_CORE && hTcxDec->tcxltp_last_gain_unmodified_float != 0 ) || ( st->flagGuidedAcelp == 1 ) ) { /* no updates needed here, because already updated in last good frame */ st->plc_use_future_lag = 1; @@ -303,29 +303,29 @@ int16_t GetPLCModeDecision( st->tonal_mdct_plc_active = 0; if ( !( st->rf_flag && st->use_partial_copy && ( st->rf_frame_type == RF_TCXTD1 || st->rf_frame_type == RF_TCXTD2 ) ) ) { - if ( st->hTonalMDCTConc != NULL && st->last_core == TCX_20_CORE && st->second_last_core == TCX_20_CORE && ( ( st->old_fpitch <= 0.5f * st->L_frame ) || ( hTcxDec->tcxltp_last_gain_unmodified <= 0.4f ) ) + if ( st->hTonalMDCTConc != NULL && st->last_core == TCX_20_CORE && st->second_last_core == TCX_20_CORE && ( ( st->old_fpitch <= 0.5f * st->L_frame ) || ( hTcxDec->tcxltp_last_gain_unmodified_float <= 0.4f ) ) /* it is fine to call the detection even if no ltp information is available, meaning that st->old_fpitch == st->tcxltp_second_last_pitch == st->L_frame */ - && ( st->old_fpitch == hTcxDec->tcxltp_second_last_pitch ) && !st->last_tns_active && !st->second_last_tns_active ) + && ( st->old_fpitch == hTcxDec->tcxltp_second_last_pitch_float ) && !st->last_tns_active && !st->second_last_tns_active ) { - TonalMDCTConceal_Detect( st->hTonalMDCTConc, ( hTcxDec->tcxltp_last_gain_unmodified > 0 ) ? st->old_fpitch : 0, &numIndices, + TonalMDCTConceal_Detect( st->hTonalMDCTConc, ( hTcxDec->tcxltp_last_gain_unmodified_float > 0 ) ? st->old_fpitch : 0, &numIndices, ( st->element_mode == IVAS_CPE_MDCT ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent ) ); - if ( ( numIndices > 10 ) || ( ( numIndices > 5 ) && ( fabs( hTcxDec->tcxltp_third_last_pitch - hTcxDec->tcxltp_second_last_pitch ) < 0.5f ) ) || ( ( numIndices > 0 ) && ( ( st->last_good <= UNVOICED_TRANSITION ) || ( hTcxDec->tcxltp_last_gain_unmodified <= 0.4f ) ) && ( fabs( hTcxDec->tcxltp_third_last_pitch - hTcxDec->tcxltp_second_last_pitch ) < 0.5f ) ) ) + if ( ( numIndices > 10 ) || ( ( numIndices > 5 ) && ( fabs( hTcxDec->tcxltp_third_last_pitch_float - hTcxDec->tcxltp_second_last_pitch_float ) < 0.5f ) ) || ( ( numIndices > 0 ) && ( ( st->last_good <= UNVOICED_TRANSITION ) || ( hTcxDec->tcxltp_last_gain_unmodified_float <= 0.4f ) ) && ( fabs( hTcxDec->tcxltp_third_last_pitch_float - hTcxDec->tcxltp_second_last_pitch_float ) < 0.5f ) ) ) { core = TCX_20_CORE; st->tonal_mdct_plc_active = 1; } - else if ( st->last_good <= UNVOICED_TRANSITION || hTcxDec->tcxltp_last_gain_unmodified <= 0.4f ) + else if ( st->last_good <= UNVOICED_TRANSITION || hTcxDec->tcxltp_last_gain_unmodified_float <= 0.4f ) { core = TCX_20_CORE; } } else if ( st->last_core != ACELP_CORE ) { - if ( st->last_good <= UNVOICED_TRANSITION || hTcxDec->tcxltp_last_gain_unmodified <= 0.4f ) + if ( st->last_good <= UNVOICED_TRANSITION || hTcxDec->tcxltp_last_gain_unmodified_float <= 0.4f ) { core = st->last_core; } diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c index 7b6dc2b9d..63b4092ad 100644 --- a/lib_dec/evs_dec.c +++ b/lib_dec/evs_dec.c @@ -121,13 +121,13 @@ ivas_error evs_dec( * PLC: overlapping part needs to be attenuated for first good frame */ if ( !st->bfi && st->prev_bfi && ( st->last_codec_mode == MODE2 ) && ( st->last_core_bfi == TCX_20_CORE || st->last_core_bfi == TCX_10_CORE ) ) { - v_multc( st->hHQ_core->old_out, st->hPlcInfo->recovery_gain, st->hHQ_core->old_out, st->hTcxDec->L_frameTCX ); - v_multc( st->hHQ_core->old_outLB, st->hPlcInfo->recovery_gain, st->hHQ_core->old_outLB, st->L_frame ); + v_multc( st->hHQ_core->old_out, st->hPlcInfo->recovery_gain_float, st->hHQ_core->old_out, st->hTcxDec->L_frameTCX ); + v_multc( st->hHQ_core->old_outLB, st->hPlcInfo->recovery_gain_float, st->hHQ_core->old_outLB, st->L_frame ); if ( !st->hTcxCfg->last_aldo ) { - v_multc( st->hTcxDec->syn_OverlFB, st->hPlcInfo->recovery_gain, st->hTcxDec->syn_OverlFB, st->hTcxCfg->tcx_mdct_window_lengthFB ); - v_multc( st->hTcxDec->syn_Overl, st->hPlcInfo->recovery_gain, st->hTcxDec->syn_Overl, st->hTcxCfg->tcx_mdct_window_length ); + v_multc( st->hTcxDec->syn_OverlFB_float, st->hPlcInfo->recovery_gain_float, st->hTcxDec->syn_OverlFB_float, st->hTcxCfg->tcx_mdct_window_lengthFB ); + v_multc( st->hTcxDec->syn_Overl_float, st->hPlcInfo->recovery_gain_float, st->hTcxDec->syn_Overl_float, st->hTcxCfg->tcx_mdct_window_length ); } } @@ -153,7 +153,7 @@ ivas_error evs_dec( if ( frameMode != FRAMEMODE_MISSING ) /* frame mode normal or future frame */ { - getPartialCopyInfo( st, &sharpFlag ); + getPartialCopyInfo_float( st, &sharpFlag ); frameMode = st->bfi; } @@ -357,7 +357,7 @@ ivas_error evs_dec( if ( output_frame >= L_FRAME16k ) { tmps = NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ); - delay_signal( synth, output_frame, st->prev_synth_buffer, tmps ); + delay_signal_float( synth, output_frame, st->prev_synth_buffer, tmps ); } if ( st->core == ACELP_CORE && !st->bfi && st->prev_bfi && st->last_total_brate >= HQ_48k && st->last_codec_mode == MODE2 && ( st->last_core_bfi == TCX_20_CORE || st->last_core_bfi == TCX_10_CORE ) && st->hPlcInfo->concealment_method == TCX_NONTONAL && st->hPlcInfo->nbLostCmpt < 4 ) @@ -368,7 +368,7 @@ ivas_error evs_dec( tmps = NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS ); } - waveform_adj2( st->hPlcInfo, st->hTonalMDCTConc->secondLastPcmOut, synth + tmps, tmps, st->hPlcInfo->nbLostCmpt + 1, st->bfi ); + waveform_adj2( st->hPlcInfo, st->hTonalMDCTConc->secondLastPcmOut_float, synth + tmps, tmps, st->hPlcInfo->nbLostCmpt + 1, st->bfi ); st->hPlcInfo->Pitch = 0; } @@ -445,7 +445,7 @@ ivas_error evs_dec( } /* Delay hb_synth */ - delay_signal( hb_synth, output_frame, st->hb_prev_synth_buffer, tmps ); + delay_signal_float( hb_synth, output_frame, st->hb_prev_synth_buffer, tmps ); st->old_bwe_delay = tmps; if ( ( st->ppp_mode_dec || ( st->nelp_mode_dec == 1 && st->bfi == 1 ) ) && st->L_frame == st->last_L_frame && ( st->bws_cnt > 1 || st->last_extl != -1 ) ) @@ -666,7 +666,7 @@ ivas_error evs_dec( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = 0.99f * st->hFdCngDec->hFdCngCom->likelihood_noisy_speech + 0.01f * (float) st->hFdCngDec->hFdCngCom->flag_noisy_speech; - st->lp_noise = st->hFdCngDec->lp_noise; + st->lp_noise = st->hFdCngDec->lp_noise_float; ApplyFdCng( output, NULL, realBuffer, imagBuffer, st, concealWholeFrame, 0 ); @@ -779,12 +779,12 @@ ivas_error evs_dec( { if ( st->output_Fs == 8000 ) { - mvr2r( st->delay_buf_out, st->hTcxDec->FBTCXdelayBuf, delay_comp ); + mvr2r( st->delay_buf_out, st->hTcxDec->FBTCXdelayBuf_float, delay_comp ); } else { - mvr2r( st->prev_synth_buffer, st->hTcxDec->FBTCXdelayBuf, delay_tdbwe ); - mvr2r( st->delay_buf_out, st->hTcxDec->FBTCXdelayBuf + delay_tdbwe, delay_comp ); + mvr2r( st->prev_synth_buffer, st->hTcxDec->FBTCXdelayBuf_float, delay_tdbwe ); + mvr2r( st->delay_buf_out, st->hTcxDec->FBTCXdelayBuf_float + delay_tdbwe, delay_comp ); } } } @@ -801,11 +801,11 @@ ivas_error evs_dec( if ( st->output_Fs == 8000 ) { - mvr2r( st->hTcxDec->FBTCXdelayBuf, st->previoussynth, delay_comp ); + mvr2r( st->hTcxDec->FBTCXdelayBuf_float, st->previoussynth, delay_comp ); } else { - mvr2r( st->hTcxDec->FBTCXdelayBuf + delay_tdbwe, st->previoussynth, delay_comp ); + mvr2r( st->hTcxDec->FBTCXdelayBuf_float + delay_tdbwe, st->previoussynth, delay_comp ); } mvr2r( pcmbufFB, st->previoussynth + delay_comp, output_frame - delay_comp ); @@ -814,7 +814,7 @@ ivas_error evs_dec( /* Delay compensation for TBE */ if ( output_frame >= L_FRAME16k ) { - delay_signal( output, output_frame, st->prev_synth_buffer, delay_tdbwe ); + delay_signal_float( output, output_frame, st->prev_synth_buffer, delay_tdbwe ); } if ( st->igf && st->m_frame_type == ACTIVE_FRAME ) @@ -851,7 +851,7 @@ ivas_error evs_dec( /* TCX / HQ-CORE / TD-TCX-PLC -> TCX / TD-TCX-PLC */ if ( st->last_core_bfi > ACELP_CORE || ( st->bfi && st->last_core > ACELP_CORE ) || ( st->prev_bfi && st->last_con_tcx ) ) { - mvr2r( st->hTcxDec->FBTCXdelayBuf, output, tmps ); + mvr2r( st->hTcxDec->FBTCXdelayBuf_float, output, tmps ); mvr2r( pcmbufFB, output + tmps, st->hTcxDec->L_frameTCX - tmps ); } /* ACELP -> TCX */ @@ -865,32 +865,32 @@ ivas_error evs_dec( mvr2r( pcmbufFB + tmps, output + 2 * tmps, st->hTcxDec->L_frameTCX - 2 * tmps ); } - mvr2r( pcmbufFB + st->hTcxDec->L_frameTCX - tmps, st->hTcxDec->FBTCXdelayBuf, tmps ); + mvr2r( pcmbufFB + st->hTcxDec->L_frameTCX - tmps, st->hTcxDec->FBTCXdelayBuf_float, tmps ); if ( st->bfi && st->last_core > ACELP_CORE ) { if ( st->output_Fs == 8000 ) { - mvr2r( st->hTcxDec->FBTCXdelayBuf, st->delay_buf_out, NS2SA( st->output_Fs, DELAY_CLDFB_NS ) ); + mvr2r( st->hTcxDec->FBTCXdelayBuf_float, st->delay_buf_out, NS2SA( st->output_Fs, DELAY_CLDFB_NS ) ); } else { - mvr2r( st->hTcxDec->FBTCXdelayBuf, st->prev_synth_buffer, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); - mvr2r( st->hTcxDec->FBTCXdelayBuf + NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), st->delay_buf_out, NS2SA( st->output_Fs, DELAY_CLDFB_NS ) ); + mvr2r( st->hTcxDec->FBTCXdelayBuf_float, st->prev_synth_buffer, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); + mvr2r( st->hTcxDec->FBTCXdelayBuf_float + NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), st->delay_buf_out, NS2SA( st->output_Fs, DELAY_CLDFB_NS ) ); } } } /* TCX/TD TCX PLC->ACELP */ else if ( st->last_codec_mode == MODE2 && st->last_core > ACELP_CORE ) { - mvr2r( st->hTcxDec->FBTCXdelayBuf, output, delta ); + mvr2r( st->hTcxDec->FBTCXdelayBuf_float, output, delta ); for ( i = delta; i < tmps; i++ ) { - output[i] = ( output[i] * ( i - delta ) + st->hTcxDec->FBTCXdelayBuf[i] * ( tmps - i ) ) / ( tmps - delta ); + output[i] = ( output[i] * ( i - delta ) + st->hTcxDec->FBTCXdelayBuf_float[i] * ( tmps - i ) ) / ( tmps - delta ); } } - tcx_ltp_post( st, hTcxLtpDec, st->core, output_frame, NS2SA( st->output_Fs, ACELP_LOOK_NS ) + tmps, output, st->hTcxDec->FBTCXdelayBuf ); + tcx_ltp_post( st, hTcxLtpDec, st->core, output_frame, NS2SA( st->output_Fs, ACELP_LOOK_NS ) + tmps, output, st->hTcxDec->FBTCXdelayBuf_float ); } /* end of Mode 2 */ @@ -904,7 +904,7 @@ ivas_error evs_dec( * HP filtering *----------------------------------------------------------------*/ - hp20( output, output_frame, mem_hp20_out, st->output_Fs ); + hp20_flt( output, output_frame, mem_hp20_out, st->output_Fs ); /*--------------------------------------------------------* * Updates diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index c736e2462..4fbc443c0 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -103,7 +103,7 @@ ivas_error createFdCngDec( *-------------------------------------------------------------------*/ void initFdCngDec( - DEC_CORE_HANDLE st /* i/o: decoder state structure */ + DEC_CORE_HANDLE_FLOAT st /* i/o: decoder state structure */ ) { HANDLE_FD_CNG_DEC hFdCngDec; @@ -111,36 +111,36 @@ void initFdCngDec( hFdCngDec = st->hFdCngDec; /* Initialize common */ - initFdCngCom( hFdCngDec->hFdCngCom, st->cldfbSyn->scale ); + initFdCngCom( hFdCngDec->hFdCngCom, st->cldfbSyn->scale_flt ); /* Set some counters and flags */ hFdCngDec->flag_dtx_mode = 0; - hFdCngDec->lp_noise = -20.f; - hFdCngDec->lp_speech = 25.f; + hFdCngDec->lp_noise_float = -20.f; + hFdCngDec->lp_speech_float = 25.f; /* Initialize noise estimation algorithm */ - set_f( hFdCngDec->bandNoiseShape, 0.0f, FFTLEN2 ); - set_f( hFdCngDec->partNoiseShape, 0.0f, NPART ); - set_f( hFdCngDec->msPeriodog, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->msAlpha, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->msBminWin, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->msBminSubWin, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->msPsd, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->msNoiseFloor, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->msNoiseEst, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->msMinBuf, FLT_MAX, MSNUMSUBFR * NPART_SHAPING ); - set_f( hFdCngDec->msCurrentMin, FLT_MAX, NPART_SHAPING ); - set_f( hFdCngDec->msCurrentMinOut, FLT_MAX, NPART_SHAPING ); - set_f( hFdCngDec->msCurrentMinSubWindow, FLT_MAX, NPART_SHAPING ); + set_f( hFdCngDec->bandNoiseShape_float, 0.0f, FFTLEN2 ); + set_f( hFdCngDec->partNoiseShape_float, 0.0f, NPART ); + set_f( hFdCngDec->msPeriodog_float, 0.0f, NPART_SHAPING ); + set_f( hFdCngDec->msAlpha_float, 0.0f, NPART_SHAPING ); + set_f( hFdCngDec->msBminWin_float, 0.0f, NPART_SHAPING ); + set_f( hFdCngDec->msBminSubWin_float, 0.0f, NPART_SHAPING ); + set_f( hFdCngDec->msPsd_float, 0.0f, NPART_SHAPING ); + set_f( hFdCngDec->msNoiseFloor_float, 0.0f, NPART_SHAPING ); + set_f( hFdCngDec->msNoiseEst_float, 0.0f, NPART_SHAPING ); + set_f( hFdCngDec->msMinBuf_float, FLT_MAX, MSNUMSUBFR * NPART_SHAPING ); + set_f( hFdCngDec->msCurrentMin_float, FLT_MAX, NPART_SHAPING ); + set_f( hFdCngDec->msCurrentMinOut_float, FLT_MAX, NPART_SHAPING ); + set_f( hFdCngDec->msCurrentMinSubWindow_float, FLT_MAX, NPART_SHAPING ); set_s( hFdCngDec->msLocalMinFlag, 0, NPART_SHAPING ); set_s( hFdCngDec->msNewMinFlag, 0, NPART_SHAPING ); - set_f( hFdCngDec->msPsdFirstMoment, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->msPsdSecondMoment, 0.0f, NPART_SHAPING ); + set_f( hFdCngDec->msPsdFirstMoment_float, 0.0f, NPART_SHAPING ); + set_f( hFdCngDec->msPsdSecondMoment_float, 0.0f, NPART_SHAPING ); hFdCngDec->msPeriodogBufPtr = 0; - set_f( hFdCngDec->msPeriodogBuf, 0.0f, MSBUFLEN * NPART_SHAPING ); - set_f( hFdCngDec->msLogPeriodog, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->msLogNoiseEst, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->psize_shaping, 0.0f, NPART_SHAPING ); + set_f( hFdCngDec->msPeriodogBuf_float, 0.0f, MSBUFLEN * NPART_SHAPING ); + set_f( hFdCngDec->msLogPeriodog_float, 0.0f, NPART_SHAPING ); + set_f( hFdCngDec->msLogNoiseEst_float, 0.0f, NPART_SHAPING ); + set_f( hFdCngDec->psize_shaping_float, 0.0f, NPART_SHAPING ); hFdCngDec->nFFTpart_shaping = 0; set_f( hFdCngDec->hFdCngCom->sidNoiseEstLp, 0.0f, NPART ); @@ -315,7 +315,7 @@ void configureFdCngDec( { stopBandFR = hsCom->stopFFTbin; } - initPartitions( hsCom->FdCngSetup.shapingPartitions, hsCom->FdCngSetup.numShapingPartitions, hsCom->startBand, hsCom->stopFFTbin, hFdCngDec->part_shaping, &hFdCngDec->npart_shaping, hFdCngDec->midband_shaping, hFdCngDec->psize_shaping, hFdCngDec->psize_inv_shaping, stopBandFR ); + initPartitions( hsCom->FdCngSetup.shapingPartitions, hsCom->FdCngSetup.numShapingPartitions, hsCom->startBand, hsCom->stopFFTbin, hFdCngDec->part_shaping, &hFdCngDec->npart_shaping, hFdCngDec->midband_shaping, hFdCngDec->psize_shaping_float, hFdCngDec->psize_inv_shaping_float, stopBandFR ); hFdCngDec->nFFTpart_shaping = hFdCngDec->npart_shaping; @@ -433,21 +433,21 @@ void ApplyFdCng( if ( st->element_mode != IVAS_CPE_TD && st->element_mode != IVAS_CPE_DFT ) { /* Update the shaping parameters */ - scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, hFdCngCom->stopFFTbin - hFdCngCom->startBand, hFdCngDec->bandNoiseShape, 1 ); + scalebands( hFdCngDec->msNoiseEst_float, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, hFdCngCom->stopFFTbin - hFdCngCom->startBand, hFdCngDec->bandNoiseShape_float, 1 ); } /* Update CNG levels */ if ( hFdCngDec->flag_dtx_mode && st->cng_type == FD_CNG ) { - bandcombinepow( hFdCngDec->bandNoiseShape, hFdCngCom->stopFFTbin - hFdCngCom->startBand, hFdCngCom->part, hFdCngCom->nFFTpart, hFdCngCom->psize_inv, hFdCngDec->partNoiseShape ); /* This needs to be done only once per inactive phase */ + bandcombinepow( hFdCngDec->bandNoiseShape_float, hFdCngCom->stopFFTbin - hFdCngCom->startBand, hFdCngCom->part, hFdCngCom->nFFTpart, hFdCngCom->psize_inv, hFdCngDec->partNoiseShape_float); /* This needs to be done only once per inactive phase */ j = 0; for ( k = 0; k < hFdCngCom->nFFTpart; k++ ) { - factor = ( hFdCngCom->sidNoiseEst[k] + DELTA ) / ( hFdCngDec->partNoiseShape[k] + DELTA ); + factor = ( hFdCngCom->sidNoiseEst[k] + DELTA ) / ( hFdCngDec->partNoiseShape_float[k] + DELTA ); for ( ; j <= hFdCngCom->part[k]; j++ ) { - cngNoiseLevel[j] = hFdCngDec->bandNoiseShape[j] * factor; + cngNoiseLevel[j] = hFdCngDec->bandNoiseShape_float[j] * factor; } } } @@ -456,7 +456,7 @@ void ApplyFdCng( /* This sets the new CNG levels until a SID update overwrites it */ if ( !( st->element_mode == IVAS_CPE_TD ) || ( st->element_mode == IVAS_CPE_TD && !hFdCngDec->flag_dtx_mode && !st->VAD ) ) { - mvr2r( hFdCngDec->bandNoiseShape, cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand ); /* This sets the new CNG levels until a SID update overwrites it */ + mvr2r( hFdCngDec->bandNoiseShape_float, cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand ); /* This sets the new CNG levels until a SID update overwrites it */ } } @@ -522,11 +522,11 @@ void ApplyFdCng( if ( st->element_mode != IVAS_CPE_TD && st->element_mode != IVAS_CPE_DFT ) { /* Update the shaping parameters */ - scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, hFdCngCom->stopFFTbin - hFdCngCom->startBand, hFdCngDec->bandNoiseShape, 1 ); + scalebands( hFdCngDec->msNoiseEst_float, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, hFdCngCom->stopFFTbin - hFdCngCom->startBand, hFdCngDec->bandNoiseShape_float, 1 ); } /* This sets the new CNG levels until a SID update overwrites it */ - mvr2r( hFdCngDec->bandNoiseShape, cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand ); /* This sets the new CNG levels until a SID update overwrites it */ + mvr2r( hFdCngDec->bandNoiseShape_float, cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand ); /* This sets the new CNG levels until a SID update overwrites it */ st->cngTDLevel = (float) sqrt( ( sum_f( cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand ) / 2 * hFdCngCom->fftlen ) / L_frame ); break; @@ -542,7 +542,7 @@ void ApplyFdCng( if ( hFdCngCom->inactive_frame_counter == 1 ) { /* Compute the fine spectral structure of the comfort noise shape using the decoder-side noise estimates */ - bandcombinepow( hFdCngDec->bandNoiseShape, hFdCngCom->stopFFTbin - hFdCngCom->startBand, hFdCngCom->part, hFdCngCom->nFFTpart, hFdCngCom->psize_inv, hFdCngDec->partNoiseShape ); + bandcombinepow( hFdCngDec->bandNoiseShape_float, hFdCngCom->stopFFTbin - hFdCngCom->startBand, hFdCngCom->part, hFdCngCom->nFFTpart, hFdCngCom->psize_inv, hFdCngDec->partNoiseShape_float); if ( st->element_mode == IVAS_CPE_DFT ) { @@ -575,10 +575,10 @@ void ApplyFdCng( j = 0; for ( k = 0; k < hFdCngCom->nFFTpart; k++ ) { - factor = ( sidNoiseEst[k] + DELTA ) / ( hFdCngDec->partNoiseShape[k] + DELTA ); + factor = ( sidNoiseEst[k] + DELTA ) / ( hFdCngDec->partNoiseShape_float[k] + DELTA ); for ( ; j <= hFdCngCom->part[k]; j++ ) { - cngNoiseLevel[j] = hFdCngDec->bandNoiseShape[j] * factor; + cngNoiseLevel[j] = hFdCngDec->bandNoiseShape_float[j] * factor; } } } @@ -591,10 +591,10 @@ void ApplyFdCng( j = 0; for ( k = 0; k < hFdCngCom->nFFTpart; k++ ) { - factor = ( sidNoiseEst[k] + DELTA ) / ( hFdCngDec->partNoiseShape[k] + DELTA ); + factor = ( sidNoiseEst[k] + DELTA ) / ( hFdCngDec->partNoiseShape_float[k] + DELTA ); for ( ; j <= hFdCngCom->part[k]; j++ ) { - cngNoiseLevel[j] = hFdCngDec->bandNoiseShape[j] * factor; + cngNoiseLevel[j] = hFdCngDec->bandNoiseShape_float[j] * factor; } } } @@ -642,16 +642,16 @@ static void perform_noise_estimation_dec( float *fftBuffer = hFdCngDec->hFdCngCom->fftBuffer; float *periodog = hFdCngDec->hFdCngCom->periodog; float *ptr_per = periodog; - float *msPeriodog = hFdCngDec->msPeriodog; - float *msNoiseEst = hFdCngDec->msNoiseEst; + float *msPeriodog = hFdCngDec->msPeriodog_float; + float *msNoiseEst = hFdCngDec->msNoiseEst_float; int16_t *part = hFdCngDec->part_shaping; int16_t npart = hFdCngDec->npart_shaping; int16_t nFFTpart = hFdCngDec->nFFTpart_shaping; - float *psize_inv = hFdCngDec->psize_inv_shaping; - float *psize = hFdCngDec->psize_shaping; - float *msLogPeriodog = hFdCngDec->msLogPeriodog; - float *msLogNoiseEst = hFdCngDec->msLogNoiseEst; + float *psize_inv = hFdCngDec->psize_inv_shaping_float; + float *psize = hFdCngDec->psize_shaping_float; + float *msLogPeriodog = hFdCngDec->msLogPeriodog_float; + float *msLogNoiseEst = hFdCngDec->msLogNoiseEst_float; int16_t i; float enr, enr_tot, enr_tot0, enr_ratio, alpha; int16_t p; @@ -885,12 +885,12 @@ static void perform_noise_estimation_dec( } } - mvr2r( msNoiseEst, hFdCngDec->msPsd, npart ); + mvr2r( msNoiseEst, hFdCngDec->msPsd_float, npart ); /* Expand partitions into bins of power spectrum */ - scalebands( msNoiseEst, part, nFFTpart, hFdCngDec->midband_shaping, nFFTpart, stopFFTbin - startBand, hFdCngDec->bandNoiseShape, 1 ); + scalebands( msNoiseEst, part, nFFTpart, hFdCngDec->midband_shaping, nFFTpart, stopFFTbin - startBand, hFdCngDec->bandNoiseShape_float, 1 ); - mvr2r( hFdCngDec->bandNoiseShape, &hFdCngDec->smoothed_psd[startBand], stopFFTbin - startBand ); + mvr2r( hFdCngDec->bandNoiseShape_float, &hFdCngDec->smoothed_psd[startBand], stopFFTbin - startBand ); set_zero( &hFdCngDec->smoothed_psd[stopFFTbin], L_FRAME16k - stopFFTbin ); } else @@ -935,7 +935,7 @@ static void perform_noise_estimation_dec( compress_range( msPeriodog, msLogPeriodog, npart ); /* Call the minimum statistics routine for noise estimation */ - minimum_statistics( npart, nFFTpart, psize, msLogPeriodog, hFdCngDec->msNoiseFloor, msLogNoiseEst, hFdCngDec->msAlpha, hFdCngDec->msPsd, hFdCngDec->msPsdFirstMoment, hFdCngDec->msPsdSecondMoment, hFdCngDec->msMinBuf, hFdCngDec->msBminWin, hFdCngDec->msBminSubWin, hFdCngDec->msCurrentMin, hFdCngDec->msCurrentMinOut, hFdCngDec->msCurrentMinSubWindow, hFdCngDec->msLocalMinFlag, hFdCngDec->msNewMinFlag, hFdCngDec->msPeriodogBuf, &( hFdCngDec->msPeriodogBufPtr ), hFdCngDec->hFdCngCom, + minimum_statistics( npart, nFFTpart, psize, msLogPeriodog, hFdCngDec->msNoiseFloor_float, msLogNoiseEst, hFdCngDec->msAlpha_float, hFdCngDec->msPsd_float, hFdCngDec->msPsdFirstMoment_float, hFdCngDec->msPsdSecondMoment_float, hFdCngDec->msMinBuf_float, hFdCngDec->msBminWin_float, hFdCngDec->msBminSubWin_float, hFdCngDec->msCurrentMin_float, hFdCngDec->msCurrentMinOut_float, hFdCngDec->msCurrentMinSubWindow_float, hFdCngDec->msLocalMinFlag, hFdCngDec->msNewMinFlag, hFdCngDec->msPeriodogBuf_float, &( hFdCngDec->msPeriodogBufPtr ), hFdCngDec->hFdCngCom, DEC, element_mode ); /* Expand MS outputs */ @@ -991,11 +991,11 @@ void FdCng_decodeSID( if ( st->element_mode != EVS_MONO ) { create_IDCT_N_Matrix( invTrfMatrix, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM ) / ( sizeof( float ) ) ); - msvq_dec( cdk_37bits_ivas, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix, v, NULL ); + msvq_dec_float( cdk_37bits_ivas, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix, v, NULL ); } else { /* Legacy EVS_MONO MSVQ tables */ - msvq_dec( cdk_37bits, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 0, NULL, v, NULL ); + msvq_dec_float( cdk_37bits, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 0, NULL, v, NULL ); } @@ -1012,12 +1012,12 @@ void FdCng_decodeSID( if ( hFdCngCom->CngBandwidth == NB ) { - sidNoiseEst[N - 1] *= NB_LAST_BAND_SCALE; + sidNoiseEst[N - 1] *= NB_LAST_BAND_SCALE_FLT; } if ( hFdCngCom->CngBandwidth == SWB && hFdCngCom->CngBitrate <= ACELP_13k20 ) { - sidNoiseEst[N - 1] *= SWB_13k2_LAST_BAND_SCALE; + sidNoiseEst[N - 1] *= SWB_13k2_LAST_BAND_SCALE_FLT; } scalebands( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, hFdCngCom->stopBand - hFdCngCom->startBand, hFdCngCom->cngNoiseLevel, 1 ); @@ -1044,22 +1044,22 @@ void noisy_speech_detection( if ( vad == 0 ) { - tmp = dotp( hFdCngDec->msNoiseEst, hFdCngDec->psize_shaping, hFdCngDec->nFFTpart_shaping ); - hFdCngDec->lp_noise = 0.995f * hFdCngDec->lp_noise + 0.005f * 10.f * (float) log10( tmp + DELTA ); + tmp = dotp( hFdCngDec->msNoiseEst_float, hFdCngDec->psize_shaping_float, hFdCngDec->nFFTpart_shaping ); + hFdCngDec->lp_noise_float = 0.995f * hFdCngDec->lp_noise_float + 0.005f * 10.f * (float) log10( tmp + DELTA ); } else { tmp = dotp( syn, syn, hFdCngDec->hFdCngCom->frameSize ) * 2.f / hFdCngDec->hFdCngCom->frameSize; - hFdCngDec->lp_speech = 0.995f * hFdCngDec->lp_speech + 0.005f * 10.f * (float) log10( tmp + DELTA ); + hFdCngDec->lp_speech_float = 0.995f * hFdCngDec->lp_speech_float + 0.005f * 10.f * (float) log10( tmp + DELTA ); } - tmp = hFdCngDec->lp_speech - 45.f; - if ( hFdCngDec->lp_noise < tmp ) + tmp = hFdCngDec->lp_speech_float - 45.f; + if ( hFdCngDec->lp_noise_float < tmp ) { - hFdCngDec->lp_noise = tmp; + hFdCngDec->lp_noise_float = tmp; } - hFdCngDec->hFdCngCom->flag_noisy_speech = ( hFdCngDec->lp_speech - hFdCngDec->lp_noise ) < 28.f; + hFdCngDec->hFdCngCom->flag_noisy_speech = ( hFdCngDec->lp_speech_float - hFdCngDec->lp_noise_float ) < 28.f; return; } @@ -1267,8 +1267,8 @@ void generate_comfort_noise_dec( if ( st->core > ACELP_CORE ) { - tcx_windowing_synthesis_current_frame( timeDomainOutput, st->hTcxCfg->tcx_mdct_window, /*Keep sine windows for limiting Time modulation*/ - st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, st->hTcxCfg->tcx_mdct_window_length, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, 0, st->hTcxCfg->tcx_last_overlap_mode == ALDO_WINDOW ? FULL_OVERLAP : st->hTcxCfg->tcx_last_overlap_mode, NULL, NULL, NULL, NULL, NULL, N / 2, st->hTcxCfg->tcx_offset < 0 ? -st->hTcxCfg->tcx_offset : 0, 1, 0, 0 ); + tcx_windowing_synthesis_current_frame( timeDomainOutput, st->hTcxCfg->tcx_mdct_window_flt, /*Keep sine windows for limiting Time modulation*/ + st->hTcxCfg->tcx_mdct_window_half_flt, st->hTcxCfg->tcx_mdct_window_minimum_flt, st->hTcxCfg->tcx_mdct_window_length, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, 0, st->hTcxCfg->tcx_last_overlap_mode == ALDO_WINDOW ? FULL_OVERLAP : st->hTcxCfg->tcx_last_overlap_mode, NULL, NULL, NULL, NULL, NULL, N / 2, st->hTcxCfg->tcx_offset < 0 ? -st->hTcxCfg->tcx_offset : 0, 1, 0, 0 ); if ( st->hTcxCfg->last_aldo ) { @@ -1279,11 +1279,13 @@ void generate_comfort_noise_dec( } else { - tcx_windowing_synthesis_past_frame( st->hTcxDec->syn_Overl, st->hTcxCfg->tcx_mdct_window, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, st->hTcxCfg->tcx_mdct_window_length, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->hTcxCfg->tcx_last_overlap_mode ); + + tcx_windowing_synthesis_past_frame( st->hTcxDec->syn_Overl_float, st->hTcxCfg->tcx_mdct_window_flt, st->hTcxCfg->tcx_mdct_window_half_flt, st->hTcxCfg->tcx_mdct_window_minimum_flt, st->hTcxCfg->tcx_mdct_window_length, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->hTcxCfg->tcx_last_overlap_mode ); + for ( i = 0; i < st->hTcxCfg->tcx_mdct_window_length; i++ ) { - timeDomainOutput[i] += st->hTcxDec->syn_Overl[i]; + timeDomainOutput[i] += st->hTcxDec->syn_Overl_float[i]; } } } @@ -1449,7 +1451,7 @@ void generate_masking_noise( } } - scale *= (float) pow( 10.f, -scaleTable_cn_only[i].scale / 10.f ) - 1.f; + scale *= (float) pow( 10.f, -scaleTable_cn_only[i].scale_flt / 10.f ) - 1.f; } else { @@ -1611,7 +1613,7 @@ void generate_masking_noise_mdct( } } - scale *= (float) pow( 10.f, -scaleTable_cn_only[i].scale / 10.f ) - 1.f; + scale *= (float) pow( 10.f, -scaleTable_cn_only[i].scale_flt / 10.f ) - 1.f; /* Exclude clean speech */ scale *= hFdCngCom->likelihood_noisy_speech; @@ -1838,7 +1840,7 @@ void generate_masking_noise_lb_dirac( } } - scale = (float) pow( 10.f, -scaleTable_cn_dirac[i].scale / 10.f ) - 1.f; + scale = (float) pow( 10.f, -scaleTable_cn_dirac[i].scale_flt / 10.f ) - 1.f; scale *= hFdCngCom->likelihood_noisy_speech; } } @@ -1968,7 +1970,7 @@ void generate_masking_noise_dirac( } } - scale = (float) pow( 10.f, -scaleTable_cn_dirac[i].scale / 10.f ) - 1.f; + scale = (float) pow( 10.f, -scaleTable_cn_dirac[i].scale_flt / 10.f ) - 1.f; scale *= hFdCngCom->likelihood_noisy_speech; } } @@ -1994,7 +1996,7 @@ void generate_masking_noise_dirac( } if ( scale != 0 ) { - scale *= CLDFB_SCALING * ( h_cldfb->scale * h_cldfb->scale * 8.f ); + scale *= CLDFB_SCALING * ( h_cldfb->scale_flt * h_cldfb->scale_flt * 8.f ); ptr_level = hFdCngCom->cngNoiseLevel + hFdCngCom->stopFFTbin - hFdCngCom->startBand; for ( i = hFdCngCom->numCoreBands; i < hFdCngCom->regularStopBand; i++ ) @@ -2027,7 +2029,7 @@ void FdCngDecodeMDCTStereoSID( CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ ) { - DEC_CORE_HANDLE sts[CPE_CHANNELS]; + DEC_CORE_HANDLE_FLOAT sts[CPE_CHANNELS]; HANDLE_FD_CNG_COM hFdCngCom; float *ms_ptr[CPE_CHANNELS]; float *lr_ptr[CPE_CHANNELS]; @@ -2085,7 +2087,7 @@ void FdCngDecodeMDCTStereoSID( } /* MSVQ decoder */ - msvq_dec( cdk_37bits_ivas, NULL, NULL, stages, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix, ms_ptr[ch], NULL ); + msvq_dec_float( cdk_37bits_ivas, NULL, NULL, stages, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix, ms_ptr[ch], NULL ); } dtx_read_padding_bits( sts[1], ( IVAS_SID_5k2 - 4400 ) / FRAMES_PER_SEC ); @@ -2136,7 +2138,7 @@ void FdCngDecodeDiracMDCTStereoSID( CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ ) { - DEC_CORE_HANDLE sts[CPE_CHANNELS]; + DEC_CORE_HANDLE_FLOAT sts[CPE_CHANNELS]; HANDLE_FD_CNG_COM hFdCngCom; float *ms_ptr[CPE_CHANNELS]; float *lr_ptr[CPE_CHANNELS]; @@ -2172,7 +2174,7 @@ void FdCngDecodeDiracMDCTStereoSID( gain[1] = gain[0]; /* MSVQ decoder */ - msvq_dec( cdk_37bits_ivas, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix, ms_ptr[0], NULL ); + msvq_dec_float( cdk_37bits_ivas, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix, ms_ptr[0], NULL ); mvr2r( ms_ptr[0], ms_ptr[1], N ); /*inverseMS( N, ms_ptr[0], ms_ptr[1], 1.f );*/ @@ -2188,11 +2190,11 @@ void FdCngDecodeDiracMDCTStereoSID( /* NB last band energy compensation */ if ( hFdCngCom->CngBandwidth == NB ) { - lr_ptr[ch][N - 1] *= NB_LAST_BAND_SCALE; + lr_ptr[ch][N - 1] *= NB_LAST_BAND_SCALE_FLT; } else if ( hFdCngCom->CngBandwidth == SWB && hFdCngCom->CngBitrate <= ACELP_13k20 ) { - lr_ptr[ch][N - 1] *= SWB_13k2_LAST_BAND_SCALE; + lr_ptr[ch][N - 1] *= SWB_13k2_LAST_BAND_SCALE_FLT; } scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, hFdCngCom->stopBand - hFdCngCom->startBand, hFdCngCom->cngNoiseLevel, 1 ); diff --git a/lib_dec/gaus_dec.c b/lib_dec/gaus_dec.c index 141812b30..daa6148af 100644 --- a/lib_dec/gaus_dec.c +++ b/lib_dec/gaus_dec.c @@ -259,7 +259,7 @@ void gaus_L2_dec( } /*Shape the gaussian excitation*/ - cb_shape( 1, 0, 0, 1, 0, formant_enh_num, FORMANT_SHARPENING_G2, Aq, code, tilt_code, 0, L_SUBFR ); + cb_shape( 1, 0, 0, 1, 0, formant_enh_num, FORMANT_SHARPENING_G2_FLT, Aq, code, tilt_code, 0, L_SUBFR ); return; } diff --git a/lib_dec/hf_synth.c b/lib_dec/hf_synth.c index 5be0404f8..74ade1649 100644 --- a/lib_dec/hf_synth.c +++ b/lib_dec/hf_synth.c @@ -101,7 +101,7 @@ void hf_synth_amr_wb_init( hAmrwb_IO->frame_count = 0; hAmrwb_IO->ne_min = -30.0f; hAmrwb_IO->fmerit_m_sm = 0.0f; - hAmrwb_IO->voice_fac_amr_wb_hf = 0.0f; + hAmrwb_IO->voice_fac_amr_wb_hf_float = 0.0f; hAmrwb_IO->unvoicing = 0.0f; hAmrwb_IO->unvoicing_sm = 1.0f; hAmrwb_IO->unvoicing_flag = 0; @@ -140,7 +140,7 @@ void hf_synth_amr_wb_reset( hAmrwb_IO->frame_count = 0; hAmrwb_IO->ne_min = -30.0f; hAmrwb_IO->fmerit_m_sm = 0.0f; - hAmrwb_IO->voice_fac_amr_wb_hf = 0.0f; + hAmrwb_IO->voice_fac_amr_wb_hf_float = 0.0f; hAmrwb_IO->unvoicing = 0.0f; hAmrwb_IO->unvoicing_sm = 1.0f; hAmrwb_IO->unvoicing_flag = 0; @@ -545,7 +545,7 @@ static void hf_synthesis_amr_wb( *-----------------------------------------------------------------*/ /* compensate CLDFB resampling delay */ - delay_signal( HF_syn, L_SUBFR16k, delay_syn_hf, NS2SA( 16000, DELAY_CLDFB_NS ) ); + delay_signal_float( HF_syn, L_SUBFR16k, delay_syn_hf, NS2SA( 16000, DELAY_CLDFB_NS ) ); /* interpolate the HF synthesis */ if ( output_subfr == L_FRAME48k / NB_SUBFR ) /* 48kHz sampled output */ @@ -715,7 +715,7 @@ static void envelope( qq = 1.0f / ( (float) sqrt( qx * qx + qy * qy ) ); - Unvoicing_flag = EnhanceClass( rr, pp, tilt0, tilt, voice_factor, &hAmrwb_IO->voice_fac_amr_wb_hf, &hAmrwb_IO->unvoicing, &hAmrwb_IO->unvoicing_sm, &hAmrwb_IO->unvoicing_flag ); + Unvoicing_flag = EnhanceClass( rr, pp, tilt0, tilt, voice_factor, &hAmrwb_IO->voice_fac_amr_wb_hf_float, &hAmrwb_IO->unvoicing, &hAmrwb_IO->unvoicing_sm, &hAmrwb_IO->unvoicing_flag ); alpha = 0.0f; if ( Unvoicing_flag ) @@ -745,7 +745,7 @@ static void envelope( env_level[0] = pp; env_level[1] = qq; env_level[2] = rr; - v_sort( env_level, 0, 2 ); + v_sort_float( env_level, 0, 2 ); rr = env_level[0]; est_level2 = rr * ( 1.0f + (float) fabs( tilt - 1 ) * ( 1.6f - voice_factor ) ); rr = min( est_level1, est_level2 ); @@ -1042,7 +1042,7 @@ static void hf_synthesis( *-----------------------------------------------------------------*/ /* delay by 5 samples @16kHz to compensate CLDFB resampling delay (20samples) and HP filtering delay (roughly 15 samples) */ - delay_signal( HF_syn, L_SUBFR16k, hBWE_zero->delay_syn_hf, NS2SA( 16000, DELAY_CLDFB_NS ) - 15 ); + delay_signal_float( HF_syn, L_SUBFR16k, hBWE_zero->delay_syn_hf, NS2SA( 16000, DELAY_CLDFB_NS ) - 15 ); /* interpolate the HF synthesis */ if ( output_subfr == L_FRAME48k / NB_SUBFR ) /* 48kHz sampled output */ diff --git a/lib_dec/hq_core_dec.c b/lib_dec/hq_core_dec.c index 99d74c63b..1de3c78d2 100644 --- a/lib_dec/hq_core_dec.c +++ b/lib_dec/hq_core_dec.c @@ -344,13 +344,15 @@ void hq_core_dec( index = tcx_cfg->tcx_last_overlap_mode; /* LB synthesis */ - IMDCT( t_audio_q, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, wtda_audio, tcx_cfg->tcx_aldo_window_1_trunc, tcx_cfg->tcx_aldo_window_2, tcx_cfg->tcx_mdct_window_half, tcx_cfg->tcx_mdct_window_minimum, tcx_cfg->tcx_mdct_window_trans, tcx_cfg->tcx_mdct_window_half_length, tcx_cfg->tcx_mdct_window_min_length, index, + + IMDCT( t_audio_q, hTcxDec->syn_Overl_float, hTcxDec->syn_Overl_TDAC_float, wtda_audio, tcx_cfg->tcx_aldo_window_1_trunc_flt, tcx_cfg->tcx_aldo_window_2_flt, tcx_cfg->tcx_mdct_window_half_flt, tcx_cfg->tcx_mdct_window_minimum_flt, tcx_cfg->tcx_mdct_window_trans_flt, tcx_cfg->tcx_mdct_window_half_length, tcx_cfg->tcx_mdct_window_min_length, index, MDCT_IV, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frame_glob, 0, st->bfi, hHQ_core->old_outLB, 0, st, 0, acelp_zir ); mvr2r( wtda_audio + ( overlap >> 1 ) - tcx_offset, output, L_frame_glob ); /* FB synthesis */ - IMDCT( t_audio_q, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, wtda_audio, tcx_cfg->tcx_aldo_window_1_FB_trunc, tcx_cfg->tcx_aldo_window_2_FB, tcx_cfg->tcx_mdct_window_halfFB, tcx_cfg->tcx_mdct_window_minimumFB, tcx_cfg->tcx_mdct_window_transFB, tcx_cfg->tcx_mdct_window_half_lengthFB, tcx_cfg->tcx_mdct_window_min_lengthFB, index, + + IMDCT( t_audio_q, hTcxDec->syn_OverlFB_float, hTcxDec->syn_Overl_TDACFB_float, wtda_audio, tcx_cfg->tcx_aldo_window_1_FB_trunc_flt, tcx_cfg->tcx_aldo_window_2_FB_flt, tcx_cfg->tcx_mdct_window_halfFB_flt, tcx_cfg->tcx_mdct_window_minimumFB_flt, tcx_cfg->tcx_mdct_window_transFB_flt, tcx_cfg->tcx_mdct_window_half_lengthFB, tcx_cfg->tcx_mdct_window_min_lengthFB, index, MDCT_IV, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frameTCX_glob, 0, st->bfi, hHQ_core->old_out, 1, st, FSCALE_DENOM * L_frameTCX_glob / L_frame_glob, acelp_zir ); mvr2r( wtda_audio + ( overlapFB >> 1 ) - tcx_offsetFB, synth, L_frameTCX_glob ); @@ -443,7 +445,7 @@ void hq_core_dec( if ( !st->bfi && st->prev_bfi && st->last_total_brate >= HQ_48k && st->last_codec_mode == MODE2 && ( st->last_core_bfi == TCX_20_CORE || st->last_core_bfi == TCX_10_CORE ) && st->hPlcInfo->concealment_method == TCX_NONTONAL && st->hPlcInfo->nbLostCmpt < 4 ) { - waveform_adj2( st->hPlcInfo, st->hTonalMDCTConc->secondLastPcmOut, synth, 0, st->hPlcInfo->nbLostCmpt + 1, st->bfi ); + waveform_adj2( st->hPlcInfo, st->hTonalMDCTConc->secondLastPcmOut_float, synth, 0, st->hPlcInfo->nbLostCmpt + 1, st->bfi ); } if ( output_frame >= L_FRAME16k ) @@ -564,7 +566,7 @@ void HQ_core_dec_init( set_f( hHQ_core->mag_chg_1st, 1.0f, LGW_MAX ); set_f( hHQ_core->Xavg, 0.0f, LGW_MAX ); - hHQ_core->beta_mute = BETA_MUTE_FAC_INI; + hHQ_core->beta_mute = BETA_MUTE_FAC_INI_FLT; hHQ_core->time_offs = 0; hHQ_core->ber_occured_in_pvq = 0; diff --git a/lib_dec/hq_env_dec.c b/lib_dec/hq_env_dec.c index 74309410c..4468956e6 100644 --- a/lib_dec/hq_env_dec.c +++ b/lib_dec/hq_env_dec.c @@ -158,7 +158,7 @@ void dequantize_norms( int16_t idxbuf[NB_SFM]; /* First sub-frame */ - normqlg2[start_norm] = dicnlg2[ynrm[start_norm]]; + normqlg2[start_norm] = dicnlg2_float[ynrm[start_norm]]; /* Other sub-frames */ if ( is_transient ) @@ -191,7 +191,7 @@ void dequantize_norms( ynrm[i] = 39; st->BER_detect = 1; } - normqlg2[i] = dicnlg2[ynrm[i]]; + normqlg2[i] = dicnlg2_float[ynrm[i]]; } } diff --git a/lib_dec/igf_dec.c b/lib_dec/igf_dec.c index e5903902e..49067b987 100644 --- a/lib_dec/igf_dec.c +++ b/lib_dec/igf_dec.c @@ -377,14 +377,14 @@ static void IGF_prep( { if ( hPrivateData->n_noise_bands ) { - IGF_replaceTCXNoise_2_new( igf_spec, TCXNoise, strt_cpy, stop, hPrivateData->totalNoiseNrg, hPrivateData->n_noise_bands, hInfo->nfSeed ); + IGF_replaceTCXNoise_2_new( igf_spec, TCXNoise, strt_cpy, stop, hPrivateData->totalNoiseNrg_float, hPrivateData->n_noise_bands, hInfo->nfSeed ); } } else { if ( hPrivateData->n_noise_bands ) { - IGF_replaceTCXNoise_2( igf_spec, TCXNoise, hGrid->minSrcSubband, hGrid->startLine, hPrivateData->totalNoiseNrg, hInfo->nfSeed ); + IGF_replaceTCXNoise_2( igf_spec, TCXNoise, hGrid->minSrcSubband, hGrid->startLine, hPrivateData->totalNoiseNrg_float, hInfo->nfSeed ); } } @@ -396,14 +396,14 @@ static void IGF_prep( { if ( hPrivateData->n_noise_bands_off ) { - IGF_replaceTCXNoise_2_new( src_spec, TCXNoise, strt_cpy, stop, hPrivateData->totalNoiseNrg_off, hPrivateData->n_noise_bands_off, hInfo->nfSeed ); + IGF_replaceTCXNoise_2_new( src_spec, TCXNoise, strt_cpy, stop, hPrivateData->totalNoiseNrg_off_float, hPrivateData->n_noise_bands_off, hInfo->nfSeed ); } } else { if ( hPrivateData->n_noise_bands_off ) { - IGF_replaceTCXNoise_2( src_spec, TCXNoise, hGrid->minSrcSubband, hGrid->startLine, hPrivateData->totalNoiseNrg_off, hInfo->nfSeed ); + IGF_replaceTCXNoise_2( src_spec, TCXNoise, hGrid->minSrcSubband, hGrid->startLine, hPrivateData->totalNoiseNrg_off_float, hInfo->nfSeed ); } } @@ -479,7 +479,7 @@ static void IGF_prepStereo( { if ( hPrivateDataL->n_noise_bands ) { - IGF_replaceTCXNoise_2_new( igf_specL, TCXNoiseL, strt_cpy, stop, hPrivateDataL->totalNoiseNrg, hPrivateDataL->n_noise_bands, hInfoL->nfSeed ); + IGF_replaceTCXNoise_2_new( igf_specL, TCXNoiseL, strt_cpy, stop, hPrivateDataL->totalNoiseNrg_float, hPrivateDataL->n_noise_bands, hInfoL->nfSeed ); } sel_specL = igf_specL; } @@ -487,7 +487,7 @@ static void IGF_prepStereo( { if ( hPrivateDataL->n_noise_bands_off ) { - IGF_replaceTCXNoise_2_new( igf_specL, TCXNoiseL, strt_cpy, stop, hPrivateDataL->totalNoiseNrg_off, hPrivateDataL->n_noise_bands_off, hInfoL->nfSeed ); + IGF_replaceTCXNoise_2_new( igf_specL, TCXNoiseL, strt_cpy, stop, hPrivateDataL->totalNoiseNrg_off_float, hPrivateDataL->n_noise_bands_off, hInfoL->nfSeed ); } sel_specL = src_specL; } @@ -496,7 +496,7 @@ static void IGF_prepStereo( { if ( hPrivateDataR->n_noise_bands ) { - IGF_replaceTCXNoise_2_new( igf_specR, TCXNoiseR, strt_cpy, stop, hPrivateDataR->totalNoiseNrg, hPrivateDataR->n_noise_bands, hInfoR->nfSeed ); + IGF_replaceTCXNoise_2_new( igf_specR, TCXNoiseR, strt_cpy, stop, hPrivateDataR->totalNoiseNrg_float, hPrivateDataR->n_noise_bands, hInfoR->nfSeed ); } sel_specR = igf_specR; } @@ -504,7 +504,7 @@ static void IGF_prepStereo( { if ( hPrivateDataR->n_noise_bands_off ) { - IGF_replaceTCXNoise_2_new( igf_specR, TCXNoiseR, strt_cpy, stop, hPrivateDataR->totalNoiseNrg_off, hPrivateDataR->n_noise_bands_off, hInfoR->nfSeed ); + IGF_replaceTCXNoise_2_new( igf_specR, TCXNoiseR, strt_cpy, stop, hPrivateDataR->totalNoiseNrg_off_float, hPrivateDataR->n_noise_bands_off, hInfoR->nfSeed ); } sel_specR = src_specR; } @@ -560,7 +560,7 @@ static void IGF_prepStereo( { if ( hPrivateDataL->n_noise_bands ) { - IGF_replaceTCXNoise_2_new( igf_specL, TCXNoiseL, strt_cpy, stop, hPrivateDataL->totalNoiseNrg, hPrivateDataL->n_noise_bands, hInfoL->nfSeed ); + IGF_replaceTCXNoise_2_new( igf_specL, TCXNoiseL, strt_cpy, stop, hPrivateDataL->totalNoiseNrg_float, hPrivateDataL->n_noise_bands, hInfoL->nfSeed ); } sel_specL = igf_specL; } @@ -568,7 +568,7 @@ static void IGF_prepStereo( { if ( hPrivateDataL->n_noise_bands_off ) { - IGF_replaceTCXNoise_2_new( igf_specL, TCXNoiseL, strt_cpy, stop, hPrivateDataL->totalNoiseNrg_off, hPrivateDataL->n_noise_bands_off, hInfoL->nfSeed ); + IGF_replaceTCXNoise_2_new( igf_specL, TCXNoiseL, strt_cpy, stop, hPrivateDataL->totalNoiseNrg_off_float, hPrivateDataL->n_noise_bands_off, hInfoL->nfSeed ); } sel_specL = src_specL; } @@ -577,7 +577,7 @@ static void IGF_prepStereo( { if ( hPrivateDataR->n_noise_bands ) { - IGF_replaceTCXNoise_2_new( igf_specR, TCXNoiseR, strt_cpy, stop, hPrivateDataR->totalNoiseNrg, hPrivateDataR->n_noise_bands, hInfoR->nfSeed ); + IGF_replaceTCXNoise_2_new( igf_specR, TCXNoiseR, strt_cpy, stop, hPrivateDataR->totalNoiseNrg_float, hPrivateDataR->n_noise_bands, hInfoR->nfSeed ); } sel_specR = igf_specR; } @@ -585,7 +585,7 @@ static void IGF_prepStereo( { if ( hPrivateDataR->n_noise_bands_off ) { - IGF_replaceTCXNoise_2_new( igf_specR, TCXNoiseR, strt_cpy, stop, hPrivateDataR->totalNoiseNrg_off, hPrivateDataR->n_noise_bands_off, hInfoR->nfSeed ); + IGF_replaceTCXNoise_2_new( igf_specR, TCXNoiseR, strt_cpy, stop, hPrivateDataR->totalNoiseNrg_off_float, hPrivateDataR->n_noise_bands_off, hInfoR->nfSeed ); } sel_specR = src_specR; } @@ -649,8 +649,8 @@ static void IGF_calc( set_zero( tmp, N_MAX_TCX ); hGrid = &hPrivateData->igfInfo.grid[igfGridIdx]; - igf_pN = hPrivateData->igf_pN; - igf_sN = hPrivateData->igf_sN; + igf_pN = hPrivateData->igf_pN_float; + igf_sN = hPrivateData->igf_sN_float; IGF_getMDCTSquare( hGrid->startLine, hGrid->stopLine, spectrum, tmp ); IGF_calcSfbEnergy( hGrid->startSfb, hGrid->stopSfb, hGrid->swb_offset, tmp, igf_sN ); @@ -706,13 +706,13 @@ static void IGF_appl( /* more inits */ hGrid = &hPrivateData->igfInfo.grid[igfGridIdx]; - sN = hPrivateData->igf_sN; - pN = hPrivateData->igf_pN; + sN = hPrivateData->igf_sN_float; + pN = hPrivateData->igf_pN_float; start_sfb = hGrid->startSfb; stop_sfb = hGrid->stopSfb; - gFactor = hGrid->gFactor; - fFactor = hGrid->fFactor; - lFactor = hGrid->lFactor; + gFactor = hGrid->gFactor_flt; + fFactor = hGrid->fFactor_flt; + lFactor = hGrid->lFactor_flt; swb_offset = hGrid->swb_offset; @@ -1153,13 +1153,13 @@ void IGFDecApplyMono( nShift = igfGridIdx == IGF_GRID_LB_SHORT ? 2 : 1; set_s( hIGFDec->flag_sparse, 0, ( N_MAX_TCX - IGF_START_MN ) / nShift ); - set_f( hIGFDec->virtualSpec, 0.f, ( N_MAX_TCX - IGF_START_MN ) / nShift ); + set_f( hIGFDec->virtualSpec_float, 0.f, ( N_MAX_TCX - IGF_START_MN ) / nShift ); hPrivateData = &hIGFDec->igfData; hGrid = &hPrivateData->igfInfo.grid[igfGridIdx]; - hPrivateData->totalNoiseNrg = 0.f; + hPrivateData->totalNoiseNrg_float = 0.f; hPrivateData->n_noise_bands = 0; - hPrivateData->totalNoiseNrg_off = 0.f; + hPrivateData->totalNoiseNrg_off_float = 0.f; hPrivateData->n_noise_bands_off = 0; hPrivateData->restrict_hopsize = 0; @@ -1182,14 +1182,14 @@ void IGFDecApplyMono( { if ( element_mode == EVS_MONO || !bfi ) { - IGF_getWhiteSpectralData( hPrivateData->pSpecFlat, igf_spec, hGrid->minSrcSubband, hGrid->startLine, whiteningLevel ); + IGF_getWhiteSpectralData( hPrivateData->pSpecFlat_float, igf_spec, hGrid->minSrcSubband, hGrid->startLine, whiteningLevel ); } else { - mvr2r( hPrivateData->pSpecFlat, igf_spec, hGrid->startLine ); + mvr2r( hPrivateData->pSpecFlat_float, igf_spec, hGrid->startLine ); } - hPrivateData->n_noise_bands = IGF_replaceTCXNoise_1( igf_spec, hIGFDec->infoTCXNoise, hGrid->minSrcSubband, hGrid->startLine, &hPrivateData->totalNoiseNrg ); + hPrivateData->n_noise_bands = IGF_replaceTCXNoise_1( igf_spec, hIGFDec->infoTCXNoise, hGrid->minSrcSubband, hGrid->startLine, &hPrivateData->totalNoiseNrg_float ); break; } } @@ -1198,15 +1198,15 @@ void IGFDecApplyMono( { if ( hPrivateData->currWhiteningLevel[i] == IGF_WHITENING_OFF ) { - hPrivateData->n_noise_bands_off = IGF_replaceTCXNoise_1( hPrivateData->pSpecFlat, hIGFDec->infoTCXNoise, hGrid->minSrcSubband, hGrid->startLine, &hPrivateData->totalNoiseNrg_off ); + hPrivateData->n_noise_bands_off = IGF_replaceTCXNoise_1( hPrivateData->pSpecFlat_float, hIGFDec->infoTCXNoise, hGrid->minSrcSubband, hGrid->startLine, &hPrivateData->totalNoiseNrg_off_float ); break; } } /* apply IGF in three steps: */ - IGF_prep( hPrivateData, igfGridIdx, hIGFDec->infoTCXNoise, igf_spec, hPrivateData->pSpecFlat, element_mode ); + IGF_prep( hPrivateData, igfGridIdx, hIGFDec->infoTCXNoise, igf_spec, hPrivateData->pSpecFlat_float, element_mode ); IGF_calc( hPrivateData, igfGridIdx, spectrum, igf_spec ); - IGF_appl( hPrivateData, igfGridIdx, spectrum, igf_spec, hIGFDec->virtualSpec, hIGFDec->flag_sparse, 1 ); + IGF_appl( hPrivateData, igfGridIdx, spectrum, igf_spec, hIGFDec->virtualSpec_float, hIGFDec->flag_sparse, 1 ); } /* reset TCX noise indicator vector */ @@ -1250,21 +1250,21 @@ void IGFDecApplyStereo( nShift = igfGridIdx == IGF_GRID_LB_SHORT ? 2 : 1; set_s( hIGFDecL->flag_sparse, 0, ( N_MAX_TCX - IGF_START_MN ) / nShift ); set_s( hIGFDecR->flag_sparse, 0, ( N_MAX_TCX - IGF_START_MN ) / nShift ); - set_f( hIGFDecL->virtualSpec, 0.f, ( N_MAX_TCX - IGF_START_MN ) / nShift ); - set_f( hIGFDecR->virtualSpec, 0.f, ( N_MAX_TCX - IGF_START_MN ) / nShift ); + set_f( hIGFDecL->virtualSpec_float, 0.f, ( N_MAX_TCX - IGF_START_MN ) / nShift ); + set_f( hIGFDecR->virtualSpec_float, 0.f, ( N_MAX_TCX - IGF_START_MN ) / nShift ); hPrivateDataL = &hIGFDecL->igfData; hGrid = &hPrivateDataL->igfInfo.grid[igfGridIdx]; - hPrivateDataL->totalNoiseNrg = 0.f; + hPrivateDataL->totalNoiseNrg_float = 0.f; hPrivateDataL->n_noise_bands = 0; - hPrivateDataL->totalNoiseNrg_off = 0.f; + hPrivateDataL->totalNoiseNrg_off_float = 0.f; hPrivateDataL->n_noise_bands_off = 0; hPrivateDataL->restrict_hopsize = restrict_hopsize; hPrivateDataR = &hIGFDecR->igfData; - hPrivateDataR->totalNoiseNrg = 0.f; + hPrivateDataR->totalNoiseNrg_float = 0.f; hPrivateDataR->n_noise_bands = 0; - hPrivateDataR->totalNoiseNrg_off = 0.f; + hPrivateDataR->totalNoiseNrg_off_float = 0.f; hPrivateDataR->n_noise_bands_off = 0; hPrivateDataR->restrict_hopsize = restrict_hopsize; @@ -1289,25 +1289,25 @@ void IGFDecApplyStereo( { if ( !bfi ) { - IGF_getWhiteSpectralData( hPrivateDataL->pSpecFlat, igf_specL, hGrid->minSrcSubband, hGrid->startLine, whiteningLevel ); + IGF_getWhiteSpectralData( hPrivateDataL->pSpecFlat_float, igf_specL, hGrid->minSrcSubband, hGrid->startLine, whiteningLevel ); } else { - mvr2r( hPrivateDataL->pSpecFlat, igf_specL, hGrid->startLine ); + mvr2r( hPrivateDataL->pSpecFlat_float, igf_specL, hGrid->startLine ); } - hPrivateDataL->n_noise_bands = IGF_replaceTCXNoise_1( igf_specL, hIGFDecL->infoTCXNoise, hGrid->minSrcSubband, hGrid->startLine, &hPrivateDataL->totalNoiseNrg ); + hPrivateDataL->n_noise_bands = IGF_replaceTCXNoise_1( igf_specL, hIGFDecL->infoTCXNoise, hGrid->minSrcSubband, hGrid->startLine, &hPrivateDataL->totalNoiseNrg_float ); if ( !bfi ) { - IGF_getWhiteSpectralData( hPrivateDataR->pSpecFlat, igf_specR, hGrid->minSrcSubband, hGrid->startLine, whiteningLevel ); + IGF_getWhiteSpectralData( hPrivateDataR->pSpecFlat_float, igf_specR, hGrid->minSrcSubband, hGrid->startLine, whiteningLevel ); } else { - mvr2r( hPrivateDataR->pSpecFlat, igf_specR, hGrid->startLine ); + mvr2r( hPrivateDataR->pSpecFlat_float, igf_specR, hGrid->startLine ); } - hPrivateDataR->n_noise_bands = IGF_replaceTCXNoise_1( igf_specR, hIGFDecR->infoTCXNoise, hGrid->minSrcSubband, hGrid->startLine, &hPrivateDataR->totalNoiseNrg ); + hPrivateDataR->n_noise_bands = IGF_replaceTCXNoise_1( igf_specR, hIGFDecR->infoTCXNoise, hGrid->minSrcSubband, hGrid->startLine, &hPrivateDataR->totalNoiseNrg_float ); break; } @@ -1317,20 +1317,20 @@ void IGFDecApplyStereo( { if ( hPrivateDataL->currWhiteningLevel[i] == IGF_WHITENING_OFF || hPrivateDataR->currWhiteningLevel[i] == IGF_WHITENING_OFF ) { - hPrivateDataL->n_noise_bands_off = IGF_replaceTCXNoise_1( hPrivateDataL->pSpecFlat, hIGFDecL->infoTCXNoise, hGrid->minSrcSubband, hGrid->startLine, &hPrivateDataL->totalNoiseNrg_off ); + hPrivateDataL->n_noise_bands_off = IGF_replaceTCXNoise_1( hPrivateDataL->pSpecFlat_float, hIGFDecL->infoTCXNoise, hGrid->minSrcSubband, hGrid->startLine, &hPrivateDataL->totalNoiseNrg_off_float ); - hPrivateDataR->n_noise_bands_off = IGF_replaceTCXNoise_1( hPrivateDataR->pSpecFlat, hIGFDecR->infoTCXNoise, hGrid->minSrcSubband, hGrid->startLine, &hPrivateDataR->totalNoiseNrg_off ); + hPrivateDataR->n_noise_bands_off = IGF_replaceTCXNoise_1( hPrivateDataR->pSpecFlat_float, hIGFDecR->infoTCXNoise, hGrid->minSrcSubband, hGrid->startLine, &hPrivateDataR->totalNoiseNrg_off_float ); break; } } /* apply IGF in three steps: */ - IGF_prepStereo( hPrivateDataL, hPrivateDataR, igfGridIdx, hIGFDecL->infoTCXNoise, hIGFDecR->infoTCXNoise, igf_specL, igf_specR, hPrivateDataL->pSpecFlat, hPrivateDataR->pSpecFlat, coreMsMask ); + IGF_prepStereo( hPrivateDataL, hPrivateDataR, igfGridIdx, hIGFDecL->infoTCXNoise, hIGFDecR->infoTCXNoise, igf_specL, igf_specR, hPrivateDataL->pSpecFlat_float, hPrivateDataR->pSpecFlat_float, coreMsMask ); IGF_calc( hPrivateDataL, igfGridIdx, spectrumL, igf_specL ); IGF_calc( hPrivateDataR, igfGridIdx, spectrumR, igf_specR ); - IGF_appl( hPrivateDataL, igfGridIdx, spectrumL, igf_specL, hIGFDecL->virtualSpec, hIGFDecL->flag_sparse, bfi_apply_damping ); - IGF_appl( hPrivateDataR, igfGridIdx, spectrumR, igf_specR, hIGFDecR->virtualSpec, hIGFDecR->flag_sparse, bfi_apply_damping ); + IGF_appl( hPrivateDataL, igfGridIdx, spectrumL, igf_specL, hIGFDecL->virtualSpec_float, hIGFDecL->flag_sparse, bfi_apply_damping ); + IGF_appl( hPrivateDataR, igfGridIdx, spectrumR, igf_specR, hIGFDecR->virtualSpec_float, hIGFDecR->flag_sparse, bfi_apply_damping ); } /* reset TCX noise indicator vector */ @@ -1396,8 +1396,8 @@ void IGFDecSetMode( hIGFDec->flag_sparse = &hIGFDec->flag_sparseBuf[0]; hIGFDec->infoTCXNoise = &hIGFDec->infoTCXNoiseBuf[0]; - hIGFDec->virtualSpec = &hIGFDec->virtualSpecBuf[0]; - hIGFDec->igfData.pSpecFlat = &hIGFDec->igfData.pSpecFlatBuf[0]; + hIGFDec->virtualSpec_float = &hIGFDec->virtualSpecBuf[0]; + hIGFDec->igfData.pSpecFlat_float = &hIGFDec->igfData.pSpecFlatBuf[0]; hIGFDec->igfData.igfInfo.nfSeed = &hIGFDec->igfData.igfInfo.nfSeedBuf[0]; return; @@ -1421,8 +1421,8 @@ void IGFDecUpdateInfo( hIGFDec->flag_sparse = &hIGFDec->flag_sparseBuf[0]; hIGFDec->infoTCXNoise = &hIGFDec->infoTCXNoiseBuf[0]; - hIGFDec->virtualSpec = &hIGFDec->virtualSpecBuf[0]; - hIGFDec->igfData.pSpecFlat = &hIGFDec->igfData.pSpecFlatBuf[0]; + hIGFDec->virtualSpec_float = &hIGFDec->virtualSpecBuf[0]; + hIGFDec->igfData.pSpecFlat_float = &hIGFDec->igfData.pSpecFlatBuf[0]; hIGFDec->igfData.igfInfo.nfSeed = &hIGFDec->igfData.igfInfo.nfSeedBuf[0]; if ( igfGridIdx == IGF_GRID_LB_SHORT ) @@ -1488,7 +1488,7 @@ void IGFDecCopyLPCFlatSpectrum( for ( i = hGrid->minSrcSubband - IGF_MID_WHITENING_LEVEL2; i < hGrid->startLine; i++ ) { - hPrivateData->pSpecFlat[i] = pSpectrumFlat[i] * 1024.f; + hPrivateData->pSpecFlat_float[i] = pSpectrumFlat[i] * 1024.f; } } @@ -1553,8 +1553,8 @@ void IGFDecRestoreTCX10SubFrameData( hIGFDec->flatteningTrigger = hPrivateData->igf_flatteningTrigger_subframe[subFrameIdx]; hIGFDec->flag_sparse = &hIGFDec->flag_sparseBuf[subFrameIdx * ( N_MAX_TCX - IGF_START_MN ) / 2]; hIGFDec->infoTCXNoise = &hIGFDec->infoTCXNoiseBuf[subFrameIdx * ( IGF_START_MX ) / 2]; - hIGFDec->virtualSpec = &hIGFDec->virtualSpecBuf[subFrameIdx * ( N_MAX_TCX - IGF_START_MN ) / 2]; - hIGFDec->igfData.pSpecFlat = &hIGFDec->igfData.pSpecFlatBuf[subFrameIdx * IGF_START_MX / 2]; + hIGFDec->virtualSpec_float = &hIGFDec->virtualSpecBuf[subFrameIdx * ( N_MAX_TCX - IGF_START_MN ) / 2]; + hIGFDec->igfData.pSpecFlat_float = &hIGFDec->igfData.pSpecFlatBuf[subFrameIdx * IGF_START_MX / 2]; hIGFDec->igfData.igfInfo.nfSeed = &hIGFDec->igfData.igfInfo.nfSeedBuf[subFrameIdx]; return; @@ -1575,10 +1575,10 @@ void init_igf_dec( hIGFDec->igfData.igfInfo.nfSeedBuf[0] = 9733; hIGFDec->igfData.igfInfo.nfSeedBuf[1] = 9733; hIGFDec->igfData.igfInfo.nfSeed = &hIGFDec->igfData.igfInfo.nfSeedBuf[0]; - hIGFDec->igfData.pSpecFlat = &hIGFDec->igfData.pSpecFlatBuf[0]; + hIGFDec->igfData.pSpecFlat_float = &hIGFDec->igfData.pSpecFlatBuf[0]; hIGFDec->flag_sparse = &hIGFDec->flag_sparseBuf[0]; hIGFDec->infoTCXNoise = &hIGFDec->infoTCXNoiseBuf[0]; - hIGFDec->virtualSpec = &hIGFDec->virtualSpecBuf[0]; + hIGFDec->virtualSpec_float = &hIGFDec->virtualSpecBuf[0]; return; } diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index 6d2849841..0ba639e2e 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -594,7 +594,7 @@ ivas_error init_decoder( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxDec\n" ) ); } - set_f( st->hTcxDec->FBTCXdelayBuf, 0.0f, 111 ); + set_f( st->hTcxDec->FBTCXdelayBuf_float, 0.0f, 111 ); st->hTcxDec->old_synthFB = st->hTcxDec->synth_history + NS2SA( st->output_Fs, PH_ECU_MEM_NS ); st->hTcxDec->prev_good_synth = st->hTcxDec->old_synthFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ); diff --git a/lib_dec/inov_dec.c b/lib_dec/inov_dec.c index adbbb4fd3..e8eaa38e8 100644 --- a/lib_dec/inov_dec.c +++ b/lib_dec/inov_dec.c @@ -67,13 +67,13 @@ void inov_decode( if ( L_frame == L_FRAME ) { - g1 = FORMANT_SHARPENING_G1; - g2 = FORMANT_SHARPENING_G2; + g1 = FORMANT_SHARPENING_G1_FLT; + g2 = FORMANT_SHARPENING_G2_FLT; } else { - g1 = FORMANT_SHARPENING_G1_16k; - g2 = FORMANT_SHARPENING_G2_16k; + g1 = FORMANT_SHARPENING_G1_16k_FLT; + g2 = FORMANT_SHARPENING_G2_16k_FLT; } if ( !Opt_AMR_WB ) diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 7ad9082fb..c3e1bfa88 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -190,8 +190,8 @@ ivas_error ivas_core_dec( if ( !st->bfi && st->prev_bfi && ( st->last_core_bfi == TCX_20_CORE || st->last_core_bfi == TCX_10_CORE ) && st->hTcxDec != NULL ) { - v_multc( st->hHQ_core->old_out, st->hTcxDec->conceal_eof_gain * st->last_concealed_gain_syn_deemph, st->hHQ_core->old_out, st->hTcxDec->L_frameTCX ); - v_multc( st->hHQ_core->old_outLB, st->hTcxDec->conceal_eof_gain * st->last_concealed_gain_syn_deemph, st->hHQ_core->old_outLB, st->L_frame ); + v_multc( st->hHQ_core->old_out, st->hTcxDec->conceal_eof_gain_float * st->last_concealed_gain_syn_deemph, st->hHQ_core->old_out, st->hTcxDec->L_frameTCX ); + v_multc( st->hHQ_core->old_outLB, st->hTcxDec->conceal_eof_gain_float * st->last_concealed_gain_syn_deemph, st->hHQ_core->old_outLB, st->L_frame ); } set_f( voice_factors[n], 0.f, NB_SUBFR16k ); @@ -566,7 +566,7 @@ ivas_error ivas_core_dec( { tmps = NS2SA( output_Fs, DELAY_CLDFB_NS ); - waveform_adj2( st->hPlcInfo, st->hTonalMDCTConc->secondLastPcmOut, synth[n] + tmps, tmps, st->hPlcInfo->nbLostCmpt + 1, st->bfi ); + waveform_adj2( st->hPlcInfo, st->hTonalMDCTConc->secondLastPcmOut_float, synth[n] + tmps, tmps, st->hPlcInfo->nbLostCmpt + 1, st->bfi ); st->hPlcInfo->Pitch = 0; } @@ -648,7 +648,7 @@ ivas_error ivas_core_dec( if ( ( st->element_mode != IVAS_CPE_TD && !use_cldfb_for_dft ) || ( hCPE->element_mode == IVAS_CPE_TD && tdm_LRTD_flag ) ) { /* Delay hb_synth */ - delay_signal( hb_synth[n], output_frame, st->hb_prev_synth_buffer, tmps ); + delay_signal_float( hb_synth[n], output_frame, st->hb_prev_synth_buffer, tmps ); } else { diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index 8b7b8ce13..a82d2fcef 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -707,7 +707,7 @@ ivas_error create_cpe_dec( break; } - if ( ( st = (DEC_CORE_HANDLE) malloc( sizeof( Decoder_State ) ) ) == NULL ) + if ( ( st = (DEC_CORE_HANDLE_FLOAT) malloc( sizeof( Decoder_State ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CoreCoder structure\n" ) ); } diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 48d9012b1..06bcecf23 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -127,7 +127,7 @@ ivas_error ivas_dec( /* HP filtering */ for ( n = 0; n < min( nchan_out, st_ivas->nchan_transport ); n++ ) { - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } /* Rendering */ @@ -181,7 +181,7 @@ ivas_error ivas_dec( } /* HP filtering */ - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } /* Rendering */ @@ -334,7 +334,7 @@ ivas_error ivas_dec( /* HP filtering */ for ( n = 0; n < nchan_remapped; n++ ) { - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } if ( st_ivas->ivas_format == SBA_FORMAT ) { @@ -448,7 +448,7 @@ ivas_error ivas_dec( /* HP filtering */ for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } /* Rendering */ @@ -559,7 +559,7 @@ ivas_error ivas_dec( /* HP filtering */ for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } nchan_remapped = ivas_sba_remapTCs( &p_output[sba_ch_idx], st_ivas, output_frame ); @@ -644,7 +644,7 @@ ivas_error ivas_dec( { for ( n = 0; n < nchan_ism; n++ ) { - delay_signal( p_output[n], output_frame, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); + delay_signal_float( p_output[n], output_frame, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); } } @@ -686,7 +686,7 @@ ivas_error ivas_dec( { if ( n != LFE_CHANNEL ) { - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } } @@ -740,7 +740,7 @@ ivas_error ivas_dec( { if ( n != LFE_CHANNEL ) { - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } } @@ -806,7 +806,7 @@ ivas_error ivas_dec( /* HP filtering */ for ( n = 0; n < st_ivas->nchan_transport; n++ ) { - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } /* Rendering */ @@ -859,7 +859,8 @@ ivas_error ivas_dec( else if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe == 0 ) { /* Delay the separated channel to sync with the DirAC rendering */ - delay_signal( p_output[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); + delay_signal_float( p_output[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); + } } else @@ -888,7 +889,7 @@ ivas_error ivas_dec( /* HP filtering */ for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } /* Rendering */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 86643b646..ef3956759 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1935,7 +1935,7 @@ ivas_error ivas_init_decoder( *-------------------------------------------------------------------------*/ void destroy_core_dec( - DEC_CORE_HANDLE hCoreCoder /* i/o: core decoder structure */ + DEC_CORE_HANDLE_FLOAT hCoreCoder /* i/o: core decoder structure */ ) { destroy_cldfb_decoder( hCoreCoder ); diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index c4b07078d..eb48b62bc 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -45,9 +45,9 @@ * Local functions *-----------------------------------------------------------------------*/ -static void decode_angle_indices( DEC_CORE_HANDLE st0, ISM_METADATA_ANGLE_HANDLE angle, const int16_t non_diegetic_flag, int16_t *flag_abs_azimuth ); +static void decode_angle_indices( DEC_CORE_HANDLE_FLOAT st0, ISM_METADATA_ANGLE_HANDLE angle, const int16_t non_diegetic_flag, int16_t *flag_abs_azimuth ); -static int16_t decode_radius( DEC_CORE_HANDLE st0, int16_t *last_radius_idx, int16_t *flag_abs_radius ); +static int16_t decode_radius( DEC_CORE_HANDLE_FLOAT st0, int16_t *last_radius_idx, int16_t *flag_abs_radius ); /*-------------------------------------------------------------------------* @@ -149,7 +149,7 @@ ivas_error ivas_ism_metadata_dec( const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ int16_t *ism_extmeta_active, /* i/o: Extended metadata active in renderer */ int16_t *ism_extmeta_cnt, /* i/o: Number of change frames observed */ - DEC_CORE_HANDLE st0 /* i : core-coder handle */ + DEC_CORE_HANDLE_FLOAT st0 /* i : core-coder handle */ ) { int16_t ch, nb_bits_start = 0, last_bit_pos; @@ -703,7 +703,7 @@ ivas_error ivas_ism_metadata_dec_create( *-------------------------------------------------------------------------*/ static void decode_angle_indices( - DEC_CORE_HANDLE st0, /* i/o: bitstream handle */ + DEC_CORE_HANDLE_FLOAT st0, /* i/o: bitstream handle */ ISM_METADATA_ANGLE_HANDLE angle, /* i/o: angle handle */ const int16_t non_diegetic_flag, /* i : Non diegetic flag */ int16_t *flag_abs_angle1 /* o : Azimuth/yaw encoding mode */ @@ -857,7 +857,7 @@ static void decode_angle_indices( *-------------------------------------------------------------------------*/ static int16_t decode_radius( - DEC_CORE_HANDLE st0, /* i/o: bitstream handle */ + DEC_CORE_HANDLE_FLOAT st0, /* i/o: bitstream handle */ int16_t *last_radius_idx, /* i/o: last radius index */ int16_t *flag_abs_radius /* o : Radius encoding mode */ ) @@ -943,7 +943,7 @@ void ivas_ism_metadata_sid_dec( int16_t nBits_azimuth, nBits_elevation, nBits_coh, nBits_sce_id; int16_t md_diff_flag[MAX_NUM_OBJECTS]; ISM_MODE ism_mode_bstr; - DEC_CORE_HANDLE st0; + DEC_CORE_HANDLE_FLOAT st0; ISM_METADATA_HANDLE hIsmMetaData; int16_t next_bit_pos_orig; uint16_t bstr_meta[IVAS_SID_5k2 / FRAMES_PER_SEC], *bstr_orig; diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index ee99ce067..ace33f10c 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -518,7 +518,7 @@ void ivas_omasa_separate_object_render( for ( obj = 0; obj < num_objects; obj++ ) { - delay_signal( input_f[obj], output_frame, st_ivas->hMasaIsmData->delayBuffer[obj], st_ivas->hMasaIsmData->delayBuffer_size ); /* Delay the signal to match CLDFB delay */ + delay_signal_float( input_f[obj], output_frame, st_ivas->hMasaIsmData->delayBuffer[obj], st_ivas->hMasaIsmData->delayBuffer_size ); /* Delay the signal to match CLDFB delay */ for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) { @@ -664,7 +664,7 @@ void ivas_omasa_separate_object_render_jbm( int16_t tcBufferSize; tcBufferSize = hSpatParamRendCom->num_slots * hSpatParamRendCom->slot_size; - delay_signal( input_f[obj], tcBufferSize, st_ivas->hMasaIsmData->delayBuffer[obj], st_ivas->hMasaIsmData->delayBuffer_size ); + delay_signal_float( input_f[obj], tcBufferSize, st_ivas->hMasaIsmData->delayBuffer[obj], st_ivas->hMasaIsmData->delayBuffer_size ); } offsetSamples = 0; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 88f6e0468..45ee0f945 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -121,7 +121,7 @@ ivas_error ivas_jbm_dec_tc( /* HP filtering */ for ( n = 0; n < min( nchan_out, st_ivas->nchan_transport ); n++ ) { - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } if ( st_ivas->renderer_type == RENDERER_MC && st_ivas->hDecoderConfig->nchan_out == 1 ) @@ -174,7 +174,7 @@ ivas_error ivas_jbm_dec_tc( } /* HP filtering */ - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) @@ -270,7 +270,7 @@ ivas_error ivas_jbm_dec_tc( /* HP filtering */ for ( n = 0; n < nchan_remapped; n++ ) { - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } if ( st_ivas->ivas_format == SBA_FORMAT ) @@ -358,7 +358,7 @@ ivas_error ivas_jbm_dec_tc( /* HP filtering */ for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) @@ -450,7 +450,7 @@ ivas_error ivas_jbm_dec_tc( /* HP filtering */ for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } nchan_remapped = ivas_sba_remapTCs( &p_output[sba_ch_idx], st_ivas, output_frame ); @@ -501,7 +501,7 @@ ivas_error ivas_jbm_dec_tc( { if ( n != LFE_CHANNEL ) { - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } } @@ -542,7 +542,7 @@ ivas_error ivas_jbm_dec_tc( { if ( n != LFE_CHANNEL ) { - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } } @@ -584,7 +584,7 @@ ivas_error ivas_jbm_dec_tc( /* HP filtering */ for ( n = 0; n < st_ivas->nchan_transport; n++ ) { - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } /* Rendering */ @@ -633,7 +633,7 @@ ivas_error ivas_jbm_dec_tc( else if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe == 0 ) { /* Delay the separated channel to sync with the DirAC rendering */ - delay_signal( p_output[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); + delay_signal_float( p_output[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); } } else @@ -662,7 +662,7 @@ ivas_error ivas_jbm_dec_tc( /* HP filtering */ for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } if ( st_ivas->renderer_type == RENDERER_MCMASA_MONO_STEREO ) @@ -801,7 +801,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( { for ( n = 0; n < st_ivas->nchan_ism; n++ ) { - delay_signal( st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); + delay_signal_float( st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); } } diff --git a/lib_dec/ivas_lfe_dec.c b/lib_dec/ivas_lfe_dec.c index 441b33356..4acd85713 100644 --- a/lib_dec/ivas_lfe_dec.c +++ b/lib_dec/ivas_lfe_dec.c @@ -333,7 +333,7 @@ void ivas_lfe_dec( /* add delay to make overall max(block_offset, 11.5) */ if ( hLFE->lfe_addl_delay > 0 ) { - delay_signal( output_lfe_ch, output_frame, hLFE->lfe_delay_buf, hLFE->lfe_addl_delay ); + delay_signal_float( output_lfe_ch, output_frame, hLFE->lfe_delay_buf, hLFE->lfe_addl_delay ); } return; diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 73fca37fd..6ae62d779 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1507,7 +1507,7 @@ void ivas_spar_param_to_masa_param_mapping( float instEne; float inCovarianceMtx[FOA_CHANNELS][FOA_CHANNELS]; float foaCovarianceMtx[FOA_CHANNELS][FOA_CHANNELS]; - float Iy, Iz, Ix, E, azi, ele, I, ratio; + float Iy, Iz, Ix, E, azi, ele, I, ratio_float; float diffuseGainX, diffuseGainY, diffuseGainZ, diffuseGainSum; int16_t slot_idx, slot_idx_start, sf; SPAR_DEC_HANDLE hSpar; @@ -1654,13 +1654,13 @@ void ivas_spar_param_to_masa_param_mapping( E = ( foaCovarianceMtx[0][0] + foaCovarianceMtx[1][1] + foaCovarianceMtx[2][2] + foaCovarianceMtx[3][3] ) / 2.0f; /* Overall energy */ azi = atan2f( Iy, Ix ); /* Azimuth */ ele = atan2f( Iz, sqrtf( Ix * Ix + Iy * Iy ) ); /* Elevation */ - ratio = I / fmaxf( 1e-12f, E ); /* Energy ratio */ - ratio = fmaxf( 0.0f, fminf( 1.0f, ratio ) ); + ratio_float = I / fmaxf( 1e-12f, E ); /* Energy ratio */ + ratio_float = fmaxf( 0.0f, fminf( 1.0f, ratio_float ) ); hSpatParamRendCom->azimuth[dirac_write_idx][bin] = (int16_t) roundf( azi / PI_OVER_180 ); hSpatParamRendCom->elevation[dirac_write_idx][bin] = (int16_t) roundf( ele / PI_OVER_180 ); - hSpatParamRendCom->energy_ratio1[dirac_write_idx][bin] = ratio; - hSpatParamRendCom->diffuseness_vector[dirac_write_idx][bin] = 1.0f - ratio; + hSpatParamRendCom->energy_ratio1[dirac_write_idx][bin] = ratio_float; + hSpatParamRendCom->diffuseness_vector[dirac_write_idx][bin] = 1.0f - ratio_float; hSpatParamRendCom->spreadCoherence[dirac_write_idx][bin] = 0.0f; hSpatParamRendCom->surroundingCoherence[dirac_write_idx][bin] = 0.0f; diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 26a655425..4b0501697 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -687,7 +687,7 @@ static void paramupmix_td_decorr_process_jbm( for ( k = 0; k < MC_PARAMUPMIX_COMBINATIONS; k++ ) { mvr2r( pcm_in[k], pp_out_pcm[k], output_frame ); - delay_signal( pp_out_pcm[k], output_frame, hTdDecorr[k]->look_ahead_buf, offset ); + delay_signal_float( pp_out_pcm[k], output_frame, hTdDecorr[k]->look_ahead_buf, offset ); /* In ducking gains */ if ( hTdDecorr[k]->ducking_flag ) @@ -1118,7 +1118,7 @@ static void paramupmix_td_decorr_process( for ( k = 0; k < MC_PARAMUPMIX_COMBINATIONS; k++ ) { mvr2r( pcm_in[k], pp_out_pcm[k], output_frame ); - delay_signal( pp_out_pcm[k], output_frame, hTdDecorr[k]->look_ahead_buf, offset ); + delay_signal_float( pp_out_pcm[k], output_frame, hTdDecorr[k]->look_ahead_buf, offset ); /* In ducking gains */ if ( hTdDecorr[k]->ducking_flag ) diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 0f9d1c66c..eb6074776 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -117,7 +117,7 @@ static void dec_prm_tcx_sidebits( /* Init LTP data */ st->hTcxDec->tcx_hm_LtpPitchLag = -1; - st->hTcxLtpDec->tcxltp_gain = 0.0f; + st->hTcxLtpDec->tcxltp_gain_float = 0.0f; /*--------------------------------------------------------------------------------* * Header @@ -525,9 +525,9 @@ void ivas_mdct_core_invQ( { L_frameTCX[0] = sts[0]->L_frameTCX_past; L_frameTCX[1] = sts[1]->L_frameTCX_past; - mvr2r( sts[0]->hTonalMDCTConc->lastBlockData.spectralData, tmp_ms_sig[0], L_frameTCX[0] ); - mvr2r( sts[1]->hTonalMDCTConc->lastBlockData.spectralData, tmp_ms_sig[1], L_frameTCX[0] ); - stereo_decoder_tcx( hCPE->hStereoMdct, ms_mask, x_0[1], &sts[0]->hTonalMDCTConc->lastBlockData.spectralData, &sts[1]->hTonalMDCTConc->lastBlockData.spectralData, &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 1 ); + mvr2r( sts[0]->hTonalMDCTConc->lastBlockData.spectralData_float, tmp_ms_sig[0], L_frameTCX[0] ); + mvr2r( sts[1]->hTonalMDCTConc->lastBlockData.spectralData_float, tmp_ms_sig[1], L_frameTCX[0] ); + stereo_decoder_tcx( hCPE->hStereoMdct, ms_mask, x_0[1], &sts[0]->hTonalMDCTConc->lastBlockData.spectralData_float, &sts[1]->hTonalMDCTConc->lastBlockData.spectralData_float, &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 1 ); } if ( bfi ) @@ -646,8 +646,8 @@ void ivas_mdct_core_invQ( } } - mvr2r( tmp_ms_sig[0], sts[0]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[0] ); - mvr2r( tmp_ms_sig[1], sts[1]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[0] ); + mvr2r( tmp_ms_sig[0], sts[0]->hTonalMDCTConc->lastBlockData.spectralData_float, L_frameTCX[0] ); + mvr2r( tmp_ms_sig[1], sts[1]->hTonalMDCTConc->lastBlockData.spectralData_float, L_frameTCX[0] ); } /*--------------------------------------------------------------------------------* @@ -707,9 +707,9 @@ void ivas_mdct_core_invQ( { set_f( x[ch][0], 0.f, st->hTcxCfg->tcx_coded_lines ); /* usually set in decoder_tcx_invQ(), needed for concealment */ - st->hTcxDec->damping = 0.f; - st->hTcxDec->gainHelper = 1.f; - st->hTcxDec->stepCompensate = 0.f; + st->hTcxDec->damping_float = 0.f; + st->hTcxDec->gainHelper_float = 1.f; + st->hTcxDec->stepCompensate_float = 0.f; continue; } @@ -751,7 +751,7 @@ void ivas_mdct_core_invQ( if ( bfi && !MCT_flag ) { - TonalMdctConceal_create_concealment_noise( concealment_noise[ch], hCPE, L_frameTCX[ch], L_frame[ch], ch, k, st->core, st->hTcxDec->cummulative_damping_tcx, noise_gen_mode_bfi ); + TonalMdctConceal_create_concealment_noise( concealment_noise[ch], hCPE, L_frameTCX[ch], L_frame[ch], ch, k, st->core, st->hTcxDec->cummulative_damping_tcx_float, noise_gen_mode_bfi ); } decoder_tcx_noisefilling( st, concealment_noise[ch], Aq[ch], L_frameTCX_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], NULL, &tmp_concealment_method, gain_tcx, prm_sqQ, nf_seed, bfi, MCT_flag, k ); @@ -821,7 +821,7 @@ void ivas_mdct_core_reconstruct( nSubframes[ch] = ( st->core == TCX_20_CORE ) ? 1 : NB_DIV; synth = synth_buf + st->hTcxDec->old_synth_len; synthFB = synth_bufFB + st->hTcxDec->old_synth_lenFB; - mvr2r( st->hTcxDec->old_synth, synth_buf, st->hTcxDec->old_synth_len ); + mvr2r( st->hTcxDec->old_synth_float, synth_buf, st->hTcxDec->old_synth_len ); mvr2r( st->hTcxDec->old_synthFB, synth_bufFB, st->hTcxDec->old_synth_lenFB ); set_zero( synth, L_FRAME_PLUS + M ); set_zero( synthFB, L_FRAME_PLUS + M ); @@ -891,7 +891,7 @@ void ivas_mdct_core_reconstruct( if ( bfi && st->last_core != ACELP_CORE && st->core == ACELP_CORE ) { /* Update FEC_scale_syn parameters */ - if ( st->hTcxLtpDec->tcxltp_gain == 0 ) + if ( st->hTcxLtpDec->tcxltp_gain_float == 0 ) { fer_energy( st->L_frame, UNVOICED, synth, (float) ( st->L_frame / 2 ), &st->enr_old, st->L_frame ); } @@ -902,7 +902,7 @@ void ivas_mdct_core_reconstruct( } /* Update */ - mvr2r( synth_buf + st->L_frame, st->hTcxDec->old_synth, st->hTcxDec->old_synth_len ); + mvr2r( synth_buf + st->L_frame, st->hTcxDec->old_synth_float, st->hTcxDec->old_synth_len ); mvr2r( st->hTcxDec->old_synthFB + st->hTcxDec->L_frameTCX - NS2SA( st->output_Fs, PH_ECU_MEM_NS ), st->hTcxDec->synth_history, NS2SA( st->output_Fs, PH_ECU_MEM_NS ) ); mvr2r( synth_bufFB + st->hTcxDec->L_frameTCX, st->hTcxDec->old_synthFB, st->hTcxDec->old_synth_lenFB ); if ( st->hHQ_core != NULL ) @@ -1026,12 +1026,12 @@ void ivas_mdct_core_tns_ns( { if ( st->hTonalMDCTConc != NULL ) { - if ( !MCT_flag && st->hTcxDec->cummulative_damping_tcx != 1.f ) + if ( !MCT_flag && st->hTcxDec->cummulative_damping_tcx_float != 1.f ) { float *scf_last, *scf_bg; float fade_in, fade_out; - scf_last = &st->hTonalMDCTConc->lastBlockData.scaleFactors[0]; + scf_last = &st->hTonalMDCTConc->lastBlockData.scaleFactors_float[0]; scf_bg = &st->hTonalMDCTConc->scaleFactorsBackground[0]; st->hTonalMDCTConc->scf_fadeout *= 0.95f; @@ -1047,7 +1047,7 @@ void ivas_mdct_core_tns_ns( else { st->hTonalMDCTConc->scf_fadeout = 1.0f; - mvr2r( st->hTonalMDCTConc->lastBlockData.scaleFactors, &sns_int_scf[0], st->hTonalMDCTConc->nScaleFactors ); + mvr2r( st->hTonalMDCTConc->lastBlockData.scaleFactors_float, &sns_int_scf[0], st->hTonalMDCTConc->nScaleFactors ); } } } @@ -1067,7 +1067,7 @@ void ivas_mdct_core_tns_ns( if ( ( bfi || MCT_flag ) && st->hTonalMDCTConc != NULL ) { - TonalMDCTConceal_UpdateState( st->hTonalMDCTConc, L_frameTCX[ch], ( st->hTcxDec->tcxltp_last_gain_unmodified > 0 ) ? st->old_fpitch : 0, bfi, bfi && st->tonal_mdct_plc_active ); + TonalMDCTConceal_UpdateState( st->hTonalMDCTConc, L_frameTCX[ch], ( st->hTcxDec->tcxltp_last_gain_unmodified_float > 0 ) ? st->old_fpitch : 0, bfi, bfi && st->tonal_mdct_plc_active ); } } diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index dfa867ac0..3056a56d7 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -684,7 +684,7 @@ ivas_error ivas_omasa_dirac_td_binaural( for ( n = 0; n < st_ivas->nchan_ism; n++ ) { - delay_signal( data_separated_objects[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); + delay_signal_float( data_separated_objects[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); } ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, output, st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -741,7 +741,7 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( { tc_local[n] = st_ivas->hTcBuffer->tc[n + 2]; v_multc( tc_local[n], gain, tc_local[n], tcBufferSize ); - delay_signal( tc_local[n], tcBufferSize, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); + delay_signal_float( tc_local[n], tcBufferSize, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); } } diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 8da8628e9..782ef61f5 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -188,7 +188,7 @@ ivas_error ivas_osba_dirac_td_binaural( { for ( n = 0; n < st_ivas->nchan_ism; n++ ) { - delay_signal( data_separated_objects[n], output_frame, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); + delay_signal_float( data_separated_objects[n], output_frame, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); } } @@ -283,7 +283,7 @@ ivas_error ivas_osba_render( for ( n = 0; n < nchan_ism; n++ ) { mvr2r( output_f[n], tmp_ism_out[n], output_frame ); - delay_signal( tmp_ism_out[n], output_frame, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); + delay_signal_float( tmp_ism_out[n], output_frame, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); } if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI ) diff --git a/lib_dec/ivas_post_proc.c b/lib_dec/ivas_post_proc.c index 08d1d25ab..728242c0e 100644 --- a/lib_dec/ivas_post_proc.c +++ b/lib_dec/ivas_post_proc.c @@ -94,16 +94,16 @@ void ivas_post_proc( if ( !( sts[n]->element_mode == IVAS_CPE_DFT && hCPE->nchan_out == 1 && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) && sts[n]->element_mode != IVAS_CPE_MDCT ) { - mvr2r( sts[n]->prev_synth_buffer, sts[n]->hTcxDec->FBTCXdelayBuf, 0 ); - mvr2r( sts[n]->delay_buf_out, sts[n]->hTcxDec->FBTCXdelayBuf + 0, delay_comp ); + mvr2r( sts[n]->prev_synth_buffer, sts[n]->hTcxDec->FBTCXdelayBuf_float, 0 ); + mvr2r( sts[n]->delay_buf_out, sts[n]->hTcxDec->FBTCXdelayBuf_float + 0, delay_comp ); } else if ( sba_dirac_stereo_flag && sts[n]->element_mode == IVAS_CPE_MDCT ) { int16_t numZeros = (int16_t) ( NS2SA( output_Fs, N_ZERO_MDCT_NS ) ); - mvr2r( sts[n]->hHQ_core->old_out + numZeros, sts[n]->hTcxDec->FBTCXdelayBuf, delay_comp ); + mvr2r( sts[n]->hHQ_core->old_out + numZeros, sts[n]->hTcxDec->FBTCXdelayBuf_float, delay_comp ); } - tcx_ltp_post( sts[n], hTcxLtpDec, sts[n]->core, output_frame, NS2SA( output_Fs, ACELP_LOOK_NS ) + delay_comp, synth, sts[n]->hTcxDec->FBTCXdelayBuf ); + tcx_ltp_post( sts[n], hTcxLtpDec, sts[n]->core, output_frame, NS2SA( output_Fs, ACELP_LOOK_NS ) + delay_comp, synth, sts[n]->hTcxDec->FBTCXdelayBuf_float ); } } } @@ -123,7 +123,7 @@ void ivas_post_proc( hTcxLtpDec = hCPE->hStereoDft->hTcxLtpDec; /* copy LTP side-info of downmix channel also to right channel struct */ hTcxLtpDec->tcxltp = sts[0]->hTcxLtpDec->tcxltp; - hTcxLtpDec->tcxltp_gain = sts[0]->hTcxLtpDec->tcxltp_gain; + hTcxLtpDec->tcxltp_gain_float = sts[0]->hTcxLtpDec->tcxltp_gain_float; hTcxLtpDec->tcxltp_pitch_int = sts[0]->hTcxLtpDec->tcxltp_pitch_int; hTcxLtpDec->tcxltp_pitch_fr = sts[0]->hTcxLtpDec->tcxltp_pitch_fr; /* revert update of pit_res_max_past to have correct value also in right channel */ @@ -479,7 +479,7 @@ void stereo_dft_dec_core_switching( predelay = NS2SA( st->sr_core, DELAY_BWE_TOTAL_NS ); /* apply predelay to have same overall filter delay for all cases */ - delay_signal( pAp_input, st->L_frame, hCPE->hStereoDft->ap_delay_mem, predelay ); + delay_signal_float( pAp_input, st->L_frame, hCPE->hStereoDft->ap_delay_mem, predelay ); /* input zeroes for transient frames */ diff --git a/lib_dec/ivas_range_uni_dec.c b/lib_dec/ivas_range_uni_dec.c index 70ce6b84e..addccb979 100644 --- a/lib_dec/ivas_range_uni_dec.c +++ b/lib_dec/ivas_range_uni_dec.c @@ -145,9 +145,9 @@ uint16_t rc_uni_dec_read_symbol_fastS( sym_end = alphabet_size; /* the possible values are {sym_begin, .., sym_end - 1} */ /* ceil(log2(x)) = 1 + floor(log2(x - 1)), for any x >= 2 */ - /* floor(log2(y)) = 31 - norm_ul(y) = 30 - norm_l(y), for any 1 <= y <= 2 ^ 31 - 1 */ + /* floor(log2(y)) = 31 - norm_ul_float(y) = 30 - norm_l(y), for any 1 <= y <= 2 ^ 31 - 1 */ ceil_log2_alphabet_size = 31 - norm_l( alphabet_size - 1 ); - /* completely equivalent with 32 - norm_ul(alphabet_size - 1), but norm_l is faster */ + /* completely equivalent with 32 - norm_ul_float(alphabet_size - 1), but norm_l is faster */ reversed_low = ( range << tot_shift ) - low; /* at most ceil_log2_alphabet_size steps are needed so that sym_end - sym_begin == 1 */ @@ -403,9 +403,9 @@ int16_t rc_uni_dec_finish( int16_t bits; /* floor(log2(x)) = floor(log2(x >> 24)) + 24, for any x >= 2 ^ 24 */ - /* 32 - floor(log2(y)) = norm_ul(y) + 1 = norm_l(y >> 24) - 22 */ + /* 32 - floor(log2(y)) = norm_ul_float(y) + 1 = norm_l(y >> 24) - 22 */ bits = norm_l( rc_st_dec->rc_range >> 24 ) - 22; /* bits = 32 - floor(log2(rc_range)) */ - /* completely equivalent with norm_ul(rc_st_enc->rc_range) + 1, but norm_l is faster */ + /* completely equivalent with norm_ul_float(rc_st_enc->rc_range) + 1, but norm_l is faster */ bits++; /* conservative number of bits, because the decoder only has rc_range available */ diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index 752ce0e95..96f69a8b7 100644 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -254,13 +254,13 @@ ivas_error ivas_sce_dec( * LB synthesis synchronization between IVAS formats *----------------------------------------------------------------*/ - delay_signal( output[0], output_frame, st->prev_synth_buffer, NS2SA( output_Fs, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ) ); + delay_signal_float( output[0], output_frame, st->prev_synth_buffer, NS2SA( output_Fs, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ) ); /*----------------------------------------------------------------* * HB synthesis synchronization between IVAS formats *----------------------------------------------------------------*/ - delay_signal( outputHB[0], output_frame, hSCE->prev_hb_synth, NS2SA( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ) ); + delay_signal_float( outputHB[0], output_frame, hSCE->prev_hb_synth, NS2SA( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ) ); /*----------------------------------------------------------------* * output LB and HB mix @@ -326,7 +326,7 @@ ivas_error create_sce_dec( * Core Coder, 1 instance: allocate and initialize *-----------------------------------------------------------------*/ - if ( ( st = (DEC_CORE_HANDLE) malloc( sizeof( Decoder_State ) ) ) == NULL ) + if ( ( st = (DEC_CORE_HANDLE_FLOAT) malloc( sizeof( Decoder_State ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CoreCoder structure\n" ) ); } diff --git a/lib_dec/ivas_sns_dec.c b/lib_dec/ivas_sns_dec.c index 18eb18e78..775494013 100644 --- a/lib_dec/ivas_sns_dec.c +++ b/lib_dec/ivas_sns_dec.c @@ -273,11 +273,11 @@ void dequantize_sns( } nStages = SNS_MSVQ_NSTAGES_SIDE; - msvq_dec( side_cdbks, NULL, NULL, nStages, M, M, &indices[ch][idxIndices + SNS_STEREO_MODE_OFFSET_INDICES], 0, NULL, snsQ, NULL ); + msvq_dec_float( side_cdbks, NULL, NULL, nStages, M, M, &indices[ch][idxIndices + SNS_STEREO_MODE_OFFSET_INDICES], 0, NULL, snsQ, NULL ); } else { - msvq_dec( cdbks, NULL, NULL, nStages, M, M, &indices[ch][idxIndices + SNS_STEREO_MODE_OFFSET_INDICES], 0, NULL, snsQ, NULL ); + msvq_dec_float( cdbks, NULL, NULL, nStages, M, M, &indices[ch][idxIndices + SNS_STEREO_MODE_OFFSET_INDICES], 0, NULL, snsQ, NULL ); } idxIndices += nStages; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index b4eef45cc..33231c298 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -683,7 +683,7 @@ typedef struct sce_dec_data_structure int32_t last_element_brate; /* SCE last total bitrate in bps */ /* core coder handle */ - DEC_CORE_HANDLE hCoreCoder[1]; + DEC_CORE_HANDLE_FLOAT hCoreCoder[1]; float prev_hb_synth[NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS )]; /* HB synthesis synchro buffer */ @@ -711,7 +711,7 @@ typedef struct cpe_dec_data_structure float lt_es_em; /* core coder handle */ - DEC_CORE_HANDLE hCoreCoder[CPE_CHANNELS]; + DEC_CORE_HANDLE_FLOAT hCoreCoder[CPE_CHANNELS]; /* stereo data handles */ STEREO_DFT_DEC_DATA_HANDLE hStereoDft; /* DFT stereo data structure */ diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 91a560cb2..e93a7fda0 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -394,7 +394,7 @@ static void stereo_dft_generate_comfort_noise( } /* Update CNG noise level from MS noise estimation */ - mvr2r( st->hFdCngDec->bandNoiseShape, cngNoiseLevel_hist, hFdCngCom->stopFFTbin - hFdCngCom->startBand ); + mvr2r( st->hFdCngDec->bandNoiseShape_float, cngNoiseLevel_hist, hFdCngCom->stopFFTbin - hFdCngCom->startBand ); ptr_cng = cngNoiseLevel_hist; for ( i = 0; i < ( st->last_L_frame - hFdCngCom->startBand ) / 2; i++ ) { @@ -522,11 +522,11 @@ static void stereo_dft_generate_comfort_noise( j = 0; for ( k = 0; k < ( hFdCngCom->nFFTpart - 2 ); k++ ) { - factor = ( hFdCngCom->sidNoiseEstLp[k] + DELTA ) / ( st->hFdCngDec->partNoiseShape[k] + DELTA ); + factor = ( hFdCngCom->sidNoiseEstLp[k] + DELTA ) / ( st->hFdCngDec->partNoiseShape_float[k] + DELTA ); factor = min( hStereoDft->scale + ( 1 / MAX_K ) * ( factor - hStereoDft->scale ) * hStereoCng->xfade_frame_counter, factor ); for ( ; j <= hFdCngCom->part[k]; j++ ) { - hFdCngCom->cngNoiseLevel[j] = st->hFdCngDec->bandNoiseShape[j] * factor; + hFdCngCom->cngNoiseLevel[j] = st->hFdCngDec->bandNoiseShape_float[j] * factor; } } } @@ -589,9 +589,9 @@ static void stereo_dft_generate_comfort_noise( } else if ( chan == 0 ) { - st->hFdCngDec->lp_noise = 0.9f * st->hFdCngDec->lp_noise + 0.1f * 10.f * log10f( lp_noise + DELTA ); - st->lp_noise = st->hFdCngDec->lp_noise; - st->hFdCngDec->hFdCngCom->flag_noisy_speech = ( st->hFdCngDec->lp_speech - st->hFdCngDec->lp_noise ) < 28.f; + st->hFdCngDec->lp_noise_float = 0.9f * st->hFdCngDec->lp_noise_float + 0.1f * 10.f * log10f( lp_noise + DELTA ); + st->lp_noise = st->hFdCngDec->lp_noise_float; + st->hFdCngDec->hFdCngCom->flag_noisy_speech = ( st->hFdCngDec->lp_speech_float - st->hFdCngDec->lp_noise_float ) < 28.f; st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = 0.99f * st->hFdCngDec->hFdCngCom->likelihood_noisy_speech + 0.01f * st->hFdCngDec->hFdCngCom->flag_noisy_speech; } @@ -627,10 +627,10 @@ static void stereo_dft_generate_comfort_noise( } /* update msNoiseEst in SID and NO_DATA frames */ - bandcombinepow( &st->hFdCngDec->smoothed_psd[hFdCngCom->startBand], hFdCngCom->stopFFTbin - hFdCngCom->startBand, st->hFdCngDec->part_shaping, st->hFdCngDec->nFFTpart_shaping, st->hFdCngDec->psize_inv_shaping, st->hFdCngDec->msNoiseEst ); + bandcombinepow( &st->hFdCngDec->smoothed_psd[hFdCngCom->startBand], hFdCngCom->stopFFTbin - hFdCngCom->startBand, st->hFdCngDec->part_shaping, st->hFdCngDec->nFFTpart_shaping, st->hFdCngDec->psize_inv_shaping_float, st->hFdCngDec->msNoiseEst_float); st->hFdCngDec->first_cna_noise_updated = 1; - mvr2r( st->hFdCngDec->msNoiseEst, st->hFdCngDec->msPeriodog_ST, st->hFdCngDec->nFFTpart_shaping ); + mvr2r( st->hFdCngDec->msNoiseEst_float, st->hFdCngDec->msPeriodog_ST, st->hFdCngDec->nFFTpart_shaping ); st->hFdCngDec->ms_last_inactive_bwidth = st->bwidth; } diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c index 20a6e3e5b..a22d7af07 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec.c +++ b/lib_dec/ivas_stereo_mdct_core_dec.c @@ -323,7 +323,7 @@ void stereo_mdct_core_dec( } } - TonalMDCTConceal_UpdateState( st->hTonalMDCTConc, L_frameTCX[ch], ( st->hTcxDec->tcxltp_last_gain_unmodified > 0 ) ? st->old_fpitch : 0, bfi, bfi && st->tonal_mdct_plc_active ); + TonalMDCTConceal_UpdateState( st->hTonalMDCTConc, L_frameTCX[ch], ( st->hTcxDec->tcxltp_last_gain_unmodified_float > 0 ) ? st->old_fpitch : 0, bfi, bfi && st->tonal_mdct_plc_active ); } mvs2s( ms_mask[0], hCPE->hStereoMdct->prev_ms_mask[0], MAX_SFB ); @@ -629,7 +629,7 @@ static void run_min_stats( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = 0.99f * st->hFdCngDec->hFdCngCom->likelihood_noisy_speech + 0.01f * (float) st->hFdCngDec->hFdCngCom->flag_noisy_speech; - st->lp_noise = st->hFdCngDec->lp_noise; + st->lp_noise = st->hFdCngDec->lp_noise_float; } if ( will_estimate_noise_on_channel[0] || will_estimate_noise_on_channel[1] || st->bfi ) diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index 7373bc781..11874d39e 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -434,7 +434,7 @@ ivas_error initMdctStereoDtxData( for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { - DEC_CORE_HANDLE st = hCPE->hCoreCoder[ch]; + DEC_CORE_HANDLE_FLOAT st = hCPE->hCoreCoder[ch]; if ( st->hFdCngDec == NULL ) { @@ -583,21 +583,21 @@ void updateBuffersForDmxMdctStereo( for ( i = 0; i < tcxltp_mem_in_len; i++ ) { - sts[0]->hTcxLtpDec->tcxltp_mem_in[i] = INV_SQRT2 * ( sts[0]->hTcxLtpDec->tcxltp_mem_in[i] + sts[1]->hTcxLtpDec->tcxltp_mem_in[i] ); + sts[0]->hTcxLtpDec->tcxltp_mem_in_float[i] = INV_SQRT2 * ( sts[0]->hTcxLtpDec->tcxltp_mem_in_float[i] + sts[1]->hTcxLtpDec->tcxltp_mem_in_float[i] ); sts[0]->delay_buf_out[i] = INV_SQRT2 * ( sts[0]->delay_buf_out[i] + sts[1]->delay_buf_out[i] ); sts[0]->hHQ_core->old_out[i] = INV_SQRT2 * ( sts[0]->hHQ_core->old_out[i] + sts[1]->hHQ_core->old_out[i] ); - sts[0]->hTcxLtpDec->tcxltp_mem_out[i] = INV_SQRT2 * ( sts[0]->hTcxLtpDec->tcxltp_mem_out[i] + sts[1]->hTcxLtpDec->tcxltp_mem_out[i] ); + sts[0]->hTcxLtpDec->tcxltp_mem_out_float[i] = INV_SQRT2 * ( sts[0]->hTcxLtpDec->tcxltp_mem_out_float[i] + sts[1]->hTcxLtpDec->tcxltp_mem_out_float[i] ); } for ( ; i < delay_buf_out_len; i++ ) { sts[0]->delay_buf_out[i] = INV_SQRT2 * ( sts[0]->delay_buf_out[i] + sts[1]->delay_buf_out[i] ); sts[0]->hHQ_core->old_out[i] = INV_SQRT2 * ( sts[0]->hHQ_core->old_out[i] + sts[1]->hHQ_core->old_out[i] ); - sts[0]->hTcxLtpDec->tcxltp_mem_out[i] = INV_SQRT2 * ( sts[0]->hTcxLtpDec->tcxltp_mem_out[i] + sts[1]->hTcxLtpDec->tcxltp_mem_out[i] ); + sts[0]->hTcxLtpDec->tcxltp_mem_out_float[i] = INV_SQRT2 * ( sts[0]->hTcxLtpDec->tcxltp_mem_out_float[i] + sts[1]->hTcxLtpDec->tcxltp_mem_out_float[i] ); } for ( ; i < output_frame; i++ ) { sts[0]->hHQ_core->old_out[i] = INV_SQRT2 * ( sts[0]->hHQ_core->old_out[i] + sts[1]->hHQ_core->old_out[i] ); - sts[0]->hTcxLtpDec->tcxltp_mem_out[i] = INV_SQRT2 * ( sts[0]->hTcxLtpDec->tcxltp_mem_out[i] + sts[1]->hTcxLtpDec->tcxltp_mem_out[i] ); + sts[0]->hTcxLtpDec->tcxltp_mem_out_float[i] = INV_SQRT2 * ( sts[0]->hTcxLtpDec->tcxltp_mem_out_float[i] + sts[1]->hTcxLtpDec->tcxltp_mem_out_float[i] ); } } diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 681effb0b..2628d53fa 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -55,7 +55,7 @@ *-------------------------------------------------------------------*/ static ivas_error allocate_CoreCoder_TCX( - DEC_CORE_HANDLE st /* i/o: Core decoder state structure */ + DEC_CORE_HANDLE_FLOAT st /* i/o: Core decoder state structure */ ) { if ( st->hTcxDec == NULL ) @@ -67,8 +67,8 @@ static ivas_error allocate_CoreCoder_TCX( reset_tcx_overl_buf( st->hTcxDec ); - set_zero( st->hTcxDec->syn_OverlFB, L_FRAME48k / 2 ); - set_zero( st->hTcxDec->old_synth, OLD_SYNTH_INTERNAL_DEC ); + set_zero( st->hTcxDec->syn_OverlFB_float, L_FRAME48k / 2 ); + set_zero( st->hTcxDec->old_synth_float, OLD_SYNTH_INTERNAL_DEC ); set_zero( st->hTcxDec->synth_history, L_PROT48k + L_FRAME48k ); } @@ -135,7 +135,7 @@ static ivas_error allocate_CoreCoder_TCX( *-------------------------------------------------------------------*/ static ivas_error allocate_CoreCoder( - DEC_CORE_HANDLE st /* i/o: Core decoder state structure */ + DEC_CORE_HANDLE_FLOAT st /* i/o: Core decoder state structure */ ) { ivas_error error; @@ -222,7 +222,7 @@ static ivas_error allocate_CoreCoder( *-------------------------------------------------------------------*/ static void deallocate_CoreCoder_TCX( - DEC_CORE_HANDLE st /* i/o: Core decoder state structure */ + DEC_CORE_HANDLE_FLOAT st /* i/o: Core decoder state structure */ ) { if ( st->hTcxDec != NULL ) @@ -260,7 +260,7 @@ static void deallocate_CoreCoder_TCX( *-------------------------------------------------------------------*/ static void deallocate_CoreCoder( - DEC_CORE_HANDLE st /* i/o: Core decoder state structure */ + DEC_CORE_HANDLE_FLOAT st /* i/o: Core decoder state structure */ ) { if ( st->hGSCDec != NULL ) @@ -324,11 +324,11 @@ static void cpy_tcx_ltp_data( { hTcxLtpDecNew->tcxltp_pitch_int_post_prev = hTcxLtpDecOld->tcxltp_pitch_int_post_prev; hTcxLtpDecNew->tcxltp_pitch_fr_post_prev = hTcxLtpDecOld->tcxltp_pitch_fr_post_prev; - hTcxLtpDecNew->tcxltp_gain_post_prev = hTcxLtpDecOld->tcxltp_gain_post_prev; + hTcxLtpDecNew->tcxltp_gain_post_prev_float = hTcxLtpDecOld->tcxltp_gain_post_prev_float; hTcxLtpDecNew->tcxltp_filt_idx_prev = hTcxLtpDecOld->tcxltp_filt_idx_prev; - mvr2r( hTcxLtpDecOld->tcxltp_mem_in, hTcxLtpDecNew->tcxltp_mem_in, (int16_t) ( ( TCXLTP_MAX_DELAY * output_Fs ) / 48000 ) ); - mvr2r( hTcxLtpDecOld->tcxltp_mem_out, hTcxLtpDecNew->tcxltp_mem_out, (int16_t) ( ( L_FRAME48k * output_Fs ) / 48000 ) ); + mvr2r( hTcxLtpDecOld->tcxltp_mem_in_float, hTcxLtpDecNew->tcxltp_mem_in_float, (int16_t) ( ( TCXLTP_MAX_DELAY * output_Fs ) / 48000 ) ); + mvr2r( hTcxLtpDecOld->tcxltp_mem_out_float, hTcxLtpDecNew->tcxltp_mem_out_float, (int16_t) ( ( L_FRAME48k * output_Fs ) / 48000 ) ); return; } @@ -350,7 +350,7 @@ ivas_error stereo_memory_dec( const int16_t nchan_transport /* i : number of transport channels*/ ) { - DEC_CORE_HANDLE st; + DEC_CORE_HANDLE_FLOAT st; int16_t i, n, delay_comp_DFT; ivas_error error; @@ -736,10 +736,10 @@ ivas_error stereo_memory_dec( if ( hCPE->last_element_mode == IVAS_CPE_TD ) { - mvr2r( tmpF_buff, st->hTcxDec->old_syn_Overl, L_FRAME16k / 2 ); + mvr2r( tmpF_buff, st->hTcxDec->old_syn_Overl_float, L_FRAME16k / 2 ); } - set_f( st->hTcxDec->FBTCXdelayBuf, 0.0f, 111 ); + set_f( st->hTcxDec->FBTCXdelayBuf_float, 0.0f, 111 ); st->hTcxDec->old_synthFB = st->hTcxDec->synth_history + NS2SA( st->output_Fs, PH_ECU_MEM_NS ); st->hTcxDec->prev_good_synth = st->hTcxDec->old_synthFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ); @@ -1108,8 +1108,8 @@ void synchro_synthesis( if ( use_cldfb_for_last_dft ) { /* delay CLDFB-based mono output (<= 24.4 kbps) to be aligned with DFT-based mono output (32 kbps), needed to avoid discontinuities with TCX-LTP. */ - mvr2r( sts[0]->prev_synth_buffer + delay_comp_DFT, hCPE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf, delay_diff ); - delay_signal( output[0], output_frame, hCPE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf, delay_diff ); + mvr2r( sts[0]->prev_synth_buffer + delay_comp_DFT, hCPE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_float, delay_diff ); + delay_signal_float( output[0], output_frame, hCPE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_float, delay_diff ); } if ( hCPE->element_mode != IVAS_CPE_MDCT ) @@ -1122,17 +1122,17 @@ void synchro_synthesis( { if ( sba_dirac_stereo_flag ) { - delay_signal( output[n], output_frame, hCPE->prev_synth[n], delay_comp_DFT ); + delay_signal_float( output[n], output_frame, hCPE->prev_synth[n], delay_comp_DFT ); } else { - delay_signal( output[n], output_frame, sts[n]->prev_synth_buffer, delay_comp_DFT ); + delay_signal_float( output[n], output_frame, sts[n]->prev_synth_buffer, delay_comp_DFT ); } } if ( use_cldfb_for_last_dft ) { - mvr2r( hCPE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf, sts[0]->prev_synth_buffer + delay_comp_DFT, delay_diff ); + mvr2r( hCPE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_float, sts[0]->prev_synth_buffer + delay_comp_DFT, delay_diff ); } /* handling of TD->DFT switching */ @@ -1304,15 +1304,15 @@ void synchro_synthesis( { if ( hCPE->element_mode == IVAS_CPE_MDCT ) { - mvr2r( sts[n]->prev_synth_buffer + delay_comp_DFT, hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf, delay_diff ); - delay_signal( output[n], output_frame, hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf, delay_diff ); + mvr2r( sts[n]->prev_synth_buffer + delay_comp_DFT, hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float, delay_diff ); + delay_signal_float( output[n], output_frame, hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float, delay_diff ); ivas_post_proc( NULL, hCPE, n, output[n], output, output_frame, 0 ); - delay_signal( output[n], output_frame, sts[n]->prev_synth_buffer, delay_comp_DFT ); - mvr2r( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf, sts[n]->prev_synth_buffer + delay_comp_DFT, delay_diff ); + delay_signal_float( output[n], output_frame, sts[n]->prev_synth_buffer, delay_comp_DFT ); + mvr2r( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float, sts[n]->prev_synth_buffer + delay_comp_DFT, delay_diff ); } else { - delay_signal( output[n], output_frame, sts[n]->prev_synth_buffer, delay_comp_TD ); + delay_signal_float( output[n], output_frame, sts[n]->prev_synth_buffer, delay_comp_TD ); } } @@ -1550,7 +1550,7 @@ void stereo_switching_dec( mvr2r( sts[0]->hHQ_core->old_out, sts[1]->hHQ_core->old_out, L_FRAME48k ); mvr2r( sts[0]->delay_buf_out, sts[1]->delay_buf_out, HQ_DELTA_MAX * HQ_DELAY_COMP ); - mvr2r( sts[0]->hTcxDec->old_syn_Overl, sts[1]->hTcxDec->old_syn_Overl, 256 ); + mvr2r( sts[0]->hTcxDec->old_syn_Overl_float, sts[1]->hTcxDec->old_syn_Overl_float, 256 ); } } else if ( hCPE->element_mode == IVAS_CPE_TD && hCPE->last_element_mode == IVAS_CPE_MDCT ) @@ -1569,7 +1569,7 @@ void stereo_switching_dec( sts[1]->pit_res_max = sts[0]->pit_res_max; sts[1]->pit_res_max_past = sts[0]->pit_res_max_past; sts[1]->hTcxDec->L_frameTCX = sts[0]->hTcxDec->L_frameTCX; - sts[1]->hTcxDec->conceal_eof_gain = sts[0]->hTcxDec->conceal_eof_gain; + sts[1]->hTcxDec->conceal_eof_gain_float = sts[0]->hTcxDec->conceal_eof_gain_float; } return; diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec.c index 9ea4af761..31666bfd7 100644 --- a/lib_dec/ivas_svd_dec.c +++ b/lib_dec/ivas_svd_dec.c @@ -738,7 +738,7 @@ static void singularVectorsAccumulationRight( { int16_t nCh, iCh, k; int16_t nChannels; - float norm_y, t_ii, ratio; + float norm_y, t_ii, ratio_float; /* Processing */ nChannels = nChannelsC; /* nChannelsC */ @@ -756,8 +756,8 @@ static void singularVectorsAccumulationRight( for ( iCh = nCh + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC*/ { - ratio = singularVectors_Left[nCh][iCh] / maxWithSign( singularVectors_Left[nCh][nCh + 1] ); - singularVectors_Right[iCh][nCh] = ratio / maxWithSign( t_ii ); + ratio_float = singularVectors_Left[nCh][iCh] / maxWithSign( singularVectors_Left[nCh][nCh + 1] ); + singularVectors_Right[iCh][nCh] = ratio_float / maxWithSign( t_ii ); } for ( iCh = nCh + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */ diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index d705b8f45..bb6ebf50a 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -241,7 +241,7 @@ void stereo_tcx_core_dec( /* Initialize pointers */ synth = synth_buf + hTcxDec->old_synth_len; synthFB = synth_bufFB + hTcxDec->old_synth_lenFB; - mvr2r( hTcxDec->old_synth, synth_buf, hTcxDec->old_synth_len ); + mvr2r( hTcxDec->old_synth_float, synth_buf, hTcxDec->old_synth_len ); mvr2r( hTcxDec->old_synthFB, synth_bufFB, hTcxDec->old_synth_lenFB ); set_zero( synth, L_FRAME_PLUS + M ); set_zero( synthFB, L_FRAME_PLUS + M ); @@ -283,11 +283,11 @@ void stereo_tcx_core_dec( if ( bfi && st->use_partial_copy && st->rf_frame_type == RF_TCXFD ) { - tcx_lpc_cdk = tcxlpc_get_cdk( GENERIC ); + tcx_lpc_cdk = tcxlpc_get_cdk_float( GENERIC ); } else { - tcx_lpc_cdk = tcxlpc_get_cdk( st->coder_type ); + tcx_lpc_cdk = tcxlpc_get_cdk_float( st->coder_type ); } mvr2r( st->lsf_old, &lsf[0], M ); @@ -297,11 +297,11 @@ void stereo_tcx_core_dec( lsf2lsp( &lsf[M], &lsp[M], M, st->sr_core ); - lsf_update_memory( st->narrowBand, &lsf[M], st->mem_MA, st->mem_MA ); + lsf_update_memory_float( st->narrowBand, &lsf[M], st->mem_MA, st->mem_MA ); mvr2r( &lsf[M], st->mem_AR, M ); hTcxDec->envWeighted = 1; - E_LPC_lsp_unweight( &lsp[M], lspnew_uw, lsfnew_uw, 1.0f / st->gamma ); + E_LPC_lsp_unweight_float( &lsp[M], lspnew_uw, lsfnew_uw, 1.0f / st->gamma ); } else { @@ -460,7 +460,7 @@ void stereo_tcx_core_dec( else { /* LPC Interpolation for TCX */ - E_LPC_int_lpc_tcx( &lsp[0], &lsp[M], Aq ); + E_LPC_int_lpc_tcx_float( &lsp[0], &lsp[M], Aq ); } } else @@ -562,7 +562,7 @@ void stereo_tcx_core_dec( set_f( pitch_C, floorf( st->old_fpitch + 0.5f ), 4 ); /* note: codec_mode is forced to MODE2, since FEC_clas_estim() considers only TCX being in Mode2*/ - FEC_clas_estim( synth, pitch_C, st->L_frame, st->tcxonly ? GENERIC : st->core_ext_mode, MODE2, st->mem_syn_clas_estim, &st->clas_dec, &st->lp_ener_bfi, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, hTcxLtpDec->tcxltp ? hTcxDec->tcxltp_last_gain_unmodified : -1.0f, st->narrowBand, CLASSIFIER_TCX, bfi, st->preemph_fac, st->tcxonly, st->last_core_brate, -1 ); + FEC_clas_estim( synth, pitch_C, st->L_frame, st->tcxonly ? GENERIC : st->core_ext_mode, MODE2, st->mem_syn_clas_estim, &st->clas_dec, &st->lp_ener_bfi, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, hTcxLtpDec->tcxltp ? hTcxDec->tcxltp_last_gain_unmodified_float : -1.0f, st->narrowBand, CLASSIFIER_TCX, bfi, st->preemph_fac, st->tcxonly, st->last_core_brate, -1 ); } } @@ -573,7 +573,7 @@ void stereo_tcx_core_dec( if ( bfi && st->last_core != ACELP_CORE ) { /* Update FEC_scale_syn parameters */ - if ( hTcxLtpDec->tcxltp_gain == 0 ) + if ( hTcxLtpDec->tcxltp_gain_float == 0 ) { fer_energy( st->L_frame, UNVOICED, synth, (float) ( st->L_frame / 2 ), &st->enr_old, st->L_frame ); } @@ -590,7 +590,7 @@ void stereo_tcx_core_dec( } /* Update past buffers */ - mvr2r( synth_buf + st->L_frame, hTcxDec->old_synth, hTcxDec->old_synth_len ); + mvr2r( synth_buf + st->L_frame, hTcxDec->old_synth_float, hTcxDec->old_synth_len ); mvr2r( hTcxDec->old_synthFB + hTcxDec->L_frameTCX - NS2SA( st->output_Fs, PH_ECU_MEM_NS ), hTcxDec->synth_history, NS2SA( st->output_Fs, PH_ECU_MEM_NS ) ); mvr2r( synth_bufFB + hTcxDec->L_frameTCX, hTcxDec->old_synthFB, hTcxDec->old_synth_lenFB ); mvr2r( st->hHQ_core->old_out + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->old_synthFB + hTcxDec->old_synth_lenFB, NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); @@ -689,7 +689,7 @@ void stereo_tcx_core_dec( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = 0.99f * st->hFdCngDec->hFdCngCom->likelihood_noisy_speech + 0.01f * (float) st->hFdCngDec->hFdCngCom->flag_noisy_speech; - st->lp_noise = st->hFdCngDec->lp_noise; + st->lp_noise = st->hFdCngDec->lp_noise_float; if ( st->element_mode != IVAS_CPE_TD ) { @@ -715,7 +715,7 @@ void stereo_tcx_core_dec( /* Clear memory for secondary channel CNA */ set_f( hStereoCng->olapBufferSynth22, 0.0f, st->hFdCngDec->hFdCngCom->frameSize / 2 ); } - expand_range( st->hFdCngDec->msPsd, psd_part, st->hFdCngDec->nFFTpart_shaping ); + expand_range( st->hFdCngDec->msPsd_float, psd_part, st->hFdCngDec->nFFTpart_shaping ); scalebands( psd_part, st->hFdCngDec->part_shaping, st->hFdCngDec->nFFTpart_shaping, st->hFdCngDec->midband_shaping, st->hFdCngDec->nFFTpart_shaping, st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand, psd, 1 ); generate_stereo_masking_noise( signal_out, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out ); } @@ -772,7 +772,7 @@ static void dec_prm_tcx( /* Init LTP data */ st->hTcxDec->tcx_hm_LtpPitchLag = -1; - st->hTcxLtpDec->tcxltp_gain = 0.0f; + st->hTcxLtpDec->tcxltp_gain_float = 0.0f; /*--------------------------------------------------------------------------------* * header diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 5cc036b18..f47c39902 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -586,7 +586,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( if ( hIvasDec->hVoIP != NULL && hIvasDec->hVoIP->hCurrentDataUnit != NULL ) { - DEC_CORE_HANDLE st = hIvasDec->st_ivas->hSCE[0]->hCoreCoder[0]; + DEC_CORE_HANDLE_FLOAT st = hIvasDec->st_ivas->hSCE[0]->hCoreCoder[0]; st->ini_frame = 0; st->prev_use_partial_copy = 0; hIvasDec->st_ivas->hDecoderConfig->ivas_total_brate = hIvasDec->hVoIP->hCurrentDataUnit->dataSize * FRAMES_PER_SEC; @@ -607,7 +607,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( /* Update redundant frame information in EVS (pre- read indices) */ if ( hIvasDec->mode == IVAS_DEC_MODE_EVS && hIvasDec->hVoIP != NULL && hIvasDec->hVoIP->hCurrentDataUnit != NULL ) { - DEC_CORE_HANDLE st = hIvasDec->st_ivas->hSCE[0]->hCoreCoder[0]; + DEC_CORE_HANDLE_FLOAT st = hIvasDec->st_ivas->hSCE[0]->hCoreCoder[0]; st->bit_stream = serial; if ( hIvasDec->hVoIP->hCurrentDataUnit->partial_frame || st->prev_use_partial_copy ) @@ -636,7 +636,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hIvasDec->hVoIP->hCurrentDataUnit != NULL && hIvasDec->hVoIP->hCurrentDataUnit->partial_frame != 0 ) { - DEC_CORE_HANDLE st = hIvasDec->st_ivas->hSCE[0]->hCoreCoder[0]; + DEC_CORE_HANDLE_FLOAT st = hIvasDec->st_ivas->hSCE[0]->hCoreCoder[0]; st->codec_mode = MODE2; st->use_partial_copy = 1; } @@ -1885,7 +1885,7 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( } /* check if frame contains a partial copy and get its offset */ - evs_dec_previewFrame( au, auSize, &partialCopyFrameType, &partialCopyOffset ); + evs_dec_previewFrame_float( au, auSize, &partialCopyFrameType, &partialCopyOffset ); /* create data unit for primary copy in the frame */ dataUnit = JB4_AllocDataUnit( hIvasDec->hVoIP->hJBM ); @@ -2641,7 +2641,7 @@ static ivas_error evs_dec_main( float *floatBuf, int16_t *pcmBuf ) { - DEC_CORE_HANDLE *hCoreCoder; + DEC_CORE_HANDLE_FLOAT *hCoreCoder; float output[MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN][L_FRAME48k]; float mixer_left, mixer_rigth; float *p_output[MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; diff --git a/lib_dec/lsf_dec.c b/lib_dec/lsf_dec.c index 4e5871fea..e3fb90991 100644 --- a/lib_dec/lsf_dec.c +++ b/lib_dec/lsf_dec.c @@ -305,13 +305,13 @@ void lsf_end_dec( if ( st->core_brate == SID_2k40 ) { dqlsf_CNG( st, qlsf ); - v_sort( qlsf, 0, M - 1 ); + v_sort_float( qlsf, 0, M - 1 ); reorder_lsf( qlsf, MODE1_LSF_GAP, M, st->sr_core ); return; } - find_pred_mode( &predmode, coder_type, bwidth, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate ); + find_pred_mode_float( &predmode, coder_type, bwidth, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate ); /*----------------------------------------------------------------* * Calculate number of stages and levels for each stage based on the allowed bit allocation @@ -577,7 +577,7 @@ void lsf_end_dec( *--------------------------------------------------------------------------*/ /* Sort the quantized vector */ - v_sort( qlsf, 0, M - 1 ); + v_sort_float( qlsf, 0, M - 1 ); /* Verify stability */ reorder_lsf( qlsf, MODE1_LSF_GAP, M, st->sr_core ); @@ -607,7 +607,7 @@ static void lsf_mid_dec( int16_t j, idx; int16_t nb_bits; float qlsf0[M], qlsf1[M], qlsf[M]; - const float *ratio = NULL; + const float *ratio_float = NULL; int16_t bad_spacing; bad_spacing = 0; @@ -620,12 +620,12 @@ static void lsf_mid_dec( if ( st->ppp_mode_dec == 1 ) { nb_bits = 1; - ratio = &( tbl_mid_voi_wb_1b[0] ); + ratio_float = &( tbl_mid_voi_wb_1b[0] ); } else if ( st->nelp_mode_dec == 1 ) { nb_bits = 4; - ratio = &( tbl_mid_unv_wb_4b[0] ); + ratio_float = &( tbl_mid_unv_wb_4b[0] ); } else { @@ -638,24 +638,24 @@ static void lsf_mid_dec( { case 5: { - ratio = tbl_mid_voi_wb_5b; + ratio_float = tbl_mid_voi_wb_5b; break; } case 4: { - ratio = tbl_mid_voi_wb_4b; + ratio_float = tbl_mid_voi_wb_4b; break; } case 1: { - ratio = tbl_mid_voi_wb_1b; + ratio_float = tbl_mid_voi_wb_1b; break; } } } else if ( coder_type == UNVOICED ) { - ratio = tbl_mid_unv_wb_5b; + ratio_float = tbl_mid_unv_wb_5b; } else { @@ -664,17 +664,17 @@ static void lsf_mid_dec( { case 5: { - ratio = tbl_mid_gen_wb_5b; + ratio_float = tbl_mid_gen_wb_5b; break; } case 4: { - ratio = tbl_mid_gen_wb_4b; + ratio_float = tbl_mid_gen_wb_4b; break; } case 2: { - ratio = tbl_mid_gen_wb_2b; + ratio_float = tbl_mid_gen_wb_2b; break; } } @@ -687,7 +687,7 @@ static void lsf_mid_dec( /* Calculation of mid-LSF vector */ for ( j = 0; j < M; j++ ) { - qlsf[j] = ( 1.0f - ratio[idx * M + j] ) * qlsf0[j] + ratio[idx * M + j] * qlsf1[j]; + qlsf[j] = ( 1.0f - ratio_float[idx * M + j] ) * qlsf0[j] + ratio_float[idx * M + j] * qlsf1[j]; } /* check for incorrect LSF ordering */ diff --git a/lib_dec/lsf_msvq_ma_dec.c b/lib_dec/lsf_msvq_ma_dec.c index 945797915..0471cdf76 100644 --- a/lib_dec/lsf_msvq_ma_dec.c +++ b/lib_dec/lsf_msvq_ma_dec.c @@ -61,17 +61,17 @@ int16_t lsf_msvq_ma_decprm( if ( st->sr_core == INT_FS_16k && st->coder_type == UNVOICED ) { - find_pred_mode( &predmode, GENERIC, 1 - st->narrowBand /*st->bwidth*/, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate ); + find_pred_mode_float( &predmode, GENERIC, 1 - st->narrowBand /*st->bwidth*/, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate ); } else { if ( st->core == TCX_20_CORE ) { - find_pred_mode( &predmode, AUDIO, 1 - st->narrowBand /*st->bwidth*/, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate ); + find_pred_mode_float( &predmode, AUDIO, 1 - st->narrowBand /*st->bwidth*/, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate ); } else { - find_pred_mode( &predmode, st->coder_type, 1 - st->narrowBand /*st->bwidth*/, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate ); + find_pred_mode_float( &predmode, st->coder_type, 1 - st->narrowBand /*st->bwidth*/, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate ); } } @@ -184,7 +184,7 @@ int16_t D_lsf_tcxlpc( NumIndices = 1; - msvq_dec( lsf_codebook[narrowband][cdk], lsf_dims, lsf_offs, TCXLPC_NUMSTAGES, M, M, indices + NumIndices, 0, NULL, lsf_q, lsf_q_ind ); + msvq_dec_float( lsf_codebook[narrowband][cdk], lsf_dims, lsf_offs, TCXLPC_NUMSTAGES, M, M, indices + NumIndices, 0, NULL, lsf_q, lsf_q_ind ); NumIndices += TCXLPC_NUMSTAGES; @@ -193,7 +193,7 @@ int16_t D_lsf_tcxlpc( /* Only add contribution if flag is enabled */ - msvq_dec( lsf_ind_codebook[narrowband][cdk], lsf_ind_dims, lsf_ind_offs, TCXLPC_IND_NUMSTAGES, M, M, indices + NumIndices, 0, NULL, lsf_rem_q, lsf_rem_q_ind ); + msvq_dec_float( lsf_ind_codebook[narrowband][cdk], lsf_ind_dims, lsf_ind_offs, TCXLPC_IND_NUMSTAGES, M, M, indices + NumIndices, 0, NULL, lsf_rem_q, lsf_rem_q_ind ); NumIndices += TCXLPC_IND_NUMSTAGES; /* Add to MA-removed vector */ @@ -204,7 +204,7 @@ int16_t D_lsf_tcxlpc( } /* Inter-frame prediction */ - means = lsf_means[narrowband]; + means = lsf_means_float[narrowband]; for ( i = 0; i < M; ++i ) { @@ -217,9 +217,9 @@ int16_t D_lsf_tcxlpc( lsf_q[i] += pred[i]; lsf_q_ind[i] = add( lsf_q_ind[i], LSFM( means[i] ) ); } - reorder_lsf( lsf_q, TCXLPC_LSF_GAP, M, INT_FS_12k8 ); + reorder_lsf( lsf_q, TCXLPC_LSF_GAP_FLT, M, INT_FS_12k8 ); - basop_reorder_lsf( lsf_q_ind, LSF_GAP_VAL( TCXLPC_LSF_GAP ), M, INT_FS_FX ); + basop_reorder_lsf( lsf_q_ind, LSF_GAP_VAL(TCXLPC_LSF_GAP_FLT), M, INT_FS_FX ); if ( lsp_q_ind ) { @@ -262,10 +262,10 @@ int16_t dec_lsf_tcxlpc( } /* Decode independent lsf */ - msvq_dec( lsf_codebook[narrowband][cdk], lsf_dims, lsf_offs, TCXLPC_NUMSTAGES, M, M, flag + 1, 0, NULL, lsf_q_ignored, lsf_q_ind ); + msvq_dec_float( lsf_codebook[narrowband][cdk], lsf_dims, lsf_offs, TCXLPC_NUMSTAGES, M, M, flag + 1, 0, NULL, lsf_q_ignored, lsf_q_ind ); /* Update flag */ - *flag = lsf_ind_is_active( lsf_q_ind, lsf_means[narrowband], narrowband, cdk ); + *flag = lsf_ind_is_active( lsf_q_ind, lsf_means_float[narrowband], narrowband, cdk ); if ( *flag ) { diff --git a/lib_dec/peak_vq_dec.c b/lib_dec/peak_vq_dec.c index 857bf0d5f..fea37eee8 100644 --- a/lib_dec/peak_vq_dec.c +++ b/lib_dec/peak_vq_dec.c @@ -250,7 +250,7 @@ static void peak_vq_dec( peak_gains[i] *= 4.0f; manPkEnrg = manPkEnrg_tbl[pgain_difidx[i]]; expPkEnrg = expPkEnrg_tbl[pgain_difidx[i]]; - floating_point_add( &manE_peak, &expE_peak, manPkEnrg, expPkEnrg ); + floating_point_add_float( &manE_peak, &expE_peak, manPkEnrg, expPkEnrg ); } /* Number of bits used for peak gain quantization */ diff --git a/lib_dec/post_dec.c b/lib_dec/post_dec.c index f661992ac..eb081a175 100644 --- a/lib_dec/post_dec.c +++ b/lib_dec/post_dec.c @@ -101,11 +101,11 @@ void post_decoder( { /* Past frame was low-bitrate with formant post-filter */ lsp2a_stab( st->lsp_old, A, M ); - mvr2r( st->hPFstat->mem_pf_in + L_SYN_MEM - M, synth - M, M ); + mvr2r( st->hPFstat->mem_pf_in_flt + L_SYN_MEM - M, synth - M, M ); L_subfr = st->L_frame / st->nb_subfr; residu( A, M, synth, synth_buf, L_subfr ); - syn_filt( A, M, synth_buf, synth2, L_subfr, st->hPFstat->mem_stp + L_SYN_MEM - M, 0 ); - scale_st( synth, synth2, &st->hPFstat->gain_prec, L_subfr, -1 ); + syn_filt( A, M, synth_buf, synth2, L_subfr, st->hPFstat->mem_stp_flt + L_SYN_MEM - M, 0 ); + scale_st( synth, synth2, &st->hPFstat->gain_prec_flt, L_subfr, -1 ); blend_subfr2( synth2 + L_subfr / 2, synth + L_subfr / 2, synth2 + L_subfr / 2 ); } } @@ -133,12 +133,12 @@ void post_decoder( if ( st->bwidth == NB ) { st->hPFstat->on = 1; - nb_post_filt( L_frame, L_SUBFR, st->hPFstat, &tmp, 0, synth_buf, st->mem_Aq, pitch_buf, GENERIC, st->BER_detect, st->lp_noise > LP_NOISE_THRESH ? 1 : ( ( st->core != ACELP_CORE ) || ( st->coder_type == UNVOICED ) ) ); + nb_post_filt( L_frame, L_SUBFR, st->hPFstat, &tmp, 0, synth_buf, st->mem_Aq, pitch_buf, GENERIC, st->BER_detect, st->lp_noise > LP_NOISE_THRESH_FLT ? 1 : ( ( st->core != ACELP_CORE ) || ( st->coder_type == UNVOICED ) ) ); } else { st->hPFstat->on = 0; - nb_post_filt( L_frame, L_SUBFR, st->hPFstat, &tmp, 0, synth_buf, st->mem_Aq, pitch_buf, AUDIO, st->BER_detect, st->lp_noise > LP_NOISE_THRESH ? 1 : ( ( st->core != ACELP_CORE ) || ( st->coder_type == UNVOICED ) ) ); + nb_post_filt( L_frame, L_SUBFR, st->hPFstat, &tmp, 0, synth_buf, st->mem_Aq, pitch_buf, AUDIO, st->BER_detect, st->lp_noise > LP_NOISE_THRESH_FLT ? 1 : ( ( st->core != ACELP_CORE ) || ( st->coder_type == UNVOICED ) ) ); } @@ -167,7 +167,7 @@ void post_decoder( } /*Bass Post-filter */ - bass_pf_1sf_delay( synth2, pitch, pit_gain, L_frame, L_SUBFR, bpf_noise_buf, pitch_gain_adjust, ( st->lp_noise > LP_NOISE_THRESH && st->narrowBand ) ? 1 : 0, &( st->hBPF->pst_mem_deemp_err ), &( st->hBPF->pst_lp_ener ) ); + bass_pf_1sf_delay( synth2, pitch, pit_gain, L_frame, L_SUBFR, bpf_noise_buf, pitch_gain_adjust, ( st->lp_noise > LP_NOISE_THRESH_FLT && st->narrowBand ) ? 1 : 0, &( st->hBPF->pst_mem_deemp_err ), &( st->hBPF->pst_lp_ener ) ); } /* Output */ diff --git a/lib_dec/range_dec.c b/lib_dec/range_dec.c index 87589a840..04cbb8365 100644 --- a/lib_dec/range_dec.c +++ b/lib_dec/range_dec.c @@ -92,7 +92,7 @@ uint32_t rc_decode( uint32_t inv, val; int16_t exp; - inv = UL_inverse( tot, &exp ); + inv = UL_inverse_float( tot, &exp ); hPVQ->rc_help = UMult_32_32( hPVQ->rc_range, inv ); hPVQ->rc_help = hPVQ->rc_help >> ( exp - 32 ); @@ -182,7 +182,7 @@ uint32_t rc_dec_uniform( uint32_t value; int16_t n; - n = 32 - norm_ul( tot - 1 ); /* aligned to BASOP */ + n = 32 - norm_ul_float( tot - 1 ); /* aligned to BASOP */ if ( n <= 8 ) { diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 822b593c5..7beabf0f7 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -58,8 +58,7 @@ typedef enum FRAMEMODE_NORMAL = 0x0, /* frame available */ FRAMEMODE_MISSING = 0x1, /* frame missing => conceal */ FRAMEMODE_FUTURE = 0x2 -} FRAME_MODE; - +} FRAME_MODE,frameMode_fx; /*---------------------------------------------------------------* * Structure for FD CNG @@ -69,31 +68,89 @@ typedef struct { HANDLE_FD_CNG_COM hFdCngCom; - float msPeriodog[NPART_SHAPING]; /* Periodogram */ - float msBminWin[NPART_SHAPING]; - float msBminSubWin[NPART_SHAPING]; - float msPsd[NPART_SHAPING]; /* Power Spectral Density estimate (i.e., smoothed periodogram) */ - float msAlpha[NPART_SHAPING]; /* Optimal smoothing parameter */ - float msMinBuf[MSNUMSUBFR * NPART_SHAPING]; /* Buffer of minima */ - float msCurrentMinOut[NPART_SHAPING]; - float msCurrentMin[NPART_SHAPING]; - float msCurrentMinSubWindow[NPART_SHAPING]; + Word16 olapBufferAna[320]; + Word16 olapBufferSynth2[FFTLEN]; + + float msPeriodog_float[NPART_SHAPING]; /* Periodogram */ + Word32 msPeriodog[NPART_SHAPING]; /* Periodogram */ + + Word16 msPeriodog_exp; /* Common exponent for fft and cldfb energies */ + Word16 msPeriodog_exp_fft; + Word16 msPeriodog_exp_cldfb; + + float msBminWin_float[NPART_SHAPING]; + Word32 msBminWin[NPART_SHAPING]; + + float msBminSubWin_float[NPART_SHAPING]; + Word32 msBminSubWin[NPART_SHAPING]; + + float msPsd_float[NPART_SHAPING]; /* Power Spectral Density estimate (i.e., smoothed periodogram) */ + Word16 msPsd[NPART_SHAPING]; /* Power Spectral Density estimate (i.e., smoothed periodogram) */ + + Word16 msPsd_exp_fft; + + float msAlpha_float[NPART_SHAPING]; /* Optimal smoothing parameter */ + Word32 msAlpha[NPART_SHAPING]; /* Optimal smoothing parameter */ + + float msMinBuf_float[MSNUMSUBFR * NPART_SHAPING]; /* Buffer of minima */ + Word32 msMinBuf[MSNUMSUBFR*NPART_SHAPING]; /* Buffer of minima */ + + float msCurrentMinOut_float[NPART_SHAPING]; + Word32 msCurrentMinOut[NPART_SHAPING]; + + float msCurrentMin_float[NPART_SHAPING]; + Word32 msCurrentMin[NPART_SHAPING]; + + float msCurrentMinSubWindow_float[NPART_SHAPING]; + Word32 msCurrentMinSubWindow[NPART_SHAPING]; + int16_t msLocalMinFlag[NPART_SHAPING]; int16_t msNewMinFlag[NPART_SHAPING]; - float msPsdFirstMoment[NPART_SHAPING]; - float msPsdSecondMoment[NPART_SHAPING]; - float msNoiseFloor[NPART_SHAPING]; /* Estimated noise floor */ - float msNoiseEst[NPART_SHAPING]; /* Estimated noise level */ - float msLogPeriodog[NPART_SHAPING]; /* Periodogram */ - float msLogNoiseEst[NPART_SHAPING]; /* Estimated noise level */ - int16_t npart_shaping; /* Number of partitions */ + + float msPsdFirstMoment_float[NPART_SHAPING]; + Word16 msPsdFirstMoment[NPART_SHAPING]; + + float msPsdSecondMoment_float[NPART_SHAPING]; + Word32 msPsdSecondMoment[NPART_SHAPING]; + + float msNoiseFloor_float[NPART_SHAPING]; /* Estimated noise floor */ + Word16 msNoiseFloor[NPART_SHAPING]; /* Estimated noise floor */ + + float msNoiseEst_float[NPART_SHAPING]; /* Estimated noise level */ + Word32 msNoiseEst[NPART_SHAPING]; /* Estimated noise level */ + + Word16 msNoiseEst_exp; + + float msLogPeriodog_float[NPART_SHAPING]; /* Periodogram */ + Word16 msLogPeriodog[NPART_SHAPING]; + + float msLogNoiseEst_float[NPART_SHAPING]; /* Estimated noise level */ + Word16 msLogNoiseEst[NPART_SHAPING]; + + int16_t npart_shaping; /* Number of partitions */ int16_t nFFTpart_shaping; /* Number of hybrid spectral partitions */ int16_t part_shaping[NPART_SHAPING]; /* Partition upper boundaries (band indices starting from 0) */ int16_t midband_shaping[NPART_SHAPING]; /* Central band of each partition */ - float psize_shaping[NPART_SHAPING]; /* Partition sizes */ - float psize_inv_shaping[NPART_SHAPING]; /* Inverse of partition sizes */ - float bandNoiseShape[FFTLEN2]; /* CNG spectral shape computed at the decoder */ - float partNoiseShape[NPART]; /* CNG spectral shape computed at the decoder */ + + float psize_shaping_float[NPART_SHAPING]; /* Partition sizes */ + Word16 psize_shaping[NPART_SHAPING]; /* Partition sizes */ + + Word16 psize_shaping_norm[NPART_SHAPING]; /* Partition sizes, fractional variable */ + Word16 psize_shaping_norm_exp; /* Partition sizes exponent for fractional variable */ + + float psize_inv_shaping_float[NPART_SHAPING]; /* Inverse of partition sizes */ + Word16 psize_inv_shaping[NPART_SHAPING]; /* Inverse of partition sizes */ + + + float bandNoiseShape_float[FFTLEN2]; /* CNG spectral shape computed at the decoder */ + Word32 bandNoiseShape[FFTLEN2]; /* CNG spectral shape computed at the decoder */ + + Word16 bandNoiseShape_exp; /* exponent of bandNoiseShape */ + + float partNoiseShape_float[NPART]; /* CNG spectral shape computed at the decoder */ + Word32 partNoiseShape[NPART]; /* CNG spectral shape computed at the decoder */ + + Word16 partNoiseShape_exp; /* exponent of partNoiseShape */ float smoothed_psd[L_FRAME16k]; /* stereo CNA - periodogram smoothed with IIR filter */ float msPeriodog_ST[NPART_SHAPING]; /* stereo CNA - short-term periodogram */ @@ -113,13 +170,20 @@ typedef struct int16_t cna_seed; /* stereo CNA - seed for random CN generator */ int16_t flag_dtx_mode; - float lp_speech; - float lp_noise; - float msPeriodogBuf[MSBUFLEN * NPART_SHAPING]; - int16_t msPeriodogBufPtr; + float lp_speech_float; + Word32 lp_speech; /* format: Q9.23 */ + + float lp_noise_float; + Word32 lp_noise; /* format: Q9.23 */ + + float msPeriodogBuf_float[MSBUFLEN * NPART_SHAPING]; + Word16 msPeriodogBuf[MSBUFLEN*NPART_SHAPING]; + + int16_t msPeriodogBufPtr; + } FD_CNG_DEC, *HANDLE_FD_CNG_DEC; /*---------------------------------------------------------------* @@ -129,27 +193,55 @@ typedef struct typedef struct { int16_t L_frameTCX; + Word16 FrameSize; int16_t Pitch; - int16_t T_bfi; + Word16 Pitch_fx; + + int16_t T_bfi; + Word8 T_bfi_fx; int16_t Transient[MAX_POST_LEN]; int16_t TCX_Tonality[DEC_STATE_LEN]; float outx_new_n1; + Word16 outx_new_n1_fx; + float nsapp_gain; - float nsapp_gain_n; - float data_reci2[L_FRAME_MAX]; - float data_noise[L_FRAME_MAX]; + Word16 nsapp_gain_fx; + + float nsapp_gain_n; + Word16 nsapp_gain_n_fx; + + float data_reci2[L_FRAME_MAX]; + Word32 data_reci2_fx[L_FRAME_MAX]; + + Word16 data_reci2_scale; + + float data_noise_float[L_FRAME_MAX]; + Word16 data_noise[L_FRAME_MAX]; + float ener_mean; - float ener; - int16_t zp; - float recovery_gain; - float step_concealgain; + Word32 ener_mean_fx; + + float ener; + Word32 ener_fx; + + int16_t zp; + Word16 zp_fx; + + float recovery_gain_float; + Word16 recovery_gain; /*outside waveformadjustment: Q14 - insinde waveformadjustment: Q15*/ + + float step_concealgain; + Word16 step_concealgain_fx; int16_t concealment_method; - int16_t subframe; - int16_t nbLostCmpt; + + int16_t subframe; + Word16 subframe_fx; + + int16_t nbLostCmpt; int16_t seed; @@ -164,9 +256,20 @@ typedef struct { uint16_t nSamples; uint16_t nSamplesCore; - Float32 *spectralData; - float *scaleFactors; - int16_t blockIsValid; + + Float32 *spectralData_float; + Word16 * spectralData; + + Word16 spectralData_exp; + + float *scaleFactors_float; + Word16 * scaleFactors; + + Word16 * scaleFactors_exp; + Word16 scaleFactors_max_e; + Word16 gain_tcx_exp; + + int16_t blockIsValid; int16_t blockIsConcealed; int16_t tonalConcealmentActive; } blockData; @@ -177,11 +280,16 @@ typedef struct uint16_t indexOfTonalPeak[MAX_NUMBER_OF_IDX]; uint16_t lowerIndex[MAX_NUMBER_OF_IDX]; uint16_t upperIndex[MAX_NUMBER_OF_IDX]; - Float32 phaseDiff[MAX_NUMBER_OF_IDX]; /* This one can be stored with 16 bits in range 0..2*PI */ - Float32 phase_currentFramePredicted[MAX_NUMBER_OF_IDX * GROUP_LENGTH]; /* This one can be stored with 16 bits in range 0..2*PI, but the code has to be adapted to use moduo(2*PI) after adding */ + + Float32 phaseDiff_float[MAX_NUMBER_OF_IDX]; /* This one can be stored with 16 bits in range 0..2*PI */ + Word16 phaseDiff[MAX_NUMBER_OF_IDX]; /* This one can be stored with 16 bits in range 0..2*PI */ + + Float32 phase_currentFramePredicted_float[MAX_NUMBER_OF_IDX * GROUP_LENGTH]; /* This one can be stored with 16 bits in range 0..2*PI, but the code has to be adapted to use moduo(2*PI) after adding */ + Word16 phase_currentFramePredicted[MAX_NUMBER_OF_IDX*GROUP_LENGTH]; /* This one can be stored with 16 bits in range [-pi;pi] 2Q13, but the code has to be adapted to use moduo(2*PI) after adding */ + } TonalComponentsInfo; -typedef struct +typedef struct tonalmdctconceal { TCX_config *tcx_cfg; void *pMDSTData; @@ -190,17 +298,34 @@ typedef struct int16_t nNonZeroSamples; int16_t nScaleFactors; - float lastPitchLag; + float lastPitchLag_float; + Word32 lastPitchLag; blockData lastBlockData; blockData secondLastBlockData; - Float32 scaleFactorsBuffers[2][FDNS_NPTS]; /* Contains also global gain. If it can not be stored in 16 bits with global gain included, then store global gain separately. */ - Float32 spectralDataBuffers[2][L_FRAME_MAX]; /* 16 bits is enough, because it is stored before applying scale factors. Take care that power spectrum is also stored here. */ - Float32 timeDataBuffer[( 3 * L_FRAME_MAX ) / 2]; - Float32 *lastPcmOut; - Float32 *secondLastPcmOut; - float *secondLastPowerSpectrum; + Float32 scaleFactorsBuffers_float[2][FDNS_NPTS]; /* Contains also global gain. If it can not be stored in 16 bits with global gain included, then store global gain separately. */ + Word16 scaleFactorsBuffers[2][FDNS_NPTS]; /* Contains also global gain. */ + + Word16 scaleFactorsBuffers_exp[2][FDNS_NPTS]; + + Float32 spectralDataBuffers_float[2][L_FRAME_MAX]; /* 16 bits is enough, because it is stored before applying scale factors. Take care that power spectrum is also stored here. */ + Word16 spectralDataBuffers[2][L_FRAME_MAX]; /* 16 bits is enough, because it is stored before applying scale factors. Take care that power spectrum is also stored here. */ + + Float32 timeDataBuffer_float[( 3 * L_FRAME_MAX ) / 2]; + Word16 timeDataBuffer[(3 * L_FRAME_MAX) / 2]; /* 16 bits are enough for the TD signal */ + + + Float32 *lastPcmOut_float; + Word16 * lastPcmOut; + + Float32 *secondLastPcmOut_float; + Word16 * secondLastPcmOut; + + float *secondLastPowerSpectrum_float; + Word16 * secondLastPowerSpectrum; + + Word16 secondLastPowerSpectrum_exp; float scaleFactorsBackground[FDNS_NPTS]; float scf_fadeout; @@ -212,17 +337,13 @@ typedef struct float curr_noise_nrg; float faded_signal_nrg; - float nFramesLost; + float nFramesLost_float; + Word16 nFramesLost; TonalComponentsInfo *pTCI; } TonalMDCTConceal_INSTANCE, *TonalMDCTConcealPtr; -typedef enum SIGNAL_CLASSIFER_MODE -{ - CLASSIFIER_ACELP, - CLASSIFIER_TCX -} SIGNAL_CLASSIFIER_MODE; /*---------------------------------------------------------------* @@ -254,17 +375,28 @@ typedef struct igfdec_private_data_struct IGF_INFO igfInfo; /* envelope reconstruction: */ - float igf_sN[IGF_MAX_SFB]; /* only with short blocks as static needed */ - float igf_pN[IGF_MAX_SFB]; /* only with short blocks as static needed */ - int16_t igf_curr[IGF_MAX_SFB]; /* current igf energies */ + float igf_sN_float[IGF_MAX_SFB]; /* only with short blocks as static needed */ + Word32 igf_sN[IGF_MAX_SFB]; /* Q31 | only with short blocks as static needed */ + + Word16 igf_sN_e[IGF_MAX_SFB]; /* | exponent for igf_sN */ + + float igf_pN_float[IGF_MAX_SFB]; /* only with short blocks as static needed */ + Word32 igf_pN[IGF_MAX_SFB]; /* Q31 | only with short blocks as static needed */ + + Word16 igf_pN_e[IGF_MAX_SFB]; + + int16_t igf_curr[IGF_MAX_SFB]; /* current igf energies */ int16_t igf_prev[IGF_MAX_SFB]; /* needed for concealment or indepflag==0 */ int16_t igf_curr_subframe[IGF_MAX_SUBFRAMES][IGF_TRANS_FAK][IGF_MAX_SFB]; /* current igf energies per subframe*/ int16_t igf_prev_subframe[IGF_MAX_SUBFRAMES][IGF_MAX_SFB]; /* needed for concealment or indepflag==0 */ int16_t igf_flatteningTrigger_subframe[IGF_MAX_SUBFRAMES]; /* spectral whitening: */ - float *pSpecFlat; + float *pSpecFlat_float; float pSpecFlatBuf[IGF_START_MX]; + Word32 pSpecFlat[IGF_START_MX]; /* Q31 | MDCT spectrum before LPC shaping */ + Word16 pSpecFlat_exp; + int16_t restrict_hopsize; int16_t currWhiteningLevel[IGF_MAX_TILES]; @@ -272,12 +404,19 @@ typedef struct igfdec_private_data_struct int16_t currWhiteningLevel_subframe[IGF_MAX_SUBFRAMES][IGF_MAX_TILES]; int16_t prevWhiteningLevel_subframe[IGF_MAX_SUBFRAMES][IGF_MAX_TILES]; /* needed for concealment */ - float totalNoiseNrg; - int16_t n_noise_bands; + float totalNoiseNrg_float; + Word32 totalNoiseNrg; + + int16_t n_noise_bands; + + Word16 headroom_TCX_noise_white; + Word16 headroom_TCX_noise; - float totalNoiseNrg_off; + float totalNoiseNrg_off_float; + Word32 totalNoiseNrg_off; int16_t n_noise_bands_off; + /* IGF SCF decoding: */ IGFSCFDEC_INSTANCE hArithSCFdec; @@ -298,8 +437,11 @@ typedef struct igfdec_instance_struct uint8_t infoTCXNoiseBuf[IGF_START_MX]; int16_t *flag_sparse; int16_t flag_sparseBuf[N_MAX_TCX - IGF_START_MN]; - float *virtualSpec; + + float *virtualSpec_float; float virtualSpecBuf[N_MAX_TCX - IGF_START_MN]; + Word32 virtualSpec[N_MAX_TCX - IGF_START_MN]; /* Q31 | buffer for temp flattening */ + Word16 virtualSpec_e; /* | exponent of virtualSpec */ int16_t flatteningTrigger; IGFDEC_PRIVATE_DATA igfData; @@ -327,16 +469,27 @@ typedef struct tcx_ltp_dec_structure { /* TCX-LTP */ int16_t tcxltp; - float tcxltp_gain; - int16_t tcxltp_pitch_int; + + float tcxltp_gain_float; + Word16 tcxltp_gain; + + int16_t tcxltp_pitch_int; int16_t tcxltp_pitch_fr; - float tcxltp_mem_in[TCXLTP_MAX_DELAY]; - float tcxltp_mem_out[L_FRAME48k]; + float tcxltp_mem_in_float[TCXLTP_MAX_DELAY]; + Word16 tcxltp_mem_in[TCXLTP_MAX_DELAY]; + + float tcxltp_mem_out_float[L_FRAME48k]; + Word16 tcxltp_mem_out[L_FRAME48k]; + + int16_t tcxltp_pitch_int_post_prev; int16_t tcxltp_pitch_fr_post_prev; - float tcxltp_gain_post_prev; - int16_t tcxltp_filt_idx_prev; + + float tcxltp_gain_post_prev_float; + Word16 tcxltp_gain_post_prev; + + int16_t tcxltp_filt_idx_prev; } TCX_LTP_DEC_DATA, *TCX_LTP_DEC_HANDLE; @@ -351,9 +504,14 @@ typedef struct tcx_dec_structure int16_t envWeighted; /* are is{p,f}_old[] weighted or not? */ /* tonal PLC */ - float tcxltp_second_last_pitch; - float tcxltp_third_last_pitch; - float tcxltp_last_gain_unmodified; + float tcxltp_second_last_pitch_float; + Word32 tcxltp_second_last_pitch; + + float tcxltp_third_last_pitch_float; + Word32 tcxltp_third_last_pitch; + + float tcxltp_last_gain_unmodified_float; + Word16 tcxltp_last_gain_unmodified; int16_t tcx_hm_LtpPitchLag; int16_t tcx_lpc_shaped_ari; @@ -364,24 +522,41 @@ typedef struct tcx_dec_structure int16_t L_frameTCX; float old_excFB[L_FRAME48k]; /* old excitation FB */ + Word16 old_excFB_fx[L_FRAME48k]; /* old excitation FB */ int16_t old_synth_len; int16_t old_synth_lenFB; - float old_synth[OLD_SYNTH_INTERNAL_DEC]; /* synthesis memory */ - float synth_history[L_PROT48k + L_FRAME_MAX]; /* unified synthesis memory */ + + float old_synth_float[OLD_SYNTH_INTERNAL_DEC]; /* synthesis memory */ + Word16 old_synth[OLD_SYNTH_INTERNAL_DEC]; /* synthesis memory */ + + float synth_history[L_PROT48k + L_FRAME_MAX]; /* unified synthesis memory */ + Word16 synth_history_fx[L_PROT48k + L_FRAME_MAX]; /*TCX unified synthesis memory */ float *old_synthFB; + Word16* old_synthFB_fx; + float *prev_good_synth; + Word16* prev_good_synth_fx; - float old_syn_Overl[L_FRAME32k / 2]; + float old_syn_Overl_float[L_FRAME32k / 2]; + Word16 old_syn_Overl[L_FRAME32k / 2]; - float syn_Overl_TDAC[L_FRAME32k / 2]; - float syn_Overl_TDACFB[L_FRAME_MAX / 2]; + float syn_Overl_TDAC_float[L_FRAME32k / 2]; + Word16 syn_Overl_TDAC[L_FRAME32k / 2]; + + float syn_Overl_TDACFB_float[L_FRAME_MAX / 2]; + Word16 syn_Overl_TDACFB[L_FRAME_MAX / 2]; - float syn_Overl[L_FRAME32k / 2]; - float syn_OverlFB[L_FRAME_MAX / 2]; + float syn_Overl_float[L_FRAME32k / 2]; + Word16 syn_Overl[L_FRAME32k / 2]; + + float syn_OverlFB_float[L_FRAME_MAX / 2]; + Word16 syn_OverlFB[L_FRAME_MAX / 2]; + + float FBTCXdelayBuf_float[111]; /* 2.3125ms at 48kHz -> 111 samples */ + Word16 FBTCXdelayBuf[111]; /* 2.3125ms at 48kHz -> 111 samples */ - float FBTCXdelayBuf[111]; /* 2.3125ms at 48kHz -> 111 samples */ /*TCX resisual Q*/ int16_t resQBits[NB_DIV]; /* number of bits read for the residual Quantization in TCX*/ @@ -398,14 +573,38 @@ typedef struct tcx_dec_structure float NoiseLevelMemory_bfi[PLC_MIN_STAT_BUFF_SIZE]; int16_t NoiseLevelIndex_bfi; int16_t CurrLevelIndex_bfi; - float LastFrameLevel_bfi; - float old_gaintcx_bfi; - float conceal_eof_gain; - float damping; - float gainHelper; - float stepCompensate; - int16_t tcxConceal_recalc_exc; - float cummulative_damping_tcx; + + Word16 conCngLevelBackgroundTrace; /* Q15 long term gain estimate for background level, used for PLC fade out */ + Word16 conCngLevelBackgroundTrace_e; + + float LastFrameLevel_bfi; + + Word16 conNoiseLevelMemory[PLC_MIN_STAT_BUFF_SIZE], conNoiseLevelMemory_e[PLC_MIN_STAT_BUFF_SIZE];/*Q15*/ + Word16 conNoiseLevelIndex; /*Q0*/ + Word16 conCurrLevelIndex; /*Q0*/ + Word16 conLastFrameLevel, conLastFrameLevel_e;/*Q15*/ + + float old_gaintcx_bfi_float; + Word16 old_gaintcx_bfi, old_gaintcx_bfi_e; + + float conceal_eof_gain_float; + Word16 conceal_eof_gain; /*Q14*/ + + float damping_float; + Word16 damping; /* 1Q14 */ + + + float gainHelper_float; + Word16 gainHelper, gainHelper_e; /*can be >1*/ + + float stepCompensate_float; + Word16 stepCompensate, stepCompensate_e; + + int16_t tcxConceal_recalc_exc; + + float cummulative_damping_tcx_float; + Word16 cummulative_damping_tcx; + } TCX_DEC_DATA, *TCX_DEC_HANDLE; @@ -417,16 +616,39 @@ typedef struct tcx_dec_structure typedef struct gsc_dec_structure { int16_t seed_tcx; /* AC mode (GSC) - seed for noise fill */ - int16_t cor_strong_limit; /* AC mode (GSC) - Indicator about high spectral correlation per band */ - float old_y_gain[MBANDS_GN16k]; /* AC mode (GSC) - AR mem for low rate gain quantization */ - int16_t noise_lev; /* AC mode (GSC) - noise level */ - float lt_ener_per_band[MBANDS_GN16k]; - float Last_frame_ener; /* AC mode (GSC) - last frame energy */ - float Last_GSC_spectrum[L_FRAME16k]; /* AC mode (GSC) - Last good GSC spectrum */ - int16_t Last_GSC_pit_band_idx; /* AC mode (GSC) - Last pitch band index */ - float last_exc_dct_in[L_FRAME16k]; /* AC mode (GSC) - previous excitation */ - float last_ener; /* AC mode (GSC) - previous energy */ - int16_t last_bitallocation_band[6]; /* AC mode (GSC) - previous bit allocation of each band */ + Word16 seed_tcx_fx; /* AC mode (GSC) - seed for noise fill Q0*/ + + int16_t cor_strong_limit; /* AC mode (GSC) - Indicator about high spectral correlation per band */ + Word16 cor_strong_limit_fx; /* AC mode (GSC) - Indicator about high spectral correlation per band */ + + float old_y_gain[MBANDS_GN16k]; /* AC mode (GSC) - AR mem for low rate gain quantization */ + Word16 old_y_gain_fx[MBANDS_GN]; /* AC mode (GSC) - AR mem for low rate gain quantization */ + + int16_t noise_lev; /* AC mode (GSC) - noise level */ + Word16 noise_lev_fx; /* AC mode (GSC) - noise level Q0*/ + + float lt_ener_per_band[MBANDS_GN16k]; + Word16 lt_ener_per_band_fx[MBANDS_GN]; /* Q12 */ + + float Last_frame_ener; /* AC mode (GSC) - last frame energy */ + Word32 Last_frame_ener_fx; /* AC mode (GSC) - last frame energy */ + + float Last_GSC_spectrum[L_FRAME16k]; /* AC mode (GSC) - Last good GSC spectrum */ + Word16 Last_GSC_spectrum_fx[L_FRAME]; /* AC mode (GSC) - Last good GSC spectrum */ + + int16_t Last_GSC_pit_band_idx; /* AC mode (GSC) - Last pitch band index */ + Word16 Last_GSC_pit_band_idx_fx; /* AC mode (GSC) - Last pitch band index Q0*/ + + float last_exc_dct_in[L_FRAME16k]; /* AC mode (GSC) - previous excitation */ + Word16 last_exc_dct_in_fx[L_FRAME]; /* AC mode (GSC) - previous excitation */ + + float last_ener; /* AC mode (GSC) - previous energy */ + Word16 last_ener_fx; /* AC mode (GSC) - previous energy */ + + int16_t last_bitallocation_band[6]; /* AC mode (GSC) - previous bit allocation of each band */ + Word16 last_bitallocation_band_fx[6]; /* AC mode (GSC) - previous bit allocation of each band */ + + //fixed } GSC_DEC_DATA, *GSC_DEC_HANDLE; @@ -438,26 +660,17 @@ typedef struct gsc_dec_structure typedef struct WI_dec_structure { float old_exc2[L_EXC_MEM]; /* FEC - old excitation2 used in fast recovery */ - float old_syn2[L_EXC_MEM]; /* FEC - old syn speech used in fast recovery */ + Word16 old_exc2_fx[L_EXC_MEM]; /* FEC - old excitation2 used in fast recovery */ + + float old_syn2[L_EXC_MEM]; /* FEC - old syn speech used in fast recovery */ + Word16 old_syn2_fx[L_EXC_MEM]; /* FEC - old syn speech used in fast recovery */ -} WI_DEC_DATA, *WI_DEC_HANDLE; + //fixed -/*----------------------------------------------------------------------------------* - * NB postfilter / formant postfilter static variables - *----------------------------------------------------------------------------------*/ +} WI_DEC_DATA, *WI_DEC_HANDLE; -typedef struct pfstat_structure -{ - int16_t on; /* On/off flag */ - int16_t reset; /* reset flag */ - float mem_pf_in[L_SUBFR]; /* Input memory */ - float mem_stp[L_SUBFR]; /* 1/A(gamma1) memory */ - float mem_res2[DECMEM_RES2]; /* A(gamma2) residual */ - float mem_zero[M]; /* null memory to compute i.r. of A(gamma2)/A(gamma1) */ - float gain_prec; /* for gain adjustment */ -} PFSTAT, *PFSTAT_HANDLE; /*----------------------------------------------------------------------------------* * LD music post-filter @@ -466,18 +679,46 @@ typedef struct pfstat_structure typedef struct ld_music_postfilt_structure { float LDm_mem_etot; /* LD music post-filter - total energy memory */ - int16_t LDm_last_music_flag; /* LD music post-filter - last music flag */ - int16_t LDm_nb_thr_1; /* LD music post-filter - number of consecutive frames of level 1 */ - int16_t LDm_nb_thr_3; - float dct_post_old_exc[DCT_L_POST - OFFSET2]; - float LDm_thres[4]; /* LD music post-filter - Classification threshold */ - float LDm_lt_diff_etot[MAX_LT]; /* LD music post-filter - long-term total energy variation */ - float LDm_enh_lp_gbin[VOIC_BINS_HR]; /* LD music post-filter - smoothed suppression gain, per bin FFT */ - float LDm_enh_lf_EO[VOIC_BINS_HR]; /* LD music post-filter - old per bin E for previous half frame */ - float LDm_enh_min_ns_gain; /* LD music post-filter - minimum suppression gain */ - float LDm_bckr_noise[MBANDS_GN_LD]; /* LD music post-filter - background noise estimation per critical band */ - float filt_lfE[DCT_L_POST]; - int16_t last_nonfull_music; + Word16 LDm_mem_etot_fx; /* LD music post-filter - total energy memory */ + + int16_t LDm_last_music_flag; /* LD music post-filter - last music flag */ + Word16 LDm_last_music_flag_fx; /* LD music post-filter - last music flag */ + + int16_t LDm_nb_thr_1; /* LD music post-filter - number of consecutive frames of level 1 */ + Word16 LDm_nb_thr_1_fx; /* LD music post-filter - number of consecutives frames of level 1 */ + + int16_t LDm_nb_thr_3; + Word16 LDm_nb_thr_3_fx; + + float dct_post_old_exc[DCT_L_POST - OFFSET2]; + Word16 dct_post_old_exc_fx[DCT_L_POST - OFFSET2]; + + float LDm_thres[4]; /* LD music post-filter - Classification threshold */ + Word16 LDm_thres_fx[4]; /* LD music post-filter - Classification threshold */ + + float LDm_lt_diff_etot[MAX_LT]; /* LD music post-filter - long-term total energy variation */ + Word16 LDm_lt_diff_etot_fx[MAX_LT]; /* LD music post-filter - long-term total energy variation */ + + float LDm_enh_lp_gbin[VOIC_BINS_HR]; /* LD music post-filter - smoothed suppression gain, per bin FFT */ + Word16 LDm_enh_lp_gbin_fx[VOIC_BINS_HR]; /* LD music post-filter - smoothed suppression gain, per bin FFT */ + + float LDm_enh_lf_EO[VOIC_BINS_HR]; /* LD music post-filter - old per bin E for previous half frame */ + Word32 LDm_enh_lf_EO_fx[VOIC_BINS_HR]; /* LD music post-filter - old per bin E for previous half frame */ + + float LDm_enh_min_ns_gain; /* LD music post-filter - minimum suppression gain */ + Word16 LDm_enh_min_ns_gain_fx; /* LD music post-filter - minimum suppression gain */ + + float LDm_bckr_noise[MBANDS_GN_LD]; /* LD music post-filter - background noise estimation per critical band */ + Word32 LDm_bckr_noise_fx[MBANDS_GN_LD]; /* LD music post-filter - background noise estimation per critical band */ + + float filt_lfE[DCT_L_POST]; + Word16 filt_lfE_fx[DCT_L_POST]; + + int16_t last_nonfull_music; + Word16 last_nonfull_music_fx; + + Word16 Old_ener_Q; /* Old energy scaling factor */ + } MUSIC_POSTFILT_DATA, *MUSIC_POSTFILT_HANDLE; @@ -488,12 +729,28 @@ typedef struct ld_music_postfilt_structure typedef struct bass_postfilt_structure { float pst_old_syn[NBPSF_PIT_MAX]; /* Bass post-filter - old synthesis buffer 1 */ - float pst_mem_deemp_err; /* Bass post-filter - filter memory of noise LP filter */ - float pst_lp_ener; /* Bass post-filter - long-term energy */ - int16_t Track_on_hist[L_TRACK_HIST]; /* Bass post-filter - History of half frame usage */ - int16_t vibrato_hist[L_TRACK_HIST]; /* Bass post-filter - History of frames declared as vibrato */ - float psf_att; /* Bass post-filter - post filter attenuation factor */ - float mem_mean_pit[L_TRACK_HIST]; /* Bass post-filter - average pitch memory */ + Word16 pst_old_syn_fx[NBPSF_PIT_MAX]; /* Bass post-filter - old synthesis buffer 1 Q_syn2-1*/ + + float pst_mem_deemp_err; /* Bass post-filter - filter memory of noise LP filter */ + Word16 pst_mem_deemp_err_fx; /* Bass post-filter - filter memory of noise LP filter Q_syn2-1*/ + + float pst_lp_ener; /* Bass post-filter - long-term energy */ + Word16 pst_lp_ener_fx; /* Bass post-filter - long-term energy Q8*/ + + int16_t Track_on_hist[L_TRACK_HIST]; /* Bass post-filter - History of half frame usage */ + Word16 Track_on_hist_fx[L_TRACK_HIST]; /* Bass post-filter - History of half frame usage */ + + int16_t vibrato_hist[L_TRACK_HIST]; /* Bass post-filter - History of frames declared as vibrato */ + Word16 vibrato_hist_fx[L_TRACK_HIST]; /* Bass post-filter - History of frames declared as vibrato */ + + float psf_att; /* Bass post-filter - post filter attenuation factor */ + Word16 psf_att_fx; /* Bass post-filter - post filter attenuation factor */ + + float mem_mean_pit[L_TRACK_HIST]; /* Bass post-filter - average pitch memory */ + Word16 mem_mean_pit_fx[L_TRACK_HIST]; /* Bass post-filter - average pitch memory */ + + //fixed + } BPF_DEC_DATA, *BPF_DEC_HANDLE; @@ -504,30 +761,83 @@ typedef struct bass_postfilt_structure typedef struct td_cng_dec_structure { int16_t cng_seed; /* DTX/CNG - seed for white noise random generator */ - float Enew; /* DTX/CNG - decoded residual energy */ - int16_t old_enr_index; /* DTX/CNG - index of last encoded CNG energy */ - int16_t cng_ener_seed; /* DTX/CNG - seed for random generator for variation of excitation energy */ - int16_t cng_ener_seed1; - int16_t last_allow_cn_step; - int16_t ho_hist_size; /* DTX/CNG - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ - int16_t ho_hist_ptr; /* DTX/CNG - pointer for averaging buffers */ - int16_t ho_sid_bw; /* DTX/CNG - SID bandwidth flags */ + Word16 cng_seed_fx; /*CNG and DTX - seed for white noise random generator*/ + + float Enew; /* DTX/CNG - decoded residual energy */ + Word32 Enew_fx; /* CNG and DTX - decoded residual energy Q6*/ + + int16_t old_enr_index; /* DTX/CNG - index of last encoded CNG energy */ + Word16 old_enr_index_fx; /* CNG and DTX - index of last encoded CNG energy Q0*/ + + int16_t cng_ener_seed; /* DTX/CNG - seed for random generator for variation of excitation energy */ + Word16 cng_ener_seed_fx; /*CNG and DTX - seed for random generator for variation of excitation energyQ0*/ + + int16_t cng_ener_seed1; + Word16 cng_ener_seed1_fx; + + int16_t last_allow_cn_step; + Word16 last_allow_cn_step_fx; /*Q0*/ + + int16_t ho_hist_size; /* DTX/CNG - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ + Word16 ho_hist_size_fx; /* CNG and DTX - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ + + int16_t ho_hist_ptr; /* DTX/CNG - pointer for averaging buffers */ + Word16 ho_hist_ptr_fx; /* CNG and DTX - pointer for averaging buffers */ + + int16_t ho_sid_bw; /* DTX/CNG - SID bandwidth flags */ + Word32 ho_sid_bw_fx; /* CNG and DTX - SID bandwidth flags */ + float ho_lsp_hist[HO_HIST_SIZE * M]; /* DTX/CNG - old LSP buffer for averaging */ - float ho_ener_hist[HO_HIST_SIZE]; /* DTX/CNG - energy buffer for averaging */ - float ho_env_hist[HO_HIST_SIZE * NUM_ENV_CNG]; + Word16 ho_lsp_hist_fx[HO_HIST_SIZE * M]; /* CNG and DTX - old LSP buffer for averaging */ + + float ho_ener_hist[HO_HIST_SIZE]; /* DTX/CNG - energy buffer for averaging */ + Word32 ho_ener_hist_fx[HO_HIST_SIZE]; /* CNG and DTX - energy buffer for averaging */ /*Q6 */ + + float ho_env_hist[HO_HIST_SIZE * NUM_ENV_CNG]; + Word32 ho_env_hist_fx[HO_HIST_SIZE * NUM_ENV_CNG]; + + int16_t act_cnt; /* DTX/CNG - counter of active frames */ - int16_t ho_circ_size; /* DTX/CNG - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ - int16_t ho_circ_ptr; /* DTX/CNG - pointer for averaging buffers */ - float ho_lsp_circ[HO_HIST_SIZE * M]; /* DTX/CNG - old LSP buffer for averaging */ - float ho_ener_circ[HO_HIST_SIZE]; /* DTX/CNG - energy buffer for averaging */ - float ho_env_circ[HO_HIST_SIZE * NUM_ENV_CNG]; - int16_t num_ho; /* DTX/CNG - number of selected hangover frames */ - int16_t ho_16k_lsp[HO_HIST_SIZE]; /* DTX/CNG - 16k LSPs flags */ + Word16 act_cnt_fx; /* CNG and DTX - counter of active frames */ + + int16_t ho_circ_size; /* DTX/CNG - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ + Word16 ho_circ_size_fx; /* CNG and DTX - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ + + int16_t ho_circ_ptr; /* DTX/CNG - pointer for averaging buffers */ + Word16 ho_circ_ptr_fx; /* CNG and DTX - pointer for averaging buffers */ + + + float ho_lsp_circ[HO_HIST_SIZE * M]; /* DTX/CNG - old LSP buffer for averaging */ + Word16 ho_lsp_circ_fx[HO_HIST_SIZE * M]; /* CNG and DTX - old LSP buffer for averaging */ + + float ho_ener_circ[HO_HIST_SIZE]; /* DTX/CNG - energy buffer for averaging */ + Word32 ho_ener_circ_fx[HO_HIST_SIZE]; /* CNG and DTX - energy buffer for averaging */ /* Q6 */ + + float ho_env_circ[HO_HIST_SIZE * NUM_ENV_CNG]; + Word32 ho_env_circ_fx[HO_HIST_SIZE * NUM_ENV_CNG]; + + + int16_t num_ho; /* DTX/CNG - number of selected hangover frames */ + Word16 num_ho_fx; /* DTX/CNG - number of selected hangover frames */ + + int16_t ho_16k_lsp[HO_HIST_SIZE]; /* DTX/CNG - 16k LSPs flags */ + Word16 ho_16k_lsp_fx[HO_HIST_SIZE]; /* DTX/CNG - 16k LSPs flags */ + + int16_t act_cnt2; /* DTX/CNG - counter of active frames for CNG_mode switching */ - float old_env[20]; - float lp_env[20]; - float exc_mem[24]; - float exc_mem1[30]; + Word16 act_cnt2_fx; /* DTX/CNG - counter of active frames for CNG_mode switching */ + + float old_env[20]; + Word32 old_env_fx[20]; + + float lp_env[20]; + Word32 lp_env_fx[20]; + + float exc_mem[24]; + Word16 exc_mem_fx[24]; + + float exc_mem1[30]; + Word16 exc_mem1_fx[30]; float interpol_3_2_cng_dec[INTERP_3_2_MEM_LEN]; @@ -544,8 +854,16 @@ typedef struct td_cng_dec_structure float lsp_shb_prev[LPC_SHB_ORDER]; int16_t shb_dtx_count; int16_t trans_cnt; - int16_t burst_cnt; - float last_shb_ener; + + int16_t burst_cnt; + Word16 burst_cnt_fx; + + float last_shb_ener; + + Word16 last_cng_type_fx; /* DTX/CNG - flag indicating last frame LP or CLDFB based SID/CNG */ + + //fixed + } TD_CNG_DEC_DATA, *TD_CNG_DEC_HANDLE; @@ -553,31 +871,73 @@ typedef struct td_cng_dec_structure * SC-VBR structure *----------------------------------------------------------------------------------*/ + typedef struct sc_vbr_dec_structure { int16_t firstTime_voiceddec; + Word16 firstTime_voiceddec_fx; /*Q0*/ /* DTFS variables */ float dtfs_dec_a[MAXLAG_WI]; - float dtfs_dec_b[MAXLAG_WI]; + Word16 dtfs_dec_a_fx[MAXLAG_WI]; /*Variable Q format in dtfs_dec_Q*/ + + float dtfs_dec_b[MAXLAG_WI]; + Word16 dtfs_dec_b_fx[MAXLAG_WI]; /*Variable Q format in dtfs_dec_Q*/ + int16_t dtfs_dec_lag; - int16_t dtfs_dec_nH; - int16_t dtfs_dec_nH_4kHz; + Word16 dtfs_dec_lag_fx; + + int16_t dtfs_dec_nH; + Word16 dtfs_dec_nH_fx; + + int16_t dtfs_dec_nH_4kHz; + Word16 dtfs_dec_nH_4kHz_fx; /*Q0*/ + + float dtfs_dec_upper_cut_off_freq_of_interest; + Word16 dtfs_dec_upper_cut_off_freq_of_interest_fx; /*Q0*/ + float dtfs_dec_upper_cut_off_freq; - float ph_offset_D; - float lastLgainD; /* previous gain value for the low band */ - float lastHgainD; /* previous gain value for the high band */ - float lasterbD[NUM_ERB_WB]; /* previous amplitude spectrum (ERB) */ + Word16 dtfs_dec_upper_cut_off_freq_fx; /*Q0*/ + + float ph_offset_D; + Word16 ph_offset_D_fx; /* normalized by 2Pi Q15*/ + + float lastLgainD; /* previous gain value for the low band */ + Word16 lastLgainD_fx; /* previous gain value for the low band Q11*/ + + float lastHgainD; /* previous gain value for the high band */ + Word16 lastHgainD_fx; /* previous gain value for the high band Q11 */ + + float lasterbD[NUM_ERB_WB]; /* previous amplitude spectrum (ERB) */ + Word16 lasterbD_fx[NUM_ERB_WB]; /* previous amplitude spectrum (ERB) Q13*/ + + Word16 dtfs_dec_Q; /*Q0*/ /* NELP decoder variables */ float bp1_filt_mem_nb_dec[14]; - float bp1_filt_mem_wb_dec[8]; + Word32 bp1_filt_mem_nb_dec_fx[14]; /* qfm currently Q0*/ + + float bp1_filt_mem_wb_dec[8]; + Word16 bp1_filt_mem_wb_dec_fx[8]; /* qfm currently Q0*/ + float shape1_filt_mem_dec[20]; + Word16 shape1_filt_mem_dec_fx[10]; /* qfm currently Q0*/ + float shape2_filt_mem_dec[20]; + Word16 shape2_filt_mem_dec_fx[10]; /* qfm currently Q0*/ + + float shape3_filt_mem_dec[20]; + Word16 shape3_filt_mem_dec_fx[10]; /* qfm currently Q0*/ + int16_t nelp_dec_seed; + Word16 nelp_dec_seed_fx; /* Q0*/ + + Word16 FadeScale_fx; /*Q15*/ + //fixed + } SC_VBR_DEC_DATA, *SC_VBR_DEC_HANDLE; @@ -588,25 +948,68 @@ typedef struct sc_vbr_dec_structure typedef struct hq_nbfec_structure { int16_t prev_last_core; /* !!! note: the parameter is identical to last_core in IVAS */ + Word16 prev_last_core_fx; /* !!! note: the parameter is identical to last_core in IVAS */ float diff_energy; + Word16 diff_energy_fx; + int16_t stat_mode_out; + Word16 stat_mode_out_fx; + int16_t stat_mode_old; + Word16 stat_mode_old_fx; + + int16_t phase_mat_flag; - int16_t phase_mat_next; + Word16 phase_mat_flag_fx; + + int16_t phase_mat_next; + Word16 phase_mat_next_fx; + int16_t old_Min_ind; - float old_auOut_2fr[L_FRAME8k * 2]; - float old_out_pha[2][N_LEAD_NB]; /* FEC for HQ Core, 0-phase matching old_out, 1-overlapping original old_out and phase matching old_out*/ - float ynrm_values[MAX_SB_NB][MAX_PGF]; - float r_p_values[MAX_SB_NB][MAX_ROW]; + Word16 old_Min_ind_fx; + + float old_auOut_2fr[L_FRAME8k * 2]; + Word16 old_auOut_2fr_fx[L_FRAME8k * 2]; + + float old_out_pha[2][N_LEAD_NB]; /* FEC for HQ Core, 0-phase matching old_out, 1-overlapping original old_out and phase matching old_out*/ + Word16 old_out_pha_fx[2][N_LEAD_NB]; /* FEC for HQ Core, 0-phase matching old_out, 1-overlapping original old_out and phase matching old_out*/ + + float ynrm_values[MAX_SB_NB][MAX_PGF]; + Word32 ynrm_values_fx[MAX_SB_NB][MAX_PGF]; + + float r_p_values[MAX_SB_NB][MAX_ROW]; + Word32 r_p_values_fx[MAX_SB_NB][MAX_ROW]; + float Norm_gain[SFM_N_NB]; + Word16 Norm_gain_fx[SFM_N_NB]; + + /*Word16 old_hqswb_clas;*/ /* only used in inactive code, where it might probably be replaced by old_hqswb_clas_fx */ + + + int16_t HQ_FEC_seed; + Word16 HQ_FEC_seed_fx; + float energy_MA_Curr[2]; - int16_t prev_sign_switch[HQ_FEC_SIGN_SFM]; - int16_t prev_sign_switch_2[HQ_FEC_SIGN_SFM]; - float old_coeffs[L_FRAME8k]; /* HQ core - old coefficients (for FEC) */ - float oldIMDCTout[L_FRAME8k / 2]; - float prev_oldauOut[L_FRAME8k]; + Word16 energy_MA_Curr_fx[2]; + + int16_t prev_sign_switch[HQ_FEC_SIGN_SFM]; + Word16 prev_sign_switch_fx[HQ_FEC_SIGN_SFM]; + + int16_t prev_sign_switch_2[HQ_FEC_SIGN_SFM]; + Word16 prev_sign_switch_2_fx[HQ_FEC_SIGN_SFM]; + + float old_coeffs[L_FRAME8k]; /* HQ core - old coefficients (for FEC) */ + Word32 old_coeffs_fx[L_FRAME8k]; /* HQ core - old coefficients (for FEC) */ + + float oldIMDCTout[L_FRAME8k / 2]; + Word32 oldIMDCTout_fx[L_FRAME8k / 2]; + + float prev_oldauOut[L_FRAME8k]; + Word16 prev_oldauOut_fx[L_FRAME8k]; + + //fixed } HQ_NBFEC_DATA, *HQ_NBFEC_HANDLE; @@ -617,43 +1020,113 @@ typedef struct hq_nbfec_structure typedef struct hq_dec_structure { float old_out[L_FRAME48k]; /* HQ core - previous synthesis for OLA */ - float old_outLB[L_FRAME32k]; - int16_t last_hq_core_type; - int16_t old_is_transient[3]; /* HQ core - previous transient flag (for FEC and BWE/NF) */ + Word16 old_out_fx[L_FRAME48k]; /* HQ core - previous synthesis for OLA */ + + float old_outLB[L_FRAME32k]; + Word16 old_out_LB_fx[L_FRAME32k]; /* HQ core - previous synthesis for OLA for Low Band */ + + Word16 Q_old_wtda_LB; + Word16 Q_old_wtda; + Word16 Q_old_postdec; /*scaling of the output of core_switching_post_dec_fx() */ + + int16_t last_hq_core_type; + Word16 last_hq_core_type_fx; /*Q0*/ + + int16_t old_is_transient[3]; /* HQ core - previous transient flag (for FEC and BWE/NF) */ + Word16 old_is_transient_fx[3]; /* HQ core - previous transient flag (for FEC) */ int16_t mem_norm[SFM_N_ENV_STAB]; + Word16 mem_norm_fx[SFM_N_ENV_STAB]; /* Q0 */ + int16_t mem_env_delta; - int16_t no_att_hangover; - float energy_lt; - int16_t hq_generic_seed; - float prev_noise_level[2]; - int16_t prev_hqswb_clas; - int16_t prev_R; /* the table of bit allocation of last frame */ - float prev_coeff_out[L_HQ_WB_BWE]; /* the highest coefficients of last frame */ + Word16 mem_env_delta_fx; /* Q11 */ + + int16_t no_att_hangover; + Word16 no_att_hangover_fx; /* Q0 */ + + float energy_lt; + Word32 energy_lt_fx; /* Q13 */ + + int16_t hq_generic_seed; + Word16 hq_generic_seed_fx; + + float prev_noise_level[2]; + Word16 prev_noise_level_fx[2]; /* Q15 */ + + int16_t prev_hqswb_clas; + Word16 prev_hqswb_clas_fx; + + int16_t prev_R; /* the table of bit allocation of last frame */ + Word16 prev_R_fx; /* the table of bit allocation of last frame */ + + float prev_coeff_out[L_HQ_WB_BWE]; /* the highest coefficients of last frame */ int16_t prev_SWB_peak_pos[SPT_SHORTEN_SBNUM]; + + Word32 prev_coeff_out_fx[L_HQ_WB_BWE]; /* Q12 */ /* the coefficients of last frame */ + Word16 prev_SWB_peak_pos_fx[SPT_SHORTEN_SBNUM]; + int16_t HqVoicing; - float fer_samples[L_FRAME48k]; - float prev_normq[SFM_N_WB]; /* previous norms */ - float prev_env[SFM_N_WB]; /* previous noise envelopes */ + Word16 HqVoicing_fx; + + float fer_samples[L_FRAME48k]; + Word16 fer_samples_fx[L_FRAME48k]; + + float prev_normq[SFM_N_WB]; /* previous norms */ + Word32 prev_normq_fx[SFM_N_WB]; /* Q14 */ /* previous norms */ + + float prev_env[SFM_N_WB]; /* previous noise envelopes */ + Word32 prev_env_fx[SFM_N_WB]; /* previous noise envelopes */ + + Word16 prev_env_Q[SFM_N_WB]; + + float last_ni_gain[BANDS_MAX]; + Word32 last_ni_gain_fx[BANDS_MAX]; + + float last_env[BANDS_MAX]; + Word16 last_env_fx[BANDS_MAX]; - float last_ni_gain[BANDS_MAX]; - float last_env[BANDS_MAX]; int16_t last_max_pos_pulse; + Word16 last_max_pos_pulse_fx; /* pre-echo reduction */ float memfilt_lb; - float mean_prev_hb; - float smoothmem; - float mean_prev; - float mean_prev_nc; - float wmold_hb; - int16_t prevflag; - int16_t pastpre; + Word16 memfilt_lb_fx; /* Q0 */ + + float mean_prev_hb; + Word32 mean_prev_hb_fx; /* Q0 */ + + float smoothmem; + Word16 smoothmem_fx; /* Q15 */ + + float mean_prev; + Word32 mean_prev_fx; /* Q0 */ + + float mean_prev_nc; + Word32 mean_prev_nc_fx; /* Q0 */ + + float wmold_hb; + Word16 wmold_hb_fx; /* Q15 */ + + int16_t prevflag; + Word16 prevflag_fx; /* Q0 */ + + int16_t pastpre; + Word16 pastpre_fx; /* Q0 */ + + int16_t prev_frm_hfe2; - int16_t prev_stab_hfe2; - float prev_ni_ratio; - float prev_En_sb[NB_SWB_SUBBANDS]; + Word16 prev_frm_hfe2_fx; + + int16_t prev_stab_hfe2; + Word16 prev_stab_hfe2_fx; + + float prev_ni_ratio; + Word16 prev_ni_ratio_fx; /* 15 */ + + float prev_En_sb[NB_SWB_SUBBANDS]; + Word16 prev_En_sb_fx[NB_SWB_SUBBANDS]; /* QsEn(4) */ + /*----------------------------------------------------------------------------------* * HQ FEC @@ -661,28 +1134,69 @@ typedef struct hq_dec_structure /* HQ PHASE ECU internal state */ int16_t time_offs; - float X_sav[PH_ECU_SPEC_SIZE]; - int16_t num_p; - int16_t plocs[MAX_PLOCS]; - float plocsi[MAX_PLOCS]; - float env_stab; - int16_t mem_norm_hqfec[SFM_N_ENV_STAB]; - int16_t mem_env_delta_hqfec; - float env_stab_plc; - float env_stab_state_p[NUM_ENV_STAB_PLC_STATES]; - int16_t envstabplc_hocnt; + Word16 time_offs_fx; + + float X_sav[PH_ECU_SPEC_SIZE]; + Word16 X_sav_fx[PH_ECU_SPEC_SIZE]; + + Word16 Q_X_sav; + + int16_t num_p; + Word16 num_p_fx; + + int16_t plocs[MAX_PLOCS]; + Word16 plocs_fx[MAX_PLOCS]; + + float plocsi[MAX_PLOCS]; + Word32 plocsi_fx[MAX_PLOCS]; + + float env_stab; + Word16 env_stab_fx; + + int16_t mem_norm_hqfec[SFM_N_ENV_STAB]; + Word16 mem_norm_hqfec_fx[SFM_N_ENV_STAB]; + + int16_t mem_env_delta_hqfec; + Word16 mem_env_delta_hqfec_fx; + + float env_stab_plc; + Word16 env_stab_plc_fx; + + float env_stab_state_p[NUM_ENV_STAB_PLC_STATES]; + Word16 env_stab_state_p_fx[NUM_ENV_STAB_PLC_STATES]; + + int16_t envstabplc_hocnt; + Word16 envstabplc_hocnt_fx; float mag_chg_1st[LGW_MAX]; /* i/o: per band magnitude modifier for transients*/ - float Xavg[LGW_MAX]; /* Frequency group average gain to fade to */ - float beta_mute; /* Factor for long-term mute */ + Word16 mag_chg_1st_fx[LGW_MAX]; /* i/o: per band magnitude modifier for transients*/ + + float Xavg[LGW_MAX]; /* Frequency group average gain to fade to */ + Word16 Xavg_fx[LGW_MAX]; /* Frequency group average gain to fade to */ + + float beta_mute; /* Factor for long-term mute */ + Word16 beta_mute_fx; /* Factor for long-term mute */ int16_t last_fec; - int16_t ph_ecu_HqVoicing; - int16_t oldHqVoicing; - float oldgapsynth[L_FRAME48k]; - int16_t ph_ecu_active; /* Set to 1 if Phase ECU was used in last bad frame; Set to 2 if TCX TD PLC was used */ - int16_t ni_seed_forfec; - int16_t ber_occured_in_pvq; /* flag for BER detection from PVQ routines */ + Word16 last_fec_fx; + + int16_t ph_ecu_HqVoicing; + Word16 ph_ecu_HqVoicing_fx; + + int16_t oldHqVoicing; + Word16 oldHqVoicing_fx; + + float oldgapsynth[L_FRAME48k]; + Word16 oldgapsynth_fx[L_FRAME48k]; + + int16_t ph_ecu_active; /* Set to 1 if Phase ECU was used in last bad frame; Set to 2 if TCX TD PLC was used */ + Word16 ph_ecu_active_fx; /* Set if Phase ECU was used in last bad frame */ + + int16_t ni_seed_forfec; + + int16_t ber_occured_in_pvq; /* flag for BER detection from PVQ routines */ + + //fixed } HQ_DEC_DATA, *HQ_DEC_HANDLE; @@ -694,11 +1208,25 @@ typedef struct hq_dec_structure typedef struct zero_bwe_dec_structure { int16_t seed2; /* HF (6-7kHz) BWE - seed for random signal generator */ - float mem_hp400[4]; /* HF (6-7kHz) BWE - hp400 filter memory */ - float mem_hf[( L_FIR - 1 )]; /* HF (6-7kHz) BWE - band-pass filter memory */ - float mem_syn_hf[M]; /* HF (6-7kHz) BWE - synthesis filter memory */ - float delay_syn_hf[NS2SA( 16000, DELAY_CLDFB_NS )]; /* HF (6-7kHz) BWE - To synchronise BWE content with postfiltered synthesis */ - float mem_hp_interp[INTERP_3_1_MEM_LEN]; /* HF (6-7 kHz) BWE - interp. memory */ + Word16 seed2_fx; /* HF (6-7kHz) BWE - seed for random signal generator Q0*/ + + float mem_hp400[4]; /* HF (6-7kHz) BWE - hp400 filter memory */ + Word16 mem_hp400_fx[6]; /* HF (6-7kHz) BWE - hp400 filter memory */ + + float mem_hf[( L_FIR - 1 )]; /* HF (6-7kHz) BWE - band-pass filter memory */ + Word16 mem_hf_fx[2 * L_FILT16k]; /* HF (6-7kHz) BWE - band-pass filter memory Q(-2-memExp1)*/ + + float mem_syn_hf[M]; /* HF (6-7kHz) BWE - synthesis filter memory */ + Word16 mem_syn_hf_fx[M]; /* HF (6-7kHz) BWE - synthesis filter memory Q0*/ + + float delay_syn_hf[NS2SA( 16000, DELAY_CLDFB_NS )]; /* HF (6-7kHz) BWE - To synchronise BWE content with postfiltered synthesis */ + Word16 delay_syn_hf_fx[NS2SA(16000, DELAY_CLDFB_NS)]; /* HF (6-7kHz) BWE - To synchronise BWE content with postfiltered synthesis Q0*/ + + float mem_hp_interp[INTERP_3_1_MEM_LEN]; /* HF (6-7 kHz) BWE - interp. memory */ + Word16 mem_hp_interp_fx[INTERP_3_1_MEM_LEN]; /* HF (6-7 kHz) BWE - interp. memory */ + + //fixed + } ZERO_BWE_DEC_DATA, *ZERO_BWE_DEC_HANDLE; @@ -711,83 +1239,202 @@ typedef struct td_bwe_dec_structure { /* states for the filters used in generating SHB excitation from WB excitation */ float state_lpc_syn[LPC_SHB_ORDER]; + Word16 state_lpc_syn_fx[LPC_SHB_ORDER]; + float mem_csfilt[2]; + Word32 mem_csfilt_fx[2]; /* states for the filters used in generating SHB signal from SHB excitation*/ float state_syn_shbexc[L_SHB_LAHEAD]; - float syn_overlap[L_SHB_LAHEAD]; /* overlap buffer used to Adjust SHB Frame Gain*/ + Word16 state_syn_shbexc_fx[L_SHB_LAHEAD]; + + float syn_overlap[L_SHB_LAHEAD]; /* overlap buffer used to Adjust SHB Frame Gain*/ + Word16 syn_overlap_fx[L_SHB_LAHEAD]; /* overlap buffer used to Adjust SHB Frame Gain*/ /* previous frame parameters for frame error concealment */ float lsp_prevfrm[LPC_SHB_ORDER]; - float GainFrame_prevfrm; - float GainShape_Delay[NUM_SHB_SUBFR / 2]; - float GainAttn; + Word16 lsp_prevfrm_fx[LPC_SHB_ORDER]; + + float GainFrame_prevfrm; + Word32 GainFrame_prevfrm_fx; + + float GainShape_Delay[NUM_SHB_SUBFR / 2]; + + float GainAttn; + Word16 GainAttn_fx; + float old_bwe_exc[PIT16k_MAX * 2]; /* old excitation */ - int16_t bwe_seed[2]; - float bwe_non_lin_prev_scale; - float old_bwe_exc_extended[NL_BUFF_OFFSET]; + Word16 old_bwe_exc_fx[PIT16k_MAX * 2]; /*Q_exc*/ + + int16_t bwe_seed[2]; + Word16 bwe_seed_fx[2]; /*Q0*/ + + float bwe_non_lin_prev_scale; + Word32 bwe_non_lin_prev_scale_fx; + + float old_bwe_exc_extended[NL_BUFF_OFFSET]; + Word16 old_bwe_exc_extended_fx[NL_BUFF_OFFSET]; + + float genSHBsynth_Hilbert_Mem[HILBERT_MEM_SIZE]; + Word32 genSHBsynth_Hilbert_Mem_fx[HILBERT_MEM_SIZE]; float mem_genSHBexc_filt_down_shb[( 2 * ALLPASSSECTIONS_STEEP + 1 )]; - float mem_genSHBexc_filt_down_wb2[( 2 * ALLPASSSECTIONS_STEEP + 1 )]; - float mem_genSHBexc_filt_down_wb3[( 2 * ALLPASSSECTIONS_STEEP + 1 )]; - float genSHBsynth_state_lsyn_filt_shb_local[2 * ALLPASSSECTIONS_STEEP]; - float state_lsyn_filt_shb[2 * ALLPASSSECTIONS_STEEP]; - float state_lsyn_filt_dwn_shb[2 * ALLPASSSECTIONS_STEEP]; - float mem_resamp_HB[INTERP_3_1_MEM_LEN]; - float mem_resamp_HB_32k[2 * ALLPASSSECTIONS_STEEP + 1]; - float prev_pow_exc16kWhtnd; /* power of the LB excitation signal in the previous frame */ + Word16 mem_genSHBexc_filt_down_shb_fx[2 * ALLPASSSECTIONS_STEEP + 1]; + + float mem_genSHBexc_filt_down_wb2[( 2 * ALLPASSSECTIONS_STEEP + 1 )]; + Word16 mem_genSHBexc_filt_down_wb2_fx[2 * ALLPASSSECTIONS_STEEP + 1]; + + float mem_genSHBexc_filt_down_wb3[( 2 * ALLPASSSECTIONS_STEEP + 1 )]; + Word16 mem_genSHBexc_filt_down_wb3_fx[2 * ALLPASSSECTIONS_STEEP + 1]; + + float genSHBsynth_state_lsyn_filt_shb_local[2 * ALLPASSSECTIONS_STEEP]; + Word16 genSHBsynth_state_lsyn_filt_shb_local_fx[2 * ALLPASSSECTIONS_STEEP]; + + float state_lsyn_filt_shb[2 * ALLPASSSECTIONS_STEEP]; + Word16 state_lsyn_filt_shb_fx[2 * ALLPASSSECTIONS_STEEP]; + + float state_lsyn_filt_dwn_shb[2 * ALLPASSSECTIONS_STEEP]; + Word16 state_lsyn_filt_dwn_shb_fx[2 * ALLPASSSECTIONS_STEEP]; + + float mem_resamp_HB[INTERP_3_1_MEM_LEN]; + Word16 mem_resamp_HB_fx[INTERP_3_1_MEM_LEN]; + + float mem_resamp_HB_32k[2 * ALLPASSSECTIONS_STEEP + 1]; + Word16 mem_resamp_HB_32k_fx[2 * ALLPASSSECTIONS_STEEP + 1]; + + Word16 state_32and48k_WB_upsample_fx[2 * ALLPASSSECTIONS_STEEP]; /* !!! this memory in FLP is called mem_resamp_HB */ + + float prev_pow_exc16kWhtnd; /* power of the LB excitation signal in the previous frame */ float prev_mix_factor; /* mixing factor in the previous frame */ int16_t syn_dm_phase; + Word16 syn_dm_phase_fx; + float fbbwe_hpf_mem[4][4]; - float prev_wb_bwe_frame_pow; - float prev_swb_bwe_frame_pow; - float prev_ener; - float prev_GainShape; - float fb_state_lpc_syn[LPC_SHB_ORDER]; - float fb_tbe_demph; - float prev_fbbwe_ratio; + Word32 fbbwe_hpf_mem_fx[4][4]; + + Word16 fbbwe_hpf_mem_fx_Q[4]; + + float prev_wb_bwe_frame_pow; + Word32 prev_wb_bwe_frame_pow_fx; + + float prev_swb_bwe_frame_pow; + Word32 prev_swb_bwe_frame_pow_fx; + + float prev_ener; + Word32 prev_ener_fx; + + float prev_GainShape; + Word16 prev_GainShape_fx; + + float fb_state_lpc_syn[LPC_SHB_ORDER]; + Word16 fb_state_lpc_syn_fx[LPC_SHB_ORDER]; + + //Word16 prev_Q_bwe_exc_fb; + //Word16 prev_Qx; + //Word16 prev_Q_bwe_exc; + //Word16 prev_Q_synth; + + float fb_tbe_demph; + Word16 fb_tbe_demph_fx; + + float prev_fbbwe_ratio; + Word16 prev_fbbwe_ratio_fx; + float tbe_demph; + Word16 tbe_demph_fx; + float tbe_premph; - float mem_stp_swb[LPC_SHB_ORDER]; - float *ptr_mem_stp_swb; - float gain_prec_swb; - float mem_zero_swb[LPC_SHB_ORDER]; + Word16 tbe_premph_fx; + + float mem_stp_swb[LPC_SHB_ORDER]; + Word16 mem_stp_swb_fx[LPC_SHB_ORDER]; + + float *ptr_mem_stp_swb; + Word16* ptr_mem_stp_swb_fx; + + float gain_prec_swb; + Word16 gain_prec_swb_fx; + + float mem_zero_swb[LPC_SHB_ORDER]; + Word16 mem_zero_swb_fx[LPC_SHB_ORDER]; float swb_lsp_prev_interp[LPC_SHB_ORDER]; - float prev1_shb_ener_sf, prev2_shb_ener_sf, prev3_shb_ener_sf, prev_res_shb_gshape, prev_mixFactors; - float tilt_mem; /* Formant factor adaptation tilt smoothing memory */ - float prev_lsf_diff[LPC_SHB_ORDER - 2]; - float prev_tilt_para; - float cur_sub_Aq[M + 1]; + Word16 swb_lsp_prev_interp_fx[LPC_SHB_ORDER]; + + float prev1_shb_ener_sf, prev2_shb_ener_sf, prev3_shb_ener_sf, prev_res_shb_gshape, prev_mixFactors; + Word32 prev1_shb_ener_sf_fx, prev2_shb_ener_sf_fx, prev3_shb_ener_sf_fx; + + Word16 prev_res_shb_gshape_fx, prev_mixFactors_fx; + + float tilt_mem; /* Formant factor adaptation tilt smoothing memory */ + Word16 tilt_mem_fx; + + float prev_lsf_diff[LPC_SHB_ORDER - 2]; + Word16 prev_lsf_diff_fx[LPC_SHB_ORDER - 2]; + + float prev_tilt_para; + Word16 prev_tilt_para_fx; + + float cur_sub_Aq[M + 1]; + Word16 cur_sub_Aq_fx[M + 1]; + /* quantized data */ int16_t lsf_idx[NUM_Q_LSF]; - int16_t m_idx; - int16_t grid_idx; - int16_t idxSubGains; - int16_t idxFrameGain; - int16_t idx_shb_fr_gain; - int16_t idx_res_gs[NB_SUBFR16k]; - int16_t idx_mixFac; + Word16 lsf_idx_fx[NUM_Q_LSF]; + + int16_t m_idx; + Word16 m_idx_fx; + + int16_t grid_idx; + Word16 grid_idx_fx; + + int16_t idxSubGains; + Word16 idxSubGains_fx; + + int16_t idxFrameGain; + Word16 idxFrameGain_fx; + + int16_t idx_shb_fr_gain; + Word16 idx_shb_fr_gain_fx; + + int16_t idx_res_gs[NB_SUBFR16k]; + Word16 idx_res_gs_fx[NB_SUBFR16k]; + + int16_t idx_mixFac; + Word16 idx_mixFac_fx; int16_t lsf_WB; - int16_t gFrame_WB; + Word16 lsf_WB_fx; - int16_t idxGain; + int16_t gFrame_WB; + Word16 gFrame_WB_fx; - float old_core_synth[L_FRAME16k]; - float old_tbe_synth[L_SHB_TRANSITION_LENGTH]; + int16_t idxGain; + Word16 idxGain_fx; + + float old_core_synth[L_FRAME16k]; + Word16 old_core_synth_fx[L_FRAME16k]; + + float old_tbe_synth[L_SHB_TRANSITION_LENGTH]; + Word16 old_tbe_synth_fx[L_SHB_TRANSITION_LENGTH]; float int_3_over_2_tbemem_dec[INTERP_3_2_MEM_LEN]; + Word16 int_3_over_2_tbemem_dec_fx[INTERP_3_2_MEM_LEN]; float old_hb_synth[L_FRAME48k]; + Word16 old_hb_synth_fx[L_FRAME48k]; float tilt_swb_fec; /* FEC - SWB TBE TILT */ + Word16 tilt_swb_fec_fx; /* FEC - SWB TBE TILT */ + + Word16 prev_hb_synth_fx_exp; + } TD_BWE_DEC_DATA, *TD_BWE_DEC_HANDLE; @@ -797,22 +1444,67 @@ typedef struct td_bwe_dec_structure typedef struct fd_bwe_dec_structure { - float old_wtda_swb[L_FRAME48k]; - float old_syn_12k8_16k[NS2SA( 16000, DELAY_FD_BWE_ENC_NS )]; - float mem_deemph_old_syn; - int16_t prev_mode; - float prev_SWB_fenv[SWB_FENV]; - float prev_Energy; - float prev_Energy_wb; - int16_t prev_L_swb_norm; - int16_t Seed; - int16_t prev_frica_flag; - float mem_imdct[L_FRAME48k]; - float prev_td_energy; - float prev_weight; - int16_t prev_flag; - float last_wb_bwe_ener; - float prev_fb_ener_adjust; + Word16 old_wtda_wb_fx_exp; + + float old_wtda_swb[L_FRAME48k]; + Word16 L_old_wtda_swb_fx[L_FRAME48k]; + + Word16 old_wtda_swb_fx_exp; + + float old_syn_12k8_16k[NS2SA( 16000, DELAY_FD_BWE_ENC_NS )]; + Word16 old_syn_12k8_16k_fx[NS2SA(16000, DELAY_FD_BWE_ENC_NS)]; /*Q_syn2-1*/ + + float mem_deemph_old_syn; + Word16 mem_deemph_old_syn_fx; + + int16_t prev_mode; + Word16 prev_mode_fx; + + float prev_SWB_fenv[SWB_FENV]; + //Word16 prev_SWB_fenv_fx[SWB_FENV]; + + float prev_Energy; + Word16 prev_Energy_fx; + + float prev_Energy_wb; + Word32 prev_Energy_wb_fx; + + int16_t prev_L_swb_norm; + Word16 prev_L_swb_norm_fx; + + int16_t Seed; + Word16 Seed_fx; + + Word16 memExp1; + + int16_t prev_frica_flag; + Word16 prev_frica_flag_fx; + + float mem_imdct[L_FRAME48k]; + Word16 mem_imdct_fx[L_FRAME48k]; + + Word16 mem_imdct_exp_fx; + + float prev_td_energy; + Word16 prev_td_energy_fx; + + float prev_weight; + Word16 prev_weight_fx; + + int16_t prev_flag; + Word16 prev_flag_fx; + + float last_wb_bwe_ener; + //Word16 last_wb_bwe_ener_fx; + + float prev_fb_ener_adjust; + //Word16 prev_fb_ener_adjust_fx; + + //Word16 prev_frame_pow_exp; + //Word16 prev_Qx; + //Word16 prev_Q_bwe_exc; + //Word16 prev_Q_synth; + } FD_BWE_DEC_DATA, *FD_BWE_DEC_HANDLE; @@ -825,9 +1517,23 @@ typedef struct hr_swb_bwe_dec_structure { int16_t bwe_highrate_seed; - float t_audio_prev[2 * END_FREQ_BWE_FULL_FB / FRAMES_PER_SEC - NUM_NONTRANS_START_FREQ_COEF]; - int16_t old_is_transient_hr_bwe; - float mem_EnergyLT; + Word16 bwe_highrate_seed_fx; + + float t_audio_prev[2 * END_FREQ_BWE_FULL_FB / FRAMES_PER_SEC - NUM_NONTRANS_START_FREQ_COEF]; + Word16 t_audio_prev_fx[2 * END_FREQ_BWE_FULL_FB / 50 - NUM_NONTRANS_START_FREQ_COEF]; + + Word16 t_audio_prev_fx_exp[NUM_TIME_SWITCHING_BLOCKS]; + + int16_t old_is_transient_hr_bwe; + Word16 old_is_transient_hr_bwe_fx; + + float mem_EnergyLT; + Word32 L_mem_EnergyLT_fx; + + Word16 mem_EnergyLT_fx_exp; + + //fixed + } HR_BWE_DEC_DATA, *HR_BWE_DEC_HANDLE; @@ -855,30 +1561,74 @@ typedef struct pvq_dec_structure typedef struct amrwb_io_dec_structure { float past_qua_en[GAIN_PRED_ORDER]; /* gain quantization memory (used also in AMR-WB IO mode) */ + Word16 past_qua_en_fx[GAIN_PRED_ORDER]; /* gain quantization memory (used also in AMR-WB IO mode) */ float prev_r; /* HF BWE - previous sub-frame gain */ - float fmerit_w_sm; /* HF BWE - fmerit parameter memory */ - int16_t frame_count; /* HF BWE - frame count */ - float ne_min; /* HF BWE - minimum Noise gate - short-term energy */ - float fmerit_m_sm; /* HF BWE - memory of fmerit_m param */ - float voice_fac_amr_wb_hf; /* HF BWE - voice factor */ - float unvoicing; /* HF BWE - unvoiced parameter */ - float unvoicing_sm; /* HF BWE - smoothed unvoiced parameter */ - int16_t unvoicing_flag; /* HF BWE - unvoiced flag */ - int16_t voicing_flag; /* HF BWE - voiced flag */ - int16_t start_band_old; /* HF BWE - previous start point for copying frequency band */ - float OptCrit_old; /* HF BWE - previous criterion value for deciding the start point */ + Word16 prev_r_fx; /* HF BWE - previous sub-frame gain */ + + float fmerit_w_sm; /* HF BWE - fmerit parameter memory */ + Word16 fmerit_w_sm_fx; /* HF BWE - fmerit parameter memory */ + + int16_t frame_count; /* HF BWE - frame count */ + Word16 frame_count_fx; /* HF BWE - frame count */ + + float ne_min; /* HF BWE - minimum Noise gate - short-term energy */ + Word16 ne_min_fx; /* HF BWE - minimum Noise gate - short-term energy */ + + float fmerit_m_sm; /* HF BWE - memory of fmerit_m param */ + Word16 fmerit_m_sm_fx; /* HF BWE - memory of fmerit_m param */ + + float voice_fac_amr_wb_hf_float; /* HF BWE - voice factor */ + Word16 voice_fac_amr_wb_hf; /* HF BWE - voice factor */ + + float unvoicing; /* HF BWE - unvoiced parameter */ + Word16 unvoicing_fx; /* HF BWE - unvoiced parameter */ + + float unvoicing_sm; /* HF BWE - smoothed unvoiced parameter */ + Word16 unvoicing_sm_fx; /* HF BWE - smoothed unvoiced parameter */ + + int16_t unvoicing_flag; /* HF BWE - unvoiced flag */ + Word16 unvoicing_flag_fx; /* HF BWE - unvoiced flag */ + + int16_t voicing_flag; /* HF BWE - voiced flag */ + Word16 voicing_flag_fx; /* HF BWE - voiced flag */ + + int16_t start_band_old; /* HF BWE - previous start point for copying frequency band */ + Word16 start_band_old_fx; /* HF BWE - previous start point for copying frequency band */ + + float OptCrit_old; /* HF BWE - previous criterion value for deciding the start point */ + Word32 OptCrit_old_fx; /* HF BWE - previous criterion value for deciding the start point */ + /* Improvement of unvoiced and audio signals in AMR-WB IO mode */ int16_t UV_cnt; /* number of consecutives frames classified as UV */ - float LT_UV_cnt; /* long-term consecutives frames classified as UV */ - float Last_ener; /* last_energy frame */ - float lt_diff_etot[MAX_LT]; /* stability estimation - long-term total energy variation */ - float old_Aq[NB_SUBFR * ( M + 1 )]; /* old LPC filter coefficient */ - float lt_voice_fac; /* average voice factor over 4 sub-frames */ + Word16 UV_cnt_fx; /* number of consecutives frames classified as UV */ + + float LT_UV_cnt; /* long-term consecutives frames classified as UV */ + Word16 LT_UV_cnt_fx; /* long-term consecutives frames classified as UV */ + + float Last_ener; /* last_energy frame */ + Word16 Last_ener_fx; /* last_energy frame */ + + float lt_diff_etot[MAX_LT]; /* stability estimation - long-term total energy variation */ + Word16 lt_diff_etot_fx[MAX_LT]; /* stability estimation - long-term total energy variation */ + + float old_Aq[NB_SUBFR * ( M + 1 )]; /* old LPC filter coefficient */ + Word16 old_Aq_fx[68]; /* old LPC filter coefficient */ + + float lt_voice_fac; /* average voice factor over 4 sub-frames */ + Word16 lt_voice_fac_fx; /* average voice factor over 4 sub-frames */ + + //fixed } AMRWB_IO_DEC_DATA, *AMRWB_IO_DEC_HANDLE; +struct dispMem_fx +{ + Word16 prev_state; /*Q0 */ + Word32 prev_gain_code; /*Q16 */ + Word16 prev_gain_pit[6]; /*Q14 */ +}; /*----------------------------------------------------------------------------------* * @@ -1341,6 +2091,518 @@ typedef struct Decoder_State int16_t cng_ism_flag; /* CNG in ISM format flag */ int16_t is_ism_format; /* Indication whether the codec operates in ISM format */ -} Decoder_State, *DEC_CORE_HANDLE; +} Decoder_State, *DEC_CORE_HANDLE_FLOAT; + +typedef struct Decoder_State_fx +{ + + /*----------------------------------------------------------------------------------* + * Common parameters + *----------------------------------------------------------------------------------*/ + Word16 codec_mode; /* MODE1 or MODE2 */ + Word16 mdct_sw_enable; /* MDCT switching enable flag */ + Word16 mdct_sw; /* MDCT switching indicator */ + Word16 last_codec_mode; /* last used codec mode*/ + UWord16 *bit_stream_fx; + Word16 next_bit_pos_fx; /* position of the next bit to be read from the bitstream */ + Word16 bitstreamformat; /* Bitstream format flag (G.192/MIME/VOIP_G192_RTP/VOIP_RTPDUMP) */ + Word16 sdp_hf_only; /* RTP payload format parameter: only Header-Full format without zero padding for size collision avoidance */ + Word16 amrwb_rfc4867_flag; /* MIME from rfc4867 is used */ + Word16 total_num_bits; /* == st->total_brate / 50 */ + Word16 BER_detect; /* flag to signal detected bit error in the bitstream */ + + Word32 output_Fs_fx; /* output sampling rate Q0*/ + Word16 output_frame_fx; /* Output frame length Q0*/ + Word32 total_brate_fx; /* total bitrate in kbps of the codec Q0*/ + Word32 last_total_brate_fx; /* last total bitrate in kbps of the codec Q0*/ + Word32 last_total_brate_ber_fx; /* last total bitrate in kbps of the codec - used only when first frame is lost and BER is detected afterwards */ + Word16 core_fx; /* core (ACELP_CORE, TCX_20_CORE, TCX_10_CORE, HQ_CORE, AMR_WB_CORE) */ + Word32 core_brate_fx; /* core bitrate */ + Word32 last_core_brate_fx; /* previous frame core bitrate Q0*/ + Word16 extl_fx; /* extension layer Q0*/ + Word16 last_extl_fx; /* previous extension layer Q0*/ + Word32 extl_brate_fx; /* extension layer bitrate */ + Word16 L_frame_fx; /* ACELP core internal frame length */ + Word16 bwidth_fx; /* encoded signal bandwidth */ + Word16 Opt_AMR_WB_fx; /* flag indicating AMR-WB IO mode Q0*/ + Word16 Opt_VOIP_fx; /* flag indicating VOIP mode with JBM */ + Word16 ini_frame_fx; /* initialization frames counter */ + Word16 CNG_fx; /* RXDTX handler: CNG=1, nonCNG=0 */ + Word16 prev_ft_speech_fx; /* RXDTX handler: previous frametype flag for G.192 format AMRWB SID_FIRST detection */ + + /*----------------------------------------------------------------------------------* + * ACELP core parameters + *----------------------------------------------------------------------------------*/ + + Word16 old_exc_fx[L_EXC_MEM_DEC]; /* old excitation Q_exc*/ + Word16 lsp_old_fx[M]; /* old LSP vector at the end of the frame Q15*/ + Word16 lsf_old_fx[M]; /* old LSF vector at the end of the frame Q2.56*/ + Word32 offset_scale1_fx[MAX_NO_MODES + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure 1st 8-dim subvector*/ + Word32 offset_scale2_fx[MAX_NO_MODES + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure 2nd 8-dim subvector*/ + Word32 offset_scale1_p_fx[MAX_NO_MODES_p + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure, pred. case, 1st 8-dim subvector*/ + Word32 offset_scale2_p_fx[MAX_NO_MODES_p + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure, pred. case, 2nd 8-dim subvector*/ + Word16 no_scales_fx[MAX_NO_MODES][2]; /* LSF LVQ structure Q0*/ + Word16 no_scales_p_fx[MAX_NO_MODES_p][2]; /* LSF LVQ structure Q0*/ + Word16 tilt_code_fx; /* tilt of code Q15*/ + Word16 mem_syn2_fx[M]; /* synthesis filter memory Q_syn*/ + Word16 mem_syn1_fx[M]; /* synthesis filter memory (for core switching and FD BWE) */ + Word16 mem_syn3_fx[M]; + Word16 mem_deemph_fx; /* deemphasis filter memory Q_syn*/ + Word32 L_mem_hp_out_fx[5]; /* hp filter memory for synthesis */ + Word16 mem_MA_fx[M]; /* MA memory of LSF quantizer (past quantized residual)(Qx2.56)*/ + Word16 mem_AR_fx[M]; /* AR memory of LSF quantizer (past quantized LSFs without mean)(Qx2.56) */ + Word16 stab_fac_fx; /* LSF stability factor Q15*/ + Word16 stab_fac_smooth_fx; /* low-pass filtered stability factor Q15*/ + Word16 last_coder_type_fx; /* previous coder type Q0*/ + Word16 agc_mem_fx[2]; /* memory of AGC for saturation control Q0*/ + Word16 mid_lsf_int_fx; + Word16 safety_net_fx; + + GSC_DEC_HANDLE hGSCDec; + Word16 GSC_IVAS_mode; /* AC mode (GSC) - GSC IVAS mode */ + + Word16 Last_GSC_noisy_speech_flag_fx; /* AC mode (GSC) - mem of the past flag to indicate GSC osn SWB noisy speech */ + Word16 GSC_noisy_speech_fx; /* AC mode (GSC) - flag to indicate GSC osn SWB noisy speech */ + + Word32 gc_threshold_fx; /* Noise enhancer - threshold for gain_code Q16*/ + struct dispMem_fx dm_fx; /* Noise enhancer - phase dispersion algorithm memory */ + + ZERO_BWE_DEC_HANDLE hBWE_zero; /* HF (6-7kHz) BWE */ + + Word16 unv_cnt_fx; /* Stationary noise UV modification - unvoiced frame counter Q0*/ + Word16 uv_count_fx; /* Stationary noise UV modification - unvoiced counter Q0*/ + Word16 act_count_fx; /* Stationary noise UV modification - activation counter Q0*/ + Word32 ge_sm_fx; /* Stationary noise UV modification - smoothed excitation gain Q(GE_SHIFT)*/ + Word16 lspold_s_fx[M]; /* Stationary noise UV modification - old LSP vector Q15*/ + Word16 noimix_seed_fx; /* Stationary noise UV modification - mixture seed Q0*/ + Word16 min_alpha_fx; /* Stationary noise UV modification - minimum alpha Q15*/ + Word16 Q_stat_noise; /* Q of Exc_pe */ + Word16 exc_pe_fx; /* Stationary noise UV modification - scale (Q_stat_noise) */ + Word16 Q_stat_noise_ge; /* Q of ge_sm_fx */ + + Word16 bfi_fx; /* FEC - bad frame indicator */ + Word16 prev_bfi_fx; /* FEC - previous bad frame indicator Q0*/ + Word16 seed_fx; /* FEC - seed for random generator for excitation Q0*/ + Word16 lp_ener_FER_fx; /* FEC - long-term active-signal average energy Q8*/ + Word16 last_good_fx; /* FEC - clas of last good received Q0*/ + Word16 lp_gainc_fx; /* FEC - low-pass filtered code gain Q3*/ + Word16 lp_gainp_fx; /* FEC - low-pass filtered pitch gain Q14 */ + Word32 lp_ener_fx; /* FEC - low-pass filtered energy Q6*/ + Word32 enr_old_fx; /* FEC - energy of the concealed frame Q0*/ + Word16 bfi_pitch_fx; /* FEC - pitch for FEC */ + Word16 bfi_pitch_frame_fx; /*FEC - frame length when pitch for FEC is saved Q0*/ + Word32 old_pitch_buf_fx[2 * NB_SUBFR16k + 2]; /* FEC - buffer of old subframe pitch values 15Q16 */ + Word16 upd_cnt_fx; /* FEC - counter of frames since last update Q0*/ + Word16 scaling_flag; /* FEC - flag to indicate energy control of syn */ + Word32 lp_ener_FEC_av; /* FEC - averaged voiced signal energy Q0 */ + Word32 lp_ener_FEC_max; /* FEC - averaged voiced signal energy Q0 */ + Word16 old_enr_LP; /* FEC - LP filter gain Q5*/ + Word16 lsfoldbfi0_fx[M]; /* FEC - LSF vector of the previous frame (Qx2.56)*/ + Word16 lsfoldbfi1_fx[M]; /* FEC - LSF vector of the past previous frame (Qx2.56) */ + Word16 lsf_adaptive_mean_fx[M]; /* FEC - adaptive mean LSF vector for FEC (Qx2.56)*/ + Word16 decision_hyst_fx; /* FEC - hysteresis of the music/speech decision Q0*/ + + WI_DEC_HANDLE hWIDec; + Word16 relax_prev_lsf_interp_fx; + Word16 mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM]; /* FEC - memory of the synthesis signal for frame class estimation */ + /*----------------------------------------------------------------------------------* + * DTX and TD CNG parameters + *----------------------------------------------------------------------------------*/ + Word16 first_CNG_fx; /* CNG and DTX - first CNG frame flag Q0*/ + Word16 cng_type_fx; /* DTX/CNG - flag indicating LP or CLDFB based SID/CNG */ + Word16 last_CNG_L_frame_fx; /* DTX/CNG - last CNG frame length */ + Word32 last_active_brate_fx; /* DTX/CNG - last active frame bitrate used for CNG_mode control */ + Word16 CNG_mode_fx; /* DTX/CNG - mode for DTX configuration */ + Word16 lspCNG_fx[M]; /* CNG and DTX - LP filtered ISPs Q15*/ + Word16 active_cnt; + + TD_CNG_DEC_HANDLE hTdCngDec; + Word16 bpf_off_fx; /* Bass post-filter - do not use BPF when this flag is set to 1 Q0*/ + BPF_DEC_HANDLE hBPF; /* Bass post-filter handle */ + Word16 Ng_ener_ST_fx; /* Noise gate - short-term energy Q8*/ + + Word16 last_L_frame_fx; /* ACELP@16kHz - last value of st->L_frame */ + Word16 mem_preemp_preQ_fx; /* ACELP@16kHz - prequantizer preemhasis memory */ + Word16 last_nq_preQ_fx; /* ACELP@16kHz - AVQ subquantizer number of the last sub-band of the last subframe */ + Word16 use_acelp_preq; /* ACELP@16kHz - flag of prequantizer usage */ + + AMRWB_IO_DEC_HANDLE hAmrwb_IO; + + SC_VBR_DEC_HANDLE hSC_VBR; + /*----------------------------------------------------------------------------------* + * SC-VBR + *----------------------------------------------------------------------------------*/ + Word16 last_ppp_mode_dec_fx; /*Q0*/ + Word16 ppp_mode_dec_fx; /*Q0*/ + Word16 last_nelp_mode_dec_fx; + Word16 nelp_mode_dec_fx; /* Q0 */ + Word16 prev_gain_pit_dec_fx; /*Q14*/ + Word16 prev_tilt_code_dec_fx; /*Q15*/ + Word16 vbr_hw_BWE_disable_dec_fx; + Word16 last_vbr_hw_BWE_disable_dec_fx; + + /*----------------------------------------------------------------------------------* + * channel-aware mode + *----------------------------------------------------------------------------------*/ + + Word16 tilt_code_dec_fx[NB_SUBFR16k]; + Word16 rf_frame_type; + Word16 use_partial_copy; + Word16 prev_use_partial_copy; + Word16 rf_flag; + Word16 rf_flag_last; + + Word16 rf_fec_offset; + Word16 next_coder_type; + Word16 prev_rf_frame_type; + Word16 rf_target_bits; + + Word16 rf_indx_nelp_fid; + Word16 rf_indx_nelp_iG1; + Word16 rf_indx_nelp_iG2[2]; + Word16 rf_indx_tbeGainFr; + + /*----------------------------------------------------------------------------------* + * HR SWB BWE parameters + *----------------------------------------------------------------------------------*/ + HR_BWE_DEC_HANDLE hBWE_FD_HR; + Word16 Qprev_synth_buffer_fx; + + /*----------------------------------------------------------------------------------* + * HQ core parameters + *----------------------------------------------------------------------------------*/ + Word16 last_core_fx; /*Q0*/ + Word16 last_core_bs_fx; + Word16 last_L_frame_ori_fx; + Word16 previoussynth_fx[L_FRAME48k]; + Word16 old_synth_sw_fx[NS2SA(48000, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS)]; + Word16 delay_buf_out_fx[HQ_DELTA_MAX * HQ_DELAY_COMP]; /*Q0*/ + Word16 old_Aq_12_8_fx[M + 1]; /* Q12 old Aq[] for core switching */ + Word16 old_Es_pred_fx; /* old Es_pred for core switching */ + + HQ_DEC_HANDLE hHQ_core; + + /*----------------------------------------------------------------------------------* + * HQ FEC + *----------------------------------------------------------------------------------*/ + + Word16 old_bfi_cnt_fx; /* HQ core - # of bfi until previous frame(for FEC) */ + Word16 prev_old_bfi_fx; + HQ_NBFEC_HANDLE hHQ_nbfec; + + /*----------------------------------------------------------------------------------* + * TBE parameters + *----------------------------------------------------------------------------------*/ + TD_BWE_DEC_HANDLE hBWE_TD; + Word16 hb_prev_synth_buffer_fx[NS2SA(48000, DELAY_BWE_TOTAL_NS)]; + Word16 old_bwe_delay_fx; /*Q0*/ + + /* WB/SWB bandwidth switching */ + Word16 tilt_wb_fx; + Word16 tilt_swb_fx; + Word16 prev_ener_shb_fx; + Word32 enerLH_fx; + Word32 prev_enerLH_fx; + Word32 enerLL_fx; + Word32 prev_enerLL_fx; + + Word16 prev_fractive_fx; + Word16 prev_bws_cnt_fx; + Word16 bws_cnt_fx; + Word16 bws_cnt1_fx; + Word16 attenu_fx; + Word16 last_inner_frame_fx; /* (HQ_CORE) DCT length */ + Word16 last_bwidth_fx; + Word16 t_audio_q_fx[L_FRAME]; + + + Word16 interpol_3_2_cng_dec_fx[INTERP_3_2_MEM_LEN]; + + /*----------------------------------------------------------------------------------* + * SWB BWE parameters + *----------------------------------------------------------------------------------*/ + FD_BWE_DEC_HANDLE hBWE_FD; + Word16 prev_coder_type_fx; + /*----------------------------------------------------------------------------------* + * SWB DTX/CNG parameters + *----------------------------------------------------------------------------------*/ + + Word16 shb_cng_ener_fx; + Word16 wb_cng_ener_fx; + Word16 last_wb_cng_ener_fx; + Word16 last_shb_cng_ener_fx; + Word16 swb_cng_seed_fx; + Word16 lsp_shb_prev_prev_fx[LPC_SHB_ORDER]; + Word16 lsp_shb_prev_fx[LPC_SHB_ORDER]; + Word16 shb_dtx_count_fx; + Word16 last_vad_fx; + Word16 trans_cnt_fx; + //Word16 burst_cnt_fx; + Word16 last_shb_ener_fx; + + + /*----------------------------------------------------------------------------------* + * LD music post-filter + *----------------------------------------------------------------------------------*/ + MUSIC_POSTFILT_HANDLE hMusicPF; + + /*----------------------------------------------------------------------------------* + * Fixed point only + *----------------------------------------------------------------------------------*/ + Word16 Q_exc; + Word16 prev_Q_exc; + Word16 Q_subfr[L_Q_MEM]; + + Word16 prev_Q_bwe_syn; + Word16 prev_Q_bwe_syn2; + + Word16 prev_Q_bwe_exc_fb; + Word16 prev_Qx; + Word16 prev_Q_bwe_exc; + Word16 prev_Q_synth; + Word16 prev_SWB_fenv_fx[SWB_FENV]; + + Word16 Q_syn2; + Word16 Q_syn; + Word16 prev_Q_syn; + Word16 prev_frame_pow_exp; + Word16 prev_ener_fx_Q; + Word16 last_wb_bwe_ener_fx; + Word16 prev_fb_ener_adjust_fx; + + Word16 prev_synth_buffer_fx[NS2SA(48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS)]; + Word16 prev_lpc_wb_fx[LPC_SHB_ORDER_WB]; + Word16 GainShape_Delay[NUM_SHB_SUBFR / 2]; + + HANDLE_CLDFB_FILTER_BANK cldfbAna_fx; /* main analysis filter bank handle */ + HANDLE_CLDFB_FILTER_BANK cldfbBPF_fx; /* BPF analysis filter bank handle */ + HANDLE_CLDFB_FILTER_BANK cldfbSyn_fx; /* main synthesis filter bank handle */ + + Word16 last_active_bandsToZero_bwdec; + Word16 last_flag_filter_NB; + Word16 perc_bwddec; /*Q14*/ + Word16 active_frame_cnt_bwddec; + Word16 flag_buffer[20]; + Word16 total_frame_cnt_bwddec; + Word32 avg_nrg_LT; + /*Frequency-domain-based CNG*/ + HANDLE_FD_CNG_DEC hFdCngDec_fx; + + /*ACELP config*/ + Word16 force_lpd_reset; + ACELP_config acelp_cfg; /*configuration set for each frame*/ + + ACELP_config acelp_cfg_rf; /* configuration for RF frame */ + + TCX_CONFIG_HANDLE hTcxCfg; /* TCX config */ + + /* evs decoder */ + Word16 m_decodeMode; + Word16 m_frame_type; /*ZERO_FRAME/SID_FRAME/ACTIVE_FRAME*/ + Word16 m_old_frame_type; /*ZERO_FRAME/SID_FRAME/ACTIVE_FRAME*/ + + + /*dec_prm.c*/ + Word16 bits_frame; /* bit per frame overall included */ + Word16 bits_frame_core; /* bit per frame for the core */ + Word8 narrowBand; + Word16 bits_common; /* read bits from header and LPC*/ + + Word8 last_is_cng; + + + Word16 syn[M + 1]; + + /* bass_pf.c */ + Word16 bpf_gain_param; /*int*/ /* bass post-filter gain factor parameter (0->noBpf)*/ + + Word16 L_frame_past; + Word16 L_frameTCX_past; + + Word16 lsfold_uw[M]; /* old lsf (unweighted) */ + Word16 lspold_uw[M]; /* old lsp (unweighted) */ + Word16 seed_tcx_plc; /* seed memory (for random function in TCX PLC) */ + Word16 past_gpit; /* past gain of pitch (for frame recovery) */ + Word32 past_gcode; /* past energy (!) of code (for frame recovery) */ /*15Q16*/ + Word16 lsf_cng[M]; /* xSF coefficients used for CNG generation (long term) */ + Word16 lspold_cng[M]; /* xSP coefficients used for CNG generation (long term) */ + Word8 plcBackgroundNoiseUpdated; /* flag: Is background noise estimate updated? */ + Word16 lsp_q_cng[M]; /* xSP coefficients used for CNG generation (short term interpolated) */ + Word16 old_lsp_q_cng[M]; /* xSP coefficients used for CNG generation (short term interpolated) */ + Word16 lsf_q_cng[M]; /* xSF coefficients used for CNG generation (short term interpolated) */ + Word16 old_lsf_q_cng[M]; /* xSF: old quantized lsfs for background noise */ + Word16 Aq_cng[(NB_SUBFR16k + 1)*(M + 1)]; /* LPC coefficients derived from CNG estimate */ + Word16 mem_syn_unv_back[M]; /* filter memory for unvoiced synth */ + Word16 last_gain_syn_deemph; /*Q15*/ + Word16 last_gain_syn_deemph_e; + Word16 last_concealed_gain_syn_deemph; /*Q15*/ + Word16 last_concealed_gain_syn_deemph_e; + + /* variables for framing */ + Word16 nb_subfr; + + Word16 fscale; + Word16 fscale_old; + Word32 sr_core; /*Q0*/ + + Word16 pit_min; /*int*/ + Word16 pit_fr1; + Word16 pit_fr1b; + Word16 pit_fr2; + Word16 pit_max; /*int Q0*/ + Word16 pit_res_max; + Word16 pit_res_max_past; + + + /*Preemphasis factor*/ + Word16 preemph_fac; /*0Q15*/ + Word16 gamma; + Word16 inv_gamma; + + /*for AMR-WB like 6.4 to 7 kHz upsampling and noise filling*/ + Word16 mem_Aq[(NB_SUBFR16k)*(M + 1)]; /* Q12 */ + + /* Error concealment */ + Word16 last_core_bfi; + Word16 nbLostCmpt; /* compt for number of consecutive lost frame*/ + Word16 prev_nbLostCmpt; /* compt for number of consecutive lost frame at the previous frame*/ + Word16 mode_lvq; /* index for LSF mean vector */ + Word32 old_fpitch; /* last pitch of previous frame */ /*15Q16*/ + Word32 old_fpitchFB; /* PLC - last pitch of previous FB frame (depends on output sr) */ /*15Q16*/ + Word16 clas_dec; + Word16 mem_pitch_gain[2 * NB_SUBFR16k + 2]; /* Pitch gain memory Q14 */ + Word8 plc_use_future_lag; + Word32 Mode2_lp_gainc; /* 15Q16 low passed code gain used for concealment*/ + Word32 Mode2_lp_gainp; /* 15Q16 low passed pitch gain used for concealment*/ + + Word16 cummulative_damping; /*Q15*/ + Word16 cngTDLevel; + Word16 cngTDLevel_e; + + Word16 prev_widow_left_rect; + + + + Word16 reset_mem_AR; + + + Word16 classifier_Q_mem_syn; /*scalingfactor of mem_syn_clas_estim_fx in MODE2 */ + + Word16 rate_switching_init; + + /* LPC quantization */ + Word16 lpcQuantization; + Word16 numlpc; + + /* Bandwidth */ + Word16 TcxBandwidth; + + /* For NB and formant post-filter */ + PFSTAT_HANDLE hPFstat; /* NB and formant post-filter states */ + Word16 psf_lp_noise_fx; + Word16 last_voice_factor_fx; /* Q6*/ + + /* For adaptive tilt_code */ + Word16 voice_fac; + + Word16 tcxonly; + + + Word16 last_ctx_hm_enabled; + + + /*----------------------------------------------------------------------------------* + * TCX LTP decoder handle + *----------------------------------------------------------------------------------*/ + TCX_LTP_DEC_HANDLE hTcxLtpDec; + struct tonalmdctconceal tonalMDCTconceal; + Word8 tonal_mdct_plc_active; + Word8 last_tns_active; + Word8 second_last_tns_active; + Word16 second_last_core; + /*----------------------------------------------------------------------------------* + * TCX core decoder handle + *----------------------------------------------------------------------------------*/ + + TCX_DEC_HANDLE hTcxDec; + + /* parameters for switching */ + Word16 mem_syn_r[L_SYN_MEM]; /*LPC synthesis memory needed for rate switching*/ + Word16 rate_switching_reset; + + Word32 lp_error_ener; + Word32 mem_error; + Word16 bpf_noise_buf[L_FRAME_16k]; + Word16 *p_bpf_noise_buf; + + Word8 enableGplc; + Word16 flagGuidedAcelp; /*int*/ + Word16 T0_4th;/*int*/ + Word16 guidedT0; /*int*/ + + Word16 enablePlcWaveadjust; + Word16 tonality_flag; + T_PLCInfo plcInfo; + + Word8 VAD; + Word8 flag_cna; + Word8 last_flag_cna; + + Word32 lp_noise; + + Word16 seed_acelp; + + Word16 core_ext_mode; /*GC,VC,UC,TC: core extended mode used for PLC or Acelp-external modules.*/ + + Word8 dec_glr; + Word16 dec_glr_idx; + + + Word16 igf; + IGF_DEC_INSTANCE_HANDLE hIGFDec; + CLDFB_SCALE_FACTOR scaleFactor; + + Word16 tec_tfa; + Word16 tec_flag; + Word16 tfa_flag; + TEMPORAL_ENVELOPE_CODING_DECODER_FX tecDec_fx; + + Word16 con_tcx; + Word16 last_con_tcx; + Word16 old_ppp_mode_fx; + + Word16 prev_Q_exc_fr; + Word16 prev_Q_syn_fr; + + Word16 writeFECoffset; + + /*----------------------------------------------------------------------------------* + * Stereo/IVAS parameters + *----------------------------------------------------------------------------------*/ + Word16 bits_frame_nominal; /* avg bits per frame on active frame */ + Word16 last_bits_frame_nominal; /* last avg bits per frame on active frame */ + Word16 flag_ACELP16k; /* flag indicating use of ACELP core at 16kHz internal sampling rate */ + + Word16 tdm_LRTD_flag; /* LRTD stereo mode flag */ + Word16 cna_dirac_flag; /* CNA in DirAC flag */ + Word16 cng_sba_flag; /* CNG in SBA flag */ + Word16 idchan; /* channel ID (audio channel number) */ + Word16 element_mode; /* element mode */ + Word16 last_element_mode; /* element mode */ + Word16 low_rate_mode; /* low-rate mode flag */ + Word16 last_low_rate_mode; /* previous low-rate mode flag */ + Word16 coder_type_fx; /* low-rate mode flag */ + Word16 mct_chan_mode; + Word16 cng_ism_flag; /* CNG in ISM format flag */ + Word16 is_ism_format; /* Indication whether the codec operates in ISM format */ + +#ifdef DEBUGGING + Word16 id_element; /* element ID */ +#endif + Word32 element_brate; /* element bitrate */ + Word16 extl_orig; /* extension layer */ + Word32 extl_brate_orig; /* extension layer bitrate */ + +} Decoder_State_fx, *DEC_CORE_HANDLE; #endif diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c index c858a80af..2bc59695c 100644 --- a/lib_dec/swb_tbe_dec.c +++ b/lib_dec/swb_tbe_dec.c @@ -1866,7 +1866,7 @@ static void dequantizeSHBparams( } v_add( SHB_LSF_mean, lsf_q, lsf_q, LPC_SHB_ORDER ); - v_sort( lsf_q, 0, LPC_SHB_ORDER - 1 ); + v_sort_float( lsf_q, 0, LPC_SHB_ORDER - 1 ); } else { @@ -1977,7 +1977,7 @@ void fb_tbe_dec( { int16_t i; TD_BWE_DEC_HANDLE hBWE_TD; - float ratio = 0, fb_exc_energy = 0; + float ratio_float = 0, fb_exc_energy = 0; float fb_synth[L_FRAME48k]; hBWE_TD = st->hBWE_TD; @@ -1995,11 +1995,11 @@ void fb_tbe_dec( { i = get_next_indice( st, NUM_BITS_FB_FRAMEGAIN_TBE ); } - ratio = (float) ( 1 << i ); + ratio_float = (float) ( 1 << i ); } else if ( st->extl == FB_TBE && st->bfi ) { - ratio = hBWE_TD->prev_fbbwe_ratio; + ratio_float = hBWE_TD->prev_fbbwe_ratio; } } else @@ -2016,7 +2016,7 @@ void fb_tbe_dec( fb_exc_energy = sum2_f( fb_exc, L_FRAME16k ); /* FB TBE synthesis */ - synthesise_fb_high_band( fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio ), hBWE_TD->fbbwe_hpf_mem ); + synthesise_fb_high_band( fb_exc, fb_synth, fb_exc_energy, ratio_float, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio ), hBWE_TD->fbbwe_hpf_mem ); if ( st->element_mode >= IVAS_CPE_DFT && st->idchan == 0 ) { diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index 56bae2137..2d9f4583b 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -65,11 +65,11 @@ ivas_error TonalMDCTConceal_Init( assert( ( hTonalMDCTConc->nScaleFactors == nScaleFactors ) || ( hTonalMDCTConc->nSamples != nSamples ) ); /* If nSamples doesn't change then also nScaleFactors must stay the same */ hTonalMDCTConc->tcx_cfg = hTcxCfg; - hTonalMDCTConc->lastBlockData.spectralData = hTonalMDCTConc->spectralDataBuffers[0]; - hTonalMDCTConc->secondLastBlockData.spectralData = hTonalMDCTConc->spectralDataBuffers[1]; - hTonalMDCTConc->secondLastPowerSpectrum = hTonalMDCTConc->secondLastBlockData.spectralData; - hTonalMDCTConc->lastBlockData.scaleFactors = hTonalMDCTConc->scaleFactorsBuffers[0]; - hTonalMDCTConc->secondLastBlockData.scaleFactors = hTonalMDCTConc->scaleFactorsBuffers[1]; + hTonalMDCTConc->lastBlockData.spectralData_float = hTonalMDCTConc->spectralDataBuffers_float[0]; + hTonalMDCTConc->secondLastBlockData.spectralData_float = hTonalMDCTConc->spectralDataBuffers_float[1]; + hTonalMDCTConc->secondLastPowerSpectrum_float = hTonalMDCTConc->secondLastBlockData.spectralData_float; + hTonalMDCTConc->lastBlockData.scaleFactors_float = hTonalMDCTConc->scaleFactorsBuffers_float[0]; + hTonalMDCTConc->secondLastBlockData.scaleFactors_float = hTonalMDCTConc->scaleFactorsBuffers_float[1]; hTonalMDCTConc->lastBlockData.blockIsValid = 0; hTonalMDCTConc->secondLastBlockData.blockIsValid = 0; hTonalMDCTConc->nSamples = 0; @@ -77,9 +77,9 @@ ivas_error TonalMDCTConceal_Init( hTonalMDCTConc->lastBlockData.blockIsConcealed = 0; hTonalMDCTConc->secondLastBlockData.blockIsConcealed = 0; - hTonalMDCTConc->pTCI = (TonalComponentsInfo *) hTonalMDCTConc->timeDataBuffer; + hTonalMDCTConc->pTCI = (TonalComponentsInfo *) hTonalMDCTConc->timeDataBuffer_float; - hTonalMDCTConc->lastPitchLag = 0; + hTonalMDCTConc->lastPitchLag_float = 0; if ( hTonalMDCTConc->nSamples != nSamples ) { @@ -103,12 +103,12 @@ ivas_error TonalMDCTConceal_Init( /* Offset the pointer to the end of buffer, so that pTCI is not destroyed when new time samples are stored in lastPcmOut */ /* just the second half of the second last pcm output is needed */ - hTonalMDCTConc->secondLastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - ( 3 * min( L_FRAME_MAX, nSamples ) ) / 2]; - hTonalMDCTConc->lastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - min( L_FRAME_MAX, nSamples )]; + hTonalMDCTConc->secondLastPcmOut_float = &hTonalMDCTConc->timeDataBuffer_float[( 3 * L_FRAME_MAX ) / 2 - ( 3 * min( L_FRAME_MAX, nSamples ) ) / 2]; + hTonalMDCTConc->lastPcmOut_float = &hTonalMDCTConc->timeDataBuffer_float[( 3 * L_FRAME_MAX ) / 2 - min( L_FRAME_MAX, nSamples )]; /* If the second last frame was lost and concealed with tonal PLC, we reuse saved TonalComponentsInfo and don't update pcm buffers */ - assert( sizeof( *hTonalMDCTConc->pTCI ) <= ( hTonalMDCTConc->lastPcmOut - hTonalMDCTConc->timeDataBuffer ) * sizeof( hTonalMDCTConc->timeDataBuffer[0] ) ); + assert( sizeof( *hTonalMDCTConc->pTCI ) <= ( hTonalMDCTConc->lastPcmOut_float - hTonalMDCTConc->timeDataBuffer_float) * sizeof( hTonalMDCTConc->timeDataBuffer_float[0] ) ); return IVAS_ERR_OK; } @@ -135,20 +135,20 @@ void TonalMDCTConceal_SaveFreqSignal( if ( nNewSamples <= L_FRAME_MAX ) { /* Shift the buffers */ - temp = hTonalMDCTConc->secondLastBlockData.spectralData; /* Save the pointer */ - hTonalMDCTConc->secondLastBlockData.spectralData = hTonalMDCTConc->lastBlockData.spectralData; - hTonalMDCTConc->lastBlockData.spectralData = temp; - temp = hTonalMDCTConc->secondLastBlockData.scaleFactors; - hTonalMDCTConc->secondLastBlockData.scaleFactors = hTonalMDCTConc->lastBlockData.scaleFactors; - hTonalMDCTConc->lastBlockData.scaleFactors = temp; + temp = hTonalMDCTConc->secondLastBlockData.spectralData_float; /* Save the pointer */ + hTonalMDCTConc->secondLastBlockData.spectralData_float = hTonalMDCTConc->lastBlockData.spectralData_float; + hTonalMDCTConc->lastBlockData.spectralData_float = temp; + temp = hTonalMDCTConc->secondLastBlockData.scaleFactors_float; + hTonalMDCTConc->secondLastBlockData.scaleFactors_float = hTonalMDCTConc->lastBlockData.scaleFactors_float; + hTonalMDCTConc->lastBlockData.scaleFactors_float = temp; } else { /* Order the buffers so that even transition frame can fit in if written into the first buffer */ - hTonalMDCTConc->lastBlockData.spectralData = hTonalMDCTConc->spectralDataBuffers[0]; - hTonalMDCTConc->secondLastBlockData.spectralData = hTonalMDCTConc->spectralDataBuffers[1]; - hTonalMDCTConc->lastBlockData.scaleFactors = hTonalMDCTConc->scaleFactorsBuffers[0]; - hTonalMDCTConc->secondLastBlockData.scaleFactors = hTonalMDCTConc->scaleFactorsBuffers[1]; + hTonalMDCTConc->lastBlockData.spectralData_float = hTonalMDCTConc->spectralDataBuffers_float[0]; + hTonalMDCTConc->secondLastBlockData.spectralData_float = hTonalMDCTConc->spectralDataBuffers_float[1]; + hTonalMDCTConc->lastBlockData.scaleFactors_float = hTonalMDCTConc->scaleFactorsBuffers_float[0]; + hTonalMDCTConc->secondLastBlockData.scaleFactors_float = hTonalMDCTConc->scaleFactorsBuffers_float[1]; } nOldSamples = hTonalMDCTConc->lastBlockData.nSamples; hTonalMDCTConc->lastBlockData.nSamples = nNewSamples; @@ -166,15 +166,15 @@ void TonalMDCTConceal_SaveFreqSignal( hTonalMDCTConc->last_block_nrg = 0.0f; for ( i = 0; i < infoIGFStartLine; i++ ) { - hTonalMDCTConc->lastBlockData.spectralData[i] = mdctSpectrum[i]; + hTonalMDCTConc->lastBlockData.spectralData_float[i] = mdctSpectrum[i]; hTonalMDCTConc->last_block_nrg += mdctSpectrum[i] * mdctSpectrum[i]; } for ( ; i < nNewSamples; i++ ) { - hTonalMDCTConc->lastBlockData.spectralData[i] = mdctSpectrum[i]; + hTonalMDCTConc->lastBlockData.spectralData_float[i] = mdctSpectrum[i]; } - mvr2r( scaleFactors, hTonalMDCTConc->lastBlockData.scaleFactors, hTonalMDCTConc->nScaleFactors ); + mvr2r( scaleFactors, hTonalMDCTConc->lastBlockData.scaleFactors_float, hTonalMDCTConc->nScaleFactors ); } return; @@ -210,7 +210,7 @@ void TonalMDCTConceal_UpdateState( hTonalMDCTConc->lastBlockData.blockIsConcealed = badBlock; hTonalMDCTConc->lastBlockData.blockIsValid = newBlockIsValid; hTonalMDCTConc->lastBlockData.tonalConcealmentActive = tonalConcealmentActive; - hTonalMDCTConc->lastPitchLag = pitchLag; + hTonalMDCTConc->lastPitchLag_float = pitchLag; return; } @@ -225,7 +225,7 @@ static void FindPhases( int16_t l; float *pCurrentPhase; - pCurrentPhase = hTonalMDCTConc->pTCI->phase_currentFramePredicted; + pCurrentPhase = hTonalMDCTConc->pTCI->phase_currentFramePredicted_float; /* for each index/index group */ for ( i = 0; i < hTonalMDCTConc->pTCI->numIndexes; i++ ) { @@ -257,7 +257,7 @@ static void FindPhaseDifferences( float fractional; float Q, a; - phaseDiff = hTonalMDCTConc->pTCI->phaseDiff; + phaseDiff = hTonalMDCTConc->pTCI->phaseDiff_float; for ( i = 0; i < hTonalMDCTConc->pTCI->numIndexes; i++ ) { k = hTonalMDCTConc->pTCI->indexOfTonalPeak[i]; @@ -339,8 +339,8 @@ static void CalcPowerSpecAndDetectTonalComponents( set_zero( powerSpectrum + hTonalMDCTConc->nSamples, hTonalMDCTConc->nSamplesCore - hTonalMDCTConc->nSamples ); } - DetectTonalComponents( hTonalMDCTConc->pTCI->indexOfTonalPeak, hTonalMDCTConc->pTCI->lowerIndex, hTonalMDCTConc->pTCI->upperIndex, &hTonalMDCTConc->pTCI->numIndexes, hTonalMDCTConc->lastPitchLag, pitchLag, - hTonalMDCTConc->lastBlockData.spectralData, hTonalMDCTConc->lastBlockData.scaleFactors, powerSpectrum, nSamples, hTonalMDCTConc->nSamplesCore, floorPowerSpectrum, psychParamsCurrent ); + DetectTonalComponents( hTonalMDCTConc->pTCI->indexOfTonalPeak, hTonalMDCTConc->pTCI->lowerIndex, hTonalMDCTConc->pTCI->upperIndex, &hTonalMDCTConc->pTCI->numIndexes, hTonalMDCTConc->lastPitchLag_float, pitchLag, + hTonalMDCTConc->lastBlockData.spectralData_float, hTonalMDCTConc->lastBlockData.scaleFactors_float, powerSpectrum, nSamples, hTonalMDCTConc->nSamplesCore, floorPowerSpectrum, psychParamsCurrent ); FindPhases( hTonalMDCTConc, secondLastMDCT, secondLastMDST ); @@ -348,7 +348,7 @@ static void CalcPowerSpecAndDetectTonalComponents( if ( hTonalMDCTConc->pTCI->numIndexes > 0 ) { - hTonalMDCTConc->secondLastPowerSpectrum = hTonalMDCTConc->secondLastBlockData.spectralData; + hTonalMDCTConc->secondLastPowerSpectrum_float = hTonalMDCTConc->secondLastBlockData.spectralData_float; for ( i = 0; i < nSamples; i++ ) { @@ -357,7 +357,7 @@ static void CalcPowerSpecAndDetectTonalComponents( for ( i = 0; i < hTonalMDCTConc->nScaleFactors; i++ ) { - invScaleFactors[i] = 1.0f / hTonalMDCTConc->secondLastBlockData.scaleFactors[i]; + invScaleFactors[i] = 1.0f / hTonalMDCTConc->secondLastBlockData.scaleFactors_float[i]; } if ( psychParamsCurrent == NULL ) @@ -372,7 +372,7 @@ static void CalcPowerSpecAndDetectTonalComponents( } v_multc( powerSpectrum + hTonalMDCTConc->nSamplesCore, invScaleFactors[nBands - 1], powerSpectrum + hTonalMDCTConc->nSamplesCore, hTonalMDCTConc->nSamples - hTonalMDCTConc->nSamplesCore ); - mvr2r( powerSpectrum, hTonalMDCTConc->secondLastPowerSpectrum, hTonalMDCTConc->nSamples ); /* 16 bits are now enough for storing the power spectrum */ + mvr2r( powerSpectrum, hTonalMDCTConc->secondLastPowerSpectrum_float, hTonalMDCTConc->nSamples ); /* 16 bits are now enough for storing the power spectrum */ } return; @@ -426,12 +426,12 @@ void TonalMDCTConceal_Detect( { if ( !hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) { - CalcMDXT( hTonalMDCTConc, 'S', hTonalMDCTConc->secondLastPcmOut, secondLastMDST ); - CalcMDXT( hTonalMDCTConc, 'C', hTonalMDCTConc->secondLastPcmOut, secondLastMDCT ); + CalcMDXT( hTonalMDCTConc, 'S', hTonalMDCTConc->secondLastPcmOut_float, secondLastMDST ); + CalcMDXT( hTonalMDCTConc, 'C', hTonalMDCTConc->secondLastPcmOut_float, secondLastMDCT ); hTonalMDCTConc->nNonZeroSamples = 0; for ( i = 0; i < hTonalMDCTConc->nSamples; i++ ) { - if ( hTonalMDCTConc->secondLastBlockData.spectralData[i] != 0 ) + if ( hTonalMDCTConc->secondLastBlockData.spectralData_float[i] != 0 ) { hTonalMDCTConc->nNonZeroSamples = i; } @@ -445,24 +445,24 @@ void TonalMDCTConceal_Detect( /* If the second last frame was also lost, it is expected that pastTimeSignal could hold a bit different signal (e.g. including fade-out) from the one stored in TonalMDCTConceal_SaveTimeSignal. */ /* That is why we reuse the already stored information about the concealed spectrum in the second last frame */ nSamples = hTonalMDCTConc->nNonZeroSamples; - mvr2r( hTonalMDCTConc->secondLastPowerSpectrum, powerSpectrum, nSamples ); /* Convert from 16 bits to 32 bits */ + mvr2r( hTonalMDCTConc->secondLastPowerSpectrum_float, powerSpectrum, nSamples ); /* Convert from 16 bits to 32 bits */ if ( psychParamsCurrent == NULL ) { nBands = FDNS_NPTS; - mdct_noiseShaping( powerSpectrum, hTonalMDCTConc->nSamplesCore, hTonalMDCTConc->secondLastBlockData.scaleFactors, nBands ); + mdct_noiseShaping( powerSpectrum, hTonalMDCTConc->nSamplesCore, hTonalMDCTConc->secondLastBlockData.scaleFactors_float, nBands ); } else { - sns_shape_spectrum( powerSpectrum, psychParamsCurrent, hTonalMDCTConc->secondLastBlockData.scaleFactors, hTonalMDCTConc->nSamplesCore ); + sns_shape_spectrum( powerSpectrum, psychParamsCurrent, hTonalMDCTConc->secondLastBlockData.scaleFactors_float, hTonalMDCTConc->nSamplesCore ); nBands = psychParamsCurrent->nBands; } - v_multc( powerSpectrum + hTonalMDCTConc->nSamplesCore, hTonalMDCTConc->secondLastBlockData.scaleFactors[nBands - 1], powerSpectrum + hTonalMDCTConc->nSamplesCore, nSamples - hTonalMDCTConc->nSamplesCore ); + v_multc( powerSpectrum + hTonalMDCTConc->nSamplesCore, hTonalMDCTConc->secondLastBlockData.scaleFactors_float[nBands - 1], powerSpectrum + hTonalMDCTConc->nSamplesCore, nSamples - hTonalMDCTConc->nSamplesCore ); v_mult( powerSpectrum, powerSpectrum, powerSpectrum, nSamples ); - RefineTonalComponents( hTonalMDCTConc->pTCI->indexOfTonalPeak, hTonalMDCTConc->pTCI->lowerIndex, hTonalMDCTConc->pTCI->upperIndex, hTonalMDCTConc->pTCI->phaseDiff, - hTonalMDCTConc->pTCI->phase_currentFramePredicted, &hTonalMDCTConc->pTCI->numIndexes, hTonalMDCTConc->lastPitchLag, pitchLag, - hTonalMDCTConc->lastBlockData.spectralData, hTonalMDCTConc->lastBlockData.scaleFactors, powerSpectrum, + RefineTonalComponents( hTonalMDCTConc->pTCI->indexOfTonalPeak, hTonalMDCTConc->pTCI->lowerIndex, hTonalMDCTConc->pTCI->upperIndex, hTonalMDCTConc->pTCI->phaseDiff_float, + hTonalMDCTConc->pTCI->phase_currentFramePredicted_float, &hTonalMDCTConc->pTCI->numIndexes, hTonalMDCTConc->lastPitchLag_float, pitchLag, + hTonalMDCTConc->lastBlockData.spectralData_float, hTonalMDCTConc->lastBlockData.scaleFactors_float, powerSpectrum, nSamples, hTonalMDCTConc->nSamplesCore, hTonalMDCTConc->nSamples * hTonalMDCTConc->nSamples / 400.0f /* floorPowerSpectrum */, psychParamsCurrent ); } } @@ -532,17 +532,17 @@ void TonalMDCTConceal_InsertNoise( { if ( concealment_noise[i] > 0 ) { - mdctSpectrum[i] = hTonalMDCTConc->lastBlockData.spectralData[i]; + mdctSpectrum[i] = hTonalMDCTConc->lastBlockData.spectralData_float[i]; } else { - mdctSpectrum[i] = -hTonalMDCTConc->lastBlockData.spectralData[i]; + mdctSpectrum[i] = -hTonalMDCTConc->lastBlockData.spectralData_float[i]; } } for ( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ ) { - mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData[l]; + mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData_float[l]; } } /* actual fadeout is done in this case */ @@ -552,7 +552,7 @@ void TonalMDCTConceal_InsertNoise( for ( i = 0; i < crossOverFreq; i++ ) { - x = hTonalMDCTConc->lastBlockData.spectralData[i]; + x = hTonalMDCTConc->lastBlockData.spectralData_float[i]; y = concealment_noise[i]; if ( y > 0 ) @@ -587,7 +587,7 @@ void TonalMDCTConceal_InsertNoise( mdctSpectrum[l] = 0; if ( l < crossOverFreq ) { - last_block_nrg_correct += hTonalMDCTConc->lastBlockData.spectralData[l] * hTonalMDCTConc->lastBlockData.spectralData[l]; + last_block_nrg_correct += hTonalMDCTConc->lastBlockData.spectralData_float[l] * hTonalMDCTConc->lastBlockData.spectralData_float[l]; hTonalMDCTConc->curr_noise_nrg -= concealment_noise[l] * concealment_noise[l]; } } @@ -600,11 +600,11 @@ void TonalMDCTConceal_InsertNoise( { if ( concealment_noise[l] > 0 ) { - mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData[l]; + mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData_float[l]; } else { - mdctSpectrum[l] = -hTonalMDCTConc->lastBlockData.spectralData[l]; + mdctSpectrum[l] = -hTonalMDCTConc->lastBlockData.spectralData_float[l]; } } for ( i = 1; i < hTonalMDCTConc->pTCI->numIndexes; i++ ) @@ -613,11 +613,11 @@ void TonalMDCTConceal_InsertNoise( { if ( concealment_noise[l] > 0 ) { - mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData[l]; + mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData_float[l]; } else { - mdctSpectrum[l] = -hTonalMDCTConc->lastBlockData.spectralData[l]; + mdctSpectrum[l] = -hTonalMDCTConc->lastBlockData.spectralData_float[l]; } } } @@ -626,17 +626,17 @@ void TonalMDCTConceal_InsertNoise( { if ( concealment_noise[l] > 0 ) { - mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData[l]; + mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData_float[l]; } else { - mdctSpectrum[l] = -hTonalMDCTConc->lastBlockData.spectralData[l]; + mdctSpectrum[l] = -hTonalMDCTConc->lastBlockData.spectralData_float[l]; } } for ( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ ) { - mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData[l]; + mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData_float[l]; } } /* actual fadeout is done in this case */ @@ -646,7 +646,7 @@ void TonalMDCTConceal_InsertNoise( for ( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ ) { - x = hTonalMDCTConc->lastBlockData.spectralData[l]; + x = hTonalMDCTConc->lastBlockData.spectralData_float[l]; y = concealment_noise[l]; if ( y > 0 ) @@ -663,7 +663,7 @@ void TonalMDCTConceal_InsertNoise( { for ( l = hTonalMDCTConc->pTCI->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI->lowerIndex[i]; l++ ) { - x = hTonalMDCTConc->lastBlockData.spectralData[l]; + x = hTonalMDCTConc->lastBlockData.spectralData_float[l]; y = concealment_noise[l]; if ( y > 0 ) @@ -680,7 +680,7 @@ void TonalMDCTConceal_InsertNoise( for ( l = hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1] + 1; l < crossOverFreq; l++ ) { - x = hTonalMDCTConc->lastBlockData.spectralData[l]; + x = hTonalMDCTConc->lastBlockData.spectralData_float[l]; y = concealment_noise[l]; if ( y > 0 ) @@ -715,7 +715,7 @@ void TonalMDCTConceal_InsertNoise( { for ( i = 0; i < crossOverFreq; i++ ) { - x = hTonalMDCTConc->lastBlockData.spectralData[i]; + x = hTonalMDCTConc->lastBlockData.spectralData_float[i]; nrgNoiseInLastFrame += x * x; rnd = own_random( &rnd ); mdctSpectrum[i] = tilt * rnd; @@ -728,7 +728,7 @@ void TonalMDCTConceal_InsertNoise( } for ( i = 0; i < crossOverFreq; i++ ) { - x = hTonalMDCTConc->lastBlockData.spectralData[i]; + x = hTonalMDCTConc->lastBlockData.spectralData_float[i]; y = mdctSpectrum[i]; if ( y > 0 ) @@ -743,7 +743,7 @@ void TonalMDCTConceal_InsertNoise( for ( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ ) { - mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData[l]; + mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData_float[l]; } } else @@ -751,7 +751,7 @@ void TonalMDCTConceal_InsertNoise( assert( hTonalMDCTConc->pTCI->numIndexes > 0 ); for ( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ ) { - x = hTonalMDCTConc->lastBlockData.spectralData[l]; + x = hTonalMDCTConc->lastBlockData.spectralData_float[l]; rnd = own_random( &rnd ); mdctSpectrum[l] = tilt * rnd; tilt *= tiltFactor; @@ -764,7 +764,7 @@ void TonalMDCTConceal_InsertNoise( tilt *= (float) pow( tiltFactor, hTonalMDCTConc->pTCI->upperIndex[i - 1] - hTonalMDCTConc->pTCI->lowerIndex[i - 1] + 1 ); for ( l = hTonalMDCTConc->pTCI->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI->lowerIndex[i]; l++ ) { - x = hTonalMDCTConc->lastBlockData.spectralData[l]; + x = hTonalMDCTConc->lastBlockData.spectralData_float[l]; rnd = own_random( &rnd ); mdctSpectrum[l] = tilt * rnd; tilt *= tiltFactor; @@ -776,7 +776,7 @@ void TonalMDCTConceal_InsertNoise( for ( l = hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1] + 1; l < crossOverFreq; l++ ) { - x = hTonalMDCTConc->lastBlockData.spectralData[l]; + x = hTonalMDCTConc->lastBlockData.spectralData_float[l]; rnd = own_random( &rnd ); mdctSpectrum[l] = tilt * rnd; tilt *= tiltFactor; @@ -789,7 +789,7 @@ void TonalMDCTConceal_InsertNoise( } for ( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ ) { - x = hTonalMDCTConc->lastBlockData.spectralData[l]; + x = hTonalMDCTConc->lastBlockData.spectralData_float[l]; y = mdctSpectrum[l]; if ( y > 0 ) @@ -805,7 +805,7 @@ void TonalMDCTConceal_InsertNoise( { for ( l = hTonalMDCTConc->pTCI->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI->lowerIndex[i]; l++ ) { - x = hTonalMDCTConc->lastBlockData.spectralData[l]; + x = hTonalMDCTConc->lastBlockData.spectralData_float[l]; y = mdctSpectrum[l]; if ( y > 0 ) @@ -831,7 +831,7 @@ void TonalMDCTConceal_InsertNoise( } for ( l = hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1] + 1; l < crossOverFreq; l++ ) { - x = hTonalMDCTConc->lastBlockData.spectralData[l]; + x = hTonalMDCTConc->lastBlockData.spectralData_float[l]; y = mdctSpectrum[l]; if ( y > 0 ) @@ -846,7 +846,7 @@ void TonalMDCTConceal_InsertNoise( for ( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ ) { - mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData[l]; + mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData_float[l]; } } } @@ -877,39 +877,39 @@ void TonalMDCTConceal_Apply( nSamples = hTonalMDCTConc->nNonZeroSamples; assert( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1] < nSamples ); - mvr2r( hTonalMDCTConc->secondLastPowerSpectrum, powerSpectrum, nSamples ); /* Convert from 16 bits to 32 bits */ + mvr2r( hTonalMDCTConc->secondLastPowerSpectrum_float, powerSpectrum, nSamples ); /* Convert from 16 bits to 32 bits */ if ( psychParamsCurrent == NULL ) { nBands = FDNS_NPTS; - mdct_noiseShaping( powerSpectrum, hTonalMDCTConc->nSamplesCore, hTonalMDCTConc->secondLastBlockData.scaleFactors, nBands ); + mdct_noiseShaping( powerSpectrum, hTonalMDCTConc->nSamplesCore, hTonalMDCTConc->secondLastBlockData.scaleFactors_float, nBands ); } else { - sns_shape_spectrum( powerSpectrum, psychParamsCurrent, hTonalMDCTConc->secondLastBlockData.scaleFactors, hTonalMDCTConc->nSamplesCore ); + sns_shape_spectrum( powerSpectrum, psychParamsCurrent, hTonalMDCTConc->secondLastBlockData.scaleFactors_float, hTonalMDCTConc->nSamplesCore ); nBands = psychParamsCurrent->nBands; } - v_multc( powerSpectrum + hTonalMDCTConc->nSamplesCore, hTonalMDCTConc->secondLastBlockData.scaleFactors[nBands - 1], powerSpectrum + hTonalMDCTConc->nSamplesCore, nSamples - hTonalMDCTConc->nSamplesCore ); + v_multc( powerSpectrum + hTonalMDCTConc->nSamplesCore, hTonalMDCTConc->secondLastBlockData.scaleFactors_float[nBands - 1], powerSpectrum + hTonalMDCTConc->nSamplesCore, nSamples - hTonalMDCTConc->nSamplesCore ); - phaseDiff = hTonalMDCTConc->pTCI->phaseDiff; /* if multiple frame loss occurs use the phase from the last frame and continue rotating */ - pCurrentPhase = hTonalMDCTConc->pTCI->phase_currentFramePredicted; + phaseDiff = hTonalMDCTConc->pTCI->phaseDiff_float; /* if multiple frame loss occurs use the phase from the last frame and continue rotating */ + pCurrentPhase = hTonalMDCTConc->pTCI->phase_currentFramePredicted_float; if ( !hTonalMDCTConc->lastBlockData.blockIsConcealed ) { if ( hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) { - hTonalMDCTConc->nFramesLost += 1; + hTonalMDCTConc->nFramesLost_float += 1; } else { - hTonalMDCTConc->nFramesLost = 1.5; + hTonalMDCTConc->nFramesLost_float = 1.5; } } /* for each index group */ for ( i = 0; i < hTonalMDCTConc->pTCI->numIndexes; i++ ) { - phaseToAdd = hTonalMDCTConc->nFramesLost * phaseDiff[i]; + phaseToAdd = hTonalMDCTConc->nFramesLost_float * phaseDiff[i]; /* Move phaseToAdd to range -EVS_PI..EVS_PI */ while ( phaseToAdd > EVS_PI ) @@ -931,7 +931,7 @@ void TonalMDCTConceal_Apply( } } - hTonalMDCTConc->nFramesLost++; + hTonalMDCTConc->nFramesLost_float++; return; } @@ -948,10 +948,10 @@ void TonalMDCTConceal_SaveTimeSignal( if ( !hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) { - mvr2r( hTonalMDCTConc->lastPcmOut + hTonalMDCTConc->nSamples / 2, hTonalMDCTConc->secondLastPcmOut, hTonalMDCTConc->nSamples / 2 ); + mvr2r( hTonalMDCTConc->lastPcmOut_float + hTonalMDCTConc->nSamples / 2, hTonalMDCTConc->secondLastPcmOut_float, hTonalMDCTConc->nSamples / 2 ); } - mvr2r( timeSignal, hTonalMDCTConc->lastPcmOut, hTonalMDCTConc->nSamples ); + mvr2r( timeSignal, hTonalMDCTConc->lastPcmOut_float, hTonalMDCTConc->nSamples ); } return; diff --git a/lib_dec/updt_dec.c b/lib_dec/updt_dec.c index 9ee8093ff..c6c348333 100644 --- a/lib_dec/updt_dec.c +++ b/lib_dec/updt_dec.c @@ -691,19 +691,19 @@ void update_decoder_LPD_cng( if ( hTcxDec != NULL ) { - mvr2r( hTcxDec->old_synth, buf_synth, hTcxDec->old_synth_len ); + mvr2r( hTcxDec->old_synth_float, buf_synth, hTcxDec->old_synth_len ); mvr2r( timeDomainBuffer, buf_synth + hTcxDec->old_synth_len, st->L_frame ); /* Update synth memory */ mvr2r( st->syn, synth_buf, 1 + M ); mvr2r( timeDomainBuffer, synth, st->L_frame ); mvr2r( synth + st->L_frame - ( 1 + M ), st->syn, 1 + M ); - mvr2r( hTcxDec->old_synth + st->L_frame, hTcxDec->old_synth, hTcxDec->old_synth_len - st->L_frame ); - mvr2r( synth, hTcxDec->old_synth + hTcxDec->old_synth_len - st->L_frame, st->L_frame ); + mvr2r( hTcxDec->old_synth_float + st->L_frame, hTcxDec->old_synth_float, hTcxDec->old_synth_len - st->L_frame ); + mvr2r( synth, hTcxDec->old_synth_float + hTcxDec->old_synth_len - st->L_frame, st->L_frame ); - mvr2r( synth + st->L_frame - ( st->L_frame / 2 ), hTcxDec->old_syn_Overl, st->L_frame / 2 ); + mvr2r( synth + st->L_frame - ( st->L_frame / 2 ), hTcxDec->old_syn_Overl_float, st->L_frame / 2 ); - hTcxDec->tcxltp_last_gain_unmodified = 0.0f; + hTcxDec->tcxltp_last_gain_unmodified_float = 0.0f; } /* Update pre-synth memory */ diff --git a/lib_dec/vlpc_2st_dec.c b/lib_dec/vlpc_2st_dec.c index 8ac23141b..58dc89554 100644 --- a/lib_dec/vlpc_2st_dec.c +++ b/lib_dec/vlpc_2st_dec.c @@ -70,7 +70,7 @@ void vlpc_2st_dec( } /* reorder */ - v_sort( lsfq, 0, M - 1 ); + v_sort_float( lsfq, 0, M - 1 ); reorder_lsf( lsfq, LSF_GAP, M, sr_core ); return; diff --git a/lib_dec/waveadjust_fec_dec.c b/lib_dec/waveadjust_fec_dec.c index dce0e221d..ba242e064 100644 --- a/lib_dec/waveadjust_fec_dec.c +++ b/lib_dec/waveadjust_fec_dec.c @@ -530,7 +530,7 @@ static int16_t waveform_adj( add_noise( sbuf, &( hPlcInfo->outx_new_n1 ), outdata2, L_frameTCX, &( hPlcInfo->nsapp_gain ), &( hPlcInfo->nsapp_gain_n ), 1 ); /* save current (noisy) output from IMDCT */ - mvr2r( outx_new, hPlcInfo->data_noise, L_frameTCX ); + mvr2r( outx_new, hPlcInfo->data_noise_float, L_frameTCX ); /* overlapbuf can now be filled with sbuf, needed for subsequently lost frames */ mvr2r( pitch125_data, &overlapbuf[L_frameTCX / 4], ( 3 * L_frameTCX ) / 4 ); @@ -558,7 +558,7 @@ void waveform_adj2( const int16_t bfi ) { int16_t i, n = 0; - float ratio; + float ratio_float; float sbuf[L_FRAME_MAX]; int16_t pitch, L_frameTCX; @@ -582,12 +582,12 @@ void waveform_adj2( } /* use last (noisy) output from IMDCT for noise generation */ - add_noise( sbuf, &( hPlcInfo->outx_new_n1 ), hPlcInfo->data_noise, L_frameTCX, &( hPlcInfo->nsapp_gain ), &( hPlcInfo->nsapp_gain_n ), 0 ); + add_noise( sbuf, &( hPlcInfo->outx_new_n1 ), hPlcInfo->data_noise_float, L_frameTCX, &( hPlcInfo->nsapp_gain ), &( hPlcInfo->nsapp_gain_n ), 0 ); if ( bfi ) { /* save current (noisy) output from IMDCT */ - mvr2r( outx_new, hPlcInfo->data_noise, L_frameTCX ); + mvr2r( outx_new, hPlcInfo->data_noise_float, L_frameTCX ); } if ( bfi_cnt == 4 || bfi == 0 ) @@ -598,7 +598,7 @@ void waveform_adj2( /* overlap-and-add */ if ( hPlcInfo->step_concealgain > EPSILON ) { - gain_zero_start = (int16_t) min( (float) L_FRAME48k, ( hPlcInfo->recovery_gain / hPlcInfo->step_concealgain ) ) + 1; + gain_zero_start = (int16_t) min( (float) L_FRAME48k, ( hPlcInfo->recovery_gain_float / hPlcInfo->step_concealgain ) ) + 1; } if ( delay > 0 ) @@ -607,18 +607,18 @@ void waveform_adj2( } for ( i = 0; i < min( gain_zero_start, L_frameTCX ); i++ ) { - ratio = (float) i / (float) L_frameTCX; - outx_new[i] = ( 1 - ratio ) * sbuf[i] * hPlcInfo->recovery_gain + ratio * outx_new[i]; - hPlcInfo->recovery_gain -= hPlcInfo->step_concealgain; + ratio_float = (float) i / (float) L_frameTCX; + outx_new[i] = ( 1 - ratio_float ) * sbuf[i] * hPlcInfo->recovery_gain_float + ratio_float * outx_new[i]; + hPlcInfo->recovery_gain_float -= hPlcInfo->step_concealgain; } for ( i = gain_zero_start; i < L_frameTCX; i++ ) { - ratio = (float) i / (float) L_frameTCX; - outx_new[i] = ratio * outx_new[i]; + ratio_float = (float) i / (float) L_frameTCX; + outx_new[i] = ratio_float * outx_new[i]; } - if ( hPlcInfo->recovery_gain < 0.0f ) + if ( hPlcInfo->recovery_gain_float < 0.0f ) { - hPlcInfo->recovery_gain = 0.0f; + hPlcInfo->recovery_gain_float = 0.0f; } } else @@ -626,8 +626,8 @@ void waveform_adj2( /* overlap-and-add */ for ( i = 0; i < L_frameTCX; i++ ) { - ratio = (float) i / (float) L_frameTCX; - outx_new[i] = ( 1 - ratio ) * sbuf[i] + ratio * outx_new[i]; + ratio_float = (float) i / (float) L_frameTCX; + outx_new[i] = ( 1 - ratio_float ) * sbuf[i] + ratio_float * outx_new[i]; } } } @@ -685,7 +685,7 @@ void concealment_init( hPlcInfo->ener_mean = 59.4260f; hPlcInfo->ener = 0.0f; hPlcInfo->zp = L_frameTCX; - hPlcInfo->recovery_gain = 0.0f; + hPlcInfo->recovery_gain_float = 0.0f; hPlcInfo->step_concealgain = 0.0f; hPlcInfo->concealment_method = TCX_NONTONAL; hPlcInfo->subframe = 0; @@ -845,8 +845,8 @@ void concealment_signal_tuning( { float voicing = 0; T_PLCInfo_HANDLE hPlcInfo = st->hPlcInfo; - float *OverlapBuf = st->hTonalMDCTConc->secondLastPcmOut; - float *outdata2 = st->hTonalMDCTConc->lastPcmOut; + float *OverlapBuf = st->hTonalMDCTConc->secondLastPcmOut_float; + float *outdata2 = st->hTonalMDCTConc->lastPcmOut_float; if ( bfi ) { diff --git a/lib_enc/acelp_core_enc.c b/lib_enc/acelp_core_enc.c index 7162bdeea..280c752d1 100644 --- a/lib_enc/acelp_core_enc.c +++ b/lib_enc/acelp_core_enc.c @@ -74,7 +74,7 @@ ivas_error acelp_core_enc( { int16_t i, nBits; /* reserved bits */ LPD_state_HANDLE hLPDmem; /* i/o: acelp memories */ - float old_exc[L_EXC], *exc; /* excitation signal buffer */ + float old_exc_flt[L_EXC], *exc; /* excitation signal buffer */ float lsf_new[M]; /* ISFs at the end of the frame */ float Aq[NB_SUBFR16k * ( M + 1 )]; /* A(z) quantized for the 4 subframes */ float syn[L_FRAME16k]; /* synthesis signal buffer */ @@ -133,8 +133,8 @@ ivas_error acelp_core_enc( Es_pred = 0; - exc = old_exc + L_EXC_MEM; /* pointer to excitation signal in the current frame */ - mvr2r( hLPDmem->old_exc, old_exc, L_EXC_MEM ); + exc = old_exc_flt + L_EXC_MEM; /* pointer to excitation signal in the current frame */ + mvr2r( hLPDmem->old_exc_flt, old_exc_flt, L_EXC_MEM ); if ( st->hBWE_TD != NULL ) { @@ -261,13 +261,13 @@ ivas_error acelp_core_enc( set_zero( st->mem_MA, M ); /* update synthesis filter memories */ - synth_mem_updt2( st->L_frame, st->last_L_frame, hLPDmem->old_exc, hLPDmem->mem_syn_r, hLPDmem->mem_syn2, hLPDmem->mem_syn, ENC ); - mvr2r( hLPDmem->old_exc, old_exc, L_EXC_MEM ); - mvr2r( hLPDmem->mem_syn2, hLPDmem->mem_syn1, M ); - mvr2r( hLPDmem->mem_syn2, hLPDmem->mem_syn3, M ); + synth_mem_updt2( st->L_frame, st->last_L_frame, hLPDmem->old_exc_flt, hLPDmem->mem_syn_r_flt, hLPDmem->mem_syn2_flt, hLPDmem->mem_syn_flt, ENC ); + mvr2r( hLPDmem->old_exc_flt, old_exc_flt, L_EXC_MEM ); + mvr2r( hLPDmem->mem_syn2_flt, hLPDmem->mem_syn1_flt, M ); + mvr2r( hLPDmem->mem_syn2_flt, hLPDmem->mem_syn3_flt, M ); /* update Aw[] coefficients */ - weight_a_subfr( st->L_frame / L_SUBFR, A, Aw, st->gamma, M ); + weight_a_subfr( st->L_frame / L_SUBFR, A, Aw, st->gamma_flt, M ); } if ( st->last_bwidth == NB && st->bwidth != NB && st->ini_frame != 0 ) @@ -284,7 +284,7 @@ ivas_error acelp_core_enc( if ( st->cng_type == LP_CNG ) { /* Run CNG post parameter update */ - cng_params_postupd( st->hTdCngEnc->ho_circ_ptr, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_brate_buf, st->hTdCngEnc->ho_env_circ, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); + cng_params_postupd( st->hTdCngEnc->ho_circ_ptr, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf_flt, st->hTdCngEnc->cng_brate_buf, st->hTdCngEnc->ho_env_circ, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); /* encode CNG parameters */ CNG_enc( st, Aq, inp, ener, lsp_mid, lsp_new, lsf_new, &allow_cn_step, q_env, &sid_bw ); @@ -324,29 +324,29 @@ ivas_error acelp_core_enc( } /* synthesis at 12.8kHz sampling rate */ - syn_12k8( st->L_frame, Aq, exc3, syn1, hLPDmem->mem_syn3, 1 ); + syn_12k8( st->L_frame, Aq, exc3, syn1, hLPDmem->mem_syn3_flt, 1 ); /* reset the encoder */ CNG_reset_enc( st, pitch_buf, voice_factors, 0 ); - /* update st->mem_syn1 for ACELP core switching */ - mvr2r( hLPDmem->mem_syn3, hLPDmem->mem_syn1, M ); + /* update st->mem_syn1_flt for ACELP core switching */ + mvr2r( hLPDmem->mem_syn3_flt, hLPDmem->mem_syn1_flt, M ); /* update ACELP core synthesis filter memory */ - mvr2r( hLPDmem->mem_syn3, hLPDmem->mem_syn, M ); + mvr2r( hLPDmem->mem_syn3_flt, hLPDmem->mem_syn_flt, M ); /* update old synthesis buffer - needed for ACELP internal sampling rate switching */ - mvr2r( syn1 + st->L_frame - L_SYN_MEM, hLPDmem->mem_syn_r, L_SYN_MEM ); + mvr2r( syn1 + st->L_frame - L_SYN_MEM, hLPDmem->mem_syn_r_flt, L_SYN_MEM ); /* save and delay synthesis to be used by SWB BWE */ if ( st->hBWE_FD != NULL ) { - save_old_syn( st->L_frame, syn1, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn ); + save_old_syn( st->L_frame, syn1, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k, st->preemph_fac_flt, &st->hBWE_FD->mem_deemph_old_syn ); } /*Update MODE2 core switching memory*/ - deemph( syn1, st->preemph_fac, st->L_frame, &( hLPDmem->syn[M] ) ); - mvr2r( syn1 + st->L_frame - M - 1, hLPDmem->syn, M + 1 ); + deemph( syn1, st->preemph_fac_flt, st->L_frame, &( hLPDmem->syn_flt[M] ) ); + mvr2r( syn1 + st->L_frame - M - 1, hLPDmem->syn_flt, M + 1 ); } /*----------------------------------------------------------------* @@ -445,10 +445,10 @@ ivas_error acelp_core_enc( if ( st->last_core == HQ_CORE && st->element_mode > EVS_MONO ) { /* Prepare ACB memory from last HQ frame */ - tmpF = hLPDmem->old_exc[0]; - preemph( hLPDmem->old_exc, st->preemph_fac, st->L_frame, &tmpF ); - mvr2r( hLPDmem->old_exc + st->L_frame - M, hLPDmem->mem_syn, M ); - residu( Aq, M, hLPDmem->old_exc, old_exc, st->L_frame ); + tmpF = hLPDmem->old_exc_flt[0]; + preemph( hLPDmem->old_exc_flt, st->preemph_fac_flt, st->L_frame, &tmpF ); + mvr2r( hLPDmem->old_exc_flt + st->L_frame - M, hLPDmem->mem_syn_flt, M ); + residu( Aq, M, hLPDmem->old_exc_flt, old_exc_flt, st->L_frame ); } if ( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO ) @@ -456,11 +456,11 @@ ivas_error acelp_core_enc( /* Prepare ACB memory of old_bwe_exc */ if ( st->L_frame == L_FRAME ) { - lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC ); + lerp( old_exc_flt, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC ); } else { - lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * 2, L_EXC_MEM_DEC ); + lerp( old_exc_flt, old_bwe_exc, L_EXC_MEM_DEC * 2, L_EXC_MEM_DEC ); } } @@ -568,26 +568,26 @@ ivas_error acelp_core_enc( } - /* update mem_syn1 for ACELP core switching */ - mvr2r( hLPDmem->mem_syn, hLPDmem->mem_syn1, M ); + /* update mem_syn1_flt for ACELP core switching */ + mvr2r( hLPDmem->mem_syn_flt, hLPDmem->mem_syn1_flt, M ); /* update old synthesis buffer - needed for ACELP internal sampling rate switching */ - mvr2r( syn + st->L_frame - L_SYN_MEM, hLPDmem->mem_syn_r, L_SYN_MEM ); + mvr2r( syn + st->L_frame - L_SYN_MEM, hLPDmem->mem_syn_r_flt, L_SYN_MEM ); /* save and delay synthesis to be used by SWB BWE */ if ( st->hBWE_FD != NULL ) { - save_old_syn( st->L_frame, syn, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn ); + save_old_syn( st->L_frame, syn, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k, st->preemph_fac_flt, &st->hBWE_FD->mem_deemph_old_syn ); } /*Update MODE2 core switching memory*/ mvr2r( syn, syn1, st->L_frame ); - deemph( syn1, st->preemph_fac, st->L_frame, &( hLPDmem->syn[M] ) ); - mvr2r( syn1 + st->L_frame - M - 1, hLPDmem->syn, M + 1 ); + deemph( syn1, st->preemph_fac_flt, st->L_frame, &( hLPDmem->syn_flt[M] ) ); + mvr2r( syn1 + st->L_frame - M - 1, hLPDmem->syn_flt, M + 1 ); if ( st->element_mode > EVS_MONO && st->hTcxEnc != NULL ) { - mvr2r( syn1 + st->L_frame / 2, st->hTcxEnc->Txnq, st->L_frame / 2 ); + mvr2r( syn1 + st->L_frame / 2, st->hTcxEnc->Txnq_flt, st->L_frame / 2 ); } /*--------------------------------------------------------------------------------------* @@ -667,12 +667,12 @@ ivas_error acelp_core_enc( * Updates *-----------------------------------------------------------------*/ - updt_enc( st, old_exc, pitch_buf, Es_pred, Aq, lsf_new, lsp_new, old_bwe_exc ); + updt_enc( st, old_exc_flt, pitch_buf, Es_pred, Aq, lsf_new, lsp_new, old_bwe_exc ); if ( st->hTdCngEnc != NULL && st->Opt_DTX_ON && st->core_brate > SID_2k40 ) { /* update CNG parameters in active frames */ - cng_params_upd( lsp_new, exc, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ, ENC, st->hTdCngEnc->ho_env_circ, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); + cng_params_upd( lsp_new, exc, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ, ENC, st->hTdCngEnc->ho_env_circ, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf_flt, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); if ( st->L_frame == L_FRAME ) { diff --git a/lib_enc/acelp_core_switch_enc.c b/lib_enc/acelp_core_switch_enc.c index b54262c4f..46fc6b725 100644 --- a/lib_enc/acelp_core_switch_enc.c +++ b/lib_enc/acelp_core_switch_enc.c @@ -76,7 +76,7 @@ void acelp_core_switch_enc( /* initializations */ exc = old_exc + L_EXC_MEM; /* pointer to excitation signal in the current frame */ - mvr2r( st->hLPDmem->old_exc, old_exc, L_EXC_MEM ); + mvr2r( st->hLPDmem->old_exc_flt, old_exc, L_EXC_MEM ); mvr2r( st->old_Aq_12_8, Aq, M + 1 ); mvr2r( st->old_Aq_12_8, Aq + ( M + 1 ), M + 1 ); @@ -257,13 +257,13 @@ static void encod_gen_voic_core_switch( if ( L_frame == L_FRAME16k ) { - weight_a( A, Ap, GAMMA16k, M ); /* Bandwidth expansion of A(z) filter coefficients */ - find_targets( inp, hLPDmem->mem_syn, 0, &( hLPDmem->mem_w0 ), Aq, res, L_SUBFR, Ap, PREEMPH_FAC_16k, xn, cn, h1 ); + weight_a( A, Ap, GAMMA16k_FLT, M ); /* Bandwidth expansion of A(z) filter coefficients */ + find_targets( inp, hLPDmem->mem_syn_flt, 0, &( hLPDmem->mem_w0_flt ), Aq, res, L_SUBFR, Ap, PREEMPH_FAC_16k_FLT, xn, cn, h1 ); } else { - weight_a( A, Ap, GAMMA1, M ); /* Bandwidth expansion of A(z) filter coefficients */ - find_targets( inp, hLPDmem->mem_syn, 0, &( hLPDmem->mem_w0 ), Aq, res, L_SUBFR, Ap, PREEMPH_FAC, xn, cn, h1 ); + weight_a( A, Ap, GAMMA1_FLT, M ); /* Bandwidth expansion of A(z) filter coefficients */ + find_targets( inp, hLPDmem->mem_syn_flt, 0, &( hLPDmem->mem_w0_flt ), Aq, res, L_SUBFR, Ap, PREEMPH_FAC_FLT, xn, cn, h1 ); } /*----------------------------------------------------------------* @@ -304,7 +304,7 @@ static void encod_gen_voic_core_switch( * Innovation encoding *-----------------------------------------------------------------*/ - inov_encode( st, core_bitrate, 0, L_frame, L_frame, GENERIC, st->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc, h1, hLPDmem->tilt_code, pitch, xn2, code, y2, &unbits, L_SUBFR ); + inov_encode( st, core_bitrate, 0, L_frame, L_frame, GENERIC, st->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc, h1, hLPDmem->tilt_code_flt, pitch, xn2, code, y2, &unbits, L_SUBFR ); /*-----------------------------------------------------------------* * Gain encoding @@ -321,7 +321,7 @@ static void encod_gen_voic_core_switch( gp_clip_test_gain_pit( st->element_mode, core_bitrate, gain_pit, st->clip_var ); - hLPDmem->tilt_code = est_tilt( exc, gain_pit, code, gain_code, &voice_fac, L_SUBFR, 0 ); + hLPDmem->tilt_code_flt = est_tilt( exc, gain_pit, code, gain_code, &voice_fac, L_SUBFR, 0 ); /*-----------------------------------------------------------------* * Construct adaptive part of the excitation diff --git a/lib_enc/amr_wb_enc.c b/lib_enc/amr_wb_enc.c index b133d9413..43406ac39 100644 --- a/lib_enc/amr_wb_enc.c +++ b/lib_enc/amr_wb_enc.c @@ -59,7 +59,7 @@ void amr_wb_enc( int16_t i, delay, harm_flag; float old_inp[L_INP_12k8], *new_inp, *inp; /* buffer of old input signal */ float old_inp_16k[L_INP_12k8 + L_SUBFR], *inp_16k, *new_inp_16k; /* buffer of old input signal @16kHz*/ - float old_exc[L_EXC], *exc; /* excitation signal buffer */ + float old_exc_flt[L_EXC], *exc; /* excitation signal buffer */ float old_wsp[L_WSP], *wsp; /* weighted input signal buffer */ int16_t input_frame; /* frame length at input sampling freq. */ float fr_bands[2 * NB_BANDS]; /* energy in frequency bands */ @@ -107,7 +107,7 @@ void amr_wb_enc( *------------------------------------------------------------------*/ st->L_frame = L_FRAME; - st->gamma = GAMMA1; + st->gamma_flt = GAMMA1_FLT; st->core = AMR_WB_CORE; st->core_brate = st->total_brate; st->input_bwidth = st->last_input_bwidth; @@ -140,8 +140,8 @@ void amr_wb_enc( set_s( hf_gain, 0, NB_SUBFR ); set_f( old_inp, 0.0f, L_INP_12k8 ); - exc = old_exc + L_EXC_MEM; /* pointer to excitation signal in the current frame */ - mvr2r( hLPDmem->old_exc, old_exc, L_EXC_MEM ); + exc = old_exc_flt + L_EXC_MEM; /* pointer to excitation signal in the current frame */ + mvr2r( hLPDmem->old_exc_flt, old_exc_flt, L_EXC_MEM ); new_inp = old_inp + L_INP_MEM; /* pointer to new samples of the input signal */ inp = new_inp - L_LOOK_12k8; /* pointer to current frame of input signal */ @@ -182,7 +182,7 @@ void amr_wb_enc( st->input[i] = 0; } - hp20( st->input, input_frame, mem_hp20_in, st->input_Fs ); + hp20_flt( st->input, input_frame, mem_hp20_in, st->input_Fs ); /*-----------------------------------------------------------------* * switching from ACELP@16k core to AMR-WB IO mode @@ -205,10 +205,10 @@ void amr_wb_enc( set_zero( st->mem_MA, M ); /* update synthesis filter memories */ - synth_mem_updt2( L_FRAME, st->last_L_frame, hLPDmem->old_exc, hLPDmem->mem_syn_r, hLPDmem->mem_syn1, hLPDmem->mem_syn, ENC ); - mvr2r( hLPDmem->old_exc, old_exc, L_EXC_MEM ); - mvr2r( hLPDmem->mem_syn1, hLPDmem->mem_syn2, M ); - mvr2r( hLPDmem->mem_syn2, hLPDmem->mem_syn3, M ); + synth_mem_updt2( L_FRAME, st->last_L_frame, hLPDmem->old_exc_flt, hLPDmem->mem_syn_r_flt, hLPDmem->mem_syn1_flt, hLPDmem->mem_syn_flt, ENC ); + mvr2r( hLPDmem->old_exc_flt, old_exc_flt, L_EXC_MEM ); + mvr2r( hLPDmem->mem_syn1_flt, hLPDmem->mem_syn2_flt, M ); + mvr2r( hLPDmem->mem_syn2_flt, hLPDmem->mem_syn3_flt, M ); /* lsp -> isp */ mvr2r( stable_ISP, isp_tmp, M ); @@ -253,13 +253,13 @@ void amr_wb_enc( modify_Fs( st->input, input_frame, st->input_Fs, new_inp, 12800, st->mem_decim, 0 ); /* update signal buffer */ - mvr2r( new_inp, st->buf_speech_enc + L_FRAME, L_FRAME ); + mvr2r( new_inp, st->buf_speech_enc_flt + L_FRAME, L_FRAME ); /*------------------------------------------------------------------* * Perform fixed preemphasis through 1 - g*z^-1 *-----------------------------------------------------------------*/ - preemph( new_inp, PREEMPH_FAC, L_FRAME, &st->mem_preemph ); + preemph( new_inp, PREEMPH_FAC_FLT, L_FRAME, &st->mem_preemph ); /*----------------------------------------------------------------* * Compute spectrum, find energy per critical frequency band @@ -325,7 +325,7 @@ void amr_wb_enc( lp_bckr = mean( st->hNoiseEst->bckr + 1, 9 ); } hp_bckr = 0.5f * ( st->hNoiseEst->bckr[st->max_band - 1] + st->hNoiseEst->bckr[st->max_band] ); - st->bckr_tilt_lt = 0.9f * st->bckr_tilt_lt + 0.1f * lp_bckr / hp_bckr; + st->bckr_tilt_lt_flt = 0.9f * st->bckr_tilt_lt_flt + 0.1f * lp_bckr / hp_bckr; corr_shift = correlation_shift( st->hNoiseEst->totalNoise ); @@ -360,7 +360,7 @@ void amr_wb_enc( analy_lp_AMR_WB( inp, &ener, A, epsP, isp_new, st->lsp_old1, isf_new, st->old_pitch_la, st->voicing[2] ); /* compute weighted input */ - find_wsp( L_FRAME, L_SUBFR, NB_SUBFR, A, Aw, inp, TILT_FAC, wsp, &st->mem_wsp, GAMMA1, L_LOOK_12k8 ); + find_wsp( L_FRAME, L_SUBFR, NB_SUBFR, A, Aw, inp, TILT_FAC, wsp, &st->mem_wsp, GAMMA1_FLT, L_LOOK_12k8 ); /* open-loop pitch analysis */ pitch_ol( st->pitch, st->voicing, &st->old_pitch, &st->old_corr, corr_shift, &st->old_thres, &st->delta_pit, st->old_wsp2, wsp, st->mem_decim2, relE, L_LOOK_12k8, 0, st->bwidth, 0 ); @@ -410,23 +410,23 @@ void amr_wb_enc( } /* synthesis */ - syn_12k8( L_FRAME, Aq, exc2, dummy_buf, hLPDmem->mem_syn3, 1 ); /* dummy_buf = temporary buffer to handle syn1[] */ + syn_12k8( L_FRAME, Aq, exc2, dummy_buf, hLPDmem->mem_syn3_flt, 1 ); /* dummy_buf = temporary buffer to handle syn1[] */ /* reset the encoder */ CNG_reset_enc( st, pitch_buf, dummy_buf + L_FRAME, 0 ); - /* update mem_syn1 for ACELP core switching */ - mvr2r( hLPDmem->mem_syn3, hLPDmem->mem_syn1, M ); + /* update mem_syn1_flt for ACELP core switching */ + mvr2r( hLPDmem->mem_syn3_flt, hLPDmem->mem_syn1_flt, M ); /* update ACELP core synthesis filter memory */ - mvr2r( hLPDmem->mem_syn3, hLPDmem->mem_syn, M ); + mvr2r( hLPDmem->mem_syn3_flt, hLPDmem->mem_syn_flt, M ); /* update old synthesis buffer - needed for ACELP internal sampling rate switching */ - mvr2r( dummy_buf + L_FRAME - L_SYN_MEM, hLPDmem->mem_syn_r, L_SYN_MEM ); + mvr2r( dummy_buf + L_FRAME - L_SYN_MEM, hLPDmem->mem_syn_r_flt, L_SYN_MEM ); /* Update MODE2 core switching memory */ - deemph( dummy_buf, PREEMPH_FAC, L_FRAME, &( hLPDmem->syn[M] ) ); - mvr2r( dummy_buf + L_FRAME - M - 1, hLPDmem->syn, M + 1 ); + deemph( dummy_buf, PREEMPH_FAC_FLT, L_FRAME, &( hLPDmem->syn_flt[M] ) ); + mvr2r( dummy_buf + L_FRAME - M - 1, hLPDmem->syn_flt, M + 1 ); } /*----------------------------------------------------------------* @@ -443,7 +443,7 @@ void amr_wb_enc( { mvr2r( st->hDtxEnc->lspCNG, st->lsp_old, M ); isp2isf( st->hDtxEnc->lspCNG, st->lsf_old, M, INT_FS_12k8 ); - set_f( old_exc, 0, L_EXC_MEM ); + set_f( old_exc_flt, 0, L_EXC_MEM ); } /*-----------------------------------------------------------------* @@ -470,16 +470,16 @@ void amr_wb_enc( encod_amr_wb( st, inp, Aw, Aq, res, syn, exc, exc2, pitch_buf, hf_gain, inp_16k ); - /* update mem_syn1 for ACELP core switching */ - mvr2r( hLPDmem->mem_syn, hLPDmem->mem_syn1, M ); + /* update mem_syn1_flt for ACELP core switching */ + mvr2r( hLPDmem->mem_syn_flt, hLPDmem->mem_syn1_flt, M ); /* update old synthesis buffer - needed for ACELP internal sampling rate switching */ - mvr2r( syn + L_FRAME - L_SYN_MEM, hLPDmem->mem_syn_r, L_SYN_MEM ); + mvr2r( syn + L_FRAME - L_SYN_MEM, hLPDmem->mem_syn_r_flt, L_SYN_MEM ); /* Update MODE2 core switching memory */ mvr2r( syn, dummy_buf, L_FRAME ); - deemph( dummy_buf, PREEMPH_FAC, L_FRAME, &( hLPDmem->syn[M] ) ); - mvr2r( dummy_buf + L_FRAME - M - 1, hLPDmem->syn, M + 1 ); + deemph( dummy_buf, PREEMPH_FAC_FLT, L_FRAME, &( hLPDmem->syn_flt[M] ) ); + mvr2r( dummy_buf + L_FRAME - M - 1, hLPDmem->syn_flt, M + 1 ); /*--------------------------------------------------------------------------------------* * Write VAD information into the bitstream in AMR-WB IO mode @@ -509,11 +509,11 @@ void amr_wb_enc( mvr2r( fr_bands + NB_BANDS, st->hNoiseEst->enrO, NB_BANDS ); /* update signal buffers */ - mvr2r( new_inp, st->buf_speech_enc_pe + L_FRAME, L_FRAME ); - mvr2r( wsp, st->buf_wspeech_enc + L_FRAME + L_SUBFR, L_FRAME + L_LOOK_12k8 ); + mvr2r( new_inp, st->buf_speech_enc_pe_flt + L_FRAME, L_FRAME ); + mvr2r( wsp, st->buf_wspeech_enc_flt + L_FRAME + L_SUBFR, L_FRAME + L_LOOK_12k8 ); /* update ACELP core parameters */ - updt_enc( st, old_exc, pitch_buf, 0, Aq, isf_new, isp_new, dummy_buf ); + updt_enc( st, old_exc_flt, pitch_buf, 0, Aq, isf_new, isp_new, dummy_buf ); /* update main codec paramaters */ updt_enc_common( st ); diff --git a/lib_enc/ari_hm_enc.c b/lib_enc/ari_hm_enc.c index 46a093369..d37bdd92c 100644 --- a/lib_enc/ari_hm_enc.c +++ b/lib_enc/ari_hm_enc.c @@ -267,7 +267,7 @@ int16_t SearchPeriodicityIndex( } - if ( ( LtpPitchLag > 0 ) && ( LtpGain > kLtpHmGainThr ) ) + if ( ( LtpPitchLag > 0 ) && ( LtpGain > kLtpHmGainThr_FLT ) ) { int16_t FractionalResolution = kLtpHmFractionalResolution; int16_t Multiplier, LtpPitchIndex, Bandwidth; diff --git a/lib_enc/arith_coder_enc.c b/lib_enc/arith_coder_enc.c index d4b473549..d200fc9a9 100644 --- a/lib_enc/arith_coder_enc.c +++ b/lib_enc/arith_coder_enc.c @@ -601,15 +601,15 @@ void tcx_arith_encode_envelope( assert( L_spec <= N_MAX_ARI ); hTcxCfg = st->hTcxCfg; - deadzone = hTcxCfg->sq_rounding; + deadzone = hTcxCfg->sq_rounding_flt; deadzone_flags = hTcxEnc->memQuantZeros; *signaling_bits = 0; assert( st->enableTcxLpc ); gamma_w = 1.0f; - gamma_uw = 1.0f / st->gamma; + gamma_uw = 1.0f / st->gamma_flt; #define WMC_TOOL_SKIP - tcx_arith_render_envelope( A_ind, L_frame, L_spec, FL2WORD16( hTcxCfg->preemph_fac ), FL2WORD16( gamma_w ), FL2WORD16( 0.5f * gamma_uw ), env ); + tcx_arith_render_envelope( A_ind, L_frame, L_spec, FL2WORD16( hTcxCfg->preemph_fac_flt), FL2WORD16( gamma_w ), FL2WORD16( 0.5f * gamma_uw ), env ); #undef WMC_TOOL_SKIP for ( k = 0; k < L_spec; ++k ) @@ -627,7 +627,7 @@ void tcx_arith_encode_envelope( if ( use_hm ) { - tcx_hm_analyse( spectrum, L_spec, env, target_bits, hTcxCfg->coder_type, prm_hm, tcxltp_pitch, hTcxEnc->tcxltp_gain, &hm_bits ); + tcx_hm_analyse( spectrum, L_spec, env, target_bits, hTcxCfg->coder_type, prm_hm, tcxltp_pitch, hTcxEnc->tcxltp_gain_flt, &hm_bits ); target_bits -= hm_bits; *signaling_bits += hm_bits; @@ -653,7 +653,7 @@ void tcx_arith_encode_envelope( exponents[k] = expfp( negate( envelope[k] ), tmp ); } #undef WMC_TOOL_SKIP - scale = tcx_arith_rateloop( spectrum, L_spec, envelope, envelope_e, exponents, target_bits, deadzone, deadzone_flags, &( hTcxEnc->tcx_target_bits_fac ) ); + scale = tcx_arith_rateloop( spectrum, L_spec, envelope, envelope_e, exponents, target_bits, deadzone, deadzone_flags, &( hTcxEnc->tcx_target_bits_fac_flt) ); /* Final quantization */ kMax = tcx_arith_find_kMax( spectrum, L_spec, scale, deadzone, deadzone_flags ); diff --git a/lib_enc/bw_detect.c b/lib_enc/bw_detect.c index 94e26fbf5..fa0cdc6c3 100644 --- a/lib_enc/bw_detect.c +++ b/lib_enc/bw_detect.c @@ -100,7 +100,7 @@ void bw_detect( { float ScalFac; - ScalFac = 1 / ( st->cldfbAnaEnc->scale * st->cldfbAnaEnc->scale * 8.f ); + ScalFac = 1 / ( st->cldfbAnaEnc->scale_flt * st->cldfbAnaEnc->scale_flt * 8.f ); set_f( cldfb_bin, 0.001f, 9 ); /* NB: 1.2 - 2.8 kHz, 4 cldfb-bands*/ diff --git a/lib_enc/cod4t64.c b/lib_enc/cod4t64.c index 8d851c47d..6f93a9d5c 100644 --- a/lib_enc/cod4t64.c +++ b/lib_enc/cod4t64.c @@ -110,7 +110,7 @@ int16_t acelp_4t64( { case 20: /* EVS/AMR-WB pulse indexing: 20 bits, 4 pulses, 4 tracks */ config.nbiter = 4; /* 4x12x16=768 loop */ - config.alp = 2.0f; + config.alp_flt = 2.0f; config.nb_pulse = 4; config.fixedpulses = 0; config.nbpos[0] = 4; @@ -119,7 +119,7 @@ int16_t acelp_4t64( case 28: /* EVS pulse indexing: 28 bits, 6 pulses, 4 tracks */ config.nbiter = 4; /* 4x20x16=1280 loops */ - config.alp = 1.0f; /* coeff for sign setting */ + config.alp_flt = 1.0f; /* coeff for sign setting */ config.nb_pulse = 6; config.fixedpulses = 0; config.nbpos[0] = 6; @@ -129,7 +129,7 @@ int16_t acelp_4t64( case 36: /* EVS/AMR-WB pulse indexing: 36 bits, 8 pulses, 4 tracks */ config.nbiter = 4; /* 4x20x16=1280 loops */ - config.alp = 1.0f; /* coeff for sign setting */ + config.alp_flt = 1.0f; /* coeff for sign setting */ config.nb_pulse = 8; config.fixedpulses = 2; config.nbpos[0] = 4; @@ -140,7 +140,7 @@ int16_t acelp_4t64( case 43: /* EVS pulse indexing: 43 bits, 10 pulses, 4 tracks */ case 44: /* AMR-WB pulse indexing: 44 bits, 10 pulses, 4 tracks */ config.nbiter = 4; /* 4x26x16=1664 loops */ - config.alp = 1.0f; + config.alp_flt = 1.0f; config.nb_pulse = 10; config.fixedpulses = 2; config.nbpos[0] = 4; @@ -152,7 +152,7 @@ int16_t acelp_4t64( case 50: /* EVS pulse indexing: 50 bits, 12 pulses, 4 tracks */ case 52: /* AMR-WB pulse indexing: 52 bits, 12 pulses, 4 tracks */ config.nbiter = 4; /* 4x26x16=1664 loops */ - config.alp = 1.0f; + config.alp_flt = 1.0f; config.nb_pulse = 12; config.fixedpulses = 4; config.nbpos[0] = 4; @@ -164,7 +164,7 @@ int16_t acelp_4t64( case 62: /* EVS pulse indexing: 62 bits, 16 pulses, 4 tracks */ case 64: /* AMR-WB pulse indexing: 64 bits, 16 pulses, 4 tracks */ config.nbiter = 3; /* 3x36x16=1728 loops */ - config.alp = 0.8F; + config.alp_flt = 0.8F; config.nb_pulse = 16; config.fixedpulses = 4; config.nbpos[0] = 4; @@ -177,7 +177,7 @@ int16_t acelp_4t64( case 72: /* AMR-WB pulse indexing: 72 bits, 18 pulses, 4 tracks */ config.nbiter = 3; /* 3x35x16=1680 loops */ - config.alp = 0.75F; + config.alp_flt = 0.75F; config.nb_pulse = 18; config.fixedpulses = 4; config.nbpos[0] = 2; @@ -191,7 +191,7 @@ int16_t acelp_4t64( case 88: /* AMR-WB pulse indexing: 88 bits, 24 pulses, 4 tracks */ config.nbiter = 2; /* 2x53x16=1696 loop */ - config.alp = 0.5f; + config.alp_flt = 0.5f; config.nb_pulse = 24; config.fixedpulses = 4; config.nbpos[0] = 2; @@ -208,7 +208,7 @@ int16_t acelp_4t64( case 87: /* EVS pulse indexing: 87 bits, 26 pulses, 4 tracks */ config.nbiter = 1; - config.alp = 0.5F; + config.alp_flt = 0.5F; config.nb_pulse = 26; config.fixedpulses = 4; config.nbpos[0] = 4; diff --git a/lib_enc/cod_ace.c b/lib_enc/cod_ace.c index 75058cfdd..867a96e47 100644 --- a/lib_enc/cod_ace.c +++ b/lib_enc/cod_ace.c @@ -109,17 +109,17 @@ void coder_acelp( /* Reset phase dispersion */ if ( st->last_core > ACELP_CORE ) { - set_zero( st->hLPDmem->dispMem, 8 ); + set_zero( st->hLPDmem->dispMem_flt, 8 ); } /* set excitation memory*/ exc = exc_buf + L_EXC_MEM; - mvr2r( LPDmem->old_exc, exc_buf, L_EXC_MEM ); + mvr2r( LPDmem->old_exc_flt, exc_buf, L_EXC_MEM ); *( exc + st->L_frame ) = 0.f; /*to solve a warning*/ /* Init syn buffer */ syn = syn_buf + M; - mvr2r( LPDmem->mem_syn, syn_buf, M ); + mvr2r( LPDmem->mem_syn_flt, syn_buf, M ); pt_pitch = pitch_buf; pt_gain_pitch = gain_pitch_buf; @@ -195,7 +195,7 @@ void coder_acelp( * and impulse response of the weighted synthesis filter (h1[]). * *--------------------------------------------------------------------------*/ - find_targets( speech, &syn[i_subfr - M], i_subfr, &LPDmem->mem_w0, p_Aq, exc, L_SUBFR, p_A, st->preemph_fac, xn, cn, h1 ); + find_targets( speech, &syn[i_subfr - M], i_subfr, &LPDmem->mem_w0_flt, p_Aq, exc, L_SUBFR, p_A, st->preemph_fac_flt, xn, cn, h1 ); /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure @@ -249,15 +249,15 @@ void coder_acelp( prm++; } - g_corr.y1y1 = g_corr2[0]; - g_corr.xy1 = -0.5f * ( g_corr2[1] - 0.01f ) + 0.01f; + g_corr.y1y1_flt = g_corr2[0]; + g_corr.xy1_flt = -0.5f * ( g_corr2[1] - 0.01f ) + 0.01f; } else { /* No adaptive codebook (UC) */ gain_pit = 0.f; - g_corr.xy1 = 0.f; - g_corr.y1y1 = 0.f; + g_corr.xy1_flt = 0.f; + g_corr.y1y1_flt = 0.f; set_zero( y1, L_SUBFR ); set_zero( exc + i_subfr, L_SUBFR ); T0 = L_SUBFR; @@ -276,14 +276,14 @@ void coder_acelp( * Encode the algebraic innovation * *----------------------------------------------------------------------*/ - E_ACELP_innovative_codebook( exc, T0, T0_frac, T0_res, gain_pit, LPDmem->tilt_code, acelp_cfg, i_subfr, p_Aq, h1, xn, cn, y1, y2, st->acelp_autocorr, &prm, code, st->L_frame, st->last_L_frame, st->total_brate ); + E_ACELP_innovative_codebook( exc, T0, T0_frac, T0_res, gain_pit, LPDmem->tilt_code_flt, acelp_cfg, i_subfr, p_Aq, h1, xn, cn, y1, y2, st->acelp_autocorr, &prm, code, st->L_frame, st->last_L_frame, st->total_brate ); E_corr_xy2( xn, y1, y2, g_corr2, L_SUBFR ); - g_corr.y2y2 = 0.01F + g_corr2[2]; - g_corr.xy2 = 0.01F + -0.5f * g_corr2[3]; - g_corr.y1y2 = 0.01F + 0.5f * g_corr2[4]; + g_corr.y2y2_flt = 0.01F + g_corr2[2]; + g_corr.xy2_flt = 0.01F + -0.5f * g_corr2[3]; + g_corr.y1y2_flt = 0.01F + 0.5f * g_corr2[4]; - g_corr.xx = 0.01F + dotp( xn, xn, L_SUBFR ); + g_corr.xx_flt = 0.01F + dotp( xn, xn, L_SUBFR ); /*----------------------------------------------------------------------* * Add Gaussian excitation * @@ -293,10 +293,10 @@ void coder_acelp( { assert( gain_pit == 0.f ); - gauss_L2( h1, code2, y2, y22, &gain_code2, g_corr2, LPDmem->tilt_code, p_Aq, acelp_cfg->formant_enh_num, &( st->seed_acelp ) ); + gauss_L2( h1, code2, y2, y22, &gain_code2, g_corr2, LPDmem->tilt_code_flt, p_Aq, acelp_cfg->formant_enh_num_flt, &( st->seed_acelp ) ); - g_corr.y1y1 = g_corr2[0]; - g_corr.y1y2 = g_corr2[4]; + g_corr.y1y1_flt = g_corr2[0]; + g_corr.y1y2_flt = g_corr2[4]; } else { @@ -318,11 +318,11 @@ void coder_acelp( * - voice factor (for codebook tilt sharpening) * *----------------------------------------------------------*/ - LPDmem->tilt_code = est_tilt( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, L_SUBFR, acelp_cfg->voice_tilt ); + LPDmem->tilt_code_flt = est_tilt( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, L_SUBFR, acelp_cfg->voice_tilt ); if ( st->Opt_RF_ON ) { - st->hRF->rf_tilt_buf[i_subfr / L_SUBFR] = LPDmem->tilt_code; + st->hRF->rf_tilt_buf_flt[i_subfr / L_SUBFR] = LPDmem->tilt_code_flt; } @@ -330,7 +330,7 @@ void coder_acelp( * Update memory of the weighting filter *-----------------------------------------------------------------*/ - LPDmem->mem_w0 = xn[L_SUBFR - 1] - gain_pit * y1[L_SUBFR - 1] - gain_code * y2[L_SUBFR - 1] - gain_code2 * y22[L_SUBFR - 1]; + LPDmem->mem_w0_flt = xn[L_SUBFR - 1] - gain_pit * y1[L_SUBFR - 1] - gain_code * y2[L_SUBFR - 1] - gain_code2 * y22[L_SUBFR - 1]; /*-------------------------------------------------------* * - Find the total excitation. * @@ -353,13 +353,13 @@ void coder_acelp( * Enhance the excitation * *---------------------------------------------------------*/ - enhancer( MODE2, -1, acelp_cfg->fixed_cdk_index[i_subfr / L_SUBFR], 0, st->coder_type, st->L_frame, voice_fac, stab_fac, norm_gain_code, gain_inov, &( LPDmem->gc_threshold ), code, exc2, gain_pit, LPDmem->dispMem ); + enhancer( MODE2, -1, acelp_cfg->fixed_cdk_index[i_subfr / L_SUBFR], 0, st->coder_type, st->L_frame, voice_fac, stab_fac, norm_gain_code, gain_inov, &( LPDmem->gc_threshold_flt ), code, exc2, gain_pit, LPDmem->dispMem_flt); /*----------------------------------------------------------* * - compute the synthesis speech * *----------------------------------------------------------*/ - syn_filt( p_Aq, M, exc2, &syn2[i_subfr], L_SUBFR, LPDmem->mem_syn2, 1 ); + syn_filt( p_Aq, M, exc2, &syn2[i_subfr], L_SUBFR, LPDmem->mem_syn2_flt, 1 ); syn_filt( p_Aq, M, &exc[i_subfr], &syn[i_subfr], L_SUBFR, &syn[i_subfr - M], 0 ); @@ -396,9 +396,9 @@ void coder_acelp( * Update LPD memory * *----------------------------------------------------------*/ - mvr2r( exc + st->L_frame - L_EXC_MEM, LPDmem->old_exc, L_EXC_MEM ); - mvr2r( syn + st->L_frame - M, LPDmem->mem_syn, M ); - mvr2r( syn + st->L_frame - L_SYN_MEM, LPDmem->mem_syn_r, L_SYN_MEM ); + mvr2r( exc + st->L_frame - L_EXC_MEM, LPDmem->old_exc_flt, L_EXC_MEM ); + mvr2r( syn + st->L_frame - M, LPDmem->mem_syn_flt, M ); + mvr2r( syn + st->L_frame - L_SYN_MEM, LPDmem->mem_syn_r_flt, L_SYN_MEM ); if ( st->hPlcExt != NULL ) { @@ -410,14 +410,14 @@ void coder_acelp( *----------------------------------------------------------*/ mvr2r( syn2, syn, st->L_frame ); - tmp = LPDmem->syn[M]; - deemph( syn, st->preemph_fac, st->L_frame, &tmp ); + tmp = LPDmem->syn_flt[M]; + deemph( syn, st->preemph_fac_flt, st->L_frame, &tmp ); if ( st->hTcxEnc != NULL ) { - mvr2r( syn + st->L_frame / 2, st->hTcxEnc->Txnq, st->L_frame / 2 ); + mvr2r( syn + st->L_frame / 2, st->hTcxEnc->Txnq_flt, st->L_frame / 2 ); } - mvr2r( syn + st->L_frame - ( M + 1 ), LPDmem->syn, M + 1 ); - mvr2r( syn, st->synth, st->L_frame ); + mvr2r( syn + st->L_frame - ( M + 1 ), LPDmem->syn_flt, M + 1 ); + mvr2r( syn, st->synth_flt, st->L_frame ); /*Update MODE1*/ mvr2r( p_Aq, st->old_Aq_12_8, M + 1 ); diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c index b2d8883c5..ffb45d9e9 100644 --- a/lib_enc/cod_tcx.c +++ b/lib_enc/cod_tcx.c @@ -227,21 +227,21 @@ void TNSAnalysisStereo( /* if prediction gain and avgSqrCoef are both close we are pretty sure the filters are quite similar, use the avg of * both filters for the decision */ - meanPredictionGain = ( pFilter[0]->predictionGain + pFilter[1]->predictionGain ) * 0.5f; + meanPredictionGain = ( pFilter[0]->predictionGain_flt + pFilter[1]->predictionGain_flt) * 0.5f; maxPredictionGain = max( maxPredictionGain, meanPredictionGain ); - if ( ( pFilter[0]->predictionGain > pTnsParameters[0]->minPredictionGain ) && ( sts[0]->element_brate < IVAS_80k ) && - ( pFilter[1]->predictionGain > pTnsParameters[1]->minPredictionGain ) && ( sts[0]->hTcxEnc->tnsData[k].nFilters == sts[1]->hTcxEnc->tnsData[k].nFilters ) ) + if ( ( pFilter[0]->predictionGain_flt > pTnsParameters[0]->minPredictionGain_flt) && ( sts[0]->element_brate < IVAS_80k ) && + ( pFilter[1]->predictionGain_flt > pTnsParameters[1]->minPredictionGain_flt) && ( sts[0]->hTcxEnc->tnsData[k].nFilters == sts[1]->hTcxEnc->tnsData[k].nFilters ) ) { - pFilter[0]->predictionGain = pFilter[1]->predictionGain = meanPredictionGain; /* more TNS filter sync at 48kbps */ + pFilter[0]->predictionGain_flt = pFilter[1]->predictionGain_flt = meanPredictionGain; /* more TNS filter sync at 48kbps */ } - if ( ( fabs( pFilter[0]->predictionGain - pFilter[1]->predictionGain ) < SIMILAR_TNS_THRESHOLD * meanPredictionGain ) && + if ( ( fabs( pFilter[0]->predictionGain_flt - pFilter[1]->predictionGain_flt) < SIMILAR_TNS_THRESHOLD * meanPredictionGain ) && ( sts[0]->hTcxEnc->tnsData[k].nFilters == sts[1]->hTcxEnc->tnsData[k].nFilters ) ) { - float maxAvgSqrCoef = max( pFilter[0]->avgSqrCoef, pFilter[1]->avgSqrCoef ); - float meanLtpGain = ( sts[0]->hTcxEnc->tcxltp_gain + sts[1]->hTcxEnc->tcxltp_gain ) * 0.5f; + float maxAvgSqrCoef = max( pFilter[0]->avgSqrCoef_flt, pFilter[1]->avgSqrCoef_flt); + float meanLtpGain = ( sts[0]->hTcxEnc->tcxltp_gain_flt + sts[1]->hTcxEnc->tcxltp_gain_flt ) * 0.5f; maxPredGain = max( maxPredGain, meanPredictionGain ); - if ( ( meanPredictionGain > pTnsParameters[0]->minPredictionGain ) || ( maxAvgSqrCoef > pTnsParameters[0]->minAvgSqrCoef ) ) + if ( ( meanPredictionGain > pTnsParameters[0]->minPredictionGain_flt) || ( maxAvgSqrCoef > pTnsParameters[0]->minAvgSqrCoef_flt) ) { if ( sts[0]->hTcxEnc->tnsData[k].nFilters > 0 || sts[1]->hTcxEnc->tnsData[k].nFilters > 0 || isTCX10 || meanLtpGain < 0.6f ) { @@ -254,7 +254,7 @@ void TNSAnalysisStereo( { const float maxEnergyChange = ( GetTCXMaxenergyChange( sts[0]->hTranDet, isTCX10, NSUBBLOCKS, 3 ) + GetTCXMaxenergyChange( sts[1]->hTranDet, isTCX10, NSUBBLOCKS, 3 ) ) * 0.5f; - if ( maxEnergyChange >= pTnsParameters[0]->minEnergyChange ) + if ( maxEnergyChange >= pTnsParameters[0]->minEnergyChange_flt) { ++sts[0]->hTcxEnc->tnsData[k].nFilters; pFilter[0]->filterType = TNS_FILTER_ON; @@ -394,11 +394,11 @@ void TNSAnalysisStereo( const struct TnsParameters *pTnsParameters; pFilter = sts[ch]->hTcxEnc->tnsData[k].filter + iFilter; pTnsParameters = sts[ch]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; - maxPredGain = max( maxPredGain, pFilter->predictionGain ); + maxPredGain = max( maxPredGain, pFilter->predictionGain_flt); - if ( ( pFilter->predictionGain > pTnsParameters->minPredictionGain ) || ( pFilter->avgSqrCoef > pTnsParameters->minAvgSqrCoef ) ) + if ( ( pFilter->predictionGain_flt > pTnsParameters->minPredictionGain_flt) || ( pFilter->avgSqrCoef_flt > pTnsParameters->minAvgSqrCoef_flt) ) { - if ( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 || isTCX10 || sts[ch]->hTcxEnc->tcxltp_gain < 0.6f ) + if ( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 || isTCX10 || sts[ch]->hTcxEnc->tcxltp_gain_flt < 0.6f ) { ++sts[ch]->hTcxEnc->tnsData[k].nFilters; pFilter->filterType = TNS_FILTER_ON; @@ -407,7 +407,7 @@ void TNSAnalysisStereo( { const float maxEnergyChange = GetTCXMaxenergyChange( sts[ch]->hTranDet, isTCX10, NSUBBLOCKS, 3 ); - if ( maxEnergyChange >= pTnsParameters->minEnergyChange ) + if ( maxEnergyChange >= pTnsParameters->minEnergyChange_flt) { ++sts[ch]->hTcxEnc->tnsData[k].nFilters; pFilter->filterType = TNS_FILTER_ON; @@ -681,7 +681,7 @@ void ShapeSpectrum( L_frame = L_frame_glob; tcx_offset = hTcxCfg->tcx_offset; - gamma1 = st->gamma; + gamma1 = st->gamma_flt; if ( st->enableTcxLpc ) { gamma1 = 1.0f; @@ -700,12 +700,12 @@ void ShapeSpectrum( } } - tcxGetNoiseFillingTilt( A, L_frame, ( total_brate >= ACELP_13k20 && !st->rf_mode ), &st->hTcxEnc->noiseTiltFactor ); + tcxGetNoiseFillingTilt( A, L_frame, ( total_brate >= ACELP_13k20 && !st->rf_mode ), &st->hTcxEnc->noiseTiltFactor_flt); /* Calculate Spectrum Flatness Measure for the TCX Concealment */ if ( st->enablePlcWaveadjust ) { - hTcxCfg->SFM2 = SFM_Cal( spectrum, min( 200, L_frame ) ); + hTcxCfg->SFM2_flt = SFM_Cal( spectrum, min( 200, L_frame ) ); } if ( ( total_brate <= ACELP_13k20 && st->bwidth == SWB ) ) @@ -817,7 +817,7 @@ void ShapeSpectrum( } } - if ( st->element_mode != IVAS_CPE_MDCT && st->tcxonly && st->hTcxEnc->tcxltp && ( st->hTcxEnc->tcxltp_gain > 0.0f ) && !fUseTns ) + if ( st->element_mode != IVAS_CPE_MDCT && st->tcxonly && st->hTcxEnc->tcxltp && ( st->hTcxEnc->tcxltp_gain_flt > 0.0f ) && !fUseTns ) { PsychAdaptLowFreqEmph( spectrum, gainlpc ); } @@ -835,14 +835,14 @@ void ShapeSpectrum( static int16_t GetTransWidth( const int16_t tcxonly, const int16_t tcx10, - const float tcxltp_gain, + const float tcxltp_gain_flt, const int16_t hm_active ) { int16_t noiseTransWidth = MIN_NOISE_FILLING_HOLE; if ( tcxonly ) { - noiseTransWidth = HOLE_SIZE_FROM_LTP( max( tcxltp_gain, 0.3125f * hm_active ) ); + noiseTransWidth = HOLE_SIZE_FROM_LTP_FLT( max( tcxltp_gain_flt, 0.3125f * hm_active ) ); if ( tcx10 ) { @@ -875,7 +875,7 @@ static void EstimateTCXNoiseLevel( int16_t maxNfCalcBw, iStart, noiseTransWidth; TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - maxNfCalcBw = min( noiseFillingBorder, (int16_t) ( hTcxEnc->measuredBwRatio * (float) L_frame + 0.5f ) ); + maxNfCalcBw = min( noiseFillingBorder, (int16_t) ( hTcxEnc->measuredBwRatio_flt * (float) L_frame + 0.5f ) ); if ( st->total_brate >= HQ_96k ) { @@ -886,8 +886,8 @@ static void EstimateTCXNoiseLevel( { const int16_t minLevel = ( hTcxEnc->tcx_lpc_shaped_ari && st->element_mode > IVAS_SCE ? 0 : 1 ); iStart = L_frame / ( ( st->total_brate >= ACELP_13k20 && !st->rf_mode ) ? 6 : 8 ); /* noise filling start bin*/ - noiseTransWidth = GetTransWidth( st->tcxonly, ( L_frame == st->L_frame >> 1 ), st->hTcxEnc->tcxltp_gain, ( st->hTcxCfg->ctx_hm && st->last_core != ACELP_CORE && hm_active ) ); - tcx_noise_factor( x_orig, spectrum, iStart, maxNfCalcBw, noiseTransWidth, L_frame, gain_tcx, hTcxEnc->noiseTiltFactor, fac_ns, fac_ns_q, st->element_mode ); + noiseTransWidth = GetTransWidth( st->tcxonly, ( L_frame == st->L_frame >> 1 ), st->hTcxEnc->tcxltp_gain_flt, ( st->hTcxCfg->ctx_hm && st->last_core != ACELP_CORE && hm_active ) ); + tcx_noise_factor( x_orig, spectrum, iStart, maxNfCalcBw, noiseTransWidth, L_frame, gain_tcx, hTcxEnc->noiseTiltFactor_flt, fac_ns, fac_ns_q, st->element_mode ); /* hysteresis for very tonal passages (more stationary noise filling level) */ if ( *fac_ns_q == minLevel ) @@ -957,7 +957,7 @@ void EstimateStereoTCXNoiseLevel( for ( n = 0; n < nSubframes; n++ ) { fac_ns_q = param_core[ch] + n * NPRM_DIV + 1; - maxNfCalcBw = min( noiseFillingBorder[ch][n], (int16_t) ( hTcxEnc->measuredBwRatio * (float) L_frame[ch][n] + 0.5f ) ); + maxNfCalcBw = min( noiseFillingBorder[ch][n], (int16_t) ( hTcxEnc->measuredBwRatio_flt * (float) L_frame[ch][n] + 0.5f ) ); if ( ( total_brate >= HQ_96k && ( st->element_mode <= IVAS_SCE || st->bwidth < SWB ) ) || total_brate > IVAS_192k ) { fac_ns[ch][n] = 0.0f; @@ -970,7 +970,7 @@ void EstimateStereoTCXNoiseLevel( if ( n == 0 ) { mvr2r( hTcxEnc->ltpGainMemory, &hTcxEnc->ltpGainMemory[1], N_LTP_GAIN_MEMS - 1 ); - hTcxEnc->ltpGainMemory[0] = st->hTcxEnc->tcxltp_gain; + hTcxEnc->ltpGainMemory[0] = st->hTcxEnc->tcxltp_gain_flt; } smooth_gain = dotp( hTcxEnc->ltpGainMemory, nf_tw_smoothing_coeffs, N_LTP_GAIN_MEMS ); @@ -978,7 +978,7 @@ void EstimateStereoTCXNoiseLevel( noiseTransWidth = GetTransWidth( st->tcxonly, ( L_frame[ch][n] == st->L_frame >> 1 ), smooth_gain, ( st->hTcxCfg->ctx_hm && st->last_core != ACELP_CORE && hm_active[ch][n] ) ); mvr2r( q_spectrum[ch][n], combined_q_spectrum, L_frame[ch][n] ); - tcx_noise_factor( hTcxEnc->spectrum[n], combined_q_spectrum, iStart, maxNfCalcBw, noiseTransWidth, L_frame[ch][n], gain_tcx[ch][n], hTcxEnc->noiseTiltFactor, &fac_ns[ch][n], fac_ns_q, st->element_mode ); + tcx_noise_factor( hTcxEnc->spectrum[n], combined_q_spectrum, iStart, maxNfCalcBw, noiseTransWidth, L_frame[ch][n], gain_tcx[ch][n], hTcxEnc->noiseTiltFactor_flt, &fac_ns[ch][n], fac_ns_q, st->element_mode ); /* hysteresis for very tonal passages (more stationary noise filling level) */ if ( *fac_ns_q == 1 ) @@ -1017,7 +1017,7 @@ void EstimateStereoTCXNoiseLevel( static int16_t DecideTonalSideInfo( const float spectrum[], const int16_t L_frame_glob, - float SFM2 ) + float SFM2_flt ) { float SFM, K, K2; int16_t Tonal_SideInfo; @@ -1047,7 +1047,7 @@ static int16_t DecideTonalSideInfo( Tonal_SideInfo = 1; } - if ( SFM2 < K2 ) + if ( SFM2_flt < K2 ) { Tonal_SideInfo = 1; } @@ -1163,7 +1163,7 @@ void QuantizeTCXSpectrum( if ( st->enablePlcWaveadjust ) { - st->Tonal_SideInfo = DecideTonalSideInfo( x_orig, ( st->core == TCX_20_CORE ) ? st->L_frame : st->L_frame / 2, st->hTcxCfg->SFM2 ); + st->Tonal_SideInfo = DecideTonalSideInfo( x_orig, ( st->core == TCX_20_CORE ) ? st->L_frame : st->L_frame / 2, st->hTcxCfg->SFM2_flt ); } /* Start with the pre-shaped spectrum*/ @@ -1215,7 +1215,7 @@ void QuantizeTCXSpectrum( ++ctxHmBits; /* ContextHM flag */ --sqTargetBits; /* ContextHM flag */ - PeriodicityIndex = SearchPeriodicityIndex( spectrum, NULL, L_spec, sqTargetBits, LtpPitchLag, hTcxEnc->tcxltp ? hTcxEnc->tcxltp_gain : -1.0f, &RelativeScore ); + PeriodicityIndex = SearchPeriodicityIndex( spectrum, NULL, L_spec, sqTargetBits, LtpPitchLag, hTcxEnc->tcxltp ? hTcxEnc->tcxltp_gain_flt : -1.0f, &RelativeScore ); NumIndexBits = CountIndexBits( L_spec >= 256, PeriodicityIndex ); @@ -1229,9 +1229,9 @@ void QuantizeTCXSpectrum( } /* Quantize original spectrum */ - sqGain = SQ_gain( spectrum, (int16_t) ( hTcxEnc->tcx_target_bits_fac * (float) sqTargetBits ), L_spec ); + sqGain = SQ_gain( spectrum, (int16_t) ( hTcxEnc->tcx_target_bits_fac_flt * (float) sqTargetBits ), L_spec ); - tcx_scalar_quantization( spectrum, sqQ, L_spec, sqGain, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly ); + tcx_scalar_quantization( spectrum, sqQ, L_spec, sqGain, st->hTcxCfg->sq_rounding_flt, hTcxEnc->memQuantZeros, st->tcxonly ); /* Estimate original bitrate */ stop = 0; @@ -1260,7 +1260,7 @@ void QuantizeTCXSpectrum( /* Decide whether or not to use context mapping */ Selector = max( stop, sqBits ) - ( max( stopCtxHm, sqBitsCtxHm ) + NumIndexBits ); - if ( Selector > 2 || ( abs( Selector ) <= 2 && kCtxHmOlRSThr < RelativeScore ) ) + if ( Selector > 2 || ( abs( Selector ) <= 2 && kCtxHmOlRSThr_FLT < RelativeScore ) ) { /* CtxHm is likely better */ sqTargetBits -= NumIndexBits; @@ -1295,15 +1295,15 @@ void QuantizeTCXSpectrum( if ( st->element_mode == IVAS_CPE_MDCT ) { - sqGain = SQ_gain_estimate( spectrum, (int16_t) ( hTcxEnc->tcx_target_bits_fac * (float) sqTargetBits ), L_spec ); + sqGain = SQ_gain_estimate( spectrum, (int16_t) ( hTcxEnc->tcx_target_bits_fac_flt * (float) sqTargetBits ), L_spec ); } else { - sqGain = SQ_gain( spectrum, (int16_t) ( hTcxEnc->tcx_target_bits_fac * (float) sqTargetBits ), L_spec ); + sqGain = SQ_gain( spectrum, (int16_t) ( hTcxEnc->tcx_target_bits_fac_flt * (float) sqTargetBits ), L_spec ); } /* Quantize spectrum */ - tcx_scalar_quantization( spectrum, sqQ, L_spec, sqGain, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly ); + tcx_scalar_quantization( spectrum, sqQ, L_spec, sqGain, st->hTcxCfg->sq_rounding_flt, hTcxEnc->memQuantZeros, st->tcxonly ); /* Estimate bitrate */ stop = 0; @@ -1326,24 +1326,24 @@ void QuantizeTCXSpectrum( if ( ( L_spec & ( L_spec - 1 ) ) == 0 ) { /* power-of-2 */ - hTcxEnc->tcx_target_bits_fac *= (float) sqTargetBits / (float) ( sqBits + 1 ); + hTcxEnc->tcx_target_bits_fac_flt *= (float) sqTargetBits / (float) ( sqBits + 1 ); } else { - hTcxEnc->tcx_target_bits_fac *= (float) sqTargetBits / (float) sqBits; + hTcxEnc->tcx_target_bits_fac_flt *= (float) sqTargetBits / (float) sqBits; } - if ( hTcxEnc->tcx_target_bits_fac > 1.25 ) + if ( hTcxEnc->tcx_target_bits_fac_flt > 1.25 ) { - hTcxEnc->tcx_target_bits_fac = 1.25; + hTcxEnc->tcx_target_bits_fac_flt = 1.25; } - if ( hTcxEnc->tcx_target_bits_fac < 0.75 ) + if ( hTcxEnc->tcx_target_bits_fac_flt < 0.75 ) { - hTcxEnc->tcx_target_bits_fac = 0.75; + hTcxEnc->tcx_target_bits_fac_flt = 0.75; } /* Refine quantizer step size with a rate-control-loop (optional) */ - sqBits = tcx_scalar_quantization_rateloop( spectrum, sqQ, L_spec, &sqGain, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, prm_lastnz, /* lastnz */ sqTargetBits, &nEncoded, &stop, sqBits_noStop, sqBits, st->hTcxCfg->tcxRateLoopOpt, st->tcxonly, PeriodicityIndex >= 0 ? hm_cfg : NULL, ( st->element_mode == IVAS_CPE_MDCT ? 2 : 4 ), st->element_mode ); + sqBits = tcx_scalar_quantization_rateloop( spectrum, sqQ, L_spec, &sqGain, st->hTcxCfg->sq_rounding_flt, hTcxEnc->memQuantZeros, prm_lastnz, /* lastnz */ sqTargetBits, &nEncoded, &stop, sqBits_noStop, sqBits, st->hTcxCfg->tcxRateLoopOpt, st->tcxonly, PeriodicityIndex >= 0 ? hm_cfg : NULL, ( st->element_mode == IVAS_CPE_MDCT ? 2 : 4 ), st->element_mode ); if ( ctxHmBits > 0 ) { @@ -1455,7 +1455,7 @@ void QuantizeTCXSpectrum( { sqGain = (float) sqrt( (float) NORM_MDCT_FACTOR / (float) L_spec ); - tcx_scalar_quantization( spectrum, sqQ, L_spec, sqGain, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly ); + tcx_scalar_quantization( spectrum, sqQ, L_spec, sqGain, st->hTcxCfg->sq_rounding_flt, hTcxEnc->memQuantZeros, st->tcxonly ); stop = 1; if ( st->element_mode > EVS_MONO ) @@ -1539,7 +1539,7 @@ void QuantizeTCXSpectrum( } assert( x_orig != spectrum ); - gain_tcx_opt = get_gain( x_orig, spectrum, L_spec, ener ); + gain_tcx_opt = get_gain_flt( x_orig, spectrum, L_spec, ener ); if ( gain_tcx_opt <= 0.0f ) { @@ -1578,7 +1578,7 @@ void QuantizeTCXSpectrum( prm_resq = sqQ + sqTargetBits - resQTargetBits; - resQBits = tcx_ari_res_Q_spec( x_orig, hm_cfg->indexBuffer, spectrum, L_spec, *gain_tcx, prm_resq, resQTargetBits, resQBits, st->hTcxCfg->sq_rounding, lf_deemph_fact ); + resQBits = tcx_ari_res_Q_spec( x_orig, hm_cfg->indexBuffer, spectrum, L_spec, *gain_tcx, prm_resq, resQTargetBits, resQBits, st->hTcxCfg->sq_rounding_flt, lf_deemph_fact ); /* Transmit zeros when there bits remain after RESQ */ for ( i = resQBits; i < resQTargetBits; ++i ) @@ -1591,7 +1591,7 @@ void QuantizeTCXSpectrum( /* context based arithmetic coder */ resQBits = tcx_res_Q_gain( gain_tcx_opt, gain_tcx, sqQ + L_spec, resQTargetBits ); - resQBits = tcx_res_Q_spec( x_orig, spectrum, L_spec, *gain_tcx, sqQ + L_spec, resQTargetBits, resQBits, st->hTcxCfg->sq_rounding, st->tcxonly ? NULL : lf_deemph_fact ); + resQBits = tcx_res_Q_spec( x_orig, spectrum, L_spec, *gain_tcx, sqQ + L_spec, resQTargetBits, resQBits, st->hTcxCfg->sq_rounding_flt, st->tcxonly ? NULL : lf_deemph_fact ); } } @@ -1603,7 +1603,7 @@ void QuantizeTCXSpectrum( { if ( st->tcxonly ) { - if ( hTcxEnc->tcxltp && ( hTcxEnc->tcxltp_gain > 0.0f ) && !hTcxEnc->fUseTns[frame_cnt] ) + if ( hTcxEnc->tcxltp && ( hTcxEnc->tcxltp_gain_flt > 0.0f ) && !hTcxEnc->fUseTns[frame_cnt] ) { PsychAdaptLowFreqDeemph( spectrum, gainlpc, NULL ); } @@ -1666,11 +1666,11 @@ void InternalTCXDecoder( if ( fac_ns > 0.0f ) { - iStart = tcxGetNoiseFillingTilt( A, L_frame, ( st->total_brate >= ACELP_13k20 && !st->rf_mode ), &hTcxEnc->noiseTiltFactor ); + iStart = tcxGetNoiseFillingTilt( A, L_frame, ( st->total_brate >= ACELP_13k20 && !st->rf_mode ), &hTcxEnc->noiseTiltFactor_flt); - noiseTransWidth = GetTransWidth( st->tcxonly, ( L_frame == st->L_frame >> 1 ), hTcxEnc->tcxltp_gain, ( st->hTcxCfg->ctx_hm && st->last_core != ACELP_CORE && hm_active ) ); + noiseTransWidth = GetTransWidth( st->tcxonly, ( L_frame == st->L_frame >> 1 ), hTcxEnc->tcxltp_gain_flt, ( st->hTcxCfg->ctx_hm && st->last_core != ACELP_CORE && hm_active ) ); assert( st->element_mode != IVAS_CPE_MDCT ); - tcx_noise_filling( spectrum, nf_seed, iStart, noiseFillingBorder, noiseTransWidth, L_frame, hTcxEnc->noiseTiltFactor, fac_ns, NULL, st->element_mode ); + tcx_noise_filling( spectrum, nf_seed, iStart, noiseFillingBorder, noiseTransWidth, L_frame, hTcxEnc->noiseTiltFactor_flt, fac_ns, NULL, st->element_mode ); } if ( st->total_brate < ACELP_13k20 || st->rf_mode ) @@ -1708,7 +1708,7 @@ void InternalTCXDecoder( if ( st->hTcxCfg->coder_type == INACTIVE ) { - gain_tcx *= st->hTcxCfg->na_scale; + gain_tcx *= st->hTcxCfg->na_scale_flt; } v_multc( spectrum, gain_tcx, spectrum, L_spec ); @@ -1797,11 +1797,11 @@ void InternalTCXDecoder( TCX_MDCT_Inverse( spectrum + w * L_spec_TCX5, win, L_ola, L_win - L_ola, L_ola, st->element_mode ); } - tcx_windowing_synthesis_current_frame( win, st->hTcxCfg->tcx_aldo_window_2, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, L_ola, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, w == 0 && st->last_core == ACELP_CORE, ( w > 0 ) || ( w == 0 && tcx_last_overlap_mode == 2 ) ? MIN_OVERLAP : st->hTcxCfg->tcx_last_overlap_mode, st->hTcxEnc->acelp_zir, st->hTcxEnc->Txnq, NULL, Aq_old, st->hTcxCfg->tcx_mdct_window_trans, L_win, tcx_offset < 0 ? -tcx_offset : 0, ( w > 0 ) ? 1 : st->last_core, 0, 0 ); + tcx_windowing_synthesis_current_frame( win, st->hTcxCfg->tcx_aldo_window_2_flt, st->hTcxCfg->tcx_mdct_window_half_flt, st->hTcxCfg->tcx_mdct_window_minimum_flt, L_ola, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, w == 0 && st->last_core == ACELP_CORE, ( w > 0 ) || ( w == 0 && tcx_last_overlap_mode == 2 ) ? MIN_OVERLAP : st->hTcxCfg->tcx_last_overlap_mode, st->hTcxEnc->acelp_zir_flt, st->hTcxEnc->Txnq_flt, NULL, Aq_old, st->hTcxCfg->tcx_mdct_window_trans_flt, L_win, tcx_offset < 0 ? -tcx_offset : 0, ( w > 0 ) ? 1 : st->last_core, 0, 0 ); if ( w > 0 ) { - tcx_windowing_synthesis_past_frame( xn_buf + tcx_offset - ( L_ola >> 1 ) + w * L_win, st->hTcxCfg->tcx_aldo_window_1_trunc, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, L_ola, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, 2 ); + tcx_windowing_synthesis_past_frame( xn_buf + tcx_offset - ( L_ola >> 1 ) + w * L_win, st->hTcxCfg->tcx_aldo_window_1_trunc_flt, st->hTcxCfg->tcx_mdct_window_half_flt, st->hTcxCfg->tcx_mdct_window_minimum_flt, L_ola, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, 2 ); } /* add part of current sub-window overlapping with previous window */ @@ -1811,7 +1811,7 @@ void InternalTCXDecoder( mvr2r( win + L_ola, xn_buf + tcx_offset + ( L_ola >> 1 ) + w * L_win, L_win ); } - /* To assure that no garbage values are copied to Txnq */ + /* To assure that no garbage values are copied to Txnq_flt */ set_zero( xn_buf + L_frame + tcx_offset + ( L_ola >> 1 ), overlap - tcx_offset - ( L_ola >> 1 ) ); } else if ( ( frame_cnt == 0 ) && ( st->hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) ) @@ -1837,10 +1837,10 @@ void InternalTCXDecoder( /* 2nd TCX-5 window, regular MDCT with minimum overlap on both sides */ TCX_MDCT_Inverse( spectrum + L_spec_TCX5, win, L_ola, L_win - L_ola, L_ola, st->element_mode ); - tcx_windowing_synthesis_current_frame( win, st->hTcxCfg->tcx_aldo_window_2, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, L_ola, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, 0, /* left_rect */ - 2, /* left_mode */ st->hTcxEnc->acelp_zir, st->hTcxEnc->Txnq, NULL, Aq_old, st->hTcxCfg->tcx_mdct_window_trans, L_win, tcx_offset < 0 ? -tcx_offset : 0, 1, /* not st->last_core */ 0, 0 ); + tcx_windowing_synthesis_current_frame( win, st->hTcxCfg->tcx_aldo_window_2_flt, st->hTcxCfg->tcx_mdct_window_half_flt, st->hTcxCfg->tcx_mdct_window_minimum_flt, L_ola, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, 0, /* left_rect */ + 2, /* left_mode */ st->hTcxEnc->acelp_zir_flt, st->hTcxEnc->Txnq_flt, NULL, Aq_old, st->hTcxCfg->tcx_mdct_window_trans_flt, L_win, tcx_offset < 0 ? -tcx_offset : 0, 1, /* not st->last_core */ 0, 0 ); - tcx_windowing_synthesis_past_frame( xn_buf + ( overlap >> 1 ) + L_win - ( L_ola >> 1 ), st->hTcxCfg->tcx_aldo_window_1_trunc, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, L_ola, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, 2 ); + tcx_windowing_synthesis_past_frame( xn_buf + ( overlap >> 1 ) + L_win - ( L_ola >> 1 ), st->hTcxCfg->tcx_aldo_window_1_trunc_flt, st->hTcxCfg->tcx_mdct_window_half_flt, st->hTcxCfg->tcx_mdct_window_minimum_flt, L_ola, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, 2 ); /* add part of current sub-window overlapping with previous window */ v_add( win, xn_buf + ( overlap >> 1 ) + L_win - ( L_ola >> 1 ), xn_buf + ( overlap >> 1 ) + L_win - ( L_ola >> 1 ), L_ola ); @@ -1854,14 +1854,14 @@ void InternalTCXDecoder( xn_buf[overlap - 1 - w] = -1.0f * xn_buf[w]; } - tcx_windowing_synthesis_current_frame( xn_buf, st->hTcxCfg->tcx_aldo_window_2, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, overlap, /*st->hTcxCfg->tcx_mdct_window_length*/ st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->last_core == ACELP_CORE, 0, /* left_mode */ st->hTcxEnc->acelp_zir, st->hTcxEnc->Txnq, NULL, Aq_old, st->hTcxCfg->tcx_mdct_window_trans, L_win, tcx_offset < 0 ? -tcx_offset : 0, st->last_core, 0, 0 ); + tcx_windowing_synthesis_current_frame( xn_buf, st->hTcxCfg->tcx_aldo_window_2_flt, st->hTcxCfg->tcx_mdct_window_half_flt, st->hTcxCfg->tcx_mdct_window_minimum_flt, overlap, /*st->hTcxCfg->tcx_mdct_window_length*/ st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->last_core == ACELP_CORE, 0, /* left_mode */ st->hTcxEnc->acelp_zir_flt, st->hTcxEnc->Txnq_flt, NULL, Aq_old, st->hTcxCfg->tcx_mdct_window_trans_flt, L_win, tcx_offset < 0 ? -tcx_offset : 0, st->last_core, 0, 0 ); } else { /* default, i.e. maximum overlap, single transform, no grouping */ TCX_MDCT_Inverse( spectrum, xn_buf, overlap, L_frame - overlap, overlap, st->element_mode ); - tcx_windowing_synthesis_current_frame( xn_buf, st->hTcxCfg->tcx_aldo_window_2, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, overlap, /*st->hTcxCfg->tcx_mdct_window_length*/ st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->last_core == ACELP_CORE, ( frame_cnt > 0 ) && ( tcx_last_overlap_mode == 0 ) && ( st->last_core != ACELP_CORE ) ? 2 : tcx_last_overlap_mode, st->hTcxEnc->acelp_zir, st->hTcxEnc->Txnq, NULL, Aq_old, st->hTcxCfg->tcx_mdct_window_trans, st->L_frame >> 2, tcx_offset < 0 ? -tcx_offset : 0, st->last_core, 0, 0 ); + tcx_windowing_synthesis_current_frame( xn_buf, st->hTcxCfg->tcx_aldo_window_2_flt, st->hTcxCfg->tcx_mdct_window_half_flt, st->hTcxCfg->tcx_mdct_window_minimum_flt, overlap, /*st->hTcxCfg->tcx_mdct_window_length*/ st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->last_core == ACELP_CORE, ( frame_cnt > 0 ) && ( tcx_last_overlap_mode == 0 ) && ( st->last_core != ACELP_CORE ) ? 2 : tcx_last_overlap_mode, st->hTcxEnc->acelp_zir_flt, st->hTcxEnc->Txnq_flt, NULL, Aq_old, st->hTcxCfg->tcx_mdct_window_trans_flt, st->L_frame >> 2, tcx_offset < 0 ? -tcx_offset : 0, st->last_core, 0, 0 ); } /* tcx_last_overlap_mode != FULL_OVERLAP */ } @@ -1885,7 +1885,7 @@ void InternalTCXDecoder( /* Windowing, overlap and add */ /* Window current frame */ - tcx_windowing_synthesis_current_frame( xn_buf, st->hTcxCfg->tcx_aldo_window_2, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, overlap, /*st->hTcxCfg->tcx_mdct_window_length*/ st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->last_core == ACELP_CORE, st->hTcxCfg->tcx_last_overlap_mode, /*left mode*/ st->hTcxEnc->acelp_zir, st->hTcxEnc->Txnq, NULL, Aq_old, st->hTcxCfg->tcx_mdct_window_trans, st->L_frame >> 1, tcx_offset < 0 ? -tcx_offset : 0, st->last_core, 0, 0 ); + tcx_windowing_synthesis_current_frame( xn_buf, st->hTcxCfg->tcx_aldo_window_2_flt, st->hTcxCfg->tcx_mdct_window_half_flt, st->hTcxCfg->tcx_mdct_window_minimum_flt, overlap, /*st->hTcxCfg->tcx_mdct_window_length*/ st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->last_core == ACELP_CORE, st->hTcxCfg->tcx_last_overlap_mode, /*left mode*/ st->hTcxEnc->acelp_zir_flt, st->hTcxEnc->Txnq_flt, NULL, Aq_old, st->hTcxCfg->tcx_mdct_window_trans_flt, st->L_frame >> 1, tcx_offset < 0 ? -tcx_offset : 0, st->last_core, 0, 0 ); } } /* TCX-20/TCX-10 and TCX-only */ @@ -1901,7 +1901,7 @@ void InternalTCXDecoder( /* fade truncated ALDO window */ for ( ; i < overlap; i++ ) { - xn_buf[i] += st->hTcxEnc->old_out[i + nz] * st->hTcxCfg->tcx_mdct_window_minimum[overlap - 1 - i]; + xn_buf[i] += st->hTcxEnc->old_out[i + nz] * st->hTcxCfg->tcx_mdct_window_minimum_flt[overlap - 1 - i]; } } else @@ -1911,11 +1911,11 @@ void InternalTCXDecoder( tcx_last_overlap_mode = 2; /* use minimum overlap between the two TCX-10 windows */ } - tcx_windowing_synthesis_past_frame( st->hTcxEnc->Txnq, st->hTcxCfg->tcx_aldo_window_1_trunc, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, overlap, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, ( tcx_last_overlap_mode == 0 || st->hTcxCfg->tcx_last_overlap_mode == MIN_OVERLAP ) ? st->hTcxCfg->tcx_last_overlap_mode : tcx_last_overlap_mode ); + tcx_windowing_synthesis_past_frame( st->hTcxEnc->Txnq_flt, st->hTcxCfg->tcx_aldo_window_1_trunc_flt, st->hTcxCfg->tcx_mdct_window_half_flt, st->hTcxCfg->tcx_mdct_window_minimum_flt, overlap, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, ( tcx_last_overlap_mode == 0 || st->hTcxCfg->tcx_last_overlap_mode == MIN_OVERLAP ) ? st->hTcxCfg->tcx_last_overlap_mode : tcx_last_overlap_mode ); for ( i = 0; i < overlap; i++ ) { - xn_buf[i] += st->hTcxEnc->Txnq[i]; + xn_buf[i] += st->hTcxEnc->Txnq_flt[i]; } } } @@ -1926,23 +1926,23 @@ void InternalTCXDecoder( mvr2r( xn_buf + L_frame - nz, st->hTcxEnc->old_out, nz + overlap ); set_zero( st->hTcxEnc->old_out + nz + overlap, nz ); - tcx_windowing_synthesis_past_frame( st->hTcxEnc->old_out + nz, st->hTcxCfg->tcx_aldo_window_1_trunc, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, overlap, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->hTcxCfg->tcx_curr_overlap_mode ); + tcx_windowing_synthesis_past_frame( st->hTcxEnc->old_out + nz, st->hTcxCfg->tcx_aldo_window_1_trunc_flt, st->hTcxCfg->tcx_mdct_window_half_flt, st->hTcxCfg->tcx_mdct_window_minimum_flt, overlap, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->hTcxCfg->tcx_curr_overlap_mode ); if ( st->hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) { for ( i = 0; i < nz; i++ ) { - st->hTcxEnc->old_out[nz + overlap + i] = xn_buf[L_frame - 1 - i] * st->hTcxCfg->tcx_aldo_window_1_trunc[-1 - i]; + st->hTcxEnc->old_out[nz + overlap + i] = xn_buf[L_frame - 1 - i] * st->hTcxCfg->tcx_aldo_window_1_trunc_flt[-1 - i]; } } } st->hTcxCfg->last_aldo = aldo; - /* Update Txnq */ + /* Update Txnq_flt */ if ( !st->hTcxCfg->last_aldo ) { - mvr2r( xn_buf + L_frame, st->hTcxEnc->Txnq, overlap ); + mvr2r( xn_buf + L_frame, st->hTcxEnc->Txnq_flt, overlap ); } /* Output */ @@ -2062,16 +2062,16 @@ void coder_tcx( if ( st->hTcxCfg->tcx_last_overlap_mode == TRANSITION_OVERLAP ) { - WindowSignal( hTcxCfg, hTcxCfg->tcx_offsetFB, hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode, &left_overlap, &right_overlap, st->hTcxEnc->speech_TCX, &L_frame, win, 1, 1 ); + WindowSignal( hTcxCfg, hTcxCfg->tcx_offsetFB, hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode, &left_overlap, &right_overlap, st->hTcxEnc->speech_TCX_flt, &L_frame, win, 1, 1 ); /* Compute MDCT for xn_buf[] */ TCX_MDCT( win, spectrum, left_overlap, L_frame - ( left_overlap + right_overlap ) / 2, right_overlap, st->element_mode ); } else { - wtda( st->hTcxEnc->new_speech_TCX, win, NULL, hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode, L_frame ); + wtda( st->hTcxEnc->new_speech_TCX_flt, win, NULL, hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode, L_frame ); - WindowSignal( hTcxCfg, hTcxCfg->tcx_offsetFB, hTcxCfg->tcx_last_overlap_mode == ALDO_WINDOW ? FULL_OVERLAP : hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode == ALDO_WINDOW ? FULL_OVERLAP : hTcxCfg->tcx_curr_overlap_mode, &left_overlap, &right_overlap, st->hTcxEnc->speech_TCX, &L_frame, winMDST, 1, 1 ); + WindowSignal( hTcxCfg, hTcxCfg->tcx_offsetFB, hTcxCfg->tcx_last_overlap_mode == ALDO_WINDOW ? FULL_OVERLAP : hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode == ALDO_WINDOW ? FULL_OVERLAP : hTcxCfg->tcx_curr_overlap_mode, &left_overlap, &right_overlap, st->hTcxEnc->speech_TCX_flt, &L_frame, winMDST, 1, 1 ); edct( win, spectrum, L_frame, st->element_mode ); @@ -2100,7 +2100,7 @@ void coder_tcx( { SetTnsConfig( hTcxCfg, L_frame_glob == st->L_frame, st->last_core == ACELP_CORE ); - TNSAnalysis( hTcxCfg, L_frame, L_spec, TCX_20, st->last_core == ACELP_CORE, spectrum, NULL, -1, hTcxEnc->tnsData, hTcxEnc->fUseTns, &st->hIGFEnc->tns_predictionGain ); + TNSAnalysis( hTcxCfg, L_frame, L_spec, TCX_20, st->last_core == ACELP_CORE, spectrum, NULL, -1, hTcxEnc->tnsData, hTcxEnc->fUseTns, &st->hIGFEnc->tns_predictionGain_flt); } else { @@ -2144,13 +2144,13 @@ void coder_tcx_post( float xn_buf[L_FRAME_MAX]; /* TCX output */ - mvr2r( st->synth, xn_buf, st->L_frame ); + mvr2r( st->synth_flt, xn_buf, st->L_frame ); /*-----------------------------------------------------------* * Memory update * *-----------------------------------------------------------*/ - /* Update LPDmem (Txnq,syn,syn_pe,old_exc,wsyn,Ai,Aq) */ + /* Update LPDmem (Txnq_flt,syn,syn_pe,old_exc,wsyn,Ai,Aq) */ tcx_encoder_memory_update( st, xn_buf, Ai, A ); return; diff --git a/lib_enc/cod_uv.c b/lib_enc/cod_uv.c index 2c22ed418..da70d51a1 100644 --- a/lib_enc/cod_uv.c +++ b/lib_enc/cod_uv.c @@ -76,7 +76,7 @@ void gauss_L2( } /*Shape the gaussian excitation*/ - cb_shape( 1, 0, 0, 1, 0, formant_enh_num, FORMANT_SHARPENING_G2, Aq, code, tilt_code, 0, L_SUBFR ); + cb_shape( 1, 0, 0, 1, 0, formant_enh_num, FORMANT_SHARPENING_G2_FLT, Aq, code, tilt_code, 0, L_SUBFR ); /*compute 0s memory weighted synthesis contribution and find gain*/ conv( code, h, y11, L_SUBFR ); diff --git a/lib_enc/core_enc_2div.c b/lib_enc/core_enc_2div.c index 25d62130c..1fdf330d4 100644 --- a/lib_enc/core_enc_2div.c +++ b/lib_enc/core_enc_2div.c @@ -169,7 +169,7 @@ void core_encode_twodiv( bitsAvailable -= st->hIGFEnc->infoTotalBitsWritten; } - hTcxEnc->measuredBwRatio = 1.f; + hTcxEnc->measuredBwRatio_flt = 1.f; for ( n = 0; n < 2; n++ ) { @@ -186,7 +186,7 @@ void core_encode_twodiv( } /* Run TCX10 encoder */ - QuantizeSpectrum( st, A_q, NULL, gainlpc[n], st->synth + n * st->L_frame / 2, target_bits, tnsSize[n], param_core + n * NPRM_DIV, n, &hm_cfg[n], vad_hover_flag ); + QuantizeSpectrum( st, A_q, NULL, gainlpc[n], st->synth_flt + n * st->L_frame / 2, target_bits, tnsSize[n], param_core + n * NPRM_DIV, n, &hm_cfg[n], vad_hover_flag ); /* Update tcx overlap mode */ if ( ( n > 0 ) || !st->tcxonly ) @@ -208,7 +208,7 @@ void core_encode_twodiv( ShapeSpectrum( st->hTcxCfg, A_q, gainlpc[0], st->L_frame, st->hTcxCfg->tcx_coded_lines, hTcxEnc->spectrum_long, hTcxEnc->fUseTns[0], st, NULL ); - hTcxEnc->measuredBwRatio = 1.f; + hTcxEnc->measuredBwRatio_flt = 1.f; /* Calculate target bits */ target_bits = st->bits_frame_core - tnsBits[0] - nbits_lpc[0] - st->nb_bits_header_tcx - ltpBits; @@ -223,7 +223,7 @@ void core_encode_twodiv( target_bits -= 1; } - QuantizeSpectrum( st, A_q, NULL, gainlpc[0], st->synth, target_bits, tnsSize[0], param_core, 0, &hm_cfg[0], vad_hover_flag ); + QuantizeSpectrum( st, A_q, NULL, gainlpc[0], st->synth_flt, target_bits, tnsSize[0], param_core, 0, &hm_cfg[0], vad_hover_flag ); coder_tcx_post( st, A_q, Aw ); } diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c index b0ef74245..d19224d73 100644 --- a/lib_enc/core_enc_init.c +++ b/lib_enc/core_enc_init.c @@ -89,9 +89,9 @@ void init_coder_ace_plus( if ( st->ini_frame == 0 ) { - set_zero( hTcxEnc->Txnq, L_FRAME32k / 2 + 64 ); - hTcxEnc->acelp_zir = hTcxEnc->Txnq + L_FRAME / 2; - hTcxEnc->tcx_target_bits_fac = 1.0f; + set_zero( hTcxEnc->Txnq_flt, L_FRAME32k / 2 + 64 ); + hTcxEnc->acelp_zir_flt = hTcxEnc->Txnq_flt + L_FRAME / 2; + hTcxEnc->tcx_target_bits_fac_flt = 1.0f; } } @@ -231,10 +231,10 @@ void init_coder_ace_plus( st->glr_idx[0] = 0; st->glr_idx[1] = 0; - st->mean_gc[0] = 0.0f; - st->mean_gc[1] = 0.0f; - st->prev_lsf4_mean = 0.0f; - st->last_stab_fac = 0.0f; + st->mean_gc_flt[0] = 0.0f; + st->mean_gc_flt[1] = 0.0f; + st->prev_lsf4_mean_flt = 0.0f; + st->last_stab_fac_flt = 0.0f; return; } @@ -258,12 +258,12 @@ static void init_tcx( hTcxEnc->spectrum[0] = hTcxEnc->spectrum_long; hTcxEnc->spectrum[1] = hTcxEnc->spectrum_long + N_TCX10_MAX; - init_tcx_cfg( st->hTcxCfg, total_brate, st->sr_core, st->input_Fs, st->L_frame, st->bwidth, hTcxEnc->L_frameTCX, st->fscale, st->encoderLookahead_enc, st->encoderLookahead_FB, st->preemph_fac, st->tcxonly, st->rf_mode, st->igf, st->hIGFEnc != NULL ? st->hIGFEnc->infoStopFrequency : 0, st->element_mode, st->ini_frame, MCT_flag ); + init_tcx_cfg( st->hTcxCfg, total_brate, st->sr_core, st->input_Fs, st->L_frame, st->bwidth, hTcxEnc->L_frameTCX, st->fscale, st->encoderLookahead_enc, st->encoderLookahead_FB, st->preemph_fac_flt, st->tcxonly, st->rf_mode, st->igf, st->hIGFEnc != NULL ? st->hIGFEnc->infoStopFrequency : 0, st->element_mode, st->ini_frame, MCT_flag ); /* Init TCX target bits correction factor */ - hTcxEnc->tcx_target_bits_fac = 1.0f; - hTcxEnc->measuredBwRatio = 1.0f; - hTcxEnc->noiseTiltFactor = 0.5625f; + hTcxEnc->tcx_target_bits_fac_flt = 1.0f; + hTcxEnc->measuredBwRatio_flt = 1.0f; + hTcxEnc->noiseTiltFactor_flt = 0.5625f; hTcxEnc->noiseLevelMemory_cnt = 0; set_f( hTcxEnc->ltpGainMemory, 0.0f, N_LTP_GAIN_MEMS ); @@ -276,10 +276,10 @@ static void init_tcx( { hTcxEnc->tcxltp_pitch_int_past = st->L_frame; hTcxEnc->tcxltp_pitch_fr_past = 0; - hTcxEnc->tcxltp_gain_past = 0.f; - hTcxEnc->tcxltp_norm_corr_past = 0.f; - hTcxEnc->tcxltp_norm_corr_mem = 0.f; - hTcxEnc->kernel_switch_corr_past = 0.f; + hTcxEnc->tcxltp_gain_past_flt = 0.f; + hTcxEnc->tcxltp_norm_corr_past_flt = 0.f; + hTcxEnc->tcxltp_norm_corr_mem_flt = 0.f; + hTcxEnc->kernel_switch_corr_past_flt = 0.f; hTcxEnc->kernel_symmetry_past = 0; /* MDCT_IV & 1 */ hTcxEnc->enc_ste_pre_corr_past = 0; hTcxEnc->tfm_mem = 0.75f; @@ -339,89 +339,89 @@ static void init_sig_buffers( /* Initialize Signal Buffers and Pointers at encoder-sampling-rate */ if ( st->ini_frame == 0 ) { - set_zero( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); - set_zero( st->buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); - set_zero( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); + set_zero( st->buf_speech_enc_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + set_zero( st->buf_speech_enc_pe_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + set_zero( st->buf_wspeech_enc_flt, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); if ( hTcxEnc != NULL ) { - set_zero( hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + set_zero( hTcxEnc->buf_speech_ltp_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); } } else if ( st->L_frame != L_frame_old && !( ( total_brate >= ACELP_16k40 && total_brate <= ACELP_24k40 ) && ( total_brate == last_total_brate ) && ( st->last_bwidth == st->bwidth ) ) ) { - lerp( st->buf_speech_enc, st->buf_speech_enc, st->L_frame, L_frame_old ); + lerp( st->buf_speech_enc_flt, st->buf_speech_enc_flt, st->L_frame, L_frame_old ); if ( ( st->last_core != TCX_20_CORE ) && ( st->last_core != TCX_10_CORE ) ) { - mvr2r( st->buf_speech_enc, hTcxEnc->buf_speech_ltp, st->L_frame ); + mvr2r( st->buf_speech_enc_flt, hTcxEnc->buf_speech_ltp_flt, st->L_frame ); } - mvr2r( st->old_wsp, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); + mvr2r( st->old_wsp, st->buf_wspeech_enc_flt + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); /*Resamp buffers needed only for ACELP*/ if ( st->L_frame == L_FRAME && !st->tcxonly ) { - mvr2r( st->old_inp_12k8, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); + mvr2r( st->old_inp_12k8, st->buf_speech_enc_pe_flt + st->L_frame - L_INP_MEM, L_INP_MEM ); } else if ( st->L_frame == L_FRAME16k && !st->tcxonly ) { - lerp( st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, st->buf_wspeech_enc + st->L_frame + L_SUBFR - 310, 310, L_WSP_MEM ); - mvr2r( st->old_inp_16k, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); + lerp( st->buf_wspeech_enc_flt + st->L_frame + L_SUBFR - L_WSP_MEM, st->buf_wspeech_enc_flt + st->L_frame + L_SUBFR - 310, 310, L_WSP_MEM ); + mvr2r( st->old_inp_16k, st->buf_speech_enc_pe_flt + st->L_frame - L_INP_MEM, L_INP_MEM ); } - st->mem_preemph_enc = st->buf_speech_enc[st->L_frame - 1]; - st->mem_wsp_enc = st->buf_wspeech_enc[st->L_frame + L_SUBFR - 1]; + st->mem_preemph_enc_flt = st->buf_speech_enc_flt[st->L_frame - 1]; + st->mem_wsp_enc_flt = st->buf_wspeech_enc_flt[st->L_frame + L_SUBFR - 1]; } else if ( !st->tcxonly && last_total_brate > ACELP_32k ) /* coming from TCXonly modes */ { - mvr2r( st->old_wsp, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); + mvr2r( st->old_wsp, st->buf_wspeech_enc_flt + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); /*Resamp buffers needed only for ACELP*/ if ( st->L_frame == L_FRAME16k ) { - lerp( st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, st->buf_wspeech_enc + st->L_frame + L_SUBFR - 310, 310, L_WSP_MEM ); + lerp( st->buf_wspeech_enc_flt + st->L_frame + L_SUBFR - L_WSP_MEM, st->buf_wspeech_enc_flt + st->L_frame + L_SUBFR - 310, 310, L_WSP_MEM ); } - st->hLPDmem->mem_w0 = 0; - st->mem_wsp_enc = st->buf_wspeech_enc[st->L_frame + L_SUBFR - 1]; + st->hLPDmem->mem_w0_flt = 0; + st->mem_wsp_enc_flt = st->buf_wspeech_enc_flt[st->L_frame + L_SUBFR - 1]; } - st->new_speech_enc = st->buf_speech_enc + st->encoderPastSamples_enc + st->encoderLookahead_enc; - st->new_speech_enc_pe = st->buf_speech_enc_pe + st->encoderPastSamples_enc + st->encoderLookahead_enc; + st->new_speech_enc_flt = st->buf_speech_enc_flt + st->encoderPastSamples_enc + st->encoderLookahead_enc; + st->new_speech_enc_pe_flt = st->buf_speech_enc_pe_flt + st->encoderPastSamples_enc + st->encoderLookahead_enc; if ( hTcxEnc != NULL ) { - hTcxEnc->new_speech_ltp = hTcxEnc->buf_speech_ltp + st->encoderPastSamples_enc + st->encoderLookahead_enc; + hTcxEnc->new_speech_ltp_flt = hTcxEnc->buf_speech_ltp_flt + st->encoderPastSamples_enc + st->encoderLookahead_enc; } if ( st->hTcxEnc != NULL ) { - st->hTcxEnc->new_speech_TCX = st->input_buff + st->input_Fs / FRAMES_PER_SEC; /* note: in EVS st->new_speech_TCX == st->input - 0.9375ms; in IVAS st->new_speech_TCX == st->input */ - st->hTcxEnc->speech_TCX = st->hTcxEnc->new_speech_TCX - st->encoderLookahead_FB; + st->hTcxEnc->new_speech_TCX_flt = st->input_buff + st->input_Fs / FRAMES_PER_SEC; /* note: in EVS st->new_speech_TCX == st->input - 0.9375ms; in IVAS st->new_speech_TCX == st->input */ + st->hTcxEnc->speech_TCX_flt = st->hTcxEnc->new_speech_TCX_flt - st->encoderLookahead_FB; } - st->speech_enc = st->buf_speech_enc + st->encoderPastSamples_enc; - st->speech_enc_pe = st->buf_speech_enc_pe + st->encoderPastSamples_enc; + st->speech_enc_flt = st->buf_speech_enc_flt + st->encoderPastSamples_enc; + st->speech_enc_pe_flt = st->buf_speech_enc_pe_flt + st->encoderPastSamples_enc; if ( hTcxEnc != NULL ) { - hTcxEnc->speech_ltp = hTcxEnc->buf_speech_ltp + st->encoderPastSamples_enc; + hTcxEnc->speech_ltp_flt = hTcxEnc->buf_speech_ltp_flt + st->encoderPastSamples_enc; } if ( st->element_mode > EVS_MONO ) { - st->wspeech_enc = st->buf_wspeech_enc + st->L_frame + L_SUBFR; + st->wspeech_enc_flt = st->buf_wspeech_enc_flt + st->L_frame + L_SUBFR; } else { - st->wspeech_enc = st->buf_wspeech_enc + st->L_frame + L_subfr; + st->wspeech_enc_flt = st->buf_wspeech_enc_flt + st->L_frame + L_subfr; } if ( st->ini_frame == 0 || st->L_frame != L_frame_old || st->last_codec_mode == MODE1 ) { - set_zero( st->buf_synth, OLD_SYNTH_SIZE_ENC + L_FRAME32k ); + set_zero( st->buf_synth_flt, OLD_SYNTH_SIZE_ENC + L_FRAME32k ); } - st->synth = st->buf_synth + st->L_frame + L_subfr; + st->synth_flt = st->buf_synth_flt + st->L_frame + L_subfr; return; } @@ -439,24 +439,24 @@ static void init_core_sig_ana( /* Pre-emphasis factor and memory */ if ( st->fscale < ( 16000 * FSCALE_DENOM ) / 12800 ) { - st->preemph_fac = PREEMPH_FAC; /*WB*/ + st->preemph_fac_flt = PREEMPH_FAC_FLT; /*WB*/ } else if ( st->fscale < ( 24000 * FSCALE_DENOM ) / 12800 ) { - st->preemph_fac = PREEMPH_FAC_16k; /*WB*/ + st->preemph_fac_flt = PREEMPH_FAC_16k_FLT; /*WB*/ } else { - st->preemph_fac = PREEMPH_FAC_SWB; /*SWB*/ + st->preemph_fac_flt = PREEMPH_FAC_SWB_FLT; /*SWB*/ } if ( st->sr_core == INT_FS_16k ) { - st->gamma = GAMMA16k; + st->gamma_flt = GAMMA16k_FLT; } else { - st->gamma = GAMMA1; + st->gamma_flt = GAMMA1_FLT; } if ( st->narrowBand ) @@ -507,14 +507,14 @@ static void init_acelp( { if ( hLPDmem != NULL ) { - set_zero( hLPDmem->syn, 1 + M ); - set_zero( hLPDmem->mem_syn_r, L_SYN_MEM ); + set_zero( hLPDmem->syn_flt, 1 + M ); + set_zero( hLPDmem->mem_syn_r_flt, L_SYN_MEM ); } if ( st->hTcxEnc != NULL ) { - set_zero( st->hTcxEnc->Txnq, L_FRAME32k / 2 + 64 ); - st->hTcxEnc->acelp_zir = st->hTcxEnc->Txnq + ( st->L_frame / 2 ); + set_zero( st->hTcxEnc->Txnq_flt, L_FRAME32k / 2 + 64 ); + st->hTcxEnc->acelp_zir_flt = st->hTcxEnc->Txnq_flt + ( st->L_frame / 2 ); } } else /*Rate switching*/ @@ -523,13 +523,13 @@ static void init_acelp( { if ( st->last_core == ACELP_CORE ) { - lerp( st->hTcxEnc->Txnq, st->hTcxEnc->Txnq, st->L_frame / 2, L_frame_old / 2 ); + lerp( st->hTcxEnc->Txnq_flt, st->hTcxEnc->Txnq_flt, st->L_frame / 2, L_frame_old / 2 ); } else { - lerp( st->hTcxEnc->Txnq, st->hTcxEnc->Txnq, st->hTcxCfg->tcx_mdct_window_length, st->hTcxCfg->tcx_mdct_window_length_old ); + lerp( st->hTcxEnc->Txnq_flt, st->hTcxEnc->Txnq_flt, st->hTcxCfg->tcx_mdct_window_length, st->hTcxCfg->tcx_mdct_window_length_old ); } - st->hTcxEnc->acelp_zir = st->hTcxEnc->Txnq + ( st->L_frame / 2 ); + st->hTcxEnc->acelp_zir_flt = st->hTcxEnc->Txnq_flt + ( st->L_frame / 2 ); } /* Rate switching */ @@ -537,13 +537,13 @@ static void init_acelp( { if ( hLPDmem != NULL ) { - mvr2r( hLPDmem->mem_syn1, hLPDmem->mem_syn2, M ); - set_zero( hLPDmem->syn, M ); + mvr2r( hLPDmem->mem_syn1_flt, hLPDmem->mem_syn2_flt, M ); + set_zero( hLPDmem->syn_flt, M ); } if ( st->hTcxEnc != NULL ) { - set_zero( st->hTcxEnc->Txnq, L_FRAME32k / 2 + 64 ); + set_zero( st->hTcxEnc->Txnq_flt, L_FRAME32k / 2 + 64 ); } } @@ -560,12 +560,12 @@ static void init_acelp( st->rate_switching_reset = 1; if ( hLPDmem != NULL ) { - hLPDmem->tilt_code = TILT_CODE; - set_zero( hLPDmem->old_exc, L_EXC_MEM ); - set_zero( hLPDmem->syn, 1 + M ); - hLPDmem->mem_w0 = 0.0f; - set_zero( hLPDmem->mem_syn, M ); - set_zero( hLPDmem->mem_syn2, M ); + hLPDmem->tilt_code_flt = TILT_CODE; + set_zero( hLPDmem->old_exc_flt, L_EXC_MEM ); + set_zero( hLPDmem->syn_flt, 1 + M ); + hLPDmem->mem_w0_flt = 0.0f; + set_zero( hLPDmem->mem_syn_flt, M ); + set_zero( hLPDmem->mem_syn2_flt, M ); } /* unquantized LPC*/ @@ -610,15 +610,15 @@ static void init_acelp( /* Update wsyn */ if ( hLPDmem != NULL ) { - synth_mem_updt2( st->L_frame, st->last_L_frame, hLPDmem->old_exc, hLPDmem->mem_syn_r, hLPDmem->mem_syn2, hLPDmem->mem_syn, ENC ); + synth_mem_updt2( st->L_frame, st->last_L_frame, hLPDmem->old_exc_flt, hLPDmem->mem_syn_r_flt, hLPDmem->mem_syn2_flt, hLPDmem->mem_syn_flt, ENC ); lsp2a_stab( st->lsp_old, A, M ); - weight_a( A, Ap, GAMMA1, M ); + weight_a( A, Ap, GAMMA1_FLT, M ); tmp = 0.f; tmp_buf[0] = 0.f; - mvr2r( hLPDmem->mem_syn2, tmp_buf + 1, M ); - deemph( tmp_buf + 1, st->preemph_fac, M, &tmp ); + mvr2r( hLPDmem->mem_syn2_flt, tmp_buf + 1, M ); + deemph( tmp_buf + 1, st->preemph_fac_flt, M, &tmp ); residu( Ap, M, tmp_buf + M, &tmp, 1 ); - hLPDmem->mem_w0 = st->wspeech_enc[-1] - tmp; + hLPDmem->mem_w0_flt = st->wspeech_enc_flt[-1] - tmp; } } else if ( st->L_frame != L_frame_old ) /* Rate switching involving TCX only modes */ @@ -630,19 +630,19 @@ static void init_acelp( /*reset partly some memories*/ if ( hLPDmem != NULL ) { - hLPDmem->tilt_code = TILT_CODE; - set_zero( hLPDmem->old_exc, L_EXC_MEM ); + hLPDmem->tilt_code_flt = TILT_CODE; + set_zero( hLPDmem->old_exc_flt, L_EXC_MEM ); /*Resamp others memories*/ /*Size of LPC syn memory*/ mem_syn_r_size_old = (int16_t) ( 1.25 * L_frame_old / 20.f ); mem_syn_r_size_new = (int16_t) ( 1.25 * st->L_frame / 20.f ); - lerp( hLPDmem->mem_syn_r + L_SYN_MEM - mem_syn_r_size_old, hLPDmem->mem_syn_r + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); - mvr2r( hLPDmem->mem_syn_r + L_SYN_MEM - M, hLPDmem->mem_syn, M ); - mvr2r( hLPDmem->mem_syn, hLPDmem->mem_syn2, M ); + lerp( hLPDmem->mem_syn_r_flt + L_SYN_MEM - mem_syn_r_size_old, hLPDmem->mem_syn_r_flt + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + mvr2r( hLPDmem->mem_syn_r_flt + L_SYN_MEM - M, hLPDmem->mem_syn_flt, M ); + mvr2r( hLPDmem->mem_syn_flt, hLPDmem->mem_syn2_flt, M ); - /*Untouched memories : LPDmem->syn & LPDmem->mem_w0*/ - hLPDmem->mem_w0 = 0; + /*Untouched memories : LPDmem->syn & LPDmem->mem_w0_flt*/ + hLPDmem->mem_w0_flt = 0; } /* unquantized LPC*/ @@ -670,8 +670,8 @@ static void init_acelp( /* Post-processing */ if ( hLPDmem != NULL ) { - set_zero( hLPDmem->dispMem, 8 ); - hLPDmem->gc_threshold = 0.0f; + set_zero( hLPDmem->dispMem_flt, 8 ); + hLPDmem->gc_threshold_flt = 0.0f; } /* Pulse Search configuration */ diff --git a/lib_enc/core_enc_ol.c b/lib_enc/core_enc_ol.c index 278f47b73..051d99f67 100644 --- a/lib_enc/core_enc_ol.c +++ b/lib_enc/core_enc_ol.c @@ -47,7 +47,7 @@ * Local function prototypes *-------------------------------------------------------------------*/ -static void BITS_ALLOC_ACELP_config_rf( const int16_t coder_type, float *tilt_code, int16_t *rf_frame_type, int16_t *rf_target_bits, const int16_t nb_subfr, const int16_t rf_fec_indicator, float *pitch_buf ); +static void BITS_ALLOC_ACELP_config_rf( const int16_t coder_type, float *tilt_code_flt, int16_t *rf_frame_type, int16_t *rf_target_bits, const int16_t nb_subfr, const int16_t rf_fec_indicator, float *pitch_buf ); static void BITS_ALLOC_TCX_config_rf( int16_t *rf_frame_type, int16_t *rf_target_bits, const int16_t PLC_Mode, const int16_t coder_type, const int16_t last_core, const int16_t TD_Mode ); @@ -123,32 +123,32 @@ void core_encode_openloop( /* back up old exc before primary encoding */ set_f( exc_buf_rf, 0, ( L_EXC_MEM + L_FRAME + 1 ) ); exc_rf = exc_buf_rf + L_EXC_MEM; - mvr2r( hLPDmem->old_exc, exc_buf_rf, L_EXC_MEM ); + mvr2r( hLPDmem->old_exc_flt, exc_buf_rf, L_EXC_MEM ); /* back up old synthesis before primary encoding */ set_f( syn_buf_rf, 0, ( M + L_FRAME16k + L_FRAME16k / 2 ) ); syn_rf = syn_buf_rf + M; - mvr2r( hLPDmem->mem_syn, syn_buf_rf, M ); + mvr2r( hLPDmem->mem_syn_flt, syn_buf_rf, M ); if ( st->Opt_RF_ON ) { /* back up syn2 mem */ - mvr2r( hLPDmem->mem_syn2, st->hRF->rf_mem_syn2, M ); + mvr2r( hLPDmem->mem_syn2_flt, st->hRF->rf_mem_syn2_flt, M ); - /* back up LPD mem_w0 target generation memory */ - st->hRF->rf_mem_w0 = hLPDmem->mem_w0; + /* back up LPD mem_w0_flt target generation memory */ + st->hRF->rf_mem_w0_flt = hLPDmem->mem_w0_flt; /* back up clip gain memory */ - mvr2r( st->clip_var, st->hRF->rf_clip_var, 6 ); + mvr2r( st->clip_var, st->hRF->rf_clip_var_flt, 6 ); /* back up tilt code */ - st->hRF->rf_tilt_code = hLPDmem->tilt_code; + st->hRF->rf_tilt_code_flt = hLPDmem->tilt_code_flt; /* back up dispMem */ - mvr2r( hLPDmem->dispMem, st->hRF->rf_dispMem, 8 ); + mvr2r( hLPDmem->dispMem_flt, st->hRF->rf_dispMem, 8 ); - /* back up gc_threshold for noise addition */ - st->hRF->rf_gc_threshold = hLPDmem->gc_threshold; + /* back up gc_threshold_flt for noise addition */ + st->hRF->rf_gc_threshold_flt = hLPDmem->gc_threshold_flt; } @@ -185,7 +185,7 @@ void core_encode_openloop( if ( st->envWeighted ) { /* Unweight the envelope */ - E_LPC_lsp_unweight( st->lsp_old, st->lsp_old, st->lsf_old, 1.0f / st->gamma ); + E_LPC_lsp_unweight_float( st->lsp_old, st->lsp_old, st->lsf_old, 1.0f / st->gamma_flt); st->envWeighted = 0; } @@ -264,17 +264,17 @@ void core_encode_openloop( } /* Run ACELP encoder */ - coder_acelp( st, Aw, A_q_ace, st->speech_enc_pe, hLPDmem, param_core, stab_fac, target_bits, gain_pitch_buf, gain_code_buf, pitch_buf, voice_factors, ptr_bwe_exc ); + coder_acelp( st, Aw, A_q_ace, st->speech_enc_pe_flt, hLPDmem, param_core, stab_fac, target_bits, gain_pitch_buf, gain_code_buf, pitch_buf, voice_factors, ptr_bwe_exc ); if ( st->hPlcExt ) { - st->glr_idx[0] = encSideSpecPowDiffuseDetector( st->hPlcExt->last_lsf_ref, st->hPlcExt->last_lsf_con, st->last_sr_core, &( st->prev_lsf4_mean ), st->glr, st->coder_type ); + st->glr_idx[0] = encSideSpecPowDiffuseDetector( st->hPlcExt->last_lsf_ref_flt, st->hPlcExt->last_lsf_con_flt, st->last_sr_core, &( st->prev_lsf4_mean_flt), st->glr, st->coder_type ); - mvr2r( lsf_q, st->hPlcExt->last_lsf_ref, M ); - mvr2r( st->hPlcExt->lsf_con, st->hPlcExt->last_lsf_con, M ); - updateSpecPowDiffuseIdx( gain_pitch_buf, gain_code_buf, st->glr_idx, st->mean_gc ); + mvr2r( lsf_q, st->hPlcExt->last_lsf_ref_flt, M ); + mvr2r( st->hPlcExt->lsf_con_flt, st->hPlcExt->last_lsf_con_flt, M ); + updateSpecPowDiffuseIdx( gain_pitch_buf, gain_code_buf, st->glr_idx, st->mean_gc_flt); - if ( st->last_stab_fac > 0.02 ) + if ( st->last_stab_fac_flt > 0.02 ) { st->glr_idx[0] = 0; } @@ -283,9 +283,9 @@ void core_encode_openloop( encoderSideLossSimulation( st, st->hPlcExt, lsf_q, stab_fac, st->hPlcExt->calcOnlylsf, st->L_frame ); } - st->last_stab_fac = stab_fac; + st->last_stab_fac_flt = stab_fac; - hTcxEnc->tcxltp_norm_corr_past = st->voicing[1]; + hTcxEnc->tcxltp_norm_corr_past_flt = st->voicing[1]; st->hTcxCfg->tcx_curr_overlap_mode = st->hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW; } @@ -303,13 +303,13 @@ void core_encode_openloop( mvr2r( st->mem_MA, rf_mem_MA, M ); } - tcx_lpc_cdk = tcxlpc_get_cdk( st->hTcxCfg->coder_type ); + tcx_lpc_cdk = tcxlpc_get_cdk_float( st->hTcxCfg->coder_type ); /* Get the envelope corresponding to the current frame */ - E_LPC_int_lpc_tcx( st->lspold_enc, lsp_new, A_q_tcx ); + E_LPC_int_lpc_tcx_float( st->lspold_enc, lsp_new, A_q_tcx ); /* Weight the envelope */ - weight_a( A_q_tcx, A_q_tcx, st->gamma, M ); + weight_a( A_q_tcx, A_q_tcx, st->gamma_flt, M ); /* Save the weighted envelope */ mvr2r( A_q_tcx, A_w, M + 1 ); @@ -334,7 +334,7 @@ void core_encode_openloop( } else { - E_LPC_int_lpc_tcx( st->lsp_old, lsp_q, A_q_tcx ); + E_LPC_int_lpc_tcx_float( st->lsp_old, lsp_q, A_q_tcx ); } if ( hTcxEnc->tcx_lpc_shaped_ari ) @@ -372,7 +372,7 @@ void core_encode_openloop( target_bits -= hTcxEnc->tcxltp_bits; /* Run TCX20 encoder */ - coder_tcx( st, st->hTcxCfg, A_q_tcx, A_q_ind, st->synth, st->L_frame, hTcxEnc->L_frameTCX, st->hTcxCfg->tcx_coded_lines, target_bits, hTcxEnc->spectrum_long, param_core, &hm_cfg, vad_hover_flag ); + coder_tcx( st, st->hTcxCfg, A_q_tcx, A_q_ind, st->synth_flt, st->L_frame, hTcxEnc->L_frameTCX, st->hTcxCfg->tcx_coded_lines, target_bits, hTcxEnc->spectrum_long, param_core, &hm_cfg, vad_hover_flag ); coder_tcx_post( st, A_q_tcx, Aw ); @@ -385,7 +385,7 @@ void core_encode_openloop( if ( st->enableTcxLpc ) { - E_LPC_lsp_unweight( lsp_tcx_q, lsp_q, lsf_q, 1.0f / st->gamma ); /* Update lsf_q for encoderSideLossSimulation() */ + E_LPC_lsp_unweight_float( lsp_tcx_q, lsp_q, lsf_q, 1.0f / st->gamma_flt); /* Update lsf_q for encoderSideLossSimulation() */ } if ( st->hPlcExt ) { @@ -405,7 +405,7 @@ void core_encode_openloop( st->envWeighted = 1; /* Update ACELP quantizer state */ - lsf_update_memory( st->narrowBand, st->lsf_old, st->mem_MA, st->mem_MA ); + lsf_update_memory_float( st->narrowBand, st->lsf_old, st->mem_MA, st->mem_MA ); st->pstreaklen = 0; st->streaklimit = 1.0f; @@ -428,9 +428,9 @@ void core_encode_openloop( assert( st->L_frame == L_FRAME ); - mvr2r( st->synth + L_FRAME - L_LP, buf, L_LP ); - tmp = st->synth[L_FRAME - L_LP - 1]; - preemph( buf, st->preemph_fac, L_LP, &tmp ); + mvr2r( st->synth_flt + L_FRAME - L_LP, buf, L_LP ); + tmp = st->synth_flt[L_FRAME - L_LP - 1]; + preemph( buf, st->preemph_fac_flt, L_LP, &tmp ); autocorr( buf, r, M, L_LP, LP_assym_window, 0, 0, 0 ); lag_wind( r, M, INT_FS_12k8, LAGW_WEAK ); lev_dur( A, r, M, NULL ); @@ -438,11 +438,11 @@ void core_encode_openloop( residu( A, M, buf + L_LP - L_FRAME, res, L_FRAME ); - cng_params_upd( lsptmp, res, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ, ENC, st->hTdCngEnc->ho_env_circ, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); + cng_params_upd( lsptmp, res, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ, ENC, st->hTdCngEnc->ho_env_circ, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf_flt, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); } else { - cng_params_upd( lsp_new, hLPDmem->old_exc + L_EXC_MEM - st->L_frame, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ, ENC, st->hTdCngEnc->ho_env_circ, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); + cng_params_upd( lsp_new, hLPDmem->old_exc_flt + L_EXC_MEM - st->L_frame, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ, ENC, st->hTdCngEnc->ho_env_circ, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf_flt, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); } if ( st->L_frame == L_FRAME ) @@ -477,7 +477,7 @@ void core_encode_openloop( /*ACELP: estimate bpf parameter with delay=0*/ /*Estimate bpf parameter*/ - bass_pf_enc( st->speech_enc, st->synth, pitch_buf, gain_pitch_buf, st->L_frame, L_SUBFR, st->mem_bpf, st->mem_error_bpf, &( st->bpf_gain_param ), st->acelp_cfg.bpf_mode, &( st->pst_lp_ener ), &( st->pst_mem_deemp_err ) ); + bass_pf_enc( st->speech_enc_flt, st->synth_flt, pitch_buf, gain_pitch_buf, st->L_frame, L_SUBFR, st->mem_bpf, st->mem_error_bpf, &( st->bpf_gain_param ), st->acelp_cfg.bpf_mode, &( st->pst_lp_ener ), &( st->pst_mem_deemp_err ) ); } /*--------------------------------------------------------------* @@ -508,12 +508,12 @@ void core_encode_openloop( /* quantized lsf from two stages */ v_add( lsf_q_1st_rf, lsf_q_diff_cb_8b_rf + M * hRF->rf_indx_lsf[0][1], lsf_q_rf, M ); - v_sort( lsf_q_rf, 0, M - 1 ); + v_sort_float( lsf_q_rf, 0, M - 1 ); reorder_lsf( lsf_q_rf, LSF_GAP, M, st->sr_core ); } else { - rf_tcx_lpc_cdk = tcxlpc_get_cdk( GENERIC ); + rf_tcx_lpc_cdk = tcxlpc_get_cdk_float( GENERIC ); /* Quantize */ Q_lsf_tcxlpc( lsf, lsf_tcx_q, lspq_ind, param_lpc, st->narrowBand, rf_tcx_lpc_cdk, rf_mem_MA, GENERIC, st->Bin_E ); @@ -539,7 +539,7 @@ void core_encode_openloop( /* o: rf_frame_type, o: rf_target_bits */ if ( st->Opt_RF_ON ) { - BITS_ALLOC_ACELP_config_rf( st->coder_type, hRF->rf_tilt_buf, &hRF->rf_frame_type, &hRF->rf_target_bits, st->nb_subfr, st->rf_fec_indicator, pitch_buf ); + BITS_ALLOC_ACELP_config_rf( st->coder_type, hRF->rf_tilt_buf_flt, &hRF->rf_frame_type, &hRF->rf_target_bits, st->nb_subfr, st->rf_fec_indicator, pitch_buf ); } /* RF frame type in the buffer */ @@ -549,7 +549,7 @@ void core_encode_openloop( if ( hRF->rf_frame_type != RF_NO_DATA ) { /* coder_acelp_rf does the partial copy encoding based on the rf frame type chosen for the RF encoding */ - coder_acelp_rf( hRF->rf_target_bits, st->speech_enc_pe, st->coder_type, hRF->rf_frame_type, Aw, Aq_rf, st->voicing, st->pitch, stab_fac_rf, st, &( hRF->acelp_cfg_rf ), exc_rf, syn_rf ); + coder_acelp_rf( hRF->rf_target_bits, st->speech_enc_pe_flt, st->coder_type, hRF->rf_frame_type, Aw, Aq_rf, st->voicing, st->pitch, stab_fac_rf, st, &( hRF->acelp_cfg_rf ), exc_rf, syn_rf ); } } else @@ -559,7 +559,7 @@ void core_encode_openloop( hRF->rf_gain_tcx[0] = param_core[0]; /* attenuate somewhat the gain for onset when the correlation with previous frame is too low: avoid preecho */ - if ( hRF->rf_gain_tcx[1] != 0 && hRF->rf_gain_tcx[0] > 1.6 * hRF->rf_gain_tcx[1] && hTcxEnc->tcxltp_gain <= 0.2 ) + if ( hRF->rf_gain_tcx[1] != 0 && hRF->rf_gain_tcx[0] > 1.6 * hRF->rf_gain_tcx[1] && hTcxEnc->tcxltp_gain_flt <= 0.2 ) { hRF->rf_gain_tcx[0] = (int16_t) ( 1.6f * hRF->rf_gain_tcx[1] ); @@ -571,13 +571,13 @@ void core_encode_openloop( /* get concealment decision*/ rf_PLC_Mode = 0; - if ( st->core == TCX_20_CORE && ( st->last_core == TCX_20_CORE ) && ( hRF->rf_second_last_core == TCX_20_CORE ) && ( ( hTcxEnc->tcxltp_pitch_int <= 0.5f * st->L_frame ) || ( hTcxEnc->tcxltp_gain <= 0.4f ) ) && ( hTcxEnc->tcxltp_pitch_int == hRF->rf_tcxltp_pitch_int_past ) && !hRF->rf_last_tns_active && !hRF->rf_second_last_tns_active && !( st->hTcxCfg->fIsTNSAllowed & hTcxEnc->fUseTns[0] ) ) + if ( st->core == TCX_20_CORE && ( st->last_core == TCX_20_CORE ) && ( hRF->rf_second_last_core == TCX_20_CORE ) && ( ( hTcxEnc->tcxltp_pitch_int <= 0.5f * st->L_frame ) || ( hTcxEnc->tcxltp_gain_flt <= 0.4f ) ) && ( hTcxEnc->tcxltp_pitch_int == hRF->rf_tcxltp_pitch_int_past ) && !hRF->rf_last_tns_active && !hRF->rf_second_last_tns_active && !( st->hTcxCfg->fIsTNSAllowed & hTcxEnc->fUseTns[0] ) ) { rf_PLC_Mode = 1; } else if ( st->last_core != ACELP_CORE ) { - if ( ( st->clas <= UNVOICED_TRANSITION || st->last_clas <= UNVOICED_TRANSITION || hTcxEnc->tcxltp_gain <= 0.4f ) && st->last_core != -1 ) + if ( ( st->clas <= UNVOICED_TRANSITION || st->last_clas <= UNVOICED_TRANSITION || hTcxEnc->tcxltp_gain_flt <= 0.4f ) && st->last_core != -1 ) { rf_PLC_Mode = st->last_core; } @@ -709,12 +709,12 @@ void core_acelp_tcx20_switching( } if ( st->narrowBand == 1 ) { - pitchDoubling_det( st->wspeech_enc, st->pitch, pitch_fr, voicing_fr ); + pitchDoubling_det( st->wspeech_enc_flt, st->pitch, pitch_fr, voicing_fr ); } lsp2a_stab( lsp_mid, A_q_tcx, M ); - tcx_ltp_encode( st, TCX_20, st->L_frame, st->speech_enc + st->encoderLookahead_enc, hTcxEnc->speech_ltp + st->encoderLookahead_enc, st->wspeech_enc + st->encoderLookahead_enc, st->pitch, hTcxEnc->tcxltp_param, &hTcxEnc->tcxltp_bits, A_q_tcx, 0, st->element_mode ); + tcx_ltp_encode( st, TCX_20, st->L_frame, st->speech_enc_flt + st->encoderLookahead_enc, hTcxEnc->speech_ltp_flt + st->encoderLookahead_enc, st->wspeech_enc_flt + st->encoderLookahead_enc, st->pitch, hTcxEnc->tcxltp_param, &hTcxEnc->tcxltp_bits, A_q_tcx, 0, st->element_mode ); /* Force TCX when TCX20 in MODE1 is selected */ @@ -760,7 +760,7 @@ void core_acelp_tcx20_switching( overlap = st->hTcxCfg->tcx_mdct_window_delay; - mvr2r( hTcxEnc->speech_ltp - ( overlap >> 1 ) + tcx_offset, xn_buf, L_frame + overlap ); + mvr2r( hTcxEnc->speech_ltp_flt - ( overlap >> 1 ) + tcx_offset, xn_buf, L_frame + overlap ); if ( st->last_core == ACELP_CORE ) { @@ -773,13 +773,13 @@ void core_acelp_tcx20_switching( { for ( i = 0; i < overlap; i++ ) { - xn_buf[i] *= st->hTcxCfg->tcx_mdct_window[i]; + xn_buf[i] *= st->hTcxCfg->tcx_mdct_window_flt[i]; } } for ( i = 0; i < overlap; i++ ) { - xn_buf[L_frame + i] *= st->hTcxCfg->tcx_mdct_window[overlap - 1 - i]; + xn_buf[L_frame + i] *= st->hTcxCfg->tcx_mdct_window_flt[overlap - 1 - i]; } TCX_MDCT( xn_buf, x, overlap, L_frame - overlap, overlap, st->element_mode ); @@ -789,7 +789,7 @@ void core_acelp_tcx20_switching( x[i] *= (float) ( L_frame / sqrt( 2 * NORM_MDCT_FACTOR ) ); } - weight_a( A_q_tcx, Ap, st->gamma, M ); + weight_a( A_q_tcx, Ap, st->gamma_flt, M ); lpc2mdct( Ap, M, gainlpc, FDNS_NPTS, 0 ); @@ -847,7 +847,7 @@ void core_acelp_tcx20_switching( for ( i = 0; i < st->L_frame; i += L_SUBFR ) { - *pt_ener_sfr = sum2_f( st->wspeech_enc + i, L_SUBFR ) + 1e-6f; + *pt_ener_sfr = sum2_f( st->wspeech_enc_flt + i, L_SUBFR ) + 1e-6f; snr_tcx += (float) log10( *pt_ener_sfr / ( ener * L_SUBFR ) ); pt_ener_sfr++; @@ -881,12 +881,12 @@ void core_acelp_tcx20_switching( for ( i = 0; i < st->L_frame; i += L_SUBFR ) { T0 = (int16_t) ( ( fac * pitch_fr[(int16_t) ( (float) ( i / L_SUBFR ) / fac + 0.5f )] ) + 0.5f ); - gain = get_gain( st->wspeech_enc + i, st->wspeech_enc + i - T0, L_SUBFR, NULL ); + gain = get_gain_flt( st->wspeech_enc_flt + i, st->wspeech_enc_flt + i - T0, L_SUBFR, NULL ); noise = 1e-6f; for ( j = 0; j < L_SUBFR; j++ ) { - tmp = st->wspeech_enc[i + j] - gain * st->wspeech_enc[i + j - T0]; + tmp = st->wspeech_enc_flt[i + j] - gain * st->wspeech_enc_flt[i + j - T0]; noise += tmp * tmp; } @@ -981,7 +981,7 @@ void core_acelp_tcx20_switching( static void BITS_ALLOC_ACELP_config_rf( const int16_t coder_type, - float *tilt_code, + float *tilt_code_flt, int16_t *rf_frame_type, int16_t *rf_target_bits, const int16_t nb_subfr, @@ -1003,15 +1003,15 @@ static void BITS_ALLOC_ACELP_config_rf( /* Mean tilt code estimation */ mean_tc = 0; - mean_tc = mean( tilt_code, nb_subfr ); + mean_tc = mean( tilt_code_flt, nb_subfr ); /* Maximum tilt code estimation */ - max_tilt_code = tilt_code[0]; - maximum( tilt_code, nb_subfr, &max_tilt_code ); + max_tilt_code = tilt_code_flt[0]; + maximum( tilt_code_flt, nb_subfr, &max_tilt_code ); /* Minimum tilt code estimation */ - min_tilt_code = tilt_code[0]; - minimum( tilt_code, nb_subfr, &min_tilt_code ); + min_tilt_code = tilt_code_flt[0]; + minimum( tilt_code_flt, nb_subfr, &min_tilt_code ); /* ----------------------------------------*/ /* Decide Criticality */ diff --git a/lib_enc/core_enc_reconf.c b/lib_enc/core_enc_reconf.c index 0ad804f95..87cfe5789 100644 --- a/lib_enc/core_enc_reconf.c +++ b/lib_enc/core_enc_reconf.c @@ -67,8 +67,8 @@ void core_coder_reconfig( st->hRF->acelp_cfg_rf.formant_enh = 1; st->hRF->acelp_cfg_rf.formant_tilt = 1; st->hRF->acelp_cfg_rf.voice_tilt = 1; - st->hRF->acelp_cfg_rf.formant_enh_num = FORMANT_SHARPENING_G1; - st->hRF->acelp_cfg_rf.formant_enh_den = FORMANT_SHARPENING_G2; + st->hRF->acelp_cfg_rf.formant_enh_num_flt = FORMANT_SHARPENING_G1_FLT; + st->hRF->acelp_cfg_rf.formant_enh_den_flt = FORMANT_SHARPENING_G2_FLT; } if ( st->element_mode == IVAS_CPE_MDCT ) @@ -132,7 +132,7 @@ void core_coder_reconfig( /*Scale TCX for non-active frames to adjust loudness with ACELP*/ if ( st->hTcxCfg != NULL ) { - st->hTcxCfg->na_scale = 1.f; + st->hTcxCfg->na_scale_flt = 1.f; if ( bwidth < SWB && !( st->tcxonly ) ) { for ( i = 0; i < SIZE_SCALE_TABLE_TCX; i++ ) @@ -145,7 +145,7 @@ void core_coder_reconfig( { i--; } - st->hTcxCfg->na_scale = scaleTcxTable[i].scale; + st->hTcxCfg->na_scale_flt = scaleTcxTable[i].scale_flt; break; } } @@ -170,7 +170,7 @@ void core_coder_reconfig( { if ( st->tec_tfa == 0 ) { - set_zero( st->hTECEnc->loBuffer, MAX_TEC_SMOOTHING_DEG ); + set_zero( st->hTECEnc->loBuffer_flt, MAX_TEC_SMOOTHING_DEG ); } st->tec_tfa = 1; } diff --git a/lib_enc/core_enc_switch.c b/lib_enc/core_enc_switch.c index e6b672d85..e446ee8e2 100644 --- a/lib_enc/core_enc_switch.c +++ b/lib_enc/core_enc_switch.c @@ -101,7 +101,7 @@ void core_coder_mode_switch( } st->hTcxCfg->tcx_coded_lines = getNumTcxCodedLines( st->bwidth ); - st->hTcxCfg->bandwidth = getTcxBandwidth( st->bwidth ); + st->hTcxCfg->bandwidth_flt = getTcxBandwidth( st->bwidth ); st->hTcxCfg->tcxRateLoopOpt = ( st->tcxonly ) ? 2 : 0; st->hTcxCfg->tcxRateLoopOpt = ( st->element_mode == IVAS_CPE_MDCT ) ? 3 : st->hTcxCfg->tcxRateLoopOpt; st->hTcxCfg->ctx_hm = getCtxHm( st->element_mode, st->total_brate, st->rf_mode ); @@ -174,7 +174,7 @@ void core_coder_mode_switch( if ( st->envWeighted && !st->enableTcxLpc ) { /* Unweight the envelope */ - E_LPC_lsp_unweight( st->lsp_old, st->lsp_old, st->lsf_old, 1.0f / st->gamma ); + E_LPC_lsp_unweight_float( st->lsp_old, st->lsp_old, st->lsf_old, 1.0f / st->gamma_flt); st->envWeighted = 0; } diff --git a/lib_enc/core_enc_updt.c b/lib_enc/core_enc_updt.c index 1e17f7822..4b9470599 100644 --- a/lib_enc/core_enc_updt.c +++ b/lib_enc/core_enc_updt.c @@ -57,32 +57,32 @@ void core_encode_update( /* Update Input Signal Buffers */ n = st->encoderPastSamples_enc + st->encoderLookahead_enc; - mvr2r( st->buf_speech_enc_pe + st->L_frame, st->buf_speech_enc_pe, n ); - mvr2r( st->buf_speech_enc + st->L_frame, st->buf_speech_enc, n ); + mvr2r( st->buf_speech_enc_pe_flt + st->L_frame, st->buf_speech_enc_pe_flt, n ); + mvr2r( st->buf_speech_enc_flt + st->L_frame, st->buf_speech_enc_flt, n ); if ( !st->tcxonly ) { n = st->L_frame + st->L_frame / 4; - mvr2r( st->buf_wspeech_enc + st->L_frame, st->buf_wspeech_enc, n ); + mvr2r( st->buf_wspeech_enc_flt + st->L_frame, st->buf_wspeech_enc_flt, n ); } if ( hTcxEnc != NULL ) { if ( st->core == ACELP_CORE || st->core == AMR_WB_CORE || st->core_brate == SID_2k40 || st->core_brate == FRAME_NO_DATA ) { - mvr2r( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame ); + mvr2r( st->buf_speech_enc_flt + st->L_frame, hTcxEnc->buf_speech_ltp_flt + st->L_frame, st->L_frame ); } } n = st->encoderPastSamples_enc + st->encoderLookahead_enc; - mvr2r( st->buf_synth + st->L_frame, st->buf_synth, st->L_frame + L_SUBFR ); + mvr2r( st->buf_synth_flt + st->L_frame, st->buf_synth_flt, st->L_frame + L_SUBFR ); if ( hTcxEnc != NULL ) { - mvr2r( hTcxEnc->buf_speech_ltp + st->L_frame, hTcxEnc->buf_speech_ltp, n ); + mvr2r( hTcxEnc->buf_speech_ltp_flt + st->L_frame, hTcxEnc->buf_speech_ltp_flt, n ); if ( st->element_mode != IVAS_CPE_MDCT ) { - st->hTcxEnc->kernel_switch_corr_past = 0.f; + st->hTcxEnc->kernel_switch_corr_past_flt = 0.f; st->hTcxEnc->kernel_type[0] = MDCT_IV; st->hTcxEnc->kernel_symmetry_past = 0; st->hTcxEnc->enc_ste_pre_corr_past = 0; @@ -137,32 +137,32 @@ void core_encode_update_cng( /* Update synth memory */ synth = synth_buf + ( 1 + M ); - mvr2r( hLPDmem->syn, synth_buf, 1 + M ); + mvr2r( hLPDmem->syn_flt, synth_buf, 1 + M ); mvr2r( timeDomainBuffer, synth, L_frame ); - mvr2r( synth + L_frame - ( 1 + M ), hLPDmem->syn, 1 + M ); - mvr2r( synth, st->synth, L_frame ); + mvr2r( synth + L_frame - ( 1 + M ), hLPDmem->syn_flt, 1 + M ); + mvr2r( synth, st->synth_flt, L_frame ); /* Update ZIR */ set_zero( synth + L_frame, L_frame / 2 ); syn_filt( A, M, synth + L_frame, synth + L_frame, L_frame / 2, &synth[L_frame - M], 0 ); if ( st->hTcxEnc != NULL ) { - mvr2r( synth + L_frame - ( L_frame / 2 ), st->hTcxEnc->Txnq, L_frame / 2 ); + mvr2r( synth + L_frame - ( L_frame / 2 ), st->hTcxEnc->Txnq_flt, L_frame / 2 ); } /* Update pe-synth memory */ tmp = synth[-( 1 + M )]; - preemph( synth - M, st->preemph_fac, M + L_frame, &tmp ); - mvr2r( synth + L_frame - M, hLPDmem->mem_syn, M ); - mvr2r( synth + L_frame - M, hLPDmem->mem_syn2, M ); + preemph( synth - M, st->preemph_fac_flt, M + L_frame, &tmp ); + mvr2r( synth + L_frame - M, hLPDmem->mem_syn_flt, M ); + mvr2r( synth + L_frame - M, hLPDmem->mem_syn2_flt, M ); /* Update excitation memory */ - mvr2r( hLPDmem->old_exc + L_frame, hLPDmem->old_exc, max( L_EXC_MEM - L_frame, 0 ) ); - residu( A, M, synth, hLPDmem->old_exc + max( L_EXC_MEM - L_frame, 0 ), L_frame ); + mvr2r( hLPDmem->old_exc_flt + L_frame, hLPDmem->old_exc_flt, max( L_EXC_MEM - L_frame, 0 ) ); + residu( A, M, synth, hLPDmem->old_exc_flt + max( L_EXC_MEM - L_frame, 0 ), L_frame ); if ( st->core_brate == SID_2k40 ) { - enr = cng_energy( st->element_mode, st->bwidth, st->hDtxEnc->CNG_mode, st->hTdCngEnc->CNG_att, hLPDmem->old_exc + max( L_EXC_MEM - L_frame, 0 ), L_frame ); + enr = cng_energy( st->element_mode, st->bwidth, st->hDtxEnc->CNG_mode, st->hTdCngEnc->CNG_att, hLPDmem->old_exc_flt + max( L_EXC_MEM - L_frame, 0 ), L_frame ); enr_index = (int16_t) ( ( enr + 2.0f ) * STEP_SID ); enr_index = min( max( enr_index, 0 ), 127 ); @@ -171,9 +171,9 @@ void core_encode_update_cng( /* Update weighted synthesis memory */ calc_residu( synth, wsyn, Aw, L_frame ); - tmp = st->wspeech_enc[-1] - hLPDmem->mem_w0; - deemph( wsyn, st->preemph_fac, L_frame, &tmp ); - hLPDmem->mem_w0 = st->wspeech_enc[L_frame - 1] - wsyn[L_frame - 1]; + tmp = st->wspeech_enc_flt[-1] - hLPDmem->mem_w0_flt; + deemph( wsyn, st->preemph_fac_flt, L_frame, &tmp ); + hLPDmem->mem_w0_flt = st->wspeech_enc_flt[L_frame - 1] - wsyn[L_frame - 1]; /* Update LPC-related memories */ mvr2r( lsp, st->lsp_old, M ); @@ -183,9 +183,9 @@ void core_encode_update_cng( st->old_Es_pred = 0; /* Reset acelp memories */ - set_zero( hLPDmem->dispMem, 8 ); - hLPDmem->tilt_code = TILT_CODE; - hLPDmem->gc_threshold = 0.0f; + set_zero( hLPDmem->dispMem_flt, 8 ); + hLPDmem->tilt_code_flt = TILT_CODE; + hLPDmem->gc_threshold_flt = 0.0f; /* Update ace/tcx mode */ st->core = ACELP_CORE; diff --git a/lib_enc/core_switching_enc.c b/lib_enc/core_switching_enc.c index 9b988a123..1957dee02 100644 --- a/lib_enc/core_switching_enc.c +++ b/lib_enc/core_switching_enc.c @@ -67,7 +67,7 @@ void core_switching_pre_enc( { if ( hLPDmem != NULL ) { - mvr2r( hLPDmem->mem_syn2, hLPDmem->mem_syn1, M ); + mvr2r( hLPDmem->mem_syn2_flt, hLPDmem->mem_syn1_flt, M ); } if ( st->element_mode != IVAS_CPE_MDCT ) @@ -186,14 +186,14 @@ void core_switching_pre_enc( /* Reset ACELP parameters */ if ( hLPDmem != NULL ) { - hLPDmem->syn[M] = 0; - set_f( hLPDmem->mem_syn2, 0.0f, M ); - set_f( hLPDmem->mem_syn, 0.0f, M ); - set_f( hLPDmem->mem_syn1, 0.0f, M ); - hLPDmem->mem_w0 = 0.0f; - hLPDmem->tilt_code = 0.0f; - hLPDmem->gc_threshold = 0.0f; - set_f( hLPDmem->dispMem, 0, 8 ); + hLPDmem->syn_flt[M] = 0; + set_f( hLPDmem->mem_syn2_flt, 0.0f, M ); + set_f( hLPDmem->mem_syn_flt, 0.0f, M ); + set_f( hLPDmem->mem_syn1_flt, 0.0f, M ); + hLPDmem->mem_w0_flt = 0.0f; + hLPDmem->tilt_code_flt = 0.0f; + hLPDmem->gc_threshold_flt = 0.0f; + set_f( hLPDmem->dispMem_flt, 0, 8 ); } st->Nb_ACELP_frames = 0; @@ -209,7 +209,7 @@ void core_switching_pre_enc( /* Reset old ACELP buffers */ if ( st->element_mode == EVS_MONO && hLPDmem != NULL ) { - set_f( hLPDmem->old_exc, 0, L_EXC_MEM ); + set_f( hLPDmem->old_exc_flt, 0, L_EXC_MEM ); } if ( st->hBWE_TD != NULL ) @@ -233,11 +233,11 @@ void core_switching_pre_enc( if ( hLPDmem != NULL ) { - hLPDmem->mem_w0 = 0.0f; - hLPDmem->tilt_code = 0.0f; + hLPDmem->mem_w0_flt = 0.0f; + hLPDmem->tilt_code_flt = 0.0f; init_gp_clip( st->clip_var ); - hLPDmem->gc_threshold = 0.0f; - set_f( hLPDmem->dispMem, 0, 8 ); + hLPDmem->gc_threshold_flt = 0.0f; + set_f( hLPDmem->dispMem_flt, 0, 8 ); } st->last_coder_type = GENERIC; diff --git a/lib_enc/dtx.c b/lib_enc/dtx.c index 9153316fa..6f05de234 100644 --- a/lib_enc/dtx.c +++ b/lib_enc/dtx.c @@ -304,22 +304,22 @@ void dtx( } /*More conservative selection of LP-CNG for SCE*/ - if ( st->cng_type == LP_CNG && ( st->bckr_tilt_lt > lp_thresh ) ) + if ( st->cng_type == LP_CNG && ( st->bckr_tilt_lt_flt > lp_thresh ) ) { st->cng_type = FD_CNG; } - else if ( st->cng_type == FD_CNG && ( st->bckr_tilt_lt < fd_thresh ) && ( st->lp_noise > 2.f ) ) + else if ( st->cng_type == FD_CNG && ( st->bckr_tilt_lt_flt < fd_thresh ) && ( st->lp_noise > 2.f ) ) { st->cng_type = LP_CNG; } } else { - if ( st->cng_type == LP_CNG && ( ( st->input_bwidth == NB && st->bckr_tilt_lt > 9.f ) || ( st->input_bwidth > NB && st->bckr_tilt_lt > 45.f ) ) ) + if ( st->cng_type == LP_CNG && ( ( st->input_bwidth == NB && st->bckr_tilt_lt_flt > 9.f ) || ( st->input_bwidth > NB && st->bckr_tilt_lt_flt > 45.f ) ) ) { st->cng_type = FD_CNG; } - else if ( st->cng_type == FD_CNG && ( ( st->input_bwidth == NB && st->bckr_tilt_lt < 2.f ) || ( st->input_bwidth > NB && st->bckr_tilt_lt < 10.f ) ) ) + else if ( st->cng_type == FD_CNG && ( ( st->input_bwidth == NB && st->bckr_tilt_lt_flt < 2.f ) || ( st->input_bwidth > NB && st->bckr_tilt_lt_flt < 10.f ) ) ) { st->cng_type = LP_CNG; } diff --git a/lib_enc/enc_acelp.c b/lib_enc/enc_acelp.c index 8e034e1c7..4122a3193 100644 --- a/lib_enc/enc_acelp.c +++ b/lib_enc/enc_acelp.c @@ -711,7 +711,7 @@ void E_ACELP_4tsearch( float s; int16_t restpulses; - alp = config->alp; /* initial value for energy of all fixed pulses */ + alp = config->alp_flt; /* initial value for energy of all fixed pulses */ for ( k = 0; k < config->nb_pulse; k++ ) { @@ -1262,7 +1262,7 @@ void E_ACELP_innovative_codebook( /* Include fixed-gain pitch contribution into impulse resp. h1[] */ mvr2r( h1, h2, L_SUBFR ); - cb_shape( acelp_cfg->pre_emphasis, acelp_cfg->pitch_sharpening, acelp_cfg->phase_scrambling, acelp_cfg->formant_enh, acelp_cfg->formant_tilt, acelp_cfg->formant_enh_num, acelp_cfg->formant_enh_den, Aq, h2, tilt_code, pitch, L_SUBFR ); + cb_shape( acelp_cfg->pre_emphasis, acelp_cfg->pitch_sharpening, acelp_cfg->phase_scrambling, acelp_cfg->formant_enh, acelp_cfg->formant_tilt, acelp_cfg->formant_enh_num_flt, acelp_cfg->formant_enh_den_flt, Aq, h2, tilt_code, pitch, L_SUBFR ); /* Correlation between target xn2[] and impulse response h1[] */ if ( acelpautoc & 0x01 ) @@ -1313,7 +1313,7 @@ void E_ACELP_innovative_codebook( * - Add the fixed-gain pitch contribution to code[]. * *-------------------------------------------------------*/ - cb_shape( acelp_cfg->pre_emphasis, acelp_cfg->pitch_sharpening, acelp_cfg->phase_scrambling, acelp_cfg->formant_enh, acelp_cfg->formant_tilt, acelp_cfg->formant_enh_num, acelp_cfg->formant_enh_den, Aq, code, tilt_code, pitch, L_SUBFR ); + cb_shape( acelp_cfg->pre_emphasis, acelp_cfg->pitch_sharpening, acelp_cfg->phase_scrambling, acelp_cfg->formant_enh, acelp_cfg->formant_tilt, acelp_cfg->formant_enh_num_flt, acelp_cfg->formant_enh_den_flt, Aq, code, tilt_code, pitch, L_SUBFR ); return; } diff --git a/lib_enc/enc_acelpx.c b/lib_enc/enc_acelpx.c index d8dcf192b..b02f63cc1 100644 --- a/lib_enc/enc_acelpx.c +++ b/lib_enc/enc_acelpx.c @@ -230,7 +230,7 @@ void E_ACELP_4tsearchx( float s; int16_t restpulses; - alp = config->alp; + alp = config->alp_flt; for ( k = 0; k < config->nb_pulse; k++ ) { codvec[k] = ( k & 3 ); diff --git a/lib_enc/enc_amr_wb.c b/lib_enc/enc_amr_wb.c index f90268002..2b78444a3 100644 --- a/lib_enc/enc_amr_wb.c +++ b/lib_enc/enc_amr_wb.c @@ -141,7 +141,7 @@ void encod_amr_wb( mvr2r( &res[i_subfr], &exc[i_subfr], L_SUBFR ); - find_targets( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res, L_SUBFR, p_Aw, TILT_FAC, xn, cn, h1 ); + find_targets( speech, hLPDmem->mem_syn_flt, i_subfr, &hLPDmem->mem_w0_flt, p_Aq, res, L_SUBFR, p_Aw, TILT_FAC, xn, cn, h1 ); /*----------------------------------------------------------------* * Close-loop pitch search and quantization @@ -178,7 +178,7 @@ void encod_amr_wb( * Innovation encoding *-----------------------------------------------------------------*/ - inov_encode( st, st->core_brate, 1, L_FRAME, st->last_L_frame, -1, -1, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h1, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits, L_SUBFR ); + inov_encode( st, st->core_brate, 1, L_FRAME, st->last_L_frame, -1, -1, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h1, hLPDmem->tilt_code_flt, *pt_pitch, xn2, code, y2, &unbits, L_SUBFR ); /*-----------------------------------------------------------------* * Gain encoding @@ -190,13 +190,13 @@ void encod_amr_wb( gp_clip_test_gain_pit( st->element_mode, st->core_brate, gain_pit, st->clip_var ); - hLPDmem->tilt_code = est_tilt( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, L_SUBFR, 0 ); + hLPDmem->tilt_code_flt = est_tilt( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, L_SUBFR, 0 ); /*-----------------------------------------------------------------* * Update memory of the weighting filter *-----------------------------------------------------------------*/ - hLPDmem->mem_w0 = xn[L_SUBFR - 1] - gain_pit * y1[L_SUBFR - 1] - gain_code * y2[L_SUBFR - 1]; + hLPDmem->mem_w0_flt = xn[L_SUBFR - 1] - gain_pit * y1[L_SUBFR - 1] - gain_code * y2[L_SUBFR - 1]; /*-----------------------------------------------------------------* * Find the total excitation @@ -213,7 +213,7 @@ void encod_amr_wb( * Update A(z) filters *-----------------------------------------------------------------*/ - syn_filt( p_Aq, M, &exc[i_subfr], &syn[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 ); + syn_filt( p_Aq, M, &exc[i_subfr], &syn[i_subfr], L_SUBFR, hLPDmem->mem_syn_flt, 1 ); /*-----------------------------------------------------------------* * HF gain modification factors at 23.85 kbps diff --git a/lib_enc/enc_gen_voic.c b/lib_enc/enc_gen_voic.c index 07dc54f77..4c0c4e15d 100644 --- a/lib_enc/enc_gen_voic.c +++ b/lib_enc/enc_gen_voic.c @@ -156,7 +156,7 @@ void encod_gen_voic( mvr2r( &res[i_subfr], &exc[i_subfr], L_SUBFR ); - find_targets( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res, L_SUBFR, p_Aw, st->preemph_fac, xn, cn, h1 ); + find_targets( speech, hLPDmem->mem_syn_flt, i_subfr, &hLPDmem->mem_w0_flt, p_Aq, res, L_SUBFR, p_Aw, st->preemph_fac_flt, xn, cn, h1 ); /*----------------------------------------------------------------* * Close-loop pitch search and quantization @@ -197,7 +197,7 @@ void encod_gen_voic( } /* update long-term pitch gain for speech/music classifier */ - st->hSpMusClas->lowrate_pitchGain = 0.9f * st->hSpMusClas->lowrate_pitchGain + 0.1f * gain_pit; + st->hSpMusClas->lowrate_pitchGain_flt = 0.9f * st->hSpMusClas->lowrate_pitchGain_flt + 0.1f * gain_pit; /*-----------------------------------------------------------------* * Transform-domain contribution (active frames) @@ -212,7 +212,7 @@ void encod_gen_voic( * Innovation encoding *-----------------------------------------------------------------*/ - inov_encode( st, st->core_brate, 0, L_frame, st->last_L_frame, st->coder_type, st->bwidth, st->sharpFlag, i_subfr, -1, p_Aq, gain_pit, cn, exc, h1, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR ); + inov_encode( st, st->core_brate, 0, L_frame, st->last_L_frame, st->coder_type, st->bwidth, st->sharpFlag, i_subfr, -1, p_Aq, gain_pit, cn, exc, h1, hLPDmem->tilt_code_flt, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR ); /*-----------------------------------------------------------------* * Gain encoding @@ -246,7 +246,7 @@ void encod_gen_voic( gp_clip_test_gain_pit( st->element_mode, st->core_brate, gain_pit, st->clip_var ); - hLPDmem->tilt_code = est_tilt( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, L_SUBFR, 0 ); + hLPDmem->tilt_code_flt = est_tilt( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, L_SUBFR, 0 ); /*-----------------------------------------------------------------* * Transform-domain contribution (inactive frames) @@ -261,7 +261,7 @@ void encod_gen_voic( * Update memory of the weighting filter *-----------------------------------------------------------------*/ - hLPDmem->mem_w0 = xn[L_SUBFR - 1] - ( gain_pit * y1[L_SUBFR - 1] ) - ( gain_code * y2[L_SUBFR - 1] ); + hLPDmem->mem_w0_flt = xn[L_SUBFR - 1] - ( gain_pit * y1[L_SUBFR - 1] ) - ( gain_code * y2[L_SUBFR - 1] ); /*-----------------------------------------------------------------* * Construct adaptive part of the excitation @@ -294,11 +294,11 @@ void encod_gen_voic( prep_tbe_exc( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc, gain_preQ, code_preQ, T0, st->coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag ); /*-----------------------------------------------------------------* - * Synthesize speech to update mem_syn[]. + * Synthesize speech to update mem_syn_flt[]. * Update A(z) filters *-----------------------------------------------------------------*/ - syn_filt( p_Aq, M, &exc[i_subfr], &syn[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 ); + syn_filt( p_Aq, M, &exc[i_subfr], &syn[i_subfr], L_SUBFR, hLPDmem->mem_syn_flt, 1 ); p_Aw += ( M + 1 ); p_Aq += ( M + 1 ); @@ -317,7 +317,7 @@ void encod_gen_voic( if ( st->Opt_SC_VBR ) { st->hSC_VBR->prev_ppp_gain_pit = gain_pit; - st->hSC_VBR->prev_tilt_code = hLPDmem->tilt_code; + st->hSC_VBR->prev_tilt_code = hLPDmem->tilt_code_flt; } return; diff --git a/lib_enc/enc_gen_voic_rf.c b/lib_enc/enc_gen_voic_rf.c index c3a6a4f8f..8df1450e5 100644 --- a/lib_enc/enc_gen_voic_rf.c +++ b/lib_enc/enc_gen_voic_rf.c @@ -58,13 +58,13 @@ void reset_rf_indices( { hRF->rf_frame_type = 0; /* since this function is called every frame this will happen even for a SID frame, hence treating it as GSC frame, i.e no RF encoding */ - hRF->rf_mem_w0 = 0; - set_f( hRF->rf_clip_var, 0, 6 ); - hRF->rf_tilt_code = 0; - set_f( hRF->rf_mem_syn2, 0, M ); + hRF->rf_mem_w0_flt = 0; + set_f( hRF->rf_clip_var_flt, 0, 6 ); + hRF->rf_tilt_code_flt = 0; + set_f( hRF->rf_mem_syn2_flt, 0, M ); set_f( hRF->rf_dispMem, 0, 8 ); - hRF->rf_gc_threshold = 0; - set_f( hRF->rf_tilt_buf, 0, NB_SUBFR16k ); + hRF->rf_gc_threshold_flt = 0; + set_f( hRF->rf_tilt_buf_flt, 0, NB_SUBFR16k ); hRF->rf_target_bits = 0; *rf_target_bits_write = 0; @@ -219,7 +219,7 @@ void coder_acelp_rf( * and impulse response of the weighted synthesis filter (h1[]). * *--------------------------------------------------------------------------*/ - find_targets( speech, &syn_rf[i_subfr - M], i_subfr, &( hRF->rf_mem_w0 ), p_Aq, exc_rf, L_SUBFR, p_A, st->preemph_fac, xn, cn, h1 ); + find_targets( speech, &syn_rf[i_subfr - M], i_subfr, &( hRF->rf_mem_w0_flt), p_Aq, exc_rf, L_SUBFR, p_A, st->preemph_fac_flt, xn, cn, h1 ); } /* full frame nelp partial copy encoding */ @@ -239,7 +239,7 @@ void coder_acelp_rf( * or in case of floating point encoder & fixed p. decoder *-----------------------------------------------------------------*/ - clip_gain = gp_clip( st->element_mode, st->core_brate, voicing, i_subfr, coder_type, xn, hRF->rf_clip_var ); + clip_gain = gp_clip( st->element_mode, st->core_brate, voicing, i_subfr, coder_type, xn, hRF->rf_clip_var_flt); /*-----------------------------------------------------------------* * - find unity gain pitch excitation (adaptive codebook entry) * @@ -279,14 +279,14 @@ void coder_acelp_rf( hRF->rf_indx_ltfMode[0][nSubfr] = lp_select; } - g_corr.y1y1 = g_corr2[0]; - g_corr.xy1 = -0.5f * ( g_corr2[1] - 0.01f ) + 0.01f; + g_corr.y1y1_flt = g_corr2[0]; + g_corr.xy1_flt = -0.5f * ( g_corr2[1] - 0.01f ) + 0.01f; } else { gain_pit = 0.f; - g_corr.xy1 = 0.f; - g_corr.y1y1 = 0.f; + g_corr.xy1_flt = 0.f; + g_corr.y1y1_flt = 0.f; set_zero( y1, L_SUBFR ); set_zero( exc_rf + i_subfr, L_SUBFR ); T0 = L_SUBFR; @@ -301,7 +301,7 @@ void coder_acelp_rf( if ( acelp_cfg->fixed_cdk_index[i_subfr / L_SUBFR] >= 0 ) { prm_rf = &hRF->rf_indx_fcb[0][nSubfr]; - E_ACELP_innovative_codebook( exc_rf, T0, T0_frac, T0_res, gain_pit, hRF->rf_tilt_code, acelp_cfg, i_subfr, p_Aq, h1, xn, cn, y1, y2, st->acelp_autocorr, &prm_rf, code, st->L_frame, st->last_L_frame, st->total_brate ); + E_ACELP_innovative_codebook( exc_rf, T0, T0_frac, T0_res, gain_pit, hRF->rf_tilt_code_flt, acelp_cfg, i_subfr, p_Aq, h1, xn, cn, y1, y2, st->acelp_autocorr, &prm_rf, code, st->L_frame, st->last_L_frame, st->total_brate ); } else { @@ -312,11 +312,11 @@ void coder_acelp_rf( if ( i_subfr < ( st->L_frame - L_SUBFR ) ) { E_corr_xy2( xn, y1, y2, g_corr2, L_SUBFR ); - g_corr.y2y2 = 0.01F + g_corr2[2]; - g_corr.xy2 = 0.01F + -0.5f * g_corr2[3]; - g_corr.y1y2 = 0.01F + 0.5f * g_corr2[4]; + g_corr.y2y2_flt = 0.01F + g_corr2[2]; + g_corr.xy2_flt = 0.01F + -0.5f * g_corr2[3]; + g_corr.y1y2_flt = 0.01F + 0.5f * g_corr2[4]; - g_corr.xx = 0.01F + dotp( xn, xn, L_SUBFR ); + g_corr.xx_flt = 0.01F + dotp( xn, xn, L_SUBFR ); /*----------------------------------------------------------------------* * Add Gaussian excitation * @@ -337,19 +337,19 @@ void coder_acelp_rf( encode_acelp_gains( code, acelp_cfg->gains_mode[i_subfr / L_SUBFR], Es_pred_rf, clip_gain, &g_corr, &gain_pit, &gain_code, &prm_rf, &past_gcode, &gain_inov, L_SUBFR, code2, &gain_code2, st->flag_noisy_speech_snr ); } - gp_clip_test_gain_pit( st->element_mode, st->core_brate, gain_pit, hRF->rf_clip_var ); + gp_clip_test_gain_pit( st->element_mode, st->core_brate, gain_pit, hRF->rf_clip_var_flt); /*----------------------------------------------------------* * - voice factor (for codebook tilt sharpening) * *----------------------------------------------------------*/ - hRF->rf_tilt_code = est_tilt( exc_rf + i_subfr, gain_pit, code, gain_code, &voice_fac, L_SUBFR, acelp_cfg->voice_tilt ); + hRF->rf_tilt_code_flt = est_tilt( exc_rf + i_subfr, gain_pit, code, gain_code, &voice_fac, L_SUBFR, acelp_cfg->voice_tilt ); /*-----------------------------------------------------------------* * Update memory of the weighting filter *-----------------------------------------------------------------*/ - hRF->rf_mem_w0 = xn[L_SUBFR - 1] - gain_pit * y1[L_SUBFR - 1] - gain_code * y2[L_SUBFR - 1] - gain_code2 * y22[L_SUBFR - 1]; + hRF->rf_mem_w0_flt = xn[L_SUBFR - 1] - gain_pit * y1[L_SUBFR - 1] - gain_code * y2[L_SUBFR - 1] - gain_code2 * y22[L_SUBFR - 1]; /*-------------------------------------------------------* * - Find the total excitation. * @@ -366,7 +366,7 @@ void coder_acelp_rf( * Enhance the excitation * *---------------------------------------------------------*/ - enhancer( MODE2, -1, acelp_cfg->fixed_cdk_index[i_subfr / L_SUBFR], 0, coder_type, st->L_frame, voice_fac, stab_fac, past_gcode, gain_inov, &hRF->rf_gc_threshold, code, exc2, gain_pit, hRF->rf_dispMem ); + enhancer( MODE2, -1, acelp_cfg->fixed_cdk_index[i_subfr / L_SUBFR], 0, coder_type, st->L_frame, voice_fac, stab_fac, past_gcode, gain_inov, &hRF->rf_gc_threshold_flt, code, exc2, gain_pit, hRF->rf_dispMem ); } } @@ -376,7 +376,7 @@ void coder_acelp_rf( * - compute the synthesis speech * *----------------------------------------------------------*/ - syn_filt( p_Aq, M, exc2, &syn2[i_subfr], L_SUBFR, hRF->rf_mem_syn2, 1 ); + syn_filt( p_Aq, M, exc2, &syn2[i_subfr], L_SUBFR, hRF->rf_mem_syn2_flt, 1 ); syn_filt( p_Aq, M, &exc_rf[i_subfr], &syn_rf[i_subfr], L_SUBFR, &syn_rf[i_subfr - M], 0 ); diff --git a/lib_enc/enc_higher_acelp.c b/lib_enc/enc_higher_acelp.c index bd68e5d68..2c8e85dda 100644 --- a/lib_enc/enc_higher_acelp.c +++ b/lib_enc/enc_higher_acelp.c @@ -338,7 +338,7 @@ static void find_cn( mvr2r( xn, tmp_fl + M, L_SUBFR ); tmp = 0.0f; - preemph( tmp_fl + M, PREEMPH_FAC_16k, L_SUBFR, &tmp ); + preemph( tmp_fl + M, PREEMPH_FAC_16k_FLT, L_SUBFR, &tmp ); syn_filt( Ap, M, tmp_fl + M, tmp_fl + M, L_SUBFR, tmp_fl, 0 ); residu( p_Aq, M, tmp_fl + M, cn, L_SUBFR ); diff --git a/lib_enc/enc_nelp.c b/lib_enc/enc_nelp.c index 253a97a9b..393ca38dc 100644 --- a/lib_enc/enc_nelp.c +++ b/lib_enc/enc_nelp.c @@ -77,9 +77,9 @@ void encod_nelp( { if ( hSC_VBR->last_nelp_mode == 0 ) { - set_f( hSC_VBR->nelp_lp_fit_mem, 0, NELP_LP_ORDER * 2 ); + set_f( hSC_VBR->nelp_lp_fit_mem_flt, 0, NELP_LP_ORDER * 2 ); } - polezero_filter( res, res, L_FRAME, num_nelp_lp, den_nelp_lp, NELP_LP_ORDER, hSC_VBR->nelp_lp_fit_mem ); /*16-Q of filter coeff*/ + polezero_filter( res, res, L_FRAME, num_nelp_lp, den_nelp_lp, NELP_LP_ORDER, hSC_VBR->nelp_lp_fit_mem_flt); /*16-Q of filter coeff*/ } p_Aw = Aw; @@ -94,7 +94,7 @@ void encod_nelp( *----------------------------------------------------------------*/ mvr2r( &res[i_subfr], &exc[i_subfr], L_SUBFR ); - find_targets( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res, L_SUBFR, p_Aw, TILT_FAC, xn, NULL, h1 ); + find_targets( speech, hLPDmem->mem_syn_flt, i_subfr, &hLPDmem->mem_w0_flt, p_Aq, res, L_SUBFR, p_Aw, TILT_FAC, xn, NULL, h1 ); if ( i_subfr == 0 ) { @@ -108,11 +108,11 @@ void encod_nelp( *tmp_noise = 0; /*-----------------------------------------------------------------* - * Synthesize speech to update mem_syn[]. + * Synthesize speech to update mem_syn_flt[]. * Update A(z) filters *-----------------------------------------------------------------*/ - syn_filt( p_Aq, M, &exc_nelp[i_subfr], &synth[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 ); + syn_filt( p_Aq, M, &exc_nelp[i_subfr], &synth[i_subfr], L_SUBFR, hLPDmem->mem_syn_flt, 1 ); p_Aw += ( M + 1 ); p_Aq += ( M + 1 ); @@ -123,22 +123,22 @@ void encod_nelp( mvr2r( exc_nelp, exc, L_FRAME ); /*-----------------------------------------------------------------* - * Updates: last value of new target is stored in mem_w0 + * Updates: last value of new target is stored in mem_w0_flt *-----------------------------------------------------------------*/ - hLPDmem->mem_w0 = xn[L_SUBFR - 1] - ( exc[L_FRAME - 1] ); - hLPDmem->tilt_code = 0.0f; /* purely unvoiced */ - hSC_VBR->prev_tilt_code = hLPDmem->tilt_code; + hLPDmem->mem_w0_flt = xn[L_SUBFR - 1] - ( exc[L_FRAME - 1] ); + hLPDmem->tilt_code_flt = 0.0f; /* purely unvoiced */ + hSC_VBR->prev_tilt_code = hLPDmem->tilt_code_flt; mvr2r( exc, exc2, L_FRAME ); hSC_VBR->prev_ppp_gain_pit = 0.0; - hLPDmem->dispMem[0] = 0; - hLPDmem->dispMem[2] = hSC_VBR->prev_ppp_gain_pit; + hLPDmem->dispMem_flt[0] = 0; + hLPDmem->dispMem_flt[2] = hSC_VBR->prev_ppp_gain_pit; for ( j = 3; j < 7; j++ ) { - hLPDmem->dispMem[j] = hLPDmem->dispMem[j - 1]; + hLPDmem->dispMem_flt[j] = hLPDmem->dispMem_flt[j - 1]; } interp_code_5over2( exc2, bwe_exc, L_FRAME ); diff --git a/lib_enc/enc_pit_exc.c b/lib_enc/enc_pit_exc.c index b640e0b41..8decea877 100644 --- a/lib_enc/enc_pit_exc.c +++ b/lib_enc/enc_pit_exc.c @@ -191,7 +191,7 @@ void enc_pit_exc( mvr2r( &res[i_subfr], &exc[i_subfr], L_subfr ); - find_targets( speech, st->hGSCEnc->mem_syn_tmp, i_subfr, &st->hGSCEnc->mem_w0_tmp, p_Aq, res, L_subfr, p_Aw, st->preemph_fac, xn, cn, h1 ); + find_targets( speech, st->hGSCEnc->mem_syn_tmp, i_subfr, &st->hGSCEnc->mem_w0_tmp, p_Aq, res, L_subfr, p_Aw, st->preemph_fac_flt, xn, cn, h1 ); /*----------------------------------------------------------------* * Close-loop pitch search and quantization @@ -226,7 +226,7 @@ void enc_pit_exc( } /* update long-term pitc hgain for speech/music classifier */ - st->hSpMusClas->lowrate_pitchGain = 0.9f * st->hSpMusClas->lowrate_pitchGain + 0.1f * gain_pit; + st->hSpMusClas->lowrate_pitchGain_flt = 0.9f * st->hSpMusClas->lowrate_pitchGain_flt + 0.1f * gain_pit; gpit_tmp = gain_pit; @@ -249,7 +249,7 @@ void enc_pit_exc( * Innovation encoding *-----------------------------------------------------------------*/ - inov_encode( st, st->core_brate, 0, st->L_frame, st->last_L_frame, GENERIC, st->bwidth, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h1, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &i, 2 * L_SUBFR ); + inov_encode( st, st->core_brate, 0, st->L_frame, st->last_L_frame, GENERIC, st->bwidth, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h1, hLPDmem->tilt_code_flt, *pt_pitch, xn2, code, y2, &i, 2 * L_SUBFR ); /*-----------------------------------------------------------------* * Gain encoding @@ -263,7 +263,7 @@ void enc_pit_exc( * Innovation & gain encoding *-----------------------------------------------------------------*/ - inov_encode( st, Local_BR, 0, st->L_frame, st->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, gain_pit, cn, exc, h1, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR ); + inov_encode( st, Local_BR, 0, st->L_frame, st->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, gain_pit, cn, exc, h1, hLPDmem->tilt_code_flt, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR ); gain_enc_mless( hBstr, st->acelp_cfg.gains_mode, st->element_mode, st->L_frame, i_subfr, -1, xn, y1, y2, code, Es_pred, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); } @@ -272,11 +272,11 @@ void enc_pit_exc( if ( use_fcb != 0 ) { - hLPDmem->tilt_code = est_tilt( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, L_subfr, 0 ); + hLPDmem->tilt_code_flt = est_tilt( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, L_subfr, 0 ); } else { - hLPDmem->tilt_code = 0.0f; + hLPDmem->tilt_code_flt = 0.0f; } /*-----------------------------------------------------------------* diff --git a/lib_enc/enc_ppp.c b/lib_enc/enc_ppp.c index 51e353dfe..fb1d9e51c 100644 --- a/lib_enc/enc_ppp.c +++ b/lib_enc/enc_ppp.c @@ -96,7 +96,7 @@ ivas_error encod_ppp( mvr2r( &res[i_subfr], &exc[i_subfr], L_SUBFR ); - find_targets( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res, L_SUBFR, p_Aw, TILT_FAC, xn, NULL, h1 ); + find_targets( speech, hLPDmem->mem_syn_flt, i_subfr, &hLPDmem->mem_w0_flt, p_Aq, res, L_SUBFR, p_Aw, TILT_FAC, xn, NULL, h1 ); /* call voiced encoder at this point */ if ( i_subfr == 0 ) /* generate the L_FRAME exc */ @@ -136,11 +136,11 @@ ivas_error encod_ppp( gp_clip_test_gain_pit( st->element_mode, st->core_brate, hSC_VBR->prev_ppp_gain_pit, st->clip_var ); /*-----------------------------------------------------------------* - * Synthesize speech to update mem_syn[]. + * Synthesize speech to update mem_syn_flt[]. * Update A(z) filters *-----------------------------------------------------------------*/ - syn_filt( p_Aq, M, &excQ_ppp[i_subfr], &synth[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 ); + syn_filt( p_Aq, M, &excQ_ppp[i_subfr], &synth[i_subfr], L_SUBFR, hLPDmem->mem_syn_flt, 1 ); p_Aw += ( M + 1 ); p_Aq += ( M + 1 ); @@ -176,21 +176,21 @@ ivas_error encod_ppp( mvr2r( excQ_ppp, exc, L_FRAME ); /*-----------------------------------------------------------------* - * Updates: last value of new target is stored in mem_w0 + * Updates: last value of new target is stored in mem_w0_flt *-----------------------------------------------------------------*/ - hLPDmem->mem_w0 = xn[L_SUBFR - 1] - ( exc[L_FRAME - 1] ); + hLPDmem->mem_w0_flt = xn[L_SUBFR - 1] - ( exc[L_FRAME - 1] ); mvr2r( exc, exc2, L_FRAME ); - hLPDmem->dispMem[0] = 2; - hLPDmem->dispMem[2] = hSC_VBR->prev_ppp_gain_pit; + hLPDmem->dispMem_flt[0] = 2; + hLPDmem->dispMem_flt[2] = hSC_VBR->prev_ppp_gain_pit; for ( k = 3; k < 7; k++ ) { - hLPDmem->dispMem[k] = hLPDmem->dispMem[k - 1]; + hLPDmem->dispMem_flt[k] = hLPDmem->dispMem_flt[k - 1]; } - hLPDmem->tilt_code = hSC_VBR->prev_tilt_code; + hLPDmem->tilt_code_flt = hSC_VBR->prev_tilt_code; mvr2r( pitch, pitch_buf, NB_SUBFR ); pitch_buf[NB_SUBFR16k - 1] = pitch[NB_SUBFR - 1]; interp_code_5over2( exc2, bwe_exc, L_FRAME ); @@ -199,7 +199,7 @@ ivas_error encod_ppp( hSC_VBR->rate_control = rate_ctrl; - set_f( hSC_VBR->nelp_lp_fit_mem, 0, NELP_LP_ORDER * 2 ); + set_f( hSC_VBR->nelp_lp_fit_mem_flt, 0, NELP_LP_ORDER * 2 ); return error; } diff --git a/lib_enc/enc_prm.c b/lib_enc/enc_prm.c index 41a211fbf..92dc8268b 100644 --- a/lib_enc/enc_prm.c +++ b/lib_enc/enc_prm.c @@ -465,7 +465,7 @@ void writeTCXparam( if ( post_part ) { - hm_size = (int16_t) ( 2.0f * st->hTcxCfg->bandwidth * (float) lg ); + hm_size = (int16_t) ( 2.0f * st->hTcxCfg->bandwidth_flt * (float) lg ); if ( st->hTcxEnc->tcx_lpc_shaped_ari && last_core != ACELP_CORE && core == TCX_20_CORE ) { diff --git a/lib_enc/enc_tran.c b/lib_enc/enc_tran.c index 6bd536aae..c6e19a1ad 100644 --- a/lib_enc/enc_tran.c +++ b/lib_enc/enc_tran.c @@ -139,7 +139,7 @@ int16_t encod_tran( mvr2r( &res[i_subfr], &exc[i_subfr], L_SUBFR ); - find_targets( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res, L_SUBFR, p_Aw, st->preemph_fac, xn, cn, h1 ); + find_targets( speech, hLPDmem->mem_syn_flt, i_subfr, &hLPDmem->mem_w0_flt, p_Aq, res, L_SUBFR, p_Aw, st->preemph_fac_flt, xn, cn, h1 ); /*-----------------------------------------------------------------* * TC: subframe determination & @@ -161,7 +161,7 @@ int16_t encod_tran( * ACELP codebook search + pitch sharpening *-----------------------------------------------------------------*/ - inov_encode( st, st->core_brate, 0, L_frame, st->last_L_frame, st->coder_type, st->bwidth, st->sharpFlag, i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc, h1, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR ); + inov_encode( st, st->core_brate, 0, L_frame, st->last_L_frame, st->coder_type, st->bwidth, st->sharpFlag, i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc, h1, hLPDmem->tilt_code_flt, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR ); if ( ( L_frame == L_FRAME16k ) && ( tc_subfr == 0 ) && ( i_subfr == L_SUBFR ) && ( T0 == 2 * L_SUBFR ) ) { @@ -199,13 +199,13 @@ int16_t encod_tran( gp_clip_test_gain_pit( st->element_mode, st->core_brate, gain_pit, st->clip_var ); - hLPDmem->tilt_code = est_tilt( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, L_SUBFR, 0 ); + hLPDmem->tilt_code_flt = est_tilt( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, L_SUBFR, 0 ); /*-----------------------------------------------------------------* * Update memory of the weighting filter *-----------------------------------------------------------------*/ - hLPDmem->mem_w0 = xn[L_SUBFR - 1] - ( gain_pit * y1[L_SUBFR - 1] ) - ( gain_code * y2[L_SUBFR - 1] ); + hLPDmem->mem_w0_flt = xn[L_SUBFR - 1] - ( gain_pit * y1[L_SUBFR - 1] ) - ( gain_code * y2[L_SUBFR - 1] ); /*-----------------------------------------------------------------* * Construct adaptive part of the excitation @@ -238,11 +238,11 @@ int16_t encod_tran( prep_tbe_exc( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc, gain_preQ, code_preQ, T0, st->coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag ); /*-----------------------------------------------------------------* - * Synthesize speech to update mem_syn[]. + * Synthesize speech to update mem_syn_flt[]. * Update A(z) filters *-----------------------------------------------------------------*/ - syn_filt( p_Aq, M, &exc[i_subfr], &syn[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 ); + syn_filt( p_Aq, M, &exc[i_subfr], &syn[i_subfr], L_SUBFR, hLPDmem->mem_syn_flt, 1 ); p_Aw += ( M + 1 ); p_Aq += ( M + 1 ); @@ -335,7 +335,7 @@ int16_t encod_tran( if ( st->Opt_SC_VBR ) { st->hSC_VBR->prev_ppp_gain_pit = gain_pit; - st->hSC_VBR->prev_tilt_code = hLPDmem->tilt_code; + st->hSC_VBR->prev_tilt_code = hLPDmem->tilt_code_flt; } return tc_subfr; diff --git a/lib_enc/enc_uv.c b/lib_enc/enc_uv.c index 2ca7ecfdc..6207c0ac7 100644 --- a/lib_enc/enc_uv.c +++ b/lib_enc/enc_uv.c @@ -121,7 +121,7 @@ void encod_unvoiced( mvr2r( &res[i_subfr], &exc[i_subfr], L_SUBFR ); - find_targets( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res, L_SUBFR, p_Aw, st->preemph_fac, xn, cn, h1 ); + find_targets( speech, hLPDmem->mem_syn_flt, i_subfr, &hLPDmem->mem_w0_flt, p_Aq, res, L_SUBFR, p_Aw, st->preemph_fac_flt, xn, cn, h1 ); if ( !uc_two_stage_flag ) { @@ -129,7 +129,7 @@ void encod_unvoiced( * Unvoiced subframe processing *----------------------------------------------------------------*/ - *pt_pitch = gaus_encode( st, i_subfr, h1, xn, exc, &hLPDmem->mem_w0, st->clip_var, &hLPDmem->tilt_code, code, &gain_code, y2, &gain_inov, &voice_fac, &gain_pit, &norm_gain_code ); + *pt_pitch = gaus_encode( st, i_subfr, h1, xn, exc, &hLPDmem->mem_w0_flt, st->clip_var, &hLPDmem->tilt_code_flt, code, &gain_code, y2, &gain_inov, &voice_fac, &gain_pit, &norm_gain_code ); } else { @@ -153,14 +153,14 @@ void encod_unvoiced( * Innovation encoding *-----------------------------------------------------------------*/ - inov_encode( st, st->core_brate, 0, L_FRAME, st->last_L_frame, UNVOICED, st->bwidth, 1, i_subfr, -1, p_Aq, gain_pit, cn, exc, h1, hLPDmem->tilt_code, *pt_pitch, xn, code, y2, &unbits_PI, L_SUBFR ); + inov_encode( st, st->core_brate, 0, L_FRAME, st->last_L_frame, UNVOICED, st->bwidth, 1, i_subfr, -1, p_Aq, gain_pit, cn, exc, h1, hLPDmem->tilt_code_flt, *pt_pitch, xn, code, y2, &unbits_PI, L_SUBFR ); E_corr_xy2( xn, y1, y2, g_corr2, L_SUBFR ); - g_corr.y2y2 = 0.01F + g_corr2[2]; - g_corr.xy2 = 0.01F + -0.5f * g_corr2[3]; - g_corr.y1y2 = 0.01F + 0.5f * g_corr2[4]; + g_corr.y2y2_flt = 0.01F + g_corr2[2]; + g_corr.xy2_flt = 0.01F + -0.5f * g_corr2[3]; + g_corr.y1y2_flt = 0.01F + 0.5f * g_corr2[4]; - g_corr.xx = 0.01F + dotp( xn, xn, L_SUBFR ); + g_corr.xx_flt = 0.01F + dotp( xn, xn, L_SUBFR ); /*----------------------------------------------------------------------* * Add Gaussian excitation @@ -168,11 +168,11 @@ void encod_unvoiced( assert( gain_pit == 0.f ); - gauss_L2( h1, code2, y2, y22, &gain_code2, g_corr2, hLPDmem->tilt_code, p_Aq, FORMANT_SHARPENING_G1, &( st->seed_acelp ) ); + gauss_L2( h1, code2, y2, y22, &gain_code2, g_corr2, hLPDmem->tilt_code_flt, p_Aq, FORMANT_SHARPENING_G1_FLT, &( st->seed_acelp ) ); - g_corr.xy1 = 0.f; - g_corr.y1y1 = g_corr2[0]; - g_corr.y1y2 = g_corr2[4]; + g_corr.xy1_flt = 0.f; + g_corr.y1y1_flt = g_corr2[0]; + g_corr.y1y2_flt = g_corr2[4]; /*-----------------------------------------------------------------* * Gain encoding @@ -188,13 +188,13 @@ void encod_unvoiced( * - voice factor (for codebook tilt sharpening) * *----------------------------------------------------------*/ - hLPDmem->tilt_code = est_tilt( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, L_SUBFR, 0 ); + hLPDmem->tilt_code_flt = est_tilt( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, L_SUBFR, 0 ); /*-----------------------------------------------------------------* * Update memory of the weighting filter *-----------------------------------------------------------------*/ - hLPDmem->mem_w0 = xn[L_SUBFR - 1] - gain_code * y2[L_SUBFR - 1] - gain_code2 * y22[L_SUBFR - 1]; + hLPDmem->mem_w0_flt = xn[L_SUBFR - 1] - gain_code * y2[L_SUBFR - 1] - gain_code2 * y22[L_SUBFR - 1]; /*-------------------------------------------------------* * - Find the total excitation. * @@ -218,11 +218,11 @@ void encod_unvoiced( } /*-----------------------------------------------------------------* - * Synthesize speech to update mem_syn[]. + * Synthesize speech to update mem_syn_flt[]. * Update A(z) filters *-----------------------------------------------------------------*/ - syn_filt( p_Aq, M, &exc[i_subfr], &syn[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 ); + syn_filt( p_Aq, M, &exc[i_subfr], &syn[i_subfr], L_SUBFR, hLPDmem->mem_syn_flt, 1 ); p_Aw += ( M + 1 ); p_Aq += ( M + 1 ); @@ -233,7 +233,7 @@ void encod_unvoiced( if ( st->Opt_SC_VBR ) { st->hSC_VBR->prev_ppp_gain_pit = gain_pit; - st->hSC_VBR->prev_tilt_code = hLPDmem->tilt_code; + st->hSC_VBR->prev_tilt_code = hLPDmem->tilt_code_flt; } return; diff --git a/lib_enc/evs_enc.c b/lib_enc/evs_enc.c index 7ae9a30bc..f6fdee93f 100644 --- a/lib_enc/evs_enc.c +++ b/lib_enc/evs_enc.c @@ -150,7 +150,7 @@ ivas_error evs_enc( * HP filtering *----------------------------------------------------------------*/ - hp20( st->input, input_frame, mem_hp20_in, st->input_Fs ); + hp20_flt( st->input, input_frame, mem_hp20_in, st->input_Fs ); /*----------------------------------------------------------------* * Updates in case of AMR-WB IO mode -> EVS primary mode switching @@ -183,10 +183,10 @@ ivas_error evs_enc( if ( ( st->total_brate > ACELP_24k40 && st->total_brate < HQ_96k ) || ( st->total_brate == ACELP_24k40 && st->bwidth >= WB ) ) { st->L_frame = L_FRAME16k; - st->gamma = GAMMA16k; - st->preemph_fac = PREEMPH_FAC_16k; + st->gamma_flt = GAMMA16k_FLT; + st->preemph_fac_flt = PREEMPH_FAC_16k_FLT; - weight_a_subfr( NB_SUBFR16k, A, Aw, GAMMA16k, M ); + weight_a_subfr( NB_SUBFR16k, A, Aw, GAMMA16k_FLT, M ); if ( st->last_L_frame == L_FRAME && st->ini_frame != 0 ) { @@ -197,8 +197,8 @@ ivas_error evs_enc( else { st->L_frame = L_FRAME; - st->gamma = GAMMA1; - st->preemph_fac = PREEMPH_FAC; + st->gamma_flt = GAMMA1_FLT; + st->preemph_fac_flt = PREEMPH_FAC_FLT; } st->sr_core = st->L_frame * FRAMES_PER_SEC; @@ -438,7 +438,7 @@ ivas_error evs_enc( st->tec_flag = 0; st->hTECEnc->corrFlag = 0; } - st->tfa_flag = tfaEnc_TBE( st->tfa_enr, st->last_core, st->voicing, pitch_buf ); + st->tfa_flag = tfaEnc_TBE( st->tfa_enr_flt, st->last_core, st->voicing, pitch_buf ); set_TEC_TFA_code( st->hTECEnc->corrFlag, &st->tec_flag, &st->tfa_flag ); } else diff --git a/lib_enc/ext_sig_ana.c b/lib_enc/ext_sig_ana.c index 6488407e3..74b09d323 100644 --- a/lib_enc/ext_sig_ana.c +++ b/lib_enc/ext_sig_ana.c @@ -108,7 +108,7 @@ void core_signal_analysis_high_bitrate( if ( st->tcxonly && st->element_mode != IVAS_CPE_MDCT ) { /* Copy Samples */ - mvr2r( new_samples, st->new_speech_enc, L_frame ); + mvr2r( new_samples, st->new_speech_enc_flt, L_frame ); } /*--------------------------------------------------------------* @@ -117,18 +117,18 @@ void core_signal_analysis_high_bitrate( if ( st->element_mode == IVAS_CPE_DFT ) { - tcx_ltp_encode( st, hTcxEnc->tcxMode, L_frame, st->wspeech_enc, NULL, st->wspeech_enc, T_op, ¶m_core[1 + NOISE_FILL_RANGES], ltpBits, NULL, disable_ltp, st->element_mode ); + tcx_ltp_encode( st, hTcxEnc->tcxMode, L_frame, st->wspeech_enc_flt, NULL, st->wspeech_enc_flt, T_op, ¶m_core[1 + NOISE_FILL_RANGES], ltpBits, NULL, disable_ltp, st->element_mode ); } else if ( st->element_mode != IVAS_CPE_MDCT ) { - tcx_ltp_encode( st, hTcxEnc->tcxMode, L_frame, st->speech_enc + st->encoderLookahead_enc, hTcxEnc->speech_ltp + st->encoderLookahead_enc, st->speech_enc + st->encoderLookahead_enc, T_op, ¶m_core[1 + NOISE_FILL_RANGES], ltpBits, NULL, disable_ltp, st->element_mode ); + tcx_ltp_encode( st, hTcxEnc->tcxMode, L_frame, st->speech_enc_flt + st->encoderLookahead_enc, hTcxEnc->speech_ltp_flt + st->encoderLookahead_enc, st->speech_enc_flt + st->encoderLookahead_enc, T_op, ¶m_core[1 + NOISE_FILL_RANGES], ltpBits, NULL, disable_ltp, st->element_mode ); } if ( st->tcxonly && st->element_mode != IVAS_CPE_MDCT ) { - mvr2r( st->speech_enc + st->encoderLookahead_enc, st->new_speech_enc_pe, L_frame ); + mvr2r( st->speech_enc_flt + st->encoderLookahead_enc, st->new_speech_enc_pe_flt, L_frame ); - preemph( st->new_speech_enc_pe, st->preemph_fac, L_frame, &( st->mem_preemph_enc ) ); + preemph( st->new_speech_enc_pe_flt, st->preemph_fac_flt, L_frame, &( st->mem_preemph_enc_flt) ); } if ( hTcxEnc->tcxMode == TCX_10 ) @@ -209,7 +209,7 @@ void core_signal_analysis_high_bitrate( if ( transform_type[frameno] == TCX_20 && st->hTcxCfg->tcx_last_overlap_mode != TRANSITION_OVERLAP ) { - wtda( hTcxEnc->new_speech_TCX, tcx20Win, NULL, overlap_mode[frameno], overlap_mode[frameno + 1], L_frameTCX ); + wtda( hTcxEnc->new_speech_TCX_flt, tcx20Win, NULL, overlap_mode[frameno], overlap_mode[frameno + 1], L_frameTCX ); if ( windowed_samples != NULL ) /* store overlap data for later */ { @@ -220,15 +220,15 @@ void core_signal_analysis_high_bitrate( if ( st->element_mode != IVAS_CPE_MDCT ) { /* Windowing of the 2xTCX5 subframes or 1xTCX10 or 1xTCX20 */ - WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno], overlap_mode[frameno + 1] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX[frameno * tcx10SizeFB], &L_subframe, mdstWin, 1, 1 ); + WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno], overlap_mode[frameno + 1] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX_flt[frameno * tcx10SizeFB], &L_subframe, mdstWin, 1, 1 ); } } else { /* Windowing of the 2xTCX5 subframes or 1xTCX10 or 1xTCX20 */ - WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno], overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX[frameno * tcx10SizeFB], &L_subframe, tcx20Win, st->element_mode != IVAS_CPE_MDCT, 1 ); + WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno], overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX_flt[frameno * tcx10SizeFB], &L_subframe, tcx20Win, st->element_mode != IVAS_CPE_MDCT, 1 ); - if ( windowed_samples != NULL ) /* save windowed speech_TCX samples */ + if ( windowed_samples != NULL ) /* save windowed speech_TCX_flt samples */ { assert( L_subframe + ( left_overlap + right_overlap ) / 2 < 2 * L_FRAME_MAX / nSubframes - L_FRAME_MAX / 8 ); windowed_samples[frameno * L_FRAME_MAX + 0] = (float) overlap_mode[frameno]; @@ -249,7 +249,7 @@ void core_signal_analysis_high_bitrate( { for ( i = minWindowLen; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ { - tcx20Win[left_overlap + i] -= hTcxEnc->speech_TCX[-1 - i] * st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] * st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i]; + tcx20Win[left_overlap + i] -= hTcxEnc->speech_TCX_flt[-1 - i] * st->hTcxCfg->tcx_aldo_window_1_FB_flt[left_overlap / 2 + minWindowLen - i] * st->hTcxCfg->tcx_mdct_window_minimumFB_flt[minWindowLen - i]; } } @@ -293,7 +293,7 @@ void core_signal_analysis_high_bitrate( { for ( i = minWindowLen; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ { - tcx20Win[left_overlap + i] -= hTcxEnc->speech_TCX[-1 - i] * st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] * st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i]; + tcx20Win[left_overlap + i] -= hTcxEnc->speech_TCX_flt[-1 - i] * st->hTcxCfg->tcx_aldo_window_1_FB_flt[left_overlap / 2 + minWindowLen - i] * st->hTcxCfg->tcx_mdct_window_minimumFB_flt[minWindowLen - i]; } } @@ -323,12 +323,12 @@ void core_signal_analysis_high_bitrate( if ( transform_type[frameno] == TCX_20 && st->hTcxCfg->tcx_last_overlap_mode != TRANSITION_OVERLAP ) { - wtda_ext( hTcxEnc->new_speech_TCX, mdstWin, overlap_mode[frameno], overlap_mode[frameno + 1], L_frameTCX, 3 ); + wtda_ext( hTcxEnc->new_speech_TCX_flt, mdstWin, overlap_mode[frameno], overlap_mode[frameno + 1], L_frameTCX, 3 ); } else { /* Windowing for the MDST */ - WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno], overlap_mode[frameno + 1] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX[frameno * tcx10SizeFB], &L_subframe, mdstWin, 0, 1 ); + WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno], overlap_mode[frameno + 1] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX_flt[frameno * tcx10SizeFB], &L_subframe, mdstWin, 0, 1 ); } if ( transform_type[frameno] == TCX_5 ) @@ -343,7 +343,7 @@ void core_signal_analysis_high_bitrate( { for ( i = minWindowLen; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ { - mdstWin[left_overlap + i] += hTcxEnc->speech_TCX[-1 - i] * st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] * st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i]; + mdstWin[left_overlap + i] += hTcxEnc->speech_TCX_flt[-1 - i] * st->hTcxCfg->tcx_aldo_window_1_FB_flt[left_overlap / 2 + minWindowLen - i] * st->hTcxCfg->tcx_mdct_window_minimumFB_flt[minWindowLen - i]; } } @@ -383,7 +383,7 @@ void core_signal_analysis_high_bitrate( { for ( i = minWindowLen; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ { - mdstWin[left_overlap + i] += hTcxEnc->speech_TCX[-1 - i] * st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] * st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i]; + mdstWin[left_overlap + i] += hTcxEnc->speech_TCX_flt[-1 - i] * st->hTcxCfg->tcx_aldo_window_1_FB_flt[left_overlap / 2 + minWindowLen - i] * st->hTcxCfg->tcx_mdct_window_minimumFB_flt[minWindowLen - i]; } } @@ -424,7 +424,7 @@ void core_signal_analysis_high_bitrate( if ( st->tcxonly ) { - HBAutocorrelation( st->hTcxCfg, overlap_mode[frameno] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno], overlap_mode[frameno + 1] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno + 1], &st->speech_enc_pe[frameno * tcx10Size], L_frame / nSubframes, r ); + HBAutocorrelation( st->hTcxCfg, overlap_mode[frameno] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno], overlap_mode[frameno + 1] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno + 1], &st->speech_enc_pe_flt[frameno * tcx10Size], L_frame / nSubframes, r ); adapt_lag_wind( r, M, alw_pitch_lag_12k8[frameno], alw_voicing[frameno], st->sr_core ); diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c index 12019f480..214a15cf0 100644 --- a/lib_enc/fd_cng_enc.c +++ b/lib_enc/fd_cng_enc.c @@ -508,7 +508,7 @@ void FdCng_encodeSID( float v[32], e; int16_t indices[32]; float w[32]; - float preemph_fac = st->preemph_fac; + float preemph_fac = st->preemph_fac_flt; float *invTrfMatrix; float tmpRAM[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; @@ -565,12 +565,12 @@ void FdCng_encodeSID( } create_IDCT_N_Matrix( invTrfMatrix, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM ) / ( sizeof( float ) ) ); msvq_enc( cdk_37bits_ivas, NULL, NULL, v, levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, w, N, FD_CNG_maxN_37bits, 1, invTrfMatrix, indices ); - msvq_dec( cdk_37bits_ivas, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix, v, NULL ); + msvq_dec_float( cdk_37bits_ivas, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix, v, NULL ); } else { /* EVS_MONO tables */ msvq_enc( cdk_37bits, NULL, NULL, v, levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, w, N, FD_CNG_maxN_37bits, 0, NULL, indices ); - msvq_dec( cdk_37bits, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 0, NULL, v, NULL ); + msvq_dec_float( cdk_37bits, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 0, NULL, v, NULL ); } @@ -618,12 +618,12 @@ void FdCng_encodeSID( /* NB last band energy compensation */ if ( hFdCngCom->CngBandwidth == NB ) { - hFdCngCom->sidNoiseEst[N - 1] *= NB_LAST_BAND_SCALE; + hFdCngCom->sidNoiseEst[N - 1] *= NB_LAST_BAND_SCALE_FLT; } if ( hFdCngCom->CngBandwidth == SWB && hFdCngCom->CngBitrate <= ACELP_13k20 ) { - hFdCngCom->sidNoiseEst[N - 1] *= SWB_13k2_LAST_BAND_SCALE; + hFdCngCom->sidNoiseEst[N - 1] *= SWB_13k2_LAST_BAND_SCALE_FLT; } /* Write bitstream */ @@ -680,7 +680,7 @@ void generate_comfort_noise_enc( float scale = 1.f; float *fftBuffer = hFdCngCom->fftBuffer; float *timeDomainOutput = hFdCngCom->timeDomainBuffer; - float preemph_fac = st->preemph_fac; + float preemph_fac = st->preemph_fac_flt; int16_t tcx_transition = 0; float enr; @@ -752,8 +752,8 @@ void generate_comfort_noise_enc( if ( st->last_core > ACELP_CORE ) { - tcx_windowing_synthesis_current_frame( timeDomainOutput, st->hTcxCfg->tcx_mdct_window, /*Keep sine windows for limiting Time modulation*/ - st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, st->hTcxCfg->tcx_mdct_window_length, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, 0, st->hTcxCfg->tcx_last_overlap_mode == ALDO_WINDOW ? FULL_OVERLAP : st->hTcxCfg->tcx_last_overlap_mode, NULL, NULL, NULL, NULL, NULL, N / 2, st->hTcxCfg->tcx_offset < 0 ? -st->hTcxCfg->tcx_offset : 0, 1, 0, 0 ); + tcx_windowing_synthesis_current_frame( timeDomainOutput, st->hTcxCfg->tcx_mdct_window_flt, /*Keep sine windows for limiting Time modulation*/ + st->hTcxCfg->tcx_mdct_window_half_flt, st->hTcxCfg->tcx_mdct_window_minimum_flt, st->hTcxCfg->tcx_mdct_window_length, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, 0, st->hTcxCfg->tcx_last_overlap_mode == ALDO_WINDOW ? FULL_OVERLAP : st->hTcxCfg->tcx_last_overlap_mode, NULL, NULL, NULL, NULL, NULL, N / 2, st->hTcxCfg->tcx_offset < 0 ? -st->hTcxCfg->tcx_offset : 0, 1, 0, 0 ); if ( st->hTcxCfg->last_aldo ) { @@ -764,20 +764,20 @@ void generate_comfort_noise_enc( } else { - tcx_windowing_synthesis_past_frame( st->hTcxEnc->Txnq, st->hTcxCfg->tcx_aldo_window_1_trunc, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, st->hTcxCfg->tcx_mdct_window_length, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->hTcxCfg->tcx_last_overlap_mode ); + tcx_windowing_synthesis_past_frame( st->hTcxEnc->Txnq_flt, st->hTcxCfg->tcx_aldo_window_1_trunc_flt, st->hTcxCfg->tcx_mdct_window_half_flt, st->hTcxCfg->tcx_mdct_window_minimum_flt, st->hTcxCfg->tcx_mdct_window_length, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->hTcxCfg->tcx_last_overlap_mode ); for ( i = 0; i < st->hTcxCfg->tcx_mdct_window_length; i++ ) { - timeDomainOutput[i] += st->hTcxEnc->Txnq[i]; + timeDomainOutput[i] += st->hTcxEnc->Txnq_flt[i]; } } } else { lsp2a_stab( st->lsp_old, old_Aq, M ); - old_exc = st->hLPDmem->old_exc + L_EXC_MEM - ( N / 2 ); - old_syn_pe = st->hLPDmem->mem_syn2; - old_syn = st->hLPDmem->syn[M]; + old_exc = st->hLPDmem->old_exc_flt + L_EXC_MEM - ( N / 2 ); + old_syn_pe = st->hLPDmem->mem_syn2_flt; + old_syn = st->hLPDmem->syn_flt[M]; for ( i = 0; i < N / 2; i++ ) { old_exc_ener += old_exc[i] * old_exc[i]; @@ -1113,7 +1113,7 @@ void FdCngEncodeMDCTStereoSID( { msvq_enc( cdk_37bits_ivas, NULL, NULL, ms_ptr[ch], levels_37bits, FD_CNG_maxC_37bits, stages, weights, N, FD_CNG_maxN_37bits, 1, invTrfMatrix, indices[ch] ); - msvq_dec( cdk_37bits_ivas, NULL, NULL, stages, N, FD_CNG_maxN_37bits, indices[ch], 1, invTrfMatrix, ms_ptr[ch], NULL ); + msvq_dec_float( cdk_37bits_ivas, NULL, NULL, stages, N, FD_CNG_maxN_37bits, indices[ch], 1, invTrfMatrix, ms_ptr[ch], NULL ); } } @@ -1160,7 +1160,7 @@ void FdCngEncodeMDCTStereoSID( /* scale bands and get scalefactors */ scalebands( lr_out_ptr[ch], hFdCngEnc->partDec, N, hFdCngEnc->midbandDec, hFdCngEnc->nFFTpartDec, hFdCngEnc->stopBandDec - hFdCngEnc->startBandDec, hFdCngCom->cngNoiseLevel, 1 ); - lpc_from_spectrum( hFdCngCom, hFdCngEnc->startBandDec, hFdCngEnc->stopFFTbinDec, sts[ch]->preemph_fac ); + lpc_from_spectrum( hFdCngCom, hFdCngEnc->startBandDec, hFdCngEnc->stopFFTbinDec, sts[ch]->preemph_fac_flt); sts[ch]->hDtxEnc->last_CNG_L_frame = sts[ch]->L_frame; } @@ -1290,7 +1290,7 @@ void FdCngEncodeDiracMDCTStereoSID( create_IDCT_N_Matrix( invTrfMatrix, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM ) / ( sizeof( float ) ) ); msvq_enc( cdk_37bits_ivas, NULL, NULL, ms_ptr[0], levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, weights, N[0], FD_CNG_maxN_37bits, 1, invTrfMatrix, indices[0] ); - msvq_dec( cdk_37bits_ivas, NULL, NULL, FD_CNG_stages_37bits, N[0], FD_CNG_maxN_37bits, indices[0], 1, invTrfMatrix, ms_ptr[0], NULL ); + msvq_dec_float( cdk_37bits_ivas, NULL, NULL, FD_CNG_stages_37bits, N[0], FD_CNG_maxN_37bits, indices[0], 1, invTrfMatrix, ms_ptr[0], NULL ); /* set S to zero */ @@ -1325,17 +1325,17 @@ void FdCngEncodeDiracMDCTStereoSID( /* NB last band energy compensation */ if ( hFdCngCom->CngBandwidth == NB ) { - lr_out_ptr[ch][N[ch] - 1] *= NB_LAST_BAND_SCALE; + lr_out_ptr[ch][N[ch] - 1] *= NB_LAST_BAND_SCALE_FLT; } else if ( hFdCngCom->CngBandwidth == SWB && hFdCngCom->CngBitrate <= ACELP_13k20 ) { - lr_out_ptr[ch][N[ch] - 1] *= SWB_13k2_LAST_BAND_SCALE; + lr_out_ptr[ch][N[ch] - 1] *= SWB_13k2_LAST_BAND_SCALE_FLT; } /* scale bands and get scalefactors */ scalebands( lr_out_ptr[ch], hFdCngEnc->partDec, N[ch], hFdCngEnc->midbandDec, hFdCngEnc->nFFTpartDec, hFdCngEnc->stopBandDec - hFdCngEnc->startBandDec, hFdCngCom->cngNoiseLevel, 1 ); - lpc_from_spectrum( hFdCngCom, hFdCngEnc->startBandDec, hFdCngEnc->stopFFTbinDec, sts[ch]->preemph_fac ); + lpc_from_spectrum( hFdCngCom, hFdCngEnc->startBandDec, hFdCngEnc->stopFFTbinDec, sts[ch]->preemph_fac_flt); sts[ch]->hDtxEnc->last_CNG_L_frame = sts[ch]->L_frame; } diff --git a/lib_enc/gs_enc.c b/lib_enc/gs_enc.c index c22285436..ef5c5d802 100644 --- a/lib_enc/gs_enc.c +++ b/lib_enc/gs_enc.c @@ -97,8 +97,8 @@ void encod_audio( T0_tmp = 64; T0_frac_tmp = 0; - mvr2r( hLPDmem->mem_syn, hGSCEnc->mem_syn_tmp, M ); - hGSCEnc->mem_w0_tmp = hLPDmem->mem_w0; + mvr2r( hLPDmem->mem_syn_flt, hGSCEnc->mem_syn_tmp, M ); + hGSCEnc->mem_w0_tmp = hLPDmem->mem_w0_flt; Es_pred = 0; /*---------------------------------------------------------------* @@ -293,7 +293,7 @@ void encod_audio( if ( last_pit_bin == 0 ) { - hLPDmem->tilt_code = 0.0f; + hLPDmem->tilt_code_flt = 0.0f; } else { @@ -360,7 +360,7 @@ void encod_audio( p_Aq = Aq; for ( i_subfr = 0; i_subfr < st->L_frame; i_subfr += L_SUBFR ) { - syn_filt( p_Aq, M, &exc_wo_nf[i_subfr], &synth[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 ); + syn_filt( p_Aq, M, &exc_wo_nf[i_subfr], &synth[i_subfr], L_SUBFR, hLPDmem->mem_syn_flt, 1 ); p_Aq += ( M + 1 ); } @@ -368,7 +368,7 @@ void encod_audio( * Updates *--------------------------------------------------------------------------------------*/ - hLPDmem->mem_w0 = hGSCEnc->mem_w0_tmp; + hLPDmem->mem_w0_flt = hGSCEnc->mem_w0_tmp; mvr2r( exc_wo_nf, exc, st->L_frame ); return; diff --git a/lib_enc/guided_plc_enc.c b/lib_enc/guided_plc_enc.c index cb5e84683..4869f2421 100644 --- a/lib_enc/guided_plc_enc.c +++ b/lib_enc/guided_plc_enc.c @@ -139,9 +139,9 @@ static void getConcealedlsf( const int16_t L_frame, const int16_t last_good ) { - float *lsf = memDecState->lsf_con; + float *lsf = memDecState->lsf_con_flt; - dlpc_bfi( L_frame, &lsf[0], memDecState->lsfold, last_good, 1 /*assumes packet loss */, memDecState->mem_MA, memDecState->mem_AR, &( memDecState->stab_fac ), memDecState->lsf_adaptive_mean, 1, NULL, 0, NULL, NULL, lsfBase ); + dlpc_bfi( L_frame, &lsf[0], memDecState->lsfold, last_good, 1 /*assumes packet loss */, memDecState->mem_MA, memDecState->mem_AR_flt, &( memDecState->stab_fac ), memDecState->lsf_adaptive_mean, 1, NULL, 0, NULL, NULL, lsfBase ); return; } @@ -231,8 +231,8 @@ void encoderSideLossSimulation( /* Initialize pointers here */ mvr2r( hPlc_Ext->old_exc, old_exc, 8 ); - mvr2r( hPlc_Ext->LPDmem->old_exc, &old_exc[8], L_EXC_MEM ); - speechLookAhead = &( st->speech_enc_pe[L_frame] ); + mvr2r( hPlc_Ext->LPDmem->old_exc_flt, &old_exc[8], L_EXC_MEM ); + speechLookAhead = &( st->speech_enc_pe_flt[L_frame] ); /* lsf concealment simulation */ getConcealedLP( hPlc_Ext, AqCon, lsfBase, st->sr_core, st->clas, L_frame ); diff --git a/lib_enc/hq_core_enc.c b/lib_enc/hq_core_enc.c index 261e02202..e84dcb01f 100644 --- a/lib_enc/hq_core_enc.c +++ b/lib_enc/hq_core_enc.c @@ -113,7 +113,7 @@ void hq_core_enc( left_overlap = -1; right_overlap = -1; - WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, TRANSITION_OVERLAP, FULL_OVERLAP, &left_overlap, &right_overlap, st->hTcxEnc->speech_TCX, &L_spec, wtda_audio, 1, 1 ); + WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, TRANSITION_OVERLAP, FULL_OVERLAP, &left_overlap, &right_overlap, st->hTcxEnc->speech_TCX_flt, &L_spec, wtda_audio, 1, 1 ); TCX_MDCT( wtda_audio, t_audio, left_overlap, L_spec - ( left_overlap + right_overlap ) / 2, right_overlap, st->element_mode ); @@ -256,17 +256,17 @@ void hq_core_enc( TCX_MDCT_Inverse( t_audio, wtda_audio, overlap, L_frame - overlap, overlap, st->element_mode ); /* Window current frame */ - tcx_windowing_synthesis_current_frame( wtda_audio, st->hTcxCfg->tcx_aldo_window_2, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, overlap, /*st->hTcxCfg->tcx_mdct_window_length*/ st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->last_core == ACELP_CORE, st->hTcxCfg->tcx_last_overlap_mode, /*left mode*/ st->hTcxEnc->acelp_zir, st->hTcxEnc->Txnq, NULL, Aq_old, st->hTcxCfg->tcx_mdct_window_trans, st->L_frame >> 1, tcx_offset < 0 ? -tcx_offset : 0, st->last_core, 0, 0 ); + tcx_windowing_synthesis_current_frame( wtda_audio, st->hTcxCfg->tcx_aldo_window_2_flt, st->hTcxCfg->tcx_mdct_window_half_flt, st->hTcxCfg->tcx_mdct_window_minimum_flt, overlap, /*st->hTcxCfg->tcx_mdct_window_length*/ st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->last_core == ACELP_CORE, st->hTcxCfg->tcx_last_overlap_mode, /*left mode*/ st->hTcxEnc->acelp_zir_flt, st->hTcxEnc->Txnq_flt, NULL, Aq_old, st->hTcxCfg->tcx_mdct_window_trans_flt, st->L_frame >> 1, tcx_offset < 0 ? -tcx_offset : 0, st->last_core, 0, 0 ); /*Compute windowed synthesis in case of switching to ALDO windows in next frame*/ mvr2r( wtda_audio + L_frame - nz, st->hTcxEnc->old_out, nz + overlap ); set_zero( st->hTcxEnc->old_out + nz + overlap, nz ); - tcx_windowing_synthesis_past_frame( st->hTcxEnc->old_out + nz, st->hTcxCfg->tcx_aldo_window_1_trunc, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, overlap, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, FULL_OVERLAP ); + tcx_windowing_synthesis_past_frame( st->hTcxEnc->old_out + nz, st->hTcxCfg->tcx_aldo_window_1_trunc_flt, st->hTcxCfg->tcx_mdct_window_half_flt, st->hTcxCfg->tcx_mdct_window_minimum_flt, overlap, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, FULL_OVERLAP ); for ( i = 0; i < nz; i++ ) { - st->hTcxEnc->old_out[nz + overlap + i] = wtda_audio[L_frame - 1 - i] * st->hTcxCfg->tcx_aldo_window_1_trunc[-1 - i]; + st->hTcxEnc->old_out[nz + overlap + i] = wtda_audio[L_frame - 1 - i] * st->hTcxCfg->tcx_aldo_window_1_trunc_flt[-1 - i]; } mvr2r( wtda_audio + ( overlap >> 1 ) - tcx_offset, output, st->L_frame ); } @@ -283,7 +283,7 @@ void hq_core_enc( if ( st->element_mode > EVS_MONO ) { /* Store LB synthesis in case of switch to ACELP */ - mvr2r( output, st->hLPDmem->old_exc, L_FRAME16k ); + mvr2r( output, st->hLPDmem->old_exc_flt, L_FRAME16k ); } pop_wmops(); diff --git a/lib_enc/hq_env_enc.c b/lib_enc/hq_env_enc.c index c0a63e262..9abb5fd69 100644 --- a/lib_enc/hq_env_enc.c +++ b/lib_enc/hq_env_enc.c @@ -553,7 +553,7 @@ void diff_envelope_coding( for ( i = start_norm; i < start_norm + num_env_bands; i++ ) { - normqlg2[i] = dicnlg2[ynrm[i]]; + normqlg2[i] = dicnlg2_float[ynrm[i]]; } } diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index c1a2e29b8..1166a4d46 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -1081,8 +1081,8 @@ static void IGF_Whitening( for ( p = 0; p < hGrid->nTiles; p++ ) { /* reset filter */ - hPrivateData->prevSFM_FIR[p] = 0.f; - hPrivateData->prevSFM_IIR[p] = 0.f; + hPrivateData->prevSFM_FIR_flt[p] = 0.f; + hPrivateData->prevSFM_IIR_flt[p] = 0.f; /* preset values: */ hPrivateData->igfCurrWhiteningLevel[p] = IGF_WHITENING_OFF; @@ -1125,7 +1125,7 @@ static void IGF_Whitening( if ( last_core_acelp || hPrivateData->wasTransient ) { - hPrivateData->prevSFM_FIR[p] = hPrivateData->prevSFM_IIR[p] = tmp; + hPrivateData->prevSFM_FIR_flt[p] = hPrivateData->prevSFM_IIR_flt[p] = tmp; } if ( brate <= IVAS_48k && element_mode == IVAS_CPE_MDCT ) @@ -1206,12 +1206,12 @@ static void IGF_Whitening( } else { - SFM = tmp + hPrivateData->prevSFM_FIR[p] + 0.5f * hPrivateData->prevSFM_IIR[p]; + SFM = tmp + hPrivateData->prevSFM_FIR_flt[p] + 0.5f * hPrivateData->prevSFM_IIR_flt[p]; SFM = min( 2.7f, SFM ); } - hPrivateData->prevSFM_FIR[p] = tmp; - hPrivateData->prevSFM_IIR[p] = SFM; + hPrivateData->prevSFM_FIR_flt[p] = tmp; + hPrivateData->prevSFM_IIR_flt[p] = SFM; if ( SFM > hGrid->whiteningThreshold[1][p] ) { @@ -1309,8 +1309,8 @@ static void IGF_Whitening( /* reset filter */ for ( p = 0; p < IGF_MAX_TILES; p++ ) { - hPrivateData->prevSFM_FIR[p] = 0.f; - hPrivateData->prevSFM_IIR[p] = 0.f; + hPrivateData->prevSFM_FIR_flt[p] = 0.f; + hPrivateData->prevSFM_IIR_flt[p] = 0.f; } } @@ -1658,8 +1658,8 @@ void IGFEncSetMode( } hPrivateData->wasTransient = 0; - set_f( hPrivateData->prevSFM_FIR, 0, IGF_MAX_TILES ); - set_f( hPrivateData->prevSFM_IIR, 0, IGF_MAX_TILES ); + set_f( hPrivateData->prevSFM_FIR_flt, 0, IGF_MAX_TILES ); + set_f( hPrivateData->prevSFM_IIR_flt, 0, IGF_MAX_TILES ); set_s( hPrivateData->dampingFactorSmoothing, 2, IGF_MAX_SFB ); set_f( hPrivateData->prevSFM_FIR_SFB_SB, 0, IGF_MAX_SFB ); set_f( hPrivateData->prevSFM_IIR_SFB_SB, 0, IGF_MAX_SFB ); @@ -1695,8 +1695,8 @@ void IGFEncSetMode( hIGFEnc->infoTotalBitsWritten = 0; hIGFEnc->infoTotalBitsPerFrameWritten = 0; hIGFEnc->flatteningTrigger = 0; - hIGFEnc->tns_predictionGain = 0; - set_f( hIGFEnc->spec_be_igf, 0, N_MAX_TCX - IGF_START_MN ); + hIGFEnc->tns_predictionGain_flt = 0; + set_f( hIGFEnc->spec_be_igf_flt, 0, N_MAX_TCX - IGF_START_MN ); return; } @@ -1995,7 +1995,7 @@ void IGFSaveSpectrumForITF( { IGF_UpdateInfo( hIGFEnc, igfGridIdx ); - mvr2r( pITFSpectrum + IGF_START_MN, hIGFEnc->spec_be_igf, hIGFEnc->infoStopLine - IGF_START_MN ); + mvr2r( pITFSpectrum + IGF_START_MN, hIGFEnc->spec_be_igf_flt, hIGFEnc->infoStopLine - IGF_START_MN ); return; } diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index 7ac925cf0..ff7961732 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -155,7 +155,7 @@ ivas_error init_encoder( st->mem_preemph = 0.0f; st->mem_preemph16k = 0.0f; - st->mem_preemph_enc = 0.0; + st->mem_preemph_enc_flt = 0.0; /* AVQ pre-quantizer memory */ st->mem_preemp_preQ = 0.0f; @@ -166,7 +166,7 @@ ivas_error init_encoder( st->last_harm_flag_acelp = 0; /* (Decimated) Weighted Speech Memory */ - st->mem_wsp_enc = 0.0; + st->mem_wsp_enc_flt = 0.0; st->mem_wsp = 0.0f; set_f( st->mem_decim2, 0, 3 ); @@ -241,8 +241,8 @@ ivas_error init_encoder( /* FEC */ st->last_clas = UNVOICED_CLAS; - st->prev_fmerit = 0.0f; - st->fmerit_dt = 0.0f; + st->prev_fmerit_flt = 0.0f; + st->fmerit_dt_flt = 0.0f; st->Last_pulse_pos = 0; for ( i = 0; i < 2 * NB_SUBFR16k; i++ ) @@ -277,15 +277,15 @@ ivas_error init_encoder( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Signal buffers\n" ) ); } - st->Bin_E_old = st->hSignalBuf->Bin_E_old; - st->mem_decim = st->hSignalBuf->mem_decim; - st->mem_decim16k = st->hSignalBuf->mem_decim16k; - st->old_inp_12k8 = st->hSignalBuf->old_inp_12k8; - st->old_inp_16k = st->hSignalBuf->old_inp_16k; - st->buf_speech_enc_pe = st->hSignalBuf->buf_speech_enc_pe; - st->buf_synth = st->hSignalBuf->buf_synth; - st->buf_speech_enc = st->hSignalBuf->buf_speech_enc; - st->buf_wspeech_enc = st->hSignalBuf->buf_wspeech_enc; + st->Bin_E_old = st->hSignalBuf->Bin_E_old_flt; + st->mem_decim = st->hSignalBuf->mem_decim_flt; + st->mem_decim16k = st->hSignalBuf->mem_decim16k_flt; + st->old_inp_12k8 = st->hSignalBuf->old_inp_12k8_flt; + st->old_inp_16k = st->hSignalBuf->old_inp_16k_flt; + st->buf_speech_enc_pe_flt = st->hSignalBuf->buf_speech_enc_pe_flt; + st->buf_synth_flt = st->hSignalBuf->buf_synth_flt; + st->buf_speech_enc_flt = st->hSignalBuf->buf_speech_enc_flt; + st->buf_wspeech_enc_flt = st->hSignalBuf->buf_wspeech_enc_flt; /* initializations */ set_f( st->Bin_E_old, 0, L_FFT / 2 ); @@ -294,7 +294,7 @@ ivas_error init_encoder( set_f( st->old_inp_12k8, 0, L_INP_MEM ); set_f( st->old_inp_16k, 0, L_INP_MEM ); - st->input_buff = st->hSignalBuf->input_buff; + st->input_buff = st->hSignalBuf->input_buff_flt; set_zero( st->input_buff, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ); st->old_input_signal = st->input_buff; if ( st->element_mode == EVS_MONO ) @@ -314,10 +314,10 @@ ivas_error init_encoder( st->mem_decim16k = NULL; st->old_inp_12k8 = NULL; st->old_inp_16k = NULL; - st->buf_speech_enc_pe = NULL; - st->buf_synth = NULL; - st->buf_speech_enc = NULL; - st->buf_wspeech_enc = NULL; + st->buf_speech_enc_pe_flt = NULL; + st->buf_synth_flt = NULL; + st->buf_speech_enc_flt = NULL; + st->buf_wspeech_enc_flt = NULL; st->input_buff = NULL; } @@ -425,7 +425,7 @@ ivas_error init_encoder( st->flag_noisy_speech_snr = 0; st->fd_cng_reset_flag = 0; st->cng_type = -1; - st->bckr_tilt_lt = 0.f; + st->bckr_tilt_lt_flt = 0.f; st->active_cnt = 0; if ( ( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO ) || ( st->element_mode == IVAS_CPE_MDCT && st->Opt_DTX_ON ) ) @@ -834,7 +834,7 @@ ivas_error init_encoder( return error; } - initFdCngEnc( st->hFdCngEnc, st->input_Fs, st->cldfbAnaEnc->scale ); + initFdCngEnc( st->hFdCngEnc, st->input_Fs, st->cldfbAnaEnc->scale_flt); /* initialization for IVAS modes happens in first frame pre-processing */ if ( st->element_mode == EVS_MONO ) @@ -888,19 +888,19 @@ void LPDmem_enc_init( LPD_state_HANDLE hLPDmem /* i/o: LP memories */ ) { - set_zero( hLPDmem->syn, 1 + M ); - - set_f( hLPDmem->old_exc, 0, L_EXC_MEM ); - hLPDmem->mem_w0 = 0.0f; - set_f( hLPDmem->mem_syn, 0, M ); - set_f( hLPDmem->mem_syn1, 0, M ); - set_f( hLPDmem->mem_syn2, 0, M ); - set_zero( hLPDmem->mem_syn_r, L_SYN_MEM ); - set_f( hLPDmem->mem_syn3, 0, M ); - - hLPDmem->tilt_code = 0.0f; - hLPDmem->gc_threshold = 0.0f; - set_f( hLPDmem->dispMem, 0, 8 ); + set_zero( hLPDmem->syn_flt, 1 + M ); + + set_f( hLPDmem->old_exc_flt, 0, L_EXC_MEM ); + hLPDmem->mem_w0_flt = 0.0f; + set_f( hLPDmem->mem_syn_flt, 0, M ); + set_f( hLPDmem->mem_syn1_flt, 0, M ); + set_f( hLPDmem->mem_syn2_flt, 0, M ); + set_zero( hLPDmem->mem_syn_r_flt, L_SYN_MEM ); + set_f( hLPDmem->mem_syn3_flt, 0, M ); + + hLPDmem->tilt_code_flt = 0.0f; + hLPDmem->gc_threshold_flt = 0.0f; + set_f( hLPDmem->dispMem_flt, 0, 8 ); return; } diff --git a/lib_enc/inov_enc.c b/lib_enc/inov_enc.c index 2c99ebdac..4739f2537 100644 --- a/lib_enc/inov_enc.c +++ b/lib_enc/inov_enc.c @@ -84,13 +84,13 @@ void inov_encode( if ( L_frame == L_FRAME ) { - g1 = FORMANT_SHARPENING_G1; - g2 = FORMANT_SHARPENING_G2; + g1 = FORMANT_SHARPENING_G1_FLT; + g2 = FORMANT_SHARPENING_G2_FLT; } else { - g1 = FORMANT_SHARPENING_G1_16k; - g2 = FORMANT_SHARPENING_G2_16k; + g1 = FORMANT_SHARPENING_G1_16k_FLT; + g2 = FORMANT_SHARPENING_G2_16k_FLT; } /*----------------------------------------------------------------* diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc.c index dd95f8dbe..95c5cd007 100644 --- a/lib_enc/ivas_core_pre_proc.c +++ b/lib_enc/ivas_core_pre_proc.c @@ -152,18 +152,18 @@ ivas_error pre_proc_ivas( if ( st->L_frame == L_FRAME ) { - st->gamma = GAMMA1; - st->preemph_fac = PREEMPH_FAC; + st->gamma_flt = GAMMA1_FLT; + st->preemph_fac_flt = PREEMPH_FAC_FLT; } else if ( st->L_frame == L_FRAME32k ) { - st->gamma = GAMMA16k; - st->preemph_fac = PREEMPH_FAC_SWB; + st->gamma_flt = GAMMA16k_FLT; + st->preemph_fac_flt = PREEMPH_FAC_SWB_FLT; } else { - st->gamma = GAMMA16k; - st->preemph_fac = PREEMPH_FAC_16k; + st->gamma_flt = GAMMA16k_FLT; + st->preemph_fac_flt = PREEMPH_FAC_16k_FLT; } st->sr_core = st->L_frame * FRAMES_PER_SEC; @@ -247,18 +247,18 @@ ivas_error pre_proc_ivas( if ( st->sr_core == INT_FS_12k8 ) { - st->preemph_fac = PREEMPH_FAC; - st->gamma = GAMMA1; + st->preemph_fac_flt = PREEMPH_FAC_FLT; + st->gamma_flt = GAMMA1_FLT; } else if ( st->sr_core == INT_FS_16k ) { - st->preemph_fac = PREEMPH_FAC_16k; - st->gamma = GAMMA16k; + st->preemph_fac_flt = PREEMPH_FAC_16k_FLT; + st->gamma_flt = GAMMA16k_FLT; } else /* st->sr_core >=25600 */ { - st->preemph_fac = PREEMPH_FAC_SWB; - st->gamma = GAMMA16k; + st->preemph_fac_flt = PREEMPH_FAC_SWB_FLT; + st->gamma_flt = GAMMA16k_FLT; } if ( st->vad_flag == 0 ) @@ -399,31 +399,31 @@ ivas_error pre_proc_ivas( if ( !( st->L_frame == L_FRAME16k && element_mode != IVAS_CPE_MDCT ) ) { /* update signal buffers */ - mvr2r( new_inp_12k8, st->buf_speech_enc_pe + st->L_frame, L_FRAME ); - mvr2r( st->buf_speech_enc + L_FRAME32k, st->buf_speech_enc + st->L_frame, L_FRAME ); + mvr2r( new_inp_12k8, st->buf_speech_enc_pe_flt + st->L_frame, L_FRAME ); + mvr2r( st->buf_speech_enc_flt + L_FRAME32k, st->buf_speech_enc_flt + st->L_frame, L_FRAME ); if ( element_mode == IVAS_CPE_DFT ) { - mvr2r( st->buf_speech_enc + L_FRAME32k - STEREO_DFT_OVL_12k8, st->buf_speech_enc + st->L_frame - STEREO_DFT_OVL_12k8, STEREO_DFT_OVL_12k8 ); + mvr2r( st->buf_speech_enc_flt + L_FRAME32k - STEREO_DFT_OVL_12k8, st->buf_speech_enc_flt + st->L_frame - STEREO_DFT_OVL_12k8, STEREO_DFT_OVL_12k8 ); } else if ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_MDCT ) { - mvr2r( st->buf_speech_enc + L_FRAME32k - lMemRecalc_12k8 - L_FILT, st->buf_speech_enc + st->L_frame - lMemRecalc_12k8 - L_FILT, lMemRecalc_12k8 + L_FILT ); + mvr2r( st->buf_speech_enc_flt + L_FRAME32k - lMemRecalc_12k8 - L_FILT, st->buf_speech_enc_flt + st->L_frame - lMemRecalc_12k8 - L_FILT, lMemRecalc_12k8 + L_FILT ); } else if ( element_mode == IVAS_SCE ) { - mvr2r( st->buf_speech_enc + L_FRAME32k - L_FILT, st->buf_speech_enc + st->L_frame - L_FILT, L_FILT ); + mvr2r( st->buf_speech_enc_flt + L_FRAME32k - L_FILT, st->buf_speech_enc_flt + st->L_frame - L_FILT, L_FILT ); } if ( st->tcxonly == 0 ) { - mvr2r( wsp, st->wspeech_enc, L_FRAME + L_LOOK_12k8 ); + mvr2r( wsp, st->wspeech_enc_flt, L_FRAME + L_LOOK_12k8 ); } } if ( flag_16k_smc ) { - mvr2r( st->buf_speech_enc + L_FRAME16k, new_inp_resamp16k, L_FRAME16k ); + mvr2r( st->buf_speech_enc_flt + L_FRAME16k, new_inp_resamp16k, L_FRAME16k ); } /*-----------------------------------------------------------------* @@ -660,7 +660,7 @@ ivas_error ivas_compute_core_buffers( st->tcxonly == 0 && !( ( element_mode == IVAS_CPE_TD && st->idchan == 1 ) || element_mode == IVAS_CPE_MDCT ) ) { - st->mem_preemph_enc = new_inp_16k[L_frame_tmp - 1]; + st->mem_preemph_enc_flt = new_inp_16k[L_frame_tmp - 1]; } if ( input_Fs > 8000 && sr_core == INT_FS_16k && element_mode != IVAS_CPE_MDCT ) @@ -674,11 +674,11 @@ ivas_error ivas_compute_core_buffers( if ( st->L_frame == L_FRAME16k ) { - mvr2r( new_inp_16k - STEREO_DFT_OVL_16k, st->buf_speech_enc + L_FRAME16k - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k ); + mvr2r( new_inp_16k - STEREO_DFT_OVL_16k, st->buf_speech_enc_flt + L_FRAME16k - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k ); } - preemph( new_inp_16k - STEREO_DFT_OVL_16k, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k ) ); + preemph( new_inp_16k - STEREO_DFT_OVL_16k, PREEMPH_FAC_16k_FLT, L_FRAME16k, &( st->mem_preemph16k ) ); tmp = st->mem_preemph16k; - preemph( new_inp_16k - STEREO_DFT_OVL_16k + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp ); + preemph( new_inp_16k - STEREO_DFT_OVL_16k + L_FRAME16k, PREEMPH_FAC_16k_FLT, STEREO_DFT_OVL_16k, &tmp ); } else if ( st->element_mode == IVAS_CPE_TD ) { @@ -686,7 +686,7 @@ ivas_error ivas_compute_core_buffers( { st->mem_preemph16k = st->mem_preemph16k_DFT; mvr2r( st->inp_16k_mem_stereo_sw, new_inp_16k - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); - preemph( new_inp_16k - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k ); + preemph( new_inp_16k - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), PREEMPH_FAC_16k_FLT, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k ); } st->mem_preemph16k_DFT = old_inp_16k[L_INP_MEM - STEREO_DFT_OVL_16k + L_FRAME16k - 1]; @@ -695,22 +695,22 @@ ivas_error ivas_compute_core_buffers( if ( last_element_mode == IVAS_CPE_MDCT ) { int16_t length_16k = NS2SA( INT_FS_16k, L_MEM_RECALC_SCH_NS - DELAY_FIR_RESAMPL_NS ); - preemph( new_inp_16k - lMemRecalc_16k - length_16k, PREEMPH_FAC, length_16k, &st->mem_preemph16k ); + preemph( new_inp_16k - lMemRecalc_16k - length_16k, PREEMPH_FAC_FLT, length_16k, &st->mem_preemph16k ); } if ( st->L_frame == L_FRAME16k ) { - mvr2r( new_inp_16k - lMemRecalc_16k, st->buf_speech_enc + L_FRAME16k - lMemRecalc_16k - L_FILT16k, L_FRAME16k + lMemRecalc_16k + L_FILT16k ); + mvr2r( new_inp_16k - lMemRecalc_16k, st->buf_speech_enc_flt + L_FRAME16k - lMemRecalc_16k - L_FILT16k, L_FRAME16k + lMemRecalc_16k + L_FILT16k ); } - preemph( new_inp_16k - lMemRecalc_16k, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k ) ); + preemph( new_inp_16k - lMemRecalc_16k, PREEMPH_FAC_16k_FLT, L_FRAME16k, &( st->mem_preemph16k ) ); tmp = st->mem_preemph16k; - preemph( new_inp_16k - lMemRecalc_16k + L_FRAME16k, PREEMPH_FAC_16k, lMemRecalc_16k + L_FILT16k, &tmp ); + preemph( new_inp_16k - lMemRecalc_16k + L_FRAME16k, PREEMPH_FAC_16k_FLT, lMemRecalc_16k + L_FILT16k, &tmp ); } else if ( element_mode == IVAS_SCE ) { - preemph( new_inp_16k, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k ) ); + preemph( new_inp_16k, PREEMPH_FAC_16k_FLT, L_FRAME16k, &( st->mem_preemph16k ) ); tmp = st->mem_preemph16k; - preemph( new_inp_16k + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp ); + preemph( new_inp_16k + L_FRAME16k, PREEMPH_FAC_16k_FLT, L_FILT16k, &tmp ); } } else if ( input_Fs > 8000 ) /* keep memory up-to-date in case of bitrate switching */ @@ -744,16 +744,16 @@ ivas_error ivas_compute_core_buffers( /* update signal buffers */ if ( element_mode == IVAS_CPE_DFT ) { - mvr2r( new_inp_16k - STEREO_DFT_OVL_16k, st->buf_speech_enc_pe + L_FRAME16k - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k ); + mvr2r( new_inp_16k - STEREO_DFT_OVL_16k, st->buf_speech_enc_pe_flt + L_FRAME16k - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k ); } else if ( element_mode == IVAS_CPE_TD ) { - mvr2r( new_inp_16k - lMemRecalc_16k, st->buf_speech_enc_pe + L_FRAME16k - lMemRecalc_16k - L_FILT16k, L_FRAME16k + lMemRecalc_16k + L_FILT16k ); + mvr2r( new_inp_16k - lMemRecalc_16k, st->buf_speech_enc_pe_flt + L_FRAME16k - lMemRecalc_16k - L_FILT16k, L_FRAME16k + lMemRecalc_16k + L_FILT16k ); } else { - mvr2r( new_inp_resamp16k, st->buf_speech_enc + L_FRAME16k, L_FRAME16k ); - mvr2r( new_inp_16k, st->buf_speech_enc_pe + L_FRAME16k, L_FRAME16k ); + mvr2r( new_inp_resamp16k, st->buf_speech_enc_flt + L_FRAME16k, L_FRAME16k ); + mvr2r( new_inp_16k, st->buf_speech_enc_pe_flt + L_FRAME16k, L_FRAME16k ); } /*--------------------------------------------------------------* @@ -772,7 +772,7 @@ ivas_error ivas_compute_core_buffers( * Compute Weighted Input *---------------------------------------------------------------*/ - find_wsp( L_FRAME16k, L_SUBFR, NB_SUBFR16k, A, Aw, st->speech_enc_pe, PREEMPH_FAC_16k, st->wspeech_enc, &st->mem_wsp_enc, st->gamma, L_LOOK_16k ); + find_wsp( L_FRAME16k, L_SUBFR, NB_SUBFR16k, A, Aw, st->speech_enc_pe_flt, PREEMPH_FAC_16k_FLT, st->wspeech_enc_flt, &st->mem_wsp_enc_flt, st->gamma_flt, L_LOOK_16k ); } /*-----------------------------------------------------------------* diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 8a9c62e1f..fe8520c91 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -347,15 +347,15 @@ ivas_error pre_proc_front_ivas( /* save input resampled at 12.8kHz, non-preemhasised */ if ( element_mode == IVAS_CPE_DFT ) { - mvr2r( new_inp_12k8 - STEREO_DFT_OVL_12k8, st->buf_speech_enc + L_FRAME32k - STEREO_DFT_OVL_12k8, L_FRAME + STEREO_DFT_OVL_12k8 ); + mvr2r( new_inp_12k8 - STEREO_DFT_OVL_12k8, st->buf_speech_enc_flt + L_FRAME32k - STEREO_DFT_OVL_12k8, L_FRAME + STEREO_DFT_OVL_12k8 ); } else if ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_MDCT ) { - mvr2r( new_inp_12k8 - lMemRecalc_12k8, st->buf_speech_enc + L_FRAME32k - lMemRecalc_12k8 - L_FILT, L_FRAME + lMemRecalc_12k8 + L_FILT ); + mvr2r( new_inp_12k8 - lMemRecalc_12k8, st->buf_speech_enc_flt + L_FRAME32k - lMemRecalc_12k8 - L_FILT, L_FRAME + lMemRecalc_12k8 + L_FILT ); } else { - mvr2r( new_inp_12k8, st->buf_speech_enc + L_FRAME32k, L_FRAME ); + mvr2r( new_inp_12k8, st->buf_speech_enc_flt + L_FRAME32k, L_FRAME ); } /*------------------------------------------------------------------* @@ -369,9 +369,9 @@ ivas_error pre_proc_front_ivas( st->mem_preemph = st->mem_preemph_DFT; st->mem_preemph_DFT = old_inp_12k8[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; - preemph( new_inp_12k8 - STEREO_DFT_OVL_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph ); + preemph( new_inp_12k8 - STEREO_DFT_OVL_12k8, PREEMPH_FAC_FLT, L_FRAME, &st->mem_preemph ); dummy = st->mem_preemph; - preemph( new_inp_12k8 - STEREO_DFT_OVL_12k8 + L_FRAME, PREEMPH_FAC, STEREO_DFT_OVL_12k8, &dummy ); + preemph( new_inp_12k8 - STEREO_DFT_OVL_12k8 + L_FRAME, PREEMPH_FAC_FLT, STEREO_DFT_OVL_12k8, &dummy ); } else if ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_MDCT ) { @@ -381,7 +381,7 @@ ivas_error pre_proc_front_ivas( { st->mem_preemph = st->mem_preemph_DFT; mvr2r( st->inp_12k8_mem_stereo_sw, new_inp_12k8 - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); - preemph( new_inp_12k8 - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph ); + preemph( new_inp_12k8 - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), PREEMPH_FAC_FLT, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph ); } st->mem_preemph_DFT = old_inp_12k8[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* == inp_12k8[L_FRAME-1] */ @@ -391,18 +391,18 @@ ivas_error pre_proc_front_ivas( if ( hCPE->last_element_mode == IVAS_CPE_DFT && st->idchan == 1 ) { int16_t length_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_SCH_NS ); - preemph( new_inp_12k8 - lMemRecalc_12k8 - length_12k8, PREEMPH_FAC, length_12k8, &st->mem_preemph ); + preemph( new_inp_12k8 - lMemRecalc_12k8 - length_12k8, PREEMPH_FAC_FLT, length_12k8, &st->mem_preemph ); } - preemph( new_inp_12k8 - lMemRecalc_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph ); + preemph( new_inp_12k8 - lMemRecalc_12k8, PREEMPH_FAC_FLT, L_FRAME, &st->mem_preemph ); dummy = st->mem_preemph; - preemph( new_inp_12k8 - lMemRecalc_12k8 + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy ); + preemph( new_inp_12k8 - lMemRecalc_12k8 + L_FRAME, PREEMPH_FAC_FLT, lMemRecalc_12k8 + L_FILT, &dummy ); } else /* IVAS_SCE or IVAS_CPE_MDCT */ { - preemph( new_inp_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph ); + preemph( new_inp_12k8, PREEMPH_FAC_FLT, L_FRAME, &st->mem_preemph ); dummy = st->mem_preemph; - preemph( new_inp_12k8 + L_FRAME, PREEMPH_FAC, L_FILT, &dummy ); + preemph( new_inp_12k8 + L_FRAME, PREEMPH_FAC_FLT, L_FILT, &dummy ); } /*-------------------------------------------------------------------------* @@ -607,7 +607,7 @@ ivas_error pre_proc_front_ivas( * 1/4 pitch precision improvement *----------------------------------------------------------------*/ - find_wsp( L_FRAME, L_SUBFR, NB_SUBFR, A, Aw, inp_12k8, TILT_FAC, wsp, &st->mem_wsp, GAMMA1, L_look ); + find_wsp( L_FRAME, L_SUBFR, NB_SUBFR, A, Aw, inp_12k8, TILT_FAC, wsp, &st->mem_wsp, GAMMA1_FLT, L_look ); if ( st->vad_flag == 0 ) { @@ -681,7 +681,7 @@ ivas_error pre_proc_front_ivas( * UC and VC frame selection *-----------------------------------------------------------------*/ - find_tilt( fr_bands, st->hNoiseEst->bckr, ee, st->pitch, st->voicing, lf_E, corr_shift, st->input_bwidth, st->max_band, hp_E, MODE1, &( st->bckr_tilt_lt ), st->Opt_SC_VBR ); + find_tilt( fr_bands, st->hNoiseEst->bckr, ee, st->pitch, st->voicing, lf_E, corr_shift, st->input_bwidth, st->max_band, hp_E, MODE1, &( st->bckr_tilt_lt_flt), st->Opt_SC_VBR ); st->coder_type = find_uv( st, pitch_fr, voicing_fr, inp_12k8, ee, &dE1X, corr_shift, *relE, Etot, hp_E, &flag_spitch, last_core_orig, hStereoClassif ); @@ -771,7 +771,7 @@ ivas_error pre_proc_front_ivas( return error; } - smc_dec = ivas_acelp_tcx20_switching( st, st->speech_enc, st->wspeech_enc, non_staX, pitch_fr, voicing_fr, currFlatness, lsp_mid, stab_fac, res_cod_SNR_M, flag_16k_smc ); + smc_dec = ivas_acelp_tcx20_switching( st, st->speech_enc_flt, st->wspeech_enc_flt, non_staX, pitch_fr, voicing_fr, currFlatness, lsp_mid, stab_fac, res_cod_SNR_M, flag_16k_smc ); } else { diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 36fafd8af..eb74301a2 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -135,11 +135,11 @@ ivas_error ivas_enc( { if ( ( ivas_format == SBA_FORMAT ) && !( st_ivas->sba_analysis_order > 1 ) ) { - hp20( data_f[HOA_keep_ind[st_ivas->hSpar->hMdEnc->HOA_md_ind[i]]], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); + hp20_flt( data_f[HOA_keep_ind[st_ivas->hSpar->hMdEnc->HOA_md_ind[i]]], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); } else if ( !( ivas_format == MC_FORMAT && i == LFE_CHANNEL ) ) { - hp20( data_f[i], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); + hp20_flt( data_f[i], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); } } diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index 4dcf2cd61..f5ecc1f80 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -163,7 +163,7 @@ ivas_error front_vad( modify_Fs( sts[n]->input, input_frame, sts[0]->input_Fs, hFrontVad->buffer_12k8 + L_FFT / 2, INT_FS_12k8, hFrontVad->mem_decim, ( sts[0]->max_bwidth == NB ) ); /* Preemphasis */ - preemph( hFrontVad->buffer_12k8 + L_FFT / 2, PREEMPH_FAC, L_FRAME, &hFrontVad->mem_preemph ); + preemph( hFrontVad->buffer_12k8 + L_FFT / 2, PREEMPH_FAC_FLT, L_FRAME, &hFrontVad->mem_preemph ); analy_sp( IVAS_CPE_TD, hCPE, sts[0]->input_Fs, hFrontVad->buffer_12k8 + L_FFT / 2 - 3 * ( L_SUBFR / 2 ), Bin_E, Bin_E_old, fr_bands[n], lf_E[n], &Etot_LR[n], sts[0]->min_band, sts[0]->max_band, band_energies, PS, fft_buffLR ); @@ -400,7 +400,7 @@ ivas_error front_vad_spar( st->input = input; mvr2r( omni_in, st->input, input_frame ); - delay_signal( st->input, input_frame, hFrontVad->delay_buf, hFrontVad->delay_samples ); + delay_signal_float( st->input, input_frame, hFrontVad->delay_buf, hFrontVad->delay_samples ); /*------------------------------------------------------------------* * Front-VAD @@ -423,7 +423,7 @@ ivas_error front_vad_spar( relE = Etot[0] - st->lp_speech; - find_wsp( L_FRAME, L_SUBFR, NB_SUBFR, A, Aw, inp_12k8, TILT_FAC, wsp, &st->mem_wsp, GAMMA1, L_LOOK_12k8 ); + find_wsp( L_FRAME, L_SUBFR, NB_SUBFR, A, Aw, inp_12k8, TILT_FAC, wsp, &st->mem_wsp, GAMMA1_FLT, L_LOOK_12k8 ); if ( st->vad_flag == 0 ) { diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index 5a90fc89a..12fe0d879 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -1504,9 +1504,9 @@ static void ivas_param_mc_transient_detection( push_wmops( "param_mc_trn_det" ); - attackRatioThreshold = hTranDet->transientDetector.attackRatioThreshold; - pSubblockNrg = &hTranDet->subblockEnergies.subblockNrg[hParamMC->transient_detector_delay]; - pAccSubblockNrg = &hTranDet->subblockEnergies.accSubblockNrg[hParamMC->transient_detector_delay]; + attackRatioThreshold = hTranDet->transientDetector.attackRatioThreshold_flt; + pSubblockNrg = &hTranDet->subblockEnergies.subblockNrg_flt[hParamMC->transient_detector_delay]; + pAccSubblockNrg = &hTranDet->subblockEnergies.accSubblockNrg_flt[hParamMC->transient_detector_delay]; bIsAttackPresent = FALSE; attackIndex = 16; diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 84aef1d46..7bcf0d86a 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -390,7 +390,7 @@ void ivas_mct_core_enc( ComputeSpectrumNoiseMeasure( powerSpec[ch], st->hTcxEnc->L_frameTCX, st->hTcxEnc->nmStartLine, ( st->L_frame * st->last_sr_core != st->L_frame_past * st->sr_core ) || ( st->last_core != TCX_20_CORE ), st->hTcxEnc->memQuantZeros, st->hTcxEnc->L_frameTCX ); } - st->hTcxEnc->measuredBwRatio = 1.f; /* No bandwidth limit for the noise filling */ + st->hTcxEnc->measuredBwRatio_flt = 1.f; /* No bandwidth limit for the noise filling */ } if ( sts[0]->igf ) diff --git a/lib_enc/ivas_mct_enc_mct.c b/lib_enc/ivas_mct_enc_mct.c index ee2690507..005d46318 100644 --- a/lib_enc/ivas_mct_enc_mct.c +++ b/lib_enc/ivas_mct_enc_mct.c @@ -121,7 +121,7 @@ static void getNextBestCorrelation( } /* sort values */ - v_sort( tmp_corrVals, 0, ( ( nChannels * ( nChannels - 1 ) ) / 2 ) - 1 ); + v_sort_float( tmp_corrVals, 0, ( ( nChannels * ( nChannels - 1 ) ) / 2 ) - 1 ); /* get max, or 2nd max and so on depending on sortInd value */ *max_corr = tmp_corrVals[( nChannels * ( nChannels - 1 ) ) / 2 - 1 - sortInd]; @@ -380,7 +380,7 @@ static void getGlobalILD( { int16_t k, ch, nSubframes, L_subframe; float nrg[MCT_MAX_CHANNELS]; - float meanE = 0.f, ratio, qratio; + float meanE = 0.f, ratio_float, qratio; int16_t cnt = 0; /*Initializations*/ @@ -410,15 +410,15 @@ static void getGlobalILD( if ( nrg[ch] > meanE ) /*change it to meanE if final solution*/ { - ratio = meanE / nrg[ch]; - hMCT->mc_global_ild[ch] = max( 1, min( SMDCT_ILD_RANGE - 1, (int16_t) ( SMDCT_ILD_RANGE * ratio + 0.5f ) ) ); + ratio_float = meanE / nrg[ch]; + hMCT->mc_global_ild[ch] = max( 1, min( SMDCT_ILD_RANGE - 1, (int16_t) ( SMDCT_ILD_RANGE * ratio_float + 0.5f ) ) ); qratio = (float) hMCT->mc_global_ild[ch] / SMDCT_ILD_RANGE; } else { - ratio = nrg[ch] / meanE; + ratio_float = nrg[ch] / meanE; hMCT->lowE_ch[ch] = 1; - hMCT->mc_global_ild[ch] = max( 1, min( SMDCT_ILD_RANGE - 1, (int16_t) ( SMDCT_ILD_RANGE * ratio + 0.5f ) ) ); + hMCT->mc_global_ild[ch] = max( 1, min( SMDCT_ILD_RANGE - 1, (int16_t) ( SMDCT_ILD_RANGE * ratio_float + 0.5f ) ) ); qratio = (float) SMDCT_ILD_RANGE / hMCT->mc_global_ild[ch]; } diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index 368b76e94..09ede7a09 100644 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -277,7 +277,7 @@ static void kernel_switch_update_transforms( { for ( i = minWindowLen; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ { - windowedTimeSignal[2 + leftOverlap + i] += sign * speech_TCX[-1 - i] * hTcxCfg->tcx_aldo_window_1_FB[leftOverlap / 2 + minWindowLen - i] * hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i]; + windowedTimeSignal[2 + leftOverlap + i] += sign * speech_TCX[-1 - i] * hTcxCfg->tcx_aldo_window_1_FB_flt[leftOverlap / 2 + minWindowLen - i] * hTcxCfg->tcx_mdct_window_minimumFB_flt[minWindowLen - i]; } } @@ -635,7 +635,7 @@ void ivas_mdct_core_whitening_enc( if ( mct_on ) { sts[0]->hTcxEnc->tfm_mem = sts[1]->hTcxEnc->tfm_mem = sqrtf( 0.5f * ( sts[0]->hTcxEnc->tfm_mem * sts[0]->hTcxEnc->tfm_mem + sts[1]->hTcxEnc->tfm_mem * sts[1]->hTcxEnc->tfm_mem ) ); /* RMS */ - sts[0]->hTcxEnc->tcxltp_norm_corr_past = sts[1]->hTcxEnc->tcxltp_norm_corr_past = 0.5f * ( sts[0]->hTcxEnc->tcxltp_norm_corr_past + sts[1]->hTcxEnc->tcxltp_norm_corr_past ); + sts[0]->hTcxEnc->tcxltp_norm_corr_past_flt = sts[1]->hTcxEnc->tcxltp_norm_corr_past_flt = 0.5f * ( sts[0]->hTcxEnc->tcxltp_norm_corr_past_flt + sts[1]->hTcxEnc->tcxltp_norm_corr_past_flt); for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = sts[ch]; @@ -682,7 +682,7 @@ void ivas_mdct_core_whitening_enc( if ( st->last_core == ACELP_CORE ) /* reset past kernel info */ { - st->hTcxEnc->kernel_switch_corr_past = 0.f; + st->hTcxEnc->kernel_switch_corr_past_flt = 0.f; st->hTcxEnc->kernel_symmetry_past = 0; } } @@ -711,8 +711,8 @@ void ivas_mdct_core_whitening_enc( nSampCore = tcx_subframe_coded_lines; } - nrg = 0.25f * ( hTcxEnc0->tcxltp_norm_corr_past + hTcxEnc0->tcxltp_norm_corr_mem + /* tcxltp_norm_corr_past already contains the */ - hTcxEnc1->tcxltp_norm_corr_past + hTcxEnc1->tcxltp_norm_corr_mem ); /* normalized correlation of the current frame */ + nrg = 0.25f * ( hTcxEnc0->tcxltp_norm_corr_past_flt + hTcxEnc0->tcxltp_norm_corr_mem_flt + /* tcxltp_norm_corr_past already contains the */ + hTcxEnc1->tcxltp_norm_corr_past_flt + hTcxEnc1->tcxltp_norm_corr_mem_flt); /* normalized correlation of the current frame */ L_subframe = max( 512, L_subframe ); nSubframes = ( hTcxEnc0->tcxMode == TCX_20 ) ? 1 : NB_DIV; @@ -723,7 +723,7 @@ void ivas_mdct_core_whitening_enc( { const int16_t switchKernel = /* these 4 transform types can be applied: 0 = MDCT-IV, 1 = MDST-II, 2 = MDCT-II, 3 = MDST-IV */ kernel_switch_detect( hTcxEnc0->spectrum[n], hTcxEnc1->spectrum[n], mdst_spectrum[0][n], mdst_spectrum[1][n], nSampCore / nSubframes, - L_subframeTCX / nSubframes, hTcxEnc0->transform_type[n], &hTcxEnc0->kernel_switch_corr_past, ( totalRate * L_subframe ) / nSubframes ); + L_subframeTCX / nSubframes, hTcxEnc0->transform_type[n], &hTcxEnc0->kernel_switch_corr_past_flt, ( totalRate * L_subframe ) / nSubframes ); if ( switchKernel ) /* apply MDST-IV coding in one of the channels */ { hTcxEnc0->kernel_type[n] = ( hTcxEnc0->kernel_symmetry_past ? 3 : 1 ) - max( 0, switchKernel ); @@ -737,7 +737,7 @@ void ivas_mdct_core_whitening_enc( } else { - hTcxEnc0->kernel_switch_corr_past = 0.f; /* don't update the kernel switching state, postpone it to when data is available */ + hTcxEnc0->kernel_switch_corr_past_flt = 0.f; /* don't update the kernel switching state, postpone it to when data is available */ hTcxEnc0->kernel_type[n] = ( hTcxEnc0->kernel_symmetry_past ? 3 : 0 ); hTcxEnc1->kernel_type[n] = ( hTcxEnc1->kernel_symmetry_past ? 3 : 0 ); } @@ -745,9 +745,9 @@ void ivas_mdct_core_whitening_enc( hTcxEnc1->kernel_symmetry_past = hTcxEnc1->kernel_type[n] & 1; kernel_switch_update_transforms( hTcxEnc0->spectrum[n], mdst_spectrum[0][n], hTcxEnc0->transform_type[n], sts[0]->hTcxCfg, sts[0]->bwidth_sw_cnt, hTcxEnc0->kernel_type[n], - hTcxEnc0->new_speech_TCX, ( n == 1 ? NULL : hTcxEnc0->speech_TCX ), windowedSignal[0] + n * L_FRAME48k, L_subframeTCX / nSubframes ); + hTcxEnc0->new_speech_TCX_flt, ( n == 1 ? NULL : hTcxEnc0->speech_TCX_flt ), windowedSignal[0] + n * L_FRAME48k, L_subframeTCX / nSubframes ); kernel_switch_update_transforms( hTcxEnc1->spectrum[n], mdst_spectrum[1][n], hTcxEnc1->transform_type[n], sts[1]->hTcxCfg, sts[1]->bwidth_sw_cnt, hTcxEnc1->kernel_type[n], - hTcxEnc1->new_speech_TCX, ( n == 1 ? NULL : hTcxEnc1->speech_TCX ), windowedSignal[1] + n * L_FRAME48k, L_subframeTCX / nSubframes ); + hTcxEnc1->new_speech_TCX_flt, ( n == 1 ? NULL : hTcxEnc1->speech_TCX_flt ), windowedSignal[1] + n * L_FRAME48k, L_subframeTCX / nSubframes ); } for ( n = 0; n < nSubframes; n++ ) { @@ -783,7 +783,7 @@ void ivas_mdct_core_whitening_enc( else { sts[0]->hTcxEnc->enc_ste_pre_corr_past = 0; - sts[0]->hTcxEnc->kernel_switch_corr_past = 0.f; + sts[0]->hTcxEnc->kernel_switch_corr_past_flt = 0.f; for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { @@ -805,7 +805,7 @@ void ivas_mdct_core_whitening_enc( hTcxEncCh->kernel_symmetry_past = hTcxEncCh->kernel_type[n] & 1; kernel_switch_update_transforms( hTcxEncCh->spectrum[n], mdst_spectrum[ch][n], hTcxEncCh->transform_type[n], sts[ch]->hTcxCfg, sts[ch]->bwidth_sw_cnt, hTcxEncCh->kernel_type[n], - hTcxEncCh->new_speech_TCX, ( n /*1*/ ? NULL : hTcxEncCh->speech_TCX ), windowedSignal[ch] + n * L_FRAME48k, L_subframeTCX / nSubframes ); + hTcxEncCh->new_speech_TCX_flt, ( n /*1*/ ? NULL : hTcxEncCh->speech_TCX_flt ), windowedSignal[ch] + n * L_FRAME48k, L_subframeTCX / nSubframes ); } } } diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index fb360a010..1cacc3fd0 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -409,7 +409,7 @@ void ivas_osba_enc( /* delay ISM input channels to match the SBA encoder delay */ for ( n = 0; n < nchan_ism; n++ ) { - delay_signal( data_in_f[n], input_frame, hOSba->input_data_mem[n], delay_s ); + delay_signal_float( data_in_f[n], input_frame, hOSba->input_data_mem[n], delay_s ); /*keep prev gain upto date for bitrate switching*/ diff --git a/lib_enc/ivas_range_uni_enc.c b/lib_enc/ivas_range_uni_enc.c index 6781c750a..c0001d966 100644 --- a/lib_enc/ivas_range_uni_enc.c +++ b/lib_enc/ivas_range_uni_enc.c @@ -158,9 +158,9 @@ int16_t rc_uni_enc_finish( int16_t bits; /* floor(log2(x)) = floor(log2(x >> 24)) + 24, for any x >= 2 ^ 24 */ - /* 32 - floor(log2(y)) = norm_ul(y) + 1 = norm_l(y >> 24) - 22 */ + /* 32 - floor(log2(y)) = norm_ul_float(y) + 1 = norm_l(y >> 24) - 22 */ bits = norm_l( rc_st_enc->rc_range >> 24 ) - 22; /* bits = 32 - floor(log2(rc_range)) */ - /* completely equivalent with norm_ul(rc_st_enc->rc_range) + 1, but norm_l is faster */ + /* completely equivalent with norm_ul_float(rc_st_enc->rc_range) + 1, but norm_l is faster */ bits++; /* conservative number of bits, because the decoder only has rc_range available */ diff --git a/lib_enc/ivas_sns_enc.c b/lib_enc/ivas_sns_enc.c index 5b455060a..16236fdaa 100644 --- a/lib_enc/ivas_sns_enc.c +++ b/lib_enc/ivas_sns_enc.c @@ -462,12 +462,12 @@ int16_t quantize_sns( nStages = SNS_MSVQ_NSTAGES_SIDE; bits = ( st->core == TCX_20_CORE ) ? ivas_sns_cdbks_side_tcx20_bits : ivas_sns_cdbks_side_tcx10_bits; msvq_enc( side_cdbks, NULL, NULL, snsQ, side_levels, 3, nStages, weights, M, M, 0, NULL, &indices[idxIndices] ); - msvq_dec( side_cdbks, NULL, NULL, nStages, M, M, &indices[idxIndices], 0, NULL, snsQ, NULL ); + msvq_dec_float( side_cdbks, NULL, NULL, nStages, M, M, &indices[idxIndices], 0, NULL, snsQ, NULL ); } else { msvq_enc( cdbks, NULL, NULL, sns_ptr, levels, 3, nStages, weights, M, M, 0, NULL, &indices[idxIndices] ); - msvq_dec( cdbks, NULL, NULL, nStages, M, M, &indices[idxIndices], 0, NULL, snsQ, NULL ); + msvq_dec_float( cdbks, NULL, NULL, nStages, M, M, &indices[idxIndices], 0, NULL, snsQ, NULL ); } idxIndices += nStages; diff --git a/lib_enc/ivas_stereo_dmx_evs.c b/lib_enc/ivas_stereo_dmx_evs.c index 5ac6fe180..766497788 100644 --- a/lib_enc/ivas_stereo_dmx_evs.c +++ b/lib_enc/ivas_stereo_dmx_evs.c @@ -106,8 +106,8 @@ static ivas_error estimate_itd( float *corr, STEREO_DMX_EVS_POC_HANDLE hPOC, STE static void weighted_ave( const float src1[], const float src2[], float dst[], const float gain, const float old_gain, const int16_t input_frame, const float wnd[] ); static void adapt_gain( const float src[], float dst[], const float gain, const float old_gain, const int16_t input_frame, const float wnd[] ); static void create_M_signal( const float srcL[], const float srcR[], float dmx[], const float w_curr, const int16_t input_frame, const float wnd[], float *w_prev, float *dmx_energy, float *src_energy ); -static float find_poc_peak( STEREO_DMX_EVS_POC_HANDLE hPOC, float itd[], const int16_t input_frame, const float ratio ); -static void calc_energy( const float src1[], const float src2[], float energy[], const int16_t input_frame, const float ratio ); +static float find_poc_peak( STEREO_DMX_EVS_POC_HANDLE hPOC, float itd[], const int16_t input_frame, const float ratio_float ); +static void calc_energy( const float src1[], const float src2[], float energy[], const int16_t input_frame, const float ratio_float ); /*-------------------------------------------------------------------* * estimate_itd_wnd_fft() @@ -740,7 +740,7 @@ static float find_poc_peak( STEREO_DMX_EVS_POC_HANDLE hPOC, /* i/o: phase only correlation structure */ float itd[], /* o : estimated itd */ const int16_t input_frame, /* i : input frame length per channel */ - const float ratio /* i : adapting ratio */ + const float ratio_float /* i : adapting ratio */ ) { int16_t itd_cand[CPE_CHANNELS], i, n, cnt[CPE_CHANNELS], Lh, peak_range, *on, *itdLR, prev_off[CPE_CHANNELS]; @@ -791,7 +791,7 @@ static float find_poc_peak( cQ[n] += P[Lh - itd_cand[n] + i] + P[Lh - itd_cand[n] - i]; } - peak_width[n] = peak_width[n] * ratio + (float) cnt[n] * ( 1.0f - ratio ); + peak_width[n] = peak_width[n] * ratio_float + (float) cnt[n] * ( 1.0f - ratio_float ); eps2 = eps * peak_width[n] * 0.25f; Q[n] = ( 1.0f - ( cQ[n] / ( peak_range * 2 + 1 ) + eps2 ) / ( Q[n] + eps2 ) ); Q[n] = max( Q[n], 0.0f ); @@ -977,7 +977,7 @@ static void calc_energy( const float src2[], /* i : Rch input signal */ float energy[], /* o : calculated energy */ const int16_t input_frame, /* i : input frame length per channel */ - const float ratio /* i : adapting ratio */ + const float ratio_float /* i : adapting ratio */ ) { float E, wnd, wnd_diff; @@ -1006,7 +1006,7 @@ static void calc_energy( E += ( src1[i] * wnd ) * ( src2[i] * wnd ); } - *energy = *energy * ratio + ( E / (float) input_frame ) * ( 1.0f - ratio ); + *energy = *energy * ratio_float + ( E / (float) input_frame ) * ( 1.0f - ratio_float ); return; } diff --git a/lib_enc/ivas_stereo_ica_enc.c b/lib_enc/ivas_stereo_ica_enc.c index 4d698dfde..f2fb439d6 100644 --- a/lib_enc/ivas_stereo_ica_enc.c +++ b/lib_enc/ivas_stereo_ica_enc.c @@ -223,8 +223,8 @@ static void deEmphResample( mvr2r( tempChan2, buf2, input_frame ); /* De-emphasis, 1/(1-mu z^-1), and resample, stage 1 */ - deemph( buf1, PREEMPH_FAC_16k, input_frame, &hStereoTCA->memdecim[0] ); - deemph( buf2, PREEMPH_FAC_16k, input_frame, &hStereoTCA->memdecim[1] ); + deemph( buf1, PREEMPH_FAC_16k_FLT, input_frame, &hStereoTCA->memdecim[0] ); + deemph( buf2, PREEMPH_FAC_16k_FLT, input_frame, &hStereoTCA->memdecim[1] ); for ( i = 0; i < ( input_frame / dsFac1 ); i++ ) { @@ -233,8 +233,8 @@ static void deEmphResample( } /* De-emphasis, 1/(1-mu z^-1), and resample, stage 2 */ - deemph( tempBuf1, PREEMPH_FAC_16k, ( input_frame / dsFac1 ), &hStereoTCA->memdecim[2] ); - deemph( tempBuf2, PREEMPH_FAC_16k, ( input_frame / dsFac1 ), &hStereoTCA->memdecim[3] ); + deemph( tempBuf1, PREEMPH_FAC_16k_FLT, ( input_frame / dsFac1 ), &hStereoTCA->memdecim[2] ); + deemph( tempBuf2, PREEMPH_FAC_16k_FLT, ( input_frame / dsFac1 ), &hStereoTCA->memdecim[3] ); for ( i = 0; i < ( input_frame / dsFactor ); i++ ) { diff --git a/lib_enc/ivas_stereo_mdct_core_enc.c b/lib_enc/ivas_stereo_mdct_core_enc.c index 579438a3f..761c9300f 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc.c +++ b/lib_enc/ivas_stereo_mdct_core_enc.c @@ -51,10 +51,10 @@ static void sync_tcx_mode( Encoder_State **st /* i/o: Encoder state */ ) { - const float prevAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg[st[0]->hTranDet->subblockEnergies.nDelay]; - const float prevAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg[st[1]->hTranDet->subblockEnergies.nDelay]; - const float lastAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg[st[0]->hTranDet->subblockEnergies.nDelay + st[0]->hTranDet->transientDetector.nSubblocksToCheck]; - const float lastAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg[st[1]->hTranDet->subblockEnergies.nDelay + st[1]->hTranDet->transientDetector.nSubblocksToCheck]; + const float prevAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg_flt[st[0]->hTranDet->subblockEnergies.nDelay]; + const float prevAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg_flt[st[1]->hTranDet->subblockEnergies.nDelay]; + const float lastAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg_flt[st[0]->hTranDet->subblockEnergies.nDelay + st[0]->hTranDet->transientDetector.nSubblocksToCheck]; + const float lastAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg_flt[st[1]->hTranDet->subblockEnergies.nDelay + st[1]->hTranDet->transientDetector.nSubblocksToCheck]; if ( ( st[0]->hTcxEnc->tcxMode == st[1]->hTcxEnc->tcxMode ) && ( st[0]->element_brate == IVAS_48k ) && ( st[0]->hTcxCfg->tcx_curr_overlap_mode != st[1]->hTcxCfg->tcx_curr_overlap_mode ) ) @@ -168,7 +168,7 @@ void stereo_mdct_core_enc( *---------------------------------------------------------------*/ sts[0]->hTcxEnc->tfm_mem = sts[1]->hTcxEnc->tfm_mem = sqrtf( 0.5f * ( sts[0]->hTcxEnc->tfm_mem * sts[0]->hTcxEnc->tfm_mem + sts[1]->hTcxEnc->tfm_mem * sts[1]->hTcxEnc->tfm_mem ) ); /* RMS */ - sts[0]->hTcxEnc->tcxltp_norm_corr_past = sts[1]->hTcxEnc->tcxltp_norm_corr_past = 0.5f * ( sts[0]->hTcxEnc->tcxltp_norm_corr_past + sts[1]->hTcxEnc->tcxltp_norm_corr_past ); + sts[0]->hTcxEnc->tcxltp_norm_corr_past_flt = sts[1]->hTcxEnc->tcxltp_norm_corr_past_flt = 0.5f * ( sts[0]->hTcxEnc->tcxltp_norm_corr_past_flt + sts[1]->hTcxEnc->tcxltp_norm_corr_past_flt); for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { @@ -322,7 +322,7 @@ void stereo_mdct_core_enc( ( st->L_frame * st->last_sr_core != st->L_frame_past * st->sr_core ) || ( st->last_core != TCX_20_CORE ), st->hTcxEnc->memQuantZeros, L_subframeTCX ); } - st->hTcxEnc->measuredBwRatio = 1.f; /* No bandwidth limit for the noise filling */ + st->hTcxEnc->measuredBwRatio_flt = 1.f; /* No bandwidth limit for the noise filling */ } /*--------------------------------------------------------------* diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc.c b/lib_enc/ivas_stereo_mdct_stereo_enc.c index 78d950c74..43ebe7f64 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc.c @@ -831,22 +831,22 @@ void FindSplitRatio( ) { const uint8_t highRateMdctStereo = ( sts[0]->element_brate < IVAS_80k && sts[0]->core == sts[1]->core && sts[0]->element_mode == IVAS_CPE_MDCT && sts[0]->hTcxEnc->enc_ste_pre_corr_past ? 0 : 1 ); - float ratio; + float ratio_float; /* Calculate split ratio and quantize it */ hCPE->hStereoMdct->split_ratio = SMDCT_EQUAL_RATIO_RANGE; /* Equal bits to both channels */ - ratio = GetChannelEnergyRatio( sts, 0, 1, highRateMdctStereo ); + ratio_float = GetChannelEnergyRatio( sts, 0, 1, highRateMdctStereo ); - if ( ratio >= 0 ) + if ( ratio_float >= 0 ) { - hCPE->hStereoMdct->split_ratio = (uint16_t) ( SMDCT_BITRATE_RATIO_RANGE * ratio + 0.5f ); + hCPE->hStereoMdct->split_ratio = (uint16_t) ( SMDCT_BITRATE_RATIO_RANGE * ratio_float + 0.5f ); /* Tuning to get closer to the optimal split ratio */ - if ( ratio < 8.0f / 9.0f && hCPE->hStereoMdct->split_ratio > SMDCT_EQUAL_RATIO_RANGE + ( SMDCT_BITRATE_RATIO_RANGE >> 4 ) ) + if ( ratio_float < 8.0f / 9.0f && hCPE->hStereoMdct->split_ratio > SMDCT_EQUAL_RATIO_RANGE + ( SMDCT_BITRATE_RATIO_RANGE >> 4 ) ) { hCPE->hStereoMdct->split_ratio -= SMDCT_BITRATE_RATIO_RANGE >> 3; } - if ( ratio > 1.0f / 9.0f && hCPE->hStereoMdct->split_ratio < SMDCT_EQUAL_RATIO_RANGE - ( SMDCT_BITRATE_RATIO_RANGE >> 4 ) ) + if ( ratio_float > 1.0f / 9.0f && hCPE->hStereoMdct->split_ratio < SMDCT_EQUAL_RATIO_RANGE - ( SMDCT_BITRATE_RATIO_RANGE >> 4 ) ) { hCPE->hStereoMdct->split_ratio += SMDCT_BITRATE_RATIO_RANGE >> 3; } diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c index 5b173936c..2b6b96ced 100644 --- a/lib_enc/ivas_stereo_switching_enc.c +++ b/lib_enc/ivas_stereo_switching_enc.c @@ -578,7 +578,7 @@ ivas_error stereo_memory_enc( return error; } - initFdCngEnc( st->hFdCngEnc, st->input_Fs, st->cldfbAnaEnc->scale ); + initFdCngEnc( st->hFdCngEnc, st->input_Fs, st->cldfbAnaEnc->scale_flt); configureFdCngEnc( st->hFdCngEnc, st->bwidth, st->rf_mode && st->total_brate == ACELP_13k20 ? ACELP_9k60 : st->total_brate ); } } @@ -670,7 +670,7 @@ void stereo_switching_enc( /* update DFT synthesis overlap memory @12.8kHz */ for ( i = 0; i < STEREO_DFT_OVL_12k8; i++ ) { - hCPE->hStereoDft->output_mem_dmx_12k8[i] = sts[0]->buf_speech_enc[L_FRAME32k + L_FRAME - STEREO_DFT_OVL_12k8 + i] * hCPE->hStereoDft->win_12k8[STEREO_DFT_OVL_12k8 - 1 - i]; + hCPE->hStereoDft->output_mem_dmx_12k8[i] = sts[0]->buf_speech_enc_flt[L_FRAME32k + L_FRAME - STEREO_DFT_OVL_12k8 + i] * hCPE->hStereoDft->win_12k8[STEREO_DFT_OVL_12k8 - 1 - i]; } /* update DFT synthesis overlap memory @16kHz, primary channel only */ @@ -757,17 +757,17 @@ void stereo_switching_enc( set_zero( sts[1]->mem_decim, 2 * L_FILT_MAX ); sts[1]->mem_preemph = 0; - set_zero( sts[1]->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); - set_zero( sts[1]->buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + set_zero( sts[1]->buf_speech_enc_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + set_zero( sts[1]->buf_speech_enc_pe_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); if ( sts[1]->hTcxEnc != NULL ) { - set_zero( sts[1]->hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + set_zero( sts[1]->hTcxEnc->buf_speech_ltp_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); } - set_zero( sts[1]->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k ); - set_zero( sts[1]->buf_synth, OLD_SYNTH_SIZE_ENC + L_FRAME32k ); + set_zero( sts[1]->buf_wspeech_enc_flt, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k ); + set_zero( sts[1]->buf_synth_flt, OLD_SYNTH_SIZE_ENC + L_FRAME32k ); sts[1]->mem_wsp = 0.0f; - sts[1]->mem_wsp_enc = 0.0f; + sts[1]->mem_wsp_enc_flt = 0.0f; init_gp_clip( sts[1]->clip_var ); set_f( sts[1]->Bin_E, 0, L_FFT ); @@ -788,7 +788,7 @@ void stereo_switching_enc( /* populate PCh memories into the SCh */ if ( sts[0]->hLPDmem != NULL ) { - mvr2r( sts[0]->hLPDmem->old_exc, sts[1]->hLPDmem->old_exc, L_EXC_MEM ); + mvr2r( sts[0]->hLPDmem->old_exc_flt, sts[1]->hLPDmem->old_exc_flt, L_EXC_MEM ); } mvr2r( sts[0]->lsf_old, sts[1]->lsf_old, M ); mvr2r( sts[0]->lsp_old, sts[1]->lsp_old, M ); @@ -815,8 +815,8 @@ void stereo_switching_enc( } else if ( hCPE->element_mode == IVAS_CPE_TD && hCPE->last_element_mode == IVAS_CPE_MDCT ) { - set_f( sts[0]->hLPDmem->old_exc, 0.0f, L_EXC_MEM ); - set_f( sts[1]->hLPDmem->old_exc, 0.0f, L_EXC_MEM ); + set_f( sts[0]->hLPDmem->old_exc_flt, 0.0f, L_EXC_MEM ); + set_f( sts[1]->hLPDmem->old_exc_flt, 0.0f, L_EXC_MEM ); } /* TD/DFT -> MDCT stereo switching (there is no TCX in the TD stereo secondary channel, or DFT stereo) */ diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index ef239607e..7d318909c 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -303,7 +303,7 @@ void stereo_tcx_core_enc( if ( st->envWeighted ) { /* Unweight the envelope */ - E_LPC_lsp_unweight( st->lsp_old, st->lsp_old, st->lsf_old, 1.0f / st->gamma ); + E_LPC_lsp_unweight_float( st->lsp_old, st->lsp_old, st->lsf_old, 1.0f / st->gamma_flt); st->envWeighted = 0; } @@ -327,13 +327,13 @@ void stereo_tcx_core_enc( /* Get the envelope */ if ( st->enableTcxLpc ) { - tcx_lpc_cdk = tcxlpc_get_cdk( st->hTcxCfg->coder_type ); + tcx_lpc_cdk = tcxlpc_get_cdk_float( st->hTcxCfg->coder_type ); /* Get the envelope corresponding to the current frame */ - E_LPC_int_lpc_tcx( st->lspold_enc, lsp_new, A_q ); + E_LPC_int_lpc_tcx_float( st->lspold_enc, lsp_new, A_q ); /* Weight the envelope */ - weight_a( A_q, A_q, st->gamma, M ); + weight_a( A_q, A_q, st->gamma_flt, M ); /* Convert to lsp and lsf */ a2lsp_stab( A_q, lsp, lsp_new ); @@ -355,7 +355,7 @@ void stereo_tcx_core_enc( } else if ( !st->tcxonly ) { - E_LPC_int_lpc_tcx( st->lsp_old, lsp_q, A_q ); + E_LPC_int_lpc_tcx_float( st->lsp_old, lsp_q, A_q ); } else if ( n + 2 == n_subframes ) /* First TCX10/5 subframe */ { @@ -393,7 +393,7 @@ void stereo_tcx_core_enc( * Run TCX10/20 Core *---------------------------------------------------------------*/ - hTcxEnc->measuredBwRatio = 1.f; + hTcxEnc->measuredBwRatio_flt = 1.f; for ( n = 0; n < n_subframes; n++ ) { @@ -409,7 +409,7 @@ void stereo_tcx_core_enc( } /* Run TCX20/10 encoder */ - QuantizeSpectrum( st, A_q, A_q_ind, gainlpc[n], st->synth + n * st->L_frame / n_subframes, target_bits[n], tnsSize[n], param_core + n * NPRM_DIV, n, &hm_cfg[n], vad_hover_flag ); + QuantizeSpectrum( st, A_q, A_q_ind, gainlpc[n], st->synth_flt + n * st->L_frame / n_subframes, target_bits[n], tnsSize[n], param_core + n * NPRM_DIV, n, &hm_cfg[n], vad_hover_flag ); } /* Update tcx overlap mode */ @@ -419,7 +419,7 @@ void stereo_tcx_core_enc( if ( st->enableTcxLpc ) { - E_LPC_lsp_unweight( lsp_tcx_q, lsp_q, lsf_q, 1.0f / st->gamma ); /* Update lsf_q for encoderSideLossSimulation() */ + E_LPC_lsp_unweight_float( lsp_tcx_q, lsp_q, lsf_q, 1.0f / st->gamma_flt); /* Update lsf_q for encoderSideLossSimulation() */ } /* Update lsp/lsf memory */ @@ -431,7 +431,7 @@ void stereo_tcx_core_enc( st->envWeighted = 1; /* Update ACELP quantizer state */ - lsf_update_memory( st->narrowBand, st->lsf_old, st->mem_MA, st->mem_MA ); + lsf_update_memory_float( st->narrowBand, st->lsf_old, st->mem_MA, st->mem_MA ); st->pstreaklen = 0; st->streaklimit = 1.0f; /* check resonance for pitch clipping algorithm */ @@ -453,9 +453,9 @@ void stereo_tcx_core_enc( assert( st->L_frame == L_FRAME ); - mvr2r( st->synth + L_FRAME - L_LP, buf, L_LP ); - tmp = st->synth[L_FRAME - L_LP - 1]; - preemph( buf, st->preemph_fac, L_LP, &tmp ); + mvr2r( st->synth_flt + L_FRAME - L_LP, buf, L_LP ); + tmp = st->synth_flt[L_FRAME - L_LP - 1]; + preemph( buf, st->preemph_fac_flt, L_LP, &tmp ); autocorr( buf, r, M, L_LP, LP_assym_window, 0, 0, 0 ); lag_wind( r, M, INT_FS_12k8, LAGW_WEAK ); lev_dur( A, r, M, NULL ); @@ -463,11 +463,11 @@ void stereo_tcx_core_enc( residu( A, M, buf + L_LP - L_FRAME, res, L_FRAME ); - cng_params_upd( lsptmp, res, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ, ENC, st->hTdCngEnc->ho_env_circ, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); + cng_params_upd( lsptmp, res, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ, ENC, st->hTdCngEnc->ho_env_circ, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf_flt, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); } else { - cng_params_upd( lsp_new, st->hLPDmem->old_exc + L_EXC_MEM - st->L_frame, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ, ENC, st->hTdCngEnc->ho_env_circ, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); + cng_params_upd( lsp_new, st->hLPDmem->old_exc_flt + L_EXC_MEM - st->L_frame, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ, ENC, st->hTdCngEnc->ho_env_circ, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf_flt, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); } if ( st->L_frame == L_FRAME ) @@ -594,7 +594,7 @@ int16_t ivas_acelp_tcx20_switching( } overlap = st->hTcxCfg->tcx_mdct_window_delay; - mvr2r( st->hTcxCfg->tcx_mdct_window, window, L_LOOK_16k ); + mvr2r( st->hTcxCfg->tcx_mdct_window_flt, window, L_LOOK_16k ); } else { @@ -638,7 +638,7 @@ int16_t ivas_acelp_tcx20_switching( y[i] = x[i]; } - weight_a( A_q_tcx, Ap, GAMMA1, M ); + weight_a( A_q_tcx, Ap, GAMMA1_FLT, M ); lpc2mdct( Ap, M, gainlpc, FDNS_NPTS, 0 ); @@ -754,7 +754,7 @@ int16_t ivas_acelp_tcx20_switching( for ( i = 0; i < L_loop; i += L_SUBFR ) { T0 = (int16_t) ( ( fac * pitch_fr_local[(int16_t) ( (float) ( i / L_SUBFR ) / fac + 0.5f )] ) + 0.5f ); - gain = get_gain( wsp + i, wsp + i - T0, L_SUBFR, NULL ); + gain = get_gain_flt( wsp + i, wsp + i - T0, L_SUBFR, NULL ); noise = 1e-6f; for ( j = 0; j < L_SUBFR; j++ ) { diff --git a/lib_enc/ivas_td_low_rate_enc.c b/lib_enc/ivas_td_low_rate_enc.c index 40d10e485..a2563e209 100644 --- a/lib_enc/ivas_td_low_rate_enc.c +++ b/lib_enc/ivas_td_low_rate_enc.c @@ -79,7 +79,7 @@ void tdm_low_rate_enc( st->GSC_noisy_speech = 1; st->hGSCEnc->noise_lev = 14; - hLPDmem->tilt_code = 0.0f; + hLPDmem->tilt_code_flt = 0.0f; set_f( dct_epit, 0, L_FRAME ); set_f( pitch_buf, L_SUBFR, NB_SUBFR ); last_pit_bin = L_FRAME / 2; @@ -144,7 +144,7 @@ void tdm_low_rate_enc( p_Aq = Aq; for ( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR ) { - syn_filt( p_Aq, M, &exc_wo_nf[i_subfr], &synth[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 ); + syn_filt( p_Aq, M, &exc_wo_nf[i_subfr], &synth[i_subfr], L_SUBFR, hLPDmem->mem_syn_flt, 1 ); p_Aq += ( M + 1 ); } @@ -237,7 +237,7 @@ void encod_gen_2sbfr( mvr2r( &res[i_subfr], &exc[i_subfr], 2 * L_SUBFR ); - find_targets( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res, 2 * L_SUBFR, p_Aw, st->preemph_fac, xn, cn, h1 ); + find_targets( speech, hLPDmem->mem_syn_flt, i_subfr, &hLPDmem->mem_w0_flt, p_Aq, res, 2 * L_SUBFR, p_Aw, st->preemph_fac_flt, xn, cn, h1 ); /*------------------------------------------------------------------------* * Close-loop pitch search on the 1st and 3rd subfr only and quantization @@ -267,13 +267,13 @@ void encod_gen_2sbfr( lp_filt_exc_enc( MODE1, coder_type, i_subfr, exc, h1, xn, y1, xn2, 2 * L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &st->acelp_cfg.ltf_mode ); /* update long-term pitch gain for speech/music classifier */ - st->hSpMusClas->lowrate_pitchGain = 0.9f * st->hSpMusClas->lowrate_pitchGain + 0.1f * gain_pit; + st->hSpMusClas->lowrate_pitchGain_flt = 0.9f * st->hSpMusClas->lowrate_pitchGain_flt + 0.1f * gain_pit; /*-----------------------------------------------------------------* * Innovation encoding *-----------------------------------------------------------------*/ - inov_encode( st, st->core_brate, 0, L_frame, st->last_L_frame, coder_type, st->bwidth, st->sharpFlag, i_subfr, -1, p_Aq, gain_pit, cn, exc, h1, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &i, 2 * L_SUBFR ); + inov_encode( st, st->core_brate, 0, L_frame, st->last_L_frame, coder_type, st->bwidth, st->sharpFlag, i_subfr, -1, p_Aq, gain_pit, cn, exc, h1, hLPDmem->tilt_code_flt, *pt_pitch, xn2, code, y2, &i, 2 * L_SUBFR ); /*-----------------------------------------------------------------* * Gain encoding @@ -296,13 +296,13 @@ void encod_gen_2sbfr( gp_clip_test_gain_pit( st->element_mode, st->core_brate, gain_pit, st->clip_var ); - hLPDmem->tilt_code = est_tilt( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, 2 * L_SUBFR, 0 ); + hLPDmem->tilt_code_flt = est_tilt( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, 2 * L_SUBFR, 0 ); /*-----------------------------------------------------------------* * Update memory of the weighting filter *-----------------------------------------------------------------*/ - hLPDmem->mem_w0 = xn[2 * L_SUBFR - 1] - ( gain_pit * y1[2 * L_SUBFR - 1] ) - ( gain_code * y2[2 * L_SUBFR - 1] ); + hLPDmem->mem_w0_flt = xn[2 * L_SUBFR - 1] - ( gain_pit * y1[2 * L_SUBFR - 1] ) - ( gain_code * y2[2 * L_SUBFR - 1] ); /*-----------------------------------------------------------------* * Construct adaptive part of the excitation @@ -324,11 +324,11 @@ void encod_gen_2sbfr( voice_factors[i_subfr / L_SUBFR + 1] = voice_factors[i_subfr / L_SUBFR]; /*-----------------------------------------------------------------* - * Synthesize speech to update mem_syn[]. + * Synthesize speech to update mem_syn_flt[]. * Update A(z) filters *-----------------------------------------------------------------*/ - syn_filt( p_Aq, M, &exc[i_subfr], &syn[i_subfr], 2 * L_SUBFR, hLPDmem->mem_syn, 1 ); + syn_filt( p_Aq, M, &exc[i_subfr], &syn[i_subfr], 2 * L_SUBFR, hLPDmem->mem_syn_flt, 1 ); p_Aw += 2 * ( M + 1 ); p_Aq += 2 * ( M + 1 ); @@ -342,7 +342,7 @@ void encod_gen_2sbfr( if ( st->Opt_SC_VBR ) { st->hSC_VBR->prev_ppp_gain_pit = gain_pit; - st->hSC_VBR->prev_tilt_code = hLPDmem->tilt_code; + st->hSC_VBR->prev_tilt_code = hLPDmem->tilt_code_flt; } return; diff --git a/lib_enc/lsf_enc.c b/lib_enc/lsf_enc.c index c32757972..81268825d 100644 --- a/lib_enc/lsf_enc.c +++ b/lib_enc/lsf_enc.c @@ -504,11 +504,11 @@ void lsf_end_enc( if ( st->bwidth == NB ) { - abs_threshold = SFNETLOWLIMIT_NB; + abs_threshold = SFNETLOWLIMIT_NB_FLT; } else { - abs_threshold = SFNETLOWLIMIT_WB; + abs_threshold = SFNETLOWLIMIT_WB_FLT; } Unified_weighting( &st->Bin_E[L_FFT / 2], lsf, wghts, st->bwidth == NB, coder_type == UNVOICED, st->sr_core, M ); @@ -520,13 +520,13 @@ void lsf_end_enc( if ( st->core_brate == SID_2k40 ) { lsfq_CNG( st->hBstr, lsf, wghts, qlsf ); - v_sort( qlsf, 0, M - 1 ); + v_sort_float( qlsf, 0, M - 1 ); reorder_lsf( qlsf, MODE1_LSF_GAP, M, st->sr_core ); return; } - find_pred_mode( &predmode, coder_type, st->bwidth, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate ); + find_pred_mode_float( &predmode, coder_type, st->bwidth, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate ); /*----------------------------------------------------------------* * Calculate number of stages and levels for each stage based on the allowed bit allocation @@ -610,7 +610,7 @@ void lsf_end_enc( if ( st->sr_core == INT_FS_16k && coder_type == VOICED && flag_1bit_gran == 0 ) { /* select safety_net or predictive in open loop*/ - safety_net = qlsf_Mode_Select( lsf, wghts, pred2, st->streaklimit, OP_LOOP_THR_HVO ); + safety_net = qlsf_Mode_Select( lsf, wghts, pred2, st->streaklimit, OP_LOOP_THR_HVO_FLT); if ( force_sf == 1 ) { @@ -931,7 +931,7 @@ void lsf_end_enc( *--------------------------------------------------------------------------*/ /* Sort the quantized vector to ascending order */ - v_sort( qlsf, 0, M - 1 ); + v_sort_float( qlsf, 0, M - 1 ); /* Verify stability by adding minimum separation */ reorder_lsf( qlsf, MODE1_LSF_GAP, M, st->sr_core ); @@ -1191,7 +1191,7 @@ static float vq_lvq_lsf_enc( v_add( cand[i], quant[i], cand[i], M ); /* arrange the LSF candidate vector prior to selection to an ascending order*/ - v_sort( cand[i], 0, M - 1 ); + v_sort_float( cand[i], 0, M - 1 ); /* calculate the spectral distortion using weighted MSE of sorted LSF vector*/ v_sub( cand[i], lsf, diff, M ); @@ -1955,7 +1955,7 @@ static void lsf_mid_enc( { float ftemp, lsf[M], qlsf[M], qlsf1[M], qlsf0[M], wghts[M], err, err_min; int16_t j, k, idx, size = 0; - const float *ratio = 0; + const float *ratio_float = 0; /* convert LSPs to LSFs */ lsp2lsf( lsp, lsf, M, int_fs ); @@ -1974,24 +1974,24 @@ static void lsf_mid_enc( { case 5: { - ratio = tbl_mid_voi_wb_5b; + ratio_float = tbl_mid_voi_wb_5b; break; } case 4: { - ratio = tbl_mid_voi_wb_4b; + ratio_float = tbl_mid_voi_wb_4b; break; } case 1: { - ratio = tbl_mid_voi_wb_1b; + ratio_float = tbl_mid_voi_wb_1b; break; } } } else if ( coder_type == UNVOICED ) { - ratio = tbl_mid_unv_wb_5b; + ratio_float = tbl_mid_unv_wb_5b; } else { @@ -2000,17 +2000,17 @@ static void lsf_mid_enc( { case 5: { - ratio = tbl_mid_gen_wb_5b; + ratio_float = tbl_mid_gen_wb_5b; break; } case 4: { - ratio = tbl_mid_gen_wb_4b; + ratio_float = tbl_mid_gen_wb_4b; break; } case 2: { - ratio = tbl_mid_gen_wb_2b; + ratio_float = tbl_mid_gen_wb_2b; break; } } @@ -2020,13 +2020,13 @@ static void lsf_mid_enc( } else if ( ppp_mode == 1 ) { - ratio = tbl_mid_voi_wb_1b; + ratio_float = tbl_mid_voi_wb_1b; nb_bits = 1; size = 2; } else if ( nelp_mode == 1 ) { - ratio = tbl_mid_unv_wb_4b; + ratio_float = tbl_mid_unv_wb_4b; nb_bits = 4; size = 16; } @@ -2040,7 +2040,7 @@ static void lsf_mid_enc( for ( j = 0; j < M; j++ ) { - qlsf[j] = ( 1.0f - ratio[k * M + j] ) * qlsf0[j] + ratio[k * M + j] * qlsf1[j]; + qlsf[j] = ( 1.0f - ratio_float[k * M + j] ) * qlsf0[j] + ratio_float[k * M + j] * qlsf1[j]; if ( j > 0 && j < M && qlsf[j] < qlsf[j - 1] + LSF_GAP_MID ) { @@ -2061,7 +2061,7 @@ static void lsf_mid_enc( /* calculate the quantized LSF vector */ for ( j = 0; j < M; j++ ) { - qlsf[j] = ( 1.0f - ratio[idx * M + j] ) * qlsf0[j] + ratio[idx * M + j] * qlsf1[j]; + qlsf[j] = ( 1.0f - ratio_float[idx * M + j] ) * qlsf0[j] + ratio_float[idx * M + j] * qlsf1[j]; if ( j > 0 && j < M && qlsf[j] < qlsf[j - 1] + LSF_GAP_MID ) { diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index b825109dd..8607f1d51 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -649,16 +649,16 @@ void midlsf_enc( { float pred[M], wghts[M], err, err_min, tmp; int16_t NS, j, k; - const float *ratio = NULL; + const float *ratio_float = NULL; /* Select codebook */ if ( coder_type == UNVOICED ) { - ratio = tbl_mid_unv_wb_5b; + ratio_float = tbl_mid_unv_wb_5b; } else { - ratio = tbl_mid_gen_wb_5b; + ratio_float = tbl_mid_gen_wb_5b; } NS = 32; @@ -672,7 +672,7 @@ void midlsf_enc( for ( j = 0; j < N; j++ ) { - pred[j] = ( 1.0f - ratio[k * N + j] ) * qlsf0[j] + ratio[k * N + j] * qlsf1[j]; + pred[j] = ( 1.0f - ratio_float[k * N + j] ) * qlsf0[j] + ratio_float[k * N + j] * qlsf1[j]; if ( j > 0 && j < N && pred[j] < pred[j - 1] + LSF_GAP_MID ) { @@ -730,7 +730,7 @@ int16_t Q_lsf_tcxlpc( indices[NumIndices++] = 0; /* Inter-frame prediction */ - means = lsf_means[narrowband]; + means = lsf_means_float[narrowband]; for ( i = 0; i < M; ++i ) { pred[i] = means[i] + MU_MA * mem_MA[i]; @@ -744,17 +744,17 @@ int16_t Q_lsf_tcxlpc( msvq_enc( lsf_codebook[narrowband][cdk], lsf_dims, lsf_offs, lsf, lsf_numlevels, kMaxC, TCXLPC_NUMSTAGES, weights, M, M, 0, NULL, indices + NumIndices ); - msvq_dec( lsf_codebook[narrowband][cdk], lsf_dims, lsf_offs, TCXLPC_NUMSTAGES, M, M, indices + NumIndices, 0, NULL, lsf_q, lsf_q_ind ); + msvq_dec_float( lsf_codebook[narrowband][cdk], lsf_dims, lsf_offs, TCXLPC_NUMSTAGES, M, M, indices + NumIndices, 0, NULL, lsf_q, lsf_q_ind ); NumIndices += TCXLPC_NUMSTAGES; /* Update flag */ - indices[0] = lsf_ind_is_active( lsf_q_ind, lsf_means[narrowband], narrowband, cdk ); + indices[0] = lsf_ind_is_active( lsf_q_ind, lsf_means_float[narrowband], narrowband, cdk ); /* Get residual vector */ for ( i = 0; i < M; ++i ) { - lsf_rem[i] = ( pred[i] + lsf[i] ) - ( lsf_means[narrowband][i] + lsf_q_ind[i] / (float) ( 2.0f * 1.28f ) ); + lsf_rem[i] = ( pred[i] + lsf[i] ) - ( lsf_means_float[narrowband][i] + lsf_q_ind[i] / (float) ( 2.0f * 1.28f ) ); } /* Quantize using extra stage(s) */ msvq_enc( lsf_ind_codebook[narrowband][cdk], lsf_ind_dims, lsf_ind_offs, lsf_rem, lsf_ind_numlevels, kMaxC, TCXLPC_IND_NUMSTAGES, weights, M, M, 0, NULL, indices + NumIndices ); @@ -763,7 +763,7 @@ int16_t Q_lsf_tcxlpc( if ( indices[0] ) { /* Decode */ - msvq_dec( lsf_ind_codebook[narrowband][cdk], lsf_ind_dims, lsf_ind_offs, TCXLPC_IND_NUMSTAGES, M, M, indices + NumIndices, 0, NULL, lsf_rem_q, lsf_rem_q_ind ); + msvq_dec_float( lsf_ind_codebook[narrowband][cdk], lsf_ind_dims, lsf_ind_offs, TCXLPC_IND_NUMSTAGES, M, M, indices + NumIndices, 0, NULL, lsf_rem_q, lsf_rem_q_ind ); NumIndices += TCXLPC_IND_NUMSTAGES; /* Add to MA-removed vector */ @@ -780,14 +780,14 @@ int16_t Q_lsf_tcxlpc( lsf[i] += pred[i]; } - reorder_lsf( lsf_q, TCXLPC_LSF_GAP, M, INT_FS_12k8 ); + reorder_lsf( lsf_q, TCXLPC_LSF_GAP_FLT, M, INT_FS_12k8 ); for ( i = 0; i < M; ++i ) { - lsf_q_ind[i] = add( lsf_q_ind[i], LSFM( lsf_means[narrowband][i] ) ); + lsf_q_ind[i] = add( lsf_q_ind[i], LSFM( lsf_means_float[narrowband][i] ) ); move16(); } - basop_reorder_lsf( lsf_q_ind, LSF_GAP_VAL( TCXLPC_LSF_GAP ), M, INT_FS_FX ); + basop_reorder_lsf( lsf_q_ind, LSF_GAP_VAL(TCXLPC_LSF_GAP_FLT), M, INT_FS_FX ); if ( lsp_q_ind ) { basop_lsf2lsp( lsf_q_ind, lsp_q_ind ); diff --git a/lib_enc/mdct_classifier.c b/lib_enc/mdct_classifier.c index 976c642a2..1171dc4cf 100644 --- a/lib_enc/mdct_classifier.c +++ b/lib_enc/mdct_classifier.c @@ -304,14 +304,14 @@ int16_t mdct_classifier( } /* Smooth decision from instantaneous decision*/ - clas_sec = ( SMOOTH_FILT_COEFF * hTcxEnc->clas_sec_old ) + ( ( 1 - SMOOTH_FILT_COEFF ) * c ); + clas_sec = ( SMOOTH_FILT_COEFF * hTcxEnc->clas_sec_old_flt) + ( ( 1 - SMOOTH_FILT_COEFF ) * c ); /* Do thresholding with hysteresis */ - if ( ( hTcxEnc->clas_final_old == HQ_CORE || hTcxEnc->clas_final_old == TCX_20_CORE ) && ( ( hTcxEnc->last_gain1 > 0.5f * gain1 && hTcxEnc->last_gain1 < 2.0f * gain1 ) && ( hTcxEnc->last_gain2 > 0.5f * gain2 && hTcxEnc->last_gain2 < 2.0f * gain2 ) ) ) + if ( ( hTcxEnc->clas_final_old == HQ_CORE || hTcxEnc->clas_final_old == TCX_20_CORE ) && ( ( hTcxEnc->last_gain1_flt > 0.5f * gain1 && hTcxEnc->last_gain1_flt < 2.0f * gain1 ) && ( hTcxEnc->last_gain2_flt > 0.5f * gain2 && hTcxEnc->last_gain2_flt < 2.0f * gain2 ) ) ) { clas_final = hTcxEnc->clas_final_old; } - else if ( clas_sec > hTcxEnc->clas_sec_old && clas_sec > THRESH_UP ) /* Going up? */ + else if ( clas_sec > hTcxEnc->clas_sec_old_flt && clas_sec > THRESH_UP ) /* Going up? */ { clas_final = HQ_CORE; } @@ -339,10 +339,10 @@ int16_t mdct_classifier( } /* Memory update */ - hTcxEnc->clas_sec_old = clas_sec; + hTcxEnc->clas_sec_old_flt = clas_sec; hTcxEnc->clas_final_old = clas_final; - hTcxEnc->last_gain1 = gain1; - hTcxEnc->last_gain2 = gain2; + hTcxEnc->last_gain1_flt = gain1; + hTcxEnc->last_gain2_flt = gain2; return clas_final; } @@ -357,10 +357,10 @@ void MDCT_classifier_reset( TCX_ENC_HANDLE hTcxEnc /* i/o: TCX Encoder Handle */ ) { - hTcxEnc->clas_sec_old = 1.0f; + hTcxEnc->clas_sec_old_flt = 1.0f; hTcxEnc->clas_final_old = 1; - hTcxEnc->last_gain1 = 0.0f; - hTcxEnc->last_gain2 = 0.0f; + hTcxEnc->last_gain1_flt = 0.0f; + hTcxEnc->last_gain2_flt = 0.0f; return; } diff --git a/lib_enc/mdct_selector.c b/lib_enc/mdct_selector.c index ebe268fc7..65dba4c20 100644 --- a/lib_enc/mdct_selector.c +++ b/lib_enc/mdct_selector.c @@ -191,7 +191,7 @@ void MDCT_selector( /* Allowed switching point? */ switching_point = ( last_core != HQ_CORE && last_core != TCX_20_CORE ) || /* previous core was non-MDCT */ - ( hTcxEnc->prev_hi_ener <= MDCT_SW_HI_ENER_LO_THR || hi_ener <= MDCT_SW_HI_ENER_LO_THR ) || /* hi band is close to silent */ + ( hTcxEnc->prev_hi_ener_flt <= MDCT_SW_HI_ENER_LO_THR || hi_ener <= MDCT_SW_HI_ENER_LO_THR ) || /* hi band is close to silent */ ( last_core == HQ_CORE && ( st->mdct_sw_enable == MODE1 || ( hi_sparse > 0 && hTcxEnc->prev_hi_sparse >= 0 && hTcxEnc->prev_hi_sparse <= 1 ) ) ) || /* HQ_CORE and hi band became sparse */ ( last_core == TCX_20_CORE && ( hi_sparse == 0 && hTcxEnc->prev_hi_sparse > 0 ) ); /* TCX and hi band became dense */ @@ -266,7 +266,7 @@ void MDCT_selector( hTcxEnc->prev_hi_sparse = 2; } } - hTcxEnc->prev_hi_ener = hi_ener; + hTcxEnc->prev_hi_ener_flt = hi_ener; } return; @@ -282,7 +282,7 @@ void MDCT_selector_reset( TCX_ENC_HANDLE hTcxEnc /* i/o: TCX Encoder Handle */ ) { - hTcxEnc->prev_hi_ener = 0; + hTcxEnc->prev_hi_ener_flt = 0; hTcxEnc->prev_hi_sparse = -1; return; diff --git a/lib_enc/peak_vq_enc.c b/lib_enc/peak_vq_enc.c index 27943ed61..f81945f27 100644 --- a/lib_enc/peak_vq_enc.c +++ b/lib_enc/peak_vq_enc.c @@ -188,7 +188,7 @@ int16_t peak_vq_enc( pgain_q[i] *= 4.0f; manPkEnrg = manPkEnrg_tbl[pgain_cb_idx[i]]; expPkEnrg = expPkEnrg_tbl[pgain_cb_idx[i]]; - floating_point_add( &manE_peak, &expE_peak, manPkEnrg, expPkEnrg ); + floating_point_add_float( &manE_peak, &expE_peak, manPkEnrg, expPkEnrg ); } /* Huffman coding */ diff --git a/lib_enc/pitch_ol2.c b/lib_enc/pitch_ol2.c index b7864e758..fdeefb83f 100644 --- a/lib_enc/pitch_ol2.c +++ b/lib_enc/pitch_ol2.c @@ -184,7 +184,7 @@ void StableHighPitchDetect( int16_t T, Tp, pit_min; float voicing_m; - float energy0, energy1, ratio, cor_max, diff, sum_energy; + float energy0, energy1, ratio_float, cor_max, diff, sum_energy; const float *pt_wsp; voicing_m = mean( voicing, 3 ); @@ -220,12 +220,12 @@ void StableHighPitchDetect( /* short pitch possiblity pre-decision */ maximum( Bin_E, 7, &energy0 ); maximum( Bin_E + 8, 7, &energy1 ); - ratio = max( energy1 - energy0, 0 ); - ratio *= max( voicing_m, 0 ); + ratio_float = max( energy1 - energy0, 0 ); + ratio_float *= max( voicing_m, 0 ); - *LF_EnergyRatio_sm = ( 15 * ( *LF_EnergyRatio_sm ) + ratio ) / 16; + *LF_EnergyRatio_sm = ( 15 * ( *LF_EnergyRatio_sm ) + ratio_float ) / 16; - if ( *LF_EnergyRatio_sm > 35 || ratio > 50 ) + if ( *LF_EnergyRatio_sm > 35 || ratio_float > 50 ) { *predecision_flag = 1; } diff --git a/lib_enc/plc_enc_ext.c b/lib_enc/plc_enc_ext.c index 8e5cfc382..fc52cac5c 100644 --- a/lib_enc/plc_enc_ext.c +++ b/lib_enc/plc_enc_ext.c @@ -74,9 +74,9 @@ void init_PLC_enc( hPlcExt->T0 = L_SUBFR; for ( itr = 0; itr < M; itr++ ) { - hPlcExt->lsf_con[itr] = lsf_init[itr]; - hPlcExt->last_lsf_ref[itr] = lsf_init[itr]; - hPlcExt->last_lsf_con[itr] = lsf_init[itr]; + hPlcExt->lsf_con_flt[itr] = lsf_init[itr]; + hPlcExt->last_lsf_ref_flt[itr] = lsf_init[itr]; + hPlcExt->last_lsf_con_flt[itr] = lsf_init[itr]; } } else @@ -85,9 +85,9 @@ void init_PLC_enc( hPlcExt->T0 = L_SUBFR; for ( itr = 0; itr < M; itr++ ) { - hPlcExt->lsf_con[itr] = lsf_init[itr] * 1.25f; - hPlcExt->last_lsf_ref[itr] = lsf_init[itr] * 1.25f; - hPlcExt->last_lsf_con[itr] = lsf_init[itr] * 1.25f; + hPlcExt->lsf_con_flt[itr] = lsf_init[itr] * 1.25f; + hPlcExt->last_lsf_ref_flt[itr] = lsf_init[itr] * 1.25f; + hPlcExt->last_lsf_con_flt[itr] = lsf_init[itr] * 1.25f; } } diff --git a/lib_enc/pre_proc.c b/lib_enc/pre_proc.c index b12ee3410..904fdcc4b 100644 --- a/lib_enc/pre_proc.c +++ b/lib_enc/pre_proc.c @@ -175,13 +175,13 @@ void pre_proc( modify_Fs( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim, ( st->max_bwidth == NB ) ); /* save input resampled at 12.8kHz, non-preemhasised */ - mvr2r( new_inp_12k8, st->buf_speech_enc + L_FRAME32k, L_FRAME ); + mvr2r( new_inp_12k8, st->buf_speech_enc_flt + L_FRAME32k, L_FRAME ); /*------------------------------------------------------------------* * Perform fixed preemphasis (12.8 kHz signal) through 1 - g*z^-1 *-----------------------------------------------------------------*/ - preemph( new_inp_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph ); + preemph( new_inp_12k8, PREEMPH_FAC_FLT, L_FRAME, &st->mem_preemph ); /*-------------------------------------------------------------------------* * Spectral analysis @@ -272,7 +272,7 @@ void pre_proc( SetModeIndex( st, st->last_total_brate, EVS_MONO, 0 ); } - calcLoEnvCheckCorrHiLo( st->cldfbAnaEnc->no_col, freqTable, st->hTECEnc->loBuffer, st->hTECEnc->loTempEnv, st->hTECEnc->loTempEnv_ns, st->hTECEnc->hiTempEnv, &( st->hTECEnc->corrFlag ) ); + calcLoEnvCheckCorrHiLo( st->cldfbAnaEnc->no_col, freqTable, st->hTECEnc->loBuffer_flt, st->hTECEnc->loTempEnv_flt, st->hTECEnc->loTempEnv_ns_flt, st->hTECEnc->hiTempEnv_flt, &( st->hTECEnc->corrFlag ) ); /*---------------------------------------------------------------* * Time Domain Transient Detector @@ -307,7 +307,7 @@ void pre_proc( * 1/4 pitch precision improvement *----------------------------------------------------------------*/ - find_wsp( L_FRAME, L_SUBFR, NB_SUBFR, A, Aw, inp_12k8, TILT_FAC, wsp, &st->mem_wsp, GAMMA1, L_look ); + find_wsp( L_FRAME, L_SUBFR, NB_SUBFR, A, Aw, inp_12k8, TILT_FAC, wsp, &st->mem_wsp, GAMMA1_FLT, L_look ); if ( st->vad_flag == 0 ) { @@ -363,7 +363,7 @@ void pre_proc( * UC and VC frame selection *-----------------------------------------------------------------*/ - find_tilt( fr_bands, st->hNoiseEst->bckr, ee, st->pitch, st->voicing, lf_E, corr_shift, st->input_bwidth, st->max_band, hp_E, st->codec_mode, &( st->bckr_tilt_lt ), st->Opt_SC_VBR ); + find_tilt( fr_bands, st->hNoiseEst->bckr, ee, st->pitch, st->voicing, lf_E, corr_shift, st->input_bwidth, st->max_band, hp_E, st->codec_mode, &( st->bckr_tilt_lt_flt), st->Opt_SC_VBR ); st->coder_type = find_uv( st, pitch_fr, voicing_fr, inp_12k8, ee, NULL, corr_shift, relE, Etot, hp_E, &flag_spitch, last_core_orig, NULL ); @@ -466,13 +466,13 @@ void pre_proc( if ( st->L_frame == L_FRAME ) { - st->gamma = GAMMA1; - st->preemph_fac = PREEMPH_FAC; + st->gamma_flt = GAMMA1_FLT; + st->preemph_fac_flt = PREEMPH_FAC_FLT; } else { - st->gamma = GAMMA16k; - st->preemph_fac = PREEMPH_FAC_16k; + st->gamma_flt = GAMMA16k_FLT; + st->preemph_fac_flt = PREEMPH_FAC_16k_FLT; } st->sr_core = st->L_frame * FRAMES_PER_SEC; @@ -603,13 +603,13 @@ void pre_proc( if ( st->sr_core == INT_FS_12k8 ) { - st->preemph_fac = PREEMPH_FAC; - st->gamma = GAMMA1; + st->preemph_fac_flt = PREEMPH_FAC_FLT; + st->gamma_flt = GAMMA1_FLT; } else { - st->preemph_fac = PREEMPH_FAC_16k; - st->gamma = GAMMA16k; + st->preemph_fac_flt = PREEMPH_FAC_16k_FLT; + st->gamma_flt = GAMMA16k_FLT; } st->igf = getIgfPresent( EVS_MONO, st->total_brate, st->bwidth, st->rf_mode ); @@ -780,12 +780,12 @@ void pre_proc( if ( ( st->tcxonly == 0 || st->codec_mode == MODE1 ) && st->input_Fs > 8000 ) { - st->mem_preemph_enc = new_inp_16k[L_frame_tmp - 1]; + st->mem_preemph_enc_flt = new_inp_16k[L_frame_tmp - 1]; } if ( st->input_Fs > 8000 && sr_core_tmp == INT_FS_16k ) { - preemph( new_inp_16k, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k ) ); + preemph( new_inp_16k, PREEMPH_FAC_16k_FLT, L_FRAME16k, &( st->mem_preemph16k ) ); } else if ( st->input_Fs > 8000 ) /* keep memory up-to-date in case of bitrate switching */ { @@ -802,8 +802,8 @@ void pre_proc( ( st->L_frame == L_FRAME16k && st->codec_mode == MODE1 ) ) { /* update signal buffers */ - mvr2r( new_inp_resamp16k, st->buf_speech_enc + L_FRAME16k, L_FRAME16k ); - mvr2r( new_inp_16k, st->buf_speech_enc_pe + L_FRAME16k, L_FRAME16k ); + mvr2r( new_inp_resamp16k, st->buf_speech_enc_flt + L_FRAME16k, L_FRAME16k ); + mvr2r( new_inp_16k, st->buf_speech_enc_pe_flt + L_FRAME16k, L_FRAME16k ); /*--------------------------------------------------------------* * LPC analysis @@ -823,22 +823,22 @@ void pre_proc( if ( st->codec_mode == MODE2 ) { - find_wsp( L_FRAME16k, L_SUBFR, st->nb_subfr, A, Aw, st->speech_enc_pe, PREEMPH_FAC_16k, st->wspeech_enc, &st->mem_wsp_enc, st->gamma, L_LOOK_16k ); + find_wsp( L_FRAME16k, L_SUBFR, st->nb_subfr, A, Aw, st->speech_enc_pe_flt, PREEMPH_FAC_16k_FLT, st->wspeech_enc_flt, &st->mem_wsp_enc_flt, st->gamma_flt, L_LOOK_16k ); } else { - weight_a_subfr( NB_SUBFR16k, A, Aw, GAMMA16k, M ); + weight_a_subfr( NB_SUBFR16k, A, Aw, GAMMA16k_FLT, M ); } } else { /* update signal buffers */ - mvr2r( new_inp_12k8, st->buf_speech_enc_pe + st->L_frame, L_FRAME ); - mvr2r( st->buf_speech_enc + L_FRAME32k, st->buf_speech_enc + st->L_frame, L_FRAME ); + mvr2r( new_inp_12k8, st->buf_speech_enc_pe_flt + st->L_frame, L_FRAME ); + mvr2r( st->buf_speech_enc_flt + L_FRAME32k, st->buf_speech_enc_flt + st->L_frame, L_FRAME ); if ( st->tcxonly == 0 ) { - mvr2r( wsp, st->wspeech_enc, L_FRAME + L_LOOK_12k8 ); + mvr2r( wsp, st->wspeech_enc_flt, L_FRAME + L_LOOK_12k8 ); } } diff --git a/lib_enc/q_gain2p.c b/lib_enc/q_gain2p.c index c03f5c430..e7a941a5d 100644 --- a/lib_enc/q_gain2p.c +++ b/lib_enc/q_gain2p.c @@ -189,9 +189,9 @@ int16_t Mode2_gain_enc_mless( } coeff = *pcoeff; - coeff.xy1 *= -2.0f; - coeff.xy2 *= -2.0f; - coeff.y1y2 *= 2.0f; + coeff.xy1_flt *= -2.0f; + coeff.xy2_flt *= -2.0f; + coeff.y1y2_flt *= 2.0f; /*-----------------------------------------------------------------* * search for the best quantizer @@ -206,7 +206,7 @@ int16_t Mode2_gain_enc_mless( g_pitch = (float) ( *p++ ) / ( 1 << 14 ); /* pitch gain */ g_code = gcode0 * (float) ( *p++ ) / ( 1 << 11 ); /* codebook gain */ - dist = g_pitch * g_pitch * coeff.y1y1 + g_pitch * coeff.xy1 + g_code * g_code * coeff.y2y2 + g_code * coeff.xy2 + g_pitch * g_code * coeff.y1y2; + dist = g_pitch * g_pitch * coeff.y1y1_flt + g_pitch * coeff.xy1_flt + g_code * g_code * coeff.y2y2_flt + g_code * coeff.xy2_flt + g_pitch * g_code * coeff.y1y2_flt; if ( dist < dist_min ) { @@ -252,7 +252,7 @@ static int16_t gain_enc_uv( *gain_inov = 1.0f / (float) sqrt( ( dotp( code, code, lcode ) + 0.01f ) / lcode ); - g_code_corr = coeff->xy2 / ( coeff->y2y2 * ( *gain_inov ) ); /*Correlation based*/ + g_code_corr = coeff->xy2_flt / ( coeff->y2y2_flt * ( *gain_inov ) ); /*Correlation based*/ g_code = g_code_corr; @@ -328,7 +328,7 @@ int16_t gain_enc_gacelp_uv( * search for the best quantizer *-----------------------------------------------------------------*/ - *gain_code = coeff->xy2 / ( coeff->y2y2 * gcode ); + *gain_code = coeff->xy2_flt / ( coeff->y2y2_flt * gcode ); if ( *gain_code > 0.000001f ) { @@ -353,22 +353,22 @@ int16_t gain_enc_gacelp_uv( if ( noisy_speech_flag ) { - c_first = 0.8f * coeff->xx - ( *gain_code ) * ( *gain_code ) * coeff->y2y2; + c_first = 0.8f * coeff->xx_flt - ( *gain_code ) * ( *gain_code ) * coeff->y2y2_flt; } else { - c_first = coeff->xx - ( *gain_code ) * ( *gain_code ) * coeff->y2y2; + c_first = coeff->xx_flt - ( *gain_code ) * ( *gain_code ) * coeff->y2y2_flt; } index2 = 0; *gain_code2 = (float) ( index2 * 0.25f + 0.25f ) * ( *gain_code * ( gcode2 / gcode ) ); - c_index2 = c_first - ( *gain_code2 ) * ( *gain_code2 ) * coeff->y1y1 - 2 * ( *gain_code ) * ( *gain_code2 ) * coeff->y1y2; + c_index2 = c_first - ( *gain_code2 ) * ( *gain_code2 ) * coeff->y1y1_flt - 2 * ( *gain_code ) * ( *gain_code2 ) * coeff->y1y2_flt; for ( i = 1; i < 4; i++ ) { *gain_code2 = (float) ( i * 0.25f + 0.25f ) * ( *gain_code * ( gcode2 / gcode ) ); - c = c_first - ( *gain_code2 ) * ( *gain_code2 ) * coeff->y1y1 - 2 * ( *gain_code ) * ( *gain_code2 ) * coeff->y1y2; + c = c_first - ( *gain_code2 ) * ( *gain_code2 ) * coeff->y1y1_flt - 2 * ( *gain_code ) * ( *gain_code2 ) * coeff->y1y2_flt; if ( fabs( c ) < fabs( c_index2 ) ) { diff --git a/lib_enc/range_enc.c b/lib_enc/range_enc.c index 9074c9a9a..c7e1287ed 100644 --- a/lib_enc/range_enc.c +++ b/lib_enc/range_enc.c @@ -91,7 +91,7 @@ void rc_encode( uint32_t inv_tot; int16_t exp; - inv_tot = UL_inverse( tot, &exp ); + inv_tot = UL_inverse_float( tot, &exp ); tmp = UMult_32_32( hPVQ->rc_range, inv_tot ); r = tmp >> ( exp - 32 ); tmp = r * cum_freq; @@ -128,7 +128,7 @@ void rc_enc_finish( uint32_t val, mask, high; int16_t bits, over1, over2; - bits = norm_ul( hPVQ->rc_range ) + 1; /* aligned to BASOP */ + bits = norm_ul_float( hPVQ->rc_range ) + 1; /* aligned to BASOP */ mask = 0xffffffff >> bits; val = hPVQ->rc_low + mask; @@ -292,7 +292,7 @@ void rc_enc_uniform( { int16_t n; - n = 32 - norm_ul( tot - 1 ); /* aligned to BASOP */ + n = 32 - norm_ul_float( tot - 1 ); /* aligned to BASOP */ if ( n <= 8 ) { diff --git a/lib_enc/rst_enc.c b/lib_enc/rst_enc.c index 023f1998c..d940e4bd6 100644 --- a/lib_enc/rst_enc.c +++ b/lib_enc/rst_enc.c @@ -56,15 +56,15 @@ void CNG_reset_enc( init_gp_clip( st->clip_var ); mvr2r( UVWB_Ave, st->mem_AR, M ); set_f( st->mem_MA, 0, M ); - st->hLPDmem->mem_w0 = 0.0f; - st->hLPDmem->tilt_code = 0.0f; - st->hLPDmem->gc_threshold = 0.0f; + st->hLPDmem->mem_w0_flt = 0.0f; + st->hLPDmem->tilt_code_flt = 0.0f; + st->hLPDmem->gc_threshold_flt = 0.0f; if ( VBR_cng_reset_flag ) { - set_f( st->hLPDmem->mem_syn, 0, M ); + set_f( st->hLPDmem->mem_syn_flt, 0, M ); } - set_f( st->hLPDmem->dispMem, 0, 8 ); + set_f( st->hLPDmem->dispMem_flt, 0, 8 ); /* last good received frame for FEC in ACELP */ st->clas = UNVOICED_CLAS; diff --git a/lib_enc/sig_clas.c b/lib_enc/sig_clas.c index 3e282c4bc..04fe8b4ba 100644 --- a/lib_enc/sig_clas.c +++ b/lib_enc/sig_clas.c @@ -173,8 +173,8 @@ int16_t signal_clas( * FEC classification *-----------------------------------------------------------------*/ - st->fmerit_dt = st->prev_fmerit - fmerit1; - st->prev_fmerit = fmerit1; + st->fmerit_dt_flt = st->prev_fmerit_flt - fmerit1; + st->prev_fmerit_flt = fmerit1; /* FEC classification */ if ( st->localVAD == 0 || st->coder_type == UNVOICED || relE < -6.0f ) diff --git a/lib_enc/speech_music_classif.c b/lib_enc/speech_music_classif.c index 5b50391c0..9da8cea07 100644 --- a/lib_enc/speech_music_classif.c +++ b/lib_enc/speech_music_classif.c @@ -211,12 +211,12 @@ void speech_music_clas_init( /* speech/music classification */ set_s( hSpMusClas->lt_old_mode, 1, 3 ); - hSpMusClas->lt_voicing = 0.5f; - hSpMusClas->lt_corr = 0.5f; - hSpMusClas->lt_tonality = 0; + hSpMusClas->lt_voicing_flt = 0.5f; + hSpMusClas->lt_corr_flt = 0.5f; + hSpMusClas->lt_tonality_flt = 0; set_s( hSpMusClas->lt_corr_pitch, 0, 3 ); hSpMusClas->lt_hangover = 0; - hSpMusClas->lowrate_pitchGain = 0; + hSpMusClas->lowrate_pitchGain_flt = 0; hSpMusClas->lt_music_hangover = 0; set_f( hSpMusClas->tonality2_buf, 0, HANG_LEN_INIT ); @@ -2620,19 +2620,19 @@ static void tonal_context_improv( mvr2r( PS, sort_val, 80 ); /* tonality in band 0-1 kHz */ - v_sort( sort_val, 0, 19 ); + v_sort_float( sort_val, 0, 19 ); sort_max = sort_val[19]; sort_avg = sum_f( &sort_val[0], 10 ); tonality1 = sort_max / sort_avg; /* tonality in band 1-2 kHz */ - v_sort( sort_val, 20, 39 ); + v_sort_float( sort_val, 20, 39 ); sort_max = sort_val[39]; sort_avg = sum_f( &sort_val[20], 10 ); tonality2 = sort_max / sort_avg; /* tonality in band 2-4 kHz */ - v_sort( sort_val, 40, 79 ); + v_sort_float( sort_val, 40, 79 ); sort_max = sort_val[79]; sort_avg = sum_f( &sort_val[40], 20 ); tonality3 = sort_max / sort_avg; @@ -2642,24 +2642,24 @@ static void tonal_context_improv( if ( st->hVAD->hangover_cnt == 10 && st->vad_flag == 1 ) { /* long-term voicing parameter */ - hSpMusClas->lt_voicing = 0.1f * hSpMusClas->lt_voicing + 0.9f * *st->voicing; + hSpMusClas->lt_voicing_flt = 0.1f * hSpMusClas->lt_voicing_flt + 0.9f * *st->voicing; /* long-term correlation value */ - hSpMusClas->lt_corr = 0.1f * hSpMusClas->lt_corr + 0.9f * st->old_corr; + hSpMusClas->lt_corr_flt = 0.1f * hSpMusClas->lt_corr_flt + 0.9f * st->old_corr; /* long-term tonality measure */ - hSpMusClas->lt_tonality = 0.1f * hSpMusClas->lt_tonality + 0.9f * tonality; + hSpMusClas->lt_tonality_flt = 0.1f * hSpMusClas->lt_tonality_flt + 0.9f * tonality; } else { /* long-term voicing parameter */ - hSpMusClas->lt_voicing = 0.7f * hSpMusClas->lt_voicing + 0.3f * *st->voicing; + hSpMusClas->lt_voicing_flt = 0.7f * hSpMusClas->lt_voicing_flt + 0.3f * *st->voicing; /* long-term correlation value */ - hSpMusClas->lt_corr = 0.7f * hSpMusClas->lt_corr + 0.3f * st->old_corr; + hSpMusClas->lt_corr_flt = 0.7f * hSpMusClas->lt_corr_flt + 0.3f * st->old_corr; /* long-term tonality measure */ - hSpMusClas->lt_tonality = 0.5f * hSpMusClas->lt_tonality + 0.5f * tonality; + hSpMusClas->lt_tonality_flt = 0.5f * hSpMusClas->lt_tonality_flt + 0.5f * tonality; } /* pitch difference w.r.t to past 3 frames */ @@ -2677,11 +2677,11 @@ static void tonal_context_improv( if ( st->sp_aud_decision1 == 1 && ( min( min( tonality1, tonality2 ), tonality3 ) > 50.0f ) && ( tonality1 + tonality2 > 200.0f && tonality2 + tonality3 > 200.0f && tonality1 + tonality3 > 200.0f ) && - ( hSpMusClas->lt_tonality < 20000.0f ) && - ( ( hSpMusClas->lt_tonality > 1000 && max( hSpMusClas->lt_voicing, *st->voicing ) > 0.99f ) || - ( hSpMusClas->lt_tonality > 1500 && hSpMusClas->lt_corr > 0.99f ) || - ( hSpMusClas->lt_tonality > 3000 && hSpMusClas->lowrate_pitchGain > 0.96f ) || - ( lt_pitch_diff == 0 && hSpMusClas->lowrate_pitchGain > 0.89f ) ) ) + ( hSpMusClas->lt_tonality_flt < 20000.0f ) && + ( ( hSpMusClas->lt_tonality_flt > 1000 && max( hSpMusClas->lt_voicing_flt, *st->voicing ) > 0.99f ) || + ( hSpMusClas->lt_tonality_flt > 1500 && hSpMusClas->lt_corr_flt > 0.99f ) || + ( hSpMusClas->lt_tonality_flt > 3000 && hSpMusClas->lowrate_pitchGain_flt > 0.96f ) || + ( lt_pitch_diff == 0 && hSpMusClas->lowrate_pitchGain_flt > 0.89f ) ) ) { if ( sum_s( hSpMusClas->lt_old_mode, 2 ) < 2 ) { @@ -2715,7 +2715,7 @@ static void tonal_context_improv( hSpMusClas->tonality3_buf[HANG_LEN_INIT - 1] = 0.2f * log10f( tonality3 ); t3 = std_dev( hSpMusClas->tonality3_buf, HANG_LEN_INIT ); - tL = 0.2f * log10f( hSpMusClas->lt_tonality ); + tL = 0.2f * log10f( hSpMusClas->lt_tonality_flt); /* calculate standard deviation of residual LP energy */ mvr2r( hSpMusClas->LPCErr_buf + 1, hSpMusClas->LPCErr_buf, HANG_LEN_INIT - 1 ); diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 5c37656b7..4ce027a19 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -38,10 +38,12 @@ #define STAT_ENC_H #include +#include #include "options.h" #include "stat_com.h" #include "cnst.h" #include "ivas_cnst.h" +#include "stat_dec.h" /* Compilation switches */ /*------------------------------------------------------------------------------------------* * Indice @@ -54,6 +56,17 @@ typedef struct int16_t nb_bits; /* number of bits used for the quantization of the indice */ } Indice, *INDICE_HANDLE; +typedef struct +{ + Word16 s16Exp; + Word32 s32Mantissa; +} T_VAD_EXP; + +typedef struct +{ + Word32 low, high; + Word16 value; +} TastatEnc; /*----------------------------------------------------------------------------------* * Bitstream structure *----------------------------------------------------------------------------------*/ @@ -66,6 +79,12 @@ typedef struct bitstream_enc_data_structure int16_t *ivas_max_num_indices; /* maximum total number of indices in the list */ Indice **ivas_ind_list_zero; /* beginning of the buffer of indices */ void *st_ivas; /* IVAS encoder structure */ + + Word16 nb_bits_tot_fx; /* total number of bits already written */ + Indice* ind_list_fx; /* list of indices */ + Word16 next_ind_fx; /* pointer to the next empty slot in the list of indices */ + Word16 last_ind_fx; /* last written indice */ + } BSTR_ENC_DATA, *BSTR_ENC_HANDLE; /*----------------------------------------------------------------------------------* @@ -74,17 +93,30 @@ typedef struct bitstream_enc_data_structure typedef struct signal_buffers_enc_data_structure { - float input_buff[L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS )]; - - float Bin_E_old[L_FFT / 2]; /* per bin energy of old 2nd frames */ - float mem_decim[2 * L_FILT_MAX]; /* decimation filter memory */ - float mem_decim16k[2 * L_FILT_MAX]; /* ACELP@16kHz - decimation filter memory @16kHz */ - float old_inp_12k8[L_INP_MEM]; /* memory of input signal at 12.8kHz */ - float old_inp_16k[L_INP_MEM]; /* ACELP@16kHz - memory of input signal @16 kHz */ - float buf_speech_enc_pe[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; - float buf_synth[OLD_SYNTH_SIZE_ENC + L_FRAME32k]; /* can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching */ - float buf_speech_enc[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; - float buf_wspeech_enc[L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320]; /* increased by 320 to avoid memory overlap in find_wsp() and also to accomodate for the wspeech_enc */ + float input_buff_flt[L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS )]; + + float Bin_E_old_flt[L_FFT / 2]; /* per bin energy of old 2nd frames */ + float mem_decim_flt[2 * L_FILT_MAX]; /* decimation filter memory */ + float mem_decim16k_flt[2 * L_FILT_MAX]; /* ACELP@16kHz - decimation filter memory @16kHz */ + float old_inp_12k8_flt[L_INP_MEM]; /* memory of input signal at 12.8kHz */ + float old_inp_16k_flt[L_INP_MEM]; /* ACELP@16kHz - memory of input signal @16 kHz */ + float buf_speech_enc_pe_flt[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; + float buf_synth_flt[OLD_SYNTH_SIZE_ENC + L_FRAME32k]; /* can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching */ + float buf_speech_enc_flt[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; + float buf_wspeech_enc_flt[L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320]; /* increased by 320 to avoid memory overlap in find_wsp() and also to accomodate for the wspeech_enc */ + //Fixed + Word16 input_buff[L_FRAME48k + L_FRAME48k + NS2SA(48000, DELAY_FIR_RESAMPL_NS)]; + + Word32 Bin_E_old_fx[L_FFT / 2]; /* per bin energy of old 2nd frames */ + Word16 mem_decim_fx[2 * L_FILT_MAX]; /* decimation filter memory */ + Word16 mem_decim16k_fx[2 * L_FILT_MAX]; /* ACELP@16kHz - decimation filter memory @16kHz */ + Word16 old_inp_12k8_fx[L_INP_MEM]; /* memory of input signal at 12.8kHz */ + Word16 old_inp_16k_fx[L_INP_MEM]; /* ACELP@16kHz - memory of input signal @16 kHz */ + + Word16 buf_speech_enc_pe[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; + Word16 buf_synth[OLD_SYNTH_SIZE_ENC + L_FRAME32k]; + Word16 buf_speech_enc[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; + Word16 buf_wspeech_enc[L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k]; /*normally there is a lookahead for 12k8 and 16k but L_FRAME_MAX=L_FRAME_16K+L_NEXT_16k*/ } SIGNAL_BUFFERS_ENC_DATA, *SIGNAL_BUFFERS_ENC_HANDLE; @@ -97,7 +129,8 @@ typedef struct signal_buffers_enc_data_structure typedef struct { int16_t nSubblockSize; /* Subblock size of a transient detector that uses this delay buffer. */ - float buffer[L_FRAME_MAX / NSUBBLOCKS]; /* Delay buffer */ + float buffer_flt[L_FRAME_MAX / NSUBBLOCKS]; /* Delay buffer */ + Word16 buffer[L_FRAME48k / NSUBBLOCKS]; int16_t nDelay; /* Size of the delay buffer in use. Maximum delay from all users of this buffer. */ } DelayBuffer; @@ -106,20 +139,26 @@ typedef struct typedef struct { DelayBuffer *pDelayBuffer; /* Delay buffer. */ - float subblockNrg[NSUBBLOCKS + MAX_TD_DELAY]; /* Subblock energies with a delay buffering. */ - float accSubblockNrg[NSUBBLOCKS + MAX_TD_DELAY + 1]; /* Recursively accumulated subblock energies with a delay buffering. + float subblockNrg_flt[NSUBBLOCKS + MAX_TD_DELAY]; /* Subblock energies with a delay buffering. */ + Word32 subblockNrg[NSUBBLOCKS + MAX_TD_DELAY]; + float accSubblockNrg_flt[NSUBBLOCKS + MAX_TD_DELAY + 1]; /* Recursively accumulated subblock energies with a delay buffering. At index i the value corresponds to the accumulated subblock energy up to i-1, including block i-1 and without block i. */ - float subblockNrgChange[NSUBBLOCKS + MAX_TD_DELAY]; /* subblockNrgChange[i] = max(subblockNrg[i]/subblockNrg[i-1], subblockNrg[i-1]/subblockNrg[i]) */ + Word32 accSubblockNrg[NSUBBLOCKS + MAX_TD_DELAY + 1]; + float subblockNrgChange_flt[NSUBBLOCKS + MAX_TD_DELAY]; /* subblockNrgChange[i] = max(subblockNrg[i]/subblockNrg[i-1], subblockNrg[i-1]/subblockNrg[i]) */ + Word16 subblockNrgChange[NSUBBLOCKS + MAX_TD_DELAY]; int16_t nDelay; /* Size of the delay buffer in use, as number of subblocks. Maximum delay from all users of this buffer. */ int16_t nPartialDelay; /* Delay of the input (modulo pDelayBuffer->nSubblockSize), nPartialDelay <= pDelayBuffer->nDelay. */ /* Decay factor for the recursive accumulation */ - float facAccSubblockNrg; + float facAccSubblockNrg_flt; + Word16 facAccSubblockNrg; /* High-pass filter states (delay line) */ - float firState1; - float firState2; + float firState1_flt; + float firState2_flt; + Word16 firState1; + Word16 firState2; uint16_t ramp_up_flag; /* bit map flags to indicate a ramp up in beginning of TCX frame */ @@ -136,7 +175,8 @@ typedef struct TransientDetector int16_t nDelay; /* Delay of the transient detector in number of subblocks, nDelay <= pSubblockEnergies->nDelay. */ int16_t nSubblocksToCheck; /* Number of subblocks to check for transients. */ TCheckSubblocksForAttack CheckSubblocksForAttack; /* Function for checking a presence of an attack. */ - float attackRatioThreshold; /* Attack ratio threshold. */ + float attackRatioThreshold_flt; /* Attack ratio threshold. */ + Word16 attackRatioThreshold; int16_t bIsAttackPresent; /* True when an attack was detected. */ int16_t prev_bIsAttackPresent; /* True if an attack was detected in the previous frame. */ int16_t attackIndex; /* The index of an attack. */ @@ -173,6 +213,7 @@ typedef struct vad_structure int16_t hangover_cnt_music; float bcg_flux; + Word16 bcg_flux_fx; int16_t soft_hangover; int16_t voiced_burst; int16_t bcg_flux_init; @@ -185,13 +226,22 @@ typedef struct vad_structure float prim_act_quick_he; /* Noise estimator - primary activity quick */ float prim_act_slow_he; /* Noise estimator - primary activity slow */ float prim_act_he; /* Noise estimator - primary activity slow rise quick fall */ + Word16 prim_act_quick_fx; /* Noise estimator - primary activity quick */ + Word16 prim_act_slow_fx; /* Noise estimator - primary activity slow */ + Word16 prim_act_fx; /* Noise estimator - primary activity slow rise quick fall */ + Word16 prim_act_quick_he_fx; /* Noise estimator - primary activity quick */ + Word16 prim_act_slow_he_fx; /* Noise estimator - primary activity slow */ + Word16 prim_act_he_fx; /* Q15 Noise estimator - primary activity slow rise quick fall */ int16_t spectral_tilt_reset; int16_t consec_inactive; float ra_deltasum; + Word16 ra_deltasum_fx; int16_t trigger_SID; float running_avg; float snr_sum_vad; + Word16 running_avg_fx; /*Q15 */ + Word32 L_snr_sum_vad_fx; /*Q4*/ int16_t hangover_terminate_flag; /* CNG and DTX - flag indicating whether to early terminate DTX hangover */ int16_t vad_flag; /* VAD flag */ @@ -261,15 +311,20 @@ typedef struct td_cng_enc_structure int16_t lp_cng_mode2; float lp_ener; /* CNG and DTX - low-pass filtered energy for CNG */ + Word32 lp_ener_fx; /* CNG and DTX - low-pass filtered energy for CNG */ int16_t cng_seed; /* CNG and DTX - seed for white noise random generator */ int16_t old_enr_index; /* CNG and DTX - index of last encoded CNG energy */ float Enew; /* CNG and DTX - CNG target residual energy */ + Word32 Enew_fx; /* CNG and DTX - CNG target residual energy */ int16_t cng_hist_ptr; /* CNG and DTX - pointer for averaging buffers */ float cng_lsp_hist[DTX_HIST_SIZE * M]; /* CNG and DTX - old LSP buffer for averaging */ float cng_ener_hist[DTX_HIST_SIZE]; /* CNG and DTX - log energy buffer for averaging */ + Word16 cng_lsp_hist_fx[DTX_HIST_SIZE * M]; /* CNG and DTX - old LSP buffer for averaging */ + Word16 cng_ener_hist_fx[DTX_HIST_SIZE]; /* CNG and DTX - log energy buffer for averaging */ int16_t cng_ener_seed; /* CNG and DTX - seed for random generator for variation of excitation energy */ int16_t cng_ener_seed1; float lp_sp_enr; + Word16 lp_sp_enr_fx; /*Q8*/ int16_t last_allow_cn_step; int16_t ho_hist_size; /* CNG and DTX - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ int16_t ho_hist_ptr; /* CNG and DTX - pointer for averaging buffers */ @@ -277,6 +332,9 @@ typedef struct td_cng_enc_structure float ho_lsp_hist[HO_HIST_SIZE * M]; /* CNG and DTX - old LSP buffer for averaging */ float ho_ener_hist[HO_HIST_SIZE]; /* CNG and DTX - energy buffer for averaging */ float ho_env_hist[HO_HIST_SIZE * NUM_ENV_CNG]; + Word16 ho_lsp_circ_fx[HO_HIST_SIZE * M]; /* CNG and DTX - old LSP buffer for averaging */ + Word32 ho_ener_circ_fx[HO_HIST_SIZE]; /* CNG and DTX - energy buffer for averaging */ + Word32 ho_env_circ_fx[HO_HIST_SIZE * NUM_ENV_CNG]; int16_t act_cnt; /* CNG and DTX - counter of active frames */ int16_t ho_circ_size; /* CNG and DTX - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ int16_t ho_circ_ptr; /* CNG and DTX - pointer for averaging buffers */ @@ -285,12 +343,15 @@ typedef struct td_cng_enc_structure float ho_env_circ[HO_HIST_SIZE * NUM_ENV_CNG]; int16_t burst_ho_cnt; /* CNG and DTX - counter of hangover frames at end of active burst */ int16_t cng_buf_cnt; /* CNG and DTX - Counter of buffered CNG parameters */ - float cng_exc2_buf[HO_HIST_SIZE * L_FFT]; /* CNG and DTX - exc2 buffer for storing */ + float cng_exc2_buf_flt[HO_HIST_SIZE * L_FFT]; /* CNG and DTX - exc2 buffer for storing */ + Word16 cng_exc2_buf[HO_HIST_SIZE * L_FFT]; /* CNG and DTX - exc2 buffer for storing */ + Word16 cng_Qexc_buf[HO_HIST_SIZE]; /* CNG and DTX - Q_exc buffer for storing */ int32_t cng_brate_buf[HO_HIST_SIZE]; /* CNG and DTX - buffer for storing last_active_brate */ float CNG_att; /* CNG and DTX - attenuation factor for CNG, in dB */ int16_t ho_16k_lsp[HO_HIST_SIZE]; /* CNG and DTX - 16k LSPs flags */ int16_t act_cnt2; /* CNG and DTX - counter of active frames for CNG_mode switching */ float ho_lsp_circ2[HO_HIST_SIZE * M]; /* CNG and DTX - second buffer of LSPs */ + Word16 ho_lsp_circ2_fx[HO_HIST_SIZE * M]; /* CNG and DTX - second buffer of LSPs */ int16_t num_ho; /* CNG and DTX - number of selected hangover frames */ float old_env[NUM_ENV_CNG]; float lp_env[NUM_ENV_CNG]; @@ -298,7 +359,12 @@ typedef struct td_cng_enc_structure float exc_mem[24]; float exc_mem1[30]; float exc_mem2[30]; - + Word32 old_env_fx[NUM_ENV_CNG]; + Word32 lp_env_fx[NUM_ENV_CNG]; + Word32 cng_res_env_fx[NUM_ENV_CNG * HO_HIST_SIZE]; + Word16 exc_mem_fx[24]; + Word16 exc_mem1_fx[30]; + Word16 exc_mem2_fx[30]; /* SWB DTX/CNG parameters */ int16_t last_vad; @@ -306,6 +372,10 @@ typedef struct td_cng_enc_structure float last_shb_cng_ener; float mov_wb_cng_ener; float mov_shb_cng_ener; + Word16 last_wb_cng_ener_fx; + Word16 last_shb_cng_ener_fx; + Word16 mov_wb_cng_ener_fx; + Word16 mov_shb_cng_ener_fx; int16_t last_idx_ener; int16_t shb_cng_ini_cnt; int16_t last_SID_bwidth; @@ -369,13 +439,18 @@ typedef struct dtx_enc_structure int16_t max_SID; /* CNG and DTX - max allowed number of CNG FRAME_NO_DATA frames */ int16_t CNG_mode; /* CNG and DTX - mode for DTX configuration */ float lspCNG[M]; /* CNG and DTX - LP filtered ISPs */ + Word16 lspCNG_fx[M]; /* CNG and DTX - LP filtered lsps */ int16_t VarDTX_cnt_voiced; /* CNG and DTX - counter for variable DTX activation (speech) */ int16_t VarDTX_cnt_noise; /* CNG and DTX - counter for variable DTX activation (noise) */ float lt_ener_voiced; /* CNG and DTX - long-term energy of signal (measured on voiced parts) */ float lt_ener_noise; /* CNG and DTX - long-term energy of background noise */ float frame_ener; + Word32 lt_ener_voiced_fx; /* CNG and DTX - long-term energy of signal (measured on voiced parts) */ + Word32 lt_ener_noise_fx; /* CNG and DTX - long-term energy of background noise */ + Word32 frame_ener_fx; int16_t cng_hist_size; /* CNG and DTX - size of CNG history buffer for averaging, <0,DTX_HIST_SIZE> */ float lt_ener_last_SID; /* CNG and DTX - long-term energy of last SID frame */ + Word32 lt_ener_last_SID_fx; /* CNG and DTX - long-term energy of last SID frame */ int16_t last_CNG_L_frame; /* CNG and DTX - last CNG frame length */ int16_t var_SID_rate_flag; /* CNG and DTX - flag for variable SID rate */ int16_t interval_SID; /* CNG and DTX - interval of SID update, default 8 */ @@ -435,8 +510,10 @@ typedef struct igf_enc_private_data_struct float igfPastSFM[IGF_MAX_TILES][IGF_PAST_SFM_LEN]; int16_t igfPastSFM_pos; - float prevSFM_FIR[IGF_MAX_TILES]; - float prevSFM_IIR[IGF_MAX_TILES]; + float prevSFM_FIR_flt[IGF_MAX_TILES]; + float prevSFM_IIR_flt[IGF_MAX_TILES]; + Word32 prevSFM_FIR[IGF_MAX_TILES]; /* 15Q16 */ + Word16 prevSFM_IIR[IGF_MAX_TILES]; int16_t wasTransient; UWord8 igfBitstream[IGF_BITBUFSIZE / 8]; @@ -456,8 +533,11 @@ typedef struct igf_enc_instance_struct int16_t infoTotalBitsWritten; int16_t infoTotalBitsPerFrameWritten; int16_t flatteningTrigger; - float spec_be_igf[N_MAX_TCX - IGF_START_MN]; - float tns_predictionGain; + float spec_be_igf_flt[N_MAX_TCX - IGF_START_MN]; + float tns_predictionGain_flt; + Word32 spec_be_igf[N_MAX_TCX - IGF_START_MN]; /* copy of MDCT spectrum */ + Word16 spec_be_igf_e; /* exponent of copy of MDCT spectrum */ + Word16 tns_predictionGain; } IGF_ENC_INSTANCE, *IGF_ENC_INSTANCE_HANDLE; @@ -470,6 +550,8 @@ typedef struct noise_estimation_structure { float fr_bands1[NB_BANDS]; /* spectrum per critical bands of the previous frame */ float fr_bands2[NB_BANDS]; /* spectrum per critical bands 2 frames ago */ + Word32 fr_bands1_fx[NB_BANDS]; /* Q_new + Q_SCALE spectrum per critical bands of the previous frame */ + Word32 fr_bands2_fx[NB_BANDS]; /* Q_new + Q_SCALE spectrum per critical bands 2 frames ago */ float old_S[L_FFT / 2]; /* Tonal detector - prev. log-energy spectrum with subtracted floor */ float cor_map[L_FFT / 2]; /* Tonal detector - LT correlation map */ @@ -480,8 +562,20 @@ typedef struct noise_estimation_structure float enrO[NB_BANDS]; /* Noise estimator - previous energy per critical band */ float bckr[NB_BANDS]; /* Noise estimator - background noise estimation per critical band */ float ave_enr[NB_BANDS]; /* Noise estimator - long-term average energy per critical band */ + Word16 old_S_fx[L_FFT / 2]; /* Q7 Tonal detector - prev. log-energy spectrum with subtracted floor */ + Word16 cor_map_fx[L_FFT / 2]; /* Q15 Tonal detector - LT correlation map */ + Word16 noise_char_fx; /* Q11 Tonal detector - LT noise character */ + Word32 ave_enr2_fx[NB_BANDS]; /* Q_new + Q_SCALE Tonal detector - LT average E per crit. band (for non_sta2) */ + Word16 act_pred_fx; /* Q15 Tonal detector - prediction of speech activity from 0 to 1 (0-inactive, 1-active) */ + Word16 multi_harm_limit_fx; /* Q9 Tonal detector - adaptive threshold */ + Word32 enrO_fx[NB_BANDS]; /* Noise estimator - previous energy per critical band */ + Word32 bckr_fx[NB_BANDS]; /* Q_new + Q_SCALE Noise estimator - background noise estimation per critical band */ + Word32 ave_enr_fx[NB_BANDS]; /* Q_new + Q_SCALE Noise estimator - long-term average energy per critical band */ + int16_t aEn; /* Noise estimator - noise estimator adaptation flag */ float totalNoise; /* Noise estimator - total noise energy */ + Word16 totalNoise_fx; /* Q8 Noise estimator - total noise energy */ + int16_t first_noise_updt; /* Noise estimator - flag used to determine if the first noise update frame */ int16_t first_noise_updt_cnt; /* Noise estimator - counter of frame after first noise update */ int16_t harm_cor_cnt; /* Noise estimator - 1st memory counter of harm or correlation frame */ @@ -495,6 +589,15 @@ typedef struct noise_estimation_structure float lt_tn_dist; float lt_Ellp_dist; float lt_haco_ev; + Word16 Etot_l_fx; /* Q8 Noise estimator - Track energy from below */ + Word16 Etot_h_fx; /* Q8 Noise estimator - Track energy from above */ + Word16 Etot_l_lp_fx; /* Q8 Noise estimator - Smoothed low energy */ + Word16 Etot_last_fx; /*Q8*/ + Word16 Etot_lp_fx; /* Q8 Noise estimator - Filtered input energy */ + Word16 lt_tn_track_fx; /* Q15 */ + Word16 lt_tn_dist_fx; /* Q8*/ + Word16 lt_Ellp_dist_fx; /* Etot low lp same domain as *Etot_l_lp, Q8 */ + Word16 lt_haco_ev_fx; /* Q15 */ int16_t low_tn_track_cnt; float epsP_0_2_lp; float epsP_0_2_ad_lp; @@ -503,11 +606,22 @@ typedef struct noise_estimation_structure float epsP_2_16_dlp_lp; float epsP_2_16_dlp_lp2; float lt_aEn_zero; + Word16 epsP_0_2_lp_fx; /* Q12, all epsP quotas , range ]8.0 ..0]*/ + Word16 epsP_0_2_ad_lp_fx; + Word16 epsP_2_16_lp_fx; + Word16 epsP_2_16_lp2_fx; + Word16 epsP_2_16_dlp_lp2_fx; /* Q12 */ + Word16 lt_aEn_zero_fx; /* Q15 */ float Etot_v_h2; float sign_dyn_lp; float Etot_st_est; /* Noise estimation - short term estimate of E{ Etot } */ float Etot_sq_st_est; /* Noise estimation - short term estimate of E{ Etot^2 } */ + Word16 Etot_v_h2_fx; + Word16 sign_dyn_lp_fx; /*Q8*/ + Word16 Etot_st_est_fx; /* Q8 Noise estimation - short term estimate of E{ Etot } */ + Word16 Etot_sq_st_est_fx; /* Q2 Noise estimation - short term estimate of E{ Etot^2 } */ + int16_t aEn_inac_cnt; } NOISE_EST_DATA, *NOISE_EST_HANDLE; @@ -521,17 +635,23 @@ typedef struct sp_mus_clas_structure float FV_st[N_SMC_FEATURES]; /* Speech/music classifier - short-term mean of the feature vector */ float past_PS[HIGHEST_FBIN - LOWEST_FBIN]; float past_ps_diff; + Word32 past_PS_fx[HIGHEST_FBIN - LOWEST_FBIN]; + Word16 past_ps_diff_fx; float prev_FV[N_SMC_FEATURES]; float past_epsP; float past_epsP2; + Word16 past_epsP2_fx; int16_t inact_cnt; float wdrop; + Word16 wdrop_fx; float wrise; float wdlp_0_95_sp; + Word16 wdlp_0_95_sp_fx; float wdlp_xtalk; int16_t sp_mus_state; int16_t past_dec[HANG_LEN - 1]; /* Speech/music classifier - buffer of past binary decisions */ float past_dlp[HANG_LEN - 1]; /* Speech/music classifier - buffer of past non-binary decisions */ + Word16 past_dlp_fx[HANG_LEN - 1]; float past_dlp_mean_ST[HANG_LEN - 1]; /* Speech/music classifier - buffer of past non-binary decisions (with ST smoothing) */ float dlp_mean_ST; int16_t flag_spitch_cnt; @@ -544,6 +664,14 @@ typedef struct sp_mus_clas_structure float gsc_thres[4]; /* Speech/music classifier - classification threshold */ float gsc_lt_diff_etot[MAX_LT]; /* Speech/music classifier - long-term total energy variation */ float gsc_mem_etot; /* Speech/music classifier - total energy memory */ + Word16 last_lsp_fx[M_LSP_SPMUS]; + Word16 last_cor_map_sum_fx; + Word16 last_non_sta_fx; + Word16 past_log_enr_fx[NB_BANDS_SPMUS]; /* Speech/music classifier - last average per-band log energy used for non_staX */ + Word16 gsc_thres_fx[4]; /* Speech/music classifier - classification threshold */ + Word16 gsc_lt_diff_etot_fx[MAX_LT]; /* Speech/music classifier - long-term total energy variation */ + Word16 gsc_mem_etot_fx; /* Speech/music classifier - total energy memory */ + int16_t gsc_last_music_flag; /* Speech/music classifier - last music flag */ int16_t gsc_nb_thr_1; /* Speech/music classifier - number of consecutives frames of level 1 */ int16_t gsc_nb_thr_3; /* Speech/music classifier - number of consecutives frames of level 3 */ @@ -552,6 +680,11 @@ typedef struct sp_mus_clas_structure float last_sw_dyn; /* Speech/music classifier - last dynamic */ float lt_dec_thres; /* Speech/music classifier - Long term speech/music thresold values */ float ener_RAT; /* Speech/music classifier - LF/to total energy ratio */ + Word16 mold_corr_fx; + Word16 mean_avr_dyn_fx; /* Q7 Speech/music classifier - long term average dynamic */ + Word16 last_sw_dyn_fx; /* Q7 Speech/music classifier - last dynamic */ + Word16 lt_dec_thres_fx; /* Speech/music classifier - Long term speech/music thresold values */ + Word16 ener_RAT_fx; /* Q15 Speech/music classifier - LF/to total energy ratio */ int16_t relE_attack_cnt; float prev_relE; @@ -570,15 +703,31 @@ typedef struct sp_mus_clas_structure float buf_Ntonal2[BUF_LEN]; float buf_Ntonal_lf[BUF_LEN]; float buf_dlp[10]; + Word16 old_Bin_E_fx[3 * N_OLD_BIN_E]; + Word16 buf_flux_fx[BUF_LEN]; + Word16 buf_pkh_fx[BUF_LEN]; + Word16 buf_epsP_tilt_fx[BUF_LEN]; + Word16 buf_cor_map_sum_fx[BUF_LEN]; + Word16 buf_Ntonal_fx[BUF_LEN]; + Word16 buf_Ntonal2_fx[BUF_LEN]; + Word16 buf_Ntonal_lf_fx[BUF_LEN]; + Word16 buf_dlp_fx[10]; + int16_t onset_cnt; float buf_etot[4]; + Word16 buf_etot_fx[4]; int16_t attack_hangover; float dec_mov; float dec_mov1; float mov_log_max_spl; float old_lt_diff[2]; + Word16 dec_mov_fx; + Word16 dec_mov1_fx; + Word16 mov_log_max_spl_fx; + Word16 old_lt_diff_fx[2]; int16_t UV_cnt1; float LT_UV_cnt1; + Word16 LT_UV_cnt1_fx; float finc_prev[ATT_NSEG]; /* strong attack detection - previous finc */ float lt_finc; /* strong attack detection - long-term finc energy */ @@ -594,33 +743,49 @@ typedef struct sp_mus_clas_structure float tonality2_buf[HANG_LEN_INIT]; float tonality3_buf[HANG_LEN_INIT]; float LPCErr_buf[HANG_LEN_INIT]; + Word16 tonality2_buf_fx[HANG_LEN_INIT]; + Word16 tonality3_buf_fx[HANG_LEN_INIT]; + Word16 LPCErr_buf_fx[HANG_LEN_INIT]; int16_t lt_music_state; int16_t lt_speech_state; int16_t lt_speech_hangover; float lpe_buf[HANG_LEN_INIT]; float voicing_buf[HANG_LEN_INIT]; + Word16 lpe_buf_fx[HANG_LEN_INIT]; + Word16 voicing_buf_fx[HANG_LEN_INIT]; int16_t gsc_hangover; float sparse_buf[HANG_LEN_INIT]; float hf_spar_buf[HANG_LEN_INIT]; float LT_sparse; + Word16 sparse_buf_fx[HANG_LEN_INIT]; + Word16 hf_spar_buf_fx[HANG_LEN_INIT]; + Word16 LT_sparse_fx; int16_t gsc_cnt; /* speech/music classification */ int16_t last_vad_spa; int16_t lt_old_mode[3]; - float lt_voicing; - float lt_corr; - float lt_tonality; + float lt_voicing_flt; + float lt_corr_flt; + float lt_tonality_flt; + Word16 lt_voicing; + Word16 lt_corr; + Word32 lt_tonality; int16_t lt_corr_pitch[3]; int16_t lt_hangover; - float lowrate_pitchGain; + float lowrate_pitchGain_flt; + Word16 lowrate_pitchGain; float tdm_lt_Etot; float var_cor_t[VAR_COR_LEN]; + Word16 var_cor_t_fx[VAR_COR_LEN]; int16_t high_stable_cor; float lps; float lpm; + Word16 lps_fx; + Word16 lpm_fx; + float lpn; } SP_MUS_CLAS_DATA, *SP_MUS_CLAS_HANDLE; @@ -632,21 +797,35 @@ typedef struct sp_mus_clas_structure typedef struct lpd_state_structure { + Word16 nbits; /* number of bits used by ACELP or TCX */ + /* signal memory */ - float syn[1 + M]; /* Synthesis memory (non-pe) */ + float syn_flt[1 + M]; /* Synthesis memory (non-pe) */ + Word16 syn[1 + M]; /* Synthesis memory (non-pe) */ /* ACELP memories*/ - float old_exc[L_EXC_MEM]; /* ACELP exc memory (Aq) */ - float mem_w0; - float mem_syn[M]; /* ACELP synthesis memory (pe) before post-proc */ - float mem_syn1[M]; - float mem_syn2[M]; /* ACELP synthesis memory (pe) after post-proc */ - float mem_syn_r[L_SYN_MEM]; /* ACELP synthesis memory for 1.25ms */ - float mem_syn3[M]; - - float tilt_code; - float gc_threshold; /* Noise enhancer - threshold for gain_code */ - float dispMem[8]; /* Noise enhancer - phase dispersion algorithm memory */ + float old_exc_flt[L_EXC_MEM]; /* ACELP exc memory (Aq) */ + Word16 old_exc[L_EXC_MEM]; /* ACELP exc memory (Aq) */ + + float mem_w0_flt; + float mem_syn_flt[M]; /* ACELP synthesis memory (pe) before post-proc */ + float mem_syn1_flt[M]; + float mem_syn2_flt[M]; /* ACELP synthesis memory (pe) after post-proc */ + float mem_syn_r_flt[L_SYN_MEM]; /* ACELP synthesis memory for 1.25ms */ + float mem_syn3_flt[M]; + Word16 mem_syn[M]; /* ACELP synthesis memory (pe) before post-proc */ + Word16 mem_syn1_fx[M]; /* synthesis filter memory (for core switching and FD BWE) */ + Word16 mem_syn2[M]; /* ACELP synthesis memory (pe) after post-proc */ + Word16 mem_syn_r[L_SYN_MEM]; /* ACELP synthesis memory for 1.25ms */ + Word16 mem_syn3[M]; + Word16 mem_w0; /* weighting filter memory */ + + float tilt_code_flt; + float gc_threshold_flt; /* Noise enhancer - threshold for gain_code */ + float dispMem_flt[8]; /* Noise enhancer - phase dispersion algorithm memory */ + Word16 tilt_code; + Word32 gc_threshold; /* exponent = 15, 15Q16 */ + struct dispMem_fx dm_fx; /* Noise enhancer - phase dispersion algorithm memory */ } LPD_state, *LPD_state_HANDLE; @@ -654,12 +833,26 @@ typedef struct lpd_state_structure /* Structure for storing correlations between ACELP codebook components and target */ typedef struct acelp_cbkcorr_structure { - float xx; /* energy of target x */ - float y1y1; /* energy of adaptive cbk contribution y1 */ - float y2y2; /* energy of fixed cbk contribution y2 */ - float xy1; /* correlation of x and y1 */ - float xy2; /* correlation of x and y2 */ - float y1y2; /* correlation of y1 and y2 */ + float xx_flt; /* energy of target x */ + float y1y1_flt; /* energy of adaptive cbk contribution y1 */ + float y2y2_flt; /* energy of fixed cbk contribution y2 */ + float xy1_flt; /* correlation of x and y1 */ + float xy2_flt; /* correlation of x and y2 */ + float y1y2_flt; /* correlation of y1 and y2 */ + + Word16 xx; /* energy of target x */ + Word16 y1y1; /* energy of adaptive cbk contribution y1 */ + Word16 y2y2; /* energy of fixed cbk contribution y2 */ + Word16 xy1; /* correlation of x and y1 */ + Word16 xy2; /* correlation of x and y2 */ + Word16 y1y2; /* correlation of y1 and y2 */ + + Word16 xx_e; /* energy of target x */ + Word16 y1y1_e; /* energy of adaptive cbk contribution y1 */ + Word16 y2y2_e; /* energy of fixed cbk contribution y2 */ + Word16 xy1_e; /* correlation of x and y1 */ + Word16 xy2_e; /* correlation of x and y2 */ + Word16 y1y2_e; /* correlation of y1 and y2 */ } ACELP_CbkCorr; @@ -675,15 +868,22 @@ typedef struct gsc_enc_structure float mem_w0_tmp; float mem_syn_tmp[M]; float mid_dyn; /* AC mode (GSC) - signal dynamic */ + Word16 mem_w0_tmp_fx; + Word16 mem_syn_tmp_fx[M]; + Word16 mid_dyn_fx; /* AC mode (GSC) - signal dynamic */ + int16_t noise_lev; /* AC mode (GSC) - noise level */ int16_t past_dyn_dec; /* AC mode (GSC) - Past noise level decision */ float Last_frame_ener; /* AC mode (GSC) - Last frame energy */ + Word32 Last_frame_ener_fx; /* AC mode (GSC) - Last frame energy */ int16_t pit_exc_hangover; /* AC mode (GSC) - Hangover for the time contribution switching */ float last_exc_dct_in[L_FRAME16k]; /* AC mode (GSC) - previous excitation */ + Word16 last_exc_dct_in_fx[L_FRAME16k]; /* AC mode (GSC) - previous exciation */ float last_ener; /* AC mode (GSC) - previous energy */ + Word16 last_ener_fx; /* AC mode (GSC) - previous energy */ int16_t last_bitallocation_band[6]; /* AC mode (GSC) - previous bit allocation of each band */ float lt_gpitch; - + Word16 lt_gpitch_fx; /*Q15 */ } GSC_ENC_DATA, *GSC_ENC_HANDLE; /*----------------------------------------------------------------------------------* @@ -710,9 +910,14 @@ typedef struct hq_enc_structure int16_t prev_stab_hfe2; float prev_ni_ratio; float prev_En_sb[NB_SWB_SUBBANDS]; + Word16 prev_ni_ratio_fx; /* 15 */ + Word16 prev_En_sb_fx[NB_SWB_SUBBANDS]; /* QsEn(4) */ + int16_t last_bitalloc_max_band[2]; float last_ni_gain[BANDS_MAX]; float last_env[BANDS_MAX]; + Word32 last_ni_gain_fx[BANDS_MAX]; + Word16 last_env_fx[BANDS_MAX]; int16_t last_max_pos_pulse; } HQ_ENC_DATA, *HQ_ENC_HANDLE; @@ -740,6 +945,8 @@ typedef struct sc_vbr_enc_structure { float vadsnr; float vadnoise; + Word16 vadsnr_fx; /*Q7*/ + Word16 vadnoise_fx; /* NELP variables */ float shape1_filt_mem[20]; @@ -749,11 +956,24 @@ typedef struct sc_vbr_enc_structure float txlpf1_filt2_mem[20]; float txhpf1_filt1_mem[20]; float txhpf1_filt2_mem[20]; + Word16 shape1_filt_mem_fx[10]; + Word16 shape2_filt_mem_fx[10]; + Word16 shape3_filt_mem_fx[10]; + Word16 txlpf1_filt1_mem_fx[10]; + Word16 txlpf1_filt2_mem_fx[10]; + Word16 txhpf1_filt1_mem_fx[10]; + Word16 txhpf1_filt2_mem_fx[10]; + float bp1_filt_mem_wb[8]; - float nelp_lp_fit_mem[NELP_LP_ORDER * 2]; + float nelp_lp_fit_mem_flt[NELP_LP_ORDER * 2]; float bp1_filt_mem_nb[14]; + Word16 bp1_filt_mem_wb_fx[8]; + Word16 nelp_lp_fit_mem[NELP_LP_ORDER * 2]; + Word32 bp1_filt_mem_nb_fx[14]; + int16_t nelp_enc_seed; float nelp_gain_mem; + Word16 nelp_gain_mem_fx; int16_t last_nelp_mode; int16_t nelp_mode; @@ -765,6 +985,8 @@ typedef struct sc_vbr_enc_structure int16_t ppp_mode; float prev_ppp_gain_pit; float prev_tilt_code; + Word16 prev_ppp_gain_pit_fx; /*Q14*/ + Word16 prev_tilt_code_fx; /* voiced encoder variables */ int16_t firstTime_voicedenc; @@ -772,21 +994,34 @@ typedef struct sc_vbr_enc_structure /* DTFS variables */ float dtfs_enc_a[MAXLAG_WI]; float dtfs_enc_b[MAXLAG_WI]; + Word16 dtfs_enc_a_fx[MAXLAG_WI]; /*Q0*/ + Word16 dtfs_enc_b_fx[MAXLAG_WI]; /*Q0*/ + int16_t dtfs_enc_lag; int16_t dtfs_enc_nH; int16_t dtfs_enc_nH_4kHz; float dtfs_enc_upper_cut_off_freq_of_interest; float dtfs_enc_upper_cut_off_freq; + Word16 dtfs_enc_upper_cut_off_freq_of_interest_fx; + Word16 dtfs_enc_upper_cut_off_freq_fx; + Word16 dtfs_enc_Q; float prev_cw_en; float ph_offset_E; float lastLgainE; /* Previous gain value for the low band */ float lastHgainE; /* Previous gain value for the high band */ float lasterbE[NUM_ERB_WB]; /* Previous Amplitude spectrum (ERB) */ + Word32 prev_cw_en_fx; /*Q_prev_cw_en_fx*/ + Word16 ph_offset_E_fx; /*Q15 normalized y 2*Pi */ + Word16 lastLgainE_fx; /*Q11 Previous gain value for the low band */ + Word16 lastHgainE_fx; /*Q11 Previous gain value for the high band */ + Word16 lasterbE_fx[NUM_ERB_WB]; /*Q13 Previous Amplitude spectrum (ERB) */ + Word16 Q_prev_cw_en_fx; int16_t mode_QQF; int16_t rate_control; float SNR_THLD; + Word16 SNR_THLD_fx; int16_t Q_to_F; int16_t pattern_m; int16_t patterncount; @@ -794,6 +1029,8 @@ typedef struct sc_vbr_enc_structure int16_t numactive; /* keep the count of the frames inside current 600 frame block */ float sum_of_rates; /* sum of the rates of past 600 active frames */ float global_avr_rate; /* global rate up to current time. recorded a (rate in kbps) * 6000 */ + Word32 sum_of_rates_fx; /* sum of the rates of past 600 active frames*/ + Word32 global_avr_rate_fx; /* global rate upto current time. recorded a (rate in kbps) *6000*/ int16_t global_frame_cnt; /* 600 active frame block count. Used to update the global rate */ int16_t set_ppp_generic; int16_t avoid_HQ_VBR_NB; @@ -812,6 +1049,7 @@ typedef struct sc_vbr_enc_structure typedef struct amrwb_io_enc_structure { float past_qua_en[4]; /* gain quantization memory (used also in AMR-WB IO mode) */ + Word16 past_qua_en_fx[4]; /* gain quantization memory (used also in AMR-WB IO mode) */ /* HF WB BWE for AMR-WB IO mode at 23.85 kbps */ float gain_alpha; @@ -819,6 +1057,11 @@ typedef struct amrwb_io_enc_structure float mem_hp400_enc[4]; float mem_hf_enc[L_FIR - 1]; float mem_syn_hf_enc[M]; + Word16 gain_alpha_fx; + Word16 mem_hf2_enc_fx[L_FIR - 1]; + Word16 mem_hp400_enc_fx[6]; + Word16 mem_hf_enc_fx[L_FIR - 1]; + Word16 mem_syn_hf_enc_fx[M]; int16_t seed2_enc; } AMRWB_IO_ENC_DATA, *AMRWB_IO_ENC_HANDLE; @@ -833,11 +1076,20 @@ typedef struct td_bwe_enc_structure float old_speech_shb[L_LOOK_16k + L_SUBFR16k]; /* Buffer memories */ float old_speech_wb[( L_LOOK_12k8 + L_SUBFR ) * 5 / 16]; /* Buffer memories */ float old_input_fhb[NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2]; + Word16 old_speech_shb_fx[L_LOOK_16k + L_SUBFR16k]; /* Buffer memories */ + Word16 old_speech_wb_fx[(L_LOOK_12k8 + L_SUBFR) * 5 / 16]; /* Buffer memories */ + Word16 old_input_fhb_fx[NS2SA(48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS) - L_FRAME48k / 2]; + Word16 old_input_fhb_fx_Q; + float prev_lsp_shb[LPC_SHB_ORDER]; + Word16 prev_lsp_shb_fx[LPC_SHB_ORDER]; float state_ana_filt_shb[2 * ALLPASSSECTIONS_STEEP + 1]; /* states for the analysis filters */ - float cldfbHBLT; + float cldfbHBLT_flt; + Word16 state_ana_filt_shb_fx[(2 * ALLPASSSECTIONS_STEEP + 1)]; + Word16 cldfbHBLT; /* states for the filters used in generating SHB excitation from WB excitation*/ float mem_csfilt[2]; + Word32 mem_csfilt_fx[2]; float mem_shb_res[MAX_LEN_MA_FILTER]; /* old SHB residual signal */ float old_EnvSHBres[L_FRAME4k]; /* old TD envelope of the SHB residual signal */ float old_mean_EnvSHBres; /* energy of the last subframe of the SHB residual signal from previous frame */ @@ -851,6 +1103,9 @@ typedef struct td_bwe_enc_structure float state_syn_shbexc[L_SHB_LAHEAD]; float state_lpc_syn[LPC_SHB_ORDER]; float old_bwe_exc[PIT16k_MAX * 2]; /* old excitation */ + Word16 state_syn_shbexc_fx[L_SHB_LAHEAD]; + Word16 state_lpc_syn_fx[LPC_SHB_ORDER]; + Word16 old_bwe_exc_fx[PIT16k_MAX * 2]; /*Q_exc*/ int16_t bwe_seed[2]; float bwe_non_lin_prev_scale; float old_bwe_exc_extended[NL_BUFF_OFFSET]; @@ -860,6 +1115,14 @@ typedef struct td_bwe_enc_structure float mem_genSHBexc_filt_down_wb2[( 2 * ALLPASSSECTIONS_STEEP + 1 )]; float mem_genSHBexc_filt_down_wb3[( 2 * ALLPASSSECTIONS_STEEP + 1 )]; float mem_genSHBexc_filt_down_shb[( 2 * ALLPASSSECTIONS_STEEP + 1 )]; + Word32 bwe_non_lin_prev_scale_fx; /*Q30*/ + Word16 old_bwe_exc_extended_fx[NL_BUFF_OFFSET]; + Word16 syn_overlap_fx[L_SHB_LAHEAD]; + Word16 decim_state1_fx[(2 * ALLPASSSECTIONS_STEEP + 1)]; + Word16 decim_state2_fx[(2 * ALLPASSSECTIONS_STEEP + 1)]; + Word16 mem_genSHBexc_filt_down_wb2_fx[(2 * ALLPASSSECTIONS_STEEP + 1)]; + Word16 mem_genSHBexc_filt_down_wb3_fx[(2 * ALLPASSSECTIONS_STEEP + 1)]; + Word16 mem_genSHBexc_filt_down_shb_fx[(2 * ALLPASSSECTIONS_STEEP + 1)]; float elliptic_bpf_2_48k_mem[4][4]; float prev_fb_energy; @@ -869,18 +1132,37 @@ typedef struct td_bwe_enc_structure float shb_inv_filt_mem[LPC_SHB_ORDER]; float lsp_shb_spacing[3]; float prev_swb_GainShape; + Word32 elliptic_bpf_2_48k_mem_fx[4][4]; + Word16 elliptic_bpf_2_48k_mem_fx_Q[4]; + Word32 prev_fb_energy_fx; + Word16 prev_fb_energy_fx_Q; + Word32 prev_gainFr_SHB_fx; + Word16 lsp_shb_slow_interpl_fx[LPC_SHB_ORDER]; + Word16 lsp_shb_fast_interpl_fx[LPC_SHB_ORDER]; + Word16 shb_inv_filt_mem_fx[LPC_SHB_ORDER]; + Word16 lsp_shb_spacing_fx[3]; + Word16 prev_swb_GainShape_fx; int16_t prev_frGainAtten; - float prev_wb_GainShape; + float prev_wb_GainShape_flt; float swb_lsp_prev_interp[LPC_SHB_ORDER]; float fb_state_lpc_syn[LPC_SHB_ORDER]; float fb_tbe_demph; float tilt_mem; + Word16 prev_wb_GainShape; + Word16 swb_lsp_prev_interp_fx[LPC_SHB_ORDER]; + Word16 fb_state_lpc_syn_fx[LPC_SHB_ORDER]; + Word16 prev_Q_bwe_exc_fb; + Word16 fb_tbe_demph_fx; + Word16 tilt_mem_fx; int16_t prev_coder_type; float prev_lsf_diff[LPC_SHB_ORDER - 2]; float prev_tilt_para; float cur_sub_Aq[M + 1]; + Word16 prev_lsf_diff_fx[LPC_SHB_ORDER - 2]; + Word16 prev_tilt_para_fx; + Word16 cur_sub_Aq_fx[M + 1]; /* quantized data */ int16_t lsf_idx[NUM_Q_LSF]; @@ -898,6 +1180,8 @@ typedef struct td_bwe_enc_structure int16_t idxGain; float dec_2_over_3_mem[L_FILT_2OVER3]; float dec_2_over_3_mem_lp[L_FILT_2OVER3_LP]; + Word16 dec_2_over_3_mem_fx[12]; + Word16 dec_2_over_3_mem_lp_fx[6]; float tbe_demph; float tbe_premph; @@ -905,6 +1189,12 @@ typedef struct td_bwe_enc_structure float *ptr_mem_stp_swb; float gain_prec_swb; float mem_zero_swb[LPC_SHB_ORDER]; + Word16 tbe_demph_fx; + Word16 tbe_premph_fx; + Word16 mem_stp_swb_fx[LPC_SHB_ORDER]; + Word16* ptr_mem_stp_swb_fx; + Word16 gain_prec_swb_fx; + Word16 mem_zero_swb_fx[LPC_SHB_ORDER]; } TD_BWE_ENC_DATA, *TD_BWE_ENC_HANDLE; @@ -922,12 +1212,22 @@ typedef struct fd_bwe_enc_structure float old_syn_12k8_16k[NS2SA( 16000, DELAY_FD_BWE_ENC_NS )]; float old_fdbwe_speech[L_FRAME48k]; float mem_deemph_old_syn; + Word16 new_input_hp_fx[NS2SA(16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS)]; + Word16 old_input_fx[NS2SA(48000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS)]; + Word16 old_input_wb_fx[NS2SA(16000, DELAY_FD_BWE_ENC_NS)]; + Word16 old_input_lp_fx[NS2SA(16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS)]; + Word16 old_syn_12k8_16k_fx[NS2SA(16000, DELAY_FD_BWE_ENC_NS)]; + Word16 old_fdbwe_speech_fx[L_FRAME48k]; + Word16 mem_deemph_old_syn_fx; int16_t prev_mode; float old_wtda_swb[L_FRAME48k]; + Word16 L_old_wtda_swb_fx[L_FRAME48k]; int16_t prev_L_swb_norm1; float prev_global_gain; + Word32 prev_global_gain_fx; int16_t modeCount; float EnergyLF; + Word32 EnergyLF_fx; float mem_old_wtda_swb; } FD_BWE_ENC_DATA, *FD_BWE_ENC_HANDLE; @@ -945,15 +1245,22 @@ typedef struct rf_enc_structure ACELP_config acelp_cfg_rf; /* configuration for RF frame */ - float rf_mem_w0; - float rf_clip_var[6]; - float rf_tilt_code; - float rf_mem_syn2[M]; + float rf_mem_w0_flt; + float rf_clip_var_flt[6]; + float rf_tilt_code_flt; + float rf_mem_syn2_flt[M]; float rf_dispMem[8]; - float rf_gc_threshold; + float rf_gc_threshold_flt; + Word16 rf_mem_w0; + Word16 rf_clip_var[6]; + Word16 rf_tilt_code; + Word16 rf_mem_syn2[M]; + //struct dispMem_fx rf_dm_fx; + Word32 rf_gc_threshold; int16_t rf_target_bits; - float rf_tilt_buf[NB_SUBFR16k]; + float rf_tilt_buf_flt[NB_SUBFR16k]; + Word16 rf_tilt_buf[NB_SUBFR16k]; int16_t rf_indx_lsf[MAX_RF_FEC_OFFSET][3]; int16_t rf_indx_pitch[MAX_RF_FEC_OFFSET][NB_SUBFR16k]; @@ -989,6 +1296,9 @@ typedef struct plc_enc_evs_structure { int16_t nBits; /* number of bits */ + Word16 Q_new; + Word16 Q_exp; + int16_t enableGplc; int16_t T0_4th; int16_t T0; @@ -997,22 +1307,34 @@ typedef struct plc_enc_evs_structure int16_t pit_max; float mem_MA[M]; - float mem_AR[M]; + float mem_AR_flt[M]; + Word16 mem_MA_14Q1[M]; + Word16 mem_AR[M]; float lsfold[M]; /* old lsf (frequency domain) */ float lspold[M]; /* old lsp (immittance spectral pairs) */ + Word16 lsfold_14Q1[M]; /* old lsf (frequency domain) */ + Word16 lspold_Q15[M]; /* old lsp (immittance spectral pairs) */ float lsfoldbfi0[M]; /* Previous frame lsf */ float lsfoldbfi1[M]; /* Past previous frame lsf */ + Word16 lsfoldbfi0_14Q1[M]; /* Previous frame LSF */ + Word16 lsfoldbfi1_14Q1[M]; /* Past previous frame LSF */ float lsf_adaptive_mean[M]; /* Mean lsf for bfi cases */ + Word16 lsf_adaptive_mean_14Q1[M]; /* Mean isf for bfi cases */ float stab_fac; + Word16 stab_fac_Q15; LPD_state *LPDmem; float old_exc[8]; /* ACELP exc memory (Aq) */ + Word16 old_exc_Qold[8]; /* ACELP exc memory (Aq)*/ - float lsf_con[M]; - float last_lsf_ref[M]; - float last_lsf_con[M]; + float lsf_con_flt[M]; + float last_lsf_ref_flt[M]; + float last_lsf_con_flt[M]; + Word16 lsf_con[M]; + Word16 last_lsf_ref[M]; + Word16 last_lsf_con[M]; } PLC_ENC_EVS, *PLC_ENC_EVS_HANDLE; @@ -1023,10 +1345,14 @@ typedef struct plc_enc_evs_structure typedef struct tec_enc_structure { - float loBuffer[CLDFB_NO_COL_MAX + MAX_TEC_SMOOTHING_DEG + DELAY_TEMP_ENV_BUFF_TEC]; - float loTempEnv[CLDFB_NO_COL_MAX]; - float loTempEnv_ns[CLDFB_NO_COL_MAX]; - float hiTempEnv[CLDFB_NO_COL_MAX + DELAY_TEMP_ENV_BUFF_TEC + EXT_DELAY_HI_TEMP_ENV]; + float loBuffer_flt[CLDFB_NO_COL_MAX + MAX_TEC_SMOOTHING_DEG + DELAY_TEMP_ENV_BUFF_TEC]; + float loTempEnv_flt[CLDFB_NO_COL_MAX]; + float loTempEnv_ns_flt[CLDFB_NO_COL_MAX]; + float hiTempEnv_flt[CLDFB_NO_COL_MAX + DELAY_TEMP_ENV_BUFF_TEC + EXT_DELAY_HI_TEMP_ENV]; + Word16 loBuffer[CLDFB_NO_COL_MAX + MAX_TEC_SMOOTHING_DEG + DELAY_TEMP_ENV_BUFF_TEC]; + Word16 loTempEnv[CLDFB_NO_COL_MAX]; + Word16 loTempEnv_ns[CLDFB_NO_COL_MAX]; + Word16 hiTempEnv[CLDFB_NO_COL_MAX + DELAY_TEMP_ENV_BUFF_TEC + EXT_DELAY_HI_TEMP_ENV]; int16_t tranFlag; int16_t corrFlag; @@ -1048,7 +1374,8 @@ typedef struct tcx_enc_structure float *spectrum[2]; /* MDCT output for a short block */ float spectrum_long[N_MAX]; /* MDCT output for a long block. Points to spectrum */ - float noiseTiltFactor; /* compensation for LPC tilt in noise filling */ + float noiseTiltFactor_flt; /* compensation for LPC tilt in noise filling */ + Word16 noiseTiltFactor; /* compensation for LPC tilt in noise filling */ int16_t noiseLevelMemory_cnt; /* counter of consecutive low TCX noise levels */ float ltpGainMemory[N_LTP_GAIN_MEMS]; /* for smoothing noiseTransWidth */ STnsData tnsData[2]; @@ -1057,50 +1384,69 @@ typedef struct tcx_enc_structure int16_t memQuantZeros[L_FRAME_PLUS]; /* Quantization deadzone flags */ - float *speech_TCX; - float *new_speech_TCX; + float *speech_TCX_flt; + float *new_speech_TCX_flt; + Word16* speech_TCX; + Word16* new_speech_TCX; int16_t tcxltp; int16_t tcxltp_pitch_int; int16_t tcxltp_pitch_fr; - float tcxltp_gain; + float tcxltp_gain_flt; + Word16 tcxltp_gain; int16_t tcxltp_pitch_int_past; int16_t tcxltp_pitch_fr_past; - float tcxltp_gain_past; - float tcxltp_norm_corr_past; - float tcxltp_norm_corr_mem; - float kernel_switch_corr_past; + float tcxltp_gain_past_flt; + float tcxltp_norm_corr_past_flt; + Word16 tcxltp_gain_past; + Word16 tcxltp_norm_corr_past; + float tcxltp_norm_corr_mem_flt; + float kernel_switch_corr_past_flt; uint16_t kernel_type[2]; /* transform kernel type in each subframe (MDCT or MDST) */ uint16_t kernel_symmetry_past; /* last TDA symmetry (0 for MDCT, 1 for MDST type) */ uint16_t enc_ste_pre_corr_past; float tfm_mem; /* state of IIR filtered temporal flatness measure */ - float buf_speech_ltp[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; - float *speech_ltp; - float *new_speech_ltp; + float buf_speech_ltp_flt[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; + float *speech_ltp_flt; + float *new_speech_ltp_flt; + Word16 buf_speech_ltp[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; + Word16* speech_ltp; + Word16* new_speech_ltp; int16_t tcxltp_filt_idx; int16_t tcxltp_bits; int16_t tcxltp_param[LTPSIZE]; int16_t tcxltp_on_mem; - float measuredBwRatio; /* measured bw; used for TCX noise-filling */ + float measuredBwRatio_flt; /* measured bw; used for TCX noise-filling */ + Word16 measuredBwRatio; /* measured bw; used for TCX noise-filling. 1Q14 */ int16_t nmStartLine; /* Starting line for the noise measurement */ int16_t tcx_lpc_shaped_ari; float old_out[L_FRAME32k]; + Word16 old_out_fx[L_FRAME32k]; /* buffer for OLA; at the encoder, the maximum length is L_FRAME32k (corresponds to maximum internal L_frame length) */ + Word16 Q_old_out; /* MDCT switching */ - float prev_hi_ener; + float prev_hi_ener_flt; int16_t prev_hi_sparse; - float clas_sec_old; + float clas_sec_old_flt; int16_t clas_final_old; - float last_gain1; - float last_gain2; + float last_gain1_flt; + float last_gain2_flt; + //Fix + Word16 prev_hi_ener; + Word16 clas_sec_old_fx; /* MDCT classifier secondary decision memory */ + Word32 last_gain1; + Word32 last_gain2; /* TCX memory */ - float Txnq[L_FRAME32k / 2 + 64]; /* Q target (overlap or ACELP+ZIR, use Aq) */ - float *acelp_zir; - float tcx_target_bits_fac; + float Txnq_flt[L_FRAME32k / 2 + 64]; /* Q target (overlap or ACELP+ZIR, use Aq) */ + float *acelp_zir_flt; + float tcx_target_bits_fac_flt; + Word16 Txnq[L_FRAME32k / 2 + 64]; /* Q target (overlap or ACELP+ZIR, use Aq) */ + Word16* acelp_zir; + Word16 tcx_target_bits_fac; int16_t tns_ms_flag[2]; @@ -1120,8 +1466,11 @@ typedef struct enc_core_structure *----------------------------------------------------------------------------------*/ int16_t idchan; /* channel ID (audio channel number) */ + Word16 id_element; /* element ID */ int16_t element_mode; /* element mode */ int32_t element_brate; /* element bitrate */ + Word16 extl_orig; /* extension layer */ + Word32 extl_brate_orig; /* extension layer bitrate */ int16_t codec_mode; /* Mode1 or Mode2 */ int16_t last_codec_mode; /* previous frame Mode 1 or 2 */ int16_t last_codec_mode_cng; /* previous inactive frame Mode 1 or 2 */ @@ -1131,6 +1480,8 @@ typedef struct enc_core_structure int16_t mdct_sw; /* MDCT switching indicator */ BSTR_ENC_HANDLE hBstr; /* encoder bitstream handle */ + Word16 last_enerBuffer_exp; + Word16 next_bit_pos_fx; /* position of the next bit to be written in the bitstream */ int16_t bitstreamformat; /* Bitstream format flag (G.192/MIME) */ int32_t input_Fs; /* input signal sampling frequency in Hz */ @@ -1162,21 +1513,51 @@ typedef struct enc_core_structure int16_t last_Opt_SC_VBR; /* flag indicating prev frame's SC-VBR mode */ int16_t low_rate_mode; /* low-rate mode flag */ int16_t inactive_coder_type_flag; /* inactive coder type flag (0 = AVQ / 1 = GSC) */ + Word16 nTimeSlots; /* for CLDFB */ int16_t ini_frame; /* initialization frames counter */ + //Word32 input_Fs_fx; /* input signal sampling frequency in Hz */ + //Word32 total_brate_fx; /* total bitrate in kbps of the codec */ + //Word32 last_total_brate_fx; /* total bitrate in kbps of the codec */ + //Word32 last_total_brate_cng_fx; /* total bitrate in kbps of the last inactive frame */ + //Word16 core_fx; /* core (ACELP_CORE, TCX_20_CORE, TCX_10_CORE, HQ_CORE, AMR_WB_CORE) */ + //Word32 core_brate_fx; /* core bitrate */ + //Word32 last_core_brate_fx; /* previous frame core bitrate */ + //Word16 input_frame_fx; /* Frame lenght (function of input_Fs) */ + //Word16 extl_fx; /* extension layer */ + //Word16 last_extl_fx; /* previous extension layer */ + //Word32 extl_brate_fx; /* extension layer bitrate */ + //Word16 input_bwidth_fx; /* input signal bandwidth */ + //Word16 last_input_bwidth_fx; /* input signal bandwidth in the previous frame */ + //Word16 bwidth_fx; /* encoded bandwidth NB, WB, SWB or FB */ + //Word16 max_bwidth_fx; /* maximum encoded bandwidth */ + //Word16 last_bwidth_fx; /* input signal bandwidth in the previous frame */ + //Word16 last_bwidth_cng_fx; /* input signal bandwidth in the previous inactive frame */ + //Word16 L_frame_fx; /* ACELP core internal frame length */ + //Word16 Opt_AMR_WB_fx; /* flag indicating AMR-WB IO mode */ + //Word16 Opt_DTX_ON_fx; /* flag indicating DTX operation */ + //Word16 cng_type_fx; /* flag indicating LP or CLDFB based SID/CNG */ + //Word16 active_fr_cnt_fx; /* counter of active frames */ + //Word16 Opt_SC_VBR_fx; /* flag indicating SC-VBR mode */ + //Word16 last_Opt_SC_VBR_fx; /* flag indicating SC-VBR mode in the last frame */ + /*----------------------------------------------------------------------------------* * ACELP core parameters *----------------------------------------------------------------------------------*/ int16_t clas; /* current frame clas */ int16_t last_clas; /* previous frame signal classification */ - float prev_fmerit; /* previous signal classification score*/ - float fmerit_dt; /* signal classification score difference */ + float prev_fmerit_flt; /* previous signal classification score*/ + float fmerit_dt_flt; /* signal classification score difference */ + Word16 prev_fmerit; + Word16 fmerit_dt; int16_t Nb_ACELP_frames; int16_t pitch[3]; /* open-loop pitch values @12.8 kHz for three half-frames */ float voicing[3]; /* open-loop normalized correlation values for three half-frames */ + Word16 pitch_fx[3]; + Word16 voicing_fx[3]; LPD_state_HANDLE hLPDmem; /* ACELP LPDmem memories */ @@ -1187,7 +1568,16 @@ typedef struct enc_core_structure float lsf_old[M]; /* old LSF vector at the end of the frame */ float lsp_old16k[M]; /* old LSP vector at the end of the frame @16kHz */ float lspold_enc[M]; /* old lsp (immittance spectral pairs) */ + Word32 Bin_E_fx[L_FFT]; /* Q_new + Q_SCALE -2 per bin energy of two frames */ + Word16 lsp_old1_fx[M]; /* old unquantized LSP vector at the end of the frame */ + Word16 lsf_old1_fx[M]; /* old LSF vector at the end of the frame */ + Word16 lsp_old_fx[M]; /* old LSP vector at the end of the frame */ + Word16 lsf_old_fx[M]; /* old LSF vector at the end of the frame */ + Word16 lsp_old16k_fx[M]; /* old LSP vector at the end of the frame @16kHz */ + Word16 lspold_enc_fx[M]; /* old LSP vector at the end of the frame @16kHz */ + int16_t pstreaklen; /* LSF quantizer */ + float streaklimit; /* LSF quantizer */ float stab_fac; /* LSF stability factor */ float mem_preemph; /* preemphasis filter memory */ @@ -1199,6 +1589,28 @@ typedef struct enc_core_structure float clip_var[6]; /* pitch gain clipping memory */ float mem_AR[M]; /* AR memory of LSF quantizer (past quantized LSFs without mean) */ float mem_MA[M]; /* MA memory of LSF quantizer (past quantized residual) (used also in AMR-WB IO mode) */ + Word16 pstreaklen_fx; /* LSF quantizer */ + Word16 streaklimit_fx; /* LSF quantizer */ + Word32 offset_scale1_fx[MAX_NO_MODES + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure 1st 8-dim subvector*/ + Word32 offset_scale2_fx[MAX_NO_MODES + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure 2nd 8-dim subvector*/ + Word32 offset_scale1_p_fx[MAX_NO_MODES_p + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure, pred. case, 1st 8-dim subvector*/ + Word32 offset_scale2_p_fx[MAX_NO_MODES_p + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure, pred. case, 2nd 8-dim subvector*/ + Word16 no_scales_fx[MAX_NO_MODES][2]; /* LSF LVQ structure Q0*/ + Word16 no_scales_p_fx[MAX_NO_MODES_p][2]; /* LSF LVQ structure Q0*/ + Word16 stab_fac_fx; /* LSF stability factor */ + Word16 mem_deemph_fx; /* deemphasis filter memory */ + Word16 mem_preemph_fx; /* preemphasis filter memory */ + Word32 mem_hp20_in_fx[5]; /* HP filter memory for AMR-WB IO */ + Word16 old_wsp_fx[L_WSP_MEM]; /* old weighted signal vector */ + /*Word16 old_exc_fx[L_EXC_MEM];*/ /* old excitation vector */ + Word16 old_wsp2_fx[(L_WSP_MEM - L_INTERPOL) / OPL_DECIM]; /* old decimated weighted signal vector qwsp */ + Word16 mem_wsp_fx; /* weighted signal vector memory */ + Word16 mem_decim2_fx[3]; /* weighted signal decimation filter memory qwsp */ + Word16 clip_var_fx[6]; + Word16 mem_AR_fx[M]; /* AR memory of LSF quantizer (past quantized LSFs without mean) */ + Word16 mem_MA_fx[M]; /* MA memory of LSF quantizer (past quantized residual) (used also in AMR-WB IO mode) */ + Word16 mCb1_fx; /* LSF quantizer - counter of stationary frames after a transition frame */ + int16_t GSC_noisy_speech; /* AC mode (GSC) - flag to indicate GSC on SWB noisy speech */ int16_t GSC_IVAS_mode; @@ -1208,46 +1620,64 @@ typedef struct enc_core_structure float lsfoldbfi0[M]; /* FEC - LSF vector of the previous frame */ float lsfoldbfi1[M]; /* FEC - LSF vector of the past previous frame */ float lsf_adaptive_mean[M]; /* FEC - adaptive mean LSF vector for FEC */ + Word16 lsfoldbfi0_fx[M]; /* FEC - LSF vector of the previous frame */ + Word16 lsfoldbfi1_fx[M]; /* FEC - LSF vector of the past previous frame */ + Word16 lsf_adaptive_mean_fx[M]; /* FEC - adaptive mean LSF vector for FEC */ int16_t next_force_safety_net; /* FEC - flag to force safety net in next frame */ + Word16 next_force_safety_net_fx; /* FEC - flag to force safety net in next frame */ int16_t uv_count; /* Stationary noise UV modification - unvoiced counter */ int16_t act_count; /* Stationary noise UV modification - activation counter */ float ge_sm; /* Stationary noise UV modification - smoothed excitation gain */ float lspold_s[M]; /* Stationary noise UV modification - old LSP vector */ + Word32 ge_sm_fx; /* Stationary noise UV modification - smoothed excitation gain */ + Word16 lspold_s_fx[M]; /*Q15*/ /* Stationary noise UV modification - old LSP vector */ int16_t noimix_seed; /* Stationary noise UV modification - mixture seed */ float min_alpha; /* Stationary noise UV modification - minimum alpha */ float exc_pe; /* Stationary noise UV modification - memory of the preemphasis filter */ + Word16 min_alpha_fx; /*Q15*/ /* Stationary noise UV modification - minimum alpha */ + Word16 exc_pe_fx; /* Stationary noise UV modification - memory of the preemphasis filter */ int16_t coder_type_raw; /* raw coder_type (before UNVOICED is lost) */ int16_t last_coder_type_raw; /* raw last_coder_type (coming from the sigal classification) */ int16_t last_coder_type; /* previous coding type */ float old_thres; /* normalized correlation weighting in open-loop pitch */ float old_corr; /* normalized correlation in previous frame (mean value) */ - int16_t old_pitch; /* previous pitch for open-loop pitch search */ + Word16 old_thres_fx; /* normalized correlation weighting in open-loop pitch Q15 */ + Word16 old_corr_fx; /* normalized correlation in previous frame (mean value) Q15 */ int16_t old_pitch; /* previous pitch for open-loop pitch search */ int16_t delta_pit; /* open-loop pitch extrapolation correction */ float ee_old; /* previous frame low/high frequency energy ratio */ + Word32 ee_old_fx; int16_t min_band; /* minimum critical band of useful bandwidth */ int16_t max_band; /* maximum critical band of useful bandwidth */ int16_t tc_cnt; /* TC frame counter */ int16_t audio_frame_cnt; /* Counter of relative presence of audio frames */ float old_dE1; /* Maximum energy increase in previous frame */ + Word32 old_dE1_fx; /* Maximum energy increase in previous frame */ int16_t old_ind_deltaMax; /* Index of the sub-subframe of maximum energy in previous frame */ float old_enr_ssf[2 * NB_SSF]; /* Maxima of energies per sub-subframes of previous frame */ + Word32 old_enr_ssf_fx[2 * NB_SSF]; /* Maxima of energies per sub-subframes of previous frame */ int16_t spike_hyst; /* Hysteresis to prevent UC after sharp energy spike */ int16_t last_harm_flag_acelp; /* harmonicity flag for ACELP @32kbps rate */ float old_Aq_12_8[M + 1]; /* old Aq[] for core switching */ float old_Es_pred; /* old Es_pred for core switching */ + Word16 old_Aq_12_8_fx[M + 1]; /* Q12 old Aq[] for core switching */ + Word16 old_Es_pred_fx; /* Q8 old Es_pred for core switching */ int16_t last_L_frame; /* ACELP@16kHz - last L_frame value */ float mem_preemph16k; /* ACELP@16kHz - preemphasis filter memory @16kHz */ float mem_deemp_preQ; /* ACELP@16kHz - prequantizer deemhasis memory */ float mem_preemp_preQ; /* ACELP@16kHz - prequantizer preemhasis memory */ + Word16 mem_preemph16k_fx; /* ACELP@16kHz - preemphasis filter memory @16kHz */ + Word16 mem_deemp_preQ_fx; /* ACELP@16kHz - prequantizer deemhasis memory */ + Word16 mem_preemp_preQ_fx; /* ACELP@16kHz - prequantizer preemhasis memory */ int16_t last_nq_preQ; /* ACELP@16kHz - AVQ subquantizer number of the last sub-band of the last subframe */ int16_t last_code_preq; /* ACELP@16kHz - last coefficient of the pre-quantizer contribution */ int16_t use_acelp_preq; /* ACELP@16kHz - flag of prequantizer usage */ int16_t bpf_off; /* Bass post-filter - do not use BPF when this flag is set to 1 */ float old_pitch_buf[2 * NB_SUBFR16k]; /* Bass post-filter - buffer of old subframe pitch values */ + Word16 old_pitch_buf_fx[2 * NB_SUBFR16k]; /*Q6 Bass post-filter - buffer of old subframe pitch values */ float pst_mem_deemp_err; /* Bass post-filter - filter memory of noise LP filter */ float pst_lp_ener; /* Bass post-filter - long-term energy */ @@ -1255,12 +1685,16 @@ typedef struct enc_core_structure float voicing0_sm; float voicing_sm; float LF_EnergyRatio_sm; + Word16 voicing0_sm_fx; + Word16 voicing_sm_fx; + Word16 LF_EnergyRatio_sm_fx; int16_t predecision_flag; float diff_sm; float energy_sm; + Word32 diff_sm_fx; + Word32 energy_sm_fx; - int16_t sharpFlag; - + Word16 finalVAD; int16_t flag_noisy_speech_snr; /* encoder detector for noisy speech */ int16_t Pos_relE_cnt; /* Number of frames between relE */ @@ -1281,10 +1715,20 @@ typedef struct enc_core_structure float *mem_decim16k; /* ACELP@16kHz - decimation filter memory @16kHz */ float *old_inp_12k8; /* memory of input signal at 12.8kHz */ float *old_inp_16k; /* ACELP@16kHz - memory of input signal @16 kHz */ - float *buf_speech_enc_pe; - float *buf_synth; /*can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/ - float *buf_speech_enc; - float *buf_wspeech_enc; + float *buf_speech_enc_pe_flt; + float *buf_synth_flt; /*can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/ + float *buf_speech_enc_flt; + float *buf_wspeech_enc_flt; + Word32* Bin_E_old_fx; /* per bin energy of old 2nd frames */ + Word16* mem_decim_fx; /* decimation filter memory */ + Word16* mem_decim16k_fx; /* ACELP@16kHz - decimation filter memory @16kHz */ + Word16* old_inp_12k8_fx; /* memory of input signal at 12.8kHz */ + Word16* old_inp_16k_fx; /* ACELP@16kHz - memory of input signal @16 kHz */ + + Word16* buf_speech_enc_pe; + Word16* buf_synth; /*can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/ + Word16* buf_speech_enc; + Word16* buf_wspeech_enc; /*----------------------------------------------------------------------------------* * Noise estimation @@ -1311,11 +1755,20 @@ typedef struct enc_core_structure VAD_CLDFB_HANDLE hVAD_CLDFB; int16_t vad_flag; /* i : VAD flag */ + int16_t sharpFlag; int16_t localVAD; /* i : local VAD flag */ - float bckr_tilt_lt; + float bckr_tilt_lt_flt; float lp_speech; float lp_noise; /* CNG and DTX - LP filtered total noise estimation */ + Word16 lp_speech_fx; + Word16 Opt_HE_SAD_ON_fx; + Word16 nb_active_frames_HE_SAD_fx; + Word16 voicing_old_fx; + Word16 lp_noise_fx; /* CNG and DTX - LP filtered total noise estimation */ + Word16 var_SID_rate_flag_fx; /* CNG and DTX - flag for variable SID rate */ + Word16 interval_SID_fx; + Word32 bckr_tilt_lt; int16_t active_cnt; /* counter of active frames */ TD_CNG_ENC_HANDLE hTdCngEnc; @@ -1334,6 +1787,9 @@ typedef struct enc_core_structure HANDLE_CLDFB_FILTER_BANK cldfbAnaEnc; /* main analysis filter bank handle */ HANDLE_CLDFB_FILTER_BANK cldfbSynTd; /* synthesis filterbank - used for HB signal generation */ + //HANDLE_CLDFB_FILTER_BANK cldfbAna_Fx; + + //HANDLE_CLDFB_FILTER_BANK cldfbSyn_Fx; /*----------------------------------------------------------------------------------* * FD CNG handle @@ -1343,6 +1799,8 @@ typedef struct enc_core_structure int16_t fd_cng_reset_flag; float last_totalNoise; float totalNoise_increase_hist[TOTALNOISE_HIST_SIZE]; + Word16 last_totalNoise_fx; + Word16 totalNoise_increase_hist_fx[TOTALNOISE_HIST_SIZE]; int16_t totalNoise_increase_len; /*----------------------------------------------------------------------------------* @@ -1360,10 +1818,15 @@ typedef struct enc_core_structure float old_hpfilt_out; float EnergyLT; float Energy_Old; + Word16 old_hpfilt_in_fx; + Word16 old_hpfilt_out_fx; + Word32 EnergyLT_fx; + Word32 Energy_Old_fx; int16_t TransientHangOver; HQ_ENC_HANDLE hHQ_core; /* HQ core encoder handle */ + PVQ_ENC_HANDLE hPVQ; /*----------------------------------------------------------------------------------* * TD BWE parameters *----------------------------------------------------------------------------------*/ @@ -1383,6 +1846,9 @@ typedef struct enc_core_structure float lt_mean_NB; float lt_mean_WB; float lt_mean_SWB; + Word16 lt_mean_NB_fx; + Word16 lt_mean_WB_fx; + Word16 lt_mean_SWB_fx; int16_t count_WB; int16_t count_SWB; int16_t count_FB; @@ -1427,20 +1893,29 @@ typedef struct enc_core_structure /*ACELP config*/ ACELP_config acelp_cfg; /*configuration set for each frame*/ + ACELP_config acelp_cfg_rf; /* configuration for RF frame */ + Word16 mode_index; /* Mode Index for LPD core */ /*TCX config*/ TCX_CONFIG_HANDLE hTcxCfg; /* cod_main.c */ - float mem_preemph_enc; /* speech preemph filter memory (at encoder-sampling-rate) */ + float mem_preemph_enc_flt; /* speech preemph filter memory (at encoder-sampling-rate) */ + Word16 mem_preemph_enc; /* speech preemph filter memory (at encoder-sampling-rate) */ /* Signal Buffers and Pointers at encoder-sampling-rate */ - float *speech_enc; - float *speech_enc_pe; - float *new_speech_enc; - float *new_speech_enc_pe; - float *wspeech_enc; - float *synth; + float *speech_enc_flt; + float *speech_enc_pe_flt; + float *new_speech_enc_flt; + float *new_speech_enc_pe_flt; + float *wspeech_enc_flt; + float *synth_flt; + Word16 *speech_enc; + Word16 *speech_enc_pe; + Word16 *new_speech_enc; + Word16 *new_speech_enc_pe; + Word16 *wspeech_enc; + Word16 *synth; int16_t enableTcxLpc; /* global toggle for the TCX LPC quantizer */ int16_t envWeighted; /* are is{p,f}_old_q[] weighted or not? */ @@ -1449,31 +1924,51 @@ typedef struct enc_core_structure int16_t tcx10Enabled; /* Flag indicating if TCX 10 can be used */ int16_t tcx20Enabled; /* Flag indicating if TCX 20 can be used */ - float mem_wsp_enc; /* wsp vector memory */ + float mem_wsp_enc_flt; /* wsp vector memory */ + Word16 mem_wsp_enc; /* wsp vector memory */ int16_t nb_bits_header_ace; /* number of bits for the header */ int16_t nb_bits_header_tcx; /* number of bits for the header */ - float preemph_fac; /* Preemphasis factor */ - float gamma; + float preemph_fac_flt; /* Preemphasis factor */ + float gamma_flt; + Word16 preemph_fac; /*Preemphasis factor*/ - TRAN_DET_HANDLE hTranDet; + Word16 gamma; + Word16 inv_gamma; + TRAN_DET_HANDLE hTranDet; + //TransientDetection transientDetection; + Word16 transient_info[3]; int16_t acelpFramesCount; float prevTempFlatness; + Word16 prevTempFlatness_fx; /* exponent is AVG_FLAT_E */ float prevEnergyHF; float currEnergyHF; float currEnergyLookAhead; + Word32 prevEnergyHF_fx; + Word32 currEnergyHF_fx; + Word16 currEnergyHF_e_fx; /* exponent of currEnergyHF and prevEnergyHF */ + Word32 energyCoreLookahead_Fx; + Word16 sf_energyCoreLookahead_Fx; - int16_t lpcQuantization; + /* lsf quantizer*/ + Word16 parcorr[2]; + Word16 parcorr_mid[2]; + int16_t lpcQuantization; + Word16 numlpc; int16_t encoderLookahead_enc; int16_t encoderPastSamples_enc; int16_t encoderLookahead_FB; /* pitch_ol for adaptive lag window */ int16_t old_pitch_la; /* past open loop pitch lag from look-ahead before very short stable pitch detection */ + Word16 old_voicing_la; /* past open loop pitch gain from look-ahead */ + + Word32 band_energies[2 * NB_BANDS]; /* energy in critical bands without minimum noise floor MODE2_E_MIN */ + Word16 band_energies_exp; /* exponent for energy in critical bands without minimum noise floor MODE2_E_MIN */ int16_t acelp_autocorr; /* Optimize acelp in 0 covariance or 1 correlation domain */ @@ -1491,14 +1986,19 @@ typedef struct enc_core_structure int16_t bpf_gain_param; float mem_bpf[2 * L_FILT16k]; float mem_error_bpf[2 * L_FILT16k]; + Word16 bpf_T[NB_SUBFR16k]; + Word16 bpf_gainT[NB_SUBFR16k]; int16_t glr; int16_t glr_idx[2]; - float mean_gc[2]; - float prev_lsf4_mean; + float mean_gc_flt[2]; + float prev_lsf4_mean_flt; + Word32 mean_gc[2]; + Word16 prev_lsf4_mean; int16_t glr_reset; int32_t last_sr_core; - float last_stab_fac; + float last_stab_fac_flt; + Word16 last_stab_fac; /*for rate switching*/ int16_t rate_switching_reset; /*Rate switching flag requiring a reset of memories at least partially */ @@ -1526,13 +2026,15 @@ typedef struct enc_core_structure TEC_ENC_HANDLE hTECEnc; /* TEC encoder handle */ int16_t tec_flag; int16_t tfa_flag; - float tfa_enr[N_TEC_TFA_SUBFR]; + float tfa_enr_flt[N_TEC_TFA_SUBFR]; + Word32 tfa_enr[N_TEC_TFA_SUBFR]; /*---------------------------------------------------------------* * IVAS parameters *---------------------------------------------------------------*/ int16_t tdm_LRTD_flag; /* LRTD stereo mode flag */ + Word16 cna_dirac_flag; /* CNA in DirAC flag */ /* stereo switching memories */ float mem_preemph_DFT; @@ -1546,6 +2048,29 @@ typedef struct enc_core_structure int16_t is_ism_format; /* Indication whether the codec operates in ISM format */ int16_t dtx_sce_sba; /* enable use of FD CNG with transform domain cores in SCE SBA */ + /*----------------------------------------------------------------------------------* + * Fixed point only variables + *----------------------------------------------------------------------------------*/ + + Word16 prev_Q_bwe_exc; + Word16 prev_Q_bwe_syn; + Word16 Q_stat_noise_ge; + Word16 Q_stat_noise; + Word16 Q_syn2; + Word16 Q_syn; + Word16 Q_max[L_Q_MEM]; + Word16 Q_max_16k[L_Q_MEM]; + Word16 Q_old; + Word16 prev_Q_old; + Word16 old_wsp_max; /* Last weigthed speech maximal value */ + Word16 old_wsp_shift; /* Last wsp scaling */ + Word16 prev_Q_new; + Word16 prev_Q_shb; + + Word16 EnergyLT_fx_exp; + Word16 prev_lsp_wb_fx[LPC_SHB_ORDER_WB]; + Word16 prev_lpc_wb_fx[LPC_SHB_ORDER_WB]; + Word16 prev_lsp_wb_temp_fx[LPC_SHB_ORDER_WB]; } Encoder_State, *ENC_CORE_HANDLE; diff --git a/lib_enc/swb_bwe_enc.c b/lib_enc/swb_bwe_enc.c index 3ff74624a..17f6dc8c6 100644 --- a/lib_enc/swb_bwe_enc.c +++ b/lib_enc/swb_bwe_enc.c @@ -1702,7 +1702,7 @@ void hq_generic_hf_encoding( for ( n_band = 0; n_band < DIM_FB; n_band++ ) { energy = EPSILON; - for ( n_coeff = fb_bwe_subband[n_band]; n_coeff < fb_bwe_subband[n_band + 1]; n_coeff++ ) + for ( n_coeff = fb_bwe_subband_float[n_band]; n_coeff < fb_bwe_subband_float[n_band + 1]; n_coeff++ ) { energy += coefs[n_coeff] * coefs[n_coeff]; } diff --git a/lib_enc/swb_pre_proc.c b/lib_enc/swb_pre_proc.c index 87d28c0b0..5bbc461cd 100644 --- a/lib_enc/swb_pre_proc.c +++ b/lib_enc/swb_pre_proc.c @@ -547,7 +547,7 @@ void swb_pre_proc( { CldfbHB = 1.0f; } - hBWE_TD->cldfbHBLT = 0.9f * hBWE_TD->cldfbHBLT + 0.1f * ( 0.221462f /*=1/log10(32768)*/ * ( log10f( CldfbHB ) - 1.0f ) ); + hBWE_TD->cldfbHBLT_flt = 0.9f * hBWE_TD->cldfbHBLT_flt + 0.1f * ( 0.221462f /*=1/log10(32768)*/ * ( log10f( CldfbHB ) - 1.0f ) ); lbEner = 0.05f * (float) sqrt( hCPE->hStereoDft->lbEner ); hCPE->hStereoICBWE->icbweRefEner = 0.05f * (float) sqrt( hCPE->hStereoDft->icbweRefEner ); @@ -596,7 +596,7 @@ void swb_pre_proc( { CldfbHB = 1.0f; } - hBWE_TD->cldfbHBLT = 0.9f * hBWE_TD->cldfbHBLT + 0.1f * ( 0.221462f /*=1/log10(32768)*/ * ( log10f( CldfbHB ) - 1.0f ) ); + hBWE_TD->cldfbHBLT_flt = 0.9f * hBWE_TD->cldfbHBLT_flt + 0.1f * ( 0.221462f /*=1/log10(32768)*/ * ( log10f( CldfbHB ) - 1.0f ) ); if ( st->element_mode >= IVAS_CPE_DFT && hCPE->hStereoICBWE != NULL ) { diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c index e8573d96b..0b2193fb9 100644 --- a/lib_enc/swb_tbe_enc.c +++ b/lib_enc/swb_tbe_enc.c @@ -113,7 +113,7 @@ void InitSWBencBuffer( hBWE_TD->prev_lsp_shb[i] = i / 20.0f; } - hBWE_TD->cldfbHBLT = 1.0f; + hBWE_TD->cldfbHBLT_flt = 1.0f; hBWE_TD->prev_gainFr_SHB = 0; set_f( hBWE_TD->lsp_shb_slow_interpl, 0, LPC_SHB_ORDER ); set_f( hBWE_TD->lsp_shb_fast_interpl, 0, LPC_SHB_ORDER ); @@ -121,7 +121,7 @@ void InitSWBencBuffer( set_f( hBWE_TD->lsp_shb_spacing, 0.1f, 3 ); hBWE_TD->prev_swb_GainShape = 0; hBWE_TD->prev_frGainAtten = 0; - hBWE_TD->prev_wb_GainShape = 0; + hBWE_TD->prev_wb_GainShape_flt = 0; set_f( hBWE_TD->fb_state_lpc_syn, 0, LPC_SHB_ORDER ); hBWE_TD->fb_tbe_demph = 0.0f; hBWE_TD->tilt_mem = 0.0f; @@ -403,7 +403,7 @@ void wb_tbe_enc( EstimateSHBGainShape( SHB_OVERLAP_LEN / 2, hb_frame, shaped_wb_excitation, GainShape, subwin_wb ); /* Gain frame adjustment factor */ - temp_wb_fac = (float) log( ( GainShape[0] + 0.00001f ) / ( hBWE_TD->prev_wb_GainShape + 0.0001f ) ); + temp_wb_fac = (float) log( ( GainShape[0] + 0.00001f ) / ( hBWE_TD->prev_wb_GainShape_flt + 0.0001f ) ); feedback = temp_wb_fac * temp_wb_fac; for ( i = 1; i < NUM_SHB_SUBFR / 4; i++ ) { @@ -412,13 +412,13 @@ void wb_tbe_enc( } feedback = 0.4f / ( 1 + 0.5f * feedback ); - temp_wb_fac = hBWE_TD->prev_wb_GainShape; + temp_wb_fac = hBWE_TD->prev_wb_GainShape_flt; for ( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) { GainShape[i] = ( 1 - feedback ) * GainShape[i] + feedback * temp_wb_fac; temp_wb_fac = GainShape[i]; } - hBWE_TD->prev_wb_GainShape = GainShape[NUM_SHB_SUBFR / 4 - 1]; + hBWE_TD->prev_wb_GainShape_flt = GainShape[NUM_SHB_SUBFR / 4 - 1]; /* Compute the power of gains away from the peak gain prior to quantization */ if ( st->element_mode > EVS_MONO ) @@ -1105,7 +1105,7 @@ void swb_tbe_enc( if ( st->extl_brate != SWB_TBE_1k10 && st->extl_brate != SWB_TBE_1k75 ) { /* Gain shape BWS/high band low energy fix */ - if ( hBWE_TD->cldfbHBLT < 1.0f ) + if ( hBWE_TD->cldfbHBLT_flt < 1.0f ) { /* There is not much HB past 10kHz; the temporal resolution is quite coarse, so reduce the dynamic range */ for ( i = 0; i < NUM_SHB_SUBGAINS; i++ ) @@ -1241,7 +1241,7 @@ void swb_tbe_enc( if ( st->tec_tfa == 1 ) { - tfaCalcEnv( shb_frame, st->tfa_enr ); + tfaCalcEnv( shb_frame, st->tfa_enr_flt); } /* If there's a big difference in the power of gains away from the peak gain */ @@ -2055,7 +2055,7 @@ static void LVQQuant_BWE_LSF( v_add( cand, quant, cand, LATTICE_DIM ); /* arrange the LSF candidate vector prior to selection to an ascending order*/ - v_sort( cand, 0, LPC_SHB_ORDER - 1 ); + v_sort_float( cand, 0, LPC_SHB_ORDER - 1 ); set_zero( Q_lsfs, LPC_SHB_ORDER ); /* mvr2r( mean_lsf, Q_lsfs, LPC_SHB_ORDER ); */ @@ -2112,7 +2112,7 @@ static void LVQQuant_BWE_LSF( } v_add( SHB_LSF_mean, lsf_q, lsf_q, LPC_SHB_ORDER ); - v_sort( lsf_q, 0, LPC_SHB_ORDER - 1 ); + v_sort_float( lsf_q, 0, LPC_SHB_ORDER - 1 ); for ( i = 0; i < LPC_SHB_ORDER; i++ ) { @@ -2686,7 +2686,7 @@ void fb_tbe_enc( const float fb_exc[] /* i : FB excitation from the SWB part */ ) { - float fb_exc_energy, ratio, temp2; + float fb_exc_energy, ratio_float, temp2; float tmp_vec[L_FRAME48k]; int16_t idxGain; float input_fhb[L_FRAME48k]; @@ -2734,10 +2734,10 @@ void fb_tbe_enc( temp2 = sum2_f( input_fhb, L_FRAME48k / 2 ) + hBWE_TD->prev_fb_energy; hBWE_TD->prev_fb_energy = sum2_f( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); fb_exc_energy = sum2_f( fb_exc, L_FRAME16k ) + EPSILON; - ratio = (float) sqrt( temp2 / fb_exc_energy ); - idxGain = (int16_t) ( log2_f( (float) ratio ) + 0.5f ); + ratio_float = (float) sqrt( temp2 / fb_exc_energy ); + idxGain = (int16_t) ( log2_f( (float) ratio_float ) + 0.5f ); idxGain = max( 0, min( 15, idxGain ) ); - ratio = (float) ( 1 << idxGain ); + ratio_float = (float) ( 1 << idxGain ); if ( st->codec_mode == MODE2 ) { diff --git a/lib_enc/tcx_ltp_enc.c b/lib_enc/tcx_ltp_enc.c index b8bc7dcd0..e9b1112d6 100644 --- a/lib_enc/tcx_ltp_enc.c +++ b/lib_enc/tcx_ltp_enc.c @@ -263,7 +263,7 @@ static void tcx_ltp_find_gain( int16_t gainbits = 2; /* Find gain */ - *gain = get_gain( speech, pred_speech, L_frame, NULL ); + *gain = get_gain_flt( speech, pred_speech, L_frame, NULL ); /* Quantize gain */ if ( *gain >= 0.875f ) @@ -336,7 +336,7 @@ void tcx_ltp_encode( { hTcxEnc->tcxltp_pitch_int_past = L_frame; hTcxEnc->tcxltp_pitch_fr_past = 0; - hTcxEnc->tcxltp_gain_past = 0.f; + hTcxEnc->tcxltp_gain_past_flt = 0.f; } /* By default, LTP is off */ @@ -406,8 +406,8 @@ void tcx_ltp_encode( } /* Switch LTP on */ - if ( ( tcxOnly == 0 && tcxMode == TCX_20 && norm_corr * hTcxEnc->tcxltp_norm_corr_past > 0.25f && tempFlatness < 3.5f ) || - ( tcxOnly == 1 && tcxMode == TCX_10 && max( norm_corr, hTcxEnc->tcxltp_norm_corr_past ) > 0.5f && maxEnergyChange < 3.5f ) || + if ( ( tcxOnly == 0 && tcxMode == TCX_20 && norm_corr * hTcxEnc->tcxltp_norm_corr_past_flt > 0.25f && tempFlatness < 3.5f ) || + ( tcxOnly == 1 && tcxMode == TCX_10 && max( norm_corr, hTcxEnc->tcxltp_norm_corr_past_flt) > 0.5f && maxEnergyChange < 3.5f ) || /* Use LTP for lower correlation when pitch lag is big, L_frame*(1.2f-norm_corr) < hTcxEnc->tcxltp_pitch_int <=> norm_corr > 1.2f-hTcxEnc->/L_frame */ ( tcxOnly == 1 && norm_corr > 0.44f && L_frame * ( 1.2f - norm_corr ) < hTcxEnc->tcxltp_pitch_int ) || ( tcxOnly == 1 && tcxMode == TCX_20 && norm_corr > 0.44f && ( tempFlatness < 6.0f || ( tempFlatness < 7.0f && maxEnergyChange < 22.0f ) ) ) ) @@ -447,16 +447,16 @@ void tcx_ltp_encode( predict_signal( speech, pred_speech, hTcxEnc->tcxltp_pitch_int, hTcxEnc->tcxltp_pitch_fr, st->pit_res_max, L_frame ); /* Find gain */ - tcx_ltp_find_gain( speech, pred_speech, L_frame, &hTcxEnc->tcxltp_gain, <p_param[2] ); + tcx_ltp_find_gain( speech, pred_speech, L_frame, &hTcxEnc->tcxltp_gain_flt, <p_param[2] ); if ( ltp_param[0] ) { /* Total number of bits for LTP */ - if ( ltp_param[2] + 1 ) /* hTcxEnc->tcxltp_gain > 0 */ + if ( ltp_param[2] + 1 ) /* hTcxEnc->tcxltp_gain_flt > 0 */ { *ltp_bits = 12; } - else /* hTcxEnc->tcxltp_gain <= 0 -> turn off LTP */ + else /* hTcxEnc->tcxltp_gain_flt <= 0 -> turn off LTP */ { ltp_param[0] = 0; } @@ -469,7 +469,7 @@ void tcx_ltp_encode( hTcxEnc->tcxltp_pitch_fr = 0; ltp_param[1] = 0; set_zero( pred_speech, L_frame ); - hTcxEnc->tcxltp_gain = 0.f; + hTcxEnc->tcxltp_gain_flt = 0.f; ltp_param[2] = 0; if ( hTcxEnc->tcxltp || SideInfoOnly ) { @@ -484,23 +484,23 @@ void tcx_ltp_encode( si_gain = 0; if ( SideInfoOnly ) { - si_gain = hTcxEnc->tcxltp_gain; - hTcxEnc->tcxltp_gain = 0.f; + si_gain = hTcxEnc->tcxltp_gain_flt; + hTcxEnc->tcxltp_gain_flt = 0.f; } if ( speech_ltp != NULL ) { - if ( hTcxEnc->tcxltp_gain_past == 0.f && hTcxEnc->tcxltp_gain == 0.f ) + if ( hTcxEnc->tcxltp_gain_past_flt == 0.f && hTcxEnc->tcxltp_gain_flt == 0.f ) { mvr2r( speech, speech_ltp, L_subfr ); } - else if ( hTcxEnc->tcxltp_gain_past == 0.f ) + else if ( hTcxEnc->tcxltp_gain_past_flt == 0.f ) { alpha = 0.f; step = 1.f / (float) ( L_subfr ); for ( n = 0; n < L_subfr; n++ ) { - speech_ltp[n] = speech[n] - alpha * hTcxEnc->tcxltp_gain * pred_speech[n]; + speech_ltp[n] = speech[n] - alpha * hTcxEnc->tcxltp_gain_flt * pred_speech[n]; alpha += step; } } @@ -526,7 +526,7 @@ void tcx_ltp_encode( A = Aest; } - if ( hTcxEnc->tcxltp_gain > 0.f ) + if ( hTcxEnc->tcxltp_gain_flt > 0.f ) { predict_signal( speech - M, buf_zir, hTcxEnc->tcxltp_pitch_int, hTcxEnc->tcxltp_pitch_fr, st->pit_res_max, M ); } @@ -537,7 +537,7 @@ void tcx_ltp_encode( for ( n = 0; n < M; n++ ) { - buf_zir[n] = speech_ltp[n - M] - speech[n - M] + hTcxEnc->tcxltp_gain * buf_zir[n]; + buf_zir[n] = speech_ltp[n - M] - speech[n - M] + hTcxEnc->tcxltp_gain_flt * buf_zir[n]; } zir = buf_zir + M; @@ -554,11 +554,11 @@ void tcx_ltp_encode( for ( n = 0; n < L_subfr; n++ ) { - speech_ltp[n] = ( speech[n] - hTcxEnc->tcxltp_gain * pred_speech[n] ) + zir[n]; + speech_ltp[n] = ( speech[n] - hTcxEnc->tcxltp_gain_flt * pred_speech[n] ) + zir[n]; } } - if ( SideInfoOnly || hTcxEnc->tcxltp_gain == 0.0f ) + if ( SideInfoOnly || hTcxEnc->tcxltp_gain_flt == 0.0f ) { for ( n = L_subfr; n < L_frame; n++ ) { @@ -569,7 +569,7 @@ void tcx_ltp_encode( { for ( n = L_subfr; n < L_frame; n++ ) { - speech_ltp[n] = speech[n] - hTcxEnc->tcxltp_gain * pred_speech[n]; + speech_ltp[n] = speech[n] - hTcxEnc->tcxltp_gain_flt * pred_speech[n]; } } } @@ -577,14 +577,14 @@ void tcx_ltp_encode( /* Update */ hTcxEnc->tcxltp_pitch_int_past = hTcxEnc->tcxltp_pitch_int; hTcxEnc->tcxltp_pitch_fr_past = hTcxEnc->tcxltp_pitch_fr; - hTcxEnc->tcxltp_gain_past = hTcxEnc->tcxltp_gain; + hTcxEnc->tcxltp_gain_past_flt = hTcxEnc->tcxltp_gain_flt; if ( SideInfoOnly ) { - hTcxEnc->tcxltp_gain = si_gain; + hTcxEnc->tcxltp_gain_flt = si_gain; } - hTcxEnc->tcxltp_norm_corr_past = norm_corr; + hTcxEnc->tcxltp_norm_corr_past_flt = norm_corr; return; } diff --git a/lib_enc/tcx_utils_enc.c b/lib_enc/tcx_utils_enc.c index 31473d404..ad2e28558 100644 --- a/lib_enc/tcx_utils_enc.c +++ b/lib_enc/tcx_utils_enc.c @@ -203,12 +203,12 @@ void AnalyzePowerSpectrum( if ( st->total_brate <= ACELP_24k40 ) { - lowpassLine = (int16_t) ( 2.0f * st->hTcxCfg->bandwidth * L_frame ); - detectLowpassFac( powerSpec, L_frame, ( st->last_core == ACELP_CORE ), &hTcxEnc->measuredBwRatio, lowpassLine ); + lowpassLine = (int16_t) ( 2.0f * st->hTcxCfg->bandwidth_flt * L_frame ); + detectLowpassFac( powerSpec, L_frame, ( st->last_core == ACELP_CORE ), &hTcxEnc->measuredBwRatio_flt, lowpassLine ); } else { - hTcxEnc->measuredBwRatio = 1.0f; + hTcxEnc->measuredBwRatio_flt = 1.0f; } return; @@ -1029,40 +1029,40 @@ void tcx_encoder_memory_update( L_frame_glob = st->L_frame; /* Output synth */ - mvr2r( xn_buf, st->synth, L_frame_glob ); + mvr2r( xn_buf, st->synth_flt, L_frame_glob ); /* Update synth */ synth = buf + 1 + M; - mvr2r( LPDmem->syn, buf, 1 + M ); + mvr2r( LPDmem->syn_flt, buf, 1 + M ); mvr2r( xn_buf, synth, L_frame_glob ); - mvr2r( synth + L_frame_glob - M - 1, LPDmem->syn, 1 + M ); + mvr2r( synth + L_frame_glob - M - 1, LPDmem->syn_flt, 1 + M ); if ( !st->tcxonly ) { /* Update weighted synthesis */ residu( Ai + ( st->nb_subfr - 1 ) * ( M + 1 ), M, synth + L_frame_glob - 1, &tmp, 1 ); - LPDmem->mem_w0 = st->wspeech_enc[L_frame_glob - 1] - tmp; + LPDmem->mem_w0_flt = st->wspeech_enc_flt[L_frame_glob - 1] - tmp; } /* Emphasis of synth -> synth_pe */ tmp = synth[-M - 1]; - preemph( synth - M, st->hTcxCfg->preemph_fac, M + L_frame_glob, &tmp ); - mvr2r( synth + L_frame_glob - M, LPDmem->mem_syn, M ); - mvr2r( synth + L_frame_glob - M, LPDmem->mem_syn2, M ); - mvr2r( synth + L_frame_glob - L_SYN_MEM, LPDmem->mem_syn_r, L_SYN_MEM ); + preemph( synth - M, st->hTcxCfg->preemph_fac_flt, M + L_frame_glob, &tmp ); + mvr2r( synth + L_frame_glob - M, LPDmem->mem_syn_flt, M ); + mvr2r( synth + L_frame_glob - M, LPDmem->mem_syn2_flt, M ); + mvr2r( synth + L_frame_glob - L_SYN_MEM, LPDmem->mem_syn_r_flt, L_SYN_MEM ); if ( !st->tcxonly || ( L_frame_glob == L_FRAME16k ) ) { /* Update excitation */ if ( L_frame_glob < L_EXC_MEM ) { - mvr2r( LPDmem->old_exc + ( L_frame_glob ), LPDmem->old_exc, L_EXC_MEM - L_frame_glob ); - residu( A, M, synth, LPDmem->old_exc + L_EXC_MEM - ( L_frame_glob ), L_frame_glob ); + mvr2r( LPDmem->old_exc_flt + ( L_frame_glob ), LPDmem->old_exc_flt, L_EXC_MEM - L_frame_glob ); + residu( A, M, synth, LPDmem->old_exc_flt + L_EXC_MEM - ( L_frame_glob ), L_frame_glob ); } else { - residu( A, M, synth + (L_frame_glob) -L_EXC_MEM, LPDmem->old_exc, L_EXC_MEM ); + residu( A, M, synth + (L_frame_glob) -L_EXC_MEM, LPDmem->old_exc_flt, L_EXC_MEM ); } } @@ -1471,9 +1471,9 @@ void ProcessIGF( curr_order = 0; predictionGain = 0; - ITF_Detect( hIGFEnc->spec_be_igf, hIGFEnc->infoStartLine, hIGFEnc->infoStopLine, 8 /*maxOrder*/, A, &predictionGain, &curr_order ); + ITF_Detect( hIGFEnc->spec_be_igf_flt, hIGFEnc->infoStartLine, hIGFEnc->infoStopLine, 8 /*maxOrder*/, A, &predictionGain, &curr_order ); - hIGFEnc->flatteningTrigger = hIGFEnc->tns_predictionGain < 1.15 && predictionGain < 1.15; + hIGFEnc->flatteningTrigger = hIGFEnc->tns_predictionGain_flt < 1.15 && predictionGain < 1.15; hIGFEnc->infoTotalBitsPerFrameWritten = 0; @@ -1554,9 +1554,9 @@ void ProcessStereoIGF( { curr_order = 0; - ITF_Detect( hIGFEnc[ch]->spec_be_igf, hIGFEnc[ch]->infoStartLine, hIGFEnc[ch]->infoStopLine, 8 /*maxOrder*/, A, &predictionGain, &curr_order ); + ITF_Detect( hIGFEnc[ch]->spec_be_igf_flt, hIGFEnc[ch]->infoStartLine, hIGFEnc[ch]->infoStopLine, 8 /*maxOrder*/, A, &predictionGain, &curr_order ); - hIGFEnc[ch]->flatteningTrigger = hIGFEnc[ch]->tns_predictionGain < 1.15 && predictionGain < 1.15; + hIGFEnc[ch]->flatteningTrigger = hIGFEnc[ch]->tns_predictionGain_flt < 1.15 && predictionGain < 1.15; hIGFEnc[ch]->infoTotalBitsPerFrameWritten = 0; diff --git a/lib_enc/tns_base_enc.c b/lib_enc/tns_base_enc.c index 594f78241..37a0b10a2 100644 --- a/lib_enc/tns_base_enc.c +++ b/lib_enc/tns_base_enc.c @@ -266,7 +266,7 @@ static void GetFilterParameters( /* Variable initialization */ /* compute TNS filter in lattice (ParCor) form with LeRoux-Gueguen algorithm */ - pTnsFilter->predictionGain = AutoToParcor( rxx, parCoeff, maxOrder ); + pTnsFilter->predictionGain_flt = AutoToParcor( rxx, parCoeff, maxOrder ); /* non-linear quantization of TNS lattice coefficients with given resolution */ Parcor2Index( parCoeff, indexes, maxOrder ); @@ -281,15 +281,15 @@ static void GetFilterParameters( pTnsFilter->order = i + 1; /* compute avg(coef*coef) */ - pTnsFilter->avgSqrCoef = 0; + pTnsFilter->avgSqrCoef_flt = 0; for ( i = pTnsFilter->order - 1; i >= 0; i-- ) { const float value = values[indexes[i] + INDEX_SHIFT]; /* Variable initialization */ - pTnsFilter->avgSqrCoef += value * value; + pTnsFilter->avgSqrCoef_flt += value * value; } - pTnsFilter->avgSqrCoef /= maxOrder; + pTnsFilter->avgSqrCoef_flt /= maxOrder; return; } @@ -416,7 +416,7 @@ void CalculateTnsFilt( if ( predictionGain ) { assert( pTnsConfig->nMaxFilters == 1 ); - *predictionGain = pTnsData->filter->predictionGain; + *predictionGain = pTnsData->filter->predictionGain_flt; } return; @@ -449,7 +449,7 @@ static void TnsDecision( pTnsParameters = pTnsConfig->pTnsParameters + iFilter; /* TNS decision function */ - if ( ( pFilter->predictionGain > pTnsParameters->minPredictionGain ) || ( pFilter->avgSqrCoef > pTnsParameters->minAvgSqrCoef ) ) + if ( ( pFilter->predictionGain_flt > pTnsParameters->minPredictionGain_flt) || ( pFilter->avgSqrCoef_flt > pTnsParameters->minAvgSqrCoef_flt) ) { if ( pTnsData->nFilters > 0 || isTCX10 || ltp_gain < 0.6f || hTranDet == NULL ) { @@ -458,7 +458,7 @@ static void TnsDecision( else { maxEnergyChange = GetTCXMaxenergyChange( hTranDet, isTCX10, NSUBBLOCKS, 3 ); - if ( maxEnergyChange >= pTnsParameters->minEnergyChange ) + if ( maxEnergyChange >= pTnsParameters->minEnergyChange_flt) { ++pTnsData->nFilters; } diff --git a/lib_enc/transient_detection.c b/lib_enc/transient_detection.c index 43689d333..88f592dde 100644 --- a/lib_enc/transient_detection.c +++ b/lib_enc/transient_detection.c @@ -132,7 +132,7 @@ float GetTCXAvgTemporalFlatnessMeasure( sumTempFlatness = 0.0f; assert( ( nPrevSubblocks <= nRelativeDelay ) && ( nCurrentSubblocks <= NSUBBLOCKS + nDelay ) ); - pSubblockNrgChange = &pSubblockEnergies->subblockNrgChange[nRelativeDelay - nPrevSubblocks]; + pSubblockNrgChange = &pSubblockEnergies->subblockNrgChange_flt[nRelativeDelay - nPrevSubblocks]; for ( i = 0; i < nTotBlocks; i++ ) { sumTempFlatness += pSubblockNrgChange[i]; @@ -167,10 +167,10 @@ float GetTCXMaxenergyChange( maxEnergyChange = 0.0f; assert( ( nPrevSubblocks <= nRelativeDelay ) && ( nCurrentSubblocks <= NSUBBLOCKS + nDelay ) ); - pSubblockNrgChange = &pSubblockEnergies->subblockNrgChange[nRelativeDelay - nPrevSubblocks]; + pSubblockNrgChange = &pSubblockEnergies->subblockNrgChange_flt[nRelativeDelay - nPrevSubblocks]; if ( pTransientDetector->bIsAttackPresent || isTCX10 ) /* frame is TCX-10 */ { - const float *pSubblockNrg = &pSubblockEnergies->subblockNrg[nRelativeDelay - nPrevSubblocks]; + const float *pSubblockNrg = &pSubblockEnergies->subblockNrg_flt[nRelativeDelay - nPrevSubblocks]; float nrgMin, nrgMax = pSubblockNrg[0]; int16_t idxMax = 0; /* find subblock with maximum energy */ @@ -226,7 +226,7 @@ void RunTransientDetection( assert( ( input != NULL ) && ( hTranDet != NULL ) && ( pSubblockEnergies != NULL ) && ( pTransientDetector != NULL ) ); /* Variable initializations */ - HighPassFilter( input, length, &pSubblockEnergies->firState1, &pSubblockEnergies->firState2, filteredInput ); + HighPassFilter( input, length, &pSubblockEnergies->firState1_flt, &pSubblockEnergies->firState2_flt, filteredInput ); /* Update subblock energies. */ UpdateSubblockEnergies( filteredInput, length, pSubblockEnergies ); @@ -240,7 +240,7 @@ void RunTransientDetection( /* compute ramp up flag */ pSubblockEnergies->ramp_up_flag = ( ( pSubblockEnergies->ramp_up_flag << 1 ) & 0x0003 ); e0 = dotp( filteredInput + length / 2, filteredInput + length / 2, pSubblockEnergies->pDelayBuffer->nSubblockSize / 2 ) + 0.5f * MIN_BLOCK_ENERGY; - e1 = pSubblockEnergies->subblockNrg[pSubblockEnergies->nDelay + 4] - e0; + e1 = pSubblockEnergies->subblockNrg_flt[pSubblockEnergies->nDelay + 4] - e0; if ( e1 > e0 ) { pSubblockEnergies->ramp_up_flag |= 0x0001; @@ -352,7 +352,7 @@ void SetTCXModeInfo( } if ( isLongTermTransient( 1.0f / GetTCXAvgTemporalFlatnessMeasure( hTranDet, NSUBBLOCKS, 0 ), &hTcxEnc->tfm_mem ) && st->element_mode == IVAS_CPE_MDCT ) { - if ( ( *tcxModeOverlap != MIN_OVERLAP ) && ( hTcxEnc->tcxltp_norm_corr_past < 0.5625f ) ) + if ( ( *tcxModeOverlap != MIN_OVERLAP ) && ( hTcxEnc->tcxltp_norm_corr_past_flt < 0.5625f ) ) { *tcxModeOverlap = HALF_OVERLAP; } @@ -374,7 +374,7 @@ void SetTCXModeInfo( } if ( isLongTermTransient( 1.0f / GetTCXAvgTemporalFlatnessMeasure( hTranDet, NSUBBLOCKS, 0 ), &hTcxEnc->tfm_mem ) && st->element_mode == IVAS_CPE_MDCT ) { - if ( ( *tcxModeOverlap != MIN_OVERLAP ) && ( hTcxEnc->tcxltp_norm_corr_past < 0.5625f ) ) + if ( ( *tcxModeOverlap != MIN_OVERLAP ) && ( hTcxEnc->tcxltp_norm_corr_past_flt < 0.5625f ) ) { *tcxModeOverlap = HALF_OVERLAP; } @@ -496,7 +496,7 @@ static void InitDelayBuffer( assert( ( nFrameLength > NSUBBLOCKS ) && ( nFrameLength % NSUBBLOCKS == 0 ) && ( nDelay >= 0 ) && ( pDelayBuffer != NULL ) ); pDelayBuffer->nSubblockSize = nFrameLength / NSUBBLOCKS; assert( pDelayBuffer->nSubblockSize <= nMaxBuffSize ); - set_f( pDelayBuffer->buffer, 0.0f, nMaxBuffSize ); + set_f( pDelayBuffer->buffer_flt, 0.0f, nMaxBuffSize ); pDelayBuffer->nDelay = nDelay % pDelayBuffer->nSubblockSize; assert( pDelayBuffer->nDelay <= nMaxBuffSize ); @@ -514,15 +514,15 @@ static void InitSubblockEnergies( assert( ( pDelayBuffer != NULL ) && ( pSubblockEnergies != NULL ) && ( pDelayBuffer->nSubblockSize * NSUBBLOCKS == nFrameLength ) && ( pDelayBuffer->nSubblockSize > 0 ) ); - set_f( pSubblockEnergies->subblockNrg, MIN_BLOCK_ENERGY, nMaxBuffSize ); - set_f( pSubblockEnergies->accSubblockNrg, MIN_BLOCK_ENERGY, nMaxBuffSize + 1 ); - set_f( pSubblockEnergies->subblockNrgChange, 1.0f, nMaxBuffSize ); + set_f( pSubblockEnergies->subblockNrg_flt, MIN_BLOCK_ENERGY, nMaxBuffSize ); + set_f( pSubblockEnergies->accSubblockNrg_flt, MIN_BLOCK_ENERGY, nMaxBuffSize + 1 ); + set_f( pSubblockEnergies->subblockNrgChange_flt, 1.0f, nMaxBuffSize ); pSubblockEnergies->nDelay = nDelay / pDelayBuffer->nSubblockSize; assert( pSubblockEnergies->nDelay < nMaxBuffSize ); pSubblockEnergies->nPartialDelay = nDelay % pDelayBuffer->nSubblockSize; - pSubblockEnergies->facAccSubblockNrg = 0.8125f; /* Energy accumulation factor */ - pSubblockEnergies->firState1 = 0.0f; - pSubblockEnergies->firState2 = 0.0f; + pSubblockEnergies->facAccSubblockNrg_flt = 0.8125f; /* Energy accumulation factor */ + pSubblockEnergies->firState1_flt = 0.0f; + pSubblockEnergies->firState2_flt = 0.0f; pSubblockEnergies->pDelayBuffer = pDelayBuffer; pDelayBuffer->nDelay = max( pDelayBuffer->nDelay, pSubblockEnergies->nPartialDelay ); @@ -560,7 +560,7 @@ static void InitTransientDetector( assert( nSubblocksToCheck <= NSUBBLOCKS + pTransientDetector->nDelay ); pTransientDetector->nSubblocksToCheck = nSubblocksToCheck; pTransientDetector->CheckSubblocksForAttack = pCheckSubblocksForAttack; - pTransientDetector->attackRatioThreshold = attackRatioThreshold; + pTransientDetector->attackRatioThreshold_flt = attackRatioThreshold; pTransientDetector->bIsAttackPresent = FALSE; pTransientDetector->prev_bIsAttackPresent = FALSE; pTransientDetector->attackIndex = -1; @@ -607,12 +607,12 @@ static void HighPassFilter( static void RunTransientDetector( TransientDetector *pTransientDetector ) { - const float attackRatioThreshold = pTransientDetector->attackRatioThreshold; + const float attackRatioThreshold = pTransientDetector->attackRatioThreshold_flt; const SubblockEnergies *pSubblockEnergies = pTransientDetector->pSubblockEnergies; const int16_t nDelay = pTransientDetector->nDelay; const int16_t nRelativeDelay = pSubblockEnergies->nDelay - nDelay; - const float *pSubblockNrg = &pSubblockEnergies->subblockNrg[nRelativeDelay]; - const float *pAccSubblockNrg = &pSubblockEnergies->accSubblockNrg[nRelativeDelay]; + const float *pSubblockNrg = &pSubblockEnergies->subblockNrg_flt[nRelativeDelay]; + const float *pAccSubblockNrg = &pSubblockEnergies->accSubblockNrg_flt[nRelativeDelay]; assert( ( pTransientDetector->CheckSubblocksForAttack != NULL ) ); @@ -633,7 +633,7 @@ static void UpdateDelayBuffer( int16_t i; int16_t nDelay = pDelayBuffer->nDelay; - assert( ( nDelay >= 0 ) && ( nDelay <= (int16_t) sizeof( pDelayBuffer->buffer ) / (int16_t) sizeof( pDelayBuffer->buffer[0] ) ) ); + assert( ( nDelay >= 0 ) && ( nDelay <= (int16_t) sizeof( pDelayBuffer->buffer_flt) / (int16_t) sizeof( pDelayBuffer->buffer_flt[0] ) ) ); assert( nSamplesAvailable <= NSUBBLOCKS * pDelayBuffer->nSubblockSize ); /* If this is not the last frame */ @@ -642,7 +642,7 @@ static void UpdateDelayBuffer( /* Store the newest samples into the delay buffer */ for ( i = 0; i < nDelay; i++ ) { - pDelayBuffer->buffer[i] = input[i + nSamplesAvailable - nDelay]; + pDelayBuffer->buffer_flt[i] = input[i + nSamplesAvailable - nDelay]; } } @@ -657,7 +657,7 @@ static void UpdateSubblockEnergies( { int16_t i; - assert( ( pSubblockEnergies->nDelay >= 0 ) && ( pSubblockEnergies->nDelay + NSUBBLOCKS <= (int16_t) sizeof( pSubblockEnergies->subblockNrg ) / (int16_t) sizeof( pSubblockEnergies->subblockNrg[0] ) ) ); + assert( ( pSubblockEnergies->nDelay >= 0 ) && ( pSubblockEnergies->nDelay + NSUBBLOCKS <= (int16_t) sizeof( pSubblockEnergies->subblockNrg_flt) / (int16_t) sizeof( pSubblockEnergies->subblockNrg_flt[0] ) ) ); assert( pSubblockEnergies->nPartialDelay <= pSubblockEnergies->pDelayBuffer->nDelay ); /* At least one block delay is required when subblock energy change is required */ assert( pSubblockEnergies->nDelay >= 1 ); @@ -665,9 +665,9 @@ static void UpdateSubblockEnergies( /* Shift old subblock energies */ for ( i = 0; i < pSubblockEnergies->nDelay; i++ ) { - pSubblockEnergies->subblockNrg[i] = pSubblockEnergies->subblockNrg[i + NSUBBLOCKS]; - pSubblockEnergies->accSubblockNrg[i] = pSubblockEnergies->accSubblockNrg[i + NSUBBLOCKS]; - pSubblockEnergies->subblockNrgChange[i] = pSubblockEnergies->subblockNrgChange[i + NSUBBLOCKS]; + pSubblockEnergies->subblockNrg_flt[i] = pSubblockEnergies->subblockNrg_flt[i + NSUBBLOCKS]; + pSubblockEnergies->accSubblockNrg_flt[i] = pSubblockEnergies->accSubblockNrg_flt[i + NSUBBLOCKS]; + pSubblockEnergies->subblockNrgChange_flt[i] = pSubblockEnergies->subblockNrgChange_flt[i + NSUBBLOCKS]; } /* Compute filtered subblock energies for the new samples */ @@ -707,11 +707,11 @@ static void CalculateSubblockEnergies( const int16_t nSubblockSize = pDelayBuffer->nSubblockSize; /* */ const int16_t nDelay = pSubblockEnergies->nDelay; /* */ const int16_t nPartialDelay = pSubblockEnergies->nPartialDelay; /* */ - const float *delayBuffer = &pDelayBuffer->buffer[pDelayBuffer->nDelay - nPartialDelay]; /* */ - const float facAccSubblockNrg = pSubblockEnergies->facAccSubblockNrg; /* */ - float *pSubblockNrg = &pSubblockEnergies->subblockNrg[nDelay]; /* */ - float *pAccSubblockNrg = &pSubblockEnergies->accSubblockNrg[nDelay]; /* */ - float *pSubblockNrgChange = &pSubblockEnergies->subblockNrgChange[nDelay]; /* */ + const float *delayBuffer = &pDelayBuffer->buffer_flt[pDelayBuffer->nDelay - nPartialDelay]; /* */ + const float facAccSubblockNrg = pSubblockEnergies->facAccSubblockNrg_flt; /* */ + float *pSubblockNrg = &pSubblockEnergies->subblockNrg_flt[nDelay]; /* */ + float *pAccSubblockNrg = &pSubblockEnergies->accSubblockNrg_flt[nDelay]; /* */ + float *pSubblockNrgChange = &pSubblockEnergies->subblockNrgChange_flt[nDelay]; /* */ float *pAccSubblockTmp; int16_t nWindows; int16_t i, w, k; @@ -878,7 +878,7 @@ int16_t transient_analysis( /* forward attack analysis */ for ( i = -2; i < 7; i++ ) { - if ( hTranDet->subblockEnergies.subblockNrg[nRelativeDelay + i] > hTranDet->subblockEnergies.accSubblockNrg[nRelativeDelay + i] * thr_fwd ) + if ( hTranDet->subblockEnergies.subblockNrg_flt[nRelativeDelay + i] > hTranDet->subblockEnergies.accSubblockNrg_flt[nRelativeDelay + i] * thr_fwd ) { prel_force_td |= 0x0001; } @@ -886,7 +886,7 @@ int16_t transient_analysis( if ( prel_force_td == 0 && hTranDet->transientDetector.prev_bIsAttackPresent == 1 ) { /* release analysis */ - pSubblockNrg = hTranDet->transientDetector.pSubblockEnergies->subblockNrg; + pSubblockNrg = hTranDet->transientDetector.pSubblockEnergies->subblockNrg_flt; set_zero( accSubblockNrgRev, NSUBBLOCKS ); for ( i = NSUBBLOCKS - 1; i > -1; i-- ) @@ -898,7 +898,7 @@ int16_t transient_analysis( else { accSubblockNrgRev[i] = *pTmp; - *pTmp *= hTranDet->transientDetector.pSubblockEnergies->facAccSubblockNrg; + *pTmp *= hTranDet->transientDetector.pSubblockEnergies->facAccSubblockNrg_flt; if ( pSubblockNrg[i + offset] > *pTmp ) { *pTmp = pSubblockNrg[i + offset]; diff --git a/lib_enc/updt_enc.c b/lib_enc/updt_enc.c index a92e7ef47..674403f7c 100644 --- a/lib_enc/updt_enc.c +++ b/lib_enc/updt_enc.c @@ -61,7 +61,7 @@ void updt_enc( int16_t i; /* update old excitation buffer */ - mvr2r( &old_exc[st->L_frame], st->hLPDmem->old_exc, L_EXC_MEM ); + mvr2r( &old_exc[st->L_frame], st->hLPDmem->old_exc_flt, L_EXC_MEM ); if ( !st->Opt_AMR_WB && st->hBWE_TD != NULL ) { mvr2r( &old_bwe_exc[L_FRAME32k], st->hBWE_TD->old_bwe_exc, PIT16k_MAX * 2 ); @@ -182,7 +182,7 @@ void updt_IO_switch_enc( } /* Perform preemphasis of the old input signal @16kHz */ st->mem_preemph16k = 0; - preemph( st->old_inp_16k, PREEMPH_FAC_16k, L_INP_MEM, &( st->mem_preemph16k ) ); + preemph( st->old_inp_16k, PREEMPH_FAC_16k_FLT, L_INP_MEM, &( st->mem_preemph16k ) ); /* reset TD BWE buffers */ set_f( st->hBWE_TD->old_speech_wb, 0.0f, ( L_LOOK_12k8 + L_SUBFR ) * 5 / 16 ); @@ -396,13 +396,13 @@ void updt_enc_common( if ( st->sr_core == INT_FS_12k8 ) { - st->preemph_fac = PREEMPH_FAC; - st->gamma = GAMMA1; + st->preemph_fac_flt = PREEMPH_FAC_FLT; + st->gamma_flt = GAMMA1_FLT; } else { - st->preemph_fac = PREEMPH_FAC_16k; - st->gamma = GAMMA16k; + st->preemph_fac_flt = PREEMPH_FAC_16k_FLT; + st->gamma_flt = GAMMA16k_FLT; } st->igf = getIgfPresent( EVS_MONO, st->total_brate, st->bwidth, st->rf_mode ); @@ -450,7 +450,7 @@ void updt_enc_common( if ( st->element_mode > EVS_MONO && st->hTcxEnc != NULL ) { - st->hTcxEnc->tcxltp_norm_corr_mem = st->hTcxEnc->tcxltp_norm_corr_past; + st->hTcxEnc->tcxltp_norm_corr_mem_flt = st->hTcxEnc->tcxltp_norm_corr_past_flt; } return; diff --git a/lib_enc/vlpc_2st_cod.c b/lib_enc/vlpc_2st_cod.c index 9e1e9fe55..2197c13c4 100644 --- a/lib_enc/vlpc_2st_cod.c +++ b/lib_enc/vlpc_2st_cod.c @@ -140,7 +140,7 @@ int16_t vlpc_2st_cod( } /* reorder */ - v_sort( lsfq, 0, M - 1 ); + v_sort_float( lsfq, 0, M - 1 ); reorder_lsf( lsfq, LSF_GAP, M, sr_core ); return ( nbits ); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 07ab219ac..dd6e5823e 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -1024,20 +1024,20 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric int16_t aziDeg, eleDeg; float lRealp, lImagp, rRealp, rImagp; float lRealpTmp, lImagpTmp, rRealpTmp, rImagpTmp; - float hrtfEne[BINAURAL_CHANNELS], hrtfCrossRe, hrtfCrossIm, ratio; + float hrtfEne[BINAURAL_CHANNELS], hrtfCrossRe, hrtfCrossIm, ratio_float; uint8_t isIsmDirection = 0; if ( dirIndex == 0 ) /* For first of the two simultaneous directions */ { aziDeg = hSpatParamRendCom->azimuth[dirac_read_idx][bin]; eleDeg = hSpatParamRendCom->elevation[dirac_read_idx][bin]; - ratio = hSpatParamRendCom->energy_ratio1[dirac_read_idx][bin]; + ratio_float = hSpatParamRendCom->energy_ratio1[dirac_read_idx][bin]; spreadCoh = hSpatParamRendCom->spreadCoherence[dirac_read_idx][bin]; gainCacheBaseIndex = 0; } else if ( ivas_format != MASA_ISM_FORMAT || ( ivas_format == MASA_ISM_FORMAT && dirIndex < hSpatParamRendCom->numParametricDirections ) ) /* For second of the two simultaneous directions */ { - if ( ( ratio = hSpatParamRendCom->energy_ratio2[dirac_read_idx][bin] ) < 0.001 ) + if ( ( ratio_float = hSpatParamRendCom->energy_ratio2[dirac_read_idx][bin] ) < 0.001 ) { /* This touches only MASA path where second direction always has smaller ratio and * for non-2dir it is zero. As the whole direction contribution is multiplied with @@ -1066,12 +1066,12 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric aziDeg = hMasaIsmData->azimuth_ism[ismDirIndex][dirac_read_idx]; eleDeg = hMasaIsmData->elevation_ism[ismDirIndex][dirac_read_idx]; } - ratio = hMasaIsmData->energy_ratio_ism[ismDirIndex][dirac_read_idx][bin]; + ratio_float = hMasaIsmData->energy_ratio_ism[ismDirIndex][dirac_read_idx][bin]; spreadCoh = 0.0f; gainCacheBaseIndex = 6 + ismDirIndex; } - diffuseness -= ratio; /* diffuseness = 1 - ratio1 - ratio2 */ + diffuseness -= ratio_float; /* diffuseness = 1 - ratio1 - ratio2 */ if ( diffuseness < 0.0f ) { @@ -1080,11 +1080,11 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric if ( isIsmDirection ) { /* Objects cause lesser decorrelation reduction, to avoid removing all decorrelation when only objects are present */ - diffusenessValForDecorrelationReduction -= ratio * 0.5f; + diffusenessValForDecorrelationReduction -= ratio_float * 0.5f; } else { - diffusenessValForDecorrelationReduction -= ratio; + diffusenessValForDecorrelationReduction -= ratio_float; } if ( separateCenterChannelRendering ) @@ -1210,7 +1210,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric hrtfCrossIm = ( -lImagp * rRealp ) + ( lRealp * rImagp ); /* Add direct part (1 or 2) covariance matrix */ - dirEne = ratio * meanEnePerCh; + dirEne = ratio_float * meanEnePerCh; hDiracDecBin->ChEneOut[0][bin] += dirEne * hrtfEne[0]; /* Dir ene part*/ hDiracDecBin->ChEneOut[1][bin] += dirEne * hrtfEne[1]; hDiracDecBin->ChCrossReOut[bin] += dirEne * hrtfCrossRe; /* Dir cross re */ @@ -2540,14 +2540,14 @@ void ivas_omasa_preProcessStereoTransportsForMovedObjects( { float panGainsOut[2]; float panGainsIn[2]; - float ratio; + float ratio_float; float panEnesOut[2]; float panEnesIn[2]; float centeringFactor; - ratio = hMasaIsmData->energy_ratio_ism[ismDirIndex][dirac_read_idx][bin]; + ratio_float = hMasaIsmData->energy_ratio_ism[ismDirIndex][dirac_read_idx][bin]; - ismRatioAcc += ratio; + ismRatioAcc += ratio_float; /* Get input and output panning gains */ ivas_get_stereo_panning_gains( hMasaIsmData->azimuth_ism[ismDirIndex][dirac_read_idx], @@ -2593,11 +2593,11 @@ void ivas_omasa_preProcessStereoTransportsForMovedObjects( eneMoveThis = fmaxf( 0.0f, panEnesIn[ch] - panEnesOut[ch] ); enePreserveThis = panEnesIn[ch] - eneMoveThis; - eneMove[ch] += ratio * eneMoveThis; - enePreserve[ch] += ratio * enePreserveThis; + eneMove[ch] += ratio_float * eneMoveThis; + enePreserve[ch] += ratio_float * enePreserveThis; /* Subtract object parts from normEnes */ - normEnes[ch] -= panEnesIn[ch] * ratio; + normEnes[ch] -= panEnesIn[ch] * ratio_float; } } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 7ac648d8d..4a107d5d9 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -798,7 +798,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( int16_t nchan_transport_foa; int16_t ch_idx_diff; float aux_buf[CLDFB_NO_CHANNELS_MAX]; - float ratio[DIRAC_HO_NUMSECTORS * CLDFB_NO_CHANNELS_MAX]; + float ratio_float[DIRAC_HO_NUMSECTORS * CLDFB_NO_CHANNELS_MAX]; /* collect some often used parameters */ h_dirac_output_synthesis_params = hDirACRend->h_output_synthesis_psd_params; @@ -843,18 +843,18 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( for ( l = 0; l < num_freq_bands; l++ ) { aux_buf[l] = 1.f - diffuseness[l]; - ratio[l] = 1.f - h_dirac_output_synthesis_state.direct_power_factor[hSpatParamRendCom->num_freq_bands + l]; - ratio[l + num_freq_bands] = 1.f - ratio[l]; + ratio_float[l] = 1.f - h_dirac_output_synthesis_state.direct_power_factor[hSpatParamRendCom->num_freq_bands + l]; + ratio_float[l + num_freq_bands] = 1.f - ratio_float[l]; } - v_mult( aux_buf, ratio, ratio, num_freq_bands ); - v_mult( aux_buf, &ratio[num_freq_bands], &ratio[num_freq_bands], num_freq_bands ); + v_mult( aux_buf, ratio_float, ratio_float, num_freq_bands ); + v_mult( aux_buf, &ratio_float[num_freq_bands], &ratio_float[num_freq_bands], num_freq_bands ); - v_mult( ratio, + v_mult( ratio_float, &h_dirac_output_synthesis_state.direct_responses[ch_idx * num_freq_bands], &h_dirac_output_synthesis_state.cy_cross_dir_smooth[ch_idx * num_freq_bands], num_freq_bands ); - v_mult( &ratio[num_freq_bands], + v_mult( &ratio_float[num_freq_bands], &h_dirac_output_synthesis_state.direct_responses[ch_idx * num_freq_bands + num_freq_bands * num_channels_dir], &h_dirac_output_synthesis_state.cy_cross_dir_smooth[ch_idx * num_freq_bands + num_freq_bands * num_channels_dir], num_freq_bands ); @@ -2152,7 +2152,7 @@ void ivas_lfe_synth_with_filters( /* Delay the separated channel to sync the LFE synthesis with the DirAC rendering */ delay = hMasaLfeSynth->delayBuffer_syncDirAC_size; - delay_signal( data_f[separateChannelIndex], output_frame, hMasaLfeSynth->delayBuffer_syncDirAC, delay ); + delay_signal_float( data_f[separateChannelIndex], output_frame, hMasaLfeSynth->delayBuffer_syncDirAC, delay ); /* Filterbank for dividing the separated channel to LFE frequencies and higher frequencies */ lowpassCoef = 1.0f / ( (float) hMasaLfeSynth->ringBufferSize ); @@ -2233,7 +2233,7 @@ void ivas_lfe_synth_with_filters( /* Delay the separated channel to match the delay of the lowpass filter */ delay = hMasaLfeSynth->delayBuffer_syncLp_size; - delay_signal( data_f[separateChannelIndex], output_frame, hMasaLfeSynth->delayBuffer_syncLp, delay ); + delay_signal_float( data_f[separateChannelIndex], output_frame, hMasaLfeSynth->delayBuffer_syncLp, delay ); return; } diff --git a/lib_rend/ivas_efap.c b/lib_rend/ivas_efap.c index 4c202a481..9391a5a73 100644 --- a/lib_rend/ivas_efap.c +++ b/lib_rend/ivas_efap.c @@ -769,7 +769,7 @@ static void add_ghost_speakers( else /* fill gaps greater than maxAngle */ { /* Here, k correspond to the number of LS whose ele is < 45 deg, should be = numVertex */ - v_sort( tmpAzi, 0, k - 1 ); + v_sort_float( tmpAzi, 0, k - 1 ); /* The next lines correspond to angle_diff = [azi(2:end), azi(1) + 360] - azi; in Matlab */ for ( i = 0; i < k - 1; ++i ) diff --git a/lib_util/mime_io.c b/lib_util/mime_io.c index b5c257bb4..3f976faf8 100644 --- a/lib_util/mime_io.c +++ b/lib_util/mime_io.c @@ -201,8 +201,8 @@ MIME_ERROR MIME_WriteFrame( { int16_t mode; int16_t cmi; - mode = rate2EVSmode( numBits * FRAMES_PER_SEC, &isAmrWb ); - cmi = rate2EVSmode( totalBrate, &isAmrWb ); + mode = rate2EVSmode_float( numBits * FRAMES_PER_SEC, &isAmrWb ); + cmi = rate2EVSmode_float( totalBrate, &isAmrWb ); ToC = (uint8_t) ( isAmrWb << 5 | isAmrWb << 4 | mode ); writeByte( hMIME->file, ToC ); diff --git a/lib_util/test_fft.c b/lib_util/test_fft.c new file mode 100644 index 000000000..6622b3396 --- /dev/null +++ b/lib_util/test_fft.c @@ -0,0 +1,213 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + + +#include +#include +#include +#include +#include + +typedef int Word32; +typedef short Word16; +typedef short int16_t; + +#define ALLOWED_DEVIATION (0.005) +#define Q31 (2147483647.0f) + +void DoFFT_fx( + Word32 *re2, + Word32 *im2, + const int16_t length ); + +void DoFFT( + float *re2, + float *im2, + const int16_t length ); + +void fft_fx( + Word32 *re, /* i/o: real part */ + Word32 *im, /* i/o: imag part */ + const int16_t length, /* i : length of fft */ + const int16_t s /* i : sign */ +); + +void fft( + float *re, /* i/o: real part */ + float *im, /* i/o: imag part */ + const int16_t length, /* i : length of fft */ + const int16_t s /* i : sign */ +); + +#define print_output(fRe, fIm, iRe, iIm) \ + printf("Real = %.2f %d Imag = %.2f %d\n", fRe, iRe, fIm, iIm) + +float test_fixed_fft(Word16 N, Word32 isDoFFT) +{ + Word32 *iRe = malloc(N * sizeof(iRe[0])); + Word32 *iIm = malloc(N * sizeof(iRe[0])); + float *fRe = malloc(N * sizeof(fRe[0])); + float *fIm = malloc(N * sizeof(fRe[0])); + float max_deviation = 0.0f; + Word32 max_val_in = 0; + Word32 max_val_out = 0; + + if ((iRe == NULL) || (iIm == NULL) || (fRe == NULL) || (fIm == NULL)) + { + printf("!!!!Malloc failed!!!!"); + exit(1); + } + + do { + srand(N); + for(int i = 0; i < N; i++) + { + iRe[i] = rand(); + iIm[i] = rand(); + if (max_val_in < abs(iRe[i])) + max_val_in = abs(iRe[i]); + if (max_val_in < abs(iIm[i])) + max_val_in = abs(iIm[i]); + fRe[i] = (float)iRe[i]; + fIm[i] = (float)iIm[i]; + } + } while(max_val_in == 0); + + if (isDoFFT) + { + DoFFT(fRe, fIm, N); + DoFFT_fx(iRe, iIm, N); + } + else + { + fft(fRe, fIm, N, 1); + fft_fx(iRe, iIm, N, 1); + } + + for(int i = 0; i < N; i++) + { + float OutRe = fRe[i]; + float OutIm = fIm[i]; + float dev_val_real = (float)(fabs(OutRe - (float)iRe[i])); + float dev_val_imag = (float)(fabs(OutIm - (float)iIm[i])); + if (max_val_out < iRe[i]) + max_val_out = iRe[i]; + if (max_val_out < iIm[i]) + max_val_out = iIm[i]; + //print_output(OutRe, OutIm, iRe[i], iIm[i]); + if (dev_val_real > max_deviation) + max_deviation = dev_val_real; + if (dev_val_imag > max_deviation) + max_deviation = dev_val_imag; + } + free( iRe ); + free( iIm ); + free( fRe ); + free( fIm ); + return (( max_deviation / max_val_out) * 100); +} + +void test_DoFFT(Word16 *fft_lengths, Word16 num_lengths) +{ + Word32 num_tests = 0, num_passed = 0, num_failed = 0; + printf("\033[0;33m"); + printf("============== Starting DoFFT tests ================\n"); + for ( int i = num_lengths - 1; i >=0 ; i-- ) + { + float max_deviation = test_fixed_fft( fft_lengths[i], 1); + num_tests++; + if (max_deviation < ALLOWED_DEVIATION) + { + printf("\033[0;32m"); + printf("[PASSED] FFT test of length %d\n", fft_lengths[i]); + num_passed++; + } + else + { + printf("\033[0;31m"); + printf("[FAILED] FFT test of length %d Max_deviation = %.6f\n", fft_lengths[i], max_deviation); + num_failed++; + } + } + printf("\033[0;33m"); + printf("============== Completed DoFFT tests ================\n\n"); + printf("Summary of FFT unit tests:\n"); + printf("--------------------------\n"); + printf("Total tests: %d\n", num_tests); + printf("Passed: %d\n", num_passed); + printf("\033[0;31m"); + printf("Failed: %d\n\n", num_failed); + printf("\033[0m"); +} + + +void test_fft(Word16 *fft_lengths, Word16 num_lengths) +{ + Word32 num_tests = 0, num_passed = 0, num_failed = 0; + printf("\033[0;33m"); + printf("============== Starting fft tests ================\n"); + for ( int i = num_lengths - 1; i >=0 ; i-- ) + { + float max_deviation = test_fixed_fft( fft_lengths[i], 0); + num_tests++; + if (max_deviation < ALLOWED_DEVIATION) + { + printf("\033[0;32m"); + printf("[PASSED] FFT test of length %d\n", fft_lengths[i]); + num_passed++; + } + else + { + printf("\033[0;31m"); + printf("[FAILED] FFT test of length %d Max_deviation = %.6f\n", fft_lengths[i], max_deviation); + num_failed++; + } + } + printf("\033[0;33m"); + printf("============== Completed fft tests ================\n\n"); + printf("Summary of FFT unit tests:\n"); + printf("--------------------------\n"); + printf("Total tests: %d\n", num_tests); + printf("Passed: %d\n", num_passed); + printf("\033[0;31m"); + printf("Failed: %d\n\n", num_failed); + printf("\033[0m"); +} + +void run_fft_unit_test(void) +{ + Word16 fft_lengths[] = {600, 480, 400, 320, 256, 240, 200, 160, 128, 120, 100, 80, 64, 40, 20,}; + Word16 fft_lengths_2[] = {960, 640, 600, 480, 400, 320, 256, 240, 200, 160, 128, 120, 100, 80, 64, 40, 20}; + test_DoFFT(&fft_lengths[0], sizeof(fft_lengths) / sizeof(fft_lengths[0])); + test_fft(&fft_lengths_2[0], sizeof(fft_lengths_2) / sizeof(fft_lengths_2[0])); + return; +} \ No newline at end of file -- GitLab From 19ca46c69f54433465ed2a41e264da91ccbc0393 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 17 Nov 2023 11:43:38 +0530 Subject: [PATCH 2/2] Update for using 64 bit operator [x] Fix for using 64 bit operator in place of 40 bit operator [x] Few cleanup changes --- Workspace_msvc/lib_com.vcxproj | 3 +- Workspace_msvc/lib_com.vcxproj.filters | 9 +- lib_com/basop_mpy.c | 177 ------------------- lib_com/basop_mpy.h | 94 ---------- lib_com/basop_settings.h | 1 - lib_com/basop_util.c | 1 - lib_com/basop_util.h | 3 +- lib_com/enh32.c | 236 +++++++++++++++++++++++++ lib_com/enh32.h | 38 ++++ lib_com/hq2_bit_alloc.c | 1 - lib_com/lpc_tools_fx.c | 1 - lib_com/math_32.h | 10 ++ lib_com/prot_fx1.h | 2 - lib_com/stl.h | 3 +- lib_com/tcq_position_arith.c | 24 --- lib_com/tools_fx.c | 10 -- 16 files changed, 291 insertions(+), 322 deletions(-) delete mode 100644 lib_com/basop_mpy.c delete mode 100644 lib_com/basop_mpy.h create mode 100644 lib_com/enh32.c create mode 100644 lib_com/enh32.h create mode 100644 lib_com/math_32.h diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 5db9f886e..d85ee4e99 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -128,7 +128,6 @@ - @@ -149,6 +148,7 @@ + @@ -293,7 +293,6 @@
- diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index 2b88b2d97..91091b0ad 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -40,9 +40,6 @@ common_all_c - - common_all_c - common_all_c @@ -518,6 +515,9 @@ common_all_c + + common_all_c + @@ -526,9 +526,6 @@ common_h - - common_h - common_h diff --git a/lib_com/basop_mpy.c b/lib_com/basop_mpy.c deleted file mode 100644 index 606f49c93..000000000 --- a/lib_com/basop_mpy.c +++ /dev/null @@ -1,177 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include "basop_mpy.h" -#include -#include "options.h" - -#define WMC_TOOL_SKIP - -Word32 Mpy_32_16_1( Word32 x, Word16 y ) -{ - Word32 mh; - UWord16 ml; - - Mpy_32_16_ss( x, y, &mh, &ml ); - - return ( mh ); -} - -Word32 Mpy_32_16_r( Word32 x, Word16 y ) -{ - Word32 mh; - UWord16 ml; - - Mpy_32_16_ss( x, y, &mh, &ml ); - - if ( s_and( ml, -32768 /* 0x8000 */ ) ) - { - mh = L_add( mh, 1 ); - } - - return ( mh ); -} - - -Word32 Mpy_32_32( Word32 x, Word32 y ) -{ - Word32 mh; - UWord32 ml; - - Mpy_32_32_ss( x, y, &mh, &ml ); - - return ( mh ); -} - - -Word32 Mpy_32_32_r(Word32 L_var1, Word32 L_var2) { - Word32 L_var_out; - Word64 L64_var1; - - L64_var1 = ((Word64)L_var1 * L_var2); - L64_var1 = W_shr(L64_var1, 15); - L_var_out = W_round48_L(L64_var1); - return L_var_out; -} - - -Word32 Madd_32_16(Word32 L_var3, Word32 L_var1, Word16 var2) { - Word32 L_var_out; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; -#endif - - L_var_out = Mpy_32_16_1(L_var1, var2); -#ifdef BASOP_NOGLOB - L_var_out = L_add_o(L_var3, L_var_out, &Overflow); -#else /* BASOP_NOGLOB */ - L_var_out = L_add(L_var3, L_var_out); -#endif /* BASOP_NOGLOB */ - - return L_var_out; -} - -Word32 Madd_32_16_r(Word32 L_var3, Word32 L_var1, Word16 var2) { - Word32 L_var_out; - - L_var_out = Mpy_32_16_r(L_var1, var2); - L_var_out = L_add(L_var3, L_var_out); - - return L_var_out; -} - -Word32 Msub_32_16(Word32 L_var3, Word32 L_var1, Word16 var2) { - Word32 L_var_out; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; -#endif - - L_var_out = Mpy_32_16_1(L_var1, var2); -#ifdef BASOP_NOGLOB - L_var_out = L_sub_o(L_var3, L_var_out, &Overflow); -#else /* BASOP_NOGLOB */ - L_var_out = L_sub(L_var3, L_var_out); -#endif - - return L_var_out; -} - -Word32 Msub_32_16_r(Word32 L_var3, Word32 L_var1, Word16 var2) { - Word32 L_var_out; - - L_var_out = Mpy_32_16_r(L_var1, var2); - L_var_out = L_sub(L_var3, L_var_out); - - return L_var_out; -} - -Word32 Madd_32_32(Word32 L_var3, Word32 L_var1, Word32 L_var2) { - Word32 L_var_out; - - L_var_out = Mpy_32_32(L_var1, L_var2); - L_var_out = L_add(L_var3, L_var_out); - - return L_var_out; -} - -Word32 Madd_32_32_r(Word32 L_var3, Word32 L_var1, Word32 L_var2) { - Word32 L_var_out; - - L_var_out = Mpy_32_32_r(L_var1, L_var2); - L_var_out = L_add(L_var3, L_var_out); - - return L_var_out; -} - -Word32 Msub_32_32(Word32 L_var3, Word32 L_var1, Word32 L_var2) { - Word32 L_var_out; - - L_var_out = Mpy_32_32(L_var1, L_var2); - L_var_out = L_sub(L_var3, L_var_out); - - return L_var_out; -} - - -Word32 Msub_32_32_r(Word32 L_var3, Word32 L_var1, Word32 L_var2) { - Word32 L_var_out; - - L_var_out = Mpy_32_32_r(L_var1, L_var2); - L_var_out = L_sub(L_var3, L_var_out); - - return L_var_out; -} -#undef WMC_TOOL_SKIP diff --git a/lib_com/basop_mpy.h b/lib_com/basop_mpy.h deleted file mode 100644 index ef1a3cd9d..000000000 --- a/lib_com/basop_mpy.h +++ /dev/null @@ -1,94 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#ifndef __BASOP_MPY_H -#define __BASOP_MPY_H - -#include "stl.h" -#include -#include "options.h" - -/** - * \brief 32*16 Bit fractional Multiplication using 40 bit OPS - * Performs a multiplication of a 32-bit variable x by - * a 16-bit variable y, returning a 32-bit value. - * - * \param[i] x - * \param[i] y - * - * \return x*y - */ -Word32 Mpy_32_16_1( Word32 x, Word16 y ); - - -/** - * \brief 32*16 Bit fractional Multiplication using 40 bit OPS - * Performs a multiplication of a 32-bit variable x by - * a 16-bit variable y including rounding, returning a 32-bit value. - * - * \param[i] x - * \param[i] y - * - * \return x*y - */ -Word32 Mpy_32_16_r( Word32 x, Word16 y ); - - -/** - * \brief 32*32 Bit fractional Multiplication using 40 bit OPS - * - * Performs a multiplication of a 32-bit variable x by - * a 32-bit variable y, returning a 32-bit value. - * - * \param[i] x - * \param[i] y - * - * \return x*y - */ - -Word32 Mpy_32_32( Word32 x, Word32 y ); - -Word32 Madd_32_16(Word32 L_var3, Word32 L_var1, Word16 var2); -Word32 Madd_32_16_r(Word32 L_var3, Word32 L_var1, Word16 var2); -Word32 Msub_32_16(Word32 L_var3, Word32 L_var1, Word16 var2); -Word32 Msub_32_16_r(Word32 L_var3, Word32 L_var1, Word16 var2); -Word32 Madd_32_32(Word32 L_var3, Word32 L_var1, Word32 L_var2); -Word32 Madd_32_32_r(Word32 L_var3, Word32 L_var1, Word32 L_var2); -Word32 Msub_32_32(Word32 L_var3, Word32 L_var1, Word32 L_var2); -Word32 Msub_32_32_r(Word32 L_var3, Word32 L_var1, Word32 L_var2); - - -#endif /* __BASOP_SETTINGS_H */ diff --git a/lib_com/basop_settings.h b/lib_com/basop_settings.h index 758a99650..5936c69aa 100644 --- a/lib_com/basop_settings.h +++ b/lib_com/basop_settings.h @@ -40,7 +40,6 @@ #include #include "options.h" #include "stl.h" -#include "basop_mpy.h" #define WORD32_BITS 32 #define MAXVAL_WORD32 ( (int32_t) 0x7FFFFFFF ) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index c4f265580..6c184d69c 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -41,7 +41,6 @@ #include "basop_util.h" #include "rom_com.h" #include "basop_settings.h" -#include "basop_mpy.h" #include "control.h" #include "cnst.h" diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index 910a635a0..85500c1e9 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -42,8 +42,7 @@ #include "basop_settings.h" #include "typedef.h" #include "basop32.h" -#include "basop_mpy.h" - +#include "math_32.h" #define LD_DATA_SCALE ( 6 ) diff --git a/lib_com/enh32.c b/lib_com/enh32.c new file mode 100644 index 000000000..9015fc1be --- /dev/null +++ b/lib_com/enh32.c @@ -0,0 +1,236 @@ +/***************************************************************************** + * + * Enhanced 32 bit operators : + * + * Mpy_32_16_1() + * Mpy_32_16_r() + * Mpy_32_32() + * Mpy_32_32_r() + * Madd_32_16() + * Msub_32_16() + * Madd_32_32() + * Msub_32_32() + * + *****************************************************************************/ + + +/***************************************************************************** + * + * Include-Files + * + *****************************************************************************/ +#include +#include +#include "enh32.h" + +#if (WMOPS) +extern BASIC_OP multiCounter[MAXCOUNTERS]; +extern int currCounter; +#endif /* if WMOPS */ + +#ifdef ENH_32_BIT_OPERATOR +/***************************************************************************** + * + * Local Functions + * + *****************************************************************************/ + +/***************************************************************************** + * + * Constants and Globals + * + *****************************************************************************/ + + +/***************************************************************************** + * + * Functions + * + *****************************************************************************/ + +Word32 Mpy_32_16_1 (Word32 L_var1, Word16 var2) { + Word32 L_var_out = W_sat_m (W_mult_32_16 (L_var1, var2) ); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_1++; + multiCounter[currCounter].W_mult_32_16--; + multiCounter[currCounter].W_sat_m--; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Mpy_32_16_r (Word32 L_var1, Word16 var2) { + Word32 L_var_out = W_round48_L (W_mult_32_16 (L_var1, var2 ) ); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_r++; + multiCounter[currCounter].W_mult_32_16--; + multiCounter[currCounter].W_round48_L--; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Mpy_32_32 (Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; + Word64 L64_var1; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + L64_var1 = ((Word64)L_var1 * L_var2); +#ifdef BASOP_NOGLOB + L64_var1 = W_shl_o (L64_var1, 1, &Overflow); +#else /* BASOP_NOGLOB */ + L64_var1 = W_shl (L64_var1, 1); +#endif /* BASOP_NOGLOB */ + L_var_out = W_extract_h (L64_var1 ); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_32++; + multiCounter[currCounter].W_shl--; + multiCounter[currCounter].W_extract_h--; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Mpy_32_32_r (Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; + Word64 L64_var1; + + L64_var1 = ((Word64) L_var1 * L_var2); + L64_var1 = W_shr (L64_var1, 15); + L_var_out = W_round48_L (L64_var1 ); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_32_r++; + multiCounter[currCounter].W_shr--; + multiCounter[currCounter].W_round48_L--; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Madd_32_16 (Word32 L_var3, Word32 L_var1, Word16 var2) { + Word32 L_var_out; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + L_var_out = Mpy_32_16_1 (L_var1, var2); +#ifdef BASOP_NOGLOB + L_var_out = L_add_o (L_var3, L_var_out, &Overflow); +#else /* BASOP_NOGLOB */ + L_var_out = L_add (L_var3, L_var_out); +#endif /* BASOP_NOGLOB */ + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].L_add--; + multiCounter[currCounter].Madd_32_16++; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Madd_32_16_r (Word32 L_var3, Word32 L_var1, Word16 var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_16_r (L_var1, var2); + L_var_out = L_add (L_var3, L_var_out); + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_r--; + multiCounter[currCounter].L_add--; + multiCounter[currCounter].Madd_32_16_r++; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Msub_32_16 (Word32 L_var3, Word32 L_var1, Word16 var2) { + Word32 L_var_out; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + L_var_out = Mpy_32_16_1 (L_var1, var2); +#ifdef BASOP_NOGLOB + L_var_out = L_sub_o(L_var3, L_var_out, &Overflow); +#else /* BASOP_NOGLOB */ + L_var_out = L_sub(L_var3, L_var_out); +#endif + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].L_sub--; + multiCounter[currCounter].Msub_32_16++; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Msub_32_16_r (Word32 L_var3, Word32 L_var1, Word16 var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_16_r (L_var1, var2); + L_var_out = L_sub (L_var3, L_var_out); + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_r--; + multiCounter[currCounter].L_sub--; + multiCounter[currCounter].Msub_32_16_r++; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Madd_32_32 (Word32 L_var3, Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_32 (L_var1, L_var2); + L_var_out = L_add (L_var3, L_var_out); + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_32--; + multiCounter[currCounter].L_add--; + multiCounter[currCounter].Madd_32_32++; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Madd_32_32_r (Word32 L_var3, Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_32_r (L_var1, L_var2); + L_var_out = L_add (L_var3, L_var_out); + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_32_r--; + multiCounter[currCounter].L_add--; + multiCounter[currCounter].Madd_32_32_r++; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Msub_32_32 (Word32 L_var3, Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_32 (L_var1, L_var2); + L_var_out = L_sub (L_var3, L_var_out); + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_32--; + multiCounter[currCounter].L_sub--; + multiCounter[currCounter].Msub_32_32++; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Msub_32_32_r (Word32 L_var3, Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_32_r (L_var1, L_var2); + L_var_out = L_sub (L_var3, L_var_out); + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_32_r--; + multiCounter[currCounter].L_sub--; + multiCounter[currCounter].Msub_32_32_r++; +#endif /* if WMOPS */ + return L_var_out; +} + +#endif /* #ifdef ENH_32_BIT_OPERATOR */ + +/* end of file */ diff --git a/lib_com/enh32.h b/lib_com/enh32.h new file mode 100644 index 000000000..a6e220c95 --- /dev/null +++ b/lib_com/enh32.h @@ -0,0 +1,38 @@ + +#ifndef _ENH32_H +#define _ENH32_H + +#include "stl.h" + +#ifndef Word64 +#define Word64 long long int +#endif + + /***************************************************************************** + * + * Prototypes for enhanced 32 bit arithmetic operators + * + *****************************************************************************/ +#ifdef ENH_32_BIT_OPERATOR + +Word32 Mpy_32_16_1 (Word32 L_var1, Word16 var2); +Word32 Mpy_32_16_r (Word32 L_var1, Word16 var2); +Word32 Mpy_32_32 (Word32 L_var1, Word32 L_var2); +Word32 Mpy_32_32_r (Word32 L_var1, Word32 L_var2); +Word32 Madd_32_16 (Word32 L_var3, Word32 L_var1, Word16 var2); +Word32 Madd_32_16_r (Word32 L_var3, Word32 L_var1, Word16 var2); +Word32 Msub_32_16 (Word32 L_var3, Word32 L_var1, Word16 var2); +Word32 Msub_32_16_r (Word32 L_var3, Word32 L_var1, Word16 var2); +Word32 Madd_32_32 (Word32 L_var3, Word32 L_var1, Word32 L_var2); +Word32 Madd_32_32_r (Word32 L_var3, Word32 L_var1, Word32 L_var2); +Word32 Msub_32_32 (Word32 L_var3, Word32 L_var1, Word32 L_var2); +Word32 Msub_32_32_r (Word32 L_var3, Word32 L_var1, Word32 L_var2); + +#endif /* #ifdef ENH_32_BIT_OPERATOR */ + +#endif /*_ENH32_H*/ + + +/* end of file */ + + diff --git a/lib_com/hq2_bit_alloc.c b/lib_com/hq2_bit_alloc.c index 96f8eee57..c9440433d 100644 --- a/lib_com/hq2_bit_alloc.c +++ b/lib_com/hq2_bit_alloc.c @@ -40,7 +40,6 @@ #include "prot.h" #include "rom_com.h" #include "basop_util.h" -#include "basop_mpy.h" #include "stl.h" #include "wmc_auto.h" diff --git a/lib_com/lpc_tools_fx.c b/lib_com/lpc_tools_fx.c index f33986f60..3505da50d 100644 --- a/lib_com/lpc_tools_fx.c +++ b/lib_com/lpc_tools_fx.c @@ -40,7 +40,6 @@ #include "ivas_cnst.h" /* Common constants */ #include "prot_fx2.h" /* Function prototypes */ #include "rom_com.h" -#include "basop_mpy.h" #include "basop_util.h" diff --git a/lib_com/math_32.h b/lib_com/math_32.h new file mode 100644 index 000000000..539284d5a --- /dev/null +++ b/lib_com/math_32.h @@ -0,0 +1,10 @@ +#ifndef _MATH_32_H_ +#define _MATH_32_H_ + +#include "typedef.h" +#include "basop32.h" +#include "enh32.h" + +#define Mult_32_16(A,B) Mpy_32_16_1(A,B) +#define Mult_32_32(A,B) Mpy_32_32(A,B) +#endif /* #ifndef _MATH_32_H_ */ diff --git a/lib_com/prot_fx1.h b/lib_com/prot_fx1.h index 6bcd60344..536740741 100644 --- a/lib_com/prot_fx1.h +++ b/lib_com/prot_fx1.h @@ -41,8 +41,6 @@ #include "cnst.h" #include "stl.h" -Word32 Mult_32_16(Word32 a, Word16 b); - int16_t norm_ul(uint32_t UL_var1); Word16 usdequant_fx( /* Qx*/ const Word16 idx, /* i: quantizer index Q0*/ diff --git a/lib_com/stl.h b/lib_com/stl.h index 3d05e5d80..53543407a 100644 --- a/lib_com/stl.h +++ b/lib_com/stl.h @@ -60,7 +60,7 @@ //#define ENH_U_32_BIT_OPERATOR #define COMPLEX_OPERATOR #define CONTROL_CODE_OPS -//#define ENH_32_BIT_OPERATOR +#define ENH_32_BIT_OPERATOR #define ENH_64_BIT_OPERATOR #define BASOP_NOGLOB #if defined BASOP_NOGLOB && !defined BASOP_NOGLOB_DEV_USE_GLOBALS @@ -76,6 +76,7 @@ #include "enh1632.h" #include "enh40.h" #include "enh64.h" +#include "enh32.h" #endif /* ifndef _STL_H */ diff --git a/lib_com/tcq_position_arith.c b/lib_com/tcq_position_arith.c index ee8ab03d9..6e17301d9 100644 --- a/lib_com/tcq_position_arith.c +++ b/lib_com/tcq_position_arith.c @@ -53,30 +53,6 @@ static int32_t ar_decode( PARCODEC arInst, const int16_t *model ); static void ar_encode( PARCODEC arInst, const int16_t *model, int32_t symbol ); static void ar_encode_uniform( PARCODEC arInst, uint16_t data, const int16_t bits ); -//already defined in tools_fx.c - -/* 32x16 multiply: */ -//Word32 Mult_32_16( Word32 a, Word16 b ) -//{ -// Word32 result; -// UWord16 lo; -// /* use Mpy_32_16_ss(): */ -// Mpy_32_16_ss( a, b, &result, &lo ); -// -// return result; -//} - -/* 32x32 multiply: */ -Word32 Mult_32_32( Word32 a, Word32 b ) -{ - Word32 result; - UWord32 lo; - /* use Mpy_32_32_ss(): */ - Mpy_32_32_ss( a, b, &result, &lo ); - - return result; -} - static void set16_fx( Word16 y[], /* i/o: Vector to set */ const Word16 a, /* i : Value to set the vector to */ diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 98c8fbeeb..cc3545d07 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -54,16 +54,6 @@ #define INV_BANDS3 10923 /* 1/9 in Q15 */ const Word16 b_hp400_fx[3] = { 3660, -7320, 3660 }; /* Q12 (/4) */ const Word16 a_hp400_fx[3] = { 16384, 29280, -14160 }; -//basic functions -Word32 Mult_32_16(Word32 a, Word16 b) -{ - Word32 result; - UWord16 lo; - /* use Mpy_32_16_ss(): */ - Mpy_32_16_ss(a, b, &result, &lo); - - return result; -} static __inline Word16 L_Extract_lc(const Word32 L_32, Word16 *p_hi) { -- GitLab