Commit 1cc3e2cb authored by multrus's avatar multrus
Browse files

[cleanup] accept ENV_STAB_FIX

parent cea17ad5
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -1682,14 +1682,12 @@ enum
#define HALF_D_STAB_TBL_FX                  ( (Word16) 422 )        /* Q13 0.1013138/2.0 */
#define NUM_ENV_STAB_PLC_STATES             2                       /* Number of states of markov model */

#ifdef ENV_STAB_FIX
#define ENV_STAB_EST1                       2.93f                   /* env_stab estimation coefficient 1 */
#define ENV_STAB_EST2                       (-2.20f)                /* env_stab estimation coefficient 2 */
#define ENV_STAB_EST3                       0.741f                  /* env_stab estimation coefficient 3 */
#define STAB_FAC_EST1                       1.093f                  /* stab_fac HQ estimation coefficient 1 */
#define STAB_FAC_EST2                       (-5.84e-05f)            /* stab_fac HQ estimation coefficient 2, including Q12 scaling */
#define STAB_FAC_EST3                       0.125f                  /* stab_fac HQ estimation coefficient 3 */
#endif

#define ATT_LIM_HANGOVER                    150                     /* Number of hangover frames for disabling stability dependent attenuation */
#define DELTA_TH                            5.0f                    /* Delta energy threshold for transient detection for envelope stability */
+0 −55
Original line number Diff line number Diff line
@@ -66,12 +66,8 @@ float env_stability(
    const int16_t *ynrm,  /* i  : Norm vector for current frame          */
    const int16_t nb_sfm, /* i  : Number of sub-bands                    */
    int16_t *mem_norm,    /* i/o: Norm vector memory from past frame     */
#ifdef ENV_STAB_FIX
    int16_t *mem_env_delta,           /* i/o: Envelope stability memory for smoothing*/
    const int16_t core_switching_flag /* i  : Core switching flag        */
#else
    int16_t *mem_env_delta /* i/o: Envelope stability memory for smoothing*/
#endif
)
{
    Word16 env_delta;
@@ -87,7 +83,6 @@ float env_stability(
    Flag Overflow;
#endif /* BASOP_NOGLOB */

#ifdef ENV_STAB_FIX
    if ( core_switching_flag )
    {
        for ( i = 0; i < nb_sfm; i++ )
@@ -150,56 +145,6 @@ float env_stability(
        env_delta = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow );              /* Q13 */
#endif                                             /* BASOP_NOGLOB */
    }
#else

    /* Calculate envelope stability parameter */
    L_env_delta = L_deposit_l( 0 );
    for ( i = 0; i < nb_sfm; i++ )
    {
        tmp = sub( mem_norm[i], ynrm[i] );
        L_env_delta = L_mac0( L_env_delta, tmp, tmp );
        mem_norm[i] = ynrm[i];
    }

#ifdef DEBUGGING
    assert( nb_sfm == 27 || nb_sfm == 26 );
#endif
    inv_nb_sfm = 19418; /* Q19 */
    if ( nb_sfm == 26 )
    {
        inv_nb_sfm = 20165; /* Q19 */
    }
    exp = norm_l( L_env_delta );
    L_env_delta = Mult_32_16( L_shl( L_env_delta, exp ), inv_nb_sfm ); /* 0+exp+19-15 */

    L_tmp = Sqrt_l( L_env_delta, &exp2 ); /* exp+4+31+exp2 */

    exp = add( 35, add( exp, exp2 ) );
    if ( sub( s_and( exp, 1 ), 1 ) == 0 )
    {
        L_tmp = Mult_32_16( L_tmp, 23170 ); /* 1/sqrt(2) in Q15 */
    }
    exp = shr( exp, 1 );

#ifndef BASOP_NOGLOB
    env_delta = round_fx( L_shl( L_tmp, sub( 26, exp ) ) ); /* Q10 */
    L_tmp = L_mult0( 26214, env_delta );                    /* 26214 is 0.1 in Q18. Q28 */
    L_tmp = L_mac( L_tmp, 29491, *mem_env_delta );          /* 29491 is 0.9 in Q15. Q28 */
    *mem_env_delta = round_fx( L_tmp );                     /* Q12 */
#else  /* BASOP_NOGLOB */
    env_delta = round_fx_o( L_shl_o( L_tmp, sub( 26, exp ), &Overflow ), &Overflow ); /* Q10 */
    L_tmp = L_mult0( 26214, env_delta );                                              /* 26214 is 0.1 in Q18. Q28 */
    L_tmp = L_mac_o( L_tmp, 29491, *mem_env_delta, &Overflow );                       /* 29491 is 0.9 in Q15. Q28 */
    *mem_env_delta = round_fx_o( L_tmp, &Overflow );                                  /* Q12 */
#endif /* BASOP_NOGLOB */
    Overflow = 0;
#ifndef BASOP_NOGLOB
    env_delta = round_fx( L_shl( L_tmp, 1 ) ); /* Q13 */
#else /* BASOP_NOGLOB */
    env_delta = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow );              /* Q13 */
#endif
                                               /* BASOP_NOGLOB */
#endif
    if ( Overflow != 0 ) /* Saturated due to the above up-shifting operation. */
    {
        env_stab = stab_trans_fx[L_STAB_TBL - 1];             /* The highest quantized index. */
+0 −1
Original line number Diff line number Diff line
@@ -147,7 +147,6 @@
#endif
#define FIX_I59_DELAY_ROUNDING                          /* Issue 59: rounding in sample domain instead of nanosec for IVAS_ENC_GetDelay() and IVAS_DEC_GetDelay() */
#define FIX_FIX_I59                                     /* Issue 59:  small fix concerning LFE delay rounding */
#define ENV_STAB_FIX                                    /* Contribution 23: HQ envelope stability memory fix */
#define STABILIZE_GIPD                                  /* FhG: Contribution 22: gIPD stabilization */
#define FIX_292_VBAP_CALLOC_REMOVAL                     /* Nokia: Fixes issue 292 by removing the remnant callocs */
#define FIX_293_EXT_RENDERER_CLI                        /* FhG: Fix bugs in external renderer CLI */
+0 −8
Original line number Diff line number Diff line
@@ -5395,12 +5395,8 @@ void hq_hr_dec(
    int16_t *ynrm,          /* o  : norm quantization index vector  */
    int16_t *is_transient,  /* o  : transient flag                  */
    int16_t *hqswb_clas,    /* o  : HQ SWB class                    */
#ifdef ENV_STAB_FIX
    float *SWB_fenv,                  /* o  : SWB frequency envelopes         */
    const int16_t core_switching_flag /* i  : Core switching flag             */
#else
    float *SWB_fenv        /* o  : SWB frequency envelopes              */
#endif

);

@@ -5828,12 +5824,8 @@ float env_stability(
    const int16_t *ynrm,  /* i  : Norm vector for current frame          */
    const int16_t nb_sfm, /* i  : Number of sub-bands                    */
    int16_t *mem_norm,    /* i/o: Norm vector memory from past frame     */
#ifdef ENV_STAB_FIX
    int16_t *mem_env_delta,           /* i/o: Envelope stability memory for smoothing*/
    const int16_t core_switching_flag /* i  : Core switching flag             */
#else
    int16_t *mem_env_delta /* i/o: Envelope stability memory for smoothing*/
#endif
);

/*! r: New speech/music state */
+0 −11
Original line number Diff line number Diff line
@@ -70,9 +70,7 @@ ivas_error core_switching_pre_dec(
{
    int16_t i, oldLenClasBuff, newLenClasBuff;
    ivas_error error;
#ifdef ENV_STAB_FIX
    float tmp;
#endif

    error = IVAS_ERR_OK;

@@ -404,11 +402,7 @@ ivas_error core_switching_pre_dec(
        }
    }

#ifdef ENV_STAB_FIX
    if ( st->core == HQ_CORE && ( st->last_core == ACELP_CORE || st->last_core == AMR_WB_CORE || ( ( st->element_mode != EVS_MONO ) && ( st->last_core != HQ_CORE ) ) ) )
#else
    if ( st->core == HQ_CORE && ( st->last_core == ACELP_CORE || st->last_core == AMR_WB_CORE ) )
#endif
    {
        set_f( st->hHQ_core->prev_env, 0, SFM_N_WB );
        set_f( st->hHQ_core->prev_normq, 0, SFM_N_WB );
@@ -425,7 +419,6 @@ ivas_error core_switching_pre_dec(
            set_f( st->hHQ_core->prev_coeff_out, 0, L_HQ_WB_BWE );
        }

#ifdef ENV_STAB_FIX
        if ( st->element_mode != EVS_MONO )
        {
            /* Estimate mem_env_delta to reinit env_stab */
@@ -454,10 +447,6 @@ ivas_error core_switching_pre_dec(
            set_f( st->hHQ_core->old_out, 0, output_frame );
            set_f( st->hHQ_core->old_outLB, 0, L_FRAME16k );
        }
#else
        set_f( st->hHQ_core->old_out, 0, output_frame );
        set_f( st->hHQ_core->old_outLB, 0, L_FRAME16k );
#endif
    }

    /* handle switching cases where preecho_sb was not called in the last frame (memory not up to date) */
Loading