/*==================================================================================== EVS Codec 3GPP TS26.443 Jun 30, 2015. Version CR 26.443-0006 ====================================================================================*/ #include #include "options.h" #include "prot.h" /*---------------------------------------------------------------------* * Local constants *---------------------------------------------------------------------*/ #define TILT_COMP_LIM 0.75f /*---------------------------------------------------------* * Local functions *---------------------------------------------------------*/ static float calc_tilt(const float *x, const short len); /*--------------------------------------------------------------------* * stat_noise_uv_mod() * * Modifies excitation signal in stationary noise segments *--------------------------------------------------------------------*/ void stat_noise_uv_mod( const short coder_type, /* i : coder type */ float noisiness, /* i : noisiness parameter */ const float *lsp_old, /* i : old LSP vector at 4th sfr */ const float *lsp_new, /* i : LSP vector at 4th sfr */ const float *lsp_mid, /* i : LSP vector at 2nd sfr */ float *Aq, /* o : A(z) quantized for the 4 subframes */ float *exc2, /* o : excitation buffer */ const short bfi, /* i : bad frame indicator */ float *ge_sm, /* i/o: smoothed excitation gain */ short *uv_count, /* i/o: unvoiced counter */ short *act_count, /* i/o: activation counter */ float lspold_s[], /* i/o: old LSP */ short *noimix_seed, /* i/o: mixture seed */ float *st_min_alpha, /* i/o: minimum alpha */ float *exc_pe, /* i/o: memory of the preemphasis filter */ const long bitrate, /* i : core bitrate */ const short bwidth /* i : Sampling rate */ ) { short i, k; short i_subfr; float exctilt; float vare, ge, randval; float alpha, min_alpha; float lspnew_s[M], oldlsp_mix[M], midlsp_mix[M], newlsp_mix[M]; float beta; float noimix_fac; alpha = 1.0f; min_alpha = 0.5f; /*---------------------------------------------------------* * Update minimum mixing factor alpha *---------------------------------------------------------*/ /* Activate modifications for WB/SWB <= 9.6kbps for NB only at 9.6kbps */ if ( coder_type == INACTIVE && ( bitrate == ACELP_9k60 || (bitrate < ACELP_9k60 && bwidth > NB) ) ) { if ( !bfi ) { min_alpha = max( noisiness/31.0f * 0.5f + 0.5f, *st_min_alpha - 0.05f ); *st_min_alpha = min_alpha; } else { min_alpha = *st_min_alpha; } } /*---------------------------------------------------------* * Mix excitation signal with random noise *---------------------------------------------------------*/ /* Activate modifications for WB/SWB <= 9.6kbps for NB only at 9.6kbps */ if ( coder_type == INACTIVE && (bitrate == ACELP_9k60 || (bitrate < ACELP_9k60 && bwidth > NB ) ) ) { /* preemphasize the excitation signal with its tilt */ if( min_alpha < TILT_COMP_LIM ) { for (i_subfr=0; i_subfr FULL_NG) { *uv_count = FULL_NG; } alpha = 1 + ((float)*uv_count - START_NG)/((float)FULL_NG - START_NG) * (min_alpha - 1.0f); } /* calculate lowpass-filtered excitation gain */ vare = 0.01f; for (i=0; i 3) { *act_count = 3; *uv_count = 0; } } return; } /*---------------------------------------------------------------------------* * calc_tilt() * * Calculate spectral tilt by means of 1st-order LP analysis *---------------------------------------------------------------------------*/ static float calc_tilt( const float *x, /* i : Signal input */ const short len /* i : lenght */ ) { int i; float r0, r1; r0 = 0; r1 = 0; for ( i=0; i