From 39294083dd00fe0845d735390cbeca7b4a8ea664 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 15 Jul 2024 12:35:47 +0530 Subject: [PATCH 1/2] BASOP updates for lib_com, lib_dec, WMOPS optimization changes [x] BASOP and instrumentation changes for lib_com, lib_dec and lib_rend files [x] Replaced some of the basops where MAC operation were performed with Madd_* and Msub_* operations. [x] Crash fix for OMASA 2Dir2TC 4ISM at br sw techs 13.2 to 512 kbps start 384 kbps, 48kHz in, 16kHz out, BINAURAL out (Model from file) --- lib_com/arith_coder.c | 4 +- lib_com/cldfb.c | 274 +++++----- lib_com/core_com_config.c | 210 ++++++-- lib_com/deemph.c | 21 +- lib_com/delay_comp.c | 13 +- lib_com/dlpc_bfi_fx.c | 2 +- lib_com/edct_fx.c | 220 +++++--- lib_com/enhancer_fx.c | 205 ++++---- lib_com/fd_cng_com.c | 11 +- lib_com/fd_cng_com_fx.c | 9 +- lib_com/int_lsp.c | 8 +- lib_com/interleave_spectrum.c | 1 + lib_com/isf_dec_amr_wb_fx.c | 8 +- lib_com/ivas_agc_com_fx.c | 18 +- lib_com/ivas_arith.c | 147 +++++- lib_com/ivas_avq_pos_reorder_com.c | 29 ++ lib_com/ivas_cov_smooth.c | 12 +- lib_com/ivas_dirac_com.c | 266 +++++++--- lib_com/ivas_fb_mixer.c | 274 ++++++---- lib_com/ivas_filters.c | 7 + lib_com/ivas_ism_com.c | 139 ++++- lib_com/ivas_lfe_com.c | 5 + lib_com/ivas_prot.h | 47 ++ lib_com/ivas_rom_com.c | 2 +- lib_com/ivas_sns_com_fx.c | 12 +- lib_com/ivas_stereo_ica_com_fx.c | 2 +- lib_com/prot.h | 14 +- lib_com/prot_fx1.h | 6 + lib_com/prot_fx2.h | 8 +- lib_com/stat_noise_uv_mod_fx.c | 10 +- lib_com/swb_bwe_com_fx.c | 74 ++- lib_com/swb_bwe_com_lr_fx.c | 90 +++- lib_com/swb_tbe_com.c | 83 +-- lib_com/swb_tbe_com_fx.c | 249 +++++++-- lib_com/syn_filt_fx.c | 15 +- lib_com/tcq_position_arith.c | 577 ++++++++++++--------- lib_com/tns_base.c | 6 +- lib_com/tools_fx.c | 18 + lib_com/weight_a_fx.c | 49 +- lib_dec/amr_wb_dec_fx.c | 35 +- lib_dec/arith_coder_dec.c | 6 +- lib_dec/fd_cng_dec.c | 4 +- lib_dec/ivas_init_dec.c | 57 +- lib_dec/ivas_mdct_core_dec.c | 2 +- lib_dec/ivas_spar_decoder.c | 55 +- lib_dec/lsf_dec_fx.c | 79 ++- lib_dec/lsf_msvq_ma_dec_fx.c | 12 +- lib_dec/nelp_dec_fx.c | 38 +- lib_dec/peak_vq_dec_fx.c | 27 +- lib_dec/pit_dec_fx.c | 62 ++- lib_dec/pitch_extr_fx.c | 18 +- lib_dec/post_dec_fx.c | 97 ++-- lib_dec/ppp_dec_fx.c | 47 +- lib_enc/arith_coder_enc.c | 4 +- lib_rend/ivas_dirac_output_synthesis_dec.c | 59 +-- lib_rend/ivas_limiter.c | 4 +- 56 files changed, 2563 insertions(+), 1188 deletions(-) diff --git a/lib_com/arith_coder.c b/lib_com/arith_coder.c index 08c972ea9..bba7ab973 100644 --- a/lib_com/arith_coder.c +++ b/lib_com/arith_coder.c @@ -223,7 +223,7 @@ void powfp_odd2_evs( * and decoder remain synchronized. *-------------------------------------------------------------------------*/ -void tcx_arith_scale_envelope_flt( +void tcx_arith_scale_envelope_ivas( const Word16 L_spec_core, /* i : number of lines to scale Q0 */ Word16 L_frame, /* i : number of lines Q0 */ const Word32 env[], /* i : unscaled envelope Q16 */ @@ -518,7 +518,7 @@ void tcx_arith_scale_envelope_flt( * and decoder remain synchronized. *-------------------------------------------------------------------------*/ -void tcx_arith_render_envelope_flt( +void tcx_arith_render_envelope_ivas( const Word16 A_ind[], /* i : LPC coefficients of signal envelope */ const Word16 L_frame, /* i : number of spectral lines */ const Word16 L_spec, /* i : length of the coded spectrum */ diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index b319bf21c..e3d9912f2 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -330,29 +330,29 @@ void cldfbAnalysis_ivas_fx( FOR( k = 0; k < M4; k++ ) { /* prototype filter */ - r1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // Qx - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // Qx - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // Qx - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // Qx - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // Qx - - r2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ) ); // Qx - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ) ); // Qx - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ) ); // Qx - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ) ); // Qx - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ) ); // Qx - - i1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ) ); // Qx - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ) ); // Qx - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ) ); // Qx - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ) ); // Qx - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ) ); // Qx - - i2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // Qx - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // Qx - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // Qx - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // Qx - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // Qx + r1_fx = Msub_32_16( 0, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx + + r2_fx = Msub_32_16( 0, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ); // Qx + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ); // Qx + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ); // Qx + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ); // Qx + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ); // Qx + + i1_fx = Msub_32_16( 0, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // Qx + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // Qx + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // Qx + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // Qx + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // Qx + + i2_fx = Msub_32_16( 0, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // Qx - 1 r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // Qx - 1 @@ -363,47 +363,47 @@ void cldfbAnalysis_ivas_fx( rr12_fx = L_sub( r1_fx, r2_fx ); // Qx - 1 ri12_fx = L_negate( L_add( i1_fx, i2_fx ) ); // Qx - 1 // cplxMult( &rBuffer_fx[2 * k], &rBuffer_fx[2 * k + 1], rr12_fx, ri12_fx, rot_vctr_re_fx[k], rot_vctr_im_fx[k] ); - rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // Qx - 3 + rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // Qx - 3 move32(); - rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // Qx - 3 + rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // Qx - 3 move32(); /* folding + pre modulation of DCT IV */ ir12_fx = L_add( r1_fx, r2_fx ); // Qx - 1 ii12_fx = L_sub( i1_fx, i2_fx ); // Qx - 1 // cplxMult( &iBuffer_fx[2 * k], &iBuffer_fx[2 * k + 1], ir12_fx, ii12_fx, rot_vctr_re_fx[k], rot_vctr_im_fx[k] ); - iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // Qx - 3 + iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // Qx - 3 move32(); - iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // Qx - 3 + iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // Qx - 3 move32(); } FOR( k = M4; k < M2; k++ ) { /* prototype filter */ - r1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // Qx - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // Qx - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // Qx - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // Qx - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // Qx - - r2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ) ); // Qx - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ) ); // Qx - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ) ); // Qx - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ) ); // Qx - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ) ); // Qx - - i1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // Qx - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // Qx - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // Qx - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // Qx - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // Qx - - i2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ) ); // Qx - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ) ); // Qx - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ) ); // Qx - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ) ); // Qx - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ) ); // Qx + r1_fx = Msub_32_16( 0, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx + + r2_fx = Msub_32_16( 0, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ); // Qx + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ); // Qx + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ); // Qx + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ); // Qx + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ); // Qx + + i1_fx = Msub_32_16( 0, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx + + i2_fx = Msub_32_16( 0, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // Qx + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // Qx + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // Qx + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // Qx + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // Qx r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // Qx - 1 r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // Qx - 1 @@ -414,18 +414,18 @@ void cldfbAnalysis_ivas_fx( rr12_fx = L_add( r1_fx, r2_fx ); // Qx - 1 ri12_fx = L_sub( i1_fx, i2_fx ); // Qx - 1 // cplxMult( &rBuffer_fx[2 * k], &rBuffer[2 * k + 1], rr12, ri12, rot_vctr_re[k], rot_vctr_im[k] ); - rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // Qx - 3 + rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // Qx - 3 move32(); - rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // Qx - 3 + rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // Qx - 3 move32(); /* folding + pre modulation of DCT IV */ ir12_fx = L_sub( r1_fx, r2_fx ); // Qx - 1 ii12_fx = L_add( i1_fx, i2_fx ); // Qx - 1 // cplxMult( &iBuffer[2 * k], &iBuffer[2 * k + 1], ir12, ii12, rot_vctr_re[k], rot_vctr_im[k] ); - iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // Qx - 3 + iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // Qx - 3 move32(); - iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // Qx - 3 + iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // Qx - 3 move32(); } @@ -437,9 +437,9 @@ void cldfbAnalysis_ivas_fx( FOR( k = 0; k < M2; k++ ) { // cplxMult( &realBuffer[i][M1 - 1 - ( 2 * k )], &realBuffer[i][2 * k], rBuffer[2 * k], rBuffer[2 * k + 1], rot_vctr_re[k], rot_vctr_im[k] ); - realBuffer_fx[i][M1 - 1 - ( 2 * k )] = L_sub( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // Qx - 5 + realBuffer_fx[i][M1 - 1 - ( 2 * k )] = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // Qx - 5 move32(); - realBuffer_fx[i][2 * k] = L_add( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // Qx - 5 + realBuffer_fx[i][2 * k] = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // Qx - 5 move32(); } @@ -452,9 +452,9 @@ void cldfbAnalysis_ivas_fx( { /* do it inplace */ // cplxMult( &imagBuffer[i][2 * k], &imagBuffer[i][M1 - 1 - ( 2 * k )], iBuffer[2 * k], iBuffer[2 * k + 1], rot_vctr_re[k], rot_vctr_im[k] ); - imagBuffer_fx[i][2 * k] = L_sub( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // QX - 5 + imagBuffer_fx[i][2 * k] = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // QX - 5 move32(); - imagBuffer_fx[i][M1 - 1 - ( 2 * k )] = L_add( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // Qx - 5 + imagBuffer_fx[i][M1 - 1 - ( 2 * k )] = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // Qx - 5 move32(); } @@ -1022,29 +1022,29 @@ void cldfbAnalysis_ts_fx_fixed_q( for ( k = 0; k < M4; k++ ) { /* prototype filter */ - r1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // q - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // q - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // q - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // q - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // q - - r2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ) ); // q - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ) ); // q - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ) ); // q - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ) ); // q - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ) ); // q - - i1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ) ); // q - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ) ); // q - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ) ); // q - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ) ); // q - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ) ); // q - - i2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // q - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // q - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // q - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // q - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // q + r1_fx = Msub_32_16( 0, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + r2_fx = Msub_32_16( 0, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i1_fx = Msub_32_16( 0, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i2_fx = Msub_32_16( 0, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 @@ -1055,43 +1055,43 @@ void cldfbAnalysis_ts_fx_fixed_q( rr12_fx = L_sub( r1_fx, r2_fx ); // q -1 ri12_fx = L_negate( L_add( i1_fx, i2_fx ) ); // q - 1 /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ - rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3 + rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3 ///* folding + pre modulation of DCT IV */ ir12_fx = L_add( r1_fx, r2_fx ); // q - 1 ii12_fx = L_sub( i1_fx, i2_fx ); // q - 1 /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ - iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3 + iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3 } for ( k = M4; k < M2; k++ ) { /* prototype filter */ - r1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // q - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // q - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // q - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // q - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // q - - r2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ) ); // q - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ) ); // q - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ) ); // q - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ) ); // q - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ) ); // q - - i1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // q - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // q - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // q - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // q - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // q - - i2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ) ); // q - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ) ); // q - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ) ); // q - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ) ); // q - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ) ); // q + r1_fx = Msub_32_16( 0, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + r2_fx = Msub_32_16( 0, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i1_fx = Msub_32_16( 0, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + i2_fx = Msub_32_16( 0, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 @@ -1102,15 +1102,15 @@ void cldfbAnalysis_ts_fx_fixed_q( rr12_fx = L_add( r1_fx, r2_fx ); // q - 1 ri12_fx = L_sub( i1_fx, i2_fx ); // q - 1 /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ - rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3 + rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3 /* folding + pre modulation of DCT IV */ ir12_fx = L_sub( r1_fx, r2_fx ); // q - 1 ii12_fx = L_add( i1_fx, i2_fx ); // q - 1 /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ - iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3 + iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3 } *q_cldfb = sub( *q_cldfb, 3 ); @@ -1122,8 +1122,8 @@ void cldfbAnalysis_ts_fx_fixed_q( for ( k = 0; k < M2; k++ ) { /*cplxMult(&realBuffer[M1-1-(2*k)],&realBuffer[2*k],rBuffer[2*k],rBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/ - realBuffer_fx[M1 - 1 - ( 2 * k )] = L_sub( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5 - realBuffer_fx[2 * k] = L_add( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5 + realBuffer_fx[M1 - 1 - ( 2 * k )] = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5 + realBuffer_fx[2 * k] = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5 } *q_cldfb = sub( *q_cldfb, 2 ); @@ -1135,8 +1135,8 @@ void cldfbAnalysis_ts_fx_fixed_q( { /* do it inplace */ /*cplxMult(&imagBuffer[2*k],&imagBuffer[M1-1-(2*k)],iBuffer[2*k],iBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/ - imagBuffer_fx[2 * k] = L_sub( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5 - imagBuffer_fx[M1 - 1 - ( 2 * k )] = L_add( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5 + imagBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5 + imagBuffer_fx[M1 - 1 - ( 2 * k )] = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5 } if ( h_cldfb->prototype == CLDFB_PROTOTYPE_5_00MS ) @@ -1155,8 +1155,8 @@ void cldfbAnalysis_ts_fx_fixed_q( /*cplxMult(&realBuffer[k], &imagBuffer[k], realBuffer[k], imagBuffer[k], rot_vctr_delay_re[k], rot_vctr_delay_im[k]);*/ /*realBuffer[k] = rBuffer[k]; imagBuffer[k] = iBuffer[k];*/ - cplx_aux_fx = L_sub( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ) ); // q - 5 - imagBuffer_fx[k] = L_add( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ) ); // q - 5 + cplx_aux_fx = Msub_32_32( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ); // q - 5 + imagBuffer_fx[k] = Madd_32_32( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ); // q - 5 realBuffer_fx[k] = cplx_aux_fx; } } @@ -1450,8 +1450,8 @@ void cldfbSynthesis_ivas_fx( sin((EVS_PI/M1)*(i+0.5)*(-(h_cldfb->ds-M1)*0.5)));*/ /*cplxMult(&rBuffer[i], &iBuffer[i], realBuffer[k][i], imagBuffer[k][i], rot_vctr_delay_re[i], rot_vctr_delay_im[i]);*/ /*cplxMult(&realBuffer[k][i], &imagBuffer[k][i], realBuffer[k][i], imagBuffer[k][i], rot_vctr_delay_re[i], rot_vctr_delay_im[i]);*/ - cplx_aux = L_sub( Mpy_32_32( realBuffer_fx[k][i], rot_vctr_delay_re_fx[i] ), Mpy_32_32( imagBuffer_fx[k][i], rot_vctr_delay_im_fx[i] ) ); // Qx - imagBuffer_fx[k][i] = L_add( Mpy_32_32( realBuffer_fx[k][i], rot_vctr_delay_im_fx[i] ), Mpy_32_32( imagBuffer_fx[k][i], rot_vctr_delay_re_fx[i] ) ); + cplx_aux = Msub_32_32( Mpy_32_32( realBuffer_fx[k][i], rot_vctr_delay_re_fx[i] ), imagBuffer_fx[k][i], rot_vctr_delay_im_fx[i] ); // Qx + imagBuffer_fx[k][i] = Madd_32_32( Mpy_32_32( realBuffer_fx[k][i], rot_vctr_delay_im_fx[i] ), imagBuffer_fx[k][i], rot_vctr_delay_re_fx[i] ); move32(); realBuffer_fx[k][i] = cplx_aux; move32(); @@ -1472,16 +1472,16 @@ void cldfbSynthesis_ivas_fx( { /* pre modulation of DST IV */ /*cplxMult(&rBuffer[2*i], &rBuffer[2*i+1], realBuffer[k][2*i], realBuffer[k][M1-1-2*i], rot_vctr_re[i], rot_vctr_im[i]);*/ - rBuffer_fx[2 * i] = L_sub( Mpy_32_32( realBuffer_fx[k][2 * i], rot_vctr_re_fx[i] ), Mpy_32_32( realBuffer_fx[k][M1 - 1 - 2 * i], rot_vctr_im_fx[i] ) ); // Qx + rBuffer_fx[2 * i] = Msub_32_32( Mpy_32_32( realBuffer_fx[k][2 * i], rot_vctr_re_fx[i] ), realBuffer_fx[k][M1 - 1 - 2 * i], rot_vctr_im_fx[i] ); // Qx move32(); - rBuffer_fx[2 * i + 1] = L_add( Mpy_32_32( realBuffer_fx[k][2 * i], rot_vctr_im_fx[i] ), Mpy_32_32( realBuffer_fx[k][M1 - 1 - 2 * i], rot_vctr_re_fx[i] ) ); // Qx + rBuffer_fx[2 * i + 1] = Madd_32_32( Mpy_32_32( realBuffer_fx[k][2 * i], rot_vctr_im_fx[i] ), realBuffer_fx[k][M1 - 1 - 2 * i], rot_vctr_re_fx[i] ); // Qx move32(); /* pre modulation of DCT IV */ /*cplxMult(&iBuffer[2*i], &iBuffer[2*i+1],-imagBuffer[k][2*i], imagBuffer[k][M1-1-2*i], rot_vctr_re[i], rot_vctr_im[i]);*/ - iBuffer_fx[2 * i] = L_sub( Mpy_32_32( ( L_negate( imagBuffer_fx[k][2 * i] ) ), rot_vctr_re_fx[i] ), Mpy_32_32( imagBuffer_fx[k][M1 - 1 - 2 * i], rot_vctr_im_fx[i] ) ); // Qx + iBuffer_fx[2 * i] = Msub_32_32( Mpy_32_32( ( L_negate( imagBuffer_fx[k][2 * i] ) ), rot_vctr_re_fx[i] ), imagBuffer_fx[k][M1 - 1 - 2 * i], rot_vctr_im_fx[i] ); // Qx move32(); - iBuffer_fx[2 * i + 1] = L_add( Mpy_32_32( ( L_negate( imagBuffer_fx[k][2 * i] ) ), rot_vctr_im_fx[i] ), Mpy_32_32( imagBuffer_fx[k][M1 - 1 - 2 * i], rot_vctr_re_fx[i] ) ); // Qx + iBuffer_fx[2 * i + 1] = Madd_32_32( Mpy_32_32( ( L_negate( imagBuffer_fx[k][2 * i] ) ), rot_vctr_im_fx[i] ), imagBuffer_fx[k][M1 - 1 - 2 * i], rot_vctr_re_fx[i] ); // Qx move32(); } @@ -1495,12 +1495,12 @@ void cldfbSynthesis_ivas_fx( FOR( i = 0; i < M41; i++ ) { /* post modulation of DST IV */ - rr12_fx = L_sub( Mpy_32_32( rBuffer_fx[M1 - 2 - 2 * i], rot_vctr_re_fx[M2 - 1 - i] ), Mpy_32_32( rBuffer_fx[M1 - 1 - 2 * i], rot_vctr_im_fx[M2 - 1 - i] ) ); // Qx - ri12_fx = L_add( Mpy_32_32( rBuffer_fx[M1 - 2 - 2 * i], rot_vctr_im_fx[M2 - 1 - i] ), Mpy_32_32( rBuffer_fx[M1 - 1 - 2 * i], rot_vctr_re_fx[M2 - 1 - i] ) ); // Qx + rr12_fx = Msub_32_32( Mpy_32_32( rBuffer_fx[M1 - 2 - 2 * i], rot_vctr_re_fx[M2 - 1 - i] ), rBuffer_fx[M1 - 1 - 2 * i], rot_vctr_im_fx[M2 - 1 - i] ); // Qx + ri12_fx = Madd_32_32( Mpy_32_32( rBuffer_fx[M1 - 2 - 2 * i], rot_vctr_im_fx[M2 - 1 - i] ), rBuffer_fx[M1 - 1 - 2 * i], rot_vctr_re_fx[M2 - 1 - i] ); // Qx /* post modulation of DCT IV */ - ir12_fx = L_sub( Mpy_32_32( iBuffer_fx[M1 - 2 - 2 * i], rot_vctr_re_fx[M2 - 1 - i] ), Mpy_32_32( iBuffer_fx[M1 - 1 - 2 * i], rot_vctr_im_fx[M2 - 1 - i] ) ); // Qx - ii12_fx = L_add( Mpy_32_32( iBuffer_fx[M1 - 2 - 2 * i], rot_vctr_im_fx[M2 - 1 - i] ), Mpy_32_32( iBuffer_fx[M1 - 1 - 2 * i], rot_vctr_re_fx[M2 - 1 - i] ) ); // Qx + ir12_fx = Msub_32_32( Mpy_32_32( iBuffer_fx[M1 - 2 - 2 * i], rot_vctr_re_fx[M2 - 1 - i] ), iBuffer_fx[M1 - 1 - 2 * i], rot_vctr_im_fx[M2 - 1 - i] ); // Qx + ii12_fx = Madd_32_32( Mpy_32_32( iBuffer_fx[M1 - 2 - 2 * i], rot_vctr_im_fx[M2 - 1 - i] ), iBuffer_fx[M1 - 1 - 2 * i], rot_vctr_re_fx[M2 - 1 - i] ); // Qx new_samples_fx[M1 + M2 + 1 + 2 * i] = L_negate( L_add( rr12_fx, ii12_fx ) ); // Qx move32(); @@ -1516,12 +1516,12 @@ void cldfbSynthesis_ivas_fx( FOR( i = 0; i < M42; i++ ) { /* post modulation of DST IV */ - rr12_fx = L_sub( Mpy_32_32( rBuffer_fx[2 * i], rot_vctr_re_fx[i] ), Mpy_32_32( rBuffer_fx[2 * i + 1], rot_vctr_im_fx[i] ) ); // Qx - ri12_fx = L_add( Mpy_32_32( rBuffer_fx[2 * i], rot_vctr_im_fx[i] ), Mpy_32_32( rBuffer_fx[2 * i + 1], rot_vctr_re_fx[i] ) ); // Qx + rr12_fx = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * i], rot_vctr_re_fx[i] ), rBuffer_fx[2 * i + 1], rot_vctr_im_fx[i] ); // Qx + ri12_fx = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * i], rot_vctr_im_fx[i] ), rBuffer_fx[2 * i + 1], rot_vctr_re_fx[i] ); // Qx /* post modulation of DCT IV */ - ir12_fx = L_sub( Mpy_32_32( iBuffer_fx[2 * i], rot_vctr_re_fx[i] ), Mpy_32_32( iBuffer_fx[2 * i + 1], rot_vctr_im_fx[i] ) ); // Qx - ii12_fx = L_add( Mpy_32_32( iBuffer_fx[2 * i], rot_vctr_im_fx[i] ), Mpy_32_32( iBuffer_fx[2 * i + 1], rot_vctr_re_fx[i] ) ); // Qx + ir12_fx = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * i], rot_vctr_re_fx[i] ), iBuffer_fx[2 * i + 1], rot_vctr_im_fx[i] ); // Qx + ii12_fx = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * i], rot_vctr_im_fx[i] ), iBuffer_fx[2 * i + 1], rot_vctr_re_fx[i] ); // Qx new_samples_fx[M1 + M2 + 2 * i] = L_add( ri12_fx, ir12_fx ); // Qx move32(); @@ -1537,11 +1537,11 @@ void cldfbSynthesis_ivas_fx( /* synthesis prototype filter */ FOR( i = 0; i < L2; i++ ) { - accu0 = L_add( synthesisBuffer_fx[0 * L2 + i], Mpy_32_16_1( Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 0 * L2 + i )] ), p_filter_sf ) ); // Qx - 1 - accu1 = L_add( synthesisBuffer_fx[1 * L2 + i], Mpy_32_16_1( Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 1 * L2 + i )] ), p_filter_sf ) ); // Qx - 1 - accu2 = L_add( synthesisBuffer_fx[2 * L2 + i], Mpy_32_16_1( Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 2 * L2 + i )] ), p_filter_sf ) ); // Qx - 1 - accu3 = L_add( synthesisBuffer_fx[3 * L2 + i], Mpy_32_16_1( Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 3 * L2 + i )] ), p_filter_sf ) ); // Qx - 1 - accu4 = L_add( synthesisBuffer_fx[4 * L2 + i], Mpy_32_16_1( Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 4 * L2 + i )] ), p_filter_sf ) ); // Qx - 1 + accu0 = Madd_32_16( synthesisBuffer_fx[0 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 0 * L2 + i )] ), p_filter_sf ); // Qx - 1 + accu1 = Madd_32_16( synthesisBuffer_fx[1 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 1 * L2 + i )] ), p_filter_sf ); // Qx - 1 + accu2 = Madd_32_16( synthesisBuffer_fx[2 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 2 * L2 + i )] ), p_filter_sf ); // Qx - 1 + accu3 = Madd_32_16( synthesisBuffer_fx[3 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 3 * L2 + i )] ), p_filter_sf ); // Qx - 1 + accu4 = Madd_32_16( synthesisBuffer_fx[4 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 4 * L2 + i )] ), p_filter_sf ); // Qx - 1 synthesisBuffer_fx[0 * L2 + i] = accu0; move32(); diff --git a/lib_com/core_com_config.c b/lib_com/core_com_config.c index c91e6f782..e01bb339a 100644 --- a/lib_com/core_com_config.c +++ b/lib_com/core_com_config.c @@ -43,6 +43,7 @@ #include "ivas_prot.h" #include "prot_fx2.h" +#define FSCALE_DENOM_BY_12800_Q15 1311 /*-------------------------------------------------------------------* * is_EVS_bitrate() * @@ -58,9 +59,11 @@ Word16 is_EVS_bitrate( Word16 j; j = 0; + move16(); WHILE( LT_16( j, SIZE_BRATE_TBL ) && NE_32( ivas_total_brate, brate_tbl[j] ) ) { - j++; + test(); + j = add( j, 1 ); } /* AMR-WB IO mode/EVS primary mode determination */ @@ -86,10 +89,12 @@ Word16 is_EVS_bitrate( } *Opt_AMR_WB = 1; + move16(); } ELSE { *Opt_AMR_WB = 0; + move16(); } return 1; @@ -107,45 +112,59 @@ Word16 get_codec_mode( const Word32 total_brate /* i : total bitrate */ ) { - Word16 codec_mode = -1; + Word16 codec_mode; + codec_mode = -1; + move16(); SWITCH( total_brate ) { case 5900: codec_mode = MODE1; + move16(); BREAK; case 7200: codec_mode = MODE1; + move16(); BREAK; case 8000: codec_mode = MODE1; + move16(); BREAK; case 9600: codec_mode = MODE2; + move16(); BREAK; case 13200: codec_mode = MODE1; + move16(); BREAK; case 16400: codec_mode = MODE2; + move16(); BREAK; case 24400: codec_mode = MODE2; + move16(); BREAK; case 32000: codec_mode = MODE1; + move16(); BREAK; case 48000: codec_mode = MODE2; + move16(); BREAK; case 64000: codec_mode = MODE1; + move16(); BREAK; case 96000: codec_mode = MODE2; + move16(); BREAK; case 128000: codec_mode = MODE2; + move16(); BREAK; } @@ -280,44 +299,63 @@ Word16 getTcxonly( const Word16 is_ism_format /* i : flag indicating ISM format */ ) { - Word16 tcxonly = 0; + Word16 tcxonly; + tcxonly = 0; + move16(); SWITCH( element_mode ) { case EVS_MONO: - IF( GT_32( total_brate, ACELP_32k ) ) + if ( GT_32( total_brate, ACELP_32k ) ) { tcxonly = 1; + move16(); } BREAK; case IVAS_SCE: IF( is_ism_format ) { - IF( GT_32( total_brate, MAX_ACELP_BRATE_ISM ) ) + if ( GT_32( total_brate, MAX_ACELP_BRATE_ISM ) ) { tcxonly = 1; + move16(); } } ELSE { - IF( GT_32( total_brate, MAX_ACELP_BRATE ) ) + if ( GT_32( total_brate, MAX_ACELP_BRATE ) ) { tcxonly = 1; + move16(); } } BREAK; case IVAS_CPE_DFT: case IVAS_CPE_TD: - IF( GT_32( total_brate, MAX_ACELP_BRATE ) ) + if ( GT_32( total_brate, MAX_ACELP_BRATE ) ) { tcxonly = 1; + move16(); } BREAK; case IVAS_CPE_MDCT: - IF( GE_32( total_brate, ( MCT_flag ? IVAS_32k : IVAS_48k ) ) ) + IF( MCT_flag ) { - tcxonly = 1; + + if ( GE_32( total_brate, IVAS_32k ) ) + { + tcxonly = 1; + move16(); + } + } + ELSE + { + if ( GE_32( total_brate, IVAS_48k ) ) + { + tcxonly = 1; + move16(); + } } BREAK; } @@ -349,6 +387,7 @@ Word16 getTcxonly( test(); test(); test(); + test(); if ( ( ( LE_16( element_mode, IVAS_SCE ) && GT_32( total_brate, LPC_SHAPED_ARI_MAX_RATE ) ) || ( GT_16( element_mode, IVAS_SCE ) && GT_32( total_brate, LPC_SHAPED_ARI_MAX_RATE_CPE ) ) ) && !rf_flag && ( ( LE_32( total_brate, IVAS_64k ) && NE_16( element_mode, IVAS_CPE_DFT ) ) || ( LT_32( total_brate, 24400 ) && EQ_16( element_mode, IVAS_CPE_DFT ) ) ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) { ctx_hm = 1; @@ -372,7 +411,7 @@ Word16 getTcxonly( resq = 0; move16(); - IF( LE_32( total_brate, IVAS_64k ) ) + if ( LE_32( total_brate, IVAS_64k ) ) { resq = 1; move16(); @@ -393,13 +432,15 @@ Word16 getTcxonly( const Word16 element_mode /* i : IVAS element mode */ ) { - Word16 tnsAllowed = 0; + Word16 tnsAllowed; tnsAllowed = 0; move16(); - IF( NE_16( igf, 0 ) ) + IF( igf != 0 ) { - IF( GT_32( total_brate, HQ_16k40 ) || ( GT_32( total_brate, HQ_13k20 ) && EQ_16( element_mode, IVAS_CPE_DFT ) ) ) + test(); + test(); + if ( GT_32( total_brate, HQ_16k40 ) || ( GT_32( total_brate, HQ_13k20 ) && EQ_16( element_mode, IVAS_CPE_DFT ) ) ) { tnsAllowed = 1; move16(); @@ -407,7 +448,7 @@ Word16 getTcxonly( } ELSE { - IF( GT_32( total_brate, HQ_32k ) ) + if ( GT_32( total_brate, HQ_32k ) ) { tnsAllowed = 1; move16(); @@ -429,19 +470,28 @@ Word16 getTcxonly( const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ ) { - Word16 restrictedMode = 3; + Word16 restrictedMode; + restrictedMode = 3; + move16(); + test(); + test(); + test(); + test(); IF( !Opt_AMR_WB && ( GT_32( total_brate, HQ_32k ) && NE_16( element_mode, IVAS_SCE ) ) ) { restrictedMode = 6; + move16(); } ELSE IF( !Opt_AMR_WB && ( GT_32( total_brate, HQ_48k ) && EQ_16( element_mode, IVAS_SCE ) ) ) { restrictedMode = 6; + move16(); } ELSE IF( Opt_AMR_WB ) { restrictedMode = 1; + move16(); } return restrictedMode; @@ -483,7 +533,7 @@ Word16 getTcxonly( const Word32 sr_core /* i : internal sampling rate */ ) { - return (Word16) ( ( FSCALE_DENOM * sr_core ) / 12800 ); + return extract_l( Mpy_32_16_1( sr_core, FSCALE_DENOM_BY_12800_Q15 ) ); } #endif @@ -590,19 +640,19 @@ Word16 getTcxonly( test(); test(); test(); - IF( EQ_32( bwidth, NB ) ) + test(); + IF( bwidth == NB ) { sr_core = INT_FS_12k8; move32(); } - ELSE IF( EQ_16( element_mode, EVS_MONO ) && ( L_and( EQ_32( bwidth, WB ), LT_32( total_brate, ACELP_13k20 ) ) || - L_and( EQ_32( bwidth, SWB ), LE_32( total_brate, ACELP_13k20 ) ) || EQ_16( rf_mode, 1 ) ) ) - + ELSE IF( element_mode == EVS_MONO && ( L_and( EQ_32( bwidth, WB ), LT_32( total_brate, ACELP_13k20 ) ) || + L_and( EQ_32( bwidth, SWB ), LE_32( total_brate, ACELP_13k20 ) ) || EQ_16( rf_mode, 1 ) ) ) { sr_core = INT_FS_12k8; move32(); } - ELSE IF( GT_16( element_mode, EVS_MONO ) && flag_ACELP16k == 0 ) + ELSE IF( element_mode > EVS_MONO && flag_ACELP16k == 0 ) { sr_core = INT_FS_12k8; move32(); @@ -620,12 +670,14 @@ Word16 getTcxonly( ELSE IF( bwd_swb_or_fb_flag && LE_32( total_brate, MAX_ACELP_BRATE_ISM ) && EQ_16( element_mode, IVAS_SCE ) && is_ism_format ) { sr_core = INT_FS_16k; + move32(); } ELSE IF( bwd_swb_or_fb_flag && LE_32( total_brate, MAX_ACELP_BRATE ) && EQ_16( element_mode, IVAS_SCE ) && is_ism_format ) { sr_core = 25600; + move32(); } - ELSE IF( ( EQ_16( element_mode, EVS_MONO ) && ( bwd_swb_or_fb_flag && LE_32( total_brate, HQ_64k ) ) ) || ( GT_16( element_mode, IVAS_SCE ) && ( ( EQ_16( bwidth, SWB ) && LE_32( total_brate, IVAS_96k ) ) || ( EQ_16( bwidth, FB ) && LE_32( total_brate, IVAS_96k ) ) ) ) ) + ELSE IF( ( element_mode == EVS_MONO && ( bwd_swb_or_fb_flag && LE_32( total_brate, HQ_64k ) ) ) || ( GT_16( element_mode, IVAS_SCE ) && ( ( EQ_16( bwidth, SWB ) && LE_32( total_brate, IVAS_96k ) ) || ( EQ_16( bwidth, FB ) && LE_32( total_brate, IVAS_96k ) ) ) ) ) { sr_core = 25600; move32(); @@ -652,7 +704,7 @@ Word16 getTcxonly( tcxBandwidth = 16384 /*0.5f Q15*/; move16(); - if ( EQ_16( bwidth, NB ) ) + if ( bwidth == NB ) { tcxBandwidth = 10240 /*0.3125f Q15*/; move16(); @@ -786,7 +838,8 @@ Word16 getTcxonly( const Word16 rf_mode /* i : flag to signal the RF mode */ ) { - Word16 igfPresent = 0; + Word16 igfPresent; + igfPresent = 0; move16(); IF( EQ_16( bwidth, SWB ) ) @@ -795,7 +848,7 @@ Word16 getTcxonly( { case EVS_MONO: case IVAS_SCE: - IF( LE_32( total_brate, HQ_64k ) ) + if ( LE_32( total_brate, HQ_64k ) ) { igfPresent = 1; move16(); @@ -803,14 +856,14 @@ Word16 getTcxonly( BREAK; case IVAS_CPE_DFT: case IVAS_CPE_TD: - IF( LE_32( total_brate, HQ_48k ) ) + if ( LE_32( total_brate, HQ_48k ) ) { igfPresent = 1; move16(); } BREAK; case IVAS_CPE_MDCT: - IF( LE_32( total_brate, IVAS_96k ) ) + if ( LE_32( total_brate, IVAS_96k ) ) { igfPresent = 1; move16(); @@ -824,7 +877,7 @@ Word16 getTcxonly( { case EVS_MONO: case IVAS_SCE: - IF( LE_32( total_brate, IVAS_128k ) ) + if ( LE_32( total_brate, IVAS_128k ) ) { igfPresent = 1; move16(); @@ -832,14 +885,14 @@ Word16 getTcxonly( BREAK; case IVAS_CPE_DFT: case IVAS_CPE_TD: - IF( LE_32( total_brate, IVAS_48k ) ) + if ( LE_32( total_brate, IVAS_48k ) ) { igfPresent = 1; move16(); } BREAK; case IVAS_CPE_MDCT: - IF( LE_32( total_brate, IVAS_128k ) ) + if ( LE_32( total_brate, IVAS_128k ) ) { igfPresent = 1; move16(); @@ -847,13 +900,13 @@ Word16 getTcxonly( BREAK; } } - ELSE IF( bwidth == WB ) + ELSE IF( EQ_16( bwidth, WB ) ) { SWITCH( element_mode ) { case EVS_MONO: case IVAS_SCE: - IF( LE_32( total_brate, ACELP_9k60 ) ) + if ( LE_32( total_brate, ACELP_9k60 ) ) { igfPresent = 1; move16(); @@ -862,7 +915,7 @@ Word16 getTcxonly( case IVAS_CPE_DFT: case IVAS_CPE_TD: case IVAS_CPE_MDCT: - IF( LE_32( total_brate, ACELP_13k20 ) ) + if ( LE_32( total_brate, ACELP_13k20 ) ) { igfPresent = 1; move16(); @@ -873,7 +926,7 @@ Word16 getTcxonly( test(); test(); test(); - IF( ( ( EQ_16( bwidth, WB ) ) || ( EQ_16( bwidth, SWB ) ) ) && ( EQ_16( rf_mode, 1 ) ) && ( EQ_32( total_brate, ACELP_13k20 ) ) ) + if ( ( ( EQ_16( bwidth, WB ) ) || ( EQ_16( bwidth, SWB ) ) ) && ( EQ_16( rf_mode, 1 ) ) && ( EQ_32( total_brate, ACELP_13k20 ) ) ) { igfPresent = 1; move16(); @@ -928,17 +981,20 @@ Word16 getTcxonly( const Word16 bwidth /* i : audio bandwidth */ ) { - Word16 flag_cna = 0; + Word16 flag_cna; + flag_cna = 0; + move16(); + test(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) && LE_32( element_brate, CNA_MAX_BRATE_DFT_STEREO ) ) { flag_cna = 1; + move16(); } ELSE { - move16(); test(); - IF( LE_16( bwidth, SWB ) && ( LE_32( total_brate, ACELP_13k20 ) ) ) + if ( LE_16( bwidth, SWB ) && ( LE_32( total_brate, ACELP_13k20 ) ) ) { flag_cna = 1; move16(); @@ -957,12 +1013,12 @@ Word16 getTcxonly( const Word32 sr_core /* i : internal sampling rate */ ) { - Word16 tcxltp = 0; + Word16 tcxltp; tcxltp = 0; move16(); - test(); - IF( ( LE_32( sr_core, 25600 ) ) ) + + if ( ( LE_32( sr_core, 25600 ) ) ) { tcxltp = 1; move16(); @@ -1070,18 +1126,23 @@ Word16 getTcxonly( { case NB: tcx_coded_lines = 160; + move16(); BREAK; case WB: tcx_coded_lines = 320; + move16(); BREAK; case SWB: tcx_coded_lines = 640; + move16(); BREAK; case FB: tcx_coded_lines = 960; + move16(); BREAK; default: tcx_coded_lines = 0; + move16(); BREAK; } @@ -1100,13 +1161,15 @@ Word16 getTcxonly( const Word16 element_mode /* i : IVAS element mode */ ) { - Word16 tcx_lpc_shaped_ari = 0; - + Word16 tcx_lpc_shaped_ari; + tcx_lpc_shaped_ari = 0; move16(); + + test(); test(); test(); test(); - IF( ( ( LE_16( element_mode, IVAS_SCE ) && LE_32( total_brate, LPC_SHAPED_ARI_MAX_RATE ) ) || ( GT_16( element_mode, IVAS_SCE ) && LE_32( total_brate, LPC_SHAPED_ARI_MAX_RATE_CPE ) ) ) || rf_mode ) + if ( ( ( LE_16( element_mode, IVAS_SCE ) && LE_32( total_brate, LPC_SHAPED_ARI_MAX_RATE ) ) || ( GT_16( element_mode, IVAS_SCE ) && LE_32( total_brate, LPC_SHAPED_ARI_MAX_RATE_CPE ) ) ) || rf_mode ) { tcx_lpc_shaped_ari = 1; move16(); @@ -1363,11 +1426,15 @@ Word16 getTcxonly( hTcxCfg->tcx_mdct_window_delayFB = mdctWindowLengthFB; hTcxCfg->tcx_mdct_window_length = mdctWindowLength; hTcxCfg->tcx_mdct_window_lengthFB = mdctWindowLengthFB; + move16(); + move16(); + move16(); + move16(); mdct_window_sine_IVAS_updated( hTcxCfg->tcx_mdct_window, sr_core, hTcxCfg->tcx_mdct_window_length, FULL_OVERLAP, element_mode ); IF( EQ_16( hTcxCfg->tcx_mdct_window_length, hTcxCfg->tcx_mdct_window_lengthFB ) ) { - Copy_pword( hTcxCfg->tcx_mdct_window, hTcxCfg->tcx_mdct_windowFB, hTcxCfg->tcx_mdct_window_length / 2 ); + Copy_pword( hTcxCfg->tcx_mdct_window, hTcxCfg->tcx_mdct_windowFB, shr( hTcxCfg->tcx_mdct_window_length, 1 ) ); } ELSE { @@ -1380,11 +1447,13 @@ Word16 getTcxonly( /*1.25ms transition window for ACELP->TCX*/ hTcxCfg->tcx_mdct_window_trans_length = NS2SA_fx2( sr_core, ACELP_TCX_TRANS_NS ); + move16(); mdct_window_sine_IVAS_updated( hTcxCfg->tcx_mdct_window_trans, sr_core, hTcxCfg->tcx_mdct_window_trans_length, TRANSITION_OVERLAP, element_mode ); hTcxCfg->tcx_mdct_window_trans_lengthFB = NS2SA_fx2( input_Fs, ACELP_TCX_TRANS_NS ); + move16(); IF( EQ_16( hTcxCfg->tcx_mdct_window_trans_length, hTcxCfg->tcx_mdct_window_trans_lengthFB ) ) { - Copy_pword( hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_trans_length / 2 ); + Copy_pword( hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_transFB, shr( hTcxCfg->tcx_mdct_window_trans_length, 1 ) ); } ELSE { @@ -1394,12 +1463,14 @@ Word16 getTcxonly( /*compute minimum length for "half" window: lookahead - 5ms. It must be also multiple of 2*/ hTcxCfg->tcx_mdct_window_half_length = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA_fx2( 12800, 5000000L ), sr2fscale( sr_core ) ), LD_FSCALE_DENOM ) ); hTcxCfg->tcx_mdct_window_half_lengthFB = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA_fx2( 12800, 5000000L ), sr2fscale( input_Fs ) ), LD_FSCALE_DENOM ) ); + move16(); + move16(); assert( GT_16( hTcxCfg->tcx_mdct_window_half_length, 16 ) && "Half window can not be large enough!" ); mdct_window_sine_IVAS_updated( hTcxCfg->tcx_mdct_window_half, sr_core, hTcxCfg->tcx_mdct_window_half_length, HALF_OVERLAP, element_mode ); IF( EQ_16( hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_half_lengthFB ) ) { - Copy_pword( hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_half_length / 2 ); + Copy_pword( hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_halfFB, shr( hTcxCfg->tcx_mdct_window_half_length, 1 ) ); } ELSE { @@ -1409,10 +1480,12 @@ Word16 getTcxonly( /* minimum overlap 1.25 ms */ hTcxCfg->tcx_mdct_window_min_length = shr( L_frame, 4 ); /* 1.25ms */ hTcxCfg->tcx_mdct_window_min_lengthFB = shr( L_frameTCX, 4 ); /* 1.25ms */ + move16(); + move16(); /* save complexity by copying the small windows if they have the same length */ IF( EQ_16( hTcxCfg->tcx_mdct_window_min_length, hTcxCfg->tcx_mdct_window_trans_length ) ) { - Copy_pword( hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_min_length / 2 ); + Copy_pword( hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_minimum, shr( hTcxCfg->tcx_mdct_window_min_length, 1 ) ); } ELSE { @@ -1421,11 +1494,11 @@ Word16 getTcxonly( IF( EQ_16( hTcxCfg->tcx_mdct_window_min_lengthFB, hTcxCfg->tcx_mdct_window_trans_lengthFB ) ) { - Copy_pword( hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_min_lengthFB / 2 ); + Copy_pword( hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_minimumFB, shr( hTcxCfg->tcx_mdct_window_min_lengthFB, 1 ) ); } ELSE IF( EQ_16( hTcxCfg->tcx_mdct_window_min_length, hTcxCfg->tcx_mdct_window_min_lengthFB ) ) { - Copy_pword( hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_min_lengthFB / 2 ); + Copy_pword( hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_minimumFB, shr( hTcxCfg->tcx_mdct_window_min_lengthFB, 1 ) ); } ELSE { @@ -1437,6 +1510,10 @@ Word16 getTcxonly( /*<0 rectangular transition with optimized window size = L_frame+L_frame/4*/ hTcxCfg->lfacNext = sub( hTcxCfg->tcx_offset, shr( L_frame, 2 ) ); hTcxCfg->lfacNextFB = sub( hTcxCfg->tcx_offsetFB, shr( L_frameTCX, 2 ) ); + move16(); + move16(); + move16(); + move16(); return; } @@ -1470,6 +1547,8 @@ Word16 getTcxonly( hTcxCfg->tcx5Size = shr( L_frame, 2 ); /* Always 5 ms */ hTcxCfg->tcx5SizeFB = shr( L_frameTCX, 2 ); /* Always 5 ms */ + move16(); + move16(); hTcxCfg->tcx_mdct_window_length_old = hTcxCfg->tcx_mdct_window_length; move16(); @@ -1484,49 +1563,60 @@ Word16 getTcxonly( hTcxCfg->tcxRateLoopOpt = 0; move16(); - IF( tcxonly != 0 ) + if ( tcxonly != 0 ) { hTcxCfg->tcxRateLoopOpt = 2; move16(); } - IF( EQ_16( element_mode, IVAS_CPE_MDCT ) ) - hTcxCfg->tcxRateLoopOpt = 3; + if ( EQ_16( element_mode, IVAS_CPE_MDCT ) ) + { + hTcxCfg->tcxRateLoopOpt = 3; + move16(); + } hTcxCfg->bandwidth = getTcxBandwidth( bwidth ); move16(); /* set number of coded lines */ hTcxCfg->tcx_coded_lines = getNumTcxCodedLines( bwidth ); + move16(); /* TNS in TCX */ hTcxCfg->pCurrentTnsConfig = NULL; hTcxCfg->fIsTNSAllowed = getTnsAllowed( total_brate, igf, element_mode ); + move16(); IF( hTcxCfg->fIsTNSAllowed ) { InitTnsConfigs( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag ); - SetAllowTnsOnWhite( hTcxCfg->tnsConfig, element_mode == IVAS_CPE_MDCT ); + SetAllowTnsOnWhite( hTcxCfg->tnsConfig, (Word8) EQ_16( element_mode, IVAS_CPE_MDCT ) ); } IF( ini_frame == 0 ) { hTcxCfg->tcx_curr_overlap_mode = hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW; hTcxCfg->last_aldo = 1; + move16(); + move16(); + move16(); } /* Context HM*/ hTcxCfg->ctx_hm = getCtxHm( element_mode, total_brate, rf_mode ); + move16(); /* Residual Coding*/ hTcxCfg->resq = getResq( total_brate ); - IF( hTcxCfg->resq && !tcxonly ) + move16(); + test(); + if ( hTcxCfg->resq && !tcxonly ) { hTcxCfg->tcxRateLoopOpt = 1; move16(); } /*Set bandwidth scale*/ - IF( EQ_16( bwidth, NB ) ) + IF( bwidth == NB ) { na_scale_bwidth = NB; } @@ -1538,21 +1628,27 @@ Word16 getTcxonly( { na_scale_bwidth = SWB; } + move16(); hTcxCfg->na_scale = 32767 /*1.0f Q15*/; + move16(); + test(); IF( LT_16( na_scale_bwidth, SWB ) && !tcxonly ) { FOR( i = 0; i < SIZE_SCALE_TABLE_TCX; i++ ) { + test(); + test(); IF( ( EQ_16( na_scale_bwidth, scaleTcxTable[i].bwmode ) ) && ( GE_32( total_brate, scaleTcxTable[i].bitrateFrom ) ) && ( LT_32( total_brate, scaleTcxTable[i].bitrateTo ) ) ) { - IF( rf_mode ) + if ( rf_mode ) { - i--; + i = sub( i, 1 ); } hTcxCfg->na_scale = scaleTcxTable[i].scale; + move16(); BREAK; } } diff --git a/lib_com/deemph.c b/lib_com/deemph.c index a746d326e..1c00dde1a 100644 --- a/lib_com/deemph.c +++ b/lib_com/deemph.c @@ -79,13 +79,16 @@ void deemph_fx_32( Word32 *mem /* i/o: memory (y[-1]) Qx*/ ) { - int16_t i; + Word16 i; signal[0] = L_add( signal[0], Mpy_32_16_1( ( *mem ), mu ) ); + move32(); FOR( i = 1; i < L; i++ ) { signal[i] = L_add( signal[i], Mpy_32_16_1( signal[i - 1], mu ) ); signal[i] = L_shl( signal[i], shift ); + move32(); + move32(); } *mem = signal[L - 1]; @@ -125,7 +128,9 @@ void deemph_fx( Word16 i; Word32 L_tmp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; + Flag Overflow; + Overflow = 0; + move32(); #endif L_tmp = L_deposit_h( signal[0] ); @@ -136,6 +141,7 @@ void deemph_fx( L_tmp = L_mac( L_tmp, *mem, mu ); signal[0] = round_fx( L_tmp ); #endif + move16(); FOR( i = 1; i < L; i++ ) { @@ -147,6 +153,7 @@ void deemph_fx( L_tmp = L_mac( L_tmp, signal[i - 1], mu ); signal[i] = round_fx( L_tmp ); #endif /* BASOP_NOGLOB */ + move16(); } *mem = signal[L - 1]; @@ -169,7 +176,9 @@ void Deemph2( Word16 i; Word32 L_tmp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; + Flag Overflow; + Overflow = 0; + move32(); #endif /* saturation can occur in L_mac() */ @@ -215,7 +224,9 @@ void E_UTIL_deemph2( Word16 shift, Word16 *x, const Word16 mu, const Word16 L, W Word16 i; Word32 L_tmp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; + Flag Overflow; + Overflow = 0; + move32(); #endif /* signal[0] = signal[0] + mu * (*mem); */ @@ -232,6 +243,7 @@ void E_UTIL_deemph2( Word16 shift, Word16 *x, const Word16 mu, const Word16 L, W L_tmp = L_msu( Mpy_32_16_1( L_tmp, mu ), x[i], shift ); x[i] = round_fx( L_tmp ); #endif + move16(); } } ELSE @@ -245,6 +257,7 @@ void E_UTIL_deemph2( Word16 shift, Word16 *x, const Word16 mu, const Word16 L, W L_tmp = L_msu( Mpy_32_16_1( L_tmp, mu ), shr( x[i], shift ), -32768 ); x[i] = round_fx( L_tmp ); #endif + move16(); } } diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c index 0c0beef9e..b0ccb9888 100644 --- a/lib_com/delay_comp.c +++ b/lib_com/delay_comp.c @@ -124,10 +124,11 @@ Word32 get_delay_fx( /* o : delay value in ms #endif ) { - Word32 delay = 0; + Word32 delay; + delay = 0; move32(); - IF( EQ_16( what_delay, ENC ) ) + IF( what_delay == ENC ) { IF( EQ_16( ivas_format, MONO_FORMAT ) ) /* EVS mono */ { @@ -139,14 +140,14 @@ Word32 get_delay_fx( /* o : delay value in ms delay = IVAS_ENC_DELAY_NS; move32(); test(); - IF( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) + 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 */ move32(); } } test(); - IF( EQ_16( ivas_format, SBA_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) ) + if ( EQ_16( ivas_format, SBA_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) ) { /* compensate for DirAC/SPAR filterbank delay */ delay = L_add( delay, IVAS_FB_ENC_DELAY_NS ); @@ -177,7 +178,7 @@ Word32 get_delay_fx( /* o : delay value in ms IF( NE_16( output_config, AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) { #endif - IF( hCldfb != NULL ) + if ( hCldfb != NULL ) { /* compensate for filterbank delay */ delay = L_add( delay, IVAS_FB_DEC_DELAY_NS ); @@ -186,7 +187,7 @@ Word32 get_delay_fx( /* o : delay value in ms } #endif test(); - IF( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) + if ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) { delay = L_add( delay, IVAS_ENC_DELAY_NS ); /* Compensate also the encoder delay in the decoder with MASA */ } diff --git a/lib_com/dlpc_bfi_fx.c b/lib_com/dlpc_bfi_fx.c index 63391f6d0..43a8c360c 100644 --- a/lib_com/dlpc_bfi_fx.c +++ b/lib_com/dlpc_bfi_fx.c @@ -35,7 +35,7 @@ void dlpc_bfi( { /* Decode the second LPC */ lsf_dec_bfi( MODE2, &lsf_q[M], &lsf_q[0], lsf_adaptive_mean, lsfBase, mem_MA, mem_AR, *stab_fac, - 0, L_frame, last_good, nbLostCmpt + 1, plcBackgroundNoiseUpdated, lsf_q_cng, lsf_cng, old_lsf_q_cng, 0, 0, tcxonly, 0 ); + 0, L_frame, last_good, add( nbLostCmpt, 1 ), plcBackgroundNoiseUpdated, lsf_q_cng, lsf_cng, old_lsf_q_cng, 0, 0, tcxonly, 0 ); } /**/ /*No local variabvles defined*/ } diff --git a/lib_com/edct_fx.c b/lib_com/edct_fx.c index 0bc9234c2..721a5bf25 100644 --- a/lib_com/edct_fx.c +++ b/lib_com/edct_fx.c @@ -18,140 +18,146 @@ static Word16 get_edxt_factor( Word16 length ) /* Returns value of sqrtf(2.f/length) in Q15 */ { - Word16 factor = 0; /*Q15*/ + Word16 factor; /*Q15*/ + factor = 0; + move16(); IF( EQ_16( length, 512 ) ) { factor = 2048; + move16(); } ELSE IF( EQ_16( length, 256 ) ) { factor = 2896; + move16(); } ELSE IF( EQ_16( length, 128 ) ) { factor = 4096; + move16(); } ELSE IF( EQ_16( length, 640 ) ) { factor = 1832; + move16(); } ELSE IF( EQ_16( length, 320 ) ) { factor = 2590; + move16(); } ELSE IF( EQ_16( length, 160 ) ) { factor = 3663; + move16(); } ELSE IF( EQ_16( length, 80 ) ) { factor = 5181; + move16(); } ELSE IF( EQ_16( length, 40 ) ) { factor = 7327; + move16(); } ELSE IF( EQ_16( length, 960 ) ) { factor = 1496; + move16(); } ELSE IF( EQ_16( length, 480 ) ) { factor = 2115; + move16(); } ELSE IF( EQ_16( length, 240 ) ) { factor = 2991; + move16(); } ELSE IF( EQ_16( length, 120 ) ) { factor = 4230; + move16(); } ELSE IF( EQ_16( length, 1200 ) ) { factor = 1338; + move16(); } ELSE IF( EQ_16( length, 800 ) ) { factor = 1638; + move16(); } ELSE IF( EQ_16( length, 400 ) ) { factor = 2317; + move16(); } ELSE IF( EQ_16( length, 200 ) ) { factor = 3277; + move16(); } return factor; } static Word16 const *get_edct_table( Word16 length, Word16 *q ) { - Word16 const *edct_table = NULL; + Word16 const *edct_table; + edct_table = NULL; SWITCH( length ) { case 1200: edct_table = edct_table_600_fx; - move16(); *q = add( *q, 2 ); + move16(); BREAK; case 960: edct_table = edct_table_480_fx; - move16(); BREAK; case 640: edct_table = edct_table_320_fx; - move16(); BREAK; case 320: edct_table = edct_table_160_fx; - move16(); BREAK; case 256: edct_table = edct_table_128_fx; - move16(); BREAK; case 240: edct_table = edct_table_120_fx; - move16(); BREAK; case 200: edct_table = edct_table_100_fx; - move16(); BREAK; case 160: edct_table = edct_table_80_fx; - move16(); BREAK; case 40: edct_table = edct_table_20_fx; - move16(); BREAK; case 800: edct_table = edct_table_400_fx; - move16(); *q = add( *q, 2 ); + move16(); BREAK; case 512: edct_table = edct_table_256_fx; - move16(); BREAK; case 480: edct_table = edct_table_240_fx; - move16(); BREAK; case 400: edct_table = edct_table_200_fx; - move16(); BREAK; case 128: edct_table = edct_table_64_fx; - move16(); BREAK; case 80: edct_table = edct_table_40_fx; - move16(); BREAK; default: BREAK; @@ -182,7 +188,7 @@ void edct_fx( Word16 i; Word32 re; Word32 im; - const Word16 *edct_table = 0; /*Q16 */ + const Word16 *edct_table; /*Q16 */ Word32 complex_buf[2 * ( L_FRAME48k / 2 + 240 )]; Word32 L_tmp; Word16 tmp; @@ -193,32 +199,34 @@ void edct_fx( /* Twiddling and Pre-rotate */ FOR( i = 0; i < len1; i++ ) { - L_tmp = Mult_32_16( x[2 * i], edct_table[i] ); /*Q(q+1) */ - complex_buf[2 * i] = Madd_32_16( L_tmp, x[length - 1 - 2 * i], edct_table[len1 - 1 - i] ); /*Q(q+1) */ + L_tmp = Mult_32_16( x[2 * i], edct_table[i] ); /*Q(q+1) */ + complex_buf[2 * i] = Madd_32_16( L_tmp, x[sub( length, add( 1, shl( i, 1 ) ) )], edct_table[sub( len1, add( 1, i ) )] ); /*Q(q+1) */ move32(); - L_tmp = Mult_32_16( x[length - 1 - 2 * i], edct_table[i] ); /*Q(q+1) */ + L_tmp = Mult_32_16( x[sub( length, add( 1, shl( i, 1 ) ) )], edct_table[i] ); /*Q(q+1) */ - complex_buf[2 * i + 1] = Msub_32_16( L_tmp, x[2 * i], edct_table[len1 - 1 - i] ); /*Q(q+1) */ + complex_buf[add( shl( i, 1 ), 1 )] = Msub_32_16( L_tmp, x[shl( i, 1 )], edct_table[sub( len1, add( 1, i ) )] ); /*Q(q+1) */ move32(); } *q = sub( 15, *q ); + move16(); BASOP_cfft( (cmplx *) complex_buf, len1, q, y ); tmp = div_s( 1, length ); /*Q15 */ tmp = round_fx( L_shl( L_mult( tmp, 19302 ), 2 ) ); /*Q15 */ FOR( i = 0; i < len1; i++ ) { - re = Msub_32_16( complex_buf[2 * i], complex_buf[2 * i + 1], tmp ); - im = Madd_32_16( complex_buf[2 * i + 1], complex_buf[2 * i], tmp ); - y[2 * i] = L_add( Mult_32_16( re, edct_table[i] ), Mult_32_16( im, edct_table[len1 - 1 - i] ) ); + re = Msub_32_16( complex_buf[2 * i], complex_buf[add( shl( i, 1 ), 1 )], tmp ); + im = Madd_32_16( complex_buf[add( shl( i, 1 ), 1 )], complex_buf[2 * i], tmp ); + y[2 * i] = L_add( Mult_32_16( re, edct_table[i] ), Mult_32_16( im, edct_table[sub( len1, add( 1, i ) )] ) ); move32(); - y[length - 1 - 2 * i] = L_sub( Mult_32_16( re, edct_table[len1 - 1 - i] ), Mult_32_16( im, edct_table[i] ) ); + y[sub( length, add( 1, shl( i, 1 ) ) )] = L_sub( Mult_32_16( re, edct_table[sub( len1, add( 1, i ) )] ), Mult_32_16( im, edct_table[i] ) ); move32(); } /*Q(q-2) */ *q = sub( 15 + 2, *q ); + move16(); return; } @@ -245,7 +253,7 @@ void edst_fx( Word16 i; Word32 re; Word32 im; - const Word16 *edct_table = 0; /*Q16 */ + const Word16 *edct_table; /*Q16 */ Word32 complex_buf[2 * ( L_FRAME48k / 2 + 240 )]; Word32 L_tmp; Word16 tmp; @@ -256,31 +264,33 @@ void edst_fx( /* Twiddling and Pre-rotate */ FOR( i = 0; i < len1; i++ ) { - L_tmp = Mult_32_16( x[length - 1 - 2 * i], edct_table[i] ); - complex_buf[2 * i] = Madd_32_16( L_tmp, x[2 * i], edct_table[len1 - 1 - i] ); + L_tmp = Mult_32_16( x[sub( length, add( 1, shl( i, 1 ) ) )], edct_table[i] ); + complex_buf[2 * i] = Madd_32_16( L_tmp, x[2 * i], edct_table[sub( len1, add( 1, i ) )] ); move32(); L_tmp = Mult_32_16( x[2 * i], edct_table[i] ); - complex_buf[2 * i + 1] = Msub_32_16( L_tmp, x[length - 1 - 2 * i], edct_table[len1 - 1 - i] ); + complex_buf[add( shl( i, 1 ), 1 )] = Msub_32_16( L_tmp, x[sub( length, add( 1, shl( i, 1 ) ) )], edct_table[sub( len1, add( 1, i ) )] ); move32(); } *q = sub( 15, *q ); + move16(); BASOP_cfft( (cmplx *) complex_buf, len1, q, y ); tmp = div_s( 1, length ); /*Q15 */ tmp = round_fx( L_shl( L_mult( tmp, 19302 ), 2 ) ); /*Q15 */ FOR( i = 0; i < len1; i++ ) { - re = Msub_32_16( complex_buf[2 * i], complex_buf[2 * i + 1], tmp ); - im = Madd_32_16( complex_buf[2 * i + 1], complex_buf[2 * i], tmp ); - y[2 * i] = L_add( Mult_32_16( re, edct_table[i] ), Mult_32_16( im, edct_table[len1 - 1 - i] ) ); + re = Msub_32_16( complex_buf[2 * i], complex_buf[add( shl( i, 1 ), 1 )], tmp ); + im = Madd_32_16( complex_buf[add( shl( i, 1 ), 1 )], complex_buf[2 * i], tmp ); + y[2 * i] = L_add( Mult_32_16( re, edct_table[i] ), Mult_32_16( im, edct_table[sub( len1, add( 1, i ) )] ) ); move32(); - y[length - 1 - 2 * i] = L_sub( Mult_32_16( im, edct_table[i] ), Mult_32_16( re, edct_table[len1 - 1 - i] ) ); + y[sub( length, add( 1, shl( i, 1 ) ) )] = L_sub( Mult_32_16( im, edct_table[i] ), Mult_32_16( re, edct_table[sub( len1, add( 1, i ) )] ) ); move32(); } /*Q(q) */ *q = sub( 15 + 2, *q ); + move16(); return; } @@ -316,7 +326,7 @@ void edct_16fx( Word16 i; Word16 re[L_FRAME48k / 2]; Word16 im[L_FRAME48k / 2]; - const Word16 *edct_table = 0; + const Word16 *edct_table = NULL; Word16 re2[L_FRAME48k / 2]; Word16 im2[L_FRAME48k / 2]; @@ -330,24 +340,23 @@ void edct_16fx( (void) element_mode; #endif #ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; + Flag Overflow; + Overflow = 0; + move32(); #endif /*COMPLETE: some eDCT sub function are missing */ IF( EQ_16( length, L_FRAME32k ) ) { edct_table = &edct_table_320_16fx[0]; - move16(); } ELSE IF( EQ_16( length, L_FRAME ) ) { edct_table = &edct_table_128_16fx[0]; - move16(); } ELSE IF( EQ_16( length, L_FRAME16k ) ) { edct_table = &edct_table_160_16fx[0]; - move16(); } ELSE { @@ -356,8 +365,8 @@ void edct_16fx( /* Twiddling and Pre-rotate */ Lmax = L_deposit_l( 0 ); Len2 = shr( length, 1 ); - px = x + length - 1; - pt = edct_table + Len2 - 1; + px = x + sub( length, 1 ); + pt = edct_table + sub( Len2, 1 ); FOR( i = 0; i < Len2; i++ ) { i2 = shl( i, 1 ); @@ -376,14 +385,15 @@ void edct_16fx( } tmp = 31; + move16(); if ( Lmax != 0 ) { tmp = norm_l( Lmax ); } Q_edct = sub( tmp, bh ); /*creating a bit-headroom */ - px = x + length - 1; - pt = edct_table + Len2 - 1; + px = x + sub( length, 1 ); + pt = edct_table + sub( Len2, 1 ); FOR( i = 0; i < Len2; i++ ) { i2 = shl( i, 1 ); @@ -396,7 +406,7 @@ void edct_16fx( Lacc = L_mac( L_tmp, *px, *pt ); /*Q(Qx+16) */ re2[i] = round_fx( L_shl( Lacc, Q_edct ) ); /* Q(Qx+Q_edct) */ #endif - + move16(); L_tmp = L_mult( *px, edct_table[i] ); /*Q(Qx+16) */ #ifdef BASOP_NOGLOB Lacc = L_msu_o( L_tmp, x[i2], *pt, &Overflow ); /*Q(Qx+16) */ @@ -405,6 +415,7 @@ void edct_16fx( Lacc = L_msu( L_tmp, x[i2], *pt ); /*Q(Qx+16) */ im2[i] = round_fx( L_shl( Lacc, Q_edct ) ); /* Q(Qx+Q_edct) */ #endif + move16(); px -= 2; pt--; } @@ -426,7 +437,7 @@ void edct_16fx( tmp = div_s( 1, length ); /*Q15 */ L_tmp = L_mult( tmp, 19302 ); /*Q29, (3*PI/4) in Q13 */ fact = round_fx( L_shl( L_tmp, 2 ) ); /*Q15 */ - FOR( i = 0; i < length / 2; i++ ) + FOR( i = 0; i < shr( length, 1 ); i++ ) { tmp = mult_r( im2[i], fact ); /*Q(Qx+Q_edct) */ #ifdef BASOP_NOGLOB @@ -448,8 +459,8 @@ void edct_16fx( } /* Post-rotate and obtain the output data */ - py = y + length - 1; - pt = edct_table + Len2 - 1; + py = y + sub( length, 1 ); + pt = edct_table + sub( Len2, 1 ); FOR( i = 0; i < Len2; i++ ) { i2 = shl( i, 1 ); @@ -462,14 +473,16 @@ void edct_16fx( Lacc = L_mac( L_tmp, im[i], *pt ); /*Q(Qx+Q_edct+16) */ y[i2] = round_fx( L_shr( Lacc, Q_edct ) ); /* Q(Qx) */ #endif /* BASOP_NOGLOB */ + move16(); - L_tmp = L_mult( re[i], edct_table[length / 2 - 1 - i] ); /*Q(Qx+Q_edct+16) */ - Lacc = L_msu( L_tmp, im[i], edct_table[i] ); /*Q(Qx+Q_edct+16) */ + L_tmp = L_mult( re[i], edct_table[sub( shr( length, 1 ), add( 1, i ) )] ); /*Q(Qx+Q_edct+16) */ + Lacc = L_msu( L_tmp, im[i], edct_table[i] ); /*Q(Qx+Q_edct+16) */ #ifdef BASOP_NOGLOB *py = round_fx_o( L_shr_o( Lacc, Q_edct, &Overflow ), &Overflow ); /* Q(Qx) */ #else /* BASOP_NOGLOB */ *py = round_fx( L_shr( Lacc, Q_edct ) ); /* Q(Qx) */ #endif + move16(); py -= 2; pt--; @@ -521,13 +534,13 @@ void iedct_short_fx( } FOR( i = 0; i < seg_len_div4; i++ ) { - out[i] = alias[seg_len_div4 + i]; + out[i] = alias[add( seg_len_div4, i )]; move32(); - out[seg_len_div4 + i] = L_negate( alias[seg_len_div2 - 1 - i] ); + out[add( seg_len_div4, i )] = L_negate( alias[sub( sub( seg_len_div2, 1 ), i )] ); move32(); - out[seg_len_div2 + i] = L_negate( alias[seg_len_div4 - 1 - i] ); + out[add( seg_len_div2, i )] = L_negate( alias[sub( sub( seg_len_div4, 1 ), i )] ); move32(); - out[seg_len_3mul_div4 + i] = L_negate( alias[i] ); + out[add( seg_len_3mul_div4, i )] = L_negate( alias[i] ); move32(); } @@ -549,112 +562,132 @@ void edxt_fx( const UWord16 synthesis /* i : nonzero for inverse */ ) { - Word16 k, m, fac = 0; - const Word16 *cosPtr = NULL, *sinPtr = NULL; - Word16 n = 0; - + Word16 k, m, fac; + const Word16 *cosPtr, *sinPtr; + Word16 n; + n = 0; + move16(); + cosPtr = NULL; + sinPtr = NULL; IF( EQ_16( length, 512 ) ) { cosPtr = cos_scale_tbl_512; sinPtr = sin_scale_tbl_512; n = 1; + move16(); } ELSE IF( EQ_16( length, 256 ) ) { cosPtr = cos_scale_tbl_512; sinPtr = sin_scale_tbl_512; n = 2; + move16(); } ELSE IF( EQ_16( length, 128 ) ) { cosPtr = cos_scale_tbl_512; sinPtr = sin_scale_tbl_512; n = 4; + move16(); } ELSE IF( EQ_16( length, 640 ) ) { cosPtr = cos_scale_tbl_640; sinPtr = sin_scale_tbl_640; n = 1; + move16(); } ELSE IF( EQ_16( length, 320 ) ) { cosPtr = cos_scale_tbl_640; sinPtr = sin_scale_tbl_640; n = 2; + move16(); } ELSE IF( EQ_16( length, 160 ) ) { cosPtr = cos_scale_tbl_640; sinPtr = sin_scale_tbl_640; n = 4; + move16(); } ELSE IF( EQ_16( length, 80 ) ) { cosPtr = cos_scale_tbl_640; sinPtr = sin_scale_tbl_640; n = 8; + move16(); } ELSE IF( EQ_16( length, 40 ) ) { cosPtr = cos_scale_tbl_640; sinPtr = sin_scale_tbl_640; n = 16; + move16(); } ELSE IF( EQ_16( length, 960 ) ) { cosPtr = cos_scale_tbl_960; sinPtr = sin_scale_tbl_960; n = 1; + move16(); } ELSE IF( EQ_16( length, 480 ) ) { cosPtr = cos_scale_tbl_960; sinPtr = sin_scale_tbl_960; n = 2; + move16(); } ELSE IF( EQ_16( length, 240 ) ) { cosPtr = cos_scale_tbl_960; sinPtr = sin_scale_tbl_960; n = 4; + move16(); } ELSE IF( EQ_16( length, 120 ) ) { cosPtr = cos_scale_tbl_960; sinPtr = sin_scale_tbl_960; n = 8; + move16(); } ELSE IF( EQ_16( length, 1200 ) ) { cosPtr = cos_scale_tbl_1200; sinPtr = sin_scale_tbl_1200; n = 1; + move16(); } ELSE IF( EQ_16( length, 800 ) ) { cosPtr = cos_scale_tbl_800; sinPtr = sin_scale_tbl_800; n = 1; + move16(); } ELSE IF( EQ_16( length, 400 ) ) { cosPtr = cos_scale_tbl_800; sinPtr = sin_scale_tbl_800; n = 2; + move16(); } ELSE IF( EQ_16( length, 200 ) ) { cosPtr = cos_scale_tbl_800; sinPtr = sin_scale_tbl_800; n = 4; + move16(); } #ifdef FAST_EDXT + test(); IF( EQ_16( kernelType, MDST_II ) || EQ_16( kernelType, MDCT_II ) ) { const Word16 Nm1 = sub( length, 1 ); - const Word16 xSign = 2 * ( kernelType >> 1 ) - 1; + const Word16 xSign = sub( imult1616( 2, shr( kernelType, 1 ) ), 1 ); Word32 re[L_FRAME_PLUS]; Word32 im[L_FRAME_PLUS]; @@ -663,8 +696,11 @@ void edxt_fx( FOR( k = shr( Nm1, 1 ); k >= 0; k-- ) /* pre-modulation of audio input */ { re[k] = x[2 * k]; - re[Nm1 - k] = Mpy_32_16_1( x[2 * k + 1], shl_sat( xSign, 15 ) ); - im[k] = im[Nm1 - k] = 0; + re[sub( Nm1, k )] = Mpy_32_16_1( x[add( shl( k, 1 ), 1 )], shl_sat( xSign, 15 ) ); + im[k] = im[sub( Nm1, k )] = 0; + move32(); + move32(); + move32(); } IF( EQ_16( length, 512 ) ) @@ -682,13 +718,16 @@ void edxt_fx( { // const float wRe = cosf( scale * k ); // const float wIm = sinf( scale * k ); - const Word16 wRe = cosPtr[k * n]; - const Word16 wIm = sinPtr[k * n]; + const Word16 wRe = cosPtr[imult1616( k, n )]; + const Word16 wIm = sinPtr[imult1616( k, n )]; y[k] /*pt 1*/ = L_add( Mpy_32_16_1( re[k], wRe ), Mpy_32_16_1( im[k], wIm ) ); - y[length - k] = L_sub( Mpy_32_16_1( re[k], wIm ), Mpy_32_16_1( im[k], wRe ) ); + y[sub( length, k )] = L_sub( Mpy_32_16_1( re[k], wIm ), Mpy_32_16_1( im[k], wRe ) ); + move32(); + move32(); } y[shr( length, 1 )] = Mpy_32_16_1( re[shr( length, 1 )], INV_SQRT_2_Q15 ); + move32(); } ELSE /* forw. DST-II */ { @@ -696,16 +735,20 @@ void edxt_fx( { // const float wRe = cosf( scale * k ); // const float wIm = sinf( scale * k ); - const Word16 wRe = cosPtr[k * n]; - const Word16 wIm = sinPtr[k * n]; + const Word16 wRe = cosPtr[imult1616( k, n )]; + const Word16 wIm = sinPtr[imult1616( k, n )]; - y[Nm1 - k] = L_add( Mpy_32_16_1( re[k], wRe ), Mpy_32_16_1( im[k], wIm ) ); + y[sub( Nm1, k )] = L_add( Mpy_32_16_1( re[k], wRe ), Mpy_32_16_1( im[k], wIm ) ); y[k - 1] = L_sub( Mpy_32_16_1( re[k], wIm ), Mpy_32_16_1( im[k], wRe ) ); + move32(); + move32(); } y[shr( Nm1, 1 )] = Mpy_32_16_1( re[shr( length, 1 )], INV_SQRT_2_Q15 ); + move32(); } - y[Nm1 - Nm1 * ( kernelType >> 1 )] = L_shr( re[0], 1 ); + y[sub( Nm1, imult1616( Nm1, shl( kernelType, 1 ) ) )] = L_shr( re[0], 1 ); + move32(); } ELSE /* inverse II = III */ { @@ -715,13 +758,16 @@ void edxt_fx( { // const float wRe = cosf( scale * k ) * 0.5f; // const float wIm = sinf( scale * k ) * 0.5f; - const Word16 wRe = shr( cosPtr[k * n], 1 ); - const Word16 wIm = shr( sinPtr[k * n], 1 ); + const Word16 wRe = shr( cosPtr[imult1616( k, n )], 1 ); + const Word16 wIm = shr( sinPtr[imult1616( k, n )], 1 ); - re[k] = L_add( Mpy_32_16_1( x[k], wRe ), Mpy_32_16_1( x[length - k], wIm ) ); - im[k] = L_sub( Mpy_32_16_1( x[length - k], wRe ), Mpy_32_16_1( x[k], wIm ) ); + re[k] = L_add( Mpy_32_16_1( x[k], wRe ), Mpy_32_16_1( x[sub( length, k )], wIm ) ); + im[k] = L_sub( Mpy_32_16_1( x[sub( length, k )], wRe ), Mpy_32_16_1( x[k], wIm ) ); + move32(); + move32(); } re[shr( length, 1 )] = Mpy_32_16_1( x[shr( length, 1 )], INV_SQRT_2_Q15 ); + move32(); } ELSE /* DST type III */ { @@ -729,21 +775,28 @@ void edxt_fx( { // const float wRe = cosf( scale * k ) * 0.5f; // const float wIm = sinf( scale * k ) * 0.5f; - const Word16 wRe = shr( cosPtr[k * n], 1 ); - const Word16 wIm = shr( sinPtr[k * n], 1 ); + const Word16 wRe = shr( cosPtr[imult1616( k, n )], 1 ); + const Word16 wIm = shr( sinPtr[imult1616( k, n )], 1 ); - re[k] = L_add( Mpy_32_16_1( x[Nm1 - k], wRe ), Mpy_32_16_1( x[k - 1], wIm ) ); - im[k] = L_sub( Mpy_32_16_1( x[k - 1], wRe ), Mpy_32_16_1( x[Nm1 - k], wIm ) ); + re[k] = L_add( Mpy_32_16_1( x[sub( Nm1, k )], wRe ), Mpy_32_16_1( x[sub( k, 1 )], wIm ) ); + im[k] = L_sub( Mpy_32_16_1( x[sub( k, 1 )], wRe ), Mpy_32_16_1( x[sub( Nm1, k )], wIm ) ); + move32(); + move32(); } re[shr( length, 1 )] = Mpy_32_16_1( x[shr( Nm1, 1 )], INV_SQRT_2_Q15 ); + move32(); } - re[0] = x[Nm1 - Nm1 * shr( kernelType, 1 )]; + re[0] = x[sub( Nm1, imult1616( Nm1, shr( kernelType, 1 ) ) )]; im[0] = im[shr( length, 1 )] = 0; + move32(); + move32(); FOR( k = shr( Nm1, 1 ); k > 0; k-- ) { - re[length - k] = re[k]; - im[length - k] = L_negate( im[k] ); + re[sub( length, k )] = re[k]; + im[sub( length, k )] = L_negate( im[k] ); + move32(); + move32(); } IF( EQ_16( length, 512 ) ) @@ -758,14 +811,16 @@ void edxt_fx( FOR( k = shr( Nm1, 1 ); k >= 0; k-- ) /* post-modulation of FFT output */ { y[2 * k] = re[k]; - IF( NE_16( xSign, 0 ) ) + move32(); + IF( xSign != 0 ) { - y[2 * k + 1] = Mpy_32_16_1( re[sub( Nm1, k )], shl_sat( xSign, 15 ) ); + y[add( shl( k, 1 ), 1 )] = Mpy_32_16_1( re[sub( Nm1, k )], shl_sat( xSign, 15 ) ); } ELSE { - y[2 * k + 1] = 0; + y[add( shl( k, 1 ), 1 )] = 0; } + move32(); } } } @@ -812,7 +867,7 @@ void edxt_fx( #endif // IVAS_FLOAT_FIXED_TO_BE_DONE /*v_multc(y, (kernelType == MDCT_II ? -1.f : 1.f) * sqrtf(2.f / length), y, length);*/ fac = get_edxt_factor( length ); /* Q15 */ - IF( EQ_16( kernelType, MDCT_II ) ) + if ( EQ_16( kernelType, MDCT_II ) ) { fac = negate( fac ); } @@ -820,6 +875,7 @@ void edxt_fx( FOR( m = 0; m < length; m++ ) { y[m] = Mpy_32_16_1( y[m], fac ); + move32(); } return; } diff --git a/lib_com/enhancer_fx.c b/lib_com/enhancer_fx.c index 6336dd685..2482bf58b 100644 --- a/lib_com/enhancer_fx.c +++ b/lib_com/enhancer_fx.c @@ -25,38 +25,38 @@ static void phase_dispersion_fx( Word32 gain_code, Word16 gain_pit, Word16 code[ static void agc2_fx( const Word16 *sig_in, Word16 *sig_out, const Word16 l_trm ); /*======================================================================================*/ -/* FUNCTION : enhancer_fx() */ +/* FUNCTION : enhancer_fx() */ /*--------------------------------------------------------------------------------------*/ -/* PURPOSE : Enhancement of the excitation signal before synthesis */ +/* PURPOSE : Enhancement of the excitation signal before synthesis */ /*--------------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word32) core_brate : decoder bitrate */ -/* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode */ -/* _ (Word16) coder_type : coder type */ -/* _ (Word16) i_subfr : subframe number */ -/* _ (Word16) voice_fac : subframe voicing estimation (Q15) */ -/* _ (Word16) stab_fac : LP filter stablility measure (Q15) */ -/* _ (Word32) norm_gain_code : normalised innovative cb. gain (Q16) */ -/* _ (Word16) gain_inov : gain of the unscaled innovation (Q12) */ -/* _ (Word16) gain_pit_fx : Pitch gain (Q14) */ -/* _ (Word16) Q_exc : Q of the excitation */ -/* _ (Word16) Enc : Encoder = 1; decoder = 0 */ +/* INPUT ARGUMENTS : */ +/* _ (Word32) core_brate : decoder bitrate */ +/* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode */ +/* _ (Word16) coder_type : coder type */ +/* _ (Word16) i_subfr : subframe number */ +/* _ (Word16) voice_fac : subframe voicing estimation (Q15) */ +/* _ (Word16) stab_fac : LP filter stablility measure (Q15) */ +/* _ (Word32) norm_gain_code : normalised innovative cb. gain (Q16) */ +/* _ (Word16) gain_inov : gain of the unscaled innovation (Q12) */ +/* _ (Word16) gain_pit_fx : Pitch gain (Q14) */ +/* _ (Word16) Q_exc : Q of the excitation */ +/* _ (Word16) Enc : Encoder = 1; decoder = 0 */ /*--------------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16*) voice_factors_fx : TBE voicing factor (Q15) */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16*) voice_factors_fx : TBE voicing factor (Q15) */ /*--------------------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ (Word32*) gc_threshold : gain code threshold (Q16) */ -/* _ (Word16*[]) code : innovation (Q12) */ -/* _ (Word16*[]) exc2 : adapt. excitation/total exc (Q0) */ -/* _ (struct dispMem_fx*) dm_fx : phase dispersion algorithm memory */ -/* (a[0]->Q0,a[1]->Q16,a[2-7]->Q14) */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ (Word32*) gc_threshold : gain code threshold (Q16) */ +/* _ (Word16*[]) code : innovation (Q12) */ +/* _ (Word16*[]) exc2 : adapt. excitation/total exc (Q0) */ +/* _ (struct dispMem_fx*) dm_fx : phase dispersion algorithm memory */ +/* (a[0]->Q0,a[1]->Q16,a[2-7]->Q14) */ /*--------------------------------------------------------------------------------------*/ -/* _ None */ +/* _ None */ /*--------------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*======================================================================================*/ void enhancer_fx( const Word32 core_brate, /* i : decoder bitrate */ @@ -87,7 +87,6 @@ void enhancer_fx( pit_sharp = gain_pit; move16(); /* to remove gcc warning */ pt_exc2 = exc2 + i_subfr; - move16(); /*------------------------------------------------------------* * Phase dispersion to enhance noise at low bit rate @@ -120,7 +119,7 @@ void enhancer_fx( i = 0; move16(); /* high dispersion */ } - ELSE if ( ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) || EQ_16( coder_type, AUDIO ) || EQ_16( coder_type, INACTIVE ) ) && LE_32( core_brate, ACELP_9k60 ) ) + ELSE if ( ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) || EQ_16( coder_type, AUDIO ) || coder_type == INACTIVE ) && LE_32( core_brate, ACELP_9k60 ) ) { i = 1; move16(); /* low dispersion */ @@ -186,6 +185,7 @@ void enhancer_fx( FOR( i = 0; i < L_SUBFR; i++ ) { pt_exc2[i] = round_fx( L_shl( L_mult( gain_code_hi, code[i] ), sc ) ); /*Q0 */ /* code in Q12 (Q9 for encoder) */ + move16(); } } ELSE @@ -236,9 +236,11 @@ void enhancer_fx( #ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_mult( gain_code_hi, extract_h( L_tmp ) ), sc ); pt_exc2[0] = msu_r_sat( L_tmp, -32768, pt_exc2[0] ); + move16(); #else L_tmp = L_shl( L_mult( gain_code_hi, extract_h( L_tmp ) ), sc ); pt_exc2[0] = msu_r( L_tmp, -32768, pt_exc2[0] ); + move16(); #endif move16(); /* in Q_exc */ @@ -251,6 +253,7 @@ void enhancer_fx( tmp16 = msu_r_sat( L_tmp, code[i - 1], tmp ); L_tmp = L_shl_sat( L_mult( gain_code_hi, tmp16 ), sc ); pt_exc2[i] = msu_r_sat( L_tmp, -32768, pt_exc2[i] ); + move16(); #else tmp16 = msu_r( L_tmp, code[i - 1], tmp ); L_tmp = L_shl( L_mult( gain_code_hi, tmp16 ), sc ); @@ -265,8 +268,10 @@ void enhancer_fx( L_tmp = L_shl( L_mult( gain_code_hi, extract_h( L_tmp ) ), sc ); #ifdef BASOP_NOGLOB pt_exc2[L_SUBFR - 1] = msu_r_sat( L_tmp, -32768, pt_exc2[L_SUBFR - 1] ); + move16(); #else pt_exc2[L_SUBFR - 1] = msu_r( L_tmp, -32768, pt_exc2[L_SUBFR - 1] ); + move16(); #endif move16(); /* in Q_exc */ test(); @@ -294,38 +299,38 @@ void enhancer_fx( /*======================================================================================*/ -/* FUNCTION : enhancer_fx() */ +/* FUNCTION : enhancer_fx() */ /*--------------------------------------------------------------------------------------*/ -/* PURPOSE : Enhancement of the excitation signal before synthesis */ +/* PURPOSE : Enhancement of the excitation signal before synthesis */ /*--------------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word32) core_brate : decoder bitrate */ -/* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode */ -/* _ (Word16) coder_type : coder type */ -/* _ (Word16) i_subfr : subframe number */ -/* _ (Word16) voice_fac : subframe voicing estimation (Q15) */ -/* _ (Word16) stab_fac : LP filter stablility measure (Q15) */ -/* _ (Word32) norm_gain_code : normalised innovative cb. gain (Q16) */ -/* _ (Word16) gain_inov : gain of the unscaled innovation (Q12) */ -/* _ (Word16) gain_pit_fx : Pitch gain (Q14) */ -/* _ (Word16) Q_exc : Q of the excitation */ -/* _ (Word16) Enc : Encoder = 1; decoder = 0 */ +/* INPUT ARGUMENTS : */ +/* _ (Word32) core_brate : decoder bitrate */ +/* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode */ +/* _ (Word16) coder_type : coder type */ +/* _ (Word16) i_subfr : subframe number */ +/* _ (Word16) voice_fac : subframe voicing estimation (Q15) */ +/* _ (Word16) stab_fac : LP filter stablility measure (Q15) */ +/* _ (Word32) norm_gain_code : normalised innovative cb. gain (Q16) */ +/* _ (Word16) gain_inov : gain of the unscaled innovation (Q12) */ +/* _ (Word16) gain_pit_fx : Pitch gain (Q14) */ +/* _ (Word16) Q_exc : Q of the excitation */ +/* _ (Word16) Enc : Encoder = 1; decoder = 0 */ /*--------------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16*) voice_factors_fx : TBE voicing factor (Q15) */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16*) voice_factors_fx : TBE voicing factor (Q15) */ /*--------------------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ (Word32*) gc_threshold : gain code threshold (Q16) */ -/* _ (Word16*[]) code : innovation (Q12) */ -/* _ (Word16*[]) exc2 : adapt. excitation/total exc (Q0) */ -/* _ (struct dispMem_fx*) dm_fx : phase dispersion algorithm memory */ -/* (a[0]->Q0,a[1]->Q16,a[2-7]->Q14) */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ (Word32*) gc_threshold : gain code threshold (Q16) */ +/* _ (Word16*[]) code : innovation (Q12) */ +/* _ (Word16*[]) exc2 : adapt. excitation/total exc (Q0) */ +/* _ (struct dispMem_fx*) dm_fx : phase dispersion algorithm memory */ +/* (a[0]->Q0,a[1]->Q16,a[2-7]->Q14) */ /*--------------------------------------------------------------------------------------*/ -/* _ None */ +/* _ None */ /*--------------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*======================================================================================*/ void enhancer_ivas_fx( const Word16 codec_mode, /* i : flag indicating Codec Mode */ @@ -358,7 +363,6 @@ void enhancer_ivas_fx( pit_sharp = gain_pit; move16(); /* to remove gcc warning */ pt_exc2 = exc2 + i_subfr; - move16(); /*------------------------------------------------------------* * Phase dispersion to enhance noise at low bit rate @@ -366,6 +370,9 @@ void enhancer_ivas_fx( i = 2; move16(); /* no dispersion */ + test(); + test(); + test(); IF( Opt_AMR_WB ) { IF( LE_32( core_brate, ACELP_6k60 ) ) @@ -391,7 +398,7 @@ void enhancer_ivas_fx( i = 0; move16(); /* high dispersion */ } - ELSE IF( ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) || EQ_16( coder_type, AUDIO ) || EQ_16( coder_type, INACTIVE ) ) && LE_32( core_brate, ACELP_9k60 ) ) + ELSE IF( ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) || EQ_16( coder_type, AUDIO ) || coder_type == INACTIVE ) && LE_32( core_brate, ACELP_9k60 ) ) { i = 1; move16(); /* low dispersion */ @@ -399,18 +406,29 @@ void enhancer_ivas_fx( } ELSE IF( EQ_16( codec_mode, MODE2 ) ) { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); IF( ( NE_16( coder_type, VOICED ) && LE_16( cbk_index, 2 ) ) || ( EQ_16( coder_type, UNVOICED ) && EQ_16( L_frame, L_FRAME ) && LE_16( cbk_index, 10 ) ) || ( EQ_16( coder_type, UNVOICED ) && EQ_16( L_frame, L_FRAME16k ) && LE_16( cbk_index, 14 ) ) ) { i = 0; /* high dispersion */ + move16(); } ELSE IF( NE_16( coder_type, VOICED ) && LE_16( cbk_index, 7 ) ) { i = 1; /* low dispersion */ + move16(); } } ELSE IF( EQ_16( codec_mode, MODE1 ) && EQ_16( coder_type, UNVOICED ) && cbk_index /*uc_two_stage_flag*/ ) { i = 0; /* high dispersion */ + move16(); } phase_dispersion_fx( norm_gain_code, gain_pit, code, i, dm_fx ); @@ -472,6 +490,7 @@ void enhancer_ivas_fx( FOR( i = 0; i < L_SUBFR; i++ ) { pt_exc2[i] = round_fx( L_shl( L_mult( gain_code_hi, code[i] ), sc ) ); /*Q0 */ /* code in Q12 (Q9 for encoder) */ + move16(); } } ELSE @@ -593,7 +612,7 @@ Word16 E_UTIL_enhancer( move16(); code_exp = 15 - 9; - exc2_exp = 15 - Q_new; + exc2_exp = sub( 15, Q_new ); gain_inov = shr( gain_inov, 1 ); /*-----------------------------------------------------------------* * Phase dispersion to enhance noise at low bit rates @@ -659,8 +678,9 @@ Word16 E_UTIL_enhancer( L_tmp = Mpy_32_32( L_tmp, 1804608000l /*1.0f/1.19f Q31*/ ); L_tmp = L_max( L_tmp, *gc_threshold ); } - move32(); + *gc_threshold = L_tmp; /* in 15Q16 */ + move32(); /* gain = ( (fac * L_tmp) + (gain_code - fac*gain_code) ) * gain_inov */ /* exponent of L_tmp: 31-16 + 15-11 */ @@ -670,7 +690,6 @@ Word16 E_UTIL_enhancer( tmp = norm_l( L_tmp ); /* exponent of code: 31-16 + 15-11 - tmp + code_exp */ - move16(); code_exp = sub( add( 31 - 16 + 15 - 11, code_exp ), tmp ); #ifdef BASOP_NOGLOB @@ -699,7 +718,7 @@ Word16 E_UTIL_enhancer( gain = add( sub( code_exp, exc2_exp ), 1 ); tmp = mac_r( 268435456l /*0.125f Q31*/, 4096 /*0.125f Q15*/, voice_fac ); /* 0.25=voiced, 0=unvoiced */ - if ( EQ_16( L_frame, L_FRAME16k ) ) + IF( EQ_16( L_frame, L_FRAME16k ) ) { tmp = mac_r( 322122560l /*0.150f Q31*/, 4915 /*0.150f Q15*/, voice_fac ); /* 0.30=voiced, 0=unvoiced */ } @@ -707,7 +726,7 @@ Word16 E_UTIL_enhancer( /* exc2[0] = exc2[0] + code[0] - tmp*code[1]; */ L_tmp = L_mult( code[0], 16384 ); L_tmp = L_msu0( L_tmp, tmp, code[1] ); - if ( gain ) + IF( gain ) { #ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_tmp, gain ); @@ -722,14 +741,14 @@ Word16 E_UTIL_enhancer( #endif move16(); - FOR( i = 1; i < L_subfr - 1; i++ ) + FOR( i = 1; i < sub( L_subfr, 1 ); i++ ) { /* exc2[i] = exc2[i] + code[i] - tmp*(code[i+1]+code[i-1]); */ L_tmp = L_mult( code[i], 16384 ); #ifdef BASOP_NOGLOB L_tmp = L_msu0_sat( L_tmp, tmp, code[i - 1] ); L_tmp = L_msu0_sat( L_tmp, tmp, code[i + 1] ); - if ( gain ) + IF( gain ) { L_tmp = L_shl_sat( L_tmp, gain ); } @@ -749,7 +768,7 @@ Word16 E_UTIL_enhancer( L_tmp = L_mult( code[i], 16384 ); #ifdef BASOP_NOGLOB L_tmp = L_msu0_sat( L_tmp, tmp, code[i - 1] ); - if ( gain ) + IF( gain ) { L_tmp = L_shl_sat( L_tmp, gain ); } @@ -774,28 +793,28 @@ Word16 E_UTIL_enhancer( * post-processing to enhance noise in low bit rate. *-----------------------------------------------------------------------*/ /*======================================================================================*/ -/* FUNCTION : phase_dispersion_fx() */ +/* FUNCTION : phase_dispersion_fx() */ /*--------------------------------------------------------------------------------------*/ -/* PURPOSE : post-processing to enhance noise in low bit rate. */ +/* PURPOSE : post-processing to enhance noise in low bit rate. */ /*--------------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word32) gain_code : gain of code Q16 */ -/* _ (Word16) gain_pit : gain of pitch Q14 */ -/* _ (Word16) mode : level, 0=hi, 1=lo, 2=off */ +/* INPUT ARGUMENTS : */ +/* _ (Word32) gain_code : gain of code Q16 */ +/* _ (Word16) gain_pit : gain of pitch Q14 */ +/* _ (Word16) mode : level, 0=hi, 1=lo, 2=off */ /*--------------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ None */ +/* OUTPUT ARGUMENTS : */ +/* _ None */ /*--------------------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ (Word16[]) code : code vector (Q12) */ -/* _ (struct dispMem_fx*) dm_fx : static memory (size = 8) */ -/* (a[0]->Q0,a[1]->Q16,a[2-7]->Q14) */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ (Word16[]) code : code vector (Q12) */ +/* _ (struct dispMem_fx*) dm_fx : static memory (size = 8) */ +/* (a[0]->Q0,a[1]->Q16,a[2-7]->Q14) */ /*--------------------------------------------------------------------------------------*/ -/* _ None */ +/* _ None */ /*--------------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*======================================================================================*/ static void phase_dispersion_fx( Word32 gain_code, /* i : gain of code Q16 */ @@ -886,26 +905,19 @@ static void phase_dispersion_fx( r_fft_fx_lc( phs_tbl_dec, SIZE, SIZE2, NUM_STAGES, code, code2, 1 ); h_real = Mid_H_phasedisp; - move16(); if ( state == 0 ) { h_real = Low_H_phasedisp; - move16(); } /* FFT Coefs are in code2 */ code2_real = code2; - move16(); code2_imag = code2 + L_SUBFR - 1; - move16(); code_real = code; - move16(); code_imag = code + L_SUBFR - 1; - move16(); h_imag = h_real + L_SUBFR - 1; - move16(); *code_real++ = mult( *code2_real++, *h_real++ ); move16(); /* DC */ @@ -937,25 +949,25 @@ static void phase_dispersion_fx( } /*======================================================================================*/ -/* FUNCTION : agc2_fx() */ +/* FUNCTION : agc2_fx() */ /*--------------------------------------------------------------------------------------*/ -/* PURPOSE : AGC post-processing for lower G722.2 modes */ +/* PURPOSE : AGC post-processing for lower G722.2 modes */ /*--------------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16*[]) sig_in : postfilter input signal (Q0) */ -/* _ (Word16) l_trm : subframe size */ +/* INPUT ARGUMENTS : */ +/* _ (Word16*[]) sig_in : postfilter input signal (Q0) */ +/* _ (Word16) l_trm : subframe size */ /*--------------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ None */ +/* OUTPUT ARGUMENTS : */ +/* _ None */ /*--------------------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ (Word16*[]) sig_out : postfilter output signal (Q0) */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ (Word16*[]) sig_out : postfilter output signal (Q0) */ /*--------------------------------------------------------------------------------------*/ -/* _ None */ +/* _ None */ /*--------------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*======================================================================================*/ static void agc2_fx( const Word16 *sig_in, /* i : postfilter input signal */ @@ -1034,6 +1046,7 @@ static void agc2_fx( #else sig_out[i] = round_fx( L_shl( L_mac( -8192, sig_out[i], g0 ), 2 ) ); #endif + move16(); } } } diff --git a/lib_com/fd_cng_com.c b/lib_com/fd_cng_com.c index 32df6893f..8a03d64ca 100644 --- a/lib_com/fd_cng_com.c +++ b/lib_com/fd_cng_com.c @@ -957,7 +957,6 @@ void SynthesisSTFT_flt( void SynthesisSTFT_fx( Word32 *fftBuffer, /* i : FFT bins */ - Word16 Q_in, Word32 *timeDomainOutput, Word32 *olapBuffer, const Word16 *olapWin, @@ -1064,11 +1063,11 @@ void SynthesisSTFT_fx( // floatToFixed_arr( hFdCngCom->A_cng_flt, hFdCngCom->A_cng, Q13, M + 1 ); // residu_ivas_fx( hFdCngCom->A_cng, Q13, M, buf_fx + 1 + M, hFdCngCom->exc_cng_32fx, hFdCngCom->frameSize ); - residu_ivas_fx( hFdCngCom->A_cng, sub( 15, norm_s( hFdCngCom->A_cng[0] - 1 ) ), M, buf_fx + 1 + M, hFdCngCom->exc_cng_32fx, hFdCngCom->frameSize ); - for ( i = 0; i < hFdCngCom->frameSize; i++ ) - { - hFdCngCom->exc_cng_flt[i] = fix_to_float( hFdCngCom->exc_cng_32fx[i], sub( Q_in, 9 ) ); - } + residu_ivas_fx( hFdCngCom->A_cng, ( 15 - norm_s( hFdCngCom->A_cng[0] - 1 ) ), M, buf_fx + 1 + M, hFdCngCom->exc_cng_32fx, hFdCngCom->frameSize ); + // for ( i = 0; i < hFdCngCom->frameSize; i++ ) + //{ + // hFdCngCom->exc_cng_flt[i] = fix_to_float( hFdCngCom->exc_cng_32fx[i], Q_in - 9 ); + // } return; } diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index 7ba5cf7c6..9e0f2e375 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -2174,7 +2174,14 @@ void scalebands_fx( nint = sub( midband[j], midband[j - 1] ); /* log-linear interpolation */ - partpowLD64 = BASOP_Util_Log2( L_add( partpow[j], DELTA_FX ) ); + IF( NE_32( partpow[j], MAX_32 ) ) + { + partpowLD64 = BASOP_Util_Log2( L_add( partpow[j], DELTA_FX ) ); + } + ELSE + { + partpowLD64 = BASOP_Util_Log2( partpow[j] ); + } tmp = L_sub( partpowLD64, partpowLD64M1 ); tmp = Mpy_32_16_1( tmp, getNormReciprocalWord16( nint ) ); diff --git a/lib_com/int_lsp.c b/lib_com/int_lsp.c index a340281f7..a79a6bba5 100644 --- a/lib_com/int_lsp.c +++ b/lib_com/int_lsp.c @@ -130,13 +130,17 @@ void int_lsp_fx( 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 ) + 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 ) @@ -302,7 +306,7 @@ void int_lsp4_fx( move16(); E_LPC_f_lsp_a_conversion( lsp, Aq, m ); - Aq += ( m + 1 ); + Aq += add( m, 1 ); move16(); } diff --git a/lib_com/interleave_spectrum.c b/lib_com/interleave_spectrum.c index 12e628fb7..f5e6acf31 100644 --- a/lib_com/interleave_spectrum.c +++ b/lib_com/interleave_spectrum.c @@ -321,6 +321,7 @@ void ivas_de_interleave_spectrum_fx( grps = N_INTL_GRP_48; move16(); l_frame = L_FRAME48k; + move16(); 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 */ diff --git a/lib_com/isf_dec_amr_wb_fx.c b/lib_com/isf_dec_amr_wb_fx.c index b97bee56d..4327339b8 100644 --- a/lib_com/isf_dec_amr_wb_fx.c +++ b/lib_com/isf_dec_amr_wb_fx.c @@ -146,7 +146,7 @@ void isf_dec_amr_wb_fx( * A(z) calculation *-------------------------------------------------------------------------------------*/ - if ( st->rate_switching_reset ) + IF( st->rate_switching_reset ) { /*extrapolation instead of interpolation*/ Copy( isp_new, st->lsp_old_fx, M ); @@ -160,13 +160,15 @@ void isf_dec_amr_wb_fx( * Check ISF stability : distance between old ISF and current ISF *------------------------------------------------------------------*/ - IF( EQ_16( st->element_mode, EVS_MONO ) ) + IF( st->element_mode == EVS_MONO ) { st->stab_fac_fx = lsf_stab_fx( isf_new, st->lsf_old_fx, 1, st->L_frame ); + move16(); } - else + ELSE { st->stab_fac_fx = lsf_stab_ivas_fx( isf_new, st->lsf_old_fx, 1, st->L_frame ); + move16(); } return; diff --git a/lib_com/ivas_agc_com_fx.c b/lib_com/ivas_agc_com_fx.c index 3b8a95e93..c173e79a2 100644 --- a/lib_com/ivas_agc_com_fx.c +++ b/lib_com/ivas_agc_com_fx.c @@ -45,9 +45,9 @@ * Local constants *------------------------------------------------------------------------------------------*/ -#define SQRKMAX ( 1.5f ) -#define NBITS_DIFFG ( 2 ) -#define DBSTEP ( -6.f ) /* desired dB step value in dB*/ +//#define SQRKMAX ( 1.5f ) +//#define NBITS_DIFFG ( 2 ) +//#define DBSTEP ( -6.f ) /* desired dB step value in dB*/ #define ABS_EMIN_MAX ( 3 ) #define MAXATTEXP ( 1 ) /* the desired maximum attenuation exponent range per frame*/ @@ -70,6 +70,7 @@ void ivas_agc_initWindowFunc_fx( const Word16 *cos_val; a = A_FX; /* for DBSTEP -6.f */ + move16(); SWITCH( length ) { @@ -87,9 +88,10 @@ void ivas_agc_initWindowFunc_fx( BREAK; } - for ( i = 0; i < length; i++ ) + FOR( i = 0; i < length; i++ ) { - pWinFunc[i] = add( MAX_16, (Word16) Mpy_32_16_1( L_sub( (Word32) cos_val[i], (Word32) MAX_16 ), a ) ); + pWinFunc[i] = add( MAX_16, extract_l( Mpy_32_16_1( L_sub( cos_val[i], MAX_16 ), a ) ) ); + move16(); } return; @@ -112,12 +114,14 @@ void ivas_agc_calcGainParams_fx( // Word16 nbits; // nbits = NBITS_DIFFG; - assert( EQ_16( numCoeffs, IVAS_SPAR_MAX_DMX_CHS ) ); + assert( numCoeffs == IVAS_SPAR_MAX_DMX_CHS ); *absEmin = s_max( ABS_EMIN_MAX, LOG2_NUMCOEFF_SQRKMAX ); + move16(); // totExp = add( add( *absEmin, AGC_EMAX ), 1 ); /**betaE = (UWord16)ceilf(logf(totExp) * INV_LOG_2);*/ *betaE = (UWord16) LOG2_4; + move16(); /*Bm = (UWord16)ceilf(logf((AGC_EMAX + 1 + 1)) * INV_LOG_2);*/ // Bm = 1; @@ -130,6 +134,8 @@ void ivas_agc_calcGainParams_fx( /**maxAttExp = ((UWord16) powf( 2, Bm ) ) - 2;*/ *maxAttExp = sub( shl( 2, 1 ), 2 ); *maxAttExp = s_min( MAXATTEXP, *maxAttExp ); + move16(); + move16(); return; } diff --git a/lib_com/ivas_arith.c b/lib_com/ivas_arith.c index 47ac42fbd..92357f05e 100644 --- a/lib_com/ivas_arith.c +++ b/lib_com/ivas_arith.c @@ -46,6 +46,39 @@ * Similar to ari_start_decoding_14bits_fx(), but do not read past frame boundary. *-----------------------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void ivas_ari_start_decoding_14bits_ext_1_lfe( + Decoder_State *st, + Tastat *s, + Word16 *extra_bits_read ) +{ + Word32 val; + + IF( GE_16( st->bits_frame, add( st->next_bit_pos, cbitsnew ) ) ) + { + val = get_next_indice( st, cbitsnew ); + } + ELSE + { + Word16 rem_bits; + rem_bits = sub( st->bits_frame, st->next_bit_pos ); + val = get_next_indice( st, rem_bits ); + val = L_shl( val, sub( cbitsnew, rem_bits ) ); + *extra_bits_read = add( *extra_bits_read, sub( cbitsnew, rem_bits ) ); + move16(); + } + + s->low = 0; + s->high = ari_q4new; + s->value = val; + + move32(); + move32(); + move32(); + + return; +} +#else void ivas_ari_start_decoding_14bits_ext_1_lfe( Decoder_State *st, Tastat *s, @@ -72,9 +105,28 @@ void ivas_ari_start_decoding_14bits_ext_1_lfe( return; } - +#endif /* Helper function to determine the symbol. */ +#ifdef IVAS_FLOAT_FIXED +static UWord16 ivas_ari_get_symbol( + const UWord16 *p, + UWord32 range, + UWord32 cum ) +{ + UWord16 symbol; + + symbol = 0; + move16(); + + WHILE( GT_64( W_mult0_32_32( p[symbol + 1], range ), cum ) ) + { + symbol = u_extract_l( UL_addNsD( symbol, 1 ) ); + } + + return symbol; +} +#else static uint16_t ivas_ari_get_symbol( const uint16_t *p, uint32_t range, @@ -92,6 +144,7 @@ static uint16_t ivas_ari_get_symbol( return symbol; } +#endif /*--------------------------------------------------------------- * Function ivas_ari_decode_14bits_bit_ext_1_lfe() @@ -99,6 +152,86 @@ static uint16_t ivas_ari_get_symbol( * *-------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +UWord16 ivas_ari_decode_14bits_bit_ext_1_lfe( + Decoder_State *st, + Tastat *s, + const UWord16 *cum_freq, + Word16 *extra_bits_read ) +{ + UWord16 symbol; + UWord32 low, high, range, value; + UWord32 cum; + + /* read s->low,high,value sequentially */ + low = s->low; + high = s->high; + value = s->value; + + move32(); + move32(); + move32(); + + range = UL_addNsD( UL_subNsD( high, low ), 1 ); + cum = UL_subNsD( UL_lshl( ( UL_addNsD( UL_subNsD( value, low ), 1 ) ), stat_bitsnew ), 1 ); + + symbol = ivas_ari_get_symbol( cum_freq, range, cum ); + + high = UL_subNsD( UL_addNsD( low, mul_sbc_14bits_ivas( range, cum_freq[symbol] ) ), 1 ); + low = UL_addNsD( low, mul_sbc_14bits_ivas( range, cum_freq[symbol + 1] ) ); + + FOR( ;; ) + { + IF( GE_32( high, ari_q2new ) ) + { + IF( GE_32( low, ari_q2new ) ) + { + value = UL_subNsD( value, ari_q2new ); + low = UL_subNsD( low, ari_q2new ); + high = UL_subNsD( high, ari_q2new ); + } + ELSE + { + test(); + IF( GE_32( low, ari_q1new ) && LT_32( high, ari_q3new ) ) + { + value = UL_subNsD( value, ari_q1new ); + low = UL_subNsD( low, ari_q1new ); + high = UL_subNsD( high, ari_q1new ); + } + ELSE + { + BREAK; + } + } + } + + low = UL_addNsD( low, low ); + high = UL_addNsD( high, UL_addNsD( high, 1 ) ); + + IF( GE_16( st->next_bit_pos, st->bits_frame ) ) + { + value = UL_lshl( value, 1 ); + *extra_bits_read = add( *extra_bits_read, 1 ); + move16(); + } + ELSE + { + value = UL_or( UL_lshl( value, 1 ), get_next_indice_1( st ) ); + } + } + + s->low = low; + s->high = high; + s->value = value; + + move32(); + move32(); + move32(); + + return symbol; +} +#else uint16_t ivas_ari_decode_14bits_bit_ext_1_lfe( Decoder_State *st, Tastat *s, @@ -167,6 +300,7 @@ uint16_t ivas_ari_decode_14bits_bit_ext_1_lfe( return symbol; } +#endif /*--------------------------------------------------------------- * Function ivas_ari_done_decoding_14bits_ext_1_lfe() @@ -174,6 +308,16 @@ uint16_t ivas_ari_decode_14bits_bit_ext_1_lfe( * *-------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void ivas_ari_done_decoding_14bits_ext_1_lfe( + Decoder_State *st, + const Word16 extra_bits_read ) +{ + get_next_indice_tmp( st, negate( sub( cbitsnew - 2, extra_bits_read ) ) ); + + return; +} +#else void ivas_ari_done_decoding_14bits_ext_1_lfe( Decoder_State *st, const int16_t extra_bits_read ) @@ -182,6 +326,7 @@ void ivas_ari_done_decoding_14bits_ext_1_lfe( return; } +#endif /*--------------------------------------------------------------- diff --git a/lib_com/ivas_avq_pos_reorder_com.c b/lib_com/ivas_avq_pos_reorder_com.c index 27878028d..f47aead34 100644 --- a/lib_com/ivas_avq_pos_reorder_com.c +++ b/lib_com/ivas_avq_pos_reorder_com.c @@ -41,6 +41,7 @@ * *-----------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ordr_esti( const int16_t svLength, /* i : sub-vector index */ int16_t *Mpos, /* i/o: dominant sub-vector position from ACV */ @@ -61,3 +62,31 @@ void ordr_esti( return; } +#else +void ordr_esti( + const Word16 svLength, /* i : sub-vector index */ + Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ + Word16 svOrder[], /* i/o: AVQ sub-vector order */ + const Word16 Nsv /* i : total sub-vectors in a sub-frames */ +) +{ + Word16 i, tmp; + + tmp = svOrder[0]; + svOrder[0] = *Mpos; + *Mpos = sub( Nsv, 1 ); + + move16(); + move16(); + move16(); + + FOR( i = 1; i < svLength; ( tmp++, i++ ) ) + { + svOrder[i] = tmp; + move16(); + } + + return; +} + +#endif \ No newline at end of file diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth.c index c1d35c45e..0be1c40ff 100644 --- a/lib_com/ivas_cov_smooth.c +++ b/lib_com/ivas_cov_smooth.c @@ -56,6 +56,7 @@ static Word32 ivas_calculate_update_factor_fx( Word16 active_bins ) { Word32 update_factor_temp = 0; + move32(); Word16 k; FOR( k = 0; k < active_bins; k++ ) @@ -107,6 +108,8 @@ static void ivas_calculate_smoothning_factor_fx( { Word32 smooth_fact, L_tmp = 0; Word16 tmp, exp_diff = 0; + move32(); + move16(); tmp = BASOP_Util_Divide3232_Scale( update_factor, L_shl( L_deposit_l( min_pool_size ), Q22 ), &exp_diff ); // (Q15 - exp_diff) *Smoothing_factor = L_shl_sat( L_deposit_l( tmp ), add( Q16, exp_diff ) ); // Q31 @@ -204,6 +207,7 @@ static void ivas_set_up_cov_smoothing_fx( FOR( j = 0; j < pFb->filterbank_num_bands; j++ ) { Word16 active_bins = pFb->fb_bin_to_band.pFb_active_bins_per_band[j]; + move16(); update_factor = ivas_calculate_update_factor_fx( pFb->fb_bin_to_band.pFb_bin_to_band_fx[j], active_bins ); ivas_calculate_smoothning_factor_fx( &hCovState->pSmoothing_factor_fx[j], update_factor, min_pool_size, max_update_rate, smooth_mode, ivas_total_brate, j ); } @@ -214,6 +218,7 @@ static void ivas_set_up_cov_smoothing_fx( { Word32 *p_bin_to_band = pFb->fb_bin_to_band.pp_short_stride_bin_to_band_fx[j]; Word16 active_bins = pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[j]; + move16(); update_factor = ivas_calculate_update_factor_fx( p_bin_to_band, active_bins ); ivas_calculate_smoothning_factor_fx( &hCovState->pSmoothing_factor_fx[j], update_factor, min_pool_size, max_update_rate, smooth_mode, ivas_total_brate, j ); } @@ -476,9 +481,12 @@ static void ivas_compute_smooth_cov_fx( sm_b = BAND_SMOOTH_REST_START_IDX; move16(); + move16(); + move32(); - assert( LE_16( end_band, pFb->filterbank_num_bands ) ); + assert( end_band <= pFb->filterbank_num_bands ); + test(); IF( EQ_16( prev_idx, -1 ) || EQ_16( transient_det[1], 1 ) ) { FOR( i = 0; i < num_ch; i++ ) @@ -542,7 +550,7 @@ static void ivas_compute_smooth_cov_fx( } } } - ELSE IF( EQ_16( prev_idx, 0 ) ) + ELSE IF( prev_idx == 0 ) { FOR( i = 0; i < num_ch; i++ ) { diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index e2d4abf3f..1762c9f68 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -121,14 +121,19 @@ ivas_error ivas_dirac_config_fx( Word16 *dirac_to_spar_md_bands; error = IVAS_ERR_OK; + move32(); - IF( EQ_16( enc_dec, ENC ) ) + IF( enc_dec == ENC ) { ivas_format = ( (Encoder_Struct *) st_ivas )->hEncoderConfig->ivas_format; + move32(); element_mode = &( (Encoder_Struct *) st_ivas )->hEncoderConfig->element_mode_init; sba_order = ( (Encoder_Struct *) st_ivas )->sba_analysis_order; + move16(); ivas_total_brate = ( (Encoder_Struct *) st_ivas )->hEncoderConfig->ivas_total_brate; + move32(); Fs = ( (Encoder_Struct *) st_ivas )->hEncoderConfig->input_Fs; + move32(); band_grouping = ( (Encoder_Struct *) st_ivas )->hDirAC->band_grouping; hConfig = ( (Encoder_Struct *) st_ivas )->hDirAC->hConfig; hQMetaData = ( (Encoder_Struct *) st_ivas )->hQMetaData; @@ -148,8 +153,11 @@ ivas_error ivas_dirac_config_fx( ivas_format = ( (Decoder_Struct *) st_ivas )->ivas_format; element_mode = &( (Decoder_Struct *) st_ivas )->element_mode_init; sba_order = ( (Decoder_Struct *) st_ivas )->sba_analysis_order; + move16(); ivas_total_brate = ( (Decoder_Struct *) st_ivas )->hDecoderConfig->ivas_total_brate; + move32(); Fs = ( (Decoder_Struct *) st_ivas )->hDecoderConfig->output_Fs; + move32(); band_grouping = ( (Decoder_Struct *) st_ivas )->hDirAC->band_grouping; hConfig = ( (Decoder_Struct *) st_ivas )->hDirAC->hConfig; hQMetaData = ( (Decoder_Struct *) st_ivas )->hQMetaData; @@ -166,45 +174,61 @@ ivas_error ivas_dirac_config_fx( ( (Decoder_Struct *) st_ivas )->hDirAC->hFbMdft = hFbMdft; } - IF( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) + test(); + IF( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) ) { hConfig->nbands = IVAS_MAX_NUM_BANDS; + move16(); spar_dirac_split_band = s_min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); IF( ivas_get_hodirac_flag_fx( ivas_total_brate, sba_order ) ) // add call after merge of 100861_dirac_dec { spar_dirac_split_band = 0; + move16(); } } ELSE { hConfig->nbands = 5; spar_dirac_split_band = 0; + + move16(); + move16(); } hConfig->enc_param_start_band = 0; hConfig->dec_param_estim = FALSE; - IF( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) /* skip for MASA decoder */ + + move16(); + move16(); + + test(); + IF( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) ) /* skip for MASA decoder */ { - IF( ( error = ivas_dirac_sba_config_fx( hQMetaData, element_mode, ivas_total_brate, sba_order, hConfig->nbands - spar_dirac_split_band, - ivas_format ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_dirac_sba_config_fx( hQMetaData, element_mode, ivas_total_brate, sba_order, sub( hConfig->nbands, spar_dirac_split_band ), + ivas_format ) ), + IVAS_ERR_OK ) ) { return error; } IF( hQMetaData != NULL ) { - IF( enc_dec == ENC ) + if ( enc_dec == ENC ) { hConfig->nbands = hQMetaData->q_direction[0].cfg.nbands; + move16(); } hConfig->enc_param_start_band = add( hQMetaData->q_direction[0].cfg.start_band, spar_dirac_split_band ); + move16(); } hConfig->dec_param_estim = TRUE; - IF( hConfig->dec_param_estim == TRUE ) + move16(); + if ( EQ_16( hConfig->dec_param_estim, TRUE ) ) { hConfig->enc_param_start_band = spar_dirac_split_band; + move16(); } IF( ivas_get_hodirac_flag_fx( ivas_total_brate, sba_order ) ) @@ -212,12 +236,16 @@ ivas_error ivas_dirac_config_fx( hConfig->dec_param_estim = FALSE; hConfig->enc_param_start_band = 0; - set_c( (int8_t *) hQMetaData->twoDirBands, (int8_t) 1, hQMetaData->q_direction[0].cfg.nbands ); - hQMetaData->numTwoDirBands = (uint8_t) hQMetaData->q_direction[0].cfg.nbands; + move16(); + move16(); + + set_c( (Word8 *) hQMetaData->twoDirBands, (Word8) 1, hQMetaData->q_direction[0].cfg.nbands ); + hQMetaData->numTwoDirBands = (UWord8) hQMetaData->q_direction[0].cfg.nbands; } } - IF( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) + test(); + IF( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) ) { // 100861_dirac_dec ivas_dirac_config_bands_fx( band_grouping, IVAS_MAX_NUM_BANDS, (Word16) ( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), dirac_to_spar_md_bands, hQMetaData->useLowerBandRes, hConfig->enc_param_start_band, hFbMdft ); @@ -590,55 +618,83 @@ void ivas_get_dirac_sba_max_md_bits_fx( const Word16 nbands, IVAS_FORMAT ivas_format ) { - IF( sba_total_brate <= IVAS_13k2 ) + IF( LE_32( sba_total_brate, IVAS_13k2 ) ) { *bits_frame_nominal = ACELP_9k60 / FRAMES_PER_SEC; *metadata_max_bits = 70; + + move16(); + move16(); } - ELSE IF( sba_total_brate <= IVAS_16k4 ) + ELSE IF( LE_32( sba_total_brate, IVAS_16k4 ) ) { *bits_frame_nominal = ACELP_13k20 / FRAMES_PER_SEC; *metadata_max_bits = 80; + + move16(); + move16(); } - ELSE IF( sba_total_brate <= IVAS_24k4 ) + ELSE IF( LE_32( sba_total_brate, IVAS_24k4 ) ) { *bits_frame_nominal = ACELP_16k40 / FRAMES_PER_SEC; *metadata_max_bits = 103; + + move16(); + move16(); /* OSBA needs an additional 2-bits safety margin to avoid acelp crashes */ - IF( ivas_format == SBA_ISM_FORMAT ) + IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) ) { ( *metadata_max_bits ) = sub( ( *metadata_max_bits ), 3 ); + move16(); } } - ELSE IF( sba_total_brate <= IVAS_32k ) + ELSE IF( LE_32( sba_total_brate, IVAS_32k ) ) { *bits_frame_nominal = ACELP_32k / FRAMES_PER_SEC; *metadata_max_bits = 214; + + move16(); + move16(); } - ELSE IF( sba_total_brate <= IVAS_48k ) + ELSE IF( LE_32( sba_total_brate, IVAS_48k ) ) { *bits_frame_nominal = IVAS_48k / FRAMES_PER_SEC; *metadata_max_bits = 240; + + move16(); + move16(); } - ELSE IF( sba_total_brate <= IVAS_64k ) + ELSE IF( LE_32( sba_total_brate, IVAS_64k ) ) { *bits_frame_nominal = IVAS_64k / FRAMES_PER_SEC; *metadata_max_bits = 200; + + move16(); + move16(); } - ELSE IF( sba_total_brate <= IVAS_80k ) + ELSE IF( LE_32( sba_total_brate, IVAS_80k ) ) { *bits_frame_nominal = IVAS_80k / FRAMES_PER_SEC; *metadata_max_bits = 200; + + move16(); + move16(); } - ELSE IF( sba_total_brate <= IVAS_96k ) + ELSE IF( LE_32( sba_total_brate, IVAS_96k ) ) { *bits_frame_nominal = IVAS_96k / FRAMES_PER_SEC; *metadata_max_bits = 200; + + move16(); + move16(); } - ELSE IF( sba_total_brate <= IVAS_128k ) + ELSE IF( LE_32( sba_total_brate, IVAS_128k ) ) { *bits_frame_nominal = IVAS_128k / FRAMES_PER_SEC; *metadata_max_bits = 250; + + move16(); + move16(); } ELSE { @@ -653,6 +709,9 @@ void ivas_get_dirac_sba_max_md_bits_fx( Word32 var2_32 = L_deposit_h( var2 ); Word32 var4 = var2_32; + move16(); + move32(); + Word16 exp_res = 0; IF( var1 % 5 != 0 ) { @@ -661,19 +720,25 @@ void ivas_get_dirac_sba_max_md_bits_fx( } Word16 flag = BASOP_Util_Cmp_Mant32Exp( MAX16B, 31, var4, exp ); Word32 tmp; - if ( flag == 1 ) + IF( EQ_16( flag, 1 ) ) { tmp = var4; + move32(); } - else + ELSE { tmp = MAX16B; exp = 31; + + move32(); + move16(); } *metadata_max_bits = (Word16) L_shr( tmp, 31 - exp ); - ; *qmetadata_max_bit_req = QMETADATA_MAXBIT_REQ_SBA >> 1; + move16(); + move16(); + return; } #else @@ -769,12 +834,19 @@ ivas_error ivas_dirac_sba_config_fx( Word32 tmp1 = IVAS_192k; Word32 tmp2 = SPAR_DIRAC_SPLIT_START_BAND; Word16 exp = 0; + + move32(); + move32(); + move16(); Word16 tmp3 = BASOP_Util_Divide3232_Scale( tmp1, tmp2, &exp ); - Word32 res = L_shr( L_deposit_h( tmp3 ), 31 - exp ); + Word32 res = L_shr( L_deposit_h( tmp3 ), sub( 31, exp ) ); error = IVAS_ERR_OK; hQMetaData->is_masa_ivas_format = 0; - hodirac_flag = ivas_get_hodirac_flag( sba_total_brate, sba_order ); // implemented on 100861_dirac_dec + move32(); + move16(); + + hodirac_flag = ivas_get_hodirac_flag_fx( sba_total_brate, sba_order ); // implemented on 100861_dirac_dec /* map the bitrate for SID frame */ IF( EQ_32( sba_total_brate, IVAS_SID_5k2 ) ) @@ -782,10 +854,12 @@ ivas_error ivas_dirac_sba_config_fx( IF( EQ_16( *element_mode, IVAS_SCE ) ) { sba_total_brate = ACELP_24k40; + move32(); } ELSE { sba_total_brate = ACELP_48k; + move32(); } } @@ -794,10 +868,12 @@ ivas_error ivas_dirac_sba_config_fx( IF( LE_32( sba_total_brate, IVAS_16k4 ) ) { hQMetaData->useLowerRes = 1; + move16(); } ELSE { hQMetaData->useLowerRes = 0; + move16(); } nbands_coded = nbands; @@ -806,25 +882,31 @@ ivas_error ivas_dirac_sba_config_fx( { hQMetaData->useLowerBandRes = 1; Word16 tmp = nbands % 2; + + move16(); + move16(); nbands_coded = add( shr( nbands, 1 ), tmp ); } ELSE { hQMetaData->useLowerBandRes = 0; + move16(); IF( hodirac_flag == 0 ) { - nbands_coded = nbands - 1; /* always combine the last two bands */ + nbands_coded = sub( nbands, 1 ); /* always combine the last two bands */ } } { Word16 no_dirs = 1; + move16(); IF( hodirac_flag ) { no_dirs = 2; + move16(); } - IF( ( error = ivas_qmetadata_allocate_memory( hQMetaData, nbands_coded, no_dirs, 0 ) ) != IVAS_ERR_OK ) // WIP + IF( NE_32( ( error = ivas_qmetadata_allocate_memory( hQMetaData, nbands_coded, no_dirs, 0 ) ), IVAS_ERR_OK ) ) // WIP { return error; } @@ -933,7 +1015,7 @@ void computeDirectionVectors_fixed( Word16 norm_x, norm_y, norm_z; Word32 scaled_x, scaled_y, scaled_z; Word16 e_x, e_y, e_z; - for ( i = enc_param_start_band; i < enc_param_start_band + num_frequency_bands; ++i ) + FOR( i = enc_param_start_band; i < enc_param_start_band + num_frequency_bands; ++i ) { norm_x = norm_l( *intensity_real_x ); norm_y = norm_l( *intensity_real_y ); @@ -941,9 +1023,9 @@ void computeDirectionVectors_fixed( scaled_x = L_shl( *intensity_real_x, norm_x ); scaled_y = L_shl( *intensity_real_y, norm_y ); scaled_z = L_shl( *intensity_real_z, norm_z ); - e_x = i_e - norm_x; - e_y = i_e - norm_y; - e_z = i_e - norm_z; + e_x = sub( i_e, norm_x ); + e_y = sub( i_e, norm_y ); + e_z = sub( i_e, norm_z ); temp1 = BASOP_Util_Add_Mant32Exp( Mult_32_32( scaled_x, scaled_x ), 2 * e_x, Mult_32_32( scaled_y, scaled_y ), 2 * e_y, &exp1 ); intensityNorm = BASOP_Util_Add_Mant32Exp( temp1, exp1, Mult_32_32( scaled_z, scaled_z ), 2 * e_z, &intensityNorm_e ); @@ -953,6 +1035,10 @@ void computeDirectionVectors_fixed( *( direction_vector_x++ ) = ONE_IN_Q30; *( direction_vector_y++ ) = 0; *( direction_vector_z++ ) = 0; + + move32(); + move32(); + move32(); intensity_real_x++; intensity_real_y++; intensity_real_z++; @@ -966,6 +1052,10 @@ void computeDirectionVectors_fixed( intensity_real_y++; *( direction_vector_z++ ) = L_shl( Mult_32_32( scaled_z, intensityNorm ), e_z + intensityNorm_e - 1 ); /*Q30*/ intensity_real_z++; + + move32(); + move32(); + move32(); } } @@ -992,48 +1082,55 @@ void computeDirectionVectors_fx( Word16 i; Word32 intensityNorm; - Word16 sq = 31 - ( 2 * ( *i_q ) - 31 ); - Word16 sq1 = ( 2 * ( *i_q ) - 31 ); + Word16 sq = sub( 31, sub( 2 * ( *i_q ), 31 ) ); + Word16 sq1 = sub( 2 * ( *i_q ), 31 ); Word16 exp = sq; Word16 local_i_q = sq1; Word16 min_factor = 30; + + move16(); + move16(); + move16(); + Word32 *init_x = intensity_real_x; Word32 *init_y = intensity_real_y; Word32 *init_z = intensity_real_z; // First loop to determine the Q for the direction vector - for ( i = enc_param_start_band; i < enc_param_start_band + num_frequency_bands; ++i ) + FOR( i = enc_param_start_band; i < enc_param_start_band + num_frequency_bands; ++i ) { intensityNorm = L_add( L_add( Mpy_32_32_r( *( intensity_real_x ), *( intensity_real_x ) ), Mpy_32_32_r( *( intensity_real_y ), *( intensity_real_y ) ) ), Mpy_32_32_r( *( intensity_real_z ), *( intensity_real_z ) ) ); /*Q (2*i_q - 31) */ exp = sq; - if ( intensityNorm <= EPSILON_FX ) + move16(); + IF( LE_32( intensityNorm, EPSILON_FX ) ) { intensity_real_x++; intensity_real_y++; intensity_real_z++; } - else + ELSE { intensityNorm = ISqrt32( intensityNorm, &exp ); // Q31-exp intensity_real_x++; // i_q + Q31-exp -31 = i_q -exp intensity_real_y++; // i_q + Q31-exp -31 = i_q -exp intensity_real_z++; // i_q + Q31-exp-31 = i_q -exo - local_i_q = *i_q - exp; - min_factor = min( min_factor, local_i_q ); + local_i_q = sub( *i_q, exp ); + min_factor = s_min( min_factor, local_i_q ); } } intensity_real_x = init_x; intensity_real_y = init_y; intensity_real_z = init_z; // Actual processing loop for the direction vector - for ( i = enc_param_start_band; i < enc_param_start_band + num_frequency_bands; ++i ) + FOR( i = enc_param_start_band; i < enc_param_start_band + num_frequency_bands; ++i ) { intensityNorm = L_add( L_add( Mpy_32_32_r( *( intensity_real_x ), *( intensity_real_x ) ), Mpy_32_32_r( *( intensity_real_y ), *( intensity_real_y ) ) ), Mpy_32_32_r( *( intensity_real_z ), *( intensity_real_z ) ) ); /*Q (2*i_q - 31) */ exp = sq; - if ( intensityNorm <= EPSILON_FX ) + move16(); + IF( LE_32( intensityNorm, EPSILON_FX ) ) { intensityNorm = L_shl( 1, min_factor ); *( direction_vector_x++ ) = L_shl( 1, min_factor ); @@ -1042,8 +1139,12 @@ void computeDirectionVectors_fx( intensity_real_x++; intensity_real_y++; intensity_real_z++; + + move32(); + move32(); + move32(); } - else + ELSE { intensityNorm = ISqrt32( intensityNorm, &exp ); // Q31-exp Word32 temp = L_shr( Mpy_32_32( *( intensity_real_x++ ), intensityNorm ), ( *i_q - exp - min_factor ) ); @@ -1052,9 +1153,14 @@ void computeDirectionVectors_fx( *( direction_vector_y++ ) = temp; // i_q + Q31-exp -31 = i_q -exp temp = L_shr( Mpy_32_32( *( intensity_real_z++ ), intensityNorm ), ( *i_q - exp - min_factor ) ); *( direction_vector_z++ ) = temp; // i_q + Q31-exp-31 = i_q -exp + + move32(); + move32(); + move32(); } } *i_q = min_factor; + move16(); return; } #endif @@ -1127,6 +1233,7 @@ void computeDiffuseness_fx( Word32 energy_slow[CLDFB_NO_CHANNELS_MAX]; Word16 i, j, k; Word32 tmp = 0, tmp_1; + move32(); Word32 *p_tmp; const Word32 *p_tmp_c; @@ -1136,58 +1243,83 @@ void computeDiffuseness_fx( set_val_Word32( intensity_slow_abs, 0, CLDFB_NO_CHANNELS_MAX ); set_val_Word32( energy_slow, 0, CLDFB_NO_CHANNELS_MAX ); - for ( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i ) + FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i ) { /* Energy slow */ p_tmp_c = buffer_energy + i * num_freq_bands; - for ( k = 0; k < num_freq_bands; k++ ) + FOR( k = 0; k < num_freq_bands; k++ ) { energy_slow[k] = L_add( *( p_tmp_c++ ), energy_slow[k] ); // Q(q_factor_energy) + move32(); } /* Intensity slow */ - for ( j = 0; j < DIRAC_NUM_DIMS; ++j ) + FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = buffer_intensity[j][i]; - for ( k = 0; k < num_freq_bands; k++ ) + FOR( k = 0; k < num_freq_bands; k++ ) { intensity_slow[j * num_freq_bands + k] = L_add( *( p_tmp++ ), intensity_slow[j * num_freq_bands + k] ); + move32(); } } } /* intensity_slow.^2 + intensity_slow_abs*/ - for ( j = 0; j < DIRAC_NUM_DIMS; ++j ) + FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { - p_tmp = intensity_slow + j * num_freq_bands; + p_tmp = intensity_slow + imult1616( j, num_freq_bands ); - for ( k = 0; k < num_freq_bands; k++ ) + FOR( k = 0; k < num_freq_bands; k++ ) { *( p_tmp ) = Mpy_32_32( *p_tmp, *( p_tmp ) ); // Q( 2*(q_factor_intensity + scale_fact - 1) -31 ) intensity_slow_abs[k] = L_add( *( p_tmp++ ), intensity_slow_abs[k] ); + move32(); + move32(); } } - Word16 init_exp = 31 - ( ( 2 * ( q_factor_intensity ) ) - 31 ), exp; + Word16 init_exp = sub( 31, sub( ( ( 2 * ( q_factor_intensity ) ) ), 31 ) ), exp; Word16 exp1 = 0, exp2; + move16(); /* Compute Diffuseness */ p_tmp = intensity_slow_abs; - for ( i = 0; i < num_freq_bands; ++i ) + FOR( i = 0; i < num_freq_bands; ++i ) { exp = init_exp; Word32 temp = *( p_tmp++ ); + move32(); tmp_1 = Sqrt32( temp, &exp ); tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp_1, L_add( energy_slow[i], 1 ), &exp1 ) ); - exp2 = 31 - exp1 + ( 31 - exp - q_factor_energy ); - if ( exp2 > 30 ) + exp2 = add( sub( 31, exp1 ), sub( sub( 31, exp ), q_factor_energy ) ); + IF( GT_32( exp2, 30 ) ) { - tmp = L_shr( tmp, ( exp2 - 30 ) ); - exp2 -= ( exp2 - 30 ); + tmp = L_shr( tmp, sub( exp2, 30 ) ); + exp2 = sub( exp2, sub( exp2, 30 ) ); } tmp = L_sub( L_shl( 1, exp2 ), tmp ); - diffuseness[i] = ( ( tmp < L_shl( 1, exp2 ) ) ? ( ( tmp < 0 ) ? 0 : tmp ) : L_shl( 1, exp2 ) ); + // diffuseness[i] = ( ( tmp < L_shl( 1, exp2 ) ) ? ( ( tmp < 0 ) ? 0 : tmp ) : L_shl( 1, exp2 ) ); + + IF( LT_32( tmp, L_shl( 1, exp2 ) ) ) + { + IF( tmp < 0 ) + { + diffuseness[i] = 0; + } + ELSE + { + diffuseness[i] = tmp; + } + } + ELSE + { + diffuseness[i] = L_shl( 1, exp2 ); + } out_exp[i] = exp2; + + move32(); + move16(); } return; } @@ -1319,7 +1451,7 @@ void computeDiffuseness_fixed( tmp = Sqrt32( p_tmp[i], &exp1 ); tmp = BASOP_Util_Divide3232_Scale_cadence( tmp, L_add( energy_slow[i], EPSILLON_FX ), &exp2 ); - q_tmp = sub( 31, exp2 ) + sub( sub( 31, exp1 ), q_ene ); + q_tmp = add( sub( 31, exp2 ), sub( sub( 31, exp1 ), q_ene ) ); IF( LT_16( q_tmp, Q30 ) ) { @@ -1329,6 +1461,7 @@ void computeDiffuseness_fixed( { tmp = L_sub( ONE_IN_Q30, L_shr( tmp, sub( q_tmp, Q30 ) ) ); q_tmp = Q30; + move16(); } IF( GE_32( tmp, L_shl( 1, q_tmp ) ) ) @@ -1336,7 +1469,7 @@ void computeDiffuseness_fixed( diffuseness[i] = ONE_IN_Q30; move32(); } - ELSE IF( LE_32( tmp, 0 ) ) + ELSE IF( tmp <= 0 ) { diffuseness[i] = 0; move32(); @@ -1498,9 +1631,10 @@ Word32 deindex_azimuth_fx( test(); IF( NE_32( mc_format, MC_LS_SETUP_INVALID ) && EQ_16( no_bits, 2 ) ) { - IF( EQ_16( s_and( id_phi, 1 ), 0 ) ) + IF( s_and( id_phi, 1 ) == 0 ) { phi_hat_fx = cb_azi_chan_fx[shr( id_phi, 1 )]; + move32(); } ELSE { @@ -1508,7 +1642,7 @@ Word32 deindex_azimuth_fx( } return phi_hat_fx; } - flag_delta = (Word16) EQ_16( s_and( id_th, 1 ), 1 ); + flag_delta = extract_l( EQ_16( s_and( id_th, 1 ), 1 ) ); IF( remap ) { @@ -1625,9 +1759,11 @@ void deindex_spherical_component_fx( *az_idx = sph_idx; move16(); *az_fx = deindex_azimuth_fx( *az_idx, no_bits, 0, 0, mc_format ); + move16(); BREAK; default: *el_idx = deindex_sph_idx_general_fx( sph_idx, no_bits, el_fx, az_fx, az_idx, mc_format ); + move16(); BREAK; } @@ -2060,14 +2196,15 @@ static UWord16 deindex_sph_idx_general_fx( } } - IF( EQ_32( id_th, 0 ) ) + IF( id_th == 0 ) { id_phi = idx_sph; move16(); } ELSE { - IF( EQ_32( id_th, sub( no_th, 1 ) ) && GT_16( no_bits, 4 ) ) + test(); + if ( EQ_32( id_th, sub( no_th, 1 ) ) && GT_16( no_bits, 4 ) ) { id_phi = 0; move16(); @@ -2077,10 +2214,12 @@ static UWord16 deindex_sph_idx_general_fx( q_id_th = norm_l( id_th ); id_th_fx = L_shl( id_th, q_id_th ); *theta_dec_fx = L_shl( Mpy_32_32( id_th_fx, delta_theta_masa_fx[no_bits - 3] ), sub( 31, q_id_th ) ); + move32(); - IF( GE_32( *theta_dec_fx, L_shl( 90, Q22 ) ) ) + IF( GE_32( *theta_dec_fx, 90 << Q22 ) ) { - *theta_dec_fx = L_shl( 90, 22 ) * sign_theta; + *theta_dec_fx = 90 << 22 * sign_theta; + move32(); *phi_dec_fx = 0; move32(); *p_id_phi = 0; @@ -2091,6 +2230,7 @@ static UWord16 deindex_sph_idx_general_fx( *theta_dec_fx *= sign_theta; *phi_dec_fx = deindex_azimuth_fx( id_phi, no_bits, id_th, 0, mc_format ); + move32(); *p_id_phi = id_phi; move16(); } diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index a72aba04a..0b890d7a8 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -57,7 +57,7 @@ static void ivas_get_ld_fb_resp_fx( Word32 **ppIdeal_FRs_re_fx, Word32 **ppIdeal #endif static ivas_error ivas_filterbank_setup( IVAS_FB_MIXER_HANDLE hFbMixer, const int32_t sampling_rate ); #ifdef IVAS_FLOAT_FIXED -static ivas_error ivas_filterbank_setup_fx( IVAS_FB_MIXER_HANDLE hFbMixer, const int32_t sampling_rate, Word16 *index ); +static ivas_error ivas_filterbank_setup_fx( IVAS_FB_MIXER_HANDLE hFbMixer, const Word32 sampling_rate, Word16 *index ); #endif static ivas_error ivas_fb_mixer_get_window( const int16_t fade_len, const int32_t sampling_rate, const float **pWindow ); #ifdef IVAS_FLOAT_FIXED @@ -80,7 +80,7 @@ Word16 ivas_get_num_bands_from_bw_idx( Word16 num_active_bands; assert( bwidth > 0 ); /*NB BW is not supported*/ - num_active_bands = ivas_num_active_bands[bwidth - 1]; + num_active_bands = ivas_num_active_bands[sub( bwidth, 1 )]; move16(); return num_active_bands; @@ -166,31 +166,54 @@ ivas_error ivas_fb_set_cfg( pFb_cfg->active_w_mixing = active_w_mixing; pFb_cfg->windowed_fr_offset = 0; - IF( ivas_format == ISM_FORMAT ) + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + + IF( EQ_16( ivas_format, ISM_FORMAT ) ) { pFb_cfg->fb_latency = NS2SA( sampling_rate, DELAY_FB_4_NS ); pFb_cfg->fade_len = NS2SA( sampling_rate, DELAY_FB_4_NS ); pFb_cfg->prior_input_length = NS2SA( sampling_rate, DELAY_DIRAC_ENC_CMP_NS_PARAM_ISM ) + NS2SA( sampling_rate, DIRAC_SLOT_ENC_NS ); + + move16(); + move16(); + move16(); } - ELSE IF( ivas_format == SBA_FORMAT ) + ELSE IF( EQ_16( ivas_format, SBA_FORMAT ) ) { pFb_cfg->fb_latency = NS2SA( sampling_rate, DELAY_FB_1_NS ); pFb_cfg->fade_len = NS2SA( sampling_rate, DELAY_FB_4_NS ); pFb_cfg->prior_input_length = NS2SA( sampling_rate, FRAME_SIZE_NS ); pFb_cfg->windowed_fr_offset = (Word16) ( (float) ( sampling_rate / FRAMES_PER_SEC ) * 3.0f / 4.0f ) - NS2SA( sampling_rate, DELAY_DIRAC_SPAR_ENC_CMP_NS ); + + move16(); + move16(); + move16(); } - ELSE IF( ivas_format == MASA_FORMAT ) + ELSE IF( EQ_16( ivas_format, MASA_FORMAT ) ) { pFb_cfg->fb_latency = NS2SA( sampling_rate, DELAY_FB_1_NS ); pFb_cfg->fade_len = NS2SA( sampling_rate, DELAY_FB_1_NS ); pFb_cfg->prior_input_length = NS2SA( sampling_rate, DELAY_DIRAC_ENC_CMP_NS ) + NS2SA( sampling_rate, DIRAC_SLOT_ENC_NS ); + + move16(); + move16(); + move16(); } - ELSE IF( ivas_format == MC_FORMAT ) + ELSE IF( EQ_16( ivas_format, MC_FORMAT ) ) { pFb_cfg->fb_latency = NS2SA( sampling_rate, DELAY_FB_1_NS ); pFb_cfg->fade_len = NS2SA( sampling_rate, DELAY_FB_1_NS ); pFb_cfg->prior_input_length = NS2SA( sampling_rate, DELAY_DIRAC_ENC_CMP_NS ) + NS2SA( sampling_rate, PARAM_MC_SLOT_ENC_NS ); + + move16(); + move16(); + move16(); } *pFb_cfg_out = pFb_cfg; @@ -467,13 +490,15 @@ ivas_error ivas_FB_mixer_open_fx( ) { IVAS_FB_MIXER_HANDLE hFbMixer; - int16_t i, j, frame_len, num_bands; - int16_t num_chs_alloc; + Word16 i, j, frame_len, num_bands; + Word16 num_chs_alloc, exp; ivas_error error; error = IVAS_ERR_OK; + move32(); - frame_len = (int16_t) ( sampling_rate / FRAMES_PER_SEC ); + frame_len = BASOP_Util_Divide3232_Scale( sampling_rate, FRAMES_PER_SEC, &exp ); + frame_len = shr( frame_len, sub( 15, exp ) ); hFbMixer = *hFbMixer_out; @@ -497,18 +522,19 @@ ivas_error ivas_FB_mixer_open_fx( } } - IF( fb_cfg->active_w_mixing == -1 ) + IF( EQ_16( fb_cfg->active_w_mixing, -1 ) ) { num_chs_alloc = 0; move16(); } ELSE IF( fb_cfg->active_w_mixing ) { - num_chs_alloc = max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ); + num_chs_alloc = s_max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ); } ELSE { num_chs_alloc = 1; /* only W channel processed for predicting YZX */ + move16(); } #ifndef IVAS_FLOAT_FIXED /////////////////////////////// FLOAT /////////////////////////////////////////////// @@ -535,23 +561,23 @@ ivas_error ivas_FB_mixer_open_fx( } } #else - for ( i = 0; i < num_chs_alloc; i++ ) + FOR( i = 0; i < num_chs_alloc; i++ ) { - if ( fb_cfg->num_out_chans == 0 ) + IF( fb_cfg->num_out_chans == 0 ) { hFbMixer->ppFilterbank_inFR_re_fx[i] = NULL; hFbMixer->ppFilterbank_inFR_im_fx[i] = NULL; } - else + ELSE { j = fb_cfg->remix_order[i]; - if ( ( hFbMixer->ppFilterbank_inFR_re_fx[j] = (Word32 *) malloc( sizeof( Word32 ) * frame_len ) ) == NULL ) + IF( ( hFbMixer->ppFilterbank_inFR_re_fx[j] = (Word32 *) malloc( sizeof( Word32 ) * frame_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); } - if ( ( hFbMixer->ppFilterbank_inFR_im_fx[j] = (Word32 *) malloc( sizeof( Word32 ) * frame_len ) ) == NULL ) + IF( ( hFbMixer->ppFilterbank_inFR_im_fx[j] = (Word32 *) malloc( sizeof( Word32 ) * frame_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); } @@ -559,14 +585,14 @@ ivas_error ivas_FB_mixer_open_fx( } #endif - IF( fb_cfg->active_w_mixing == -1 ) + IF( EQ_16( fb_cfg->active_w_mixing, -1 ) ) { num_chs_alloc = 0; move16(); } ELSE { - num_chs_alloc = max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ); + num_chs_alloc = s_max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ); } #ifndef IVAS_FLOAT_FIXED //////////////////////////// Float ////////////////////////////////////// @@ -589,7 +615,8 @@ ivas_error ivas_FB_mixer_open_fx( } #endif - IF( ( fb_cfg->active_w_mixing != -1 ) && ( fb_cfg->num_out_chans > 0 ) ) + test(); + IF( ( NE_16( fb_cfg->active_w_mixing, -1 ) ) && ( fb_cfg->num_out_chans > 0 ) ) { #ifndef IVAS_FLOAT_FIXED ////////////////////////////////////////// FLOAT ////////////////////////////////////////////////////// float *pTemp_mem; @@ -628,13 +655,13 @@ ivas_error ivas_FB_mixer_open_fx( { IF( fb_cfg->num_out_chans > 0 ) { - const int16_t *pActive_bins_per_band, *pActive_bins_per_band_abs, *pStart_offset, *pStart_offset_abs; + const Word16 *pActive_bins_per_band, *pActive_bins_per_band_abs, *pStart_offset, *pStart_offset_abs; num_bands = ivas_get_num_bands( sampling_rate ); ivas_get_active_bins( &pActive_bins_per_band, &pActive_bins_per_band_abs, &pStart_offset, &pStart_offset_abs, sampling_rate ); - IF( fb_cfg->active_w_mixing != -1 ) + IF( NE_16( fb_cfg->active_w_mixing, -1 ) ) { FOR( i = 0; i < num_bands; i++ ) { @@ -651,16 +678,18 @@ ivas_error ivas_FB_mixer_open_fx( } } - IF( sampling_rate != 48000 ) + IF( NE_32( sampling_rate, 48000 ) ) { - int16_t num_diff_bands, start_diff_band_non48k; + Word16 num_diff_bands, start_diff_band_non48k; num_diff_bands = MAX_NUM_BANDS_DIFF_NON48K; - start_diff_band_non48k = num_bands - num_diff_bands; + move16(); + start_diff_band_non48k = sub( num_bands, num_diff_bands ); hFbMixer->num_diff_bands = num_diff_bands; + move16(); - for ( j = start_diff_band_non48k; j < num_bands; j++ ) + FOR( j = start_diff_band_non48k; j < num_bands; j++ ) { #if 0 ////////////////////////////////// FLOAT //////////////////////// if ( ( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[0][j] = (float *) malloc( sizeof( float ) * pActive_bins_per_band[j] ) ) == NULL ) @@ -695,9 +724,9 @@ ivas_error ivas_FB_mixer_open_fx( hFbMixer->fb_cfg = fb_cfg; set_s( hFbMixer->first_frame, 1, hFbMixer->fb_cfg->num_out_chans ); - set_s( hFbMixer->first_frame + hFbMixer->fb_cfg->num_out_chans, 0, IVAS_SPAR_MAX_CH - hFbMixer->fb_cfg->num_out_chans ); + set_s( hFbMixer->first_frame + hFbMixer->fb_cfg->num_out_chans, 0, sub( IVAS_SPAR_MAX_CH, hFbMixer->fb_cfg->num_out_chans ) ); - if ( !spar_reconfig_flag ) + IF( !spar_reconfig_flag ) { #ifdef IVAS_FLOAT_FIXED #if 1 /*********************Intermediate Conversion that needs to remove *****************************/ @@ -722,7 +751,7 @@ ivas_error ivas_FB_mixer_open_fx( // } /************************************* Float table is gettin assigned here **************************************/ - if ( ( error = ivas_fb_mixer_get_window( hFbMixer->fb_cfg->fade_len, sampling_rate, &( hFbMixer->pFilterbank_cross_fade ) ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_fb_mixer_get_window( hFbMixer->fb_cfg->fade_len, sampling_rate, &( hFbMixer->pFilterbank_cross_fade ) ) ), IVAS_ERR_OK ) ) { return error; } @@ -777,7 +806,7 @@ ivas_error ivas_FB_mixer_open_fx( set16_fx( index, 0, IVAS_MAX_NUM_FB_BANDS ); #endif /*********************Intermediate Conversion that needs to remove *****************************/ - IF( ( error = ivas_filterbank_setup_fx( hFbMixer, sampling_rate, index ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_filterbank_setup_fx( hFbMixer, sampling_rate, index ) ), IVAS_ERR_OK ) ) { return error; } @@ -875,6 +904,7 @@ ivas_error ivas_FB_mixer_open_fx( * Deallocate FB mixer handle *------------------------------------------------------------------------*/ + void ivas_FB_mixer_close( IVAS_FB_MIXER_HANDLE *hFbMixer_in, /* i/o: FB mixer handle */ const int32_t sampling_rate, /* i : sampling rate in Hz */ @@ -1007,32 +1037,35 @@ void ivas_FB_mixer_close( return; } + #ifdef IVAS_FLOAT_FIXED void ivas_FB_mixer_close_fx( IVAS_FB_MIXER_HANDLE *hFbMixer_in, /* i/o: FB mixer handle */ - const int32_t sampling_rate, /* i : sampling rate in Hz */ - const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ + const Word32 sampling_rate, /* i : sampling rate in Hz */ + const Word16 spar_reconfig_flag /* i : SPAR reconfiguration flag */ ) { IVAS_FB_MIXER_HANDLE hFbMixer; IVAS_FB_CFG *fb_cfg; - int16_t i, j, num_bands; - int16_t num_chs_alloc; + Word16 i, j, num_bands; + Word16 num_chs_alloc; hFbMixer = *hFbMixer_in; fb_cfg = hFbMixer->fb_cfg; - IF( fb_cfg->active_w_mixing == -1 ) + IF( EQ_16( fb_cfg->active_w_mixing, -1 ) ) { num_chs_alloc = 0; + move16(); } ELSE IF( fb_cfg->active_w_mixing ) { - num_chs_alloc = max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ); + num_chs_alloc = s_max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ); } ELSE { num_chs_alloc = 1; /* only W channel processed for predicting YZX */ + move16(); } IF( hFbMixer != NULL ) @@ -1042,6 +1075,7 @@ void ivas_FB_mixer_close_fx( IF( fb_cfg->num_out_chans > 0 ) { j = fb_cfg->remix_order[i]; + move16(); free( hFbMixer->ppFilterbank_inFR_re_fx[j] ); hFbMixer->ppFilterbank_inFR_re_fx[j] = NULL; @@ -1051,13 +1085,14 @@ void ivas_FB_mixer_close_fx( } } - IF( fb_cfg->active_w_mixing == -1 ) + IF( EQ_16( fb_cfg->active_w_mixing, -1 ) ) { num_chs_alloc = 0; + move16(); } ELSE { - num_chs_alloc = max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ); + num_chs_alloc = s_max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ); } FOR( i = 0; i < num_chs_alloc; i++ ) @@ -1066,7 +1101,8 @@ void ivas_FB_mixer_close_fx( hFbMixer->ppFilterbank_prior_input_fx[i] = NULL; } - IF( ( fb_cfg->active_w_mixing != -1 ) && ( fb_cfg->num_out_chans > 0 ) ) + test(); + IF( NE_16( fb_cfg->active_w_mixing, -1 ) && ( fb_cfg->num_out_chans > 0 ) ) { free( hFbMixer->prior_mixer_fx[0][0] ); hFbMixer->prior_mixer_fx[0][0] = NULL; @@ -1078,7 +1114,7 @@ void ivas_FB_mixer_close_fx( { num_bands = hFbMixer->pFb->filterbank_num_bands; - IF( fb_cfg->active_w_mixing != -1 ) + IF( NE_16( fb_cfg->active_w_mixing, -1 ) ) { FOR( i = 0; i < num_bands; i++ ) { @@ -1087,10 +1123,10 @@ void ivas_FB_mixer_close_fx( } } - IF( sampling_rate != 48000 ) + IF( NE_32( sampling_rate, 48000 ) ) { - int16_t start_diff_band_non48k; - start_diff_band_non48k = num_bands - hFbMixer->num_diff_bands; + Word16 start_diff_band_non48k; + start_diff_band_non48k = sub( num_bands, hFbMixer->num_diff_bands ); FOR( j = start_diff_band_non48k; j < num_bands; j++ ) { @@ -1125,7 +1161,6 @@ void ivas_FB_mixer_close_fx( return; } #endif - /*-----------------------------------------------------------------------------------------* * Function ivas_fb_mixer_pcm_ingest() * @@ -1305,33 +1340,40 @@ void ivas_fb_mixer_cross_fading_fx( { Word16 k, fade_start_offset, fade_end_offset; - if ( hFbMixer->first_frame[ch] == 0 ) + IF( hFbMixer->first_frame[ch] == 0 ) { fade_start_offset = hFbMixer->cross_fade_start_offset; fade_end_offset = hFbMixer->cross_fade_end_offset; + move16(); + move16(); - for ( k = 0; k < fade_start_offset; k++ ) + FOR( k = 0; k < fade_start_offset; k++ ) { ppOut_pcm_fx[ch][k] = pMdft_out_old_fx[k + cf_offset]; + move32(); } - for ( k = fade_start_offset; k < fade_end_offset; k++ ) + FOR( k = fade_start_offset; k < fade_end_offset; k++ ) { - ppOut_pcm_fx[ch][k] = L_add( Mpy_32_16_1( pMdft_out_new_fx[k + cf_offset], hFbMixer->pFilterbank_cross_fade_fx[k - fade_start_offset] ), Mpy_32_16_1( pMdft_out_old_fx[k + cf_offset], ( ONE_IN_Q15 - hFbMixer->pFilterbank_cross_fade_fx[k - fade_start_offset] ) ) ); + ppOut_pcm_fx[ch][k] = L_add( Mpy_32_16_1( pMdft_out_new_fx[k + cf_offset], hFbMixer->pFilterbank_cross_fade_fx[k - fade_start_offset] ), Mpy_32_16_1( pMdft_out_old_fx[k + cf_offset], sub( 32767, hFbMixer->pFilterbank_cross_fade_fx[k - fade_start_offset] ) ) ); + move32(); } - for ( k = fade_end_offset; k < frame_len; k++ ) + FOR( k = fade_end_offset; k < frame_len; k++ ) { ppOut_pcm_fx[ch][k] = pMdft_out_new_fx[k + cf_offset]; + move32(); } } - else + ELSE { hFbMixer->first_frame[ch] = 0; + move32(); - for ( k = 0; k < frame_len; k++ ) + FOR( k = 0; k < frame_len; k++ ) { ppOut_pcm_fx[ch][k] = pMdft_out_new_fx[k + cf_offset]; + move32(); } } @@ -1758,6 +1800,7 @@ static Word16 ivas_calculate_abs_fr_fx( Word32 cldfb_nrg_fx = 0; Word16 cldfb_nrg_e = 0; move16(); + move16(); Word16 short_stride = pFb->fb_bin_to_band.short_stride; move16(); const Word16 num_bins_per_short_stride_bin = ( const Word16 )( ( sampling_rate / FRAMES_PER_SEC ) / short_stride ); @@ -1802,7 +1845,7 @@ static Word16 ivas_calculate_abs_fr_fx( /* accumulate bin energies within a short stride bin */ - short_stride_nrg_fx = L_add( short_stride_nrg_fx, L_shl( sq_abs_fx, Q22 - ( Q31 - sq_abs_e ) ) ); + short_stride_nrg_fx = L_add( short_stride_nrg_fx, L_shl( sq_abs_fx, sub( Q22, sub( Q31, sq_abs_e ) ) ) ); move32(); IF( !( ( j + 1 ) % num_bins_per_short_stride_bin ) ) @@ -1818,7 +1861,6 @@ static Word16 ivas_calculate_abs_fr_fx( /* accumulate bin energies within a CLDFB band */ cldfb_nrg_fx = BASOP_Util_Add_Mant32Exp( cldfb_nrg_fx, cldfb_nrg_e, sq_abs_fx, sq_abs_e, &cldfb_nrg_e ); - move32(); IF( !( ( j + 1 ) % num_bins_per_cldfb_band ) ) { @@ -1828,6 +1870,7 @@ static Word16 ivas_calculate_abs_fr_fx( move32(); pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j / num_bins_per_cldfb_band][i] = temp; cldfb_nrg_fx = 0; + move32(); cldfb_nrg_e = 0; move16(); } @@ -1840,17 +1883,17 @@ static Word16 ivas_calculate_abs_fr_fx( move16(); short_stride_pow_spec_fx[j] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22 move32(); - short_stride_pow_spec_fx[j] = L_max( L_sub( short_stride_pow_spec_fx[j], (Word32) ( 0.3f * ONE_IN_Q22 ) ), 0 ); + short_stride_pow_spec_fx[j] = L_max( L_sub( short_stride_pow_spec_fx[j], 1258291 ), 0 ); // 0.3f * ONE_IN_Q22c move32(); - tmp = BASOP_Util_Divide3232_Scale( short_stride_pow_spec_fx[j], (Word32) ( 0.7f * ONE_IN_Q22 ), &exp_diff ); + tmp = BASOP_Util_Divide3232_Scale( short_stride_pow_spec_fx[j], 2936012, &exp_diff ); // 0.7f * ONE_IN_Q22 move16(); short_stride_pow_spec_fx[j] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22 move32(); - IF( GT_32( short_stride_pow_spec_fx[j], 0 ) ) + IF( short_stride_pow_spec_fx[j] > 0 ) { assert( idx_short_stride_bin_to_band < 2 * MDFT_FB_BANDS_240 ); /* array size of p_short_stride_bin_to_band */ - IF( short_mdft_start_bin == -1 ) + IF( EQ_16( short_mdft_start_bin, -1 ) ) { short_mdft_start_bin = j; move16(); @@ -1859,13 +1902,15 @@ static Word16 ivas_calculate_abs_fr_fx( pFb->fb_bin_to_band.pp_short_stride_bin_to_band_fx[i] = &pFb->fb_bin_to_band.p_short_stride_bin_to_band_fx[idx_short_stride_bin_to_band]; index[i] = idx_short_stride_bin_to_band; + move16(); } pFb->fb_bin_to_band.p_short_stride_bin_to_band_fx[idx_short_stride_bin_to_band] = short_stride_pow_spec_fx[j]; move32(); - idx_short_stride_bin_to_band++; + idx_short_stride_bin_to_band = add( idx_short_stride_bin_to_band, 1 ); - pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[i]++; + pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[i] = add( pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[i], 1 ); + move16(); } } } @@ -1897,14 +1942,15 @@ static Word16 ivas_calculate_abs_fr_fx( } } - sum_over_spar_bands_fx = max( sum_over_spar_bands_fx, EPSILON_FX ); + sum_over_spar_bands_fx = L_max( sum_over_spar_bands_fx, EPSILON_FX ); move32(); FOR( i = 0; i < bands; i++ ) { + test(); IF( pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i] == 0 && !any_non_zero ) { - spar_start++; + spar_start = add( spar_start, 1 ); } ELSE { @@ -1923,7 +1969,9 @@ static Word16 ivas_calculate_abs_fr_fx( move16(); } - frame_len = (int16_t) ( sampling_rate / FRAMES_PER_SEC ); + Word16 exp; + frame_len = BASOP_Util_Divide3232_Scale( sampling_rate, FRAMES_PER_SEC, &exp ); + frame_len = shr( frame_len, sub( 15, exp ) ); set_l( ppFilterbank_FRs_s_fx, 0, frame_len ); @@ -1981,13 +2029,15 @@ static Word16 ivas_calculate_abs_fr_fx( temp_fx = L_sub( temp_fx, 1258291 ); move32(); - IF( temp_fx < 0 ) + if ( temp_fx < 0 ) { temp_fx = 0; move32(); } - IF( j < ( abs_active_bins + abs_start_offset ) && j >= abs_start_offset && alloc_fb_resp != -1 ) + test(); + test(); + IF( LT_16( j, add( abs_active_bins, abs_start_offset ) ) && GE_16( j, abs_start_offset ) && NE_16( alloc_fb_resp, -1 ) ) { pFb->fb_bin_to_band.pFb_bin_to_band_fx[i][idx] = temp_fx; move32(); @@ -2002,13 +2052,14 @@ static Word16 ivas_calculate_abs_fr_fx( FOR( i = 0; i < frame_len; i++ ) { - IF( ppFilterbank_FRs_s_fx[i] < 0 ) + if ( ppFilterbank_FRs_s_fx[i] < 0 ) { ppFilterbank_FRs_s_fx[i] = 419430; + move32(); } } - IF( alloc_fb_resp != -1 ) + IF( NE_16( alloc_fb_resp, -1 ) ) { FOR( j = 0; j < bands; j++ ) { @@ -2016,6 +2067,10 @@ static Word16 ivas_calculate_abs_fr_fx( Word16 abs_start_offset = pFb->fb_bin_to_band.pFb_start_bin_per_band[j]; Word16 exp_diff = 0, tmp; + move16(); + move16(); + move16(); + FOR( i = 0; i < abs_active_bins; i++ ) { tmp = BASOP_Util_Divide3232_Scale( pFb->fb_bin_to_band.pFb_bin_to_band_fx[j][i], ppFilterbank_FRs_s_fx[i + abs_start_offset], &exp_diff ); @@ -2236,10 +2291,10 @@ static ivas_error ivas_filterbank_setup( #ifdef IVAS_FLOAT_FIXED static ivas_error ivas_filterbank_setup_fx( IVAS_FB_MIXER_HANDLE hFbMixer, - const int32_t sampling_rate, + const Word32 sampling_rate, Word16 *index ) { - Word16 i, j; + Word16 i, j, exp, tmp; const Word32 *pAll_fb_fr_fx[2]; const Word16 *pAll_bins_start_offset = NULL; const Word16 *pAll_bins_per_band = NULL; @@ -2250,14 +2305,16 @@ static ivas_error ivas_filterbank_setup_fx( IVAS_FB_CFG *pCfg = hFbMixer->fb_cfg; error = IVAS_ERR_OK; + move32(); IF( pCfg->num_out_chans > 0 ) { hFbMixer->pFb->filterbank_num_bands = ivas_get_num_bands( sampling_rate ); + move16(); ivas_get_active_bins( &pAll_bins_per_band, &pAll_bins_per_band_abs, &pAll_bins_start_offset, &pAll_bins_start_offset_abs, sampling_rate ); - IF( pCfg->fb_latency == NS2SA( sampling_rate, DELAY_FB_1_NS ) ) + IF( EQ_16( pCfg->fb_latency, NS2SA( sampling_rate, DELAY_FB_1_NS ) ) ) { pAll_fb_fr_fx[0] = ivas_fb_fr_12band_1ms_re_fx; // Q30 move32(); @@ -2273,19 +2330,19 @@ static ivas_error ivas_filterbank_setup_fx( } } - hFbMixer->cross_fade_end_offset = pCfg->fade_len + pCfg->pcm_offset; + hFbMixer->cross_fade_end_offset = add( pCfg->fade_len, pCfg->pcm_offset ); move16(); - hFbMixer->cross_fade_start_offset = hFbMixer->cross_fade_end_offset - pCfg->fade_len; + hFbMixer->cross_fade_start_offset = sub( hFbMixer->cross_fade_end_offset, pCfg->fade_len ); move16(); - hFbMixer->ana_window_offset = pCfg->fb_latency + pCfg->pcm_offset; + hFbMixer->ana_window_offset = add( pCfg->fb_latency, pCfg->pcm_offset ); move16(); - IF( ( error = ivas_fb_mixer_get_window_fx( pCfg->fb_latency, sampling_rate, &( hFbMixer->pAna_window_fx ) ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_fb_mixer_get_window_fx( pCfg->fb_latency, sampling_rate, &( hFbMixer->pAna_window_fx ) ) ), IVAS_ERR_OK ) ) { return error; } - IF( ( error = ivas_fb_mixer_get_window_fx( pCfg->fade_len, sampling_rate, &( hFbMixer->pFilterbank_cross_fade_fx ) ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_fb_mixer_get_window_fx( pCfg->fade_len, sampling_rate, &( hFbMixer->pFilterbank_cross_fade_fx ) ) ), IVAS_ERR_OK ) ) { return error; } @@ -2294,6 +2351,7 @@ static ivas_error ivas_filterbank_setup_fx( { ivas_filterbank_t *pFb = hFbMixer->pFb; Word16 offset = 0; + move16(); pFb->fb_consts.pFilterbank_bins_per_band = pAll_bins_per_band; pFb->fb_consts.pFilterbank_bins_start_offset = pAll_bins_start_offset; @@ -2306,19 +2364,23 @@ static ivas_error ivas_filterbank_setup_fx( case 48000: pFb->fb_bin_to_band.num_cldfb_bands = 60; /* sampling_rate * 1.0f / 800.0f */ move16(); - break; + BREAK; case 32000: pFb->fb_bin_to_band.num_cldfb_bands = 40; move16(); - break; + BREAK; case 16000: pFb->fb_bin_to_band.num_cldfb_bands = 20; move16(); - break; + BREAK; } /*pFb->fb_bin_to_band.cldfb_stride = ( int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX );*/ /* equals num_cldfb_bands*/ - pFb->fb_bin_to_band.short_stride = extract_l( ( sampling_rate / FRAMES_PER_SEC ) / 4 ); + // pFb->fb_bin_to_band.short_stride = extract_l( ( sampling_rate / FRAMES_PER_SEC ) / 4 ); + tmp = BASOP_Util_Divide3232_Scale( sampling_rate, FRAMES_PER_SEC, &exp ); + pFb->fb_bin_to_band.short_stride = shr( tmp, sub( 15, exp ) + 2 ); + + move16(); set_l( pFb->fb_bin_to_band.p_short_stride_bin_to_band_fx, 0, 2 * MDFT_FB_BANDS_240 ); @@ -2341,7 +2403,7 @@ static ivas_error ivas_filterbank_setup_fx( move32(); } } - IF( sampling_rate == 48000 ) + IF( EQ_32( sampling_rate, 48000 ) ) { FOR( j = 0; j < pFb->filterbank_num_bands; j++ ) { @@ -2400,6 +2462,8 @@ static ivas_error ivas_filterbank_setup_fx( active_bins_temp[j - start_diff_band_non48k] = pFb->fb_consts.pFilterbank_bins_per_band[j]; start_offset_temp[j - start_diff_band_non48k] = pFb->fb_consts.pFilterbank_bins_start_offset[j]; + move16(); + move16(); } ivas_get_ld_fb_resp_fx( ppFilterbank_FRs_re_temp_fx, ppFilterbank_FRs_im_temp_fx, ppFilterbank_FRs_re_temp_fx, ppFilterbank_FRs_im_temp_fx, @@ -2491,6 +2555,7 @@ static ivas_error ivas_fb_mixer_get_window_fx( ivas_error error; error = IVAS_ERR_OK; + move32(); IF( EQ_16( fade_len, NS2SA( sampling_rate, DELAY_FB_4_NS ) ) ) { @@ -2501,10 +2566,10 @@ static ivas_error ivas_fb_mixer_get_window_fx( BREAK; case 32000: *pWindow = ivas_fb_cf_4ms_32k_fx; - break; + BREAK; case 16000: *pWindow = ivas_fb_cf_4ms_16k_fx; - break; + BREAK; default: return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Unsupported Sampling frequency!" ); } @@ -2566,10 +2631,10 @@ static const Word32 *ivas_get_cheby_ramp_fx( { case IVAS_FB_1MS_32K_SAMP: pCheby_fx = ivas_fb_resp_cheby_ramp_32del_fx; - break; + BREAK; case IVAS_FB_1MS_16K_SAMP: pCheby_fx = ivas_fb_resp_cheby_ramp_16del_fx; - break; + BREAK; default: assert( !"Unsupported cheby ramp length!" ); } @@ -2726,6 +2791,7 @@ static void ivas_get_ld_fb_resp_fx( Word16 b, s, frame_len; const Word32 *pCheby_fx; frame_len = 0; + move16(); /*common scratch buffers for computing impulse/frequency responses, pre-ring, post-ring and circular shifted outputs to optimize stack*/ Word32 scratch1_fx[L_FRAME32k * 2]; @@ -2740,22 +2806,27 @@ static void ivas_get_ld_fb_resp_fx( { case 48000: frame_len = 960; + move16(); han_win_fx = ivas_han_win_48k_fx; // Q31 - break; + BREAK; case 32000: frame_len = 640; + move16(); han_win_fx = ivas_han_win_32k_fx; // Q31 - break; + BREAK; case 16000: frame_len = 320; + move16(); han_win_fx = ivas_han_win_16k_fx; // Q31 - break; + BREAK; } pCheby_fx = ivas_get_cheby_ramp_fx( delay ); // Q31 b = 0; s = 0; + move16(); + move16(); assert( sampling_rate == 32000 || sampling_rate == 16000 ); @@ -2766,7 +2837,7 @@ static void ivas_get_ld_fb_resp_fx( Copy32( ppIdeal_FRs_re_fx[b], &scratch2_fx[pStart_offset[b]], pActive_bins[b] ); Copy32( ppIdeal_FRs_im_fx[b], &scratch2_fx[frame_len + pStart_offset[b]], pActive_bins[b] ); // Q30 - Word16 guard_bits = L_norm_arr( scratch2_fx, shl( L_FRAME32k, 1 ) ) - find_guarded_bits_fx( shl( frame_len, 1 ) ); + Word16 guard_bits = sub( L_norm_arr( scratch2_fx, shl( L_FRAME32k, 1 ) ), find_guarded_bits_fx( shl( frame_len, 1 ) ) ); Scale_sig32( scratch2_fx, shl( L_FRAME32k, 1 ), guard_bits ); ivas_imdft_fx( scratch2_fx, &scratch2_fx[frame_len], scratch1_fx, frame_len ); @@ -2775,6 +2846,9 @@ static void ivas_get_ld_fb_resp_fx( { scratch2_fx[x] = L_shr( scratch2_fx[x], guard_bits ); scratch1_fx[x] = L_shr( scratch1_fx[x], guard_bits ); + + move32(); + move32(); } /*apply circular shift and hanning window*/ @@ -2783,18 +2857,21 @@ static void ivas_get_ld_fb_resp_fx( { scratch2_fx[sub( s, delay )] = Mpy_32_32( scratch1_fx[s], L_sub( ONE_IN_Q31, han_win_fx[sub( s, delay )] ) ); // Q(30 + 31 - 31) == Q30 + move32(); } FOR( ; s < 2 * frame_len; s++ ) { scratch2_fx[sub( s, delay )] = Mpy_32_32( scratch1_fx[s], han_win_fx[sub( s, add( frame_len, delay ) )] ); // Q30 + move32(); } FOR( s = 0; s < delay; s++ ) { scratch2_fx[add( sub( shl( frame_len, 1 ), delay ), s )] = L_negate( Mpy_32_32( scratch1_fx[s], han_win_fx[add( sub( frame_len, delay ), s )] ) ); // Q30 + move32(); } /*apply heavy/cheby ramp window and compute pre ring*/ @@ -2802,6 +2879,7 @@ static void ivas_get_ld_fb_resp_fx( FOR( s = 0; s < delay + 1; s++ ) { scratch1_fx[s] = Mpy_32_32( scratch2_fx[s], pCheby_fx[sub( delay, s )] ); // Q30 + move32(); } FOR( ; s < frame_len; s++ ) @@ -2813,27 +2891,32 @@ static void ivas_get_ld_fb_resp_fx( FOR( ; s < 2 * frame_len - delay; s++ ) { scratch1_fx[s] = scratch2_fx[s]; + move32(); } FOR( ; s < 2 * frame_len; s++ ) { scratch1_fx[s] = Mpy_32_32( scratch2_fx[s], L_sub( ONE_IN_Q31, pCheby_fx[sub( s, sub( shl( frame_len, 1 ), delay ) )] ) ); // Q30 + move32(); } /*IR - pre ring + post ring*/ FOR( s = 1; s < 2 * frame_len; s++ ) { scratch2_fx[s] = L_sub( L_sub( scratch2_fx[s] /*pre ring*/, scratch1_fx[s] /*post ring*/ ), scratch1_fx[sub( shl( frame_len, 1 ), s )] ); + move32(); } FOR( s = 0; s < 2 * frame_len - delay; s++ ) { scratch1_fx[add( s, delay )] = scratch2_fx[s]; + move32(); } FOR( ; s < 2 * frame_len; s++ ) { scratch1_fx[sub( s, sub( shl( frame_len, 1 ), delay ) )] = L_negate( scratch2_fx[s] ); + move32(); } /* apply final window*/ @@ -2841,21 +2924,28 @@ static void ivas_get_ld_fb_resp_fx( Word16 offset = 1; Word16 delay_16 = 0; - IF( delay == IVAS_FB_1MS_16K_SAMP ) + move16(); + move16(); + + if ( EQ_16( delay, IVAS_FB_1MS_16K_SAMP ) ) { delay_16 = 1; + move16(); } FOR( s = 0; s < delay; s++ ) { - scratch1_fx[s] = Mpy_32_32( scratch1_fx[s], sine_till_delay[s + ( offset * delay_16 )] ); + scratch1_fx[s] = Mpy_32_32( scratch1_fx[s], sine_till_delay[add( s, imult1616( offset, delay_16 ) )] ); offset = add( offset, 1 ); scratch1_fx[s] = L_shl( scratch1_fx[s], 1 ); // Q30 + + move32(); + move32(); } const Word32 *sine_till_frame_len = NULL; - IF( delay == IVAS_FB_1MS_16K_SAMP ) + IF( EQ_16( delay, IVAS_FB_1MS_16K_SAMP ) ) { sine_till_frame_len = ivas_sine_frame_len_640_del_16_fx; // Q30 } @@ -2864,18 +2954,24 @@ static void ivas_get_ld_fb_resp_fx( sine_till_frame_len = ivas_sine_frame_len_640_del_32_fx; // Q30 } Word16 iterator = 0; + move16(); FOR( s = 2 * delay; s < frame_len + 1; s++ ) { scratch1_fx[s] = Mpy_32_32( scratch1_fx[s], sine_till_frame_len[iterator] ); iterator = add( iterator, 1 ); scratch1_fx[s] = L_shl( scratch1_fx[s], 1 ); // Q30 + move32(); + move32(); + // assert(fabs(scratch1[s]) - fabs(fix_to_float(scratc h1_fx[s], 30)) < 0.00001); } FOR( ; s < 2 * frame_len; s++ ) { scratch1_fx[s] = 0; + + move32(); } /*compute frequency response*/ diff --git a/lib_com/ivas_filters.c b/lib_com/ivas_filters.c index 2790cfb5c..21ec2a2a4 100644 --- a/lib_com/ivas_filters.c +++ b/lib_com/ivas_filters.c @@ -109,10 +109,13 @@ void ivas_filters_init_fx( Word16 i; filter_state->order = order; move16(); + + test(); IF( EQ_16( order, IVAS_FILTER_ORDER_2 ) || EQ_16( order, IVAS_FILTER_ORDER_1 ) ) { filter_state->filt_len = add( order, 1 ); + move16(); FOR( i = 0; i < IVAS_BIQUAD_FILT_LEN; i++ ) { @@ -142,6 +145,7 @@ void ivas_filters_init_fx( ELSE { filter_state->filt_len = IVAS_BIQUAD_FILT_LEN; + move16(); FOR( i = 0; i < IVAS_BIQUAD_FILT_LEN; i++ ) { @@ -303,6 +307,9 @@ static void ivas_iir_2_filter_fx( Word32 L_tmp_prod, L_tmp; Word16 L_prod_e, L_tmp_e; + move16(); + move16(); + FOR( i = 0; i < length; i++ ) { tmp_pIn_buf_i_fx = pIn_fx[i]; diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index aab90fab5..6955e83e3 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -73,6 +73,7 @@ * Convert bit-budget to bitrate *-------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED void bitbudget_to_brate( const Word16 x[], /* i : bitbudgets */ Word32 y[], /* o : bitrates */ @@ -82,6 +83,23 @@ void bitbudget_to_brate( Word16 i; FOR( i = 0; i < N; i++ ) + { + y[i] = FRAMES_PER_SEC * x[i]; + move32(); + } + + return; +} +#else +void bitbudget_to_brate( + const int16_t x[], /* i : bitbudgets */ + int32_t y[], /* o : bitrates */ + const int16_t N /* i : number of entries to be converted */ +) +{ + int16_t i; + + for ( i = 0; i < N; i++ ) { y[i] = FRAMES_PER_SEC * x[i]; } @@ -89,6 +107,8 @@ void bitbudget_to_brate( return; } +#endif + /*-------------------------------------------------------------------* * ivas_ism_config() @@ -417,7 +437,7 @@ ivas_error ivas_ism_config_fx( ivas_error error; error = IVAS_ERR_OK; - move16(); + move32(); IF( combined_format_flag ) { n_ISms = nchan_ism; @@ -449,8 +469,9 @@ ivas_error ivas_ism_config_fx( // bits_ism = (Word16) ( ism_total_brate / FRAMES_PER_SEC ); bits_ism = (Word16) Mpy_32_32( 42949673, ism_total_brate ); tmp1 = BASOP_Util_Divide1616_Scale( bits_ism, n_ISms, &exp ); - set_s( bits_element, shr( tmp1, ( 15 - exp ) ), n_ISms ); + set_s( bits_element, shr( tmp1, sub( 15, exp ) ), n_ISms ); bits_element[n_ISms - 1] = add( bits_element[n_ISms - 1], bits_ism % n_ISms ); + move16(); /* ISM common signaling bits are counted in MASA MD bit-budget */ } @@ -462,22 +483,26 @@ ivas_error ivas_ism_config_fx( //(Q31 +Q0) - Q31 --> Q0 bits_ism = (Word16) Mpy_32_32( 42949673, ism_total_brate ); tmp1 = BASOP_Util_Divide1616_Scale( bits_ism, n_ISms, &exp ); - set_s( bits_element, shr( tmp1, ( 15 - exp ) ), n_ISms ); + set_s( bits_element, shr( tmp1, sub( 15, exp ) ), n_ISms ); bits_element[n_ISms - 1] = add( bits_element[n_ISms - 1], bits_ism % n_ISms ); + move16(); bitbudget_to_brate( bits_element, element_brate, n_ISms ); /* count ISm common signaling bits */ IF( hIsmMeta != NULL ) { nb_bits_metadata[0] = add( nb_bits_metadata[0], add( n_ISms * ISM_METADATA_FLAG_BITS, nchan_ism ) ); + move16(); IF( GE_32( ism_total_brate, ISM_EXTENDED_METADATA_BRATE ) ) { nb_bits_metadata[0] = add( nb_bits_metadata[0], ISM_EXTENDED_METADATA_BITS ); + move16(); IF( ism_extended_metadata_flag ) { nb_bits_metadata[0] = add( nb_bits_metadata[0], ISM_METADATA_IS_NDP_BITS ); + move16(); } } @@ -487,6 +512,9 @@ ivas_error ivas_ism_config_fx( { nb_bits_metadata[0] = add( nb_bits_metadata[0], ISM_METADATA_MD_FLAG_BITS ); nb_bits_metadata[0] = add( nb_bits_metadata[0], ISM_METADATA_FLAG_BITS ); + + move16(); + move16(); } ELSE { @@ -494,6 +522,9 @@ ivas_error ivas_ism_config_fx( { nb_bits_metadata[0] = add( nb_bits_metadata[0], ISM_METADATA_MD_FLAG_BITS ); nb_bits_metadata[0] = add( nb_bits_metadata[0], ISM_METADATA_INACTIVE_FLAG_BITS ); + + move16(); + move16(); } } } @@ -507,6 +538,7 @@ ivas_error ivas_ism_config_fx( tmp1 = BASOP_Util_Divide1616_Scale( bits_side, n_ISms, &exp ); set_s( nb_bits_metadata, shr( tmp1, ( 15 - exp ) ), n_ISms ); nb_bits_metadata[n_ISms - 1] = add( nb_bits_metadata[n_ISms - 1], bits_side % n_ISms ); + move16(); v_sub_s( bits_element, nb_bits_metadata, bits_CoreCoder, n_ISms ); bitbudget_to_brate( bits_CoreCoder, total_brate, n_ISms ); @@ -529,21 +561,24 @@ ivas_error ivas_ism_config_fx( diff = add( diff, sub( bits_CoreCoder[ch], BITS_ISM_INACTIVE ) ); bits_CoreCoder[ch] = BITS_ISM_INACTIVE; flag_higher[ch] = 0; + move16(); + move16(); } } n_higher = sum_s( flag_higher, n_ISms ); test(); - IF( GT_16( diff, 0 ) && GT_16( n_higher, 0 ) ) + IF( diff > 0 && n_higher > 0 ) { tmp = BASOP_Util_Divide1616_Scale( diff, n_higher, &exp ); - tmp = shr( tmp, ( 15 - exp ) ); + tmp = shr( tmp, sub( 15, exp ) ); FOR( ch = 0; ch < n_ISms; ch++ ) { IF( flag_higher[ch] ) { bits_CoreCoder[ch] = add( bits_CoreCoder[ch], tmp ); + move16(); } } @@ -551,11 +586,12 @@ ivas_error ivas_ism_config_fx( move16(); ch = 0; move16(); - WHILE( EQ_16( flag_higher[ch], 0 ) ) + WHILE( flag_higher[ch] == 0 ) { ch = add( ch, 1 ); } bits_CoreCoder[ch] = add( bits_CoreCoder[ch], tmp ); + move16(); } bitbudget_to_brate( bits_CoreCoder, total_brate, n_ISms ); @@ -609,15 +645,16 @@ ivas_error ivas_ism_config_fx( } test(); - IF( GT_16( diff, 0 ) && GT_16( n_higher, 0 ) ) + IF( diff > 0 && n_higher > 0 ) { tmp = BASOP_Util_Divide1616_Scale( diff, n_higher, &exp ); - tmp = shr( tmp, ( 15 - exp ) ); + tmp = shr( tmp, sub( 15, exp ) ); FOR( ch = 0; ch < n_ISms; ch++ ) { IF( flag_higher[ch] ) { bits_CoreCoder[ch] = add( bits_CoreCoder[ch], tmp ); + move16(); } } @@ -625,11 +662,12 @@ ivas_error ivas_ism_config_fx( move16(); ch = 0; move16(); - WHILE( EQ_16( flag_higher[ch], 0 ) ) + WHILE( flag_higher[ch] == 0 ) { ch = add( ch, 1 ); } bits_CoreCoder[ch] = add( bits_CoreCoder[ch], tmp ); + move16(); } /* verify for the maximum bitrate @12.8kHz core */ @@ -639,7 +677,7 @@ ivas_error ivas_ism_config_fx( { limit_high = BITS_IVAS_512k; move16(); - IF( LT_32( element_brate[ch], SCE_CORE_16k_LOW_LIMIT ) ) /* replicate function set_ACELP_flag() -> it is not intended to switch the ACELP internal sampling rate within an object */ + if ( LT_32( element_brate[ch], SCE_CORE_16k_LOW_LIMIT ) ) /* replicate function set_ACELP_flag() -> it is not intended to switch the ACELP internal sampling rate within an object */ { limit_high = BITS_ACELP_12k8_HIGH_LIMIT; move16(); @@ -670,13 +708,13 @@ ivas_error ivas_ism_config_fx( } } - IF( GT_16( diff, 0 ) ) + IF( diff > 0 ) { ch = 0; move16(); FOR( ch = 0; ch < n_ISms; ch++ ) { - IF( EQ_16( flag_higher[ch], 0 ) ) + IF( flag_higher[ch] == 0 ) { IF( GT_16( diff, limit_high ) ) { @@ -687,8 +725,9 @@ ivas_error ivas_ism_config_fx( ELSE { bits_CoreCoder[ch] = add( bits_CoreCoder[ch], diff ); + move16(); - IF( combined_format_flag ) + if ( combined_format_flag ) { diff = 0; move16(); @@ -701,7 +740,7 @@ ivas_error ivas_ism_config_fx( IF( combined_format_flag ) { - IF( GT_16( diff, 0 ) ) + IF( diff > 0 ) { FOR( ch = 0; ch < n_ISms; ch++ ) { @@ -853,7 +892,7 @@ Word16 ism_quant_meta_fx( Word32 qlow_fx, step_fx; Word16 tmp, tmp_e; - IF( val <= borders_fx[1] ) + IF( LE_32( val, borders_fx[1] ) ) { qlow_fx = borders_fx[0]; move32(); @@ -862,7 +901,7 @@ Word16 ism_quant_meta_fx( step_fx = q_step_border_fx; move32(); } - ELSE IF( val <= borders_fx[2] ) + ELSE IF( LE_32( val, borders_fx[2] ) ) { qlow_fx = borders_fx[1]; move32(); @@ -890,6 +929,7 @@ Word16 ism_quant_meta_fx( // idx = idx_start + (int16_t) max( 0.f, min( cbsize - 1, ( ( val - qlow_fx ) / step_fx + 0.5f ) ) ); *valQ = L_add( imult3216( step_fx, sub( idx, idx_start ) ), qlow_fx ); + move32(); return idx; } @@ -949,29 +989,48 @@ Word32 ism_dequant_meta_fx( const Word16 cbsize /* i : codebook size */ ) { - Word16 idx_start; + Word16 idx_start, tmp1, tmp2, exp1, exp2; Word32 qlow_fx, step_fx, valQ_fx; - IF( idx <= L_shr( L_sub( borders_fx[1], borders_fx[0] ), 21 ) / L_shr( q_step_border_fx, 21 ) ) + tmp1 = BASOP_Util_Divide3232_Scale( L_shr( L_sub( borders_fx[1], borders_fx[0] ), 21 ), L_shr( q_step_border_fx, 21 ), &exp1 ); + tmp1 = shr( tmp1, sub( 15, exp1 ) ); + + tmp2 = BASOP_Util_Divide3232_Scale( L_shr( L_sub( borders_fx[3], borders_fx[2] ), 21 ), L_shr( q_step_border_fx, 21 ), &exp2 ); + tmp2 = shr( tmp2, sub( 15, exp2 ) ); + + + IF( LE_16( idx, tmp1 ) ) { qlow_fx = borders_fx[0]; idx_start = 0; step_fx = q_step_border_fx; + + move32(); + move32(); + move16(); } - ELSE IF( idx <= cbsize - 1 - L_shr( L_sub( borders_fx[3], borders_fx[2] ), 21 ) / L_shr( q_step_border_fx, 21 ) ) + ELSE IF( LE_16( idx, sub( sub( cbsize, 1 ), tmp2 ) ) ) { qlow_fx = borders_fx[1]; - idx_start = (Word16) ( L_shr( L_sub( borders_fx[1], borders_fx[0] ), 21 ) / L_shr( q_step_border_fx, 21 ) ); + idx_start = tmp1; step_fx = q_step_fx; + + move32(); + move32(); + move16(); } ELSE { qlow_fx = borders_fx[2]; - idx_start = (Word16) ( cbsize - 1 - L_shr( L_sub( borders_fx[3], borders_fx[2] ), 21 ) / L_shr( q_step_border_fx, 21 ) ); + idx_start = (Word16) sub( sub( cbsize, 1 ), tmp2 ); step_fx = q_step_border_fx; + + move32(); + move32(); + move16(); } - valQ_fx = sub( idx, idx_start ) * step_fx + qlow_fx; + valQ_fx = L_add( sub( idx, idx_start ) * step_fx, qlow_fx ); return valQ_fx; } @@ -1094,6 +1153,7 @@ void ivas_param_ism_config_fx( * ---------------------------------------------------------------*/ /*! r : ISM format mode */ +#ifdef IVAS_FLOAT_FIXED ISM_MODE ivas_ism_mode_select( const Word16 nchan_inp, /* i : number of input objects */ const Word32 ivas_total_brate /* i : IVAS total bitrate */ @@ -1116,7 +1176,27 @@ ISM_MODE ivas_ism_mode_select( return ism_mode; } +#else +ISM_MODE ivas_ism_mode_select( + const int16_t nchan_inp, /* i : number of input objects */ + const int32_t ivas_total_brate /* i : IVAS total bitrate */ +) +{ + ISM_MODE ism_mode = ISM_MODE_NONE; + + if ( nchan_inp > 2 && ivas_total_brate <= ACELP_32k ) + { + ism_mode = ISM_MODE_PARAM; + } + else + { + ism_mode = ISM_MODE_DISC; + } + + return ism_mode; +} +#endif /*--------------------------------------------------------------- * ivas_ism_metadata_close() @@ -1253,13 +1333,26 @@ void ivas_get_ism_sid_quan_bitbudget_fx( *nBits_coh = ISM_DTX_COH_SCA_BITS; *nBits_sce_id = 1; - IF( nchan_ism >= 3 ) + move16(); + move16(); + move16(); + move16(); + move32(); + move32(); + + IF( GE_16( nchan_ism, 3 ) ) { *nBits_azimuth = ISM_DTX_AZI_BITS_LOW; *nBits_elevation = ISM_DTX_ELE_BITS_LOW; *q_step_fx = ISM_Q_STEP_LOW_FX; *q_step_border_fx = ISM_Q_STEP_BORDER_LOW_FX; *nBits_sce_id = 2; + + move16(); + move16(); + move16(); + move16(); + move32(); } return; diff --git a/lib_com/ivas_lfe_com.c b/lib_com/ivas_lfe_com.c index 0249e288e..7fdfe40fa 100644 --- a/lib_com/ivas_lfe_com.c +++ b/lib_com/ivas_lfe_com.c @@ -199,6 +199,11 @@ void ivas_lfe_window_init_fx( move16(); move16(); + move16(); + move16(); + move16(); + move16(); + return; } #else diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 27ceb3c0b..437e88399 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1200,11 +1200,19 @@ ivas_error ivas_ism_config( const int16_t combined_format_flag /* i : flag indicating combined format */ ); +#ifdef IVAS_FLOAT_FIXED void bitbudget_to_brate( const Word16 x[], /* i : bitbudgets */ Word32 y[], /* o : bitrates */ const Word16 N /* i : number of entries to be converted */ ); +#else +void bitbudget_to_brate( + const int16_t x[], /* i : bitbudgets */ + int32_t y[], /* o : bitrates */ + const int16_t N /* i : number of entries to be converted */ +); +#endif void ivas_ism_reset_metadata( ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handles */ @@ -1306,10 +1314,17 @@ ivas_error ivas_ism_metadata_dec( *----------------------------------------------------------------------------------*/ /*! r: ISM format mode */ +#ifdef IVAS_FLOAT_FIXED ISM_MODE ivas_ism_mode_select( const Word16 nchan_inp, /* i : number of input objects */ const Word32 ivas_total_brate /* i : IVAS total bitrate */ ); +#else +ISM_MODE ivas_ism_mode_select( + const int16_t nchan_inp, /* i : number of input objects */ + const int32_t ivas_total_brate /* i : IVAS total bitrate */ +); +#endif ivas_error ivas_param_ism_enc_open( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ @@ -6439,22 +6454,45 @@ void ivas_arith_decode_cmplx_cell_array( int16_t *pSymbol_re_old ); +#ifndef IVAS_FLOAT_FIXED void ivas_ari_start_decoding_14bits_ext_1_lfe( Decoder_State *st, Tastat *s, int16_t *extra_bits_read ); +#else +void ivas_ari_start_decoding_14bits_ext_1_lfe( + Decoder_State *st, + Tastat *s, + Word16 *extra_bits_read +); +#endif +#ifndef IVAS_FLOAT_FIXED uint16_t ivas_ari_decode_14bits_bit_ext_1_lfe( Decoder_State *st, Tastat *s, const uint16_t *cum_freq, int16_t *extra_bits_read ); +#else +UWord16 ivas_ari_decode_14bits_bit_ext_1_lfe( + Decoder_State *st, Tastat *s, + const UWord16 *cum_freq, + Word16 *extra_bits_read +); +#endif +#ifndef IVAS_FLOAT_FIXED void ivas_ari_done_decoding_14bits_ext_1_lfe( Decoder_State *st, const int16_t extra_bits_read ); +#else +void ivas_ari_done_decoding_14bits_ext_1_lfe( + Decoder_State *st, + const Word16 extra_bits_read +); +#endif void ivas_ari_done_encoding_14bits( BSTR_ENC_HANDLE hBstr, Tastat *s @@ -7773,6 +7811,15 @@ ivas_error ivas_FB_mixer_open( const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ ); +#ifdef IVAS_FLOAT_FIXED +void ivas_FB_mixer_close_fx( + IVAS_FB_MIXER_HANDLE *hFbMixer, /* i/o: FB mixer handle */ + const Word32 sampling_rate, /* i : sampling rate in Hz */ + const Word16 spar_reconfig_flag /* i : SPAR reconfiguration flag */ +); + +#endif + void ivas_FB_mixer_close( IVAS_FB_MIXER_HANDLE *hFbMixer, /* i/o: FB mixer handle */ const int32_t sampling_rate, /* i : sampling rate in Hz */ diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 8733ad0bd..ace600eab 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -6835,4 +6835,4 @@ const ACPL_QUANT_TABLE ivas_mc_paramupmix_beta_quant_table[9] = 0, /* offset */ { +0.000000e+000f, +5.937500e-002f, +1.375000e-001f, +2.343750e-001f, +3.500000e-001f, +4.843750e-001f, +6.375000e-001f, +8.093750e-001f, +1.000000e+000f } /* data */ } -}; +}; \ No newline at end of file diff --git a/lib_com/ivas_sns_com_fx.c b/lib_com/ivas_sns_com_fx.c index d053e957f..9e83cd240 100644 --- a/lib_com/ivas_sns_com_fx.c +++ b/lib_com/ivas_sns_com_fx.c @@ -280,14 +280,14 @@ void sns_interpolate_scalefactors_fx( FOR( n = 0; n <= M - 2; n++ ) { - scf_int[add( n * 4, 2 )] = L_add( scf[n], Mpy_32_16_1( L_sub( scf[n + 1], scf[n] ), 4096 ) ); /* 4096 -> 1/8 in Q15 */ - scf_int[add( n * 4, 3 )] = L_add( scf[n], Mpy_32_16_1( L_sub( scf[n + 1], scf[n] ), 12288 ) ); /* 12288 -> 3/8 in Q15 */ - scf_int[add( n * 4, 4 )] = L_add( scf[n], Mpy_32_16_1( L_sub( scf[n + 1], scf[n] ), 20480 ) ); /* 20480 -> 5/8 in Q15 */ - scf_int[add( n * 4, 5 )] = L_add( scf[n], Mpy_32_16_1( L_sub( scf[n + 1], scf[n] ), 28672 ) ); /* 28672 -> 7/8 in Q15 */ + scf_int[add( n * 4, 2 )] = Madd_32_16( scf[n], L_sub( scf[n + 1], scf[n] ), 4096 ); /* 4096 -> 1/8 in Q15 */ + scf_int[add( n * 4, 3 )] = Madd_32_16( scf[n], L_sub( scf[n + 1], scf[n] ), 12288 ); /* 12288 -> 3/8 in Q15 */ + scf_int[add( n * 4, 4 )] = Madd_32_16( scf[n], L_sub( scf[n + 1], scf[n] ), 20480 ); /* 20480 -> 5/8 in Q15 */ + scf_int[add( n * 4, 5 )] = Madd_32_16( scf[n], L_sub( scf[n + 1], scf[n] ), 28672 ); /* 28672 -> 7/8 in Q15 */ } - scf_int[FDNS_NPTS - 2] = L_add( scf[M - 1], Mpy_32_16_1( L_sub( scf[M - 1], scf[M - 2] ), 4096 ) ); - scf_int[FDNS_NPTS - 1] = L_add( scf[M - 1], Mpy_32_16_1( L_sub( scf[M - 1], scf[M - 2] ), 12288 ) ); + scf_int[FDNS_NPTS - 2] = Madd_32_16( scf[M - 1], L_sub( scf[M - 1], scf[M - 2] ), 4096 ); + scf_int[FDNS_NPTS - 1] = Madd_32_16( scf[M - 1], L_sub( scf[M - 1], scf[M - 2] ), 12288 ); /* Inversion at encoder-side */ IF( encoder_side == ENC ) diff --git a/lib_com/ivas_stereo_ica_com_fx.c b/lib_com/ivas_stereo_ica_com_fx.c index 6ffce03e4..d96d64c7c 100644 --- a/lib_com/ivas_stereo_ica_com_fx.c +++ b/lib_com/ivas_stereo_ica_com_fx.c @@ -397,4 +397,4 @@ void adjustTargetSignal_fx( return; } -#endif +#endif \ No newline at end of file diff --git a/lib_com/prot.h b/lib_com/prot.h index 54444a92b..96bdd1952 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -4201,12 +4201,21 @@ void AVQ_encmux( int16_t trgtSvPos /* i : target SV for AVQ bit savings */ ); +#ifndef IVAS_FLOAT_FIXED void ordr_esti( const int16_t k, /* i : sub-vector index */ int16_t *Mpos, /* i/o: dominant sub-vector position from ACV */ int16_t svOrder[], /* i/o: AVQ sub-vector order */ const int16_t Nsv /* i : total sub-vectors in a sub-frames */ ); +#else +void ordr_esti( + const Word16 k, /* i : sub-vector index */ + Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ + Word16 svOrder[], /* i/o: AVQ sub-vector order */ + const Word16 Nsv /* i : total sub-vectors in a sub-frames */ +); +#endif void re8_cod( int16_t x[], /* i : point in RE8 (8-dimensional integer vector) */ @@ -7907,7 +7916,7 @@ void powfp_odd2_evs( Word16 *pout2 /* Q15 */ ); -void tcx_arith_scale_envelope_flt( +void tcx_arith_scale_envelope_ivas( const Word16 L_spec_core, /* i : number of lines to scale Q0 */ Word16 L_frame, /* i : number of lines Q0 */ const Word32 env[], /* i : unscaled envelope Q16 */ @@ -7917,7 +7926,7 @@ void tcx_arith_scale_envelope_flt( Word16 *s_env_e /* o : scaled envelope exponent Q0 */ ); -void tcx_arith_render_envelope_flt( +void tcx_arith_render_envelope_ivas( const Word16 A_ind[], /* i : LPC coefficients of signal envelope */ const Word16 L_frame, /* i : number of spectral lines */ const Word16 L_spec, /* i : length of the coded spectrum */ @@ -9049,7 +9058,6 @@ void SynthesisSTFT_flt( #ifdef IVAS_FLOAT_FIXED void SynthesisSTFT_fx( Word32 *fftBuffer, /* i : FFT bins */ - Word16 Q_in, Word32 *timeDomainOutput, Word32 *olapBuffer, const Word16 *olapWin, diff --git a/lib_com/prot_fx1.h b/lib_com/prot_fx1.h index d560a67a7..b7867429b 100644 --- a/lib_com/prot_fx1.h +++ b/lib_com/prot_fx1.h @@ -93,6 +93,12 @@ void Copy32( const Word16 L /* i : vector length */ ); +void set8_fx( + Word8 y[], /* i/o: Vector to set */ + const Word8 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ +); + 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/prot_fx2.h b/lib_com/prot_fx2.h index 4f0a2cbbc..fc488f233 100644 --- a/lib_com/prot_fx2.h +++ b/lib_com/prot_fx2.h @@ -144,6 +144,12 @@ void Vr_add( Word16 Len /* i : Vector lenght */ ); +void set8_fx( + Word8 y[], /* i/o: Vector to set */ + const Word8 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ +); + void set16_fx( Word16 y[], /* i/o: Vector to set */ const Word16 a, /* i : Value to set the vector to */ @@ -2762,7 +2768,7 @@ void ScaleShapedSHB_fx( Word16 prev_Q_bwe_syn2 ); void ScaleShapedSHB_32( - const int16_t length, /* i : SHB overlap length */ + const Word16 length, /* i : SHB overlap length */ Word32 *synSHB_fx, /* i/o: synthesized shb signal Qx */ Word32 *overlap_fx, /* i/o: buffer for overlap-add Qx */ const Word16 *subgain_fx, /* i : subframe gain Q15 */ diff --git a/lib_com/stat_noise_uv_mod_fx.c b/lib_com/stat_noise_uv_mod_fx.c index 8d8949758..4d3badffc 100644 --- a/lib_com/stat_noise_uv_mod_fx.c +++ b/lib_com/stat_noise_uv_mod_fx.c @@ -77,6 +77,7 @@ void stat_noise_uv_mod_fx( Word16 Exc2_local[L_FRAME]; /* local_copy in scaled Q_local*/ #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif /*---------------------------------------------------------* @@ -188,7 +189,7 @@ void stat_noise_uv_mod_fx( ELSE { *uv_count = s_min( *uv_count, FULL_NG ); - + move16(); tmp_nom = sub( *uv_count, START_NG ); tmp_den = sub( FULL_NG, START_NG ); tmp_shift = norm_s( tmp_den ); @@ -228,6 +229,7 @@ void stat_noise_uv_mod_fx( IF( EQ_16( *uv_count, 1 ) ) { *ge_sm = L_shr( L_Ge, Q_local ); + move32(); } ELSE { @@ -300,8 +302,10 @@ void stat_noise_uv_mod_fx( L_tmp = L_add( L_tmp3, L_shl( Mult_32_16( L_tmp, tmp_res ), 1 ) ); /* Q_local+16+14-15+1 */ #endif Exc2_local[i] = extract_h( L_tmp ); /*Q_local */ + move16(); } - *Q_stat_noise = Q_local; /* update for next call, routine can only be called once every frame */ + *Q_stat_noise = Q_local; /* update for next call, routine can only be called once every frame */ + move16(); Qdiff = sub( Q_exc, Q_local ); /* local excitation and incoming excitation */ Scale_sig( Exc2_local, L_FRAME, Qdiff ); Copy( Exc2_local, exc2, L_FRAME ); @@ -376,7 +380,6 @@ static Word16 calc_tilt_fx( /* o : Excitation tilt Q15*/ r0 = L_deposit_l( 0 ); r1 = L_deposit_l( 0 ); xi = shr( x[0], Q_shift ); - move16(); FOR( i = 0; i < len - 1; i++ ) { @@ -403,7 +406,6 @@ static Word16 calc_tilt_fx( /* o : Excitation tilt Q15*/ } tmp_shift = norm_l( r0 ); - move16(); r0 = L_shl( r0, tmp_shift ); tmp_sign = 1; move16(); diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index f194355bf..ff4f55f9f 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -81,8 +81,10 @@ Word16 WB_BWE_gain_pred_fx( Word32 enerL; Word16 n_freq, mode, pitch; Word16 ener_var_flag = 0; + move16(); Word16 voice_factor, enerL_16, enerL_40, enerL_64; Word16 env_var_flag = 0; + move16(); Word16 exp; Word16 tmp, tmp1; Word32 L_tmp; @@ -128,7 +130,7 @@ Word16 WB_BWE_gain_pred_fx( voice_factor = extract_l( L_shr( L_tmp, 2 ) ); /*Q13 */ Copy_Scale_sig( pitch_buf, pitch_buf_tmp, 4, -1 ); pitch = sum16_fx( pitch_buf_tmp, 4 ); - move16(); /*Q5 */ + /*Q5 */ L_tmp = L_shr( enerL, 4 ); test(); @@ -201,6 +203,7 @@ Word16 WB_BWE_gain_pred_fx( #ifdef BASOP_NOGLOB WB_fenv[0] = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 12 ) ) ); /* Q3 */ + move16(); #else WB_fenv[0] = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* Q3 */ #endif @@ -252,12 +255,14 @@ Word16 WB_BWE_gain_pred_fx( tmp = s_min( tmp, 16384 ); L_tmp = L_shr( L_mult0( tmp, WB_fenv[0] ), 12 ); /*Q15 */ WB_fenv[0] = extract_l( L_tmp ); /*Q3 */ + move16(); } IF( GT_16( WB_fenv[0], prev_WB_fenv ) ) { /*WB_fenv[0]= add(mult_r(9830, WB_fenv[0]), mult_r(22938, prev_WB_fenv)); move16();//Q3 */ WB_fenv[0] = round_fx( L_mac( L_mult( 9830, WB_fenv[0] ), 22938, prev_WB_fenv ) ); /*Q3 */ + move16(); } } @@ -308,11 +313,12 @@ Word16 WB_BWE_gain_pred_fx( tmp = s_min( tmp, 16384 ); L_tmp = L_shr( L_mult0( tmp, WB_fenv[0] ), 12 ); /*Q3 */ WB_fenv[0] = extract_l( L_tmp ); /*Q3 */ - + move16(); IF( GT_16( WB_fenv[0], prev_WB_fenv ) ) { /*WB_fenv[0] = add(mult_r(9830, WB_fenv[0]), mult_r(22938, prev_WB_fenv));//Q3 */ WB_fenv[0] = round_fx( L_mac( L_mult( 9830, WB_fenv[0] ), 22938, prev_WB_fenv ) ); /*Q3 */ + move16(); } } @@ -332,12 +338,14 @@ Word16 WB_BWE_gain_pred_fx( L_tmp = L_mult( WB_fenv[0], tmp ); /*Q(21-exp) */ WB_fenv[0] = round_fx( L_shl( L_tmp, sub( exp, 2 ) ) ); /*Q3 */ - tmp1 = mult_r( 328, pitch ); /*Q7 */ - tmp = s_min( s_max( tmp1, 16 ), 256 ); /*Q7 */ - L_tmp = L_shr( L_mult0( WB_fenv[0], tmp ), 7 ); /*Q3 */ - /*WB_fenv[0] = saturate(L_tmp); //Q3 */ + move16(); + tmp1 = mult_r( 328, pitch ); /*Q7 */ + tmp = s_min( s_max( tmp1, 16 ), 256 ); /*Q7 */ + L_tmp = L_shr( L_mult0( WB_fenv[0], tmp ), 7 ); /*Q3 */ + /*WB_fenv[0] = saturate(L_tmp); //Q3 */ #ifdef BASOP_NOGLOB WB_fenv[0] = round_fx_sat( L_shl_sat( L_tmp, 16 ) ); /*Q3 */ + move16(); #else WB_fenv[0] = round_fx( L_shl( L_tmp, 16 ) ); /*Q3 */ #endif @@ -347,11 +355,13 @@ Word16 WB_BWE_gain_pred_fx( { /*WB_fenv[0]= add(mult_r(29491, last_wb_bwe_ener), mult_r(3277, WB_fenv[0]));//Q3 */ WB_fenv[0] = round_fx( L_mac( L_mult( 29491, last_wb_bwe_ener ), 3277, WB_fenv[0] ) ); /*Q3 */ + move16(); } IF( NE_16( last_extl_fx, WB_BWE ) && LT_16( tilt_wb_fx, 128 ) ) { WB_fenv[0] = mult_r( s_min( 16384, shl( tilt_wb_fx, 8 ) ), WB_fenv[0] ); + move16(); } IF( env_var_flag == 1 ) @@ -620,6 +630,7 @@ Word32 calc_tilt_bwe_fx( /* o : Tilt in Q24 */ Word16 exp2; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif BASOP_SATURATE_WARNING_OFF_EVS @@ -742,18 +753,17 @@ Word16 ivas_calc_tilt_bwe_fx( /* o : Tilt in Q24 */ Word32 L_ener, L_ener_tot, L_temp; Word32 tmp1, tmp2; Word16 sign = 0; + move16(); const Word32 *ptr; Word16 exp2, tmp_exp; BASOP_SATURATE_WARNING_OFF_EVS /* this is required for adaptative precision energy summation loop, do not remove */ - move16(); exp2 = 0; move16(); - ptr = sp; - move16(); + L_ener_tot = L_deposit_l( 1 ); /* Divide Frame Length by 32 */ @@ -796,6 +806,7 @@ Word16 ivas_calc_tilt_bwe_fx( /* o : Tilt in Q24 */ } L_temp = L_ener_tot; + move32(); tmp_exp = sub( Q31, sub( shl( exp_sp, 1 ), Q31 ) ); L_temp = Sqrt32( L_temp, &tmp_exp ); L_temp = L_shl( L_temp, sub( exp_sp, sub( Q31, tmp_exp ) ) ); @@ -805,6 +816,7 @@ Word16 ivas_calc_tilt_bwe_fx( /* o : Tilt in Q24 */ IF( GT_16( sub( exp2, 4 ), norm_l( L_temp ) ) ) { L_temp = MAX_16; + move32(); } ELSE { @@ -833,7 +845,6 @@ void calc_norm_envelop_fx( Word16 i, lookback, env_index, n_freq, n_lag_now, n_lag, tmp; lookback = shr( L_swb_norm, 1 ); - move16(); env_index = add( swb_bwe_subband[0], st_offset ); n_lag_now = L_swb_norm; move16(); @@ -937,6 +948,8 @@ void WB_BWE_decoding_fx( Word16 alfa, beta; Word16 flag = 0; Word16 core_type = 1; + move16(); + move16(); Word16 tmp, tmp1, exp, tmp2; Word32 L_tmp, L_tmp1, L_tmp2; Word32 prev_ener_alpha, prev_ener_beta; @@ -984,6 +997,7 @@ void WB_BWE_decoding_fx( FOR( n_freq = swb_bwe_subband[0]; n_freq < swb_bwe_subband[4]; n_freq++ ) { signum[n_freq] = 1; + move16(); IF( WB_signal[n_freq] < 0 ) { signum[n_freq] = -1; @@ -996,10 +1010,12 @@ void WB_BWE_decoding_fx( L_tmp1 = L_deposit_l( WB_signal[n_freq] ); /* Q_syn */ L_tmp = L_sub( L_tmp1, L_tmp ); /* Q_syn */ WB_signal[n_freq] = extract_l( L_tmp ); /* Q_syn */ + move16(); IF( L_tmp > 0 ) { tmp = sub( 18022, weight ); /* Q15 */ WB_signal[n_freq] = extract_l( Mult_32_16( L_tmp, tmp ) ); /* Q_syn */ + move16(); } IF( NE_16( signum[n_freq], 1 ) ) @@ -1021,6 +1037,7 @@ void WB_BWE_decoding_fx( tmp = div_s( 16384, tmp ); L_tmp = L_shr( L_mult0( WB_signal[n_freq], tmp ), add( exp, Q_syn ) ); /*Q15 */ WB_signal[n_freq] = extract_l( L_tmp ); /*Q15 */ + move16(); } ELSE { @@ -1188,15 +1205,19 @@ void WB_BWE_decoding_fx( { /*wfenv[0]= add(mult_r(9830, WB_fenv[0]), mult_r(22938, prev_WB_fenv[0]));//Q3 */ wfenv[0] = round_fx( L_mac( L_mult( 9830, WB_fenv[0] ), 22938, prev_WB_fenv[0] ) ); /*Q3 */ + move16(); /*wfenv[1]= add(mult_r(9830, WB_fenv[1]), mult_r(22938, prev_WB_fenv[1]));//Q3 */ wfenv[1] = round_fx( L_mac( L_mult( 9830, WB_fenv[1] ), 22938, prev_WB_fenv[1] ) ); /*Q3 */ + move16(); } ELSE { /*wfenv[0]= add(mult_r(16384,WB_fenv[0]),mult_r(16384,prev_WB_fenv[0]));//Q3 */ wfenv[0] = round_fx( L_mac( L_mult( 16384, WB_fenv[0] ), 16384, prev_WB_fenv[0] ) ); /*Q3 */ + move16(); /*wfenv[1]= add(mult_r(13108,WB_fenv[1]),mult_r(13108,prev_WB_fenv[1]));//Q3 */ wfenv[1] = round_fx( L_mac( L_mult( 13108, WB_fenv[1] ), 13108, prev_WB_fenv[1] ) ); /*Q3 */ + move16(); } } ELSE IF( EQ_16( last_extl, WB_BWE ) && LT_32( L_tmp1, L_tmp2 ) && GT_16( WB_fenv[0], prev_WB_fenv[0] ) && @@ -1204,16 +1225,20 @@ void WB_BWE_decoding_fx( { /*wfenv[0]= add(mult_r(9830,WB_fenv[0]),mult_r(22938,prev_WB_fenv[0]));//Q3 */ wfenv[0] = round_fx( L_mac( L_mult( 9830, WB_fenv[0] ), 22938, prev_WB_fenv[0] ) ); /*Q3 */ + move16(); /*wfenv[1]= add(mult_r(9830,WB_fenv[1]),mult_r(22938,prev_WB_fenv[1]));//Q3 */ wfenv[1] = round_fx( L_mac( L_mult( 9830, WB_fenv[1] ), 22938, prev_WB_fenv[1] ) ); /*Q3 */ + move16(); } ELSE IF( EQ_16( last_extl, WB_BWE ) && GT_32( EnergyL, prev_ener_alpha ) && GT_32( prev_ener_beta, EnergyL ) && NE_16( prev_coder_type, UNVOICED ) ) { /*wfenv[0] = add(shr(WB_fenv[0],1), shr(prev_WB_fenv[0],1));//Q3 */ wfenv[0] = round_fx( L_mac( L_mult( WB_fenv[0], 16384 ), prev_WB_fenv[0], 16384 ) ); /*Q3 */ + move16(); /*wfenv[1] = add(shr(WB_fenv[1],1), shr(prev_WB_fenv[1],1));//Q3 */ wfenv[1] = round_fx( L_mac( L_mult( WB_fenv[1], 16384 ), prev_WB_fenv[1], 16384 ) ); /*Q3 */ + move16(); } ELSE { @@ -1309,6 +1334,7 @@ void WB_BWE_decoding_fx( move32(); } *Q_syn_hb = add( Q_syn, add( tmp, 3 ) ); + move16(); return; } @@ -1475,6 +1501,7 @@ void SWB_BWE_decoding_fx( tmp = div_s( 16384, tmp ); /*Q(15+exp) */ L_tmp = L_shr( L_mult0( SWB_signal[n_freq], tmp ), add( exp, Q_syn ) ); /*Q15 */ SWB_signal[n_freq] = extract_l( L_tmp ); /*Q15 */ + move16(); } ELSE { @@ -1535,12 +1562,14 @@ void SWB_BWE_decoding_fx( { L_tmp = L_mult( SWB_fenv[n_band / 4], SWB_fenv[n_band / 4] ); /*Q3 */ prev_SWB_fenv[n_band] = round_fx( L_shl( L_tmp, 14 ) ); /*Q1 */ + move16(); } FOR( n_band = 0; n_band < 6; n_band++ ) { L_tmp = L_mult( SWB_fenv[2 + n_band / 3], SWB_fenv[2 + n_band / 3] ); /*Q3 */ prev_SWB_fenv[8 + n_band] = round_fx( L_shl( L_tmp, 14 ) ); /*Q1 */ + move16(); } *prev_weight = 16384; @@ -1582,6 +1611,7 @@ void SWB_BWE_decoding_fx( FOR( n_band = 0; n_band < SWB_FENV; n_band++ ) { SWB_fenv[n_band] = mult_r( SWB_fenv[n_band], 6554 ); + move16(); } fenvL_16 = mult_r( fenvL_16, 6554 ); } @@ -1611,6 +1641,7 @@ void SWB_BWE_decoding_fx( FOR( n_freq = add( swb_bwe_subband[0], st_offset ); n_freq < tmp; n_freq++ ) { *Seed = extract_l( L_mac0( 20101L, 12345, *Seed ) ); + move16(); SWB_signal[n_freq] = mult_r( *Seed, 32767 ); move16(); /*Q15 */ } @@ -1693,7 +1724,7 @@ void SWB_BWE_decoding_fx( } pit1 = &SWB_signal[367 + st_offset]; - move16(); + IF( GT_16( mult_r( tmp1, 6554 ), tmp2 ) ) { /*20480 = 5 in Q12 */ @@ -1704,6 +1735,7 @@ void SWB_BWE_decoding_fx( #else *pit1 = round_fx( L_shl( L_mult( *pit1, tmp3 ), 3 ) ); /*Q_syn */ #endif + move16(); pit1--; } } @@ -1716,7 +1748,6 @@ void SWB_BWE_decoding_fx( tmp2 = add( add( abs_s( SWB_signal[492 + st_offset] ), abs_s( SWB_signal[493 + st_offset] ) ), add( abs_s( SWB_signal[494 + st_offset] ), abs_s( SWB_signal[495 + st_offset] ) ) ); #endif pit1 = &SWB_signal[496 + st_offset]; - move16(); test(); IF( ( tmp2 == 0 ) || ( LT_16( tmp2, mult_r( tmp1, 9830 ) ) ) ) @@ -1775,6 +1806,7 @@ void SWB_BWE_decoding_fx( { L_tmp = Mult_32_16( L_tmp3, *pit1 ); /*Q(16-exp) */ *pit1-- = round_fx( L_shl( L_tmp, exp ) ); /*Q_syn */ + move16(); L_tmp3 = L_sub( L_tmp3, L_tmp4 ); } @@ -1807,6 +1839,7 @@ void SWB_BWE_decoding_fx( FOR( n_freq = L; n_freq < swb_bwe_subband[SWB_FENV] + st_offset; n_freq++ ) { signum[n_freq] = 1; + move16(); IF( SWB_signal[n_freq] < 0 ) { signum[n_freq] = -1; @@ -1827,7 +1860,7 @@ void SWB_BWE_decoding_fx( { SWB_signal[n_freq] = extract_l( L_tmp ); /* Q_syn */ } - + move16(); IF( NE_16( signum[n_freq], 1 ) ) { SWB_signal[n_freq] = negate( SWB_signal[n_freq] ); @@ -1843,7 +1876,8 @@ void SWB_BWE_decoding_fx( exp = sub( sub( 30, exp ), Q_syn ); tmp = div_s( 16384, tmp ); /* Q(15+exp) */ L_tmp = L_shr( L_mult0( SWB_signal[n_freq], tmp ), add( exp, Q_syn ) ); /* Q15 */ - SWB_signal[n_freq] = extract_l( L_tmp ); /* Q15 */ + SWB_signal[n_freq] = extract_l( L_tmp ); + move16(); /* Q15 */ } ELSE { @@ -1852,6 +1886,7 @@ void SWB_BWE_decoding_fx( } } *prev_weight = weight; + move16(); } ELSE { @@ -1859,6 +1894,7 @@ ELSE tmp = shl( div_s( shl( 1, sub( 14, exp ) ), L_swb_norm ), sub( exp, 14 ) ); /* Q15 */ tmp = add( shl( tmp, 1 ), tmp ); *prev_weight = s_max( s_min( tmp, 16384 ), 6554 ); /* Q15 */ + move16(); } IF( EQ_16( mode, HARMONIC ) ) @@ -1875,7 +1911,6 @@ IF( EQ_16( mode, HARMONIC ) ) } mean = extract_l( Mult_32_16( L_mean, 2048 ) ); /*Q15 */ pit1 -= 16; - move16(); FOR( n_freq = 0; n_freq < 16; n_freq++ ) { if ( LT_16( abs_s( *pit1 ), mean ) ) @@ -1921,6 +1956,7 @@ FOR( n_band = 0; n_band < SWB_FENV; n_band += L ) FOR( n_freq = add( swb_bwe_subband[n_band], st_offset ); n_freq < tmp; n_freq++ ) { SWB_signal_32[n_freq] = L_shl( L_mult( tmp_ener, SWB_signal[n_freq] ), tmp_exp ); /*Qsyn */ + move32(); } } ELSE @@ -2120,7 +2156,6 @@ void time_envelop_shaping_fx( Word32 L_tmp; pit = werr; - move16(); exp_L = norm_s( L ); inv_L = div_s( shl( 1, sub( 14, exp_L ) ), L ); /*Q(29-exp_L) */ FOR( i = 0; i < SWB_TENV; i++ ) @@ -2189,6 +2224,7 @@ void time_envelop_shaping_fx( #else *pit = round_fx( L_shl( L_mult( tmp, *pit ), sub( exp, 1 ) ) ); /*Q(13-exp+1)->Q(14-exp)->Qsyn-3 */ #endif + move16(); pit++; } } @@ -2270,7 +2306,6 @@ void time_reduce_pre_echo_fx( FOR( i = 0; i < 3; i++ ) { L_tmp = Mult_32_16( energyL[i], 29491 ); /*Q14 */ - test(); IF( GT_32( L_shr( energyL[i + 1], 1 ), L_tmp ) && GT_32( energyL[i + 1], 1638400 ) ) { pos = add( i, 1 ); @@ -2287,7 +2322,6 @@ void time_reduce_pre_echo_fx( } energy = L_deposit_l( 0 ); j = i_mult( L, pos ); - move16(); FOR( i = 0; i < j; i++ ) { #ifdef BASOP_NOGLOB @@ -2340,6 +2374,7 @@ void time_reduce_pre_echo_fx( #else error[i] = round_fx( L_shl( Mult_32_16( L_tmp, error[i] ), tmp_exp ) ); /*Q(30-exp+1-16)->Q(15-exp)->Q_synth */ #endif + move16(); } energy = L_deposit_l( 0 ); @@ -2394,6 +2429,7 @@ void time_reduce_pre_echo_fx( tmp = round_fx( L_shl( Mult_32_16( L_tmp, *pit ), add( 1, exp ) ) ); /*Q0 */ #endif *pit++ = tmp; + move16(); } } @@ -2519,6 +2555,7 @@ void calc_normal_length_fx_32( *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(); + move16(); } return; @@ -2700,6 +2737,7 @@ void hq_generic_decoding_fx( IF( EQ_16( tmp, 0 ) ) { nband_lf = 0; + move16(); } ELSE { diff --git a/lib_com/swb_bwe_com_lr_fx.c b/lib_com/swb_bwe_com_lr_fx.c index 738cff591..386db3433 100644 --- a/lib_com/swb_bwe_com_lr_fx.c +++ b/lib_com/swb_bwe_com_lr_fx.c @@ -87,12 +87,14 @@ static void est_freq_har_decis_fx( ) { Word16 temp_hfe2 = 0; + move16(); Word16 har_freq_est2_2; Word16 prev_frm_hfe2_2; IF( k != 0 ) { *har_freq_est1 = div_s_ss( sharp, k ); + move16(); } test(); @@ -100,6 +102,7 @@ static void est_freq_har_decis_fx( IF( GT_16( k1, 1 ) ) { *har_freq_est2 = div_s_ss( sharp1, k1 ); + move16(); } ELSE IF( LT_16( k1, 2 ) && ( k2 != 0 || GT_16( k, 1 ) ) ) { @@ -257,6 +260,7 @@ Word16 har_est_fx( FOR( i = N; i < temp; i++ ) { L_input_abs[i] = L_deposit_l( 0 ); + move16(); } q = start_pos; @@ -315,6 +319,7 @@ Word16 har_est_fx( IF( GT_32( *p_L_blk_peak, *pm1_L_blk_peak ) ) { *pm1_L_blk_peak = L_deposit_l( 0 ); + move32(); *pm1_blk_peak_pos = 0; move16(); } @@ -325,6 +330,7 @@ Word16 har_est_fx( *p_blk_peak_pos = *pm1_blk_peak_pos; move16(); *pm1_L_blk_peak = L_deposit_l( 0 ); + move32(); *pm1_blk_peak_pos = 0; move16(); } @@ -569,7 +575,6 @@ Word16 har_est_fx( blk_peak_pos_hfsb2[ct_hfsb2] = blk_peak_pos_te[i]; move16(); ct_hfsb2 = add( ct_hfsb2, 1 ); - move16(); } } @@ -580,9 +585,11 @@ Word16 har_est_fx( FOR( i = 1; i < ct_hfsb2; i++ ) { diff_peak_pos_hfsb2[i - 1] = sub( blk_peak_pos_hfsb2[i], blk_peak_pos_hfsb2[i - 1] ); + move16(); sum_diff = add( sum_diff, diff_peak_pos_hfsb2[i - 1] ); } *har_freq_est2 = div_s_ss( sum_diff, ct_hfsb2 ); + move16(); } ELSE { @@ -648,7 +655,7 @@ void genhf_noise_fx( FOR( k = 0; k < 2; k++ ) { nlags[k] = shl( 1, bits_lagIndices_mode0_Har[k] ); - + move16(); l = 0; move16(); WHILE( LT_16( st_last_peakpos, add( fLenLow, subband_offsets[k] ) ) ) @@ -665,7 +672,7 @@ void genhf_noise_fx( FOR( j = 0; j < sbWidth[k]; j++ ) { L_xSynth_har[j] = L_shl( L_deposit_l( noise_flr_fx[st_pos + j] ), sub( QsL, Qss ) ); - + move32(); L_tmpbuf[j] = L_xSynth_har[j]; move32(); IF( predBuf_fx[st_pos + j] != 0x0 ) @@ -692,6 +699,7 @@ void genhf_noise_fx( /*xSynth_har[ii] = noise_flr[j];*/ L_xSynth_har[ii] = L_shl( L_deposit_l( noise_flr_fx[j] ), sub( QsL, Qss ) ); + move32(); L_tmpbuf[ii] = L_xSynth_har[ii]; move32(); IF( predBuf_fx[j] != 0x0 ) @@ -749,6 +757,8 @@ void genhf_noise_fx( { st_last_peakpos = add( st_last_peakpos, har_freq_est2 ); } + test(); + test(); WHILE( LT_16( st_last_peakpos, hfband_end[k] ) && LT_16( pul_res[k], pul_res[2 - l] ) && LE_16( l, 2 ) ) { test(); @@ -813,7 +823,7 @@ static void SmoothSpec_fx( lo = L_Extract_lc( L_sum, &hi ); *outBuf++ = round_fx( L_shl( Mpy_32_16( hi, lo, inItems ), 16 ) ); /* Q(8+15+1-16)=Q8 -> Q(8+16-16)=Q8 */ - + move16(); L_sum = L_mac0( L_sum, 0x0001, *newPtr++ ); /* nItems += 2, * only used value is 5 --> @@ -831,6 +841,7 @@ static void SmoothSpec_fx( lo = L_Extract_lc( L_sum, &hi ); /* 4681 (in Q15) = 0.1428 = 1/7 */ *outBuf++ = round_fx( L_shl( Mpy_32_16( hi, lo, 4681 ), 16 ) ); /* Q(8+15+1-16)=Q8 -> Q(8+16-16)=Q8 */ + move16(); i = add( i, 1 ); /*-- Moving average. --*/ @@ -843,6 +854,7 @@ static void SmoothSpec_fx( lo = L_Extract_lc( L_sum, &hi ); /* 4681 (in Q15) = 0.1428 = 1/7 */ *outBuf++ = round_fx( L_shl( Mpy_32_16( hi, lo, 4681 ), 16 ) ); /* Q(8+15+1-16)=Q8 -> Q(8+16-16)=Q8 */ + move16(); inBuf++; } @@ -921,10 +933,11 @@ void SpectrumSmoothing_fx( Word16 exp_norm; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif *Qss = 10; - + move16(); num_subband_smooth_pre_fx = mult( fLen, 21845 ); /* 1/L_SB = 1/12 = 21845(Q18) Q = exp_normn-18 */ num_subband_smooth_fx = shr( num_subband_smooth_pre_fx, 18 - 15 ); IF( NE_16( num_subband_smooth_pre_fx, shl( num_subband_smooth_fx, 18 - 15 ) ) ) @@ -943,14 +956,17 @@ void SpectrumSmoothing_fx( FOR( i = fLen; i < fLen + ( num_subband_smooth_fx * L_SB - fLen ); i++ ) { L_inBuf_pss[i] = L_deposit_l( 0 ); + move32(); outBuf_pss_fx[i] = 0; move16(); } j = 0; + move16(); FOR( i = 0; i < num_subband_smooth_fx; i++ ) { L_max_val[i] = L_deposit_l( 0 ); + move32(); FOR( k = 0; k < L_SB; k++ ) { L_inBuf_abs = L_abs( L_inBuf_pss[j] ); @@ -966,6 +982,7 @@ void SpectrumSmoothing_fx( /* convert to maximum amplitude frequency log scale envelope */ j = 0; + move16(); FOR( i = 0; i < num_subband_smooth_fx; i++ ) { /* max_val_norm = 10.0f / (max_val[i] + 0.001f); */ @@ -1017,6 +1034,7 @@ void SpectrumSmoothing_fx( #else outBuf_pss_fx[j] = negate( round_fx( L_shl( Mpy_32_16_r( L_shl( L_abs( L_inBuf_pss[j] ), exp_norm ), max_val_norm_fx ), sub( exp_shift, exp_norm ) ) ) ); #endif + move16(); } } ELSE @@ -1154,6 +1172,7 @@ void Get20Log10Spec_fx( L_tmp = Mpy_32_16_1( L_tmp, 24660 ); /* 6.0206 in Q12 */ L_tmp = L_shl( L_tmp, 2 + 8 ); /* Q7 */ *outBuf_fx++ = round_fx( L_tmp ); + move16(); } return; @@ -1318,9 +1337,11 @@ void SpectrumSmoothing_nss_fx( Word16 exp_shift; L_tmp[0] = L_deposit_l( 0 ); + move32(); FOR( i = 0; i < fLen; i++ ) { L_tmp[0] = L_or( L_tmp[0], L_abs( L_inBuf[i] ) ); + move32(); } exp_norm = norm_l( L_tmp[0] ); Qm = sub( exp_norm, 4 ); /* Qm = sub(add(12, exp_norm), 16); */ @@ -1330,6 +1351,7 @@ void SpectrumSmoothing_nss_fx( L_tmp[i] = L_shl( L_inBuf[i], exp_norm ); /* Q(12+exp_norm) */ move32(); inBuf_fx[i] = round_fx( L_tmp[i] ); /* Qm */ + move16(); } num_subband_smooth_fx = shr( fLen, 3 ); /* L_SB_NSS=8 shr(target, 3); */ @@ -1404,7 +1426,8 @@ void SpectrumSmoothing_nss_fx( { L_temp_sum_1[i] = L_deposit_l( 0 ); L_temp_sum_2[i] = L_deposit_l( 0 ); - + move32(); + move32(); FOR( k = 0; k < L_SB_NSS_HALF; k++ ) { L_temp_sum_1[i] = L_add( L_temp_sum_1[i], extract_l( abs_s( inBufw_fx[k + L_SB_NSS * i] ) ) ); /* Qm */ @@ -1444,7 +1467,9 @@ void SpectrumSmoothing_nss_fx( L_temp1 = L_negate( L_temp1 ); temp_lo = L_Extract_lc( L_temp1, &temp_hi ); Qsumdiv[i] = sub( 14, temp_hi ); + move16(); temp_sum_div_fx[i] = extract_l( Pow2( 14, temp_lo ) ); /* Qsumdiv[i] */ + move16(); exp_norm = norm_s( temp_sum_div_fx[i] ); temp_sum_div_fx[i] = shl( temp_sum_div_fx[i], exp_norm ); move16(); @@ -1457,6 +1482,7 @@ void SpectrumSmoothing_nss_fx( FOR( i = 0; i < num_subband_smooth_fx; i++ ) { Qo[i] = add( add( Qm, Qsumdiv[i] ), 1 ); + move16(); L_temp1 = 0x0L; FOR( k = 0; k < L_SB_NSS; k++ ) { @@ -1489,6 +1515,7 @@ void SpectrumSmoothing_nss_fx( L_outBufw[k + L_SB_NSS * i] = L_shl( L_outBufw[k + L_SB_NSS * i], exp_shift ); move16(); outBufw_fx[k + L_SB_NSS * i] = round_fx( L_outBufw[k + L_SB_NSS * i] ); + move16(); } } *Qss = sub( *Qss, 16 ); @@ -1652,7 +1679,6 @@ void post_hq2_swb_fx( ELSE { k = sub( bands_fx, NB_SWB_SUBBANDS ); - move16(); } FOR( ; k < bands_fx; k++ ) @@ -1709,7 +1735,8 @@ void GetSynthesizedSpecThinOut_fx( { fLen_fx = sbWidth_fx[sb]; lag_fx = lagIndices_fx[sb]; - + move16(); + move16(); if ( GT_16( add( lag_fx, fLen_fx ), predBufLen_fx ) ) { /* should never happen */ @@ -1963,6 +1990,7 @@ void GetlagGains_fx( /* Sqrt part sqrt(pow (2.0f, band_energy[i])/lagEnergy) */ QlagGains[sb] = add( Qdiv, 16 ); + move16(); IF( s_and( Qdiv, 1 ) == 0 ) /* Qdiv % 2 == 0 */ { L_temp = Sqrt_l( L_shr( L_deposit_h( temp_fx ), 1 ), &exp_norm ); @@ -1970,6 +1998,7 @@ void GetlagGains_fx( QlagGains[sb] = sub( shr( QlagGains[sb], 1 ), 1 ); move16(); lagGains_fx[sb] = round_fx( L_temp ); + move16(); } ELSE { @@ -1978,6 +2007,7 @@ void GetlagGains_fx( QlagGains[sb] = shr( QlagGains[sb], 1 ); move16(); lagGains_fx[sb] = round_fx( L_temp ); + move16(); } } ELSE @@ -2022,6 +2052,7 @@ void noise_extr_corcod_fx( SpectrumSmoothing_nss_fx( L_spectra, sspectra_fx, &Qss_s, fLenLow_fx ); Copy( sspectra_fx, sspectra_ni_fx, fLenLow_fx ); tmp_fx = 0; + move16(); FOR( i = 0; i < fLenLow_fx; i++ ) { tmp_fx |= abs_s( sspectra_fx[i] ); @@ -2043,6 +2074,7 @@ void noise_extr_corcod_fx( } SpectrumSmoothing_nss_fx( L_spectra_diff, sspectra_diff_fx, &Qss_d, fLenLow_fx ); tmp_fx = 0; + move16(); FOR( i = 0; i < fLenLow_fx; i++ ) { tmp_fx |= abs_s( sspectra_diff_fx[i] ); @@ -2083,7 +2115,7 @@ void noise_extr_corcod_fx( /*Smoothing the noise components*/ br_adj_fx = 29491; /* br_adj = 0.9f; Q15 */ - + move16(); pulse_num_fx = 0; move16(); FOR( i = 0; i < fLenLow_fx; i++ ) @@ -2211,6 +2243,7 @@ void ton_ene_est_fx( #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif *QbeL = 3; @@ -2241,6 +2274,7 @@ void ton_ene_est_fx( QsN = sub( add( QsL, 11 ), 15 ); exp_safe = 4; /*move16();*/ + move16(); norm_vec_32_16_scale_fx( L_xSynth_har, QsN, fLenHigh, xSynth_har_fx, &QxSynth, exp_safe ); pos = 0; @@ -2302,6 +2336,7 @@ void ton_ene_est_fx( #else L_band_energy_Linear[i] = L_shl( L_band_energy_Linear[i], sub( *QbeL, exp_pow ) ); #endif + move32(); /* Div Part */ E_r_fx = 0x7fff; move16(); @@ -2320,7 +2355,7 @@ void ton_ene_est_fx( L_E = L_shl( L_E, sub( *QbeL, QE ) ); QE = *QbeL; - + move16(); /* 0.06=15729(Q18) */ exp_shift = sub( 18, QE_r ); #ifdef BASOP_NOGLOB @@ -2339,6 +2374,7 @@ void ton_ene_est_fx( sqrt_32n_16_fx( L_temp, Qtemp, &avg_pe_fx[k], &Qavg_pe[k] ); fac_fx = 19661; /* 0.6(Q15) */ + move16(); IF( pul_res_bnd[k] != 0 ) { /* Div Part */ @@ -2376,9 +2412,10 @@ void ton_ene_est_fx( Overflow = 0; move16(); ni_gain_fx[k] = shl( ni_gain_fx[k], sub( Qni_gain, Qavg_pe[k] ) ); + move16(); assert( Qni_gain == 8 ); /* 358 is '(short)(1.4*pow(2,Qni_gain))' */ ni_gain_fx[k] = s_max( ni_gain_fx[k], 358 ); /* 1.4 -> 22938(Q14) */ - + move16(); exp_shift = QsL - ( QxSynth + Qni_gain + 1 ); /* QsL - (QxSynth+Qni_gain+1) */ FOR( j = band_start[i]; j <= band_end[i]; j++ ) { @@ -2387,6 +2424,7 @@ void ton_ene_est_fx( } exp_safe = 4; /* move16(); */ + move16(); norm_vec_32_16_scale_fx( &L_xSynth_har[band_start[i] - fLenLow], QsL, band_width[i], &xSynth_har_fx[band_start[i] - fLenLow], &QxSynth_sft, exp_safe ); L_E = sum2_fx( &xSynth_har_fx[sub( band_start[i], fLenLow )], band_width[i] ); @@ -2398,6 +2436,7 @@ void ton_ene_est_fx( L_E = L_shl( L_E, sub( *QbeL, QE ) ); #endif QE = *QbeL; + move16(); } ELSE { @@ -2412,7 +2451,7 @@ void ton_ene_est_fx( k = add( k, 1 ); L_be_tonal[i] = L_sub( L_band_energy_Linear[i], L_E ); - + move32(); IF( L_be_tonal[i] < 0x0L ) { L_E = L_deposit_l( 0 ); @@ -2523,6 +2562,7 @@ void Gettonl_scalfact_fx( band_pos_fx = add( k_fx, harmonic_band ); count_pos_st_fx = pos_fx; move16(); + test(); WHILE( LE_16( sb_ton_loc_fx[pos_fx], sub( band_end[band_pos_fx], fLenLow ) ) && sb_ton_loc_fx[pos_fx] >= 0 ) { test(); @@ -2532,6 +2572,7 @@ void Gettonl_scalfact_fx( move16(); exp_safe = 2; /* move16(); */ + move16(); QetEne = add( shl( sub( Qss, exp_safe ), 1 ), 1 ); L_temp = L_add( L_est_ton_ene[k_fx], 0 ); FOR( i = count_pos_st_fx; i < count_pos_end_fx; i++ ) @@ -2607,6 +2648,7 @@ void Gettonl_scalfact_fx( #else L_band_energy_Linear[band_pos_fx] = L_shl( L_band_energy_Linear[band_pos_fx], sub( QbeL, exp_pow ) ); #endif + move32(); /* Div Part */ exp_normd = norm_l( L_be_tonal[band_pos_fx] ); exp_normd = sub( exp_normd, 1 ); @@ -2691,6 +2733,7 @@ void sqrt_32n_16_fx( L_in_t = L_shr( L_in_t, exp_norm ); *Qout = shr( Qin_t, 1 ); } + move16(); *out_fx = round_fx( L_in_t ); } @@ -2724,6 +2767,7 @@ void norm_vec_32_16_scale_fx( FOR( i = 0; i < length_fx; i++ ) { vec_out_fx[i] = round_fx( L_shl( L_vec_in[i], exp_shift ) ); + move16(); } } @@ -2771,6 +2815,7 @@ void get_sigma_fx_har( FOR( i = 0; i < length_fx; i++ ) { L_x_abs_sh[i] = L_shl( L_x_abs[i], exp_norm ); + move32(); } L_d = L_deposit_l( 0 ); @@ -2830,7 +2875,8 @@ void get_sigma_fx_har( *Qsigma = shr( Qd, 1 ); *sigma_fx = round_fx( L_temp ); } - + move16(); + move16(); return; } @@ -2870,7 +2916,8 @@ void FindNBiggest2_simple_fx_har( { L_abs_in[j] = L_abs( L_inBuf[j] ); /* Qabs_in */ L_abs_in_sft[j] = L_shr( L_abs_in[j], 8 ); /* 8 is safe shift */ - + move32(); + move32(); if ( LT_32( L_max_in, L_abs_in_sft[j] ) ) { L_max_in = L_abs_in_sft[j]; @@ -2923,6 +2970,7 @@ void FindNBiggest2_simple_fx_har( IF( GT_32( L_abs_in[j], L_thr ) ) { pk_sf_fx[peak_cnt_fx].nmrValue_fx = round_fx( L_abs_in[j] ); /* Qabs_in-16 */ + move16(); pk_sf_fx[peak_cnt_fx].gainIndex_fx = j; move16(); L_abs_in[j] = L_deposit_l( 0 ); @@ -3026,6 +3074,7 @@ Word16 spectrumsmooth_noiseton_fx( /* o : Qss ss_ Word32 L_temp; Word32 L_spectra_rm[L_FRAME32k]; Word32 L_cut_input = 410; + move32(); Word16 rand_a_fx[L_FRAME32k]; @@ -3033,6 +3082,7 @@ Word16 spectrumsmooth_noiseton_fx( /* o : Qss ss_ FOR( i = 0; i < fLenLow_fx; i++ ) { rand_a_fx[i] = Random( ni_seed_fx ); + move16(); } @@ -3090,6 +3140,7 @@ Word16 spectrumsmooth_noiseton_fx( /* o : Qss ss_ FOR( i = 0; i < fLenLow_fx; i++ ) { L_spectra_rm[i] = L_deposit_l( 0 ); + move32(); if ( GE_32( L_abs( L_spectra_diff[i] ), L_cut_input ) ) { L_spectra_rm[i] = L_spectra_diff[i]; @@ -3114,6 +3165,7 @@ Word16 spectrumsmooth_noiseton_fx( /* o : Qss ss_ { /*sspectra[i] = sign*((10-ss_min)/10.0f*(float)fabs(sspectra[i])+ss_min);*/ sspectra_fx[i] = add( mult_r( ratio_fx, abs_s( sspectra_fx[i] ) ), ss_min_fx ); + move16(); IF( sign_fx != 0 ) { sspectra_fx[i] = negate( sspectra_fx[i] ); @@ -3137,6 +3189,7 @@ Word16 spectrumsmooth_noiseton_fx( /* o : Qss ss_ L_temp = L_mult( ni_ratio_fx, 20480 ); /* ni_ratio*5 */ L_temp = Mult_32_16( L_temp, rand_a_fx[i] ); /* Q28 */ sspectra_ni_fx[i] = round_fx( L_shr( L_temp, 2 ) ); /* Qss */ + move16(); } } @@ -3166,11 +3219,12 @@ void noiseinj_hf_fx( Word16 *p_prev_En_sb_fx; Word16 QbeL = 7; /* Don't need 3, because this E only use under th samples */ /* QsEn=3 */ - + move16(); Word16 map_pulse_t_fx[L_FRAME32k]; Word16 map_pulse_fx[L_FRAME32k]; Word16 QsEn = 4; /* kiken */ + move16(); Word32 L_En[NB_SWB_SUBBANDS]; Word32 *p_L_En; Word16 QE; @@ -3196,20 +3250,24 @@ void noiseinj_hf_fx( Word16 Qdiv; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif set16_fx( map_pulse_t_fx, 0, band_end_fx[BANDS_fx - 1] + 1 ); set16_fx( map_pulse_fx, 0, band_end_fx[BANDS_fx - 1] + 1 ); /*level adjust the missing bands in the core coder */ exp_safe = 4; /*move16();*/ + move16(); norm_vec_32_16_scale_fx( L_xSynth_har, Qs, fLenHigh_fx, xSynth_har_fx, &QxSynth, exp_safe ); QE = add( shl( QxSynth, 1 ), 1 ); p_L_En = L_En; + move32(); p_sqrt_En_fx = sqrt_En_fx; FOR( k = sub( BANDS_fx, NB_SWB_SUBBANDS ); k < BANDS_fx; k++ ) { *p_L_En = L_deposit_l( 0 ); + move32(); IF( p2a_flags_fx[k] == 0 ) { FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ ) @@ -3217,6 +3275,7 @@ void noiseinj_hf_fx( IF( LE_32( L_abs( L_xSynth_har[i - fLenLow_fx] ), L_th_g[k - ( BANDS_fx - NB_SWB_SUBBANDS )] ) ) { *p_L_En = L_mac( *p_L_En, xSynth_har_fx[i - fLenLow_fx], xSynth_har_fx[i - fLenLow_fx] ); + move32(); } ELSE { @@ -3267,6 +3326,7 @@ void noiseinj_hf_fx( /* 0.8: 26214.4(Q15) 0.2:6553.6(Q15) */ *p_Enn_sm_sb_fx = round_fx( L_mac( L_mult( *p_sqrt_En_fx, 26214 ), *p_prev_En_sb_fx, 6554 ) ); } + move16(); } p_Enn_sm_sb_fx++; diff --git a/lib_com/swb_tbe_com.c b/lib_com/swb_tbe_com.c index ede212bb1..5229543ab 100644 --- a/lib_com/swb_tbe_com.c +++ b/lib_com/swb_tbe_com.c @@ -1218,11 +1218,11 @@ void GenSHBSynth_fx_32( Word32 *shb_syn_speech_32k, /* o : output highband component Qx*/ Word32 Hilbert_Mem[], /* i/o: memory Qx*/ Word32 state_lsyn_filt_shb_local[], /* i/o: memory Qx*/ - const int16_t L_frame, /* i : ACELP frame length */ - int16_t *syn_dm_phase ) + const Word16 L_frame, /* i : ACELP frame length */ + Word16 *syn_dm_phase ) { Word32 speech_buf_32k[L_FRAME32k]; - int16_t i; + Word16 i; Interpolate_allpass_steep_32( input_synspeech, state_lsyn_filt_shb_local, L_FRAME16k, speech_buf_32k ); @@ -1235,14 +1235,15 @@ void GenSHBSynth_fx_32( FOR( i = 0; i < L_FRAME32k; i++ ) { // shb_syn_speech_32k[i] = ( ( i % 2 ) == 0 ) ? ( -speech_buf_32k[i] ) : ( speech_buf_32k[i] ); - IF( EQ_16( i % 2, 0 ) ) + IF( i % 2 == 0 ) { - shb_syn_speech_32k[i] = -speech_buf_32k[i]; + shb_syn_speech_32k[i] = L_negate( speech_buf_32k[i] ); } ELSE { shb_syn_speech_32k[i] = speech_buf_32k[i]; } + move32(); } } @@ -1364,7 +1365,7 @@ void ScaleShapedSHB( } #ifdef IVAS_FLOAT_FIXED void ScaleShapedSHB_32( - const int16_t length, /* i : SHB overlap length */ + const Word16 length, /* i : SHB overlap length */ Word32 *synSHB_fx, /* i/o: synthesized shb signal Q_inp/Q_new */ Word32 *overlap_fx, /* i/o: buffer for overlap-add Q_inp/Q_new */ const Word16 *subgain_fx, /* i : subframe gain Q15 */ @@ -1383,26 +1384,33 @@ void ScaleShapedSHB_32( /* initilaization */ l_frame = L_FRAME16k; l_shb_lahead = L_SHB_LAHEAD; + move16(); + move16(); skip = skip_bands_SWB_TBE; - IF( length == SHB_OVERLAP_LEN / 2 ) + IF( EQ_16( length, SHB_OVERLAP_LEN / 2 ) ) { skip = skip_bands_WB_TBE; l_frame = L_FRAME16k / 4; l_shb_lahead = L_SHB_LAHEAD / 4; + move16(); + move16(); } /* apply gain for each subframe, and store noise output signal using overlap-add */ set32_fx( mod_syn_fx, 0, l_frame + l_shb_lahead ); - IF( length == SHB_OVERLAP_LEN / 2 ) + IF( EQ_16( length, SHB_OVERLAP_LEN / 2 ) ) { sum_gain_fx = 0; - FOR( k = 0; k < length / 2; k++ ) + move16(); + FOR( k = 0; k < shr( length, 1 ); k++ ) { sum_gain_fx = mult_r( subwin_fx[2 * k + 2], subgain_fx[0] ); - mod_syn_fx[skip[0] + k] = Mpy_32_16_1( synSHB_fx[skip[0] + k], sum_gain_fx ); // Qx - mod_syn_fx[skip[0] + k + length / 2] = Mpy_32_16_1( synSHB_fx[skip[0] + k + length / 2], subgain_fx[0] ); // Qx + mod_syn_fx[add( skip[0], k )] = Mpy_32_16_1( synSHB_fx[add( skip[0], k )], sum_gain_fx ); + move32(); // Qx + mod_syn_fx[add( add( skip[0], k ), shr( length, 1 ) )] = Mpy_32_16_1( synSHB_fx[add( add( skip[0], k ), shr( length, 1 ) )], subgain_fx[0] ); // Qx + move32(); } FOR( i = 1; i < NUM_SHB_SUBFR / 2; i++ ) { @@ -1410,13 +1418,15 @@ void ScaleShapedSHB_32( { L_tmp = L_mult0( subwin_fx[k + 1], subgain_fx[i] ); sum_gain_fx = round_fx( L_mac0( L_tmp, subwin_fx[length - k - 1], subgain_fx[i - 1] ) ); - mod_syn_fx[skip[i] + k] = L_shl( Mpy_32_16_1( synSHB_fx[skip[i] + k], sum_gain_fx ), 1 ); // Qx + mod_syn_fx[add( skip[i], k )] = L_shl( Mpy_32_16_1( synSHB_fx[add( skip[i], k )], sum_gain_fx ), 1 ); // Qx + move32(); } } - FOR( k = 0; k < length / 2; k++ ) + FOR( k = 0; k < shr( length, 1 ); k++ ) { - sum_gain_fx = mult_r( subwin_fx[length - 2 * k - 2], subgain_fx[i - 1] ); - mod_syn_fx[skip[i] + k] = Mpy_32_16_1( synSHB_fx[skip[i] + k], sum_gain_fx ); // Qx + sum_gain_fx = mult_r( subwin_fx[sub( sub( length, shl( k, 1 ) ), 2 )], subgain_fx[i - 1] ); + mod_syn_fx[add( skip[i], k )] = Mpy_32_16_1( synSHB_fx[add( skip[i], k )], sum_gain_fx ); // Qx + move32(); } } ELSE @@ -1424,52 +1434,61 @@ void ScaleShapedSHB_32( num_join = NUM_SHB_SUBFR / NUM_SHB_SUBGAINS; join_length = i_mult( num_join, length ); j = 0; + move16(); + move16(); FOR( k = 0; k < length; k++ ) { mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], mult_r( subwin_fx[k + 1], subgain_fx[0] ) ); // Qx - j++; + move32(); + j = add( j, 1 ); } FOR( i = 0; i < NUM_SHB_SUBGAINS - 1; i++ ) { FOR( k = 0; k < join_length - length; k++ ) { - mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], subgain_fx[i * num_join] ); // Qx - j++; + mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], subgain_fx[i_mult( i, num_join )] ); // Qx + move32(); + j = add( j, 1 ); } FOR( k = 0; k < length; k++ ) { - L_tmp = L_mult0( subwin_fx[length - k - 1], subgain_fx[i * num_join] ); - mod_syn_fx[j] = L_shl( Mpy_32_16_1( synSHB_fx[j], round_fx( L_mac0( L_tmp, subwin_fx[k + 1], subgain_fx[( i + 1 ) * num_join] ) ) ), 1 ); // Qx - j++; + L_tmp = L_mult0( subwin_fx[length - k - 1], subgain_fx[i_mult( i, num_join )] ); + mod_syn_fx[j] = L_shl( Mpy_32_16_1( synSHB_fx[j], round_fx( L_mac0( L_tmp, subwin_fx[k + 1], subgain_fx[i_mult( ( i + 1 ), num_join )] ) ) ), 1 ); // Qx + move32(); + j = add( j, 1 ); } } FOR( k = 0; k < join_length - length; k++ ) { mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], subgain_fx[( NUM_SHB_SUBGAINS - 1 ) * num_join] ); // Qx - j++; + move32(); + j = add( j, 1 ); } FOR( k = 0; k < length; k++ ) { - mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], mult_r( subwin_fx[length - k - 1], subgain_fx[( NUM_SHB_SUBGAINS - 1 ) * num_join] ) ); // Qx - j++; + mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], mult_r( subwin_fx[sub( sub( length, k ), 1 )], subgain_fx[( NUM_SHB_SUBGAINS - 1 ) * num_join] ) ); // Qx + move32(); + j = add( j, 1 ); } } Word16 norm_shift = norm_l( frame_gain_fx ); - IF( frame_gain_fx == 0 ) + if ( frame_gain_fx == 0 ) { norm_shift = 31; + move16(); } norm_shift = s_min( norm_shift, 14 ); norm_shift = sub( norm_shift, 1 ); *Q_new = add( *Q_inp, sub( norm_shift, 13 ) ); // Q_new = Q_inp + min(norm_shift,14) - 14; - + move16(); FOR( i = 0; i < L_SHB_LAHEAD; i++ ) { - overlap_fx[i] = L_shl( overlap_fx[i], *Q_new - *Q_inp ); + overlap_fx[i] = L_shl( overlap_fx[i], sub( *Q_new, *Q_inp ) ); + move32(); } FOR( i = 0; i < l_shb_lahead; i++ ) @@ -1477,21 +1496,27 @@ void ScaleShapedSHB_32( synSHB_fx[i] = Mpy_32_32( mod_syn_fx[i], Mpy_32_16_1( L_shl( frame_gain_fx, norm_shift ), win_fx[i] ) ); // Q_new synSHB_fx[i] = L_add( synSHB_fx[i], overlap_fx[i] ); synSHB_fx[i + l_shb_lahead] = Mpy_32_32( mod_syn_fx[i], L_shl( frame_gain_fx, norm_shift ) ); // Q_new + move32(); + move32(); + move32(); } FOR( ; i < l_frame; i++ ) { synSHB_fx[i] = Mpy_32_32( mod_syn_fx[i], L_shl( frame_gain_fx, norm_shift ) ); // Q_new + move32(); } FOR( ; i < l_frame + l_shb_lahead; i++ ) { - synSHB_fx[i] = L_shl( synSHB_fx[i], *Q_new - *Q_inp ); + synSHB_fx[i] = L_shl( synSHB_fx[i], sub( *Q_new, *Q_inp ) ); overlap_fx[i - l_frame] = Mpy_32_32( mod_syn_fx[i], Mpy_32_16_1( L_shl( frame_gain_fx, norm_shift ), win_fx[l_frame + l_shb_lahead - 1 - i] ) ); // Q_new + move32(); + move32(); } *Q_inp = *Q_new; - + move16(); return; } #endif diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 5b48dfada..42cab91fb 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -204,6 +204,7 @@ void tbe_celp_exc( tmp_fx = extract_l( L_mult( tmp_fx, 5 ) ); /*Q5, 2.5 in Q1*/ tmp_fx = sub( shl( offset_fx, 5 ), tmp_fx ); /*Q5*/ *error_fx = add( *error_fx, tmp_fx ); /*Q5*/ + move16(); } ELSE { @@ -233,6 +234,7 @@ void tbe_celp_exc( tmp_fx = shl( tmp_fx, 2 ); /*now above tmp_fx in Q5*/ tmp_fx = sub( shl( offset_fx, 5 ), tmp_fx ); /*move offset_fx to Q5, tmp_fx in Q5, ans tmp_fx in Q5*/ *error_fx = add( *error_fx, tmp_fx ); /*error_fx in Q5*/ + move16(); } } @@ -290,6 +292,7 @@ void tbe_celp_exc_ivas( tmp_fx = extract_l( L_mult( tmp_fx, 5 ) ); /*Q5, 2.5 in Q1*/ tmp_fx = sub( shl( offset_fx, 5 ), tmp_fx ); /*Q5*/ *error_fx = add( *error_fx, tmp_fx ); /*Q5*/ + move16(); } ELSE { @@ -319,6 +322,7 @@ void tbe_celp_exc_ivas( tmp_fx = shl( tmp_fx, 2 ); /*now above tmp_fx in Q5*/ tmp_fx = sub( shl( offset_fx, 5 ), tmp_fx ); /*move offset_fx to Q5, tmp_fx in Q5, ans tmp_fx in Q5*/ *error_fx = add( *error_fx, tmp_fx ); /*error_fx in Q5*/ + move16(); } } @@ -398,6 +402,7 @@ void flip_and_downmix_generic_fx( FOR( i = 0; i < HILBERT_ORDER1; i++ ) { tmp_16[i] = extract_h( mem1_ext[i] ); /* mem1_ext (Qx+16) tmp16 (Qx) */ + move16(); } /* Hilber transform stage - 0 - single precision */ @@ -411,6 +416,7 @@ void flip_and_downmix_generic_fx( FOR( i = 0; i < HILBERT_ORDER1; i++ ) { mem1_ext[i] = L_deposit_h( tmp_16[i + length] ); /* mem1_ext (Qx+16) tmp16 (Qx) */ + move32(); } Copy32( mem2_ext, tmpi2_R, HILBERT_ORDER2 ); @@ -467,6 +473,7 @@ void flip_and_downmix_generic_fx( L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table[j] ); /*//Qx+16 */ L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table[j] ); /*Qx+16 */ output[i] = round_fx( L_tmp ); /*Qx */ + move16(); i++; j++; } @@ -854,6 +861,7 @@ static void filt_mu_fx( Word16 tmp, exp; #ifdef FIX_729_MISSING_RESCALING Flag Overflow = 0; + move32(); #endif @@ -1005,6 +1013,7 @@ static void scale_st_swb( L_temp = L_shl( L_temp, 1 ); /*14 + Q_bwe_exc +1 */ sig_out_fx[i] = round_fx( L_temp ); /*Q_bwe_exc +15 -16 = Q_bwe_exc-1 */ #endif + move16(); } *gain_prec_fx = gain_fx; move16(); @@ -1233,6 +1242,7 @@ void ivas_GenShapedWBExcitation_fx( FOR( i = 0; i < L_FRAME16k / 4; i++ ) { exc4kWhtnd[i] = shl_r( exc4kWhtnd[i], sub( Q_bwe_exc, 5 ) ); /*Q(Q_bwe_exc)/Q5(if Q_bwe_exc > 5) */ + move16(); } } } @@ -1259,6 +1269,7 @@ void ivas_GenShapedWBExcitation_fx( /* Ensure pow1 is greater than zero when computing normalization */ max_val = 0; + move16(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { excTmp2[i] = abs_s( exc4kWhtnd[i] ); @@ -1288,6 +1299,7 @@ void ivas_GenShapedWBExcitation_fx( } n1 = sub( sub( 14, n1 ), Q_bwe_exc ); pow1 = 1; + move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB @@ -1341,9 +1353,11 @@ void ivas_GenShapedWBExcitation_fx( #else exc4k_frac[i] = extract_h( L_shl( exc4k_32[i], n2 ) ); /* Q(14-n2) */ #endif + move16(); } n2 = 30 - n2 - ( Q_bwe_exc + 6 ); pow22 = 1; + move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB @@ -1374,6 +1388,7 @@ void ivas_GenShapedWBExcitation_fx( #else exc4kWhtnd[i] = round_fx( L_shl( L_mult( exc4k_frac[i], scale ), sc ) ); /* Q_bwe_exc+n2-10+16+ Q_bwe_exc + n2 -14 -16 = //Q_bwe_exc */ #endif + move16(); } } ELSE @@ -1426,6 +1441,7 @@ void ivas_GenShapedWBExcitation_fx( L_tmp = L_add( L_tmp, L_shl( L_mult( temp2, exc4k_frac[k] ), sc ) ); /* Q(16+Q_bwe_exc) */ exc4kWhtnd[k] = round_fx( L_tmp ); /* Q_bwe_exc */ #endif + move16(); k++; } } @@ -1480,6 +1496,7 @@ void GenShapedWBExcitation_fx( Word16 avg_voice_fac; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif /*0.25f*sum_f(voice_factors, NB_SUBFR)*/ @@ -1521,6 +1538,7 @@ void GenShapedWBExcitation_fx( FOR( i = 0; i < L_FRAME16k / 4; i++ ) { exc4kWhtnd[i] = shl_r( exc4kWhtnd[i], sub( Q_bwe_exc, 5 ) ); /*Q(Q_bwe_exc)/Q5(if Q_bwe_exc > 5) */ + move16(); } } } @@ -1576,6 +1594,7 @@ void GenShapedWBExcitation_fx( } n1 = sub( sub( 14, n1 ), Q_bwe_exc ); pow1 = 1; + move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB @@ -1629,9 +1648,11 @@ void GenShapedWBExcitation_fx( #else exc4k_frac[i] = extract_h( L_shl( exc4k_32[i], n2 ) ); /* Q(14-n2) */ #endif + move16(); } n2 = 30 - n2 - ( Q_bwe_exc + 6 ); pow22 = 1; + move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB @@ -1662,6 +1683,7 @@ void GenShapedWBExcitation_fx( #else exc4kWhtnd[i] = round_fx( L_shl( L_mult( exc4k_frac[i], scale ), sc ) ); /* Q_bwe_exc+n2-10+16+ Q_bwe_exc + n2 -14 -16 = //Q_bwe_exc */ #endif + move16(); } } ELSE @@ -1669,6 +1691,7 @@ void GenShapedWBExcitation_fx( sc = sub( add( n2, Q_bwe_exc ), 14 ); /* Q_bwe_exc+n2-14*/ k = 0; + move16(); FOR( i = 0; i < 4; i++ ) { test(); @@ -1714,6 +1737,7 @@ void GenShapedWBExcitation_fx( L_tmp = L_add( L_tmp, L_shl( L_mult( temp2, exc4k_frac[k] ), sc ) ); /* Q(16+Q_bwe_exc) */ exc4kWhtnd[k] = round_fx( L_tmp ); /* Q_bwe_exc */ #endif + move16(); k++; } } @@ -1936,10 +1960,14 @@ void GenShapedSHBExcitation_fx( Word16 excTmp2[L_FRAME16k]; Word16 *White_exc16k; Word16 excNoisyEnv[L_FRAME16k]; - Word16 csfilt_num2[1] = { 6554 }; /*0.2 in Q15 */ + Word16 csfilt_num2[1] = { 6554 }; /*0.2 in Q15 */ + move16(); Word16 neg_csfilt_den2[2] = { -32767, 26214 }; /* {1.0f, -0.8f} */ + move16(); + move16(); Word16 varEnvShape; Word16 fb_deemph_fac = 15729; /*0.48f in Q15 */ + move16(); Word16 exc16kWhtnd[L_FRAME16k]; Word32 L_tmp; @@ -2020,6 +2048,7 @@ void GenShapedSHBExcitation_fx( FOR( i = 0; i < 80; i++ ) { exc16kWhtnd[temp2 + i] = round_fx( L_shl( L_mult( exc16kWhtnd[temp2 + i], temp1 ), 1 ) ); + move16(); /* exc16kWhtnd in Q_bwe_exc, shb_res_gshape in Q14 */ } temp2 = add( temp2, 80 ); @@ -2224,6 +2253,7 @@ void GenShapedSHBExcitation_fx( if ( L_tmp == 0 ) { Q_temp = 31; + move16(); } /*Copy_Scale_sig( White_exc16k, White_exc16k, L_FRAME16k, sub(NOISE_QFAC, 5) );)*/ /* White_exc16k in Q6 */ @@ -2348,10 +2378,13 @@ void GenShapedSHBExcitation_fx( Estimate_mix_factors_fx( shb_res, Q_shb, exc16kWhtnd, *Q_bwe_exc, White_exc16k, ( *Q_bwe_exc - NOISE_QADJ ), pow1, Q_pow1, pow22, Q_pow22, voiceFacEst, vf_ind ); tmp = voiceFacEst[0]; + move16(); tmp2 = MAX_16; + move16(); if ( LE_16( tmp, 22938 /*0.7f Q15*/ ) ) { tmp2 = 26214 /*0.8f Q15*/; + move16(); } } } @@ -2376,9 +2409,11 @@ void GenShapedSHBExcitation_fx( /* *vf_ind is an integer scale by 0.125f*/ tmp = shl( *vf_ind, ( 15 - 3 ) ); tmp2 = MAX_16; + move16(); if ( LE_16( tmp, 22938 /*0.7f Q15*/ ) ) { tmp2 = 26214 /*0.8f Q15*/; + move16(); } } } @@ -2413,8 +2448,9 @@ void GenShapedSHBExcitation_fx( White_exc16k_FB[k] = round_fx( L_shl( White_exc16k_32[k], tmp ) ); /* Q_bwe_exc +5 +1 +Q_temp -16 -3 */ } prev_Q_bwe_exc_fb = *Q_bwe_exc_fb; + move16(); *Q_bwe_exc_fb = sub( add( *Q_bwe_exc, Q_temp ), 13 ); - + move16(); deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph ); /* i/o: White_exc16k (Q_bwe_exc-NOISE_QADJ) */ /* i: tbe_demph (Q_bwe_exc-NOISE_QADJ) */ @@ -2472,6 +2508,7 @@ void GenShapedSHBExcitation_fx( L_tmp = L_mult( White_exc16k[k], scale ); /* L_tmp: (Q_bwe_exc-NOISE_QADJ) + 15 + 1 */ exc16kWhtnd[k] = round_fx( L_shl( L_tmp, NOISE_QADJ ) ); + move16(); /* exc16kWhtnd: Q_bwe_exc */ } preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); @@ -2500,9 +2537,11 @@ void GenShapedSHBExcitation_fx( IF( EQ_16( coder_type, VOICED ) && ( LT_32( bitrate, ACELP_24k40 ) ) ) { exp = 0; + move16(); tempQ15 = Sqrt16( voice_factors[i], &exp ); /* Q15 */ temp = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */ exp = 0; + move16(); tempQ15 = Sqrt16( temp, &exp ); /* Q15 */ temp1 = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */ @@ -2525,6 +2564,7 @@ void GenShapedSHBExcitation_fx( vf_tmp = mult_r( voice_factors[i], vf_tmp ); exp = 0; + move16(); tempQ15 = Sqrt16( vf_tmp, &exp ); /* Q15 */ temp1 = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */ @@ -2558,6 +2598,7 @@ void GenShapedSHBExcitation_fx( /* estimate the pre-emph factor */ tempQ15 = sub( MAX_16, voice_factors[i] ); exp = 0; + move16(); temp = Sqrt16( tempQ15, &exp ); temp = shl( temp, exp - 1 ); @@ -2750,8 +2791,11 @@ void GenShapedSHBExcitation_ivas_fx( Word16 excTmp2[L_FRAME16k]; Word16 *White_exc16k; Word16 excNoisyEnv[L_FRAME16k]; - Word16 csfilt_num2[1] = { 6554 }; /*0.2 in Q15 */ + Word16 csfilt_num2[1] = { 6554 }; /*0.2 in Q15 */ + move16(); Word16 neg_csfilt_den2[2] = { -32767, 26214 }; /* {1.0f, -0.8f} */ + move16(); + move16(); Word16 varEnvShape; Word16 fb_deemph_fac = 15729; /*0.48f in Q15 */ Word16 exc16kWhtnd[L_FRAME16k]; @@ -2759,6 +2803,7 @@ void GenShapedSHBExcitation_ivas_fx( Word32 L_tmp; Word16 vf_tmp; Word16 tmp, exp, tmp2 = 0; + move16(); Word16 voiceFacEst[NB_SUBFR16k]; Word16 zero_mem[LPC_SHB_ORDER]; Word32 syn_shb_ener_sf[4]; @@ -2785,6 +2830,7 @@ void GenShapedSHBExcitation_ivas_fx( Word16 c0_part[NUM_SHB_SUBGAINS], c1_part[NUM_SHB_SUBGAINS], c2_part[NUM_SHB_SUBGAINS], c3_part[NUM_SHB_SUBGAINS], c4_part[NUM_SHB_SUBGAINS], c5_part[NUM_SHB_SUBGAINS]; mix_factor = 0; + move16(); #endif set16_fx( zero_mem, 0, LPC_SHB_ORDER ); set16_fx( wht_fil_mem, 0, LPC_WHTN_ORDER ); @@ -2833,6 +2879,7 @@ void GenShapedSHBExcitation_ivas_fx( FOR( i = 0; i < 80; i++ ) { exc16kWhtnd[temp2 + i] = round_fx( L_shl( L_mult( exc16kWhtnd[temp2 + i], temp1 ), 1 ) ); + move16(); /* exc16kWhtnd in Q_bwe_exc, shb_res_gshape in Q14 */ } temp2 = add( temp2, 80 ); @@ -2949,13 +2996,18 @@ void GenShapedSHBExcitation_ivas_fx( { // varEnvShape = 0.995f; varEnvShape = 32604; - // csfilt_num2[0] = 1.0f - varEnvShape; + move16(); csfilt_num2[0] = 32768 - varEnvShape; + // csfilt_num2[0] = sub( 32767, varEnvShape ); + move16(); neg_csfilt_den2[1] = varEnvShape; + move16(); } White_exc16k = exc16k; - Word16 Q_excTmp2 = getScaleFactor16( excTmp2, L_FRAME16k ) + *Q_bwe_exc; + move16(); + Word16 Q_excTmp2 = add( getScaleFactor16( excTmp2, L_FRAME16k ), *Q_bwe_exc ); + test(); /* Track the low band envelope */ IF( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_DFT ) { @@ -2963,25 +3015,32 @@ void GenShapedSHBExcitation_ivas_fx( { mem_csfilt_left = 0; mem_csfilt_right = 0; + move16(); + move16(); FOR( k = 0; k < L_FRAME16k; k++ ) { // excNoisyEnvLeft[k] = mem_csfilt_left + csfilt_num2[0] * excTmp2[k]; excNoisyEnvLeft[k] = add( mem_csfilt_left, mult_r( csfilt_num2[0], shl( excTmp2[k], sub( Q_excTmp2, *Q_bwe_exc ) ) ) ); // Q_excTmp2 + move16(); // mem_csfilt_left = -csfilt_den2[1] * excNoisyEnvLeft[k]; mem_csfilt_left = mult_r( neg_csfilt_den2[1], excNoisyEnvLeft[k] ); // Q_excTmp2 // excNoisyEnvRight[L_FRAME16k - k - 1] = mem_csfilt_right + csfilt_num2[0] * excTmp2[L_FRAME16k - k - 1]; excNoisyEnvRight[L_FRAME16k - k - 1] = add( mem_csfilt_right, mult_r( csfilt_num2[0], shl( excTmp2[L_FRAME16k - k - 1], sub( Q_excTmp2, *Q_bwe_exc ) ) ) ); // Q_excTmp2 + move16(); // mem_csfilt_right = -csfilt_den2[1] * excNoisyEnvRight[L_FRAME16k - k - 1]; mem_csfilt_right = mult_r( neg_csfilt_den2[1], excNoisyEnvRight[L_FRAME16k - k - 1] ); // Q_excTmp2 } alpha = 0; + move16(); // step = 1.0f / L_FRAME16k; step = 102; // Q15 + move16(); FOR( k = 0; k < L_FRAME16k; k++ ) { // excNoisyEnv[k] = alpha * excNoisyEnvLeft[k] + (1 - alpha) * excNoisyEnvRight[k]; - excNoisyEnv[k] = add( mult_r( alpha, excNoisyEnvLeft[k] ), mult_r( ( 32767 - alpha ), excNoisyEnvRight[k] ) ); // Q_excTmp2 + excNoisyEnv[k] = add( mult_r( alpha, excNoisyEnvLeft[k] ), mult_r( sub( 32767, alpha ), excNoisyEnvRight[k] ) ); // Q_excTmp2 + move16(); alpha = add( alpha, step ); } } @@ -3004,20 +3063,25 @@ void GenShapedSHBExcitation_ivas_fx( move32(); } #if 1 // def ADD_IVAS_TBE_CODE - IF( extl_brate == SWB_TBE_1k10 || extl_brate == SWB_TBE_1k75 ) + test(); + IF( EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) ) { /* generate gaussian (white) excitation */ FOR( k = 0; k < L_FRAME16k; k++ ) { White_exc16k[k] = own_random( &bwe_seed[0] ); + move16(); } /* normalize the amplitude of the gaussian excitation to that of the LB exc. */ Word32 pow22_inv = POW_EXC16k_WHTND_FX_INV_SQRT; + move32(); + move32(); pow22 = POW_EXC16k_WHTND_FX; Q_pow22 = -6; + move16(); // v_multc(White_exc16k, (float)sqrt(pow1 / pow22), White_exc16k, L_FRAME16k); - Word16 pow1_exp = Q31 - Q_pow1; + Word16 pow1_exp = sub( Q31, Q_pow1 ); Word32 temp_pow = Sqrt32( pow1, &pow1_exp ); temp_pow = L_shl( Mpy_32_32( temp_pow, pow22_inv ), pow1_exp ); /*Word16 out_exp; @@ -3025,16 +3089,20 @@ void GenShapedSHBExcitation_ivas_fx( temp_pow1 = L_shl(temp_pow1, out_exp);*/ // v_multc_fixed_16_16(White_exc16k, round_fx(temp_pow), White_exc16k, L_FRAME16k); L_tmp = 0; + move32(); FOR( k = 0; k < L_FRAME16k; k++ ) { White_exc16k_32[k] = L_mult( White_exc16k[k], round_fx( temp_pow ) ); + move32(); White_exc16k[k] = round_fx( L_shl( White_exc16k_32[k], *Q_bwe_exc - NOISE_QADJ ) ); // Q_bwe_exc - NOISE_QADJ + move16(); L_tmp = max( L_tmp, L_abs( White_exc16k_32[k] ) ); } Q_temp = norm_l( L_tmp ); IF( L_tmp == 0 ) { Q_temp = 31; + move16(); } } ELSE @@ -3042,6 +3110,7 @@ void GenShapedSHBExcitation_ivas_fx( { /* create a random excitation - Reuse exc16k memory */ White_exc16k = exc16k; + move16(); create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed ); create_random_vector_fx( White_exc16k + L_FRAME, L_FRAME16k - L_FRAME, bwe_seed ); @@ -3066,6 +3135,7 @@ void GenShapedSHBExcitation_ivas_fx( IF( L_tmp == 0 ) { Q_temp = 31; + move16(); } /*Copy_Scale_sig( White_exc16k, White_exc16k, L_FRAME16k, sub(NOISE_QFAC, 5) );)*/ /* White_exc16k in Q6 */ @@ -3218,22 +3288,28 @@ void GenShapedSHBExcitation_ivas_fx( ( *Q_bwe_exc - NOISE_QADJ ), pow1, Q_pow1, pow22, Q_pow22, voiceFacEst, vf_ind ); tmp = voiceFacEst[0]; tmp2 = MAX_16; + move16(); + move16(); if ( LE_16( tmp, 22938 /*0.7f Q15*/ ) ) { tmp2 = 26214 /*0.8f Q15*/; + move16(); } } } ELSE /* decoder side */ { + test(); #if 1 // def ADD_IVAS_TBE_CODE - IF( extl_brate == SWB_TBE_1k10 || extl_brate == SWB_TBE_1k75 ) + IF( EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) ) { IF( *vf_ind == 0 ) { // mix_factor = 0.0f; mix_factor = 0; + move16(); flag_plosive = 1; + move16(); } ELSE { @@ -3247,9 +3323,11 @@ void GenShapedSHBExcitation_ivas_fx( /* *vf_ind is an integer scale by 0.125f*/ tmp = shl( *vf_ind, ( 15 - 3 ) ); tmp2 = MAX_16; + move16(); IF( LE_16( tmp, 22938 /*0.7f Q15*/ ) ) { tmp2 = 26214 /*0.8f Q15*/; + move16(); } } } @@ -3270,7 +3348,7 @@ void GenShapedSHBExcitation_ivas_fx( } } #if 1 // def ADD_IVAS_TBE_CODE - IF( element_mode >= IVAS_CPE_DFT && nlExc16k != NULL ) + IF( GE_16( element_mode, IVAS_CPE_DFT ) && nlExc16k != NULL ) { /* save buffers for IC-BWE */ // mvr2r(exc16kWhtnd, nlExc16k, L_FRAME16k); @@ -3285,6 +3363,7 @@ void GenShapedSHBExcitation_ivas_fx( FOR( k = 0; k < L_FRAME16k; k++ ) { mixExc16k[k] = mult_r( White_exc16k[k], temp_fac ); + move16(); } } #endif @@ -3295,13 +3374,15 @@ void GenShapedSHBExcitation_ivas_fx( White_exc16k_FB[k] = round_fx( L_shl( White_exc16k_32[k], tmp ) ); /* Q_bwe_exc +5 +1 +Q_temp -16 -3 */ } prev_Q_bwe_exc_fb = *Q_bwe_exc_fb; + move16(); *Q_bwe_exc_fb = sub( add( *Q_bwe_exc, Q_temp ), 13 ); - + move16(); deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph ); /* i/o: White_exc16k (Q_bwe_exc-NOISE_QADJ) */ /* i: tbe_demph (Q_bwe_exc-NOISE_QADJ) */ #if 1 // def ADD_IVAS_TBE_CODE - IF( extl_brate == SWB_TBE_1k10 || extl_brate == SWB_TBE_1k75 ) + test(); + IF( EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) ) { IF( !flag_plosive ) /* use only LB excitation in case of plosives */ { @@ -3315,17 +3396,20 @@ void GenShapedSHBExcitation_ivas_fx( old_scale = round_fx_sat( L_shl_sat( L_tmp, exp ) ); // Q15 // new_scale = 1.0f; new_scale = 32767; + move16(); // step_scale = (new_scale - old_scale) / (L_FRAME16k / 2); step_scale = mult_r( sub( new_scale, old_scale ), 205 ); scale = old_scale; - + move16(); /* interpolate between the old and the new value of the mixing factor */ old_fact = *prev_mix_factor; + move16(); new_fact = mix_factor; + move16(); // step = (new_fact - old_fact) / (L_FRAME16k / 2); step = mult_r( sub( new_fact, old_fact ), 205 ); fact = old_fact; - + move16(); /* mixing of LB and gaussian excitation in the first half of the frame */ FOR( k = 0; k < L_FRAME16k / 2; k++ ) { @@ -3334,6 +3418,7 @@ void GenShapedSHBExcitation_ivas_fx( L_tmp = L_add( L_shl( L_mult( fact, mult_r( White_exc16k[k], scale ) ), NOISE_QADJ ), L_mult( sub( 32767, fact ), exc16kWhtnd[k] ) ); // Q_bwe_exc exc16kWhtnd[k] = round_fx( L_tmp ); + move16(); fact = add_sat( fact, step ); scale = add_sat( scale, step_scale ); } @@ -3346,6 +3431,7 @@ void GenShapedSHBExcitation_ivas_fx( L_tmp = L_add( L_shl( L_mult( new_fact, White_exc16k[k] ), NOISE_QADJ ), mult_r( sub( 32767, new_fact ), exc16kWhtnd[k] ) ); // Q_bwe_exc exc16kWhtnd[k] = round_fx( L_tmp ); + move16(); } } // preemph(exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph); @@ -3372,6 +3458,7 @@ void GenShapedSHBExcitation_ivas_fx( L_tmp = L_mult( White_exc16k[k], scale ); /* L_tmp: (Q_bwe_exc-NOISE_QADJ) + 15 + 1 */ exc16kWhtnd[k] = round_fx( L_shl( L_tmp, NOISE_QADJ ) ); + move16(); /* exc16kWhtnd: Q_bwe_exc */ } preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); @@ -3386,6 +3473,8 @@ void GenShapedSHBExcitation_ivas_fx( /*nbSubFr = ( bitrate < ACELP_24k40 )? NB_SUBFR : NB_SUBFR16k;*/ nbSubFr = NB_SUBFR16k; lSubFr = ( L_FRAME16k / NB_SUBFR16k ); + move16(); + move16(); IF( LT_32( bitrate, ACELP_24k40 ) ) { nbSubFr = NB_SUBFR; @@ -3394,15 +3483,18 @@ void GenShapedSHBExcitation_ivas_fx( move16(); } k = 0; + move16(); FOR( i = 0; i < nbSubFr; i++ ) { test(); IF( EQ_16( coder_type, VOICED ) && ( LT_32( bitrate, ACELP_24k40 ) ) ) { exp = 0; + move16(); tempQ15 = Sqrt16( voice_factors[i], &exp ); /* Q15 */ temp = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */ exp = 0; + move16(); tempQ15 = Sqrt16( temp, &exp ); /* Q15 */ temp1 = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */ @@ -3425,6 +3517,7 @@ void GenShapedSHBExcitation_ivas_fx( vf_tmp = mult_r( voice_factors[i], vf_tmp ); exp = 0; + move16(); tempQ15 = Sqrt16( vf_tmp, &exp ); /* Q15 */ temp1 = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */ @@ -3458,6 +3551,7 @@ void GenShapedSHBExcitation_ivas_fx( /* estimate the pre-emph factor */ tempQ15 = sub( MAX_16, voice_factors[i] ); exp = 0; + move16(); temp = Sqrt16( tempQ15, &exp ); temp = shl( temp, exp - 1 ); @@ -3527,6 +3621,7 @@ void GenShapedSHBExcitation_ivas_fx( { L_tmp3 = Mult_32_16( L_tmp2, exc16kWhtnd[i] ); /* *Q_bwe_exc + (31-exp) - 15 */ exc16kWhtnd[i] = round_fx( L_tmp3 ); /* *Q_bwe_exc - exp */ + move16(); } } /* i: L_tmp2 in (Q31-exp) */ @@ -3749,6 +3844,7 @@ void ScaleShapedSHB_fx( move16(); sum_gain = 0; + move16(); FOR( k = 0; k < length / 2; k++ ) { sum_gain = mult_r( subwin[2 * k + 2], subgain[0] ); /* Q15 */ @@ -3836,7 +3932,10 @@ void ScaleShapedSHB_fx( Q_gFr_norm = norm_l( frame_gain ); if ( frame_gain == 0 ) + { Q_gFr_norm = 31; + move16(); + } Q_gFr_norm = sub( Q_gFr_norm, 1 ); /* give some headroom */ gain_frame_Q16 = round_fx( L_shl( frame_gain, Q_gFr_norm ) ); /* Q = 18 + Q_gFr_norm - 16 @@ -3854,14 +3953,16 @@ void ScaleShapedSHB_fx( } *Qx = *Q_bwe_exc; - + move16(); /* rescale the overlap memory */ FOR( i = 0; i < L_SHB_LAHEAD; i++ ) { temp2 = 1; + move16(); if ( overlap[i] < 0 ) { temp2 = -1; + move16(); } temp1 = abs_s( overlap[i] ); temp1 = shl( temp1, ( *Q_bwe_exc - prev_Q_bwe_syn2 ) ); @@ -3876,12 +3977,14 @@ void ScaleShapedSHB_fx( synSHB[i] = mac_r( L_tmp2, overlap[i], MAX_16 ); move16(); /* Q_bwe_exc + Q_gFr_norm - 13 */ synSHB[i + l_shb_lahead] = round_fx( L_tmp ); /* Q_bwe_exc + Q_gFr_norm - 13 */ + move16(); } FOR( ; i < l_frame; i++ ) { L_tmp = Mult_32_16( mod_syn[i], gain_frame_Q16 ); /* Q_bwe_exc + 16 + Q_gFr_norm + 2 - 15 */ synSHB[i] = round_fx( L_tmp ); /* Q_bwe_exc + Q_gFr_norm - 13 */ + move16(); } l_frame_tmp = add( l_frame, l_shb_lahead ); @@ -4053,6 +4156,7 @@ void ScaleShapedWB_fx( { shift = sub( 13, Q_bwe_exc ); /* earlier = (10 - Q_bwe_exc) but we changed GainFrame Q21 to Q18 */ *Qx = 0; + move16(); } ELSE IF( EQ_16( L_frame, L_FRAME ) ) /* 12.8k core */ { @@ -4068,6 +4172,7 @@ void ScaleShapedWB_fx( shift = s_min( min_shift, max_shift2 ); *Qx = ( Q_bwe_exc + 3 ) + shift - 16; + move16(); } ELSE /* 16k core */ { @@ -4076,17 +4181,21 @@ void ScaleShapedWB_fx( /* Qx = (Q_bwe_exc+3) + shift - 16 */ /* make sure 14 > Qx > 3 */ min_shift = 3 - ( Q_bwe_exc + 3 - 16 ); + move16(); max_shift = 13 - ( Q_bwe_exc + 3 - 16 ); + move16(); max_shift2 = s_min( max_shift, max_headroom ); /* avoid shifting more than the available max_val headroom to avoid overflow */ shift = s_min( min_shift, max_shift2 ); *Qx = ( Q_bwe_exc + 3 ) + shift - 16; + move16(); } /* bring memory st_fx->syn_overlap_fx[] = overlap[i] to new Q = Qx to prepare for addition */ FOR( i = 0; i < l_shb_lahead; i++ ) { overlap[i] = shl( overlap[i], ( *Qx - prev_Qx ) ); + move16(); } FOR( i = 0; i < l_shb_lahead; i++ ) @@ -4095,6 +4204,7 @@ void ScaleShapedWB_fx( L_tmp = Mult_32_32( mod_syn[i], frame_gain ); /* L_tmp in (Q_bwe_exc+3) */ #ifdef BASOP_NOGLOB synSHB[i] = round_fx_sat( L_shl_sat( Mult_32_16( L_tmp, win[i] ), shift ) ); /* Qx */ + move16(); synSHB[i] = add_sat( synSHB[i], overlap[i] ); move16(); /* Qx */ synSHB[i + l_shb_lahead] = round_fx_sat( L_shl_sat( L_tmp, shift ) ); /* Qx */ @@ -4114,6 +4224,7 @@ void ScaleShapedWB_fx( #else synSHB[i] = round_fx( L_shl( L_tmp, shift ) ); /* Qx; */ #endif + move16(); } l_frame_tmp = add( l_frame, l_shb_lahead ); @@ -4125,6 +4236,7 @@ void ScaleShapedWB_fx( #else overlap[i - l_frame] = round_fx( L_shl( Mult_32_16( L_tmp, win[l_frame + l_shb_lahead - 1 - i] ), shift ) ); /* Qx */ #endif + move16(); } return; @@ -4385,6 +4497,7 @@ void non_linearity_fx( Word16 length_half; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif @@ -4924,6 +5037,7 @@ void create_random_vector_fx( j = s_and( j, 0xff ); k = s_and( k, 0xff ); output[i] = round_fx( L_add( L_mult( scale1, gaus_dico_swb_fx[j] ), L_mult( scale2, gaus_dico_swb_fx[k] ) ) ); /*Q5 */ + move16(); j++; k++; } @@ -4965,19 +5079,29 @@ void interp_code_5over2_fx( Word16 i, kk, kkp1, i_len2; Word32 Ltemp; Word16 factor_i_fx[5] = { 6554, 19661, 32767, 19661, 6554 }; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); Word16 factor_j_fx[5] = { 26214, 13107, 0, 13107, 26214 }; - + move16(); + move16(); + move16(); + move16(); + move16(); interp_code_fx[0] = inp_code_fx[0]; move16(); /* Qx */ Ltemp = L_mult( inp_code_fx[0], factor_i_fx[3] ); /* Q(16+x) */ Ltemp = L_mac( Ltemp, inp_code_fx[1], factor_j_fx[3] ); /* Q(16+x) */ interp_code_fx[1] = round_fx( Ltemp ); /*Qx */ - + move16(); Ltemp = L_mult( inp_code_fx[0], factor_i_fx[4] ); /*Q(16+x) */ Ltemp = L_mac( Ltemp, inp_code_fx[1], factor_j_fx[4] ); /*Q(16+x) */ interp_code_fx[2] = round_fx( Ltemp ); /* Qx */ - + move16(); kk = 1; move16(); kkp1 = 2; @@ -4993,35 +5117,35 @@ void interp_code_5over2_fx( Ltemp = L_mult( inp_code_fx[kk], factor_j_fx[0] ); /*Q(16+x) */ Ltemp = L_mac( Ltemp, inp_code_fx[kkp1], factor_i_fx[0] ); /*Q(16+x) */ interp_code_fx[i] = round_fx( Ltemp ); /*Qx */ - + move16(); Ltemp = L_mult( inp_code_fx[kk], factor_j_fx[1] ); /*Q(16+x) */ Ltemp = L_mac( Ltemp, inp_code_fx[kkp1], factor_i_fx[1] ); /*Q(16+x) */ interp_code_fx[i + 1] = round_fx( Ltemp ); /*Qx */ - + move16(); Ltemp = L_mult( inp_code_fx[kkp1], factor_i_fx[2] ); /*Q(16+x) */ interp_code_fx[i + 2] = round_fx( Ltemp ); /*Qx */ - + move16(); kk++; kkp1++; Ltemp = L_mult( inp_code_fx[kk], factor_i_fx[3] ); /*Q(16+x) */ Ltemp = L_mac( Ltemp, inp_code_fx[kkp1], factor_j_fx[3] ); /*Q(16+x) */ interp_code_fx[i + 3] = round_fx( Ltemp ); /*Qx */ - + move16(); Ltemp = L_mult( inp_code_fx[kk], factor_i_fx[4] ); /*Q(16+x) */ Ltemp = L_mac( Ltemp, inp_code_fx[kkp1], factor_j_fx[4] ); /*Q(16+x) */ interp_code_fx[i + 4] = round_fx( Ltemp ); /*Qx */ - + move16(); kk++; kkp1++; } Ltemp = L_mult( inp_code_fx[kk], factor_j_fx[0] ); /*Q(16+x) */ interp_code_fx[i] = round_fx( Ltemp ); /*Qx */ - + move16(); Ltemp = L_mult( inp_code_fx[kk], factor_j_fx[1] ); /*Q(16+x) */ interp_code_fx[i + 1] = round_fx( Ltemp ); /*Qx */ - + move16(); return; } @@ -5127,6 +5251,11 @@ void elliptic_bpf_48k_generic_fx( memory2_fx[1][i] = L_shl_sat( memory_fx2[1][i], sub( add( *Q_input_fx, 11 ), memory_fx_Q[1] ) ); memory2_fx[2][i] = L_shl_sat( memory_fx2[2][i], sub( add( *Q_input_fx, 6 ), memory_fx_Q[2] ) ); memory2_fx[3][i] = L_shl_sat( memory_fx2[3][i], sub( add( *Q_input_fx, 1 ), memory_fx_Q[3] ) ); + move32(); + move32(); + move32(); + move32(); + move32(); #else memory_fx[0][i] = shl( memory_fx0[0][i], sub( *Q_input_fx, memory_fx_Q[0] ) ); memory2_fx[1][i] = L_shl( memory_fx2[1][i], sub( add( *Q_input_fx, 11 ), memory_fx_Q[1] ) ); @@ -5240,7 +5369,11 @@ void elliptic_bpf_48k_generic_fx( memory_fx2[0][1] = input_fx[sub( L_FRAME48k, 3 )]; memory_fx2[0][2] = input_fx[sub( L_FRAME48k, 2 )]; memory_fx2[0][3] = input_fx[sub( L_FRAME48k, 1 )]; - + move32(); + move32(); + move32(); + move32(); + move32(); L_tmpX = L_shr( Mult_32_16( memory2_fx[1][0], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][1], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ @@ -5357,7 +5490,11 @@ void elliptic_bpf_48k_generic_fx( memory_fx2[1][1] = L_tmp[sub( L_FRAME48k, 3 )]; memory_fx2[1][2] = L_tmp[sub( L_FRAME48k, 2 )]; memory_fx2[1][3] = L_tmp[sub( L_FRAME48k, 1 )]; - + move32(); + move32(); + move32(); + move32(); + move32(); FOR( j = 0; j < 4; j++ ) { #ifdef BASOP_NOGLOB @@ -5367,6 +5504,9 @@ void elliptic_bpf_48k_generic_fx( memory2_fx_2[j] = L_shl( memory_fx2[2][j], sub( add( add( *Q_input_fx, 6 ), Q_temp ), memory_fx_Q[2] ) ); memory2_fx_3[j] = L_shl( memory_fx2[3][j], sub( add( add( *Q_input_fx, 1 ), Q_temp ), memory_fx_Q[3] ) ); #endif + move32(); + move32(); + move32(); } #ifdef BASOP_NOGLOB L_tmpX = L_shr( Mult_32_16( memory2_fx_2[0], full_band_bpf_fx[2][4] ), 3 ); /* *Q_input_fx+6 +Q_temp +13 -15 -3 */ @@ -5509,19 +5649,32 @@ void elliptic_bpf_48k_generic_fx( memory_fx2[3][1] = L_output[sub( L_FRAME48k, 3 )]; memory_fx2[3][2] = L_output[sub( L_FRAME48k, 2 )]; memory_fx2[3][3] = L_output[sub( L_FRAME48k, 1 )]; - + move32(); + move32(); + move32(); + move32(); + move32(); + move32(); + move32(); + move32(); + move32(); memory_fx_Q[0] = *Q_input_fx; memory_fx_Q[1] = add( *Q_input_fx, 11 ); memory_fx_Q[2] = add( add( *Q_input_fx, 6 ), Q_temp ); memory_fx_Q[3] = add( add( *Q_input_fx, 1 ), Q_temp ); - + move16(); + move16(); + move16(); + move16(); Q_temp2 = norm_l( L_tmpMax ); Scale_sig32( L_output, 960, Q_temp2 ); FOR( i = 0; i < 960; i++ ) { output_fx[i] = extract_h( L_output[i] ); + move16(); } *Q_input_fx = sub( add( add( *Q_input_fx, Q_temp ), Q_temp2 ), 15 ); + move16(); /* BASOP_NOGLOB */ return; } @@ -5635,6 +5788,7 @@ void synthesise_fb_high_band_fx( { #ifdef BASOP_NOGLOB output[i] = negate( extract_h( L_shl_sat( L_negate( L_tmp ), tmp3 ) ) ); /*Qout*/ + move16(); #else output[i] = negate( extract_h( L_shl( L_negate( L_tmp ), tmp3 ) ) ); /*Qout*/ #endif @@ -5643,6 +5797,7 @@ void synthesise_fb_high_band_fx( { #ifdef BASOP_NOGLOB output[i] = extract_h( L_shl_sat( L_tmp, tmp3 ) ); /*Qout*/ + move16(); #else output[i] = extract_h( L_shl( L_tmp, tmp3 ) ); /*Qout*/ #endif @@ -5680,6 +5835,7 @@ void Estimate_mix_factors_fx( Word32 L_tmp1, L_tmp2; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif Copy( shb_res, shb_res_local, L_FRAME16k ); @@ -5692,6 +5848,7 @@ void Estimate_mix_factors_fx( if ( pow3 == 0 ) { pow3 = 1; + move32(); } /* temp_p1_p2 = (float)sqrt(pow1/pow2); */ @@ -5703,21 +5860,23 @@ void Estimate_mix_factors_fx( sc1 = Q_bwe_exc - ( Q_frac - exp1 ); sc2 = Q_bwe_exc - ( Q_shb - exp2 ); - + move16(); + move16(); FOR( i = 0; i < L_FRAME16k; i++ ) { L_tmp1 = Mult_32_16( temp_p1_p2, WN_exc_local[i] ); /* (Q_frac - exp1) +16 */ WN_exc_local[i] = round_fx( L_tmp1 ); - + move16(); L_tmp2 = Mult_32_16( temp_p1_p3, shb_res_local[i] ); /* (Q_shb - exp2) +16 */ shb_res_local[i] = round_fx( L_tmp2 ); - + move16(); /* temp_numer1[i] = sub(shb_res_local[i], WN_exc_local[i]); */ #ifdef BASOP_NOGLOB temp_numer1[i] = round_fx_sat( L_sub_sat( L_shl_sat( L_tmp2, sc2 ), L_shl_sat( L_tmp1, sc1 ) ) ); #else temp_numer1[i] = round_fx( L_sub( L_shl( L_tmp2, sc2 ), L_shl( L_tmp1, sc1 ) ) ); #endif + move16(); /* (Q_bwe_exc) */ /* temp_numer2[i] = sub(exc16kWhtnd[i], WN_exc_local[i]); */ @@ -5789,6 +5948,7 @@ void Estimate_mix_factors_fx( ELSE { tmp = 0; + move16(); } vf_modified[0] = s_min( s_max( tmp, 3277 /* 0.1f in Q15*/ ), 32440 /* 0.99f in Q15 */ ); @@ -5922,6 +6082,7 @@ void prep_tbe_exc_fx( Word16 tmp_code_fx[2 * L_SUBFR * HIBND_ACB_L_FAC]; Word16 tmp_code_preInt_fx[L_SUBFR]; Word16 gain_code16 = 0; + move16(); Word16 tmp /*, tmp1, tmp2*/; /*Word16 random_code[L_SUBFR * HIBND_ACB_L_FAC];*/ Word16 pitch; @@ -5931,9 +6092,11 @@ void prep_tbe_exc_fx( Word16 tempQ15; #ifndef ADD_IVAS_TBE_CODE Word16 L_subfr = L_SUBFR; + move16(); #endif #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif /**voice_factors = VF_0th_PARAM + VF_1st_PARAM * voice_fac + VF_2nd_PARAM * voice_fac * voice_fac; @@ -5943,7 +6106,7 @@ void prep_tbe_exc_fx( tempQ15 = mac_r( tempQ31, VF_2nd_PARAM_FX, voice_fac_fx ); tempQ31 = L_deposit_h( VF_0th_PARAM_FX ); *voice_factors_fx = mac_r( tempQ31, voice_fac_fx, tempQ15 ); - + move16(); tmp = 32767; move16(); @@ -5960,6 +6123,7 @@ void prep_tbe_exc_fx( tmp = MAX_16; move16(); *voice_factors_fx = mult_r( *voice_factors_fx, tmp ); + move16(); } *voice_factors_fx = s_min( s_max( *voice_factors_fx, 0 ), MAX_16 ); @@ -6000,6 +6164,7 @@ void prep_tbe_exc_fx( L_tmp = L_shl( L_tmp, 1 ); /*16+Q_exc */ /* saturation can occur here */ bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] = round_fx( L_tmp ); /*Q_exc */ #endif /* BASOP_NOGLOB */ + move16(); } } ELSE @@ -6158,6 +6323,7 @@ void prep_tbe_exc_ivas_fx( tmp = MAX_16; move16(); *voice_factors_fx = mult_r( *voice_factors_fx, tmp ); + move16(); } *voice_factors_fx = s_min( s_max( *voice_factors_fx, 0 ), MAX_16 ); @@ -6193,6 +6359,7 @@ void prep_tbe_exc_ivas_fx( L_tmp = L_shl( L_tmp, 1 ); /*16+Q_exc */ /* saturation can occur here */ bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] = round_fx( L_tmp ); /*Q_exc */ #endif /* BASOP_NOGLOB */ + move16(); } } ELSE @@ -6206,8 +6373,8 @@ void prep_tbe_exc_ivas_fx( Ltemp2 = L_mult( gain_preQ_fx, code_preQ_fx[i] ); /*Q2 * Q10 -> Q12 */ #ifdef BASOP_NOGLOB - Ltemp1 = L_shl_o( Ltemp1, Q_exc + 6 /*Q_exc+16-19*/, &Overflow ); /*Q_exc+16 */ - Ltemp2 = L_shl_o( Ltemp2, Q_exc + 4 /*Q_exc+16-13*/, &Overflow ); /*Q_exc+16 */ + Ltemp1 = L_shl_o( Ltemp1, add( Q_exc, 6 ) /*Q_exc+16-19*/, &Overflow ); /*Q_exc+16 */ + Ltemp2 = L_shl_o( Ltemp2, add( Q_exc, 4 ) /*Q_exc+16-13*/, &Overflow ); /*Q_exc+16 */ tmp_code_preInt_fx[i] = round_fx_o( L_add_o( Ltemp1, Ltemp2, &Overflow ), &Overflow ); /* Q_exc */ #else /* BASOP_NOGLOB */ @@ -6216,6 +6383,7 @@ void prep_tbe_exc_ivas_fx( tmp_code_preInt_fx[i] = round_fx( L_add( Ltemp1, Ltemp2 ) ); /* Q_exc */ #endif /* BASOP_NOGLOB */ + move16(); } } ELSE @@ -6225,22 +6393,23 @@ void prep_tbe_exc_ivas_fx( /*code in the encoder is Q9 and there is no <<1 with Mult_32_16 Q16 * Q9 -> Q9 */ Ltemp1 = Mult_32_16( gain_code_fx, code_fx[i] ); /* Q16 + Q9 + 1 - 16 = Q10 */ #ifdef BASOP_NOGLOB - Ltemp1 = L_shl_o( Ltemp1, Q_exc + 6 /*Q_exc+16-19*/, &Overflow ); /*Q_exc+16 */ - tmp_code_preInt_fx[i] = round_fx_o( Ltemp1, &Overflow ); /* Q_exc */ + Ltemp1 = L_shl_o( Ltemp1, add( Q_exc, 6 ) /*Q_exc+16-19*/, &Overflow ); /*Q_exc+16 */ + tmp_code_preInt_fx[i] = round_fx_o( Ltemp1, &Overflow ); /* Q_exc */ #else Ltemp1 = L_shl( Ltemp1, Q_exc + 6 /*Q_exc+16-19*/ ); /*Q_exc+16 */ tmp_code_preInt_fx[i] = round_fx( Ltemp1 ); /* Q_exc */ #endif + move16(); } } interp_code_4over2_fx( tmp_code_preInt_fx, tmp_code_fx, L_subfr ); /* o: tmp_code in Q_exc */ - FOR( i = 0; i < L_subfr * 2; i++ ) + FOR( i = 0; i < shl( L_subfr, 1 ); i++ ) { - L_tmp = L_mult( gain_pit_fx, bwe_exc_fx[i + i_subfr_fx * 2] ); /*Q14+Q_exc+1 */ + L_tmp = L_mult( gain_pit_fx, bwe_exc_fx[i + shl( i_subfr_fx, 1 )] ); /*Q14+Q_exc+1 */ #ifdef BASOP_NOGLOB tmp = round_fx_o( L_shl_o( L_tmp, 1 /* (Q_exc+16)-(14+Q_exc+1)*/, &Overflow ), &Overflow ); /* tmp in Q_exc */ - bwe_exc_fx[i + i_subfr_fx * 2] = add_o( tmp, tmp_code_fx[i], &Overflow ); /*Q_exc */ + bwe_exc_fx[i + shl( i_subfr_fx, 1 )] = add_o( tmp, tmp_code_fx[i], &Overflow ); /*Q_exc */ move16(); #else /* BASOP_NOGLOB */ tmp = round_fx( L_shl( L_tmp, 1 /* (Q_exc+16)-(14+Q_exc+1)*/ ) ); /* tmp in Q_exc */ diff --git a/lib_com/syn_filt_fx.c b/lib_com/syn_filt_fx.c index 5b7fcc4c3..5ce65c316 100644 --- a/lib_com/syn_filt_fx.c +++ b/lib_com/syn_filt_fx.c @@ -150,6 +150,7 @@ void syn_filt_s_lc_fx( L_tmp = L_shl( L_tmp, q ); *y++ = round_fx( L_tmp ); #endif + move16(); } FOR( ; i < lg; i++ ) @@ -162,6 +163,7 @@ void syn_filt_s_lc_fx( L_tmp = L_shl( L_tmp, q ); *y++ = round_fx( L_tmp ); #endif + move16(); } } @@ -213,6 +215,7 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W Word32 ( *syn_kern )( Word32 L_tmp, const Word16 a[], const Word16 y[] ) = NULL; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif if ( EQ_16( m, 6 ) ) @@ -257,6 +260,7 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W L_tmp = L_shl( L_tmp, q ); *y++ = round_fx( L_tmp ); #endif + move16(); /* Filtering from Input + Mix of Memory & Output Signal Past */ FOR( i = 1; i < m; i++ ) @@ -287,6 +291,7 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W L_tmp = L_shl( L_tmp, q ); *y++ = round_fx( L_tmp ); #endif + move16(); } /* Filtering from Input + Output Signal Past */ @@ -300,6 +305,7 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W L_tmp = L_shl( L_tmp, q ); *y++ = round_fx( L_tmp ); #endif + move16(); } /*-----------------------------------------------------------------------* @@ -378,6 +384,7 @@ void E_UTIL_synthesis_fx( const Word16 shift, const Word32 a[], const Word32 x[] } L_tmp = L_shl_o( L_tmp, q, &Overflow ); *y++ = L_tmp; + move32(); } /* Filtering from Input + Output Signal Past */ @@ -386,6 +393,7 @@ void E_UTIL_synthesis_fx( const Word16 shift, const Word32 a[], const Word32 x[] L_tmp = syn_kern( Mpy_32_32( a0, *x++ ), a, y ); L_tmp = L_shl_o( L_tmp, q, &Overflow ); *y++ = L_tmp; + move32(); } /*-----------------------------------------------------------------------* @@ -452,12 +460,12 @@ void ivas_synth_mem_updt2_fx( } ELSE { - en1_e = 30 - 2 * Q; - en2_e = 30 - 2 * Q; + en1_e = sub( 30, shl( Q, 1 ) ); + en2_e = sub( 30, shl( Q, 1 ) ); tmp1 = Sqrt32( en1, &en1_e ); tmp2 = Sqrt32( en2, &en2_e ); tmp = BASOP_Util_Divide3232_Scale( tmp1, tmp2, &tmp_e ); - loc_rat_e = en1_e - en2_e + tmp_e; + loc_rat_e = add( sub( en1_e, en2_e ), tmp_e ); loc_rat = shl_sat( tmp, loc_rat_e ); // Q15 } @@ -466,6 +474,7 @@ void ivas_synth_mem_updt2_fx( { // mem_syn_r[L_SYN_MEM - M + i] *= loc_rat; mem_syn_r[L_SYN_MEM - M + i] = mult_r( mem_syn_r[L_SYN_MEM - M + i], loc_rat ); + move16(); } } } diff --git a/lib_com/tcq_position_arith.c b/lib_com/tcq_position_arith.c index 4c9764fac..4368c569f 100644 --- a/lib_com/tcq_position_arith.c +++ b/lib_com/tcq_position_arith.c @@ -61,9 +61,10 @@ static void set16_fx( { Word16 i; - for ( i = 0; i < N; i++ ) + FOR( i = 0; i < N; i++ ) { y[i] = a; + move16(); } return; @@ -76,9 +77,10 @@ static void set32_fx( ) { Word16 i; - for ( i = 0; i < N; i++ ) + FOR( i = 0; i < N; i++ ) { y[i] = a; + move16(); } return; @@ -97,15 +99,15 @@ Word32 ar_div_ivas( num = L_abs( num ); denum = L_abs( denum ); - if ( L_sub( num, denum ) < 0 || denum == 0 ) + IF( L_sub( num, denum ) < 0 || denum == 0 ) { return 0; } - else if ( L_sub( num, denum ) == 0 ) + ELSE IF( L_sub( num, denum ) == 0 ) { return 1; } - else + ELSE { exp1 = norm_l( num ); exp2 = norm_l( denum ); @@ -113,16 +115,17 @@ Word32 ar_div_ivas( denum = L_shl( denum, exp ); exp = add( exp, 1 ); varout = 0; - for ( i = 0; i < exp; i++ ) + move32(); + FOR( i = 0; i < exp; i++ ) { num = L_sub( num, denum ); varout = L_shl( varout, 1 ); - if ( num >= 0 ) + IF( num >= 0 ) { num = L_shl( num, 1 ); varout = L_add( varout, 1 ); } - else + ELSE { num = L_add( num, denum ); num = L_shl( num, 1 ); @@ -149,30 +152,35 @@ void srt_vec_ind_fx_ivas( Word32 valMem; /*initialize */ - for ( pos = 0; pos < length; pos++ ) + FOR( pos = 0; pos < length; pos++ ) { I[pos] = pos; + move16(); } - for ( pos = 0; pos < length; pos++ ) + FOR( pos = 0; pos < length; pos++ ) { srt[pos] = linear[pos]; + move32(); } /* now iterate */ - for ( pos = 0; pos < ( length - 1 ); pos++ ) + FOR( pos = 0; pos < sub( length, 1 ); pos++ ) { - for ( npos = ( pos + 1 ); npos < length; npos++ ) + FOR( npos = add( pos, 1 ); npos < length; npos++ ) { if ( L_sub( srt[npos], srt[pos] ) < 0 ) { idxMem = I[pos]; I[pos] = I[npos]; I[npos] = idxMem; - + move16(); + move16(); valMem = srt[pos]; srt[pos] = srt[npos]; srt[npos] = valMem; + move32(); + move32(); } } } @@ -189,14 +197,15 @@ static Word32 GetBitsFromPulses_fx( Word32 frac_fx32; Word32 logCoeff_fx; Word16 exp = 0; + move16(); Word32 mantissa_fx = 0; - - if ( m == 0 ) + move32(); + IF( m == 0 ) { return 0; } - for ( i = 0; i < min( m, n ); i++ ) + FOR( i = 0; i < min( m, n ); i++ ) { logCoeff_fx = L_add( L_shl( i + 1, 16 ), L_sub( table_logcum_fx[n + 1], L_add( table_logcum_fx[i + 2], table_logcum_fx[n - i] ) ) ); logCoeff_fx = L_add( logCoeff_fx, L_sub( table_logcum_fx[m], L_add( table_logcum_fx[i + 1], table_logcum_fx[m - i] ) ) ); /*Q16 */ @@ -220,22 +229,23 @@ static Word32 GetBitsFromPulses_fx( exp1 = norm_l( pow_getbitsfrompulses_fx[temp_fx1] ); exp2 = norm_l( frac_fx32 ); frac_fx32 = Mult_32_32( L_shl( pow_getbitsfrompulses_fx[temp_fx1], exp1 ), L_shl( frac_fx32, exp2 ) ); /*21 + exp1 + 30 + exp2 - 31 */ - frac_fx32 = L_shr( frac_fx32, exp1 + exp2 ) + 1; /*20 */ + frac_fx32 = L_add( L_shr( frac_fx32, add( exp1, exp2 ) ), 1 ); /*20 */ - if ( sub( exp, integer_fx ) < 0 ) + IF( sub( exp, integer_fx ) < 0 ) { mantissa_fx = L_shr( mantissa_fx, sub( integer_fx, exp ) ); mantissa_fx = L_add( mantissa_fx, frac_fx32 ); exp = integer_fx; + move16(); } - else + ELSE { mantissa_fx = L_add( mantissa_fx, L_shr( frac_fx32, sub( exp, integer_fx ) ) ); } if ( L_sub( mantissa_fx, 0x200000 ) >= 0 ) { - exp++; + exp = add( exp, 1 ); mantissa_fx = L_shr( mantissa_fx, 1 ); } @@ -246,14 +256,14 @@ static Word32 GetBitsFromPulses_fx( temp32 = L_shl( L_sub( mantissa_fx, L_deposit_h( temp_fx1 ) ), 15 ); /*31 */ exp1 = sub( norm_l( temp32 ), 1 ); temp32 = ar_div_ivas( L_shl( temp32, exp1 ), temp_fx1 ); /*31 + exp1 */ - temp32 = L_shr( temp32, exp1 + 1 ); /*30 */ + temp32 = L_shr( temp32, add( exp1, 1 ) ); /*30 */ frac_fx32 = L_sub( 0x40000000, L_shr( temp32, 1 ) ); /*30 */ frac_fx32 = Mult_32_32( frac_fx32, temp32 ); /*29 */ frac_fx32 = L_shr( frac_fx32, 13 ); /*16 */ exp1 = norm_l( temp_fx1 ); - temp_fx1 = Log2_norm_lc( L_shl( temp_fx1, exp1 ) ); /*15 */ - frac_fx32 = frac_fx32 + Mult_32_32( frac_fx32, 950680361 ); /* frac_fx32 *= 1/ln(2) */ + temp_fx1 = Log2_norm_lc( L_shl( temp_fx1, exp1 ) ); /*15 */ + frac_fx32 = L_add( frac_fx32, Mult_32_32( frac_fx32, 950680361 ) ); /* frac_fx32 *= 1/ln(2) */ return L_add( L_deposit_h( exp ), L_add( L_shl( temp_fx1, 1 ), frac_fx32 ) ); } @@ -273,138 +283,159 @@ void decode_position_ari_fx_ivas( Word32 cp, scp, fxone, fxp1; Word16 stpos = 0, pos, ovrflag, temppos, storepos; - + move16(); fxone = 32768; fxp1 = 512 * 32768; + move32(); + move32(); temppos = 0; storepos = 0; ovrflag = 0; - + move16(); + move16(); + move16(); set16_fx( mode_num_nz, 0, TCQ_MAX_BAND_SIZE ); set16_fx( prob, 0, TCQ_MAX_BAND_SIZE ); - for ( i = 0; i < size; i++ ) + FOR( i = 0; i < size; i++ ) { position[i] = 0; + move32(); } - if ( L_sub( npulses, 1 ) > 0 ) + IF( L_sub( npulses, 1 ) > 0 ) { btcq_fx = GetBitsFromPulses_fx( npulses, size ); - for ( i = 0; i < L_min( npulses, size ); i++ ) + FOR( i = 0; i < L_min( npulses, size ); i++ ) { /*calculate the probability of #nz */ pnzp_fx = L_sub( L_deposit_h( add( i, 1 ) ), btcq_fx ); pnzp_fx = L_add( pnzp_fx, L_add( L_sub( table_logcum_fx[size + 1], L_add( table_logcum_fx[i + 2], table_logcum_fx[size - i] ) ), L_sub( table_logcum_fx[npulses], L_add( table_logcum_fx[i + 1], table_logcum_fx[npulses - i] ) ) ) ); pnzp_fx = L_add( pnzp_fx, 917498 ); /*16 */ - if ( L_sub( pnzp_fx, 0 ) > 0 ) + IF( L_sub( pnzp_fx, 0 ) > 0 ) { integer = extract_h( pnzp_fx ); frac = extract_l( L_shr( L_sub( pnzp_fx, L_deposit_h( integer ) ), 1 ) ); /*15 */ prob[i] = extract_h( L_shl( Pow2( integer, frac ), 16 ) ); /*0 */ + move16(); if ( prob[i] == 0 ) { prob[i] = 1; + move16(); } } - else + ELSE { prob[i] = 1; + move16(); } } ar_make_model( prob, mode_num_nz, min( npulses, size ) ); *nz = add( 1, (Word16) ar_decode( pardec, mode_num_nz ) ); /*get #nz */ nzp = *nz; - - if ( nzp == 1 ) + move16(); + move16(); + IF( EQ_16( nzp, 1 ) ) { Word16 tmp; mode_num_nz[0] = MAX_AR_FREQ; - for ( i = 0; i < size; i++ ) + FOR( i = 0; i < size; i++ ) { - tmp = div_l( L_deposit_h( size - i - 1 ), size ); + tmp = div_l( L_deposit_h( sub( sub( size, i ), 1 ) ), size ); mode_num_nz[i + 1] = round_fx( L_shr( L_deposit_h( tmp ), 1 ) ); } position[ar_decode( pardec, mode_num_nz )] = 1; + move32(); } - else + ELSE { Word16 tmp; mode_num_nz[0] = MAX_AR_FREQ; - - for ( ; nzp > 0; nzp-- ) + move16(); + FOR( ; nzp > 0; nzp-- ) { scp = fxp1; + move32(); temppos = 0; storepos = 0; - - for ( i = stpos; i < size; i++ ) + move16(); + move16(); + FOR( i = stpos; i < size; i++ ) { ovrflag = 0; - - if ( nzp == ( size - i ) ) + move16(); + IF( EQ_16( nzp, sub( size, i ) ) ) { cp = 0; + move32(); } - else + ELSE { tmp = div_l( L_deposit_h( nzp ), ( size - i ) ); cp = L_sub( fxone, tmp ); } scp = Mult_32_16( scp, extract_l( cp ) ); - mode_num_nz[i + 1 - storepos - stpos] = round_fx( L_shl( scp, 6 ) ); + mode_num_nz[sub( sub( add( i, 1 ), storepos ), stpos )] = round_fx( L_shl( scp, 6 ) ); - if ( ( mode_num_nz[i + 1 - storepos - stpos] == 0 && scp > 0 ) || mode_num_nz[i - storepos - stpos] == mode_num_nz[i + 1 - storepos - stpos] ) + IF( ( mode_num_nz[sub( sub( add( i, 1 ), storepos ), stpos )] == 0 && scp > 0 ) || EQ_16( mode_num_nz[sub( sub( i, storepos ), stpos )], mode_num_nz[sub( sub( add( i, 1 ), storepos ), stpos )] ) ) { ovrflag = 1; + move16(); temppos = (Word16) ar_decode( pardec, mode_num_nz ); - storepos += temppos; + storepos = add( storepos, temppos ); scp = fxp1; - - if ( temppos == i - stpos ) /* esc transmitted */ + move32(); + IF( EQ_16( temppos, sub( i, stpos ) ) ) /* esc transmitted */ { - i--; + i = sub( i, 1 ); } - else + ELSE { - break; + BREAK; } } } - if ( !ovrflag ) + IF( !ovrflag ) { pos = (Word16) ar_decode( pardec, mode_num_nz ) + storepos; } - else + ELSE { pos = storepos; + move16(); } position[stpos + pos] = 1; - stpos += pos + 1; + move32(); + stpos = add( stpos, add( pos, 1 ) ); } } } - else if ( L_sub( npulses, 1 ) == 0 ) + ELSE IF( L_sub( npulses, 1 ) == 0 ) { Word16 tmp; *nz = npulses; nzp = *nz; + move16(); + move16(); mode_num_nz[0] = MAX_AR_FREQ; - for ( i = 0; i < size; i++ ) + FOR( i = 0; i < size; i++ ) { - tmp = div_l( L_deposit_h( size - i - 1 ), size ); + tmp = div_l( L_deposit_h( sub( sub( size, i ), 1 ) ), size ); mode_num_nz[i + 1] = round_fx( L_shr( L_deposit_h( tmp ), 1 ) ); + move16(); } position[ar_decode( pardec, mode_num_nz )] = 1; + move32(); } - else + ELSE { *nz = 0; + move16(); } return; @@ -421,31 +452,36 @@ void decode_magnitude_usq_fx_ivas( { Word16 i, magnp, magnzp; Word16 magns[TCQ_MAX_BAND_SIZE], magncout = 0; - + move16(); Word16 storemagn, ovrflag, pos, tempmagn = 0, mmodel[MAX_PULSES + 2]; + move16(); Word32 cp, scp, fxone, fxp1; fxone = 32768; + move32(); fxp1 = 512 * 32768; + move32(); ovrflag = 0; - + move16(); set16_fx( magns, 1, TCQ_MAX_BAND_SIZE ); - if ( sub( nzpos, npulses ) == 0 ) + IF( sub( nzpos, npulses ) == 0 ) { - for ( i = 0; i < size; i++ ) + FOR( i = 0; i < size; i++ ) { out[i] = positions[i]; + move32(); } return; } - else if ( sub( nzpos, 1 ) == 0 ) + ELSE IF( sub( nzpos, 1 ) == 0 ) { - for ( i = 0; i < size; i++ ) + FOR( i = 0; i < size; i++ ) { if ( positions[i] != 0 ) { out[i] = npulses; + move32(); return; } } @@ -455,106 +491,119 @@ void decode_magnitude_usq_fx_ivas( magnp = sub( npulses, 1 ); magncout = 0; - + move16(); set32_fx( out, 0, size ); set16_fx( mmodel, 0, MAX_PULSES + 2 ); mmodel[0] = MAX_AR_FREQ; + move16(); magncout = 0; - for ( pos = 0; pos < size; pos++ ) + move16(); + FOR( pos = 0; pos < size; pos++ ) { scp = fxp1; - if ( positions[pos] != 0 ) + move32(); + IF( positions[pos] != 0 ) { storemagn = 0; - - for ( i = 0; i < magnp; i++ ) + move16(); + FOR( i = 0; i < magnp; i++ ) { ovrflag = 0; - - if ( magnzp == ( magnp - i ) ) + move16(); + IF( EQ_16( magnzp, sub( magnp, i ) ) ) { cp = 0; + move32(); } - else + ELSE { Word16 tmp; tmp = div_l( L_deposit_h( magnzp ), magnp - i ); cp = L_sub( fxone, tmp ); } - if ( cp == fxone ) + if ( EQ_32( cp, fxone ) ) { break; } scp = Mult_32_16( scp, extract_l( cp ) ); - mmodel[i + 1 - storemagn] = round_fx( L_shl( scp, 6 ) ); - - if ( ( mmodel[i + 1 - storemagn] == 0 && scp > 0 ) || mmodel[i - storemagn] == mmodel[i + 1 - storemagn] ) + mmodel[sub( add( i, 1 ), storemagn )] = round_fx( L_shl( scp, 6 ) ); + move16(); + IF( ( mmodel[sub( add( i, 1 ), storemagn )] == 0 && scp > 0 ) || EQ_16( mmodel[sub( i, storemagn )], mmodel[sub( add( i, 1 ), storemagn )] ) ) { - mmodel[i + 1 - storemagn] = 0; + mmodel[sub( add( i, 1 ), storemagn )] = 0; + move16(); /* read data */ tempmagn = (Word16) ar_decode( pardec, mmodel ); - storemagn += tempmagn; + storemagn = add( storemagn, tempmagn ); - if ( tempmagn < i ) + IF( LT_16( tempmagn, i ) ) { /* just magnitude */ ovrflag = 1; - break; + move16(); + BREAK; } - else + ELSE { /* esc code */ scp = fxp1; - i--; + move32(); + i = sub( i, 1 ); } } } - if ( ovrflag ) + IF( ovrflag ) { - out[magncout] = storemagn + 1; + out[magncout] = L_deposit_l( add( storemagn, 1 ) ); + move32(); } - else + ELSE { - out[magncout] = ar_decode( pardec, mmodel ) + storemagn + 1; + out[magncout] = L_add( ar_decode( pardec, mmodel ), L_deposit_l( add( storemagn, 1 ) ) ); + move32(); } - magnp -= (Word16) out[magncout]; - magnzp--; - magncout++; + magnp = sub( magnp, (Word16) out[magncout] ); + magnzp = sub( magnzp, 1 ); + magncout = add( magncout, 1 ); - if ( magnzp == 0 ) /* last magnitude generation */ + IF( magnzp == 0 ) /* last magnitude generation */ { - for ( pos = pos + 1; pos < size; pos++ ) + FOR( pos = add( pos, 1 ); pos < size; pos++ ) { - if ( positions[pos] != 0 ) + IF( positions[pos] != 0 ) { - out[magncout] = magnp + 1; + out[magncout] = L_deposit_l( add( magnp, 1 ) ); + move32(); return; } - else + ELSE { out[magncout] = 0; - magncout++; + move32(); + magncout = add( magncout, 1 ); } } } - else if ( magnzp == magnp ) /* rest magnitudes generation */ + ELSE IF( EQ_16( magnzp, magnp ) ) /* rest magnitudes generation */ { - for ( pos = pos + 1; pos < size; pos++ ) + FOR( pos = add( pos, 1 ); pos < size; pos++ ) { out[magncout] = positions[pos]; - magncout++; + move32(); + magncout = add( magncout, 1 ); } return; } } - else + ELSE { out[magncout] = 0; - magncout++; + move32(); + magncout = add( magncout, 1 ); } } @@ -571,11 +620,12 @@ static Word16 quantize_fx_ivas( qval4_fx = shr( abs_s( add( val, 512 ) ), 12 ); retval_fx = add( shl( qval4_fx, 2 ), DDP_fx[D] ); /* 2nd zero check */ - if ( D == 0 ) + IF( D == 0 ) { if ( sub( abs_s( sub( shl( abs_s( retval_fx ), 10 ), abs_s( val ) ) ), abs_s( val ) ) > 0 ) { retval_fx = 0; + move16(); } } @@ -600,57 +650,67 @@ void decode_mangitude_tcq_fx_ivas( Word16 leftp = npulses; /*pulsesnum; */ Word16 leftnz = nzpos; /*nzpos; */ Word16 magn_mode[3] = { MAX_AR_FREQ, 0, 0 }; - + move16(); + move16(); + move16(); bits_fx = 0; + move32(); tcq_bits_fx = L_sub( table_logcum_fx[npulses], L_add( table_logcum_fx[nzpos], table_logcum_fx[npulses - ( nzpos - 1 )] ) ); - if ( sub( nzpos, npulses ) == 0 ) + IF( sub( nzpos, npulses ) == 0 ) { - for ( i = 0; i < size; i++ ) + FOR( i = 0; i < size; i++ ) { out[i] = positions[i]; + move32(); } return; } - else if ( sub( nzpos, 1 ) == 0 ) + ELSE IF( sub( nzpos, 1 ) == 0 ) { - for ( i = 0; i < size; i++ ) + FOR( i = 0; i < size; i++ ) { - if ( positions[i] != 0 ) + IF( positions[i] != 0 ) { out[i] = npulses; + move32(); return; } } } st = 0; - for ( i = 0; i < size && leftnz > 1; i++ ) + move16(); + FOR( i = 0; i < size && leftnz > 1; i++ ) { out[i] = positions[i]; - if ( positions[i] != 0 ) + move32(); + IF( positions[i] != 0 ) { /*generate the trellis path */ symbol = 0; - for ( j = 0; j < leftp; j++ ) + move16(); + FOR( j = 0; j < leftp; j++ ) { num = sub( leftnz, 1 ); denum = sub( leftp, add( j, 1 ) ); - if ( sub( num, denum ) >= 0 ) + IF( sub( num, denum ) >= 0 ) { prob1_fx = MAX_16; prob0_fx = 0; + move16(); + move16(); } - else + ELSE { exp1 = sub( norm_s( num ), 1 ); exp2 = norm_s( denum ); prob1_fx = div_s( shl( num, exp1 ), shl( denum, exp2 ) ); /*15 + exp1 - exp2 */ - exp = 15 + exp1 - exp2; + exp = add( 15, sub( exp1, exp2 ) ); prob1_fx = shl( prob1_fx, sub( 15, exp ) ); prob0_fx = sub( MAX_16, prob1_fx ); } - if ( L_sub( sub( leftp, j ), leftnz ) == 0 ) + IF( L_sub( sub( leftp, j ), leftnz ) == 0 ) { symbol = add( j, 1 ); break; @@ -674,8 +734,8 @@ void decode_mangitude_tcq_fx_ivas( /*magn_mode[1] = (int16_t)(prob1 * MAX_AR_FREQ); */ magn_mode[1] = mult( prob1_fx, MAX_AR_FREQ ); - - if ( ar_decode( pardec, magn_mode ) ) + move16(); + IF( ar_decode( pardec, magn_mode ) ) { exp1 = norm_s( prob1_fx ); tmp32 = L_deposit_h( shl( prob1_fx, exp1 ) ); /*exp1 + 15 + 16 */ @@ -683,9 +743,9 @@ void decode_mangitude_tcq_fx_ivas( bits_fx = L_sub( bits_fx, L_sub( tmp16, L_shl( add( exp1, 1 ), 15 ) ) ); /*15 */ symbol = add( j, 1 ); - break; + BREAK; } - else + ELSE { exp1 = norm_s( prob0_fx ); tmp32 = L_deposit_h( shl( prob0_fx, exp1 ) ); /*exp1 + 15 + 16 */ @@ -694,32 +754,36 @@ void decode_mangitude_tcq_fx_ivas( } } out[i] = symbol; + move32(); /*leftp -= symbol; */ leftp = sub( leftp, symbol ); - leftnz--; + leftnz = sub( leftnz, 1 ); } quantum1_fx = quantize_fx_ivas( (Word16) out[i], ddec[st][0] ); quantum2_fx = quantize_fx_ivas( (Word16) out[i], ddec[st][1] ); /*generate the next state */ - if ( sub( quantum1_fx, (Word16) out[i] ) == 0 ) + IF( sub( quantum1_fx, (Word16) out[i] ) == 0 ) { st = nextstate[st][0]; } - else + ELSE { st = nextstate[st][1]; } + move16(); } /*generate the magnitudes */ - for ( ; i < size; i++ ) + FOR( ; i < size; i++ ) { out[i] = 0; + move32(); if ( positions[i] != 0 ) { out[i] = add( sub( leftp, leftnz ), 1 ); + move32(); } } @@ -727,6 +791,7 @@ void decode_mangitude_tcq_fx_ivas( { /*update the surplus */ *surplus_fx = L_add( *surplus_fx, L_sub( tcq_bits_fx, L_shl( bits_fx, 1 ) ) ); + move32(); } return; @@ -740,18 +805,18 @@ Word16 GetScale_fx_ivas( { Word16 pulses = MAX_PULSES, p_est, exp, exp1, exp2, magicnum, tmp; Word32 t, a, b, ab, estbits_fx = 0; - + move32(); magicnum = 24773; /*Q17: 0.188992013101951f; */ - + move16(); t = L_shr( L_mult( magicnum, blen ), 2 ); exp = norm_l( t ); - a = L_shl( 14 - exp, 15 ) + Log2_norm_lc( L_shl( t, exp ) ); + a = L_add( L_shl( L_deposit_l( sub( 14, exp ) ), 15 ), L_deposit_l( Log2_norm_lc( L_shl( t, exp ) ) ) ); exp1 = sub( norm_l( bits_fx ), 1 ); - exp2 = norm_s( blen - 1 ); + exp2 = norm_s( sub( blen, 1 ) ); - tmp = div_l( L_shl( bits_fx, exp1 ), shl( blen - 1, exp2 ) ); - b = L_shr( L_deposit_l( tmp ), exp1 - exp2 ); + tmp = div_l( L_shl( bits_fx, exp1 ), shl( sub( blen, 1 ), exp2 ) ); + b = L_shr( L_deposit_l( tmp ), sub( exp1, exp2 ) ); ab = L_add( a, b ); @@ -759,18 +824,19 @@ Word16 GetScale_fx_ivas( pulses = min( p_est, MAX_PULSES ); - for ( ; pulses >= 0; pulses-- ) + FOR( ; pulses >= 0; pulses-- ) { estbits_fx = GetBitsFromPulses_fx( pulses, blen ); - if ( L_sub( bits_fx, estbits_fx ) >= 0 ) + IF( L_sub( bits_fx, estbits_fx ) >= 0 ) { - break; + BREAK; } } if ( surplus_fx != NULL ) { *surplus_fx = L_add( *surplus_fx, L_sub( bits_fx, estbits_fx ) ); + move32(); } return pulses; @@ -784,11 +850,20 @@ void decode_signs_fx_ivas( { Word16 i; - for ( i = 0; i < size; i++ ) + FOR( i = 0; i < size; i++ ) { if ( out[i] != 0 ) { - out[i] = ( ar_decode( pardec, uniform_model ) > 0 ) ? out[i] : -out[i]; + IF( ar_decode( pardec, uniform_model ) > 0 ) + { + out[i] = out[i]; + } + ELSE + { + out[i] = L_negate( out[i] ); + } + + move32(); } } @@ -1144,16 +1219,17 @@ Word32 encode_magnitude_usq_fx_ivas( static void transmission_bits( PARCODEC arInst, - int16_t bit ) + Word16 bit ) { bitstream_save_bit( arInst->bsInst, bit ); - arInst->num_bits++; + arInst->num_bits = L_add( arInst->num_bits, 1 ); bit = !bit; - - for ( ; arInst->bits_to_follow > 0 && arInst->num_bits < arInst->max_bits; arInst->bits_to_follow-- ) + move16(); + FOR( ; arInst->bits_to_follow > 0 && arInst->num_bits < arInst->max_bits; arInst->bits_to_follow-- ) { bitstream_save_bit( arInst->bsInst, bit ); - arInst->num_bits++; + arInst->num_bits = L_add( arInst->num_bits, 1 ); + move32(); } return; @@ -1162,16 +1238,20 @@ static void transmission_bits( void ar_encoder_start( PARCODEC arInst, TCQ_PBITSTREAM bsInst, - int16_t max_bits ) + Word16 max_bits ) { arInst->bsInst = bsInst; arInst->low = 0; + move32(); arInst->high = AR_TOP; + move32(); arInst->bits_to_follow = 0; - + move16(); arInst->num_bits = 0; + move32(); arInst->max_bits = max_bits; + move32(); return; } @@ -1179,47 +1259,47 @@ void ar_encoder_start( static void ar_encode( PARCODEC arInst, - const int16_t *model, - int32_t symbol ) + const Word16 *model, + Word32 symbol ) { - uint32_t range, high, low; + UWord32 range, high, low; high = arInst->high; low = arInst->low; - symbol++; + symbol = L_add( symbol, 1 ); range = high - low + 1; high = low + ( range * model[symbol - 1] ) / model[0] - 1; low = low + ( range * model[symbol] ) / model[0]; - for ( ;; ) + FOR( ;; ) { - if ( high < AR_HALF ) + IF( high < AR_HALF ) { transmission_bits( arInst, 0 ); } - else + ELSE { - if ( low >= AR_HALF ) + IF( low >= AR_HALF ) { transmission_bits( arInst, 1 ); low -= AR_HALF; high -= AR_HALF; } - else + ELSE { - if ( low >= AR_FIRST && high < AR_THIRD ) + IF( low >= AR_FIRST && high < AR_THIRD ) { - arInst->bits_to_follow++; + arInst->bits_to_follow = add( arInst->bits_to_follow, 1 ); low -= AR_FIRST; high -= AR_FIRST; } - else + ELSE { - break; + BREAK; } } } @@ -1229,20 +1309,21 @@ static void ar_encode( } arInst->high = high; + move32(); arInst->low = low; - + move32(); return; } static void ar_encode_uniform( PARCODEC arInst, - uint16_t data, - const int16_t bits ) + UWord16 data, + const Word16 bits ) { - int16_t i; + Word16 i; - for ( i = 0; i < bits; i++ ) + FOR( i = 0; i < bits; i++ ) { ar_encode( arInst, uniform_model, data & 0x1 ); data >>= 1; @@ -1255,7 +1336,8 @@ static void ar_encode_uniform( void ar_encoder_done( PARCODEC arInst ) { - arInst->bits_to_follow++; + arInst->bits_to_follow = add( arInst->bits_to_follow, 1 ); + move16(); transmission_bits( arInst, arInst->low >= AR_FIRST ); return; @@ -1266,35 +1348,43 @@ void ar_decoder_start( PARCODEC arInst, TCQ_PBITSTREAM bsInst ) { - int16_t i; + Word16 i; arInst->bsInst = bsInst; - + move32(); + move32(); + move32(); + move32(); + move32(); + move16(); arInst->low = 0; arInst->high = AR_TOP; arInst->value = 0; - - for ( i = 0; i < AR_BITS; i++ ) + move32(); + move32(); + move32(); + FOR( i = 0; i < AR_BITS; i++ ) { - arInst->value = ( arInst->value << 1 ) + bitstream_load_bit( arInst->bsInst ); + arInst->value = L_add( L_shl( arInst->value, 1 ), bitstream_load_bit( arInst->bsInst ) ); + move32(); } return; } -static int32_t ar_decode( +static Word32 ar_decode( PARCODEC arInst, - const int16_t *model ) + const Word16 *model ) { - uint32_t range; - int16_t cum; - int16_t symbol; + UWord32 range; + Word16 cum; + Word16 symbol; - range = (uint32_t) ( arInst->high - arInst->low ) + 1; - cum = (int16_t) ( ( ( (uint32_t) ( arInst->value - arInst->low ) + 1 ) * model[0] - 1 ) / range ); + range = (UWord32) L_add( L_sub( arInst->high, arInst->low ), 1 ); + cum = (Word16) ( ( ( (UWord32) L_sub( arInst->value, arInst->low ) + 1 ) * model[0] - 1 ) / range ); - for ( symbol = 1; model[symbol] > cum; symbol++ ) + FOR( symbol = 1; model[symbol] > cum; symbol++ ) { ; } @@ -1302,36 +1392,45 @@ static int32_t ar_decode( arInst->high = arInst->low + ( range * model[symbol - 1] ) / model[0] - 1; arInst->low = arInst->low + ( range * model[symbol] ) / model[0]; - for ( ;; ) + FOR( ;; ) { - if ( arInst->high >= AR_HALF ) + IF( GE_32( arInst->high, AR_HALF ) ) { - if ( arInst->low >= AR_HALF ) + IF( GE_32( arInst->low, AR_HALF ) ) { - arInst->value -= AR_HALF; - arInst->low -= AR_HALF; - arInst->high -= AR_HALF; + arInst->value = L_sub( arInst->value, AR_HALF ); + move32(); + arInst->low = L_sub( arInst->low, AR_HALF ); + move32(); + arInst->high = L_sub( arInst->high, AR_HALF ); + move32(); } - else + ELSE { - if ( arInst->low >= AR_FIRST && arInst->high < AR_THIRD ) + IF( GE_32( arInst->low, AR_FIRST ) && LT_32( arInst->high, AR_THIRD ) ) { - arInst->value -= AR_FIRST; - arInst->low -= AR_FIRST; - arInst->high -= AR_FIRST; + arInst->value = L_sub( arInst->value, AR_FIRST ); + move32(); + arInst->low = L_sub( arInst->low, AR_FIRST ); + move32(); + arInst->high = L_sub( arInst->high, AR_FIRST ); + move32(); } - else + ELSE { - break; + BREAK; } } } - arInst->low <<= 1; - arInst->high = ( arInst->high << 1 ) + 1; - arInst->value = ( arInst->value << 1 ) + bitstream_load_bit( arInst->bsInst ); + arInst->low = L_shl( arInst->low, 1 ); + move32(); + arInst->high = L_add( L_shl( arInst->high, 1 ), 1 ); + move32(); + arInst->value = L_add( L_shl( arInst->value, 1 ), bitstream_load_bit( arInst->bsInst ) ); + move32(); } - return ( symbol - 1 ); + return ( sub( symbol, 1 ) ); } void ar_decoder_done( @@ -1343,17 +1442,17 @@ void ar_decoder_done( } -static int32_t ar_make_model( - const int16_t *freq, - int16_t *model, - const int16_t len ) +static Word32 ar_make_model( + const Word16 *freq, + Word16 *model, + const Word16 len ) { - int16_t dist; - uint32_t sum = 0; - uint32_t cum = 0; - int16_t i; + Word16 dist; + UWord32 sum = 0; + UWord32 cum = 0; + Word16 i; - for ( i = 0; i < len; i++ ) + FOR( i = 0; i < len; i++ ) { sum += freq[i]; } @@ -1363,58 +1462,62 @@ static int32_t ar_make_model( return 0; } - for ( i = len;; i-- ) + FOR( i = len;; i-- ) { - model[i] = (int16_t) ( ( cum * MAX_AR_FREQ ) / sum ); - + model[i] = (Word16) ( ( cum * MAX_AR_FREQ ) / sum ); + move16(); if ( !i ) { - break; + BREAK; } cum += freq[i - 1]; } - for ( i = 0; i < len - 1; i++ ) + FOR( i = 0; i < sub( len, 1 ); i++ ) { - dist = model[i] - model[i + 1]; + dist = sub( model[i], model[i + 1] ); if ( dist <= 0 ) { - model[i + 1] += dist - 1; + model[i + 1] = add( model[i + 1], sub( dist, 1 ) ); + move16(); } } - for ( i = len; i; i-- ) + FOR( i = len; i; i-- ) { - dist = model[i - 1] - model[i]; + dist = sub( model[i - 1], model[i] ); if ( dist <= 0 ) { - model[i - 1] -= dist - 1; + model[i - 1] = sub( model[i - 1], sub( dist, 1 ) ); + move16(); } } - return ( model[0] > model[1] ); + return ( GT_16( model[0], model[1] ) ); } static void bitstream_save_bit( TCQ_PBITSTREAM pBS, - const int16_t bit ) + const Word16 bit ) { - uint8_t cur; + UWord8 cur; cur = pBS->buf[pBS->numByte]; - cur = (uint8_t) ( cur | ( bit << pBS->curPos-- ) ); + cur = (UWord8) ( cur | shl( bit, pBS->curPos-- ) ); pBS->buf[pBS->numByte] = cur; - pBS->numbits++; + pBS->numbits = L_add( pBS->numbits, 1 ); if ( pBS->curPos < 0 ) { pBS->curPos = 7; - pBS->numByte++; + move16(); + pBS->numByte = L_add( pBS->numByte, 1 ); + move32(); } return; @@ -1424,22 +1527,25 @@ static void bitstream_save_bit( static uint32_t bitstream_load_bit( TCQ_PBITSTREAM pBS ) { - uint32_t bit; + UWord32 bit; Word16 *curPos; /* safety check in case of bit errors */ - if ( pBS->numByte >= pBS->maxBytes ) + if ( GE_32( pBS->numByte, pBS->maxBytes ) ) { return 0; } curPos = &pBS->curPos; + move16(); bit = ( ( pBS->buf[pBS->numByte] >> ( *curPos )-- ) & 0x00000001 ); if ( *curPos < 0 ) { - pBS->numByte++; + pBS->numByte = L_add( pBS->numByte, 1 ); + move32(); *curPos = 7; + move16(); } return bit; @@ -1448,18 +1554,20 @@ static uint32_t bitstream_load_bit( static void bitstream_rollback( TCQ_PBITSTREAM pBS, - int16_t numBits ) + Word16 numBits ) { - while ( numBits > 0 ) + WHILE( numBits > 0 ) { - pBS->curPos++; - pBS->numbits--; - if ( pBS->curPos == 8 ) + pBS->curPos = add( pBS->curPos, 1 ); + pBS->numbits = L_sub( pBS->numbits, 1 ); + IF( EQ_16( pBS->curPos, 8 ) ) { pBS->curPos = 0; - pBS->numByte--; + move16(); + pBS->numByte = L_sub( pBS->numByte, 1 ); + move32(); } - numBits--; + numBits = sub( numBits, 1 ); } return; @@ -1930,10 +2038,10 @@ float GetISCScale( void InitLSBTCQ( - int16_t *bcount ) + Word16 *bcount ) { *bcount = 0; - + move16(); return; } @@ -2068,12 +2176,12 @@ void TCQLSBdec( void SaveTCQdata( PARCODEC arInst, - int16_t *dpath, - int16_t bcount ) + Word16 *dpath, + Word16 bcount ) { - int16_t i; + Word16 i; - for ( i = 0; i < bcount; i++ ) + FOR( i = 0; i < bcount; i++ ) { ar_encode_uniform( arInst, dpath[i], 1 ); } @@ -2083,14 +2191,15 @@ void SaveTCQdata( void LoadTCQdata( PARCODEC arInst, - int16_t *dpath, - int16_t bcount ) + Word16 *dpath, + Word16 bcount ) { - int16_t i; + Word16 i; - for ( i = 0; i < bcount; i++ ) + FOR( i = 0; i < bcount; i++ ) { - dpath[i] = (int16_t) ar_decode( arInst, uniform_model ); + dpath[i] = (Word16) ar_decode( arInst, uniform_model ); + move16(); } return; diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c index 6c62b0a3c..b0b8bb8e3 100644 --- a/lib_com/tns_base.c +++ b/lib_com/tns_base.c @@ -1097,12 +1097,12 @@ static Word32 IIRLattice( Word16 order, const Word16 *parCoeff, Word32 *state, W /* first stage: no need to calculate state[order-1] */ - x = L_sub( x, Mpy_32_16_1( state[order - 1], parCoeff[order - 1] ) ); + x = Msub_32_16( x, state[order - 1], parCoeff[order - 1] ); FOR( i = order - 2; i >= 0; i-- ) { - x = L_sub( x, Mpy_32_16_1( state[i], parCoeff[i] ) ); - state[i + 1] = L_add( state[i], Mpy_32_16_1( x, parCoeff[i] ) ); + x = Msub_32_16( x, state[i], parCoeff[i] ); + state[i + 1] = Madd_32_16( state[i], x, parCoeff[i] ); move32(); } diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 6d17d6a4a..c0f402d61 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -573,6 +573,24 @@ void Copy32( } } } + +void set8_fx( + Word8 y[], /* i/o: Vector to set */ + const Word8 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ +) +{ + Word16 i; + + FOR( i = 0; i < N; i++ ) + { + y[i] = a; + move16(); + } + + return; +} + /*-------------------------------------------------------------------* * set16_fx() * set32_fx() diff --git a/lib_com/weight_a_fx.c b/lib_com/weight_a_fx.c index 3177fea34..61f453a20 100644 --- a/lib_com/weight_a_fx.c +++ b/lib_com/weight_a_fx.c @@ -29,7 +29,7 @@ void weight_a_subfr_fx( orderp1 = add( order, 1 ); FOR( k = 0; k < nb_subfr; k++ ) { - weight_a_fx( &A[k * ( orderp1 )], &Aw[k * ( orderp1 )], gamma, order ); + weight_a_fx( &A[imult1616( k, ( orderp1 ) )], &Aw[imult1616( k, ( orderp1 ) )], gamma, order ); } return; @@ -78,8 +78,10 @@ void weight_a_lc_fx( FOR( i = 1; i < m; i++ ) { ap[i] = round_fx( L_shl( L_mult0( a[i], *ptr_gamma++ ), shift ) ); + move16(); } ap[m] = round_fx( L_shl( L_mult0( a[m], *ptr_gamma++ ), shift ) ); + move16(); return; } @@ -100,7 +102,9 @@ void weight_a_fx( Word32 Amax; Word16 shift; #ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; + Flag Overflow; + Overflow = 0; + move32(); #endif fac = gamma; @@ -124,9 +128,11 @@ void weight_a_fx( #else /* BASOP_NOGLOB */ ap[i] = round_fx( L_shl( L_mult0( a[i], fac ), shift ) ); #endif + move16(); fac = mult_r( fac, gamma ); } ap[m] = round_fx( L_shl( L_mult0( a[m], fac ), shift ) ); + move16(); return; } @@ -157,13 +163,46 @@ void E_LPC_a_weight_inv( 17350, 18859, 20499, 22281, 24219, 26325, 28614, 31102 }; /* Q13 */ static const Word16 inv_gamma_tab_16k[16] = { 17430, 18542, 19726, 20985, 22324, 23749, 25265, 26878, /* Q14 */ 14297, 15209, 16180, 17213, 18312, 19480, 20724, 22047 }; /* Q13 */ + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + const Word16 *inv_gamma_tab; Word32 L_tmp; Word32 Amax; Word16 shift; - IF( inv_gamma == 16384 ) + IF( EQ_16( inv_gamma, 16384 ) ) { FOR( i = 0; i <= m; i++ ) { @@ -177,11 +216,9 @@ void E_LPC_a_weight_inv( assert( m == 16 ); inv_gamma_tab = inv_gamma_tab_12k8; - move16(); if ( EQ_16( inv_gamma, GAMMA16k_INV ) ) { inv_gamma_tab = inv_gamma_tab_16k; - move16(); } @@ -201,12 +238,14 @@ void E_LPC_a_weight_inv( { L_tmp = L_mult( a[i], inv_gamma_tab[i - 1] ); ap[i] = round_fx( L_shl( L_tmp, shift ) ); + move16(); } shift = add( shift, 1 ); FOR( i = 9; i < 17; i++ ) { L_tmp = L_mult( a[i], inv_gamma_tab[i - 1] ); ap[i] = round_fx( L_shl( L_tmp, shift ) ); + move16(); } diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index e1ffd2adf..2ea166a70 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -194,7 +194,7 @@ ivas_error amr_wb_dec_fx( st_fx->hPFstat->reset = 1; move16(); } - IF( GT_16( st_fx->bfi, 0 ) ) + IF( st_fx->bfi > 0 ) { st_fx->nbLostCmpt = add( st_fx->nbLostCmpt, 1 ); move16(); @@ -226,7 +226,7 @@ ivas_error amr_wb_dec_fx( move16(); test(); test(); - if ( st_fx->last_con_tcx && ( NE_16( st_fx->L_frameTCX_past, st_fx->L_frame ) ) && ( ( st_fx->last_core != 0 ) ) ) + if ( st_fx->last_con_tcx && ( NE_16( st_fx->L_frameTCX_past, st_fx->L_frame ) ) && ( st_fx->last_core != 0 ) ) { avoid_lpc_burst_on_recovery = 1; move16(); @@ -244,7 +244,6 @@ ivas_error amr_wb_dec_fx( /* in case of switching, do not apply BPF */ st_fx->bpf_off = 1; move16(); - IF( st_fx->hPFstat->on ) { Word16 mem_syn_r_size_old, mem_syn_r_size_new; @@ -353,7 +352,7 @@ ivas_error amr_wb_dec_fx( } /*End of _DIFF_FLOAT_FIX_*/ test(); - if ( EQ_16( st_fx->last_bwidth, NB ) && NE_16( st_fx->ini_frame, 0 ) ) + if ( EQ_16( st_fx->last_bwidth, NB ) && st_fx->ini_frame != 0 ) { st_fx->rate_switching_reset = 1; move16(); @@ -385,16 +384,9 @@ ivas_error amr_wb_dec_fx( class_para_fx = 0; move16(); - // has been moved to updt_dec_common_fx() - // if( st_fx->first_CNG == 0 ) - //{ - // st_fx->first_CNG = 1; - // move16(); - //} - delta_mem_scale = 3; move16(); - test(); + if ( LT_32( st_fx->lp_ener_fx, 40 ) ) /* very low energy frames, less than 0.3125 */ { delta_mem_scale = 0; @@ -432,6 +424,7 @@ ivas_error amr_wb_dec_fx( frame_energy_fx( L_FRAME, pitch_temp, syn_fx, 0, &frame_e_fx, st_fx->Q_syn ); /*st->psf_lp_noise = 0.99f * st->psf_lp_noise + 0.01f * frame_e; */ st_fx->psf_lp_noise_fx = round_fx( L_mac( L_mult( 32440, st_fx->psf_lp_noise_fx ), 328, frame_e_fx ) ); /*Q8*/ + move16(); } /* update old synthesis for classification */ Copy( syn_fx + L_FRAME - L_SYN_MEM_CLAS_ESTIM, st_fx->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM ); @@ -510,6 +503,7 @@ ivas_error amr_wb_dec_fx( /*st->lp_ener = 0.7f * st->lp_ener + 0.3f * ftmp;*/ L_tmp = Mult_32_16( st_fx->lp_ener_fx, 22938 ); st_fx->lp_ener_fx = L_add( L_tmp, Mult_32_16( L_tmp1, 9830 ) ); /*Q6 + Q6*/ + move32(); FOR( i = 0; i < M; i++ ) { L_tmp = L_mult( 3277, lsp_new_fx[i] ); @@ -539,7 +533,7 @@ ivas_error amr_wb_dec_fx( move16(); test(); test(); - IF( EQ_16( st_fx->coder_type, INACTIVE ) && st_fx->flag_cna && GE_16( st_fx->psf_lp_noise_fx, shl( 15, 7 ) ) ) + if ( EQ_16( st_fx->coder_type, INACTIVE ) && st_fx->flag_cna && GE_16( st_fx->psf_lp_noise_fx, shl( 15, 7 ) ) ) { tmp16 = 1; move16(); @@ -582,7 +576,7 @@ ivas_error amr_wb_dec_fx( tmp_coder_type = AUDIO; move16(); test(); - IF( EQ_16( st_fx->last_coder_type, INACTIVE ) || EQ_16( st_fx->last_coder_type, UNVOICED ) ) + if ( EQ_16( st_fx->last_coder_type, INACTIVE ) || EQ_16( st_fx->last_coder_type, UNVOICED ) ) { tmp_coder_type = INACTIVE; move16(); @@ -784,11 +778,11 @@ ivas_error amr_wb_dec_fx( flag_cna = 0; move16(); test(); - IF( ( GE_16( st_fx->psf_lp_noise_fx, ( 15 << 8 ) ) ) || EQ_16( st_fx->coder_type, INACTIVE ) ) + IF( ( GE_16( st_fx->psf_lp_noise_fx, ( 15 * ONE_IN_Q8 ) ) ) || EQ_16( st_fx->coder_type, INACTIVE ) ) { /*VAD only for non inactive frame*/ test(); - IF( EQ_16( st_fx->VAD, 1 ) && NE_16( st_fx->coder_type, INACTIVE ) ) + IF( EQ_16( st_fx->VAD, 1 ) && st_fx->coder_type != INACTIVE ) { st_fx->VAD = 1; move16(); @@ -811,7 +805,7 @@ ivas_error amr_wb_dec_fx( noisy_speech_detection_fx( st_fx->hFdCngDec, st_fx->VAD, syn_fx, st_fx->Q_syn ); st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech = mult_r( st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 32440 /*0.99 Q15*/ ); - IF( NE_16( st_fx->hFdCngDec->hFdCngCom->flag_noisy_speech, 0 ) ) + IF( st_fx->hFdCngDec->hFdCngCom->flag_noisy_speech != 0 ) { st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech = add( st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 328 /*0.01 Q15*/ ); move16(); @@ -838,7 +832,6 @@ ivas_error amr_wb_dec_fx( generate_masking_noise_update_seed_fx( st_fx->hFdCngDec->hFdCngCom ); } - IF( !flag_cna ) { test(); @@ -869,7 +862,7 @@ ivas_error amr_wb_dec_fx( resampleCldfb( st_fx->cldfbAna, newCldfbBands, L_FRAME, 0 ); resampleCldfb( st_fx->cldfbBPF, newCldfbBands, L_FRAME, 0 ); - if ( st_fx->ini_frame > 0 ) + IF( st_fx->ini_frame > 0 ) { st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->cldfbAna->no_channels ); move16(); @@ -902,6 +895,7 @@ ivas_error amr_wb_dec_fx( { /* in case of BW switching, re-init to default */ st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->cldfbAna->no_channels ); + move16(); } cldfb_synth_set_bandsToZero( st_fx, realBuffer, imagBuffer, CLDFB_NO_COL_MAX, scaleFactor ); /* CLDFB synthesis of the combined signal */ @@ -968,7 +962,7 @@ ivas_error amr_wb_dec_fx( test(); test(); test(); - test(); + if ( !st_fx->bfi && st_fx->prev_bfi && GE_32( st_fx->last_total_brate, HQ_48k ) && EQ_16( st_fx->last_codec_mode, MODE2 ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) && EQ_16( st_fx->plcInfo.concealment_method, TCX_NONTONAL ) && LT_32( st_fx->plcInfo.nbLostCmpt, 4 ) ) { waveadj_rec = 1; @@ -1093,6 +1087,7 @@ ivas_error amr_wb_dec_fx( /* HP filter */ Scale_sig32( st_fx->L_mem_hp_out_fx, 4, sub( st_fx->Q_syn2, st_fx->Qprev_synth_buffer_fx ) ); st_fx->Qprev_synth_buffer_fx = st_fx->Q_syn2; + move16(); hp20( synth_out_fx, 1 /*stride*/, output_frame, st_fx->L_mem_hp_out_fx, L_mult0( output_frame, 50 ) ); /* save synthesis for core switching */ diff --git a/lib_dec/arith_coder_dec.c b/lib_dec/arith_coder_dec.c index 0bffd6963..507a8d2e0 100644 --- a/lib_dec/arith_coder_dec.c +++ b/lib_dec/arith_coder_dec.c @@ -245,7 +245,7 @@ void tcx_arith_decode_envelope( gamma_uw = 1.0f / st->gamma_float; #define WMC_TOOL_SKIP - tcx_arith_render_envelope_flt( A_ind, L_frame, L_spec, FL2WORD16( hTcxCfg->preemph_fac_flt ), FL2WORD16( gamma_w ), FL2WORD16( 0.5f * gamma_uw ), env ); + tcx_arith_render_envelope_ivas( 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 ) @@ -278,7 +278,7 @@ void tcx_arith_decode_envelope( } envelope = (Word16 *) env; - tcx_arith_scale_envelope_flt( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e ); + tcx_arith_scale_envelope_ivas( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e ); *arith_bits = tcx_arith_decode( L_spec, envelope, envelope_e, target_bits, prm, q_spectrum ); @@ -362,7 +362,7 @@ void tcx_arith_decode_envelope_ivas_fx( move16(); #define WMC_TOOL_SKIP - tcx_arith_render_envelope_flt( A_ind, L_frame, L_spec, hTcxCfg->preemph_fac, gamma_w, gamma_uw, env ); + tcx_arith_render_envelope_ivas( A_ind, L_frame, L_spec, hTcxCfg->preemph_fac, gamma_w, gamma_uw, env ); #undef WMC_TOOL_SKIP IF( use_hm != 0 ) diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index d1fb87d05..e4bab0bf9 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -2094,11 +2094,11 @@ void generate_masking_noise_ivas_fx( /* Perform STFT synthesis */ IF( secondary ) { - SynthesisSTFT_fx( fftBuffer_fx, *exp_out, maskingNoise_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); + SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); } ELSE { - SynthesisSTFT_fx( fftBuffer_fx, *exp_out, maskingNoise_fx, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); + SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); } *exp_out = sub( *exp_out, Q9 ); move16(); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 5840e553d..5e79a9ffc 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -204,6 +204,9 @@ ivas_error ivas_dec_setup( { IF( EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) { + test(); + test(); + test(); IF( ( st_ivas->ini_active_frame == 0 ) && NE_32( ivas_total_brate, FRAME_NO_DATA ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && EQ_16( st_ivas->nCPE, 1 ) ) { st_ivas->hCPE[0]->nchan_out = 1; @@ -277,7 +280,7 @@ ivas_error ivas_dec_setup( num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); /* read Ambisonic (SBA) order */ - IF( LT_32( ivas_total_brate, IVAS_256k ) ) + if ( LT_32( ivas_total_brate, IVAS_256k ) ) { st_ivas->sba_order = 3; move16(); @@ -326,7 +329,7 @@ ivas_error ivas_dec_setup( move16(); FOR( k = 0; k < MC_LS_SETUP_BITS; k++ ) { - IF( st_ivas->bit_stream[num_bits_read + k] ) + IF( st_ivas->bit_stream[add( num_bits_read, k )] ) { idx = add( idx, shl( 1, sub( ( MC_LS_SETUP_BITS - 1 ), k ) ) ); } @@ -390,8 +393,7 @@ ivas_error ivas_dec_setup( st_ivas->nchan_transport = 1; move16(); BREAK; - case SID_MASA_2TC: - move16(); + case SID_MASA_2TC:; // empyt statement for declaration Word32 res_dec, res_frac; iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 ); IF( EQ_16( st_ivas->bit_stream[L_sub( L_sub( res_dec, 1 ), SID_FORMAT_NBITS )], 1 ) ) @@ -481,7 +483,7 @@ ivas_error ivas_dec_setup( k = sub( k, 1 ); test(); - if ( st_ivas->ini_frame > 0 && nchan_ism != st_ivas->nchan_ism ) + if ( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong number of objects signalled!" ); } @@ -519,7 +521,7 @@ ivas_error ivas_dec_setup( * and number of transport channels *-------------------------------------------------------------------*/ - IF( st_ivas->ini_frame == 0 && NE_32( st_ivas->ivas_format, UNDEFINED_FORMAT ) ) + IF( st_ivas->ini_frame == 0 && st_ivas->ivas_format != UNDEFINED_FORMAT ) { IF( NE_32( ( error = doSanityChecks_IVAS( st_ivas ) ), IVAS_ERR_OK ) ) { @@ -990,7 +992,7 @@ static ivas_error ivas_read_format( /* read IVAS format */ k = 0; move16(); - IF( st_ivas->bit_stream[*num_bits_read] ) + if ( st_ivas->bit_stream[*num_bits_read] ) { k = 1; move16(); @@ -998,7 +1000,7 @@ static ivas_error ivas_read_format( k = shl( k, 1 ); ( *num_bits_read ) = add( ( *num_bits_read ), 1 ); move16(); - IF( st_ivas->bit_stream[*num_bits_read] ) + if ( st_ivas->bit_stream[*num_bits_read] ) { k = add( k, 1 ); } @@ -1059,7 +1061,7 @@ static ivas_error ivas_read_format( move16(); st_ivas->sba_order = add( st_ivas->sba_order, shl( st_ivas->bit_stream[add( add( ( *num_bits_read ), 1 ), SBA_PLANAR_BITS )], 1 ) ); move16(); - IF( st_ivas->sba_order == 0 ) + if ( st_ivas->sba_order == 0 ) { st_ivas->ivas_format = SBA_ISM_FORMAT; move32(); @@ -1124,7 +1126,7 @@ static ivas_error ivas_read_format( move32(); Word32 res_dec, res_frac; iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 ); - IF( st_ivas->bit_stream[res_dec - 1] == 1 ) + IF( EQ_32( st_ivas->bit_stream[res_dec - 1], 1 ) ) { st_ivas->element_mode_init = IVAS_CPE_MDCT; move16(); @@ -1142,7 +1144,7 @@ static ivas_error ivas_read_format( IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) { - IF( st_ivas->sba_analysis_order == 0 ) + if ( st_ivas->sba_analysis_order == 0 ) { st_ivas->sba_analysis_order = SBA_FOA_ORDER; move16(); @@ -1342,7 +1344,6 @@ Word16 getNumChanSynthesis( n = add( st_ivas->nSCE, imult1616( CPE_CHANNELS, st_ivas->nCPE ) ); test(); test(); - test(); IF( st_ivas->sba_dirac_stereo_flag ) { n = CPE_CHANNELS; @@ -1497,7 +1498,7 @@ ivas_error ivas_init_decoder_front( IF( st_ivas->hDecoderConfig->Opt_LsCustom ) { - IF( ( error = ivas_ls_custom_open_fx( &( st_ivas->hLsSetupCustom ) ) ) == IVAS_ERR_OK ) + IF( EQ_32( ( error = ivas_ls_custom_open_fx( &( st_ivas->hLsSetupCustom ) ) ), IVAS_ERR_OK ) ) { #ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED set_zero( ( st_ivas->hLsSetupCustom )->ls_azimuth, MAX_OUTPUT_CHANNELS ); @@ -1606,7 +1607,7 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize Binaural Renderer configuration handle *--------------------------------------------------------------------*/ - IF( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { IF( NE_32( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ), IVAS_ERR_OK ) ) { @@ -1865,7 +1866,7 @@ ivas_error ivas_init_decoder_fx( IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { - IF( ( error = ivas_ls_custom_output_init_fx( st_ivas ) ) == IVAS_ERR_OK ) + IF( EQ_16( ( error = ivas_ls_custom_output_init_fx( st_ivas ) ), IVAS_ERR_OK ) ) { st_ivas->hOutSetup.ls_azimuth_fx = st_ivas->hLsSetupCustom->ls_azimuth_fx; move32(); @@ -2020,6 +2021,7 @@ ivas_error ivas_init_decoder_fx( IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2 = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed3; + move16(); } ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) ) { @@ -2093,7 +2095,7 @@ ivas_error ivas_init_decoder_fx( { st_ivas->hSpar->enc_param_start_band = 0; move16(); - set_c( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); + set8_fx( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); st_ivas->hQMetaData->numTwoDirBands = (UWord8) st_ivas->hQMetaData->q_direction[0].cfg.nbands; move16(); } @@ -2177,7 +2179,6 @@ ivas_error ivas_init_decoder_fx( test(); test(); test(); - test(); IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) ) @@ -2280,11 +2281,12 @@ ivas_error ivas_init_decoder_fx( Word16 band_grouping[IVAS_MAX_NUM_BANDS + 1]; st_ivas->hSpar->enc_param_start_band = s_min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); + move16(); IF( ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order ) ) { st_ivas->hSpar->enc_param_start_band = 0; move16(); - set_c( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); + set8_fx( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); st_ivas->hQMetaData->numTwoDirBands = (UWord8) st_ivas->hQMetaData->q_direction[0].cfg.nbands; move16(); } @@ -2385,8 +2387,7 @@ ivas_error ivas_init_decoder_fx( test(); WHILE( LT_16( k, SIZE_IVAS_BRATE_TBL ) && NE_32( ivas_total_brate, ivas_brate_tbl[k] ) ) { - k++; - move16(); + k = add( k, 1 ); } test(); IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) @@ -2619,7 +2620,7 @@ ivas_error ivas_init_decoder_fx( st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); move16(); test(); - IF( NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) && NE_32( st_ivas->renderer_type, RENDERER_MCMASA_MONO_STEREO ) ) + IF( st_ivas->renderer_type != RENDERER_DISABLE && NE_32( st_ivas->renderer_type, RENDERER_MCMASA_MONO_STEREO ) ) { IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) ) { @@ -2702,7 +2703,7 @@ ivas_error ivas_init_decoder_fx( } /* set CNA/CNG flags */ - IF( EQ_16( st_ivas->nchan_transport, 1 ) && ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) + IF( EQ_16( st_ivas->nchan_transport, 1 ) && ( ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) ) { st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag = 1; move16(); @@ -2750,8 +2751,6 @@ ivas_error ivas_init_decoder_fx( test(); test(); test(); - test(); - test(); IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { IF( NE_32( ( error = ivas_binRenderer_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) @@ -2991,7 +2990,7 @@ ivas_error ivas_init_decoder_fx( FOR( Word16 nS = 0; nS < nchan_rend; nS++ ) { TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]]; - IF( Src_p->SrcSpatial_p != NULL ) + if ( Src_p->SrcSpatial_p != NULL ) { Src_p->SrcSpatial_p->q_Pos_p = Q31; move16(); @@ -3070,7 +3069,7 @@ ivas_error ivas_init_decoder_fx( test(); test(); test(); - IF( ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !st_ivas->sba_dirac_stereo_flag && st_ivas->hDecoderConfig->nchan_out != 1 ) + IF( ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !st_ivas->sba_dirac_stereo_flag && NE_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) { #ifdef IVAS_FLOAT_FIXED #if 1 @@ -5279,7 +5278,6 @@ void ivas_init_dec_get_num_cldfb_instances( } } - test(); IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) ) { test(); @@ -5791,7 +5789,6 @@ static ivas_error doSanityChecks_IVAS( IF( st_ivas->hDecoderConfig->Opt_Headrotation ) { - test(); test(); test(); IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) @@ -5802,7 +5799,6 @@ static ivas_error doSanityChecks_IVAS( IF( st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { - test(); test(); test(); IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) @@ -5822,7 +5818,7 @@ static ivas_error doSanityChecks_IVAS( IF( st_ivas->hDecoderConfig->Opt_aeid_on ) { - IF( output_config != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + IF( NE_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { return IVAS_ERROR( IVAS_ERR_ACOUSTIC_ENVIRONMENT_NOT_SUPPORTED, "Wrong set-up: Acoustic environment is not supported in this output configuration." ); } @@ -5833,6 +5829,7 @@ static ivas_error doSanityChecks_IVAS( test(); IF( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { + return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for combined MASA and ISM format" ); } } diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 6c2bc239e..4cb343648 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -2531,7 +2531,7 @@ void ivas_mdct_core_tns_ns_fx( FOR( Word16 i = 0; i < st->hTonalMDCTConc->nScaleFactors; i++ ) { - sns_int_scf_fx[i] = L_add( Mpy_32_16_1( L_shl( scf_last_m[i], add( 1, scf_last_e[i] ) ), fade_out ), Mpy_32_16_1( L_shl( scf_bg[i], 1 ), fade_in ) ); + sns_int_scf_fx[i] = Madd_32_16( Mpy_32_16_1( L_shl( scf_last_m[i], add( 1, scf_last_e[i] ) ), fade_out ), L_shl( scf_bg[i], 1 ), fade_in ); move32(); } } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index e3d43dd5a..38df6b53f 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -66,13 +66,13 @@ static ivas_error ivas_spar_dec_MD( Decoder_Struct *st_ivas, Decoder_State *st0 #endif -#ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------- * ivas_spar_dec_open() * * Allocate and initialize SPAR decoder handle and sub-handles *------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_spar_dec_open( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ @@ -531,6 +531,7 @@ ivas_error ivas_spar_dec_open_fx( } #endif + /*------------------------------------------------------------------------- * ivas_spar_dec_close() * @@ -556,7 +557,6 @@ void ivas_spar_dec_close( ivas_td_decorr_dec_close( &( *hSpar )->hTdDecorr ); /* FB mixer handle */ - ivas_FB_mixer_close( &( *hSpar )->hFbMixer, output_Fs, spar_reconfig_flag ); /* AGC */ @@ -959,6 +959,7 @@ static int16_t ivas_parse_spar_header( } #endif + #ifdef IVAS_FLOAT_FIXED static Word16 get_random_number_fx( Word16 *seed ) @@ -975,6 +976,7 @@ static float get_random_number( } #endif // IVAS_FLOAT_FIXED + #ifdef IVAS_FLOAT_FIXED static Word32 matrix_det_fx( const Word32 a00, @@ -984,9 +986,7 @@ static Word32 matrix_det_fx( { return L_sub( Mpy_32_32( a00, a11 ), Mpy_32_32( a01, a10 ) ); } -#endif - -#ifndef IVAS_FLOAT_FIXED +#else static float matrix_det( const float a00, const float a01, @@ -997,6 +997,7 @@ static float matrix_det( } #endif + #ifdef IVAS_FLOAT_FIXED static void matrix_inverse_fx( Word32 in[3][3], @@ -1078,9 +1079,7 @@ static void matrix_inverse_fx( return; } -#endif - -#ifndef IVAS_FLOAT_FIXED +#else static void matrix_inverse( float in[3][3], float out[3][3], @@ -1134,6 +1133,7 @@ static void matrix_inverse( * * *---------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED void ivas_spar_get_cldfb_gains_fx( SPAR_DEC_HANDLE hSpar, @@ -1276,7 +1276,7 @@ void ivas_spar_get_cldfb_gains_fx( /* target is synthesis output times the cross-fade window*/ FOR( sample = 0; sample < num_samples; sample++ ) { - tgt_fx[sample] = L_shl( Mult_32_32( tgt_fx[sample], L_add( T_fx[sample][0], L_add( T_fx[sample][1], T_fx[sample][2] ) ) ), 10 ); /*Q31*/ + tgt_fx[sample] = L_shl( Mpy_32_32( tgt_fx[sample], L_add( T_fx[sample][0], L_add( T_fx[sample][1], T_fx[sample][2] ) ) ), 10 ); /*Q31*/ move32(); } /* compute matrices */ @@ -1288,7 +1288,7 @@ void ivas_spar_get_cldfb_gains_fx( move32(); FOR( sample = 0; sample < num_samples; sample++ ) { - Tt_T_fx[slot_row][slot_col] = L_add( Tt_T_fx[slot_row][slot_col], Mult_32_32( L_shl( T_fx[sample][slot_row], 8 ), L_shl( T_fx[sample][slot_col], 8 ) ) ); /*Q58-Q31*/ + Tt_T_fx[slot_row][slot_col] = L_add( Tt_T_fx[slot_row][slot_col], Mpy_32_32( L_shl( T_fx[sample][slot_row], 8 ), L_shl( T_fx[sample][slot_col], 8 ) ) ); /*Q58-Q31*/ move32(); } } @@ -1306,7 +1306,7 @@ void ivas_spar_get_cldfb_gains_fx( move32(); FOR( sample = 0; sample < num_samples; sample++ ) { - Tt_tgt_fx[slot_row] = L_add( Tt_tgt_fx[slot_row], Mult_32_32( T_fx[sample][slot_row], tgt_fx[sample] ) ); + Tt_tgt_fx[slot_row] = L_add( Tt_tgt_fx[slot_row], Mpy_32_32( T_fx[sample][slot_row], tgt_fx[sample] ) ); move32(); } } @@ -1320,7 +1320,7 @@ void ivas_spar_get_cldfb_gains_fx( move32(); FOR( slot_col = 0; slot_col < num_cf_slots; slot_col++ ) { - tmp = L_add( tmp, Mult_32_32( Tt_T_inv_fx[slot_row][slot_col], Tt_tgt_fx[slot_col] ) ); + tmp = L_add( tmp, Mpy_32_32( Tt_T_inv_fx[slot_row][slot_col], Tt_tgt_fx[slot_col] ) ); } weights_fx[add( cf_cldfb_start, slot_row )] = extract_l( L_shr( L_max( L_min( tmp, L_shl( 1, sub( output_q, 10 ) ) ), 0 ), sub( sub( output_q, 10 ), Q_weights ) ) ); /*Q_weights*/ move16(); @@ -1799,6 +1799,7 @@ static ivas_error ivas_spar_dec_MD( * * *-------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED static Word16 ivas_spar_get_cldfb_slot_gain_fx( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ @@ -1964,6 +1965,7 @@ static float ivas_spar_get_cldfb_slot_gain( * * *-------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED void ivas_spar_get_parameters_fx( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ @@ -2026,7 +2028,6 @@ void ivas_spar_get_parameters_fx( return; } #else - void ivas_spar_get_parameters( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ @@ -2081,6 +2082,7 @@ void ivas_spar_get_parameters( } #endif + /*-------------------------------------------------------------------* * ivas_spar_get_skip_mat() * @@ -2218,6 +2220,7 @@ static void ivas_spar_get_skip_mat_fx( } #endif + #ifdef IVAS_FLOAT_FIXED static void ivas_spar_calc_smooth_facs_fx( Word32 *cldfb_in_ts_re_fx[CLDFB_NO_COL_MAX], // i @@ -2457,6 +2460,7 @@ static void ivas_spar_calc_smooth_facs( } #endif + /*-------------------------------------------------------------------* * ivas_spar_dec_agc_pca() * @@ -2579,11 +2583,13 @@ void ivas_spar_dec_agc_pca_fx( } #endif + /*-------------------------------------------------------------------* * ivas_spar_dec_set_render_map() * * *-------------------------------------------------------------------*/ + #ifndef IVAS_FLOAT_FIXED void ivas_spar_dec_set_render_map( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -2651,13 +2657,14 @@ void ivas_spar_dec_set_render_map_fx( } #endif -#ifndef IVAS_FLOAT_FIXED + /*-------------------------------------------------------------------* * ivas_spar_dec_upmixer() * * IVAS SPAR upmixer *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_spar_dec_set_render_params( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const int16_t n_cldfb_slots /* i : number of cldfb slots in this frame */ @@ -2699,11 +2706,13 @@ void ivas_spar_dec_set_render_params_fx( } #endif + /*-------------------------------------------------------------------* * ivas_spar_dec_digest_tc() * * *-------------------------------------------------------------------*/ + #ifndef IVAS_FLOAT_FIXED void ivas_spar_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ @@ -2876,6 +2885,7 @@ void ivas_spar_dec_digest_tc_fx( } #endif + #ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * ivas_spar_dec_upmixer() @@ -3002,6 +3012,14 @@ void ivas_spar_dec_upmixer( return; } #endif + + +/*-------------------------------------------------------------------* + * ivas_spar_dec_upmixer_sf() + * + * IVAS SPAR upmixer + *-------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED void ivas_spar_dec_upmixer_sf_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ @@ -3196,7 +3214,7 @@ void ivas_spar_dec_upmixer_sf_fx( { FOR( in_ch = 0; in_ch < numch_in; in_ch++ ) { - mixer_mat_fx[out_ch][in_ch][spar_band] = L_add( Mult_32_16( mixer_mat_fx[out_ch][in_ch][spar_band], sub( 32767, hSpar->hMdDec->smooth_fac_fx[spar_band] ) ), Mult_32_16( hSpar->hMdDec->mixer_mat_prev2_fx[out_ch][in_ch][spar_band], hSpar->hMdDec->smooth_fac_fx[spar_band] ) ); /*q1*/ + mixer_mat_fx[out_ch][in_ch][spar_band] = Madd_32_16( Mpy_32_16_1( mixer_mat_fx[out_ch][in_ch][spar_band], sub( 32767, hSpar->hMdDec->smooth_fac_fx[spar_band] ) ), hSpar->hMdDec->mixer_mat_prev2_fx[out_ch][in_ch][spar_band], hSpar->hMdDec->smooth_fac_fx[spar_band] ); /*q1*/ move32(); hSpar->hMdDec->mixer_mat_prev2_fx[out_ch][in_ch][spar_band] = mixer_mat_fx[out_ch][in_ch][spar_band]; move32(); @@ -3237,13 +3255,13 @@ void ivas_spar_dec_upmixer_sf_fx( { /* accumulate contributions from all SPAR bands */ Word16 tmp = extract_l( L_shr( bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band], 7 ) ); - cldfb_par_fx = L_add_sat( cldfb_par_fx, Mult_32_16( mixer_mat_fx[out_ch][in_ch][spar_band], tmp ) ); /*q1*/ + cldfb_par_fx = L_add_sat( cldfb_par_fx, Mpy_32_16_1( mixer_mat_fx[out_ch][in_ch][spar_band], tmp ) ); /*q1*/ } } - out_re_fx[out_ch] = L_add( out_re_fx[out_ch], Mult_32_32( cldfb_in_ts_re_fx[in_ch][ts][cldfb_band], cldfb_par_fx ) ); /*q1-25*/ + out_re_fx[out_ch] = Madd_32_32( out_re_fx[out_ch], cldfb_in_ts_re_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); /*q1-25*/ move32(); - out_im_fx[out_ch] = L_add( out_im_fx[out_ch], Mult_32_32( cldfb_in_ts_im_fx[in_ch][ts][cldfb_band], cldfb_par_fx ) ); /*q1-25*/ + out_im_fx[out_ch] = Madd_32_32( out_im_fx[out_ch], cldfb_in_ts_im_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); /*q1-25*/ move32(); } } @@ -3384,7 +3402,6 @@ void ivas_spar_dec_upmixer_sf_fx( return; } #else - void ivas_spar_dec_upmixer_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float *output[], /* o : output audio channels */ diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index 39466c34b..4ac20d1e6 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -46,7 +46,7 @@ static void dqlsf_CNG_fx( move16(); /* deindex_lvq_cng decoder does not need to know the sampling rate, the sampling rate data is embedded inside the LSF coefficients */ - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + IF( st_fx->element_mode == EVS_MONO ) { ber_flag = deindex_lvq_cng_fx( &indice[1], lsf_q, indice[0], LSF_BITS_CNG - 4, &st_fx->offset_scale1_fx[0][0], &st_fx->offset_scale2_fx[0][0], &st_fx->no_scales_fx[0][0] ); @@ -57,6 +57,7 @@ static void dqlsf_CNG_fx( deindex_lvq_cng_ivas_fx( &indice[1], lsf_q, indice[0], LSF_BITS_CNG - 4 ); } st_fx->BER_detect = s_or( ber_flag, st_fx->BER_detect ); + move16(); /* The sampling frequency of the LP-CNG frame can be determined by checking the value of the highest order LSF coefficient (last coefficient). If the last decoded LSF coefficient is larger than 6350 the decoded frame is WB2 with sampling rate of 16 kHz @@ -122,8 +123,11 @@ void lsf_dec_fx( Word16 param_lpc[NPRM_LPC_NEW]; Word32 L_tmp; Word16 nBits = 0; + move16(); Word16 tmp_old[M + 1], tmp_new[M + 1]; Word16 enr_old = 0, enr_new = 0; + move16(); + move16(); Word16 lsf_diff, coder_type; /* initialize */ @@ -134,7 +138,7 @@ void lsf_dec_fx( move16(); } test(); - if ( EQ_16( coder_type, AUDIO ) && GT_16( st_fx->GSC_IVAS_mode, 0 ) ) + if ( EQ_16( coder_type, AUDIO ) && st_fx->GSC_IVAS_mode > 0 ) { coder_type = GENERIC; move16(); @@ -164,7 +168,7 @@ void lsf_dec_fx( { nBits = 30; move16(); - if ( EQ_16( st_fx->bwidth, NB ) ) + if ( st_fx->bwidth == NB ) { nBits = 32; move16(); @@ -195,10 +199,11 @@ void lsf_dec_fx( { st_fx->seed_acelp = 0; move16(); - FOR( i = no_param_lpc - 1; i >= 0; i-- ) + FOR( i = sub( no_param_lpc, 1 ); i >= 0; i-- ) { /* rightshift before *seed_acelp+param_lpc[i] to avoid overflows*/ - st_fx->seed_acelp = (int16_t) ( ( ( ( st_fx->seed_acelp ) >> 1 ) + param_lpc[i] ) * 31821L + 13849L ); + st_fx->seed_acelp = extract_l( L_add( imult3216( 31821L, add( shr( ( st_fx->seed_acelp ), 1 ), param_lpc[i] ) ), 13849L ) ); + move16(); // PMTE() /*IVAS_CODE to be completed */ } } @@ -218,6 +223,7 @@ void lsf_dec_fx( L_tmp = L_mac( L_tmp, st_fx->lsfoldbfi1_fx[i], 10922 ); /*Q(x2.56+16)*/ L_tmp = L_mac( L_tmp, st_fx->lsfoldbfi0_fx[i], 10922 ); /*Q(x2.56+16)*/ st_fx->lsf_adaptive_mean_fx[i] = round_fx( L_tmp ); /*Q(x2.56)*/ + move16(); } test(); @@ -245,7 +251,7 @@ void lsf_dec_fx( * Mid-frame LSF decoding * LSP interpolation and conversion of LSPs to A(z) *-------------------------------------------------------------------------------------*/ - if ( st_fx->rate_switching_reset ) + IF( st_fx->rate_switching_reset ) { /*extrapolation in case of unstable LSF convert*/ Copy( lsp_new, st_fx->lsp_old_fx, M ); @@ -277,7 +283,7 @@ void lsf_dec_fx( test(); test(); test(); - if ( EQ_16( st_fx->clas_dec, UNVOICED_CLAS ) || EQ_16( st_fx->clas_dec, SIN_ONSET ) || EQ_16( st_fx->clas_dec, INACTIVE_CLAS ) || EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) ) + if ( st_fx->clas_dec == UNVOICED_CLAS || EQ_16( st_fx->clas_dec, SIN_ONSET ) || st_fx->clas_dec == INACTIVE_CLAS || EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) ) { st_fx->relax_prev_lsf_interp = 1; move16(); @@ -286,12 +292,13 @@ void lsf_dec_fx( } } test(); - IF( EQ_16( st_fx->last_core, HQ_CORE ) && EQ_16( st_fx->core, ACELP_CORE ) ) + IF( EQ_16( st_fx->last_core, HQ_CORE ) && st_fx->core == ACELP_CORE ) { /* update old LSPs/LSFs in case of HQ->ACELP core switching */ Copy( lsp_mid, st_fx->lsp_old_fx, M ); lsp2lsf_fx( lsp_mid, st_fx->lsf_old_fx, M, st_fx->sr_core ); } + test(); IF( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( coder_type, UNVOICED ) ) { // PMT("To be verified") @@ -314,13 +321,15 @@ void lsf_dec_fx( * Check LSF stability (distance between old LSFs and current LSFs) *------------------------------------------------------------------*/ - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + IF( st_fx->element_mode == EVS_MONO ) { st_fx->stab_fac_fx = lsf_stab_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame ); /*Q15*/ + move16(); } - else + ELSE { st_fx->stab_fac_fx = lsf_stab_ivas_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame ); + move16(); } return; @@ -413,6 +422,7 @@ void lsf_end_dec_fx( test(); test(); #ifdef LSF_RE_USE_SECONDARY_CHANNEL + test(); IF( ( EQ_16( coder_type_org, GENERIC ) ) && ( EQ_32( st->sr_core, INT_FS_16k ) ) && ( mode2_flag == 0 ) && ( st->idchan == 0 ) ) #else IF( ( EQ_16( coder_type_org, GENERIC ) ) && ( EQ_32( st->sr_core, INT_FS_16k ) ) && ( mode2_flag == 0 ) ) @@ -461,6 +471,8 @@ void lsf_end_dec_fx( * Select safety_net or predictive mode *--------------------------------------------------------------------------*/ #if defined LSF_RE_USE_SECONDARY_CHANNEL || defined FIX_798_LSF_SECONDARY_CH_MISSING_CODE + test(); + test(); IF( st->tdm_LRTD_flag == 0 && EQ_16( st->idchan, 1 ) && tdm_lsfQ_PCh != NULL ) { /* if secondary channel predmode is set to be > 2 */ @@ -484,6 +496,8 @@ void lsf_end_dec_fx( } ELSE { + test(); + test(); IF( EQ_16( mode2_flag, 1 ) || EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) ) { /* read from param_lpc */ @@ -505,11 +519,12 @@ void lsf_end_dec_fx( * Read indices from array *--------------------------------------------------------------------------*/ #if defined LSF_RE_USE_SECONDARY_CHANNEL || defined FIX_798_LSF_SECONDARY_CH_MISSING_CODE + test(); /* Make sure there are the correct bit allocations */ IF( EQ_16( st->idchan, 1 ) && GT_16( predmode, 2 ) ) { /* use same AR prediction bit allocation for intra and inter modes*/ - lsf_allocate_fx( nBits - 1, mode_lvq, 9, &stages0, &stages1, levels0, levels1, bits0, bits1 ); + lsf_allocate_fx( sub( nBits, 1 ), mode_lvq, 9, &stages0, &stages1, levels0, levels1, bits0, bits1 ); stages0 = stages1; Copy( levels1, levels0, stages0 ); Copy( bits1, bits0, stages0 ); @@ -527,8 +542,8 @@ void lsf_end_dec_fx( { *nb_indices = 10; move16(); - move16(); TCQIdx[0] = safety_net; + move16(); FOR( i = 1; i < *nb_indices; i++ ) { TCQIdx[i] = *p_lpc_param++; @@ -571,7 +586,7 @@ void lsf_end_dec_fx( test(); IF( EQ_16( mode2_flag, 1 ) || EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) ) { - FOR( i = 0; i < stages - 1; i++ ) + FOR( i = 0; i < sub( stages, 1 ); i++ ) { num_bits = bits[i]; move16(); @@ -607,6 +622,7 @@ void lsf_end_dec_fx( num_bits = bits[i]; move16(); lindice[i + 1] = (Word16) get_next_indice( st, num_bits ); + move16(); } cumleft = levels[sub( stages, 1 )]; @@ -627,6 +643,7 @@ void lsf_end_dec_fx( } lindice[i + 1] = (Word16) get_next_indice( st, num_bits ); + move16(); i = add( i, 1 ); } } @@ -639,6 +656,7 @@ void lsf_end_dec_fx( move16(); } st->reset_mem_AR = 0; + move16(); } /*------------------------------------------------------------------------------------------* @@ -653,7 +671,7 @@ void lsf_end_dec_fx( IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( coder_type, VOICED ) && flag_1bit_gran == 0 ) { /* BC-TCVQ decoder */ - safety_net = qlsf_ARSN_tcvq_Dec_16k_fx( qlsf, TCQIdx, nBits - 1 ); + safety_net = qlsf_ARSN_tcvq_Dec_16k_fx( qlsf, TCQIdx, sub( nBits, 1 ) ); /* Update mem_MA */ Copy( qlsf, st->mem_MA_fx, M ); @@ -667,6 +685,7 @@ void lsf_end_dec_fx( FOR( i = 0; i < M; i++ ) { pred0[i] = add( ModeMeans_fx[mode_lvq][i], mult( Predictors_fx[mode_lvq_p][i], ( sub( st->mem_AR_fx[i], ModeMeans_fx[mode_lvq][i] ) ) ) ); /* Q(x2.56)*/ + move16(); } *LSF_Q_prediction = AUTO_REGRESSIVE; move16(); @@ -682,10 +701,11 @@ void lsf_end_dec_fx( FOR( i = 0; i < M; i++ ) { pred1[i] = add( pred0[i], mult_r( MU_MA_FX, st->mem_MA_fx[i] ) ); + move16(); } #if defined LSF_RE_USE_SECONDARY_CHANNEL || defined FIX_798_LSF_SECONDARY_CH_MISSING_CODE /* TD stereo SCh: perform intra-frame prediction with pulling-to-mean */ - if ( st->tdm_LRTD_flag == 0 && EQ_16( st->idchan, 1 ) && tdm_lsfQ_PCh != NULL ) + IF( st->tdm_LRTD_flag == 0 && EQ_16( st->idchan, 1 ) && tdm_lsfQ_PCh != NULL ) { tdm_SCh_LSF_intra_pred_fx( st->element_brate, tdm_lsfQ_PCh, pred3 ); } @@ -694,30 +714,34 @@ void lsf_end_dec_fx( { /* LVQ */ #if defined LSF_RE_USE_SECONDARY_CHANNEL || defined FIX_798_LSF_SECONDARY_CH_MISSING_CODE - if ( st->tdm_LRTD_flag == 0 && EQ_16( st->idchan, 1 ) && tdm_lsfQ_PCh != NULL ) + test(); + test(); + IF( st->tdm_LRTD_flag == 0 && EQ_16( st->idchan, 1 ) && tdm_lsfQ_PCh != NULL ) { /* intra mode*/ - st->BER_detect = st->BER_detect | - vq_dec_lvq_ivas_fx( 0, qlsf, &lindice[1], stages0, M, 9, levels0[stages0 - 1] ); + st->BER_detect = s_or( st->BER_detect, + vq_dec_lvq_ivas_fx( 0, qlsf, &lindice[1], stages0, M, 9, levels0[stages0 - 1] ) ); + move16(); Vr_add( qlsf, pred3, qlsf, M ); Vr_subt( qlsf, pred1, st->mem_MA_fx, M ); } - else + ELSE #endif { - if ( st->element_mode != EVS_MONO ) + IF( st->element_mode != EVS_MONO ) { ber_flag = vq_dec_lvq_ivas_fx( 1, qlsf, &lindice[1], stages0, M, mode_lvq, levels0[stages0 - 1] ); } - else + ELSE { ber_flag = vq_dec_lvq_fx( 1, qlsf, &lindice[1], stages0, M, mode_lvq, levels0[stages0 - 1], &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->offset_scale1_p_fx[0][0], &st->offset_scale2_p_fx[0][0], &st->no_scales_fx[0][0], &st->no_scales_p_fx[0][0] ); } st->BER_detect = s_or( st->BER_detect, ber_flag ); + move16(); Vr_add( qlsf, pred0, qlsf, M ); Vr_subt( qlsf, pred1, st->mem_MA_fx, M ); } @@ -733,17 +757,18 @@ void lsf_end_dec_fx( move16(); } #endif - if ( st->element_mode != EVS_MONO ) + IF( st->element_mode != EVS_MONO ) { ber_flag = vq_dec_lvq_ivas_fx( 0, qlsf, &lindice[1], stages1, M, mode_lvq_p, levels1[stages1 - 1] ); } - else + ELSE { ber_flag = vq_dec_lvq_fx( 0, qlsf, &lindice[1], stages1, M, mode_lvq_p, levels1[stages1 - 1], &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->offset_scale1_p_fx[0][0], &st->offset_scale2_p_fx[0][0], &st->no_scales_fx[0][0], &st->no_scales_p_fx[0][0] ); } st->BER_detect = s_or( st->BER_detect, ber_flag ); + move16(); #if defined LSF_RE_USE_SECONDARY_CHANNEL || defined FIX_798_LSF_SECONDARY_CH_MISSING_CODE test(); IF( EQ_16( predmode, 1 ) || EQ_16( predmode, 4 ) ) /* MA only */ @@ -762,6 +787,7 @@ void lsf_end_dec_fx( FOR( i = 0; i < M; i++ ) { pred2[i] = add( pred0[i], mult( Predictors_fx[mode_lvq_p][i], sub( st->mem_AR_fx[i], pred0[i] ) ) ); + move16(); } Vr_add( qlsf, pred2, qlsf, M ); Vr_subt( qlsf, pred1, st->mem_MA_fx, M ); @@ -910,9 +936,10 @@ void lsf_mid_dec_fx( /* Calculation of mid-LSF vector */ FOR( j = 0; j < M; j++ ) { - L_tmp = L_mult( sub( 0x2000, ratio[idx * M + j] ), qlsf0[j] ); /*Q(x2.56+13+1)->Q(x2.56+14)*/ - L_tmp = L_mac( L_tmp, ratio[idx * M + j], qlsf1[j] ); /*Q(x2.56+14)*/ - qlsf[j] = round_fx( L_shl( L_tmp, 2 ) ); /*Q(x2.56)*/ + L_tmp = L_mult( sub( 0x2000, ratio[add( i_mult( idx, M ), j )] ), qlsf0[j] ); /*Q(x2.56+13+1)->Q(x2.56+14)*/ + L_tmp = L_mac( L_tmp, ratio[add( i_mult( idx, M ), j )], qlsf1[j] ); /*Q(x2.56+14)*/ + qlsf[j] = round_fx( L_shl( L_tmp, 2 ) ); /*Q(x2.56)*/ + move16(); } /* check for incorrect LSF ordering */ diff --git a/lib_dec/lsf_msvq_ma_dec_fx.c b/lib_dec/lsf_msvq_ma_dec_fx.c index 13e41a8d2..a8fb91fe3 100644 --- a/lib_dec/lsf_msvq_ma_dec_fx.c +++ b/lib_dec/lsf_msvq_ma_dec_fx.c @@ -42,19 +42,16 @@ Word16 lsf_msvq_ma_decprm( Decoder_State *st, Word16 *param_lpc ) { find_pred_mode( &predmode, GENERIC, sub( 1, st->narrowBand ) /*st->bwidth*/, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate ); - move16(); } ELSE { IF( EQ_16( st->core, TCX_20_CORE ) ) { find_pred_mode( &predmode, AUDIO, sub( 1, st->narrowBand ) /*st->bwidth*/, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate ); - move16(); } ELSE { find_pred_mode( &predmode, st->coder_type, sub( 1, st->narrowBand ) /*st->bwidth*/, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate ); - move16(); } } lsf_allocate_fx( sub( ENDLSF_NBITS, shr( predmode, 1 ) ), mode_lvq, mode_lvq_p, &stages0, &stages1, levels0, levels1, bits0, bits1 ); @@ -100,15 +97,18 @@ Word16 lsf_msvq_ma_decprm( Decoder_State *st, Word16 *param_lpc ) FOR( i = 0; i < tmp; i++ ) { *param_lpc = get_next_indice_fx( st, bits[i] ); + move16(); param_lpc++; nbits_lpc = add( nbits_lpc, bits[i] ); } *param_lpc = get_next_indice_fx( st, LEN_INDICE ); + move16(); param_lpc++; nbits_lpc = add( nbits_lpc, LEN_INDICE ); - *param_lpc = get_next_indice_fx( st, bits[i] - LEN_INDICE ); + *param_lpc = get_next_indice_fx( st, sub( bits[i], LEN_INDICE ) ); + move16(); param_lpc++; nbits_lpc = add( nbits_lpc, sub( bits[i], LEN_INDICE ) ); @@ -119,6 +119,7 @@ Word16 lsf_msvq_ma_decprm( Decoder_State *st, Word16 *param_lpc ) { *param_lpc = get_next_indice_fx( st, bits_midlpc ); + move16(); nbits_lpc = add( nbits_lpc, bits_midlpc ); } @@ -135,14 +136,17 @@ Word16 lsf_bctcvq_decprm( const Word16 *bits1; num_par = 10; + move16(); bits1 = BC_TCVQ_BIT_ALLOC_40B; nbits_lpc = 0; + move16(); FOR( i = 0; i < num_par; i++ ) { *param_lpc = get_next_indice_fx( st, bits1[i] ); + move16(); param_lpc++; nbits_lpc = add( nbits_lpc, bits1[i] ); } diff --git a/lib_dec/nelp_dec_fx.c b/lib_dec/nelp_dec_fx.c index dfafc8d09..418e74bcb 100644 --- a/lib_dec/nelp_dec_fx.c +++ b/lib_dec/nelp_dec_fx.c @@ -32,6 +32,7 @@ static void normalize_arr( Word16 *arr, Word16 *qf, Word16 size, Word16 hdr ) { Word16 i; Word16 max_s = 0; + move16(); FOR( i = 0; i < size; i++ ) { @@ -46,7 +47,8 @@ static void normalize_arr( Word16 *arr, Word16 *qf, Word16 size, Word16 hdr ) move16(); } - *qf = *qf - hdr; + *qf = sub( *qf, hdr ); + move16(); FOR( i = 0; i < size; i++ ) { @@ -88,10 +90,12 @@ static void normalize_arr( Word16 *arr, Word16 *qf, Word16 size, Word16 hdr ) void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word16 *Q_exc, Word16 bfi, const Word16 coder_type, Word16 *gain_buf ) { Word16 i, fid = 0; + move16(); Word16 ptr[L_FRAME], filtRes[L_FRAME], gain_fac; /*ptr, filtRes - Q0, gain_fac - Q14 */ Word16 Gains[10]; /* Q0 */ Word32 Gain, E3, E2; Word16 BP1_ORDER = 4; + move16(); Word16 ptr_tmp[L_FRAME]; /* Q0 */ Word16 iG1, iG2[2]; Word16 exp_E2, exp_E3, frac_E2, frac_E3; @@ -101,20 +105,25 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1 Word32 max_exc_sqr; Word16 n; Word16 max_val = 0, norm_val = 0; + move16(); + move16(); Word16 qGain = 0; + move16(); SC_VBR_DEC_HANDLE hSC_VBR; hSC_VBR = st_fx->hSC_VBR; + test(); if ( EQ_16( st_fx->last_nelp_mode_dec, 1 ) && NE_16( st_fx->bwidth, st_fx->last_bwidth ) ) { st_fx->last_nelp_mode_dec = 0; + move16(); } test(); test(); test(); - IF( EQ_16( coder_type, UNVOICED ) && EQ_16( st_fx->bwidth, NB ) ) + IF( EQ_16( coder_type, UNVOICED ) && st_fx->bwidth == NB ) { IF( NE_16( st_fx->last_nelp_mode_dec, 1 ) ) { @@ -130,7 +139,7 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1 move16(); IF( NE_16( st_fx->last_nelp_mode_dec, 1 ) ) { - set16_fx( hSC_VBR->bp1_filt_mem_wb_dec_fx, 0, BP1_ORDER * 2 ); + set16_fx( hSC_VBR->bp1_filt_mem_wb_dec_fx, 0, shl( BP1_ORDER, 1 ) ); } } @@ -147,8 +156,11 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1 IF( EQ_16( st_fx->rf_frame_type, RF_NELP ) && EQ_16( st_fx->use_partial_copy, 1 ) ) { iG1 = st_fx->rf_indx_nelp_iG1; + move16(); iG2[0] = st_fx->rf_indx_nelp_iG2[0]; + move16(); iG2[1] = st_fx->rf_indx_nelp_iG2[1]; + move16(); } ELSE { @@ -169,6 +181,7 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1 IF( EQ_16( st_fx->rf_frame_type, RF_NELP ) && EQ_16( st_fx->use_partial_copy, 1 ) ) { fid = st_fx->rf_indx_nelp_fid; + move16(); } ELSE { @@ -220,8 +233,8 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1 frac = round_fx( L_shl( Gain, n ) ); n = sub( add( n, 24 ), 30 ); frac = div_s( 16384, frac ); - Gain = Isqrt_lc( L_deposit_h( frac ), &n ); /*Q(31-n-exp) */ - tmp = round_fx( L_shl( Gain, sub( n + exp, 15 ) ) ); /*Q0 */ + Gain = Isqrt_lc( L_deposit_h( frac ), &n ); /*Q(31-n-exp) */ + tmp = round_fx( L_shl( Gain, sub( add( n, exp ), 15 ) ) ); /*Q0 */ } ELSE { @@ -245,6 +258,7 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1 move16(); /* 1.16f - Q14 */ } + test(); IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) ) { /* Normalize Gains[10] with headroom 4, qGain is the new Q value os Gains, not Q0*/ @@ -261,17 +275,17 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1 { BP1_ORDER = 4; move16(); - Scale_sig( hSC_VBR->bp1_filt_mem_wb_dec_fx, 2 * BP1_ORDER, qGain ); /* bring filter prev memory from Q0 to qGain */ + Scale_sig( hSC_VBR->bp1_filt_mem_wb_dec_fx, shl( BP1_ORDER, 1 ), qGain ); /* bring filter prev memory from Q0 to qGain */ pz_filter_sp_fx( bp1_num_coef_wb_fx, bp1_den_coef_wb_fx, ptr, ptr_tmp, hSC_VBR->bp1_filt_mem_wb_dec_fx, BP1_ORDER, BP1_ORDER, L_FRAME, ( sub( 16, BP1_COEF_WB_QF ) ) ); - Scale_sig( hSC_VBR->bp1_filt_mem_wb_dec_fx, 2 * BP1_ORDER, -qGain ); /* bring filter prev memory from qGain to Q0 */ - Scale_sig( ptr_tmp, L_FRAME, -qGain ); /* bring nelp_exc to Q0 */ + Scale_sig( hSC_VBR->bp1_filt_mem_wb_dec_fx, shl( BP1_ORDER, 1 ), negate( qGain ) ); /* bring filter prev memory from qGain to Q0 */ + Scale_sig( ptr_tmp, L_FRAME, -qGain ); /* bring nelp_exc to Q0 */ Copy( ptr_tmp, ptr, L_FRAME ); } test(); - IF( EQ_16( coder_type, UNVOICED ) && ( EQ_16( st_fx->bwidth, NB ) ) ) + IF( EQ_16( coder_type, UNVOICED ) && ( st_fx->bwidth == NB ) ) { BP1_ORDER = 7; move16(); @@ -296,6 +310,7 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1 Scale_sig32( hSC_VBR->bp1_filt_mem_nb_dec_fx, shl( BP1_ORDER, 1 ), norm_val ); Scale_sig( ptr, L_FRAME, norm_val ); *Q_exc = add( norm_val, *Q_exc ); + move16(); } BP1_ORDER = 7; @@ -306,7 +321,7 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1 IF( norm_val > 0 ) { - Scale_sig32( hSC_VBR->bp1_filt_mem_nb_dec_fx, shl( BP1_ORDER, 1 ), -norm_val ); + Scale_sig32( hSC_VBR->bp1_filt_mem_nb_dec_fx, shl( BP1_ORDER, 1 ), negate( norm_val ) ); } Copy( ptr_tmp, ptr, L_FRAME ); /*Q_exc */ @@ -387,7 +402,7 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1 #else frac_E2 = round_fx( L_shl( E2, exp_E2 ) ); #endif - exp_E2 = sub( 30, add( exp_E2, 2 * ( *Q_exc ) ) ); + exp_E2 = sub( 30, add( exp_E2, shl( ( *Q_exc ), 1 ) ) ); scale = shr( sub( frac_E3, frac_E2 ), 15 ); frac_E2 = shl( frac_E2, scale ); @@ -402,6 +417,7 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1 { L_tmp = Mult_32_16( L_tmp1, ptr[i] ); /*Q(16-exp+Q_exc) */ ptr[i] = round_fx( L_shl( L_tmp, exp ) ); /*Q_exc */ + move16(); } } diff --git a/lib_dec/peak_vq_dec_fx.c b/lib_dec/peak_vq_dec_fx.c index cb93bdd7c..356592067 100644 --- a/lib_dec/peak_vq_dec_fx.c +++ b/lib_dec/peak_vq_dec_fx.c @@ -43,6 +43,7 @@ void hvq_dec_fx( Word16 noise_level_idx; bits = num_bits; + move16(); FOR( i = 0; i < HVQ_BWE_NOISE_BANDS; i++ ) { @@ -114,7 +115,7 @@ static void peak_vq_dec_fx( assert( ( core_brate > HQ_16k40 && core_brate <= HQ_48k ) && "HVQ rate not supported" ); // PMT("max_peaks equation needs to be converted") - max_peaks = (Word16) ( ( core_brate * HVQ_PEAKS_PER_DELTA + HVQ_PEAKS_PER_DELTA_OFFS ) / HVQ_PEAKS_BPS_DELTA ); + max_peaks = extract_l( Mpy_32_32( ( L_add( imult3216( core_brate, HVQ_PEAKS_PER_DELTA ), HVQ_PEAKS_PER_DELTA_OFFS ) ), 282564 ) ); /* 1 / HVQ_PEAKS_BPS_DELTA in Q31 = 282564*/ /*max_peaks = ((core_brate * HVQ_PEAKS_PER_DELTA / HVQ_PEAKS_BPS_DELTA + HVQ_PEAKS_PER_DELTA_OFFS / HVQ_PEAKS_BPS_DELTA) );*/ #if 0 { @@ -126,10 +127,13 @@ static void peak_vq_dec_fx( } #endif bin_th = HVQ_THRES_BIN_24k; + move16(); bin_th2 = HVQ_THRES_BIN_24k / HVQ_NF_GROUPS; + move16(); IF( GE_32( core_brate, HQ_BWE_CROSSOVER_BRATE ) ) { bin_th = HVQ_THRES_BIN_32k; + move16(); bin_th2 = HVQ_THRES_BIN_32k / HVQ_NF_GROUPS; move16(); } @@ -169,10 +173,12 @@ static void peak_vq_dec_fx( test(); FOR( i = 0; i < bin_th && j < vq_peaks; i++ ) /* safety check in case of bit errors */ { + test(); IF( res_vec[i] != 0 ) { - vq_peak_idx[j++] = i; + vq_peak_idx[j] = i; move16(); + j = add( j, 1 ); } } @@ -183,6 +189,7 @@ static void peak_vq_dec_fx( move16(); vq_peaks = sub( j, 1 ); *Npeaks = sub( j, 1 ); + move16(); } /* Huffman or differential coding */ @@ -190,6 +197,7 @@ static void peak_vq_dec_fx( /* De-quantize peak gains */ pgain_difidx[0] = get_next_indice( st_fx, GAIN0_BITS ); + move16(); /* safety check in case of bit errors */ IF( GT_16( pgain_difidx[0], 44 ) ) @@ -211,7 +219,7 @@ static void peak_vq_dec_fx( move16(); IF( FlagN ) { - huff_dec_fx( st_fx, vq_peaks - 1, MAX_PG_HUFFLEN, NUM_PG_HUFFLEN, hvq_pg_huff_thres, hvq_pg_huff_offset, hvq_pg_huff_tab, &pgain_difidx[1] ); + huff_dec_fx( st_fx, sub( vq_peaks, 1 ), MAX_PG_HUFFLEN, NUM_PG_HUFFLEN, hvq_pg_huff_thres, hvq_pg_huff_offset, hvq_pg_huff_tab, &pgain_difidx[1] ); FOR( i = 1; i < vq_peaks; i++ ) { @@ -298,7 +306,7 @@ static void peak_vq_dec_fx( /* safety check in case of bit errors */ test(); - if ( pvq_bands == 0 && EQ_16( st_fx->element_mode, EVS_MONO ) ) /* PVQ bands may be zero for IVAS */ + if ( pvq_bands == 0 && st_fx->element_mode == EVS_MONO ) /* PVQ bands may be zero for IVAS */ { st_fx->BER_detect = 1; move16(); @@ -328,11 +336,10 @@ static void peak_vq_dec_fx( pPvqVector = pvq_vector; pCoefsOut = coefs_out; pSelBnds = sel_bnds; - move16(); FOR( k = 0; k < pvq_bands; k++ ) { - pvq_norm[k] = get_next_indice( st_fx, HVQ_PVQ_GAIN_BITS ); - pvq_norm[k] = add( pvq_norm[k], 8 ); + pvq_norm[k] = add( get_next_indice( st_fx, HVQ_PVQ_GAIN_BITS ), 8 ); + // pvq_norm[k] = add( pvq_norm[k], 8 ); move16(); diff = add( diff, HVQ_PVQ_GAIN_BITS ); @@ -343,13 +350,12 @@ static void peak_vq_dec_fx( { i = band_start_harm[*pSelBnds++]; move16(); - move16(); pCoefsOut = coefs_out + i; } normq = L_add( dicn_fx[pvq_norm[k]], 0 ); WHILE( LT_16( j, hvq_band_width[k] ) ) { - IF( EQ_32( *pCoefsOut, 0 ) ) + IF( *pCoefsOut == 0 ) { Mpy_32_16_ss( normq, *pPvqVector++, &acc, &dontCare ); /* acc(Q11), normq(Q14), pvq_vector(Q12) */ *pCoefsOut = L_shl( acc, 12 - 11 ); /* Q12 */ @@ -439,6 +445,7 @@ static void dequant_peaks_fx( } ELSE { + test(); IF( vect_out[1] == 0 || ( LE_32( absPeakGain1, absPeakGain ) ) ) { Mpy_32_16_ss( *peak_gain, xq[1], &vect_out[1], &dontCare ); @@ -446,6 +453,7 @@ static void dequant_peaks_fx( } } vect_out[2] = *peak_gain; /* vect_out in Q12 */ + move16(); Mpy_32_16_ss( *peak_gain, xq[2], &vect_out[3], &dontCare ); Mpy_32_16_ss( *peak_gain, xq[3], &vect_out[4], &dontCare ); @@ -491,6 +499,7 @@ static Word16 hvq_dec_pos_fx( } peak_idx[0] = sub( delta[0], HVQ_CP_HUFF_OFFSET ); + move16(); /* safety check in case of bit errors */ IF( peak_idx[0] < 2 ) { diff --git a/lib_dec/pit_dec_fx.c b/lib_dec/pit_dec_fx.c index e4e6f4806..faa3cb2d3 100644 --- a/lib_dec/pit_dec_fx.c +++ b/lib_dec/pit_dec_fx.c @@ -80,6 +80,7 @@ Word32 Mode2_pit_decode( /* o: floating pitch value ELSE IF( EQ_16( coder_type, 3 ) ) /* 9/6/6/6 (HRs- VC) */ { Word16 pit_res_max2 = pit_res_max; + move16(); if ( EQ_16( pit_min, PIT_MIN_16k ) ) { pit_res_max2 = shr( pit_res_max, 1 ); @@ -100,6 +101,7 @@ Word32 Mode2_pit_decode( /* o: floating pitch value ELSE IF( EQ_16( coder_type, 4 ) ) /* 9/6/9/6 (AMRWB) */ { Word16 pit_res_max2 = pit_res_max; + move16(); if ( EQ_16( pit_min, PIT_MIN_16k ) ) { pit_res_max2 = shr( pit_res_max, 1 ); @@ -127,6 +129,7 @@ Word32 Mode2_pit_decode( /* o: floating pitch value { limit_T0_voiced( 5, shr( pit_res_max, 1 ), *T0, *T0_frac, *T0_res, T0_min, T0_min_frac, T0_max, T0_max_frac, pit_min, pit_max ); *T0_res = shr( pit_res_max, 1 ); + move16(); Mode2_delta_pit_dec( T0, T0_frac, *T0_res, T0_min, T0_min_frac, pt_indice ); } } @@ -140,6 +143,7 @@ Word32 Mode2_pit_decode( /* o: floating pitch value { limit_T0_voiced( 4, shr( pit_res_max, 1 ), *T0, *T0_frac, *T0_res, T0_min, T0_min_frac, T0_max, T0_max_frac, pit_min, pit_max ); *T0_res = shr( pit_res_max, 1 ); + move16(); Mode2_delta_pit_dec( T0, T0_frac, *T0_res, T0_min, T0_min_frac, pt_indice ); } } @@ -183,6 +187,7 @@ void Mode2_abs_pit_dec( index = **pt_indice; move16(); ( *pt_indice )++; + move16(); pit_res_max_half = shr( pit_res_max, 1 ); tmp1 = i_mult( sub( pit_fr2, pit_min ), pit_res_max ); @@ -199,9 +204,11 @@ void Mode2_abs_pit_dec( } *T0 = mult( index, inv_T0_res[res] ); + move16(); if ( EQ_16( pit_res_max, 6 ) ) { *T0 = shr( *T0, 1 ); + move16(); } *T0 = add( pit_min, *T0 ); @@ -266,18 +273,22 @@ void Mode2_delta_pit_dec( index = **pt_indice; move16(); ( *pt_indice )++; + move16(); *T0 = mult( add( index, *T0_min_frac ), inv_T0_res[res] ); + move16(); if ( EQ_16( T0_res, 6 ) ) { *T0 = shr( *T0, 1 ); + move16(); } *T0 = add( *T0_min, *T0 ); move16(); *T0_frac = add( index, sub( *T0_min_frac, i_mult( sub( *T0, *T0_min ), T0_res ) ) ); + move16(); return; } @@ -335,6 +346,7 @@ Word16 pit_decode_fx( /* o : floating pitch value Word16 pitch_index, nBits, pit_flag; pitch_index = 0; + move16(); /*----------------------------------------------------------------* * Set pit_flag = 0 for every subframe with absolute pitch search @@ -395,8 +407,7 @@ Word16 pit_decode_fx( /* o : floating pitch value /* find the number of bits */ nBits = st_fx->acelp_cfg.pitch_bits[shr( i_subfr, 6 )]; move16(); - pitch_index = (Word16) get_next_indice( st_fx, nBits ); - move16(); + pitch_index = (Word16) get_next_indice_fx( st_fx, nBits ); } /*-------------------------------------------------------* @@ -422,15 +433,13 @@ Word16 pit_decode_fx( /* o : floating pitch value move16(); } - pitch_index = (Word16) get_next_indice( st_fx, nBits ); - move16(); + pitch_index = (Word16) get_next_indice_fx( st_fx, nBits ); test(); test(); IF( EQ_16( L_subfr, L_FRAME / 2 ) && i_subfr != 0 && GE_16( pitch_index, 32 ) ) /* safety check in case of bit errors */ { pitch_index = shr( pitch_index, 1 ); - move16(); st_fx->BER_detect = 1; move16(); } @@ -551,7 +560,7 @@ Word16 pit_decode_fx( /* o : floating pitch value } } - pitch_index = (Word16) get_next_indice( st_fx, nBits ); + pitch_index = (Word16) get_next_indice_fx( st_fx, nBits ); pit_Q_dec_fx( 1, pitch_index, nBits, 8, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect ); } @@ -617,6 +626,7 @@ Word16 pit_decode_ivas_fx( /* o : floating pitch value Word16 pitch_index, nBits, pit_flag; pitch_index = 0; + move16(); /*----------------------------------------------------------------* * Set pit_flag = 0 for every subframe with absolute pitch search @@ -675,16 +685,24 @@ Word16 pit_decode_ivas_fx( /* o : floating pitch value IF( NE_16( coder_type, AUDIO ) ) { /* find the number of bits */ - nBits = st_fx->acelp_cfg.pitch_bits[i_subfr / L_subfr]; - move16(); - pitch_index = (Word16) get_next_indice( st_fx, nBits ); + IF( i_subfr ) + { + nBits = st_fx->acelp_cfg.pitch_bits[idiv1616( i_subfr, L_subfr )]; + } + ELSE + { + nBits = st_fx->acelp_cfg.pitch_bits[0]; + } move16(); + pitch_index = (Word16) get_next_indice_fx( st_fx, nBits ); } /*-------------------------------------------------------* * Pitch decoding in AUDIO mode * (both ACELP@12k8 and ACELP@16k cores) *-------------------------------------------------------*/ + test(); + test(); IF( EQ_16( coder_type, AUDIO ) ) { test(); @@ -704,15 +722,13 @@ Word16 pit_decode_ivas_fx( /* o : floating pitch value move16(); } - pitch_index = (Word16) get_next_indice( st_fx, nBits ); - move16(); + pitch_index = (Word16) get_next_indice_fx( st_fx, nBits ); test(); test(); IF( EQ_16( L_subfr, L_FRAME / 2 ) && i_subfr != 0 && GE_16( pitch_index, 32 ) ) /* safety check in case of bit errors */ { pitch_index = shr( pitch_index, 1 ); - move16(); st_fx->BER_detect = 1; move16(); } @@ -736,8 +752,6 @@ Word16 pit_decode_ivas_fx( /* o : floating pitch value #if 1 // def ADD_LRTD ELSE IF( EQ_16( st_fx->idchan, 1 ) && ( EQ_16( tdm_Pitch_reuse_flag, 1 ) || EQ_16( nBits, 4 ) ) ) { - test(); - test(); /*-------------------------------------------------------* * Pitch decoding with reusing of primary channel information *-------------------------------------------------------*/ @@ -832,7 +846,7 @@ Word16 pit_decode_ivas_fx( /* o : floating pitch value } } - pitch_index = (Word16) get_next_indice( st_fx, nBits ); + pitch_index = (Word16) get_next_indice_fx( st_fx, nBits ); pit_Q_dec_fx( 1, pitch_index, nBits, 8, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect ); } @@ -872,17 +886,23 @@ void pit_Q_dec_fx( IF( limit_flag == 0 ) { *T0 = add( PIT_MIN, shr( pitch_index, 2 ) ); + move16(); *T0_frac = sub( pitch_index, shl( sub( *T0, PIT_MIN ), 2 ) ); + move16(); } ELSE IF( EQ_16( limit_flag, 1 ) ) { *T0 = add( PIT_MIN_EXTEND, shr( pitch_index, 2 ) ); + move16(); *T0_frac = sub( pitch_index, shl( sub( *T0, PIT_MIN_EXTEND ), 2 ) ); + move16(); } ELSE /* limit_flag == 2 */ { *T0 = add( PIT_MIN_DOUBLEEXTEND, shr( pitch_index, 2 ) ); + move16(); *T0_frac = sub( pitch_index, shl( sub( *T0, PIT_MIN_DOUBLEEXTEND ), 2 ) ); + move16(); } } ELSE IF( EQ_16( nBits, 9 ) ) /* absolute decoding with 9 bits */ @@ -935,7 +955,7 @@ void pit_Q_dec_fx( /* biterror detection mechanism */ test(); test(); - IF( GT_16( add( ( *T0 << 2 ), *T0_frac ), add( ( PIT_MAX << 2 ), 2 ) ) && pit_flag == 0 && !Opt_AMR_WB ) + IF( GT_16( add( shl( *T0, 2 ), *T0_frac ), ( PIT_MAX << 2 ) + 2 ) && pit_flag == 0 && !Opt_AMR_WB ) { *T0 = L_SUBFR; move16(); @@ -988,9 +1008,11 @@ void pit16k_Q_dec_fx( { index = sub( pitch_index, shl( ( PIT16k_FR2_EXTEND_10b - PIT16k_MIN_EXTEND ), 2 ) ); *T0 = add( PIT16k_FR2_EXTEND_10b, shr( index, 1 ) ); + move16(); *T0_frac = sub( index, shl( sub( *T0, PIT16k_FR2_EXTEND_10b ), 1 ) ); /*(*T0_frac) *= 2;*/ ( *T0_frac ) = shl( *T0_frac, 1 ); + move16(); } } } @@ -1011,7 +1033,8 @@ void pit16k_Q_dec_fx( move16(); *T0_frac = sub( index, shl( sub( *T0, PIT16k_FR2_EXTEND_9b ), 1 ) ); move16(); - ( *T0_frac ) *= shl( ( *T0_frac ), 1 ); + ( *T0_frac ) = imult1616( ( *T0_frac ), shl( ( *T0_frac ), 1 ) ); + move16(); } ELSE { @@ -1029,7 +1052,7 @@ void pit16k_Q_dec_fx( /* biterror detection mechanism */ test(); - IF( GT_16( add( ( *T0 << 2 ), *T0_frac ), ( PIT16k_MAX << 2 ) ) && GE_16( nBits, 9 ) ) + IF( GT_16( add( shl( *T0, 2 ), *T0_frac ), ( PIT16k_MAX << 2 ) ) && GE_16( nBits, 9 ) ) { *T0 = L_SUBFR; move16(); @@ -1122,6 +1145,7 @@ void abs_pit_dec_fx( *T0 = add( PIT_MIN_EXTEND, shr( pitch_index, 1 ) ); move16(); *T0_frac = sub( pitch_index, shl( sub( *T0, PIT_MIN_EXTEND ), 1 ) ); + move16(); *T0_frac = shl( *T0_frac, 1 ); move16(); } @@ -1149,7 +1173,9 @@ void abs_pit_dec_fx( /*pitch_index -= (PIT_FR2_EXTEND_9b-PIT_MIN_EXTEND)*4;*/ pitch_index = sub( pitch_index, PIT_FR2_EXT9b_MINUS_PIT_MIN_EXT_X4 ); *T0 = add( PIT_FR2_EXTEND_9b, shr( pitch_index, 1 ) ); + move16(); *T0_frac = sub( pitch_index, shl( sub( *T0, PIT_FR2_EXTEND_9b ), 1 ) ); + move16(); ( *T0_frac ) = shl( *T0_frac, 1 ); move16(); } diff --git a/lib_dec/pitch_extr_fx.c b/lib_dec/pitch_extr_fx.c index 78d0fc1f0..2e327938e 100644 --- a/lib_dec/pitch_extr_fx.c +++ b/lib_dec/pitch_extr_fx.c @@ -61,6 +61,11 @@ void pitch_pred_linear_fit( Word16 pg[8]; /* local buffer for pitch gain*/ Word32 ml[8]; /* local buffer for mem_lag*/ Word16 const timeWeight[5] = { 20480 /*1.25f Q14*/, 18432 /*1.125f Q14*/, 16384 /*1.f Q14*/, 14336 /*0.875f Q14*/, 12288 /*.75f Q14*/ }; /*Q14*/ + move16(); + move16(); + move16(); + move16(); + move16(); /*timeweight*/ Word16 no_subfr_pred; Word16 a1, a2, a3, a4, a5, tmpa, tmpb, b1, b2, b3, b4, b5; Word16 a_e, b_e, sum0_q; @@ -84,16 +89,13 @@ void pitch_pred_linear_fit( move32(); } } - move16(); - move16(); - move16(); - move16(); - move16(); /*timeweight*/ IF( LT_16( pit_max, extract_h( *old_fpitch ) ) ) { *extrapolationFailed = 1; + move16(); *T0_out = pit_max; + move16(); return; } @@ -114,8 +116,8 @@ void pitch_pred_linear_fit( } /* copy to local buffers, depending on availability of info about future subframes */ - Copy( mem_pitch_gain + no_subfr_pred - 2, pg, 8 ); - Copy32( mem_lag + no_subfr_pred - 2, ml, 8 ); + Copy( mem_pitch_gain + sub( no_subfr_pred, 2 ), pg, 8 ); + Copy32( mem_lag + sub( no_subfr_pred, 2 ), ml, 8 ); mdy = L_deposit_l( 0 ); @@ -164,6 +166,7 @@ void pitch_pred_linear_fit( Word16 e1, e2, e3, e4, e5, e6, e7; t1 = L_mult0( pg[4], pg[3] ); /*Q24*/ /* t1 = pg[4]*pg[3] */ e1 = 7; + move16(); t2 = L_add( L_deposit_l( pg[3] ), L_shl( L_deposit_l( pg[4] ), 2 ) ); /*Q12*/ e2 = norm_l( t2 ); t2 = L_shl( t2, e2 ); /*Q12,-e2*/ @@ -339,6 +342,7 @@ void get_subframe_pitch( pitchDelta = L_deposit_l( BASOP_Util_Divide3216_Scale( L_sub( pitchEnd, pitchStart ), nSubframes, &s ) ); /*Q15*/ pitchDelta = L_shl( pitchDelta, add( s, 1 ) ); /*Q16*/ pitchBuf[0] = L_add( pitchStart, pitchDelta ); + move32(); FOR( i = 1; i < nSubframes; i++ ) { pitchBuf[i] = L_add( pitchBuf[i - 1], pitchDelta ); diff --git a/lib_dec/post_dec_fx.c b/lib_dec/post_dec_fx.c index 1071b2389..e6e4fffa4 100644 --- a/lib_dec/post_dec_fx.c +++ b/lib_dec/post_dec_fx.c @@ -61,7 +61,7 @@ void post_decoder( move16(); bitrate = L_add( st->total_brate, 0 ); - if ( st->core_brate <= SID_2k40 ) + if ( LE_32( st->core_brate, SID_2k40 ) ) { bitrate = L_add( st->last_active_brate, 0 ); } @@ -89,7 +89,7 @@ void post_decoder( ELSE { /*Formant enhancement*/ - IF( EQ_16( st->last_bwidth, NB ) ) + IF( st->last_bwidth == NB ) { Copy( synth, synth2_pe, L_frame ); tmp = synth[-1]; @@ -114,11 +114,12 @@ void post_decoder( st->hPFstat->reset = 1; move16(); } - IF( EQ_16( st->bwidth, NB ) ) + IF( st->bwidth == NB ) { st->hPFstat->on = 1; move16(); tmp_noise = 0; + move16(); nb_post_filt_fx( L_frame, st->hPFstat, &tmp_noise, 0, synth2_pe, st->mem_Aq, pitch, GENERIC, st->BER_detect, tmp ); } ELSE @@ -126,6 +127,7 @@ void post_decoder( st->hPFstat->on = 0; move16(); tmp_noise = 0; + move16(); nb_post_filt_fx( L_frame, st->hPFstat, &tmp_noise, 0, synth2_pe, st->mem_Aq, pitch, AUDIO, st->BER_detect, tmp ); } Copy( synth2_pe, synth2, L_frame ); @@ -217,7 +219,7 @@ void post_decoder_ivas_fx( } bitrate = L_add( st->total_brate, 0 ); - IF( LE_32( st->core_brate, SID_2k40 ) ) + if ( LE_32( st->core_brate, SID_2k40 ) ) { bitrate = L_add( st->last_active_brate, 0 ); } @@ -240,17 +242,17 @@ void post_decoder_ivas_fx( IF( pfstat_on_previous ) { Copy( st->hPFstat->mem_pf_in + L_SYN_MEM - M, synth - M, M ); - Word16 L_subfr = st->L_frame / st->nb_subfr; + Word16 L_subfr = idiv1616( st->L_frame, st->nb_subfr ); Residu3_fx( st->old_Aq_12_8_fx, synth, synth_buf, L_subfr, 1 ); E_UTIL_synthesis( 1, st->old_Aq_12_8_fx, synth_buf, synth2, L_subfr, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M ); scale_st_fx( synth, synth2, &st->hPFstat->gain_prec, L_subfr ); - blend_subfr2_fx( synth2 + L_subfr / 2, synth + L_subfr / 2, synth2 + L_subfr / 2 ); + blend_subfr2_fx( synth2 + shr( L_subfr, 1 ), synth + shr( L_subfr, 1 ), synth2 + shr( L_subfr, 1 ) ); } } ELSE { /*Formant enhancement*/ - IF( EQ_16( st->last_bwidth, NB ) ) + IF( st->last_bwidth == NB ) { Copy( synth, synth2_pe, L_frame ); tmp = synth[-1]; @@ -270,16 +272,17 @@ void post_decoder_ivas_fx( move16(); } - IF( EQ_16( pfstat_on_previous, 0 ) ) + if ( pfstat_on_previous == 0 ) { st->hPFstat->reset = 1; move16(); } - IF( EQ_16( st->bwidth, NB ) ) + IF( st->bwidth == NB ) { st->hPFstat->on = 1; move16(); tmp_noise = 0; + move16(); nb_post_filt_fx( L_frame, st->hPFstat, &tmp_noise, 0, synth2_pe, st->mem_Aq, pitch, GENERIC, st->BER_detect, tmp ); } ELSE @@ -287,6 +290,7 @@ void post_decoder_ivas_fx( st->hPFstat->on = 0; move16(); tmp_noise = 0; + move16(); nb_post_filt_fx( L_frame, st->hPFstat, &tmp_noise, 0, synth2_pe, st->mem_Aq, pitch, AUDIO, st->BER_detect, tmp ); } Copy( synth2_pe, synth2, L_frame ); @@ -297,7 +301,7 @@ void post_decoder_ivas_fx( } ELSE { - IF( EQ_16( pfstat_on_previous, 0 ) ) + if ( pfstat_on_previous == 0 ) { st->hPFstat->reset = 1; move16(); @@ -383,7 +387,7 @@ static void bass_pf_1sf_delay( lg = 0; move16(); } - if ( lg > l_subfr ) + if ( GT_16( lg, l_subfr ) ) { lg = l_subfr; move16(); @@ -412,12 +416,12 @@ static void bass_pf_1sf_delay( Word64 nrg64 = W_deposit32_l( nrg ); FOR( i = 0; i < lg; i++ ) { - tmp32 = L_mult( syn[i + i_subfr - T], 0x4000 ); - tmp32 = L_mac( tmp32, syn[i + i_subfr + T], 0x4000 ); + tmp32 = L_mult( syn[sub( add( i, i_subfr ), T )], 0x4000 ); + tmp32 = L_mac( tmp32, syn[add( add( i, i_subfr ), T )], 0x4000 ); tmp16 = round_fx( L_shl( tmp32, s1 ) ); /* Q0+s1 */ - tmp64 = W_mac0_16_16( tmp64, shl( syn[i + i_subfr], s1 ), tmp16 ); /* Q0+2*s1 */ - nrg64 = W_mac0_16_16( nrg64, tmp16, tmp16 ); /* Q0+2*s1 */ + tmp64 = W_mac0_16_16( tmp64, shl( syn[add( i, i_subfr )], s1 ), tmp16 ); /* Q0+2*s1 */ + nrg64 = W_mac0_16_16( nrg64, tmp16, tmp16 ); /* Q0+2*s1 */ } tmp = W_sat_l( tmp64 ); nrg = W_sat_l( nrg64 ); @@ -432,9 +436,9 @@ static void bass_pf_1sf_delay( Word64 nrg64 = W_deposit32_l( nrg ); FOR( i = lg; i < l_subfr; i++ ) { - tmp16 = shl( syn[i + i_subfr - T], s1 ); /* Q0+s1 */ - tmp64 = W_mac0_16_16( tmp64, shl( syn[i + i_subfr], s1 ), tmp16 ); /* Q0+2*s1 */ - nrg64 = W_mac0_16_16( nrg64, tmp16, tmp16 ); /* Q0+2*s1 */ + tmp16 = shl( syn[sub( add( i, i_subfr ), T )], s1 ); /* Q0+s1 */ + tmp64 = W_mac0_16_16( tmp64, shl( syn[add( i, i_subfr )], s1 ), tmp16 ); /* Q0+2*s1 */ + nrg64 = W_mac0_16_16( nrg64, tmp16, tmp16 ); /* Q0+2*s1 */ } tmp = W_sat_l( tmp64 ); nrg = W_sat_l( nrg64 ); @@ -474,10 +478,10 @@ static void bass_pf_1sf_delay( Word64 ener2_64 = W_deposit32_l( ener2 ); FOR( i = 0; i < lg; i++ ) { - tmp32 = L_msu0( 0, gain, syn[i + i_subfr - T] ); - tmp32 = L_msu0( tmp32, gain, syn[i + i_subfr + T] ); + tmp32 = L_msu0( 0, gain, syn[sub( add( i, i_subfr ), T )] ); + tmp32 = L_msu0( tmp32, gain, syn[add( add( i, i_subfr ), T )] ); #ifdef BASOP_NOGLOB - tmp16 = mac_r_sat( tmp32, gain, syn[i + i_subfr] ); /* Q0 */ + tmp16 = mac_r_sat( tmp32, gain, syn[add( i, i_subfr )] ); /* Q0 */ #else tmp16 = mac_r( tmp32, gain, syn[i + i_subfr] ); /* Q0 */ #endif @@ -504,8 +508,8 @@ static void bass_pf_1sf_delay( FOR( i = lg; i < l_subfr; i++ ) { #ifdef BASOP_NOGLOB - tmp32 = L_mult0( gain, syn[i + i_subfr] ); - tmp32 = L_msu0_sat( tmp32, gain, syn[i + i_subfr - T] ); /* Q0 */ + tmp32 = L_mult0( gain, syn[add( i, i_subfr )] ); + tmp32 = L_msu0_sat( tmp32, gain, syn[sub( add( i, i_subfr ), T )] ); /* Q0 */ tmp16 = round_fx_sat( tmp32 ); lp_error = Mpy_32_16_1( lp_error, 29491 /*0.9f Q15*/ ); @@ -541,6 +545,7 @@ static void bass_pf_1sf_delay( } *lp_error_ener = L_add( Mpy_32_16_1( L_sub( *lp_error_ener, ener2 ), 32440 /*0.99f Q15*/ ), ener2 ); /* 15Q16 */ + move32(); st = add( st, 6 ); ener2 = L_sub( *lp_error_ener, L_deposit_h( sub( 31, st ) ) ); @@ -587,11 +592,12 @@ static void bass_pf_1sf_delay( { FOR( i = 0; i < lg; i++ ) { - tmp32 = L_msu0( 0, tmp16, syn[i + i_subfr - T] ); + tmp32 = L_msu0( 0, tmp16, syn[sub( add( i, i_subfr ), T )] ); #ifdef BASOP_NOGLOB - tmp32 = L_msu0_sat( tmp32, tmp16, syn[i + i_subfr + T] ); - tmp32 = L_mac_sat( tmp32, tmp16, syn[i + i_subfr] ); - bpf_noise_buf[i + i_subfr] = round_fx_sat( tmp32 ); /* Q0 */ + tmp32 = L_msu0_sat( tmp32, tmp16, syn[add( add( i, i_subfr ), T )] ); + tmp32 = L_mac_sat( tmp32, tmp16, syn[add( i, i_subfr )] ); + bpf_noise_buf[add( i, i_subfr )] = round_fx_sat( tmp32 ); /* Q0 */ + move16(); #else tmp32 = L_msu0( tmp32, tmp16, syn[i + i_subfr + T] ); tmp32 = L_mac( tmp32, tmp16, syn[i + i_subfr] ); @@ -604,10 +610,11 @@ static void bass_pf_1sf_delay( { FOR( i = lg; i < l_subfr; i++ ) { - tmp32 = L_mult0( tmp16, syn[i + i_subfr] ); + tmp32 = L_mult0( tmp16, syn[add( i, i_subfr )] ); #ifdef BASOP_NOGLOB - tmp32 = L_msu0_sat( tmp32, tmp16, syn[i + i_subfr - T] ); - bpf_noise_buf[i + i_subfr] = round_fx_sat( tmp32 ); /* Q0 */ + tmp32 = L_msu0_sat( tmp32, tmp16, syn[sub( add( i, i_subfr ), T )] ); + bpf_noise_buf[add( i, i_subfr )] = round_fx_sat( tmp32 ); /* Q0 */ + move16(); #else tmp32 = L_msu0( tmp32, tmp16, syn[i + i_subfr - T] ); bpf_noise_buf[i + i_subfr] = round_fx( tmp32 ); /* Q0 */ @@ -650,6 +657,7 @@ void cldfb_synth_set_bandsToZero( Word16 i, k, tmp1, tmp2, tmp3, tmp, update_perc; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif @@ -660,16 +668,23 @@ void cldfb_synth_set_bandsToZero( set32_fx( nrg_band, 0, CLDFB_NO_CHANNELS_MAX ); max_nrg = 0; + move32(); offset = 250; + move16(); WBcnt = 20; - perc_miss = 13107; /*0.80 in Q14*/ + move16(); + perc_miss = 13107; /*0.80 in Q14*/ + move16(); perc_detect = 14746; /*0.90 in Q14*/ + move16(); IF( EQ_16( st->VAD, 1 ) ) { st->active_frame_cnt_bwddec = add( st->active_frame_cnt_bwddec, 1 ); + move16(); st->total_frame_cnt_bwddec = add( st->total_frame_cnt_bwddec, 1 ); + move16(); if ( GT_16( st->active_frame_cnt_bwddec, 99 ) ) { st->active_frame_cnt_bwddec = 100; @@ -681,15 +696,15 @@ void cldfb_synth_set_bandsToZero( move16(); } - FOR( i = 0; i < ( st->cldfbSyn->no_channels - st->cldfbSyn->bandsToZero ); i++ ) + FOR( i = 0; i < sub( st->cldfbSyn->no_channels, st->cldfbSyn->bandsToZero ); i++ ) { nrgQ31 = 0; move32(); FOR( k = 0; k < nTimeSlots; k++ ) { /* use 16-bit precision of real and imag buffers */ - realQ1 = extract_l( L_shr( rAnalysis[k][i], 31 - ( 15 + scaleFactor.lb_scale ) + 3 ) ); - imagQ1 = extract_l( L_shr( iAnalysis[k][i], 31 - ( 15 + scaleFactor.lb_scale ) + 3 ) ); /* Q(-3), headroom */ + realQ1 = extract_l( L_shr( rAnalysis[k][i], sub( 31 + 3 - 15, scaleFactor.lb_scale ) ) ); /*31 - (15 + scaleFactor.lb_scale) + 3 )*/ + imagQ1 = extract_l( L_shr( iAnalysis[k][i], sub( 31 + 3 - 15, scaleFactor.lb_scale ) ) ); /* Q(-3), headroom */ #ifdef BASOP_NOGLOB nrgQ31 = L_mac0_o( nrgQ31, realQ1, realQ1, &Overflow ); nrgQ31 = L_mac0_o( nrgQ31, imagQ1, imagQ1, &Overflow ); /* keep in Q(-6) */ @@ -723,6 +738,7 @@ void cldfb_synth_set_bandsToZero( tempQ31 = L_shr( nrgQ31, 9 ); st->avg_nrg_LT = L_add( Mult_32_16( st->avg_nrg_LT, 32440 ), Mult_32_16( tempQ31, 327 ) ); /*0.99*avg_nrg_LT + 0.01*tempQ31*/ + move32(); update_perc = 1; move16(); if ( st->ini_frame >= 25 && tempQ31 < Mult_32_16( st->avg_nrg_LT, 164 ) ) @@ -739,7 +755,7 @@ void cldfb_synth_set_bandsToZero( move16(); } - FOR( i = 0; i < WBcnt - 1; i++ ) + FOR( i = 0; i < sub( WBcnt, 1 ); i++ ) { st->flag_buffer[i] = st->flag_buffer[i + 1]; move16(); @@ -753,6 +769,7 @@ void cldfb_synth_set_bandsToZero( IF( flag != 0 ) { tmp1 = sub( 16384, st->perc_bwddec ); /*Q14*/ + move16(); tmp = norm_s( st->active_frame_cnt_bwddec ); tmp3 = shl( st->active_frame_cnt_bwddec, tmp ); /*Qtmp*/ @@ -760,10 +777,12 @@ void cldfb_synth_set_bandsToZero( tmp2 = div_s( 16384, tmp3 ); /* 1/active_frames in Q15 + Q14 - Qtmp = Q29 - Qtmp */ tmp2 = mult_r( tmp2, tmp1 ); /*(1-perc)*(1/active_frames) in Q14 + Q29 - Qtmp - Q15 = Q28 - Qtmp*/ st->perc_bwddec = add( st->perc_bwddec, shl( tmp2, sub( tmp, 14 ) ) ); /* Q14 */ + move16(); } ELSE { tmp1 = ( st->perc_bwddec ); /*Q14*/ + move16(); tmp = norm_s( st->active_frame_cnt_bwddec ); tmp3 = shl( st->active_frame_cnt_bwddec, tmp ); /*Qtmp*/ @@ -771,11 +790,14 @@ void cldfb_synth_set_bandsToZero( tmp2 = div_s( 16384, tmp3 ); /* 1/active_frames in Q15 + Q14 - Qtmp = Q29 - Qtmp */ tmp2 = mult_r( tmp2, tmp1 ); /*(perc)*(1/active_frames) in Q14 + Q29 - Qtmp - Q15 = Q28 - Qtmp*/ st->perc_bwddec = sub( st->perc_bwddec, shl( tmp2, sub( tmp, 14 ) ) ); /* Q14 */ + move16(); } } test(); IF( GT_16( st->total_frame_cnt_bwddec, offset ) && GT_16( st->active_frame_cnt_bwddec, 50 ) ) { + test(); + test(); IF( ( st->perc_bwddec >= perc_detect || ( st->perc_bwddec >= perc_miss && st->last_flag_filter_NB ) ) && ( sum16_fx( st->flag_buffer, WBcnt ) != 0 ) ) /*decision hysterysis*/ { st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 ); @@ -797,6 +819,7 @@ void cldfb_synth_set_bandsToZero( IF( sum16_fx( st->flag_buffer, WBcnt ) == 0 ) { st->perc_bwddec = 0; + move16(); st->active_frame_cnt_bwddec = 0; move16(); st->total_frame_cnt_bwddec = 0; @@ -807,12 +830,13 @@ void cldfb_synth_set_bandsToZero( } ELSE { - IF( st->last_flag_filter_NB == 1 ) + if ( EQ_16( st->last_flag_filter_NB, 1 ) ) { st->cldfbSyn->bandsToZero = st->last_active_bandsToZero_bwdec; move16(); } st->total_frame_cnt_bwddec = add( st->total_frame_cnt_bwddec, 1 ); + move16(); if ( GT_16( st->total_frame_cnt_bwddec, 500 ) ) { st->total_frame_cnt_bwddec = 500; @@ -821,6 +845,7 @@ void cldfb_synth_set_bandsToZero( } st->last_active_bandsToZero_bwdec = st->cldfbSyn->bandsToZero; + move16(); return; } diff --git a/lib_dec/ppp_dec_fx.c b/lib_dec/ppp_dec_fx.c index 24461a7fb..1f0f485df 100644 --- a/lib_dec/ppp_dec_fx.c +++ b/lib_dec/ppp_dec_fx.c @@ -58,12 +58,12 @@ static void DTFS_dequant_cw_fx( Word32 L_tmp, L_temp; Word32 L_tmp2; - IF( num_erb_fx == NUM_ERB_NB ) + IF( EQ_16( num_erb_fx, NUM_ERB_NB ) ) { PowerCB_fx = PowerCB_NB_fx; move16(); } - ELSE IF( num_erb_fx == NUM_ERB_WB ) + ELSE IF( EQ_16( num_erb_fx, NUM_ERB_WB ) ) { PowerCB_fx = PowerCB_WB_fx; move16(); @@ -73,12 +73,14 @@ static void DTFS_dequant_cw_fx( erb_add_fx( curr_erb_fx, X_fx->lag_fx, lasterbD_fx, pl_fx, AMP_IDX_fx, num_erb_fx ); - curr_erb_fx[0] = mult_r( curr_erb_fx[1], 9830 ); /* 0.3 inQ15 leaves curr_erb in Q13 */ + curr_erb_fx[0] = mult_r( curr_erb_fx[1], 9830 ); /* 0.3 inQ15 leaves curr_erb in Q13 */ + move16(); curr_erb_fx[sub( num_erb_fx, 2 )] = mult_r( curr_erb_fx[sub( num_erb_fx, 3 )], 9830 ); /* Q13 */ - move16(); + curr_erb_fx[sub( num_erb_fx, 1 )] = 0; + move16(); erb_slot_fx( X_fx->lag_fx, slot_fx, mfreq_fx, num_erb_fx ); @@ -93,7 +95,8 @@ static void DTFS_dequant_cw_fx( /* Need to unify the Q factors of both bands */ X_fx->Q = s_min( Ql, Qh ); /* set Q factor to be the smaller one */ - n = sub( Ql, Qh ); /* compare band Q factors */ + move16(); + n = sub( Ql, Qh ); /* compare band Q factors */ /* This logic adjusts difference between Q formats of both bands */ @@ -115,6 +118,8 @@ static void DTFS_dequant_cw_fx( *lastLgainD_fx = add( *lastLgainD_fx, PowerCB_fx[tmp_fx] ); /* Q11 */ *lastHgainD_fx = add( *lastHgainD_fx, PowerCB_fx[tmp_fx + 1] ); /* Q11 */ #endif + move16(); + move16(); L_tmp = L_deposit_h( X_fx->lag_fx ); /* Q16 */ exp = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, exp ); @@ -171,6 +176,7 @@ static void DTFS_dequant_cw_fx( L_temp = L_shl( L_tmp, exp1 + 15 ); /* Q15 */ #endif L_tmp2 = L_temp; + move32(); if ( GE_32( L_temp, 2147483647 ) ) { L_temp = L_shl( L_tmp, 15 ); /*Q(15-exp1) */ @@ -192,7 +198,8 @@ static void DTFS_dequant_cw_fx( /* Need to unify the Q factors of both bands */ X_fx->Q = s_min( Ql, Qh ); /* set Q factor to be the smaller one */ - n = sub( Ql, Qh ); /* compare band Q factors */ + move16(); + n = sub( Ql, Qh ); /* compare band Q factors */ IF( n < 0 ) @@ -255,11 +262,16 @@ ivas_error ppp_quarter_decoder_fx( DTFS_STRUCTURE *PREVDTFS_FX; Word16 AMP_IDX_fx[2]; Word16 temp_pl_fx = prevCW_lag_fx, temp_l_fx = CURRCW_Q_DTFS_FX->lag_fx; + move16(); + move16(); Word16 temp_fx; Word16 l_fx = CURRCW_Q_DTFS_FX->lag_fx; + move16(); Word16 POWER_IDX_fx; Word16 Erot_fx = 0; + move16(); Word16 num_erb_fx = 24; + move16(); Word32 temp32d_fx, temp32n_fx; Word32 L_tmp, L_tmp1; Word16 tmp, exp; @@ -267,7 +279,7 @@ ivas_error ppp_quarter_decoder_fx( error = IVAS_ERR_OK; move16(); - IF( ( error = DTFS_new_fx( &PREVDTFS_FX ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = DTFS_new_fx( &PREVDTFS_FX ) ), IVAS_ERR_OK ) ) { return error; } @@ -287,7 +299,6 @@ ivas_error ppp_quarter_decoder_fx( IF( bfi == 0 ) { POWER_IDX_fx = (Word16) get_next_indice( st_fx, 6 ); - move16(); AMP_IDX_fx[0] = (Word16) get_next_indice( st_fx, 6 ); move16(); AMP_IDX_fx[1] = (Word16) get_next_indice( st_fx, 6 ); @@ -299,18 +310,22 @@ ivas_error ppp_quarter_decoder_fx( This logic of normalisation is not employed in adjustlag, hence denormalisation is necessury.*/ /*As the upper cut of freqencies are normalized to 12800, we have to multiply upper cut off freq by 2.56(1/12800 in Q15) */ - temp32n_fx = L_mult( CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx, 10486 ); /* Q0+Q27 = Q28 */ - CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx = (Word16) L_shr( temp32n_fx, 13 ); /*Q15 */ - temp32n_fx = L_mult( CURRCW_Q_DTFS_FX->upper_cut_off_freq_of_interest_fx, 10486 ); /* Q0+Q27 = Q28 */ - CURRCW_Q_DTFS_FX->upper_cut_off_freq_of_interest_fx = (Word16) L_shr( temp32n_fx, 13 ); /*Q15 */ + temp32n_fx = L_mult( CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx, 10486 ); /* Q0+Q27 = Q28 */ + CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx = extract_l( L_shr( temp32n_fx, 13 ) ); /*Q15 */ + move16(); + temp32n_fx = L_mult( CURRCW_Q_DTFS_FX->upper_cut_off_freq_of_interest_fx, 10486 ); /* Q0+Q27 = Q28 */ + CURRCW_Q_DTFS_FX->upper_cut_off_freq_of_interest_fx = extract_l( L_shr( temp32n_fx, 13 ) ); /*Q15 */ + move16(); DTFS_dequant_cw_fx( prevCW_lag_fx, POWER_IDX_fx, AMP_IDX_fx, lastLgainD_fx, lastHgainD_fx, lasterbD_fx, CURRCW_Q_DTFS_FX, num_erb_fx ); /*De-normalize cut off frequencies */ - temp32n_fx = L_shl( (Word32) CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx, 13 ); /*Q28 */ - CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx = (Word16) find_remd( temp32n_fx, 20971, &temp32d_fx ); - temp32n_fx = L_shl( (Word32) CURRCW_Q_DTFS_FX->upper_cut_off_freq_of_interest_fx, 13 ); /*Q28 */ - CURRCW_Q_DTFS_FX->upper_cut_off_freq_of_interest_fx = (Word16) find_remd( temp32n_fx, 20971, &temp32d_fx ); + temp32n_fx = L_shl( L_deposit_l( CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx ), 13 ); /*Q28 */ + CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx = extract_l( find_remd( temp32n_fx, 20971, &temp32d_fx ) ); + move16(); + temp32n_fx = L_shl( L_deposit_l( CURRCW_Q_DTFS_FX->upper_cut_off_freq_of_interest_fx ), 13 ); /*Q28 */ + CURRCW_Q_DTFS_FX->upper_cut_off_freq_of_interest_fx = extract_l( find_remd( temp32n_fx, 20971, &temp32d_fx ) ); + move16(); } /* Copying phase spectrum over */ diff --git a/lib_enc/arith_coder_enc.c b/lib_enc/arith_coder_enc.c index eedd260ee..f531d9ed0 100644 --- a/lib_enc/arith_coder_enc.c +++ b/lib_enc/arith_coder_enc.c @@ -609,7 +609,7 @@ void tcx_arith_encode_envelope( gamma_uw = 1.0f / st->gamma_flt; #define WMC_TOOL_SKIP - tcx_arith_render_envelope_flt( A_ind, L_frame, L_spec, FL2WORD16( hTcxCfg->preemph_fac_flt ), FL2WORD16( gamma_w ), FL2WORD16( 0.5f * gamma_uw ), env ); + tcx_arith_render_envelope_ivas( 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 ) @@ -644,7 +644,7 @@ void tcx_arith_encode_envelope( L_spec_core = min( L_spec_core, st->hIGFEnc->infoStartLine ); } envelope = (Word16 *) env; - tcx_arith_scale_envelope_flt( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e ); + tcx_arith_scale_envelope_ivas( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e ); #define WMC_TOOL_SKIP tmp = sub( envelope_e, 1 ); diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 013051554..78ebf3009 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -2124,9 +2124,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - g1 = L_add( POINT_3679_Q31, - Mpy_32_32( onset_filter[l], - POINT_1175_Q31 - POINT_3679_Q31 ) ); // Q31, (Q31, Q31) -> Q31 + g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q g2 = L_max( g2, Mpy_32_32( 2126008812 /* 0.99f in Q31 */, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q @@ -2142,9 +2140,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - g1 = L_add( POINT_3679_Q31, - Mpy_32_32( onset_filter[l], - POINT_1175_Q31 - POINT_3679_Q31 ) ); // Q31, (Q31, Q31) -> Q31 + g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q g2 = L_max( g2, Mpy_32_32( 1825361101 /* 0.85f in Q31 */, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q @@ -2160,9 +2156,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - g1 = L_add( POINT_3679_Q31, - Mpy_32_32( onset_filter[l], - POINT_1175_Q31 - POINT_3679_Q31 ) ); // Q31, (Q31, Q31) -> Q31 + g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q g2 = L_max( g2, W_extract_h( W_shl( W_mult_32_32( -DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ), Q5 ) ) ); // p_gains_dir_q @@ -2192,9 +2186,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - g1 = L_add( POINT_3679_Q31, - Mpy_32_32( onset_filter[l], - POINT_1175_Q31 - POINT_3679_Q31 ) ); // Q31, (Q31, Q31) -> Q31 + g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // (p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q g2 = L_max( g2, W_extract_h( W_shl( W_mult_32_32( -DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ), Q5 ) ) ); // p_gains_dir_q @@ -2251,8 +2243,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( shl( i_mult( ch_idx, num_freq_bands ), Q1 ); FOR( l = 0; l < num_freq_bands; l++ ) { - g = L_add( Mpy_32_32( g1, ( *( p_gains_dir++ ) ) ), - Mpy_32_32( g2, ( *( p_gains_dir_prev++ ) ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) + g = Madd_32_32( Mpy_32_32( g1, ( *( p_gains_dir++ ) ) ), g2, ( *( p_gains_dir_prev++ ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) output_real[add( imult1616( l, num_channels_dir ), ch_idx )] = Mpy_32_32( g, ( *( p_proto_diff++ ) ) ); // (p_gains_dir_q, p_proto_diff_q) -> (p_gains_dir_q + p_proto_diff_q - 31) move32(); @@ -2278,31 +2269,25 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( shl( i_mult( proto_direct_index[1], num_freq_bands ), Q1 ); FOR( l = 0; l < num_freq_bands; l++ ) { - gs1 = L_add( Mpy_32_32( g1, ( *( p_gains_dir ) ) ), - Mpy_32_32( g2, ( *( p_gains_dir_prev ) ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) - gs2 = L_add( Mpy_32_32( g1, ( *( p_gains_dir + imult1616( num_freq_bands, num_channels_dir ) ) ) ), - Mpy_32_32( g2, ( *( p_gains_dir_prev + imult1616( num_freq_bands, num_channels_dir ) ) ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) + gs1 = Madd_32_32( Mpy_32_32( g1, ( *( p_gains_dir ) ) ), g2, ( *( p_gains_dir_prev ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) + gs2 = Madd_32_32( Mpy_32_32( g1, ( *( p_gains_dir + imult1616( num_freq_bands, num_channels_dir ) ) ) ), g2, ( *( p_gains_dir_prev + imult1616( num_freq_bands, num_channels_dir ) ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) p_gains_dir++; p_gains_dir_prev++; // ((p_gains_dir_q, p_proto_dir_q) >> 1) -> (p_gains_dir_q + p_proto_dir_q - 31) output_real[add( imult1616( l, num_channels_dir ), ch_idx )] = - L_add( - Mpy_32_32( gs1, ( L_add( Mpy_32_32( 1903158016 /* 1.772454e+00f / 2 in Q31 */, ( *p_proto ) ), - Mpy_32_32( 1098788992 /* 1.023327e+00f / 2 in Q31 */, ( *p_proto2 ) ) ) ) ), /* s1 */ - Mpy_32_32( gs2, ( L_sub( Mpy_32_32( 1903158016 /* 1.772454e+00f / 2 in Q31 */, ( *p_proto ) ), - Mpy_32_32( 1098788992 /* 1.023327e+00f / 2 in Q31 */, ( *p_proto2 ) ) ) ) ) ); /* s2 */ + Madd_32_32( + Mpy_32_32( gs1, ( L_add( Mpy_32_32( 1903158016 /* 1.772454e+00f / 2 in Q31 */, ( *p_proto ) ), Mpy_32_32( 1098788992 /* 1.023327e+00f / 2 in Q31 */, ( *p_proto2 ) ) ) ) ), /* s1 */ + gs2, L_sub( Mpy_32_32( 1903158016 /* 1.772454e+00f / 2 in Q31 */, ( *p_proto ) ), Mpy_32_32( 1098788992 /* 1.023327e+00f / 2 in Q31 */, ( *p_proto2 ) ) ) ); /* s2 */ move32(); p_proto++; p_proto2++; // ((p_gains_dir_q, p_proto_dir_q) >> 1) -> (p_gains_dir_q + p_proto_dir_q - 31) output_imag[add( imult1616( l, num_channels_dir ), ch_idx )] = - L_add( - Mpy_32_32( gs1, ( L_add( Mpy_32_32( 1903158016 /* 1.772454e+00f / 2 in Q31 */, ( *p_proto ) ), - Mpy_32_32( 1098788992 /* 1.023327e+00f / 2 in Q31 */, ( *p_proto2 ) ) ) ) ), - Mpy_32_32( gs2, ( L_sub( Mpy_32_32( 1903158016 /* 1.772454e+00f / 2 in Q31 */, ( *p_proto ) ), - Mpy_32_32( 1098788992 /* 1.023327e+00f / 2 in Q31 */, ( *p_proto2 ) ) ) ) ) ); + Madd_32_32( + Mpy_32_32( gs1, ( L_add( Mpy_32_32( 1903158016 /* 1.772454e+00f / 2 in Q31 */, ( *p_proto ) ), Mpy_32_32( 1098788992 /* 1.023327e+00f / 2 in Q31 */, ( *p_proto2 ) ) ) ) ), + gs2, L_sub( Mpy_32_32( 1903158016 /* 1.772454e+00f / 2 in Q31 */, ( *p_proto ) ), Mpy_32_32( 1098788992 /* 1.023327e+00f / 2 in Q31 */, ( *p_proto2 ) ) ) ); move32(); p_proto++; p_proto2++; @@ -2334,8 +2319,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - g = L_add( Mpy_32_32( g1, ( *( p_gains_dir++ ) ) ), - Mpy_32_32( g2, ( *( p_gains_dir_prev++ ) ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) + g = Madd_32_32( Mpy_32_32( g1, ( *( p_gains_dir++ ) ) ), g2, ( *( p_gains_dir_prev++ ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) output_real[add( imult1616( l, num_channels_dir ), ch_idx )] = Mpy_32_32( g, ( *( p_proto++ ) ) ); // (p_gains_dir_q, p_proto_dir_q) -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); @@ -2383,19 +2367,18 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( ch_idx_diff = add( ch_idx_diff, 1 ); FOR( l = 0; l < num_freq_bands_diff; l++ ) { - g = L_add( Mpy_32_32( g1, ( *( p_gains_diff++ ) ) ), - Mpy_32_32( g2, ( *( p_gains_diff_prev++ ) ) ) ); // (Q31, p_gains_diff_q) -> p_gains_diff_q + g = Madd_32_32( Mpy_32_32( g1, ( *( p_gains_diff++ ) ) ), g2, ( *( p_gains_diff_prev++ ) ) ); // (Q31, p_gains_diff_q) -> p_gains_diff_q // ((p_gains_diff_q, p_proto_diff_q) >> Q1) -> (p_gains_diff_q + p_proto_diff_q - 31) output_real[add( imult1616( l, num_channels_dir ), hDirACRend->sba_map_tc[ch_idx] )] = - L_add( output_real[add( imult1616( l, num_channels_dir ), hDirACRend->sba_map_tc[ch_idx] )], - Mpy_32_32( g, ( *( p_proto++ ) ) ) ); + Madd_32_32( output_real[add( imult1616( l, num_channels_dir ), hDirACRend->sba_map_tc[ch_idx] )], + g, ( *( p_proto++ ) ) ); move32(); // ((p_gains_diff_q, p_proto_diff_q) >> Q1) -> (p_gains_diff_q + p_proto_diff_q - 31) output_imag[add( imult1616( l, num_channels_dir ), hDirACRend->sba_map_tc[ch_idx] )] = - L_add( output_imag[add( imult1616( l, num_channels_dir ), hDirACRend->sba_map_tc[ch_idx] )], - Mpy_32_32( g, ( *( p_proto++ ) ) ) ); + Madd_32_32( output_imag[add( imult1616( l, num_channels_dir ), hDirACRend->sba_map_tc[ch_idx] )], + g, ( *( p_proto++ ) ) ); move32(); } } @@ -2436,9 +2419,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( move32(); FOR( i = 1; i < num_channels_dir; i++ ) { - p_real[l] = L_add( p_real[l], Mpy_32_32( *( p_out_real++ ), hoa_decoder[i] ) ); // (q, Q29) -> q - Q2 + p_real[l] = Madd_32_32( p_real[l], *( p_out_real++ ), hoa_decoder[i] ); // (q, Q29) -> q - Q2 move32(); - p_imag[l] = L_add( p_imag[l], Mpy_32_32( *( p_out_imag++ ), hoa_decoder[i] ) ); // (q, Q29) -> q - Q2 + p_imag[l] = Madd_32_32( p_imag[l], *( p_out_imag++ ), hoa_decoder[i] ); // (q, Q29) -> q - Q2 move32(); } } diff --git a/lib_rend/ivas_limiter.c b/lib_rend/ivas_limiter.c index 07f2ca72d..94f291ea1 100644 --- a/lib_rend/ivas_limiter.c +++ b/lib_rend/ivas_limiter.c @@ -796,11 +796,11 @@ void limiter_process_fx( /* Update gain */ IF( LT_32( frame_gain, gain ) ) { - gain = L_add( Mpy_32_32( attack_constant, ( L_sub( gain, frame_gain ) ) ), frame_gain ); /* Q30 */ + gain = Madd_32_32( frame_gain, attack_constant, L_sub( gain, frame_gain ) ); /* Q30 */ } ELSE { - gain = L_add( Mpy_32_32( release_constant, ( L_sub( gain, frame_gain ) ) ), frame_gain ); /* Q30 */ + gain = Madd_32_32( frame_gain, release_constant, L_sub( gain, frame_gain ) ); /* Q30 */ } FOR( c = 0; c < num_channels; c++ ) -- GitLab From d4ae4a4081bfd7cb810e2013677bc26ae11282fa Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 15 Jul 2024 12:38:26 +0530 Subject: [PATCH 2/2] Clang formatting changes --- lib_com/ivas_avq_pos_reorder_com.c | 2 +- lib_com/ivas_rom_com.c | 2 +- lib_com/ivas_stereo_ica_com_fx.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_com/ivas_avq_pos_reorder_com.c b/lib_com/ivas_avq_pos_reorder_com.c index f47aead34..692e89f86 100644 --- a/lib_com/ivas_avq_pos_reorder_com.c +++ b/lib_com/ivas_avq_pos_reorder_com.c @@ -89,4 +89,4 @@ void ordr_esti( return; } -#endif \ No newline at end of file +#endif diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index ace600eab..8733ad0bd 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -6835,4 +6835,4 @@ const ACPL_QUANT_TABLE ivas_mc_paramupmix_beta_quant_table[9] = 0, /* offset */ { +0.000000e+000f, +5.937500e-002f, +1.375000e-001f, +2.343750e-001f, +3.500000e-001f, +4.843750e-001f, +6.375000e-001f, +8.093750e-001f, +1.000000e+000f } /* data */ } -}; \ No newline at end of file +}; diff --git a/lib_com/ivas_stereo_ica_com_fx.c b/lib_com/ivas_stereo_ica_com_fx.c index d96d64c7c..6ffce03e4 100644 --- a/lib_com/ivas_stereo_ica_com_fx.c +++ b/lib_com/ivas_stereo_ica_com_fx.c @@ -397,4 +397,4 @@ void adjustTargetSignal_fx( return; } -#endif \ No newline at end of file +#endif -- GitLab