Loading .gitlab-ci/variables.yml +1 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ variables: - 'pytest-compare' - 'pytest-compare-enc-dmx' - 'pytest-compare-long' - 'pytest-compare-long-fx-fx' - 'pytest-compare-to-input' - 'pytest-saturation-smoke-test' - 'evs-26444' Loading lib_com/basop_util.c +4 −0 Original line number Diff line number Diff line Loading @@ -1409,7 +1409,11 @@ Word32 BASOP_Util_Divide3232_Scale_newton( Word32 x, Word32 y, Word16 *s ) *s = 0; return ( (Word32) 0 ); } #ifdef FIX_USAN_BASOP_UTIL_DIVIDE3232 IF( EQ_32( y, (Word32) 0x80000000 ) ) #else IF( EQ_32( y, 0x80000000 ) ) #endif { /* Division by -1.0: same as negation of numerator */ /* Return normalized negated numerator */ Loading lib_com/cldfb_fx.c +31 −12 Original line number Diff line number Diff line Loading @@ -519,6 +519,7 @@ void cldfbAnalysis_ts_fx( } fft_cldfb_fx( rBuffer_fx, M2 ); #ifndef FIX_1733_CLDFB_BUG /* post modulation of DST IV */ FOR( k = 0; k < M2; k++ ) { Loading @@ -533,6 +534,7 @@ void cldfbAnalysis_ts_fx( move32(); move32(); } #endif *q_cldfb = sub( *q_cldfb, 2 ); move16(); Loading @@ -553,6 +555,23 @@ void cldfbAnalysis_ts_fx( move32(); } #ifdef FIX_1733_CLDFB_BUG /* post modulation of DST IV */ FOR( k = 0; k < M2; k++ ) { /*cplxMult(&realBuffer[M1-1-(2*k)],&realBuffer[2*k],rBuffer[2*k],rBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/ #ifdef OPT_AVOID_STATE_BUF_RESCALE realBuffer_fx[( ( M1 - 1 ) - ( k * 2 ) )] = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5 realBuffer_fx[2 * k] = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5 #else /* OPT_AVOID_STATE_BUF_RESCALE */ realBuffer_fx[( ( M1 - 1 ) - ( k * 2 ) )] = L_sub( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5 realBuffer_fx[2 * k] = L_add( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5 #endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); } #endif /* post modulation of DCT IV */ FOR( k = 0; k < M2; k++ ) { Loading lib_com/cnst.h +11 −8 Original line number Diff line number Diff line Loading @@ -45,20 +45,22 @@ #define MATRIX_CONSTANT (759250113) #define NUM_SAMPLES_960 (960) #define NUM_SAMPLES_720 (720) #define NUM_SAMPLES_640 (640) #define NUM_SAMPLES_320 (320) #define NUM_SAMPLES_160 (160) #define L_SUBFRAME_48k (240) #define L_SUBFRAME_32k (180) #define L_SUBFRAME_16k (80) #define L_SUBFRAME_8k (40) #define Q31_BY_NUM_SAMPLES_960 ( 2239294 ) #define Q31_BY_NUM_SAMPLES_720 ( 2986764 ) #define Q31_BY_NUM_SAMPLES_320 ( 6731924 ) #define Q31_BY_NUM_SAMPLES_160 ( 13506186 ) #define Q31_BY_SUB_FRAME_240 ( 8985287 ) #define Q31_BY_SUB_FRAME_180 ( 11997115 ) #define Q31_BY_SUB_FRAME_80 ( 27183337 ) #define Q31_BY_SUB_FRAME_40 ( 55063683 ) #define Q31_BY_NUM_SAMPLES_960 ( 2239294 ) /* 1/959 in Q31 */ #define Q31_BY_NUM_SAMPLES_720 ( 2986764 ) /* 1/719 in Q31 */ #define Q31_BY_NUM_SAMPLES_640 ( 3360694 ) /* 1/639 in Q31 */ #define Q31_BY_NUM_SAMPLES_320 ( 6731924 ) /* 1/319 in Q31 */ #define Q31_BY_NUM_SAMPLES_160 ( 13506186 ) /* 1/159 in Q31 */ #define Q31_BY_SUB_FRAME_240 ( 8985287 ) /* 1/239 in Q31 */ #define Q31_BY_SUB_FRAME_180 ( 11997115 ) /* 1/179 in Q31 */ #define Q31_BY_SUB_FRAME_80 ( 27183337 ) /* 1/79 in Q31 */ #define Q31_BY_SUB_FRAME_40 ( 55063683 ) /* 1/39 in Q31 */ /*----------------------------------------------------------------------------------* Loading Loading @@ -761,6 +763,7 @@ enum #define PIT_FIR_SIZE6_2 ( PIT_UP_SAMP6 * PIT_L_INTERPOL6_2 + 1 ) #define E_MIN 0.0035f /* minimum allowable energy */ #define E_MIN_Q11_FX 7 /* minimum allowable energy in Q11*/ #define E_MIN_Q27_FX 469762 /* minimum allowable energy in Q27*/ #define STEP_DELTA 0.0625f /* quantization step for tilt compensation of gaussian cb. excitation */ #define GAMMA_EV 0.92f /* weighting factor for core synthesis error weighting */ #define FORMANT_SHARPENING_NOISE_THRESHOLD 21.0f /* lp_noise level above which formant sharpening is deactivated */ Loading lib_com/enhancer_fx.c +8 −213 Original line number Diff line number Diff line Loading @@ -299,10 +299,11 @@ void enhancer_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*======================================================================================*/ void enhancer_ivas_fx( const Word16 codec_mode, /* i : flag indicating Codec Mode */ const Word32 core_brate, /* i : decoder bitrate */ const Word16 cbk_index, /* i : */ const Word16 cbk_index, const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ const Word16 coder_type, /* i : coder type */ const Word16 i_subfr, /* i : subframe number */ Loading @@ -322,9 +323,11 @@ void enhancer_ivas_fx( Word16 tmp, fac, *pt_exc2; Word16 i; Word32 L_tmp; Word32 L_tmp1, L_tmp2; Word16 gain_code_hi; Word16 pit_sharp, tmp16; Word16 excp[L_SUBFR], sc; Word64 w_temp; pit_sharp = gain_pit; Loading Loading @@ -400,215 +403,6 @@ void enhancer_ivas_fx( phase_dispersion_fx( norm_gain_code, gain_pit, code, i, dm_fx ); /*------------------------------------------------------------ * noise enhancer * * - Enhance excitation on noise. (modify gain of code) * If signal is noisy and LPC filter is stable, move gain * of code 1.5 dB toward gain of code threshold. * This decreases by 3 dB noise energy variation. *-----------------------------------------------------------*/ /* tmp = 0.5f * (1.0f - voice_fac) */ tmp = msu_r_sat( 0x40000000 /*0.5.Q31*/, voice_fac, 16384 /*0.5.Q14*/ ); /*Q15 */ /* 1=unvoiced, 0=voiced */ /* fac = stab_fac * tmp */ fac = mult( stab_fac, tmp ); /*Q15*/ IF( LT_32( norm_gain_code, *gc_threshold ) ) { L_tmp = Madd_32_16( norm_gain_code, norm_gain_code, 6226 /*0.19.Q15*/ ); /*Q16 */ L_tmp = L_min( L_tmp, *gc_threshold ); /*Q16 */ } ELSE { L_tmp = Mult_32_16( norm_gain_code, 27536 /*0.84.Q15*/ ); /*Q16 */ L_tmp = L_max( L_tmp, *gc_threshold ); /*Q16 */ } *gc_threshold = L_tmp; move32(); /*Q16 */ /* gain_code = (fac * tmp) + (1.0 - fac) * gain_code ==> fac * (tmp - gain_code) + gain_code */ L_tmp = L_sub( L_tmp, norm_gain_code ); /*Q16 */ norm_gain_code = Madd_32_16( norm_gain_code, L_tmp, fac ); /*Q16 */ /* gain_code *= gain_inov - Inverse the normalization */ L_tmp = Mult_32_16( norm_gain_code, gain_inov ); /*Q13*/ /* gain_inov in Q12 */ sc = 6; move16(); gain_code_hi = round_fx( L_shl( L_tmp, add( Q_exc, 3 ) ) ); /* in Q_exc */ /*------------------------------------------------------------* * pitch enhancer * * - Enhance excitation on voiced. (HP filtering of code) * On voiced signal, filtering of code by a smooth fir HP * filter to decrease energy of code at low frequency. *------------------------------------------------------------*/ test(); IF( !Opt_AMR_WB && EQ_16( coder_type, UNVOICED ) ) { /* Copy(code, exc2, L_SUBFR) */ FOR( i = 0; i < L_SUBFR; i++ ) { pt_exc2[i] = round_fx( L_shl( L_mult( gain_code_hi, code[i] ), sc ) ); /*Q0 */ /* code in Q12 (Q9 for encoder) */ move16(); } } ELSE { test(); test(); IF( Opt_AMR_WB && ( EQ_32( core_brate, ACELP_8k85 ) || EQ_32( core_brate, ACELP_6k60 ) ) ) { pit_sharp = shl_sat( gain_pit, 1 ); /* saturation can occur here Q14 -> Q15 */ /* saturation takes care of "if (pit_sharp > 1.0) { pit_sharp=1.0; }" */ IF( GT_16( pit_sharp, 16384 /*0.5.Q15*/ ) ) { tmp16 = mult( pit_sharp, 8192 /*0.25.Q15*/ ); FOR( i = 0; i < L_SUBFR; i++ ) { /* excp[i] = pt_exc2[i] * pit_sharp * 0.25 */ excp[i] = mult_r( pt_exc2[i], tmp16 ); move16(); } } } IF( EQ_16( L_frame, L_FRAME16k ) ) { /* tmp = 0.150 * (1.0 + voice_fac) */ /* 0.30=voiced, 0=unvoiced */ tmp = mac_r( 0x13333333L /*0.150.Q31*/, voice_fac, 4915 /*0.150.Q15*/ ); /*Q15 */ } ELSE { /* tmp = 0.125 * (1.0 + voice_fac) */ /* 0.25=voiced, 0=unvoiced */ tmp = mac_r( 0x10000000L /*0.125.Q31*/, voice_fac, 4096 ); /*Q15 */ } /*----------------------------------------------------------------- * Do a simple noncasual "sharpening": effectively an FIR * filter with coefs [-tmp 1.0 -tmp] where tmp=0...0.25. * This is applied to code and add_fxed to exc2 *-----------------------------------------------------------------*/ /* pt_exc2[0] += code[0] - tmp * code[1] */ L_tmp = L_deposit_h( code[0] ); /* if Enc :Q9 * Q15 -> Q25 */ L_tmp = L_msu( L_tmp, code[1], tmp ); /* Q12 * Q15 -> Q28 */ L_tmp = L_shl( L_mult( gain_code_hi, extract_h( L_tmp ) ), sc ); pt_exc2[0] = msu_r( L_tmp, -32768, pt_exc2[0] ); move16(); /* in Q_exc */ FOR( i = 1; i < L_SUBFR - 1; i++ ) { /* pt_exc2[i] += code[i] - tmp * code[i-1] - tmp * code[i+1] */ L_tmp = L_msu( -32768, code[i], -32768 ); L_tmp = L_msu( L_tmp, code[i + 1], tmp ); tmp16 = msu_r( L_tmp, code[i - 1], tmp ); L_tmp = L_shl( L_mult( gain_code_hi, tmp16 ), sc ); pt_exc2[i] = msu_r_sat( L_tmp, -32768, pt_exc2[i] ); move16(); /* in Q_exc */ } /* pt_exc2[L_SUBFR-1] += code[L_SUBFR-1] - tmp * code[L_SUBFR-2] */ L_tmp = L_deposit_h( code[L_SUBFR - 1] ); /*Q28 */ L_tmp = L_msu( L_tmp, code[L_SUBFR - 2], tmp ); /*Q28 */ L_tmp = L_shl( L_mult( gain_code_hi, extract_h( L_tmp ) ), sc ); pt_exc2[L_SUBFR - 1] = msu_r( L_tmp, -32768, pt_exc2[L_SUBFR - 1] ); move16(); /* in Q_exc */ test(); test(); IF( Opt_AMR_WB && ( EQ_32( core_brate, ACELP_8k85 ) || EQ_32( core_brate, ACELP_6k60 ) ) ) { IF( GT_16( pit_sharp, 16384 /*0.5.Q14*/ ) ) { FOR( i = 0; i < L_SUBFR; i++ ) { /* excp[i] += pt_exc2[i] */ excp[i] = add( excp[i], pt_exc2[i] ); move16(); } agc2_fx( pt_exc2, excp, L_SUBFR ); Copy( excp, pt_exc2, L_SUBFR ); } } } } void enhancer_ivas_fx2( const Word32 core_brate, /* i : decoder bitrate */ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ const Word16 coder_type, /* i : coder type */ const Word16 i_subfr, /* i : subframe number */ const Word16 L_frame, /* i : frame size */ const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ Word16 *code, /* i/o: innovation Q12 */ Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ const Word16 gain_pit, /* i : quantized pitch gain Q14 */ struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ const Word16 Q_exc /* i : Q of the excitation */ ) { Word16 tmp, fac, *pt_exc2; Word16 i; Word32 L_tmp; Word32 L_tmp1, L_tmp2; Word16 gain_code_hi; Word16 pit_sharp, tmp16; Word16 excp[L_SUBFR], sc; Word64 w_temp; pit_sharp = gain_pit; move16(); /* to remove gcc warning */ pt_exc2 = exc2 + i_subfr; /*------------------------------------------------------------* * Phase dispersion to enhance noise at low bit rate *------------------------------------------------------------*/ i = 2; move16(); /* no dispersion */ IF( Opt_AMR_WB ) { IF( LE_32( core_brate, ACELP_6k60 ) ) { i = 0; move16(); /* high dispersion */ } ELSE IF( LE_32( core_brate, ACELP_8k85 ) ) { i = 1; move16(); /* low dispersion */ } } ELSE IF( NE_16( coder_type, UNVOICED ) ) { test(); test(); test(); test(); IF( LE_32( core_brate, ACELP_7k20 ) ) { i = 0; move16(); /* high dispersion */ } ELSE IF( ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) || EQ_16( coder_type, AUDIO ) || coder_type == INACTIVE ) && LE_32( core_brate, ACELP_9k60 ) ) { i = 1; move16(); /* low dispersion */ } } phase_dispersion_fx( norm_gain_code, gain_pit, code, i, dm_fx ); /*------------------------------------------------------------ * noise enhancer * Loading Loading @@ -656,7 +450,8 @@ void enhancer_ivas_fx2( * filter to decrease energy of code at low frequency. *------------------------------------------------------------*/ test(); IF( !Opt_AMR_WB && EQ_16( coder_type, UNVOICED ) ) test(); IF( !Opt_AMR_WB && EQ_16( codec_mode, MODE1 ) && EQ_16( coder_type, UNVOICED ) ) { /* Copy(code, exc2, L_SUBFR) */ FOR( i = 0; i < L_SUBFR; i++ ) Loading Loading
.gitlab-ci/variables.yml +1 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ variables: - 'pytest-compare' - 'pytest-compare-enc-dmx' - 'pytest-compare-long' - 'pytest-compare-long-fx-fx' - 'pytest-compare-to-input' - 'pytest-saturation-smoke-test' - 'evs-26444' Loading
lib_com/basop_util.c +4 −0 Original line number Diff line number Diff line Loading @@ -1409,7 +1409,11 @@ Word32 BASOP_Util_Divide3232_Scale_newton( Word32 x, Word32 y, Word16 *s ) *s = 0; return ( (Word32) 0 ); } #ifdef FIX_USAN_BASOP_UTIL_DIVIDE3232 IF( EQ_32( y, (Word32) 0x80000000 ) ) #else IF( EQ_32( y, 0x80000000 ) ) #endif { /* Division by -1.0: same as negation of numerator */ /* Return normalized negated numerator */ Loading
lib_com/cldfb_fx.c +31 −12 Original line number Diff line number Diff line Loading @@ -519,6 +519,7 @@ void cldfbAnalysis_ts_fx( } fft_cldfb_fx( rBuffer_fx, M2 ); #ifndef FIX_1733_CLDFB_BUG /* post modulation of DST IV */ FOR( k = 0; k < M2; k++ ) { Loading @@ -533,6 +534,7 @@ void cldfbAnalysis_ts_fx( move32(); move32(); } #endif *q_cldfb = sub( *q_cldfb, 2 ); move16(); Loading @@ -553,6 +555,23 @@ void cldfbAnalysis_ts_fx( move32(); } #ifdef FIX_1733_CLDFB_BUG /* post modulation of DST IV */ FOR( k = 0; k < M2; k++ ) { /*cplxMult(&realBuffer[M1-1-(2*k)],&realBuffer[2*k],rBuffer[2*k],rBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/ #ifdef OPT_AVOID_STATE_BUF_RESCALE realBuffer_fx[( ( M1 - 1 ) - ( k * 2 ) )] = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5 realBuffer_fx[2 * k] = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5 #else /* OPT_AVOID_STATE_BUF_RESCALE */ realBuffer_fx[( ( M1 - 1 ) - ( k * 2 ) )] = L_sub( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5 realBuffer_fx[2 * k] = L_add( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5 #endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); } #endif /* post modulation of DCT IV */ FOR( k = 0; k < M2; k++ ) { Loading
lib_com/cnst.h +11 −8 Original line number Diff line number Diff line Loading @@ -45,20 +45,22 @@ #define MATRIX_CONSTANT (759250113) #define NUM_SAMPLES_960 (960) #define NUM_SAMPLES_720 (720) #define NUM_SAMPLES_640 (640) #define NUM_SAMPLES_320 (320) #define NUM_SAMPLES_160 (160) #define L_SUBFRAME_48k (240) #define L_SUBFRAME_32k (180) #define L_SUBFRAME_16k (80) #define L_SUBFRAME_8k (40) #define Q31_BY_NUM_SAMPLES_960 ( 2239294 ) #define Q31_BY_NUM_SAMPLES_720 ( 2986764 ) #define Q31_BY_NUM_SAMPLES_320 ( 6731924 ) #define Q31_BY_NUM_SAMPLES_160 ( 13506186 ) #define Q31_BY_SUB_FRAME_240 ( 8985287 ) #define Q31_BY_SUB_FRAME_180 ( 11997115 ) #define Q31_BY_SUB_FRAME_80 ( 27183337 ) #define Q31_BY_SUB_FRAME_40 ( 55063683 ) #define Q31_BY_NUM_SAMPLES_960 ( 2239294 ) /* 1/959 in Q31 */ #define Q31_BY_NUM_SAMPLES_720 ( 2986764 ) /* 1/719 in Q31 */ #define Q31_BY_NUM_SAMPLES_640 ( 3360694 ) /* 1/639 in Q31 */ #define Q31_BY_NUM_SAMPLES_320 ( 6731924 ) /* 1/319 in Q31 */ #define Q31_BY_NUM_SAMPLES_160 ( 13506186 ) /* 1/159 in Q31 */ #define Q31_BY_SUB_FRAME_240 ( 8985287 ) /* 1/239 in Q31 */ #define Q31_BY_SUB_FRAME_180 ( 11997115 ) /* 1/179 in Q31 */ #define Q31_BY_SUB_FRAME_80 ( 27183337 ) /* 1/79 in Q31 */ #define Q31_BY_SUB_FRAME_40 ( 55063683 ) /* 1/39 in Q31 */ /*----------------------------------------------------------------------------------* Loading Loading @@ -761,6 +763,7 @@ enum #define PIT_FIR_SIZE6_2 ( PIT_UP_SAMP6 * PIT_L_INTERPOL6_2 + 1 ) #define E_MIN 0.0035f /* minimum allowable energy */ #define E_MIN_Q11_FX 7 /* minimum allowable energy in Q11*/ #define E_MIN_Q27_FX 469762 /* minimum allowable energy in Q27*/ #define STEP_DELTA 0.0625f /* quantization step for tilt compensation of gaussian cb. excitation */ #define GAMMA_EV 0.92f /* weighting factor for core synthesis error weighting */ #define FORMANT_SHARPENING_NOISE_THRESHOLD 21.0f /* lp_noise level above which formant sharpening is deactivated */ Loading
lib_com/enhancer_fx.c +8 −213 Original line number Diff line number Diff line Loading @@ -299,10 +299,11 @@ void enhancer_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*======================================================================================*/ void enhancer_ivas_fx( const Word16 codec_mode, /* i : flag indicating Codec Mode */ const Word32 core_brate, /* i : decoder bitrate */ const Word16 cbk_index, /* i : */ const Word16 cbk_index, const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ const Word16 coder_type, /* i : coder type */ const Word16 i_subfr, /* i : subframe number */ Loading @@ -322,9 +323,11 @@ void enhancer_ivas_fx( Word16 tmp, fac, *pt_exc2; Word16 i; Word32 L_tmp; Word32 L_tmp1, L_tmp2; Word16 gain_code_hi; Word16 pit_sharp, tmp16; Word16 excp[L_SUBFR], sc; Word64 w_temp; pit_sharp = gain_pit; Loading Loading @@ -400,215 +403,6 @@ void enhancer_ivas_fx( phase_dispersion_fx( norm_gain_code, gain_pit, code, i, dm_fx ); /*------------------------------------------------------------ * noise enhancer * * - Enhance excitation on noise. (modify gain of code) * If signal is noisy and LPC filter is stable, move gain * of code 1.5 dB toward gain of code threshold. * This decreases by 3 dB noise energy variation. *-----------------------------------------------------------*/ /* tmp = 0.5f * (1.0f - voice_fac) */ tmp = msu_r_sat( 0x40000000 /*0.5.Q31*/, voice_fac, 16384 /*0.5.Q14*/ ); /*Q15 */ /* 1=unvoiced, 0=voiced */ /* fac = stab_fac * tmp */ fac = mult( stab_fac, tmp ); /*Q15*/ IF( LT_32( norm_gain_code, *gc_threshold ) ) { L_tmp = Madd_32_16( norm_gain_code, norm_gain_code, 6226 /*0.19.Q15*/ ); /*Q16 */ L_tmp = L_min( L_tmp, *gc_threshold ); /*Q16 */ } ELSE { L_tmp = Mult_32_16( norm_gain_code, 27536 /*0.84.Q15*/ ); /*Q16 */ L_tmp = L_max( L_tmp, *gc_threshold ); /*Q16 */ } *gc_threshold = L_tmp; move32(); /*Q16 */ /* gain_code = (fac * tmp) + (1.0 - fac) * gain_code ==> fac * (tmp - gain_code) + gain_code */ L_tmp = L_sub( L_tmp, norm_gain_code ); /*Q16 */ norm_gain_code = Madd_32_16( norm_gain_code, L_tmp, fac ); /*Q16 */ /* gain_code *= gain_inov - Inverse the normalization */ L_tmp = Mult_32_16( norm_gain_code, gain_inov ); /*Q13*/ /* gain_inov in Q12 */ sc = 6; move16(); gain_code_hi = round_fx( L_shl( L_tmp, add( Q_exc, 3 ) ) ); /* in Q_exc */ /*------------------------------------------------------------* * pitch enhancer * * - Enhance excitation on voiced. (HP filtering of code) * On voiced signal, filtering of code by a smooth fir HP * filter to decrease energy of code at low frequency. *------------------------------------------------------------*/ test(); IF( !Opt_AMR_WB && EQ_16( coder_type, UNVOICED ) ) { /* Copy(code, exc2, L_SUBFR) */ FOR( i = 0; i < L_SUBFR; i++ ) { pt_exc2[i] = round_fx( L_shl( L_mult( gain_code_hi, code[i] ), sc ) ); /*Q0 */ /* code in Q12 (Q9 for encoder) */ move16(); } } ELSE { test(); test(); IF( Opt_AMR_WB && ( EQ_32( core_brate, ACELP_8k85 ) || EQ_32( core_brate, ACELP_6k60 ) ) ) { pit_sharp = shl_sat( gain_pit, 1 ); /* saturation can occur here Q14 -> Q15 */ /* saturation takes care of "if (pit_sharp > 1.0) { pit_sharp=1.0; }" */ IF( GT_16( pit_sharp, 16384 /*0.5.Q15*/ ) ) { tmp16 = mult( pit_sharp, 8192 /*0.25.Q15*/ ); FOR( i = 0; i < L_SUBFR; i++ ) { /* excp[i] = pt_exc2[i] * pit_sharp * 0.25 */ excp[i] = mult_r( pt_exc2[i], tmp16 ); move16(); } } } IF( EQ_16( L_frame, L_FRAME16k ) ) { /* tmp = 0.150 * (1.0 + voice_fac) */ /* 0.30=voiced, 0=unvoiced */ tmp = mac_r( 0x13333333L /*0.150.Q31*/, voice_fac, 4915 /*0.150.Q15*/ ); /*Q15 */ } ELSE { /* tmp = 0.125 * (1.0 + voice_fac) */ /* 0.25=voiced, 0=unvoiced */ tmp = mac_r( 0x10000000L /*0.125.Q31*/, voice_fac, 4096 ); /*Q15 */ } /*----------------------------------------------------------------- * Do a simple noncasual "sharpening": effectively an FIR * filter with coefs [-tmp 1.0 -tmp] where tmp=0...0.25. * This is applied to code and add_fxed to exc2 *-----------------------------------------------------------------*/ /* pt_exc2[0] += code[0] - tmp * code[1] */ L_tmp = L_deposit_h( code[0] ); /* if Enc :Q9 * Q15 -> Q25 */ L_tmp = L_msu( L_tmp, code[1], tmp ); /* Q12 * Q15 -> Q28 */ L_tmp = L_shl( L_mult( gain_code_hi, extract_h( L_tmp ) ), sc ); pt_exc2[0] = msu_r( L_tmp, -32768, pt_exc2[0] ); move16(); /* in Q_exc */ FOR( i = 1; i < L_SUBFR - 1; i++ ) { /* pt_exc2[i] += code[i] - tmp * code[i-1] - tmp * code[i+1] */ L_tmp = L_msu( -32768, code[i], -32768 ); L_tmp = L_msu( L_tmp, code[i + 1], tmp ); tmp16 = msu_r( L_tmp, code[i - 1], tmp ); L_tmp = L_shl( L_mult( gain_code_hi, tmp16 ), sc ); pt_exc2[i] = msu_r_sat( L_tmp, -32768, pt_exc2[i] ); move16(); /* in Q_exc */ } /* pt_exc2[L_SUBFR-1] += code[L_SUBFR-1] - tmp * code[L_SUBFR-2] */ L_tmp = L_deposit_h( code[L_SUBFR - 1] ); /*Q28 */ L_tmp = L_msu( L_tmp, code[L_SUBFR - 2], tmp ); /*Q28 */ L_tmp = L_shl( L_mult( gain_code_hi, extract_h( L_tmp ) ), sc ); pt_exc2[L_SUBFR - 1] = msu_r( L_tmp, -32768, pt_exc2[L_SUBFR - 1] ); move16(); /* in Q_exc */ test(); test(); IF( Opt_AMR_WB && ( EQ_32( core_brate, ACELP_8k85 ) || EQ_32( core_brate, ACELP_6k60 ) ) ) { IF( GT_16( pit_sharp, 16384 /*0.5.Q14*/ ) ) { FOR( i = 0; i < L_SUBFR; i++ ) { /* excp[i] += pt_exc2[i] */ excp[i] = add( excp[i], pt_exc2[i] ); move16(); } agc2_fx( pt_exc2, excp, L_SUBFR ); Copy( excp, pt_exc2, L_SUBFR ); } } } } void enhancer_ivas_fx2( const Word32 core_brate, /* i : decoder bitrate */ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ const Word16 coder_type, /* i : coder type */ const Word16 i_subfr, /* i : subframe number */ const Word16 L_frame, /* i : frame size */ const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ Word16 *code, /* i/o: innovation Q12 */ Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ const Word16 gain_pit, /* i : quantized pitch gain Q14 */ struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ const Word16 Q_exc /* i : Q of the excitation */ ) { Word16 tmp, fac, *pt_exc2; Word16 i; Word32 L_tmp; Word32 L_tmp1, L_tmp2; Word16 gain_code_hi; Word16 pit_sharp, tmp16; Word16 excp[L_SUBFR], sc; Word64 w_temp; pit_sharp = gain_pit; move16(); /* to remove gcc warning */ pt_exc2 = exc2 + i_subfr; /*------------------------------------------------------------* * Phase dispersion to enhance noise at low bit rate *------------------------------------------------------------*/ i = 2; move16(); /* no dispersion */ IF( Opt_AMR_WB ) { IF( LE_32( core_brate, ACELP_6k60 ) ) { i = 0; move16(); /* high dispersion */ } ELSE IF( LE_32( core_brate, ACELP_8k85 ) ) { i = 1; move16(); /* low dispersion */ } } ELSE IF( NE_16( coder_type, UNVOICED ) ) { test(); test(); test(); test(); IF( LE_32( core_brate, ACELP_7k20 ) ) { i = 0; move16(); /* high dispersion */ } ELSE IF( ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) || EQ_16( coder_type, AUDIO ) || coder_type == INACTIVE ) && LE_32( core_brate, ACELP_9k60 ) ) { i = 1; move16(); /* low dispersion */ } } phase_dispersion_fx( norm_gain_code, gain_pit, code, i, dm_fx ); /*------------------------------------------------------------ * noise enhancer * Loading Loading @@ -656,7 +450,8 @@ void enhancer_ivas_fx2( * filter to decrease energy of code at low frequency. *------------------------------------------------------------*/ test(); IF( !Opt_AMR_WB && EQ_16( coder_type, UNVOICED ) ) test(); IF( !Opt_AMR_WB && EQ_16( codec_mode, MODE1 ) && EQ_16( coder_type, UNVOICED ) ) { /* Copy(code, exc2, L_SUBFR) */ FOR( i = 0; i < L_SUBFR; i++ ) Loading