diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c index 9909f413da13f5b33d3d7ba6306817a812e1c5f5..594597325c51cfb84c793ab6d65b1d153e83313f 100644 --- a/lib_com/bits_alloc_fx.c +++ b/lib_com/bits_alloc_fx.c @@ -570,7 +570,7 @@ static ivas_error acelp_FCB_allocator_fx( SWAP( fixed_cdk_index[0], fixed_cdk_index[tc_subfr / L_SUBFR] ); /* TRANSITION coding: allocate second highest FCBQ bit-budget to the last subframe */ - IF( LT_16( idiv1616( tc_subfr, L_SUBFR ), sub( nb_subfr, 1 ) ) ) + IF( LT_16( shr( tc_subfr, L_SUBFR_LOG2 ), sub( nb_subfr, 1 ) ) ) { SWAP( fixed_cdk_index[sub( tc_subfr, L_SUBFR ) / L_SUBFR], fixed_cdk_index[nb_subfr - 1] ); } @@ -1134,7 +1134,7 @@ ivas_error config_acelp1_fx( test(); IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) && NE_16( tc_subfr, 192 ) ) { - bits = sub( bits, idiv1616( sub( L_FRAME - L_SUBFR, tc_subfr ), L_SUBFR ) ); /* LP filtering flag */ + bits = sub( bits, shr( sub( L_FRAME - L_SUBFR, tc_subfr ), L_SUBFR_LOG2 ) ); /* LP filtering flag */ } } ELSE @@ -1147,7 +1147,7 @@ ivas_error config_acelp1_fx( test(); IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) && NE_16( tc_subfr, 192 ) ) { - bits = sub( bits, idiv1616( sub( L_FRAME - L_SUBFR, tc_subfr ), L_SUBFR ) ); /* LP filtering flag */ + bits = sub( bits, shr( sub( L_FRAME - L_SUBFR, tc_subfr ), L_SUBFR_LOG2 ) ); /* LP filtering flag */ } } } @@ -1167,7 +1167,7 @@ ivas_error config_acelp1_fx( IF( NE_16( tc_subfr, 256 ) ) { - bits = sub( bits, idiv1616( sub( L_FRAME16k - L_SUBFR, tc_subfr ), L_SUBFR ) ); /* LP filtering flag */ + bits = sub( bits, shr( sub( L_FRAME16k - L_SUBFR, tc_subfr ), L_SUBFR_LOG2 ) ); /* LP filtering flag */ } } @@ -1325,7 +1325,7 @@ ivas_error config_acelp1_fx( test(); IF( EQ_16( coder_type, UNVOICED ) && !( *uc_two_stage_flag ) ) { - i = idiv1616( bits, NB_SUBFR ); + i = shr( bits, NB_SUBFR_LOG2 ); IF( s_and( i, 1 ) == 0 ) { i = sub( i, 1 ); /* must be odd */ diff --git a/lib_com/cnst.h b/lib_com/cnst.h index a608fd6077b56fc5448775b9e8fe989038bf1809..11ab8e30cac65a30ad2f8a3e55086cec2ef8fbb3 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -714,6 +714,7 @@ enum #define M 16 /* order of the LP filter @ 12.8kHz */ #define L_FRAME 256 /* frame size at 12.8kHz */ #define NB_SUBFR 4 /* number of subframes per frame */ +#define NB_SUBFR_LOG2 2 /* To be used for shift operation instead of division */ #define L_SUBFR ( L_FRAME / NB_SUBFR ) /* subframe size */ #define L_SUBFR_LOG2 6 /* To be used for shift operation instead of division */ #define L_SUBFR_Q6 ((L_FRAME/NB_SUBFR)*64) /* subframe size */ diff --git a/lib_com/codec_tcx_common_fx.c b/lib_com/codec_tcx_common_fx.c index 010590ad176ff7f53348a5bd3a763d4b0d9fc55b..ae8ea6ebc5c35d2912d8dcc6b4f9e6201afd40e4 100644 --- a/lib_com/codec_tcx_common_fx.c +++ b/lib_com/codec_tcx_common_fx.c @@ -28,7 +28,8 @@ Word16 tcxGetNoiseFillingTilt( IF( mode != 0 ) { - firstLine = idiv1616U( L_frame, 6 ); + // firstLine = idiv1616U( L_frame, 6 ); + firstLine = extract_l( L_shr( imult3216( 10923, L_frame ), 16 ) ); /* equivalent to L_frame / 6 */ *noiseTiltFactor = 18432 /*0.5625f Q15*/; move16(); } diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index 7be68453542323370cee38ad5e44df2db8db3a6d..9d98df307385e31ca5d422b31c79d7d83fdb65f0 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -907,7 +907,7 @@ void computeDiffuseness_fixed( } min_q_shift1 = getScaleFactor32( intensity_slow, i_mult( DIRAC_NUM_DIMS, num_freq_bands ) ); - min_q_shift1 = sub( min_q_shift1, idiv1616( add( find_guarded_bits_fx( DIRAC_NUM_DIMS ), 1 ), 2 ) ); + min_q_shift1 = sub( min_q_shift1, shr( add( find_guarded_bits_fx( DIRAC_NUM_DIMS ), 1 ), 1 ) ); scale_sig32( intensity_slow, i_mult( DIRAC_NUM_DIMS, num_freq_bands ), min_q_shift1 ); q_intensity = add( q_intensity, min_q_shift1 ); FOR( k = 0; k < num_freq_bands; k++ ) diff --git a/lib_dec/FEC_HQ_core_fx.c b/lib_dec/FEC_HQ_core_fx.c index c90530d5dc23b5316d00bbf860197b4377ec78be..8a1775870e87e91c7297221dbecbb408f79b882e 100644 --- a/lib_dec/FEC_HQ_core_fx.c +++ b/lib_dec/FEC_HQ_core_fx.c @@ -1180,9 +1180,9 @@ static Word16 FEC_phase_matching_fx( L = L_FRAME8k; move16(); - ol_size = idiv1616( shl( L, 1 ), 20 ); + ol_size = extract_l( L_shr( imult3216( 26215, shl( L, 1 ) ), 19 ) ); /* equivalent to shl( L, 1)/20 */ move16(); - L_overlap = idiv1616( imult1616( 3, L ), 20 ); + L_overlap = extract_l( L_shr( imult3216( 26215, imult1616( 3, L ) ), 19 ) ); /* equivalent to L*3/20 */ move16(); FOR( i = 0; i < L_overlap; i++ ) @@ -1370,7 +1370,7 @@ static void FEC_phase_matching_burst_fx( L = L_FRAME8k; move16(); - L_overlap = idiv1616( imult1616( 3, L ), 20 ); + L_overlap = extract_l( L_shr( imult3216( 26215, imult1616( 3, L ) ), 19 ) ); /* equivalent to L*3/20 */ move16(); FOR( i = 0; i < L_overlap; i++ ) diff --git a/lib_dec/avq_dec_fx.c b/lib_dec/avq_dec_fx.c index a8ba2bfc3612253b30e153d2cb22f863afe3d4a4..0e6857d4d34d3027e18ac551a439cec841232dbf 100644 --- a/lib_dec/avq_dec_fx.c +++ b/lib_dec/avq_dec_fx.c @@ -188,7 +188,7 @@ void AVQ_demuxdec_fx( nullVec = add( nullVec, 1 ); } } - nq_est = idiv1616( bits, 5 ); + nq_est = extract_l( L_shr( imult3216( 26215, bits ), 17 ) ); /* equivalent to bits/5 */ test(); test(); test(); @@ -269,7 +269,7 @@ void AVQ_demuxdec_fx( /*Compute AVQ code book number from unused Bits */ tmp = (Word16) ( sub( bits, add( add( shl( add( unusedbitsFlag, unused_bits_idx ), 2 ), unusedbitsFlag ), unused_bits_idx ) ) ); - nq_est = idiv1616( tmp, 5 ); + nq_est = extract_l( L_shr( imult3216( 26215, tmp ), 17 ) ); /* equivalent to tmp/5 */ IF( ( ( tmp % 5 ) != 0 ) ) { nq_est = add( nq_est, 1 ); diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index b6554e02c7343616afa751b98551660230abc8bf..331a9d93c1b1811dc6c739ca8d0621fdbd074c6c 100644 --- a/lib_dec/dec_ace_fx.c +++ b/lib_dec/dec_ace_fx.c @@ -265,7 +265,7 @@ void decoder_acelp_fx( Word16 idx = 0; IF( i_subfr != 0 ) { - idx = idiv1616( i_subfr, L_SUBFR ); + idx = shr( i_subfr, L_SUBFR_LOG2 ); } test(); @@ -658,7 +658,7 @@ void decoder_acelp_fx( Word16 L_frame_fr = 0; IF( st->L_frame != 0 ) { - L_frame_fr = idiv1616( st->L_frame, L_SUBFR ); + L_frame_fr = shr( st->L_frame, L_SUBFR_LOG2 ); } FOR( i = 0; i < L_frame_fr; i++ ) @@ -717,7 +717,7 @@ void decoder_acelp_fx( move16(); IF( i_subfr != 0 ) { - idx = idiv1616( i_subfr, L_SUBFR ); + idx = shr( i_subfr, L_SUBFR_LOG2 ); } *pT++ = round_fx( pitch_buf[idx] ); // Q0 } diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c index c5b08a784c0f3fa6cd8fd63f925dbc23dc60c16e..f34580bde6e95b6da4488d6c686b8154eb594535 100644 --- a/lib_dec/dec_amr_wb_fx.c +++ b/lib_dec/dec_amr_wb_fx.c @@ -141,7 +141,7 @@ void decod_amr_wb_fx( move16(); IF( i_subfr != 0 ) { - idx = idiv1616( i_subfr, L_SUBFR ); + idx = shr( i_subfr, L_SUBFR_LOG2 ); } /*voice_factors[i_subfr/L_SUBFR] = min( max(0.0f, voice_fac), 1.0f);*/ diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 39412a22e85a936a91905ce3689b58f7f82658ea..8d194d39adff2af5de78531ba6245ebdaa2afe3e 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -323,7 +323,7 @@ ivas_error decod_gen_voic_fx( move16(); IF( i_subfr_fx != 0 ) { - idx = idiv1616( i_subfr_fx, L_SUBFR ); + idx = shr( i_subfr_fx, L_SUBFR_LOG2 ); } #ifdef FIX_2010_PREP_TBE_EXC diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index b30b1a8c066576225a9db240ba71d830c1e00e21..2fd28cbf6e2c79ee6a103615e6c8ec1d657bada8 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -254,7 +254,7 @@ void decod_tran_fx( move16(); if ( i_subfr != 0 ) { - tmp_idx_2 = idiv1616( i_subfr, L_SUBFR ); + tmp_idx_2 = shr( i_subfr, L_SUBFR_LOG2 ); } #ifdef FIX_2010_PREP_TBE_EXC @@ -304,7 +304,7 @@ void decod_tran_fx( move16(); if ( i_subfr != 0 ) { - tmp_idx = idiv1616( i_subfr, L_SUBFR ); + tmp_idx = shr( i_subfr, L_SUBFR_LOG2 ); } p_Aq_fx += ( M + 1 ); pt_pitch_fx++; diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index f1ba21979228b1e0634efef8bf139c511869fc4f..9dc651fc7efabd6c750293a2290228f377e26b47 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -108,7 +108,7 @@ void decod_unvoiced_fx( move16(); if ( i_subfr_fx != 0 ) { - tmp_idx_1 = idiv1616( i_subfr_fx, L_SUBFR ); + tmp_idx_1 = shr( i_subfr_fx, L_SUBFR_LOG2 ); } Word16 index; index = get_next_indice_fx( st_fx, st_fx->acelp_cfg.gains_mode[tmp_idx_1] ); @@ -183,7 +183,7 @@ void decod_unvoiced_fx( move16(); IF( i_subfr_fx != 0 ) { - tmp_idx = idiv1616( i_subfr_fx, L_SUBFR ); + tmp_idx = shr( i_subfr_fx, L_SUBFR_LOG2 ); } voice_factors_fx[tmp_idx] = 0; move16(); diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index fa36c4f34adb85aa4c40ac21d3ca6ea4caaf176c..16f95e25a21754b950b55cc7cf73adc2ac06b367 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -509,7 +509,7 @@ static void paramupmix_td_decorr_process_jbm_fx( Word16 offset; Word32 in_duck_gain[L_FRAME48k], out_duck_gain[L_FRAME48k]; // Q30 - offset = idiv1616( output_frame, 10 ); + offset = extract_l( L_shr( imult3216( 10923, output_frame ), 18 ) ); /* equivalent to output_frame/10 */ /* Look-ahead delay */ FOR( k = 0; k < MC_PARAMUPMIX_COMBINATIONS; k++ ) diff --git a/lib_dec/ivas_pca_dec_fx.c b/lib_dec/ivas_pca_dec_fx.c index 98611ab7cbcf9af52799eb55c91a6353ee726624..3127ae00790f8e7d2bc2955fb7c0b7a03cdaebab 100644 --- a/lib_dec/ivas_pca_dec_fx.c +++ b/lib_dec/ivas_pca_dec_fx.c @@ -143,7 +143,7 @@ static void pca_dec_inv_transform_fx( pca_interp_preproc_fx( hPCA->prev_ql_fx, hPCA->prev_qr_fx, ql_fx, qr_fx, IVAS_PCA_N_SLOTS, ql_interp_fx, qr_interp_fx ); - slot_len = idiv1616( n_samples, IVAS_PCA_N_SLOTS ); /*Q0*/ + slot_len = extract_l( L_shr( imult3216( 26215, n_samples ), 20 ) ); /*Q0. equivalent to n_samples/40*/ FOR( j = 0; j < IVAS_PCA_N_SLOTS; j++ ) { diff --git a/lib_dec/ivas_qmetadata_dec_fx.c b/lib_dec/ivas_qmetadata_dec_fx.c index f71a40e1cd353b67a81860dd8d88457a6a77b458..eaf2091bf9c6260b86ab1ffe5c149d6c63a04b0f 100644 --- a/lib_dec/ivas_qmetadata_dec_fx.c +++ b/lib_dec/ivas_qmetadata_dec_fx.c @@ -3962,7 +3962,7 @@ static Word16 read_coherence_data_fx( coding_subbands = hQMetaData->q_direction[idx_dir].cfg.nbands; move16(); - extra_cv = idiv1616( coding_subbands, MASA_FACTOR_CV_COH ); /*Q0*/ + extra_cv = extract_l( L_shr( imult3216( 10923, coding_subbands ), 16 ) ); /*Q0 equivalent to coding_subbands/6 */ move16(); q_direction = &( hQMetaData->q_direction[idx_dir] ); bit_pos = *p_bit_pos; diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 2cd075478f6dc237099144841f8496d8ad00b639..de4e54da7594fb894eca9c9e0a2ae2b3b4d78f7b 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -2418,7 +2418,7 @@ void smooth_dft2td_transition_fx( ilen = shr( output_frame, 1 ); /* Q0 */ /* correlation length */ - corr_len = idiv1616( output_frame, 20 ); /* Q0 */ + corr_len = extract_l( L_shr( imult3216( 26215, output_frame ), 19 ) ); /* Q0. equivalent to output_frame/20 */ subsampl = 4; FOR( ch = 0; ch < hCPE->nchan_out; ch++ ) diff --git a/lib_dec/jbm_jb4sb_fx.c b/lib_dec/jbm_jb4sb_fx.c index 6357c3a1bc70165220d678a281b327c663a0e179..31c37aa60917a161ddaf5e6ff885e5df719c0765 100644 --- a/lib_dec/jbm_jb4sb_fx.c +++ b/lib_dec/jbm_jb4sb_fx.c @@ -953,7 +953,7 @@ static void JB4_adaptActivePlayout( temp3 = W_add( temp3, 1 ); } rate = (UWord32) W_add( temp3, dropRateMin ); - *scale = idiv1616( sub( 1000, (Word16) rate ), 10 ); + *scale = extract_l( L_shr( imult3216( 10923, sub( 1000, (Word16) rate ) ), 18 ) ); /* equivalent to (1000-rate)/10 */ /* Limit max scaling to the duration of one frame. APA will not exceed this limit * anyway due to the 50% limitation of APA_MIN_SCALE and APA_MAX_SCALE. Limiting * the value to a sensible range here avoids integer overflows at later stages when diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index c3291bde24f95ec52e5fe52d111b5e27d64af6b0..5b7bcf475fd833cec4eb9ab8573f94522777ab98 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -3470,7 +3470,7 @@ void swb_tbe_dec_fx( Word16 idx = 0; IF( i != 0 ) { - idx = idiv1616( i_mult( NUM_SHB_SUBFR, i ), L_FRAME16k ); + idx = extract_l( L_shr( imult3216( 26215, i_mult( NUM_SHB_SUBFR, i ) ), 23 ) ); /* equivalent to i_mult( NUM_SHB_SUBFR, i )/L_FRAME16k */ } L_tmp1 = Mult_32_16( L_tmp, GainShape[idx] ); /* Q : 18 + tmp +15 -15*/ White_exc16k[i] = round_fx( Mult_32_16( L_tmp1, White_exc16k[i] ) ); /* 18 + tmp +*Q_white_exc -15 -16 */ diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index a08a81c4afe7c10466b3556d59874ffbe3e96237..6027349ba6bdcd3aa290680da6d16b664e6f4cec 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -921,7 +921,8 @@ static void EstimateTCXNoiseLevel_ivas_fx( test(); IF( GE_32( st->total_brate, ACELP_13k20 ) && st->rf_mode == 0 ) { - iStart = idiv1616U( L_frame, 6 ); + // iStart = idiv1616U( L_frame, 6 ); + iStart = extract_l( L_shr( imult3216( 10923, L_frame ), 16 ) ); /* equivalent to L_frame/6 */ } noiseTransWidth = GetTransWidth_ivas_fx( st->tcxonly, (Word16) EQ_16( L_frame, shr( st->L_frame, 1 ) ), st->hTcxEnc->tcxltp_gain, ( st->hTcxCfg->ctx_hm && st->last_core != ACELP_CORE && hm_active ) ); @@ -1141,7 +1142,8 @@ void EstimateStereoTCXNoiseLevel_fx( test(); IF( GE_32( total_brate, ACELP_13k20 ) && !st->rf_mode ) { - iStart = idiv1616( L_frame[ch][n], 6 ); + // iStart = idiv1616( L_frame[ch][n], 6 ); + iStart = extract_l( L_shr( imult3216( 10923, L_frame[ch][n] ), 16 ) ); /* for x in [0...32767], this is the equivalent of x/6 */ } ELSE { @@ -2062,7 +2064,8 @@ void QuantizeSpectrum_fx( test(); IF( GE_32( st->total_brate, ACELP_13k20 ) && st->rf_mode == 0 ) { - i = idiv1616U( L_frame, 6 ); + // i = idiv1616U( L_frame, 6 ); + i = extract_l( L_shr( imult3216( 10923, L_frame ), 16 ) ); /* equivalent to L_frame/6 */ } IF( tcxonly ) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 5c8822919feef1571338decf22762ada6081021e..abcdda76f3dae62d5be6dfad27730ffa3af33a8e 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -2376,7 +2376,7 @@ static void computeLfeEnergy_fx( Word16 inp_q = q_inp; move16(); - l_ts = idiv1616( input_frame, MDFT_NO_COL_MAX ); + l_ts = shr( input_frame, MDFT_NO_COL_MAX_LOG2 ); separateChannelIndex = hMcMasa->separateChannelIndex; move16(); lfeChannelIndex = LFE_CHANNEL; diff --git a/lib_enc/ivas_pca_enc_fx.c b/lib_enc/ivas_pca_enc_fx.c index 2cb347a026794ad3e32d70cad242c81d02731e86..a5dbfc077ed73e8bb324717869b4881fd17f23f7 100644 --- a/lib_enc/ivas_pca_enc_fx.c +++ b/lib_enc/ivas_pca_enc_fx.c @@ -146,7 +146,7 @@ static void pca_enc_transform_fx( quat_shortestpath_fx( hPCA->prev_ql_fx, ql_fx, hPCA->prev_qr_fx, qr_fx ); pca_interp_preproc_fx( hPCA->prev_ql_fx, hPCA->prev_qr_fx, ql_fx, qr_fx, IVAS_PCA_N_SLOTS, ql_interp_fx, qr_interp_fx ); - slot_len = idiv1616( input_frame, IVAS_PCA_N_SLOTS ); + slot_len = extract_l( L_shr( imult3216( 26215, input_frame ), 20 ) ); /* equivalent to input_frame/40 */ FOR( time_slot = 0; time_slot < IVAS_PCA_N_SLOTS; time_slot++ ) { diff --git a/lib_enc/ivas_stereo_dft_td_itd_fx.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c index 0e404a0de6fe6e81056f5767994d4d055674f3c7..3daca2859d376371b0cdd02391bc39f299c6914f 100644 --- a/lib_enc/ivas_stereo_dft_td_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_td_itd_fx.c @@ -216,7 +216,7 @@ static void stereo_td_channel_extrapolate_fx( move16(); move16(); - pred_ovlp = idiv1616( input_frame, 10 ); + pred_ovlp = extract_l( L_shr( imult3216( 10923, input_frame ), 18 ) ); /* equivalent to input_frame/10 */ /*get pitch lag from previous frame */ // pitch_lag = (int16_t) ( pitch0 * ( (float) input_frame / L_FRAME ) ); diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index 852be98fe7132d51bdd0c5c4dba5a892a779c27f..b50bc93c55fffbc9af2afc8dbc0c415a7cde041b 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -48,8 +48,10 @@ * Local constants *-----------------------------------------------------------------------*/ -#define STEREO_DMX_EVS_FIND_POC_PEAK_TAU 4 -#define STEREO_DMX_EVS_FIND_POC_PEAK_TAU2 8 +#define STEREO_DMX_EVS_FIND_POC_PEAK_TAU 4 +#define STEREO_DMX_EVS_FIND_POC_PEAK_TAU_LOG2 2 +#define STEREO_DMX_EVS_FIND_POC_PEAK_TAU2 8 +#define STEREO_DMX_EVS_FIND_POC_PEAK_TAU2_LOG2 3 #define STEREO_DMX_EVS_POC_SMOOTH_Q30 1342177280 #define STEREO_DMX_EVS_POC_FORGETTING_Q31 1675037245 @@ -1398,8 +1400,8 @@ static Word32 find_poc_peak_fx( move16(); /*compute peak_range*/ - tmp1 = idiv1616( hPOC->shift_limit, STEREO_DMX_EVS_FIND_POC_PEAK_TAU ); - peak_range = idiv1616( add( extract_l( abs_s( itd_cand[n] ) ), tmp1 ), STEREO_DMX_EVS_FIND_POC_PEAK_TAU2 ); // Q0 + tmp1 = shr( hPOC->shift_limit, STEREO_DMX_EVS_FIND_POC_PEAK_TAU_LOG2 ); + peak_range = shr( add( extract_l( abs_s( itd_cand[n] ) ), tmp1 ), STEREO_DMX_EVS_FIND_POC_PEAK_TAU2_LOG2 ); // Q0 FOR( i = 1; i <= peak_range; i++ ) { diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index e617e1a9ab707d744a1a3d6a97498694ba3d0812..1a7b592db647bb3ea8f51f8451c7fc7be2b0629d 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -1009,7 +1009,7 @@ void stereo_tdm_prep_dwnmx_fx( Word16 mener_e; sts = hCPE->hCoreCoder; - i = idiv1616( input_frame, L_FRAME16k ); + i = extract_l( L_shr( imult3216( 26215, input_frame ), 23 ) ); /* equivalent to input_frame/L_FRAME16k */ sw_pos = i_mult( 22, i ); enr_len = i_mult( 6, i ); diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index b8f187205de3b3e3ef02d87751b1a40c061dbdc6..db9338a7b36d9fc9bb33e9908f91f52ba1aa252e 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -3852,7 +3852,7 @@ void attenuateNbSpectrum_fx( Word16 L_frame, Word32 *spectrum ) { Word16 i, length, att; - length = idiv1616U( L_frame, 20 ); + length = extract_l( L_shr( imult3216( 26215, L_frame ), 19 ) ); /* equivalent to L_frame/20 */ att = 21627 /*0.66f Q15*/; move16(); diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 83615cfb77fe3968a8bada855aa31b04d86f8d4d..9100644967a4ef07f11a2297306b02e6a8b3b34b 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -1929,8 +1929,8 @@ void protoSignalComputation2_fx( /* total_shift shift required to get common Q of sum power values */ total_shift[0] = shl( s_max( 0, sub( min_q_shift[0], min_q_shift[1] ) ), 1 ); total_shift[1] = shl( s_max( 0, sub( min_q_shift[1], min_q_shift[0] ) ), 1 ); - min_q_shift[0] = sub( min_q_shift[0], idiv1616( find_guarded_bits_fx( num_freq_bands ), 2 ) ); - min_q_shift[1] = sub( min_q_shift[1], idiv1616( find_guarded_bits_fx( num_freq_bands ), 2 ) ); + min_q_shift[0] = sub( min_q_shift[0], shr( find_guarded_bits_fx( num_freq_bands ), 1 ) ); + min_q_shift[1] = sub( min_q_shift[1], shr( find_guarded_bits_fx( num_freq_bands ), 1 ) ); q_temp[0] = sub( add( add( q_cldfb, min_q_shift[0] ), add( q_cldfb, min_q_shift[0] ) ), 31 ); q_temp[1] = sub( add( add( q_cldfb, min_q_shift[1] ), add( q_cldfb, min_q_shift[1] ) ), 31 );