Commit b1591c4a authored by TYAGIRIS's avatar TYAGIRIS
Browse files

update as per latest main

parents ba1f888d ca3146eb
Loading
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -105,8 +105,11 @@
#define REUSE_EVS_BE_GAINQ_LBR   // BE by adding one condition, but could be harmonized in a non-BE way. There is a small difference in how Etot is computed

#endif

#define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW   /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */
#define FIX_1844_MISSING_FREE                   /* FhG: add missing free in ivas_binRenderer_convModuleClose_fx() */
#define FIX_1942_ASSERTION_LOWSHELF             /* FhG: Modified the target_gains_db_fx calculation in compute_t60_coeffs_fx() */
#define FIX_1944_CRASH_FOR_STEREO                      /* FhG: improve TonalMDCTConceal_InsertNoise calculation precision */
#define FIX_1970_SBA_CRASH                                   /* Dlb: Fix for issue 1970, SBA crash */

/* #################### Start BASOP porting switches ############################ */
+5 −1
Original line number Diff line number Diff line
@@ -751,9 +751,13 @@ ivas_error ivas_core_dec_fx(
                move16();
                sts[1]->hHQ_core->Q_old_wtda = sub( 15, sts[1]->hHQ_core->exp_old_out );
                move16();

#ifdef FIX_1944_CRASH_FOR_STEREO
                shift1 = getScaleFactor16( sts[0]->hHQ_core->old_out_fx, L_FRAME48k );
                shift2 = getScaleFactor16( sts[1]->hHQ_core->old_out_fx, L_FRAME48k );
#else
                shift1 = norm_arr( sts[0]->hHQ_core->old_out_fx, L_FRAME48k );
                shift2 = norm_arr( sts[1]->hHQ_core->old_out_fx, L_FRAME48k );
#endif
                scale_sig( sts[0]->hHQ_core->old_out_fx, L_FRAME48k, shift1 );
                scale_sig( sts[1]->hHQ_core->old_out_fx, L_FRAME48k, shift2 );
                sts[0]->hHQ_core->Q_old_wtda = add( sts[0]->hHQ_core->Q_old_wtda, shift1 );
+53 −5
Original line number Diff line number Diff line
@@ -1326,8 +1326,11 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
{
    Word16 i, l, ld, fac;
    Word16 rnd;

#ifdef FIX_1944_CRASH_FOR_STEREO
    Word16 tmp, g, tilt, exp_last, exp_noise, tiltFactor, crossfadeGain, e_crossfadeGain, scaleFactor;
#else
    Word16 tmp, g, tilt, exp_last, exp_noise, tiltFactor, crossfadeGain, e_crossfadeGain;
#endif
    Word32 L_tmp, L_tmp1, L_tmp2, nrgNoiseInLastFrame, nrgWhiteNoise;
    Word16 inv_exp, inv_samples, exp;
    Word32 last_block_nrg_correct;
@@ -1505,9 +1508,10 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
                    }
                    mdctSpectrum[i] = L_shl( L_tmp2, exp ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + exp
                    move32();

#ifndef FIX_1944_CRASH_FOR_STEREO
                    hTonalMDCTConc->faded_signal_nrg = L_add( hTonalMDCTConc->faded_signal_nrg, Mpy_32_32( mdctSpectrum[i], mdctSpectrum[i] ) ); // Q31- faded_signal_nrg_exp
                    move32();
#endif
                }
                FOR( i = crossOverFreq; i < hTonalMDCTConc->lastBlockData.nSamples; i++ )
                {
@@ -1516,7 +1520,28 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
                }
                *mdctSpectrum_exp = sub( add( e_crossfadeGain, hTonalMDCTConc->lastBlockData.spectralData_exp ), exp );
                move16();
#ifdef FIX_1944_CRASH_FOR_STEREO
                scaleFactor = getScaleFactor32( mdctSpectrum, crossOverFreq );
                IF( scaleFactor > 8 )
                {
                    scaleFactor = sub( scaleFactor, 8 ); // add headroom
                }
                ELSE
                {
                    scaleFactor = 0;
                    move16();
                }

                FOR( i = 0; i < crossOverFreq; i++ )
                {
                    Word32 mdctSpectrumScaled = L_shl( mdctSpectrum[i], scaleFactor );
                    hTonalMDCTConc->faded_signal_nrg = L_add( hTonalMDCTConc->faded_signal_nrg, Mpy_32_32( mdctSpectrumScaled, mdctSpectrumScaled ) );
                }
                move32();
                hTonalMDCTConc->faded_signal_nrg_exp = shl( sub( *mdctSpectrum_exp, scaleFactor ), 1 );
#else
                hTonalMDCTConc->faded_signal_nrg_exp = shl( *mdctSpectrum_exp, 1 );
#endif
                move16();
            }
        }
