Commit f0ed4cb9 authored by multrus's avatar multrus
Browse files

take several review comments into account

parent 36c1cd94
Loading
Loading
Loading
Loading
+17 −19
Original line number Diff line number Diff line
@@ -690,9 +690,9 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs(
    Word16 i;
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    Word32 hb_nrg = EPSILON_FIX;
    Word16 q_hb_nrg_subr = Q31 + Q15 - Q6; /* in case IF( ( EQ_16( core, ACELP_CORE ) && !fd_cng_flag ) || EQ_16( hStereoDft->core_hist[1], ACELP_CORE ) ) is false, we want to end up with Q31, and we subtract Q15 - Q6 below; otherwise, we set it within this condition */
    Word16 q_hb_nrg = Q31;
    Word32 max_val;
    Word16 shift;
    Word16 shift, shift_hb_nrg_subr;
    move32();
#else
    Word32 hb_nrg = EPSILON_FIX;
@@ -712,38 +712,34 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs(
    {
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
        Word32 L_tmp;
        Word16 tmp;
        Word64 W_tmp;

        tmp = shl_sat( 1, shift );

        W_tmp = EPSILON_FIX;
        move64();

        FOR( i = 0; i < shr( output_frame, 1 ); i++ )
        {
            // needed to be adjusted for q
            L_tmp = Mpy_32_16_1( hb_synth[i], tmp );    /* q_hb_synth + shift - 15 */
            W_tmp = W_mac_32_32( W_tmp, L_tmp, L_tmp ); /* 2 * (q_hb_synth + shift) - 29 */
            L_tmp = L_shl( hb_synth[i], shift );        /* q_hb_synth + shift */
            W_tmp = W_mac_32_32( W_tmp, L_tmp, L_tmp ); /* 2 * (q_hb_synth + shift) + 1 */
        }

        hStereoDft->hb_nrg_subr_fx[0] = W_round48_L( W_tmp ); /* 2 * (q_hb_synth + shift) - 45 */
        hStereoDft->hb_nrg_subr_fx[0] = W_round48_L( W_shr( W_tmp, 16 ) ); /* 2 * (q_hb_synth + shift) - 31 */
        move32();

        W_tmp = EPSILON_FIX;
        move64();
        FOR( ; i < output_frame; i++ )
        {
            L_tmp = Mpy_32_16_1( hb_synth[i], tmp );    /* q_hb_synth + shift - 15 */
            W_tmp = W_mac_32_32( W_tmp, L_tmp, L_tmp ); /* 2 * (q_hb_synth + shift) - 45 */
            L_tmp = L_shl( hb_synth[i], shift );        /* q_hb_synth + shift */
            W_tmp = W_mac_32_32( W_tmp, L_tmp, L_tmp ); /* 2 * (q_hb_synth + shift) + 1 */
        }

        hStereoDft->hb_nrg_subr_fx[1] = W_round48_L( W_tmp ); // 2 * (q_hb_synth + shift) - 45
        hStereoDft->hb_nrg_subr_fx[1] = W_round48_L( W_shr( W_tmp, 16 ) ); /* 2 * (q_hb_synth + shift) - 31 */
        move32();
        hStereoDft->q_hb_nrg_subr = sub( shl( add( q_hb_synth, shift ), 1 ), 45 );
        move16();
        q_hb_nrg_subr = sub( shl( add( q_hb_synth, shift ), 1 ), 31 );

        hb_nrg = L_add( hStereoDft->hb_nrg_subr_fx[0], hStereoDft->hb_nrg_subr_fx[1] ); // 2 * (q_hb_synth + shift) - 45
        q_hb_nrg = hStereoDft->q_hb_nrg_subr;
        hb_nrg = L_add( L_shr( hStereoDft->hb_nrg_subr_fx[0], 1 ), L_shr( hStereoDft->hb_nrg_subr_fx[1], 1 ) ); /* 2 * (q_hb_synth + shift) - 16 - 1 */
        q_hb_nrg = sub( q_hb_nrg_subr, 1 );
        move16();
#else
        FOR( i = 0; i < shr( output_frame, 2 ); i++ )
@@ -798,11 +794,13 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs(
        move32();
    }
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    hStereoDft->hb_nrg_subr_fx[0] = ( Mpy_32_16_1( hStereoDft->hb_nrg_subr_fx[0], shl( shr( hStereoDft->NFFT, 1 ), 6 ) ) ); // 2 * (q_hb_synth + shift) - 40
    shift_hb_nrg_subr = s_min( norm_l( hStereoDft->hb_nrg_subr_fx[0] ), norm_l( hStereoDft->hb_nrg_subr_fx[1] ) );

    hStereoDft->hb_nrg_subr_fx[0] = ( Mpy_32_16_1( L_shl( hStereoDft->hb_nrg_subr_fx[0], shift_hb_nrg_subr ), shl( hStereoDft->NFFT, 5 ) ) ); /* shl( ., 5) is shortcut for shl( shr( hStereoDft->NFFT, 1 ), 6 ) */ /* q_hb_nrg_subr - (15 - 6) */
    move32();
    hStereoDft->hb_nrg_subr_fx[1] = ( Mpy_32_16_1( hStereoDft->hb_nrg_subr_fx[1], shl( shr( hStereoDft->NFFT, 1 ), 6 ) ) ); // 2 * (q_hb_synth + shift) - 40
    hStereoDft->hb_nrg_subr_fx[1] = ( Mpy_32_16_1( L_shl( hStereoDft->hb_nrg_subr_fx[1], shift_hb_nrg_subr ), shl( hStereoDft->NFFT, 5 ) ) ); /* shl( ., 5) is shortcut for shl( shr( hStereoDft->NFFT, 1 ), 6 ) */ /* q_hb_nrg_subr - (15 - 6) */
    move32();
    hStereoDft->q_hb_nrg_subr = sub( shl( ( q_hb_synth + shift ), 1 ), 45 + 9 );
    hStereoDft->q_hb_nrg_subr = sub( add( q_hb_nrg_subr, shift_hb_nrg_subr ), Q15 - Q6 );
    hStereoDft->hb_nrg_fx[0] = hb_nrg;
    move32();
    hStereoDft->q_hb_nrg[0] = q_hb_nrg;
+51 −7
Original line number Diff line number Diff line
@@ -138,7 +138,11 @@ void stereo_icBWE_dec_fx(
    Word16 nlMixFac_fx[NB_SUBFR16k];
    Word16 specMapping_fx;
    Word16 fb_synth_nonref_fx[L_FRAME48k];
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    Word32 prev_pow_fx, curr_pow_fx, maxVal1;
#else
    Word32 prev_pow_fx, curr_pow_fx, maxVal1, maxVal;
#endif
    Word16 scale_fx, e_scale_fx;
    Word16 alpha_fx, winSlope_fx, winLen_fx;
    Word16 prevgsMapping_fx;
@@ -147,7 +151,8 @@ void stereo_icBWE_dec_fx(
    Word16 gsMapping_fx;
    Word32 hb_nrg_fx;
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    Word16 q_hb_nrg;
    Word16 q_hb_nrg, q_hb_nrg_subr;
    Word16 shift_hb_nrg_subr;
#endif
    Word16 Q_syn_shb;
    Word16 shift_prev_pow, synthRef_shift;
@@ -200,6 +205,10 @@ void stereo_icBWE_dec_fx(
    /* update buffers for TD stereo filling */
    IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
    {
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
        q_hb_nrg_subr = Q31 + Q15 - Q6; /* in case IF( EQ_16( st->core, ACELP_CORE ) || EQ_16( st->last_core, ACELP_CORE ) ) is flase, we want to end up with Q31, and we subtract Q15 - Q6 below;  otherwise, we set it within this condition */
        move16();
#endif
        hb_nrg_fx = 0;
        move32();
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
@@ -220,6 +229,34 @@ void stereo_icBWE_dec_fx(
        test();
        IF( EQ_16( st->core, ACELP_CORE ) || EQ_16( st->last_core, ACELP_CORE ) )
        {
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
            Word64 W_tmp = EPSILON_FIX;
            move64();

            FOR( i = 0; i < shr( output_frame, 1 ); i++ )
            {
                L_tmp = L_shl( synthRef_fx[i], synthRef_shift ); /* Qsyn + SynthRef_shift */
                W_tmp = W_mac_32_32( W_tmp, L_tmp, L_tmp );      /* 2 * (Qsyn + SynthRef_shift) + 1 */
            }
            hCPE->hStereoDft->hb_nrg_subr_fx[0] = W_round48_L( W_shr( W_tmp, 16 ) ); /* 2 * (Qsyn + SynthRef_shift) - 31 */
            move32();
            q_hb_nrg_subr = sub( shl( add( *Q_syn, synthRef_shift ), 1 ), 31 );
            move16();

            W_tmp = EPSILON_FIX;
            move64();

            FOR( ; i < output_frame; i++ )
            {
                L_tmp = L_shl( synthRef_fx[i], synthRef_shift ); /* Qsyn + SynthRef_shift */
                W_tmp = W_mac_32_32( W_tmp, L_tmp, L_tmp );      /* 2 * (Qsyn + SynthRef_shift) + 1 */
            }
            hCPE->hStereoDft->hb_nrg_subr_fx[1] = W_round48_L( W_shr( W_tmp, 16 ) ); /* 2 * (Qsyn + SynthRef_shift) - 31 */

            hb_nrg_fx = L_add( L_shr( hCPE->hStereoDft->hb_nrg_subr_fx[0], 1 ), L_shr( hCPE->hStereoDft->hb_nrg_subr_fx[1], 1 ) ); // 2 * (Qsyn + SynthRef_shift) - 31 - 1
            q_hb_nrg = sub( q_hb_nrg_subr, 1 );
            move16();
#else
            Word64 W_tmp = 0;
            move64();
            tmp = shl_sat( 1, synthRef_shift );
@@ -244,9 +281,6 @@ void stereo_icBWE_dec_fx(

            hCPE->hStereoDft->hb_nrg_subr_fx[1] = W_round48_L( W_tmp );                                    // 2 * (Qsyn + SynthRef_shift) - 45
            hb_nrg_fx = L_add( hCPE->hStereoDft->hb_nrg_subr_fx[0], hCPE->hStereoDft->hb_nrg_subr_fx[1] ); // 2 * (Qsyn + SynthRef_shift) - 45
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
            q_hb_nrg = hStereoDft->q_hb_nrg_subr;
            move16();
#endif

            Copy32( synthRef_fx, hCPE->hStereoDft->hb_stefi_sig_fx + hCPE->hStereoDft->hb_stefi_delay, output_frame ); /* Qsynth */
@@ -259,6 +293,19 @@ void stereo_icBWE_dec_fx(
            hCPE->hStereoDft->hb_nrg_subr_fx[1] = 0;
            move32();
        }
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
        shift_hb_nrg_subr = s_min( norm_l( hCPE->hStereoDft->hb_nrg_subr_fx[0] ), norm_l( hCPE->hStereoDft->hb_nrg_subr_fx[1] ) );

        hCPE->hStereoDft->hb_nrg_subr_fx[0] = ( Mpy_32_16_1( L_shl( hCPE->hStereoDft->hb_nrg_subr_fx[0], shift_hb_nrg_subr ), shl( hCPE->hStereoDft->NFFT, 5 ) ) ); /* shl( ., 5) is shortcut for shl( shr( hStereoDft->NFFT, 1 ), 6 ) */ /* q_hb_nrg_subr + shift_hb_nrg_subr - (15 - 6) */
        move32();
        hCPE->hStereoDft->hb_nrg_subr_fx[1] = ( Mpy_32_16_1( L_shl( hCPE->hStereoDft->hb_nrg_subr_fx[1], shift_hb_nrg_subr ), shl( hCPE->hStereoDft->NFFT, 5 ) ) ); /* shl( ., 5) is shortcut for shl( shr( hStereoDft->NFFT, 1 ), 6 ) */ /* q_hb_nrg_subr + shift_hb_nrg_subr - (15 - 6) */
        move32();
        hCPE->hStereoDft->q_hb_nrg_subr = sub( add( q_hb_nrg_subr, shift_hb_nrg_subr ), Q15 - Q6 );
        hCPE->hStereoDft->hb_nrg_fx[0] = hb_nrg_fx; /* q_hb_nrg */
        move32();
        hCPE->hStereoDft->q_hb_nrg[0] = q_hb_nrg;
        move16();
#else
        hCPE->hStereoDft->hb_nrg_subr_fx[0] = ( Mpy_32_16_1( hCPE->hStereoDft->hb_nrg_subr_fx[0], shl( shr( hCPE->hStereoDft->NFFT, 1 ), 6 ) ) ); // 2 * (Qsynth + SynthRef_shift) - 40                                       // 2 * (Qx + SynthRef_shift) - 31 - 15
        move32();
        hCPE->hStereoDft->hb_nrg_subr_fx[1] = ( Mpy_32_16_1( hCPE->hStereoDft->hb_nrg_subr_fx[1], shl( shr( hCPE->hStereoDft->NFFT, 1 ), 6 ) ) ); // 2 * (Qsynth + SynthRef_shift) - 40
@@ -266,9 +313,6 @@ void stereo_icBWE_dec_fx(
        hCPE->hStereoDft->q_hb_nrg_subr = sub( shl( ( *Q_syn + synthRef_shift ), 1 ), 45 + 9 );
        hCPE->hStereoDft->hb_nrg_fx[0] = hb_nrg_fx; // 2 * (Qx + SynthRef_shift) - 31
        move32();
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
        hCPE->hStereoDft->q_hb_nrg[0] = q_hb_nrg;
        move16();
#endif
        hCPE->hStereoDft->td_gain_fx[0] = 0;
        move32();