Commit 0dd9ce61 authored by emerit's avatar emerit
Browse files

Merge branch 'main' into update_crend_v2

parents aea82666 20cb1008
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -145,6 +145,7 @@
#define FIX_ISSUE_1185                          /* Ittiam: Fix for issue 1185: Assertion in ivas_dirac_dec_binaural_internal_fx() for crash in decoder in fft30_with_cmplx_data()*/
#define FIX_ISSUE_1209                          /* Ittiam: Fix for issue 1209: Assertion exit in BASOP encoder (stereo_dmx_evs)*/
#define FIX_ISSUE_1218                          /* Ittiam: Fix for issue 1218: Assert in stereo_dft_generate_comfort_noise_fx of BASOP decoder with BASOP MASA DTX bitstream at 32 kbps*/
#define FIX_ISSUE_1290                          /* Ittiam: Fix for issue 1218: Assert in stereo_dft_generate_comfort_noise_fx of BASOP decoder with BASOP MASA DTX bitstream at 32 kbps*/
#define IVAS_ISSUE_1188_EVS_CRASH               /* Ittiam: Fix for issue 1188: Issue due to ASAN */
#define FIX_ISSUE_1155                          /* Ittiam: Fix for issue 1155: Encoder crash for Stereo at 32kbps in PostShortTerm_ivas_enc_fx()*/
#define FIX_1010_OPT_DIV                        /* FhG: SVD complexity optimizations (non-be) */
@@ -177,4 +178,5 @@
#define SVD_WMOPS_OPT                           /* Ittiam : SVD related optimizations */
#define NONBE_FIX_1087_OOB_SBA_DTX_RS           /* VA: issue 1087: Extend the length of the buffer for MCT decoding to avoid out-of-bound writing in SBA SID bitrate switching decoding */
#define FIX_ISSUE_1279                          /* VA: correction of wrong scaling update */
#define FIX_ISSUE_1247
#endif
+4 −0
Original line number Diff line number Diff line
@@ -802,7 +802,11 @@ ivas_error acelp_core_dec_ivas_fx(
            Copy_Scale_sig( syn1_fx, temp_buf_fx, st->L_frame, sub( -1, st->Q_syn ) ); // Q_syn
            IF( st->hBWE_FD != NULL )
            {
#ifdef FIX_ISSUE_1290
                save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
#else
                save_old_syn_fx( st->L_frame, syn1_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
#endif
            }
        }

+22 −2
Original line number Diff line number Diff line
@@ -394,6 +394,25 @@ ivas_error ivas_cpe_enc_fx(
    /*----------------------------------------------------------------*
     * Resets/updates in case of stereo switching
     *----------------------------------------------------------------*/
#ifdef FIX_ISSUE_1247
    shift = norm_arr( sts[1]->old_input_signal_fx, input_frame );
    Scale_sig( sts[1]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift  */
    sts[1]->q_old_inp = add( sts[1]->q_old_inp, shift );
    move16();
    shift = norm_arr( sts[1]->input_fx, input_frame );
    Scale_sig( sts[1]->input_fx, input_frame, shift ); /* sts[1]->q_inp + shift  */
    sts[1]->q_inp = add( sts[1]->q_inp, shift );
    move16();

    shift = norm_arr( sts[0]->old_input_signal_fx, input_frame );
    Scale_sig( sts[0]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift  */
    sts[0]->q_old_inp = add( sts[0]->q_old_inp, shift );
    move16();
    shift = norm_arr( sts[0]->input_fx, input_frame );
    Scale_sig( sts[0]->input_fx, input_frame, shift ); /* sts[1]->q_inp, shift  */
    sts[0]->q_inp = add( sts[0]->q_inp, shift );
    move16();
#else
    shift = getScaleFactor16( sts[1]->old_input_signal_fx, input_frame );
    Scale_sig( sts[1]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift  */
    sts[1]->q_old_inp = add( sts[1]->q_old_inp, shift );
@@ -411,6 +430,7 @@ ivas_error ivas_cpe_enc_fx(
    Scale_sig( sts[0]->input_fx, input_frame, shift ); /* sts[1]->q_inp, shift  */
    sts[0]->q_inp = add( sts[0]->q_inp, shift );
    move16();
#endif

    Word16 q_inp = s_min( s_min( sts[0]->q_inp, sts[0]->q_old_inp ), s_min( sts[1]->q_inp, sts[1]->q_old_inp ) );

+4 −4
Original line number Diff line number Diff line
@@ -2804,7 +2804,7 @@ void noise_est_ivas_fx(
    lim_Etot_fx = s_max( 5120, Etot );                                              /* 20.0f Q8 */
    lim_Etot_sq_fx = extract_h( L_shl_r( L_mult( lim_Etot_fx, lim_Etot_fx ), 1 ) ); /* Q2 */

    IF( LT_16( st_fx->ini_frame, 150 ) )
    IF( LT_16( ini_frame, 150 ) )
    {
        /* Allow use of quicker filter during init - if needed */
        /* st->Etot_st_est = 0.25f * lim_Etot + (1.0f-0.25F) * st->Etot_st_est; */
@@ -2848,7 +2848,7 @@ void noise_est_ivas_fx(
    test();
    test();
    if ( ( GT_16( *st_harm_cor_cnt, 1 ) ) && ( ( LT_16( Etot, 3840 /* 15 in Q8 */ ) ) ||
                                               ( GT_16( st_fx->ini_frame, 10 ) &&
                                               ( GT_16( ini_frame, 10 ) &&
                                                 GT_16( sub( Etot, hNoiseEst->Etot_lp_fx ), 1792 /* 7 in Q8 */ ) ) ) )
    {
        *st_harm_cor_cnt = 1;
@@ -3113,7 +3113,7 @@ void noise_est_ivas_fx(
    test();
    test();
    IF( ( ( LT_16( *st_harm_cor_cnt, ( 3 * HC_CNT_SLOW_FX ) ) ) && ( ( GT_32( non_sta, th_sta ) ) || ( LT_16( tmp_pc, TH_PC_FX ) ) || ( noise_char > 0 ) ) ) ||
        ( ( GT_16( st_fx->ini_frame, HE_LT_CNT_INIT_FX ) ) && ( GT_16( sub( Etot, Etot_l_lp ), 2560 ) ) ) ||
        ( ( GT_16( ini_frame, HE_LT_CNT_INIT_FX ) ) && ( GT_16( sub( Etot, Etot_l_lp ), 2560 ) ) ) ||
        ( GT_16( cor_tmp, cor_max ) ) || /* Q15 */
        ( GT_32( LepsP, th_eps ) ) ||    /* Q11 */
        ( GT_16( *loc_harm, 0 ) ) ||
@@ -3419,7 +3419,7 @@ void noise_est_ivas_fx(
    test();
    test();
    test();
    if ( LT_16( st_fx->ini_frame, HE_LT_CNT_INIT_FX ) && GT_16( hNoiseEst->harm_cor_cnt, 5 ) && LT_16( sub( Etot, hNoiseEst->Etot_lp_fx ), 1792 /* 7 in Q8 */ ) &&
    if ( LT_16( ini_frame, HE_LT_CNT_INIT_FX ) && GT_16( hNoiseEst->harm_cor_cnt, 5 ) && LT_16( sub( Etot, hNoiseEst->Etot_lp_fx ), 1792 /* 7 in Q8 */ ) &&
         ( ( LT_16( hNoiseEst->act_pred_fx, 19333 /* 0.59 in Q15 */ ) && LT_16( hNoiseEst->lt_haco_ev_fx, 7537 /* 0.23 in Q15 */ ) ) || LT_16( hNoiseEst->act_pred_fx, 12452 /* 0.38 in Q15 */ ) ||
           ( ( ( st_fx->element_mode == EVS_MONO ) && LT_16( hNoiseEst->lt_haco_ev_fx, 4915 /* 0.15 in Q15 */ ) ) || ( ( st_fx->element_mode > EVS_MONO ) && LT_16( hNoiseEst->lt_haco_ev_fx, 2621 /* 0.08 in Q15 */ ) ) ) ||
           LT_16( non_staB, 50 * 256 /* 50 in Q8 */ ) || ( aE_bgd != 0 ) || ( LT_16( Etot, 10752 /* 42.0 in Q8 */ ) && GT_16( hNoiseEst->harm_cor_cnt, 10 ) && LT_16( hNoiseEst->lt_haco_ev_fx, 11469 /* 0.35 in Q8 */ ) && LT_16( hNoiseEst->act_pred_fx, 26214 /* 0.8 in Q8 */ ) ) ) )
+39 −25
Original line number Diff line number Diff line
@@ -2416,15 +2416,17 @@ void tcx_noise_factor_ivas_fx(
    Word16 element_mode       /* i: element mode                                     */
)
{
    Word16 i, k, win, segmentOffset;
    Word32 sqErrorNrg, n;
    Word64 sqErrorNrg64;
    Word16 inv_gain2, inv_gain2_e, tilt_factor, nTransWidth_1;
    Word16 i, k, win, segmentOffset, j;
    Word32 sqErrorNrg = 0, n;
    move32();
    Word16 inv_gain2, inv_gain2_e, tilt_factor, nTransWidth_1, exp_sqErrorNrg = 0;
    move16();
    Word32 accu1, accu2, tmp32;
    Word16 tmp1, tmp2, s;
    Word16 c1, c2;
    Word16 att; /* noise level attenuation factor for transient windows */
    Word32 xMax;
    Word16 exp_spQ[N_MAX];
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
@@ -2432,13 +2434,12 @@ void tcx_noise_factor_ivas_fx(

    assert( nTransWidth <= 16 );

    set16_fx( exp_spQ, x_orig_e, N_MAX );
    c1 = sub( shl( nTransWidth, 1 ), 4 );
    c2 = mult( 9216 /*0.28125f Q15*/, inv_int[nTransWidth] );
    nTransWidth_1 = sub( nTransWidth, 1 );

    /*Adjust noise filling level*/
    sqErrorNrg64 = 0;
    move64();
    n = 0;
    move32();

@@ -2452,10 +2453,8 @@ void tcx_noise_factor_ivas_fx(

    /* inv_gain2 = 1.0f / ((float)(nTransWidth * nTransWidth) * gain_tcx); */
    tmp32 = L_mult( imult1616( nTransWidth, nTransWidth ), gain_tcx ); /* 15Q16 */
    tmp1 = norm_l( tmp32 );
    inv_gain2 = round_fx( L_shl( tmp32, tmp1 ) );
    inv_gain2_e = add( sub( 15, tmp1 ), gain_tcx_e );
    inv_gain2 = Inv16( inv_gain2, &inv_gain2_e );
    inv_gain2 = BASOP_Util_Divide3232_Scale( MAX_32, tmp32, &inv_gain2_e );
    inv_gain2_e = add( inv_gain2_e, sub( 0, add( 15, gain_tcx_e ) ) );
    inv_gain2 = shr( inv_gain2, 2 ); /* 2 bits headroom */
    inv_gain2_e = add( inv_gain2_e, 2 );

@@ -2588,13 +2587,19 @@ void tcx_noise_factor_ivas_fx(
                }
                FOR( k = segmentOffset; k < i - win; k++ )
                {
                    sqErrorNrg64 = W_add( sqErrorNrg64, W_mult_32_16( sqQ[k], nTransWidth ) );
                    tmp1 = norm_l( sqQ[k] );
                    sqErrorNrg = BASOP_Util_Add_Mant32Exp( sqErrorNrg, exp_sqErrorNrg, Mpy_32_16_1( L_shl( sqQ[k], tmp1 ), nTransWidth ), add( 15, sub( exp_spQ[k], tmp1 ) ), &exp_sqErrorNrg );
                    sqQ[k] = 0;
                    move32();
                    exp_spQ[k] = 0;
                    move16();
                }
                FOR( ; win > 0; win-- )
                {
                    sqErrorNrg64 = W_add( sqErrorNrg64, W_mult_32_16( sqQ[k], win ) );
                    tmp1 = norm_l( sqQ[k] );
                    sqErrorNrg = BASOP_Util_Add_Mant32Exp( sqErrorNrg, exp_sqErrorNrg, Mpy_32_16_1( L_shl( sqQ[k], tmp1 ), win ), add( 15, sub( exp_spQ[k], tmp1 ) ), &exp_sqErrorNrg );
                    exp_spQ[k] = 0;
                    move16();
                    sqQ[k++] = 0;
                    move32();
                }
@@ -2608,8 +2613,10 @@ void tcx_noise_factor_ivas_fx(
                win = add( win, 1 );
            }
            /* update segment sum: magnitudes scaled by smoothing function */
            sqQ[i] = L_shl( Mpy_32_16_1( imult3216( L_abs( x_orig[i] ), win ), inv_gain2 ), inv_gain2_e );
            sqQ[i] = Mpy_32_16_1( imult3216( L_abs( x_orig[i] ), win ), inv_gain2 );
            move32();
            exp_spQ[i] = add( x_orig_e, inv_gain2_e );
            move16();
        }
    }
    IF( win > 0 ) /* add last segment sum to sum of segment magnitudes */
@@ -2649,38 +2656,45 @@ void tcx_noise_factor_ivas_fx(
        }
        FOR( k = segmentOffset; k < i - win; k++ )
        {
            sqErrorNrg64 = W_add( sqErrorNrg64, W_mult_32_16( sqQ[k], nTransWidth ) );
            tmp1 = norm_l( sqQ[k] );
            sqErrorNrg = BASOP_Util_Add_Mant32Exp( sqErrorNrg, exp_sqErrorNrg, Mpy_32_16_1( L_shl( sqQ[k], tmp1 ), nTransWidth ), add( 15, sub( exp_spQ[k], tmp1 ) ), &exp_sqErrorNrg );
            exp_spQ[k] = 0;
            move16();
            sqQ[k] = 0;
            move32();
        }
        FOR( ; win > 0; win-- )
        {
            sqErrorNrg64 = W_add( sqErrorNrg64, W_mult_32_16( sqQ[k], win ) );
            tmp1 = norm_l( sqQ[k] );
            sqErrorNrg = BASOP_Util_Add_Mant32Exp( sqErrorNrg, exp_sqErrorNrg, Mpy_32_16_1( L_shl( sqQ[k], tmp1 ), win ), add( 15, sub( exp_spQ[k], tmp1 ) ), &exp_sqErrorNrg );
            exp_spQ[k] = 0;
            move16();
            sqQ[k++] = 0;
            move32();
        }
    }

    Word32 tmp4;
    /* noise level factor: average of segment magnitudes of noise bins */
    IF( n > 0 )
    {
        tmp2 = W_norm( sqErrorNrg64 );
        sqErrorNrg = W_extract_l( W_shr( sqErrorNrg64, sub( 32, tmp2 ) ) ); // 31 - (x_orig_e - 1) - 32 + tmp2
        tmp1 = BASOP_Util_Divide3232_Scale( Mpy_32_16_1( sqErrorNrg, att ), n, &s );
        s = add( add( add( x_orig_e, sub( 31, tmp2 ) ), -15 ), s );
        tmp4 = BASOP_Util_Divide3232_Scale_cadence( Mpy_32_16_1( sqErrorNrg, att ), n, &s );
        s = add( add( exp_sqErrorNrg, -15 ), s );
        BASOP_SATURATE_WARNING_OFF_EVS;
        tmp1 = shl_o( tmp1, s, &Overflow );
        tmp4 = L_shl_o( tmp4, s, &Overflow );
        BASOP_SATURATE_WARNING_ON_EVS;
    }
    ELSE
    {
        tmp1 = 0;
        tmp4 = 0;
        move16();
    }

    FOR( j = 0; j < N_MAX; j++ )
    {
        sqQ[j] = L_shl( sqQ[j], sub( x_orig_e, exp_spQ[j] ) );
        move32();
    }
    /* quantize, dequantize noise level factor (range 0.09375 - 0.65625) */
    tmp2 = round_fx( L_shr( L_mult( tmp1, 22016 /*1.34375f Q14*/ ), 14 - NBITS_NOISE_FILL_LEVEL ) );

    tmp2 = round_fx( L_shr( Mpy_32_16_1( tmp4, 22016 /*1.34375f Q14*/ ), 14 - NBITS_NOISE_FILL_LEVEL ) );
    if ( GT_16( tmp2, ( 1 << NBITS_NOISE_FILL_LEVEL ) - 1 ) )
    {
        tmp2 = ( 1 << NBITS_NOISE_FILL_LEVEL ) - 1;