Commit cd0e07f1 authored by Nishant S Kulgod's avatar Nishant S Kulgod
Browse files

commit 1

parent d37854b4
Loading
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -279,6 +279,33 @@ void ivas_filter_process_fx(
}
#endif

void ivas_filter_process_exp_fx(
    ivas_filters_process_state_t *filter_state, /* i/o: filter state handle             */
    Word32 *pIn_Out_fx,                         /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i])   */
    const Word16 length,                        /* i  : filter order                    */
    Word16 *pIn_Out_e )
{
    SWITCH( filter_state->order )
    {
        case IVAS_FILTER_ORDER_1:
        case IVAS_FILTER_ORDER_2:
            ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, pIn_Out_e );
            /* Scale pIn_Out_fx back to input Q */
            BREAK;
        case IVAS_FILTER_ORDER_4:
            /* biquad-1 */
            ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, pIn_Out_e );
            /* biquad-2 */
            ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, pIn_Out_e );
            /* Scale pIn_Out_fx back to input Q */
            BREAK;
        default:
            BREAK;
    }

    return;
}


/*-----------------------------------------------------------------------------------------*
 * Function ivas_iir_2_filter()
+12 −9
Original line number Diff line number Diff line
@@ -236,7 +236,7 @@ ivas_error pre_proc_front_ivas_fx(
    Word16 old_inp_12k8_fx[],                                  /* o  : (Q-1) buffer of old input signal              */
    float old_inp_12k8[],                                      /* o  : buffer of old input signal              */
    float old_inp_16k[],                                       /* o  : buffer of old input signal @16kHz          */
    float *ener,                                               /* o  : residual energy from Levinson-Durbin    */
    Word32 *ener_fx,                                              /* o  : residual energy from Levinson-Durbin  Q6  */
    Word16 *relE_fx,                                               /* o  : frame relative energy                  Q8 */
    Word16 A_fx[NB_SUBFR16k * ( M + 1 )],                          /* o  : A(z) unquantized for the 4 subframes    */
    Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )],                         /* o  : weighted A(z) unquantized for subframes */
@@ -254,9 +254,10 @@ ivas_error pre_proc_front_ivas_fx(
    Word16 *loc_harm,                                          /* o  : harmonicity flag                        */
    Word16 *cor_map_sum_fx,                                    /* o  : speech/music clasif. parameter       Q8 */
    Word16 *vad_flag_dtx,                                      /* o  : HE-SAD flag with additional DTX HO      */
    float enerBuffer[CLDFB_NO_CHANNELS_MAX],                   /* o  : energy buffer                           */
    float fft_buff[2 * L_FFT],                                 /* o  : FFT buffer                              */
    Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX],                      /* o  : energy buffer                           */
    Word16 *enerBuffer_fx_exp,                      /* o  : energy buffer                           */
    Word16 fft_buff_fx[2 * L_FFT],                             /* o  : FFT buffer                                 */
    Word16 *fft_buff_fx_q,                                     /* o  : FFT buffer                                 */
    const Word16 tdm_A_PCh_fx[M + 1],                              /* i  : unq. LP coeff. of primary channel  Q12     */
    const Word16 tdm_lsp_new_PCh_fx[M],                            /* i  : unq. LSPs of primary channel       Q15     */
    const Word16 currFlatness_fx,                                  /* i  : flatness parameter                    Q7  */
@@ -285,7 +286,7 @@ ivas_error pre_proc_ivas(
    Word16 old_inp_12k8_fx[],                                       /* i/o: buffer of old input signal              */
    float old_inp_16k[],                                        /* i/o: buffer of old input signal @ 16kHz      */
    float **inp,                                                /* o  : ptr. to inp. signal in the current frame*/
    float *ener,                                                /* o  : residual energy from Levinson-Durbin    */
    Word32 *ener_fx,                                            /* o  : residual energy from Levinson-Durbin Q6 */
    Word16 A[NB_SUBFR16k * ( M + 1 )],                           /* i/o: A(z) unquantized for the 4 subframes    */
    Word16 Aw[NB_SUBFR16k * ( M + 1 )],                          /* i/o: weighted A(z) unquantized for subframes */
    float epsP[M + 1],                                          /* i/o: LP prediction errors                    */
@@ -525,7 +526,7 @@ ivas_error ivas_core_enc(
    const int16_t n_CoreChannels,                                /* i  : number of core channels to be coded    */
    float old_inp_12k8[][L_INP_12k8],                            /* i  : buffer of old input signal             */
    float old_inp_16k[][L_INP],                                  /* i  : buffer of old input signal             */
    float ener[],                                                /* i  : residual energy from Levinson-Durbin   */
    Word32 ener_fx[],                                            /* i  : residual energy from Levinson-Durbin Q6*/
    Word16 A_fx[][NB_SUBFR16k * ( M + 1 )],                      /* i  : A(z) unquantized for the 4 subframes   */
    Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )],                     /* i  : weighted A(z) unquantized for subframes*/
    float epsP[][M + 1],                                         /* i  : LP prediction errors                   */
