diff --git a/lib_com/options.h b/lib_com/options.h index 5f33170bfe838b11fa37b3ddc9e83939a52e41b4..c9cd5ca5ee82ee648d3c12b163f2645c75c9d968 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -98,5 +98,6 @@ #define NONBE_FIX_864_JBM_RENDER_FRAMESIZE /* FhG: issue #864: fix different behaviour of JBM TSM with different render frame sizes */ #define FIX_1762_COMPILER_ISSUE /* FhG: fix compiler issues with W_mac_32_32() + ONE_IN_Q30 */ +#define ISSUE_1751_replace_shl_ro /*FhG: replace shl_ro by overflow-free alternatives*/ #endif diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 14d9d1772700242840bc8cbfb1bc39769d9d08bf..a58cd19c9c7e75572e5fbb6bd30a988817d7204d 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,11 +463,20 @@ ivas_error decod_gen_voic_fx( test(); test(); test(); +#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*/ + 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 cc13c0148d23a45b7a154bb93fc2ce91fa1ccc10..baad5c561d91aba0ea5cd8fbd78cc560cd9ccec4 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,12 @@ 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 + cc = shr_r_sat( 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 eea8dffbbab682699f66880bf4cc852d2c55ec94..19823d7c6b6585582a5a0baaeee84c6c5dec671e 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4258,11 +4258,15 @@ 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 = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp +#ifdef ISSUE_1751_replace_shl_ro + 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 +#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 ) ) { @@ -4271,11 +4275,15 @@ 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 = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp +#ifdef ISSUE_1751_replace_shl_ro + 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 +#endif } j = 0; move16();