Commit 9208e1f5 authored by multrus's avatar multrus
Browse files

[cleanup] accept NONBE_OPT_2239_IVAS_FILTER_PROCESS

parent 70adb62b
Loading
Loading
Loading
Loading
+0 −199
Original line number Diff line number Diff line
@@ -67,40 +67,18 @@ void ivas_filters_init_fx(
            filter_state->den_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[i + IVAS_BIQUAD_FILT_LEN];
            move32();
            move32();
#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
            filter_state->num_shr[IVAS_FILTER_STAGE_0][i] = Q30 - Q31;
            filter_state->den_shr[IVAS_FILTER_STAGE_0][i] = Q30 - Q31;
            move16();
            move16();
#else
            filter_state->num_e[IVAS_FILTER_STAGE_0][i] = 1;
            filter_state->den_e[IVAS_FILTER_STAGE_0][i] = 1;
            move16();
            move16();
#endif
        }

#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
        filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0;
        move64();
        move64();
        move64();
#else
        filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0;
        move32();
        move32();
        move32();
        filter_state->state_e[0][0] = 0;
        filter_state->state_e[0][1] = 0;
        filter_state->state_e[0][2] = 0;
        move16();
        move16();
        move16();
#endif
    }
    ELSE
    {
@@ -117,7 +95,6 @@ void ivas_filters_init_fx(
            move32();
            move32();
            move32();
#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
            filter_state->num_shr[IVAS_FILTER_STAGE_0][i] = sub( sub( 31, filt_coeff_e[i + 0 * IVAS_BIQUAD_FILT_LEN] ), Q31 );
            filter_state->den_shr[IVAS_FILTER_STAGE_0][i] = sub( sub( 31, filt_coeff_e[i + 1 * IVAS_BIQUAD_FILT_LEN] ), Q31 );
            filter_state->num_shr[IVAS_FILTER_STAGE_1][i] = sub( sub( 31, filt_coeff_e[i + 2 * IVAS_BIQUAD_FILT_LEN] ), Q31 );
@@ -126,19 +103,8 @@ void ivas_filters_init_fx(
            move16();
            move16();
            move16();
#else
            filter_state->num_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i];
            filter_state->den_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN];
            filter_state->num_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 2];
            filter_state->den_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 3];
            move16();
            move16();
            move16();
            move16();
#endif
        }

#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
        filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0;
@@ -151,38 +117,11 @@ void ivas_filters_init_fx(
        move64();
        move64();
        move64();
#else
        filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_1][0] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_1][1] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_1][2] = 0;
        move32();
        move32();
        move32();
        move32();
        move32();
        move32();
        filter_state->state_e[0][0] = 0;
        filter_state->state_e[0][1] = 0;
        filter_state->state_e[0][2] = 0;
        filter_state->state_e[1][0] = 0;
        filter_state->state_e[1][1] = 0;
        filter_state->state_e[1][2] = 0;
        move16();
        move16();
        move16();
        move16();
        move16();
        move16();
#endif
    }

    return;
}

#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
static Word64 ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, const Word16 stage, const Word64 in );

/*-----------------------------------------------------------------------------------------*
@@ -309,141 +248,3 @@ void ivas_filter_process_fx64(
    return;
}
#else
static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 *pIn_Out_e );

/*-----------------------------------------------------------------------------------------*
 * Function ivas_filter_process()
 *
 * Process call for selecting the type filter
 *-----------------------------------------------------------------------------------------*/

