From e17b605a64391172d10780800697d94dbab6670b Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Fri, 10 Oct 2025 15:06:08 +0200 Subject: [PATCH 01/17] lib_rend/ivas_dirac_rend_fx.c: replaced idiv1616(x,2) with shr(x,1). --- lib_rend/ivas_dirac_rend_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 83615cfb7..910064496 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 ); -- GitLab From 42fac338e18e15da1d8a23b9163a4d735443e50c Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Fri, 10 Oct 2025 15:36:24 +0200 Subject: [PATCH 02/17] replaced idiv1616(x, L_SUBFR) with shr(x, L_SUBFR_LOG2), which is equivalen, in ib_com/bits_alloc_fx.c, dec_ace_fx.c, /dec_amr_wb_fx.c, dec_gen_voic_fx.c, dec_tran_fx.c, dec_uv_fx.c --- lib_com/bits_alloc_fx.c | 8 ++++---- lib_dec/dec_ace_fx.c | 6 +++--- lib_dec/dec_amr_wb_fx.c | 2 +- lib_dec/dec_gen_voic_fx.c | 2 +- lib_dec/dec_tran_fx.c | 4 ++-- lib_dec/dec_uv_fx.c | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c index 9909f413d..6440b2672 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 */ } } diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index b6554e02c..331a9d93c 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 c5b08a784..f34580bde 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 39412a22e..8d194d39a 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 b30b1a8c0..2fd28cbf6 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 f1ba21979..9dc651fc7 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(); -- GitLab From beacbfc420801567f50cb7eba42d1e90909cbfca Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Fri, 10 Oct 2025 16:07:40 +0200 Subject: [PATCH 03/17] replaced the division by 6 with a multiplication with 10923, followed by a shift 16. --- lib_com/bits_alloc_fx.c | 2 +- lib_com/cnst.h | 1 + lib_com/codec_tcx_common_fx.c | 3 ++- lib_enc/cod_tcx_fx.c | 9 ++++++--- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c index 6440b2672..594597325 100644 --- a/lib_com/bits_alloc_fx.c +++ b/lib_com/bits_alloc_fx.c @@ -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 a608fd607..11ab8e30c 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 010590ad1..5c5ed99d3 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_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index a08a81c4a..0538eecd1 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 ) -- GitLab From c32585f9a093fc88ee4cc27967f4dc3311310e96 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Fri, 10 Oct 2025 16:10:35 +0200 Subject: [PATCH 04/17] applied the clang patch; --- lib_com/codec_tcx_common_fx.c | 2 +- lib_enc/cod_tcx_fx.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_com/codec_tcx_common_fx.c b/lib_com/codec_tcx_common_fx.c index 5c5ed99d3..ae8ea6ebc 100644 --- a/lib_com/codec_tcx_common_fx.c +++ b/lib_com/codec_tcx_common_fx.c @@ -28,7 +28,7 @@ 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_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 0538eecd1..6027349ba 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -921,7 +921,7 @@ 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 */ } @@ -1142,7 +1142,7 @@ 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 @@ -2064,7 +2064,7 @@ 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 */ } -- GitLab From 66423def56bb188f7db8d584fca4f3a9040ad016 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Mon, 13 Oct 2025 10:21:18 +0200 Subject: [PATCH 05/17] replaced division by 20 with *26215 >> 19 --- lib_dec/FEC_HQ_core_fx.c | 6 +++--- lib_dec/ivas_stereo_switching_dec_fx.c | 2 +- lib_enc/tcx_utils_enc_fx.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/FEC_HQ_core_fx.c b/lib_dec/FEC_HQ_core_fx.c index c90530d5d..8a1775870 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/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 2cd075478..20c7b1055 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_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index b8f187205..db9338a7b 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(); -- GitLab From 81a2e4e01d03cfc2105e33fe63f0bd5b25aeef7b Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Mon, 13 Oct 2025 10:28:32 +0200 Subject: [PATCH 06/17] replaced div10 with equivalent *26215 >>18 operations. --- lib_dec/ivas_mc_paramupmix_dec_fx.c | 2 +- lib_dec/ivas_stereo_switching_dec_fx.c | 2 +- lib_dec/jbm_jb4sb_fx.c | 2 +- lib_enc/ivas_stereo_dft_td_itd_fx.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index fa36c4f34..16f95e25a 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_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 20c7b1055..de4e54da7 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 = extract_L( L_shr( imult3216( 26215, output_frame ), 19 ) ); /* Q0. equivalent to output_frame/20 */ + 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 6357c3a1b..31c37aa60 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_enc/ivas_stereo_dft_td_itd_fx.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c index 0e404a0de..3daca2859 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 ) ); -- GitLab From 88d023a3d9c71ed16a09fccd8568e8f8d4302c34 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Mon, 13 Oct 2025 10:31:43 +0200 Subject: [PATCH 07/17] replaced div5 with equivalent *26215 >> 17 --- lib_dec/avq_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/avq_dec_fx.c b/lib_dec/avq_dec_fx.c index a8ba2bfc3..da5816ce3 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( 10923, bits ), 16 ) ); /* 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( 10923, tmp ), 16 ) ); /* equivalent to tmp/5 */ IF( ( ( tmp % 5 ) != 0 ) ) { nq_est = add( nq_est, 1 ); -- GitLab From a278b3f699f489ad3b37df166fb2a2c1e21bf6a9 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Mon, 13 Oct 2025 10:32:53 +0200 Subject: [PATCH 08/17] replaced div5 with equivalent *26215 >> 17 (for real this time) --- lib_dec/avq_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/avq_dec_fx.c b/lib_dec/avq_dec_fx.c index da5816ce3..0e6857d4d 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 = extract_l( L_shr( imult3216( 10923, bits ), 16 ) ); /* equivalent to 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 = extract_l( L_shr( imult3216( 10923, tmp ), 16 ) ); /* equivalent to 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 ); -- GitLab From a5263b2412459e698206078fa5e8bf9e5f009dc0 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Mon, 13 Oct 2025 10:36:40 +0200 Subject: [PATCH 09/17] replaced div25 with equivalent *5243 >> 17. --- lib_enc/fd_cng_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 8b41b4e78..d6a00745e 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -66,7 +66,7 @@ void initFdCngEnc_fx( move16(); hsCom->numCoreBands = 16; move16(); - hsCom->regularStopBand = idiv1616U( extract_l( L_shr( input_Fs, 5 ) ), 25 ); /* Q0 */ + hsCom->regularStopBand = extract_l( L_shr( imult3216( 5243, L_shr( input_Fs, 5 ) ), 17 ) ); /* Q0. equivalent to L_shr( input_Fs, 5 )/25 */ move16(); if ( GT_16( hsCom->regularStopBand, 40 ) ) { -- GitLab From b74ceadbf4520e623ab8fd7d9e3375200b5f74c4 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Mon, 13 Oct 2025 10:51:17 +0200 Subject: [PATCH 10/17] removed a compiler warning. --- lib_enc/fd_cng_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index d6a00745e..21a582180 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -66,7 +66,7 @@ void initFdCngEnc_fx( move16(); hsCom->numCoreBands = 16; move16(); - hsCom->regularStopBand = extract_l( L_shr( imult3216( 5243, L_shr( input_Fs, 5 ) ), 17 ) ); /* Q0. equivalent to L_shr( input_Fs, 5 )/25 */ + hsCom->regularStopBand = extract_l( L_shr( imult3216( 5243, extract_l( L_shr( input_Fs, 5 ) ) ), 17 ) ); /* Q0. equivalent to L_shr( input_Fs, 5 )/25 */ move16(); if ( GT_16( hsCom->regularStopBand, 40 ) ) { -- GitLab From 859121f672a4c6e5fcc590bfce5e0b0a59b9f09d Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Mon, 13 Oct 2025 11:08:13 +0200 Subject: [PATCH 11/17] rollback on the div25 --- lib_enc/fd_cng_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 21a582180..8b41b4e78 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -66,7 +66,7 @@ void initFdCngEnc_fx( move16(); hsCom->numCoreBands = 16; move16(); - hsCom->regularStopBand = extract_l( L_shr( imult3216( 5243, extract_l( L_shr( input_Fs, 5 ) ) ), 17 ) ); /* Q0. equivalent to L_shr( input_Fs, 5 )/25 */ + hsCom->regularStopBand = idiv1616U( extract_l( L_shr( input_Fs, 5 ) ), 25 ); /* Q0 */ move16(); if ( GT_16( hsCom->regularStopBand, 40 ) ) { -- GitLab From 17d907012ae3a65c055f381dab03fc5ff305d4be Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Mon, 13 Oct 2025 11:14:36 +0200 Subject: [PATCH 12/17] replaced one more div2 with shr1 --- lib_com/ivas_dirac_com_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index 7be684535..9d98df307 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++ ) -- GitLab From 769223cd4885c0757fa3160cce4710bd04570e21 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Mon, 13 Oct 2025 11:24:04 +0200 Subject: [PATCH 13/17] in linv_enc_ivas_stereo_dmx_evs_fx.c: div4 and div8 were replaced by shr2 and shr3 --- lib_enc/ivas_stereo_dmx_evs_fx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index 852be98fe..78cbd1063 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -49,7 +49,9 @@ *-----------------------------------------------------------------------*/ #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++ ) { -- GitLab From 710b59f3bfa0827b46678f1d44d2e5b68be884c0 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Mon, 13 Oct 2025 11:34:42 +0200 Subject: [PATCH 14/17] replaced / L_FRAME16k with *26215 >> 23. --- lib_dec/swb_tbe_dec_fx.c | 2 +- lib_enc/ivas_stereo_td_enc_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index c3291bde2..5b7bcf475 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/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index e617e1a9a..1a7b592db 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 ); -- GitLab From 5a10d34d350f8188478171dd53676fe064e5d025 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Mon, 13 Oct 2025 11:43:11 +0200 Subject: [PATCH 15/17] div40 replaced with *26215 >> 20 --- lib_dec/ivas_pca_dec_fx.c | 2 +- lib_enc/ivas_pca_enc_fx.c | 2 +- lib_enc/ivas_stereo_dmx_evs_fx.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_pca_dec_fx.c b/lib_dec/ivas_pca_dec_fx.c index 98611ab7c..3127ae007 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_enc/ivas_pca_enc_fx.c b/lib_enc/ivas_pca_enc_fx.c index 2cb347a02..a5dbfc077 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_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index 78cbd1063..b50bc93c5 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -48,9 +48,9 @@ * Local constants *-----------------------------------------------------------------------*/ -#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_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 -- GitLab From b14bf2d719726c842fd91f5cb2a64fc1583c74b9 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Mon, 13 Oct 2025 11:46:04 +0200 Subject: [PATCH 16/17] replaced a div4 with a shr2 --- lib_enc/ivas_mcmasa_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 5c8822919..abcdda76f 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; -- GitLab From 390af0ce927276daf4b4a362e8abe00fc65031c0 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Mon, 13 Oct 2025 11:50:05 +0200 Subject: [PATCH 17/17] replaced another div6 with *10923 >>16 --- lib_dec/ivas_qmetadata_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_qmetadata_dec_fx.c b/lib_dec/ivas_qmetadata_dec_fx.c index f71a40e1c..eaf2091bf 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; -- GitLab