Commit c9872fcb authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Fix for 3GPP issue 1365: Narrowband difference between BASOP decoder and float...

Fix for 3GPP issue 1365: Narrowband difference between BASOP decoder and float decoder with McMASA bitstream

Link #1365

With these changes, the narrowband difference for the 1st channel is eliminated. However, for the 2nd channel, even after using 64-bit calculations for energyBuildup_fx, there is still a loss of precision. When comparing energyBuildup >= 1.0f, the value for fixed is 1.00006783, while for float it is 0.999947906.
parent a185318f
Loading
Loading
Loading
Loading
Loading
+15 −16
Original line number Diff line number Diff line
@@ -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,14 +377,13 @@ 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 );
@@ -399,7 +399,6 @@ static void ivas_binaural_reverb_setReverbTimes_fx(

                    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, &currentEnergy_exp );
                currentEnergy_fx = Mpy_32_32( currentEnergy_fx, attenuationFactorPerSampleSq_fx );