Commit cdd86446 authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

Merge branch 'main' into 892-memory-consumption-in-bytes-instead-of-words

parents 21b0c283 3bab5d2b
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -172,6 +172,7 @@
#define NONBE_FIX_878_RS_FEC_STEREO_CNG                       /* Eri: Frame loss and Unified Stereo CNG may cause false BER detection which results in corrupt bitstream decoding */
#define NONBE_FIX_904_JBM_SBA_RS_FOA                          /* FhG: issue #904: fix JBM SBA RS to FOA decoding */
#define NONBE_FIX_898_ISM_BRATE_CRASH                         /* VA: issue 898: fix decoder crash in ISM bitrate switching with DTX and binaural output */
#define NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC                /* DLB: issue 862 : UBSAN: out-of-bound error in SPAR for OSBA bitrate switching with PLC*/

/* ##################### End NON-BE switches ########################### */

+15 −0
Original line number Diff line number Diff line
@@ -64,6 +64,10 @@ ivas_error ivas_corecoder_dec_reconfig(
    MC_MODE last_mc_mode;
    DECODER_CONFIG_HANDLE hDecoderConfig;
    ivas_error error;
#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
    int16_t prev_bfi;
    Decoder_State *st0;
#endif

    /*-----------------------------------------------------------------*
     * Initialization
@@ -141,6 +145,10 @@ ivas_error ivas_corecoder_dec_reconfig(
    }
    else
    {
#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
        st0 = ( nSCE_old > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0];
        prev_bfi = st0->prev_bfi;
#endif
        nSCE_existing = min( nSCE_old, st_ivas->nSCE );
        nCPE_existing = min( nCPE_old, st_ivas->nCPE );

@@ -213,6 +221,9 @@ ivas_error ivas_corecoder_dec_reconfig(
            {
                return error;
            }
#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
            st_ivas->hSCE[sce_id]->hCoreCoder[0]->prev_bfi = prev_bfi;
#endif
        }
        if ( st_ivas->sba_dirac_stereo_flag && sba_dirac_stereo_flag_old && st_ivas->nchan_transport == 1 && nSCE_old == 0 )
        {
@@ -241,6 +252,10 @@ ivas_error ivas_corecoder_dec_reconfig(
            {
                return error;
            }
#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
            st_ivas->hCPE[cpe_id]->hCoreCoder[0]->prev_bfi = prev_bfi;
            st_ivas->hCPE[cpe_id]->hCoreCoder[1]->prev_bfi = prev_bfi;
#endif
        }

        if ( st_ivas->nCPE > 1 && nCPE_old <= 1 )
+318 −11
Original line number Diff line number Diff line
@@ -76,13 +76,21 @@ static void ivas_spar_dec_compute_ramp_down_post_matrix( ivas_spar_md_dec_state_

static void ivas_spar_md_fill_invalid_bands( ivas_spar_dec_matrices_t *pSpar_coeffs, ivas_spar_dec_matrices_t *pSpar_coeffs_prev, const int16_t *valid_bands, int16_t *base_band_age, const int16_t num_bands, const int16_t numch_out, const int16_t num_md_sub_frames );

#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
static void ivas_spar_md_fill_invalid_bandcoeffs( ivas_band_coeffs_t *pBand_coeffs, ivas_band_coeffs_t *pBand_coeffs_prev, const int16_t *valid_bands, int16_t *base_band_age, int16_t *first_valid_frame, const int16_t num_bands );
#endif
static ivas_error ivas_spar_set_dec_config( ivas_spar_md_dec_state_t *hMdDec, const int16_t nchan_transport, float *pFC );

static void ivas_parse_parameter_bitstream_dtx( ivas_spar_md_t *pSpar_md, Decoder_State *st, const int16_t bw, const int16_t num_bands, int16_t *num_dmx_per_band, int16_t *num_dec_per_band );

static ivas_error ivas_deindex_real_index( const int16_t *index, const int16_t q_levels, const float min_value, const float max_value, float *quant, const int16_t num_ch_dim2 );

static void ivas_spar_dec_parse_md_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, int16_t *nB, int16_t *bands_bw, int16_t *dtx_vad, const int32_t ivas_total_brate, const int16_t sba_inactive_mode, const int32_t last_active_brate );
static void ivas_spar_dec_parse_md_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, int16_t *nB, int16_t *bands_bw, int16_t *dtx_vad, const int32_t ivas_total_brate, const int16_t sba_inactive_mode
#ifndef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
                                       ,
                                       const int32_t last_active_brate
#endif
);


/*-------------------------------------------------------------------------
@@ -103,6 +111,12 @@ ivas_error ivas_spar_md_dec_matrix_open(
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for band_coeffs in SPAR MD" );
    }
#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
    if ( ( hMdDec->band_coeffs_prev = (ivas_band_coeffs_t *) malloc( IVAS_MAX_NUM_BANDS * sizeof( ivas_band_coeffs_t ) ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for band_coeffs in SPAR MD" );
    }
#endif
    if ( ( hMdDec->mixer_mat = (float ***) malloc( num_channels * sizeof( float ** ) ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
@@ -365,6 +379,13 @@ void ivas_spar_md_dec_matrix_close(
        free( hMdDecoder->spar_md.band_coeffs );
        hMdDecoder->spar_md.band_coeffs = NULL;
    }
#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
    if ( hMdDecoder->band_coeffs_prev != NULL )
    {
        free( hMdDecoder->band_coeffs_prev );
        hMdDecoder->band_coeffs_prev = NULL;
    }
#endif

    if ( hMdDecoder->mixer_mat != NULL )
    {
@@ -543,11 +564,17 @@ ivas_error ivas_spar_md_dec_init(
    /* initialize PLC state */
    set_s( hMdDec->valid_bands, 0, IVAS_MAX_NUM_BANDS );
    set_s( hMdDec->base_band_age, 0, IVAS_MAX_NUM_BANDS );
#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
    set_s( hMdDec->base_band_coeffs_age, 0, IVAS_MAX_NUM_BANDS );
#endif
    hMdDec->spar_plc_num_lost_frames = 0;
    hMdDec->spar_plc_enable_fadeout_flag = 1;
    hMdDec->dtx_md_smoothing_cntr = 1;

    ivas_clear_band_coeffs( hMdDec->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS );
#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
    ivas_clear_band_coeffs( hMdDec->band_coeffs_prev, IVAS_MAX_NUM_BANDS );
#endif
    ivas_clear_band_coeff_idx( hMdDec->spar_md.band_coeffs_idx, IVAS_MAX_NUM_BANDS );
    ivas_clear_band_coeff_idx( hMdDec->spar_md_prev.band_coeffs_idx, IVAS_MAX_NUM_BANDS );
    ivas_clear_band_coeff_idx( hMdDec->spar_md_prev.band_coeffs_idx_mapped, IVAS_MAX_NUM_BANDS );
@@ -571,6 +598,9 @@ ivas_error ivas_spar_md_dec_init(
            set_zero( hMdDec->mixer_mat_prev2[i][j], IVAS_MAX_NUM_BANDS );
        }
    }
