Skip to content

EVS: bug in ACELP 0-BWE memory reset

In the EVS part, ACELP decoder, there is a bug in the HF synthesis (zero BWE) memory reset. A part of this memory belongs to the HP filter which is composed of 4 coefficients in FLP but 6 coefficients in BASOP. However, the reset of only 4 coefficients is done in both code bases.

A fix (two instances) is as follows:

void hf_synth_init_fx(
    ZERO_BWE_DEC_HANDLE hBWE_zero /* o  : zero BWE decoder handle */
)
{
    hBWE_zero->seed2 = RANDOM_INITSEED;
    move16();
    set16_fx( hBWE_zero->mem_hf_fx, 0, ( L_FIR - 1 ) );
    set16_fx( hBWE_zero->mem_syn_hf_fx, 0, M );
#ifdef FIX
    set16_fx( hBWE_zero->mem_hp400_fx, 0, 6 );   <<<<<<<<<<<<<<<<<<<<<<<<<<<<< FIX
#else
    set16_fx( hBWE_zero->mem_hp400_fx, 0, 4 );
#endif
    set16_fx( hBWE_zero->delay_syn_hf_fx, 0, NS2SA( 16000, DELAY_CLDFB_NS ) );
    set16_fx( hBWE_zero->mem_hp_interp_fx, 0, INTERP_3_1_MEM_LEN );
    hBWE_zero->memExp1 = 0;
    move16();
    return;
}

void hf_synth_reset_fx(
    ZERO_BWE_DEC_HANDLE hBWE_zero /* o  : zero BWE decoder handle */
)
{
    Word16 i;

    FOR( i = 0; i < L_FRAME16k; i++ )
    {
        Random( &hBWE_zero->seed2 );
    }

    set16_fx( hBWE_zero->mem_hf_fx, 0, ( L_FIR - 1 ) );
    set16_fx( hBWE_zero->mem_syn_hf_fx, 0, M );
#ifdef FIX
    set16_fx( hBWE_zero->mem_hp400_fx, 0, 6 );   <<<<<<<<<<<<<<<<<<<<<<<<<<<<< FIX
#else
    set16_fx( hBWE_zero->mem_hp400_fx, 0, 4 );
#endif

    set16_fx( hBWE_zero->delay_syn_hf_fx, 0, NS2SA( 16000, DELAY_CLDFB_NS ) );
    set16_fx( hBWE_zero->mem_hp_interp_fx, 0, INTERP_3_1_MEM_LEN );
    hBWE_zero->memExp1 = 0;
    move16();
    return;
}

In IVAS part, a patch is present at https://forge.3gpp.org/rep/sa4/audio/ivas-basop/-/blob/main/lib_dec/acelp_core_dec_ivas_fx.c#L2167.