Commit 419faaf9 authored by bayers's avatar bayers
Browse files

fixed FdCng handling

fixed some problems when going from MCT->ParamMC with 4 TCs
parent f3700669
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@
#define MCMASA_BITRATE_SWITCHING                        /* Issue 116: support bitrate switching in MC format: sub-part of McMASA modes */
#endif
#define FIX_MC_BR_SW_TCX_PLC_FADEOUT
#define FIX_MC_BR_SW_MCT_UPDT_ENC_COMMON

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
+5 −2
Original line number Diff line number Diff line
@@ -3916,8 +3916,11 @@ void updt_enc(
);

void updt_enc_common(
    Encoder_State *st, /* i/o: encoder state structure                     */
    Encoder_State *st /* i/o: encoder state structure                     */
#ifndef FIX_MC_BR_SW_MCT_UPDT_ENC_COMMON
    ,
    const float Etot /* i  : total energy                                */
#endif
);

void updt_IO_switch_enc(
+46 −1
Original line number Diff line number Diff line
@@ -855,6 +855,34 @@ ivas_error ivas_mc_dec_reconfig(
            st->igf = 0;
            init_igf_dec( st->hIGFDec );
        }

        if ( st->hHQ_core == NULL )
        {

            if ( ( st->hHQ_core = (HQ_DEC_HANDLE) count_malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n" ) );
            }

            /* HQ core initialization */
            HQ_core_dec_init( st->hHQ_core );
        }

#if 0
        if ( st->element_mode == EVS_MONO )
        {
            /* HQ NB FEC initialization */
            if ( ( st->hHQ_nbfec = (HQ_NBFEC_HANDLE) count_malloc( sizeof( HQ_NBFEC_DATA ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ NB FEC\n" ) );
            }
            HQ_nbfec_init( st->hHQ_nbfec );
        }
        else
        {
            st->hHQ_nbfec = NULL;
        }
#endif
    }
    else if ( last_mc_mode == MC_MODE_PARAMMC && st_ivas->mc_mode == MC_MODE_MCT && nchan_transport_old > 2 )
    {
@@ -887,6 +915,23 @@ ivas_error ivas_mc_dec_reconfig(
        return error;
    }

    if ( last_mc_mode == MC_MODE_MCT && st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->nchan_transport > CPE_CHANNELS )
    {
        Decoder_State *st = st_ivas->hCPE[1]->hCoreCoder[1];

#if 1
        /* TCX-LTP */
        if ( st->hTcxLtpDec == NULL )
        {
            if ( ( st->hTcxLtpDec = (TCX_LTP_DEC_HANDLE) count_malloc( sizeof( TCX_LTP_DEC_DATA ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TCX-LTP handle\n" ) );
            }
            tcxltp_dec_init( st->hTcxLtpDec, 0, st->last_codec_mode, st->element_mode, st->pit_max, st->sr_core );
        }
#endif
    }

    /* re-configure hp20 memories */
    ivas_hp20_dec_reconfig( st_ivas, nchan_hp20_old );

+15 −2
Original line number Diff line number Diff line
@@ -871,7 +871,12 @@ ivas_error stereo_memory_dec(
            /* deallocate the FdCNG handle */
            for ( i = 0; i < CPE_CHANNELS; ++i )
            {
                deleteFdCngDec( &hCPE->hCoreCoder[0]->hFdCngDec );
                deleteFdCngDec( &hCPE->hCoreCoder[i]->hFdCngDec );
                /* deallocate CLDFB synthesis for LFE channel */
                if ( hCPE->hCoreCoder[i]->mct_chan_mode == MCT_CHAN_MODE_LFE )
                {
                    deleteCldfb( &hCPE->hCoreCoder[i]->cldfbSyn );
                }
            }
        }
        else
@@ -879,6 +884,14 @@ ivas_error stereo_memory_dec(
            /* allocate the FdCNG handle (for noise estimation for TCX PLC fadeout)*/
            for ( i = 0; i < CPE_CHANNELS; ++i )
            {
                if ( hCPE->hCoreCoder[i]->cldfbSyn == NULL ) /* could be NULL when we had the MCT LFE channel */
                {
                    if ( ( error = openCldfb( &hCPE->hCoreCoder[i]->cldfbSyn, CLDFB_SYNTHESIS, hCPE->hCoreCoder[i]->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK )
                    {
                        return error;
                    }
                }

                if ( hCPE->hCoreCoder[i]->hFdCngDec == NULL )
                {
                    if ( ( error = createFdCngDec( &hCPE->hCoreCoder[i]->hFdCngDec ) ) != IVAS_ERR_OK )
+6 −0
Original line number Diff line number Diff line
@@ -536,7 +536,13 @@ void amr_wb_enc(
    updt_enc( st, old_exc, pitch_buf, 0, Aq, isf_new, isp_new, dummy_buf );

    /* update main codec paramaters */
#ifdef FIX_MC_BR_SW_MCT_UPDT_ENC_COMMON
    st->hNoiseEst->Etot_last = Etot;
    updt_enc_common( st );
#else
    updt_enc_common( st, Etot );
#endif


#ifdef DEBUG_MODE_INFO
    dbgwrite( &st->codec_mode, sizeof( int16_t ), 1, input_frame, "res/codec" );
Loading