#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
    hMdDec->first_valid_frame = 1;
#endif

    return IVAS_ERR_OK;
}
@@ -752,7 +782,24 @@ void ivas_spar_md_dec_process(
    }

    ivas_spar_dec_parse_md_bs( hMdDec, st0, &nB, &bw, &dtx_vad, st_ivas->hDecoderConfig->ivas_total_brate,
                               st_ivas->hQMetaData->sba_inactive_mode, st_ivas->last_active_ivas_total_brate );
                               st_ivas->hQMetaData->sba_inactive_mode
#ifndef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
                               ,
                               st_ivas->last_active_ivas_total_brate
#endif
    );

#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
    assert( nB == hMdDec->spar_md.num_bands );
    assert( bw == 1 );
    ivas_spar_md_fill_invalid_bandcoeffs(
        hMdDec->spar_md.band_coeffs,
        hMdDec->band_coeffs_prev,
        &hMdDec->valid_bands[0],
        &hMdDec->base_band_coeffs_age[0],
        &hMdDec->first_valid_frame,
        nB );
#endif

    ivas_dec_mono_sba_handling( st_ivas );

@@ -764,10 +811,12 @@ void ivas_spar_md_dec_process(

    /* set correct number of bands*/
    nB = IVAS_MAX_NUM_BANDS;
#ifndef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
    if ( bw == IVAS_RED_BAND_FACT )
    {
        nB = nB >> 1;
    }
#endif
#ifdef DEBUG_LBR_SBA
    /* Dumping SPAR Coefficients */
    char f_name[100];
@@ -840,6 +889,7 @@ void ivas_spar_md_dec_process(
        fprintf( fid, "%.6f\n", hMdDec->mixer_mat[1][0][band] );
    }
#endif
#ifndef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
    if ( bw == IVAS_RED_BAND_FACT )
    {
        nB = nB << 1;
@@ -849,9 +899,10 @@ void ivas_spar_md_dec_process(
    {
        hMdDec->valid_bands[b] = 1;
    }

#endif
    ivas_spar_md_fill_invalid_bands( &hMdDec->spar_coeffs, &hMdDec->spar_coeffs_prev, &hMdDec->valid_bands[0], &hMdDec->base_band_age[0], num_bands_out, num_md_chs, num_md_sub_frames );


    hMdDec->dtx_md_smoothing_cntr = 1;

    return;
@@ -1461,6 +1512,49 @@ void ivas_spar_dec_gen_umx_mat(
    return;
}

#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
static void ivas_spar_md_band_upmix(
    ivas_band_coeffs_t *band_coeffs,
    int16_t *nB,
    int16_t *bands_bw,
    int16_t *valid_bands,
    int16_t bw_final,
    int16_t ndec,
    int16_t ndm )
{
    int16_t i, ii, jj, b, idx, bw_fact;

    bw_fact = *bands_bw / bw_final;
    for ( i = *nB - 1; i >= 0; i-- )
    {

        for ( b = bw_fact - 1; b >= 0; b-- )
        {
            idx = i * bw_fact + b;
            for ( ii = 0; ii < ndec + ndm - 1; ii++ )
            {
                band_coeffs[idx].pred_re[ii] = band_coeffs[i].pred_re[ii];
            }
            for ( ii = 0; ii < ndec; ii++ )
            {
                for ( jj = 0; jj < ndm - 1; jj++ )
                {
                    band_coeffs[idx].C_re[ii][jj] = band_coeffs[i].C_re[ii][jj];
                }
            }
            for ( jj = 0; jj < ndec; jj++ )
            {
                band_coeffs[idx].P_re[jj] = band_coeffs[i].P_re[jj];
            }
            valid_bands[idx] = valid_bands[i];
        }
    }
    *nB = ( *nB ) * ( *bands_bw ) / bw_final;
    *bands_bw = bw_final;

    return;
}
#endif

/*-----------------------------------------------------------------------------------------*
 * Function ivas_spar_dec_parse_md_bs()
@@ -1475,19 +1569,29 @@ static void ivas_spar_dec_parse_md_bs(
    int16_t *bands_bw,
    int16_t *dtx_vad,
    const int32_t ivas_total_brate,
    const int16_t sba_inactive_mode,
    const int32_t last_active_brate )
    const int16_t sba_inactive_mode
#ifndef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
    ,
    const int32_t last_active_brate
#endif
)
{
    int16_t i, j, k, num_bands;
#ifndef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
    int16_t ii, jj, ndec, ndm, b, idx;
#else
    int16_t ii, jj, ndec, ndm;
#endif
    uint16_t qsi;
    ivas_quant_strat_t qs;
    int16_t strat, no_ec;
    int16_t do_diff[IVAS_MAX_NUM_BANDS];
    float quant[IVAS_SPAR_MAX_C_COEFF];
    int16_t do_repeat[IVAS_MAX_NUM_BANDS];
#ifndef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
    int16_t bw_final, bw_fact;
    int32_t active_brate;
#endif
    *dtx_vad = 1;
    *bands_bw = 1;
    qsi = 0;
@@ -1559,6 +1663,22 @@ static void ivas_spar_dec_parse_md_bs(

        ivas_parse_parameter_bitstream_dtx( &hMdDec->spar_md, st0, *bands_bw, *nB, hMdDec->spar_md_cfg.num_dmx_chans_per_band, hMdDec->spar_md_cfg.num_decorr_per_band );

#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
        if ( *bands_bw != 1 )
        {
            ndec = hMdDec->spar_md_cfg.num_decorr_per_band[0];
            ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[0];
            ivas_spar_md_band_upmix(
                hMdDec->spar_md.band_coeffs,
                nB,
                bands_bw,
                hMdDec->valid_bands,
                1,
                ndec,
                ndm );
        }

#else
        active_brate = ( ivas_total_brate > IVAS_SID_5k2 ) ? ivas_total_brate : last_active_brate;

        if ( active_brate >= IVAS_24k4 )
@@ -1593,7 +1713,7 @@ static void ivas_spar_dec_parse_md_bs(

        *bands_bw = bw_final;
        *nB = num_bands / bw_final;

#endif
        return;
    }

@@ -1645,8 +1765,14 @@ static void ivas_spar_dec_parse_md_bs(
            do_diff[i] = ( ( ( i + 1 ) & 3 ) != strat - 4 );
            do_repeat[i] = 0;
        }

#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
        if ( hMdDec->spar_md_cfg.prev_quant_idx >= 0 )
        {
#endif
            ivas_map_prior_coeffs_quant( &hMdDec->spar_md_prev, &hMdDec->spar_md_cfg, qsi, *nB );
#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
        }
#endif
    }
#ifdef SPAR_HOA_DBG
    fprintf( stdout, "\n\n no_ec = %d, strat = %d\n", no_ec, strat );
@@ -1706,13 +1832,34 @@ static void ivas_spar_dec_parse_md_bs(
        {
            hMdDec->spar_md_prev.band_coeffs_idx[i].decd_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].decd_index_re[j];
        }
#ifndef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
        hMdDec->valid_bands[*bands_bw * i] |= ( do_diff[i] == 0 && do_repeat[i] == 0 ) ? 1 : 0;
        for ( j = 1; j < *bands_bw; j++ )
        {
            hMdDec->valid_bands[*bands_bw * i + j] = hMdDec->valid_bands[*bands_bw * i];
        }
#else
        hMdDec->valid_bands[i] |= ( do_diff[i] == 0 && do_repeat[i] == 0 ) ? 1 : 0;
#endif
    }

#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
    ndec = hMdDec->spar_md_cfg.num_decorr_per_band[0];
    ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[0];
    if ( *bands_bw != 1 )
    {
        ivas_spar_md_band_upmix(
            hMdDec->spar_md.band_coeffs,
            nB,
            bands_bw,
            hMdDec->valid_bands,
            1,
            ndec,
            ndm );
    }

#endif

    return;
}

@@ -1984,6 +2131,76 @@ static void ivas_decode_huffman_bs(
    return;
}

#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
static void ivas_spar_plc_get_band_age(
    const int16_t *valid_bands,
    int16_t *base_band_age,
    const int16_t num_bands,
    int16_t last_valid_band_idx[IVAS_MAX_NUM_BANDS],
    int16_t valid_band_idx[IVAS_MAX_NUM_BANDS],
    int16_t *all_valid,
    int16_t *b_idx )
{
    int16_t b, idx;

    set_s( valid_band_idx, 0, IVAS_MAX_NUM_BANDS );
    set_s( last_valid_band_idx, 0, IVAS_MAX_NUM_BANDS );
    idx = -1;
    *all_valid = 1;
    for ( b = 0; b < num_bands; b++ )
    {
        if ( valid_bands[b] != 0 )
        {
            base_band_age[b] = 0; /* reset band age */
            idx++;
            valid_band_idx[idx] = b;
        }
        else
        {
            base_band_age[b] += 1; /* increment the age of invalid bands */

            if ( base_band_age[b] > 3 )
            {
                last_valid_band_idx[b] = idx;
            }
            *all_valid = 0;
        }
    }
    *b_idx = idx;

    return;
}

