Loading lib_enc/vad_fx.c +83 −50 Original line number Diff line number Diff line Loading @@ -13,13 +13,17 @@ /*-----------------------------------------------------------------* * Local constants *-----------------------------------------------------------------*/ /* old fx constants */ #define HANGOVER_LONG 10 /* Hangover for CNG */ #define HANGOVER_LONG_HE 20 /* Hangover of CNG */ #define HANGOVER_LONG_NB 8 /* Hangover for CNG */ #define ACTIVE_FRAMES 3 /* Number of consecutive active SPEECH frames necessary to trigger HO */ /* SNR threshold curve constants for WB input */ #define SK16_2_FX 16930 /* Q14 (1.0333f)-> Linear function for clean speech */ #define SC16_2_FX -4608 /* Q8 (-18)*/ #define NK16_2_FX 13529 /* Q15 (.41287)-> Linear function for noisy speech */ #define NC16_2_FX 3394 /* Q8 (13.259625)*/ /* SNR threshold curve constants for NB input */ #define NK8_1_FX 3509 /*Q15 (0.1071f) Linear function for noisy speech */ #define NC8_1_FX 4224 /*Q8 (16.5f) */ Loading @@ -28,12 +32,14 @@ #define SIGN_THR_FX 40 /*Q4 (2.5f) Significanse threshold for per band snr calculation */ #define MIN_SNR_FX 2 /*Q4 Minimum snr used for per band snr calculation */ #define THR_M0_FX 3379 /* Q8 (13.2) Zero ofset for threshod */ #define THR_K_BG_FX -8192 /* Q15(-0.25) Coefficient for dependence on background level */ #define THR_K_BG_OFS_FX 5120 /* Q8 (20.0f) Zero offset for background level */ #define THR_K_SNR_FX 3277 /* Q15 (0.1f) Coefficient for dependence on SNR */ #define THR_K_EV_FX 18022 /* Q15 (0.55) Coefficient for dependence on noise variations */ #define HO_DTX_CLEAN 1 /* Hangover for dtx in clean conditions */ #define HO_DTX_NOISY 10 /* Hangover for dtx in noisy conditions */ #define HO_DTX_NOISY2 4 /* Hangover for dtx in very noisy conditions */ Loading @@ -41,6 +47,7 @@ #define ONE_LG10 2466 /* 1.0*log10(2) in Q13 */ #define HANGOVER_LONG_FX 10 /* Hangover for CNG */ #define HANGOVER_LONG_MUSIC_FX 20 /* Hangover of CNG */ #define HANGOVER_LONG_HE_FX 20 /* Hangover of CNG */ Loading @@ -54,6 +61,7 @@ #define TH16_2_NFLAG_FX 8960 /* Q8 (35) */ #define TH8_1_NFLAG_FX 8960 /* Q8 (35) */ #define SNR_OUTLIER_WGHT_1_FX 16384 /* Q14 (1.00)*/ #define SNR_OUTLIER_WGHT_2_FX 16548 /* Q14 (1.01)*/ #define SNR_OUTLIER_WGHT_3_FX 16712 /* Q14 (1.02)*/ Loading @@ -66,12 +74,7 @@ #define MAX_SNR_OUTLIER_3_FX 800 /*Q4 (50.0f)*/ /*-----------------------------------------------------------------* * vad_snr_log_fx() * * snr_sum = "scale" * (float)log10( L_snr_sum ) ; *-----------------------------------------------------------------*/ /* snr_sum = "scale" * (float)log10( L_snr_sum ) ;*/ /* o: Q8 */ static Word16 vad_snr_log_fx( Word32 L_snr, /* i : Q4 */ Loading @@ -85,7 +88,6 @@ static Word16 vad_snr_log_fx( f_snr = Log2_norm_lc( L_shl( L_snr, e_snr ) ); e_snr = sub( 30 - 4, e_snr ); L_tmp = Mpy_32_16( e_snr, f_snr, scale ); return round_fx( L_shl( L_tmp, 10 ) ); /* Q8 */ } Loading Loading @@ -167,17 +169,14 @@ void wb_vad_init_fx( move16(); hVAD->hangover_terminate_flag = 0; move16(); return; } /*-----------------------------------------------------------------* * sign_thr_snr_acc_fx() * * accumulate snr_sum with significance thresholds *-----------------------------------------------------------------*/ static void sign_thr_snr_acc_ivas_fx( Word32 *L_snr_sum, /* o : q_snr_sum */ Word16 *q_snr_sum, Loading @@ -200,11 +199,8 @@ static void sign_thr_snr_acc_ivas_fx( *q_snr_sum = sub( 31, exp_snr_sum ); move32(); move32(); return; } static void sign_thr_snr_acc_fx( Word32 *L_snr_sum, /* o : Q4 */ Word32 L_snr, /* i : Q4 */ Loading @@ -225,11 +221,8 @@ static void sign_thr_snr_acc_fx( /* Q4 */ move32(); BASOP_SATURATE_WARNING_ON_EVS return; } /*-----------------------------------------------------------------* * dtx_hangover_addition_fx() * Loading Loading @@ -454,7 +447,7 @@ Word16 dtx_hangover_addition_fx( * * Voice Activity Detector *-----------------------------------------------------------------*/ /* new simplified and harmonized code */ Word16 wb_vad_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 fr_bands[], /* i : per band input energy (contains 2 vectors) Q_new+QSCALE*/ Loading @@ -462,8 +455,8 @@ Word16 wb_vad_fx( Word16 *clean_speech_HO, /* o : SC-VBR clean speech HO flag */ Word16 *NB_speech_HO, /* o : SC-VBR NB speech HO flag */ Word16 *snr_sum_he, /* o : Output snr_sum as weighted spectral measure*/ Word16 *localVAD_HE_SAD, /* o : HE-SAD flag without hangover */ Word16 *flag_noisy_speech_snr, /* o : encoder detector for noisy speech */ Word16 *localVAD_HE_SAD, Word16 *flag_noisy_speech_snr, /* o : */ const Word16 Q_new, /* i : scaling factor Q0 */ VAD_HANDLE hVAD, /* i/o: VAD data handle */ NOISE_EST_HANDLE hNoiseEst, /* i : Noise estimation handle */ Loading Loading @@ -507,6 +500,7 @@ Word16 wb_vad_fx( Word16 snr_sum_HE_SAD; /*Q8 log */ Word16 sign_thr_HE_SAD, min_snr_HE_SAD; Word16 thr1_ol; Word32 L_snr_sum_ol; Word16 snr_sum_ol; /* Q8 log */ Loading Loading @@ -578,12 +572,11 @@ Word16 wb_vad_fx( last_7k2_coder_type = -1; move16(); } /*---------------------------------------------------------------------* * set SNR thresholds depending on the input bandwitdh *---------------------------------------------------------------------*/ IF( EQ_16( st_fx->max_band, 19 ) ) /* WB input or SWB input */ IF( EQ_16( st_fx->max_band, 19 ) ) /* WB input */ /* or SWB input */ { nk = 3277; move16(); /*0.1 Q15 */ Loading Loading @@ -613,8 +606,10 @@ Word16 wb_vad_fx( sign_thr_HE_SAD = 40; move16(); /* 2.5f Q4 */ ; min_snr_HE_SAD = 3; move16(); /* 0.2f Q4 */ ; } ELSE /* NB input */ { Loading @@ -635,19 +630,23 @@ Word16 wb_vad_fx( move16(); /* .25 *Q4 MIN_SNR */ sign_thr_HE_SAD = 42; move16(); /* 2.65f Q4 */ ; min_snr_HE_SAD = 1; move16(); /* 0.05f Q4 */ ; } hangover_short = 0; move16(); /* IF( st_fx->Opt_SC_VBR != 0 ) */ *noisy_speech_HO = 0; move16(); *clean_speech_HO = 0; move16(); *NB_speech_HO = 0; move16(); /* } */ /*---------------------------------------------------------------------* * compute SNR for each band & total Loading @@ -668,6 +667,7 @@ Word16 wb_vad_fx( move16(); } IF( snr_idx == 0 ) { stmp = 6; Loading @@ -681,6 +681,7 @@ Word16 wb_vad_fx( delta4 = 0; move16(); /*vad_thr = 2.4f*lp_snr - 42.2f; vad_thr = min(vad_thr, 80 ); */ Loading Loading @@ -748,6 +749,7 @@ Word16 wb_vad_fx( snr_sum_HE_SAD = 0; move16(); FOR( i = st_fx->min_band; i <= st_fx->max_band; i++ ) { ftmp = L_add( *pt1++, 0 ); Loading Loading @@ -833,12 +835,14 @@ Word16 wb_vad_fx( } L_snr = L_max( L_snr, 1 * ( 1 << 4 ) ); /* if ( snr[i] < 1 ){snr[i] = 1;}*/ /* snr[i] = (float)log10(snr[i]); */ snr = vad_snr_log_fx( L_snr, ONE_LG10 ); /* snr_sumt += snr[i];*/ snr_sumt = add( snr_sumt, shr( snr, 4 ) ); /*Q4 */ tmp = shl_sat( snr, 5 ); /* Q8 -> Q13 */ IF( LT_16( i, 2 ) ) { Loading Loading @@ -925,6 +929,7 @@ Word16 wb_vad_fx( L_snr = L_shr( snr_tmp, shift_snr ); /*L_snr in Q4*/ } /* conditional snrsum, snr_sum = snr_sum + snr[i];*/ sign_thr_snr_acc_fx( &L_snr_sum_HE_SAD, L_snr, sign_thr_HE_SAD, min_snr_HE_SAD ); sign_thr_snr_acc_fx( &L_snr_sum, L_snr, sign_thr, min_snr ); Loading Loading @@ -987,6 +992,7 @@ Word16 wb_vad_fx( } } /* Separated SNR_SUM outlier modification */ L_snr_sum_ol = L_snr_sum; /* snr_sum_ol = snr_sum; */ Loading @@ -997,6 +1003,7 @@ Word16 wb_vad_fx( { /* Update the total SNR only for WB signals */ /* corresponding float section if( (accum_ener_L > OUTLIER_THR_1 * accum_ener_H ) || (snr_outlier < MAX_SNR_OUTLIER_1) ) { Loading @@ -1016,6 +1023,7 @@ Word16 wb_vad_fx( test(); IF( LT_32( L_accum_ener_H, Mult_32_16( L_accum_ener_L, INV_OUTLIER_THR_1_FX ) ) /* float:: (accum_ener_L*INV_OUTLIER_THR_1 > accum_ener_H ) !!! */ || LT_32( L_snr_outlier, MAX_SNR_OUTLIER_1_FX ) ) { /* as weight1 is 1.0 we do not need to multiply here , i.e. no need to loose any precisison */ L_snr_sum_ol = L_sub( L_snr_sum_ol, L_snr_outlier ); /*Q4 */ Loading Loading @@ -1054,10 +1062,10 @@ Word16 wb_vad_fx( *snr_sum_he = snr_sum_HE_SAD; move16(); /* *snr_sum_he=snr_sum_HE_SAD; */ /*---------------------------------------------------------------------* * compute thr1 for SAD decision *---------------------------------------------------------------------*/ lp_snr = sub( lp_speech_fx, lp_noise_fx ); /*Q8*/ sub( 0, 0 ); Loading Loading @@ -1095,6 +1103,7 @@ Word16 wb_vad_fx( } } /*---------------------------------------------------------------------* * WB input * SNR threshold computing Loading @@ -1103,6 +1112,7 @@ Word16 wb_vad_fx( IF( NE_16( vad_bwidth_fx, NB ) ) { /* Outlier Detection first calculates thr1_ol and snr_sum_ol instead of modyfying thr1 and snr_sum */ Loading Loading @@ -1205,6 +1215,7 @@ Word16 wb_vad_fx( move16(); } IF( GT_16( hVAD->voiced_burst, 3 ) ) { IF( LT_16( hVAD->bcg_flux_fx, 640 ) ) /* Q4 */ Loading @@ -1219,12 +1230,14 @@ Word16 wb_vad_fx( } } hangover_hd = hangover_hd_tbl[snr_idx]; move16(); IF( LT_16( hVAD->bcg_flux_fx, 640 ) ) { hangover_hd = add( shr( hangover_hd, 1 ), 1 ); // move16(); } /* VAD hangover for he1 */ Loading Loading @@ -1261,6 +1274,7 @@ Word16 wb_vad_fx( move16(); } /* Calculate background stationarity */ test(); IF( flag_he1 == 0 && hNoiseEst->first_noise_updt > 0 ) Loading Loading @@ -1405,6 +1419,7 @@ Word16 wb_vad_fx( } } /* localVAD and vad_flag for HE-SAD - in parallel with normal localVAD and vad_flag */ *localVAD_HE_SAD = 0; Loading Loading @@ -1477,6 +1492,7 @@ Word16 wb_vad_fx( } } thr2 = sub( thr1_nb_mod, 384 ); /*thr2 = thr1 - 1.5f; , clean speech */ /* -dtx condition dependency in noisy speech */ Loading @@ -1492,6 +1508,7 @@ Word16 wb_vad_fx( thr2 = sub( thr1_nb_mod, tmp ); /*thr2 = thr1 - [ 1.10 || 1.3 ];*/ } flag = 0; move16(); if ( GT_16( snr_sum, thr1_nb_mod ) ) /* Speech assumed present, even though lowered thr1 */ Loading @@ -1500,6 +1517,7 @@ Word16 wb_vad_fx( move16(); } test(); IF( ( LT_16( snr_sum, thr1_nb_mod ) ) && ( GT_16( snr_sum, thr2 ) ) ) /* Speech present */ { Loading @@ -1518,6 +1536,7 @@ Word16 wb_vad_fx( move16(); /* needed for st_fx->vadnoise_fx update below */ } /* end of NB */ /* *flag_noisy_speech_snr is a Word8 parameter */ *flag_noisy_speech_snr = 0; /*_DIFF_FLOAT_FIX_IVAS -> this initialisation is not done here in float */ move16(); Loading Loading @@ -1628,6 +1647,7 @@ Word16 wb_vad_fx( move16(); } IF( L_and( hVAD->vad_prim_reg, (Word32) 0x8000L ) != 0 ) /* 0x8000L = 1L << 15 */ { hVAD->vad_prim_cnt_16 = sub( hVAD->vad_prim_cnt_16, 1 ); Loading Loading @@ -1655,8 +1675,8 @@ Word16 wb_vad_ivas_fx( Word16 *clean_speech_HO, /* o : SC-VBR clean speech HO flag */ Word16 *NB_speech_HO, /* o : SC-VBR NB speech HO flag */ Word16 *snr_sum_he, /* o : Output snr_sum as weighted spectral measure*/ Word16 *localVAD_HE_SAD, /* o : HE-SAD flag without hangover */ Word16 *flag_noisy_speech_snr, /* o : encoder detector for noisy speech */ Word16 *localVAD_HE_SAD, Word16 *flag_noisy_speech_snr, /* o : */ VAD_HANDLE hVAD, /* i/o: VAD data handle */ NOISE_EST_HANDLE hNoiseEst, /* i : Noise estimation handle */ Word16 lp_speech_fx, /* i : long term active speech energy average Q8 */ Loading Loading @@ -1787,12 +1807,11 @@ Word16 wb_vad_ivas_fx( last_7k2_coder_type = -1; move16(); } /*---------------------------------------------------------------------* * set SNR thresholds depending on the input bandwitdh *---------------------------------------------------------------------*/ IF( EQ_16( st_fx->max_band, 19 ) ) /* WB input or SWB input */ IF( EQ_16( st_fx->max_band, 19 ) ) /* WB input */ /* or SWB input */ { nk = 3277; move16(); /*0.1 Q15 */ Loading Loading @@ -1827,6 +1846,7 @@ Word16 wb_vad_ivas_fx( } ELSE /* NB input */ { // move16(); nk = 3277; move16(); /* 0.1 Q15 */ nc = 268435456; Loading Loading @@ -1879,6 +1899,7 @@ Word16 wb_vad_ivas_fx( move16(); } IF( snr_idx == 0 ) { stmp = 6; Loading @@ -1892,6 +1913,7 @@ Word16 wb_vad_ivas_fx( delta4 = 0; move32(); /*0.0f in Q16 */ /*vad_thr = 2.4f*lp_snr - 42.2f; vad_thr = min(vad_thr, 80 ); */ Loading Loading @@ -2249,6 +2271,7 @@ Word16 wb_vad_ivas_fx( test(); IF( LT_32( L_accum_ener_H, Mult_32_16( L_accum_ener_L, INV_OUTLIER_THR_1_FX ) ) /* float:: (accum_ener_L*INV_OUTLIER_THR_1 > accum_ener_H ) !!! */ || LT_32( L_snr_outlier_Q4, MAX_SNR_OUTLIER_1_FX ) ) { /* snr_sum_ol = SNR_OUTLIER_WGHT_1 * ( snr_sum_ol - snr_outlier ); As SNR_OUTLIER_WGHT_1 is 1.0f we do not need to multiply here , i.e. no need to loose any precisison */ Loading Loading @@ -2295,10 +2318,10 @@ Word16 wb_vad_ivas_fx( *snr_sum_he = snr_sum_HE_SAD; move16(); /* *snr_sum_he=snr_sum_HE_SAD; */ /*---------------------------------------------------------------------* * compute thr1 for SAD decision *---------------------------------------------------------------------*/ lp_snr = sub( lp_speech_fx, lp_noise_fx ); /*Q8*/ IF( LT_16( lp_snr, hNoiseEst->sign_dyn_lp_fx ) ) Loading Loading @@ -2346,6 +2369,7 @@ Word16 wb_vad_ivas_fx( } } /*---------------------------------------------------------------------* * WB input * SNR threshold computing Loading @@ -2354,6 +2378,7 @@ Word16 wb_vad_ivas_fx( IF( vad_bwidth_fx != NB ) { /* Outlier Detection first calculates thr1_ol and snr_sum_ol instead of modyfying thr1 and snr_sum */ Loading Loading @@ -2465,6 +2490,7 @@ Word16 wb_vad_ivas_fx( move16(); } IF( GT_16( hVAD->voiced_burst, 3 ) ) { IF( LT_16( hVAD->bcg_flux_fx, 640 ) ) /* Q4 */ Loading @@ -2479,6 +2505,7 @@ Word16 wb_vad_ivas_fx( } } hangover_hd = hangover_hd_tbl[snr_idx]; move16(); Loading Loading @@ -2521,6 +2548,7 @@ Word16 wb_vad_ivas_fx( move16(); } /* Calculate background stationarity */ test(); IF( flag_he1 == 0 && hNoiseEst->first_noise_updt > 0 ) Loading Loading @@ -2739,6 +2767,7 @@ Word16 wb_vad_ivas_fx( } } thr2 = sub( thr1_nb_mod, 384 ); /*thr2 = thr1 - 1.5f; , clean speech */ /* -dtx condition dependency in noisy speech */ Loading @@ -2754,6 +2783,7 @@ Word16 wb_vad_ivas_fx( thr2 = sub( thr1_nb_mod, tmp ); /*thr2 = thr1 - [ 1.10 || 1.3 ];*/ } flag = 0; move16(); IF( GT_16( snr_sum, thr1_nb_mod ) ) /* Speech assumed present, even though lowered thr1 */ Loading @@ -2762,6 +2792,7 @@ Word16 wb_vad_ivas_fx( move16(); } test(); IF( ( LT_16( snr_sum, thr1_nb_mod ) ) && ( GT_16( snr_sum, thr2 ) ) ) /* Speech present */ { Loading @@ -2780,6 +2811,7 @@ Word16 wb_vad_ivas_fx( move16(); /* needed for st_fx->vadnoise_fx update below */ } /* end of NB */ /* *flag_noisy_speech_snr is a Word8 parameter */ *flag_noisy_speech_snr = 0; /*_DIFF_FLOAT_FIX_IVAS -> this initialisation is not done here in float */ move16(); Loading Loading @@ -2891,6 +2923,7 @@ Word16 wb_vad_ivas_fx( move16(); } IF( L_and( hVAD->vad_prim_reg, (Word32) 0x8000L ) != 0 ) /* 0x8000L = 1L << 15 */ { hVAD->vad_prim_cnt_16 = sub( hVAD->vad_prim_cnt_16, 1 ); /*Q0*/ Loading Loading
lib_enc/vad_fx.c +83 −50 Original line number Diff line number Diff line Loading @@ -13,13 +13,17 @@ /*-----------------------------------------------------------------* * Local constants *-----------------------------------------------------------------*/ /* old fx constants */ #define HANGOVER_LONG 10 /* Hangover for CNG */ #define HANGOVER_LONG_HE 20 /* Hangover of CNG */ #define HANGOVER_LONG_NB 8 /* Hangover for CNG */ #define ACTIVE_FRAMES 3 /* Number of consecutive active SPEECH frames necessary to trigger HO */ /* SNR threshold curve constants for WB input */ #define SK16_2_FX 16930 /* Q14 (1.0333f)-> Linear function for clean speech */ #define SC16_2_FX -4608 /* Q8 (-18)*/ #define NK16_2_FX 13529 /* Q15 (.41287)-> Linear function for noisy speech */ #define NC16_2_FX 3394 /* Q8 (13.259625)*/ /* SNR threshold curve constants for NB input */ #define NK8_1_FX 3509 /*Q15 (0.1071f) Linear function for noisy speech */ #define NC8_1_FX 4224 /*Q8 (16.5f) */ Loading @@ -28,12 +32,14 @@ #define SIGN_THR_FX 40 /*Q4 (2.5f) Significanse threshold for per band snr calculation */ #define MIN_SNR_FX 2 /*Q4 Minimum snr used for per band snr calculation */ #define THR_M0_FX 3379 /* Q8 (13.2) Zero ofset for threshod */ #define THR_K_BG_FX -8192 /* Q15(-0.25) Coefficient for dependence on background level */ #define THR_K_BG_OFS_FX 5120 /* Q8 (20.0f) Zero offset for background level */ #define THR_K_SNR_FX 3277 /* Q15 (0.1f) Coefficient for dependence on SNR */ #define THR_K_EV_FX 18022 /* Q15 (0.55) Coefficient for dependence on noise variations */ #define HO_DTX_CLEAN 1 /* Hangover for dtx in clean conditions */ #define HO_DTX_NOISY 10 /* Hangover for dtx in noisy conditions */ #define HO_DTX_NOISY2 4 /* Hangover for dtx in very noisy conditions */ Loading @@ -41,6 +47,7 @@ #define ONE_LG10 2466 /* 1.0*log10(2) in Q13 */ #define HANGOVER_LONG_FX 10 /* Hangover for CNG */ #define HANGOVER_LONG_MUSIC_FX 20 /* Hangover of CNG */ #define HANGOVER_LONG_HE_FX 20 /* Hangover of CNG */ Loading @@ -54,6 +61,7 @@ #define TH16_2_NFLAG_FX 8960 /* Q8 (35) */ #define TH8_1_NFLAG_FX 8960 /* Q8 (35) */ #define SNR_OUTLIER_WGHT_1_FX 16384 /* Q14 (1.00)*/ #define SNR_OUTLIER_WGHT_2_FX 16548 /* Q14 (1.01)*/ #define SNR_OUTLIER_WGHT_3_FX 16712 /* Q14 (1.02)*/ Loading @@ -66,12 +74,7 @@ #define MAX_SNR_OUTLIER_3_FX 800 /*Q4 (50.0f)*/ /*-----------------------------------------------------------------* * vad_snr_log_fx() * * snr_sum = "scale" * (float)log10( L_snr_sum ) ; *-----------------------------------------------------------------*/ /* snr_sum = "scale" * (float)log10( L_snr_sum ) ;*/ /* o: Q8 */ static Word16 vad_snr_log_fx( Word32 L_snr, /* i : Q4 */ Loading @@ -85,7 +88,6 @@ static Word16 vad_snr_log_fx( f_snr = Log2_norm_lc( L_shl( L_snr, e_snr ) ); e_snr = sub( 30 - 4, e_snr ); L_tmp = Mpy_32_16( e_snr, f_snr, scale ); return round_fx( L_shl( L_tmp, 10 ) ); /* Q8 */ } Loading Loading @@ -167,17 +169,14 @@ void wb_vad_init_fx( move16(); hVAD->hangover_terminate_flag = 0; move16(); return; } /*-----------------------------------------------------------------* * sign_thr_snr_acc_fx() * * accumulate snr_sum with significance thresholds *-----------------------------------------------------------------*/ static void sign_thr_snr_acc_ivas_fx( Word32 *L_snr_sum, /* o : q_snr_sum */ Word16 *q_snr_sum, Loading @@ -200,11 +199,8 @@ static void sign_thr_snr_acc_ivas_fx( *q_snr_sum = sub( 31, exp_snr_sum ); move32(); move32(); return; } static void sign_thr_snr_acc_fx( Word32 *L_snr_sum, /* o : Q4 */ Word32 L_snr, /* i : Q4 */ Loading @@ -225,11 +221,8 @@ static void sign_thr_snr_acc_fx( /* Q4 */ move32(); BASOP_SATURATE_WARNING_ON_EVS return; } /*-----------------------------------------------------------------* * dtx_hangover_addition_fx() * Loading Loading @@ -454,7 +447,7 @@ Word16 dtx_hangover_addition_fx( * * Voice Activity Detector *-----------------------------------------------------------------*/ /* new simplified and harmonized code */ Word16 wb_vad_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 fr_bands[], /* i : per band input energy (contains 2 vectors) Q_new+QSCALE*/ Loading @@ -462,8 +455,8 @@ Word16 wb_vad_fx( Word16 *clean_speech_HO, /* o : SC-VBR clean speech HO flag */ Word16 *NB_speech_HO, /* o : SC-VBR NB speech HO flag */ Word16 *snr_sum_he, /* o : Output snr_sum as weighted spectral measure*/ Word16 *localVAD_HE_SAD, /* o : HE-SAD flag without hangover */ Word16 *flag_noisy_speech_snr, /* o : encoder detector for noisy speech */ Word16 *localVAD_HE_SAD, Word16 *flag_noisy_speech_snr, /* o : */ const Word16 Q_new, /* i : scaling factor Q0 */ VAD_HANDLE hVAD, /* i/o: VAD data handle */ NOISE_EST_HANDLE hNoiseEst, /* i : Noise estimation handle */ Loading Loading @@ -507,6 +500,7 @@ Word16 wb_vad_fx( Word16 snr_sum_HE_SAD; /*Q8 log */ Word16 sign_thr_HE_SAD, min_snr_HE_SAD; Word16 thr1_ol; Word32 L_snr_sum_ol; Word16 snr_sum_ol; /* Q8 log */ Loading Loading @@ -578,12 +572,11 @@ Word16 wb_vad_fx( last_7k2_coder_type = -1; move16(); } /*---------------------------------------------------------------------* * set SNR thresholds depending on the input bandwitdh *---------------------------------------------------------------------*/ IF( EQ_16( st_fx->max_band, 19 ) ) /* WB input or SWB input */ IF( EQ_16( st_fx->max_band, 19 ) ) /* WB input */ /* or SWB input */ { nk = 3277; move16(); /*0.1 Q15 */ Loading Loading @@ -613,8 +606,10 @@ Word16 wb_vad_fx( sign_thr_HE_SAD = 40; move16(); /* 2.5f Q4 */ ; min_snr_HE_SAD = 3; move16(); /* 0.2f Q4 */ ; } ELSE /* NB input */ { Loading @@ -635,19 +630,23 @@ Word16 wb_vad_fx( move16(); /* .25 *Q4 MIN_SNR */ sign_thr_HE_SAD = 42; move16(); /* 2.65f Q4 */ ; min_snr_HE_SAD = 1; move16(); /* 0.05f Q4 */ ; } hangover_short = 0; move16(); /* IF( st_fx->Opt_SC_VBR != 0 ) */ *noisy_speech_HO = 0; move16(); *clean_speech_HO = 0; move16(); *NB_speech_HO = 0; move16(); /* } */ /*---------------------------------------------------------------------* * compute SNR for each band & total Loading @@ -668,6 +667,7 @@ Word16 wb_vad_fx( move16(); } IF( snr_idx == 0 ) { stmp = 6; Loading @@ -681,6 +681,7 @@ Word16 wb_vad_fx( delta4 = 0; move16(); /*vad_thr = 2.4f*lp_snr - 42.2f; vad_thr = min(vad_thr, 80 ); */ Loading Loading @@ -748,6 +749,7 @@ Word16 wb_vad_fx( snr_sum_HE_SAD = 0; move16(); FOR( i = st_fx->min_band; i <= st_fx->max_band; i++ ) { ftmp = L_add( *pt1++, 0 ); Loading Loading @@ -833,12 +835,14 @@ Word16 wb_vad_fx( } L_snr = L_max( L_snr, 1 * ( 1 << 4 ) ); /* if ( snr[i] < 1 ){snr[i] = 1;}*/ /* snr[i] = (float)log10(snr[i]); */ snr = vad_snr_log_fx( L_snr, ONE_LG10 ); /* snr_sumt += snr[i];*/ snr_sumt = add( snr_sumt, shr( snr, 4 ) ); /*Q4 */ tmp = shl_sat( snr, 5 ); /* Q8 -> Q13 */ IF( LT_16( i, 2 ) ) { Loading Loading @@ -925,6 +929,7 @@ Word16 wb_vad_fx( L_snr = L_shr( snr_tmp, shift_snr ); /*L_snr in Q4*/ } /* conditional snrsum, snr_sum = snr_sum + snr[i];*/ sign_thr_snr_acc_fx( &L_snr_sum_HE_SAD, L_snr, sign_thr_HE_SAD, min_snr_HE_SAD ); sign_thr_snr_acc_fx( &L_snr_sum, L_snr, sign_thr, min_snr ); Loading Loading @@ -987,6 +992,7 @@ Word16 wb_vad_fx( } } /* Separated SNR_SUM outlier modification */ L_snr_sum_ol = L_snr_sum; /* snr_sum_ol = snr_sum; */ Loading @@ -997,6 +1003,7 @@ Word16 wb_vad_fx( { /* Update the total SNR only for WB signals */ /* corresponding float section if( (accum_ener_L > OUTLIER_THR_1 * accum_ener_H ) || (snr_outlier < MAX_SNR_OUTLIER_1) ) { Loading @@ -1016,6 +1023,7 @@ Word16 wb_vad_fx( test(); IF( LT_32( L_accum_ener_H, Mult_32_16( L_accum_ener_L, INV_OUTLIER_THR_1_FX ) ) /* float:: (accum_ener_L*INV_OUTLIER_THR_1 > accum_ener_H ) !!! */ || LT_32( L_snr_outlier, MAX_SNR_OUTLIER_1_FX ) ) { /* as weight1 is 1.0 we do not need to multiply here , i.e. no need to loose any precisison */ L_snr_sum_ol = L_sub( L_snr_sum_ol, L_snr_outlier ); /*Q4 */ Loading Loading @@ -1054,10 +1062,10 @@ Word16 wb_vad_fx( *snr_sum_he = snr_sum_HE_SAD; move16(); /* *snr_sum_he=snr_sum_HE_SAD; */ /*---------------------------------------------------------------------* * compute thr1 for SAD decision *---------------------------------------------------------------------*/ lp_snr = sub( lp_speech_fx, lp_noise_fx ); /*Q8*/ sub( 0, 0 ); Loading Loading @@ -1095,6 +1103,7 @@ Word16 wb_vad_fx( } } /*---------------------------------------------------------------------* * WB input * SNR threshold computing Loading @@ -1103,6 +1112,7 @@ Word16 wb_vad_fx( IF( NE_16( vad_bwidth_fx, NB ) ) { /* Outlier Detection first calculates thr1_ol and snr_sum_ol instead of modyfying thr1 and snr_sum */ Loading Loading @@ -1205,6 +1215,7 @@ Word16 wb_vad_fx( move16(); } IF( GT_16( hVAD->voiced_burst, 3 ) ) { IF( LT_16( hVAD->bcg_flux_fx, 640 ) ) /* Q4 */ Loading @@ -1219,12 +1230,14 @@ Word16 wb_vad_fx( } } hangover_hd = hangover_hd_tbl[snr_idx]; move16(); IF( LT_16( hVAD->bcg_flux_fx, 640 ) ) { hangover_hd = add( shr( hangover_hd, 1 ), 1 ); // move16(); } /* VAD hangover for he1 */ Loading Loading @@ -1261,6 +1274,7 @@ Word16 wb_vad_fx( move16(); } /* Calculate background stationarity */ test(); IF( flag_he1 == 0 && hNoiseEst->first_noise_updt > 0 ) Loading Loading @@ -1405,6 +1419,7 @@ Word16 wb_vad_fx( } } /* localVAD and vad_flag for HE-SAD - in parallel with normal localVAD and vad_flag */ *localVAD_HE_SAD = 0; Loading Loading @@ -1477,6 +1492,7 @@ Word16 wb_vad_fx( } } thr2 = sub( thr1_nb_mod, 384 ); /*thr2 = thr1 - 1.5f; , clean speech */ /* -dtx condition dependency in noisy speech */ Loading @@ -1492,6 +1508,7 @@ Word16 wb_vad_fx( thr2 = sub( thr1_nb_mod, tmp ); /*thr2 = thr1 - [ 1.10 || 1.3 ];*/ } flag = 0; move16(); if ( GT_16( snr_sum, thr1_nb_mod ) ) /* Speech assumed present, even though lowered thr1 */ Loading @@ -1500,6 +1517,7 @@ Word16 wb_vad_fx( move16(); } test(); IF( ( LT_16( snr_sum, thr1_nb_mod ) ) && ( GT_16( snr_sum, thr2 ) ) ) /* Speech present */ { Loading @@ -1518,6 +1536,7 @@ Word16 wb_vad_fx( move16(); /* needed for st_fx->vadnoise_fx update below */ } /* end of NB */ /* *flag_noisy_speech_snr is a Word8 parameter */ *flag_noisy_speech_snr = 0; /*_DIFF_FLOAT_FIX_IVAS -> this initialisation is not done here in float */ move16(); Loading Loading @@ -1628,6 +1647,7 @@ Word16 wb_vad_fx( move16(); } IF( L_and( hVAD->vad_prim_reg, (Word32) 0x8000L ) != 0 ) /* 0x8000L = 1L << 15 */ { hVAD->vad_prim_cnt_16 = sub( hVAD->vad_prim_cnt_16, 1 ); Loading Loading @@ -1655,8 +1675,8 @@ Word16 wb_vad_ivas_fx( Word16 *clean_speech_HO, /* o : SC-VBR clean speech HO flag */ Word16 *NB_speech_HO, /* o : SC-VBR NB speech HO flag */ Word16 *snr_sum_he, /* o : Output snr_sum as weighted spectral measure*/ Word16 *localVAD_HE_SAD, /* o : HE-SAD flag without hangover */ Word16 *flag_noisy_speech_snr, /* o : encoder detector for noisy speech */ Word16 *localVAD_HE_SAD, Word16 *flag_noisy_speech_snr, /* o : */ VAD_HANDLE hVAD, /* i/o: VAD data handle */ NOISE_EST_HANDLE hNoiseEst, /* i : Noise estimation handle */ Word16 lp_speech_fx, /* i : long term active speech energy average Q8 */ Loading Loading @@ -1787,12 +1807,11 @@ Word16 wb_vad_ivas_fx( last_7k2_coder_type = -1; move16(); } /*---------------------------------------------------------------------* * set SNR thresholds depending on the input bandwitdh *---------------------------------------------------------------------*/ IF( EQ_16( st_fx->max_band, 19 ) ) /* WB input or SWB input */ IF( EQ_16( st_fx->max_band, 19 ) ) /* WB input */ /* or SWB input */ { nk = 3277; move16(); /*0.1 Q15 */ Loading Loading @@ -1827,6 +1846,7 @@ Word16 wb_vad_ivas_fx( } ELSE /* NB input */ { // move16(); nk = 3277; move16(); /* 0.1 Q15 */ nc = 268435456; Loading Loading @@ -1879,6 +1899,7 @@ Word16 wb_vad_ivas_fx( move16(); } IF( snr_idx == 0 ) { stmp = 6; Loading @@ -1892,6 +1913,7 @@ Word16 wb_vad_ivas_fx( delta4 = 0; move32(); /*0.0f in Q16 */ /*vad_thr = 2.4f*lp_snr - 42.2f; vad_thr = min(vad_thr, 80 ); */ Loading Loading @@ -2249,6 +2271,7 @@ Word16 wb_vad_ivas_fx( test(); IF( LT_32( L_accum_ener_H, Mult_32_16( L_accum_ener_L, INV_OUTLIER_THR_1_FX ) ) /* float:: (accum_ener_L*INV_OUTLIER_THR_1 > accum_ener_H ) !!! */ || LT_32( L_snr_outlier_Q4, MAX_SNR_OUTLIER_1_FX ) ) { /* snr_sum_ol = SNR_OUTLIER_WGHT_1 * ( snr_sum_ol - snr_outlier ); As SNR_OUTLIER_WGHT_1 is 1.0f we do not need to multiply here , i.e. no need to loose any precisison */ Loading Loading @@ -2295,10 +2318,10 @@ Word16 wb_vad_ivas_fx( *snr_sum_he = snr_sum_HE_SAD; move16(); /* *snr_sum_he=snr_sum_HE_SAD; */ /*---------------------------------------------------------------------* * compute thr1 for SAD decision *---------------------------------------------------------------------*/ lp_snr = sub( lp_speech_fx, lp_noise_fx ); /*Q8*/ IF( LT_16( lp_snr, hNoiseEst->sign_dyn_lp_fx ) ) Loading Loading @@ -2346,6 +2369,7 @@ Word16 wb_vad_ivas_fx( } } /*---------------------------------------------------------------------* * WB input * SNR threshold computing Loading @@ -2354,6 +2378,7 @@ Word16 wb_vad_ivas_fx( IF( vad_bwidth_fx != NB ) { /* Outlier Detection first calculates thr1_ol and snr_sum_ol instead of modyfying thr1 and snr_sum */ Loading Loading @@ -2465,6 +2490,7 @@ Word16 wb_vad_ivas_fx( move16(); } IF( GT_16( hVAD->voiced_burst, 3 ) ) { IF( LT_16( hVAD->bcg_flux_fx, 640 ) ) /* Q4 */ Loading @@ -2479,6 +2505,7 @@ Word16 wb_vad_ivas_fx( } } hangover_hd = hangover_hd_tbl[snr_idx]; move16(); Loading Loading @@ -2521,6 +2548,7 @@ Word16 wb_vad_ivas_fx( move16(); } /* Calculate background stationarity */ test(); IF( flag_he1 == 0 && hNoiseEst->first_noise_updt > 0 ) Loading Loading @@ -2739,6 +2767,7 @@ Word16 wb_vad_ivas_fx( } } thr2 = sub( thr1_nb_mod, 384 ); /*thr2 = thr1 - 1.5f; , clean speech */ /* -dtx condition dependency in noisy speech */ Loading @@ -2754,6 +2783,7 @@ Word16 wb_vad_ivas_fx( thr2 = sub( thr1_nb_mod, tmp ); /*thr2 = thr1 - [ 1.10 || 1.3 ];*/ } flag = 0; move16(); IF( GT_16( snr_sum, thr1_nb_mod ) ) /* Speech assumed present, even though lowered thr1 */ Loading @@ -2762,6 +2792,7 @@ Word16 wb_vad_ivas_fx( move16(); } test(); IF( ( LT_16( snr_sum, thr1_nb_mod ) ) && ( GT_16( snr_sum, thr2 ) ) ) /* Speech present */ { Loading @@ -2780,6 +2811,7 @@ Word16 wb_vad_ivas_fx( move16(); /* needed for st_fx->vadnoise_fx update below */ } /* end of NB */ /* *flag_noisy_speech_snr is a Word8 parameter */ *flag_noisy_speech_snr = 0; /*_DIFF_FLOAT_FIX_IVAS -> this initialisation is not done here in float */ move16(); Loading Loading @@ -2891,6 +2923,7 @@ Word16 wb_vad_ivas_fx( move16(); } IF( L_and( hVAD->vad_prim_reg, (Word32) 0x8000L ) != 0 ) /* 0x8000L = 1L << 15 */ { hVAD->vad_prim_cnt_16 = sub( hVAD->vad_prim_cnt_16, 1 ); /*Q0*/ Loading