@@ -1680,9 +1705,10 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
                    }
                    mdctSpectrum[l] = L_shl( L_tmp2, exp ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + exp
                    move32();

#ifndef FIX_1944_CRASH_FOR_STEREO
                    hTonalMDCTConc->faded_signal_nrg = L_add( hTonalMDCTConc->faded_signal_nrg, Mpy_32_32( mdctSpectrum[l], mdctSpectrum[l] ) ); // Q31 - 2*mdctSpectrum_exp
                    move32();
#endif
                }

                FOR( i = 1; i < hTonalMDCTConc->pTCI->numIndexes; i++ )
@@ -1702,8 +1728,9 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
                        }
                        mdctSpectrum[l] = L_shl( L_tmp2, exp ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + exp
                        move32();

#ifndef FIX_1944_CRASH_FOR_STEREO
                        hTonalMDCTConc->faded_signal_nrg = L_add( hTonalMDCTConc->faded_signal_nrg, Mpy_32_32( mdctSpectrum[l], mdctSpectrum[l] ) ); // Q31- 2*mdctSpectrum_exp
#endif
                    }
                }

@@ -1722,9 +1749,10 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
                    }
                    mdctSpectrum[l] = L_shl( L_tmp2, exp ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + exp
                    move32();

#ifndef FIX_1944_CRASH_FOR_STEREO
                    hTonalMDCTConc->faded_signal_nrg = L_add( hTonalMDCTConc->faded_signal_nrg, Mpy_32_32( mdctSpectrum[l], mdctSpectrum[l] ) ); // Q31- 2*mdctSpectrum_exp
                    move32();
#endif
                }

                FOR( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ )
@@ -1732,8 +1760,28 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
                    mdctSpectrum[l] = L_deposit_h( 0 );
                    move32();
                }
#ifdef FIX_1944_CRASH_FOR_STEREO
                scaleFactor = getScaleFactor32( mdctSpectrum, crossOverFreq );
                IF( scaleFactor > 8 )
                {
                    scaleFactor = sub( scaleFactor, 8 ); // add headroom
                }
                ELSE
                {
                    scaleFactor = 0;
                    move16();
                }

                FOR( i = 0; i < crossOverFreq; i++ )
                {
                    Word32 mdctSpectrumScaled = L_shl( mdctSpectrum[i], scaleFactor );
                    hTonalMDCTConc->faded_signal_nrg = L_add( hTonalMDCTConc->faded_signal_nrg, Mpy_32_32( mdctSpectrumScaled, mdctSpectrumScaled ) );
                }
                move32();
                hTonalMDCTConc->faded_signal_nrg_exp = shl( sub( *mdctSpectrum_exp, scaleFactor ), 1 );
#else
                hTonalMDCTConc->faded_signal_nrg_exp = shl( *mdctSpectrum_exp, 1 );
#endif
                move16();
            }
        }
