diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 7b359e2f40ff80ab3db4a1848c9f0e3a781f28d6..8c986b363abb499b01f02f4bfdd211ff980e635a 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -1532,7 +1532,10 @@ typedef enum _DCTTYPE #define TOD_NSPEC 80 /* number of spectral bins of the tonal detector */ #define TOD_THR_MASS 0.86f /* initial value for the adaptive threshold of the tonal detector */ #define P2A_FACT 0.9f /* long-term averaging factor for peak-to-average ratio */ -#define THR_P2A 80.0f /* threshold to detect strongly peaky signals */ +#ifdef FIX_SP2A +#define THR_P2A_HIGH 95.0f /* higher threshold to detect strongly peaky signals at low bitrates*/ +#endif +#define THR_P2A 80.0f /* lower threshold to detect strongly peaky signals at higher bitrates */ /*----------------------------------------------------------------------------------* * LD music post-filter constants diff --git a/lib_com/options.h b/lib_com/options.h index 10f0df15a20a4ed32653dc45df1c9c28974d2bf6..aecaf8747a1464a0df9d4328168d334a77aeb7ff 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -162,6 +162,7 @@ #define FIX_406_IVAS_POSITION /* Eri: Issue 406: Unify IVAS_POSITION to use IVAS_VECTOR3 instead */ #define REND_DEBUGGING_REVISION /* VA: encapsulate rendering debugging options with DEBUGGING */ #define FIX_416_ISM_BR_SWITCHING /* FhG: add missing CLDFB reconfig to ISM BR switching */ +#define FIX_SP2A /* VA: Issue 412: Adjust threshold for the S_p2a feature in the tonal detector */ diff --git a/lib_enc/speech_music_classif.c b/lib_enc/speech_music_classif.c index cf8568e649db982127b0cd978a935d7f28b97b2f..80bd2d6d2a8cc8aeb9c7d334e13959d824c0736e 100644 --- a/lib_enc/speech_music_classif.c +++ b/lib_enc/speech_music_classif.c @@ -1828,6 +1828,9 @@ void ivas_smc_mode_selection( float ton; int16_t i; float S_p2a, S_max, S_ave; +#ifdef FIX_SP2A + float thr_sp2a; +#endif SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas; @@ -1858,8 +1861,23 @@ void ivas_smc_mode_selection( S_ave = sum_f( st->hSpMusClas->tod_lt_Bin_E, TOD_NSPEC ) / TOD_NSPEC; S_p2a = S_max - S_ave; +#ifdef FIX_SP2A + if ( element_brate <= IVAS_16k4 ) + { + thr_sp2a = THR_P2A_HIGH; + } + else + { + thr_sp2a = THR_P2A; + } +#endif + /* initial 3-way selection of coding modes (ACELP/GSC/TCX) */ +#ifdef FIX_SP2A + if ( relE > -10.0f && ( S_p2a > thr_sp2a || ton > hSpMusClas->tod_thr_lt ) ) +#else if ( relE > -10.0f && ( S_p2a > THR_P2A || ton > hSpMusClas->tod_thr_lt ) ) +#endif { /* select TCX to encode extremely peaky signals or strongly tonal signals */ st->sp_aud_decision1 = 1;