Commit 3fccc102 authored by multrus's avatar multrus
Browse files

[cleanup] accept FIX_2410_HARM_MODIF_FS

parent 43274221
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -306,11 +306,7 @@ IF( NE_16( Opt_AMR_WB, 1 ) )

    IF( EQ_16( L_frame, L_FRAME16k ) )
    {
#ifndef FIX_2410_HARM_MODIF_FS
        modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, exc_mem1, 0 );
#else
        modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, exc_mem1, 0, NULL, NULL );
#endif
    }

    /* fft_rel(fft_io, L_FFT, LOG2_L_FFT); */
@@ -423,11 +419,7 @@ IF( NE_16( Opt_AMR_WB, 1 ) )

    IF( EQ_16( L_frame, L_FRAME16k ) )
    {
#ifndef FIX_2410_HARM_MODIF_FS
        modify_Fs_fx( fft_io, L_FFT, 12800, fft_io, 16000, exc_mem, 0 );
#else
        modify_Fs_fx( fft_io, L_FFT, 12800, fft_io, 16000, exc_mem, 0, NULL, NULL );
#endif
    }

    /* enr1 = dotp( fft_io, fft_io, L_frame ) / L_frame; */
+0 −285
Original line number Diff line number Diff line
@@ -42,12 +42,8 @@
/* CALLED FROM : TX/RX                              */
/*==============================================================================*/