static void ivas_spar_get_plc_interp_weights(
    int16_t valid_band_idx[IVAS_MAX_NUM_BANDS],
    int16_t last_valid_band_idx,
    int16_t idx,
    int16_t b,
    float *w,
    int16_t *id0,
    int16_t *id1 )
{
    if ( last_valid_band_idx < 0 ) /* Extrapolation */
    {
        *id1 = valid_band_idx[0];
        *id0 = 0;
        *w = 1;
    }
    else if ( last_valid_band_idx == idx ) /* Extrapolation */
    {
        *id1 = valid_band_idx[last_valid_band_idx];
        *id0 = valid_band_idx[last_valid_band_idx];
        *w = 0;
    }
    else /* Interpolation */
    {
        *id0 = valid_band_idx[last_valid_band_idx];
        *id1 = valid_band_idx[last_valid_band_idx + 1];
        *w = ( (float) ( b - *id0 ) ) / ( *id1 - *id0 );
    }
    return;
}
#endif

/*-----------------------------------------------------------------------------------------*
 * Function ivas_spar_md_fill_invalid_bands()
@@ -1991,7 +2208,6 @@ static void ivas_decode_huffman_bs(
 * Fill invalid bands in interpolation/extrapolation of valid bands
 * when PLC is to be done with partial time differential coding
 *-----------------------------------------------------------------------------------------*/

