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

Set st->Q_syn_factor when no secondary channel existed in the previous frame.

parent f94255a4
Loading
Loading
Loading
Loading
Loading
+0 −14
Original line number Diff line number Diff line
@@ -297,21 +297,7 @@ ivas_error acelp_core_dec_fx(
    move16();
    tmp_noise_fx = 0;
    move16();
#ifdef FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE
    if ( NE_32( st->last_core, TCX_10_CORE ) && NE_32( st->last_core, TCX_20_CORE ) ) // st->Q_syn_factor is set in TCX mode; otherwise, it may be uninitialized
    {
        Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); /*Q_exc*/
    }
    else
    {
        Copy_Scale_sig( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC, negate( st->Q_syn_factor ) ); /*Q_exc*/
        st->Q_syn = add( st->Q_syn, st->Q_syn_factor );
    }
    st->Q_syn_factor = 0;
    move16();
#else
    Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); /*Q_exc*/
#endif
    exc_fx = old_exc_fx + L_EXC_MEM_DEC;

    IF( st->hWIDec != NULL )
+10 −0
Original line number Diff line number Diff line
@@ -522,6 +522,16 @@ ivas_error ivas_core_dec_fx(
                Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, add( M, 1 ), sub( norm_s( sub( st->hFdCngDec->hFdCngCom->A_cng[0], 1 ) ), 3 ) ); // Qx
            }

#ifdef FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE
            if ( ( EQ_32( st->last_core, TCX_10_CORE ) || EQ_32( st->last_core, TCX_20_CORE ) ) ||                                                                                                               // st->Q_syn_factor is set in TCX mode; otherwise, it may be uninitialized
                 ( GT_16( hCPE->element_mode, IVAS_CPE_DFT ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && ( ( EQ_32( sts[0]->last_core, TCX_10_CORE ) || EQ_32( sts[0]->last_core, TCX_20_CORE ) ) ) ) ) // in this case sts[1] gets it value from sts[0]
            {
                Scale_sig( st->old_exc_fx, L_EXC_MEM_DEC, negate( st->Q_syn_factor ) );
                st->Q_syn = add( st->Q_syn, st->Q_syn_factor );
            }
            st->Q_syn_factor = 0;
            move16();
#endif
            IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) )
            {
                return error;
+4 −0
Original line number Diff line number Diff line
@@ -1951,6 +1951,10 @@ void stereo_switching_dec(
        Copy( sts[0]->old_exc_fx, sts[1]->old_exc_fx, L_EXC_MEM_DEC ); /* Q_exc */
        sts[1]->Q_exc = sts[0]->Q_exc;
        move16();
#ifdef FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE
        sts[1]->Q_syn_factor = sts[0]->Q_syn_factor;
        move16();
#endif
        sts[1]->Q_exc_cng = sts[0]->Q_exc_cng;
        move16();
        sts[1]->prev_Q_exc = sts[0]->prev_Q_exc;