Commit babb3fe9 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch '877-lf-issue-during-fec-at-32kbps' into 'main'

Resolve "LF issue during FEC at 32kbps" [allow regression]

Closes #877

See merge request !634
parents b9b256e5 d0570193
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2033,7 +2033,8 @@ int16_t res_bpf_adapt(
Word16 res_bpf_adapt_ivas_fx(
    STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo decoder handle */
    const Word32 *bpf_error_signal_8k,     /* i  : BPF modification signal   */
    Word32 res_buf[STEREO_DFT_N_8k]        /* i  : residual buffer Q12       */
    Word32 res_buf[STEREO_DFT_N_8k],        /* i  : residual buffer Q_res       */
    Word16 q_res
);
#endif
void bpf_pitch_coherence(
+3 −7
Original line number Diff line number Diff line
@@ -684,8 +684,8 @@ int16_t res_bpf_adapt(
Word16 res_bpf_adapt_ivas_fx(
    STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo decoder handle */
    const Word32 *bpf_error_signal_8k,     /* i  : BPF modification signal   */
    Word32 res_buf[STEREO_DFT_N_8k]        /* i  : residual buffer Q12       */
)
    Word32 res_buf[STEREO_DFT_N_8k],       /* i  : residual buffer Q12       */
    Word16 q_res )
{
    Word32 error_nrg;
    Word32 tmp;
@@ -696,7 +696,6 @@ Word16 res_bpf_adapt_ivas_fx(
    Word16 i_start;
    Word16 i_end;
    Word16 bw_inv;
    Word16 shift;
    Word64 W_tmp;

    IF( EQ_16( hStereoDft->res_cod_band_max, 6 ) )
@@ -726,10 +725,7 @@ Word16 res_bpf_adapt_ivas_fx(
        W_tmp = W_add_nosat( W_tmp, W_mult0_32_32( res_buf[i], res_buf[i] ) );
    }

    shift = W_norm( W_tmp );
    W_tmp = W_shl( W_tmp, shift );
    res_hb_nrg = W_extract_h( W_tmp );
    res_hb_nrg = L_shr( res_hb_nrg, sub( add( Q24, shift ), 32 ) ); // Q0
    res_hb_nrg = (Word32) W_shr( W_tmp, shl( q_res, 1 ) ); // Q0
    res_hb_nrg = Mpy_32_16_1( res_hb_nrg, bw_inv );
    res_hb_nrg = L_add( Mpy_32_16_1( res_hb_nrg, STEREO_DFT_BPF_ADAPT_ALPHA_FX ), Mpy_32_16_1( hStereoDft->res_hb_nrg_mem_fx, sub( MAX_16, STEREO_DFT_BPF_ADAPT_ALPHA_FX ) ) );
    hStereoDft->res_hb_nrg_mem_fx = res_hb_nrg;
+1 −1
Original line number Diff line number Diff line
@@ -1403,7 +1403,7 @@ void stereo_dft_dec_res_fx(
        bass_psfilter_fx( hCPE->hStereoDft->hBpf, hCPE->hCoreCoder[0]->Opt_AMR_WB, out_16, L_FRAME8k, hCPE->hCoreCoder[0]->old_pitch_buf_16_fx + ( L_FRAME8k / STEREO_DFT_L_SUBFR_8k ), hCPE->hCoreCoder[0]->bpf_off,
                          hCPE->hCoreCoder[0]->stab_fac_fx, &hCPE->hStereoDft->stab_fac_smooth_res_fx, hCPE->hCoreCoder[0]->last_coder_type, 0, bpf_error_signal_8k_16 );
        Copy_Scale_sig_16_32( bpf_error_signal_8k_16, bpf_error_signal_8k, L_FRAME8k, Q15 );
        res_bpf_flag = res_bpf_adapt_ivas_fx( hCPE->hStereoDft, bpf_error_signal_8k, res_buf );
        res_bpf_flag = res_bpf_adapt_ivas_fx( hCPE->hStereoDft, bpf_error_signal_8k, res_buf, q_res );

        IF( prev_bfi )
        {
+17 −7
Original line number Diff line number Diff line
@@ -655,12 +655,12 @@ void stereo_dft_res_subst_spec_fx(
            Word32 op;
            Word16 q_div, q_shift;
            /* For 1st subframe, apply reversed time ECU to get correct analysis window */
            f_frac = extract_l( L_shr( L_sub( plocsi[i], L_shl( plocs[i], Q16 ) ), 1 ) );
            peak_phase = BASOP_util_atan2( p_mem[2 * plocs[i] + 1], p_mem[2 * plocs[i]], 0 );
            phase_tmp = L_sub( peak_phase, mult( f_frac, STEREO_DFT_PLC_PH_C_FX ) );
            phase = L_sub( phase_tmp, mult( f_frac, EVS_PI_FX ) );
            op = L_negate( L_shl( phase, 1 ) );
            corr_phase = L_add( L_add( STEREO_DFT_PLC_STEP21, L_ana ), time_offs );
            f_frac = extract_l( L_shr( L_sub( plocsi[i], L_shl( plocs[i], Q16 ) ), 1 ) );     // Q15
            peak_phase = BASOP_util_atan2( p_mem[2 * plocs[i] + 1], p_mem[2 * plocs[i]], 0 ); // Q13
            phase_tmp = L_sub( peak_phase, mult( f_frac, STEREO_DFT_PLC_PH_C_FX ) );          // Q13
            phase = L_sub( phase_tmp, mult( f_frac, EVS_PI_FX ) );                            // Q13
            op = L_negate( L_shl( phase, 1 ) );                                               // Q13
            corr_phase = L_add( L_add( STEREO_DFT_PLC_STEP21, L_ana ), time_offs );           // Q0
            q_shift = norm_l( corr_phase );
            corr_phase = Mpy_32_32( L_shl( corr_phase, q_shift ), plocsi[i] );
            corr_phase = L_deposit_l( BASOP_Util_Divide3232_Scale( corr_phase, L_ana, &q_div ) );
@@ -680,13 +680,23 @@ void stereo_dft_res_subst_spec_fx(
        }
        ELSE
        {
            /* corr_phase = PI2 * ( L_ana + time_offs ) * ( plocsi[i] / L_ana ); */
            Word32 op = L_add( L_ana, time_offs );
            Word16 q_div;
            op = Mpy_32_32( L_shl( op, Q15 ), plocsi[i] );
            corr_phase = BASOP_Util_Divide3232_Scale( op, L_ana, &q_div );
            corr_phase = extract_l( L_and( L_shl( corr_phase, q_div ), MAX_16 ) );
            /* For 2nd subframe, do regular phase shift */
            corr_phase = L_negate( L_shr( L_mult0( extract_l( corr_phase ), EVS_PI_FX ), Q14 ) );
            /* Multiplying only with EVS_PI_Fx and taking care of 2 in shift */
            corr_phase = ( L_shr( L_mult0( extract_l( corr_phase ), EVS_PI_FX ), Q14 /* Q13 + Q1*/ ) );
            WHILE( LT_32( corr_phase, -EVS_PI_FX ) )
            {
                corr_phase = L_add( L_add( corr_phase, EVS_PI_FX ), EVS_PI_FX );
            }
            WHILE( GT_32( corr_phase, EVS_PI_FX ) )
            {
                corr_phase = L_sub( L_sub( corr_phase, EVS_PI_FX ), EVS_PI_FX );
            }
            conj_sign = MAX_32;
            move32();
        }