Commit 18d2eba7 authored by reutelhuber's avatar reutelhuber
Browse files

fix crashes for WB and bandwidth switching

parent c935d106
Loading
Loading
Loading
Loading
Loading
+37 −1
Original line number Diff line number Diff line
@@ -69,6 +69,9 @@ ivas_error init_encoder(
{
    int16_t i;
    ivas_error error;
#ifdef IGF_MEMORY_ALLOC_OPT
    int32_t igf_brate;
#endif

    error = IVAS_ERR_OK;

@@ -747,9 +750,42 @@ ivas_error init_encoder(
     *-----------------------------------------------------------------*/

#ifdef IGF_MEMORY_ALLOC_OPT
    igf_brate = st->total_brate;
    switch ( st->element_mode )
    {
        case IVAS_SCE:
            if ( st_ivas->hEncoderConfig->ivas_format == ISM_FORMAT )
            {
                igf_brate = st->total_brate - ISM_NB_BITS_METADATA_NOMINAL * FRAMES_PER_SEC;
            }
            break;
        case IVAS_CPE_DFT:
            /* use nominal bitrates for DFT Stereo, same as in stereo_dft_config() */
            if ( element_brate == IVAS_13k2 )
            {
                igf_brate = ACELP_9k60;
            }
            else if ( element_brate == IVAS_16k4 )
            {
                igf_brate = ACELP_13k20;
            }
            else if ( element_brate == IVAS_24k4 )
            {
                igf_brate = ACELP_16k40;
            }
            else if ( element_brate == IVAS_32k )
            {
                igf_brate = ACELP_24k40;
            }
            break;
        case IVAS_CPE_MDCT:
            igf_brate = element_brate;
            break;
    }

    if ( st->codec_mode == MODE2 || st->element_mode > EVS_MONO )
    {
        st->igf = getIgfPresent( st->element_mode, ( st->element_mode == IVAS_CPE_MDCT ) ? element_brate : st->total_brate, st->max_bwidth, st->rf_mode );
        st->igf = getIgfPresent( st->element_mode, igf_brate, st->max_bwidth, st->rf_mode );
    }
    else
    {
+1 −1
Original line number Diff line number Diff line
@@ -310,7 +310,7 @@ ivas_error ivas_ism_enc(
         *----------------------------------------------------------------*/
#ifdef IGF_MEMORY_ALLOC_OPT
         /* IGF reconfiguration */
        if ( hSCE->last_element_brate != hSCE->element_brate )
        if ( hSCE->last_element_brate != hSCE->element_brate || st->last_bwidth != st->bwidth )
        {
            int16_t igf;
            igf = getIgfPresent( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->max_bwidth, st->rf_mode );
+1 −1
Original line number Diff line number Diff line
@@ -232,7 +232,7 @@ ivas_error ivas_sce_enc(

#ifdef IGF_MEMORY_ALLOC_OPT
     /* IGF reconfiguration */
    if ( hSCE->last_element_brate != hSCE->element_brate )
    if ( hSCE->last_element_brate != hSCE->element_brate || st->last_bwidth != st->bwidth )
    {
        int16_t igf;
        igf = getIgfPresent( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->max_bwidth, st->rf_mode );