static void ivas_spar_md_fill_invalid_bands(
    ivas_spar_dec_matrices_t *pSpar_coeffs,
    ivas_spar_dec_matrices_t *pSpar_coeffs_prev,
@@ -2005,6 +2221,10 @@ static void ivas_spar_md_fill_invalid_bands(
    int16_t valid_band_idx[IVAS_MAX_NUM_BANDS], idx = -1;
    int16_t last_valid_band_idx[IVAS_MAX_NUM_BANDS];
    float w = 0;
#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
    ivas_spar_plc_get_band_age( valid_bands, base_band_age, num_bands,
                                last_valid_band_idx, valid_band_idx, &all_valid, &idx );
#else
    set_s( valid_band_idx, 0, IVAS_MAX_NUM_BANDS );
    set_s( last_valid_band_idx, 0, IVAS_MAX_NUM_BANDS );

@@ -2028,7 +2248,7 @@ static void ivas_spar_md_fill_invalid_bands(
            all_valid = 0;
        }
    }

#endif
    assert( idx > 0 ); /* some bands should be valid */

    if ( all_valid == 0 )
@@ -2038,6 +2258,11 @@ static void ivas_spar_md_fill_invalid_bands(
            /* check against non zero in if and else if */
            if ( base_band_age[b] > 3 ) /* old invalid bands */
            {
#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
                int16_t id0, id1;
                ivas_spar_get_plc_interp_weights( valid_band_idx, last_valid_band_idx[b],
                                                  idx, b, &w, &id0, &id1 );
#else
                int16_t tmp_id, id0, id1;

                tmp_id = last_valid_band_idx[b];
@@ -2059,7 +2284,7 @@ static void ivas_spar_md_fill_invalid_bands(
                    id1 = valid_band_idx[tmp_id + 1];
                    w = ( (float) ( b - id0 ) ) / ( id1 - id0 );
                }

#endif
                for ( i = 0; i < num_channels; i++ )
                {
                    for ( j = 0; j < num_channels; j++ )
@@ -2105,6 +2330,88 @@ static void ivas_spar_md_fill_invalid_bands(
    return;
}

#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
static void ivas_spar_md_fill_invalid_bandcoeffs(
    ivas_band_coeffs_t *pBand_coeffs,
    ivas_band_coeffs_t *pBand_coeffs_prev,
    const int16_t *valid_bands,
    int16_t *base_band_age,
    int16_t *first_valid_frame,
    const int16_t num_bands )
{
    int16_t j, k, b, all_valid;
    int16_t valid_band_idx[IVAS_MAX_NUM_BANDS], idx = -1;
    int16_t last_valid_band_idx[IVAS_MAX_NUM_BANDS];
    float w = 0;

    ivas_spar_plc_get_band_age( valid_bands, base_band_age, num_bands,
                                last_valid_band_idx, valid_band_idx, &all_valid, &idx );

    assert( idx > 0 ); /* some bands should be valid */

    if ( all_valid == 0 )
    {
        for ( b = 0; b < num_bands; b++ )
        {
            /* check against non zero in if and else if */
            if ( ( base_band_age[b] > 3 ) || ( *first_valid_frame == 0 ) ) /* old invalid bands */
            {
                int16_t id0, id1;
                ivas_spar_get_plc_interp_weights( valid_band_idx, last_valid_band_idx[b],
                                                  idx, b, &w, &id0, &id1 );

                for ( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
                {
                    pBand_coeffs[b].pred_re[j] = ( 1 - w ) * pBand_coeffs[id0].pred_re[j] + w * pBand_coeffs[id1].pred_re[j];
                }

                for ( j = 0; j < IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS; j++ )
                {
                    for ( k = 0; k < IVAS_SPAR_MAX_DMX_CHS - 1; k++ )
                    {
                        pBand_coeffs[b].C_re[j][k] = ( 1 - w ) * pBand_coeffs[id0].C_re[j][k] + w * pBand_coeffs[id1].C_re[j][k];
                    }
                }

                for ( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
                {
                    pBand_coeffs[b].P_re[j] = ( 1 - w ) * pBand_coeffs[id0].P_re[j] + w * pBand_coeffs[id1].P_re[j];
                }
            }
            else /* young invalid bands */
            {
                if ( valid_bands[b] == 0 )
                {
                    for ( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
                    {
                        pBand_coeffs[b].pred_re[j] = pBand_coeffs_prev[b].pred_re[j];
                    }

                    for ( j = 0; j < IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS; j++ )
                    {
                        for ( k = 0; k < IVAS_SPAR_MAX_DMX_CHS - 1; k++ )
                        {
                            pBand_coeffs[b].C_re[j][k] = pBand_coeffs_prev[b].C_re[j][k];
                        }
                    }

                    for ( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
                    {
                        pBand_coeffs[b].P_re[j] = pBand_coeffs_prev[b].P_re[j];
                    }
                }
            }
        }
    }
    else
    {
        *first_valid_frame = 1;
    }

    return;
}
#endif


/*-----------------------------------------------------------------------------------------*
 * Function ivas_spar_dec_compute_ramp_down_post_matrix()
+5 −1
Original line number Diff line number Diff line
@@ -603,7 +603,11 @@ typedef struct ivas_spar_md_dec_state_t
    float smooth_buf[IVAS_MAX_NUM_BANDS][2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1];
    float smooth_fac[IVAS_MAX_NUM_BANDS];
    float mixer_mat_prev2[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS];

#ifdef NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC
    int16_t first_valid_frame;
    ivas_band_coeffs_t *band_coeffs_prev;
    int16_t base_band_coeffs_age[IVAS_MAX_NUM_BANDS];
#endif
} ivas_spar_md_dec_state_t;