#ifndef FIX_2410_HARM_MODIF_FS
Word16 modify_Fs_ivas_fx( /* o  : length of output    Q0  */
#else
/* o  : length of output    Q0  */
Word16 modify_Fs_fx(
#endif
                          const Word16 sigIn_fx[], /* i  : signal to decimate  Q0  */
                          Word16 lg,               /* i  : length of input     Q0  */
                          const Word32 fin,        /* i  : frequency of input  Q0  */
@@ -84,9 +80,7 @@ Word16 modify_Fs_fx(
     * Find the resampling configuration
     *-------------------------------------------------------------------*/

#ifdef FIX_2410_HARM_MODIF_FS
    if ( Q_new_inp != NULL )
#endif
    {
        *Q_new_inp = 0;
        move16();
@@ -96,9 +90,7 @@ Word16 modify_Fs_fx(
    {
        /* just copy the signal_fx and quit */
        Copy( sigIn_fx, sigOut_fx, lg );
#ifdef FIX_2410_HARM_MODIF_FS
        if ( Q_new_inp != NULL )
#endif
        {
            *mem_decim_size = 0;
            *Q_new_inp = 0;
@@ -162,9 +154,7 @@ Word16 modify_Fs_fx(
        }

        mem_len = shl( filt_len, 1 );
#ifdef FIX_2410_HARM_MODIF_FS
        if ( mem_decim_size != NULL )
#endif
        {
            *mem_decim_size = mem_len;
            move16();
@@ -247,9 +237,7 @@ Word16 modify_Fs_fx(
    {
        filt_len_tmp = shr( add( filt_len, 1 ), 1 );
    }
#ifdef FIX_2410_HARM_MODIF_FS
    if ( Q_new_inp != NULL )
#endif
    {
        *Q_new_inp = negate( norm_s( sub( cfg_ptr_fx->filter_fx[0], 1 ) ) );
    }
@@ -285,9 +273,7 @@ Word16 modify_Fs_fx(
                    sigOut_fx[i] = round_fx( L_shl( L_mult( sigOut_fx[i], num_den ), 1 ) ); /*Q0*/
                    move16();
                }
#ifdef FIX_2410_HARM_MODIF_FS
                if ( Q_new_inp != NULL )
#endif
                {
                    *Q_new_inp = add( *Q_new_inp, 1 );
                    move16();
@@ -301,9 +287,7 @@ Word16 modify_Fs_fx(
                IF( GT_32( fin, 16000 ) && ( EQ_16( lg_out, L_FRAME ) || EQ_16( lg_out, L_FRAME16k ) || EQ_16( lg_out, 512 ) ) )
                {
                    num_den = shl_sat( num_den, 1 );
#ifdef FIX_2410_HARM_MODIF_FS
                    if ( Q_new_inp != NULL )
#endif
                    {
                        *Q_new_inp = add( *Q_new_inp, 1 );
                        move16();
@@ -336,9 +320,7 @@ Word16 modify_Fs_fx(
                    sigOut_fx[i] = round_fx( L_mac( L_deposit_h( sigOut_fx[i] ), sigOut_fx[i], num_den ) ); /*Q0*/
                    move16();
                }
#ifdef FIX_2410_HARM_MODIF_FS
                if ( Q_new_inp != NULL )
#endif
                {
                    *Q_new_inp = add( *Q_new_inp, 1 );
                    move16();
@@ -360,273 +342,6 @@ Word16 modify_Fs_fx(

    return lg_out;
}
#ifndef FIX_2410_HARM_MODIF_FS
Word16 modify_Fs_fx(                          /* o  : length of output    Q0  */
                     const Word16 sigIn_fx[], /* i  : signal to decimate  Q0  */
                     Word16 lg,               /* i  : length of input     Q0  */
                     const Word32 fin,        /* i  : frequency of input  Q0  */
                     Word16 sigOut_fx[],      /* o  : decimated signal    Q0  */
                     const Word32 fout,       /* i  : frequency of output Q0  */
                     Word16 mem_fx[],         /* i/o: filter memory       Q0  */
                     const Word16 nblp        /* i  : flag indicating if NB low-pass is applied */
)
{
    Word16 i;

    Word16 lg_out, fac_num, fac_den, filt_len, frac, temp_n, mem_len;
    Word16 num_den;
    Word16 datastep, fracstep;
    Word16 *sigIn_ptr, *sigPtr;
    Word16 signal_tab_fx[3 * L_FILT_MAX + L_FRAME48k], *signal_fx, *signal_ana_fx; /* 3* as 2* for memory and 1* for future prediction */
    Word16 A_fx[M + 1], r_fx_h[M + 1], r_fx_l[M + 1];
    Word16 mem_len_ana;
    Word16 plus_sample_in;
    Word16 j;
    Word16 mu_preemph_fx;
    Word16 mem_preemph_fx;
    Word16 Q_r;
    Word16 mem_lev_fx[18];
    Word32 t0, t1, t2, L_tmp; /* temporary variables                         */
    Word32 LepsP[M + 1];
    Word16 flag_low_order = 0;
    move16();
    Word16 filt_len_tmp;
    const Resampling_cfg *cfg_ptr_fx;

    /*-------------------------------------------------------------------*
     * Find the resampling configuration
     *-------------------------------------------------------------------*/

    /* check if fin and fout are the same */
    IF( EQ_32( fin, fout ) )
    {
        /* just copy the signal_fx and quit */
        Copy( sigIn_fx, sigOut_fx, lg );

        return lg;
    }
    ELSE
    {
        /* find the resampling configuration in the lookup table */
        cfg_ptr_fx = &resampling_cfg_tbl[0];
        WHILE( ( cfg_ptr_fx->fin_fx != 0 ) && !( EQ_32( cfg_ptr_fx->fin_fx, fin ) && EQ_32( cfg_ptr_fx->fout_fx, fout ) ) )
        {
            test();
            test();
            cfg_ptr_fx++;
        }


        /* find config with NB 4kHz low-pass */
        test();
        test();
        IF( nblp && ( GT_32( fin, 8000 ) ) && ( EQ_32( fout, 12800 ) ) )
        {
            flag_low_order = 1;
            move16();
            cfg_ptr_fx++;
            WHILE( ( cfg_ptr_fx->fin_fx != 0 ) && !( ( EQ_32( cfg_ptr_fx->fin_fx, fin ) ) && ( EQ_32( cfg_ptr_fx->fout_fx, fout ) ) ) )
            {
                test();
                test();
                cfg_ptr_fx++;
            }
        }

        /*-------------------------------------------------------------------*
         * Retrieve and/or calculate the resampling parameters
         *-------------------------------------------------------------------*/
        fac_num = cfg_ptr_fx->fac_num_fx;
        move16(); /*Q0*/
        fac_den = cfg_ptr_fx->fac_den_fx;
        move16();

        IF( GE_16( lg, L_FRAME ) )
        {
            lg_out = cfg_ptr_fx->lg_out;
            move16();
        }
        ELSE
        {
            lg_out = idiv1616( i_mult2( lg, fac_num ), fac_den );
        }
        filt_len = cfg_ptr_fx->filt_len_fx;
        move16();
        plus_sample_in = 0;
        move16(); /*default, regular delay*/
        frac = 0;
        move16();

        test();
        IF( ( EQ_32( fin, 8000 ) ) && ( EQ_32( fout, 12800 ) ) )
        {
            plus_sample_in = 7;
            move16();
            frac = 4;
            move16();
        }

        mem_len = shl( filt_len, 1 );
        signal_fx = signal_tab_fx + 2 * L_FILT_MAX + sub( L_FRAME48k, add( mem_len, lg ) );
        signal_ana_fx = signal_fx;
        mem_len_ana = mem_len;
        move16();
    }


    /*-------------------------------------------------------------------*
     * Resample
     *-------------------------------------------------------------------*/
    /* append filter memory */
    Copy( mem_fx, signal_fx, mem_len );

    sigPtr = signal_fx + mem_len;
    Copy( sigIn_fx, sigPtr, lg );

    IF( plus_sample_in > 0 )
    {
        autocorr_fx( signal_ana_fx + sub( add( mem_len_ana, lg ), LEN_WIN_SSS ), 1, r_fx_h, r_fx_l, &Q_r, LEN_WIN_SSS, wind_sss_fx, 0, 0 );

        t1 = L_Comp( r_fx_h[1], r_fx_l[1] ); /* R[1] in Q31      */
        t2 = L_abs( t1 );                    /* abs R[1]         */
        t0 = L_deposit_l( 0 );
        IF( r_fx_h[0] != 0 )
        {
            t0 = Div_32( t2, r_fx_h[0], r_fx_l[0] ); /* R[1]/R[0] in Q31 */
        }
        if ( t1 < 0 )
        {
            t0 = L_negate( t0 ); /* R[1]/R[0]       */
        }

        mu_preemph_fx = extract_h( t0 ); /*r_fx[1] / r_fx[0]; */
        mem_preemph_fx = signal_ana_fx[mem_len_ana + lg - LEN_WIN_SSS - 1];
        move16();
        preemph_fx( signal_ana_fx + sub( add( mem_len_ana, lg ), LEN_WIN_SSS ), mu_preemph_fx, LEN_WIN_SSS, &mem_preemph_fx );

        /* Autocorrelations */
        autocorr_fx( signal_ana_fx + sub( add( mem_len_ana, lg ), LEN_WIN_SSS ), M, r_fx_h, r_fx_l, &Q_r,
                     LEN_WIN_SSS, wind_sss_fx, 0, 0 );

        /* Lag windowing */
        lag_wind( r_fx_h, r_fx_l, M, fin, LAGW_STRONG );

        /* Levinson-Durbin */
        set16_fx( mem_lev_fx, 0, 18 );
        E_LPC_lev_dur_fx( r_fx_h, r_fx_l, A_fx, LepsP, M, NULL );

        Copy_Scale_sig( A_fx, A_fx, M + 1, sub( norm_s( A_fx[0] ), 2 ) );

        FOR( i = 0; i < plus_sample_in; i++ )
        {
            sigPtr = signal_fx + add( add( lg, mem_len ), i );
            move16(); /*+i*/
            L_tmp = syn_kern_16( 0, A_fx, sigPtr );
            L_tmp = L_shl_sat( L_tmp, 3 );
            *sigPtr = round_fx_sat( L_tmp ); /* AZ ringing padding */
        }
        mem_preemph_fx = signal_fx[mem_len + lg - LEN_WIN_SSS - 1];
        move16();
        deemph_fx( signal_fx + sub( add( mem_len, lg ), LEN_WIN_SSS ), mu_preemph_fx, add( LEN_WIN_SSS, plus_sample_in ), &mem_preemph_fx );
    }
    /* interpolation */

    datastep = shr( div_s( shl( fac_den, 8 ), shl( fac_num, 11 ) ), 12 );
    /* equivalent to 'datastep = fac_den % fac_num' */
    temp_n = i_mult2( datastep, fac_num ); /*Q0*/
    fracstep = sub( fac_den, temp_n );

    sigIn_ptr = signal_fx + add( filt_len, plus_sample_in );

    filt_len_tmp = filt_len;
    move16();
    IF( flag_low_order )
    {
        filt_len_tmp = shr( add( filt_len, 1 ), 1 );
    }

    FOR( i = 0; i < lg_out; i++ )
    {
        sigOut_fx[i] = round_fx_sat( Interpol_lc_fx( sigIn_ptr, cfg_ptr_fx->filter_fx, frac, fac_num, filt_len_tmp ) );
        move16();
        frac = add( frac, fracstep );

        j = sub( fac_num, frac );
        if ( j < 0 )
        {
            frac = sub( frac, fac_num );
        }
        sigIn_ptr += add( lshr( j, 15 ), datastep );
    }
    /* rescaling */
    test();

    IF( EQ_32( ( GT_16( fac_num, fac_den ) ), ( ( cfg_ptr_fx->flags_fx & RS_INV_FAC ) != 0 ) ) )
    {
        IF( LT_16( fac_num, fac_den ) )
        {
            num_den = div_s( fac_num, fac_den ); /*Q15*/
            test();
            IF( GT_32( fin, 16000 ) && EQ_16( lg_out, 512 ) )
            {

                FOR( i = 0; i < lg_out; i++ )
                {
                    sigOut_fx[i] = round_fx( L_shl( L_mult( sigOut_fx[i], num_den ), 1 ) ); /*Q0*/
                }
            }
            ELSE
            {
                test();
                test();
                test();
                if ( GT_32( fin, 16000 ) && ( EQ_16( lg_out, L_FRAME ) || EQ_16( lg_out, L_FRAME16k ) || EQ_16( lg_out, 512 ) ) )
                {
                    num_den = shl_sat( num_den, 1 );
                }
                FOR( i = 0; i < lg_out; i++ )
                {
                    sigOut_fx[i] = mult_r( sigOut_fx[i], num_den ); /*Q0*/
                    move16();
                }
            }
        }
        ELSE
        {
            IF( EQ_16( fac_num, 8 ) )
            {
                num_den = 26214;
                FOR( i = 0; i < lg_out; i++ )
                {
                    sigOut_fx[i] = mult_r( sigOut_fx[i], num_den ); /*Q-1*/
                    move16();
                }
            }
            ELSE
            {
                num_den = div_s( sub( fac_num, fac_den ), fac_den ); /*Q15*/
                FOR( i = 0; i < lg_out; i++ )
                {
                    sigOut_fx[i] = round_fx( L_mac( L_deposit_h( sigOut_fx[i] ), sigOut_fx[i], num_den ) ); /*Q0*/
                }
            }
        }
    }
    ELSE IF( ( LT_16( fac_num, fac_den ) ) && ( ( cfg_ptr_fx->flags_fx & RS_INV_FAC ) != 0 ) )
    {
        FOR( i = 0; i < lg_out; i++ )
        {
            sigOut_fx[i] = mult_r( sigOut_fx[i], 16384 );
            move16(); /*Q-1*/
        }
    }
    /* update the filter memory */
    sigPtr = signal_fx + lg;
    Copy( sigPtr, mem_fx, mem_len );

    return lg_out;
}
#endif


/*-------------------------------------------------------------------*
+0 −1
Original line number Diff line number Diff line
@@ -83,7 +83,6 @@
#define FIX_1990_SANITIZER_IN_REVERB_LOAD               /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */
#define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR      /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */
#define NONBE_1122_KEEP_EVS_MODE_UNCHANGED              /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR.  */
#define FIX_2410_HARM_MODIF_FS                          /* VA: basop issue 2410: Remove duplicated modif_Fs */
#define FIX_2425_REMOVE_RC_DUPLICATES                   /* VA: basop issue 2425: Remove duplicated RC encoder functions */
#define HARM_LEV_DURBIN                                 /* VA: basop issue 2423: harmonize levinson-Durbin algorithm */
#define HARMONIZE_TBE2                                  /* VA: basop issue 2399: Remove duplicated code: TBE, step 2 */
+0 −16
Original line number Diff line number Diff line
@@ -2438,11 +2438,7 @@ Word32 Interpol_lc_fx(
);

/* o  : length of output    Q0  */
#ifndef FIX_2410_HARM_MODIF_FS
Word16 modify_Fs_ivas_fx( /* o  : length of output    Q0  */
#else
Word16 modify_Fs_fx( /* o  : length of output    Q0  */
#endif
                          const Word16 sigIn_fx[], /* i  : signal to decimate  Q0  */
                          Word16 lg,               /* i  : length of input     Q0  */
                          const Word32 fin,        /* i  : frequency of input  Q0  */
@@ -2454,18 +2450,6 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
                          Word16 *mem_decim_size   /*i: size modified for mem_fx*/
);

#ifndef FIX_2410_HARM_MODIF_FS
/* o  : length of output    Q0  */
Word16 modify_Fs_fx(
    const Word16 sigIn_fx[], /* i  : signal to decimate  Q0  */
    Word16 lg,               /* i  : length of i         Q0  */
    const Word32 fin,        /* i  : frequency of i      Q0  */
    Word16 sigOut_fx[],      /* o  : decimated signal    Q0  */
    const Word32 fout,       /* i  : frequency of output Q0  */
    Word16 mem_fx[],         /* i/o: filter memory       Q0  */
    const Word16 nblp        /* i  : flag indicating if NB low-pass is applied */
);
#endif
/* o  : length of output    */
Word16 modify_Fs_intcub3m_sup_fx(
    const Word16 sigIn[], /* i  : signal to decimate with memory of 2 samples (indexes -2 & -1) */
+0 −8
Original line number Diff line number Diff line
@@ -1001,18 +1001,10 @@ void ivas_lfe_tdplc_fx(
    Copy_Scale_sig_32_16( rec_frame_fx, rec_frame_16_fx, LFE_PLC_RECLEN, -Q5 );             // Q0

    Word16 Q_new_inp, mem_decim_size, size_modified;
#ifndef FIX_2410_HARM_MODIF_FS
    size_modified = modify_Fs_ivas_fx( prevsynth_16_fx + LFE_PLC_BUFLEN - LFE_PLC_FDEL / LFE_PLC_DSF, LFE_PLC_FDEL / LFE_PLC_DSF, LFE_PLC_FS, rec_frame_us_16_fx, 48000, mem_fx, 0, &Q_new_inp, &mem_decim_size );
#else
    size_modified = modify_Fs_fx( prevsynth_16_fx + LFE_PLC_BUFLEN - LFE_PLC_FDEL / LFE_PLC_DSF, LFE_PLC_FDEL / LFE_PLC_DSF, LFE_PLC_FS, rec_frame_us_16_fx, 48000, mem_fx, 0, &Q_new_inp, &mem_decim_size );
#endif
    Scale_sig( rec_frame_us_16_fx, size_modified, negate( Q_new_inp ) ); /* scaling back to Q0 */

#ifndef FIX_2410_HARM_MODIF_FS
    size_modified = modify_Fs_ivas_fx( rec_frame_16_fx, LFE_PLC_RECLEN, LFE_PLC_FS, rec_frame_us_16_fx, 48000, mem_fx, 0, &Q_new_inp, &mem_decim_size );
#else
    size_modified = modify_Fs_fx( rec_frame_16_fx, LFE_PLC_RECLEN, LFE_PLC_FS, rec_frame_us_16_fx, 48000, mem_fx, 0, &Q_new_inp, &mem_decim_size );
#endif
    Scale_sig( rec_frame_us_16_fx, size_modified, negate( Q_new_inp ) ); /* scaling back to Q0 */

    /*samples are generated with 48k sampling rate
Loading