Commit 0bd96bd1 authored by bayers's avatar bayers
Browse files

Change the logic for the hTcxCfg handle of the MCT LFE channel when

switching from MCT to ParamMC with 4TC, reestablishes the old memory
foot print for MCT only MC coding and resolves a msan problem
parent fa1b0e11
Loading
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -613,14 +613,8 @@ ivas_error init_decoder(
    }

    /* TCX config. data structure */
#ifdef MC_BITRATE_SWITCHING
    /* for correct bit rate switching in MC we at least need the TcxCfg for the LFE channel in MCT */
    if ( ( idchan == 0 || st->element_mode == IVAS_CPE_MDCT ) )
#else
    if ( ( idchan == 0 || st->element_mode == IVAS_CPE_MDCT ) && st->mct_chan_mode != MCT_CHAN_MODE_LFE )
#endif
    {

        if ( ( st->hTcxCfg = (TCX_CONFIG_HANDLE) count_malloc( sizeof( TCX_config ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) );
+8 −0
Original line number Diff line number Diff line
@@ -850,6 +850,14 @@ void destroy_cpe_dec(
    int16_t n;
    Decoder_State *st;

#ifdef MC_BITRATE_SWITCHING
    /* make sure we deallocate a potential distinct hTcxCfg for a MCT LFE channel (can only happen in rs) */
    if ( hCPE->hCoreCoder[1]->mct_chan_mode == MCT_CHAN_MODE_LFE && hCPE->hCoreCoder[1]->hTcxCfg != hCPE->hCoreCoder[0]->hTcxCfg )
    {
        hCPE->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE;
    }
#endif

    for ( n = 0; n < CPE_CHANNELS; n++ )
    {
        st = hCPE->hCoreCoder[n];
+7 −4
Original line number Diff line number Diff line
@@ -354,10 +354,13 @@ ivas_error ivas_dec(
        /* LFE channel decoder */
        if ( st_ivas->mc_mode == MC_MODE_MCT )
        {
#ifndef MC_BITRATE_SWITCHING
            /* bay: this really killed the MC bitrate switching and took me one day to find it, at least a comment here why the messing with this pointers
                    happens would have been nice */
#ifdef MC_BITRATE_SWITCHING
            if ( st_ivas->hCPE[1]->hCoreCoder[1]->hTcxCfg == NULL )
            {
#endif
                st_ivas->hCPE[1]->hCoreCoder[1]->hTcxCfg = st_ivas->hCPE[1]->hCoreCoder[0]->hTcxCfg;
#ifdef MC_BITRATE_SWITCHING
            }
#endif
            ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, output_lfe_ch );
        }
+1 −5
Original line number Diff line number Diff line
@@ -1422,11 +1422,7 @@ void destroy_core_dec(
        hCoreCoder->hTcxDec = NULL;
    }

    if ( hCoreCoder->hTcxCfg != NULL
#ifndef MC_BITRATE_SWITCHING
         && hCoreCoder->mct_chan_mode != MCT_CHAN_MODE_LFE
#endif
    )
    if ( hCoreCoder->hTcxCfg != NULL && hCoreCoder->mct_chan_mode != MCT_CHAN_MODE_LFE )
    {
        count_free( hCoreCoder->hTcxCfg );
        hCoreCoder->hTcxCfg = NULL;
+9 −0
Original line number Diff line number Diff line
@@ -894,6 +894,15 @@ static ivas_error ivas_mc_dec_reconfig(
            HQ_core_dec_init( st->hHQ_core );
        }

        /* check if we have a doubly used hTxcCfg, if so, allocate a distint one for the old MCT LFE channel */
        if ( st->hTcxCfg == st_ivas->hCPE[1]->hCoreCoder[0]->hTcxCfg )
        {
            if ( ( st->hTcxCfg = (TCX_CONFIG_HANDLE) count_malloc( sizeof( TCX_config ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) );
            }
        }

        st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st_ivas->hDecoderConfig->ivas_total_brate, st->igf, st->element_mode, st->mct_chan_mode );
    }
    else if ( last_mc_mode == MC_MODE_PARAMMC && st_ivas->mc_mode == MC_MODE_MCT && nchan_transport_old > 2 )