From 5cfa3ffe0a18d6e1338aacb1e78cea1256b986aa Mon Sep 17 00:00:00 2001 From: Andrea Eichenseer Date: Mon, 8 May 2023 13:54:21 +0200 Subject: [PATCH] Issue 440: Fix directional noise becoming diffuse in ParamISM, switch FIX_440_PARAM_ISM_DIR_NOISE --- lib_com/ivas_stat_com.h | 3 ++ lib_com/options.h | 2 ++ lib_enc/ivas_ism_param_enc.c | 70 ++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index c1e35d822c..305a18951a 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 9fe797240d..7b91fac70f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -177,6 +177,8 @@ #define FIX_435_ISM_MERGE_BUG /* Eri: Merge bug fix for ISM NULL metadata and tcx_only cases */ #define FIX_355_REFACTOR_PARAMBIN_TO_5MS /* Nokia: Fixes issue 355 by refactoring parametric binauralizer code to 5 ms mode */ +#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 32fb6af515..6534d215a5 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; } -- GitLab