Commit 695bf809 authored by Fabian Bauer's avatar Fabian Bauer
Browse files

Merge branch 'main' into...

Merge branch 'main' into basop-2436-discontinuities-due-to-recycling-of-cldfbana-state-across-multiple-ism-inputs
parents a63b6c05 80ac8961
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1598,17 +1598,27 @@ ivas_error cldfb_save_memory(
    }
    hs->memory_length = cldfb_get_memory_length( hs );
    move16();
#ifdef FIX_2431_AVOID_CALLOC
    hs->memory = (Word16 *) malloc( ( hs->memory_length + CLDFB_MEM_EXPONENTS + 1 ) * sizeof( Word16 ) );
    IF( hs->memory == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" );
    }
#else
    hs->memory = (Word16 *) calloc( hs->memory_length + CLDFB_MEM_EXPONENTS + 1, sizeof( Word16 ) );
#endif

    /* save the memory */
    Copy( hs->FilterStates, hs->memory, hs->memory_length );
    Copy( hs->FilterStates_e, hs->memory + hs->memory_length, CLDFB_MEM_EXPONENTS );
    hs->memory[hs->memory_length + CLDFB_MEM_EXPONENTS] = hs->FilterStates_eg;
    move16();
#ifndef FIX_2431_AVOID_CALLOC
    IF( hs->memory == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" );
    }