+60 −7
Original line number Diff line number Diff line
@@ -106,6 +106,11 @@ static Word16 wrap_rad_fixed(

#define MAX_NR_OUTPUTS ( 2 )

#ifdef FIX_1942_ASSERTION_LOWSHELF
#define M60Q9  ( -30720 ) //-60 in Q9
#define M120Q8 ( -30720 ) //-120 in Q8
#endif

const Word16 init_loop_delay[IVAS_REV_MAX_NR_BRANCHES] = { 37, 31, 29, 23, 19, 17, 13, 11 };
const Word16 default_loop_delay_48k[IVAS_REV_MAX_NR_BRANCHES] = { 2309, 1861, 1523, 1259, 1069, 919, 809, 719 };
const Word16 default_loop_delay_32k[IVAS_REV_MAX_NR_BRANCHES] = { 1531, 1237, 1013, 839, 709, 613, 541, 479 };
@@ -658,15 +663,19 @@ static ivas_error compute_t60_coeffs_fx(
{
    Word16 bin_idx, loop_idx, tf_T60_len, len;
    ivas_error error;

#ifdef FIX_1942_ASSERTION_LOWSHELF
    Word16 loop_delay_sec_fx, tmp, tmp_e;
#else
    Word16 loop_delay_sec_fx, tmp;
#endif
    Word32 freq_Nyquist_fx = L_shr( output_Fs, 1 );
    Word16 target_gains_db_fx[RV_LENGTH_NR_FC]; // Q8
    Word16 norm_f_fx[RV_LENGTH_NR_FC];
    Word16 *pCoeffs_a_fx, *pCoeffs_b_fx;
    Word16 e;
#ifndef FIX_1942_ASSERTION_LOWSHELF
    const Word16 min120q8 = -30720; // -120 in Q8

#endif
    error = IVAS_ERR_OK;
    move32();
    tf_T60_len = nr_fc_fft_filter;
@@ -692,11 +701,47 @@ static ivas_error compute_t60_coeffs_fx(
            IF( EQ_32( pParams->pRt60_fx[bin_idx], 0 ) )
            {
                // If RT60 is 0, target gain is -120dB
#ifdef FIX_1942_ASSERTION_LOWSHELF
                target_gains_db_fx[bin_idx] = M120Q8;
                move16();
#else
                target_gains_db_fx[bin_idx] = min120q8;
#endif
            }
            ELSE
            {
                tmp = BASOP_Util_Divide3232_Scale( L_deposit_h( loop_delay_sec_fx ), pParams->pRt60_fx[bin_idx], &e );
#ifdef FIX_1942_ASSERTION_LOWSHELF
                tmp_e = add( e, sub( 0, 5 ) ); // L_deposit_h( loop_delay_sec_fx ):Q0.31, pParams->pRt60_fx[bin_idx]:Q5.26

                tmp_e = add( tmp_e, 6 ); // + Q6.9(M60Q9)
                target_gains_db_fx[bin_idx] = mult( M60Q9, tmp );

                // gain < - 120 ? -120: gain
                tmp_e = sub( tmp_e, 7 ); // - Q7.8(M120Q8)
                IF( GT_16( tmp_e, 0 ) )
                {
                    IF( LT_16( target_gains_db_fx[bin_idx], shr( M120Q8, tmp_e ) ) )
                    {
                        target_gains_db_fx[bin_idx] = M120Q8; // Q8
                        move16();
                    }
                    ELSE
                    {
                        target_gains_db_fx[bin_idx] = shl_r( target_gains_db_fx[bin_idx], tmp_e ); // Q8, gain must be less than 128
                    }
                }
                ELSE
                {
                    target_gains_db_fx[bin_idx] = shl_r( target_gains_db_fx[bin_idx], tmp_e ); // Q8, gain must be less than 128
                    IF( LT_16( target_gains_db_fx[bin_idx], M120Q8 ) )
                    {
                        target_gains_db_fx[bin_idx] = M120Q8; // Q8
                        move16();
                    }
                }
            }
#else
                IF( LT_16( e, -1 ) )
                {
                    target_gains_db_fx[bin_idx] = min120q8;
@@ -713,6 +758,7 @@ static ivas_error compute_t60_coeffs_fx(
                target_gains_db_fx[bin_idx] = -30720;
                move16();
            }
#endif
        }

        pCoeffs_a_fx = &pParams->pT60_filter_coeff_fx[add( shl( i_mult( len, loop_idx ), 1 ), len )]; // Q14
@@ -996,6 +1042,13 @@ static ivas_error calc_jot_t60_coeffs_fx(
    L_tmp = BASOP_util_Pow2( L_deposit_h( tmp_fx ), exph, &e );
    lin_gain_hf_fx = extract_l( L_shr( L_tmp, sub( 16, e ) ) );

#ifdef FIX_1942_ASSERTION_LOWSHELF
    IF( EQ_16( lin_gain_hf_fx, 0 ) )
    {
        lin_gain_hf_fx = 1;
        move16();
    }
#endif
    /* call low-pass iir shelf */
    calc_low_shelf_first_order_filter_fx( pCoeffB_fx, pCoeffA_fx, f0_fx, lin_gain_lf_fx, lin_gain_hf_fx );
    return IVAS_ERR_OK;