diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 870f8795dd4ab6fd0d1a45dbf17205e15df3fda5..f985ac063a876a7d36164e3ff8e73e4d7ed9c5c5 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -230,6 +230,7 @@ static void ivas_binaural_reverb_setReverbTimes_fx( Word16 tmp, tmp_exp, scale, tmpVal_exp, attenuationFactorPerSample_exp, attenuationFactorPerSampleSq_exp, energyBuildup_exp, currentEnergy_exp, intendedEnergy_exp, actualizedEnergy_exp; Word16 sine_inp, norm, div_exp1, div1, sine, binCenterFreq_exp; Word16 reverb_exp = 0; + Word32 tmp32; move16(); hReverb->binRend_RandNext = (UWord16) BIN_REND_RANDOM_SEED; @@ -376,29 +377,27 @@ static void ivas_binaural_reverb_setReverbTimes_fx( UWord16 ret_binRend = binRend_rand( hReverb ); - tmp = BASOP_Util_Divide3232_Scale( ret_binRend, PCM16_TO_FLT_FAC_FX, &tmp_exp ); - L_tmp = BASOP_Util_Add_Mant32Exp( L_deposit_h( tmp ), tmp_exp, L_negate( 1073741824 ), 0, &exp ); - L_tmp = Mpy_32_32( L_tmp, 214748364 ); // exp + 0 + tmp32 = BASOP_Util_Divide3232_Scale_cadence( ret_binRend, PCM16_TO_FLT_FAC_FX, &tmp_exp ); + L_tmp = BASOP_Util_Add_Mant32Exp( tmp32, tmp_exp, L_negate( 1073741824 ), 0, &exp ); + L_tmp = Mpy_32_32( L_tmp, 214748365 ); // exp + 0 L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, exp, currentEnergy_fx, currentEnergy_exp, &exp ); energyBuildup_fx = BASOP_Util_Add_Mant32Exp( energyBuildup_fx, energyBuildup_exp, L_tmp, exp, &energyBuildup_exp ); - IF( energyBuildup_fx >= 0 ) /* A new filter tap is added at this condition */ + + IF( ( BASOP_Util_Cmp_Mant32Exp( energyBuildup_fx, energyBuildup_exp, 1, 31 ) >= 0 ) ) { - IF( ( BASOP_Util_Cmp_Mant32Exp( energyBuildup_fx, energyBuildup_exp, 1, 31 ) > 0 ) ) - { - /* Four efficient phase operations: n*pi/2, n=0,1,2,3 */ - hReverb->tapPhaseShiftType[bin][ch][tap] = (Word16) ( binRend_rand( hReverb ) % 4 ); - move16(); - /* Set the tapPointer to point to the determined sample at the loop buffer */ + /* Four efficient phase operations: n*pi/2, n=0,1,2,3 */ + hReverb->tapPhaseShiftType[bin][ch][tap] = (Word16) ( binRend_rand( hReverb ) % 4 ); + move16(); + /* Set the tapPointer to point to the determined sample at the loop buffer */ - hReverb->tapPointersReal_fx[bin][ch][tap] = &( hReverb->loopBufReal_fx[bin][sample] ); - hReverb->tapPointersImag_fx[bin][ch][tap] = &( hReverb->loopBufImag_fx[bin][sample] ); + hReverb->tapPointersReal_fx[bin][ch][tap] = &( hReverb->loopBufReal_fx[bin][sample] ); + hReverb->tapPointersImag_fx[bin][ch][tap] = &( hReverb->loopBufImag_fx[bin][sample] ); - energyBuildup_fx = BASOP_Util_Add_Mant32Exp( energyBuildup_fx, energyBuildup_exp, L_negate( 1073741824 ), 1, &energyBuildup_exp ); /* A tap is added, thus remove its energy from the buildup */ + energyBuildup_fx = BASOP_Util_Add_Mant32Exp( energyBuildup_fx, energyBuildup_exp, L_negate( 1073741824 ), 1, &energyBuildup_exp ); /* A tap is added, thus remove its energy from the buildup */ - tap = add( tap, 1 ); + tap = add( tap, 1 ); - actualizedEnergy_fx = BASOP_Util_Add_Mant32Exp( actualizedEnergy_fx, actualizedEnergy_exp, 1073741824, 1, &actualizedEnergy_exp ); - } + actualizedEnergy_fx = BASOP_Util_Add_Mant32Exp( actualizedEnergy_fx, actualizedEnergy_exp, 1073741824, 1, &actualizedEnergy_exp ); } currentEnergy_fx = BASOP_Util_Add_Mant32Exp( currentEnergy_fx, currentEnergy_exp, 0, 0, ¤tEnergy_exp );