#endif

    return IVAS_ERR_OK;
}
+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; */
+6 −7
Original line number Diff line number Diff line
@@ -2956,15 +2956,8 @@ void acelp_fast_fx(
    BSTR_ENC_HANDLE hBstr,                                      /* i/o: encoder bitstream handle                */
    const Word16 cdk_index,                                     /* i  : codebook index                          */
    const Word16 dn_orig[L_SUBFR],                              /* i  : corr. between target and h[].      Q_dn */
#ifdef OPT_2416_ACELP_FAST                                      
    const Word16 Q_dncn,                                        /* i  : scaling factor of dn and cn             */  
#else
    Word16 Q_dn,
#endif
    const Word16 cn[L_SUBFR],                                   /* i  : residual after long term prediction q_cn*/
#ifndef OPT_2416_ACELP_FAST
    const Word16 q_cn,
#endif
    const Word16 H[L_SUBFR],                                    /* i  : impulse response of weighted synthesis filter  e(norm_s(H[0])+1) */
    Word16 code[L_SUBFR],                                       /* o  : algebraic (fixed) codebook excitation   */
    Word16 y[],                                                 /* o  : filtered fixed codebook excitation      */
@@ -3800,10 +3793,16 @@ ivas_error ivas_osba_render_sf_fx(
void ivas_osba_stereo_add_channels_fx(
    Word32 *tc_fx[],                                            /* i  : transport channels                          */
    Word32 *output_fx[],                                        /* i/o: output channels                             */
#ifdef FIX_2196_UNREACHABLE_CODE_IN_OSBA_STEREO_OUTPUT
    const Word32 gain,                                          /* i  : gain bed value Q11                          */
#else
    const Word32 gain_bed_fx,                                   /* i  : gain bed value Q11                          */
#endif
    const Word16 nchan_out,                                     /* i  : number of output channels                   */
    const Word16 nchan_ism,                                     /* i  : number of ISM channels                      */
#ifndef FIX_2196_UNREACHABLE_CODE_IN_OSBA_STEREO_OUTPUT
    const Word16 ism_mode,                                      /* i  : ISM mode                                    */
#endif
    const UWord16 n_samples_to_render                           /* i  : output frame length per channel             */
);

+0 −199
Original line number Diff line number Diff line
@@ -448,9 +448,7 @@ static Word32 Div_32_opt( Word32 L_num /*Q31*/, Word16 denom_hi /*Qx -16*/, Word
 */

static Word16 E_LPC_lev_dur_stab(
#ifdef HARM_LEV_DURBIN
    const Word16 element_mode,
#endif
    const Word16 Rh[] /*QR -16*/,
    const Word16 Rl[] /*QR -1*/,
    Word16 A[] /*Qx*/,
@@ -615,7 +613,6 @@ static Word16 E_LPC_lev_dur_stab(
        t1 = L_max( t1, L_abs( t0 ) );
    }

#ifdef HARM_LEV_DURBIN
    IF( element_mode == EVS_MONO )
    {
        k = s_min( norm_l( t1 ), 3 );
@@ -624,9 +621,6 @@ static Word16 E_LPC_lev_dur_stab(
    {
        k = s_min( sub( norm_l( t1 ), 1 ), 3 );
    }
#else
    k = s_min( norm_l( t1 ), 3 );
#endif
    A[0] = shl( 2048, k );
    move16();
    FOR( i = 1; i <= order; i++ )
@@ -655,205 +649,12 @@ static Word16 E_LPC_lev_dur_stab(

Word16 E_LPC_lev_dur_fx( const Word16 Rh[] /*QR -16*/, const Word16 Rl[] /*QR -1*/, Word16 A[] /*Qx*/, Word32 epsP[] /*QR*/, const Word16 order, Word16 *mem /*Qx*/ )
{
#ifdef HARM_LEV_DURBIN
    return ( E_LPC_lev_dur_stab( EVS_MONO, Rh, Rl, A, epsP, order, mem, 32750 ) ); /* 0.99945 in Q15 */
#else
    return ( E_LPC_lev_dur_stab( Rh, Rl, A, epsP, order, mem, 32750 ) );         /* 0.99945 in Q15 */
#endif
}

#ifndef HARM_LEV_DURBIN
static Word16 E_LPC_lev_dur_stab_ivas_fx( const Word16 Rh[], const Word16 Rl[], Word16 A[], Word32 epsP[], const Word16 order, Word16 *mem, Word16 k_max )
{
    Word16 i, j, k;
    Word16 hi, lo;
    Word16 Kh, Kl;                /* reflection coefficient; hi and lo           */
    Word16 alp_h, alp_l, alp_exp; /* Prediction gain; hi lo and exponent         */
    Word32 t0, t1, t2;            /* temporary variables                         */
    Word16 flag;
    Word16 Ah[TCXLTP_LTP_ORDER + 1], Al[TCXLTP_LTP_ORDER + 1]; /* LPC coef. in double prec. */

    BASOP_SATURATE_WARNING_OFF_EVS
    if ( epsP != NULL )
    {
        epsP[0] = L_Comp( Rh[0], Rl[0] );
        move32();
    }

    flag = 0;
    move16();

    /* K = A[1] = -R[1] / R[0] */
    t1 = L_Comp( Rh[1], Rl[1] ); /* R[1] in Q31      */
    t2 = L_abs( t1 );            /* abs R[1]         */
    t0 = L_deposit_l( 0 );
    IF( Rh[0] != 0 )
    {
        t0 = Div_32_opt( t2, Rh[0], Rl[0] ); /* R[1]/R[0] in Q31 */
        /* Cause a difference in MODE1 due to different implementation of div32*/
    }
    if ( t1 > 0 )
    {
        t0 = L_negate( t0 ); /* -R[1]/R[0]       */
    }
    Kl = L_Extract_lc( t0, &Kh );    /* K in DPF         */
    t0 = L_shr( t0, 4 );             /* A[1] in Q27      */
    L_Extract( t0, &Ah[1], &Al[1] ); /* A[1] in DPF      */

    /* Alpha = R[0] * (1-K**2) */
    t0 = Sqr_32( Kh, Kl );                  /* K*K      in Q31 */
    t0 = L_abs( t0 );                       /* Some case <0 !! */
    t0 = L_sub( (Word32) 0x7fffffffL, t0 ); /* 1 - K*K  in Q31 */
    lo = L_Extract_lc( t0, &hi );           /* DPF format      */
    t0 = Mpy_32( Rh[0], Rl[0], hi, lo );    /* Alpha in Q31    */
    if ( epsP != NULL )
    {
        epsP[1] = t0;
        move32();
    }

    /* Normalize Alpha */
    alp_exp = norm_l( t0 );
    t0 = L_shl( t0, alp_exp );
    alp_l = L_Extract_lc( t0, &alp_h );
    /* DPF format */

    /*--------------------------------------*
     * ITERATIONS  I=2 to m
     *--------------------------------------*/

    FOR( i = 2; i <= order; i++ )
    {
        /* t0 = SUM(R[j]*A[i-j], j=1, i-1) + R[i] */
        t0 = L_deposit_l( 0 );
        FOR( j = 1; j < i; j++ )
        {
            t0 = Mac_32( t0, Rh[j], Rl[j], Ah[i - j], Al[i - j] );
        }

        t0 = L_shl_sat( t0, 4 ); /* result in Q27 -> convert to Q31 */
                                 /* No overflow possible            */

        /* Compose and add R[i] in Q3 */
        t0 = L_mac_sat( t0, Rl[i], 1 );
        t0 = L_msu_sat( t0, Rh[i], -32768 );

        /* K = -t0 / Alpha */
        t1 = L_abs( t0 );
        t2 = L_deposit_l( 0 );
        IF( alp_h != 0 )
        {
            t2 = Div_32_opt( t1, alp_h, alp_l ); /* abs(t0)/Alpha                   */
            /* Cause a difference in MODE1 due to different implementation of div32*/
}

        if ( t0 > 0 )
        {
            t2 = L_negate( t2 ); /* K =-t0/Alpha                    */
        }
        t2 = L_shl_sat( t2, alp_exp ); /* denormalize; compare to Alpha   */
        test();
        if ( ( mem != NULL ) && ( ( GT_16( abs_s( extract_h( t2 ) ), k_max ) ) ) )
        {
            flag = 1;
            move16(); /* Test for unstable filter. If unstable keep old A(z) */
        }
        test();
        if ( ( mem != NULL ) && ( ( LT_32( L_abs( t2 ), 5 ) ) ) )
        {
            flag = 1;
            move16(); /*R matrix not reliable (R saturated for many coeff), keep old A(z) */
        }
        Kl = L_Extract_lc( t2, &Kh ); /* K in DPF                        */

        /*------------------------------------------*
         *  Compute new LPC coeff. -> An[i]
         *  An[j]= A[j] + K*A[i-j], j=1 to i-1
         *  An[i]= K
         *------------------------------------------*/

        k = mult_r( i, 16384 );
        FOR( j = 1; j < k; j++ )
        {
            /* Do two Iterations Together to Allow Direct Update of Ah & Al */
            t0 = Mac_32( L_Comp( Ah[j], Al[j] ), Kh, Kl, Ah[i - j], Al[i - j] );
            t1 = Mac_32( L_Comp( Ah[i - j], Al[i - j] ), Kh, Kl, Ah[j], Al[j] );
            L_Extract( t0, &Ah[j], &Al[j] );
            L_Extract( t1, &Ah[i - j], &Al[i - j] );
        }
        IF( s_and( i, 1 ) == 0 )
        {
            t0 = Mac_32( L_Comp( Ah[j], Al[j] ), Kh, Kl, Ah[i - j], Al[i - j] );
            L_Extract( t0, &Ah[j], &Al[j] );
        }
        t2 = L_shr( t2, 4 );             /* t2 = K in Q31 ->convert to Q27 */
        L_Extract( t2, &Ah[i], &Al[i] ); /* An[i] in Q27                   */

        /* Alpha = Alpha * (1-K**2) */
        t1 = L_mult_sat( Kh, Kh ); /* K*K      in Q31 */
        t0 = L_mac( t1, mult( Kh, Kl ), 2 );
        t0 = L_abs( t0 );                       /* Some case <0 !! */
        t0 = L_sub( (Word32) 0x7fffffffL, t0 ); /* 1 - K*K  in Q31 */
        lo = L_Extract_lc( t0, &hi );           /* DPF format      */
        t0 = Mpy_32( alp_h, alp_l, hi, lo );    /* Alpha in Q31    */


        /* store denormalized alpha in epsP */
        t1 = L_shr( t0, alp_exp );
        if ( epsP != NULL )
        {
            epsP[i] = t1;
            move32();
        }

        /* Normalize Alpha */
        j = norm_l( t0 );
        t0 = L_shl( t0, j );
        alp_l = L_Extract_lc( t0, &alp_h ); /* DPF format */
        alp_exp = add( alp_exp, j );        /* Add normalization to alp_exp */
    }

    /* Adaptive scaling */
    t1 = L_deposit_l( 0 );
    FOR( i = 1; i <= order; i++ )
    {
        t0 = L_Comp( Ah[i], Al[i] );
        t1 = L_max( t1, L_abs( t0 ) );
    }
    k = s_min( sub( norm_l( t1 ), 1 ), 3 );
    A[0] = shl( 2048, k );
    move16();
    FOR( i = 1; i <= order; i++ )
    {
        t0 = L_Comp( Ah[i], Al[i] );
        A[i] = round_fx_sat( L_shl_sat( t0, k ) );
        move16();
    }

    BASOP_SATURATE_WARNING_ON_EVS
    IF( mem != NULL )
    {
        /* Enforce stable LPC filter  - parcorr[0] and parcorr[1] are not LPC coeffiecients */
        IF( flag )
        {
            Copy( mem, A, add( order, 1 ) );
        }
        ELSE /* If stable LPC filter, store into memories */
        {
            Copy( A, mem, add( order, 1 ) );
        }
    }

    return ( flag );
}
#endif
Word16 E_LPC_lev_dur_ivas_fx( const Word16 Rh[], const Word16 Rl[], Word16 A[], Word32 epsP[], const Word16 order, Word16 *mem )
{
#ifdef HARM_LEV_DURBIN
    return ( E_LPC_lev_dur_stab( IVAS_SCE /* just to differentiate from EVS_MONO */, Rh, Rl, A, epsP, order, mem, 32750 ) ); /* 0.99945 in Q15 */
#else
    return ( E_LPC_lev_dur_stab_ivas_fx( Rh, Rl, A, epsP, order, mem, 32750 ) ); /* 0.99945 in Q15 */
#endif
}


+17 −296
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


/*-------------------------------------------------------------------*
@@ -651,7 +366,11 @@ Word16 modify_Fs_intcub3m_sup_fx(
    const Word16( *cu )[3] = 0;
    Word16 *sigin_sr, *sigOutptr, *cptr;
    const Word16 *uptr, *ctptr;
#ifdef FIX_2431_AVOID_CALLOC
    Word16 sigin_sr_tab[NS2SA( 16000, DELAY_CLDFB_NS ) + 2];
#else
    Word16 *sigin_sr_tab;
#endif
    Word16 lim, inc, lim2, lim3;
    Word32 vv32;
#define QSR 2 /* right shift to avoid overflow, 2 is OK */
@@ -677,7 +396,9 @@ Word16 modify_Fs_intcub3m_sup_fx(
    }
    ELSE
    {
#ifndef FIX_2431_AVOID_CALLOC
        sigin_sr_tab = (Word16 *) calloc( lg + 2, sizeof( *sigin_sr ) ); /*shift right*/
#endif
        sigin_sr = sigin_sr_tab + 2;
        FOR( i = -2; i < lg; i++ )
        {
@@ -861,7 +582,6 @@ Word16 modify_Fs_intcub3m_sup_fx(
            }
        }


        kk = sub( kk, 1 );
        if ( kk < 0 )
        {
@@ -916,8 +636,9 @@ Word16 modify_Fs_intcub3m_sup_fx(
        }
    }

#ifndef FIX_2431_AVOID_CALLOC
    free( sigin_sr_tab );

#endif
    return lg_out;
}

Loading