Loading lib_enc/ivas_stereo_td_analysis.c +47 −7 Original line number Diff line number Diff line Loading @@ -173,7 +173,7 @@ int16_t stereo_tdm_ener_analysis( NOOP_decision( hCPE, tdm_NOOP_flag_loc, tmp_SM_flag, rms_L, rms_R, &tdm_SM_flag_loc ); /*----------------------------------------------------------------* * Adjust stereo downmixing adaptation rate factor * Adjust stereo down-mixing adaptation rate factor * in function of the signal energy. If signal energy is low, * adaptation rate factor is lower. This prevent stereo image * move on speech offset Loading Loading @@ -737,7 +737,7 @@ static int16_t Get_dt_lt_ener( /*-------------------------------------------------------------------* * Function NOOP_decision() * * Set Near Out Of Phase decision * Set Near Out Of Phase decision (HW) *-------------------------------------------------------------------*/ static void NOOP_decision( Loading Loading @@ -882,11 +882,19 @@ static float Comp_diff_lt_corr( /*----------------------------------------------------------------* * Adjust stereo downmixing adaptation rate factor * in function of the signal energy. If signal energy is low, * adaptation rate factor is lower. This prevent stereo image * move on speech offset * adaptation rate factor is lower. This prevents stereo image * to move on speech offset. * In particular, for input signal that is considered as having low * correlation (LRTD), and the left or the right channel has more * than the double of long term energy than the other channel, * then the maximum long term energy between left and right will * be choosen to set up the adaption rate. * for all the other cases, the minimum between the 2 channel * long term energy will be used *----------------------------------------------------------------*/ if ( IsSideMono == 0 && hCPE->hStereoClassif->lrtd_mode == 1 && ( ( tdm_lt_rms_R > 2.0f * tdm_lt_rms_L ) || ( tdm_lt_rms_L > 2.0f * tdm_lt_rms_R ) ) ) if ( IsSideMono == 0 && hCPE->hStereoClassif->lrtd_mode == 1 && ( ( tdm_lt_rms_R > 2.0f * tdm_lt_rms_L ) || ( tdm_lt_rms_L > 2.0f * tdm_lt_rms_R ) ) ) { adaprate = M_ADAP * max( tdm_lt_rms_R, tdm_lt_rms_L ) + B_ADAP; } Loading @@ -898,7 +906,7 @@ static float Comp_diff_lt_corr( adaprate = check_bounds( adaprate, MIN_ADAP_FAC, 1.0f ); /*----------------------------------------------------------------* * In case of unvoiced content (expect when it is part of an onset), * In case of unvoiced content (except when it is part of an onset), * the adaptation rate is minimal. *----------------------------------------------------------------*/ Loading @@ -912,13 +920,25 @@ static float Comp_diff_lt_corr( d_lt_corr_raw = 0.0f; if ( IsSideMono == 0 ) { /*----------------------------------------------------------------* * In case of switching from a different stereo mode or * if on of the channel has very low energy and the signal is * considered as having a low correlation (LRTD) and the maximum * long term energy betweenm the 2 channel is below 10 * then speed up the adaptation rate *----------------------------------------------------------------*/ if ( hCPE->last_element_mode != IVAS_CPE_TD || ( ( tdm_lt_rms_R < 1.0f || tdm_lt_rms_L < 1.0f ) && hCPE->hStereoClassif->lrtd_mode == 1 && max( tdm_lt_rms_R, tdm_lt_rms_L ) < 10.0f ) ) { adaprate = 0.98f; /* speed up the adaptation of the long term values to the current values after coming from DFT */ } adaprate_tmp = max( adaprate, 0.8f ); madaprate = 1.0f - adaprate_tmp; /* madaprate has temporary value, will updated few lines below */ /*----------------------------------------------------------------* * Compute the short term correlation to mono difference * Then compute the instantaneous ratio between L and R channel. * The instantaneous ratio is used for bit rate distribution in case of LRTD, * while a more convservative ratio is found later and used for downmixing purpose *----------------------------------------------------------------*/ d_lt_corr_raw = ( adaprate_tmp * corr_LM + madaprate * *tdm_lt_corr_LM ) - ( adaprate_tmp * corr_RM + madaprate * *tdm_lt_corr_RM ); /* Short term smooth correlation differences to mono */ inst_ratio_L = 0.0f; Loading @@ -928,6 +948,10 @@ static float Comp_diff_lt_corr( inst_ratio_L = 0.667f * inst_ratio_L + 1.0f; *inst_ratio_L_out = ( 1.0f - cosf( EVS_PI * inst_ratio_L / 2.0f ) ) / 2.0f; } /*----------------------------------------------------------------* * Find a first estimation of the correlation/energy to mono * of L and R difference *----------------------------------------------------------------*/ madaprate = 1.0f - adaprate; corr_RM = adaprate * corr_RM + madaprate * *tdm_lt_corr_RM; corr_LM = adaprate * corr_LM + madaprate * *tdm_lt_corr_LM; Loading @@ -940,6 +964,22 @@ static float Comp_diff_lt_corr( /*----------------------------------------------------------------* * Correct the estimation depending of channels energies evolution * In case of out of phase signal and the rms of both L and R channels * are low and the long term rms of each channel is below 80% of * its current rms value and the long term rms of one of the channel * is more than the double of the other channel * then, * the long term corr evolved slowly using 80% of its long term * value and 20% of the current correlation. it is further * amplified by a factor of 2.5 * * else if the energy differential of both channel are going in the * same direction and the variation of the correlation diffirence * is low and the energy of at least one channel is not too low * then, * the long term corr uses the values estimated above * else * the long term corr average its values with the current correlation *----------------------------------------------------------------*/ if ( IsSideMono == 1 && ( ( rms_L < RMS_MIN2 && rms_R < RMS_MIN2 ) && ( ( tdm_lt_rms_L < 0.8f * rms_L ) && ( tdm_lt_rms_R < 0.8f * rms_R ) ) && Loading Loading
lib_enc/ivas_stereo_td_analysis.c +47 −7 Original line number Diff line number Diff line Loading @@ -173,7 +173,7 @@ int16_t stereo_tdm_ener_analysis( NOOP_decision( hCPE, tdm_NOOP_flag_loc, tmp_SM_flag, rms_L, rms_R, &tdm_SM_flag_loc ); /*----------------------------------------------------------------* * Adjust stereo downmixing adaptation rate factor * Adjust stereo down-mixing adaptation rate factor * in function of the signal energy. If signal energy is low, * adaptation rate factor is lower. This prevent stereo image * move on speech offset Loading Loading @@ -737,7 +737,7 @@ static int16_t Get_dt_lt_ener( /*-------------------------------------------------------------------* * Function NOOP_decision() * * Set Near Out Of Phase decision * Set Near Out Of Phase decision (HW) *-------------------------------------------------------------------*/ static void NOOP_decision( Loading Loading @@ -882,11 +882,19 @@ static float Comp_diff_lt_corr( /*----------------------------------------------------------------* * Adjust stereo downmixing adaptation rate factor * in function of the signal energy. If signal energy is low, * adaptation rate factor is lower. This prevent stereo image * move on speech offset * adaptation rate factor is lower. This prevents stereo image * to move on speech offset. * In particular, for input signal that is considered as having low * correlation (LRTD), and the left or the right channel has more * than the double of long term energy than the other channel, * then the maximum long term energy between left and right will * be choosen to set up the adaption rate. * for all the other cases, the minimum between the 2 channel * long term energy will be used *----------------------------------------------------------------*/ if ( IsSideMono == 0 && hCPE->hStereoClassif->lrtd_mode == 1 && ( ( tdm_lt_rms_R > 2.0f * tdm_lt_rms_L ) || ( tdm_lt_rms_L > 2.0f * tdm_lt_rms_R ) ) ) if ( IsSideMono == 0 && hCPE->hStereoClassif->lrtd_mode == 1 && ( ( tdm_lt_rms_R > 2.0f * tdm_lt_rms_L ) || ( tdm_lt_rms_L > 2.0f * tdm_lt_rms_R ) ) ) { adaprate = M_ADAP * max( tdm_lt_rms_R, tdm_lt_rms_L ) + B_ADAP; } Loading @@ -898,7 +906,7 @@ static float Comp_diff_lt_corr( adaprate = check_bounds( adaprate, MIN_ADAP_FAC, 1.0f ); /*----------------------------------------------------------------* * In case of unvoiced content (expect when it is part of an onset), * In case of unvoiced content (except when it is part of an onset), * the adaptation rate is minimal. *----------------------------------------------------------------*/ Loading @@ -912,13 +920,25 @@ static float Comp_diff_lt_corr( d_lt_corr_raw = 0.0f; if ( IsSideMono == 0 ) { /*----------------------------------------------------------------* * In case of switching from a different stereo mode or * if on of the channel has very low energy and the signal is * considered as having a low correlation (LRTD) and the maximum * long term energy betweenm the 2 channel is below 10 * then speed up the adaptation rate *----------------------------------------------------------------*/ if ( hCPE->last_element_mode != IVAS_CPE_TD || ( ( tdm_lt_rms_R < 1.0f || tdm_lt_rms_L < 1.0f ) && hCPE->hStereoClassif->lrtd_mode == 1 && max( tdm_lt_rms_R, tdm_lt_rms_L ) < 10.0f ) ) { adaprate = 0.98f; /* speed up the adaptation of the long term values to the current values after coming from DFT */ } adaprate_tmp = max( adaprate, 0.8f ); madaprate = 1.0f - adaprate_tmp; /* madaprate has temporary value, will updated few lines below */ /*----------------------------------------------------------------* * Compute the short term correlation to mono difference * Then compute the instantaneous ratio between L and R channel. * The instantaneous ratio is used for bit rate distribution in case of LRTD, * while a more convservative ratio is found later and used for downmixing purpose *----------------------------------------------------------------*/ d_lt_corr_raw = ( adaprate_tmp * corr_LM + madaprate * *tdm_lt_corr_LM ) - ( adaprate_tmp * corr_RM + madaprate * *tdm_lt_corr_RM ); /* Short term smooth correlation differences to mono */ inst_ratio_L = 0.0f; Loading @@ -928,6 +948,10 @@ static float Comp_diff_lt_corr( inst_ratio_L = 0.667f * inst_ratio_L + 1.0f; *inst_ratio_L_out = ( 1.0f - cosf( EVS_PI * inst_ratio_L / 2.0f ) ) / 2.0f; } /*----------------------------------------------------------------* * Find a first estimation of the correlation/energy to mono * of L and R difference *----------------------------------------------------------------*/ madaprate = 1.0f - adaprate; corr_RM = adaprate * corr_RM + madaprate * *tdm_lt_corr_RM; corr_LM = adaprate * corr_LM + madaprate * *tdm_lt_corr_LM; Loading @@ -940,6 +964,22 @@ static float Comp_diff_lt_corr( /*----------------------------------------------------------------* * Correct the estimation depending of channels energies evolution * In case of out of phase signal and the rms of both L and R channels * are low and the long term rms of each channel is below 80% of * its current rms value and the long term rms of one of the channel * is more than the double of the other channel * then, * the long term corr evolved slowly using 80% of its long term * value and 20% of the current correlation. it is further * amplified by a factor of 2.5 * * else if the energy differential of both channel are going in the * same direction and the variation of the correlation diffirence * is low and the energy of at least one channel is not too low * then, * the long term corr uses the values estimated above * else * the long term corr average its values with the current correlation *----------------------------------------------------------------*/ if ( IsSideMono == 1 && ( ( rms_L < RMS_MIN2 && rms_R < RMS_MIN2 ) && ( ( tdm_lt_rms_L < 0.8f * rms_L ) && ( tdm_lt_rms_R < 0.8f * rms_R ) ) && Loading