void ivas_filter_process_fx(
    ivas_filters_process_state_t *filter_state, /* i/o: filter state handle             */
    Word32 *pIn_Out_fx,                         /* i/o: signal subject to filtering Q(q_factor)   */
    const Word16 length,                        /* i  : number of samples to filter     */
    Word16 q_factor )
{
    Word16 pIn_Out_e[L_FRAME_MAX];
    Word16 i;

    SWITCH( filter_state->order )
    {
        case IVAS_FILTER_ORDER_1:
            set_val_Word16( pIn_Out_e, sub( Q31, q_factor ), length );
            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 */
            FOR( i = 0; i < length; i++ )
            {
                pIn_Out_fx[i] = L_shr_r_sat( pIn_Out_fx[i], sub( sub( 31, q_factor ), pIn_Out_e[i] ) ); // Q(31-pIn_Out_e[i]) -> Q(q_factor)
                move32();
            }
            BREAK;
        case IVAS_FILTER_ORDER_4:
            set_val_Word16( pIn_Out_e, sub( Q31, q_factor ), length );
            /* 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 */
            FOR( i = 0; i < length; i++ )
            {
                pIn_Out_fx[i] = L_shr_r_sat( pIn_Out_fx[i], sub( sub( 31, q_factor ), pIn_Out_e[i] ) ); // Q(31-pIn_Out_e[i]) -> Q(q_factor)
                move32();
            }
            BREAK;
        default:
            BREAK;
    }

    return;
}

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  : number of samples to filter     */
    Word16 *pIn_Out_e )
{
    SWITCH( filter_state->order )
    {
        case IVAS_FILTER_ORDER_1:
            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()
 *
 * Process call for filtering a signal
 *-----------------------------------------------------------------------------------------*/

static void ivas_iir_2_filter_fx(
    ivas_filters_process_state_t *filter_state,
    Word32 *pIn_Out_fx, // Q(31-*pIn_Out_e)
    const Word16 length,
    const Word16 stage,
    Word16 *pIn_Out_e )
{
    Word16 i, j;

    Word32 *pIn_fx = pIn_Out_fx;
    Word32 *pOut_fx = pIn_Out_fx;
    Word32 tmp_pIn_buf_i_fx;
    Word16 tmp_pIn_buf_i_e;

    Word32 L_tmp_prod, L_tmp;
    Word16 L_prod_e, L_tmp_e;

    FOR( i = 0; i < length; i++ )
    {
        tmp_pIn_buf_i_fx = pIn_fx[i];
        move32();
        tmp_pIn_buf_i_e = pIn_Out_e[i];
        move16();

        L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][0], pIn_fx[i] ); // Q31 -(pIn_Out_e[i]+ filter_state->num_e[stage][0])
        L_prod_e = add( pIn_Out_e[i], filter_state->num_e[stage][0] );

        pOut_fx[i] = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][0], filter_state->state_e[stage][0], L_tmp_prod, L_prod_e, &pIn_Out_e[i] ); // Q31 - pIn_Out_e[i]
        move32();

        FOR( j = 1; j < filter_state->filt_len; j++ )
        {
            L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][j], tmp_pIn_buf_i_fx ); // Q31-L_prod_e
            L_prod_e = add( filter_state->num_e[stage][j], tmp_pIn_buf_i_e );

            L_tmp = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][j], filter_state->state_e[stage][j], L_tmp_prod, L_prod_e, &L_tmp_e ); // Q31 - L_tmp_e

            L_tmp_prod = Mpy_32_32( filter_state->den_fx[stage][j], pOut_fx[i] ); // Q31 - ( pIn_Out_e[i]+filter_state->den_e[stage][j] )
            L_prod_e = add( pIn_Out_e[i], filter_state->den_e[stage][j] );

            filter_state->state_fx[stage][j - 1] = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_e, L_negate( L_tmp_prod ), L_prod_e, &filter_state->state_e[stage][j - 1] ); // Q31 - filter_state->state_e[stage][j - 1]
            move32();
            /*In case when exponent is less than -31 the value is very small and negligible hence resetting it to zero to avoid exponent overflow*/
            IF( LT_16( filter_state->state_e[stage][j - 1], -31 ) )
            {
                filter_state->state_fx[stage][j - 1] = 0;
                move32();
                filter_state->state_e[stage][j - 1] = 0;
                move16();
            }
        }
    }

    return;
}
#endif
+0 −16
Original line number Diff line number Diff line
@@ -3775,7 +3775,6 @@ void ivas_lfe_enc_fx(
    BSTR_ENC_HANDLE hBstr                                       /* i/o: bitstream handle                                */
);

