From 552d615d6e4ee3a56636be80b55a79721c0445fc Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 26 Mar 2025 12:09:08 +0530 Subject: [PATCH] Synth state buffer scaling/rescaling cleanup --- lib_com/cldfb.c | 113 +++++++++++++----- lib_com/options.h | 1 + lib_com/prot_fx.h | 13 +- lib_dec/acelp_core_dec_ivas_fx.c | 29 ++++- lib_dec/acelp_core_switch_dec_fx.c | 9 ++ lib_dec/core_switching_dec_fx.c | 8 ++ lib_dec/ivas_dirac_dec_fx.c | 17 ++- lib_dec/ivas_ism_param_dec_fx.c | 4 + lib_dec/ivas_mc_param_dec_fx.c | 5 + lib_dec/ivas_mc_paramupmix_dec_fx.c | 18 ++- lib_dec/ivas_spar_decoder_fx.c | 12 ++ lib_enc/swb_pre_proc_fx.c | 4 + .../ivas_dirac_dec_binaural_functions_fx.c | 4 + lib_rend/ivas_dirac_rend_fx.c | 4 + 14 files changed, 202 insertions(+), 39 deletions(-) diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index 845ec1f11..720ee37a0 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -399,18 +399,28 @@ void cldfbAnalysis_ts_fx( /* folding + pre modulation of DST IV */ rr12_fx = L_sub( r1_fx, r2_fx ); // q -1 ri12_fx = L_negate( L_add( i1_fx, i2_fx ) ); // q - 1 - /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ - rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ +#ifdef OPT_AVOID_STATE_BUF_RESCALE + rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3 + rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3 +#else /* OPT_AVOID_STATE_BUF_RESCALE */ + rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3 + rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3 +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); ///* folding + pre modulation of DCT IV */ ir12_fx = L_add( r1_fx, r2_fx ); // q - 1 ii12_fx = L_sub( i1_fx, i2_fx ); // q - 1 - /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ - iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ +#ifdef OPT_AVOID_STATE_BUF_RESCALE + iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3 + iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3 +#else /* OPT_AVOID_STATE_BUF_RESCALE */ + iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3 + iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3 +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); } @@ -450,18 +460,28 @@ void cldfbAnalysis_ts_fx( /* folding + pre modulation of DST IV */ rr12_fx = L_add( r1_fx, r2_fx ); // q - 1 ri12_fx = L_sub( i1_fx, i2_fx ); // q - 1 - /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ - rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ +#ifdef OPT_AVOID_STATE_BUF_RESCALE + rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3 + rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3 +#else /* OPT_AVOID_STATE_BUF_RESCALE */ + rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3 + rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3 +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); /* folding + pre modulation of DCT IV */ ir12_fx = L_sub( r1_fx, r2_fx ); // q - 1 ii12_fx = L_add( i1_fx, i2_fx ); // q - 1 - /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ - iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ +#ifdef OPT_AVOID_STATE_BUF_RESCALE + iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3 + iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3 +#else /* OPT_AVOID_STATE_BUF_RESCALE */ + iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3 + iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3 +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); } @@ -490,8 +510,13 @@ void cldfbAnalysis_ts_fx( FOR( k = 0; k < M2; k++ ) { /*cplxMult(&realBuffer[M1-1-(2*k)],&realBuffer[2*k],rBuffer[2*k],rBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/ +#ifdef OPT_AVOID_STATE_BUF_RESCALE + realBuffer_fx[( ( M1 - 1 ) - ( k * 2 ) )] = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5 + realBuffer_fx[2 * k] = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5 +#else /* OPT_AVOID_STATE_BUF_RESCALE */ realBuffer_fx[( ( M1 - 1 ) - ( k * 2 ) )] = L_sub( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5 realBuffer_fx[2 * k] = L_add( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5 +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); } @@ -520,8 +545,13 @@ void cldfbAnalysis_ts_fx( { /* do it inplace */ /*cplxMult(&imagBuffer[2*k],&imagBuffer[M1-1-(2*k)],iBuffer[2*k],iBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/ - imagBuffer_fx[2 * k] = L_sub( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5 - imagBuffer_fx[( M1 - 1 ) - ( k * 2 )] = L_add( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5 +#ifdef OPT_AVOID_STATE_BUF_RESCALE + imagBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5 + imagBuffer_fx[( M1 - 1 ) - ( k * 2 )] = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5 +#else /* OPT_AVOID_STATE_BUF_RESCALE */ + imagBuffer_fx[2 * k] = L_sub( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5 + imagBuffer_fx[( M1 - 1 ) - ( k * 2 )] = L_add( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5 +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); } @@ -542,8 +572,13 @@ void cldfbAnalysis_ts_fx( /*cplxMult(&realBuffer[k], &imagBuffer[k], realBuffer[k], imagBuffer[k], rot_vctr_delay_re[k], rot_vctr_delay_im[k]);*/ /*realBuffer[k] = rBuffer[k]; imagBuffer[k] = iBuffer[k];*/ - cplx_aux_fx = L_sub( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ) ); // q - 5 - imagBuffer_fx[k] = L_add( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ) ); // q - 5 +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cplx_aux_fx = Msub_32_32( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ); // q - 5 + imagBuffer_fx[k] = Madd_32_32( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ); // q - 5 +#else /* OPT_AVOID_STATE_BUF_RESCALE */ + cplx_aux_fx = L_sub( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ) ); // q - 5 + imagBuffer_fx[k] = L_add( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ) ); // q - 5 +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ realBuffer_fx[k] = cplx_aux_fx; move32(); move32(); @@ -1091,17 +1126,21 @@ void cldfbAnalysis_ts_fx_fixed_q( return; } + /*-------------------------------------------------------------------* * cldfbSynthesis_ivas() * * Conduct inverse multple overlap cmplex low delay MDCT *--------------------------------------------------------------------*/ void cldfbSynthesis_ivas_fx( - Word32 **realBuffer_fx, /* i : real values Qx*/ - Word32 **imagBuffer_fx, /* i : imag values Qx*/ - Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ - const Word16 samplesToProcess, /* i : number of processed samples */ - const Word16 shift, /* i : scale for state buffer */ + Word32 **realBuffer_fx, /* i : real values Qx*/ + Word32 **imagBuffer_fx, /* i : imag values Qx*/ + Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ + const Word16 samplesToProcess, /* i : number of processed samples */ + const Word16 shift, /* i : scale for state buffer */ +#ifdef OPT_AVOID_STATE_BUF_RESCALE + const Word16 out_shift, /* i : scale for output buffer */ +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */ ) { @@ -1295,11 +1334,11 @@ void cldfbSynthesis_ivas_fx( FOR( i = 0; i < L2; i++ ) { Word32 prod = L_shl_sat( Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter_sf ), shift ); - accu0 = Madd_32_16( synthesisBuffer_fx[i], prod, p_filter[i] ); // Qx - 1 - accu1 = Madd_32_16( synthesisBuffer_fx[1 * L2 + i], prod, p_filter[( 1 * L2 + i )] ); // Qx - 1 - accu2 = Madd_32_16( synthesisBuffer_fx[2 * L2 + i], prod, p_filter[( 2 * L2 + i )] ); // Qx - 1 - accu3 = Madd_32_16( synthesisBuffer_fx[3 * L2 + i], prod, p_filter[( 3 * L2 + i )] ); // Qx - 1 - accu4 = Madd_32_16( synthesisBuffer_fx[4 * L2 + i], prod, p_filter[( 4 * L2 + i )] ); // Qx - 1 + accu0 = Madd_32_16( synthesisBuffer_fx[i], prod, p_filter[i] ); // Qx -1 + shift + accu1 = Madd_32_16( synthesisBuffer_fx[1 * L2 + i], prod, p_filter[( 1 * L2 + i )] ); // Qx -1 + shift + accu2 = Madd_32_16( synthesisBuffer_fx[2 * L2 + i], prod, p_filter[( 2 * L2 + i )] ); // Qx -1 + shift + accu3 = Madd_32_16( synthesisBuffer_fx[3 * L2 + i], prod, p_filter[( 3 * L2 + i )] ); // Qx -1 + shift + accu4 = Madd_32_16( synthesisBuffer_fx[4 * L2 + i], prod, p_filter[( 4 * L2 + i )] ); // Qx -1 + shift synthesisBuffer_fx[i] = accu0; move32(); @@ -1314,11 +1353,26 @@ void cldfbSynthesis_ivas_fx( } } - FOR( i = 0; i < M1; i++ ) +#ifdef OPT_AVOID_STATE_BUF_RESCALE + IF( 0 == out_shift ) { - ptr_time_out_fx[( M1 - 1 ) - i] = synthesisBuffer_fx[4 * L2 + M1 + i]; - move32(); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + FOR( i = 0; i < M1; i++ ) + { + ptr_time_out_fx[( M1 - 1 ) - i] = synthesisBuffer_fx[4 * L2 + M1 + i]; + move32(); + } +#ifdef OPT_AVOID_STATE_BUF_RESCALE } + ELSE + { + FOR( i = 0; i < M1; i++ ) + { + ptr_time_out_fx[( M1 - 1 ) - i] = L_shl_sat( synthesisBuffer_fx[4 * L2 + M1 + i], out_shift ); + move32(); + } + } +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ ptr_time_out_fx += M1; @@ -1333,7 +1387,6 @@ void cldfbSynthesis_ivas_fx( return; } - void configureCldfb_ivas_enc_fx( HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */ const Word32 sampling_rate /* i : sampling rate */ diff --git a/lib_com/options.h b/lib_com/options.h index 4f818e0c3..8f404dd74 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -69,6 +69,7 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ //#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ +#define OPT_AVOID_STATE_BUF_RESCALE /* Optimization made to avoid rescale of synth state buffer */ #define FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx /*FhG: WMOPS tuning, nonbe*/ #define FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot /*FhG: WMOPS tuning, nonbe*/ #endif diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index d7ed9a140..851b461bf 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9740,11 +9740,14 @@ void cldfbAnalysis_ivas_fx( ); void cldfbSynthesis_ivas_fx( - Word32 **realBuffer_fx, /* i : real values Qx*/ - Word32 **imagBuffer_fx, /* i : imag values Qx*/ - Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ - const Word16 samplesToProcess, /* i : number of processed samples */ - const Word16 shift, /* i : scale for state buffer */ + Word32 **realBuffer_fx, /* i : real values Qx*/ + Word32 **imagBuffer_fx, /* i : imag values Qx*/ + Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ + const Word16 samplesToProcess, /* i : number of processed samples */ + const Word16 shift, /* i : scale for state buffer */ +#ifdef OPT_AVOID_STATE_BUF_RESCALE + const Word16 out_shift, /* i : scale for output buffer */ +#endif HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */ ); diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index bd8c6ec93..38999e99e 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -1807,6 +1807,7 @@ ivas_error acelp_core_dec_ivas_fx( scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_imag ); // Q_imag } +#ifndef OPT_AVOID_STATE_BUF_RESCALE #ifdef OPT_STEREO_32KBPS_V1 scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) #else /* OPT_STEREO_32KBPS_V1 */ @@ -1814,6 +1815,7 @@ ivas_error acelp_core_dec_ivas_fx( #endif /* OPT_STEREO_32KBPS_V1 */ st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); move16(); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { @@ -1833,12 +1835,18 @@ ivas_error acelp_core_dec_ivas_fx( } } +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, 0, st->cldfbSynHB ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ +#ifndef OPT_AVOID_STATE_BUF_RESCALE Scale_sig32( save_hb_synth_fx, L_FRAME48k, negate( ( sub( Q_real, 1 ) ) ) ); // Q0 Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 st->cldfbSynHB->Q_cldfb_state = Q10; move16(); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ /* restore lowband */ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { @@ -1850,14 +1858,21 @@ ivas_error acelp_core_dec_ivas_fx( move32(); } } +#ifndef OPT_AVOID_STATE_BUF_RESCALE Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // Q_real-1 st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); move16(); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSyn ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, 0, st->cldfbSyn ); Scale_sig32( synth_fx, L_FRAME48k, negate( sub( Q_real, 1 ) ) ); // Q0 Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 st->cldfbSynHB->Q_cldfb_state = Q10; move16(); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } ELSE { @@ -1892,12 +1907,16 @@ ivas_error acelp_core_dec_ivas_fx( #ifdef OPT_STEREO_32KBPS_V1 scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) #else /* OPT_STEREO_32KBPS_V1 */ - scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) + scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) #endif /* OPT_STEREO_32KBPS_V1 */ st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 ); move16(); +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, 0, st->cldfbSyn ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, st->cldfbSyn ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 st->cldfbSyn->Q_cldfb_state = Q10; @@ -1985,18 +2004,26 @@ ivas_error acelp_core_dec_ivas_fx( scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real } +#ifndef OPT_AVOID_STATE_BUF_RESCALE #ifdef OPT_STEREO_32KBPS_V1 scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) #else /* OPT_STEREO_32KBPS_V1 */ scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) #endif /* OPT_STEREO_32KBPS_V1 */ +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), sub( Q10, sub( Q_real, 1 ) ), -10, st->cldfbSyn ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), 0, st->cldfbSyn ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ +#ifndef OPT_AVOID_STATE_BUF_RESCALE Scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 st->cldfbSyn->Q_cldfb_state = Q10; move16(); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ IF( st->p_bpf_noise_buf_32 ) { Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 9013f2f03..765749188 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -832,16 +832,25 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( } /*cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out, negate(st_fx->Q_syn), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer );*/ +#ifndef OPT_AVOID_STATE_BUF_RESCALE Scale_sig32( st_fx->cldfbSyn->cldfb_state_fx, st_fx->cldfbSyn->cldfb_state_length, 1 ); // Q_cldfb_state+1 st_fx->cldfbSyn->Q_cldfb_state = add( st_fx->cldfbSyn->Q_cldfb_state, 1 ); move16(); Copy_Scale_sig_16_32_DEPREC( synth_out, synth32, L_FRAME48k, 5 ); /*11-5-1*/ cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) ), 0, st_fx->cldfbSyn ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ + Word16 out_len = extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) ); + cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, out_len, -1, 0, st_fx->cldfbSyn ); + Copy_Scale_sig_32_16( synth32, synth_out, out_len, -4 ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + +#ifndef OPT_AVOID_STATE_BUF_RESCALE Scale_sig32( st_fx->cldfbSyn->cldfb_state_fx, st_fx->cldfbSyn->cldfb_state_length, -1 ); // Q_cldfb_state-1 st_fx->cldfbSyn->Q_cldfb_state = sub( st_fx->cldfbSyn->Q_cldfb_state, 1 ); move16(); Copy_Scale_sig_32_16( synth32, synth_out, L_FRAME48k, -5 ); // 11-5-1 -> 11 +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ // Scale_sig( synth_out, L_FRAME48k, negate( st_fx->Q_syn ) ); diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 05125318f..ba7c73741 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -2056,7 +2056,11 @@ static void core_switch_lb_upsamp_fx( } /* synthesis of the combined signal */ +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, output, i_mult( CLDFB_OVRLP_MIN_SLOTS, st->cldfbSyn->no_channels ), 0, 0, st->cldfbSyn ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, output, i_mult( CLDFB_OVRLP_MIN_SLOTS, st->cldfbSyn->no_channels ), 0, st->cldfbSyn ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ /*rescaling whole buffer to a common Q*/ no_col = st->cldfbSyn->no_col; @@ -2364,7 +2368,11 @@ ivas_error core_switching_pre_dec_ivas_fx( return error; } +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, fer_samples_fx, delay_comp, 0, 0, st->cldfbSyn ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, fer_samples_fx, delay_comp, 0, st->cldfbSyn ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ cldfb_restore_memory_ivas_fx( st->cldfbSyn ); Copy_Scale_sig_32_16( syn_Overl_fx, st->hTcxDec->syn_Overl, 320, 15 ); Copy_Scale_sig_32_16( fer_samples_fx, st->hHQ_core->fer_samples_fx, 960, 9 ); diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index b45f54d48..e6c08669e 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -3743,7 +3743,11 @@ void ivas_dirac_dec_render_sf_fx( st_ivas->cldfbSynDec[ch]->Q_cldfb_state = ( Q6 - 1 ); move16(); +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, synth_fx, i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), 0, 0, st_ivas->cldfbSynDec[ch] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, synth_fx, i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), 0, st_ivas->cldfbSynDec[ch] ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ Word16 no_col = st_ivas->cldfbSynDec[ch]->no_col; move16(); @@ -3846,7 +3850,11 @@ void ivas_dirac_dec_render_sf_fx( ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[idx_in][i]; move32(); } +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_buf_fx[ch][subframe_start_sample] ), num_samples_subframe, 0, 0, st_ivas->cldfbSynDec[idx_in] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_buf_fx[ch][subframe_start_sample] ), num_samples_subframe, 0, st_ivas->cldfbSynDec[idx_in] ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE*/ IF( !st_ivas->hLsSetupCustom->separate_ch_found ) { @@ -3886,7 +3894,11 @@ void ivas_dirac_dec_render_sf_fx( scale_sig32( st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state_fx, st_ivas->cldfbSynDec[cldfbSynIdx]->p_filter_length, sub( ( Q6 - 1 ), st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state ) ); // Q6-1 st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state = ( Q6 - 1 ); move16(); +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, 0, 0, st_ivas->cldfbSynDec[cldfbSynIdx] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, 0, st_ivas->cldfbSynDec[cldfbSynIdx] ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE*/ // Calculating length of output Word16 no_col = st_ivas->cldfbSynDec[cldfbSynIdx]->no_col; @@ -3954,8 +3966,11 @@ void ivas_dirac_dec_render_sf_fx( scale_sig32( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->p_filter_length, sub( ( Q6 - 1 ), st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state ) ); st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = ( Q6 - 1 ); move16(); - +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, 0, 0, st_ivas->cldfbSynDec[idx_in] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, 0, st_ivas->cldfbSynDec[idx_in] ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ // Scaling output from Q6-1 to Q11 Scale_sig32( p_out, out_len, ( Q11 - ( Q6 - 1 ) ) ); diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 7686a5e8a..30a32c92c 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1533,7 +1533,11 @@ static void ivas_ism_param_dec_render_sf_fx( Scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( sub( Q_real, 1 ), Q11 ) ); // Q_real-1 st_ivas->cldfbSynDec[ch]->Q_cldfb_state = sub( Q_real, 1 ); move16(); +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, output_f_fx[ch], i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), 0, 0, st_ivas->cldfbSynDec[ch] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, output_f_fx[ch], i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), 0, st_ivas->cldfbSynDec[ch] ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ Scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( Q11, sub( Q_real, 1 ) ) ); // Q11 st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; move16(); diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 4c0e7fcc6..5f93c9676 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -2189,8 +2189,13 @@ void ivas_param_mc_dec_render_fx( Word16 len = add( imult1616( slot_idx_start_cldfb_synth, hParamMC->num_freq_bands ), imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ) ); scale_sig32( output_f_fx[ch], len, 5 - 11 ); +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), + imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ), 0, 0, st_ivas->cldfbSynDec[ch] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ), 0, st_ivas->cldfbSynDec[ch] ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ scale_sig32( output_f_fx[ch], len, 11 - 5 ); // Q11 } diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index 40f9f46e2..783b94940 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -866,18 +866,28 @@ static void ivas_mc_paramupmix_dec_sf( RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[ch][slot_idx]; // Q6 ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[ch][slot_idx]; // Q6 } +#ifndef OPT_AVOID_STATE_BUF_RESCALE scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, Q5 - Q11 ); // Q11 -> Q5 st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q5; move16(); cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch][0] ), imult1616( maxBand, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ), 0, st_ivas->cldfbSynDec[ch] ); // output_fx returned in Q5 - scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, Q11 - Q5 ); // Q5 -> Q11 +#else /* OPT_AVOID_STATE_BUF_RESCALE */ + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch][0] ), imult1616( maxBand, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ), 6, 0, st_ivas->cldfbSynDec[ch] ); // output_fx returned in Q11 +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + +#ifndef OPT_AVOID_STATE_BUF_RESCALE + scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, Q11 - Q5 ); // Q5 -> Q11 st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; move16(); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } + +#ifndef OPT_AVOID_STATE_BUF_RESCALE FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { Scale_sig32( output_fx[ch], imult1616( maxBand, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ), 6 ); // Q5 -> Q11 } +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } ELSE { @@ -903,9 +913,13 @@ static void ivas_mc_paramupmix_dec_sf( ptr_re_fx[0] = Cldfb_RealBuffer_fx[ch][slot_idx]; // Q6 ptr_im_fx[0] = Cldfb_ImagBuffer_fx[ch][slot_idx]; // Q6 - +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( ptr_re_fx, ptr_im_fx, &( pPcm_temp_fx[ch][L_mult0( hMCParamUpmix->num_freq_bands, slot_idx )] ), + hMCParamUpmix->num_freq_bands, 0, 0, st_ivas->cldfbSynDec[ch] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( ptr_re_fx, ptr_im_fx, &( pPcm_temp_fx[ch][L_mult0( hMCParamUpmix->num_freq_bands, slot_idx )] ), hMCParamUpmix->num_freq_bands, 0, st_ivas->cldfbSynDec[ch] ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, sub( Q11, st_ivas->cldfbSynDec[ch]->Q_cldfb_state ) ); // Q6 -> Q11 st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index a7b66ff87..29a307425 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -787,7 +787,11 @@ void ivas_spar_get_cldfb_gains_fx( cldfbAnalysis_ts_fx_fixed_q( ts_inout_fx, ts_re_fx, ts_im_fx, num_cldfb_bands, cldfbAnaDec0, &q_cldfb ); cldfb_reset_memory_fx( cldfbSynDec0 ); +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( pp_ts_re_fx, pp_ts_im_fx, ts_inout_fx, num_cldfb_bands, 0, 0, cldfbSynDec0 ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( pp_ts_re_fx, pp_ts_im_fx, ts_inout_fx, num_cldfb_bands, 0, cldfbSynDec0 ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ FOR( sample = 0; sample < stride; sample++ ) { T_fx[( ( slot * stride ) + sample )][slot] = ts_inout_fx[sample]; /*Q21*/ @@ -2037,7 +2041,11 @@ void ivas_spar_dec_upmixer_sf_fx( { FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[idx_in][ts], &cldfb_in_ts_im_fx[idx_in][ts], &output_fx[ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, 0, st_ivas->cldfbSynDec[idx_in] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[idx_in][ts], &cldfb_in_ts_im_fx[idx_in][ts], &output_fx[ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, st_ivas->cldfbSynDec[idx_in] ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } } @@ -2052,7 +2060,11 @@ void ivas_spar_dec_upmixer_sf_fx( { FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[out_ch][ts], &cldfb_in_ts_im_fx[out_ch][ts], &output_fx[out_ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, 0, st_ivas->cldfbSynDec[out_ch] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[out_ch][ts], &cldfb_in_ts_im_fx[out_ch][ts], &output_fx[out_ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, st_ivas->cldfbSynDec[out_ch] ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } } } diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index c49c32e03..ba165cba4 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -1263,7 +1263,11 @@ void swb_pre_proc_ivas_fx( thr = icbwe_thr_TDM_fx; regV = icbwe_regressionValuesTDM_fx; +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( realBufferFlipped, imagBufferFlipped, shb_speech_fx_32, -1, 0, 0, st->cldfbSynTd ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( realBufferFlipped, imagBufferFlipped, shb_speech_fx_32, -1, 0, st->cldfbSynTd ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ Copy_Scale_sig_32_16( shb_speech_fx_32, shb_speech, L_FRAME16k, negate( sub( q_reImBuffer, 1 ) ) ); *Q_shb_spch = 0; move16(); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 2376babcd..ce602160f 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -2579,7 +2579,11 @@ static void ivas_dirac_dec_binaural_process_output_fx( outSlotRePr_fx = &( outSlotRe_fx[0] ); outSlotImPr_fx = &( outSlotIm_fx[0] ); +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( &outSlotRePr_fx, &outSlotImPr_fx, &( output_fx[chA][nBins * slot + offsetSamples] ), nBins, 0, 0, cldfbSynDec[chA] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( &outSlotRePr_fx, &outSlotImPr_fx, &( output_fx[chA][nBins * slot + offsetSamples] ), nBins, 0, cldfbSynDec[chA] ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynDec[chA]->Q_cldfb_state = sub( q_result, 1 ); move16(); } diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 59c93ae55..efa0b35e6 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -4189,7 +4189,11 @@ static void ivas_masa_ext_dirac_render_sf_fx( ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[idx_in][i]; // q_cldfb } Word16 out_size = imult1616( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, 0, 0, hMasaExtRend->cldfbSynRend[idx_in] ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, 0, hMasaExtRend->cldfbSynRend[idx_in] ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ scale_sig32( &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, sub( 11, q_out ) ); // q11 idx_in++; } -- GitLab