Loading lib_rend/ivas_reverb_fx.c +24 −29 Original line number Diff line number Diff line Loading @@ -576,7 +576,7 @@ static ivas_error set_base_config_fx( *-----------------------------------------------------------------------------------------*/ static Word32 calc_dmx_gain_fx( void ) { const Word32 gain = DMX_GAIN; // Q25 const Word32 gain = DMX_GAIN; // Q23 move32(); return gain; } Loading Loading @@ -630,30 +630,26 @@ static ivas_error compute_t60_coeffs_fx( Word16 bin_idx, loop_idx, tf_T60_len, len; ivas_error error; Word16 loop_delay_sec_fx, norm_f_e, tmp; Word16 loop_delay_sec_fx, tmp; Word32 freq_Nyquist_fx = L_shr( output_Fs, 1 ); Word16 target_gains_db_fx[RV_LENGTH_NR_FC]; Word16 norm_f_fx[RV_LENGTH_NR_FC]; Word32 *targetT60_fx, *pFc_fx; Word16 *pCoeffs_a_fx, *pCoeffs_b_fx, *targetT60_e; Word16 target_gains_db_exp[RV_LENGTH_NR_FC]; Word16 *pCoeffs_a_fx, *pCoeffs_b_fx; Word16 e; error = IVAS_ERR_OK; move32(); tf_T60_len = nr_fc_fft_filter; move16(); len = add( pParams->t60_filter_order, 1 ); pFc_fx = pParams->pFc_fx; targetT60_fx = pParams->pRt60_fx; targetT60_e = pParams->pRt60_e; move16(); FOR( bin_idx = 0; bin_idx < tf_T60_len; bin_idx++ ) { norm_f_fx[bin_idx] = BASOP_Util_Divide3232_Scale( pFc_fx[bin_idx], freq_Nyquist_fx, &norm_f_e ); norm_f_fx[bin_idx] = BASOP_Util_Divide3232_Scale( pParams->pFc_fx[bin_idx], freq_Nyquist_fx, &e ); move16(); norm_f_e = add( norm_f_e, sub( 17, 31 ) ); norm_f_fx[bin_idx] = shl( norm_f_fx[bin_idx], sub( norm_f_e, 1 ) ); // making Q14 e = add( e, sub( 15, 31 ) ); norm_f_fx[bin_idx] = shl( norm_f_fx[bin_idx], sub( e, 1 ) ); // making Q14 move16(); } Loading @@ -661,24 +657,21 @@ static ivas_error compute_t60_coeffs_fx( { Word16 loop_delay_sec_fx_exp; loop_delay_sec_fx = BASOP_Util_Divide3232_Scale( pParams->pLoop_delays[loop_idx], output_Fs, &loop_delay_sec_fx_exp ); loop_delay_sec_fx = BASOP_Util_Divide3232_Scale( pParams->pLoop_delays[loop_idx], output_Fs, &e ); loop_delay_sec_fx = shl( loop_delay_sec_fx, e ); FOR( bin_idx = 0; bin_idx < tf_T60_len; bin_idx++ ) { tmp = BASOP_Util_Divide3232_Scale( L_deposit_h( loop_delay_sec_fx ), targetT60_fx[bin_idx], &target_gains_db_exp[bin_idx] ); target_gains_db_exp[bin_idx] = add( target_gains_db_exp[bin_idx], sub( loop_delay_sec_fx_exp, targetT60_e[bin_idx] ) ); move16(); target_gains_db_fx[bin_idx] = mult( -30720, tmp ); // -60 in Q9 -> -30720 move16(); target_gains_db_exp[bin_idx] = add( target_gains_db_exp[bin_idx], 6 ); // Q9 -> e6 move16(); tmp = BASOP_Util_Divide3232_Scale( L_deposit_h( loop_delay_sec_fx ), pParams->pRt60_fx[bin_idx], &e ); tmp = shr( tmp, add( e, 1 ) ); target_gains_db_fx[bin_idx] = mult( -30720, tmp ); // -60 in Q9 -> -30720 //targetgains is in Q9 tmp = BASOP_Util_Cmp_Mant32Exp( L_deposit_h( target_gains_db_fx[bin_idx] ), target_gains_db_exp[bin_idx], -2013265920, 7 ); //tmp = BASOP_Util_Cmp_Mant32Exp( L_deposit_h( target_gains_db_fx[bin_idx] ), target_gains_db_exp[bin_idx], -2013265920, 7 ); IF( tmp < 0 ) { target_gains_db_fx[bin_idx] = -30720; // -60 in Q9 -> -30720 move16(); target_gains_db_exp[bin_idx] = 7; //target_gains_db_exp[bin_idx] = 7; move16(); } } Loading @@ -686,21 +679,21 @@ static ivas_error compute_t60_coeffs_fx( pCoeffs_a_fx = &pParams->pT60_filter_coeff_fx[add( shl( i_mult( len, loop_idx ), 1 ), len )]; // Q14 pCoeffs_b_fx = &pParams->pT60_filter_coeff_fx[shl( i_mult( len, loop_idx ), 1 )]; // Q14 Word16 val = target_gains_db_exp[0]; //Word16 val = target_gains_db_exp[0]; move16(); FOR( Word16 i = 1; i < nr_fc_fft_filter; i++ ) { val = s_max( val, target_gains_db_exp[i] ); //val = s_max( val, target_gains_db_exp[i] ); } FOR( Word16 i = 0; i < nr_fc_fft_filter; i++ ) { target_gains_db_fx[i] = shr( target_gains_db_fx[i], sub( val, target_gains_db_exp[i] ) ); //target_gains_db_fx[i] = shr( target_gains_db_fx[i], sub( val, target_gains_db_exp[i] ) ); move16(); } IF( NE_32( ( error = calc_jot_t60_coeffs_fx( target_gains_db_fx, val, tf_T60_len, norm_f_fx, pCoeffs_a_fx, pCoeffs_b_fx, extract_l( freq_Nyquist_fx ) ) ), IVAS_ERR_OK ) ) //IF( NE_32( ( error = calc_jot_t60_coeffs_fx( target_gains_db_fx, val, tf_T60_len, norm_f_fx, pCoeffs_a_fx, pCoeffs_b_fx, extract_l( freq_Nyquist_fx ) ) ), IVAS_ERR_OK ) ) { return error; } Loading Loading @@ -1480,14 +1473,16 @@ ivas_error ivas_reverb_open_fx( params.pDsr_e = pDsr_e;//Should be removed set_reverb_acoustic_data_fx( ¶ms, &hRenderConfig->roomAcoustics, nr_fc_input, nr_fc_fft_filter ); Scale_sig32( params.pFc_fx, nr_fc_fft_filter, -2 ); //Not needed after adjusting the interpolate and scaling functions to output dsr in Q31, T60 in Q26 /*Scale_sig32( params.pFc_fx, nr_fc_fft_filter, -2 ); FOR( i = 0; i < nr_fc_fft_filter; i++ ) { params.pRt60_fx[i] = L_abs( params.pRt60_fx[i] ); move32(); params.pDsr_fx[i] = L_abs( params.pDsr_fx[i] ); move32(); } }*/ params.pHrtf_avg_pwr_response_l_const_fx = hHrtfStatistics->average_energy_l; params.pHrtf_avg_pwr_response_r_const_fx = hHrtfStatistics->average_energy_r; Loading @@ -1509,7 +1504,7 @@ ivas_error ivas_reverb_open_fx( } /* set up input downmix */ pState->dmx_gain_fx = calc_dmx_gain_fx(); pState->dmx_gain_fx = calc_dmx_gain_fx();//Q23 /* set up predelay - must be after set_base_config() and before compute_t60_coeffs() */ calc_predelay_fx( ¶ms, hRenderConfig->roomAcoustics.acousticPreDelay_fx, output_Fs ); Loading Loading
lib_rend/ivas_reverb_fx.c +24 −29 Original line number Diff line number Diff line Loading @@ -576,7 +576,7 @@ static ivas_error set_base_config_fx( *-----------------------------------------------------------------------------------------*/ static Word32 calc_dmx_gain_fx( void ) { const Word32 gain = DMX_GAIN; // Q25 const Word32 gain = DMX_GAIN; // Q23 move32(); return gain; } Loading Loading @@ -630,30 +630,26 @@ static ivas_error compute_t60_coeffs_fx( Word16 bin_idx, loop_idx, tf_T60_len, len; ivas_error error; Word16 loop_delay_sec_fx, norm_f_e, tmp; Word16 loop_delay_sec_fx, tmp; Word32 freq_Nyquist_fx = L_shr( output_Fs, 1 ); Word16 target_gains_db_fx[RV_LENGTH_NR_FC]; Word16 norm_f_fx[RV_LENGTH_NR_FC]; Word32 *targetT60_fx, *pFc_fx; Word16 *pCoeffs_a_fx, *pCoeffs_b_fx, *targetT60_e; Word16 target_gains_db_exp[RV_LENGTH_NR_FC]; Word16 *pCoeffs_a_fx, *pCoeffs_b_fx; Word16 e; error = IVAS_ERR_OK; move32(); tf_T60_len = nr_fc_fft_filter; move16(); len = add( pParams->t60_filter_order, 1 ); pFc_fx = pParams->pFc_fx; targetT60_fx = pParams->pRt60_fx; targetT60_e = pParams->pRt60_e; move16(); FOR( bin_idx = 0; bin_idx < tf_T60_len; bin_idx++ ) { norm_f_fx[bin_idx] = BASOP_Util_Divide3232_Scale( pFc_fx[bin_idx], freq_Nyquist_fx, &norm_f_e ); norm_f_fx[bin_idx] = BASOP_Util_Divide3232_Scale( pParams->pFc_fx[bin_idx], freq_Nyquist_fx, &e ); move16(); norm_f_e = add( norm_f_e, sub( 17, 31 ) ); norm_f_fx[bin_idx] = shl( norm_f_fx[bin_idx], sub( norm_f_e, 1 ) ); // making Q14 e = add( e, sub( 15, 31 ) ); norm_f_fx[bin_idx] = shl( norm_f_fx[bin_idx], sub( e, 1 ) ); // making Q14 move16(); } Loading @@ -661,24 +657,21 @@ static ivas_error compute_t60_coeffs_fx( { Word16 loop_delay_sec_fx_exp; loop_delay_sec_fx = BASOP_Util_Divide3232_Scale( pParams->pLoop_delays[loop_idx], output_Fs, &loop_delay_sec_fx_exp ); loop_delay_sec_fx = BASOP_Util_Divide3232_Scale( pParams->pLoop_delays[loop_idx], output_Fs, &e ); loop_delay_sec_fx = shl( loop_delay_sec_fx, e ); FOR( bin_idx = 0; bin_idx < tf_T60_len; bin_idx++ ) { tmp = BASOP_Util_Divide3232_Scale( L_deposit_h( loop_delay_sec_fx ), targetT60_fx[bin_idx], &target_gains_db_exp[bin_idx] ); target_gains_db_exp[bin_idx] = add( target_gains_db_exp[bin_idx], sub( loop_delay_sec_fx_exp, targetT60_e[bin_idx] ) ); move16(); target_gains_db_fx[bin_idx] = mult( -30720, tmp ); // -60 in Q9 -> -30720 move16(); target_gains_db_exp[bin_idx] = add( target_gains_db_exp[bin_idx], 6 ); // Q9 -> e6 move16(); tmp = BASOP_Util_Divide3232_Scale( L_deposit_h( loop_delay_sec_fx ), pParams->pRt60_fx[bin_idx], &e ); tmp = shr( tmp, add( e, 1 ) ); target_gains_db_fx[bin_idx] = mult( -30720, tmp ); // -60 in Q9 -> -30720 //targetgains is in Q9 tmp = BASOP_Util_Cmp_Mant32Exp( L_deposit_h( target_gains_db_fx[bin_idx] ), target_gains_db_exp[bin_idx], -2013265920, 7 ); //tmp = BASOP_Util_Cmp_Mant32Exp( L_deposit_h( target_gains_db_fx[bin_idx] ), target_gains_db_exp[bin_idx], -2013265920, 7 ); IF( tmp < 0 ) { target_gains_db_fx[bin_idx] = -30720; // -60 in Q9 -> -30720 move16(); target_gains_db_exp[bin_idx] = 7; //target_gains_db_exp[bin_idx] = 7; move16(); } } Loading @@ -686,21 +679,21 @@ static ivas_error compute_t60_coeffs_fx( pCoeffs_a_fx = &pParams->pT60_filter_coeff_fx[add( shl( i_mult( len, loop_idx ), 1 ), len )]; // Q14 pCoeffs_b_fx = &pParams->pT60_filter_coeff_fx[shl( i_mult( len, loop_idx ), 1 )]; // Q14 Word16 val = target_gains_db_exp[0]; //Word16 val = target_gains_db_exp[0]; move16(); FOR( Word16 i = 1; i < nr_fc_fft_filter; i++ ) { val = s_max( val, target_gains_db_exp[i] ); //val = s_max( val, target_gains_db_exp[i] ); } FOR( Word16 i = 0; i < nr_fc_fft_filter; i++ ) { target_gains_db_fx[i] = shr( target_gains_db_fx[i], sub( val, target_gains_db_exp[i] ) ); //target_gains_db_fx[i] = shr( target_gains_db_fx[i], sub( val, target_gains_db_exp[i] ) ); move16(); } IF( NE_32( ( error = calc_jot_t60_coeffs_fx( target_gains_db_fx, val, tf_T60_len, norm_f_fx, pCoeffs_a_fx, pCoeffs_b_fx, extract_l( freq_Nyquist_fx ) ) ), IVAS_ERR_OK ) ) //IF( NE_32( ( error = calc_jot_t60_coeffs_fx( target_gains_db_fx, val, tf_T60_len, norm_f_fx, pCoeffs_a_fx, pCoeffs_b_fx, extract_l( freq_Nyquist_fx ) ) ), IVAS_ERR_OK ) ) { return error; } Loading Loading @@ -1480,14 +1473,16 @@ ivas_error ivas_reverb_open_fx( params.pDsr_e = pDsr_e;//Should be removed set_reverb_acoustic_data_fx( ¶ms, &hRenderConfig->roomAcoustics, nr_fc_input, nr_fc_fft_filter ); Scale_sig32( params.pFc_fx, nr_fc_fft_filter, -2 ); //Not needed after adjusting the interpolate and scaling functions to output dsr in Q31, T60 in Q26 /*Scale_sig32( params.pFc_fx, nr_fc_fft_filter, -2 ); FOR( i = 0; i < nr_fc_fft_filter; i++ ) { params.pRt60_fx[i] = L_abs( params.pRt60_fx[i] ); move32(); params.pDsr_fx[i] = L_abs( params.pDsr_fx[i] ); move32(); } }*/ params.pHrtf_avg_pwr_response_l_const_fx = hHrtfStatistics->average_energy_l; params.pHrtf_avg_pwr_response_r_const_fx = hHrtfStatistics->average_energy_r; Loading @@ -1509,7 +1504,7 @@ ivas_error ivas_reverb_open_fx( } /* set up input downmix */ pState->dmx_gain_fx = calc_dmx_gain_fx(); pState->dmx_gain_fx = calc_dmx_gain_fx();//Q23 /* set up predelay - must be after set_base_config() and before compute_t60_coeffs() */ calc_predelay_fx( ¶ms, hRenderConfig->roomAcoustics.acousticPreDelay_fx, output_Fs ); Loading