Commit c95c5c6f authored by reutelhuber's avatar reutelhuber
Browse files

fix gain overshoot in ACELP HB for SWB and also apply SWB changes to stereo

parent 8f88afc0
Loading
Loading
Loading
Loading
Loading
+35 −15
Original line number Diff line number Diff line
@@ -469,17 +469,25 @@ static void ivas_sba_dirac_stereo_upmix_hb(
    if ( !mcmasa )
    {
#ifdef SBA2MONO
        gain_fac = ( bwidth == FB ) ? 0.25f : 0.33f; /* last matrix element zero for SWB, divide by 3 instead of 4*/
        gain_fac = ( bwidth == FB ) ? 0.25f : 0.33f; /* last matrix element not used for SWB, divide by 3 instead of 4*/
        if ( sba_mono_flag )
        {
            gp = hStereoDft->mixer_mat_smooth[0][0][8] + hStereoDft->mixer_mat_smooth[0][0][9] +
                 hStereoDft->mixer_mat_smooth[0][0][10] + hStereoDft->mixer_mat_smooth[0][0][11];
                 hStereoDft->mixer_mat_smooth[0][0][10];
            if ( bwidth == FB )
            {
                gp += hStereoDft->mixer_mat_smooth[0][0][11];
            }
            for ( i = 0; i < output_frame / 2; i++ )
            {
                hb_stereo_synth[0][i] = hb_synth[i] * gain_fac * gp;
            }
            gp = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] +
                 hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS];
                 hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS];
            if ( bwidth == FB )
            {
                gp += hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS];
            }
            for ( i = output_frame / 2; i < output_frame; i++ )
            {
                hb_stereo_synth[0][i] = hb_synth[i] * gain_fac * gp;
@@ -489,34 +497,46 @@ static void ivas_sba_dirac_stereo_upmix_hb(
        {
            gp = hStereoDft->mixer_mat_smooth[0][0][8] + hStereoDft->mixer_mat_smooth[1][0][8] +
                 hStereoDft->mixer_mat_smooth[0][0][9] + hStereoDft->mixer_mat_smooth[1][0][9] +
                 hStereoDft->mixer_mat_smooth[0][0][10] + hStereoDft->mixer_mat_smooth[1][0][10] +
                 hStereoDft->mixer_mat_smooth[0][0][11] + hStereoDft->mixer_mat_smooth[1][0][11];
                 hStereoDft->mixer_mat_smooth[0][0][10] + hStereoDft->mixer_mat_smooth[1][0][10];
            if ( bwidth == FB )
            {
                gp += hStereoDft->mixer_mat_smooth[0][0][11] + hStereoDft->mixer_mat_smooth[1][0][11];
            }

            gm = hStereoDft->mixer_mat_smooth[0][0][8] - hStereoDft->mixer_mat_smooth[1][0][8] +
                 hStereoDft->mixer_mat_smooth[0][0][9] - hStereoDft->mixer_mat_smooth[1][0][9] +
                 hStereoDft->mixer_mat_smooth[0][0][10] - hStereoDft->mixer_mat_smooth[1][0][10] +
                 hStereoDft->mixer_mat_smooth[0][0][11] - hStereoDft->mixer_mat_smooth[1][0][11];
                 hStereoDft->mixer_mat_smooth[0][0][10] - hStereoDft->mixer_mat_smooth[1][0][10];
            if ( bwidth == FB )
            {
                gm += hStereoDft->mixer_mat_smooth[0][0][11] - hStereoDft->mixer_mat_smooth[1][0][11];
            }

            for ( i = 0; i < output_frame / 2; i++ )
            {
                hb_stereo_synth[0][i] = 0.5f * hb_synth[i] * 0.25f * gp;
                hb_stereo_synth[1][i] = 0.5f * hb_synth[i] * 0.25f * gm;
                hb_stereo_synth[0][i] = 0.5f * hb_synth[i] * gain_fac * gp;
                hb_stereo_synth[1][i] = 0.5f * hb_synth[i] * gain_fac * gm;
            }

            gp = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][8 + IVAS_MAX_NUM_BANDS] +
                 hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][9 + IVAS_MAX_NUM_BANDS] +
                 hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS] +
                 hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS];
                 hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS];
            if ( bwidth == FB )
            {
                gp += hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS];
            }

            gm = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][8 + IVAS_MAX_NUM_BANDS] +
                 hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][9 + IVAS_MAX_NUM_BANDS] +
                 hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS] +
                 hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS];
                 hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS];
            if ( bwidth == FB )
            {
                gm += hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS];
            }

            for ( i = output_frame / 2; i < output_frame; i++ )
            {
                hb_stereo_synth[0][i] = 0.5f * hb_synth[i] * 0.25f * gp;
                hb_stereo_synth[1][i] = 0.5f * hb_synth[i] * 0.25f * gm;
                hb_stereo_synth[0][i] = 0.5f * hb_synth[i] * gain_fac * gp;
                hb_stereo_synth[1][i] = 0.5f * hb_synth[i] * gain_fac * gm;
            }
        }
#else