Commit 03845cc8 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Removed the dependency of common exp for mdst_spectrum_fx and spectrum_fx,...

Removed the dependency of common exp for mdst_spectrum_fx and spectrum_fx, fb_tbe_enc exponent correction
parent 291c48d3
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2711,7 +2711,8 @@ void stereo_coder_tcx_fx(
    Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV],      /* i/o: inverse spectrum                */
    Word32 *inv_mdst_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum           */
    const Word16 mct_on,                                /* i  : flag mct block (1) or stereo (0)  */
    Word16 q_spec );
    Word16 exp_spec,
    Word16 exp_mdst_spec );

// bw_detect_fx.c
Word16 set_bw_mct_fx(
+1 −1
Original line number Diff line number Diff line
@@ -744,7 +744,7 @@ ivas_error ivas_core_enc_fx(
                IF( EQ_16( st->extl, FB_TBE ) )
                {
                    /* FB TBE encoder */
                    fb_tbe_enc_ivas_fx( st, st->input_fx, fb_exc_fx, Q_fb_exc );
                    fb_tbe_enc_ivas_fx( st, st->input_fx, fb_exc_fx, Q_fb_exc, st->q_inp );
                }
            }
        }
+6 −2
Original line number Diff line number Diff line
@@ -385,7 +385,7 @@ static void getBlockValues_fx(
    p_st[0] = sts[ch1];
    p_st[1] = sts[ch2];

    stereo_coder_tcx_fx( hBlock->hStereoMdct, p_st, hBlock->mask, p_mdst_spectrum, p_inv_spectrum, p_inv_mdst_spectrum, 1, q_spec );
    stereo_coder_tcx_fx( hBlock->hStereoMdct, p_st, hBlock->mask, p_mdst_spectrum, p_inv_spectrum, p_inv_mdst_spectrum, 1, sub( 31, q_spec ), sub( 31, q_spec ) );

    test();
    test();
@@ -1073,6 +1073,7 @@ void mctStereoIGF_enc_fx(
                EQ_16( hMCT->hBlockData[b]->hStereoMdct->mdct_stereo_mode[n], SMDCT_BW_MS ) )
            {
                Word16 exp_powerSpec_tmp[CPE_CHANNELS];
                Word16 exp_p_inv_spectrum[CPE_CHANNELS];
                FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
                {
                    s = s_min( s, sub( 31, p_st[ch]->hTcxEnc->spectrum_e[n] ) );
@@ -1097,10 +1098,13 @@ void mctStereoIGF_enc_fx(
                }
                exp_powerSpec_tmp[0] = p_st[0]->hTcxEnc->spectrum_e[0];
                exp_powerSpec_tmp[1] = p_st[1]->hTcxEnc->spectrum_e[0];
                exp_p_inv_spectrum[0] = exp_p_inv_spectrum[1] = p_st[0]->hTcxEnc->spectrum_e[0];
                move16();
                move16();
                move16();
                move16();
                ProcessStereoIGF_fx( hMCT->hBlockData[b]->hStereoMdct, p_st, hMCT->hBlockData[b]->mask, p_orig_spectrum_fx, q_origSpec, q_origSpec, p_powerSpec_fx, exp_powerSpec_tmp,
                                     p_powerSpecMsInv_fx, exp_powerSpec_tmp, p_inv_spectrum_fx, exp_powerSpec_tmp, n, sp_aud_decision0[ch1], p_st[0]->total_brate, 1 );
                                     p_powerSpecMsInv_fx, exp_powerSpec_tmp, p_inv_spectrum_fx, exp_p_inv_spectrum, n, sp_aud_decision0[ch1], p_st[0]->total_brate, 1 );
            }
            ELSE
            {
+66 −74
Original line number Diff line number Diff line
@@ -152,8 +152,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 exp_powSpecMsInv[MCT_MAX_CHANNELS], q_spec, tmp_s;
    Word16 tmp_q_powSpecInv[N_MAX], *tmp_q_psi[2];
    Word16 exp_powSpecMsInv[MCT_MAX_CHANNELS];
    Word16 tmp_q_powSpecInv[N_MAX], *exp_powSpecInv[2];
    Word64 W_tmp;
    Encoder_State *st, **sts;
    STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct;
@@ -188,8 +188,8 @@ void stereo_mdct_core_enc_fx(

    set16_fx( tmp_q_powSpecInv, 63, N_MAX );

    tmp_q_psi[0] = tmp_q_powSpecInv;
    tmp_q_psi[1] = &tmp_q_powSpecInv[N_TCX10_MAX];
    exp_powSpecInv[0] = tmp_q_powSpecInv;
    exp_powSpecInv[1] = &tmp_q_powSpecInv[N_TCX10_MAX];

    sts = hCPE->hCoreCoder;
    hStereoMdct = hCPE->hStereoMdct;
@@ -343,61 +343,59 @@ void stereo_mdct_core_enc_fx(
    IF( !hStereoMdct->isSBAStereoMode )
    {
        /* Common q for mdst_spectrum and spectrum */
        Word16 k;
        q_spec = 0;
        Word16 exp1, exp2;
        Word16 length;
        FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
        {
            FOR( k = 0; k <= ( ( sts[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ )
            {
                q_spec = s_max( q_spec, sts[ch]->hTcxEnc->spectrum_e[k] );
                q_spec = s_max( q_spec, mdst_spectrum_e[ch][k] );
            }
        }
        q_spec = sub( Q31, q_spec );

        /*find headroom to increase precision*/
        Word16 hdrm_min = MAX_16;
        exp1 = MIN_16;
        exp2 = MIN_16;
        move16();
        move16();
        FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
        {
            length = sts[ch]->hTcxEnc->spectrum_length;
            move16();
            IF( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
            if ( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
            {
                length = shr( length, 1 );
            }

            hdrm_min = s_min( hdrm_min, L_norm_arr( sts[ch]->hTcxEnc->spectrum_fx[0], length ) );
            hdrm_min = s_min( hdrm_min, L_norm_arr( mdst_spectrum_fx[ch][0], length ) );
            exp1 = s_max( exp1, sub( sts[ch]->hTcxEnc->spectrum_e[0], L_norm_arr( sts[ch]->hTcxEnc->spectrum_fx[0], length ) ) );
            exp2 = s_max( exp2, sub( mdst_spectrum_e[ch][0], L_norm_arr( mdst_spectrum_fx[ch][0], length ) ) );

            IF( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
            {
                hdrm_min = s_min( hdrm_min, L_norm_arr( sts[ch]->hTcxEnc->spectrum_fx[1], length ) );
                hdrm_min = s_min( hdrm_min, L_norm_arr( mdst_spectrum_fx[ch][1], length ) );
                exp1 = s_max( exp1, sub( sts[ch]->hTcxEnc->spectrum_e[1], L_norm_arr( sts[ch]->hTcxEnc->spectrum_fx[1], length ) ) );
                exp2 = s_max( exp2, sub( mdst_spectrum_e[ch][1], L_norm_arr( mdst_spectrum_fx[ch][1], length ) ) );
            }
        }

        q_spec = sub( add( hdrm_min, q_spec ), 1 ); /* 1 guard bit to avoid over-flows in stereo_coder_tcx_fx */
        exp1 = add( exp1, 1 ); /* 1 guard bit to avoid over-flows in stereo_coder_tcx_fx */
        exp2 = add( exp2, 1 ); /* 1 guard bit to avoid over-flows in stereo_coder_tcx_fx */

        FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
        {
            length = sts[ch]->hTcxEnc->spectrum_length;
            move16();
            IF( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
            if ( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
            {
                length = shr( length, 1 );
            }
            FOR( k = 0; k <= ( ( sts[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ )

            scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[0], length, sub( sts[ch]->hTcxEnc->spectrum_e[0], exp1 ) ); /* exp1 */
            sts[ch]->hTcxEnc->spectrum_e[0] = exp1;
            scale_sig32( mdst_spectrum_fx[ch][0], length, sub( mdst_spectrum_e[ch][0], exp2 ) ); /* exp2 */
            mdst_spectrum_e[ch][0] = exp2;
            IF( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
            {
                Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[k], length, sub( q_spec, sub( Q31, sts[ch]->hTcxEnc->spectrum_e[k] ) ) ); /* q_spec */
                sts[ch]->hTcxEnc->spectrum_e[k] = sub( Q31, q_spec );
                Scale_sig32( mdst_spectrum_fx[ch][k], length, sub( q_spec, sub( Q31, mdst_spectrum_e[ch][k] ) ) ); /* q_spec */
                mdst_spectrum_e[ch][k] = sub( Q31, q_spec );
                scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[1], length, sub( sts[ch]->hTcxEnc->spectrum_e[1], exp1 ) ); /* exp1 */
                sts[ch]->hTcxEnc->spectrum_e[1] = exp1;
                scale_sig32( mdst_spectrum_fx[ch][1], length, sub( mdst_spectrum_e[ch][1], exp2 ) ); /* exp2 */
                mdst_spectrum_e[ch][1] = exp2;
            }
        }
        stereo_coder_tcx_fx( hStereoMdct, sts, ms_mask, mdst_spectrum_fx, inv_spectrum_fx, inv_mdst_spectrum_fx, 0, q_spec );
        exp_inv_spectrum[0] = exp_inv_spectrum[1] = sub( Q31, q_spec );
        stereo_coder_tcx_fx( hStereoMdct, sts, ms_mask, mdst_spectrum_fx, inv_spectrum_fx, inv_mdst_spectrum_fx, 0, sts[0]->hTcxEnc->spectrum_e[0], mdst_spectrum_e[0][0] );
        exp_inv_spectrum[0] = exp_inv_spectrum[1] = sts[0]->hTcxEnc->spectrum_e[0];
        move16();
        move16();
    }
@@ -406,10 +404,13 @@ void stereo_mdct_core_enc_fx(
     * Power spectrum calculation
     *---------------------------------------------------------------*/
    Word16 length, exp, shift1, shift2, norm;
    Word32 mdct, mdst;
    Word32 mdct, mdst, imdct, imdst;

    FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
    {
        L_subframeTCX = shr( sts[ch]->hTcxEnc->L_frameTCX, 1 ); /* Q0 */
        nSubframes = NB_DIV;
        move16();
        IF( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) )
        {
            nSubframes = 1;
@@ -417,12 +418,6 @@ void stereo_mdct_core_enc_fx(
            move16();
            move16();
        }
        ELSE
        {
            nSubframes = NB_DIV;
            move16();
            L_subframeTCX = shr( sts[ch]->hTcxEnc->L_frameTCX, 1 ); /* Q0 */
        }

        /* in MCT only relevant for bitrate switching from non-MCT bitrates */
        IF( EQ_16( sts[ch]->last_core, ACELP_CORE ) )
@@ -432,8 +427,6 @@ void stereo_mdct_core_enc_fx(

        FOR( n = 0; n < nSubframes; n++ )
        {
            q_spec = sub( 31, sts[ch]->hTcxEnc->spectrum_e[n] );

            IF( sts[ch]->hTcxEnc->tns_ms_flag[n] )
            {
                exp = add( s_max( mdst_spectrum_e[ch][n], sts[ch]->hTcxEnc->spectrum_e[n] ), 1 );
@@ -443,16 +436,18 @@ void stereo_mdct_core_enc_fx(
                /* power spectrum: MDCT^2 + MDST^2 */
                FOR( i = 0; i < L_subframeTCX; i++ )
                {
                    W_tmp = W_mac_32_32( W_mult_32_32( inv_mdst_spectrum_fx[ch][n][i], inv_mdst_spectrum_fx[ch][n][i] ), inv_spectrum_fx[ch][n][i], inv_spectrum_fx[ch][n][i] ); /* 2*q_spec+1 */
                    tmp_s = W_norm( W_tmp );
                    W_tmp = W_shl( W_tmp, tmp_s );                                     /* 2*q_spec+1+tmp_s */
                    powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_tmp );                /* 2*q_spec+1+tmp_s-32 */
                    tmp_q_psi[n][i] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
                    mdst = L_shl( mdst_spectrum_fx[ch][n][i], shift1 );          // exp: exp
                    mdct = L_shl( sts[ch]->hTcxEnc->spectrum_fx[n][i], shift2 ); // exp: exp
                    imdst = L_shl( inv_mdst_spectrum_fx[ch][n][i], shift1 );    // exp: exp
                    imdct = L_shl( inv_spectrum_fx[ch][n][i], shift2 );         // exp: exp

                    W_tmp = W_mac_32_32( W_mult_32_32( imdct, imdct ), imdst, imdst ); // exp: 2*exp
                    norm = W_norm( W_tmp );
                    powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_shl( W_tmp, norm ) ); // exp: 2*exp-norm
                    exp_powSpecInv[n][i] = sub( shl( exp, 1 ), norm );
                    move32();
                    move16();

                    mdst = L_shl( mdst_spectrum_fx[ch][n][i], shift1 );                                             // exp: exp
                    mdct = L_shl( sts[ch]->hTcxEnc->spectrum_fx[n][i], shift2 );                                    // exp: exp
                    powerSpec64[ch][i + n * L_subframeTCX] = W_mac_32_32( W_mult_32_32( mdct, mdct ), mdst, mdst ); // exp: 2*exp
                    move64();
                }
@@ -464,32 +459,28 @@ void stereo_mdct_core_enc_fx(
                IF( NE_16( hStereoMdct->mdct_stereo_mode[n], SMDCT_DUAL_MONO ) )
                {
                    /* power spectrum: MDCT^2 + MDST^2 */
                    W_tmp = W_mult_32_32( inv_spectrum_fx[ch][n][0], inv_spectrum_fx[ch][n][0] ); /* 2*q_spec+1 */
                    tmp_s = W_norm( W_tmp );
                    W_tmp = W_shl( W_tmp, tmp_s );                                     /* 2*q_spec+1+tmp_s */
                    powerSpecMsInv_fx[ch][n][0] = W_extract_h( W_tmp );                /* 2*q_spec+1+tmp_s-32 */
                    tmp_q_psi[n][0] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
                    W_tmp = W_mult_32_32( inv_spectrum_fx[ch][n][0], inv_spectrum_fx[ch][n][0] ); // exp: 2*sts[ch]->hTcxEnc->spectrum_e[n]
                    norm = W_norm( W_tmp );
                    powerSpecMsInv_fx[ch][n][0] = W_extract_h( W_shl( W_tmp, norm ) ); // exp: 2*sts[ch]->hTcxEnc->spectrum_e[n]-norm
                    exp_powSpecInv[n][0] = sub( shl( sts[ch]->hTcxEnc->spectrum_e[n], 1 ), norm );
                    move32();
                    move16();

                    FOR( i = 1; i < L_subframeTCX - 1; i++ )
                    {
                        Word32 mdst_fx = L_sub( inv_spectrum_fx[ch][n][i + 1], inv_spectrum_fx[ch][n][i - 1] ); /* An MDST estimate q_spec*/

                        W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), inv_spectrum_fx[ch][n][i], inv_spectrum_fx[ch][n][i] ); /* 2*q_spec+1 */
                        tmp_s = W_norm( W_tmp );
                        W_tmp = W_shl( W_tmp, tmp_s );                                     /* 2*q_spec+1+tmp_s */
                        powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_tmp );                /* 2*q_spec+1+tmp_s-32 */
                        tmp_q_psi[n][i] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
                        Word32 mdst_fx = L_sub( inv_spectrum_fx[ch][n][i + 1], inv_spectrum_fx[ch][n][i - 1] );                        // exp: sts[ch]->hTcxEnc->spectrum_e[n]
                        W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), inv_spectrum_fx[ch][n][i], inv_spectrum_fx[ch][n][i] ); // exp: 2*sts[ch]->hTcxEnc->spectrum_e[n]
                        norm = W_norm( W_tmp );
                        powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_shl( W_tmp, norm ) ); // exp: 2*sts[ch]->hTcxEnc->spectrum_e[n]-norm
                        exp_powSpecInv[n][i] = sub( shl( sts[ch]->hTcxEnc->spectrum_e[n], 1 ), norm );
                        move32();
                        move16();
                    }

                    W_tmp = W_mult_32_32( inv_spectrum_fx[ch][n][L_subframeTCX - 1], inv_spectrum_fx[ch][n][L_subframeTCX - 1] ); /* 2*q_spec+1 */
                    tmp_s = W_norm( W_tmp );
                    W_tmp = W_shl( W_tmp, tmp_s );                                                     /* 2*q_spec+1+tmp_s */
                    powerSpecMsInv_fx[ch][n][L_subframeTCX - 1] = W_extract_h( W_tmp );                /* 2*q_spec+1+tmp_s-32 */
                    tmp_q_psi[n][L_subframeTCX - 1] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32
                    W_tmp = W_mult_32_32( inv_spectrum_fx[ch][n][L_subframeTCX - 1], inv_spectrum_fx[ch][n][L_subframeTCX - 1] ); // exp: 2*sts[ch]->hTcxEnc->spectrum_e[n]
                    norm = W_norm( W_tmp );
                    powerSpecMsInv_fx[ch][n][L_subframeTCX - 1] = W_extract_h( W_shl( W_tmp, norm ) ); // exp: 2*sts[ch]->hTcxEnc->spectrum_e[n]-norm
                    exp_powSpecInv[n][L_subframeTCX - 1] = sub( shl( sts[ch]->hTcxEnc->spectrum_e[n], 1 ), norm );
                    move32();
                    move16();
                }
@@ -517,8 +508,7 @@ void stereo_mdct_core_enc_fx(
        }

        /* Aligning the Q-factors */
        {
            Word16 q_temp = Q31;
        exp = MIN_16;
        move16();
        FOR( n = 0; n < nSubframes; n++ )
        {
@@ -526,21 +516,23 @@ void stereo_mdct_core_enc_fx(
            {
                if ( powerSpecMsInv_fx[ch][n][i] != 0 )
                {
                        q_temp = s_min( q_temp, tmp_q_psi[n][i] );
                    exp = s_max( exp, exp_powSpecInv[n][i] );
                }
            }
        }
        IF( NE_16( exp, MIN_16 ) )
        {
            FOR( n = 0; n < nSubframes; n++ )
            {
                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_temp ) );
                    powerSpecMsInv_fx[ch][n][i] = L_shl( powerSpecMsInv_fx[ch][n][i], sub( exp_powSpecInv[n][i], exp ) );
                    move32();
                }
            }
            exp_powSpecMsInv[ch] = sub( Q31, q_temp );
            move16();
        }
        exp_powSpecMsInv[ch] = exp;
        move16();
    }

    FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
+21 −18
Original line number Diff line number Diff line
@@ -190,7 +190,8 @@ void stereo_coder_tcx_fx(
    Word32 *inv_mdst_spectrum_fx[CPE_CHANNELS][NB_DIV],
    /* i/o: inverse MDST spectrum           */ // Q( q_spec ) (same as spectrum buffer in hTcxEnc)
    const Word16 mct_on,                       /* i  : flag mct block (1) or stereo (0)  Q0*/
    Word16 q_spec )
    Word16 exp_spec,
    Word16 exp_mdct_spec )
{
    STEREO_MDCT_BAND_PARAMETERS *sfbConf = NULL;
    Word32 nrgRatio_fx[CPE_CHANNELS];
@@ -255,8 +256,8 @@ void stereo_coder_tcx_fx(
                tmp = Inv16( extract_h( nrgRatio_fx[k] ), &e_tmp ); /* Q15-e_tmp */
                tmp = shl( tmp, e_tmp );                            /* Q15 */

                v_multc_fixed_16( sts[1]->hTcxEnc->spectrum_fx[k], tmp, sts[1]->hTcxEnc->spectrum_fx[k], L_frameTCX ); /* Q31-spectrum_e[k] */
                v_multc_fixed_16( mdst_spectrum_fx[1][k], tmp, mdst_spectrum_fx[1][k], L_frameTCX );                   /* q_spec */
                v_multc_fixed_16( sts[1]->hTcxEnc->spectrum_fx[k], tmp, sts[1]->hTcxEnc->spectrum_fx[k], L_frameTCX ); /* exp: exp_spec */
                v_multc_fixed_16( mdst_spectrum_fx[1][k], tmp, mdst_spectrum_fx[1][k], L_frameTCX );                   /* exp: exp_mdct_spec */
            }
            ELSE IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( nrgRatio_fx[k], nrgRatio_e[k], ONE_IN_Q27, 4 ), -1 ) && LT_16( k, EQ_16( sts[0]->core, TCX_20_CORE ) ? 1 : NB_DIV ) )
            {
@@ -264,8 +265,8 @@ void stereo_coder_tcx_fx(
                L_frameTCX = idiv1616( L_frameTCX, ( sts[0]->core == TCX_20_CORE ) ? 1 : NB_DIV );                                          /* Q0 */

                /* This operation is resulting in some high MLDs in fixed point. */
                v_multc_fixed_16( sts[0]->hTcxEnc->spectrum_fx[k], extract_l( L_shr( nrgRatio_fx[k], 16 - nrgRatio_e[k] ) ), sts[0]->hTcxEnc->spectrum_fx[k], L_frameTCX ); /* Q31-spectrum_e[k] */
                v_multc_fixed_16( mdst_spectrum_fx[0][k], extract_l( L_shr( nrgRatio_fx[k], 16 - nrgRatio_e[k] ) ), mdst_spectrum_fx[0][k], L_frameTCX );                   /* q_spec */
                v_multc_fixed_16( sts[0]->hTcxEnc->spectrum_fx[k], extract_l( L_shr( nrgRatio_fx[k], 16 - nrgRatio_e[k] ) ), sts[0]->hTcxEnc->spectrum_fx[k], L_frameTCX ); /* exp: exp_spec */
                v_multc_fixed_16( mdst_spectrum_fx[0][k], extract_l( L_shr( nrgRatio_fx[k], 16 - nrgRatio_e[k] ) ), mdst_spectrum_fx[0][k], L_frameTCX );                   /* exp: exp_mdct_spec */
            }
        }
    }
@@ -356,7 +357,7 @@ void stereo_coder_tcx_fx(
                    move16();
                    const Word16 sfbWidth = sub( endLine, startLine );

                    nrgRatio_e[0] = nrgRatio_e[1] = sub( Q31, q_spec );
                    nrgRatio_e[0] = nrgRatio_e[1] = exp_spec;
                    move16();
                    move16();

@@ -370,10 +371,12 @@ void stereo_coder_tcx_fx(
                    {
                        Word32 tmp_fx;
                        Word16 tmp_e;
                        tmp_e = sub( Q31, q_spec );
                        tmp_e = exp_mdct_spec;
                        move16();
                        tmp_fx = sum2_32_fx( &mdst_spectrum_fx[0][k][startLine], sfbWidth, &tmp_e );                               /* Q31-tmp_e */
                        nrgRatio_fx[0] = BASOP_Util_Add_Mant32Exp( nrgRatio_fx[0], nrgRatio_e[0], tmp_fx, tmp_e, &nrgRatio_e[0] ); /* Q31-nrgRatio_e[0] */
                        tmp_e = sub( Q31, q_spec );
                        tmp_e = exp_mdct_spec;
                        move16();
                        tmp_fx = sum2_32_fx( &mdst_spectrum_fx[1][k][startLine], sfbWidth, &tmp_e );                               /* Q31-tmp_e */
                        nrgRatio_fx[1] = BASOP_Util_Add_Mant32Exp( nrgRatio_fx[1], nrgRatio_e[1], tmp_fx, tmp_e, &nrgRatio_e[1] ); /* Q31-nrgRatio_e[1] */
                    }
@@ -426,15 +429,15 @@ void stereo_coder_tcx_fx(
                        move32();


                        v_multc_fixed( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[0], &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth ); /* q_spec+30-31 */
                        v_multc_fixed( &mdst_spectrum_fx[0][k][startLine], nrgRatio_fx[0], &mdst_spectrum_fx[0][k][startLine], sfbWidth );                   /* q_spec+30-31 */
                        scale_sig32( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 );                                                            // Scaling back to q_spec
                        scale_sig32( &mdst_spectrum_fx[0][k][startLine], sfbWidth, Q1 );                                                                     // Scaling back to q_spec
                        v_multc_fixed( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[0], &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth ); /* exp: exp_spec+1 */
                        v_multc_fixed( &mdst_spectrum_fx[0][k][startLine], nrgRatio_fx[0], &mdst_spectrum_fx[0][k][startLine], sfbWidth );                   /* exp: exp_mdct_spec+1 */
                        scale_sig32( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 );                                                            // exp: exp_spec
                        scale_sig32( &mdst_spectrum_fx[0][k][startLine], sfbWidth, Q1 );                                                                     // exp: exp_mdct_spec

                        v_multc_fixed( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[1], &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth ); /* q_spec+30-31 */
                        v_multc_fixed( &mdst_spectrum_fx[1][k][startLine], nrgRatio_fx[1], &mdst_spectrum_fx[1][k][startLine], sfbWidth );                   /* q_spec+30-31 */
                        scale_sig32( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 );                                                            // Scaling back to q_spec
                        scale_sig32( &mdst_spectrum_fx[1][k][startLine], sfbWidth, Q1 );                                                                     // Scaling back to q_spec
                        v_multc_fixed( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[1], &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth ); /* exp: exp_spec+1 */
                        v_multc_fixed( &mdst_spectrum_fx[1][k][startLine], nrgRatio_fx[1], &mdst_spectrum_fx[1][k][startLine], sfbWidth );                   /* exp: exp_mdct_spec+1 */
                        scale_sig32( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 );                                                            // exp: exp_spec
                        scale_sig32( &mdst_spectrum_fx[1][k][startLine], sfbWidth, Q1 );                                                                     // exp: exp_mdct_spec
                    }
                }
            }
@@ -469,11 +472,11 @@ void stereo_coder_tcx_fx(
            nAvailBitsMS[k] = idiv1616( nAvailBitsMS[k], nSubframes ); /* Q0 */
            move16();

            MsStereoDecision_fx( sfbConf, sts[0]->hTcxEnc->spectrum_fx[k], sts[1]->hTcxEnc->spectrum_fx[k], inv_spectrum_fx[0][k], inv_spectrum_fx[1][k], q_spec, &hStereoMdct->mdct_stereo_mode[k], &ms_mask[k][0], nAvailBitsMS[k] );
            MsStereoDecision_fx( sfbConf, sts[0]->hTcxEnc->spectrum_fx[k], sts[1]->hTcxEnc->spectrum_fx[k], inv_spectrum_fx[0][k], inv_spectrum_fx[1][k], sub( Q31, exp_spec ), &hStereoMdct->mdct_stereo_mode[k], &ms_mask[k][0], nAvailBitsMS[k] );

            IF( sts[0]->igf )
            {
                IGFEncStereoEncoder_fx( sfbConf, sts[0]->hIGFEnc, sts[0]->hTcxEnc->spectrum_fx[k], sts[1]->hTcxEnc->spectrum_fx[k], q_spec, &ms_mask[k][0],
                IGFEncStereoEncoder_fx( sfbConf, sts[0]->hIGFEnc, sts[0]->hTcxEnc->spectrum_fx[k], sts[1]->hTcxEnc->spectrum_fx[k], sub( Q31, exp_spec ), &ms_mask[k][0],
                                        &hStereoMdct->IGFStereoMode[k], hStereoMdct->mdct_stereo_mode[k], (Word16) EQ_16( sts[0]->core, TCX_20_CORE ), (Word16) EQ_16( sts[0]->last_core, ACELP_CORE ) );
            }
            ELSE
Loading