Line data Source code
1 : /*==================================================================================== 2 : EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 3 : ====================================================================================*/ 4 : 5 : #include "options.h" /* Compilation switches */ 6 : #include "cnst.h" /* Common constants */ 7 : //#include "prot_fx.h" /* Function prototypes */ 8 : #include "prot_fx.h" /* Function prototypes */ 9 : #include "prot_fx_enc.h" /* Function prototypes */ 10 : 11 : 12 : /*-------------------------------------------------------------------* 13 : * correlation_shift_fx 14 : * 15 : * Find normalized correlation correction dependent on estimated noise 16 : * Note: this variable is basically active only if noise suppression 17 : * is desactivated. Otherwise, for default NS = 14 dB and up to 10dB SNR 18 : * it can be assumed about 0 19 : *-------------------------------------------------------------------*/ 20 : 21 1196036 : Word16 correlation_shift_fx( /* o : noise dependent voicing correction Q15 */ 22 : const Word16 totalNoise_fx /* i/o: noise estimate over all critical bands Q8 */ 23 : ) 24 : { 25 : Word16 corr_shift_fx, e_Noise, f_Noise, wtmp; 26 : Word32 Ltmp; 27 : 28 1196036 : corr_shift_fx = 0; 29 1196036 : move16(); 30 : 31 1196036 : IF( GT_16( totalNoise_fx, 7215 ) ) /* to make corr_shift > 0.0 */ 32 : { 33 : /*------------------------------------------------------------* 34 : * useful values range from 0 to 1 (can saturate at 1.0) Q31 value 35 : * corr_shift = 2.4492E-4 * exp(0.1596 * totalNoise) - 0.022 36 : * Result in Q14 37 : *------------------------------------------------------------*/ 38 114520 : Ltmp = L_mult( totalNoise_fx, 7545 ); /* Q24 */ 39 114520 : Ltmp = L_shr( Ltmp, 8 ); /* Q24 -> Q16 */ 40 114520 : f_Noise = L_Extract_lc( Ltmp, &e_Noise ); 41 114520 : wtmp = extract_l( Pow2( 14, f_Noise ) ); /* Put 14 as exponent */ 42 : 43 114520 : e_Noise = sub( e_Noise, 14 ); /* Retreive exponent of wtmp */ 44 114520 : Ltmp = Mpy_32_16( 8, 837, wtmp ); /* 2.4492e-4(Q31) * exp(0.1596*totalNoise) */ 45 114520 : Ltmp = L_shl_sat( Ltmp, add( e_Noise, 15 ) ); /* Result in Q31 */ 46 114520 : corr_shift_fx = round_fx( L_sub( Ltmp, 47244640 ) ); /* Represents corr_shift in Q15 */ 47 : } 48 1196036 : corr_shift_fx = s_min( corr_shift_fx, 16384 ); /* limit to 0.5 */ 49 : 50 1196036 : return corr_shift_fx; 51 : }