Commit a69924e4 authored by reutelhuber's avatar reutelhuber
Browse files

some optimization for ACELP HB processing

parent 57196485
Loading
Loading
Loading
Loading
Loading
+65 −31
Original line number Diff line number Diff line
@@ -455,35 +455,71 @@ static void ivas_sba_dirac_stereo_upmix_hb(
    const int16_t mcmasa,                            /* i  : McMASA flag                        */
#ifdef SBA2MONO
    const int16_t sba_mono_flag,                     /* i  : flag for mono output               */
    const int16_t bwidth,                            /* i  : bandwidth of signal                */
#endif
    const STEREO_DFT_DEC_DATA_HANDLE hStereoDft      /* i : Stereo DFT handle for mixing matrix */
)
{
    int16_t i;
#ifdef SBA2MONO
    float gp, gm;
    float gain_fac;
#endif

    if ( !mcmasa )
    {
#ifdef SBA2MONO
        gain_fac = ( bwidth == FB ) ? 0.25f : 0.33f; /* last matrix element zero 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];
            for ( i = 0; i < output_frame / 2; i++ )
            {
                float 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];

                hb_stereo_synth[0][i] = hb_synth[i] * 0.25f * gp;
                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];
            for ( i = output_frame / 2; i < output_frame; i++ )
            {
                float 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];

                hb_stereo_synth[0][i] = hb_synth[i] * 0.25f * gp;
                hb_stereo_synth[0][i] = hb_synth[i] * gain_fac * gp;
            }
        }
        else
        {
#endif
            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];

            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];

            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;
            }

            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];

            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];

            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;
            }
        }
#else
        for ( i = 0; i < output_frame / 2; i++ )
        {
            float gp = hStereoDft->mixer_mat_smooth[0][0][8] + hStereoDft->mixer_mat_smooth[1][0][8] +
@@ -514,8 +550,6 @@ static void ivas_sba_dirac_stereo_upmix_hb(
            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;
        }
#ifdef SBA2MONO
        }
#endif
    }
    else
@@ -877,7 +911,7 @@ void ivas_sba_dirac_stereo_dec(

        ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth, hb_gain, output_frame,
#ifdef SBA2MONO
                                        ( st_ivas->sba_mode != SBA_MODE_SPAR || mcmasa ), sba_mono_flag, hStereoDft );
                                        ( st_ivas->sba_mode != SBA_MODE_SPAR || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft );
#else
                                        ( st_ivas->sba_mode != SBA_MODE_SPAR || mcmasa ), hStereoDft );
#endif