Calculation of optimum Q_bwe_exc differs between encoder and decoder
This is a follow up of !2851 (comment 111222).
The calculation of optimum scaling factor Q_bwe_exc in IVAS modes is different between encoder and decoder SWB TBE functions swb_tbe_enc_fx() and swb_tbe_dec_fx(). While at the decoder, the length of the signal on which the scaling factor is computed equals to L_FRAME32k + NL_BUFF_OFFSET:
/* ----- calculate optimum Q_bwe_exc and rescale memories accordingly ----- */
Word16 sig_len = L_FRAME32k + NL_BUFF_OFFSET;
move16();
IF( st->element_mode == EVS_MONO )
{
sig_len = L_FRAME32k;
move16();
}
Lmax = 0;
move32();
FOR( cnt = 0; cnt < sig_len; cnt++ ) // note: this differs from the encoder where the length is always L_FRAME32k
{
Lmax = L_max( Lmax, L_abs( bwe_exc_extended_fx[cnt] ) );
}
the length at the encoder is L_FRAME16k:
/* ----- calculate optimum Q_bwe_exc and rescale memories accordingly ----- */
Lmax = L_deposit_l( 0 );
FOR( cnt = 0; cnt < L_FRAME32k; cnt++ )
{
Lmax = L_max( Lmax, L_abs( bwe_exc_extended[cnt] ) );
}
See also the comment at https://forge.3gpp.org/rep/sa4/audio/ivas-basop/-/blob/main/lib_dec/swb_tbe_dec_fx.c#L5315.
Edited by vaclav