Loading lib_com/cnst.h +2 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,8 @@ #define Q30 30 #define Q31 31 #define Q43 43 /*----------------------------------------------------------------------------------* * one in Q *----------------------------------------------------------------------------------*/ Loading lib_com/ivas_transient_det_fx.c +25 −71 Original line number Diff line number Diff line Loading @@ -44,7 +44,11 @@ *------------------------------------------------------------------------------------------*/ #define IVAS_TDET_PARM_ENV_EPS ( 1e-5f ) #ifdef 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 Loading Loading @@ -375,31 +379,6 @@ static Word32 ivas_calc_duck_gain_fx( * Calculate in/out ducking gains *-----------------------------------------------------------------------------------------*/ #if 0 static void check( Word64 computed_fx, Word16 computed_q, Word64 expected_fx, Word16 expected_q ); static void check( Word64 computed_fx, Word16 computed_q, Word64 expected_fx, Word16 expected_q ) { Word64 cfx, efx; Word16 q_diff = computed_q - expected_q; if ( q_diff >= 0 ) { cfx = W_shr( computed_fx, +q_diff ); efx = expected_fx; } else { cfx = computed_fx; efx = W_shr( expected_fx, -q_diff ); } Word64 error = llabs( cfx - efx ); if ( error > ( (Word64) 1 << 16 ) ) { assert( false ); } } #endif void ivas_td_decorr_get_ducking_gains_fx( ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */ Word32 *pIn_pcm, /*Q11*/ Loading @@ -423,64 +402,39 @@ 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]; for ( i = 0; i < frame_len; i++ ) FOR( i = 0; i < frame_len; i++ ) { e_fast_fx[i] = ( (Word64) pIn_pcm[i] ) << 32; e_fast_fx[i] = W_deposit32_h( pIn_pcm[i] ); /*Q43*/ move64(); } /* env hpf */ Word16 q_fast = Q11 + 32; ivas_filter_process_fx64( &hTranDet->env_hpf, e_fast_fx, frame_len, q_fast ); ivas_filter_process_fx64( &hTranDet->env_hpf, e_fast_fx, frame_len, Q43 ); Word64 env_eps_fx = ( (Word64) IVAS_TDET_PARM_ENV_EPS_fx ) << 32; Word16 env_eps_q = Q31 + 32; 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++ ) { e_fast_fx[i] = W_add( W_abs( W_shr( e_fast_fx[i], q_diff ) ), env_eps_fx ); move32(); e_fast_fx[i] = W_add( W_abs( e_fast_fx[i] ), IVAS_TDET_PARM_ENV_EPS_fx ); move64(); e_slow_fx[i] = e_fast_fx[i]; move32(); } } ELSE { env_eps_fx = W_shl( env_eps_fx, q_diff ); FOR( i = 0; i < frame_len; i++ ) { e_fast_fx[i] = W_add( W_abs( e_fast_fx[i] ), env_eps_fx ); move32(); e_slow_fx[i] = e_fast_fx[i]; move32(); } move64(); } Word16 q_slow = q_fast; /* env fast*/ ivas_filter_process_fx64( &hTranDet->env_fast, e_fast_fx, frame_len, q_fast ); ivas_filter_process_fx64( &hTranDet->env_fast, e_fast_fx, frame_len, Q43 ); /* env slow */ ivas_filter_process_fx64( &hTranDet->env_slow, e_slow_fx, frame_len, q_slow ); ivas_filter_process_fx64( &hTranDet->env_slow, e_slow_fx, frame_len, Q43 ); IF( tdet_flag ) { 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 ) ); fast_e = 31 - ( q_fast + fast_e - 32 ); Word32 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 ) ); slow_e = 31 - ( q_slow + slow_e - 32 ); Word32 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*/ pIn_duck_gains[i] = in_duck_gain; /*Q30*/ Loading @@ -494,11 +448,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 ) ); fast_e = 31 - ( q_fast + fast_e - 32 ); Word32 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 ) ); slow_e = 31 - ( q_slow + slow_e - 32 ); Word32 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*/ pIn_duck_gains[i] = in_duck_gain; /*Q30*/ Loading Loading @@ -526,7 +480,7 @@ void ivas_td_decorr_get_ducking_gains_fx( // ==================================================================================================== Word64 test_e_fast_fx[L_FRAME48k]; Word16 q_fast = Q11 + 32; Word16 q_fast = Q43; for ( i = 0; i < frame_len; i++ ) { Loading Loading
lib_com/cnst.h +2 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,8 @@ #define Q30 30 #define Q31 31 #define Q43 43 /*----------------------------------------------------------------------------------* * one in Q *----------------------------------------------------------------------------------*/ Loading
lib_com/ivas_transient_det_fx.c +25 −71 Original line number Diff line number Diff line Loading @@ -44,7 +44,11 @@ *------------------------------------------------------------------------------------------*/ #define IVAS_TDET_PARM_ENV_EPS ( 1e-5f ) #ifdef 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 Loading Loading @@ -375,31 +379,6 @@ static Word32 ivas_calc_duck_gain_fx( * Calculate in/out ducking gains *-----------------------------------------------------------------------------------------*/ #if 0 static void check( Word64 computed_fx, Word16 computed_q, Word64 expected_fx, Word16 expected_q ); static void check( Word64 computed_fx, Word16 computed_q, Word64 expected_fx, Word16 expected_q ) { Word64 cfx, efx; Word16 q_diff = computed_q - expected_q; if ( q_diff >= 0 ) { cfx = W_shr( computed_fx, +q_diff ); efx = expected_fx; } else { cfx = computed_fx; efx = W_shr( expected_fx, -q_diff ); } Word64 error = llabs( cfx - efx ); if ( error > ( (Word64) 1 << 16 ) ) { assert( false ); } } #endif void ivas_td_decorr_get_ducking_gains_fx( ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */ Word32 *pIn_pcm, /*Q11*/ Loading @@ -423,64 +402,39 @@ 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]; for ( i = 0; i < frame_len; i++ ) FOR( i = 0; i < frame_len; i++ ) { e_fast_fx[i] = ( (Word64) pIn_pcm[i] ) << 32; e_fast_fx[i] = W_deposit32_h( pIn_pcm[i] ); /*Q43*/ move64(); } /* env hpf */ Word16 q_fast = Q11 + 32; ivas_filter_process_fx64( &hTranDet->env_hpf, e_fast_fx, frame_len, q_fast ); ivas_filter_process_fx64( &hTranDet->env_hpf, e_fast_fx, frame_len, Q43 ); Word64 env_eps_fx = ( (Word64) IVAS_TDET_PARM_ENV_EPS_fx ) << 32; Word16 env_eps_q = Q31 + 32; 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++ ) { e_fast_fx[i] = W_add( W_abs( W_shr( e_fast_fx[i], q_diff ) ), env_eps_fx ); move32(); e_fast_fx[i] = W_add( W_abs( e_fast_fx[i] ), IVAS_TDET_PARM_ENV_EPS_fx ); move64(); e_slow_fx[i] = e_fast_fx[i]; move32(); } } ELSE { env_eps_fx = W_shl( env_eps_fx, q_diff ); FOR( i = 0; i < frame_len; i++ ) { e_fast_fx[i] = W_add( W_abs( e_fast_fx[i] ), env_eps_fx ); move32(); e_slow_fx[i] = e_fast_fx[i]; move32(); } move64(); } Word16 q_slow = q_fast; /* env fast*/ ivas_filter_process_fx64( &hTranDet->env_fast, e_fast_fx, frame_len, q_fast ); ivas_filter_process_fx64( &hTranDet->env_fast, e_fast_fx, frame_len, Q43 ); /* env slow */ ivas_filter_process_fx64( &hTranDet->env_slow, e_slow_fx, frame_len, q_slow ); ivas_filter_process_fx64( &hTranDet->env_slow, e_slow_fx, frame_len, Q43 ); IF( tdet_flag ) { 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 ) ); fast_e = 31 - ( q_fast + fast_e - 32 ); Word32 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 ) ); slow_e = 31 - ( q_slow + slow_e - 32 ); Word32 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*/ pIn_duck_gains[i] = in_duck_gain; /*Q30*/ Loading @@ -494,11 +448,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 ) ); fast_e = 31 - ( q_fast + fast_e - 32 ); Word32 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 ) ); slow_e = 31 - ( q_slow + slow_e - 32 ); Word32 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*/ pIn_duck_gains[i] = in_duck_gain; /*Q30*/ Loading Loading @@ -526,7 +480,7 @@ void ivas_td_decorr_get_ducking_gains_fx( // ==================================================================================================== Word64 test_e_fast_fx[L_FRAME48k]; Word16 q_fast = Q11 + 32; Word16 q_fast = Q43; for ( i = 0; i < frame_len; i++ ) { Loading