Commit 98177ffb authored by Arash Azizi's avatar Arash Azizi
Browse files

issue: 2446 reverting some previous changes - going through all the function...

issue: 2446 reverting some previous changes - going through all the function with various points changed - checking to see if the IVAS function runs the same in currently implemented instances.
parent ae14de2a
Loading
Loading
Loading
Loading
+193 −26
Original line number Diff line number Diff line
@@ -1048,8 +1048,19 @@ void con_tcx_ivas_fx(
        /* apply pre-emphasis to the signal */
        mem = shl( synth[( -( ( ( L_frame / 2 ) + hTcxDec->pit_max_TCX ) + M + M ) - 1 )], st->Q_syn_factor );
        move16();
#ifndef HARMONIZE_2446_CON_TCX_FX
        Q_exc = E_UTIL_f_preemph3_ivas_fx(&(synth[-(((L_frame / 2) + hTcxDec->pit_max_TCX) + 2 * M)]), st->preemph_fac, add(add(shr(L_frame, 1), hTcxDec->pit_max_TCX), shl(M, 1)), &mem, 1);

#else
        IF(NE_16(st->element_mode, EVS_MONO)) {
            Q_exc = E_UTIL_f_preemph3_ivas_fx(&(synth[-(((L_frame / 2) + hTcxDec->pit_max_TCX) + 2 * M)]), st->preemph_fac, add(add(shr(L_frame, 1), hTcxDec->pit_max_TCX), shl(M, 1)), &mem, 1);
        }
        ELSE{
            Q_exc = E_UTIL_f_preemph3(&(synth[-(((L_frame / 2) + hTcxDec->pit_max_TCX) + 2 * M)]), st->preemph_fac, add(add(shr(L_frame, 1), hTcxDec->pit_max_TCX), shl(M, 1)), &mem, 1);
        }
#endif // !HARMONIZE_2446_CON_TCX_FX

        
        scale_sig( &( synth[-( ( ( L_frame / 2 ) + hTcxDec->pit_max_TCX ) + 2 * M )] ), add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), shl( M, 1 ) ), negate( st->Q_syn_factor ) ); /*Q0, Setting back to Q0, as the following calculations are implemented assuming synth is in Q0 */

        st->Mode2_lp_gainc = L_deposit_l( 0 );
