Commit 11084088 authored by Vidhya V P's avatar Vidhya V P
Browse files

Added fb_mixer optimisation

parent 58a57c20
Loading
Loading
Loading
Loading
+134 −81
Original line number Diff line number Diff line
@@ -52,7 +52,11 @@ static void ivas_get_ld_fb_resp( float **ppIdeal_FRs_re, float **ppIdeal_FRs_im,
static int16_t ivas_fb_mixer_get_band_diff_non48k( const int32_t sampling_rate, const float delay_ms );
static const float *ivas_get_cheby_ramp( const int16_t delay );
static void ivas_get_hanning_win( const int16_t len, float *pH_win );
#ifdef SBA_BR_SWITCHING_CLEAN_UP
static ivas_error ivas_filterbank_setup( IVAS_FB_MIXER_HANDLE hFbMixer, const int32_t sampling_rate, const int16_t spar_reconfig_flag );
#else
static ivas_error ivas_filterbank_setup( IVAS_FB_MIXER_HANDLE hFbMixer, const int32_t sampling_rate );
#endif
static ivas_error ivas_fb_mixer_get_window( const int16_t fade_len, const int32_t sampling_rate, const float **pWindow );


@@ -175,6 +179,10 @@ ivas_error ivas_FB_mixer_open(
    IVAS_FB_MIXER_HANDLE *hFbMixer_out, /* i/o: FB mixer handle           */
    const int32_t sampling_rate,        /* i  : sampling rate             */
    IVAS_FB_CFG *fb_cfg                 /* i  : FB config. handle         */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ,
    const int16_t spar_reconfig_flag
#endif
)
{
    IVAS_FB_MIXER_HANDLE hFbMixer;
@@ -185,8 +193,11 @@ ivas_error ivas_FB_mixer_open(
    error = IVAS_ERR_OK;

    frame_len = (int16_t) ( sampling_rate / FRAMES_PER_SEC );


#ifdef SBA_BR_SWITCHING_CLEAN_UP
    hFbMixer = *hFbMixer_out;
    if ( !spar_reconfig_flag )
    {
#endif
        if ( ( hFbMixer = (IVAS_FB_MIXER_HANDLE) malloc( sizeof( IVAS_FB_MIXER_DATA ) ) ) == NULL )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
@@ -203,6 +214,9 @@ ivas_error ivas_FB_mixer_open(
        {
            hFbMixer->pFb = NULL;
        }
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    }
#endif
    if ( fb_cfg->active_w_mixing == -1 )
    {
        num_chs_alloc = 0;
@@ -274,7 +288,10 @@ ivas_error ivas_FB_mixer_open(
            }
        }
    }

#ifdef SBA_BR_SWITCHING_CLEAN_UP
    if ( !spar_reconfig_flag )
    {
#endif
        if ( fb_cfg->num_out_chans > 0 )
        {
            const int16_t *pActive_bins_per_band, *pActive_bins_per_band_abs, *pStart_offset, *pStart_offset_abs;
@@ -323,10 +340,15 @@ ivas_error ivas_FB_mixer_open(
            /* ignore all the deeper filter bank stuff for now */
            hFbMixer->num_diff_bands = 0;
        }

#ifdef SBA_BR_SWITCHING_CLEAN_UP
    }
#endif
    hFbMixer->fb_cfg = fb_cfg;

#ifdef SBA_BR_SWITCHING_CLEAN_UP
    if ( ( error = ivas_filterbank_setup( hFbMixer, sampling_rate, spar_reconfig_flag ) ) != IVAS_ERR_OK )
#else
    if ( ( error = ivas_filterbank_setup( hFbMixer, sampling_rate ) ) != IVAS_ERR_OK )
#endif
    {
        return error;
    }
@@ -346,6 +368,10 @@ ivas_error ivas_FB_mixer_open(
void ivas_FB_mixer_close(
    IVAS_FB_MIXER_HANDLE *hFbMixer_in, /* i/o: FB mixer handle          */
    const int32_t sampling_rate        /* i  : sampling rate in Hz      */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ,
    const int16_t spar_reconfig_flag
#endif
)
{
    IVAS_FB_MIXER_HANDLE hFbMixer;
@@ -404,7 +430,10 @@ void ivas_FB_mixer_close(
            free( hFbMixer->prior_mixer[0][0] );
            hFbMixer->prior_mixer[0][0] = NULL;
        }

#ifdef SBA_BR_SWITCHING_CLEAN_UP
        if ( !spar_reconfig_flag )
        {
#endif
            if ( fb_cfg->num_out_chans > 0 )
            {
                num_bands = hFbMixer->pFb->filterbank_num_bands;
@@ -433,21 +462,35 @@ void ivas_FB_mixer_close(
                    }
                }
            }

#ifdef SBA_BR_SWITCHING_CLEAN_UP
        }
#endif
#ifdef SBA_BR_SWITCHING_CLEAN_UP
        if ( !spar_reconfig_flag )
        {
#endif
            if ( hFbMixer->pFb != NULL )
            {
                free( hFbMixer->pFb );
                hFbMixer->pFb = NULL;
            }

#ifdef SBA_BR_SWITCHING_CLEAN_UP
        }
#endif
        if ( hFbMixer->fb_cfg != NULL )
        {
            free( hFbMixer->fb_cfg );
            hFbMixer->fb_cfg = NULL;
        }

#ifdef SBA_BR_SWITCHING_CLEAN_UP
        if ( !spar_reconfig_flag )
        {
#endif
            free( hFbMixer );
            hFbMixer = NULL;
#ifdef SBA_BR_SWITCHING_CLEAN_UP
        }
#endif
    }

    return;
@@ -1014,7 +1057,12 @@ static void ivas_get_active_bins(

static ivas_error ivas_filterbank_setup(
    IVAS_FB_MIXER_HANDLE hFbMixer,
    const int32_t sampling_rate )
    const int32_t sampling_rate
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ,
    const int16_t spar_reconfig_flag
#endif
)
{
    int16_t i, j;
    const float *pAll_fb_fr[2];
@@ -1053,7 +1101,10 @@ static ivas_error ivas_filterbank_setup(
    hFbMixer->cross_fade_end_offset = pCfg->fade_len + pCfg->pcm_offset;
    hFbMixer->cross_fade_start_offset = hFbMixer->cross_fade_end_offset - pCfg->fade_len;
    hFbMixer->ana_window_offset = pCfg->fb_latency + pCfg->pcm_offset;

#ifdef SBA_BR_SWITCHING_CLEAN_UP
    if ( !spar_reconfig_flag )
    {
#endif
        if ( ( error = ivas_fb_mixer_get_window( pCfg->fb_latency, sampling_rate, &( hFbMixer->pAna_window ) ) ) != IVAS_ERR_OK )
        {
            return error;
@@ -1063,7 +1114,9 @@ static ivas_error ivas_filterbank_setup(
        {
            return error;
        }

#ifdef SBA_BR_SWITCHING_CLEAN_UP
    }
#endif
    if ( pCfg->num_out_chans > 0 )
    {
        ivas_filterbank_t *pFb = hFbMixer->pFb;
+8 −0
Original line number Diff line number Diff line
@@ -5316,11 +5316,19 @@ ivas_error ivas_FB_mixer_open(
    IVAS_FB_MIXER_HANDLE *hFbMixer,                             /* i/o: FB mixer handle                             */
    const int32_t sampling_rate,                                /* i  : sampling rate                               */
    IVAS_FB_CFG *fb_cfg                                         /* i  : FB config. handle                           */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ,
    const int16_t spar_reconfig_flag
#endif
);

void ivas_FB_mixer_close( 
    IVAS_FB_MIXER_HANDLE *hFbMixer,                             /* i/o: FB mixer handle                             */
    const int32_t sampling_rate                                 /* i  : sampling rate in Hz                         */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ,
    const int16_t spar_reconfig_flag
#endif
);

void ivas_fb_mixer_pcm_ingest( 
+8 −0
Original line number Diff line number Diff line
@@ -116,7 +116,11 @@ ivas_error ivas_spar_dec_open(
    fb_cfg->remix_order = remix_order_set[hSpar->hMdDec->spar_md_cfg.remix_unmix_order];

    /* FB mixer handle */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    if ( ( error = ivas_FB_mixer_open( &hSpar->hFbMixer, output_Fs, fb_cfg, spar_reconfig_flag ) ) != IVAS_ERR_OK )
#else
    if ( ( error = ivas_FB_mixer_open( &hSpar->hFbMixer, output_Fs, fb_cfg ) ) != IVAS_ERR_OK )
#endif
    {
        return error;
    }
@@ -217,7 +221,11 @@ void ivas_spar_dec_close(
        ivas_spar_td_decorr_dec_close( &hSpar->hTdDecorr );

        /* FB mixer handle */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
        ivas_FB_mixer_close( &hSpar->hFbMixer, output_Fs, spar_reconfig_flag );
#else
        ivas_FB_mixer_close( &hSpar->hFbMixer, output_Fs );
#endif
#ifdef SBA_BR_SWITCHING_CLEAN_UP
        if ( !spar_reconfig_flag )
        {
+8 −0
Original line number Diff line number Diff line
@@ -104,7 +104,11 @@ ivas_error ivas_dirac_enc_open(
            return error;
        }
        /* Allocate and initialize FB mixer handle */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
        if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK )
#else
        if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), input_Fs, fb_cfg ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }
@@ -238,7 +242,11 @@ void ivas_dirac_enc_close(

    if ( hDirAC->hFbMixer != NULL )
    {
#ifdef SBA_BR_SWITCHING_CLEAN_UP
        ivas_FB_mixer_close( &hDirAC->hFbMixer, input_Fs, 0 );
#else
        ivas_FB_mixer_close( &hDirAC->hFbMixer, input_Fs );
#endif
    }

    for ( i = 0; i < DIRAC_MAX_ANA_CHANS; i++ )
+8 −0
Original line number Diff line number Diff line
@@ -281,7 +281,11 @@ ivas_error ivas_param_ism_enc_open(
    }

    /* Allocate and initialize FB mixer handle */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK )
#else
    if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), input_Fs, fb_cfg ) ) != IVAS_ERR_OK )
#endif
    {
        return error;
    }
@@ -322,7 +326,11 @@ void ivas_param_ism_enc_close(
    const int32_t input_Fs   /* i  : input sampling_rate          */
)
{
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ivas_FB_mixer_close( &hDirAC->hFbMixer, input_Fs, 0 );
#else
    ivas_FB_mixer_close( &hDirAC->hFbMixer, input_Fs );
#endif

    if ( hDirAC->hParamIsm != NULL )
    {
Loading