Commit 6adb3df6 authored by vaclav's avatar vaclav
Browse files

unify 'pState' and 'hSpar' handle names; use the proper handle name as much as possible

parent bb4b1d00
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@
 *-----------------------------------------------------------------------------------------*/

static void ivas_set_up_cov_smoothing(
    ivas_cov_smooth_state_t *pState,
    ivas_cov_smooth_state_t *hCovState,
    ivas_filterbank_t *pFb,
    const float max_update_rate,
    const int16_t min_pool_size )
@@ -63,15 +63,16 @@ static void ivas_set_up_cov_smoothing(
            update_factor += pFb->fb_bin_to_band.pFb_bin_to_band[j][k];
        }

        pState->pSmoothing_factor[j] = update_factor / min_pool_size;
        hCovState->pSmoothing_factor[j] = update_factor / min_pool_size;

        if ( pState->pSmoothing_factor[j] > max_update_rate )
        if ( hCovState->pSmoothing_factor[j] > max_update_rate )
        {
            pState->pSmoothing_factor[j] = max_update_rate;
            hCovState->pSmoothing_factor[j] = max_update_rate;
        }
    }

    pState->prior_bank_idx = -1;
    hCovState->prior_bank_idx = -1;

    return;
}

+6 −6
Original line number Diff line number Diff line
@@ -99,21 +99,21 @@ static ivas_error ivas_hrtf_init(
 *------------------------------------------------------------------------*/

static ivas_error ivas_hrtf_open(
    HRTFS_HANDLE *hHrtf /* o  : HRTF handle     */
    HRTFS_HANDLE *hHrtf_out /* o  : HRTF handle     */
)
{
    HRTFS_HANDLE pState;
    HRTFS_HANDLE hHrtf;

    if ( *hHrtf == NULL )
    if ( *hHrtf_out == NULL )
    {
        if ( ( pState = (HRTFS_HANDLE) count_malloc( sizeof( HRTFS_DATA ) ) ) == NULL )
        if ( ( hHrtf = (HRTFS_HANDLE) count_malloc( sizeof( HRTFS_DATA ) ) ) == NULL )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR decoder\n" );
        }

        ivas_hrtf_init( pState );
        ivas_hrtf_init( hHrtf );

        *hHrtf = pState;
        *hHrtf_out = hHrtf;
    }
    else
    {
+13 −13
Original line number Diff line number Diff line
@@ -140,7 +140,7 @@ void ivas_reverb_prepare_cldfb_params(
 *-----------------------------------------------------------------------------------------*/

static void ivas_cldfb_convolver(
    cldfb_convolver_state *pState,                                  /* pointer to convolver state structure   */
    cldfb_convolver_state *convolver_state,                         /* i/o: pointer to convolver state structure  */
    float out_CLDFB_real[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* o  : real part of binaural signals         */
    float out_CLDFB_imag[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* o  : imag part of binaural signals         */
    float in_CLDFB_real[CLDFB_NO_CHANNELS_MAX],                     /* i  : real part of input signals            */
@@ -161,13 +161,13 @@ static void ivas_cldfb_convolver(
        out_imag_left = 0.0f;
        out_imag_right = 0.0f;

        filter_states_real_ptr = (float *) &( pState->filter_states_re[band_idx][0] );
        filter_states_imag_ptr = (float *) &( pState->filter_states_im[band_idx][0] );
        filter_states_real_ptr = (float *) &( convolver_state->filter_states_re[band_idx][0] );
        filter_states_imag_ptr = (float *) &( convolver_state->filter_states_im[band_idx][0] );

        filter_taps_left_re_ptr = pState->filter_taps_left_re[band_idx];
        filter_taps_left_im_ptr = pState->filter_taps_left_im[band_idx];
        filter_taps_right_re_ptr = pState->filter_taps_right_re[band_idx];
        filter_taps_right_im_ptr = pState->filter_taps_right_im[band_idx];
        filter_taps_left_re_ptr = convolver_state->filter_taps_left_re[band_idx];
        filter_taps_left_im_ptr = convolver_state->filter_taps_left_im[band_idx];
        filter_taps_right_re_ptr = convolver_state->filter_taps_right_re[band_idx];
        filter_taps_right_im_ptr = convolver_state->filter_taps_right_im[band_idx];

        for ( tap_idx = num_taps - 1; tap_idx > 0; tap_idx-- )
        {
+8 −7
Original line number Diff line number Diff line
@@ -316,9 +316,11 @@ void ivas_sba_mix_matrix_determiner(
{
    int16_t i, ch;
    float temp;
    SPAR_DEC_HANDLE pState;
    SPAR_DEC_HANDLE hSpar;
    int16_t num_bands_out, nchan_transport, nchan_out;

    hSpar = st_ivas->hSpar;

    /* Convert numeric range */
    for ( ch = 0; ch < nchan_remapped; ch++ )
    {
@@ -341,10 +343,9 @@ void ivas_sba_mix_matrix_determiner(
    }

    /* AGC */    
    pState = st_ivas->hSpar;
    nchan_transport = pState->hMdDec->spar_md_cfg.nchan_transport;
    nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport;
    nchan_out = nchan_transport;
    ivas_agc_dec_process( pState->hAgcDec, output, output, nchan_transport, output_frame );
    ivas_agc_dec_process( hSpar->hAgcDec, output, output, nchan_transport, output_frame );

    /* Convert numeric range back */
    for ( ch = 0; ch < nchan_out; ch++ )
@@ -356,8 +357,8 @@ void ivas_sba_mix_matrix_determiner(
    }

    /* Mixing matrix determiner */
    num_bands_out = pState->hFbMixer->pFb->filterbank_num_bands;
    ivas_spar_dec_gen_umx_mat( pState->hMdDec, nchan_transport, num_bands_out, st_ivas->bfi );
    num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands;
    ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, st_ivas->bfi );

    wmops_sub_end();

+45 −46
Original line number Diff line number Diff line
@@ -202,7 +202,6 @@ void ivas_spar_dec_close(
        /* Covar. State handle */
        ivas_spar_td_decorr_dec_close( &hSpar->hTdDecorr );


        /* FB mixer handle */
        ivas_FB_mixer_close( &hSpar->hFbMixer, output_Fs );

@@ -215,6 +214,7 @@ void ivas_spar_dec_close(
            count_free( hSpar->hPCA );
            hSpar->hPCA = NULL;
        }

        count_free( hSpar );
        hSpar = NULL;
    }
@@ -622,7 +622,7 @@ static void ivas_spar_dec_MD(
    int16_t num_channels, table_idx, num_bands_out, bfi, sba_order;
    int32_t ivas_total_brate;
    DECODER_CONFIG_HANDLE hDecoderConfig = st_ivas->hDecoderConfig;
    SPAR_DEC_HANDLE pState = st_ivas->hSpar;
    SPAR_DEC_HANDLE hSpar = st_ivas->hSpar;

    wmops_sub_start( "ivas_spar_dec_MD" );

@@ -634,7 +634,7 @@ static void ivas_spar_dec_MD(
    bfi = st_ivas->bfi;
    ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
    num_channels = ivas_sba_get_nchan_metadata( sba_order );
    num_bands_out = pState->hFbMixer->pFb->filterbank_num_bands;
    num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands;

    if ( ivas_total_brate > FRAME_NO_DATA && !bfi )
    {
@@ -642,14 +642,14 @@ static void ivas_spar_dec_MD(
        {
            ivas_parse_spar_header( hDecoderConfig->ivas_total_brate, sba_order, st0, &table_idx );

            pState->hMdDec->spar_md.num_bands = min( SPAR_DIRAC_SPLIT_START_BAND, IVAS_MAX_NUM_BANDS );
            hSpar->hMdDec->spar_md.num_bands = min( SPAR_DIRAC_SPLIT_START_BAND, IVAS_MAX_NUM_BANDS );

            if ( pState->hMdDec->table_idx != table_idx )
            if ( hSpar->hMdDec->table_idx != table_idx )
            {
                pState->hMdDec->table_idx = table_idx;
                pState->hTdDecorr->ducking_flag = ivas_spar_br_table_consts[table_idx].td_ducking;
                hSpar->hMdDec->table_idx = table_idx;
                hSpar->hTdDecorr->ducking_flag = ivas_spar_br_table_consts[table_idx].td_ducking;

                ivas_spar_md_dec_init( pState->hMdDec, hDecoderConfig, num_channels );
                ivas_spar_md_dec_init( hSpar->hMdDec, hDecoderConfig, num_channels );
            }
        }

@@ -664,17 +664,17 @@ static void ivas_spar_dec_MD(
         *---------------------------------------------------------------------*/

#ifdef SBA_CLEANING
        if ( pState->hPCA != NULL )
        if ( hSpar->hPCA != NULL )
#else
        if ( hDecoderConfig->ivas_total_brate == PCA_BRATE && sba_order == 1 )
#endif
        {
            ivas_pca_read_bits( st0, pState->hPCA );
            ivas_pca_read_bits( st0, hSpar->hPCA );
        }
#ifndef SBA_CLEANING
        else
        {
            pState->hPCA->pca_bypass = PCA_MODE_INACTIVE;
            hSpar->hPCA->pca_bypass = PCA_MODE_INACTIVE;
        }
#endif

@@ -682,34 +682,34 @@ static void ivas_spar_dec_MD(
         * Read AGC bits
         *---------------------------------------------------------------------*/

        if ( ivas_total_brate > IVAS_SID_5k && !bfi && pState->hMdDec->dtx_vad )
        if ( ivas_total_brate > IVAS_SID_5k && !bfi && hSpar->hMdDec->dtx_vad )
        {
            pState->AGC_flag = get_next_indice( st0, 1 );
            hSpar->AGC_flag = get_next_indice( st0, 1 );

            ivas_agc_read_bits( pState->hAgcDec, st0, pState->hMdDec->spar_md_cfg.nchan_transport, pState->AGC_flag );
            ivas_agc_read_bits( hSpar->hAgcDec, st0, hSpar->hMdDec->spar_md_cfg.nchan_transport, hSpar->AGC_flag );
        }

        /*---------------------------------------------------------------------*
         * MD smoothing
         *---------------------------------------------------------------------*/

        if ( st0->m_old_frame_type == ZERO_FRAME && ivas_total_brate == IVAS_SID_5k && st0->prev_bfi == 0 && pState->hMdDec->spar_md_cfg.nchan_transport == 1 )
        if ( st0->m_old_frame_type == ZERO_FRAME && ivas_total_brate == IVAS_SID_5k && st0->prev_bfi == 0 && hSpar->hMdDec->spar_md_cfg.nchan_transport == 1 )
        {
            ivas_spar_setup_md_smoothing( pState->hMdDec, num_bands_out );
            ivas_spar_setup_md_smoothing( hSpar->hMdDec, num_bands_out );
        }
        else
        {
            ivas_spar_update_md_hist( pState->hMdDec );
            ivas_spar_update_md_hist( hSpar->hMdDec );
        }
    }
    else
    {
        if ( !bfi )
        {
            ivas_spar_smooth_md_dtx( pState->hMdDec, num_bands_out );
            ivas_spar_smooth_md_dtx( hSpar->hMdDec, num_bands_out );
        }

        set_s( pState->hMdDec->valid_bands, 0, IVAS_MAX_NUM_BANDS );
        set_s( hSpar->hMdDec->valid_bands, 0, IVAS_MAX_NUM_BANDS );
    }

    wmops_sub_end();
@@ -731,7 +731,6 @@ static float ivas_spar_get_cldfb_slot_gain(
    int16_t *time_slot_idx1,
    float *weight_lowfreq )
{
    SPAR_DEC_HANDLE pState = hSpar;
    float weight;
    float output_Fs, encfb_delay, decfb_delay;
    float xfade_start_ns;
@@ -739,12 +738,12 @@ static float ivas_spar_get_cldfb_slot_gain(
    int16_t i_hist;
    int16_t split_band;

    *weight_lowfreq = pState->hFbMixer->cldfb_cross_fade[time_slot_idx];
    *weight_lowfreq = hSpar->hFbMixer->cldfb_cross_fade[time_slot_idx];

    output_Fs = (float) hDecoderConfig->output_Fs;
    encfb_delay = IVAS_FB_ENC_DELAY_NS;
    decfb_delay = IVAS_FB_DEC_DELAY_NS;
    xfade_start_ns = pState->hFbMixer->cross_fade_start_offset / output_Fs * 1000000000.f - encfb_delay + decfb_delay * 0.5f;
    xfade_start_ns = hSpar->hFbMixer->cross_fade_start_offset / output_Fs * 1000000000.f - encfb_delay + decfb_delay * 0.5f;
    xfade_delay_subframes = (int16_t) ( xfade_start_ns / ( FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ) );

    i_hist = 4 - xfade_delay_subframes;
@@ -766,8 +765,8 @@ static float ivas_spar_get_cldfb_slot_gain(
    else
    {
        /* determine cross-fade gain for current frame Parameters*/
        *time_slot_idx0 = pState->hFbMixer->cldfb_cross_fade_start;
        *time_slot_idx1 = pState->hFbMixer->cldfb_cross_fade_end;
        *time_slot_idx0 = hSpar->hFbMixer->cldfb_cross_fade_start;
        *time_slot_idx1 = hSpar->hFbMixer->cldfb_cross_fade_end;
        weight = *weight_lowfreq;
    }

@@ -904,15 +903,14 @@ void ivas_spar_dec_upmixer(
    float mixer_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS];
    int16_t b_skip_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
    DECODER_CONFIG_HANDLE hDecoderConfig;
    SPAR_DEC_HANDLE pState, hSpar;
    SPAR_DEC_HANDLE hSpar;

    wmops_sub_start( "ivas_spar_dec_upmixer" );

    hSpar = st_ivas->hSpar;
    pState = hSpar;
    hDecoderConfig = st_ivas->hDecoderConfig;
    num_bands_out = pState->hFbMixer->pFb->filterbank_num_bands;
    nchan_transport = pState->hMdDec->spar_md_cfg.nchan_transport;
    num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands;
    nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport;

    num_cldfb_bands = hSpar->hFbMixer->pFb->fb_bin_to_band.num_cldfb_bands;
    numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans;
@@ -958,7 +956,8 @@ void ivas_spar_dec_upmixer(
     * AGC
     *---------------------------------------------------------------------*/

    ivas_agc_dec_process( pState->hAgcDec, output, output, nchan_transport, output_frame );
    ivas_agc_dec_process( hSpar->hAgcDec, output, output, nchan_transport, output_frame );

#ifdef DEBUG_SBA_AUDIO_DUMP
    int16_t l;
    float largest_value;
@@ -982,7 +981,7 @@ void ivas_spar_dec_upmixer(
     * TD Decorr and pcm ingest
     *---------------------------------------------------------------------*/

    if ( pState->hMdDec->td_decorr_flag )
    if ( hSpar->hMdDec->td_decorr_flag )
    {
        num_in_ingest = nchan_internal;
    }
@@ -1001,10 +1000,10 @@ void ivas_spar_dec_upmixer(
     *---------------------------------------------------------------------*/

#ifdef SBA_CLEANING
    if ( pState->hPCA != NULL )
    if ( hSpar->hPCA != NULL )
#endif
    {
        ivas_pca_dec( pState->hPCA, output_frame, num_in_ingest, hDecoderConfig->ivas_total_brate, hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, output );
        ivas_pca_dec( hSpar->hPCA, output_frame, num_in_ingest, hDecoderConfig->ivas_total_brate, hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, output );
#ifdef DEBUG_SBA_AUDIO_DUMP
        pca_ingest_channels = num_in_ingest;
        /* Dump audio signal after ivas_pca_dec */
@@ -1027,20 +1026,20 @@ void ivas_spar_dec_upmixer(
     * TD decorrelation
     *---------------------------------------------------------------------*/

    if ( pState->hMdDec->td_decorr_flag )
    if ( hSpar->hMdDec->td_decorr_flag )
    {
        ivas_td_decorr_process( pState->hTdDecorr, output, pPcm_tmp, output_frame );
        ivas_td_decorr_process( hSpar->hTdDecorr, output, pPcm_tmp, output_frame );

        for ( i = 0; i < nchan_internal - nchan_transport; i++ )
        {
            mvr2r( pPcm_tmp[pState->hTdDecorr->num_apd_outputs - 1 - i], output[nchan_internal - 1 - i], output_frame );
            mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - i], output[nchan_internal - 1 - i], output_frame );
        }

        pState->hFbMixer->fb_cfg->num_in_chans = num_in_ingest;
        hSpar->hFbMixer->fb_cfg->num_in_chans = num_in_ingest;
    }
    else
    {
        pState->hFbMixer->fb_cfg->num_in_chans = num_in_ingest;
        hSpar->hFbMixer->fb_cfg->num_in_chans = num_in_ingest;
    }

    /*---------------------------------------------------------------------*
@@ -1076,7 +1075,7 @@ void ivas_spar_dec_upmixer(
     * Gen umx mat
     *---------------------------------------------------------------------*/

    ivas_spar_dec_gen_umx_mat( pState->hMdDec, nchan_transport, num_bands_out, st_ivas->bfi );
    ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, st_ivas->bfi );


    /*---------------------------------------------------------------------*
@@ -1117,7 +1116,7 @@ void ivas_spar_dec_upmixer(
                float out_re[IVAS_SPAR_MAX_CH];
                float out_im[IVAS_SPAR_MAX_CH];
                float cldfb_par;
                ivas_fb_bin_to_band_data_t *bin2band = &pState->hFbMixer->pFb->fb_bin_to_band;
                ivas_fb_bin_to_band_data_t *bin2band = &hSpar->hFbMixer->pFb->fb_bin_to_band;

                for ( out_ch = 0; out_ch < numch_out; out_ch++ )
                {
@@ -1248,12 +1247,12 @@ void ivas_spar_dec_upmixer(
        split_band = SPAR_DIRAC_SPLIT_START_BAND;
        if ( split_band < IVAS_MAX_NUM_BANDS )
        {
            pState->i_subframe++;
            pState->i_subframe = min( pState->i_subframe, MAX_PARAM_SPATIAL_SUBFRAMES );
            mvr2r( pState->hMdDec->mixer_mat_prev[1][0][0], pState->hMdDec->mixer_mat_prev[0][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS );
            mvr2r( pState->hMdDec->mixer_mat_prev[2][0][0], pState->hMdDec->mixer_mat_prev[1][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS );
            mvr2r( pState->hMdDec->mixer_mat_prev[3][0][0], pState->hMdDec->mixer_mat_prev[2][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS );
            mvr2r( pState->hMdDec->mixer_mat_prev[4][0][0], pState->hMdDec->mixer_mat_prev[3][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS );
            hSpar->i_subframe++;
            hSpar->i_subframe = min( hSpar->i_subframe, MAX_PARAM_SPATIAL_SUBFRAMES );
            mvr2r( hSpar->hMdDec->mixer_mat_prev[1][0][0], hSpar->hMdDec->mixer_mat_prev[0][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS );
            mvr2r( hSpar->hMdDec->mixer_mat_prev[2][0][0], hSpar->hMdDec->mixer_mat_prev[1][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS );
            mvr2r( hSpar->hMdDec->mixer_mat_prev[3][0][0], hSpar->hMdDec->mixer_mat_prev[2][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS );
            mvr2r( hSpar->hMdDec->mixer_mat_prev[4][0][0], hSpar->hMdDec->mixer_mat_prev[3][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS );

            for ( out_ch = 0; out_ch < numch_out; out_ch++ )
            {
@@ -1261,7 +1260,7 @@ void ivas_spar_dec_upmixer(
                {
                    for ( b = 0; b < num_spar_bands; b++ )
                    {
                        pState->hMdDec->mixer_mat_prev[4][out_ch][in_ch][b] = pState->hMdDec->mixer_mat[out_ch][in_ch][b + i_sf * IVAS_MAX_NUM_BANDS];
                        hSpar->hMdDec->mixer_mat_prev[4][out_ch][in_ch][b] = hSpar->hMdDec->mixer_mat[out_ch][in_ch][b + i_sf * IVAS_MAX_NUM_BANDS];
                    }
                }
            }
Loading