@@ -1074,8 +1085,19 @@ void con_tcx_ivas_fx(
        lag_wind( r_h, r_l, M, st->output_Fs, LAGW_STRONG );

        /* Levinson Durbin */
#ifndef HARMONIZE_2446_CON_TCX_FX
        E_LPC_lev_dur_ivas_fx(r_h, r_l, A_local, NULL, M, NULL);

#else
        IF(NE_16(st->element_mode, EVS_MONO)) {
            E_LPC_lev_dur_ivas_fx(r_h, r_l, A_local, NULL, M, NULL);
        }
        ELSE{
            E_LPC_lev_dur_fx(r_h, r_l, A_local, NULL, M, NULL);
        }
#endif // !HARMONIZE_2446_CON_TCX_FX

        
        /* copy for multiple frame loss */
        Copy( A_local, st->old_Aq_12_8_fx, M + 1 ); /*Q14*/

@@ -1096,14 +1118,31 @@ void con_tcx_ivas_fx(
        /* apply pre-emphasis to the signal */
        mem = shl( synth[( -L_frame - 1 )], st->Q_syn_factor ); /*hTcxDec->Q_synth_factor_old*/
        move16();
#ifndef HARMONIZE_2446_CON_TCX_FX
        Q_exc = E_UTIL_f_preemph3_ivas_fx(&(synth[-L_frame]), st->preemph_fac, L_frame, &mem, 1);
        scale_sig(&synth[-L_frame], L_frame, negate(st->Q_syn_factor)); /*Q0, Setting back to Q0, as the following calculations are implemented assuming synth is in Q0 */

#else
        IF(NE_16(st->element_mode, EVS_MONO)) {
            Q_exc = E_UTIL_f_preemph3_ivas_fx(&(synth[-L_frame]), st->preemph_fac, L_frame, &mem, 1);
            scale_sig(&synth[-L_frame], L_frame, negate(st->Q_syn_factor)); /*Q0, Setting back to Q0, as the following calculations are implemented assuming synth is in Q0 */
        }
        ELSE{
            Q_exc = E_UTIL_f_preemph3(&(synth[-L_frame]), st->preemph_fac, L_frame, &mem, 1);
            Scale_sig(&synth[-L_frame], L_frame, negate(st->Q_syn_factor)); /*Q0, Setting back to Q0, as the following calculations are implemented assuming synth is in Q0 */
        }
#endif // !HARMONIZE_2446_CON_TCX_FX
        Copy( st->old_Aq_12_8_fx, A_local, M + 1 );                         /*Q14*/

        offset = shr( L_frame, 1 );
        IF( GE_16( st->last_good, UNVOICED_TRANSITION ) )
        {   
#ifndef HARMONIZE_2446_CON_TCX_FX
            tmp16 = s_max(Tc - shr(L_frame, 1), 0);
#else
            tmp16 = s_max(sub(Tc, shr(L_frame, 1)), 0);
#endif // !HARMONIZE_2446_CON_TCX_FX

            Copy_Scale_sig( hTcxDec->old_excFB_fx, &( exc[-tmp16] ), add( offset, tmp16 ), sub( Q_exc, st->Q_exc ) ); /*Q_exc*/
        }
        ELSE
@@ -1391,8 +1430,11 @@ void con_tcx_ivas_fx(
    /*-----------------------------------------------------------------*
     * Construct the random part of excitation
     *-----------------------------------------------------------------*/

#ifndef HARMONIZE_2446_CON_TCX_FX
    IF(NE_16(coh, -16384))
#else
    IF(NE_16(coh, -16384) && NE_16(st->element_mode,EVS_MONO ))
#endif // !HARMONIZE_2446_CON_TCX_FX
    {
        Word16 tmpSeed1;
        Word16 alpha_coh;
@@ -1515,7 +1557,11 @@ void con_tcx_ivas_fx(
                move32();
                FOR( j = 11; j > 0; j-- )
                {   
#ifndef HARMONIZE_2446_CON_TCX_FX
                    L_tmp2 = L_mac(L_tmp2, noise[(i + (L_FIR_FER2 - j))], hp_filt[sub(L_FIR_FER2, j)]);
#else
                    L_tmp2 = L_mac(L_tmp2, noise[add(i , (sub(L_FIR_FER2, j)))], hp_filt[sub(L_FIR_FER2, j)]);
#endif // !HARMONIZE_2446_CON_TCX_FX
                }
                L_tmp2 = Mpy_32_16_1( L_tmp2, st->cummulative_damping /*Q15*/ ); /*Q0, noise_e*/
                noise[i] = mac_r( L_tmp2, gain_tmp, noise[i] );                  /*Q15, noise_e*/
@@ -1572,7 +1618,16 @@ void con_tcx_ivas_fx(
    {
        gain32 = Mpy_32_16_1( gain32, 22938 /*0.7f Q15*/ ); /*Q16*/
    }
#ifndef HARMONIZE_2446_CON_TCX_FX
    L_tmp = L_shl(gain32, 1); /*Q16*/
#else
    IF( NE_16(st->element_mode, EVS_MONO) ) {
        L_tmp = L_shl(gain32, 1); /*Q16*/
    }
    ELSE{
        L_tmp = L_shl_sat(gain32, 1); /*Q16*/
    }
#endif // !HARMONIZE_2446_CON_TCX_FX

    IF( GT_32( L_shl( L_deposit_h( gainCNG ), sub( gainCNG_e, 31 - 16 ) /*Q16*/ ), L_tmp ) )
    {
@@ -1598,12 +1653,24 @@ void con_tcx_ivas_fx(
    step32 = Mpy_32_16_1( L_tmp /*Q16,-tmp_e*/, getInvFrameLen( L_frame ) /*W16Q21*/ ); /*Q22,-tmp_e*/
    step32 = L_shl( step32, sub( 25 - 22, tmp_e ) );                                    /*Q25*/

#ifndef HARMONIZE_2446_CON_TCX_FX
    pt_exc = noise + shr(L_FIR_FER2, 1);
#else
    pt_exc = noise + L_FIR_FER2 / 2 ;
#endif // !HARMONIZE_2446_CON_TCX_FX

    /*gain_inov = 1.0f / (float)sqrt( dot_product( pt_exc, pt_exc, L_frame ) / L_frame + 0.01f );*/ /* normalize energy */
    L_tmp = Dot_productSq16HQ( 0, pt_exc /*Q0,15+1*/, L_frame, &tmp_e ) /*Q31,tmp_e+16+16*/;
#ifndef HARMONIZE_2446_CON_TCX_FX
    tmp_e = sub(add(tmp_e, shl(noise_e, 1)), 1); // actual multiplier!
#else
    IF(NE_16(st->element_mode, EVS_MONO)) {
        tmp_e = sub(add(tmp_e, shl(noise_e, 1)), 1); // actual multiplier!
    }
#endif // !HARMONIZE_2446_CON_TCX_FX

    L_tmp = Mpy_32_16_1( L_tmp, getInvFrameLen( L_frame ) /*W16Q21*/ ) /*W32Q37,tmp_e+16+16*/ /*Q5,tmp_e*/;
#ifndef HARMONIZE_2446_CON_TCX_FX
    tmp_e = add(tmp_e, 31 - 6); /*-->Q31*/
    gain_inov = 0;
    move16();
@@ -1615,6 +1682,30 @@ void con_tcx_ivas_fx(
        gain_inov_e = tmp_e;
        move16();
    }
#else
    IF(NE_16(st->element_mode, EVS_MONO)){
        tmp_e = add(tmp_e, 31 - 6); /*-->Q31*/
        gain_inov = 0;
        move16();
        gain_inov_e = 0;
        move16();
        IF(NE_32(L_tmp, 0))
        {
            gain_inov = round_fx(ISqrt32(L_tmp, &tmp_e)); /*Q15,tmp_e*/
            gain_inov_e = tmp_e;
            move16();
        }
    }
    ELSE{
        tmp_e = add(tmp_e, 31 - 5);                     /*-->Q31*/
        gain_inov = round_fx(ISqrt32(L_tmp, &tmp_e)); /*Q15,tmp_e*/
        gain_inov_e = tmp_e;
        move16();
    }

#endif // !HARMONIZE_2446_CON_TCX_FX

    
    test();
    test();
    IF( EQ_16( st->last_good, UNVOICED_CLAS ) && NE_16( st->core_ext_mode, UNVOICED ) )
@@ -1737,7 +1828,11 @@ void con_tcx_ivas_fx(

    /*buf[OLD_EXC_SIZE_DEC;3/2 L_frame] Q1: exc*/
    /*buf[0;M] Q0: mem_syn*/
#ifndef HARMONIZE_2446_CON_TCX_FX
    IF( A_cng != NULL )
#else
    IF((A_cng != NULL) && NE_32(st->element_mode, EVS_MONO ))
#endif // !HARMONIZE_2446_CON_TCX_FX
    {
        Word16 alpha_delayed;

@@ -1797,6 +1892,12 @@ void con_tcx_ivas_fx(
    /* Deemphasis and output synth and ZIR */
    deemph_fx( syn, st->preemph_fac, add( L_frame, shr( L_frame, 1 ) ), &tmp_deemph );

#ifdef HARMONIZE_2446_CON_TCX_FX
    IF(EQ_32(st->element_mode, EVS_MONO)) {
        bufferCopyFx(syn + sub(L_frame, M + 1), st->syn, 1 + M, Q_syn, 0, 0, 0); /*Q_syn*/
    }
#endif // HARMONIZE_2446_CON_TCX_FX

    lerp( syn + sub( L_frame, shr( L_frame, 1 ) ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) );
    hTcxDec->Q_old_syn_Overl = Q_syn;
    move16();
@@ -1818,6 +1919,7 @@ void con_tcx_ivas_fx(
    hHQ_core->Q_old_wtda = Q_syn;
    move16();

#ifndef HARMONIZE_2446_CON_TCX_FX
    scf = add(getScaleFactor16(syn, L_frame), Q_syn);
    IF(LT_16(scf, 0)) // Only avoid left shift in bufferCopyFX when overflow could occur
    {
@@ -1834,6 +1936,37 @@ void con_tcx_ivas_fx(

    Copy_Scale_sig(syn + L_frame, hTcxDec->syn_OverlFB, shr(L_frame, 1), sub(st->Q_syn_factor, Q_syn));
    hTcxDec->Q_syn_OverlFB = st->Q_syn_factor;
#else
    IF(NE_16(st->element_mode, EVS_MONO)) {
        scf = add(getScaleFactor16(syn, L_frame), Q_syn);
        IF(LT_16(scf, 0)) // Only avoid left shift in bufferCopyFX when overflow could occur
        {
            st->Q_syn_factor = scf;
        }
        ELSE
        {
            st->Q_syn_factor = 0;
            move16();
        }
        bufferCopyFx(syn, synth, L_frame, Q_syn, st->Q_syn_factor, 0, 0);

        bufferCopyFx(syn + sub(L_frame, M + 1), st->syn, 1 + M, Q_syn, st->Q_syn_factor, 0, 0);

        Copy_Scale_sig(syn + L_frame, hTcxDec->syn_OverlFB, shr(L_frame, 1), sub(st->Q_syn_factor, Q_syn));
        hTcxDec->Q_syn_OverlFB = st->Q_syn_factor;
    }
    ELSE{
        /* As long as there is no synth scaling factor introduced, which
        is given to the outside, there might occur overflows here */
        BASOP_SATURATE_WARNING_OFF_EVS
        bufferCopyFx(syn, synth, L_frame, Q_syn, 0, 0, 0); /*Q_syn*/
        BASOP_SATURATE_WARNING_ON_EVS

        Copy_Scale_sig(syn + L_frame, hTcxDec->syn_OverlFB, shr(L_frame, 1), sub(0, Q_syn)); /*Q0*/
        hTcxDec->Q_syn_OverlFB = 0;
        move16();
    }
#endif // !HARMONIZE_2446_CON_TCX_FX

    /* copy total excitation exc2 as 16kHz for acelp mode1 decoding */
    IF( st->hWIDec != NULL )
@@ -1848,8 +1981,22 @@ void con_tcx_ivas_fx(
    move16();

    /* create aliasing and windowing need for transition to TCX10/5 */
#ifndef HARMONIZE_2446_CON_TCX_FX
    Copy(syn + L_frame, hTcxDec->syn_Overl_TDACFB, shr(L_frame, 1));
    hTcxDec->Q_syn_Overl_TDACFB = Q_syn;

#else
    IF(NE_16(st->element_mode, EVS_MONO)) {
        Copy(syn + L_frame, hTcxDec->syn_Overl_TDACFB, shr(L_frame, 1));
        hTcxDec->Q_syn_Overl_TDACFB = Q_syn;
    }
    ELSE{
        bufferCopyFx(syn + L_frame, hTcxDec->syn_Overl_TDACFB, shr(L_frame, 1), Q_syn, 0, -1, 0);
        hTcxDec->Q_syn_Overl_TDACFB = add(st->Q_syn, sub(st->Q_syn, -1));
    }
#endif // HARMONIZE_2446_CON_TCX_FX

    
    move16();

    FOR( i = 0; i < W12; i++ )
@@ -1894,7 +2041,18 @@ void con_tcx_ivas_fx(
    move16();

    /* update memory for low band */
#ifndef HARMONIZE_2446_CON_TCX_FX
    st->Q_syn = Q_syn;
#else
    IF(NE_16(st->element_mode, EVS_MONO)) {
        st->Q_syn = Q_syn;
    }
    ELSE{
        Scale_sig(hTcxDec->old_syn_Overl, shr(st->L_frame, 1), sub(-1, Q_syn)); /*Q_syn*/
        hTcxDec->Q_old_syn_Overl = -1;
    }
#endif // !HARMONIZE_2446_CON_TCX_FX

    move16();
    lerp( hTcxDec->syn_OverlFB, hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) );
    hTcxDec->Q_syn_Overl = hTcxDec->Q_syn_OverlFB;
@@ -1903,9 +2061,18 @@ void con_tcx_ivas_fx(
    hTcxDec->Q_syn_Overl_TDAC = hTcxDec->Q_syn_Overl_TDACFB;
    move16();
    lerp( st->hHQ_core->old_out_fx, st->hHQ_core->old_out_LB_fx, st->L_frame, L_frame );
#ifndef HARMONIZE_2446_CON_TCX_FX
    st->hHQ_core->Q_old_wtda_LB = Q_syn;              // st->hHQ_core->Q_old_wtda
#else
    IF(EQ_16(st->element_mode, EVS_MONO)) {
        st->hHQ_core->Q_old_wtda_LB = Q_syn;              // st->hHQ_core->Q_old_wtda
    }
#endif // !HARMONIZE_2446_CON_TCX_FX

    st->old_enr_LP = Enr_1_Az_fx( A_local, L_SUBFR ); /*Q3*/
    move16();

    return;
}

+0 −6
Original line number Diff line number Diff line
@@ -488,13 +488,7 @@ void stereo_tcx_core_dec_fx(
        }

        /* PLC: [TCX: TD PLC] */
#ifndef HARMONIZE_2446_CON_TCX_FX
        con_tcx_fx( st, &synthFB_fx[0] /*, -1.f, NULL, 0, NULL */ );
#else
        con_tcx_ivas_fx( st, &synthFB_fx[0], -16384, NULL, 0, NULL );
#endif // !HARMONIZE_2446_CON_TCX_FX


        test();
        IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || hTcxDec->tcxConceal_recalc_exc )
        {