diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index eac8ec005aaf66a5f34f8b39e21ed8c2be49e6ee..1a170720f896e8da49afc6446eed18e971e465ff 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3053,6 +3053,7 @@ ivas_error ivas_sba_dec_reinit( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); #endif + ivas_error ivas_sba_dec_reconfigure( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); @@ -3063,6 +3064,14 @@ void ivas_init_dec_get_num_cldfb_instances( int16_t *numCldfbSyntheses /* o : number of CLDFB synthesis instances */ ); +#ifdef BRATE_SWITCHING_RENDERING +ivas_error ivas_cldfb_dec_reconfig( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ + int16_t numCldfbAnalyses_old, /* i : number of CLDFB analysis instances in previous frame */ + const int16_t numCldfbSyntheses_old /* i : number of CLDFB synthesis instances in previous frame */ +); +#endif /*! r: Ambisonic (SBA) order */ int16_t ivas_sba_get_order( const int16_t nb_channels, /* i : Number of ambisonic channels */ diff --git a/lib_com/options.h b/lib_com/options.h index 29d980db05ef534beb08b3257e2e442a428b4e1e..d717b4ebb2bfc209b35f51f5f654056f5af916a4 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -161,6 +161,9 @@ #define FIX_I218_PARAMISM_NOISY_SPEECH /* Issue 218: Fix noisy speech buffer in ParamISM */ #define FIX_I217_GSC_FLAG_IN_ISM /* Issue 217: fix BER detected in ISM4 due to desynchronized 'GSC_IVAS_mode' parameter */ #define FIX_158_DIRAC_MEM /* Issue 158: Reduce memory consumption in the hDirac_mem handle */ +#define BRATE_SWITCHING_FRAMEWORK /* Bitrate switching changes related to the general framework */ +#define BRATE_SWITCHING_RENDERING /* Bitrate switching changes related to the renderers */ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index b11ba6cd396164ad19265c11ddd5dab15c0c4edc..b8d4e66cf4cb9ccdd09be64b1072a6d83a2b6f55 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -398,3 +398,92 @@ ivas_error ivas_hp20_dec_reconfig( return error; } + + +#ifdef BRATE_SWITCHING_RENDERING +/*-------------------------------------------------------------------* + * ivas_cldfb_dec_reconfig() + * + * Allocate, initialize, and configure CLDFB handles in case of bitrate switching + *-------------------------------------------------------------------*/ + +ivas_error ivas_cldfb_dec_reconfig( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ + int16_t numCldfbAnalyses_old, /* i : number of CLDFB analysis instances in previous frame */ + const int16_t numCldfbSyntheses_old /* i : number of CLDFB synthesis instances in previous frame */ +) +{ + int16_t i, numCldfbAnalyses, numCldfbSyntheses; + DECODER_CONFIG_HANDLE hDecoderConfig; + ivas_error error; + + hDecoderConfig = st_ivas->hDecoderConfig; + + ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses, &numCldfbSyntheses ); + + /* special case, if there was one transport channel in the previous frame and more than one in the current frame, + remove the second CLDFB here, it was for CNA/CNG */ + if ( st_ivas->ivas_format == SBA_FORMAT && nchan_transport_old == 1 && numCldfbAnalyses_old == 2 && st_ivas->nchan_transport > 1 ) + { + deleteCldfb( &( st_ivas->cldfbAnaDec[1] ) ); + st_ivas->cldfbAnaDec[1] = NULL; + numCldfbAnalyses_old--; + } + + /* resample CLDFB analysis instances */ + for ( i = 0; i < min( numCldfbAnalyses, numCldfbAnalyses_old ); i++ ) + { + if ( ( st_ivas->cldfbAnaDec[i]->no_channels * st_ivas->cldfbAnaDec[i]->no_col ) != ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ) ) + { + resampleCldfb( st_ivas->cldfbAnaDec[i], hDecoderConfig->output_Fs ); + } + } + + /* Analysis*/ + if ( numCldfbAnalyses_old > numCldfbAnalyses ) + { + /* delete superfluous CLDFB synthesis instances */ + for ( i = numCldfbAnalyses; i < numCldfbAnalyses_old; i++ ) + { + deleteCldfb( &( st_ivas->cldfbAnaDec[i] ) ); + st_ivas->cldfbAnaDec[i] = NULL; + } + } + else if ( numCldfbAnalyses_old < numCldfbAnalyses ) + { + /* create additional CLDFB synthesis instances */ + for ( i = numCldfbAnalyses_old; i < numCldfbAnalyses; i++ ) + { + if ( ( error = openCldfb( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + + /* Synthesis */ + if ( numCldfbSyntheses_old > numCldfbSyntheses ) + { + /* delete superfluous CLDFB synthesis instances */ + for ( i = numCldfbSyntheses; i < numCldfbSyntheses_old; i++ ) + { + deleteCldfb( &( st_ivas->cldfbSynDec[i] ) ); + st_ivas->cldfbSynDec[i] = NULL; + } + } + else if ( numCldfbSyntheses_old < numCldfbSyntheses ) + { + /* create additional CLDFB synthesis instances */ + for ( i = numCldfbSyntheses_old; i < numCldfbSyntheses; i++ ) + { + if ( ( error = openCldfb( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + + return IVAS_ERR_OK; +} +#endif diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index f8c19d0c10a84a711746a5cf2877d4c4d21ef811..5f9e908481d3aec147024820d2126d476ef364cf 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -262,6 +262,10 @@ ivas_error ivas_dirac_dec_config( * set input parameters *-----------------------------------------------------------------*/ +#ifdef BRATE_SWITCHING_FRAMEWORK + st_ivas->nchan_transport = nchan_transport_orig; +#endif + if ( flag_config == DIRAC_OPEN ) { hDirAC->slot_size = (int16_t) ( ( output_Fs / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX ); @@ -276,8 +280,9 @@ ivas_error ivas_dirac_dec_config( return IVAS_ERR_OK; } +#ifndef BRATE_SWITCHING_FRAMEWORK st_ivas->nchan_transport = nchan_transport_orig; - +#endif if ( nchan_transport_orig > 2 && hDirAC->hOutSetup.is_loudspeaker_setup && st_ivas->renderer_type == RENDERER_DIRAC ) { hDirAC->synthesisConf = DIRAC_SYNTHESIS_PSD_LS; @@ -872,8 +877,9 @@ ivas_error ivas_dirac_dec_config( st_ivas->hDirAC = hDirAC; } +#ifndef BRATE_SWITCHING_FRAMEWORK st_ivas->nchan_transport = nchan_transport_orig; - +#endif return error; } diff --git a/lib_dec/ivas_dirac_dec_binaural_functions.c b/lib_dec/ivas_dirac_dec_binaural_functions.c index 14181931391bb3582b822a3237c61af313fb2e0a..ee02a1bfe1c2f87b66515ce1451d2311811b3a62 100644 --- a/lib_dec/ivas_dirac_dec_binaural_functions.c +++ b/lib_dec/ivas_dirac_dec_binaural_functions.c @@ -98,9 +98,21 @@ ivas_error ivas_dirac_dec_init_binaural_data( float binCenterFreq, tmpFloat; ivas_error error; - if ( ( hBinaural = (DIRAC_DEC_BIN_HANDLE) count_malloc( sizeof( DIRAC_DEC_BIN_DATA ) ) ) == NULL ) +#ifdef BRATE_SWITCHING_RENDERING + hBinaural = st_ivas->hDiracDecBin; + + if ( hBinaural == NULL ) +#endif { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC binaural handle " ); + if ( ( hBinaural = (DIRAC_DEC_BIN_HANDLE) count_malloc( sizeof( DIRAC_DEC_BIN_DATA ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC binaural handle " ); + } + +#ifdef BRATE_SWITCHING_RENDERING + hBinaural->hTdDecorr = NULL; + hBinaural->hReverb = NULL; +#endif } nBins = st_ivas->hDirAC->num_freq_bands; @@ -189,18 +201,31 @@ ivas_error ivas_dirac_dec_init_binaural_data( { mvr2r( parametricEarlyPartEneCorrection, hBinaural->earlyPartEneCorrection, nBins ); - if ( hBinaural->useSubframeMode ) +#ifdef BRATE_SWITCHING_RENDERING + /* reconfiguration needed when Reverb. parameters are changed -> close and open the handle again */ + if ( hBinaural->hReverb != NULL && ( ( hBinaural->hReverb->numBins != nBins ) || + ( hBinaural->useSubframeMode && hBinaural->hReverb->blockSize != CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES ) || + ( !hBinaural->useSubframeMode && hBinaural->hReverb->blockSize != CLDFB_NO_COL_MAX ) ) ) { - if ( ( error = ivas_binaural_reverb_open( &hBinaural->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, st_ivas->hIntSetup.output_config, output_Fs, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) != IVAS_ERR_OK ) - { - return error; - } + ivas_binaural_reverb_close( &( hBinaural->hReverb ) ); } - else + + if ( hBinaural->hReverb == NULL ) +#endif { - if ( ( error = ivas_binaural_reverb_open( &hBinaural->hReverb, nBins, CLDFB_NO_COL_MAX, NULL, st_ivas->hIntSetup.output_config, output_Fs, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) != IVAS_ERR_OK ) + if ( hBinaural->useSubframeMode ) { - return error; + if ( ( error = ivas_binaural_reverb_open( &hBinaural->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, st_ivas->hIntSetup.output_config, output_Fs, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + if ( ( error = ivas_binaural_reverb_open( &hBinaural->hReverb, nBins, CLDFB_NO_COL_MAX, NULL, st_ivas->hIntSetup.output_config, output_Fs, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) != IVAS_ERR_OK ) + { + return error; + } } } } @@ -219,7 +244,13 @@ ivas_error ivas_dirac_dec_init_binaural_data( { if ( st_ivas->hDecoderConfig->ivas_total_brate >= IVAS_13k2 && st_ivas->ivas_format == SBA_FORMAT ) { - ivas_spar_td_decorr_dec_open( &( hBinaural->hTdDecorr ), output_Fs, 3, 1 ); +#ifdef BRATE_SWITCHING_RENDERING + if ( hBinaural->hTdDecorr == NULL ) +#endif + { + ivas_spar_td_decorr_dec_open( &( hBinaural->hTdDecorr ), output_Fs, 3, 1 ); + } + if ( st_ivas->hDecoderConfig->ivas_total_brate < IVAS_24k4 ) { hBinaural->hTdDecorr->pTrans_det->duck_mult_fac = IVAS_TDET_DUCK_MULT_FAC_PARA_BIN_LOW_BR; @@ -236,7 +267,11 @@ ivas_error ivas_dirac_dec_init_binaural_data( } else { +#ifdef BRATE_SWITCHING_RENDERING + ivas_spar_td_decorr_dec_close( &( hBinaural->hTdDecorr ) ); +#else hBinaural->hTdDecorr = NULL; +#endif } st_ivas->hDiracDecBin = hBinaural; diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index fe043c746bb767909a9e5e6e62a295fb0935076c..975fb604805a3131d590896ca5fc0051359221c6 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -549,26 +549,37 @@ ivas_error ivas_sba_dec_reconfigure( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { - int16_t i; - int16_t nchan_transport, nchan_transport_old; - int16_t nSCE_old, nCPE_old, nchan_hp20_old; +#ifdef BRATE_SWITCHING_RENDERING + int16_t nchan_transport_old, nSCE_old, nCPE_old, nchan_hp20_old; +#else + int16_t i, nchan_transport_old, nSCE_old, nCPE_old, nchan_hp20_old; +#endif AUDIO_CONFIG intern_config_old; +#ifdef BRATE_SWITCHING_RENDERING + int16_t numCldfbAnalyses_old, numCldfbSyntheses_old; +#else int16_t numCldfbAnalyses_old, numCldfbAnalyses, numCldfbSyntheses, numCldfbSyntheses_old; +#endif int16_t sba_dirac_stereo_flag_old; int32_t ivas_total_brate, last_ivas_total_brate; + DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; error = IVAS_ERR_OK; - ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; + hDecoderConfig = st_ivas->hDecoderConfig; + ivas_total_brate = hDecoderConfig->ivas_total_brate; + last_ivas_total_brate = hDecoderConfig->last_ivas_total_brate; /*-----------------------------------------------------------------* - * Allocate, initalize, and configure SBA and rendering handles + * Set SBA high-level parameters + * Save old SBA high-level parameters *-----------------------------------------------------------------*/ ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); +#ifndef BRATE_SWITCHING_RENDERING numCldfbAnalyses = 0; +#endif nchan_hp20_old = getNumChanSynthesis( st_ivas ); @@ -579,9 +590,12 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); - ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &nchan_transport, st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); + ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &st_ivas->nchan_transport, st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); + - st_ivas->nchan_transport = nchan_transport; + /*-----------------------------------------------------------------* + * Renderer selection + *-----------------------------------------------------------------*/ /* renderer might have changed */ intern_config_old = st_ivas->intern_config; @@ -593,9 +607,45 @@ ivas_error ivas_sba_dec_reconfigure( ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); } +#ifdef BRATE_SWITCHING_RENDERING + /*-------------------------------------------------------------------* + * Reallocate and initialize binaural rendering handles + *--------------------------------------------------------------------*/ + + if ( st_ivas->hBinRenderer == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + /* open fastconv binaural renderer */ + if ( ( error = ivas_binRenderer_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->hBinRenderer != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + ivas_binRenderer_close( &st_ivas->hBinRenderer ); + } + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + /* open parametric binaural renderer */ + if ( ( error = ivas_dirac_dec_init_binaural_data( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) ) + { + ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); + } +#endif + + /*-----------------------------------------------------------------* + * hDirAC decoder handle configuration + *-----------------------------------------------------------------*/ + if ( st_ivas->sba_mode != SBA_MODE_SPAR ) { - st_ivas->sba_dirac_stereo_flag = ( st_ivas->nchan_transport == 1 && st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ); + st_ivas->sba_dirac_stereo_flag = ( st_ivas->nchan_transport == 1 && hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ); if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_mode, -1 ) ) != IVAS_ERR_OK ) { @@ -607,15 +657,15 @@ ivas_error ivas_sba_dec_reconfigure( int16_t sba_order_internal; sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); - ivas_spar_config( st_ivas->hDecoderConfig->ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, st_ivas->sid_format ); + ivas_spar_config( hDecoderConfig->ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, st_ivas->sid_format ); - if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_mode, IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_mode, IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) != IVAS_ERR_OK ) { return error; } } - if ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC && ( last_ivas_total_brate > IVAS_SID_5k2 || nchan_transport != nchan_transport_old ) && ( st_ivas->sba_mode != SBA_MODE_SPAR ) ) + if ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC && ( last_ivas_total_brate > IVAS_SID_5k2 || st_ivas->nchan_transport != nchan_transport_old ) && ( st_ivas->sba_mode != SBA_MODE_SPAR ) ) { if ( st_ivas->hDirAC != NULL ) { @@ -662,17 +712,31 @@ ivas_error ivas_sba_dec_reconfigure( * CLDFB instances *-----------------------------------------------------------------*/ +#ifdef BRATE_SWITCHING_RENDERING + ivas_cldfb_dec_reconfig( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ); +#else ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses, &numCldfbSyntheses ); /* special case, if there was one transport channel in the previous frame and more than one in the current frame, remove the second CLDFB here, it was for CNA/CNG */ - if ( nchan_transport_old == 1 && numCldfbAnalyses_old == 2 && nchan_transport > 1 ) + if ( nchan_transport_old == 1 && numCldfbAnalyses_old == 2 && st_ivas->nchan_transport > 1 ) { deleteCldfb( &( st_ivas->cldfbAnaDec[1] ) ); st_ivas->cldfbAnaDec[1] = NULL; numCldfbAnalyses_old--; } +#ifdef BRATE_SWITCHING_RENDERING + /* resample CLDFB analysis instances */ + for ( i = 0; i < min( numCldfbAnalyses, numCldfbAnalyses_old ); i++ ) + { + if ( ( st_ivas->cldfbAnaDec[i]->no_channels * st_ivas->cldfbAnaDec[i]->no_col ) != ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ) ) + { + resampleCldfb( st_ivas->cldfbAnaDec[i], hDecoderConfig->output_Fs ); + } + } +#endif + /* Analysis*/ if ( numCldfbAnalyses_old > numCldfbAnalyses ) { @@ -688,7 +752,7 @@ ivas_error ivas_sba_dec_reconfigure( /* create additional CLDFB synthesis instances */ for ( i = numCldfbAnalyses_old; i < numCldfbAnalyses; i++ ) { - if ( ( error = openCldfb( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } @@ -710,14 +774,15 @@ ivas_error ivas_sba_dec_reconfigure( /* create additional CLDFB synthesis instances */ for ( i = numCldfbSyntheses_old; i < numCldfbSyntheses; i++ ) { - if ( ( error = openCldfb( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } } } +#endif - +#ifndef BRATE_SWITCHING_RENDERING /*-------------------------------------------------------------------* * Reallocate and initialize binaural rendering handles *--------------------------------------------------------------------*/ @@ -747,6 +812,7 @@ ivas_error ivas_sba_dec_reconfigure( { ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); } +#endif return error; } diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index 223d23d695cb720917abc71225a3c91e7c13d28c..b83cb1233f09c7a416d4e35eddfae0a713d239b6 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -131,6 +131,10 @@ ivas_error ivas_dirac_enc_open( } else { +#ifdef BRATE_SWITCHING_FRAMEWORK + hDirAC->num_samples_synchro_delay = 0; +#endif + for ( i = 0; i < DIRAC_MAX_ANA_CHANS; i++ ) { hDirAC->sba_synchro_buffer[i] = NULL; diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 18c3b93fb91f2a1b60806cc9a1cd82e6a20494bd..9fbf63c952f4fd0c0b0dfbb27c6f5606385f0e03 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -44,6 +44,48 @@ #include "wmops.h" +#ifdef BRATE_SWITCHING_FRAMEWORK +/*-------------------------------------------------------------------* + * set_mct_enc_params() + * + * Set hMCT handle parameters + *-------------------------------------------------------------------*/ + +static void set_mct_enc_params( + MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + const SBA_MODE sba_mode, /* i : SBA mode */ + const uint16_t b_nchan_change /* i : flag indicating different channel count */ +) +{ + int16_t n; + + if ( b_nchan_change ) + { + hMCT->currBlockDataCnt = 0; + + /*Initialize bits required to signal channel-pair index*/ + hMCT->bitsChannelPairIndex = max( 1, (int16_t) ( floor( ( log( hMCT->nchan_out_woLFE * ( hMCT->nchan_out_woLFE - 1 ) / 2 - 1 ) / log( 2. ) ) ) + 1 ) ); + + set_s( hMCT->lowE_ch, 0, MCT_MAX_CHANNELS ); + + for ( n = 0; n < MCT_MAX_CHANNELS; n++ ) + { + set_f( hMCT->lastxCorrMatrix[n], 0, MCT_MAX_CHANNELS ); + } + } + + hMCT->hbr_mct = 0; + if ( sba_mode == SBA_MODE_SPAR && ivas_total_brate >= IVAS_256k ) + { + hMCT->hbr_mct = 1; + } + + return; +} +#endif + + /*-------------------------------------------------------------------* * ivas_mct_enc() * @@ -276,6 +318,10 @@ ivas_error create_mct_enc( * Initializations *-----------------------------------------------------------------*/ +#ifdef BRATE_SWITCHING_FRAMEWORK + set_mct_enc_params( hMCT, ivas_total_brate, st_ivas->sba_mode, 1 ); +#else + hMCT->currBlockDataCnt = 0; /*Initialize bits required to signal channel-pair index*/ @@ -292,6 +338,7 @@ ivas_error create_mct_enc( { hMCT->hbr_mct = 1; } +#endif st_ivas->hMCT = hMCT; @@ -332,6 +379,13 @@ ivas_error mct_enc_reconfigure( hMCT->nchan_out_woLFE = st_ivas->hEncoderConfig->nchan_inp - 1; /* LFE channel is coded separately */ hMCT->num_lfe = TRUE; } +#ifdef BRATE_SWITCHING_FRAMEWORK + else if ( ivas_format == SBA_FORMAT ) + { + hMCT->nchan_out_woLFE = st_ivas->nchan_transport; + hMCT->num_lfe = FALSE; + } +#else else if ( ivas_format == SBA_FORMAT && st_ivas->hDirAC ) // VE: this condition to be reviewed together with the following one { hMCT->nchan_out_woLFE = ivas_get_sba_num_TCs( ivas_total_brate, st_ivas->sba_analysis_order ); @@ -342,6 +396,7 @@ ivas_error mct_enc_reconfigure( hMCT->nchan_out_woLFE = ivas_sba_get_nchan( st_ivas->sba_analysis_order, st_ivas->hEncoderConfig->sba_planar ); hMCT->num_lfe = FALSE; } +#endif else { assert( !"IVAS format currently not supported for MCT" ); @@ -454,6 +509,9 @@ ivas_error mct_enc_reconfigure( * Initializations *-----------------------------------------------------------------*/ +#ifdef BRATE_SWITCHING_FRAMEWORK + set_mct_enc_params( hMCT, ivas_total_brate, st_ivas->sba_mode, b_nchan_change ); +#else if ( b_nchan_change ) { hMCT->currBlockDataCnt = 0; @@ -467,6 +525,7 @@ ivas_error mct_enc_reconfigure( set_f( hMCT->lastxCorrMatrix[n], 0, MCT_MAX_CHANNELS ); } } +#endif return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_binauralRenderer.c b/lib_rend/ivas_binauralRenderer.c index 53f8dbcfa308c0048a1a43da134bdf0c12f61f7a..09713a6f5cc8a26c96c4f030c3f67aa205022507 100644 --- a/lib_rend/ivas_binauralRenderer.c +++ b/lib_rend/ivas_binauralRenderer.c @@ -552,10 +552,17 @@ ivas_error ivas_binRenderer_open( } ivas_output_init( &out_setup, AUDIO_CONFIG_7_1_4 ); - if ( ( error = ivas_sba_get_hoa_dec_matrix( out_setup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK ) + +#ifdef BRATE_SWITCHING_RENDERING + if ( st_ivas->hoa_dec_mtx == NULL ) +#endif { - return error; + if ( ( error = ivas_sba_get_hoa_dec_matrix( out_setup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK ) + { + return error; + } } + hBinRenderer->hoa_dec_mtx = st_ivas->hoa_dec_mtx; st_ivas->binaural_latency_ns = (int32_t) ( FASTCONV_BRIR_latency_s * 1000000000.f ); } diff --git a/lib_rend/ivas_binaural_reverb.c b/lib_rend/ivas_binaural_reverb.c index b03c8c005322f630cf0a91005ff99e96d0cd4909..db12954a1e95ab01d1cf5dc42a78e2a32d78f252 100644 --- a/lib_rend/ivas_binaural_reverb.c +++ b/lib_rend/ivas_binaural_reverb.c @@ -538,6 +538,9 @@ void ivas_binaural_reverb_close( } count_free( ( *hReverb ) ); +#ifdef BRATE_SWITCHING_RENDERING + ( *hReverb ) = NULL; +#endif return; }