Loading lib_com/ivas_filters_fx.c +180 −145 Original line number Diff line number Diff line Loading @@ -38,14 +38,6 @@ #include "ivas_rom_com.h" #include "ivas_prot_fx.h" /*------------------------------------------------------------------------------------------* * Local functions declaration *------------------------------------------------------------------------------------------*/ 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 ); static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); static void ivas_iir_2_filter_fx64( ivas_filters_process_state_t *filter_state, Word64 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); /*-----------------------------------------------------------------------------------------* * Function ivas_filters_init() * Loading Loading @@ -204,6 +196,185 @@ void ivas_filters_init_fx( return; } #ifdef OPT_2239_IVAS_FILTER_PROCESS static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); static void ivas_iir_2_filter_fx64( ivas_filters_process_state_t *filter_state, Word64 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ); /*-----------------------------------------------------------------------------------------* * Function Mpy_64_32() * * Performs the the following operation: * * z = ((int128_t)x * (int128_t)y) >> 31 * * where: * - x is a 64-bit signed integer * - y is a 32-bit signed integer * - z is a 64-bit signed integer *-----------------------------------------------------------------------------------------*/ static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ) { Word32 var1_l; Word64 var_out; var1_l = W_extract_l( W_var1 ); // 1 var_out = W_mult0_32_32( L_and( var1_l, 1 ), L_var2 ); // 2 var_out = W_mac_32_32( var_out, L_lshr( var1_l, 1 ), L_var2 ); // 2 var_out = W_mac_32_32( W_shr( var_out, 31 ), W_extract_h( W_var1 ), L_var2 ); // 3 return var_out; } /*-----------------------------------------------------------------------------------------* * Function ivas_iir_2_filter_fx32() * * Process call for filtering a signal *-----------------------------------------------------------------------------------------*/ static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ) { Word64 tmp_prod, tmp; Word32 in, out; Word16 i, j, shift; FOR( i = 0; i < length; i++ ) { in = pIn_Out_fx[i]; move32(); shift = filter_state->num_q[stage][0] + q - filter_state->state64_q[stage]; tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][0], in ), shift ); shift = sub( filter_state->state64_q[stage], q ); pIn_Out_fx[i] = out = W_extract_l( W_shr( W_add( filter_state->state64_fx[stage][0], tmp_prod ), shift ) ); move32(); FOR( j = 1; j < filter_state->filt_len; j++ ) { shift = filter_state->num_q[stage][j] + q - filter_state->state64_q[stage]; tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][j], in ), shift ); tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); shift = filter_state->den_q[stage][j] + q - filter_state->state64_q[stage]; tmp_prod = W_shr( W_mult0_32_32( filter_state->den_fx[stage][j], out ), shift ); filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); move32(); } } return; } /*-----------------------------------------------------------------------------------------* * Function ivas_filter_process_fx32() * * Process call for filtering a signal *-----------------------------------------------------------------------------------------*/ void ivas_filter_process_fx32( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q) */ const Word16 length, /* i : filter order */ Word16 q ) { SWITCH( filter_state->order ) { case IVAS_FILTER_ORDER_1: ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); BREAK; case IVAS_FILTER_ORDER_4: ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q ); BREAK; default: BREAK; } return; } /*-----------------------------------------------------------------------------------------* * Function ivas_iir_2_filter_fx64() * * Process call for filtering a signal *-----------------------------------------------------------------------------------------*/ static void ivas_iir_2_filter_fx64( ivas_filters_process_state_t *filter_state, Word64 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ) { Word64 tmp_prod, tmp, in, out; Word16 i, j, shift; FOR( i = 0; i < length; i++ ) { in = pIn_Out_fx[i]; move32(); shift = ( filter_state->num_q[stage][0] + q - 31 ) - q; tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][0] ), shift ); pIn_Out_fx[i] = out = W_add( filter_state->state64_fx[stage][0], tmp_prod ); move32(); FOR( j = 1; j < filter_state->filt_len; j++ ) { shift = ( filter_state->num_q[stage][j] + q - 31 ) - q; tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][j] ), shift ); tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); shift = ( filter_state->den_q[stage][j] + q - 31 ) - q; tmp_prod = W_shr( Mpy_64_32( out, filter_state->den_fx[stage][j] ), shift ); filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); move32(); } } return; } /*-----------------------------------------------------------------------------------------* * Function ivas_filter_process_fx64() * * Process call for filtering a signal *-----------------------------------------------------------------------------------------*/ void ivas_filter_process_fx64( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word64 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q) */ const Word16 length, /* i : filter order */ Word16 q ) { SWITCH( filter_state->order ) { case IVAS_FILTER_ORDER_1: ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); BREAK; case IVAS_FILTER_ORDER_4: ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q ); BREAK; default: BREAK; } 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() Loading Loading @@ -252,7 +423,6 @@ void ivas_filter_process_fx( 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]) */ Loading @@ -279,7 +449,6 @@ void ivas_filter_process_exp_fx( return; } /*-----------------------------------------------------------------------------------------* * Function ivas_iir_2_filter() * Loading Loading @@ -341,138 +510,4 @@ static void ivas_iir_2_filter_fx( return; } void ivas_filter_process_fx32( 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 : filter order */ Word16 q ) { SWITCH( filter_state->order ) { case IVAS_FILTER_ORDER_1: ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); BREAK; case IVAS_FILTER_ORDER_4: ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q ); BREAK; default: BREAK; } return; } void ivas_filter_process_fx64( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word64 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ const Word16 length, /* i : filter order */ Word16 q ) { SWITCH( filter_state->order ) { case IVAS_FILTER_ORDER_1: ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); BREAK; case IVAS_FILTER_ORDER_4: ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q ); BREAK; default: BREAK; } return; } static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ) { Word64 tmp_prod, tmp; Word32 in, out; Word16 i, j, shift; FOR( i = 0; i < length; i++ ) { in = pIn_Out_fx[i]; move32(); shift = filter_state->num_q[stage][0] + q - filter_state->state64_q[stage]; tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][0], in ), shift ); shift = sub( filter_state->state64_q[stage], q ); pIn_Out_fx[i] = out = W_extract_l( W_shr( W_add( filter_state->state64_fx[stage][0], tmp_prod ), shift ) ); move32(); FOR( j = 1; j < filter_state->filt_len; j++ ) { shift = filter_state->num_q[stage][j] + q - filter_state->state64_q[stage]; tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][j], in ), shift ); tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); shift = filter_state->den_q[stage][j] + q - filter_state->state64_q[stage]; tmp_prod = W_shr( W_mult0_32_32( filter_state->den_fx[stage][j], out ), shift ); filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); move32(); } } return; } static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ) { Word32 var1_l; Word64 var_out; var1_l = W_extract_l( W_var1 ); // 1 var_out = W_mult0_32_32( L_and( var1_l, 1 ), L_var2 ); // 2 var_out = W_mac_32_32( var_out, L_lshr( var1_l, 1 ), L_var2 ); // 2 var_out = W_mac_32_32( W_shr( var_out, 31 ), W_extract_h( W_var1 ), L_var2 ); // 3 return var_out; } static void ivas_iir_2_filter_fx64( ivas_filters_process_state_t *filter_state, Word64 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ) { Word64 tmp_prod, tmp, in, out; Word16 i, j, shift; FOR( i = 0; i < length; i++ ) { in = pIn_Out_fx[i]; move32(); shift = ( filter_state->num_q[stage][0] + q - 31 ) - q; tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][0] ), shift ); pIn_Out_fx[i] = out = W_add( filter_state->state64_fx[stage][0], tmp_prod ); move32(); FOR( j = 1; j < filter_state->filt_len; j++ ) { shift = ( filter_state->num_q[stage][j] + q - 31 ) - q; tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][j] ), shift ); tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); shift = ( filter_state->den_q[stage][j] + q - 31 ) - q; tmp_prod = W_shr( Mpy_64_32( out, filter_state->den_fx[stage][j] ), shift ); filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); move32(); } } return; } #endif lib_com/ivas_prot_fx.h +13 −19 Original line number Diff line number Diff line Loading @@ -3803,34 +3803,35 @@ void ivas_lfe_enc_fx( BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ ); void ivas_filter_process_fx( #ifdef 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 */ const Word16 length, /* i : filter order */ Word16 q_factor Word16 q ); void ivas_filter_process_exp_fx( void ivas_filter_process_fx64( 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]) */ Word64 *pIn_Out_fx, /* i : signal subject to filtering */ const Word16 length, /* i : filter order */ Word16 *pIn_Out_e Word16 q ); void ivas_filter_process_fx32( #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 : filter order */ Word16 q Word16 q_factor ); void ivas_filter_process_fx64( void ivas_filter_process_exp_fx( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word64 *pIn_Out_fx, /* i : signal subject to filtering */ Word32 *pIn_Out_fx, /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i]) */ const Word16 length, /* i : filter order */ Word16 q Word16 *pIn_Out_e ); #endif ivas_error ivas_osba_enc_open_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ); Loading Loading @@ -6821,13 +6822,6 @@ void ivas_filters_init_fx( const Word16 order ); 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 : filter order */ Word16 q_factor ); /*----------------------------------------------------------------------------------* * OSBA prototypes *----------------------------------------------------------------------------------*/ Loading lib_com/ivas_transient_det_fx.c +16 −89 Original line number Diff line number Diff line Loading @@ -401,6 +401,8 @@ void ivas_td_decorr_get_ducking_gains_fx( #ifdef 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; FOR( i = 0; i < frame_len; i++ ) { Loading Loading @@ -429,11 +431,11 @@ void ivas_td_decorr_get_ducking_gains_fx( { FOR( i = 0; i < frame_len; i++ ) { Word16 fast_e = W_norm( e_fast_fx[i] ); Word32 fast_fx = W_extract_h( W_shl( e_fast_fx[i], fast_e ) ); /*Q43 + fast_e - 32 = Q11 + fast_e*/ fast_e = W_norm( e_fast_fx[i] ); fast_fx = W_extract_h( W_shl( e_fast_fx[i], fast_e ) ); /*Q43 + fast_e - 32 = Q11 + fast_e*/ fast_e = sub( 20, fast_e ); /*exp: 31 - (Q11 + fast_e) = 20 - fast_e*/ Word16 slow_e = W_norm( e_slow_fx[i] ); Word32 slow_fx = W_extract_h( W_shl( e_slow_fx[i], slow_e ) ); /*Q43 + fast_e - 32 = Q11 + slow_e*/ slow_e = W_norm( e_slow_fx[i] ); slow_fx = W_extract_h( W_shl( e_slow_fx[i], slow_e ) ); /*Q43 + fast_e - 32 = Q11 + slow_e*/ slow_e = sub( 20, slow_e ); /*exp: 31 - (Q11 + slow_e) = 20 - slow_e*/ in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, slow_fx, slow_e, fast_fx, fast_e, duck_mult_fac ); /*Q30*/ Loading @@ -447,11 +449,11 @@ void ivas_td_decorr_get_ducking_gains_fx( { FOR( i = 0; i < frame_len; i++ ) { Word16 fast_e = W_norm( e_fast_fx[i] ); Word32 fast_fx = W_extract_h( W_shl( e_fast_fx[i], fast_e ) ); /*Q43 + fast_e - 32 = Q11 + fast_e*/ fast_e = W_norm( e_fast_fx[i] ); fast_fx = W_extract_h( W_shl( e_fast_fx[i], fast_e ) ); /*Q43 + fast_e - 32 = Q11 + fast_e*/ fast_e = sub( 20, fast_e ); /*exp: 31 - (Q11 + fast_e) = 20 - fast_e*/ Word16 slow_e = W_norm( e_slow_fx[i] ); Word32 slow_fx = W_extract_h( W_shl( e_slow_fx[i], slow_e ) ); /*Q43 + fast_e - 32 = Q11 + slow_e*/ slow_e = W_norm( e_slow_fx[i] ); slow_fx = W_extract_h( W_shl( e_slow_fx[i], slow_e ) ); /*Q43 + fast_e - 32 = Q11 + slow_e*/ slow_e = sub( 20, slow_e ); /*exp: 31 - (Q11 + slow_e) = 20 - slow_e*/ in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, slow_fx, slow_e, fast_fx, fast_e, duck_mult_fac ); /*Q30*/ Loading @@ -468,34 +470,16 @@ void ivas_td_decorr_get_ducking_gains_fx( } #else Word32 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k]; Copy32( pIn_pcm, e_fast_fx, frame_len ); /*Q11*/ 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 ); // ==================================================================================================== Word64 test_e_fast_fx[L_FRAME48k]; Word16 q_fast = Q43; for ( i = 0; i < frame_len; i++ ) { test_e_fast_fx[i] = (Word64) pIn_pcm[i] << 32; } ivas_filter_process_fx64( &hTranDet->test_env_hpf, test_e_fast_fx, frame_len, q_fast ); for ( i = 0; i < frame_len; i++ ) { check( test_e_fast_fx[i], q_fast, e_fast_fx[i], 31 - e_fast_e[i] ); } // ==================================================================================================== 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*/ Loading @@ -507,68 +491,12 @@ void ivas_td_decorr_get_ducking_gains_fx( move16(); } // ==================================================================================================== // Word32 test_e_slow_fx[L_FRAME48k]; // Word32 env_eps_fx = IVAS_TDET_PARM_ENV_EPS_fx; // Word16 env_eps_q = Q31; // Word16 q_diff = sub( q_fast, env_eps_q ); // q_fast = s_min( q_fast, env_eps_q ); // if ( q_diff >= 0 ) // { // for ( i = 0; i < frame_len; i++ ) // { // test_e_fast_fx[i] = L_add( L_abs( L_shr( test_e_fast_fx[i], q_diff ) ), env_eps_fx ); // move32(); // test_e_slow_fx[i] = test_e_fast_fx[i]; // move32(); // } // } // else // { // env_eps_fx = L_shl( env_eps_fx, q_diff ); // for ( i = 0; i < frame_len; i++ ) // { // test_e_fast_fx[i] = L_add( L_abs( test_e_fast_fx[i] ), env_eps_fx ); // move32(); // test_e_slow_fx[i] = test_e_fast_fx[i]; // move32(); // } // } // Word16 q_slow = q_fast; // for ( i = 0; i < frame_len; i++ ) // { // check( test_e_fast_fx[i], q_fast, e_fast_fx[i], 31 - e_fast_e[i] ); // } // ==================================================================================================== /* env fast*/ ivas_filter_process_exp_fx( &hTranDet->env_fast, e_fast_fx, frame_len, e_fast_e ); // ==================================================================================================== // ivas_filter_process_fx32( &hTranDet->test_env_fast, test_e_fast_fx, frame_len, q_fast ); // for ( i = 0; i < frame_len; i++ ) // { // check( test_e_fast_fx[i], q_fast, e_fast_fx[i], 31 - e_fast_e[i] ); // } // ==================================================================================================== /* env slow */ ivas_filter_process_exp_fx( &hTranDet->env_slow, e_slow_fx, frame_len, e_slow_e ); // ==================================================================================================== // ivas_filter_process_fx32( &hTranDet->test_env_slow, test_e_slow_fx, frame_len, q_slow ); // for ( i = 0; i < frame_len; i++ ) // { // check( test_e_slow_fx[i], q_slow, e_slow_fx[i], 31 - e_slow_e[i] ); // } // ==================================================================================================== IF( tdet_flag ) { FOR( i = 0; i < frame_len; i++ ) Loading Loading @@ -598,6 +526,5 @@ void ivas_td_decorr_get_ducking_gains_fx( } #endif return; } lib_dec/ivas_lfe_dec_fx.c +4 −0 Original line number Diff line number Diff line Loading @@ -408,7 +408,11 @@ void ivas_lfe_dec_fx( IF( hLFE->filter_state.order > 0 ) { /* Low Pass Filter */ #ifdef OPT_2239_IVAS_FILTER_PROCESS ivas_filter_process_fx32( &hLFE->filter_state, output_lfe_ch, output_frame, q_out ); #else ivas_filter_process_fx( &hLFE->filter_state, output_lfe_ch, output_frame, q_out ); #endif } /* add delay to make overall max(block_offset, 11.5) */ Loading lib_enc/ivas_lfe_enc_fx.c +4 −0 Original line number Diff line number Diff line Loading @@ -684,7 +684,11 @@ void ivas_lfe_lpf_enc_apply_fx( const Word16 input_frame /* i : input frame length per channel */ ) { #ifdef OPT_2239_IVAS_FILTER_PROCESS ivas_filter_process_fx32( hLfeLpf, data_lfe_ch, input_frame, (Word16) Q11 ); #else ivas_filter_process_fx( hLfeLpf, data_lfe_ch, input_frame, (Word16) Q11 ); #endif return; } Loading
lib_com/ivas_filters_fx.c +180 −145 Original line number Diff line number Diff line Loading @@ -38,14 +38,6 @@ #include "ivas_rom_com.h" #include "ivas_prot_fx.h" /*------------------------------------------------------------------------------------------* * Local functions declaration *------------------------------------------------------------------------------------------*/ 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 ); static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); static void ivas_iir_2_filter_fx64( ivas_filters_process_state_t *filter_state, Word64 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); /*-----------------------------------------------------------------------------------------* * Function ivas_filters_init() * Loading Loading @@ -204,6 +196,185 @@ void ivas_filters_init_fx( return; } #ifdef OPT_2239_IVAS_FILTER_PROCESS static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); static void ivas_iir_2_filter_fx64( ivas_filters_process_state_t *filter_state, Word64 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ); static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ); /*-----------------------------------------------------------------------------------------* * Function Mpy_64_32() * * Performs the the following operation: * * z = ((int128_t)x * (int128_t)y) >> 31 * * where: * - x is a 64-bit signed integer * - y is a 32-bit signed integer * - z is a 64-bit signed integer *-----------------------------------------------------------------------------------------*/ static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ) { Word32 var1_l; Word64 var_out; var1_l = W_extract_l( W_var1 ); // 1 var_out = W_mult0_32_32( L_and( var1_l, 1 ), L_var2 ); // 2 var_out = W_mac_32_32( var_out, L_lshr( var1_l, 1 ), L_var2 ); // 2 var_out = W_mac_32_32( W_shr( var_out, 31 ), W_extract_h( W_var1 ), L_var2 ); // 3 return var_out; } /*-----------------------------------------------------------------------------------------* * Function ivas_iir_2_filter_fx32() * * Process call for filtering a signal *-----------------------------------------------------------------------------------------*/ static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ) { Word64 tmp_prod, tmp; Word32 in, out; Word16 i, j, shift; FOR( i = 0; i < length; i++ ) { in = pIn_Out_fx[i]; move32(); shift = filter_state->num_q[stage][0] + q - filter_state->state64_q[stage]; tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][0], in ), shift ); shift = sub( filter_state->state64_q[stage], q ); pIn_Out_fx[i] = out = W_extract_l( W_shr( W_add( filter_state->state64_fx[stage][0], tmp_prod ), shift ) ); move32(); FOR( j = 1; j < filter_state->filt_len; j++ ) { shift = filter_state->num_q[stage][j] + q - filter_state->state64_q[stage]; tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][j], in ), shift ); tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); shift = filter_state->den_q[stage][j] + q - filter_state->state64_q[stage]; tmp_prod = W_shr( W_mult0_32_32( filter_state->den_fx[stage][j], out ), shift ); filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); move32(); } } return; } /*-----------------------------------------------------------------------------------------* * Function ivas_filter_process_fx32() * * Process call for filtering a signal *-----------------------------------------------------------------------------------------*/ void ivas_filter_process_fx32( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q) */ const Word16 length, /* i : filter order */ Word16 q ) { SWITCH( filter_state->order ) { case IVAS_FILTER_ORDER_1: ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); BREAK; case IVAS_FILTER_ORDER_4: ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q ); BREAK; default: BREAK; } return; } /*-----------------------------------------------------------------------------------------* * Function ivas_iir_2_filter_fx64() * * Process call for filtering a signal *-----------------------------------------------------------------------------------------*/ static void ivas_iir_2_filter_fx64( ivas_filters_process_state_t *filter_state, Word64 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ) { Word64 tmp_prod, tmp, in, out; Word16 i, j, shift; FOR( i = 0; i < length; i++ ) { in = pIn_Out_fx[i]; move32(); shift = ( filter_state->num_q[stage][0] + q - 31 ) - q; tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][0] ), shift ); pIn_Out_fx[i] = out = W_add( filter_state->state64_fx[stage][0], tmp_prod ); move32(); FOR( j = 1; j < filter_state->filt_len; j++ ) { shift = ( filter_state->num_q[stage][j] + q - 31 ) - q; tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][j] ), shift ); tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); shift = ( filter_state->den_q[stage][j] + q - 31 ) - q; tmp_prod = W_shr( Mpy_64_32( out, filter_state->den_fx[stage][j] ), shift ); filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); move32(); } } return; } /*-----------------------------------------------------------------------------------------* * Function ivas_filter_process_fx64() * * Process call for filtering a signal *-----------------------------------------------------------------------------------------*/ void ivas_filter_process_fx64( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word64 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q) */ const Word16 length, /* i : filter order */ Word16 q ) { SWITCH( filter_state->order ) { case IVAS_FILTER_ORDER_1: ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); BREAK; case IVAS_FILTER_ORDER_4: ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q ); BREAK; default: BREAK; } 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() Loading Loading @@ -252,7 +423,6 @@ void ivas_filter_process_fx( 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]) */ Loading @@ -279,7 +449,6 @@ void ivas_filter_process_exp_fx( return; } /*-----------------------------------------------------------------------------------------* * Function ivas_iir_2_filter() * Loading Loading @@ -341,138 +510,4 @@ static void ivas_iir_2_filter_fx( return; } void ivas_filter_process_fx32( 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 : filter order */ Word16 q ) { SWITCH( filter_state->order ) { case IVAS_FILTER_ORDER_1: ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); BREAK; case IVAS_FILTER_ORDER_4: ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); ivas_iir_2_filter_fx32( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q ); BREAK; default: BREAK; } return; } void ivas_filter_process_fx64( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word64 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ const Word16 length, /* i : filter order */ Word16 q ) { SWITCH( filter_state->order ) { case IVAS_FILTER_ORDER_1: ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); BREAK; case IVAS_FILTER_ORDER_4: ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q ); ivas_iir_2_filter_fx64( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q ); BREAK; default: BREAK; } return; } static void ivas_iir_2_filter_fx32( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ) { Word64 tmp_prod, tmp; Word32 in, out; Word16 i, j, shift; FOR( i = 0; i < length; i++ ) { in = pIn_Out_fx[i]; move32(); shift = filter_state->num_q[stage][0] + q - filter_state->state64_q[stage]; tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][0], in ), shift ); shift = sub( filter_state->state64_q[stage], q ); pIn_Out_fx[i] = out = W_extract_l( W_shr( W_add( filter_state->state64_fx[stage][0], tmp_prod ), shift ) ); move32(); FOR( j = 1; j < filter_state->filt_len; j++ ) { shift = filter_state->num_q[stage][j] + q - filter_state->state64_q[stage]; tmp_prod = W_shr( W_mult0_32_32( filter_state->num_fx[stage][j], in ), shift ); tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); shift = filter_state->den_q[stage][j] + q - filter_state->state64_q[stage]; tmp_prod = W_shr( W_mult0_32_32( filter_state->den_fx[stage][j], out ), shift ); filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); move32(); } } return; } static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 ) { Word32 var1_l; Word64 var_out; var1_l = W_extract_l( W_var1 ); // 1 var_out = W_mult0_32_32( L_and( var1_l, 1 ), L_var2 ); // 2 var_out = W_mac_32_32( var_out, L_lshr( var1_l, 1 ), L_var2 ); // 2 var_out = W_mac_32_32( W_shr( var_out, 31 ), W_extract_h( W_var1 ), L_var2 ); // 3 return var_out; } static void ivas_iir_2_filter_fx64( ivas_filters_process_state_t *filter_state, Word64 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q ) { Word64 tmp_prod, tmp, in, out; Word16 i, j, shift; FOR( i = 0; i < length; i++ ) { in = pIn_Out_fx[i]; move32(); shift = ( filter_state->num_q[stage][0] + q - 31 ) - q; tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][0] ), shift ); pIn_Out_fx[i] = out = W_add( filter_state->state64_fx[stage][0], tmp_prod ); move32(); FOR( j = 1; j < filter_state->filt_len; j++ ) { shift = ( filter_state->num_q[stage][j] + q - 31 ) - q; tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][j] ), shift ); tmp = W_add( filter_state->state64_fx[stage][j], tmp_prod ); shift = ( filter_state->den_q[stage][j] + q - 31 ) - q; tmp_prod = W_shr( Mpy_64_32( out, filter_state->den_fx[stage][j] ), shift ); filter_state->state64_fx[stage][j - 1] = W_sub( tmp, tmp_prod ); move32(); } } return; } #endif
lib_com/ivas_prot_fx.h +13 −19 Original line number Diff line number Diff line Loading @@ -3803,34 +3803,35 @@ void ivas_lfe_enc_fx( BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ ); void ivas_filter_process_fx( #ifdef 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 */ const Word16 length, /* i : filter order */ Word16 q_factor Word16 q ); void ivas_filter_process_exp_fx( void ivas_filter_process_fx64( 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]) */ Word64 *pIn_Out_fx, /* i : signal subject to filtering */ const Word16 length, /* i : filter order */ Word16 *pIn_Out_e Word16 q ); void ivas_filter_process_fx32( #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 : filter order */ Word16 q Word16 q_factor ); void ivas_filter_process_fx64( void ivas_filter_process_exp_fx( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word64 *pIn_Out_fx, /* i : signal subject to filtering */ Word32 *pIn_Out_fx, /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i]) */ const Word16 length, /* i : filter order */ Word16 q Word16 *pIn_Out_e ); #endif ivas_error ivas_osba_enc_open_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ); Loading Loading @@ -6821,13 +6822,6 @@ void ivas_filters_init_fx( const Word16 order ); 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 : filter order */ Word16 q_factor ); /*----------------------------------------------------------------------------------* * OSBA prototypes *----------------------------------------------------------------------------------*/ Loading
lib_com/ivas_transient_det_fx.c +16 −89 Original line number Diff line number Diff line Loading @@ -401,6 +401,8 @@ void ivas_td_decorr_get_ducking_gains_fx( #ifdef 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; FOR( i = 0; i < frame_len; i++ ) { Loading Loading @@ -429,11 +431,11 @@ void ivas_td_decorr_get_ducking_gains_fx( { FOR( i = 0; i < frame_len; i++ ) { Word16 fast_e = W_norm( e_fast_fx[i] ); Word32 fast_fx = W_extract_h( W_shl( e_fast_fx[i], fast_e ) ); /*Q43 + fast_e - 32 = Q11 + fast_e*/ fast_e = W_norm( e_fast_fx[i] ); fast_fx = W_extract_h( W_shl( e_fast_fx[i], fast_e ) ); /*Q43 + fast_e - 32 = Q11 + fast_e*/ fast_e = sub( 20, fast_e ); /*exp: 31 - (Q11 + fast_e) = 20 - fast_e*/ Word16 slow_e = W_norm( e_slow_fx[i] ); Word32 slow_fx = W_extract_h( W_shl( e_slow_fx[i], slow_e ) ); /*Q43 + fast_e - 32 = Q11 + slow_e*/ slow_e = W_norm( e_slow_fx[i] ); slow_fx = W_extract_h( W_shl( e_slow_fx[i], slow_e ) ); /*Q43 + fast_e - 32 = Q11 + slow_e*/ slow_e = sub( 20, slow_e ); /*exp: 31 - (Q11 + slow_e) = 20 - slow_e*/ in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, slow_fx, slow_e, fast_fx, fast_e, duck_mult_fac ); /*Q30*/ Loading @@ -447,11 +449,11 @@ void ivas_td_decorr_get_ducking_gains_fx( { FOR( i = 0; i < frame_len; i++ ) { Word16 fast_e = W_norm( e_fast_fx[i] ); Word32 fast_fx = W_extract_h( W_shl( e_fast_fx[i], fast_e ) ); /*Q43 + fast_e - 32 = Q11 + fast_e*/ fast_e = W_norm( e_fast_fx[i] ); fast_fx = W_extract_h( W_shl( e_fast_fx[i], fast_e ) ); /*Q43 + fast_e - 32 = Q11 + fast_e*/ fast_e = sub( 20, fast_e ); /*exp: 31 - (Q11 + fast_e) = 20 - fast_e*/ Word16 slow_e = W_norm( e_slow_fx[i] ); Word32 slow_fx = W_extract_h( W_shl( e_slow_fx[i], slow_e ) ); /*Q43 + fast_e - 32 = Q11 + slow_e*/ slow_e = W_norm( e_slow_fx[i] ); slow_fx = W_extract_h( W_shl( e_slow_fx[i], slow_e ) ); /*Q43 + fast_e - 32 = Q11 + slow_e*/ slow_e = sub( 20, slow_e ); /*exp: 31 - (Q11 + slow_e) = 20 - slow_e*/ in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, slow_fx, slow_e, fast_fx, fast_e, duck_mult_fac ); /*Q30*/ Loading @@ -468,34 +470,16 @@ void ivas_td_decorr_get_ducking_gains_fx( } #else Word32 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k]; Copy32( pIn_pcm, e_fast_fx, frame_len ); /*Q11*/ 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 ); // ==================================================================================================== Word64 test_e_fast_fx[L_FRAME48k]; Word16 q_fast = Q43; for ( i = 0; i < frame_len; i++ ) { test_e_fast_fx[i] = (Word64) pIn_pcm[i] << 32; } ivas_filter_process_fx64( &hTranDet->test_env_hpf, test_e_fast_fx, frame_len, q_fast ); for ( i = 0; i < frame_len; i++ ) { check( test_e_fast_fx[i], q_fast, e_fast_fx[i], 31 - e_fast_e[i] ); } // ==================================================================================================== 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*/ Loading @@ -507,68 +491,12 @@ void ivas_td_decorr_get_ducking_gains_fx( move16(); } // ==================================================================================================== // Word32 test_e_slow_fx[L_FRAME48k]; // Word32 env_eps_fx = IVAS_TDET_PARM_ENV_EPS_fx; // Word16 env_eps_q = Q31; // Word16 q_diff = sub( q_fast, env_eps_q ); // q_fast = s_min( q_fast, env_eps_q ); // if ( q_diff >= 0 ) // { // for ( i = 0; i < frame_len; i++ ) // { // test_e_fast_fx[i] = L_add( L_abs( L_shr( test_e_fast_fx[i], q_diff ) ), env_eps_fx ); // move32(); // test_e_slow_fx[i] = test_e_fast_fx[i]; // move32(); // } // } // else // { // env_eps_fx = L_shl( env_eps_fx, q_diff ); // for ( i = 0; i < frame_len; i++ ) // { // test_e_fast_fx[i] = L_add( L_abs( test_e_fast_fx[i] ), env_eps_fx ); // move32(); // test_e_slow_fx[i] = test_e_fast_fx[i]; // move32(); // } // } // Word16 q_slow = q_fast; // for ( i = 0; i < frame_len; i++ ) // { // check( test_e_fast_fx[i], q_fast, e_fast_fx[i], 31 - e_fast_e[i] ); // } // ==================================================================================================== /* env fast*/ ivas_filter_process_exp_fx( &hTranDet->env_fast, e_fast_fx, frame_len, e_fast_e ); // ==================================================================================================== // ivas_filter_process_fx32( &hTranDet->test_env_fast, test_e_fast_fx, frame_len, q_fast ); // for ( i = 0; i < frame_len; i++ ) // { // check( test_e_fast_fx[i], q_fast, e_fast_fx[i], 31 - e_fast_e[i] ); // } // ==================================================================================================== /* env slow */ ivas_filter_process_exp_fx( &hTranDet->env_slow, e_slow_fx, frame_len, e_slow_e ); // ==================================================================================================== // ivas_filter_process_fx32( &hTranDet->test_env_slow, test_e_slow_fx, frame_len, q_slow ); // for ( i = 0; i < frame_len; i++ ) // { // check( test_e_slow_fx[i], q_slow, e_slow_fx[i], 31 - e_slow_e[i] ); // } // ==================================================================================================== IF( tdet_flag ) { FOR( i = 0; i < frame_len; i++ ) Loading Loading @@ -598,6 +526,5 @@ void ivas_td_decorr_get_ducking_gains_fx( } #endif return; }
lib_dec/ivas_lfe_dec_fx.c +4 −0 Original line number Diff line number Diff line Loading @@ -408,7 +408,11 @@ void ivas_lfe_dec_fx( IF( hLFE->filter_state.order > 0 ) { /* Low Pass Filter */ #ifdef OPT_2239_IVAS_FILTER_PROCESS ivas_filter_process_fx32( &hLFE->filter_state, output_lfe_ch, output_frame, q_out ); #else ivas_filter_process_fx( &hLFE->filter_state, output_lfe_ch, output_frame, q_out ); #endif } /* add delay to make overall max(block_offset, 11.5) */ Loading
lib_enc/ivas_lfe_enc_fx.c +4 −0 Original line number Diff line number Diff line Loading @@ -684,7 +684,11 @@ void ivas_lfe_lpf_enc_apply_fx( const Word16 input_frame /* i : input frame length per channel */ ) { #ifdef OPT_2239_IVAS_FILTER_PROCESS ivas_filter_process_fx32( hLfeLpf, data_lfe_ch, input_frame, (Word16) Q11 ); #else ivas_filter_process_fx( hLfeLpf, data_lfe_ch, input_frame, (Word16) Q11 ); #endif return; }