From 404c6f2e0f7fd6ee0202b4eb7ff198448e424f66 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 5 Mar 2026 14:15:18 +0100 Subject: [PATCH 1/4] Replace 32bit buffer olapBufferSynth2_fx with 16bit buffer olapBufferSynth2 --- lib_com/fd_cng_com_fx.c | 13 ++++++++++--- lib_com/prot_fx.h | 3 ++- lib_com/stat_com.h | 2 +- lib_dec/acelp_core_dec_fx.c | 6 +++--- lib_dec/core_switching_dec_fx.c | 4 +++- lib_dec/fd_cng_dec_fx.c | 18 +++++++++++++----- lib_dec/ivas_tcx_core_dec_fx.c | 2 +- 7 files changed, 33 insertions(+), 15 deletions(-) diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index fc23ea45b..da8a1b85e 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -169,7 +169,7 @@ void initFdCngCom( #ifndef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING set32_fx( hFdCngCom->olapBufferSynth_fx, 0, FFTLEN ); #endif - set32_fx( hFdCngCom->olapBufferSynth2_fx, 0, FFTLEN ); + //set32_fx( hFdCngCom->olapBufferSynth2_fx, 0, FFTLEN ); set32_fx( hFdCngCom->exc_cng_32fx, 0, L_FRAME16k ); set16_fx( hFdCngCom->exc_cng, 0, L_FRAME16k ); @@ -3241,7 +3241,8 @@ void SynthesisSTFT_fx( void SynthesisSTFT_dirac_fx( Word32 *fftBuffer, /* i : FFT bins */ // hFdCngCom->fftBuffer_exp - Word32 *timeDomainOutput, + Word16 *timeDomainOutput, + //Word32 *timeDomainOutput, Word32 *olapBuffer, // Q_in const Word16 *olapWin, const Word16 samples_out, @@ -3298,7 +3299,13 @@ void SynthesisSTFT_dirac_fx( } /* Get time-domain signal */ - v_multc_fx( olapBuffer + shr( hFdCngCom->frameSize, 2 ), fftScale, timeDomainOutput, samples_out ); // Q_in - 9 + Copy_Scale_sig_32_16( olapBuffer + shr( hFdCngCom->frameSize, 2 ), timeDomainOutput, samples_out, -Q15 ); // Q_in - 15 + FOR( i = 0; i < samples_out; i++ ) + { + timeDomainOutput[i] = extract_l(Mpy_32_16_1( fftScale, timeDomainOutput[i] )); + move16(); + } + //v_multc_fx( olapBuffer + shr( hFdCngCom->frameSize, 2 ), fftScale, timeDomainOutput, samples_out ); // Q_in - 9 /* Get excitation */ v_multc_fx( olapBuffer + sub( shr( hFdCngCom->frameSize, 2 ), ( M + 1 ) ), fftScale, buf, add( M + 1, hFdCngCom->frameSize ) ); diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index f32d05534..71d3166ec 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9814,7 +9814,8 @@ void generate_masking_noise_ivas_fx( void SynthesisSTFT_dirac_fx( Word32 *fftBuffer, /* i : FFT bins */ - Word32 *timeDomainOutput, + Word16 *timeDomainOutput, + //Word32 *timeDomainOutput, Word32 *olapBuffer, const Word16 *olapWin, const Word16 samples_out, diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 0ae17b976..07a45d288 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -370,7 +370,7 @@ typedef struct #ifndef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING Word32 olapBufferSynth_fx[FFTLEN]; /*Q_olapBufferSynth*/ #endif - Word32 olapBufferSynth2_fx[FFTLEN]; /*Q_olapBufferSynth2*/ + //Word32 olapBufferSynth2_fx[FFTLEN]; /*Q_olapBufferSynth2*/ const Word32 *olapWinAna_fx; /* Q30 */ const Word16 *olapWinSyn_fx; /* Q15 */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 73ff775af..6ac251d5c 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1635,7 +1635,7 @@ ivas_error acelp_core_dec_fx( IF( NE_16( st->element_mode, last_element_mode ) ) { set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen ); - set32_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, 0, st->hFdCngDec->hFdCngCom->fftlen ); + //set32_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, 0, st->hFdCngDec->hFdCngCom->fftlen ); } Word32 psyn_32_fx[L_FRAME16k]; @@ -1643,7 +1643,7 @@ ivas_error acelp_core_dec_fx( generate_masking_noise_ivas_fx( psyn_32_fx, &exp, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out ); Copy_Scale_sig_32_16( psyn_32_fx, psyn_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( st->Q_syn, exp ) ); // Q = st->Q_syn - Copy_Scale_sig_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), -Q15 ); // Q0 + //Copy_Scale_sig_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), -Q15 ); // Q0 } } } @@ -1731,7 +1731,7 @@ ivas_error acelp_core_dec_fx( IF( st->idchan == 0 ) { set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen ); - set32_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, 0, st->hFdCngDec->hFdCngCom->fftlen ); + //set32_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, 0, st->hFdCngDec->hFdCngCom->fftlen ); } IF( hStereoCng != NULL && ( st->idchan == 0 ) ) { diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 2eab8f473..552aea083 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1949,7 +1949,9 @@ ivas_error core_switching_pre_dec_fx( } ELSE { - L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 ); + //L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 ); + lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ) ); + (void)Q_olapBufferSynth2; test(); IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) ) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 213962d43..33196fc06 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -93,7 +93,7 @@ void initFdCngDec_fx( hFdCngDec->hFdCngCom->olapBufferAna = hFdCngDec->olapBufferAna; set16_fx( hFdCngDec->olapBufferSynth2, 0, FFTLEN ); hFdCngDec->hFdCngCom->olapBufferSynth2 = hFdCngDec->olapBufferSynth2; - set32_fx( hFdCngDec->hFdCngCom->olapBufferSynth2_fx, 0, FFTLEN ); + //set32_fx( hFdCngDec->hFdCngCom->olapBufferSynth2_fx, 0, FFTLEN ); /* Set some counters and flags */ @@ -4642,7 +4642,11 @@ void generate_masking_noise_ivas_fx( } ELSE { - SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); + Word32 olapBufferSynth2_fx[FFTLEN]; /*Q_olapBufferSynth2*/ + Copy_Scale_sig_16_32_no_sat( hFdCngCom->olapBufferSynth2, olapBufferSynth2_fx, FFTLEN, Q15 ); + SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); + Copy_Scale_sig_32_16( olapBufferSynth2_fx, hFdCngCom->olapBufferSynth2, FFTLEN, -Q15 ); + //SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); } *exp_out = sub( *exp_out, Q9 ); move16(); @@ -4690,7 +4694,9 @@ void generate_stereo_masking_noise_fx( { hFdCngCom = st->hFdCngDec->hFdCngCom; Copy_Scale_sig_16_32_no_sat( hStereoCng->olapBufferSynth22_fx, Ns_fx, shr( hFdCngCom->frameSize, 1 ), sub( Q6, st->Q_syn ) ); /*Q6*/ - Copy32( hFdCngCom->olapBufferSynth2_fx, Np_fx, shr( hFdCngCom->frameSize, 1 ) ); /*st->Q_syn*/ + + //Copy32( hFdCngCom->olapBufferSynth2_fx, Np_fx, shr( hFdCngCom->frameSize, 1 ) ); /*st->Q_syn*/ + Copy_Scale_sig_16_32_no_sat( hFdCngCom->olapBufferSynth2, Np_fx, shr( hFdCngCom->frameSize, 1 ), Q15); set32_fx( &Np_fx[( hFdCngCom->frameSize / 2 )], 0, shr( hFdCngCom->frameSize, 1 ) ); set32_fx( &Ns_fx[( hFdCngCom->frameSize / 2 )], 0, shr( hFdCngCom->frameSize, 1 ) ); @@ -4966,7 +4972,8 @@ void generate_masking_noise_lb_dirac_fx( move32(); /* Perform STFT synthesis */ - SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); + SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); + //SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); scale_sig32( tdBuffer + n_samples_start, n_samples_out_loop, Q9 ); // Q2 -> Q11 } @@ -4977,7 +4984,8 @@ void generate_masking_noise_lb_dirac_fx( set32_fx( fftBuffer, 0, hFdCngCom->fftlen ); /* Perform STFT synthesis */ - SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); + SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); + //SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); } hFdCngCom->fftBuffer_exp = 31 - 11; move16(); diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index cdb2b6061..3c9e5d5ff 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -875,7 +875,7 @@ void stereo_tcx_core_dec_fx( Copy_Scale_sig_16_32_no_sat( signal_out_fx, signal_out_32_fx, st->hFdCngDec->hFdCngCom->frameSize, Q6 ); generate_masking_noise_ivas_fx( signal_out_32_fx, &exp, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out ); Copy_Scale_sig_32_16( signal_out_32_fx, signal_out_fx, st->hFdCngDec->hFdCngCom->frameSize, negate( exp ) ); // Q0 - Copy_Scale_sig_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), -Q15 ); // Q0 + //Copy_Scale_sig_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), -Q15 ); // Q0 } } -- GitLab From be3ec0744b53966929cabde0d7e27a2f1e25a701 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 5 Mar 2026 14:51:47 +0100 Subject: [PATCH 2/4] Apply Clang-format patch. --- lib_com/fd_cng_com_fx.c | 8 ++++---- lib_com/prot_fx.h | 2 +- lib_com/stat_com.h | 2 +- lib_dec/acelp_core_dec_fx.c | 8 ++++---- lib_dec/core_switching_dec_fx.c | 4 ++-- lib_dec/fd_cng_dec_fx.c | 14 +++++++------- lib_dec/ivas_tcx_core_dec_fx.c | 4 ++-- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index da8a1b85e..5023fe893 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -169,7 +169,7 @@ void initFdCngCom( #ifndef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING set32_fx( hFdCngCom->olapBufferSynth_fx, 0, FFTLEN ); #endif - //set32_fx( hFdCngCom->olapBufferSynth2_fx, 0, FFTLEN ); + // set32_fx( hFdCngCom->olapBufferSynth2_fx, 0, FFTLEN ); set32_fx( hFdCngCom->exc_cng_32fx, 0, L_FRAME16k ); set16_fx( hFdCngCom->exc_cng, 0, L_FRAME16k ); @@ -3242,7 +3242,7 @@ void SynthesisSTFT_dirac_fx( Word32 *fftBuffer, /* i : FFT bins */ // hFdCngCom->fftBuffer_exp Word16 *timeDomainOutput, - //Word32 *timeDomainOutput, + // Word32 *timeDomainOutput, Word32 *olapBuffer, // Q_in const Word16 *olapWin, const Word16 samples_out, @@ -3302,10 +3302,10 @@ void SynthesisSTFT_dirac_fx( Copy_Scale_sig_32_16( olapBuffer + shr( hFdCngCom->frameSize, 2 ), timeDomainOutput, samples_out, -Q15 ); // Q_in - 15 FOR( i = 0; i < samples_out; i++ ) { - timeDomainOutput[i] = extract_l(Mpy_32_16_1( fftScale, timeDomainOutput[i] )); + timeDomainOutput[i] = extract_l( Mpy_32_16_1( fftScale, timeDomainOutput[i] ) ); move16(); } - //v_multc_fx( olapBuffer + shr( hFdCngCom->frameSize, 2 ), fftScale, timeDomainOutput, samples_out ); // Q_in - 9 + // v_multc_fx( olapBuffer + shr( hFdCngCom->frameSize, 2 ), fftScale, timeDomainOutput, samples_out ); // Q_in - 9 /* Get excitation */ v_multc_fx( olapBuffer + sub( shr( hFdCngCom->frameSize, 2 ), ( M + 1 ) ), fftScale, buf, add( M + 1, hFdCngCom->frameSize ) ); diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 71d3166ec..c33ad441c 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9815,7 +9815,7 @@ void generate_masking_noise_ivas_fx( void SynthesisSTFT_dirac_fx( Word32 *fftBuffer, /* i : FFT bins */ Word16 *timeDomainOutput, - //Word32 *timeDomainOutput, + // Word32 *timeDomainOutput, Word32 *olapBuffer, const Word16 *olapWin, const Word16 samples_out, diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 07a45d288..8c8da8ec6 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -370,7 +370,7 @@ typedef struct #ifndef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING Word32 olapBufferSynth_fx[FFTLEN]; /*Q_olapBufferSynth*/ #endif - //Word32 olapBufferSynth2_fx[FFTLEN]; /*Q_olapBufferSynth2*/ + // Word32 olapBufferSynth2_fx[FFTLEN]; /*Q_olapBufferSynth2*/ const Word32 *olapWinAna_fx; /* Q30 */ const Word16 *olapWinSyn_fx; /* Q15 */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 6ac251d5c..d3d4a240f 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1635,15 +1635,15 @@ ivas_error acelp_core_dec_fx( IF( NE_16( st->element_mode, last_element_mode ) ) { set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen ); - //set32_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, 0, st->hFdCngDec->hFdCngCom->fftlen ); + // set32_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, 0, st->hFdCngDec->hFdCngCom->fftlen ); } Word32 psyn_32_fx[L_FRAME16k]; Copy_Scale_sig_16_32_no_sat( psyn_fx, psyn_32_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( Q6, st->Q_syn ) ); // Q6 generate_masking_noise_ivas_fx( psyn_32_fx, &exp, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out ); - Copy_Scale_sig_32_16( psyn_32_fx, psyn_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( st->Q_syn, exp ) ); // Q = st->Q_syn - //Copy_Scale_sig_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), -Q15 ); // Q0 + Copy_Scale_sig_32_16( psyn_32_fx, psyn_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( st->Q_syn, exp ) ); // Q = st->Q_syn + // Copy_Scale_sig_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), -Q15 ); // Q0 } } } @@ -1731,7 +1731,7 @@ ivas_error acelp_core_dec_fx( IF( st->idchan == 0 ) { set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen ); - //set32_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, 0, st->hFdCngDec->hFdCngCom->fftlen ); + // set32_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, 0, st->hFdCngDec->hFdCngCom->fftlen ); } IF( hStereoCng != NULL && ( st->idchan == 0 ) ) { diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 552aea083..e23cccfc9 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1949,9 +1949,9 @@ ivas_error core_switching_pre_dec_fx( } ELSE { - //L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 ); + // L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 ); lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ) ); - (void)Q_olapBufferSynth2; + (void) Q_olapBufferSynth2; test(); IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) ) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 33196fc06..5b47abd55 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -93,7 +93,7 @@ void initFdCngDec_fx( hFdCngDec->hFdCngCom->olapBufferAna = hFdCngDec->olapBufferAna; set16_fx( hFdCngDec->olapBufferSynth2, 0, FFTLEN ); hFdCngDec->hFdCngCom->olapBufferSynth2 = hFdCngDec->olapBufferSynth2; - //set32_fx( hFdCngDec->hFdCngCom->olapBufferSynth2_fx, 0, FFTLEN ); + // set32_fx( hFdCngDec->hFdCngCom->olapBufferSynth2_fx, 0, FFTLEN ); /* Set some counters and flags */ @@ -4646,7 +4646,7 @@ void generate_masking_noise_ivas_fx( Copy_Scale_sig_16_32_no_sat( hFdCngCom->olapBufferSynth2, olapBufferSynth2_fx, FFTLEN, Q15 ); SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); Copy_Scale_sig_32_16( olapBufferSynth2_fx, hFdCngCom->olapBufferSynth2, FFTLEN, -Q15 ); - //SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); + // SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); } *exp_out = sub( *exp_out, Q9 ); move16(); @@ -4694,9 +4694,9 @@ void generate_stereo_masking_noise_fx( { hFdCngCom = st->hFdCngDec->hFdCngCom; Copy_Scale_sig_16_32_no_sat( hStereoCng->olapBufferSynth22_fx, Ns_fx, shr( hFdCngCom->frameSize, 1 ), sub( Q6, st->Q_syn ) ); /*Q6*/ - - //Copy32( hFdCngCom->olapBufferSynth2_fx, Np_fx, shr( hFdCngCom->frameSize, 1 ) ); /*st->Q_syn*/ - Copy_Scale_sig_16_32_no_sat( hFdCngCom->olapBufferSynth2, Np_fx, shr( hFdCngCom->frameSize, 1 ), Q15); + + // Copy32( hFdCngCom->olapBufferSynth2_fx, Np_fx, shr( hFdCngCom->frameSize, 1 ) ); /*st->Q_syn*/ + Copy_Scale_sig_16_32_no_sat( hFdCngCom->olapBufferSynth2, Np_fx, shr( hFdCngCom->frameSize, 1 ), Q15 ); set32_fx( &Np_fx[( hFdCngCom->frameSize / 2 )], 0, shr( hFdCngCom->frameSize, 1 ) ); set32_fx( &Ns_fx[( hFdCngCom->frameSize / 2 )], 0, shr( hFdCngCom->frameSize, 1 ) ); @@ -4973,7 +4973,7 @@ void generate_masking_noise_lb_dirac_fx( /* Perform STFT synthesis */ SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); - //SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); + // SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); scale_sig32( tdBuffer + n_samples_start, n_samples_out_loop, Q9 ); // Q2 -> Q11 } @@ -4985,7 +4985,7 @@ void generate_masking_noise_lb_dirac_fx( set32_fx( fftBuffer, 0, hFdCngCom->fftlen ); /* Perform STFT synthesis */ SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); - //SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); + // SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); } hFdCngCom->fftBuffer_exp = 31 - 11; move16(); diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index 3c9e5d5ff..91a862fe3 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -874,8 +874,8 @@ void stereo_tcx_core_dec_fx( Word16 exp; Copy_Scale_sig_16_32_no_sat( signal_out_fx, signal_out_32_fx, st->hFdCngDec->hFdCngCom->frameSize, Q6 ); generate_masking_noise_ivas_fx( signal_out_32_fx, &exp, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out ); - Copy_Scale_sig_32_16( signal_out_32_fx, signal_out_fx, st->hFdCngDec->hFdCngCom->frameSize, negate( exp ) ); // Q0 - //Copy_Scale_sig_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), -Q15 ); // Q0 + Copy_Scale_sig_32_16( signal_out_32_fx, signal_out_fx, st->hFdCngDec->hFdCngCom->frameSize, negate( exp ) ); // Q0 + // Copy_Scale_sig_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), -Q15 ); // Q0 } } -- GitLab From 508f6326626f95e0c911892eccc0b6d699db89df Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 5 Mar 2026 15:43:36 +0100 Subject: [PATCH 3/4] Revert changes in SynthesisSTFT_dirac_fx() --- lib_com/fd_cng_com_fx.c | 11 ++--------- lib_com/prot_fx.h | 3 +-- lib_dec/fd_cng_dec_fx.c | 10 ++++++++-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index 5023fe893..4c8fbecc9 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -3241,8 +3241,7 @@ void SynthesisSTFT_fx( void SynthesisSTFT_dirac_fx( Word32 *fftBuffer, /* i : FFT bins */ // hFdCngCom->fftBuffer_exp - Word16 *timeDomainOutput, - // Word32 *timeDomainOutput, + Word32 *timeDomainOutput, Word32 *olapBuffer, // Q_in const Word16 *olapWin, const Word16 samples_out, @@ -3299,13 +3298,7 @@ void SynthesisSTFT_dirac_fx( } /* Get time-domain signal */ - Copy_Scale_sig_32_16( olapBuffer + shr( hFdCngCom->frameSize, 2 ), timeDomainOutput, samples_out, -Q15 ); // Q_in - 15 - FOR( i = 0; i < samples_out; i++ ) - { - timeDomainOutput[i] = extract_l( Mpy_32_16_1( fftScale, timeDomainOutput[i] ) ); - move16(); - } - // v_multc_fx( olapBuffer + shr( hFdCngCom->frameSize, 2 ), fftScale, timeDomainOutput, samples_out ); // Q_in - 9 + v_multc_fx( olapBuffer + shr( hFdCngCom->frameSize, 2 ), fftScale, timeDomainOutput, samples_out ); // Q_in - 9 /* Get excitation */ v_multc_fx( olapBuffer + sub( shr( hFdCngCom->frameSize, 2 ), ( M + 1 ) ), fftScale, buf, add( M + 1, hFdCngCom->frameSize ) ); diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index c33ad441c..f32d05534 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9814,8 +9814,7 @@ void generate_masking_noise_ivas_fx( void SynthesisSTFT_dirac_fx( Word32 *fftBuffer, /* i : FFT bins */ - Word16 *timeDomainOutput, - // Word32 *timeDomainOutput, + Word32 *timeDomainOutput, Word32 *olapBuffer, const Word16 *olapWin, const Word16 samples_out, diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 5b47abd55..01ec28c58 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -4972,7 +4972,10 @@ void generate_masking_noise_lb_dirac_fx( move32(); /* Perform STFT synthesis */ - SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); + Word32 olapBufferSynth2_fx[FFTLEN]; /*Q_olapBufferSynth2*/ + Copy_Scale_sig_16_32_no_sat( hFdCngCom->olapBufferSynth2, olapBufferSynth2_fx, FFTLEN, Q15 ); + SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); + Copy_Scale_sig_32_16( olapBufferSynth2_fx, hFdCngCom->olapBufferSynth2, FFTLEN, -Q15 ); // SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); scale_sig32( tdBuffer + n_samples_start, n_samples_out_loop, Q9 ); // Q2 -> Q11 } @@ -4984,7 +4987,10 @@ void generate_masking_noise_lb_dirac_fx( set32_fx( fftBuffer, 0, hFdCngCom->fftlen ); /* Perform STFT synthesis */ - SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); + Word32 olapBufferSynth2_fx[FFTLEN]; /*Q_olapBufferSynth2*/ + Copy_Scale_sig_16_32_no_sat( hFdCngCom->olapBufferSynth2, olapBufferSynth2_fx, FFTLEN, Q15 ); + SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); + Copy_Scale_sig_32_16( olapBufferSynth2_fx, hFdCngCom->olapBufferSynth2, FFTLEN, -Q15 ); // SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); } hFdCngCom->fftBuffer_exp = 31 - 11; -- GitLab From a378ed190f3de636582439e6e6d16fe0e36a52b0 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 5 Mar 2026 16:03:49 +0100 Subject: [PATCH 4/4] Clang format --- lib_com/fd_cng_com_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index 4c8fbecc9..9704ba9dd 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -3298,7 +3298,7 @@ void SynthesisSTFT_dirac_fx( } /* Get time-domain signal */ - v_multc_fx( olapBuffer + shr( hFdCngCom->frameSize, 2 ), fftScale, timeDomainOutput, samples_out ); // Q_in - 9 + v_multc_fx( olapBuffer + shr( hFdCngCom->frameSize, 2 ), fftScale, timeDomainOutput, samples_out ); // Q_in - 9 /* Get excitation */ v_multc_fx( olapBuffer + sub( shr( hFdCngCom->frameSize, 2 ), ( M + 1 ) ), fftScale, buf, add( M + 1, hFdCngCom->frameSize ) ); -- GitLab