Commit 0cf79f8c authored by vaclav's avatar vaclav
Browse files

Merge remote-tracking branch 'remotes/origin/main' into...

Merge remote-tracking branch 'remotes/origin/main' into 1914-remove-divisions-with-constant-denominator
parents bb5eabca 5d9d739f
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -2374,6 +2374,37 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
            }
            ELSE IF( EQ_16( num_dmx, 3 ) )
            {
#ifdef FIX_1970_SBA_CRASH
                Word64 re64[2];
                Word32 re32[2], re32_2;
                Word16 qtmp2;
                set64_fx( re64, 0, 2 );
                q_tmp = 63;
                FOR( j = 0; j < 2; j++ )
                {
                    FOR( k = 0; k < 2; k++ )
                    {
                        W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][k], cov_dd_re[k][j] ); // q_C_re+q_cov_dd_re
                        re64[j] = W_add( re64[j], W_tmp );
                        move64();
                    }
                    q_tmp = s_min( q_tmp, sub( W_norm( re64[j] ), 33 ) );
                }
                FOR( j = 0; j < 2; j++ )
                {
                    re32[j] = W_shl_sat_l( re64[j], q_tmp ); // q_C_re+q_cov_dd_re+q_tmp
                    move32();
                }
                qtmp2 = add( add( q_C_re, q_tmp ), q_cov_dd_re );
                W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], re32[0] );                 // q_C_re+qtmp2
                W_tmp = W_add( W_tmp, W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][1], re32[1] ) ); // q_C_re+qtmp2
                q_tmp = sub( W_norm( W_tmp ), 33 );
                re32_2 = W_shl_sat_l( W_tmp, q_tmp ); // q_C_re+qtmp2+q_tmp
                qtmp2 = add( add( q_C_re, q_tmp ), qtmp2 );
                q_tmp = s_min( 63, qtmp2 );
                recon_uu_re[0][0] = L_max( 0, re32_2 );
                move32();
#else
                Word32 re1[2], re2;
                Word16 q_re1[2];
                set32_fx( re1, 0, 2 );
@@ -2446,6 +2477,7 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(

                recon_uu_re[0][0] = L_add( recon_uu_re[0][0], re2 ); // q_tmp
                move32();
#endif

                IF( LT_16( q_cov_uu_re, q_tmp ) )
                {
+10 −2
Original line number Diff line number Diff line
@@ -105,8 +105,12 @@
#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 ############################ */

@@ -146,6 +150,8 @@
#define FIX_587_DEFAULT_REVERB                          /* Philips: issue 587: inconsistent default reverb parameters across renderers */
#define NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC      /* FhG: fix out-of-bound errors when switching from SID frame to active frame*/
#define NONBE_FIX_1052_SBA_EXT_FIX                      /* VA: SBA external output support fix - do not overwrite "output_config" parameter */

#define FIX_1129_EXT_REND_OUTPUT_HIGH                   /* Philips: issue 1129: External renderer BINAURAL_ROOM_REVERB format output level too high compared to internal rendering output */
#define NONBE_1289_STEREO_SW_TO_MONO                    /* VA: issue 1289: Fix glitch when stereo signal is decoded to mono n TD->DFT switching */
#define NONBE_FIX_1196_TD_HEADTRACKING_INTERPOLATION    /* Ericsson: Issue 1196, Always apply filter interpolation for each subframe */
#define NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING       /* VA: issue 1110: fix encoder crash in the stereo DTX bitrate switching condition */
@@ -173,6 +179,8 @@
#define FIX_1139_REV_COLORATION_SHORT_T60               /* Nokia,FhG: Fix issue 1139, prevent sound coloration artefacts at very low reverberation times */

#define FIX_1959_assert_in_gain_enc_mless_fx            /* VA: Fix saturation introduced by the usage of the non-EVS basop operators =, the saturation was expected */
#define NONBE_1328_FIX_NON_LINEARITY                    /* VA: Fix possible issue when computing bwe_exc_extended and previous frame were almost 0, float issue 1328  */

/* #################### End BASOP porting switches ############################ */

#endif
+25 −6
Original line number Diff line number Diff line
@@ -6061,7 +6061,9 @@ void non_linearity_ivas_fx(
    move32();
#endif
#endif

#ifdef NONBE_1328_FIX_NON_LINEARITY
    Word16 sc_factor;
#endif

    IF( EQ_16( L_frame, L_FRAME16k ) )
    {
@@ -6121,9 +6123,17 @@ void non_linearity_ivas_fx(
        scale = 1438814044;
        move32(); /* Q31; 0.67 in Q31 */
    }
#ifdef NONBE_1328_FIX_NON_LINEARITY
    /* sc_factor = 32; */                                                      /* Here we divise prev_scale, so 32 == 2 << (15-10)  1024.0 corresponds to 10 bits and 32 to 5 bits  */
    /* if ( element_mode > EVS_MONO ) */                                       /* element mode is not needed because the function is duplicated for IVAS */
    sc_factor = shl_sat( 1, sub( 15, max( 13 - norm_s( add( j, 1 ) ), 0 ) ) ); /* Adapt the scaling factor allowed depending of max position  */
    sc_factor = s_min( sc_factor, 16384 );

    IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, sc_factor ) /*Q30 -> Q31*/, scale /*Q31*/ ) )
#else
    test();
    IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, 64 ) /*Q30 -> Q31*/, scale /*Q31*/ ) )
#endif
    {
        scale_step = 16384;
        move16();                       /* Q14 */
@@ -6209,7 +6219,16 @@ void non_linearity_ivas_fx(
    }

    test();
#ifdef NONBE_1328_FIX_NON_LINEARITY
    /* sc_factor = 32; */                                                      /* Here we divise prev_scale, so 32 == 2 << (15-10)  1024.0 corresponds to 10 bits and 32 to 5 bits  */
    /* if ( element_mode > EVS_MONO ) */                                       /* element mode is not needed because the function is duplicated for IVAS */
    sc_factor = shl_sat( 1, sub( 15, max( 12 - norm_s( add( j, 1 ) ), 0 ) ) ); /* Adapt the scaling factor allowed depending of max position  */
    sc_factor = s_min( sc_factor, 16384 );

    IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, sc_factor ) /*Q30 -> Q31*/, scale /*Q31*/ ) )
#else
    IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, 64 ), scale ) )
#endif
    {
        scale_step = 16384;
        move16();                       /*Q14 */
+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();
            }
        }
Loading