From 40543cfecfd5f2b2d816eec6739ec5fafcd10e73 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 07:23:45 +0200 Subject: [PATCH 01/31] ivas_dirac_output_synthesis_dec_fx.c: change shl_ro to shr_r, invert shift factor and delete overflow flag --- lib_dec/dec_gen_voic_fx.c | 10 +++------- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 3 +-- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 6 ++---- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 14d9d1772..aa1a75b53 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -106,10 +106,6 @@ ivas_error decod_gen_voic_fx( gain_inov_fx = 0; error_fx = 0; gain_preQ_fx = 0; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif move16(); move32(); move32(); @@ -467,9 +463,9 @@ ivas_error decod_gen_voic_fx( test(); test(); test(); - IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ - LT_16( shl_ro( enratio, sub( 10, Qenratio ), &Overflow ), 15360 ) && /*compare with 15.0 in Q10*/ - GT_16( shl_ro( sp_enratio, sub( 15, Qsp_enratio ), &Overflow ), 4915 ) && /*compare with 0.15 in Q15*/ + IF( GT_16( shr_r( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ + LT_16( shr_r( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ + GT_16( shr_r( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ { diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index cc13c0148..3c1e49f32 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -128,7 +128,6 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, IF( sqrtXY != 0 ) { - Flag Overflow = 0; move32(); normCC = 0; move16(); @@ -136,7 +135,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, normCC = add( normCC, 16 ); /* scale to Q15 with saturation */ BASOP_SATURATE_WARNING_OFF - cc = shl_ro( cc, add( normXY, normCC ), &Overflow ); + cc = shr_r( cc, negate(add( normXY, normCC )) ); BASOP_SATURATE_WARNING_ON *energy = L_shr_r( L_deposit_l( sqrtXY ), normXY ); } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index ba0ab8953..e68473c1d 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4082,11 +4082,10 @@ void ivas_lfe_synth_with_filters_fx( } ELSE { - Flag overFlow; lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/ lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp - lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp, &overFlow ); // Q15 + lfeGain_fx = shr_r( lfeGain_fx, negate(lfeGain_fx_exp) ); // Q15 } IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) ) { @@ -4095,11 +4094,10 @@ void ivas_lfe_synth_with_filters_fx( } ELSE { - Flag overFlow; transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); /*Q=15-(transportGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneTransSmooth_q)*/ transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp - transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp, &overFlow ); // Q15 + transportGain_fx = shr_r( transportGain_fx, negate(transportGain_fx_exp) ); // Q15 } j = 0; move16(); -- GitLab From 37e55195a94799639de8e410686184eec0e13d51 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 07:38:26 +0200 Subject: [PATCH 02/31] apply format patch --- lib_dec/dec_gen_voic_fx.c | 4 ++-- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index aa1a75b53..0ad876eb9 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -466,8 +466,8 @@ ivas_error decod_gen_voic_fx( IF( GT_16( shr_r( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ LT_16( shr_r( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ GT_16( shr_r( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ - LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ - LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ + LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ + LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ { IF( NE_32( ( error = DTFS_new_fx( &PREVP ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index 3c1e49f32..a7b9d75ad 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -135,7 +135,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, normCC = add( normCC, 16 ); /* scale to Q15 with saturation */ BASOP_SATURATE_WARNING_OFF - cc = shr_r( cc, negate(add( normXY, normCC )) ); + cc = shr_r( cc, negate( add( normXY, normCC ) ) ); BASOP_SATURATE_WARNING_ON *energy = L_shr_r( L_deposit_l( sqrtXY ), normXY ); } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index e68473c1d..571fd6b92 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4084,8 +4084,8 @@ void ivas_lfe_synth_with_filters_fx( { lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/ lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); - lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp - lfeGain_fx = shr_r( lfeGain_fx, negate(lfeGain_fx_exp) ); // Q15 + lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp + lfeGain_fx = shr_r( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 } IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) ) { @@ -4096,8 +4096,8 @@ void ivas_lfe_synth_with_filters_fx( { transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); /*Q=15-(transportGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneTransSmooth_q)*/ transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); - transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp - transportGain_fx = shr_r( transportGain_fx, negate(transportGain_fx_exp) ); // Q15 + transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp + transportGain_fx = shr_r( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 } j = 0; move16(); -- GitLab From 7ed09264fd00973fe5d3b44b11581746319a5fa2 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 06:14:02 +0000 Subject: [PATCH 03/31] change shr_r to shr_r_sat --- lib_dec/dec_gen_voic_fx.c | 6 +++--- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 0ad876eb9..297f61788 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -463,9 +463,9 @@ ivas_error decod_gen_voic_fx( test(); test(); test(); - IF( GT_16( shr_r( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ - LT_16( shr_r( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ - GT_16( shr_r( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ + IF( GT_16( shr_r_sat( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ + LT_16( shr_r_sat( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ + GT_16( shr_r_sat( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ { diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index a7b9d75ad..72627a5a0 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -135,7 +135,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, normCC = add( normCC, 16 ); /* scale to Q15 with saturation */ BASOP_SATURATE_WARNING_OFF - cc = shr_r( cc, negate( add( normXY, normCC ) ) ); + cc = shr_r_sat( cc, negate( add( normXY, normCC ) ) ); BASOP_SATURATE_WARNING_ON *energy = L_shr_r( L_deposit_l( sqrtXY ), normXY ); } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 571fd6b92..ccdd172c7 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4085,7 +4085,7 @@ void ivas_lfe_synth_with_filters_fx( lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/ lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp - lfeGain_fx = shr_r( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 + lfeGain_fx = shr_r_sat( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 } IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) ) { @@ -4097,7 +4097,7 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); /*Q=15-(transportGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneTransSmooth_q)*/ transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp - transportGain_fx = shr_r( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 + transportGain_fx = shr_r_sat( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 } j = 0; move16(); -- GitLab From 88107f0fafbffbe7967623806426c84619c9b717 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 08:19:19 +0200 Subject: [PATCH 04/31] format patch --- lib_dec/dec_gen_voic_fx.c | 4 ++-- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 297f61788..ac1df74b2 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -466,8 +466,8 @@ ivas_error decod_gen_voic_fx( IF( GT_16( shr_r_sat( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ LT_16( shr_r_sat( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ GT_16( shr_r_sat( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ - LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ - LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ + LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ + LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ { IF( NE_32( ( error = DTFS_new_fx( &PREVP ) ), IVAS_ERR_OK ) ) { diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index ccdd172c7..7d47ea681 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4084,7 +4084,7 @@ void ivas_lfe_synth_with_filters_fx( { lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/ lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); - lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp + lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp lfeGain_fx = shr_r_sat( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 } IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) ) @@ -4096,7 +4096,7 @@ void ivas_lfe_synth_with_filters_fx( { transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); /*Q=15-(transportGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneTransSmooth_q)*/ transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); - transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp + transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp transportGain_fx = shr_r_sat( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 } j = 0; -- GitLab From b39ec53c0da752036872aac66ac2ba477466422d Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 10:25:21 +0200 Subject: [PATCH 05/31] Added switch ISSUE_1751_replace_shl_ro, added casesensitive shl_sat or shr_r --- lib_com/options.h | 1 + lib_dec/dec_gen_voic_fx.c | 25 ++++++++++++++-- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 15 +++++++++- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 29 +++++++++++++++++-- 4 files changed, 64 insertions(+), 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7996f8d41..b97f42247 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,6 +107,7 @@ #define VEC_ARITH_OPT_v1 #define FIX_1486_IND_SHB_RES /* VA: Fix for issue 1486: align the usage of IND_SHB_RES_GS indices with float code */ #define FIX_1511_POC_RENORM /* NTT: Fix for issue 1511: Renorm for POC. */ +#define ISSUE_1751_replace_shl_ro #define TEST_HR #define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */ diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index ac1df74b2..d003b9731 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -463,11 +463,30 @@ ivas_error decod_gen_voic_fx( test(); test(); test(); - IF( GT_16( shr_r_sat( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ - LT_16( shr_r_sat( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ - GT_16( shr_r_sat( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ +#ifdef ISSUE_1751_replace_shl_ro + Word16 op16_1 = sub( Qenratio, 15 ); + Word16 op16_2 = sub( Qenratio, 10 ); + Word16 op16_3 = sub( Qsp_enratio, 15 ); + +BASOP_SATURATE_WARNING_OFF + op16_1 = op16_1 >= 0 ? shr_r( enratio, op16_1 ) : shl_sat( enratio, negate(op16_1) ); + op16_2 = op16_2 >= 0 ? shr_r( sp_enratio, op16_2 ) : shl_sat( sp_enratio, negate( op16_2 ) ); + op16_3 = op16_3 >= 0 ? shr_r( sp_enratio, op16_3 ) : shl_sat( sp_enratio, negate( op16_3 ) ); +BASOP_SATURATE_WARNING_ON + + IF( GT_16( op16_1, 8192 ) && /*compare with 0.25 in Q15*/ + LT_16( op16_2, 15360 ) && /*compare with 15.0 in Q10*/ + GT_16( op16_3, 4915 ) && /*compare with 0.15 in Q15*/ LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ +#else + Flag Overflow; + IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ + LT_16( shl_ro( enratio, sub( 10, Qenratio ), &Overflow ), 15360 ) && /*compare with 15.0 in Q10*/ + GT_16( shl_ro( sp_enratio, sub( 15, Qsp_enratio ), &Overflow ), 4915 ) && /*compare with 0.15 in Q15*/ + LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ + LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ +#endif { IF( NE_32( ( error = DTFS_new_fx( &PREVP ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index 72627a5a0..34b75ed3e 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -135,7 +135,20 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, normCC = add( normCC, 16 ); /* scale to Q15 with saturation */ BASOP_SATURATE_WARNING_OFF - cc = shr_r_sat( cc, negate( add( normXY, normCC ) ) ); +#ifdef ISSUE_1751_replace_shl_ro + Word16 op1 = add( normXY, normCC ); + if ( op1 >= 0 ) + { + cc = shl_sat( cc, add( normXY, normCC ) ); + } + else + { + cc = shr_r( cc, negate( add( normXY, normCC ) ) ); + } +#else + Flag Overflow; + cc = shl_ro( cc, add( normXY, normCC ), &Overflow ); +#endif BASOP_SATURATE_WARNING_ON *energy = L_shr_r( L_deposit_l( sqrtXY ), normXY ); } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 7d47ea681..2384b3ea5 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4085,7 +4085,19 @@ void ivas_lfe_synth_with_filters_fx( lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/ lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp - lfeGain_fx = shr_r_sat( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 +#ifdef ISSUE_1751_replace_shl_ro + if ( lfeGain_fx_exp >= 0 ) + { + lfeGain_fx = shl_sat( lfeGain_fx, lfeGain_fx_exp ); // Q15 + } + else + { + lfeGain_fx = shr_r( lfeGain_fx, negate(lfeGain_fx_exp) ); // Q15 + } +#else + Flag Overflow; + lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp &Overflow); // Q15 +#endif } IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) ) { @@ -4097,7 +4109,20 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); /*Q=15-(transportGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneTransSmooth_q)*/ transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp - transportGain_fx = shr_r_sat( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 +#ifdef ISSUE_1751_replace_shl_ro + if ( transportGain_fx_exp >= 0 ) + { + transportGain_fx = shl_sat( transportGain_fx, transportGain_fx_exp ); // Q15 + } + else + { + transportGain_fx = shr_r( transportGain_fx, negate(transportGain_fx_exp) ); // Q15 + } +#else + Flag Overflow; + transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp &Overflow); // Q15 +#endif + } j = 0; move16(); -- GitLab From aa0608609864633100221bb299ac8caa46f3fa8e Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 10:59:18 +0200 Subject: [PATCH 06/31] apply format patch --- lib_dec/dec_gen_voic_fx.c | 22 +++++++++---------- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 13 +++++------ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index d003b9731..74eb0f51f 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -468,24 +468,24 @@ ivas_error decod_gen_voic_fx( Word16 op16_2 = sub( Qenratio, 10 ); Word16 op16_3 = sub( Qsp_enratio, 15 ); -BASOP_SATURATE_WARNING_OFF - op16_1 = op16_1 >= 0 ? shr_r( enratio, op16_1 ) : shl_sat( enratio, negate(op16_1) ); + BASOP_SATURATE_WARNING_OFF + op16_1 = op16_1 >= 0 ? shr_r( enratio, op16_1 ) : shl_sat( enratio, negate( op16_1 ) ); op16_2 = op16_2 >= 0 ? shr_r( sp_enratio, op16_2 ) : shl_sat( sp_enratio, negate( op16_2 ) ); op16_3 = op16_3 >= 0 ? shr_r( sp_enratio, op16_3 ) : shl_sat( sp_enratio, negate( op16_3 ) ); -BASOP_SATURATE_WARNING_ON + BASOP_SATURATE_WARNING_ON - IF( GT_16( op16_1, 8192 ) && /*compare with 0.25 in Q15*/ - LT_16( op16_2, 15360 ) && /*compare with 15.0 in Q10*/ + IF( GT_16( op16_1, 8192 ) && /*compare with 0.25 in Q15*/ + LT_16( op16_2, 15360 ) && /*compare with 15.0 in Q10*/ GT_16( op16_3, 4915 ) && /*compare with 0.15 in Q15*/ - LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ - LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ + LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ + LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ #else Flag Overflow; - IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ - LT_16( shl_ro( enratio, sub( 10, Qenratio ), &Overflow ), 15360 ) && /*compare with 15.0 in Q10*/ + IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ + LT_16( shl_ro( enratio, sub( 10, Qenratio ), &Overflow ), 15360 ) && /*compare with 15.0 in Q10*/ GT_16( shl_ro( sp_enratio, sub( 15, Qsp_enratio ), &Overflow ), 4915 ) && /*compare with 0.15 in Q15*/ - LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ - LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ + LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ + LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ #endif { IF( NE_32( ( error = DTFS_new_fx( &PREVP ) ), IVAS_ERR_OK ) ) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 2384b3ea5..5f69f0ec6 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4084,7 +4084,7 @@ void ivas_lfe_synth_with_filters_fx( { lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/ lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); - lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp + lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro if ( lfeGain_fx_exp >= 0 ) { @@ -4092,11 +4092,11 @@ void ivas_lfe_synth_with_filters_fx( } else { - lfeGain_fx = shr_r( lfeGain_fx, negate(lfeGain_fx_exp) ); // Q15 + lfeGain_fx = shr_r( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 } #else Flag Overflow; - lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp &Overflow); // Q15 + lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp & Overflow ); // Q15 #endif } IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) ) @@ -4108,7 +4108,7 @@ void ivas_lfe_synth_with_filters_fx( { transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); /*Q=15-(transportGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneTransSmooth_q)*/ transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); - transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp + transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro if ( transportGain_fx_exp >= 0 ) { @@ -4116,13 +4116,12 @@ void ivas_lfe_synth_with_filters_fx( } else { - transportGain_fx = shr_r( transportGain_fx, negate(transportGain_fx_exp) ); // Q15 + transportGain_fx = shr_r( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 } #else Flag Overflow; - transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp &Overflow); // Q15 + transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp & Overflow ); // Q15 #endif - } j = 0; move16(); -- GitLab From 1508027f28c3dc08cf43aab7e680f020e57b6820 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 12:14:51 +0200 Subject: [PATCH 07/31] add asserts to catch all shl_sat, replacing shl_ro --- lib_dec/dec_gen_voic_fx.c | 4 ++++ lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 1 + lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 2 ++ 3 files changed, 7 insertions(+) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 74eb0f51f..c61d3b56f 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -468,6 +468,10 @@ ivas_error decod_gen_voic_fx( Word16 op16_2 = sub( Qenratio, 10 ); Word16 op16_3 = sub( Qsp_enratio, 15 ); + assert( op16_1 >= 0 ); + assert( op16_2 >= 0 ); + assert( op16_3 >= 0 ); + BASOP_SATURATE_WARNING_OFF op16_1 = op16_1 >= 0 ? shr_r( enratio, op16_1 ) : shl_sat( enratio, negate( op16_1 ) ); op16_2 = op16_2 >= 0 ? shr_r( sp_enratio, op16_2 ) : shl_sat( sp_enratio, negate( op16_2 ) ); diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index 34b75ed3e..dd50ac111 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -137,6 +137,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, BASOP_SATURATE_WARNING_OFF #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); + assert( op1 >= 0 ); if ( op1 >= 0 ) { cc = shl_sat( cc, add( normXY, normCC ) ); diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 5f69f0ec6..d8f256b57 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4086,6 +4086,7 @@ void ivas_lfe_synth_with_filters_fx( lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro + assert( lfeGain_fx_exp >= 0 ); if ( lfeGain_fx_exp >= 0 ) { lfeGain_fx = shl_sat( lfeGain_fx, lfeGain_fx_exp ); // Q15 @@ -4110,6 +4111,7 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro + assert( transportGain_fx_exp >= 0 ); if ( transportGain_fx_exp >= 0 ) { transportGain_fx = shl_sat( transportGain_fx, transportGain_fx_exp ); // Q15 -- GitLab From 1079d508be1e4cc6aad38c80828268594d19ef2c Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 13:01:04 +0200 Subject: [PATCH 08/31] check asserts for shl_ro : insert asserts for other direction --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 3 ++- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index dd50ac111..1e1b33ff1 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -137,7 +137,8 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, BASOP_SATURATE_WARNING_OFF #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); - assert( op1 >= 0 ); + // assert( op1 >= 0 ); FAILS + assert( op1 <= 0 ); if ( op1 >= 0 ) { cc = shl_sat( cc, add( normXY, normCC ) ); diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index d8f256b57..17a821adb 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4086,7 +4086,8 @@ void ivas_lfe_synth_with_filters_fx( lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro - assert( lfeGain_fx_exp >= 0 ); + // assert( lfeGain_fx_exp >= 0 ); FAILS + assert( lfeGain_fx_exp <= 0 ); if ( lfeGain_fx_exp >= 0 ) { lfeGain_fx = shl_sat( lfeGain_fx, lfeGain_fx_exp ); // Q15 -- GitLab From 0591e5765e735029061727ed1021d8d2e805784a Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 15:12:11 +0200 Subject: [PATCH 09/31] shl_ro: change asserts and run once again --- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 17a821adb..b0c193006 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4112,7 +4112,8 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro - assert( transportGain_fx_exp >= 0 ); + //assert( transportGain_fx_exp >= 0 ); FAILS + assert( transportGain_fx_exp <= 0 ); if ( transportGain_fx_exp >= 0 ) { transportGain_fx = shl_sat( transportGain_fx, transportGain_fx_exp ); // Q15 -- GitLab From 6c14262bb9160ccee761365349d061b4f5b4c541 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 15:15:23 +0200 Subject: [PATCH 10/31] clang patch --- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index b0c193006..9076dd2c2 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4112,7 +4112,7 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro - //assert( transportGain_fx_exp >= 0 ); FAILS + // assert( transportGain_fx_exp >= 0 ); FAILS assert( transportGain_fx_exp <= 0 ); if ( transportGain_fx_exp >= 0 ) { -- GitLab From 0b03383556848ad4d5f5662cfd0b5a4383e97733 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 15:43:17 +0200 Subject: [PATCH 11/31] shl_ro: edit one more assert, run once more --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index 1e1b33ff1..e07472aef 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -138,7 +138,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); // assert( op1 >= 0 ); FAILS - assert( op1 <= 0 ); + //assert( op1 <= 0 ); FAILS --> twoway needed if ( op1 >= 0 ) { cc = shl_sat( cc, add( normXY, normCC ) ); -- GitLab From d2dee91e120afee46014166f97588ac8d72435d3 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 15:56:25 +0200 Subject: [PATCH 12/31] clang patch --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index e07472aef..71e221a61 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -138,7 +138,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); // assert( op1 >= 0 ); FAILS - //assert( op1 <= 0 ); FAILS --> twoway needed + // assert( op1 <= 0 ); FAILS --> twoway needed if ( op1 >= 0 ) { cc = shl_sat( cc, add( normXY, normCC ) ); -- GitLab From 9674041d1ad58fae460e7e18c5cf1fdfec2a140d Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 13:00:09 +0200 Subject: [PATCH 13/31] change asserts --- lib_dec/dec_gen_voic_fx.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index c61d3b56f..fdabd0a3d 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -468,9 +468,12 @@ ivas_error decod_gen_voic_fx( Word16 op16_2 = sub( Qenratio, 10 ); Word16 op16_3 = sub( Qsp_enratio, 15 ); - assert( op16_1 >= 0 ); + //assert( op16_1 >= 0 ); /*FAILS*/ + assert( op16_1 <= 0 ); + assert( op16_2 >= 0 ); - assert( op16_3 >= 0 ); + //assert( op16_3 >= 0 ); /*FAILS*/ + assert( op16_3 <= 0 ); BASOP_SATURATE_WARNING_OFF op16_1 = op16_1 >= 0 ? shr_r( enratio, op16_1 ) : shl_sat( enratio, negate( op16_1 ) ); -- GitLab From ef91f515af7630c98ccf1f25144f0dcc0b019baf Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 13:05:20 +0200 Subject: [PATCH 14/31] clang patch --- lib_dec/dec_gen_voic_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index fdabd0a3d..4c8543987 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -468,11 +468,11 @@ ivas_error decod_gen_voic_fx( Word16 op16_2 = sub( Qenratio, 10 ); Word16 op16_3 = sub( Qsp_enratio, 15 ); - //assert( op16_1 >= 0 ); /*FAILS*/ + // assert( op16_1 >= 0 ); /*FAILS*/ assert( op16_1 <= 0 ); assert( op16_2 >= 0 ); - //assert( op16_3 >= 0 ); /*FAILS*/ + // assert( op16_3 >= 0 ); /*FAILS*/ assert( op16_3 <= 0 ); BASOP_SATURATE_WARNING_OFF -- GitLab From aafdfa1096689fa4c1e6368c4ae51dd4a76a88f6 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 14:09:49 +0200 Subject: [PATCH 15/31] change asserts --- lib_dec/dec_gen_voic_fx.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 4c8543987..53ccc4586 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -469,11 +469,13 @@ ivas_error decod_gen_voic_fx( Word16 op16_3 = sub( Qsp_enratio, 15 ); // assert( op16_1 >= 0 ); /*FAILS*/ - assert( op16_1 <= 0 ); + //assert( op16_1 <= 0 ); /*FAILS*/ + + //assert( op16_2 >= 0 ); /*FAILS*/ + assert( op16_2 <= 0 ); - assert( op16_2 >= 0 ); // assert( op16_3 >= 0 ); /*FAILS*/ - assert( op16_3 <= 0 ); + // assert( op16_3 <= 0 ); /*FAILS*/ BASOP_SATURATE_WARNING_OFF op16_1 = op16_1 >= 0 ? shr_r( enratio, op16_1 ) : shl_sat( enratio, negate( op16_1 ) ); -- GitLab From e85ff0c6d01baf89d55de20c062c4ed0ee7e11a5 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 14:12:33 +0200 Subject: [PATCH 16/31] clang patch --- lib_dec/dec_gen_voic_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 53ccc4586..e836718d5 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -469,10 +469,10 @@ ivas_error decod_gen_voic_fx( Word16 op16_3 = sub( Qsp_enratio, 15 ); // assert( op16_1 >= 0 ); /*FAILS*/ - //assert( op16_1 <= 0 ); /*FAILS*/ + // assert( op16_1 <= 0 ); /*FAILS*/ - //assert( op16_2 >= 0 ); /*FAILS*/ - assert( op16_2 <= 0 ); + // assert( op16_2 >= 0 ); /*FAILS*/ + assert( op16_2 <= 0 ); // assert( op16_3 >= 0 ); /*FAILS*/ // assert( op16_3 <= 0 ); /*FAILS*/ -- GitLab From 3c20196fc000eacc787c62cecc5c6bba9ea1aaa2 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 14:46:52 +0200 Subject: [PATCH 17/31] change asserts --- lib_dec/dec_gen_voic_fx.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index e836718d5..557ad9be3 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -468,17 +468,9 @@ ivas_error decod_gen_voic_fx( Word16 op16_2 = sub( Qenratio, 10 ); Word16 op16_3 = sub( Qsp_enratio, 15 ); - // assert( op16_1 >= 0 ); /*FAILS*/ - // assert( op16_1 <= 0 ); /*FAILS*/ - - // assert( op16_2 >= 0 ); /*FAILS*/ - assert( op16_2 <= 0 ); - - // assert( op16_3 >= 0 ); /*FAILS*/ - // assert( op16_3 <= 0 ); /*FAILS*/ - + /*Due to all shift directrions being possible, we need both possibilities, shl_sat and shr_r*/ BASOP_SATURATE_WARNING_OFF - op16_1 = op16_1 >= 0 ? shr_r( enratio, op16_1 ) : shl_sat( enratio, negate( op16_1 ) ); + op16_1 = op16_1 >= 0 ? shr_r( enratio , op16_1 ) : shl_sat( enratio , negate( op16_1 ) ); op16_2 = op16_2 >= 0 ? shr_r( sp_enratio, op16_2 ) : shl_sat( sp_enratio, negate( op16_2 ) ); op16_3 = op16_3 >= 0 ? shr_r( sp_enratio, op16_3 ) : shl_sat( sp_enratio, negate( op16_3 ) ); BASOP_SATURATE_WARNING_ON -- GitLab From 24f64f6ac6cd3ad7e6083a4f2d511ae0140d1b85 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 14:50:07 +0200 Subject: [PATCH 18/31] clang patch --- lib_dec/dec_gen_voic_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 557ad9be3..935200eea 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -470,7 +470,7 @@ ivas_error decod_gen_voic_fx( /*Due to all shift directrions being possible, we need both possibilities, shl_sat and shr_r*/ BASOP_SATURATE_WARNING_OFF - op16_1 = op16_1 >= 0 ? shr_r( enratio , op16_1 ) : shl_sat( enratio , negate( op16_1 ) ); + op16_1 = op16_1 >= 0 ? shr_r( enratio, op16_1 ) : shl_sat( enratio, negate( op16_1 ) ); op16_2 = op16_2 >= 0 ? shr_r( sp_enratio, op16_2 ) : shl_sat( sp_enratio, negate( op16_2 ) ); op16_3 = op16_3 >= 0 ? shr_r( sp_enratio, op16_3 ) : shl_sat( sp_enratio, negate( op16_3 ) ); BASOP_SATURATE_WARNING_ON -- GitLab From 45c49362a025bf9b6ca1c3b49789acb232ac0bab Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 14:59:37 +0200 Subject: [PATCH 19/31] cleanup --- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index ef780724e..1ef10382e 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4428,16 +4428,9 @@ void ivas_lfe_synth_with_filters_fx( lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro - // assert( lfeGain_fx_exp >= 0 ); FAILS assert( lfeGain_fx_exp <= 0 ); - if ( lfeGain_fx_exp >= 0 ) - { - lfeGain_fx = shl_sat( lfeGain_fx, lfeGain_fx_exp ); // Q15 - } - else - { - lfeGain_fx = shr_r( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 - } + /*if assert is thrown, shl_sat can handle the left shift*/ + lfeGain_fx = shr_r( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 #else Flag Overflow; lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp & Overflow ); // Q15 @@ -4454,16 +4447,9 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro - // assert( transportGain_fx_exp >= 0 ); FAILS assert( transportGain_fx_exp <= 0 ); - if ( transportGain_fx_exp >= 0 ) - { - transportGain_fx = shl_sat( transportGain_fx, transportGain_fx_exp ); // Q15 - } - else - { - transportGain_fx = shr_r( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 - } + /*if assert is thrown, shl_sat can handle the left shift*/ + transportGain_fx = shr_r( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 #else Flag Overflow; transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp & Overflow ); // Q15 -- GitLab From bce58b11c1edef4fea5faf4311f89a874df5d7ad Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 14:59:54 +0200 Subject: [PATCH 20/31] asserts change --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index 71e221a61..5743064f2 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -137,15 +137,14 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, BASOP_SATURATE_WARNING_OFF #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); - // assert( op1 >= 0 ); FAILS - // assert( op1 <= 0 ); FAILS --> twoway needed + assert( op1 >= 0 ); if ( op1 >= 0 ) { - cc = shl_sat( cc, add( normXY, normCC ) ); + cc = shl_sat( cc, op1 ); } else { - cc = shr_r( cc, negate( add( normXY, normCC ) ) ); + cc = shr_r( cc, negate( op1 ) ); } #else Flag Overflow; -- GitLab From cebd2e3f5d372a71479f8b06258566fcbaec097d Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 15:17:12 +0200 Subject: [PATCH 21/31] change asserts --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index 5743064f2..a04703388 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -137,7 +137,8 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, BASOP_SATURATE_WARNING_OFF #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); - assert( op1 >= 0 ); + assert( op1 >= 0 ); /*FAILED*/ + assert( op1 <= 0 ); if ( op1 >= 0 ) { cc = shl_sat( cc, op1 ); -- GitLab From 0233735aa9281e43dda0737436f97835e58dcd2b Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 15:17:28 +0200 Subject: [PATCH 22/31] change asserts --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index a04703388..a6e735252 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -137,7 +137,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, BASOP_SATURATE_WARNING_OFF #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); - assert( op1 >= 0 ); /*FAILED*/ + //assert( op1 >= 0 ); /*FAILED*/ assert( op1 <= 0 ); if ( op1 >= 0 ) { -- GitLab From 7aa883744d7f335a5cf2247d58c446ffe4e4ad74 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 15:19:33 +0200 Subject: [PATCH 23/31] clang patch --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index a6e735252..5930f9870 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -137,7 +137,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, BASOP_SATURATE_WARNING_OFF #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); - //assert( op1 >= 0 ); /*FAILED*/ + // assert( op1 >= 0 ); /*FAILED*/ assert( op1 <= 0 ); if ( op1 >= 0 ) { -- GitLab From 4d365ea0f650ed5d7895f26267ff9ac5ced4371f Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 15:44:31 +0200 Subject: [PATCH 24/31] change asserts --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index 5930f9870..c2ec4dc83 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -138,7 +138,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); // assert( op1 >= 0 ); /*FAILED*/ - assert( op1 <= 0 ); + // assert( op1 <= 0 ); /*FAILED*/ if ( op1 >= 0 ) { cc = shl_sat( cc, op1 ); -- GitLab From 8e52b02399b8d598483dcf01252807f44e82bd99 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 16:51:37 +0200 Subject: [PATCH 25/31] cleanup --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index c2ec4dc83..c817bd1b3 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -137,8 +137,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, BASOP_SATURATE_WARNING_OFF #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); - // assert( op1 >= 0 ); /*FAILED*/ - // assert( op1 <= 0 ); /*FAILED*/ + /*Both shift directiosn possible*/ if ( op1 >= 0 ) { cc = shl_sat( cc, op1 ); -- GitLab From 99b3f1d116f25ddbb89cf2e5956c7944d54e499b Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 25 Jun 2025 09:24:00 +0200 Subject: [PATCH 26/31] change shr_r/shl_sat to shr_r_sat --- lib_dec/dec_gen_voic_fx.c | 21 +++++-------------- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 11 +--------- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 8 ++----- 3 files changed, 8 insertions(+), 32 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 935200eea..492b32775 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -464,22 +464,11 @@ ivas_error decod_gen_voic_fx( test(); test(); #ifdef ISSUE_1751_replace_shl_ro - Word16 op16_1 = sub( Qenratio, 15 ); - Word16 op16_2 = sub( Qenratio, 10 ); - Word16 op16_3 = sub( Qsp_enratio, 15 ); - - /*Due to all shift directrions being possible, we need both possibilities, shl_sat and shr_r*/ - BASOP_SATURATE_WARNING_OFF - op16_1 = op16_1 >= 0 ? shr_r( enratio, op16_1 ) : shl_sat( enratio, negate( op16_1 ) ); - op16_2 = op16_2 >= 0 ? shr_r( sp_enratio, op16_2 ) : shl_sat( sp_enratio, negate( op16_2 ) ); - op16_3 = op16_3 >= 0 ? shr_r( sp_enratio, op16_3 ) : shl_sat( sp_enratio, negate( op16_3 ) ); - BASOP_SATURATE_WARNING_ON - - IF( GT_16( op16_1, 8192 ) && /*compare with 0.25 in Q15*/ - LT_16( op16_2, 15360 ) && /*compare with 15.0 in Q10*/ - GT_16( op16_3, 4915 ) && /*compare with 0.15 in Q15*/ - LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ - LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ + IF( GT_16( shr_r_sat( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ + LT_16( shr_r_sat( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ + GT_16( shr_r_sat( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ + LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ + LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ #else Flag Overflow; IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index c817bd1b3..baad5c561 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -136,16 +136,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, /* scale to Q15 with saturation */ BASOP_SATURATE_WARNING_OFF #ifdef ISSUE_1751_replace_shl_ro - Word16 op1 = add( normXY, normCC ); - /*Both shift directiosn possible*/ - if ( op1 >= 0 ) - { - cc = shl_sat( cc, op1 ); - } - else - { - cc = shr_r( cc, negate( op1 ) ); - } + cc = shr_r_sat( cc, negate( add( normXY, normCC ) ) ); #else Flag Overflow; cc = shl_ro( cc, add( normXY, normCC ), &Overflow ); diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 1ef10382e..e368e455c 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4428,9 +4428,7 @@ void ivas_lfe_synth_with_filters_fx( lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro - assert( lfeGain_fx_exp <= 0 ); - /*if assert is thrown, shl_sat can handle the left shift*/ - lfeGain_fx = shr_r( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 + lfeGain_fx = shr_r_sat( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 #else Flag Overflow; lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp & Overflow ); // Q15 @@ -4447,9 +4445,7 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro - assert( transportGain_fx_exp <= 0 ); - /*if assert is thrown, shl_sat can handle the left shift*/ - transportGain_fx = shr_r( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 + transportGain_fx = shr_r_sat( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 #else Flag Overflow; transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp & Overflow ); // Q15 -- GitLab From b48e71bd74da31839b305b363852b3da3c2aee9b Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 25 Jun 2025 09:27:12 +0200 Subject: [PATCH 27/31] clang format patch --- lib_dec/dec_gen_voic_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 492b32775..a58cd19c9 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -467,8 +467,8 @@ ivas_error decod_gen_voic_fx( IF( GT_16( shr_r_sat( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ LT_16( shr_r_sat( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ GT_16( shr_r_sat( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ - LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ - LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ + LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ + LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ #else Flag Overflow; IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ -- GitLab From dd70cef2abd8aab094e2a948daac856aa555eae4 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 25 Jun 2025 07:36:54 +0000 Subject: [PATCH 28/31] deactivate all for testing --- lib_dec/dec_gen_voic_fx.c | 2 +- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index a58cd19c9..f311e6320 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -463,7 +463,7 @@ ivas_error decod_gen_voic_fx( test(); test(); test(); -#ifdef ISSUE_1751_replace_shl_ro +#ifdef ISSUE_1751_replace_shl_ro_ IF( GT_16( shr_r_sat( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ LT_16( shr_r_sat( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ GT_16( shr_r_sat( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index baad5c561..f7b97f3f7 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -135,7 +135,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, normCC = add( normCC, 16 ); /* scale to Q15 with saturation */ BASOP_SATURATE_WARNING_OFF -#ifdef ISSUE_1751_replace_shl_ro +#ifdef ISSUE_1751_replace_shl_ro_ cc = shr_r_sat( cc, negate( add( normXY, normCC ) ) ); #else Flag Overflow; diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index e368e455c..b56eace63 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4427,7 +4427,7 @@ void ivas_lfe_synth_with_filters_fx( lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/ lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp -#ifdef ISSUE_1751_replace_shl_ro +#ifdef ISSUE_1751_replace_shl_ro_ lfeGain_fx = shr_r_sat( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 #else Flag Overflow; @@ -4444,7 +4444,7 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); /*Q=15-(transportGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneTransSmooth_q)*/ transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp -#ifdef ISSUE_1751_replace_shl_ro +#ifdef ISSUE_1751_replace_shl_ro_ transportGain_fx = shr_r_sat( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 #else Flag Overflow; -- GitLab From fb47da0dc6a30ad3a5fc32c94a2598bfaaf33573 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 25 Jun 2025 09:52:51 +0200 Subject: [PATCH 29/31] buildfix --- lib_dec/dec_gen_voic_fx.c | 2 +- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index f311e6320..a58cd19c9 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -463,7 +463,7 @@ ivas_error decod_gen_voic_fx( test(); test(); test(); -#ifdef ISSUE_1751_replace_shl_ro_ +#ifdef ISSUE_1751_replace_shl_ro IF( GT_16( shr_r_sat( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ LT_16( shr_r_sat( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ GT_16( shr_r_sat( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 8b772e13c..c826b72f0 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4265,7 +4265,7 @@ void ivas_lfe_synth_with_filters_fx( lfeGain_fx = shr_r_sat( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 #else Flag Overflow; - lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp & Overflow ); // Q15 + lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp, &Overflow ); // Q15 #endif } IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) ) @@ -4282,7 +4282,7 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx = shr_r_sat( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 #else Flag Overflow; - transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp & Overflow ); // Q15 + transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp, &Overflow ); // Q15 #endif } j = 0; -- GitLab From b1135facc34c6c6addfb2e5dcdef3295cd704e85 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 25 Jun 2025 08:44:32 +0000 Subject: [PATCH 30/31] reactivate changes in ivas_dirac_output_synthesis_dec_fx.c --- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index c826b72f0..19823d7c6 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4261,7 +4261,7 @@ void ivas_lfe_synth_with_filters_fx( lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/ lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp -#ifdef ISSUE_1751_replace_shl_ro_ +#ifdef ISSUE_1751_replace_shl_ro lfeGain_fx = shr_r_sat( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 #else Flag Overflow; @@ -4278,7 +4278,7 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); /*Q=15-(transportGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneTransSmooth_q)*/ transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp -#ifdef ISSUE_1751_replace_shl_ro_ +#ifdef ISSUE_1751_replace_shl_ro transportGain_fx = shr_r_sat( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 #else Flag Overflow; -- GitLab From 794393658fb27cf6866fadee4d00a3f01deaf075 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 25 Jun 2025 10:10:45 +0000 Subject: [PATCH 31/31] lib_dec\jbm_pcmdsp_similarityestimation_fx.c : activate change --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index f7b97f3f7..baad5c561 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -135,7 +135,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, normCC = add( normCC, 16 ); /* scale to Q15 with saturation */ BASOP_SATURATE_WARNING_OFF -#ifdef ISSUE_1751_replace_shl_ro_ +#ifdef ISSUE_1751_replace_shl_ro cc = shr_r_sat( cc, negate( add( normXY, normCC ) ) ); #else Flag Overflow; -- GitLab