#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
void ivas_filter_process_fx32(
    ivas_filters_process_state_t *filter_state,                 /* i/o: filter state handle                             */
    Word32 *pIn_Out_fx,                                         /* i  : signal subject to filtering                     */
@@ -3787,21 +3786,6 @@ void ivas_filter_process_fx64(
    Word64 *pIn_Out_fx,                                         /* i  : signal subject to filtering                     */
    const Word16 length                                         /* i  : number of samples to filter                     */
);
#else
void ivas_filter_process_fx(
    ivas_filters_process_state_t *filter_state,                 /* i/o: filter state handle                             */
    Word32 *pIn_Out_fx,                                         /* i  : signal subject to filtering                     */
    const Word16 length,                                        /* i  : number of samples to filter                     */
    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  : number of samples to filter                     */
    Word16 *pIn_Out_e 
);
#endif
ivas_error ivas_osba_enc_open_fx(
    Encoder_Struct *st_ivas                                     /* i/o: IVAS encoder handle                             */
);
+0 −7
Original line number Diff line number Diff line
@@ -655,16 +655,9 @@ typedef struct ivas_filters_process_state_t
    Word16 filt_len;
    Word32 num_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
    Word32 den_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
    Word64 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
    Word16 num_shr[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
    Word16 den_shr[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
#else
    Word32 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
    Word16 num_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
    Word16 den_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
    Word16 state_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
#endif

} ivas_filters_process_state_t;

+0 −62
Original line number Diff line number Diff line
@@ -44,11 +44,7 @@
 *------------------------------------------------------------------------------------------*/

#define IVAS_TDET_PARM_ENV_EPS ( 1e-5f )
#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
#define IVAS_TDET_PARM_ENV_EPS_fx ( ( (Word64) 21474 ) << 12 ) // Q11+32
#else
#define IVAS_TDET_PARM_ENV_EPS_fx 21474 // Q31
#endif

#define IVAS_TDET_DUCK_MULT_FAC   ( 590558003 ) // Q29
#define IVAS_TDET_PARM_TRANS_THR  ( 107374182 ) // Q30
@@ -396,7 +392,6 @@ void ivas_td_decorr_get_ducking_gains_fx(
    Word32 duck_mult_fac = hTranDet->duck_mult_fac; /*Q29*/
    move32();

#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
    Word64 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k];
    Word32 fast_fx, slow_fx;
    Word16 fast_e, slow_e;
@@ -465,63 +460,6 @@ void ivas_td_decorr_get_ducking_gains_fx(
        hTranDet->out_duck_gain = out_duck_gain; /*Q30*/
        move32();
    }
#else
    Word32 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k];
    Word16 e_fast_e[L_FRAME48k], e_slow_e[L_FRAME48k];

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

    set16_fx( e_fast_e, 31 - Q11, L_FRAME48k );

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


    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] = 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];
        move32();
        e_slow_e[i] = e_fast_e[i];
        move16();
    }

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

    /* env slow */
    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_slow_e[i], e_fast_fx[i], e_fast_e[i], duck_mult_fac ); /*Q30*/
            pIn_duck_gains[i] = in_duck_gain;                                                                                                          /*Q30*/
            move32();
        }
        hTranDet->in_duck_gain = in_duck_gain; /*Q30*/
        move32();
    }
    ELSE
    {
        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_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_fast_e[i], e_slow_fx[i], e_slow_e[i], duck_mult_fac ); /*Q30*/
            pOut_duck_gains[i] = out_duck_gain;                                                                                                           /*Q30*/
            move32();
        }
        hTranDet->in_duck_gain = in_duck_gain; /*Q30*/
        move32();
        hTranDet->out_duck_gain = out_duck_gain; /*Q30*/
        move32();
    }
#endif

    return;
}
+0 −1
Original line number Diff line number Diff line
@@ -115,7 +115,6 @@

/* #################### Start BASOP optimization switches ############################ */

#define NONBE_OPT_2239_IVAS_FILTER_PROCESS              /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */
#define NONBE_OPT_2193_EIG2X2                           /* Dolby: Issue 2193, optimize eig2x2_fx. */

/* #################### End BASOP optimization switches ############################ */
Loading