diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index f06b65860474877d675498ac179e86d4a23b616e..cb5b9f4e0bad7d75762f611c950f3d13024eac36 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -512,13 +512,8 @@ ivas_error ivas_cpe_dec( for ( i = 0; i < n; i++ ) { -#ifdef MC_BITRATE_SWITCHING // !!! VE: Can it be removed? - dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "element_brate.cpe", 0, cpe_id, DEC ) ); - dbgwrite( &hCPE->element_mode, sizeof( int16_t ), 1, output_frame, fname( debug_dir, "element_mode.cpe", 0, cpe_id, DEC ) ); -#else dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "element_brate", 0, cpe_id, DEC ) ); dbgwrite( &hCPE->element_mode, sizeof( int16_t ), 1, output_frame, fname( debug_dir, "element_mode", 0, cpe_id, DEC ) ); -#endif for ( int16_t j = 0; j < CPE_CHANNELS; j++ ) { diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 0283d7778dbf118cab080d68f72af835778d5289..cf348ff15d10418e1611a41e38310fc482e9fab8 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -667,17 +667,18 @@ static ivas_error ivas_mc_dec_reconfig( #else int16_t numCldfbAnalyses_old, numCldfbAnalyses, numCldfbSyntheses, numCldfbSyntheses_old, i; #endif - int32_t new_brate_SCE, new_brate_CPE; + int32_t new_brate_SCE, new_brate_CPE, ivas_total_brate; RENDERER_TYPE renderer_type_old; ivas_error error; MC_MODE mc_mode, last_mc_mode; - last_mc_mode = ivas_mc_mode_select( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ), st_ivas->hDecoderConfig->last_ivas_total_brate ); /* NB: this assumes that LS config remains the same between frames */ - error = IVAS_ERR_OK; + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; nchan_transport_old = st_ivas->nchan_transport; + last_mc_mode = ivas_mc_mode_select( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ), st_ivas->hDecoderConfig->last_ivas_total_brate ); /* NB: this assumes that LS config remains the same between frames */ + /* we have to temporally set the current mc_mode back to the previous one to make sure the following call to ivas_init_dec_get_num_cldfb_instances() returns the correct counts */ mc_mode = st_ivas->mc_mode; @@ -703,6 +704,7 @@ static ivas_error ivas_mc_dec_reconfig( /* renderer might have changed, reselect */ renderer_type_old = st_ivas->renderer_type; ivas_renderer_select( st_ivas ); + /* side effect of the renderer selection can be a changed internal config */ ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); @@ -755,6 +757,7 @@ static ivas_error ivas_mc_dec_reconfig( { ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion ); } + if ( ( error = ivas_param_mc_dec_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; @@ -796,7 +799,7 @@ static ivas_error ivas_mc_dec_reconfig( } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { - ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), st_ivas->hDecoderConfig->ivas_total_brate ); + ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); if ( last_mc_mode != MC_MODE_MCMASA ) { @@ -805,6 +808,7 @@ static ivas_error ivas_mc_dec_reconfig( return error; } } + if ( ( error = ivas_mcmasa_dec_reconfig( st_ivas ) ) != IVAS_ERR_OK ) { return error; @@ -903,7 +907,7 @@ static ivas_error ivas_mc_dec_reconfig( } } - st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st_ivas->hDecoderConfig->ivas_total_brate, st->igf, st->element_mode, st->mct_chan_mode ); + st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( 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 ) { @@ -919,19 +923,20 @@ static ivas_error ivas_mc_dec_reconfig( { uint8_t separateChannelEnabled; int16_t separateChannelIndex; - ivas_mcmasa_set_separate_channel_mode( &separateChannelEnabled, &separateChannelIndex, st_ivas->hDecoderConfig->ivas_total_brate ); - ivas_mcmasa_split_brate( separateChannelEnabled, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE ); + ivas_mcmasa_set_separate_channel_mode( &separateChannelEnabled, &separateChannelIndex, ivas_total_brate ); + ivas_mcmasa_split_brate( separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE ); } else if ( st_ivas->mc_mode == MC_MODE_MCT ) { new_brate_SCE = 0; - new_brate_CPE = ( st_ivas->hDecoderConfig->ivas_total_brate / ( st_ivas->nchan_transport - 1 ) ) * CPE_CHANNELS; + new_brate_CPE = ( ivas_total_brate / ( st_ivas->nchan_transport - 1 ) ) * CPE_CHANNELS; } else { - new_brate_SCE = 0; /*st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport;*/ - new_brate_CPE = ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS; + new_brate_SCE = 0; /* ivas_total_brate / st_ivas->nchan_transport;*/ + new_brate_CPE = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS; } + if ( ( error = ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, new_brate_SCE, new_brate_CPE ) ) != IVAS_ERR_OK ) { return error; @@ -1030,7 +1035,29 @@ static ivas_error ivas_mc_dec_reconfig( if ( st_ivas->mc_mode == MC_MODE_MCT && st_ivas->hLFE == NULL ) { +#ifdef FIX_I59_LFE_TD_DELAY + int32_t binauralization_delay_ns = st_ivas->binaural_latency_ns; + + if ( st_ivas->hBinRenderer != NULL ) + { +#ifdef FIX_I59_LFE_CLDFB + if ( st_ivas->hBinRenderer->render_lfe ) + { + /* Account for filterbank delay */ + binauralization_delay_ns += IVAS_FB_DEC_DELAY_NS; + } + else + { + binauralization_delay_ns = 0; + } +#else + binauralization_delay_ns = 0; +#endif + } + if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, binauralization_delay_ns ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtf != NULL ? st_ivas->hHrtf->latency_s : 0 ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1110,6 +1137,7 @@ static ivas_error ivas_mc_dec_reconfig( { /* useTdDecorr may change => close and re-open */ ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); + if ( ( error = ivas_dirac_dec_init_binaural_data( st_ivas ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index 9ac0a1c52874626def0a30b5fdb593b814d53d6d..97ee2e83369b3a6c061237d40808e638f23bb288 100644 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -273,13 +273,8 @@ ivas_error ivas_sce_dec( for ( i = 0; i < n; i++ ) { -#ifdef MC_BITRATE_SWITCHING // !!! VE: Can it be removed? - dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "element_brate.sce", 0, sce_id, DEC ) ); - dbgwrite( &st->element_mode, sizeof( int16_t ), 1, output_frame, fname( debug_dir, "element_mode.sce", 0, sce_id, DEC ) ); -#else dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "element_brate", 0, sce_id, DEC ) ); dbgwrite( &st->element_mode, sizeof( int16_t ), 1, output_frame, fname( debug_dir, "element_mode", 0, sce_id, DEC ) ); -#endif dbgwrite( output, sizeof( float ), output_frame, 1, fname( debug_dir, "output.sce", 0, sce_id, DEC ) ); tmpF = 0; diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index 50d8e4faf8077c6cd590babd120fea73bbe18b79..dfa7ed9ffae781a84b816af08e6a2bbea991beaf 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -354,8 +354,9 @@ ivas_error ivas_corecoder_enc_reconfig( #ifdef MC_BITRATE_SWITCHING if ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->hMcMasa->separateChannelEnabled ) { - st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; // !!! VE: can it be set in McMASA config module rather than here? + st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; } + if ( ( error = create_cpe_enc( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK ) #else if ( ( error = create_cpe_enc( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index fefc4ed678e2e1cc48b899323de1bef133b4a450..b565c346920384cd505188a1aeb1e44e42a28b84 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -426,11 +426,7 @@ ivas_error ivas_cpe_enc( { dbgwrite( sts[0]->input - NS2SA( sts[0]->input_Fs, ACELP_LOOK_NS ), sizeof( float ), input_frame, 1, fname( debug_dir, "input_DMX", n, sts[n]->id_element, ENC ) ); } -#ifdef MC_BITRATE_SWITCHING // !!! VE: Can it be removed? - dbgwrite( &hCPE->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode.cpe", 0, sts[0]->id_element, ENC ) ); -#else dbgwrite( &hCPE->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode", 0, sts[0]->id_element, ENC ) ); -#endif #endif /*----------------------------------------------------------------* diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 41a071aab3f54b6e12123d2ad04eefb7cdd6f9fe..7c9253a35ec972e97b269e5754b853808b0df87e 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -526,9 +526,7 @@ ivas_error ivas_init_encoder( st_ivas->mc_mode = ivas_mc_mode_select( hEncoderConfig->mc_input_setup, ivas_total_brate ); hEncoderConfig->nchan_inp = ivas_mc_ls_setup_get_num_channels( hEncoderConfig->mc_input_setup ); -#ifdef MC_BITRATE_SWITCHING - st_ivas->hLFE = NULL; // !!! VE: already done in ivas_initialize_handles_enc() -#else +#ifndef MC_BITRATE_SWITCHING if ( ( error = ivas_create_lfe_enc( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 4d76e9e5b21b046a21bb8637ea4c53204e33f66e..1c091146af392db399fbde6ecf934a851ed19881 100755 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -740,6 +740,7 @@ static ivas_error ivas_mc_enc_reconfig( ivas_lfe_enc_close( st_ivas->hLFE ); st_ivas->hLFE = NULL; } + if ( st_ivas->hMCT != NULL ) { ivas_mct_enc_close( st_ivas->hMCT ); diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index a7d41952492e3142c32ec3b996511e0ec2716344..a26f3a4b1085860228cef69a6e9ba1d356b97164 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -176,11 +176,7 @@ ivas_error ivas_sce_enc( #ifdef DEBUG_MODE_INFO dbgwrite( st->input - NS2SA( st->input_Fs, ACELP_LOOK_NS ), sizeof( float ), input_frame, 1, "res/input_DMX" ); -#ifdef MC_BITRATE_SWITCHING // !!! VE: Can it be removed? - dbgwrite( &st->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode.sce", 0, st->id_element, ENC ) ); -#else dbgwrite( &st->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode", 0, st->id_element, ENC ) ); -#endif #endif /*----------------------------------------------------------------*