Commit a5befdfc authored by Mohammadreza Naghibzadeh's avatar Mohammadreza Naghibzadeh
Browse files

Scale synth buffer in con_tcx_fx() using st->Q_syn_factor

parent f17c254f
Loading
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -190,9 +190,16 @@ void con_tcx_fx(
    IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || hTcxDec->tcxConceal_recalc_exc )
    {
        /* apply pre-emphasis to the signal */
#ifdef FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE
        mem = shl( synth[( -( ( ( shr( L_frame, 2 ) + hTcxDec->pit_max_TCX ) + M + M ) ) - 1 )], st->Q_syn_factor ); /*Q0*/
#else
        mem = synth[( -( ( ( ( L_frame / 2 ) + hTcxDec->pit_max_TCX ) + M + M ) ) - 1 )]; /*Q0*/
#endif
        move16();
        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 );
#ifdef FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE
        scale_sig( &( synth[-( ( shr( 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 */
#endif
        st->Mode2_lp_gainc = L_deposit_l( 0 );

        st->Mode2_lp_gainp = get_gain2( synth - shl( L_subfr, 1 ), synth - add( shl( L_subfr, 1 ), Tc ), shl( L_subfr, 1 ) ); /*Q16*/
@@ -231,9 +238,16 @@ void con_tcx_fx(
    ELSE
    {
        /* apply pre-emphasis to the signal */
#ifdef FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE
        mem = shl( synth[( -L_frame - 1 )], st->Q_syn_factor ); /*Q0*/
#else
        mem = synth[( -L_frame - 1 )];                                                    /*Q0*/
#endif
        move16();
        Q_exc = E_UTIL_f_preemph3( &( synth[-L_frame] ), st->preemph_fac, L_frame, &mem, 1 );
#ifdef FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE
        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
        Copy( st->old_Aq_12_8_fx, A_local, M + 1 ); /*Q12*/

        offset = shr( L_frame, 1 );
@@ -247,7 +261,10 @@ void con_tcx_fx(
            Copy_Scale_sig( hTcxDec->old_excFB_fx, &( exc[-( L_subfr * 2 )] ), add( shl( L_subfr, 1 ), offset ), sub( Q_exc, st->Q_exc ) ); /*Q_exc*/
        }
    }

#ifdef FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE
    st->Q_syn_factor = 0;
    move16();
#endif
    /*-----------------------------------------------------------------*
     * PLC: Construct the harmonic part of excitation
     *-----------------------------------------------------------------*/
+8 −5
Original line number Diff line number Diff line
@@ -311,10 +311,7 @@ void stereo_tcx_core_dec_fx(
    set16_fx( synth_fx, 0, L_FRAME_PLUS + M );
#endif
    set16_fx( synthFB_fx, 0, L_FRAME_PLUS + M );
#ifdef FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE
    st->Q_syn_factor = 0;
    move16();
#endif

    /*--------------------------------------------------------------------------------*
     * BITSTREAM DECODING
     *--------------------------------------------------------------------------------*/
@@ -340,7 +337,13 @@ void stereo_tcx_core_dec_fx(
        st->core = GetPLCModeDecision_ivas_fx( st ); /* Q0 */
        move16();
    }

#ifdef FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE
    IF( st->core != ACELP_CORE )
    {
        st->Q_syn_factor = 0;
        move16();
    }
#endif
    /*--------------------------------------------------------------------------------*
     * LPC envelope decoding
     *--------------------------------------------------------------------------------*/