Loading lib_enc/ivas_stereo_dmx_evs_fx.c +92 −87 Original line number Diff line number Diff line Loading @@ -118,6 +118,7 @@ #define STEREO_DMX_EVS_SGC_GMIN 23170 // 0.7071f #define STEREO_DMX_EVS_IPD_ILD_THRES_Q29 1696512082 // 3.16f (5dB) #define STEREO_DMX_EVS_IPD_SF_THRES_Q31 107374182 // 0.05f const Word32 ipd_ff_Q31[STEREO_DMX_EVS_NB_SUBBAND_MAX] = { 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, Loading @@ -144,7 +145,9 @@ const Word32 ipd_ff_Q31[STEREO_DMX_EVS_NB_SUBBAND_MAX] = { 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128 }; #else const Word32 ipd_ff_Q31[STEREO_DMX_EVS_NB_SUBBAND_MAX] = { 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, Loading Loading @@ -1442,7 +1445,6 @@ static void calc_poc_fx( } } rfft_buf[0] = L_shr_r( specPOr[0], 10 ); // Q31->Q21 move32(); rfft_buf[1] = L_shr_r( specPOr[n0], 10 ); // Q31->Q21 Loading Loading @@ -2446,6 +2448,8 @@ void stereo_dmx_evs_enc_fx( Word16 n_fad_r, n_fad_g, m_fad_g, n_fad_cnt; STEREO_DMX_EVS_PRC prev_prc; STEREO_DMX_EVS_PHA_HANDLE hPHA; Word16 input_subframe, is_transient, dmx_gain_sgc; Word32 *p_sub_frame, subframe_energy[STEREO_DMX_EVS_NB_SBFRM]; Word16 subframe_energy_e[STEREO_DMX_EVS_NB_SBFRM]; Loading Loading @@ -2484,6 +2488,7 @@ void stereo_dmx_evs_enc_fx( BREAK; } move16(); hPHA = hStereoDmxEVS->hPHA; FOR( n = 0; n < input_frame; n++ ) { Loading Loading @@ -2541,29 +2546,29 @@ void stereo_dmx_evs_enc_fx( W_tmp_q = W_norm( W_tmp ); W_tmp = W_shl( W_tmp, W_tmp_q ); L_tmp1 = W_extract_h( W_tmp ); // Q(31-(30-W_tmp_q)) L_tmp1_e = sub( 15 * 2, W_tmp_q ); L_tmp1_e = sub( 15 << 1, W_tmp_q ); subframe_energy[m] = BASOP_Util_Add_Mant32Exp( subframe_energy[m], subframe_energy_e[m], L_tmp1, L_tmp1_e, &subframe_energy_e[m] ); move32(); } L_tmp1 = BASOP_Util_Add_Mant32Exp( hStereoDmxEVS->hPHA->trns_aux_energy_fx[k], hStereoDmxEVS->hPHA->trns_aux_energy_fx_e[k], EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e ); L_tmp1 = BASOP_Util_Add_Mant32Exp( hPHA->trns_aux_energy_fx[k], hPHA->trns_aux_energy_fx_e[k], EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e ); L_tmp2 = BASOP_Util_Divide3232_Scale_cadence( subframe_energy[m], L_tmp1, &L_tmp2_e ); L_tmp2_e = add( L_tmp2_e, sub( subframe_energy_e[m], L_tmp1_e ) ); // if ( subframe_energy[m] / ( hStereoDmxEVS->hPHA->trns_aux_energy[k] + EPSILON ) > hStereoDmxEVS->hPHA->crst_fctr ) if ( BASOP_Util_Cmp_Mant32Exp( L_tmp2, L_tmp2_e, hStereoDmxEVS->hPHA->crst_fctr_fx, 31 ) > 0 ) // if ( subframe_energy[m] / ( hPHA->trns_aux_energy[k] + EPSILON ) > hPHA->crst_fctr ) if ( BASOP_Util_Cmp_Mant32Exp( L_tmp2, L_tmp2_e, hPHA->crst_fctr_fx, 31 ) > 0 ) { is_transient = 1; move16(); } // hStereoDmxEVS->hPHA->trns_aux_energy[k] = STEREO_DMX_EVS_TRNS_EGY_FORGETTING * hStereoDmxEVS->hPHA->trns_aux_energy[k] + ( 1.0f - STEREO_DMX_EVS_TRNS_EGY_FORGETTING ) * subframe_energy[m]; hStereoDmxEVS->hPHA->trns_aux_energy_fx[k] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( hStereoDmxEVS->hPHA->trns_aux_energy_fx[k], STEREO_DMX_EVS_TRNS_EGY_FORGETTING_Q15 ), hStereoDmxEVS->hPHA->trns_aux_energy_fx_e[k], Mpy_32_16_1( subframe_energy[m], sub( MAX_16, STEREO_DMX_EVS_TRNS_EGY_FORGETTING_Q15 ) ), subframe_energy_e[m], &hStereoDmxEVS->hPHA->trns_aux_energy_fx_e[k] ); // hPHA->trns_aux_energy[k] = STEREO_DMX_EVS_TRNS_EGY_FORGETTING * hPHA->trns_aux_energy[k] + ( 1.0f - STEREO_DMX_EVS_TRNS_EGY_FORGETTING ) * subframe_energy[m]; hPHA->trns_aux_energy_fx[k] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( hPHA->trns_aux_energy_fx[k], STEREO_DMX_EVS_TRNS_EGY_FORGETTING_Q15 ), hPHA->trns_aux_energy_fx_e[k], Mpy_32_16_1( subframe_energy[m], sub( MAX_16, STEREO_DMX_EVS_TRNS_EGY_FORGETTING_Q15 ) ), subframe_energy_e[m], &hPHA->trns_aux_energy_fx_e[k] ); move32(); } FOR( m = 1; m < STEREO_DMX_EVS_NB_SBFRM; m++ ) { L_tmp1 = BASOP_Util_Add_Mant32Exp( subframe_energy[m - 1], subframe_energy_e[m - 1], EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e ); L_tmp1 = BASOP_Util_Add_Mant32Exp( subframe_energy[sub( m, 1 )], subframe_energy_e[sub( m, 1 )], EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e ); L_tmp2 = BASOP_Util_Divide3232_Scale_cadence( subframe_energy[m], L_tmp1, &L_tmp2_e ); L_tmp2_e = add( L_tmp2_e, sub( subframe_energy_e[m], L_tmp1_e ) ); // if ( subframe_energy[m] / ( subframe_energy[m - 1] + EPSILON ) > STEREO_DMX_EVS_TRNS_DTC_INST ) Loading @@ -2575,14 +2580,14 @@ void stereo_dmx_evs_enc_fx( } } estimate_itd_fx( &corr, hStereoDmxEVS->hPOC, hStereoDmxEVS->hPHA, data_fx[0], data_fx[1], &hStereoDmxEVS->itd_fx, input_frame ); estimate_itd_fx( &corr, hStereoDmxEVS->hPOC, hPHA, data_fx[0], data_fx[1], &hStereoDmxEVS->itd_fx, input_frame ); /* poc */ IF( hStereoDmxEVS->itd_fx ) { // dmx_weight = ( ( hStereoDmxEVS->itd > 0 ) ? ( -1 ) : 1 ) * 0.5f * corr + 0.5f; IF( hStereoDmxEVS->itd_fx > 0 ) IF( GT_16( hStereoDmxEVS->itd_fx, 0 ) ) { dmx_weight = add( negate( shr( corr, 1 ) ), ONE_IN_Q14 ); } Loading @@ -2607,11 +2612,11 @@ void stereo_dmx_evs_enc_fx( /* pha */ pha_len = hStereoDmxEVS->hPHA->pha_len; pha_len = hPHA->pha_len; move16(); fad_len = hStereoDmxEVS->hPHA->fad_len; fad_len = hPHA->fad_len; move16(); fad_g = hStereoDmxEVS->hPHA->fad_g_fx; fad_g = hPHA->fad_g_fx; set_zero_fx( dmx_pha_data, n_samples ); set_zero_fx( mem_prev, fad_len ); Loading @@ -2619,12 +2624,12 @@ void stereo_dmx_evs_enc_fx( FOR( k = 0; k < CPE_CHANNELS; k++ ) { p_data = data_fx[k]; Copy32( hStereoDmxEVS->hPHA->data_mem_fx[k], data_mem, pha_len ); Copy32( &( p_data[n_samples - pha_len] ), hStereoDmxEVS->hPHA->data_mem_fx[k], pha_len ); Copy32( hPHA->data_mem_fx[k], data_mem, pha_len ); Copy32( &( p_data[sub( n_samples, pha_len )] ), hPHA->data_mem_fx[k], pha_len ); p_data_mem = &( data_mem[pha_len] ); Copy32( p_data, p_data_mem, n_samples ); p_prev_taps = hStereoDmxEVS->hPHA->p_prev_taps_fx[k]; p_prev_taps = hPHA->p_prev_taps_fx[k]; IF( p_prev_taps ) { FOR( n = 0; n < fad_len; n++ ) Loading @@ -2632,7 +2637,7 @@ void stereo_dmx_evs_enc_fx( FOR( ( fx_tmp = 0, m = 0 ); m < pha_len; m++ ) { // ftmp += p_data_mem[n - m] * p_prev_taps[m]; fx_tmp = L_add( fx_tmp, Mpy_32_32( p_data_mem[n - m], p_prev_taps[m] ) ); // Q25 fx_tmp = L_add( fx_tmp, Mpy_32_32( p_data_mem[sub( n, m )], p_prev_taps[m] ) ); // Q25 } fx_tmp = L_shl( fx_tmp, 1 ); // Q26 mem_prev[n] = L_add( mem_prev[n], Mpy_32_32( fx_tmp, INV_SQRT_2_Q31 ) ); Loading @@ -2649,7 +2654,7 @@ void stereo_dmx_evs_enc_fx( } } p_curr_taps = hStereoDmxEVS->hPHA->p_curr_taps_fx[k]; p_curr_taps = hPHA->p_curr_taps_fx[k]; IF( p_curr_taps ) { FOR( n = 0; n < n_samples; n++ ) Loading @@ -2657,7 +2662,7 @@ void stereo_dmx_evs_enc_fx( FOR( ( fx_tmp = 0, m = 0 ); m < pha_len; m++ ) { // ftmp += p_data_mem[n - m] * p_curr_taps[m]; fx_tmp = L_add( fx_tmp, Mpy_32_32( p_data_mem[n - m], p_curr_taps[m] ) ); // Q25 fx_tmp = L_add( fx_tmp, Mpy_32_32( p_data_mem[sub( n, m )], p_curr_taps[m] ) ); // Q25 } fx_tmp = L_shl( fx_tmp, 1 ); // Q26 // dmx_pha_data[n] += ftmp * INV_SQRT_2; Loading Loading @@ -2686,59 +2691,59 @@ void stereo_dmx_evs_enc_fx( /* prc switch */ prev_prc = hStereoDmxEVS->hPHA->curr_prc; prev_prc = hPHA->curr_prc; move32(); // if ( abs( (int16_t) hStereoDmxEVS->itd ) > hStereoDmxEVS->hPHA->prc_thres ) IF( GT_16( abs_s( hStereoDmxEVS->itd_fx ), hStereoDmxEVS->hPHA->prc_thres ) ) // if ( abs( (int16_t) hStereoDmxEVS->itd ) > hPHA->prc_thres ) IF( GT_16( abs_s( hStereoDmxEVS->itd_fx ), hPHA->prc_thres ) ) { IF( NE_32( hStereoDmxEVS->hPHA->curr_prc, STEREO_DMX_EVS_PRC_POC ) ) IF( NE_32( hPHA->curr_prc, STEREO_DMX_EVS_PRC_POC ) ) { IF( EQ_32( hStereoDmxEVS->hPHA->prev_prc, STEREO_DMX_EVS_PRC_POC ) ) IF( EQ_32( hPHA->prev_prc, STEREO_DMX_EVS_PRC_POC ) ) { hStereoDmxEVS->hPHA->prc_hys_cnt = add( hStereoDmxEVS->hPHA->prc_hys_cnt, 1 ); hPHA->prc_hys_cnt = add( hPHA->prc_hys_cnt, 1 ); move16(); } ELSE { hStereoDmxEVS->hPHA->prc_hys_cnt = 0; hPHA->prc_hys_cnt = 0; move16(); } if ( GE_16( hStereoDmxEVS->hPHA->prc_hys_cnt, STEREO_DMX_EVS_SWTCH_PRC_HYS_THRES ) ) if ( GE_16( hPHA->prc_hys_cnt, STEREO_DMX_EVS_SWTCH_PRC_HYS_THRES ) ) { hStereoDmxEVS->hPHA->curr_prc = STEREO_DMX_EVS_PRC_POC; hPHA->curr_prc = STEREO_DMX_EVS_PRC_POC; move32(); } } hStereoDmxEVS->hPHA->prev_prc = STEREO_DMX_EVS_PRC_POC; hPHA->prev_prc = STEREO_DMX_EVS_PRC_POC; move32(); } ELSE { IF( NE_32( hStereoDmxEVS->hPHA->curr_prc, STEREO_DMX_EVS_PRC_PHA ) ) IF( NE_32( hPHA->curr_prc, STEREO_DMX_EVS_PRC_PHA ) ) { IF( EQ_32( hStereoDmxEVS->hPHA->prev_prc, STEREO_DMX_EVS_PRC_PHA ) ) IF( EQ_32( hPHA->prev_prc, STEREO_DMX_EVS_PRC_PHA ) ) { hStereoDmxEVS->hPHA->prc_hys_cnt = add( hStereoDmxEVS->hPHA->prc_hys_cnt, 1 ); hPHA->prc_hys_cnt = add( hPHA->prc_hys_cnt, 1 ); move16(); } ELSE { hStereoDmxEVS->hPHA->prc_hys_cnt = 0; hPHA->prc_hys_cnt = 0; move16(); } if ( GE_16( hStereoDmxEVS->hPHA->prc_hys_cnt, STEREO_DMX_EVS_SWTCH_PRC_HYS_THRES ) ) if ( GE_16( hPHA->prc_hys_cnt, STEREO_DMX_EVS_SWTCH_PRC_HYS_THRES ) ) { hStereoDmxEVS->hPHA->curr_prc = STEREO_DMX_EVS_PRC_PHA; hPHA->curr_prc = STEREO_DMX_EVS_PRC_PHA; move32(); } } hStereoDmxEVS->hPHA->prev_prc = STEREO_DMX_EVS_PRC_PHA; hPHA->prev_prc = STEREO_DMX_EVS_PRC_PHA; move32(); } // if ( ( is_transient == 1 ) || ( hStereoDmxEVS->aux_dmx_energy[0] > STEREO_DMX_EVS_ILDS_EGY * hStereoDmxEVS->aux_dmx_energy[1] ) || ( hStereoDmxEVS->aux_dmx_energy[1] > STEREO_DMX_EVS_ILDS_EGY * hStereoDmxEVS->aux_dmx_energy[0] ) || ( ( hStereoDmxEVS->hPHA->p_curr_taps[0] == NULL ) && ( hStereoDmxEVS->hPHA->p_curr_taps[1] == NULL ) ) ) // if ( ( is_transient == 1 ) || ( hStereoDmxEVS->aux_dmx_energy[0] > STEREO_DMX_EVS_ILDS_EGY * hStereoDmxEVS->aux_dmx_energy[1] ) || ( hStereoDmxEVS->aux_dmx_energy[1] > STEREO_DMX_EVS_ILDS_EGY * hStereoDmxEVS->aux_dmx_energy[0] ) || ( ( hPHA->p_curr_taps[0] == NULL ) && ( hPHA->p_curr_taps[1] == NULL ) ) ) test(); test(); test(); Loading @@ -2746,60 +2751,60 @@ void stereo_dmx_evs_enc_fx( IF( EQ_16( is_transient, 1 ) || BASOP_Util_Cmp_Mant32Exp( hStereoDmxEVS->aux_dmx_energy_fx[0], hStereoDmxEVS->aux_dmx_energy_fx_e[0], Mpy_32_32( STEREO_DMX_EVS_ILDS_EGY_Q17, hStereoDmxEVS->aux_dmx_energy_fx[1] ), add( hStereoDmxEVS->aux_dmx_energy_fx_e[1], 14 ) ) > 0 || BASOP_Util_Cmp_Mant32Exp( hStereoDmxEVS->aux_dmx_energy_fx[1], hStereoDmxEVS->aux_dmx_energy_fx_e[1], Mpy_32_32( STEREO_DMX_EVS_ILDS_EGY_Q17, hStereoDmxEVS->aux_dmx_energy_fx[0] ), add( hStereoDmxEVS->aux_dmx_energy_fx_e[0], 14 ) ) > 0 || EQ_16( hStereoDmxEVS->hPHA->force_poc, TRUE ) ) EQ_16( hPHA->force_poc, TRUE ) ) { hStereoDmxEVS->hPHA->curr_prc = STEREO_DMX_EVS_PRC_POC; hPHA->curr_prc = STEREO_DMX_EVS_PRC_POC; move32(); hStereoDmxEVS->hPHA->prc_hys_cnt = 0; hPHA->prc_hys_cnt = 0; move16(); } calc_energy_sgc( dmx_poc_data, &( hStereoDmxEVS->hPHA->dmx_poc_ener_fx ), &( hStereoDmxEVS->hPHA->dmx_poc_ener_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); calc_energy_sgc( dmx_pha_data, &( hStereoDmxEVS->hPHA->dmx_pha_ener_fx ), &( hStereoDmxEVS->hPHA->dmx_pha_ener_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); calc_energy_sgc( dmx_poc_data, &( hPHA->dmx_poc_ener_fx ), &( hPHA->dmx_poc_ener_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); calc_energy_sgc( dmx_pha_data, &( hPHA->dmx_pha_ener_fx ), &( hPHA->dmx_pha_ener_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); IF( NE_32( prev_prc, hStereoDmxEVS->hPHA->curr_prc ) && EQ_16( is_transient, 0 ) && !( ( BASOP_Util_Cmp_Mant32Exp( hStereoDmxEVS->hPHA->dmx_pha_ener_fx, hStereoDmxEVS->hPHA->dmx_pha_ener_fx_e, hStereoDmxEVS->hPHA->low_egy_thres_sgc, hStereoDmxEVS->hPHA->low_egy_thres_sgc_e ) < 0 ) && ( BASOP_Util_Cmp_Mant32Exp( hStereoDmxEVS->hPHA->dmx_poc_ener_fx, hStereoDmxEVS->hPHA->dmx_poc_ener_fx_e, hStereoDmxEVS->hPHA->low_egy_thres_sgc, hStereoDmxEVS->hPHA->low_egy_thres_sgc_e ) < 0 ) ) ) IF( NE_32( prev_prc, hPHA->curr_prc ) && EQ_16( is_transient, 0 ) && !( ( BASOP_Util_Cmp_Mant32Exp( hPHA->dmx_pha_ener_fx, hPHA->dmx_pha_ener_fx_e, hPHA->low_egy_thres_sgc, hPHA->low_egy_thres_sgc_e ) < 0 ) && ( BASOP_Util_Cmp_Mant32Exp( hPHA->dmx_poc_ener_fx, hPHA->dmx_poc_ener_fx_e, hPHA->low_egy_thres_sgc, hPHA->low_egy_thres_sgc_e ) < 0 ) ) ) { IF( EQ_32( hStereoDmxEVS->hPHA->curr_prc, STEREO_DMX_EVS_PRC_POC ) ) IF( EQ_32( hPHA->curr_prc, STEREO_DMX_EVS_PRC_POC ) ) { apply_gain_sgc( dmx_pha_data, &( hStereoDmxEVS->hPHA->dmx_pha_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_pha_data, &( hStereoDmxEVS->hPHA->dmx_pha_ener_sgc_fx ), &( hStereoDmxEVS->hPHA->dmx_pha_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); apply_gain_sgc( dmx_pha_data, &( hPHA->dmx_pha_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_pha_data, &( hPHA->dmx_pha_ener_sgc_fx ), &( hPHA->dmx_pha_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); L_tmp1 = BASOP_Util_Add_Mant32Exp( hStereoDmxEVS->hPHA->dmx_poc_ener_fx, hStereoDmxEVS->hPHA->dmx_poc_ener_fx_e, EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e ); BASOP_Util_Divide_MantExp( extract_h( hStereoDmxEVS->hPHA->dmx_pha_ener_sgc_fx ), hStereoDmxEVS->hPHA->dmx_pha_ener_sgc_fx_e, extract_h( L_tmp1 ), L_tmp1_e, &dmx_gain_sgc, &L_tmp2_e ); L_tmp1 = BASOP_Util_Add_Mant32Exp( hPHA->dmx_poc_ener_fx, hPHA->dmx_poc_ener_fx_e, EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e ); BASOP_Util_Divide_MantExp( extract_h( hPHA->dmx_pha_ener_sgc_fx ), hPHA->dmx_pha_ener_sgc_fx_e, extract_h( L_tmp1 ), L_tmp1_e, &dmx_gain_sgc, &L_tmp2_e ); dmx_gain_sgc = Sqrt16( dmx_gain_sgc, &L_tmp2_e ); hStereoDmxEVS->hPHA->dmx_poc_gain_sgc_fx = L_shl( L_deposit_l( dmx_gain_sgc ), L_tmp2_e ); // Q15 hStereoDmxEVS->hPHA->dmx_poc_gain_sgc_fx = L_min( hStereoDmxEVS->hPHA->dmx_poc_gain_sgc_fx, STEREO_DMX_EVS_SGC_GMAX ); hStereoDmxEVS->hPHA->dmx_poc_gain_sgc_fx = L_max( hStereoDmxEVS->hPHA->dmx_poc_gain_sgc_fx, STEREO_DMX_EVS_SGC_GMIN ); hPHA->dmx_poc_gain_sgc_fx = L_shl( L_deposit_l( dmx_gain_sgc ), L_tmp2_e ); // Q15 hPHA->dmx_poc_gain_sgc_fx = L_min( hPHA->dmx_poc_gain_sgc_fx, STEREO_DMX_EVS_SGC_GMAX ); hPHA->dmx_poc_gain_sgc_fx = L_max( hPHA->dmx_poc_gain_sgc_fx, STEREO_DMX_EVS_SGC_GMIN ); apply_gain_sgc( dmx_poc_data, &( hStereoDmxEVS->hPHA->dmx_poc_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_poc_data, &( hStereoDmxEVS->hPHA->dmx_poc_ener_sgc_fx ), &( hStereoDmxEVS->hPHA->dmx_poc_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); apply_gain_sgc( dmx_poc_data, &( hPHA->dmx_poc_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_poc_data, &( hPHA->dmx_poc_ener_sgc_fx ), &( hPHA->dmx_poc_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); } ELSE { apply_gain_sgc( dmx_poc_data, &( hStereoDmxEVS->hPHA->dmx_poc_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_poc_data, &( hStereoDmxEVS->hPHA->dmx_poc_ener_sgc_fx ), &( hStereoDmxEVS->hPHA->dmx_poc_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); apply_gain_sgc( dmx_poc_data, &( hPHA->dmx_poc_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_poc_data, &( hPHA->dmx_poc_ener_sgc_fx ), &( hPHA->dmx_poc_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); L_tmp1 = BASOP_Util_Add_Mant32Exp( hStereoDmxEVS->hPHA->dmx_pha_ener_fx, hStereoDmxEVS->hPHA->dmx_pha_ener_fx_e, EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e ); BASOP_Util_Divide_MantExp( extract_h( hStereoDmxEVS->hPHA->dmx_poc_ener_sgc_fx ), hStereoDmxEVS->hPHA->dmx_poc_ener_sgc_fx_e, extract_h( L_tmp1 ), L_tmp1_e, &dmx_gain_sgc, &L_tmp2_e ); L_tmp1 = BASOP_Util_Add_Mant32Exp( hPHA->dmx_pha_ener_fx, hPHA->dmx_pha_ener_fx_e, EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e ); BASOP_Util_Divide_MantExp( extract_h( hPHA->dmx_poc_ener_sgc_fx ), hPHA->dmx_poc_ener_sgc_fx_e, extract_h( L_tmp1 ), L_tmp1_e, &dmx_gain_sgc, &L_tmp2_e ); dmx_gain_sgc = Sqrt16( dmx_gain_sgc, &L_tmp2_e ); hStereoDmxEVS->hPHA->dmx_pha_gain_sgc_fx = L_shl( L_deposit_l( dmx_gain_sgc ), L_tmp2_e ); // Q15 hStereoDmxEVS->hPHA->dmx_pha_gain_sgc_fx = L_min( hStereoDmxEVS->hPHA->dmx_pha_gain_sgc_fx, STEREO_DMX_EVS_SGC_GMAX ); hStereoDmxEVS->hPHA->dmx_pha_gain_sgc_fx = L_max( hStereoDmxEVS->hPHA->dmx_pha_gain_sgc_fx, STEREO_DMX_EVS_SGC_GMIN ); hPHA->dmx_pha_gain_sgc_fx = L_shl( L_deposit_l( dmx_gain_sgc ), L_tmp2_e ); // Q15 hPHA->dmx_pha_gain_sgc_fx = L_min( hPHA->dmx_pha_gain_sgc_fx, STEREO_DMX_EVS_SGC_GMAX ); hPHA->dmx_pha_gain_sgc_fx = L_max( hPHA->dmx_pha_gain_sgc_fx, STEREO_DMX_EVS_SGC_GMIN ); apply_gain_sgc( dmx_pha_data, &( hStereoDmxEVS->hPHA->dmx_pha_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_pha_data, &( hStereoDmxEVS->hPHA->dmx_pha_ener_sgc_fx ), &( hStereoDmxEVS->hPHA->dmx_pha_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); apply_gain_sgc( dmx_pha_data, &( hPHA->dmx_pha_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_pha_data, &( hPHA->dmx_pha_ener_sgc_fx ), &( hPHA->dmx_pha_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); } } ELSE { apply_gain_sgc( dmx_poc_data, &( hStereoDmxEVS->hPHA->dmx_poc_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_poc_data, &( hStereoDmxEVS->hPHA->dmx_poc_ener_sgc_fx ), &( hStereoDmxEVS->hPHA->dmx_poc_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); apply_gain_sgc( dmx_poc_data, &( hPHA->dmx_poc_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_poc_data, &( hPHA->dmx_poc_ener_sgc_fx ), &( hPHA->dmx_poc_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); apply_gain_sgc( dmx_pha_data, &( hStereoDmxEVS->hPHA->dmx_pha_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_pha_data, &( hStereoDmxEVS->hPHA->dmx_pha_ener_sgc_fx ), &( hStereoDmxEVS->hPHA->dmx_pha_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); apply_gain_sgc( dmx_pha_data, &( hPHA->dmx_pha_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_pha_data, &( hPHA->dmx_pha_ener_sgc_fx ), &( hPHA->dmx_pha_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); } IF( EQ_32( hStereoDmxEVS->hPHA->curr_prc, STEREO_DMX_EVS_PRC_POC ) ) IF( EQ_32( hPHA->curr_prc, STEREO_DMX_EVS_PRC_POC ) ) { p_dmx_data = dmx_poc_data; p_dmx_data_fo = dmx_pha_data; Loading @@ -2821,47 +2826,48 @@ void stereo_dmx_evs_enc_fx( move16(); } IF( NE_32( prev_prc, hStereoDmxEVS->hPHA->curr_prc ) ) IF( NE_32( prev_prc, hPHA->curr_prc ) ) { IF( EQ_16( hStereoDmxEVS->hPHA->n_fad_g, input_frame ) ) IF( EQ_16( hPHA->n_fad_g, input_frame ) ) { hStereoDmxEVS->hPHA->n_fad_g = 0; hStereoDmxEVS->hPHA->n_fad_cnt = 0; hPHA->n_fad_g = 0; hPHA->n_fad_cnt = 0; move16(); move16(); } ELSE { hStereoDmxEVS->hPHA->n_fad_g = sub( input_frame, add( hStereoDmxEVS->hPHA->n_fad_g, 1 ) ); hPHA->n_fad_g = sub( input_frame, add( hPHA->n_fad_g, 1 ) ); #ifdef NONBE_FIX_947_STEREO_DMX_FADOPT hStereoDmxEVS->hPHA->n_fad_cnt = 0; hPHA->n_fad_cnt = 0; move16(); #else IF( EQ_16( is_transient, 1 ) ) { hStereoDmxEVS->hPHA->n_fad_cnt = 0; hPHA->n_fad_cnt = 0; move16(); } ELSE { hStereoDmxEVS->hPHA->n_fad_cnt = sub( n_fad_r, hStereoDmxEVS->hPHA->n_fad_cnt ); hPHA->n_fad_cnt = sub( n_fad_r, hPHA->n_fad_cnt ); } #endif } } ELSE IF( is_transient ) { hStereoDmxEVS->hPHA->n_fad_cnt = 0; hPHA->n_fad_cnt = 0; move16(); } fad_len = s_min( n_samples, sub( mult0( input_frame, n_fad_r ), add( mult0( hStereoDmxEVS->hPHA->n_fad_g, n_fad_r ), hStereoDmxEVS->hPHA->n_fad_cnt ) ) ); fad_len = s_min( n_samples, sub( mult0( input_frame, n_fad_r ), add( mult0( hPHA->n_fad_g, n_fad_r ), hPHA->n_fad_cnt ) ) ); IF( NE_16( fad_len, 0 ) ) { fad_g = hStereoDmxEVS->hPHA->fad_g_prc_fx; fad_g = hPHA->fad_g_prc_fx; move32(); n_fad_g = hStereoDmxEVS->hPHA->n_fad_g; n_fad_cnt = hStereoDmxEVS->hPHA->n_fad_cnt; n_fad_g = hPHA->n_fad_g; n_fad_cnt = hPHA->n_fad_cnt; move16(); move16(); m_fad_g = sub( input_frame, add( n_fad_g, 1 ) ); Loading Loading @@ -2949,8 +2955,8 @@ void stereo_dmx_evs_enc_fx( } #endif hStereoDmxEVS->hPHA->n_fad_g = n_fad_g; hStereoDmxEVS->hPHA->n_fad_cnt = n_fad_cnt; hPHA->n_fad_g = n_fad_g; hPHA->n_fad_cnt = n_fad_cnt; move16(); move16(); } Loading Loading @@ -3350,7 +3356,7 @@ ivas_error stereo_dmx_evs_init_encoder_fx( Word16 n, input_frame; Word16 m, len, pha_len, fad_len, fad_len2, rfft_ipd_coef_step, n0, input_frame_pha; Word32 *fad_g, fad_r, *ipd_ff; Word32 *fad_g, fad_r; Word16 *win; const Word16 *p_ipd_w; Word16 tmp_e; Loading Loading @@ -3608,7 +3614,7 @@ ivas_error stereo_dmx_evs_init_encoder_fx( move16(); IF( EQ_32( input_Fs, 16000 ) ) { hStereoDmxEVS->hPHA->win_fx[pha_len - 1] = 7373; /*0.45f in Q14*/ hStereoDmxEVS->hPHA->win_fx[sub( pha_len, 1 )] = 7373; /*0.45f in Q14*/ move16(); } ELSE IF( EQ_32( input_Fs, 32000 ) || EQ_32( input_Fs, 48000 ) ) Loading Loading @@ -3641,8 +3647,7 @@ ivas_error stereo_dmx_evs_init_encoder_fx( /* Compute the forgetting factor */ // replaced below logic with table as it is same for all frame lengths ipd_ff = hStereoDmxEVS->hPHA->ipd_ff_fx; Copy32( ipd_ff_Q31, ipd_ff, STEREO_DMX_EVS_NB_SUBBAND_MAX ); Copy32( ipd_ff_Q31, hStereoDmxEVS->hPHA->ipd_ff_fx, STEREO_DMX_EVS_NB_SUBBAND_MAX ); #ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA hStereoDmxEVS->hPHA->proc_pha = STEREO_DMX_EVS_PHA_IPD; Loading Loading @@ -3701,7 +3706,7 @@ ivas_error stereo_dmx_evs_init_encoder_fx( { win[n] = p_ipd_w[n * len]; move16(); win[input_frame_pha - n] = p_ipd_w[n * len]; win[sub( input_frame_pha, n )] = p_ipd_w[n * len]; move16(); } win[n0] = p_ipd_w[n0 * len]; Loading Loading
lib_enc/ivas_stereo_dmx_evs_fx.c +92 −87 Original line number Diff line number Diff line Loading @@ -118,6 +118,7 @@ #define STEREO_DMX_EVS_SGC_GMIN 23170 // 0.7071f #define STEREO_DMX_EVS_IPD_ILD_THRES_Q29 1696512082 // 3.16f (5dB) #define STEREO_DMX_EVS_IPD_SF_THRES_Q31 107374182 // 0.05f const Word32 ipd_ff_Q31[STEREO_DMX_EVS_NB_SUBBAND_MAX] = { 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, 2027355520, Loading @@ -144,7 +145,9 @@ const Word32 ipd_ff_Q31[STEREO_DMX_EVS_NB_SUBBAND_MAX] = { 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128, 1841888128 }; #else const Word32 ipd_ff_Q31[STEREO_DMX_EVS_NB_SUBBAND_MAX] = { 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, Loading Loading @@ -1442,7 +1445,6 @@ static void calc_poc_fx( } } rfft_buf[0] = L_shr_r( specPOr[0], 10 ); // Q31->Q21 move32(); rfft_buf[1] = L_shr_r( specPOr[n0], 10 ); // Q31->Q21 Loading Loading @@ -2446,6 +2448,8 @@ void stereo_dmx_evs_enc_fx( Word16 n_fad_r, n_fad_g, m_fad_g, n_fad_cnt; STEREO_DMX_EVS_PRC prev_prc; STEREO_DMX_EVS_PHA_HANDLE hPHA; Word16 input_subframe, is_transient, dmx_gain_sgc; Word32 *p_sub_frame, subframe_energy[STEREO_DMX_EVS_NB_SBFRM]; Word16 subframe_energy_e[STEREO_DMX_EVS_NB_SBFRM]; Loading Loading @@ -2484,6 +2488,7 @@ void stereo_dmx_evs_enc_fx( BREAK; } move16(); hPHA = hStereoDmxEVS->hPHA; FOR( n = 0; n < input_frame; n++ ) { Loading Loading @@ -2541,29 +2546,29 @@ void stereo_dmx_evs_enc_fx( W_tmp_q = W_norm( W_tmp ); W_tmp = W_shl( W_tmp, W_tmp_q ); L_tmp1 = W_extract_h( W_tmp ); // Q(31-(30-W_tmp_q)) L_tmp1_e = sub( 15 * 2, W_tmp_q ); L_tmp1_e = sub( 15 << 1, W_tmp_q ); subframe_energy[m] = BASOP_Util_Add_Mant32Exp( subframe_energy[m], subframe_energy_e[m], L_tmp1, L_tmp1_e, &subframe_energy_e[m] ); move32(); } L_tmp1 = BASOP_Util_Add_Mant32Exp( hStereoDmxEVS->hPHA->trns_aux_energy_fx[k], hStereoDmxEVS->hPHA->trns_aux_energy_fx_e[k], EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e ); L_tmp1 = BASOP_Util_Add_Mant32Exp( hPHA->trns_aux_energy_fx[k], hPHA->trns_aux_energy_fx_e[k], EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e ); L_tmp2 = BASOP_Util_Divide3232_Scale_cadence( subframe_energy[m], L_tmp1, &L_tmp2_e ); L_tmp2_e = add( L_tmp2_e, sub( subframe_energy_e[m], L_tmp1_e ) ); // if ( subframe_energy[m] / ( hStereoDmxEVS->hPHA->trns_aux_energy[k] + EPSILON ) > hStereoDmxEVS->hPHA->crst_fctr ) if ( BASOP_Util_Cmp_Mant32Exp( L_tmp2, L_tmp2_e, hStereoDmxEVS->hPHA->crst_fctr_fx, 31 ) > 0 ) // if ( subframe_energy[m] / ( hPHA->trns_aux_energy[k] + EPSILON ) > hPHA->crst_fctr ) if ( BASOP_Util_Cmp_Mant32Exp( L_tmp2, L_tmp2_e, hPHA->crst_fctr_fx, 31 ) > 0 ) { is_transient = 1; move16(); } // hStereoDmxEVS->hPHA->trns_aux_energy[k] = STEREO_DMX_EVS_TRNS_EGY_FORGETTING * hStereoDmxEVS->hPHA->trns_aux_energy[k] + ( 1.0f - STEREO_DMX_EVS_TRNS_EGY_FORGETTING ) * subframe_energy[m]; hStereoDmxEVS->hPHA->trns_aux_energy_fx[k] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( hStereoDmxEVS->hPHA->trns_aux_energy_fx[k], STEREO_DMX_EVS_TRNS_EGY_FORGETTING_Q15 ), hStereoDmxEVS->hPHA->trns_aux_energy_fx_e[k], Mpy_32_16_1( subframe_energy[m], sub( MAX_16, STEREO_DMX_EVS_TRNS_EGY_FORGETTING_Q15 ) ), subframe_energy_e[m], &hStereoDmxEVS->hPHA->trns_aux_energy_fx_e[k] ); // hPHA->trns_aux_energy[k] = STEREO_DMX_EVS_TRNS_EGY_FORGETTING * hPHA->trns_aux_energy[k] + ( 1.0f - STEREO_DMX_EVS_TRNS_EGY_FORGETTING ) * subframe_energy[m]; hPHA->trns_aux_energy_fx[k] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( hPHA->trns_aux_energy_fx[k], STEREO_DMX_EVS_TRNS_EGY_FORGETTING_Q15 ), hPHA->trns_aux_energy_fx_e[k], Mpy_32_16_1( subframe_energy[m], sub( MAX_16, STEREO_DMX_EVS_TRNS_EGY_FORGETTING_Q15 ) ), subframe_energy_e[m], &hPHA->trns_aux_energy_fx_e[k] ); move32(); } FOR( m = 1; m < STEREO_DMX_EVS_NB_SBFRM; m++ ) { L_tmp1 = BASOP_Util_Add_Mant32Exp( subframe_energy[m - 1], subframe_energy_e[m - 1], EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e ); L_tmp1 = BASOP_Util_Add_Mant32Exp( subframe_energy[sub( m, 1 )], subframe_energy_e[sub( m, 1 )], EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e ); L_tmp2 = BASOP_Util_Divide3232_Scale_cadence( subframe_energy[m], L_tmp1, &L_tmp2_e ); L_tmp2_e = add( L_tmp2_e, sub( subframe_energy_e[m], L_tmp1_e ) ); // if ( subframe_energy[m] / ( subframe_energy[m - 1] + EPSILON ) > STEREO_DMX_EVS_TRNS_DTC_INST ) Loading @@ -2575,14 +2580,14 @@ void stereo_dmx_evs_enc_fx( } } estimate_itd_fx( &corr, hStereoDmxEVS->hPOC, hStereoDmxEVS->hPHA, data_fx[0], data_fx[1], &hStereoDmxEVS->itd_fx, input_frame ); estimate_itd_fx( &corr, hStereoDmxEVS->hPOC, hPHA, data_fx[0], data_fx[1], &hStereoDmxEVS->itd_fx, input_frame ); /* poc */ IF( hStereoDmxEVS->itd_fx ) { // dmx_weight = ( ( hStereoDmxEVS->itd > 0 ) ? ( -1 ) : 1 ) * 0.5f * corr + 0.5f; IF( hStereoDmxEVS->itd_fx > 0 ) IF( GT_16( hStereoDmxEVS->itd_fx, 0 ) ) { dmx_weight = add( negate( shr( corr, 1 ) ), ONE_IN_Q14 ); } Loading @@ -2607,11 +2612,11 @@ void stereo_dmx_evs_enc_fx( /* pha */ pha_len = hStereoDmxEVS->hPHA->pha_len; pha_len = hPHA->pha_len; move16(); fad_len = hStereoDmxEVS->hPHA->fad_len; fad_len = hPHA->fad_len; move16(); fad_g = hStereoDmxEVS->hPHA->fad_g_fx; fad_g = hPHA->fad_g_fx; set_zero_fx( dmx_pha_data, n_samples ); set_zero_fx( mem_prev, fad_len ); Loading @@ -2619,12 +2624,12 @@ void stereo_dmx_evs_enc_fx( FOR( k = 0; k < CPE_CHANNELS; k++ ) { p_data = data_fx[k]; Copy32( hStereoDmxEVS->hPHA->data_mem_fx[k], data_mem, pha_len ); Copy32( &( p_data[n_samples - pha_len] ), hStereoDmxEVS->hPHA->data_mem_fx[k], pha_len ); Copy32( hPHA->data_mem_fx[k], data_mem, pha_len ); Copy32( &( p_data[sub( n_samples, pha_len )] ), hPHA->data_mem_fx[k], pha_len ); p_data_mem = &( data_mem[pha_len] ); Copy32( p_data, p_data_mem, n_samples ); p_prev_taps = hStereoDmxEVS->hPHA->p_prev_taps_fx[k]; p_prev_taps = hPHA->p_prev_taps_fx[k]; IF( p_prev_taps ) { FOR( n = 0; n < fad_len; n++ ) Loading @@ -2632,7 +2637,7 @@ void stereo_dmx_evs_enc_fx( FOR( ( fx_tmp = 0, m = 0 ); m < pha_len; m++ ) { // ftmp += p_data_mem[n - m] * p_prev_taps[m]; fx_tmp = L_add( fx_tmp, Mpy_32_32( p_data_mem[n - m], p_prev_taps[m] ) ); // Q25 fx_tmp = L_add( fx_tmp, Mpy_32_32( p_data_mem[sub( n, m )], p_prev_taps[m] ) ); // Q25 } fx_tmp = L_shl( fx_tmp, 1 ); // Q26 mem_prev[n] = L_add( mem_prev[n], Mpy_32_32( fx_tmp, INV_SQRT_2_Q31 ) ); Loading @@ -2649,7 +2654,7 @@ void stereo_dmx_evs_enc_fx( } } p_curr_taps = hStereoDmxEVS->hPHA->p_curr_taps_fx[k]; p_curr_taps = hPHA->p_curr_taps_fx[k]; IF( p_curr_taps ) { FOR( n = 0; n < n_samples; n++ ) Loading @@ -2657,7 +2662,7 @@ void stereo_dmx_evs_enc_fx( FOR( ( fx_tmp = 0, m = 0 ); m < pha_len; m++ ) { // ftmp += p_data_mem[n - m] * p_curr_taps[m]; fx_tmp = L_add( fx_tmp, Mpy_32_32( p_data_mem[n - m], p_curr_taps[m] ) ); // Q25 fx_tmp = L_add( fx_tmp, Mpy_32_32( p_data_mem[sub( n, m )], p_curr_taps[m] ) ); // Q25 } fx_tmp = L_shl( fx_tmp, 1 ); // Q26 // dmx_pha_data[n] += ftmp * INV_SQRT_2; Loading Loading @@ -2686,59 +2691,59 @@ void stereo_dmx_evs_enc_fx( /* prc switch */ prev_prc = hStereoDmxEVS->hPHA->curr_prc; prev_prc = hPHA->curr_prc; move32(); // if ( abs( (int16_t) hStereoDmxEVS->itd ) > hStereoDmxEVS->hPHA->prc_thres ) IF( GT_16( abs_s( hStereoDmxEVS->itd_fx ), hStereoDmxEVS->hPHA->prc_thres ) ) // if ( abs( (int16_t) hStereoDmxEVS->itd ) > hPHA->prc_thres ) IF( GT_16( abs_s( hStereoDmxEVS->itd_fx ), hPHA->prc_thres ) ) { IF( NE_32( hStereoDmxEVS->hPHA->curr_prc, STEREO_DMX_EVS_PRC_POC ) ) IF( NE_32( hPHA->curr_prc, STEREO_DMX_EVS_PRC_POC ) ) { IF( EQ_32( hStereoDmxEVS->hPHA->prev_prc, STEREO_DMX_EVS_PRC_POC ) ) IF( EQ_32( hPHA->prev_prc, STEREO_DMX_EVS_PRC_POC ) ) { hStereoDmxEVS->hPHA->prc_hys_cnt = add( hStereoDmxEVS->hPHA->prc_hys_cnt, 1 ); hPHA->prc_hys_cnt = add( hPHA->prc_hys_cnt, 1 ); move16(); } ELSE { hStereoDmxEVS->hPHA->prc_hys_cnt = 0; hPHA->prc_hys_cnt = 0; move16(); } if ( GE_16( hStereoDmxEVS->hPHA->prc_hys_cnt, STEREO_DMX_EVS_SWTCH_PRC_HYS_THRES ) ) if ( GE_16( hPHA->prc_hys_cnt, STEREO_DMX_EVS_SWTCH_PRC_HYS_THRES ) ) { hStereoDmxEVS->hPHA->curr_prc = STEREO_DMX_EVS_PRC_POC; hPHA->curr_prc = STEREO_DMX_EVS_PRC_POC; move32(); } } hStereoDmxEVS->hPHA->prev_prc = STEREO_DMX_EVS_PRC_POC; hPHA->prev_prc = STEREO_DMX_EVS_PRC_POC; move32(); } ELSE { IF( NE_32( hStereoDmxEVS->hPHA->curr_prc, STEREO_DMX_EVS_PRC_PHA ) ) IF( NE_32( hPHA->curr_prc, STEREO_DMX_EVS_PRC_PHA ) ) { IF( EQ_32( hStereoDmxEVS->hPHA->prev_prc, STEREO_DMX_EVS_PRC_PHA ) ) IF( EQ_32( hPHA->prev_prc, STEREO_DMX_EVS_PRC_PHA ) ) { hStereoDmxEVS->hPHA->prc_hys_cnt = add( hStereoDmxEVS->hPHA->prc_hys_cnt, 1 ); hPHA->prc_hys_cnt = add( hPHA->prc_hys_cnt, 1 ); move16(); } ELSE { hStereoDmxEVS->hPHA->prc_hys_cnt = 0; hPHA->prc_hys_cnt = 0; move16(); } if ( GE_16( hStereoDmxEVS->hPHA->prc_hys_cnt, STEREO_DMX_EVS_SWTCH_PRC_HYS_THRES ) ) if ( GE_16( hPHA->prc_hys_cnt, STEREO_DMX_EVS_SWTCH_PRC_HYS_THRES ) ) { hStereoDmxEVS->hPHA->curr_prc = STEREO_DMX_EVS_PRC_PHA; hPHA->curr_prc = STEREO_DMX_EVS_PRC_PHA; move32(); } } hStereoDmxEVS->hPHA->prev_prc = STEREO_DMX_EVS_PRC_PHA; hPHA->prev_prc = STEREO_DMX_EVS_PRC_PHA; move32(); } // if ( ( is_transient == 1 ) || ( hStereoDmxEVS->aux_dmx_energy[0] > STEREO_DMX_EVS_ILDS_EGY * hStereoDmxEVS->aux_dmx_energy[1] ) || ( hStereoDmxEVS->aux_dmx_energy[1] > STEREO_DMX_EVS_ILDS_EGY * hStereoDmxEVS->aux_dmx_energy[0] ) || ( ( hStereoDmxEVS->hPHA->p_curr_taps[0] == NULL ) && ( hStereoDmxEVS->hPHA->p_curr_taps[1] == NULL ) ) ) // if ( ( is_transient == 1 ) || ( hStereoDmxEVS->aux_dmx_energy[0] > STEREO_DMX_EVS_ILDS_EGY * hStereoDmxEVS->aux_dmx_energy[1] ) || ( hStereoDmxEVS->aux_dmx_energy[1] > STEREO_DMX_EVS_ILDS_EGY * hStereoDmxEVS->aux_dmx_energy[0] ) || ( ( hPHA->p_curr_taps[0] == NULL ) && ( hPHA->p_curr_taps[1] == NULL ) ) ) test(); test(); test(); Loading @@ -2746,60 +2751,60 @@ void stereo_dmx_evs_enc_fx( IF( EQ_16( is_transient, 1 ) || BASOP_Util_Cmp_Mant32Exp( hStereoDmxEVS->aux_dmx_energy_fx[0], hStereoDmxEVS->aux_dmx_energy_fx_e[0], Mpy_32_32( STEREO_DMX_EVS_ILDS_EGY_Q17, hStereoDmxEVS->aux_dmx_energy_fx[1] ), add( hStereoDmxEVS->aux_dmx_energy_fx_e[1], 14 ) ) > 0 || BASOP_Util_Cmp_Mant32Exp( hStereoDmxEVS->aux_dmx_energy_fx[1], hStereoDmxEVS->aux_dmx_energy_fx_e[1], Mpy_32_32( STEREO_DMX_EVS_ILDS_EGY_Q17, hStereoDmxEVS->aux_dmx_energy_fx[0] ), add( hStereoDmxEVS->aux_dmx_energy_fx_e[0], 14 ) ) > 0 || EQ_16( hStereoDmxEVS->hPHA->force_poc, TRUE ) ) EQ_16( hPHA->force_poc, TRUE ) ) { hStereoDmxEVS->hPHA->curr_prc = STEREO_DMX_EVS_PRC_POC; hPHA->curr_prc = STEREO_DMX_EVS_PRC_POC; move32(); hStereoDmxEVS->hPHA->prc_hys_cnt = 0; hPHA->prc_hys_cnt = 0; move16(); } calc_energy_sgc( dmx_poc_data, &( hStereoDmxEVS->hPHA->dmx_poc_ener_fx ), &( hStereoDmxEVS->hPHA->dmx_poc_ener_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); calc_energy_sgc( dmx_pha_data, &( hStereoDmxEVS->hPHA->dmx_pha_ener_fx ), &( hStereoDmxEVS->hPHA->dmx_pha_ener_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); calc_energy_sgc( dmx_poc_data, &( hPHA->dmx_poc_ener_fx ), &( hPHA->dmx_poc_ener_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); calc_energy_sgc( dmx_pha_data, &( hPHA->dmx_pha_ener_fx ), &( hPHA->dmx_pha_ener_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); IF( NE_32( prev_prc, hStereoDmxEVS->hPHA->curr_prc ) && EQ_16( is_transient, 0 ) && !( ( BASOP_Util_Cmp_Mant32Exp( hStereoDmxEVS->hPHA->dmx_pha_ener_fx, hStereoDmxEVS->hPHA->dmx_pha_ener_fx_e, hStereoDmxEVS->hPHA->low_egy_thres_sgc, hStereoDmxEVS->hPHA->low_egy_thres_sgc_e ) < 0 ) && ( BASOP_Util_Cmp_Mant32Exp( hStereoDmxEVS->hPHA->dmx_poc_ener_fx, hStereoDmxEVS->hPHA->dmx_poc_ener_fx_e, hStereoDmxEVS->hPHA->low_egy_thres_sgc, hStereoDmxEVS->hPHA->low_egy_thres_sgc_e ) < 0 ) ) ) IF( NE_32( prev_prc, hPHA->curr_prc ) && EQ_16( is_transient, 0 ) && !( ( BASOP_Util_Cmp_Mant32Exp( hPHA->dmx_pha_ener_fx, hPHA->dmx_pha_ener_fx_e, hPHA->low_egy_thres_sgc, hPHA->low_egy_thres_sgc_e ) < 0 ) && ( BASOP_Util_Cmp_Mant32Exp( hPHA->dmx_poc_ener_fx, hPHA->dmx_poc_ener_fx_e, hPHA->low_egy_thres_sgc, hPHA->low_egy_thres_sgc_e ) < 0 ) ) ) { IF( EQ_32( hStereoDmxEVS->hPHA->curr_prc, STEREO_DMX_EVS_PRC_POC ) ) IF( EQ_32( hPHA->curr_prc, STEREO_DMX_EVS_PRC_POC ) ) { apply_gain_sgc( dmx_pha_data, &( hStereoDmxEVS->hPHA->dmx_pha_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_pha_data, &( hStereoDmxEVS->hPHA->dmx_pha_ener_sgc_fx ), &( hStereoDmxEVS->hPHA->dmx_pha_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); apply_gain_sgc( dmx_pha_data, &( hPHA->dmx_pha_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_pha_data, &( hPHA->dmx_pha_ener_sgc_fx ), &( hPHA->dmx_pha_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); L_tmp1 = BASOP_Util_Add_Mant32Exp( hStereoDmxEVS->hPHA->dmx_poc_ener_fx, hStereoDmxEVS->hPHA->dmx_poc_ener_fx_e, EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e ); BASOP_Util_Divide_MantExp( extract_h( hStereoDmxEVS->hPHA->dmx_pha_ener_sgc_fx ), hStereoDmxEVS->hPHA->dmx_pha_ener_sgc_fx_e, extract_h( L_tmp1 ), L_tmp1_e, &dmx_gain_sgc, &L_tmp2_e ); L_tmp1 = BASOP_Util_Add_Mant32Exp( hPHA->dmx_poc_ener_fx, hPHA->dmx_poc_ener_fx_e, EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e ); BASOP_Util_Divide_MantExp( extract_h( hPHA->dmx_pha_ener_sgc_fx ), hPHA->dmx_pha_ener_sgc_fx_e, extract_h( L_tmp1 ), L_tmp1_e, &dmx_gain_sgc, &L_tmp2_e ); dmx_gain_sgc = Sqrt16( dmx_gain_sgc, &L_tmp2_e ); hStereoDmxEVS->hPHA->dmx_poc_gain_sgc_fx = L_shl( L_deposit_l( dmx_gain_sgc ), L_tmp2_e ); // Q15 hStereoDmxEVS->hPHA->dmx_poc_gain_sgc_fx = L_min( hStereoDmxEVS->hPHA->dmx_poc_gain_sgc_fx, STEREO_DMX_EVS_SGC_GMAX ); hStereoDmxEVS->hPHA->dmx_poc_gain_sgc_fx = L_max( hStereoDmxEVS->hPHA->dmx_poc_gain_sgc_fx, STEREO_DMX_EVS_SGC_GMIN ); hPHA->dmx_poc_gain_sgc_fx = L_shl( L_deposit_l( dmx_gain_sgc ), L_tmp2_e ); // Q15 hPHA->dmx_poc_gain_sgc_fx = L_min( hPHA->dmx_poc_gain_sgc_fx, STEREO_DMX_EVS_SGC_GMAX ); hPHA->dmx_poc_gain_sgc_fx = L_max( hPHA->dmx_poc_gain_sgc_fx, STEREO_DMX_EVS_SGC_GMIN ); apply_gain_sgc( dmx_poc_data, &( hStereoDmxEVS->hPHA->dmx_poc_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_poc_data, &( hStereoDmxEVS->hPHA->dmx_poc_ener_sgc_fx ), &( hStereoDmxEVS->hPHA->dmx_poc_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); apply_gain_sgc( dmx_poc_data, &( hPHA->dmx_poc_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_poc_data, &( hPHA->dmx_poc_ener_sgc_fx ), &( hPHA->dmx_poc_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); } ELSE { apply_gain_sgc( dmx_poc_data, &( hStereoDmxEVS->hPHA->dmx_poc_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_poc_data, &( hStereoDmxEVS->hPHA->dmx_poc_ener_sgc_fx ), &( hStereoDmxEVS->hPHA->dmx_poc_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); apply_gain_sgc( dmx_poc_data, &( hPHA->dmx_poc_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_poc_data, &( hPHA->dmx_poc_ener_sgc_fx ), &( hPHA->dmx_poc_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); L_tmp1 = BASOP_Util_Add_Mant32Exp( hStereoDmxEVS->hPHA->dmx_pha_ener_fx, hStereoDmxEVS->hPHA->dmx_pha_ener_fx_e, EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e ); BASOP_Util_Divide_MantExp( extract_h( hStereoDmxEVS->hPHA->dmx_poc_ener_sgc_fx ), hStereoDmxEVS->hPHA->dmx_poc_ener_sgc_fx_e, extract_h( L_tmp1 ), L_tmp1_e, &dmx_gain_sgc, &L_tmp2_e ); L_tmp1 = BASOP_Util_Add_Mant32Exp( hPHA->dmx_pha_ener_fx, hPHA->dmx_pha_ener_fx_e, EPSILON_FX_M, EPSILON_FX_E, &L_tmp1_e ); BASOP_Util_Divide_MantExp( extract_h( hPHA->dmx_poc_ener_sgc_fx ), hPHA->dmx_poc_ener_sgc_fx_e, extract_h( L_tmp1 ), L_tmp1_e, &dmx_gain_sgc, &L_tmp2_e ); dmx_gain_sgc = Sqrt16( dmx_gain_sgc, &L_tmp2_e ); hStereoDmxEVS->hPHA->dmx_pha_gain_sgc_fx = L_shl( L_deposit_l( dmx_gain_sgc ), L_tmp2_e ); // Q15 hStereoDmxEVS->hPHA->dmx_pha_gain_sgc_fx = L_min( hStereoDmxEVS->hPHA->dmx_pha_gain_sgc_fx, STEREO_DMX_EVS_SGC_GMAX ); hStereoDmxEVS->hPHA->dmx_pha_gain_sgc_fx = L_max( hStereoDmxEVS->hPHA->dmx_pha_gain_sgc_fx, STEREO_DMX_EVS_SGC_GMIN ); hPHA->dmx_pha_gain_sgc_fx = L_shl( L_deposit_l( dmx_gain_sgc ), L_tmp2_e ); // Q15 hPHA->dmx_pha_gain_sgc_fx = L_min( hPHA->dmx_pha_gain_sgc_fx, STEREO_DMX_EVS_SGC_GMAX ); hPHA->dmx_pha_gain_sgc_fx = L_max( hPHA->dmx_pha_gain_sgc_fx, STEREO_DMX_EVS_SGC_GMIN ); apply_gain_sgc( dmx_pha_data, &( hStereoDmxEVS->hPHA->dmx_pha_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_pha_data, &( hStereoDmxEVS->hPHA->dmx_pha_ener_sgc_fx ), &( hStereoDmxEVS->hPHA->dmx_pha_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); apply_gain_sgc( dmx_pha_data, &( hPHA->dmx_pha_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_pha_data, &( hPHA->dmx_pha_ener_sgc_fx ), &( hPHA->dmx_pha_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); } } ELSE { apply_gain_sgc( dmx_poc_data, &( hStereoDmxEVS->hPHA->dmx_poc_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_poc_data, &( hStereoDmxEVS->hPHA->dmx_poc_ener_sgc_fx ), &( hStereoDmxEVS->hPHA->dmx_poc_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); apply_gain_sgc( dmx_poc_data, &( hPHA->dmx_poc_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_poc_data, &( hPHA->dmx_poc_ener_sgc_fx ), &( hPHA->dmx_poc_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); apply_gain_sgc( dmx_pha_data, &( hStereoDmxEVS->hPHA->dmx_pha_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_pha_data, &( hStereoDmxEVS->hPHA->dmx_pha_ener_sgc_fx ), &( hStereoDmxEVS->hPHA->dmx_pha_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); apply_gain_sgc( dmx_pha_data, &( hPHA->dmx_pha_gain_sgc_fx ), n_samples ); calc_energy_sgc( dmx_pha_data, &( hPHA->dmx_pha_ener_sgc_fx ), &( hPHA->dmx_pha_ener_sgc_fx_e ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING_Q15 ); } IF( EQ_32( hStereoDmxEVS->hPHA->curr_prc, STEREO_DMX_EVS_PRC_POC ) ) IF( EQ_32( hPHA->curr_prc, STEREO_DMX_EVS_PRC_POC ) ) { p_dmx_data = dmx_poc_data; p_dmx_data_fo = dmx_pha_data; Loading @@ -2821,47 +2826,48 @@ void stereo_dmx_evs_enc_fx( move16(); } IF( NE_32( prev_prc, hStereoDmxEVS->hPHA->curr_prc ) ) IF( NE_32( prev_prc, hPHA->curr_prc ) ) { IF( EQ_16( hStereoDmxEVS->hPHA->n_fad_g, input_frame ) ) IF( EQ_16( hPHA->n_fad_g, input_frame ) ) { hStereoDmxEVS->hPHA->n_fad_g = 0; hStereoDmxEVS->hPHA->n_fad_cnt = 0; hPHA->n_fad_g = 0; hPHA->n_fad_cnt = 0; move16(); move16(); } ELSE { hStereoDmxEVS->hPHA->n_fad_g = sub( input_frame, add( hStereoDmxEVS->hPHA->n_fad_g, 1 ) ); hPHA->n_fad_g = sub( input_frame, add( hPHA->n_fad_g, 1 ) ); #ifdef NONBE_FIX_947_STEREO_DMX_FADOPT hStereoDmxEVS->hPHA->n_fad_cnt = 0; hPHA->n_fad_cnt = 0; move16(); #else IF( EQ_16( is_transient, 1 ) ) { hStereoDmxEVS->hPHA->n_fad_cnt = 0; hPHA->n_fad_cnt = 0; move16(); } ELSE { hStereoDmxEVS->hPHA->n_fad_cnt = sub( n_fad_r, hStereoDmxEVS->hPHA->n_fad_cnt ); hPHA->n_fad_cnt = sub( n_fad_r, hPHA->n_fad_cnt ); } #endif } } ELSE IF( is_transient ) { hStereoDmxEVS->hPHA->n_fad_cnt = 0; hPHA->n_fad_cnt = 0; move16(); } fad_len = s_min( n_samples, sub( mult0( input_frame, n_fad_r ), add( mult0( hStereoDmxEVS->hPHA->n_fad_g, n_fad_r ), hStereoDmxEVS->hPHA->n_fad_cnt ) ) ); fad_len = s_min( n_samples, sub( mult0( input_frame, n_fad_r ), add( mult0( hPHA->n_fad_g, n_fad_r ), hPHA->n_fad_cnt ) ) ); IF( NE_16( fad_len, 0 ) ) { fad_g = hStereoDmxEVS->hPHA->fad_g_prc_fx; fad_g = hPHA->fad_g_prc_fx; move32(); n_fad_g = hStereoDmxEVS->hPHA->n_fad_g; n_fad_cnt = hStereoDmxEVS->hPHA->n_fad_cnt; n_fad_g = hPHA->n_fad_g; n_fad_cnt = hPHA->n_fad_cnt; move16(); move16(); m_fad_g = sub( input_frame, add( n_fad_g, 1 ) ); Loading Loading @@ -2949,8 +2955,8 @@ void stereo_dmx_evs_enc_fx( } #endif hStereoDmxEVS->hPHA->n_fad_g = n_fad_g; hStereoDmxEVS->hPHA->n_fad_cnt = n_fad_cnt; hPHA->n_fad_g = n_fad_g; hPHA->n_fad_cnt = n_fad_cnt; move16(); move16(); } Loading Loading @@ -3350,7 +3356,7 @@ ivas_error stereo_dmx_evs_init_encoder_fx( Word16 n, input_frame; Word16 m, len, pha_len, fad_len, fad_len2, rfft_ipd_coef_step, n0, input_frame_pha; Word32 *fad_g, fad_r, *ipd_ff; Word32 *fad_g, fad_r; Word16 *win; const Word16 *p_ipd_w; Word16 tmp_e; Loading Loading @@ -3608,7 +3614,7 @@ ivas_error stereo_dmx_evs_init_encoder_fx( move16(); IF( EQ_32( input_Fs, 16000 ) ) { hStereoDmxEVS->hPHA->win_fx[pha_len - 1] = 7373; /*0.45f in Q14*/ hStereoDmxEVS->hPHA->win_fx[sub( pha_len, 1 )] = 7373; /*0.45f in Q14*/ move16(); } ELSE IF( EQ_32( input_Fs, 32000 ) || EQ_32( input_Fs, 48000 ) ) Loading Loading @@ -3641,8 +3647,7 @@ ivas_error stereo_dmx_evs_init_encoder_fx( /* Compute the forgetting factor */ // replaced below logic with table as it is same for all frame lengths ipd_ff = hStereoDmxEVS->hPHA->ipd_ff_fx; Copy32( ipd_ff_Q31, ipd_ff, STEREO_DMX_EVS_NB_SUBBAND_MAX ); Copy32( ipd_ff_Q31, hStereoDmxEVS->hPHA->ipd_ff_fx, STEREO_DMX_EVS_NB_SUBBAND_MAX ); #ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA hStereoDmxEVS->hPHA->proc_pha = STEREO_DMX_EVS_PHA_IPD; Loading Loading @@ -3701,7 +3706,7 @@ ivas_error stereo_dmx_evs_init_encoder_fx( { win[n] = p_ipd_w[n * len]; move16(); win[input_frame_pha - n] = p_ipd_w[n * len]; win[sub( input_frame_pha, n )] = p_ipd_w[n * len]; move16(); } win[n0] = p_ipd_w[n0 * len]; Loading