@@ -533,14 +534,16 @@ ivas_error ivas_core_enc(
    Word16 lsp_mid[][M],                                         /* i  : LSPs in the middle of the frame    Q15 */
    const int16_t vad_hover_flag[],                              /* i  : VAD hanglover flag                     */
    int16_t attack_flag[],                                       /* i  : attack flag (GSC or TC)                */
    float realBuffer[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer                            */
    float imagBuffer[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer                            */
    Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer                            */
    Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer                            */
    Word16 q_re_im_buf,
    float old_wsp[][L_WSP],                                      /* i  : weighted input signal buffer           */
    const int16_t loc_harm[],                                    /* i  : harmonicity flag                       */
    const Word16 cor_map_sum[],                                   /* i  : speech/music clasif. parameter     Q8 */
    const int16_t vad_flag_dtx[],                                /* i  : HE-SAD flag with additional DTX HO     */
    float enerBuffer[][CLDFB_NO_CHANNELS_MAX],                   /* i  : energy buffer                          */
    float fft_buff[][2 * L_FFT],                                 /* i  : FFT buffer                             */
    Word32 enerBuffer_fx[][CLDFB_NO_CHANNELS_MAX],                      /* o  : energy buffer                           */
    Word16 enerBuffer_fx_exp[],                      /* o  : energy buffer                           */
    Word16 fft_buff_fx[][2 * L_FFT],                             /* i  : FFT buffer                             */
    const int16_t tdm_SM_flag,                                   /* i  : channel combination scheme flag        */
    const int16_t ivas_format,                                   /* i  : IVAS format                            */
    const int16_t flag_16k_smc                                   /* i  : flag to indicate if the OL SMC is run at 16 kHz */
+7 −1
Original line number Diff line number Diff line
@@ -3752,6 +3752,12 @@ void ivas_filter_process_fx(
    const Word16 length,                        /* i  : filter order                            */
    Word16 q_factor );

void ivas_filter_process_exp_fx(
    ivas_filters_process_state_t *filter_state, /* i/o: filter state handle             */
    Word32 *pIn_Out_fx,                         /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i])   */
    const Word16 length,                        /* i  : filter order                    */
    Word16 *pIn_Out_e );

ivas_error ivas_osba_enc_open_fx(
    Encoder_Struct *st_ivas /* i/o: IVAS encoder handle                     */
);
@@ -5838,7 +5844,7 @@ ivas_error ivas_compute_core_buffers_fx(
    const Word16 input_frame,              /* i  : frame length                             */
    const Word16 last_element_mode,        /* i  : last element mode                        */
    const Word32 sr_core,                  /* i  : core-coder sampling rate                 */
    Word32 *ener,                          /* o  : residual energy from Levinson-Durbin     */
    Word32 *ener_fx,                       /* o  : residual energy from Levinson-Durbin  Q6 */
    Word16 A_fx[NB_SUBFR16k * ( M + 1 )],  /* i/o: A(z) unquantized for the 4 subframes     */
    Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes  */
    Word32 epsP[M + 1],                    /* i/o: LP prediction errors                     */
+33 −13
Original line number Diff line number Diff line
@@ -1201,18 +1201,24 @@ static void ivas_get_pred_coeffs_enc_fx(
                move32();
                dm_v_re_q[i][b] = sub( add( add( dm_v_re_q[i][b], DM_F_q[b] ), tmp_shift ), 32 );
                move16();
                if ( ppDM_Fv_re[i][b] == 0 )
                {
                    dm_v_re_q[i][b] = Q31;
                    move16();
                }
                // if ( ppDM_Fv_re[i][b] == 0 )
                //{
                //     dm_v_re_q[i][b] = Q31;
                //     move16();
                // }

                IF( ppPred_coeffs_re[i][b] )
                {
                    *q_pred_coeffs = s_min( *q_pred_coeffs, q_ppPred_coeffs_re[i][b] );
                    move16();
                }
                IF( ppDM_Fv_re[i][b] )
                {
                    *q_dm_fv_re = s_min( *q_dm_fv_re, dm_v_re_q[i][b] );
                    move16();
                }
            }
        }
        FOR( i = 0; i < pred_dim; i++ )
        {
            FOR( b = start_band; b < end_band; b++ )
@@ -1772,7 +1778,7 @@ static void ivas_get_Wscaling_factor_enc_fx(
        test();
        IF( EQ_16( active_w, 1 ) && ( dyn_active_w_flag == 0 ) )
        {
            Word16 guard_bits, q_Gw_sq, q_g_sq, q_min, tmp_exp;
            Word16 shift, guard_bits, q_Gw_sq, q_g_sq, q_min, tmp_exp;
            Word32 Gw_sq, g_sq, tmp;

            g_sq = 0;
@@ -1786,14 +1792,28 @@ static void ivas_get_Wscaling_factor_enc_fx(
            Gw_sq = BASOP_Util_Divide3232_Scale( cov_real[0][0][b], L_max( postpred_cov_re[0][0], IVAS_FIX_EPS ), &tmp_exp ); // 15-(tmp_exp-(q_cov_real[0][0][b]- q_postpred_cov_re))
            q_Gw_sq = add( sub( 15, tmp_exp ), sub( q_cov_real[0][0][b], q_postpred_cov_re ) );

            guard_bits = find_guarded_bits_fx( num_ch );
            shift = MAX16B;
            move16();

            FOR( ch = 0; ch < sub( num_ch, 1 ); ch++ )
            FOR( ch = 0; ch < ( num_ch - 1 ); ch++ )
            {
                IF( pred_coeffs_re[ch][b] != 0 )
                {
                    shift = s_min( shift, norm_l( pred_coeffs_re[ch][b] ) );
                }
            }
            guard_bits = find_guarded_bits_fx( num_ch );
            if ( EQ_16( shift, MAX16B ) )
            {
                abs_val = L_shr( Mpy_32_32( pred_coeffs_re[ch][b], pred_coeffs_re[ch][b] ), guard_bits ); // q=2*q_pred_coeffs_re-guard_bits-31
                shift = 0;
                move16();
            }
            FOR( ch = 0; ch < ( num_ch - 1 ); ch++ )
            {
                abs_val = L_shr( Mpy_32_32( L_shl( pred_coeffs_re[ch][b], shift ), L_shl( pred_coeffs_re[ch][b], shift ) ), guard_bits ); // q=2*q_pred_coeffs_re-guard_bits-31
                g_sq = L_add( g_sq, abs_val );                                                                                            // q=2*q_pred_coeffs_re-guard_bits-31
            }
            q_g_sq = sub( add( q_pred_coeffs_re, q_pred_coeffs_re ), add( 31, guard_bits ) );
            q_g_sq = sub( shl( add( q_pred_coeffs_re, shift ), 1 ), add( 31, guard_bits ) );

            tmp = Mpy_32_32( ONE_IN_Q30 /*4 in Q28*/, Mpy_32_32( dm_f_local, g_sq ) ); // q_g_sq+28-31
            q_tmp = sub( q_g_sq, 3 );
+30 −20
Original line number Diff line number Diff line
@@ -554,15 +554,18 @@ static float ivas_calc_duck_gain(
static Word32 ivas_calc_duck_gain_fx(
    const Word32 duck_gain,  /*Q30*/
    const Word32 duck_coeff, /*Q30*/
    const Word32 env_1,      /*Q14*/
    const Word32 env_2,      /*Q14*/
    const Word32 env_1,      /*exp : env1_e*/
    const Word16 env1_e,
    const Word32 env_2, /*exp : env2_e*/
    const Word16 env2_e,
    const Word32 duck_mult_fac /*Q29*/ )
{
    Word32 duck_gain_out;
    Word32 duck_gain_out, L_tmp;
    Word16 tmp_e;

    duck_gain_out = L_add( L_shl( Mpy_32_32( L_sub( duck_gain, ONE_IN_Q30 ), duck_coeff ), Q1 ), ONE_IN_Q30 ); /*Q30*/

    IF( LT_32( Mpy_32_32( duck_mult_fac, env_1 ), Mpy_32_32( L_shr( duck_gain_out, 1 ), env_2 ) ) )
    IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( Mpy_32_32( duck_mult_fac, env_1 ), add( 2, env1_e ), Mpy_32_32( duck_gain_out, env_2 ), add( 1, env2_e ) ), -1 ) )
    {
        test();
        IF( ( env_1 == 0 ) || ( env_2 == 0 ) )
@@ -572,7 +575,10 @@ static Word32 ivas_calc_duck_gain_fx(
        }
        ELSE
        {
            duck_gain_out = Mpy_32_32( duck_mult_fac, L_shl( (Word32) ( divide3232( env_1, env_2 ) ), Q16 ) ); /*Q29*/
            L_tmp = BASOP_Util_Divide3232_Scale_cadence( env_1, env_2, &tmp_e );
            L_tmp = L_shl( L_tmp, add( sub( env1_e, env2_e ), tmp_e ) );

            duck_gain_out = Mpy_32_32( duck_mult_fac, L_tmp ); /*Q29*/
            duck_gain_out = L_shl( duck_gain_out, Q1 );        /*Q30*/
        }
    }
@@ -660,9 +666,9 @@ void ivas_td_decorr_get_ducking_gains_fx(
    const Word16 frame_len,           /*Q0*/
    const Word16 tdet_flag /*Q0*/ )
{
    Word16 i, q = Q14;
    move16();
    Word16 i;
    Word32 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k];
    Word16 e_fast_e[L_FRAME48k], e_slow_e[L_FRAME48k];
    Word32 in_duck_gain = hTranDet->in_duck_gain; /*Q30*/
    move32();
    Word32 out_duck_gain = hTranDet->out_duck_gain; /*Q30*/
@@ -676,30 +682,34 @@ void ivas_td_decorr_get_ducking_gains_fx(

    Copy32( pIn_pcm, e_fast_fx, frame_len ); /*Q11*/

    set16_fx( e_fast_e, 31 - Q11, L_FRAME48k );

    /* env hpf */
    ivas_filter_process_fx( &hTranDet->env_hpf, e_fast_fx, frame_len, q );
    ivas_filter_process_exp_fx( &hTranDet->env_hpf, e_fast_fx, frame_len, e_fast_e );

    Word16 q_factor_diff = sub( 31, q );

    FOR( i = 0; i < frame_len; i++ )
    {
        e_fast_fx[i] = L_add( L_abs( e_fast_fx[i] ), L_shr( IVAS_TDET_PARM_ENV_EPS_fx, q_factor_diff ) ); /*Q14*/
        // e_fast_fx[i] = L_add( L_abs( e_fast_fx[i] ), L_shr( IVAS_TDET_PARM_ENV_EPS_fx, q_factor_diff ) ); /*Q14*/
        e_fast_fx[i] = BASOP_Util_Add_Mant32Exp( L_abs( e_fast_fx[i] ), e_fast_e[i], IVAS_TDET_PARM_ENV_EPS_fx, 0, &e_fast_e[i] );
        move32();
        e_slow_fx[i] = e_fast_fx[i]; /*Q14*/
        e_slow_fx[i] = e_fast_fx[i];
        move32();
        e_slow_e[i] = e_fast_e[i];
        move16();
    }

    /* env fast*/
    ivas_filter_process_fx( &hTranDet->env_fast, e_fast_fx, frame_len, q );
    ivas_filter_process_exp_fx( &hTranDet->env_fast, e_fast_fx, frame_len, e_fast_e );

    /* env slow */
    ivas_filter_process_fx( &hTranDet->env_slow, e_slow_fx, frame_len, q );
    ivas_filter_process_exp_fx( &hTranDet->env_slow, e_slow_fx, frame_len, e_slow_e );

    IF( tdet_flag )
    {
        FOR( i = 0; i < frame_len; i++ )
        {
            in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], e_fast_fx[i], duck_mult_fac ); /*Q30*/
            in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], e_slow_e[i], e_fast_fx[i], e_fast_e[i], duck_mult_fac ); /*Q30*/
            pIn_duck_gains[i] = in_duck_gain;                                                                                                          /*Q30*/
            move32();
        }
@@ -710,10 +720,10 @@ void ivas_td_decorr_get_ducking_gains_fx(
    {
        FOR( i = 0; i < frame_len; i++ )
        {
            in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], e_fast_fx[i], duck_mult_fac ); /*Q30*/
            in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], e_slow_e[i], e_fast_fx[i], e_fast_e[i], duck_mult_fac ); /*Q30*/
            pIn_duck_gains[i] = in_duck_gain;                                                                                                          /*Q30*/
            move32();
            out_duck_gain = ivas_calc_duck_gain_fx( out_duck_gain, out_duck_coeff, e_fast_fx[i], e_slow_fx[i], duck_mult_fac ); /*Q30*/
            out_duck_gain = ivas_calc_duck_gain_fx( out_duck_gain, out_duck_coeff, e_fast_fx[i], e_fast_e[i], e_slow_fx[i], e_slow_e[i], duck_mult_fac ); /*Q30*/
            pOut_duck_gains[i] = out_duck_gain;                                                                                                           /*Q30*/
            move32();
        }
Loading