Loading lib_com/prot_fx.h +26 −0 Original line number Diff line number Diff line Loading @@ -7580,6 +7580,31 @@ void stat_noise_uv_dec_fx( const Word16 uc_two_stage_flag /* i : flag indicating two-stage UC */ ); #ifdef HQ_ALIGN_DUPLICATED_CODE void stat_noise_uv_mod_fx( const Word16 element_mode, /* i : element mode */ const Word16 coder_type, /* i : Coder type */ Word16 noisiness, /* i : noisiness parameter Q=0 */ const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q=15*/ const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q=15*/ const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ const Word16 bfi, /* i : Bad frame indicator */ Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/ Word16 *uv_count, /* i/o: unvoiced counter */ Word16 *act_count, /* i/o: activation counter */ Word16 lspold_s[], /* i/o: old LSP Q=15*/ Word16 *noimix_seed, /* i/o: mixture seed Q0 */ Word16 *st_min_alpha, /* i/o: minimum alpha Q=15*/ Word16 *exc_pe, /* i/o: scale Q_stat_noise Q=Q_stat_noise*/ const Word32 bitrate, /* i : core bitrate */ const Word16 bwidth_fx, /* i : i bandwidth */ Word16 *Q_stat_noise, /* i/o: noise scaling */ Word16 *Q_stat_noise_ge /* i/o: noise scaling */ ); #else void stat_noise_uv_mod_fx( const Word16 coder_type, /* i : Coder type */ Word16 noisiness, /* i : noisiness parameter Q0 */ Loading Loading @@ -7625,6 +7650,7 @@ void stat_noise_uv_mod_ivas_fx( Word16 *Q_stat_noise, /* i/o: noise scaling */ Word16 *Q_stat_noise_ge /* i/o: noise scaling */ ); #endif Word16 FEC_SinOnset_fx( Word16 *exc, /* i/o : exc vector to modify */ Loading lib_com/stat_noise_uv_mod_fx.c +148 −19 Original line number Diff line number Diff line Loading @@ -28,6 +28,31 @@ Word32 L_Sqrt_Q0( const Word32 x ); * Modifies excitation signal in stationary noise segments *--------------------------------------------------------------------*/ #ifdef HQ_ALIGN_DUPLICATED_CODE void stat_noise_uv_mod_fx( const Word16 element_mode, /* i : element mode */ const Word16 coder_type, /* i : Coder type */ Word16 noisiness, /* i : noisiness parameter Q=0 */ const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q=15*/ const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q=15*/ const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ const Word16 bfi, /* i : Bad frame indicator */ Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/ Word16 *uv_count, /* i/o: unvoiced counter */ Word16 *act_count, /* i/o: activation counter */ Word16 lspold_s[], /* i/o: old LSP Q=15*/ Word16 *noimix_seed, /* i/o: mixture seed Q0 */ Word16 *st_min_alpha, /* i/o: minimum alpha Q=15*/ Word16 *exc_pe, /* i/o: scale Q_stat_noise Q=Q_stat_noise*/ const Word32 bitrate, /* i : core bitrate */ const Word16 bwidth_fx, /* i : i bandwidth */ Word16 *Q_stat_noise, /* i/o: noise scaling */ Word16 *Q_stat_noise_ge /* i/o: noise scaling */ ) #else void stat_noise_uv_mod_fx( const Word16 coder_type, /* i : Coder type */ Word16 noisiness, /* i : noisiness parameter Q0 */ Loading @@ -50,6 +75,7 @@ void stat_noise_uv_mod_fx( Word16 *Q_stat_noise, /* i/o: noise scaling */ Word16 *Q_stat_noise_ge /* i/o: noise scaling */ ) #endif { Word16 exctilt; /* Q15 */ Word32 vare; /* Q31 */ Loading @@ -63,6 +89,9 @@ void stat_noise_uv_mod_fx( Word16 newlsp_mix[M]; Word16 beta; /* Q15 */ Word16 Noimix_fract; /* (noimix_fac - 1.0) in Q15 */ #ifdef HQ_ALIGN_DUPLICATED_CODE Word32 L_Noimix_fract; /* (noimix_fac - 1.0) in Q15 */ #endif /* noimix_fax * x <-> x + Noimix_fract * x */ Word16 i_subfr; Word16 i, k; Loading @@ -74,6 +103,9 @@ void stat_noise_uv_mod_fx( Word16 En_shift, Tmp; Word16 Exc2_local[L_FRAME]; /* local_copy in scaled Q_local*/ #ifdef HQ_ALIGN_DUPLICATED_CODE Word32 L_Exc2_local[L_FRAME]; /* local_copy in scaled Q_local*/ #endif /*---------------------------------------------------------* * Init local variables Loading @@ -82,6 +114,9 @@ void stat_noise_uv_mod_fx( move16(); min_alpha = 16384; move16(); #ifdef HQ_ALIGN_DUPLICATED_CODE L_Noimix_fract = 0; #endif test(); test(); Loading @@ -98,15 +133,23 @@ void stat_noise_uv_mod_fx( tmp_den = 31; move16(); tmp_shift = norm_s( tmp_den ); #ifndef HQ_ALIGN_DUPLICATED_CODE move16(); #endif L_tmp_res = L_deposit_h( noisiness ); L_tmp_res = L_shl( L_tmp_res, sub( tmp_shift, 1 ) ); tmp_den = shl( tmp_den, tmp_shift ); #ifndef HQ_ALIGN_DUPLICATED_CODE move16(); #endif tmp_res = div_l( L_tmp_res, tmp_den ); #ifndef HQ_ALIGN_DUPLICATED_CODE move16(); #endif min_alpha = add_sat( tmp_res, 16384 ); #ifndef HQ_ALIGN_DUPLICATED_CODE move16(); #endif /**st_min_alpha = sub(*st_min_alpha, 1638); move16();*/ min_alpha = s_max( min_alpha, sub( *st_min_alpha, 1638 ) ); Loading @@ -128,9 +171,17 @@ void stat_noise_uv_mod_fx( Copy( exc2, Exc2_local, L_FRAME ); /* bound Q for internal use, optimization possible */ #ifdef HQ_ALIGN_DUPLICATED_CODE Q_local = s_min( 11, s_max( -1, *Q_exc ) ); #else Q_local = s_min( 11, s_max( -1, Q_exc ) ); #endif /* local excitation Q and incoming excitation Q*/ #ifdef HQ_ALIGN_DUPLICATED_CODE Qdiff = sub( Q_local, *Q_exc ); #else Qdiff = sub( Q_local, Q_exc ); #endif /* only shift if incoming Q is outside [11..-1] shift is done in energy calculations aswell */ Scale_sig( Exc2_local, L_FRAME, Qdiff ); /* current excitation Q and previous stat_noise states Q */ Loading Loading @@ -229,14 +280,30 @@ void stat_noise_uv_mod_fx( L_tmp_res = L_mac( 0, alpha, alpha ); L_tmp_res = L_mac( L_tmp_res, alpha_m1, alpha_m1 ); tmp_den = round_fx( L_Frac_sqrtQ31( L_tmp_res ) ); #ifdef HQ_ALIGN_DUPLICATED_CODE IF( EQ_16( element_mode, EVS_MONO ) ) { tmp_nom = sub( 32767, tmp_den ); tmp_shift = norm_s( tmp_den ); tmp_den = shl( tmp_den, tmp_shift ); tmp_res = div_s( tmp_nom, tmp_den ); Noimix_fract = shr( tmp_res, tmp_shift ); /* float value is in range 0.0 to 0.42 */ } ELSE { Word16 exp_sqr = 0; move16(); tmp_res = BASOP_Util_Divide1616_Scale( 32767, tmp_den, &exp_sqr ); // 15-exp_sqr Noimix_fract = tmp_res; // 15-exp_sqr move16(); } #else tmp_nom = sub( 32767, tmp_den ); tmp_shift = norm_s( tmp_den ); tmp_den = shl( tmp_den, tmp_shift ); tmp_res = div_s( tmp_nom, tmp_den ); Noimix_fract = shr( tmp_res, tmp_shift ); /* float value is in range 0.0 to 0.42 */ #endif /* L_Ge might be 0 in unvoiced WB */ L_Ge = L_max( L_Ge, 1 ); tmp_shift = norm_l( L_Ge ); Loading @@ -245,8 +312,20 @@ void stat_noise_uv_mod_fx( L_tmp_res = Mult_32_16( *ge_sm, tmp_res ); /* Q_stat_noise_ge+45-Q_local-Q_ge-tmp_shift-15 */ L_tmp_res = Mult_32_16( L_tmp_res, sub( 32767, beta ) ); /*30-Q_local-tmp_shift+15-15 */ L_tmp_res = L_add_sat( L_shl_sat( L_tmp_res, sub( add( Q_local, tmp_shift ), 15 ) ), beta ); /* Q15 */ #ifdef HQ_ALIGN_DUPLICATED_CODE IF( EQ_16( element_mode, EVS_MONO ) ) { tmp_res = extract_h( L_shl_sat( L_tmp_res, 15 ) ); /* 15+15-16=14 */ Noimix_fract = extract_l( Mult_32_16( L_tmp_res, Noimix_fract ) ); /*15+15-15 */ } ELSE { L_Noimix_fract = Mult_32_16( L_tmp_res, Noimix_fract ); /*15+15-exp_sqr-15 =15-exp_sqr */ } #else tmp_res = extract_h( L_shl_sat( L_tmp_res, 15 ) ); /* 15+15-16=14 */ Noimix_fract = extract_l( Mult_32_16( L_tmp_res, Noimix_fract ) ); /*15+15-15 */ #endif FOR( i = 0; i < L_FRAME; i++ ) { Loading @@ -260,21 +339,68 @@ void stat_noise_uv_mod_fx( /* (1-alpha)*(float)sqrt(12.0f) * ((float)own_random(&(st->noimix_seed))/65536.0f) */ randval = Random( noimix_seed ); /* +/-32767 */ randval = mult_r( 28378, randval ); /* Q downscaled by 2 bits ends up in Q14 */ /*sqrt(12.0f) in Q13*/ #ifdef HQ_ALIGN_DUPLICATED_CODE randval = extract_l( L_shl( Mult_32_16( L_Ge, randval ), sub( 1, *Q_stat_noise_ge ) ) ); /*Q_local+Q_ge+14-15+1-Q_ge=Q_local */ #else randval = extract_l( L_shl( Mult_32_16( L_Ge, randval ), 1 - *Q_stat_noise_ge ) ); /*Q_local+Q_ge+14-15+1-Q_ge=Q_local */ #endif L_tmp = L_mult( Exc2_local[i], alpha ); /* Q_local + 16 */ L_tmp = L_mac( L_tmp, randval, alpha_m1 ); /* Q_local + 16 */ #ifdef HQ_ALIGN_DUPLICATED_CODE IF( EQ_16( element_mode, EVS_MONO ) ) { L_tmp3 = Mult_32_16( L_tmp, Noimix_fract ); /* Q_local+16+15-15 */ L_tmp = L_add_sat( L_tmp3, L_shl_sat( Mult_32_16( L_tmp, tmp_res ), 1 ) ); /* Q_local+16+14-15+1 */ Exc2_local[i] = extract_h( L_tmp ); /*Q_local */ move16(); } ELSE { L_tmp3 = Mult_32_32( L_tmp, L_Noimix_fract ); /* Q_local+16+15-exp_sqr-15 =Q_local +1 */ L_Exc2_local[i] = L_add( L_shr( L_tmp3, 1 ), Mpy_32_32( L_tmp, L_tmp_res ) ); // Q_local + 16 +15 -31 = Q_local move32(); } #else L_tmp3 = Mult_32_16( L_tmp, Noimix_fract ); /* Q_local+16+15-15 */ L_tmp = L_add_sat( L_tmp3, L_shl_sat( Mult_32_16( L_tmp, tmp_res ), 1 ) ); /* Q_local+16+14-15+1 */ Exc2_local[i] = extract_h( L_tmp ); /*Q_local */ move16(); #endif } #ifdef HQ_ALIGN_DUPLICATED_CODE IF( EQ_16( element_mode, EVS_MONO ) ) { *Q_stat_noise = Q_local; /* update for next call, routine can only be called once every frame */ move16(); Qdiff = sub( *Q_exc, Q_local ); /* local excitation and incoming excitation */ Scale_sig( Exc2_local, L_FRAME, Qdiff ); Copy( Exc2_local, exc2, L_FRAME ); } ELSE { Word32 max_val; maximum_abs_32_fx( L_Exc2_local, L_FRAME, &max_val ); Word16 shift = 0; move16(); IF( GT_32( max_val, ONE_IN_Q15 ) ) { shift = norm_l( max_val ); shift = sub( Q31 - Q15, shift ); *Q_exc = sub( Q_local, shift ); // Q_exc = Q_local -shift move16(); } *Q_stat_noise = Q_local; /* update for next call, routine can only be called once every frame */ move16(); Copy_Scale_sig_32_16( L_Exc2_local, exc2, L_FRAME, negate( shift ) ); // Q_exc } #else *Q_stat_noise = Q_local; /* update for next call, routine can only be called once every frame */ move16(); Qdiff = sub( Q_exc, Q_local ); /* local excitation and incoming excitation */ Scale_sig( Exc2_local, L_FRAME, Qdiff ); Copy( Exc2_local, exc2, L_FRAME ); #endif /*--------------------------------------------------------------------* * Generate low-pass filtered version of ISP coefficients *--------------------------------------------------------------------*/ Loading Loading @@ -324,6 +450,8 @@ void stat_noise_uv_mod_fx( } } } #ifndef HQ_ALIGN_DUPLICATED_CODE /*--------------------------------------------------------------------* * stat_noise_uv_mod() * Loading Loading @@ -629,6 +757,7 @@ void stat_noise_uv_mod_ivas_fx( } } } #endif /*---------------------------------------------------------------------------* * calc_tilt() Loading lib_dec/acelp_core_dec_fx.c +6 −0 Original line number Diff line number Diff line Loading @@ -1439,9 +1439,15 @@ ivas_error acelp_core_dec_fx( IF( NE_16( st->nelp_mode_dec, 1 ) ) { /* modify the excitation signal of stationary unvoiced frames */ #ifdef HQ_ALIGN_DUPLICATED_CODE stat_noise_uv_mod_fx( st->element_mode, st->coder_type, 0, st->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, &st->Q_exc, 1, &st->ge_sm_fx, &st->uv_count, &st->act_count, st->lspold_s_fx, &st->noimix_seed, &st->min_alpha_fx, &st->exc_pe_fx, st->core_brate, st->bwidth, &st->Q_stat_noise, &st->Q_stat_noise_ge ); #else stat_noise_uv_mod_fx( st->coder_type, 0, st->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st->Q_exc, 1, &st->ge_sm_fx, &st->uv_count, &st->act_count, st->lspold_s_fx, &st->noimix_seed, &st->min_alpha_fx, &st->exc_pe_fx, st->core_brate, st->bwidth, &st->Q_stat_noise, &st->Q_stat_noise_ge ); #endif } } Loading lib_dec/stat_noise_uv_dec_fx.c +8 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,13 @@ void stat_noise_uv_dec_fx( IF( !st_fx->Opt_AMR_WB ) { #ifdef HQ_ALIGN_DUPLICATED_CODE stat_noise_uv_mod_fx( st_fx->element_mode, coder_type, noisiness, st_fx->lsp_old_fx, lsp_new, lsp_mid, Aq, exc2, st_fx->Q_exc, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); #else IF( st_fx->element_mode > EVS_MONO ) { stat_noise_uv_mod_ivas_fx( coder_type, noisiness, st_fx->lsp_old_fx, lsp_new, lsp_mid, Aq, exc2, &st_fx->Q_exc, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, Loading @@ -90,6 +97,7 @@ void stat_noise_uv_dec_fx( &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); } #endif } Loading lib_enc/stat_noise_uv_enc_fx.c +12 −0 Original line number Diff line number Diff line Loading @@ -97,9 +97,15 @@ void stat_noise_uv_enc_fx( * Modify the stationary noise excitation signal *-----------------------------------------------------------------*/ #ifdef HQ_ALIGN_DUPLICATED_CODE stat_noise_uv_mod_fx( st_fx->element_mode, st_fx->coder_type, noisiness, st_fx->lsp_old_fx, isp_new, isp_mid, Aq, exc2, &Q_new, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); #else stat_noise_uv_mod_fx( st_fx->coder_type, noisiness, st_fx->lsp_old_fx, isp_new, isp_mid, Aq, exc2, Q_new, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); #endif return; Loading Loading @@ -167,9 +173,15 @@ void stat_noise_uv_enc_ivas_fx( * Modify the stationary noise excitation signal *-----------------------------------------------------------------*/ #ifdef HQ_ALIGN_DUPLICATED_CODE stat_noise_uv_mod_fx( st_fx->element_mode, st_fx->coder_type, noisiness, st_fx->lsp_old_fx, isp_new, isp_mid, Aq, exc2, Q_new, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); #else stat_noise_uv_mod_ivas_fx( st_fx->coder_type, noisiness, st_fx->lsp_old_fx, isp_new, isp_mid, Aq, exc2, Q_new, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); #endif return; Loading Loading
lib_com/prot_fx.h +26 −0 Original line number Diff line number Diff line Loading @@ -7580,6 +7580,31 @@ void stat_noise_uv_dec_fx( const Word16 uc_two_stage_flag /* i : flag indicating two-stage UC */ ); #ifdef HQ_ALIGN_DUPLICATED_CODE void stat_noise_uv_mod_fx( const Word16 element_mode, /* i : element mode */ const Word16 coder_type, /* i : Coder type */ Word16 noisiness, /* i : noisiness parameter Q=0 */ const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q=15*/ const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q=15*/ const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ const Word16 bfi, /* i : Bad frame indicator */ Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/ Word16 *uv_count, /* i/o: unvoiced counter */ Word16 *act_count, /* i/o: activation counter */ Word16 lspold_s[], /* i/o: old LSP Q=15*/ Word16 *noimix_seed, /* i/o: mixture seed Q0 */ Word16 *st_min_alpha, /* i/o: minimum alpha Q=15*/ Word16 *exc_pe, /* i/o: scale Q_stat_noise Q=Q_stat_noise*/ const Word32 bitrate, /* i : core bitrate */ const Word16 bwidth_fx, /* i : i bandwidth */ Word16 *Q_stat_noise, /* i/o: noise scaling */ Word16 *Q_stat_noise_ge /* i/o: noise scaling */ ); #else void stat_noise_uv_mod_fx( const Word16 coder_type, /* i : Coder type */ Word16 noisiness, /* i : noisiness parameter Q0 */ Loading Loading @@ -7625,6 +7650,7 @@ void stat_noise_uv_mod_ivas_fx( Word16 *Q_stat_noise, /* i/o: noise scaling */ Word16 *Q_stat_noise_ge /* i/o: noise scaling */ ); #endif Word16 FEC_SinOnset_fx( Word16 *exc, /* i/o : exc vector to modify */ Loading
lib_com/stat_noise_uv_mod_fx.c +148 −19 Original line number Diff line number Diff line Loading @@ -28,6 +28,31 @@ Word32 L_Sqrt_Q0( const Word32 x ); * Modifies excitation signal in stationary noise segments *--------------------------------------------------------------------*/ #ifdef HQ_ALIGN_DUPLICATED_CODE void stat_noise_uv_mod_fx( const Word16 element_mode, /* i : element mode */ const Word16 coder_type, /* i : Coder type */ Word16 noisiness, /* i : noisiness parameter Q=0 */ const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q=15*/ const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q=15*/ const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ const Word16 bfi, /* i : Bad frame indicator */ Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/ Word16 *uv_count, /* i/o: unvoiced counter */ Word16 *act_count, /* i/o: activation counter */ Word16 lspold_s[], /* i/o: old LSP Q=15*/ Word16 *noimix_seed, /* i/o: mixture seed Q0 */ Word16 *st_min_alpha, /* i/o: minimum alpha Q=15*/ Word16 *exc_pe, /* i/o: scale Q_stat_noise Q=Q_stat_noise*/ const Word32 bitrate, /* i : core bitrate */ const Word16 bwidth_fx, /* i : i bandwidth */ Word16 *Q_stat_noise, /* i/o: noise scaling */ Word16 *Q_stat_noise_ge /* i/o: noise scaling */ ) #else void stat_noise_uv_mod_fx( const Word16 coder_type, /* i : Coder type */ Word16 noisiness, /* i : noisiness parameter Q0 */ Loading @@ -50,6 +75,7 @@ void stat_noise_uv_mod_fx( Word16 *Q_stat_noise, /* i/o: noise scaling */ Word16 *Q_stat_noise_ge /* i/o: noise scaling */ ) #endif { Word16 exctilt; /* Q15 */ Word32 vare; /* Q31 */ Loading @@ -63,6 +89,9 @@ void stat_noise_uv_mod_fx( Word16 newlsp_mix[M]; Word16 beta; /* Q15 */ Word16 Noimix_fract; /* (noimix_fac - 1.0) in Q15 */ #ifdef HQ_ALIGN_DUPLICATED_CODE Word32 L_Noimix_fract; /* (noimix_fac - 1.0) in Q15 */ #endif /* noimix_fax * x <-> x + Noimix_fract * x */ Word16 i_subfr; Word16 i, k; Loading @@ -74,6 +103,9 @@ void stat_noise_uv_mod_fx( Word16 En_shift, Tmp; Word16 Exc2_local[L_FRAME]; /* local_copy in scaled Q_local*/ #ifdef HQ_ALIGN_DUPLICATED_CODE Word32 L_Exc2_local[L_FRAME]; /* local_copy in scaled Q_local*/ #endif /*---------------------------------------------------------* * Init local variables Loading @@ -82,6 +114,9 @@ void stat_noise_uv_mod_fx( move16(); min_alpha = 16384; move16(); #ifdef HQ_ALIGN_DUPLICATED_CODE L_Noimix_fract = 0; #endif test(); test(); Loading @@ -98,15 +133,23 @@ void stat_noise_uv_mod_fx( tmp_den = 31; move16(); tmp_shift = norm_s( tmp_den ); #ifndef HQ_ALIGN_DUPLICATED_CODE move16(); #endif L_tmp_res = L_deposit_h( noisiness ); L_tmp_res = L_shl( L_tmp_res, sub( tmp_shift, 1 ) ); tmp_den = shl( tmp_den, tmp_shift ); #ifndef HQ_ALIGN_DUPLICATED_CODE move16(); #endif tmp_res = div_l( L_tmp_res, tmp_den ); #ifndef HQ_ALIGN_DUPLICATED_CODE move16(); #endif min_alpha = add_sat( tmp_res, 16384 ); #ifndef HQ_ALIGN_DUPLICATED_CODE move16(); #endif /**st_min_alpha = sub(*st_min_alpha, 1638); move16();*/ min_alpha = s_max( min_alpha, sub( *st_min_alpha, 1638 ) ); Loading @@ -128,9 +171,17 @@ void stat_noise_uv_mod_fx( Copy( exc2, Exc2_local, L_FRAME ); /* bound Q for internal use, optimization possible */ #ifdef HQ_ALIGN_DUPLICATED_CODE Q_local = s_min( 11, s_max( -1, *Q_exc ) ); #else Q_local = s_min( 11, s_max( -1, Q_exc ) ); #endif /* local excitation Q and incoming excitation Q*/ #ifdef HQ_ALIGN_DUPLICATED_CODE Qdiff = sub( Q_local, *Q_exc ); #else Qdiff = sub( Q_local, Q_exc ); #endif /* only shift if incoming Q is outside [11..-1] shift is done in energy calculations aswell */ Scale_sig( Exc2_local, L_FRAME, Qdiff ); /* current excitation Q and previous stat_noise states Q */ Loading Loading @@ -229,14 +280,30 @@ void stat_noise_uv_mod_fx( L_tmp_res = L_mac( 0, alpha, alpha ); L_tmp_res = L_mac( L_tmp_res, alpha_m1, alpha_m1 ); tmp_den = round_fx( L_Frac_sqrtQ31( L_tmp_res ) ); #ifdef HQ_ALIGN_DUPLICATED_CODE IF( EQ_16( element_mode, EVS_MONO ) ) { tmp_nom = sub( 32767, tmp_den ); tmp_shift = norm_s( tmp_den ); tmp_den = shl( tmp_den, tmp_shift ); tmp_res = div_s( tmp_nom, tmp_den ); Noimix_fract = shr( tmp_res, tmp_shift ); /* float value is in range 0.0 to 0.42 */ } ELSE { Word16 exp_sqr = 0; move16(); tmp_res = BASOP_Util_Divide1616_Scale( 32767, tmp_den, &exp_sqr ); // 15-exp_sqr Noimix_fract = tmp_res; // 15-exp_sqr move16(); } #else tmp_nom = sub( 32767, tmp_den ); tmp_shift = norm_s( tmp_den ); tmp_den = shl( tmp_den, tmp_shift ); tmp_res = div_s( tmp_nom, tmp_den ); Noimix_fract = shr( tmp_res, tmp_shift ); /* float value is in range 0.0 to 0.42 */ #endif /* L_Ge might be 0 in unvoiced WB */ L_Ge = L_max( L_Ge, 1 ); tmp_shift = norm_l( L_Ge ); Loading @@ -245,8 +312,20 @@ void stat_noise_uv_mod_fx( L_tmp_res = Mult_32_16( *ge_sm, tmp_res ); /* Q_stat_noise_ge+45-Q_local-Q_ge-tmp_shift-15 */ L_tmp_res = Mult_32_16( L_tmp_res, sub( 32767, beta ) ); /*30-Q_local-tmp_shift+15-15 */ L_tmp_res = L_add_sat( L_shl_sat( L_tmp_res, sub( add( Q_local, tmp_shift ), 15 ) ), beta ); /* Q15 */ #ifdef HQ_ALIGN_DUPLICATED_CODE IF( EQ_16( element_mode, EVS_MONO ) ) { tmp_res = extract_h( L_shl_sat( L_tmp_res, 15 ) ); /* 15+15-16=14 */ Noimix_fract = extract_l( Mult_32_16( L_tmp_res, Noimix_fract ) ); /*15+15-15 */ } ELSE { L_Noimix_fract = Mult_32_16( L_tmp_res, Noimix_fract ); /*15+15-exp_sqr-15 =15-exp_sqr */ } #else tmp_res = extract_h( L_shl_sat( L_tmp_res, 15 ) ); /* 15+15-16=14 */ Noimix_fract = extract_l( Mult_32_16( L_tmp_res, Noimix_fract ) ); /*15+15-15 */ #endif FOR( i = 0; i < L_FRAME; i++ ) { Loading @@ -260,21 +339,68 @@ void stat_noise_uv_mod_fx( /* (1-alpha)*(float)sqrt(12.0f) * ((float)own_random(&(st->noimix_seed))/65536.0f) */ randval = Random( noimix_seed ); /* +/-32767 */ randval = mult_r( 28378, randval ); /* Q downscaled by 2 bits ends up in Q14 */ /*sqrt(12.0f) in Q13*/ #ifdef HQ_ALIGN_DUPLICATED_CODE randval = extract_l( L_shl( Mult_32_16( L_Ge, randval ), sub( 1, *Q_stat_noise_ge ) ) ); /*Q_local+Q_ge+14-15+1-Q_ge=Q_local */ #else randval = extract_l( L_shl( Mult_32_16( L_Ge, randval ), 1 - *Q_stat_noise_ge ) ); /*Q_local+Q_ge+14-15+1-Q_ge=Q_local */ #endif L_tmp = L_mult( Exc2_local[i], alpha ); /* Q_local + 16 */ L_tmp = L_mac( L_tmp, randval, alpha_m1 ); /* Q_local + 16 */ #ifdef HQ_ALIGN_DUPLICATED_CODE IF( EQ_16( element_mode, EVS_MONO ) ) { L_tmp3 = Mult_32_16( L_tmp, Noimix_fract ); /* Q_local+16+15-15 */ L_tmp = L_add_sat( L_tmp3, L_shl_sat( Mult_32_16( L_tmp, tmp_res ), 1 ) ); /* Q_local+16+14-15+1 */ Exc2_local[i] = extract_h( L_tmp ); /*Q_local */ move16(); } ELSE { L_tmp3 = Mult_32_32( L_tmp, L_Noimix_fract ); /* Q_local+16+15-exp_sqr-15 =Q_local +1 */ L_Exc2_local[i] = L_add( L_shr( L_tmp3, 1 ), Mpy_32_32( L_tmp, L_tmp_res ) ); // Q_local + 16 +15 -31 = Q_local move32(); } #else L_tmp3 = Mult_32_16( L_tmp, Noimix_fract ); /* Q_local+16+15-15 */ L_tmp = L_add_sat( L_tmp3, L_shl_sat( Mult_32_16( L_tmp, tmp_res ), 1 ) ); /* Q_local+16+14-15+1 */ Exc2_local[i] = extract_h( L_tmp ); /*Q_local */ move16(); #endif } #ifdef HQ_ALIGN_DUPLICATED_CODE IF( EQ_16( element_mode, EVS_MONO ) ) { *Q_stat_noise = Q_local; /* update for next call, routine can only be called once every frame */ move16(); Qdiff = sub( *Q_exc, Q_local ); /* local excitation and incoming excitation */ Scale_sig( Exc2_local, L_FRAME, Qdiff ); Copy( Exc2_local, exc2, L_FRAME ); } ELSE { Word32 max_val; maximum_abs_32_fx( L_Exc2_local, L_FRAME, &max_val ); Word16 shift = 0; move16(); IF( GT_32( max_val, ONE_IN_Q15 ) ) { shift = norm_l( max_val ); shift = sub( Q31 - Q15, shift ); *Q_exc = sub( Q_local, shift ); // Q_exc = Q_local -shift move16(); } *Q_stat_noise = Q_local; /* update for next call, routine can only be called once every frame */ move16(); Copy_Scale_sig_32_16( L_Exc2_local, exc2, L_FRAME, negate( shift ) ); // Q_exc } #else *Q_stat_noise = Q_local; /* update for next call, routine can only be called once every frame */ move16(); Qdiff = sub( Q_exc, Q_local ); /* local excitation and incoming excitation */ Scale_sig( Exc2_local, L_FRAME, Qdiff ); Copy( Exc2_local, exc2, L_FRAME ); #endif /*--------------------------------------------------------------------* * Generate low-pass filtered version of ISP coefficients *--------------------------------------------------------------------*/ Loading Loading @@ -324,6 +450,8 @@ void stat_noise_uv_mod_fx( } } } #ifndef HQ_ALIGN_DUPLICATED_CODE /*--------------------------------------------------------------------* * stat_noise_uv_mod() * Loading Loading @@ -629,6 +757,7 @@ void stat_noise_uv_mod_ivas_fx( } } } #endif /*---------------------------------------------------------------------------* * calc_tilt() Loading
lib_dec/acelp_core_dec_fx.c +6 −0 Original line number Diff line number Diff line Loading @@ -1439,9 +1439,15 @@ ivas_error acelp_core_dec_fx( IF( NE_16( st->nelp_mode_dec, 1 ) ) { /* modify the excitation signal of stationary unvoiced frames */ #ifdef HQ_ALIGN_DUPLICATED_CODE stat_noise_uv_mod_fx( st->element_mode, st->coder_type, 0, st->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, &st->Q_exc, 1, &st->ge_sm_fx, &st->uv_count, &st->act_count, st->lspold_s_fx, &st->noimix_seed, &st->min_alpha_fx, &st->exc_pe_fx, st->core_brate, st->bwidth, &st->Q_stat_noise, &st->Q_stat_noise_ge ); #else stat_noise_uv_mod_fx( st->coder_type, 0, st->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st->Q_exc, 1, &st->ge_sm_fx, &st->uv_count, &st->act_count, st->lspold_s_fx, &st->noimix_seed, &st->min_alpha_fx, &st->exc_pe_fx, st->core_brate, st->bwidth, &st->Q_stat_noise, &st->Q_stat_noise_ge ); #endif } } Loading
lib_dec/stat_noise_uv_dec_fx.c +8 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,13 @@ void stat_noise_uv_dec_fx( IF( !st_fx->Opt_AMR_WB ) { #ifdef HQ_ALIGN_DUPLICATED_CODE stat_noise_uv_mod_fx( st_fx->element_mode, coder_type, noisiness, st_fx->lsp_old_fx, lsp_new, lsp_mid, Aq, exc2, st_fx->Q_exc, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); #else IF( st_fx->element_mode > EVS_MONO ) { stat_noise_uv_mod_ivas_fx( coder_type, noisiness, st_fx->lsp_old_fx, lsp_new, lsp_mid, Aq, exc2, &st_fx->Q_exc, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, Loading @@ -90,6 +97,7 @@ void stat_noise_uv_dec_fx( &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); } #endif } Loading
lib_enc/stat_noise_uv_enc_fx.c +12 −0 Original line number Diff line number Diff line Loading @@ -97,9 +97,15 @@ void stat_noise_uv_enc_fx( * Modify the stationary noise excitation signal *-----------------------------------------------------------------*/ #ifdef HQ_ALIGN_DUPLICATED_CODE stat_noise_uv_mod_fx( st_fx->element_mode, st_fx->coder_type, noisiness, st_fx->lsp_old_fx, isp_new, isp_mid, Aq, exc2, &Q_new, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); #else stat_noise_uv_mod_fx( st_fx->coder_type, noisiness, st_fx->lsp_old_fx, isp_new, isp_mid, Aq, exc2, Q_new, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); #endif return; Loading Loading @@ -167,9 +173,15 @@ void stat_noise_uv_enc_ivas_fx( * Modify the stationary noise excitation signal *-----------------------------------------------------------------*/ #ifdef HQ_ALIGN_DUPLICATED_CODE stat_noise_uv_mod_fx( st_fx->element_mode, st_fx->coder_type, noisiness, st_fx->lsp_old_fx, isp_new, isp_mid, Aq, exc2, Q_new, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); #else stat_noise_uv_mod_ivas_fx( st_fx->coder_type, noisiness, st_fx->lsp_old_fx, isp_new, isp_mid, Aq, exc2, Q_new, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); #endif return; Loading