Commit 5cfa3ffe authored by eichenseer's avatar eichenseer
Browse files

Issue 440: Fix directional noise becoming diffuse in ParamISM, switch FIX_440_PARAM_ISM_DIR_NOISE

parent bc0f1537
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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;

+2 −0
Original line number Diff line number Diff line
@@ -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
+70 −0
Original line number Diff line number Diff line
@@ -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;
}