Commit d5122b97 authored by multrus's avatar multrus
Browse files

[cleanup] accept FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS

parent bd63a018
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -116,7 +116,6 @@
#define FIX_BASOP_2023_TDREND_DISTATT_PRECISION_BUGFIX  /* Eri: Bug discovered in cleanup of basop issue 2023 */
#define FIX_1576_LCLD_CRASH_DIFFERENT_CODEC_ISAR_FRAME_SIZE  /* Dolby: float issue 1576: fix for crash in LCLD mode when codec frame size is less than isar frame size */
#define FIX_1548_HARMONIZE_NON_DIEGETIC_PANNING_LAW     /* Orange: float issue 1548: Harmonize non diegetic panning law in ISM and renderers */
#define FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS         /* FhG: BASOP issue 2521: Fix wrong porting for determination of first subframe length in ivas_sba_dirac_stereo_compute_td_stefi_nrgs() */
#define FIX_1452_DEFAULT_REVERB                         /* Nokia/Philips/FhG: Fix default room presets and their usage in renderer */
#define NONBE_FIX_ISSUE_2206_MDCT_STEREO_FIX_2549       /* FhG: Correct scale inconsistency of old_inp_16k_fx buffer scale. */
#define FIX_2547_ALIGN_CONDITIONS_IN_CORE_SW_DEC        /* VA : Basop issue 2547: Align conditions in core sw dec */
+0 −43
Original line number Diff line number Diff line
@@ -684,29 +684,19 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs(
    const Word16 q_hb_synth )
{
    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;
    Word16 shift, shift_hb_nrg_subr;
    move32();
#else
    Word32 hb_nrg = EPSILON_FIX;
    move32();
    Word32 hb_nrg2 = EPSILON_FIX;
    move32();
#endif

#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    shift = L_norm_arr( hb_synth, output_frame );
    shift = sub( shift, shr( add( find_guarded_bits_fx( shr( output_frame, 1 ) ), 1 ), 1 ) );
#endif

    test();
    test();
    IF( ( EQ_16( core, ACELP_CORE ) && !fd_cng_flag ) || EQ_16( hStereoDft->core_hist[1], ACELP_CORE ) )
    {
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
        Word32 L_tmp;
        Word64 W_tmp;

@@ -737,30 +727,6 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs(
        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++ )
        {
            hb_nrg2 = Madd_32_32( hb_nrg2, hb_synth[i], hb_synth[i] ); /*2*q_hb_synth-31*/
        }

        hStereoDft->hb_nrg_subr_fx[0] = hb_nrg2; /*2*q_hb_synth-31*/
        move32();
        hStereoDft->q_hb_nrg_subr = sub( shl( q_hb_synth, 1 ), 31 );
        move32();
        hb_nrg = L_add( hb_nrg, hb_nrg2 );
        move32();
        hb_nrg2 = EPSILON_FIX;
        move32();

        FOR( ; i < output_frame; i++ )
        {
            hb_nrg2 = Madd_32_32( hb_nrg2, hb_synth[i], hb_synth[i] ); /*2*q_hb_synth-31*/
        }

        hStereoDft->hb_nrg_subr_fx[1] = hb_nrg2; /*2*q_hb_synth-31*/
        move32();
        hb_nrg = L_add( hb_nrg, hb_nrg2 );
#endif

        IF( EQ_16( hStereoDft->q_hb_stefi_sig_fx, q_hb_synth ) )
        {
@@ -789,7 +755,6 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs(
        hStereoDft->hb_nrg_subr_fx[1] = 0;
        move32();
    }
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    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) */
@@ -801,14 +766,6 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs(
    move32();
    hStereoDft->q_hb_nrg[0] = q_hb_nrg;
    move16();
#else
    hStereoDft->hb_nrg_subr_fx[0] = hStereoDft->hb_nrg_subr_fx[0]; // imult3216(hStereoDft->hb_nrg_subr_fx[0] , shr(hStereoDft->NFFT, 1)); /*hStereoDft->q_hb_nrg_subr*/
    move32();
    hStereoDft->hb_nrg_subr_fx[1] = hStereoDft->hb_nrg_subr_fx[1]; // imult3216(hStereoDft->hb_nrg_subr_fx[1] , shr(hStereoDft->NFFT, 1)); /*hStereoDft->q_hb_nrg_subr*/
    move32();
    hStereoDft->hb_nrg_fx[0] = hb_nrg;
    move32();
#endif
    hStereoDft->td_gain_fx[0] = 0;
    move32();
    hStereoDft->core_hist[0] = core; /* full signal available for DTX with FD-CNG, thus apply stereo filling on full spectrum like in TCX */
+0 −5
Original line number Diff line number Diff line
@@ -199,9 +199,7 @@ typedef struct stereo_dft_dec_data_struct
    Word32 hb_nrg_fx[STEREO_DFT_CORE_HIST_MAX];                                        /* Q(q_hb_nrg) */
    Word32 hb_nrg_subr_fx[STEREO_DFT_NBDIV];                                           /* Q(q_hb_nrg_subr) */

#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    Word16 q_hb_nrg[STEREO_DFT_CORE_HIST_MAX];
#endif
    Word16 Q_nrg_subr;
    Word16 prev_Q_stefi_sig;
    Word16 q_td_gain[STEREO_DFT_CORE_HIST_MAX];
@@ -227,9 +225,6 @@ typedef struct stereo_dft_dec_data_struct
    Word32 smooth_buf_fx[SBA_DIRAC_STEREO_NUM_BANDS][SBA_DIRAC_NRG_SMOOTH_LONG + 1]; /* Q(q_smooth_buf_fx) */
    Word16 smooth_fac_fx[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS];                        /* Q15 */
    Word16 q_smooth_buf_fx;
#ifndef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    Word16 q_hb_nrg;
#endif
    Word16 q_hb_nrg_subr;
    Word16 q_res_mem;

+0 −15
Original line number Diff line number Diff line
@@ -202,9 +202,7 @@ void stereo_dft_dec_reset_fx(

    set32_fx( hStereoDft->hb_stefi_sig_fx, 0, L_FRAME48k + NS2SA( 48000, STEREO_DFT_TD_STEFI_DELAY_NS ) );
    set32_fx( hStereoDft->hb_nrg_fx, 0, STEREO_DFT_CORE_HIST_MAX );
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    set16_fx( hStereoDft->q_hb_nrg, Q31, STEREO_DFT_CORE_HIST_MAX );
#endif
    set32_fx( hStereoDft->td_gain_fx, 0, STEREO_DFT_CORE_HIST_MAX );
    set16_fx( hStereoDft->q_td_gain, 0, STEREO_DFT_CORE_HIST_MAX );
    hStereoDft->q_dft = 0;
@@ -670,12 +668,8 @@ void stereo_dft_dec_update_fx(
    }

    Copy32( hStereoDft->hb_stefi_sig_fx + output_frame, hStereoDft->hb_stefi_sig_fx, hStereoDft->hb_stefi_delay ); /* Qx */
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    Copy32( hStereoDft->hb_nrg_fx, hStereoDft->hb_nrg_fx + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); /* q_hb_nrg */
    Copy( hStereoDft->q_hb_nrg, hStereoDft->q_hb_nrg + 1, STEREO_DFT_CORE_HIST_MAX - 1 );
#else
    Copy32( hStereoDft->hb_nrg_fx, hStereoDft->hb_nrg_fx + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); /* Qx */
#endif
    Copy32( hStereoDft->td_gain_fx, hStereoDft->td_gain_fx + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); /* q_td_gain */
    Copy( hStereoDft->q_td_gain, hStereoDft->q_td_gain + 1, STEREO_DFT_CORE_HIST_MAX - 1 );

@@ -2794,7 +2788,6 @@ static void stereo_dft_compute_td_stefi_params_fx(
    move32();
    nrg_pred_DMX = hStereoDft->hb_nrg_fx[1];
    move32();
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    IF( GT_16( hStereoDft->q_hb_nrg[0], hStereoDft->q_hb_nrg[1] ) )
    {
        nrg_DMX = L_shr( nrg_DMX, sub( hStereoDft->q_hb_nrg[0], hStereoDft->q_hb_nrg[1] ) );
@@ -2803,7 +2796,6 @@ static void stereo_dft_compute_td_stefi_params_fx(
    {
        nrg_pred_DMX = L_shr( nrg_pred_DMX, sub( hStereoDft->q_hb_nrg[1], hStereoDft->q_hb_nrg[0] ) );
    }
#endif

    op1 = BASOP_Util_Divide3232_Scale( L_add( EPSILON_FIX, nrg_DMX ), L_add( EPSILON_FIX, nrg_pred_DMX ), &q_div ); /* q_div */
    q_sqrt = add( Q16, q_div );
@@ -3249,11 +3241,9 @@ void stereo_dft_generate_res_pred_fx(
        }
        ELSE IF( hStereoDft->core_hist[STEREO_DFT_STEFFI_DELAY_SHORT / 2] == ACELP_CORE )
        {
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
            Word16 q_dmx_nrg, q_diff;
            Word16 norm_dmx_nrg;
            Word32 L_temp;
#endif
            /* ACELP -> TCX/HQ core transition */
            /* calculate high band energy only */
            dmx_nrg = EPSILON_FIX;
@@ -3263,7 +3253,6 @@ void stereo_dft_generate_res_pred_fx(
                dmx_nrg = L_add( dmx_nrg, Madd_32_32( Mpy_32_32( pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ) ); /* 2 * q_dft - 31 */
            }

#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
            norm_dmx_nrg = norm_l( dmx_nrg );
            dmx_nrg = L_shl( dmx_nrg, norm_dmx_nrg );
            q_dmx_nrg = add( sub( shl( hStereoDft->q_dft, 1 ), 31 ), norm_dmx_nrg );
@@ -3319,10 +3308,6 @@ void stereo_dft_generate_res_pred_fx(
                move32();
                /* hStereoDft->q_hb_nrg[0] stays as is */
            }
#else
            hStereoDft->hb_nrg_fx[0] = L_add( hStereoDft->hb_nrg_fx[0], div_l( dmx_nrg, shr( hStereoDft->NFFT, 2 ) ) ); /* Q15 */
            move32();
#endif
            *stop = bin0;
            move16();
        }
+0 −56
Original line number Diff line number Diff line
@@ -138,11 +138,7 @@ 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;
@@ -150,10 +146,8 @@ void stereo_icBWE_dec_fx(
    Word16 icbweM2Ref_fx, ratio_L_fx;
    Word16 gsMapping_fx;
    Word32 hb_nrg_fx;
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    Word16 q_hb_nrg, q_hb_nrg_subr;
    Word16 shift_hb_nrg_subr;
#endif
    Word16 Q_syn_shb;
    Word16 shift_prev_pow, synthRef_shift;
    Word32 L_tmp;
@@ -205,31 +199,17 @@ 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
        q_hb_nrg = Q31;

        synthRef_shift = L_norm_arr( synthRef_fx, output_frame );
#else
        move32();
        maximum_abs_32_fx( synthRef_fx, output_frame, &maxVal );
        synthRef_shift = norm_l( maxVal );
        if ( maxVal == 0 )
        {
            synthRef_shift = 31;
            move16();
        }
#endif
        synthRef_shift = sub( synthRef_shift, shr( add( find_guarded_bits_fx( shr( output_frame, 1 ) ), 1 ), 1 ) );
        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();

@@ -256,32 +236,6 @@ void stereo_icBWE_dec_fx(
            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 );
            FOR( i = 0; i < output_frame / 2; i++ )
            {
                // needed to be adjusted for q
                L_tmp = Mpy_32_16_1( synthRef_fx[i], tmp ); /* Qsyn + SynthRef_shift - 15 */
                W_tmp = W_mac_32_32( W_tmp, L_tmp, L_tmp ); /* 2 * (Qsyn + SynthRef_shift) - 29 */
            }
            hb_nrg_fx = W_round48_L( W_tmp );                /* 2 * (Qsyn + SynthRef_shift) - 45 */
            hCPE->hStereoDft->hb_nrg_subr_fx[0] = hb_nrg_fx; /* 2 * (Qsyn + SynthRef_shift) - 45 */
            move32();
            hStereoDft->q_hb_nrg_subr = sub( shl( add( *Q_syn, synthRef_shift ), 1 ), 45 );
            move16();
            W_tmp = 0;
            move64();
            FOR( ; i < output_frame; i++ )
            {
                L_tmp = Mpy_32_16_1( synthRef_fx[i], tmp ); /* Qsyn + SynthRef_shift - 15 */
                W_tmp = W_mac_32_32( W_tmp, L_tmp, L_tmp ); /* 2 * (Qsyn + SynthRef_shift) - 45 */
            }

            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
#endif

            Copy32( synthRef_fx, hCPE->hStereoDft->hb_stefi_sig_fx + hCPE->hStereoDft->hb_stefi_delay, output_frame ); /* Qsynth */
        }
@@ -293,7 +247,6 @@ 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) */
@@ -305,15 +258,6 @@ void stereo_icBWE_dec_fx(
        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
        move32();
        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();
#endif
        hCPE->hStereoDft->td_gain_fx[0] = 0;
        move32();
        hCPE->hStereoDft->core_hist[0] = st->core;