diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index c1e35d822c6d1482513a756a4fce6e3c4c26d04b..305a18951a2338d8d8d282cc81a5a88e4089ea39 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -164,6 +164,9 @@ typedef struct ivas_param_ism_data_structure int16_t flag_noisy_speech; int16_t noisy_speech_buffer[PARAM_ISM_HYS_BUF_SIZE]; +#ifdef FIX_440_PARAM_ISM_DIR_NOISE + int16_t flag_equal_energy; +#endif } PARAM_ISM_CONFIG_DATA, *PARAM_ISM_CONFIG_HANDLE; diff --git a/lib_com/options.h b/lib_com/options.h index 9c461d84e6698b8bad3cb76268bd3d7e99636239..78b765d30e8b0ff1bf9d3f907471e0052f331916 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -182,6 +182,8 @@ +#define FIX_440_PARAM_ISM_DIR_NOISE /* FhG: Issue 440: Fix directional background noise becoming diffuse in ParamISM */ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index 32fb6af515af26caf85c501e63eda9c167bb9abb..6534d215a5a8ea09fe7d5d533287c88bf3072f9d 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -55,6 +55,12 @@ static void ivas_param_ism_compute_obj_parameters( int16_t i, b, m, br, mr; int16_t brange_start, brange_end, mrange_start, mrange_end, time_merge_fac; float power_ratios_m[MAX_PARAM_ISM_NBANDS][MAX_PARAM_ISM_NBLOCKS]; +#ifdef FIX_440_PARAM_ISM_DIR_NOISE + float ref_power_local_frame[MAX_NUM_OBJECTS]; + float tmp_ratio; + + set_f( ref_power_local_frame, 0, MAX_NUM_OBJECTS ); +#endif assert( nchan_ism == 3 || nchan_ism == 4 ); @@ -90,6 +96,10 @@ static void ivas_param_ism_compute_obj_parameters( ref_power_local[i] += reference_power_obj[i][mr][br]; } } +#ifdef FIX_440_PARAM_ISM_DIR_NOISE + /* Sum up T/F tiles per object */ + ref_power_local_frame[i] += ref_power_local[i]; +#endif } /* find two dominant objects and derive object indices for current T/F tile */ @@ -145,6 +155,28 @@ static void ivas_param_ism_compute_obj_parameters( } } +#ifdef FIX_440_PARAM_ISM_DIR_NOISE + /* Check if objects have roughly equal power by comparing reference power of first object against all others*/ + hParamIsm->flag_equal_energy = 1; + for ( i = 1; i < nchan_ism; i++ ) + { + if ( ref_power_local_frame[i] != 0.0f ) + { + tmp_ratio = ref_power_local_frame[0] / ref_power_local_frame[i]; + + if ( ( tmp_ratio > 0.975f ) && ( tmp_ratio < 1.025f ) ) + { + hParamIsm->flag_equal_energy &= 1; + } + else + { + hParamIsm->flag_equal_energy &= 0; + break; + } + } + } +#endif + return; } @@ -426,6 +458,7 @@ void ivas_param_ism_compute_noisy_speech_flag( st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i] = st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i + 1]; } +#ifndef FIX_440_PARAM_ISM_DIR_NOISE /* For the current frame, make a decision based on some core-coder flags */ if ( st_ivas->hSCE[0]->hCoreCoder[0]->flag_noisy_speech_snr && st_ivas->hSCE[1]->hCoreCoder[0]->flag_noisy_speech_snr ) { @@ -454,7 +487,44 @@ void ivas_param_ism_compute_noisy_speech_flag( { st_ivas->hDirAC->hParamIsm->flag_noisy_speech = st_ivas->hDirAC->hParamIsm->flag_noisy_speech && st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i]; } +#else + /* Set flag_noisy_speech to 0 for cases where object energies are not roughly equal */ + if ( !st_ivas->hDirAC->hParamIsm->flag_equal_energy ) + { + st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i] = 0; + st_ivas->hDirAC->hParamIsm->flag_noisy_speech = 0; + } + else + { + /* For the current frame, make a decision based on some core-coder flags */ + if ( st_ivas->hSCE[0]->hCoreCoder[0]->flag_noisy_speech_snr && st_ivas->hSCE[1]->hCoreCoder[0]->flag_noisy_speech_snr ) + { +#ifdef FIX_422 + if ( st_ivas->hSCE[0]->hCoreCoder[0]->vad_flag || st_ivas->hSCE[1]->hCoreCoder[0]->vad_flag ) +#else + if ( st_ivas->hSCE[0]->hCoreCoder[0]->vad_flag && st_ivas->hSCE[1]->hCoreCoder[0]->vad_flag ) +#endif + { + st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i] = 0; + } + else + { + st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i] = 1; + } + } + else + { + st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i] = 0; + } + /* Do a decision based on hysteresis */ + st_ivas->hDirAC->hParamIsm->flag_noisy_speech = 1; + for ( i = 0; i < PARAM_ISM_HYS_BUF_SIZE; i++ ) + { + st_ivas->hDirAC->hParamIsm->flag_noisy_speech = st_ivas->hDirAC->hParamIsm->flag_noisy_speech && st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i]; + } + } +#endif return; }