Commit 64d5ce21 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh Committed by Manuel Jander
Browse files

Removed scalings before ProcessStereoIGF_fx in stereo_mdct_core_enc_fx and decoder MSAN fix

parent c1529471
Loading
Loading
Loading
Loading
+4 −96
Original line number Diff line number Diff line
@@ -153,8 +153,8 @@ void stereo_mdct_core_enc_fx(
    Word32 *p_mdst_spectrum_long_fx[CPE_CHANNELS];
    Word32 mdst_spectrum_long_fx[CPE_CHANNELS][N_MAX];
    Word32 *mdst_spectrum_fx[CPE_CHANNELS][NB_DIV];
    Word16 q_powSpecMsInv[MCT_MAX_CHANNELS], q_spec, tmp_s;
    Word16 tmp_q_powSpec[N_MAX], tmp_q_powSpecInv[N_MAX], *tmp_q_psi[2];
    Word16 exp_powSpecMsInv[MCT_MAX_CHANNELS], q_spec, tmp_s;
    Word16 tmp_q_powSpecInv[N_MAX], *tmp_q_psi[2];
    Word64 W_tmp;
#endif
    Encoder_State *st, **sts;
@@ -190,8 +190,6 @@ void stereo_mdct_core_enc_fx(

#ifndef FIX_1464_NO_SINGLE_SPEC_Q
    set16_fx( tmp_q_powSpecInv, 63, N_MAX );
    set16_fx( tmp_q_powSpec, 63, N_MAX );
    set16_fx( q_powSpecMsInv, 31, MCT_MAX_CHANNELS );

    tmp_q_psi[0] = tmp_q_powSpecInv;
    tmp_q_psi[1] = &tmp_q_powSpecInv[N_TCX10_MAX];
@@ -447,9 +445,6 @@ void stereo_mdct_core_enc_fx(
        exp_inv_spectrum[0] = exp_inv_spectrum[1] = sub( Q31, q_spec );
        move16();
        move16();
#else
        stereo_coder_tcx_fx( hStereoMdct, sts, ms_mask, mdst_spectrum_fx, inv_spectrum_fx, inv_mdst_spectrum_fx, 0, mdst_spectrum_e, inv_spectrum_e, inv_mdst_spectrum_e );
#endif
    }

    /*--------------------------------------------------------------*
@@ -640,7 +635,7 @@ void stereo_mdct_core_enc_fx(

        /* Aligning the Q-factors */
        {
            q_powSpecMsInv[ch] = Q31;
            Word16 q_temp = Q31;
            move16();
            FOR( n = 0; n < nSubframes; n++ )
            {
@@ -656,7 +651,7 @@ void stereo_mdct_core_enc_fx(
            {
                FOR( i = 0; i < L_subframeTCX; i++ )
                {
                    powerSpecMsInv_fx[ch][n][i] = L_shr_sat( powerSpecMsInv_fx[ch][n][i], sub( tmp_q_psi[n][i], q_powSpecMsInv[ch] ) );
                    powerSpecMsInv_fx[ch][n][i] = L_shr_sat( powerSpecMsInv_fx[ch][n][i], sub( tmp_q_psi[n][i], q_temp ) );
                    move32();
                }
            }
@@ -730,92 +725,6 @@ void stereo_mdct_core_enc_fx(
                IF( ( NE_16( hStereoMdct->mdct_stereo_mode[n], hStereoMdct->IGFStereoMode[n] ) || EQ_16( hStereoMdct->mdct_stereo_mode[n], SMDCT_BW_MS ) ) && !hStereoMdct->isSBAStereoMode )
                {
                    IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS];
                    Word32 powerSpec_fx[CPE_CHANNELS][N_MAX], *p_powerSpec_fx[CPE_CHANNELS];
                    Word16 q_powSpec[CPE_CHANNELS];
                    p_powerSpec_fx[0] = powerSpec_fx[0];
                    p_powerSpec_fx[1] = powerSpec_fx[1];
                    {
                        /* Copy powerSpec values from 64 bit buffer to 32 bit buffer */
                        FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
                        {
                            Word16 n1, nsub = 1;
                            length = sts[ch]->hTcxEnc->L_frameTCX;
                            move16();
                            move16();
                            IF( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
                            {
                                length = shr( sts[ch]->hTcxEnc->L_frameTCX, 1 );
                                nsub = NB_DIV;
                                move16();
                            }
                            IF( EQ_16( sts[ch]->last_core, ACELP_CORE ) )
                            {
                                length = add( length, shr( length, 2 ) );
                            }
                            exp = sub( exp_powerSpec64[ch][0], W_norm_arr( powerSpec64[ch], length ) );
                            IF( EQ_16( nsub, 2 ) )
                            {
                                exp = s_max( exp, sub( exp_powerSpec64[ch][1], W_norm_arr( powerSpec64[ch] + length, length ) ) );
                            }
                            FOR( n1 = 0; n1 < nsub; n1++ )
                            {
                                shift1 = sub( sub( exp_powerSpec64[ch][n1], exp ), 32 );
                                FOR( i = 0; i < length; i++ )
                                {
                                    /* This doesn't result in saturation */
                                    powerSpec_fx[ch][i + n1 * length] = W_shl_sat_l( powerSpec64[ch][i + n1 * length], shift1 ); // exp: exp
                                    move32();
                                }
                            }
                            set32_fx( powerSpec_fx[ch] + length, 0, sub( N_MAX, length ) );
                            q_powSpec[ch] = sub( 31, exp ); // exp: exp
                            move16();
                        }
                    }
                    hIGFEnc[0] = sts[0]->hIGFEnc;
                    hIGFEnc[1] = sts[1]->hIGFEnc;

                    FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
                    {
                        q_spec = sub( Q31, sts[ch]->hTcxEnc->spectrum_e[n] );
                        Word16 q_comm = s_min( sub( Q31, sts[ch]->hTcxEnc->spectrum_e[n] ), s_min( q_powSpec[ch], q_powSpecMsInv[ch] ) );
                        Word16 n_sb = NB_DIV;
                        move16();
                        if ( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
                        {
                            n_sb = 1;
                            move16();
                        }
                        length = idiv1616( sts[ch]->hTcxEnc->L_frameTCX, n_sb ); /* Q0 */
                        IF( NE_16( q_spec, q_comm ) )
                        {
                            Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[n], length, sub( q_comm, q_spec ) ); /* q_powSpec */
                            Scale_sig32( inv_spectrum_fx[ch][n], length, sub( q_comm, q_spec ) );           /* q_powSpec */
                            sts[ch]->hTcxEnc->spectrum_e[n] = sub( Q31, q_comm );
                            move16();
                        }
                        IF( NE_16( q_powSpec[ch], q_comm ) )
                        {
                            Scale_sig32( &p_powerSpec_fx[ch][0], L_subframeTCX, sub( q_comm, q_powSpec[ch] ) ); /* q_spec */
                            q_powSpec[ch] = q_comm;
                            move16();
                        }
                        IF( NE_16( q_powSpecMsInv[ch], q_comm ) )
                        {
                            Scale_sig32( powerSpecMsInv_fx[ch][0], L_subframeTCX, sub( q_comm, q_powSpecMsInv[ch] ) ); /* q_spec */
                            q_powSpecMsInv[ch] = q_comm;
                            move16();
                        }
                    }
                    hIGFEnc[0]->spec_be_igf_e = p_orig_spectrum_e[0];
                    move16();
                    hIGFEnc[1]->spec_be_igf_e = p_orig_spectrum_e[1];
                    move16();
                    ProcessStereoIGF_fx( hStereoMdct, sts, ms_mask, orig_spectrum_fx, sub( Q31, p_orig_spectrum_e[0] ), sub( Q31, p_orig_spectrum_e[1] ),
                                         p_powerSpec_fx, powerSpecMsInv_fx, inv_spectrum_fx, 
                                         n, hCPE->hCoreCoder[0]->sp_aud_decision0, hCPE->hCoreCoder[0]->element_brate, 0 );

#else
                    Word32 powerSpec_fx[CPE_CHANNELS][N_MAX], *p_powerSpec_fx[CPE_CHANNELS];
                    Word16 exp_powSpec[CPE_CHANNELS];
                    p_powerSpec_fx[0] = powerSpec_fx[0];
@@ -869,7 +778,6 @@ void stereo_mdct_core_enc_fx(
                    ProcessStereoIGF_fx( hStereoMdct, sts, ms_mask, orig_spectrum_fx, sub( Q31, p_orig_spectrum_e[0] ), sub( Q31, p_orig_spectrum_e[1] ),
                                         p_powerSpec_fx, exp_powSpec, powerSpecMsInv_fx, exp_powSpecMsInv, inv_spectrum_fx, exp_inv_spectrum,
                                         n, hCPE->hCoreCoder[0]->sp_aud_decision0, hCPE->hCoreCoder[0]->element_brate, 0 );
#endif
                }
                ELSE
                {