From 602dfad2ec2f209ff874bf408571798e6e35fe22 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 24 Nov 2022 10:32:00 +0200 Subject: [PATCH 1/4] Implements bitrate switching within McMASA and partially to other MC modes. --- lib_com/ivas_mcmasa_com.c | 37 +++ lib_com/ivas_prot.h | 47 +++ lib_com/options.h | 6 +- lib_com/swb_tbe_com.c | 4 + lib_dec/ivas_core_dec.c | 1 - lib_dec/ivas_corecoder_dec_reconfig.c | 221 +++++++++++++- lib_dec/ivas_cpe_dec.c | 5 + lib_dec/ivas_init_dec.c | 29 +- lib_dec/ivas_masa_dec.c | 2 +- lib_dec/ivas_mcmasa_dec.c | 148 ++++++++++ lib_dec/ivas_mct_dec.c | 144 +++++++++- lib_dec/ivas_sba_dec.c | 4 + lib_dec/ivas_sce_dec.c | 5 + lib_enc/igf_enc.c | 0 lib_enc/ivas_corecoder_enc_reconfig.c | 398 +++++++++++++++++++++++++- lib_enc/ivas_cpe_enc.c | 8 +- lib_enc/ivas_init_enc.c | 24 ++ lib_enc/ivas_mc_param_enc.c | 2 +- lib_enc/ivas_mcmasa_enc.c | 114 ++++++++ lib_enc/ivas_mct_enc.c | 48 ++++ lib_enc/ivas_sba_enc.c | 4 + lib_enc/ivas_sce_enc.c | 4 + 22 files changed, 1237 insertions(+), 18 deletions(-) create mode 100644 lib_dec/ivas_mcmasa_dec.c mode change 100755 => 100644 lib_enc/igf_enc.c diff --git a/lib_com/ivas_mcmasa_com.c b/lib_com/ivas_mcmasa_com.c index 2441cf7973..a080befbaa 100644 --- a/lib_com/ivas_mcmasa_com.c +++ b/lib_com/ivas_mcmasa_com.c @@ -91,6 +91,7 @@ void ivas_mcmasa_set_separate_channel_mode( return; } +#ifndef MCMASA_BITRATE_SWITCHING /*--------------------------------------------------------------------------* * ivas_mcmasa_mono_brate() * @@ -112,3 +113,39 @@ int32_t ivas_mcmasa_mono_brate( return ( const int32_t )( MCMASA_MONOBITRATIO * ivas_total_brate ); } } +#else +/*--------------------------------------------------------------------------* + * ivas_mcmasa_split_brate() + * + * Split the total bitrate to elements in McMASA + *--------------------------------------------------------------------------*/ +void ivas_mcmasa_split_brate( + const uint8_t separateChannelEnabled, /* i : Transport running in "separate channel" mode */ + const int32_t ivas_total_brate, /* i : Total bitrate available to be split */ + const int16_t nSCE, /* i : Number of SCEs in use (0 or 1) */ + const int16_t nCPE, /* i : Number of CPEs in use (0 or 1) */ + int32_t *brate_sce, /* o : Pointer to SCE element bitrate */ + int32_t *brate_cpe /* o : Pointer to CPE element bitrate */ +) +{ + if ( separateChannelEnabled ) + { + /* 25% of total bitrate is used for SCE below 96 kb/s (separated mono channel), otherwise 30% */ + if ( ivas_total_brate < IVAS_96k ) + { + *brate_sce = (int32_t) ( MCMASA_MONOBITRATIO_64k * ivas_total_brate ); + } + else + { + *brate_sce = (int32_t) ( MCMASA_MONOBITRATIO * ivas_total_brate ); + } + + *brate_cpe = ivas_total_brate - *brate_sce; + } + else + { + *brate_sce = nSCE > 0 ? ivas_total_brate / ( nCPE + nSCE ) : 0; + *brate_cpe = nCPE > 0 ? ivas_total_brate / ( nCPE + nSCE ) : 0; + } +} +#endif diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 27b9d21c0d..170c8eafa2 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -128,7 +128,14 @@ ivas_error ivas_corecoder_enc_reconfig( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ const int16_t nSCE_old, /* i : number of SCEs in previous frame */ const int16_t nCPE_old, /* i : number of CPEs in previous frame */ +#ifdef MCMASA_BITRATE_SWITCHING + const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ + const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */ + const int32_t brate_CPE, /* i : bitrate to be set for the CPEs */ + const MC_MODE last_mc_mode /* i : switching between MC modes: last mode */ +#else const int16_t nchan_transport_old /* i : number of TCs in previous frame */ +#endif ); #endif @@ -333,11 +340,21 @@ void ivas_mct_dec_close( #ifdef CORECODER_BITRATE_SWITCHING ivas_error ivas_corecoder_dec_reconfig( +#ifdef MCMASA_BITRATE_SWITCHING + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nSCE_old, /* i : number of SCEs in previous frame */ + const int16_t nCPE_old, /* i : number of CPEs in previous frame */ + const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ + const int16_t sba_dirac_stereo_flag_old, /* i : signal stereo rendering using DFT upmix in previous frame */ + const int32_t brate_SCE, /* i : bitrate to be set for the SCEs      */ + const int32_t brate_CPE /* i : bitrate to be set for the CPEs */ +#else Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSCE_old, /* i : number of SCEs in previous frame */ const int16_t nCPE_old, /* i : number of CPEs in previous frame */ const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ const int16_t sba_dirac_stereo_flag_old /* i : signal stereo output for SBA DirAC in previous frame */ +#endif ); ivas_error ivas_hp20_dec_reconfig( @@ -4779,6 +4796,16 @@ void ivas_mcmasa_enc_close( const int32_t input_Fs /* i : input sampling rate */ ); +#ifdef MCMASA_BITRATE_SWITCHING +ivas_error ivas_mcmasa_enc_reconfig( + Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ +); + +ivas_error ivas_mcmasa_dec_reconfig( + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ +); +#endif + void ivas_mcmasa_setNumTransportChannels( int16_t* nchan_transport, /* o : Pointer to number of transport channels to be set */ int16_t* element_mode, /* o : Pointer to element mode to be set */ @@ -4791,10 +4818,21 @@ void ivas_mcmasa_set_separate_channel_mode( const int32_t ivas_total_brate /* i : Total bitrate of IVAS */ ); +#ifndef MCMASA_BITRATE_SWITCHING /*! r: McMASA SCE bitrate */ int32_t ivas_mcmasa_mono_brate( const int32_t ivas_total_brate /* i : IVAS total bitrate */ ); +#else +void ivas_mcmasa_split_brate( + const uint8_t separateChannelEnabled, /* i : Transport running in "separate channel" mode */ + const int32_t ivas_total_brate, /* i : Total bitrate available to be split */ + const int16_t nSCE, /* i : Number of SCEs in use (0 or 1) */ + const int16_t nCPE, /* i : Number of CPEs in use (0 or 1) */ + int32_t *brate_sce, /* o : Pointer to SCE element bitrate */ + int32_t *brate_cpe /* o : Pointer to CPE element bitrate */ +); +#endif void ivas_mcmasa_enc( MCMASA_ENC_HANDLE hMcMasa, /* i/o: Encoder McMASA handle */ @@ -4819,6 +4857,15 @@ void ivas_mcmasa_param_est_enc( const int16_t nchan_inp /* i : Number of input channels */ ); +#ifdef MCMASA_BITRATE_SWITCHING +void ivas_mcmasa_dmx_modify( + const int16_t n_samples, /* i : input frame length in samples */ + float dmx[][L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS )], /* i/o: downmix signal to be transformed into another format */ + const uint8_t n_chnls_dmx_old, /* i : number of downmix channels in the old format */ + const uint8_t n_chnls_dmx_new /* i : number of downmix channels in the target format */ +); +#endif + void v_multc_acc( const float x[], /* i : Input vector */ const float c, /* i : Constant */ diff --git a/lib_com/options.h b/lib_com/options.h index 28fb60c2e9..6b63e63f71 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -58,7 +58,7 @@ #ifdef DEBUGGING -#define MEM_COUNT_DETAILS /* RAM counting tool: print per sub-structure details */ +/*#define MEM_COUNT_DETAILS*/ /* RAM counting tool: print per sub-structure details */ /*#define DEBUG_MODE_INFO*/ /* output most important parameters to the subdirectory "res/" */ #ifdef DEBUG_MODE_INFO @@ -159,7 +159,9 @@ #define CORECODER_BITRATE_SWITCHING /* Issue 133: support bitrate switching in core-coder */ #define MC_BITRATE_SWITCHING /* Issue 116: support bitrate switching in MC format */ - +#ifdef MC_BITRATE_SWITCHING +#define MCMASA_BITRATE_SWITCHING /* Issue 116: support bitrate switching in MC format: sub-part of McMASA modes */ +#endif /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_com/swb_tbe_com.c b/lib_com/swb_tbe_com.c index 4291feaed9..c8961f88dd 100644 --- a/lib_com/swb_tbe_com.c +++ b/lib_com/swb_tbe_com.c @@ -1891,6 +1891,10 @@ void tbe_celp_exc( return; } +#ifdef MCMASA_BITRATE_SWITCHING + assert( bwe_exc != NULL && "BWE excitation is NULL" ); +#endif + if ( L_frame == L_FRAME ) { offset = tbe_celp_exc_offset( T0, T0_frac ); diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index ad350f4e30..12274f8762 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -442,7 +442,6 @@ ivas_error ivas_core_dec( } } #endif - } /*---------------------------------------------------------------------* diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index 8f0ba78857..479ed862af 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -50,15 +50,25 @@ /*-------------------------------------------------------------------* * ivas_corecoder_dec_reconfig() * - * Allocate, initalize, and configure SCE/CPE/MCT handles in case of bitrate switching + * Allocate, initialize, and configure SCE/CPE/MCT handles in case of bitrate switching *-------------------------------------------------------------------*/ ivas_error ivas_corecoder_dec_reconfig( +#ifdef MCMASA_BITRATE_SWITCHING + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nSCE_old, /* i : number of SCEs in previous frame */ + const int16_t nCPE_old, /* i : number of CPEs in previous frame */ + const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ + const int16_t sba_dirac_stereo_flag_old, /* i : signal stereo rendering using DFT upmix in previous frame */ + const int32_t brate_SCE, /* i : bitrate to be set for the SCEs      */ + const int32_t brate_CPE /* i : bitrate to be set for the CPEs */ +#else Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSCE_old, /* i : number of SCEs in previous frame */ const int16_t nCPE_old, /* i : number of CPEs in previous frame */ const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ const int16_t sba_dirac_stereo_flag_old /* i : signal stereo output for SBA DirAC in previous frame */ +#endif ) { int16_t n, sce_id, cpe_id, output_frame; @@ -82,7 +92,12 @@ ivas_error ivas_corecoder_dec_reconfig( *-----------------------------------------------------------------*/ /* remove dummy CPE element for DFT stereo-like upmix */ +#ifdef MCMASA_BITRATE_SWITCHING + if ( ( ( st_ivas->ivas_format == SBA_FORMAT ) && sba_dirac_stereo_flag_old && !st_ivas->sba_dirac_stereo_flag ) || + ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_MCMASA ) && sba_dirac_stereo_flag_old ) ) +#else if ( st_ivas->ivas_format == SBA_FORMAT && sba_dirac_stereo_flag_old && !st_ivas->sba_dirac_stereo_flag ) +#endif { st_ivas->hCPE[0]->hCoreCoder[0] = NULL; st_ivas->hCPE[0]->hCoreCoder[1] = NULL; @@ -99,6 +114,204 @@ ivas_error ivas_corecoder_dec_reconfig( } } +#ifdef MCMASA_BITRATE_SWITCHING + if ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_MCMASA ) ) + { + float *save_synth, *save_hb_synth; + save_synth = NULL; + save_hb_synth = NULL; + + /* McMASA specific handling: delete anything old and create completely new ones. + * sba_dirac_stereo_flag: STEREO rendering from 1 transport channel with low delay using DFT stereo */ + if ( ( nSCE_old > 0 ) && sba_dirac_stereo_flag_old && st_ivas->sba_dirac_stereo_flag ) + { + /* save the old buffers, if they exist */ + save_synth = st_ivas->hSCE[0]->save_synth; + save_hb_synth = st_ivas->hSCE[0]->save_hb_synth; + st_ivas->hSCE[0]->save_synth = NULL; + st_ivas->hSCE[0]->save_hb_synth = NULL; + } + + for ( sce_id = 0; sce_id < nSCE_old; sce_id++ ) + { + destroy_sce_dec( st_ivas->hSCE[sce_id] ); + st_ivas->hSCE[sce_id] = NULL; + } + for ( cpe_id = 0; cpe_id < nCPE_old; cpe_id++ ) + { + destroy_cpe_dec( st_ivas->hCPE[cpe_id] ); + st_ivas->hCPE[cpe_id] = NULL; + } + for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) + { + if ( ( error = create_sce_dec( st_ivas, sce_id, brate_SCE ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( ( sce_id == 0 ) && sba_dirac_stereo_flag_old && st_ivas->sba_dirac_stereo_flag ) + { + /* replace the newly created buffers with the old ones */ + if ( st_ivas->hSCE[0]->save_synth != NULL ) + { + count_free( st_ivas->hSCE[0]->save_synth ); + st_ivas->hSCE[0]->save_synth = NULL; + } + if ( st_ivas->hSCE[0]->save_hb_synth != NULL ) + { + count_free( st_ivas->hSCE[0]->save_hb_synth ); + st_ivas->hSCE[0]->save_hb_synth = NULL; + } + st_ivas->hSCE[0]->save_synth = save_synth; + st_ivas->hSCE[0]->save_hb_synth = save_hb_synth; + } + } + for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + { + if ( ( error = create_cpe_dec( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + else + { + /* non-McMASA */ + if ( ( st_ivas->nSCE == nSCE_old ) && ( st_ivas->nCPE == nCPE_old ) ) + { + for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) + { + st_ivas->hSCE[sce_id]->element_brate = brate_SCE; + st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ + } + + for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + { + st_ivas->hCPE[cpe_id]->element_brate = brate_CPE; + + /* prepare bitstream buffers */ + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ + } + } + + if ( st_ivas->nCPE > 1 ) + { + if ( ( error = mct_dec_reconfigure( st_ivas, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + else + { + nSCE_existing = min( nSCE_old, st_ivas->nSCE ); + nCPE_existing = min( nCPE_old, st_ivas->nCPE ); + + // VE: TBV - try to reuse the CoreCoder + /* destroy superfluous core coder elements */ + for ( sce_id = st_ivas->nSCE; sce_id < nSCE_old; sce_id++ ) + { + destroy_sce_dec( st_ivas->hSCE[sce_id] ); + st_ivas->hSCE[sce_id] = NULL; + } + + for ( cpe_id = st_ivas->nCPE; cpe_id < nCPE_old; cpe_id++ ) + { + destroy_cpe_dec( st_ivas->hCPE[cpe_id] ); + st_ivas->hCPE[cpe_id] = NULL; + } + + if ( st_ivas->nCPE <= 1 && st_ivas->hMCT != NULL ) + { + ivas_mct_dec_close( &st_ivas->hMCT ); + } + + /* special case, if we have MCT now and had a single CPE before, remove the MDCT Stereo handles from the first CPE*/ + if ( st_ivas->nCPE > 1 && nCPE_old == 1 ) + { + count_free( st_ivas->hCPE[0]->hStereoMdct ); + st_ivas->hCPE[0]->hStereoMdct = NULL; + } + + for ( sce_id = 0; sce_id < nSCE_existing; sce_id++ ) + { + st_ivas->hSCE[sce_id]->element_brate = brate_SCE; + st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ + } + for ( ; sce_id < st_ivas->nSCE; sce_id++ ) + { + if ( ( error = create_sce_dec( st_ivas, sce_id, brate_SCE ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + for ( cpe_id = 0; cpe_id < nCPE_existing; cpe_id++ ) + { + st_ivas->hCPE[cpe_id]->element_brate = brate_CPE; + + /* prepare bitstream buffers */ + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ + } + } + for ( ; cpe_id < st_ivas->nCPE; cpe_id++ ) + { + if ( ( error = create_cpe_dec( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + if ( st_ivas->nCPE > 1 && nCPE_old <= 1 ) + { + if ( nCPE_old == 1 ) + { + /* set correct nominal bitrates and igf config already here, needed for the correct init of the MDCT Stereo handles for MCT */ + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + st_ivas->hCPE[0]->hCoreCoder[n]->total_brate = st_ivas->hCPE[0]->element_brate; + st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal = (int16_t) ( st_ivas->hCPE[0]->element_brate / FRAMES_PER_SEC ); + st_ivas->hCPE[0]->hCoreCoder[n]->igf = 0; + } + } + + if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->hMCT != NULL && st_ivas->nCPE > 1 ) + { + if ( ( error = mct_dec_reconfigure( st_ivas, st_ivas->nchan_transport != nchan_transport_old ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* special case, if we have a single CPE and had MCT before we need to init the MDCT stereo handles here */ + if ( st_ivas->nCPE == 1 && nCPE_old > 1 ) + { + if ( ( st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) count_malloc( sizeof( STEREO_MDCT_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MDCT Stereo \n" ) ); + } + + st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->use_itd = 0; + st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->reverse_dmx = 0; + st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->smooth_ratio = 1.f; + + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + /* reset mct_chan_mode */ + st_ivas->hCPE[0]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_REGULAR; + } + } + } + } +#else if ( st_ivas->nchan_transport == nchan_transport_old ) { for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) @@ -233,9 +446,15 @@ ivas_error ivas_corecoder_dec_reconfig( } } } +#endif /* create dummy CPE element for DFT stereo-like upmix */ +#ifdef MCMASA_BITRATE_SWITCHING + if ( ( ( st_ivas->ivas_format == SBA_FORMAT ) && st_ivas->sba_dirac_stereo_flag && !sba_dirac_stereo_flag_old ) || + ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_MCMASA ) && st_ivas->sba_dirac_stereo_flag ) ) +#else if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_dirac_stereo_flag && !sba_dirac_stereo_flag_old ) +#endif { if ( ( error = create_cpe_dec( st_ivas, 0, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index e8c0493ad1..e8da2b8e48 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -535,8 +535,13 @@ ivas_error ivas_cpe_dec( for ( i = 0; i < n; i++ ) { +#ifdef MCMASA_BITRATE_SWITCHING + 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_init_dec.c b/lib_dec/ivas_init_dec.c index e183eda8e0..3d4fc869fe 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -272,7 +272,7 @@ ivas_error ivas_dec_setup( { if ( ( error = doSanityChecks_IVAS( st_ivas ) ) != IVAS_ERR_OK ) { - return IVAS_ERROR( error, "Sanitiy checks failed" ); + return IVAS_ERROR( error, "Sanity checks failed" ); } if ( ( error = ivas_init_decoder( st_ivas ) ) != IVAS_ERR_OK ) @@ -724,7 +724,7 @@ ivas_error ivas_init_decoder( } /*-----------------------------------------------------------------* - * Allocate and initalize SCE/CPE and other handles + * Allocate and initialize SCE/CPE and other handles *-----------------------------------------------------------------*/ if ( st_ivas->ivas_format == MONO_FORMAT ) @@ -1056,6 +1056,10 @@ ivas_error ivas_init_decoder( } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { +#ifdef MCMASA_BITRATE_SWITCHING + int32_t brate_sce, brate_cpe; +#endif + ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) @@ -1092,8 +1096,18 @@ ivas_error ivas_init_decoder( } } +#ifdef MCMASA_BITRATE_SWITCHING + ivas_mcmasa_split_brate( st_ivas->hOutSetup.separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &brate_sce, &brate_cpe ); +#endif + for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { +#ifdef MCMASA_BITRATE_SWITCHING + if ( ( error = create_sce_dec( st_ivas, sce_id, brate_sce ) ) != IVAS_ERR_OK ) + { + return error; + } +#else if ( st_ivas->hOutSetup.separateChannelEnabled ) { if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_mcmasa_mono_brate( ivas_total_brate ) ) ) != IVAS_ERR_OK ) @@ -1108,15 +1122,23 @@ ivas_error ivas_init_decoder( return error; } } +#endif reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] ); } for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { +#ifdef MCMASA_BITRATE_SWITCHING + st_ivas->element_mode_init = IVAS_CPE_MDCT; /* element_mode_init was IVAS_SCE for SCE initialization */ + if ( ( error = create_cpe_dec( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK ) + { + return error; + } +#else if ( st_ivas->hOutSetup.separateChannelEnabled ) { - st_ivas->element_mode_init = IVAS_CPE_MDCT; + st_ivas->element_mode_init = IVAS_CPE_MDCT; /* element_mode_init was IVAS_SCE for SCE initialization */ if ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate - st_ivas->hSCE[0]->element_brate ) ) != IVAS_ERR_OK ) { @@ -1132,6 +1154,7 @@ ivas_error ivas_init_decoder( return error; } } +#endif for ( n = 0; n < CPE_CHANNELS; n++ ) { diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index b4aa18f2a1..3d30ba2071 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1063,7 +1063,7 @@ ivas_error ivas_masa_dec_reconfigure( last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; /*-----------------------------------------------------------------* - * Allocate and initalize SCE/CPE and other handles + * Allocate and initialize SCE/CPE and other handles *-----------------------------------------------------------------*/ bit_stream = st_ivas->hSCE[0] != NULL ? st_ivas->hSCE[0]->hCoreCoder[0]->bit_stream : st_ivas->hCPE[0]->hCoreCoder[0]->bit_stream; diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec.c new file mode 100644 index 0000000000..7b7cf935a4 --- /dev/null +++ b/lib_dec/ivas_mcmasa_dec.c @@ -0,0 +1,148 @@ +/****************************************************************************************************** + +(C) 2022 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, +Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., +Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, +Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other +contributors to this repository. All Rights Reserved. + +This software is protected by copyright law and by international treaties. +The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, +Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., +Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, +Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other +contributors to this repository retain full ownership rights in their respective contributions in +the software. This notice grants no license of any kind, including but not limited to patent +license, nor is any license granted by implication, estoppel or otherwise. + +Contributors are required to enter into the IVAS codec Public Collaboration agreement before making +contributions. + +This software is provided "AS IS", without any express or implied warranties. The software is in the +development stage. It is intended exclusively for experts who have experience with such software and +solely for the purpose of inspection. All implied warranties of non-infringement, merchantability +and fitness for a particular purpose are hereby disclaimed and excluded. + +Any dispute, controversy or claim arising under or in relation to providing this software shall be +submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in +accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and +the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ +#include + +#include "ivas_cnst.h" +#include "ivas_prot.h" +#include "options.h" +#include "prot.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmops.h" + +#ifdef MCMASA_BITRATE_SWITCHING + +/*------------------------------------------------------------------------- + * Local constants + *------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------- + * Local function prototypes + *------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------- + * ivas_mcmasa_dec_reconfig() + * + * Reconfigure McMASA decoder + *------------------------------------------------------------------------*/ +ivas_error ivas_mcmasa_dec_reconfig( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + ivas_error error; + int32_t ivas_total_brate; + + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + + /* close the old MASA instance */ + if ( st_ivas->hMasa != NULL ) + { + ivas_masa_dec_close( st_ivas->hMasa ); + } + + /* get new McMASA settings */ + ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); + ivas_mcmasa_set_separate_channel_mode( &( st_ivas->hOutSetup.separateChannelEnabled ), &( st_ivas->hOutSetup.separateChannelIndex ), ivas_total_brate ); + + /* renderer might change as an effect from the transport mode change */ + ivas_renderer_select( st_ivas ); + + /* side effect of the renderer selection can be a changed internal config. this is also needed when switching from non-McMASA */ + ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); + ivas_mcmasa_set_separate_channel_mode( &( st_ivas->hIntSetup.separateChannelEnabled ), &( st_ivas->hIntSetup.separateChannelIndex ), ivas_total_brate ); + + if ( ( error = ivas_masa_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + st_ivas->sba_dirac_stereo_flag = ( st_ivas->nchan_transport == 1 && st_ivas->hOutSetup.output_config == AUDIO_CONFIG_STEREO ); + + if ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_MCMASA_MONO_STEREO ) + { + if ( st_ivas->hDirAC == NULL ) + { + if ( ( error = ivas_dirac_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + /*-------------------------------------------------------------------* + * Close binaural rendering handles and re-allocate proper ones + * in McMASA renderer_type can be only RENDERER_BINAURAL_PARAMETRIC, RENDERER_BINAURAL_PARAMETRIC_ROOM + *--------------------------------------------------------------------*/ + if ( st_ivas->hBinRenderer != NULL ) + { + ivas_binRenderer_close( &st_ivas->hBinRenderer ); + } + + if ( st_ivas->hDiracDecBin == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) + { + /* 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 ) + { + if ( st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + /* close unneeded renderer */ + ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); + } + else + { + /* the decision for useTdDecorr is done in ivas_dirac_dec_init_binaural_data(). here, comparing against the same condition. */ + if ( st_ivas->hDiracDecBin->useTdDecorr != ( st_ivas->hDecoderConfig->ivas_total_brate < IVAS_48k && st_ivas->nchan_transport == 1 ) ) + { + /* st_ivas->hDiracDecBin->useTdDecorr will 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; + } + } + } + } + return error; +} +#endif diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index bb46fbdea0..e91062ecc2 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -644,11 +644,18 @@ ivas_error ivas_mc_dec_reconfig( const int16_t last_mc_mode /* i : last frame MC mode */ ) { +#ifdef MCMASA_BITRATE_SWITCHING + int16_t nchan_transport_old, nSCE_old, nCPE_old, sba_dirac_stereo_flag_old, nchan_hp20_old; +#else int16_t nchan_transport_old, nSCE_old, nCPE_old, sba_dirac_stereo_flag_old; +#endif int16_t numCldfbAnalyses_old, numCldfbAnalyses, numCldfbSyntheses, numCldfbSyntheses_old, i; RENDERER_TYPE renderer_type_old; ivas_error error; MC_MODE mc_mode; +#ifdef MCMASA_BITRATE_SWITCHING + int32_t new_brate_SCE, new_brate_CPE; +#endif error = IVAS_ERR_OK; nchan_transport_old = st_ivas->nchan_transport; @@ -664,13 +671,23 @@ ivas_error ivas_mc_dec_reconfig( nCPE_old = st_ivas->nCPE; sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag; +#ifdef MCMASA_BITRATE_SWITCHING + /* special handling needed for the hp20 buffers for McMASA */ + if ( last_mc_mode == MC_MODE_MCMASA ) + { + nchan_hp20_old = getNumChanSynthesis( st_ivas ); + } + else + { + nchan_hp20_old = nchan_transport_old; + } +#endif /* renderer might have changed, reselect */ renderer_type_old = st_ivas->renderer_type; ivas_renderer_select( st_ivas ); + if ( st_ivas->mc_mode == MC_MODE_MCT ) { - - st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ) ); st_ivas->nSCE = 0; st_ivas->nCPE = st_ivas->nchan_transport / 2; @@ -758,8 +775,10 @@ ivas_error ivas_mc_dec_reconfig( } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { +#ifdef MCMASA_BITRATE_SWITCHING ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), st_ivas->hDecoderConfig->ivas_total_brate ); +#endif if ( last_mc_mode != MC_MODE_MCMASA ) { if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) @@ -767,12 +786,19 @@ ivas_error ivas_mc_dec_reconfig( return error; } +#ifndef MCMASA_BITRATE_SWITCHING if ( ( error = ivas_masa_dec_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - +#else + } + if ( ( error = ivas_mcmasa_dec_reconfig( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif /* ls conversion */ if ( st_ivas->hLsSetUpConversion != NULL ) { @@ -801,6 +827,19 @@ ivas_error ivas_mc_dec_reconfig( } } +#ifdef MCMASA_BITRATE_SWITCHING + if ( st_ivas->mc_mode != MC_MODE_MCMASA ) + { + if ( st_ivas->nchan_transport == 1 ) + { + st_ivas->element_mode_init = IVAS_SCE; + } + else + { + st_ivas->element_mode_init = IVAS_CPE_MDCT; + } + } +#else if ( st_ivas->nchan_transport == 1 ) { st_ivas->element_mode_init = IVAS_SCE; @@ -809,7 +848,7 @@ ivas_error ivas_mc_dec_reconfig( { st_ivas->element_mode_init = IVAS_CPE_MDCT; } - +#endif /* re-configure core coder*/ /* special case: MCT->ParamMC with more than 2 TC, CPE 1 stays, but has the wrong mct_chan_mode in channel 1 @@ -848,13 +887,33 @@ ivas_error ivas_mc_dec_reconfig( st->mct_chan_mode = MCT_CHAN_MODE_LFE; } +#ifdef MCMASA_BITRATE_SWITCHING + if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + { + 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 ); + } + else + { + new_brate_SCE = 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; + } + 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 ) +#else if ( ( error = ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old ) ) != IVAS_ERR_OK ) +#endif { return error; } /* re-configure hp20 memories */ +#ifdef MCMASA_BITRATE_SWITCHING + ivas_hp20_dec_reconfig( st_ivas, nchan_hp20_old ); +#else ivas_hp20_dec_reconfig( st_ivas, nchan_transport_old ); +#endif /*-----------------------------------------------------------------* * CLDFB instances @@ -884,6 +943,25 @@ ivas_error ivas_mc_dec_reconfig( } } +#ifdef MCMASA_BITRATE_SWITCHING + if ( ( last_mc_mode == MC_MODE_MCMASA ) && ( nchan_transport_old == 1 ) && ( ( renderer_type_old == RENDERER_BINAURAL_PARAMETRIC ) || ( renderer_type_old == RENDERER_BINAURAL_PARAMETRIC_ROOM ) || ( renderer_type_old == RENDERER_STEREO_PARAMETRIC ) ) ) + { + /* cldfbAnaDec[1] might be modified by DirAC (ivas_dirac_dec_binaural_internal) -> re-instantiate it */ + if ( ( numCldfbAnalyses_old > 1 ) && ( numCldfbAnalyses > 1 ) ) + { + deleteCldfb( &( st_ivas->cldfbAnaDec[1] ) ); + st_ivas->cldfbAnaDec[1] = NULL; + if ( ( error = openCldfb( &( st_ivas->cldfbAnaDec[1] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + for ( i = 0; i < numCldfbAnalyses; i++ ) + { + cldfb_reset_memory( st_ivas->cldfbAnaDec[i] ); + } +#endif /* Synthesis */ if ( numCldfbSyntheses_old > numCldfbSyntheses ) { @@ -905,8 +983,14 @@ ivas_error ivas_mc_dec_reconfig( } } } +#ifdef MCMASA_BITRATE_SWITCHING + for ( i = 0; i < numCldfbSyntheses; i++ ) + { + cldfb_reset_memory( st_ivas->cldfbSynDec[i] ); + } +#endif - /* Allocat the LFE handle that is coded seperately after the allocation of the core coders*/ + /* Allocate the LFE handle that is coded separately after the allocation of the core coders */ if ( st_ivas->mc_mode == MC_MODE_MCT && st_ivas->hLFE == NULL ) { @@ -923,8 +1007,37 @@ ivas_error ivas_mc_dec_reconfig( set_zero( st_ivas->hLFE->prior_out_buffer, L_FRAME48k ); } - /* renderers */ +#ifdef MCMASA_BITRATE_SWITCHING + if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + { + if ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_MCMASA_MONO_STEREO ) ) + { + if ( st_ivas->hDirAC != NULL ) + { + /* reconfigure existing DirAC dec */ + if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + /* init a new DirAC dec */ + if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + else if ( ( st_ivas->renderer_type == RENDERER_DISABLE ) && ( st_ivas->hDirAC != NULL ) ) + { + ivas_dirac_dec_close( st_ivas->hDirAC ); + st_ivas->hDirAC = NULL; + } + } +#endif + if ( renderer_type_old != st_ivas->renderer_type ) { AUDIO_CONFIG output_config; @@ -946,10 +1059,29 @@ ivas_error ivas_mc_dec_reconfig( { ivas_td_binaural_close( &st_ivas->hBinRendererTd ); } +#ifdef MCMASA_BITRATE_SWITCHING + if ( st_ivas->hDiracDecBin != NULL ) + { + if ( 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 ); + } + else + { + /* 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; + } + } + } +#else if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); } +#endif /* init necessary new renderers */ if ( st_ivas->hBinRenderer == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) ) { diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index bd02907991..08d263e8ac 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -605,7 +605,11 @@ ivas_error ivas_sba_dec_reconfigure( *-----------------------------------------------------------------*/ #ifdef CORECODER_BITRATE_SWITCHING +#ifdef MCMASA_BITRATE_SWITCHING + ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ); +#else ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old ); +#endif /*-----------------------------------------------------------------* * HP20 memories diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index 1eadd39cb0..fcc5cc8985 100644 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -285,8 +285,13 @@ ivas_error ivas_sce_dec( for ( i = 0; i < n; i++ ) { +#ifdef MCMASA_BITRATE_SWITCHING + 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/igf_enc.c b/lib_enc/igf_enc.c old mode 100755 new mode 100644 diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index f4b302eefd..e76a73046a 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -51,10 +51,20 @@ *-------------------------------------------------------------------*/ ivas_error ivas_corecoder_enc_reconfig( +#ifdef MCMASA_BITRATE_SWITCHING + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + const int16_t nSCE_old, /* i : number of SCEs in previous frame */ + const int16_t nCPE_old, /* i : number of CPEs in previous frame */ + const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ + const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */ + const int32_t brate_CPE, /* i : bitrate to be set for the CPEs */ + const MC_MODE last_mc_mode /* i : switching between MC modes: last mode */ +#else Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ const int16_t nSCE_old, /* i : number of SCEs in previous frame */ const int16_t nCPE_old, /* i : number of CPEs in previous frame */ const int16_t nchan_transport_old /* i : number of TCs in previous frame */ +#endif ) { int16_t n, sce_id, cpe_id; @@ -63,7 +73,9 @@ ivas_error ivas_corecoder_enc_reconfig( BSTR_ENC_HANDLE hBstr, hMetaData; Indice *ind_list, *ind_list_metadata; int16_t nb_bits_tot, next_ind, last_ind; +#ifndef MCMASA_BITRATE_SWITCHING int32_t ivas_total_brate; +#endif ENCODER_CONFIG_HANDLE hEncoderConfig; ivas_error error; @@ -72,7 +84,9 @@ ivas_error ivas_corecoder_enc_reconfig( *-----------------------------------------------------------------*/ hEncoderConfig = st_ivas->hEncoderConfig; +#ifndef MCMASA_BITRATE_SWITCHING ivas_total_brate = hEncoderConfig->ivas_total_brate; +#endif error = IVAS_ERR_OK; len_inp_memory = (int16_t) ( hEncoderConfig->input_Fs / FRAMES_PER_SEC ); @@ -85,18 +99,31 @@ ivas_error ivas_corecoder_enc_reconfig( * Switching between SCE(s)/CPE(s)/MCT *-----------------------------------------------------------------*/ +#ifdef MCMASA_BITRATE_SWITCHING + if ( ( st_ivas->nSCE == nSCE_old ) && ( st_ivas->nCPE == nCPE_old ) && ( st_ivas->mc_mode == last_mc_mode ) ) +#else if ( st_ivas->nchan_transport == nchan_transport_old ) +#endif { + /* transport layout (and mode) stays the same -> take a shortcut in reconfig */ for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { copy_encoder_config( st_ivas, st_ivas->hSCE[sce_id]->hCoreCoder[0], 0 ); +#ifdef MCMASA_BITRATE_SWITCHING + st_ivas->hSCE[sce_id]->element_brate = brate_SCE; +#else st_ivas->hSCE[sce_id]->element_brate = ivas_total_brate / st_ivas->nchan_transport; +#endif st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ } for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { +#ifdef MCMASA_BITRATE_SWITCHING + st_ivas->hCPE[cpe_id]->element_brate = brate_CPE; +#else st_ivas->hCPE[cpe_id]->element_brate = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS; +#endif /* prepare bitstream buffers */ for ( n = 0; n < CPE_CHANNELS; n++ ) @@ -117,11 +144,23 @@ ivas_error ivas_corecoder_enc_reconfig( } else { +#ifdef MCMASA_BITRATE_SWITCHING + /* transport layout changes */ ind_list = NULL; + ind_list_metadata = NULL; +#else + ind_list = NULL; +#endif hBstr = NULL; hMetaData = NULL; +#ifdef MCMASA_BITRATE_SWITCHING + /* get the index list pointers + * taking the hBstr from the first active element gets the start of ind_list + * the same for the hMetaData */ +#else /* get the index list pointers */ +#endif if ( nSCE_old ) { hBstr = st_ivas->hSCE[0]->hCoreCoder[0]->hBstr; @@ -140,12 +179,368 @@ ivas_error ivas_corecoder_enc_reconfig( #endif /* save bitstream information */ +#ifdef MCMASA_BITRATE_SWITCHING + ind_list = hBstr->ind_list; /* pointer to the beginning of the global list */ +#else ind_list = hBstr->ind_list; +#endif nb_bits_tot = hBstr->nb_bits_tot; next_ind = hBstr->next_ind; last_ind = hBstr->last_ind; - ind_list_metadata = hMetaData->ind_list; + ind_list_metadata = hMetaData->ind_list; /* pointer to the beginning of the global list */ + +#ifdef MCMASA_BITRATE_SWITCHING + if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + { + int16_t buff_len; + buff_len = L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ); + + if ( last_mc_mode == MC_MODE_MCMASA ) + { + /* copy earlier dmx buffers */ + if ( nSCE_old > 0 ) + { + set_zero( input_buff[0], buff_len ); + mvr2r( st_ivas->hSCE[0]->hCoreCoder[0]->input_buff, input_buff[0], len_inp_memory ); + } + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + set_zero( input_buff[n + 1], buff_len ); + if ( nCPE_old > 0 ) + { + mvr2r( st_ivas->hCPE[0]->hCoreCoder[n]->input_buff, input_buff[n + 1], len_inp_memory ); + } + } + + /* modify the dmx format to match the new one */ + ivas_mcmasa_dmx_modify( buff_len, input_buff, nSCE_old + 2 * nCPE_old, st_ivas->nSCE + 2 * st_ivas->nCPE ); + } + + for ( sce_id = 0; sce_id < nSCE_old; sce_id++ ) + { + destroy_sce_enc( st_ivas->hSCE[sce_id] ); + st_ivas->hSCE[sce_id] = NULL; + } + for ( cpe_id = 0; cpe_id < nCPE_old; cpe_id++ ) + { + destroy_cpe_enc( st_ivas->hCPE[cpe_id] ); + st_ivas->hCPE[cpe_id] = NULL; + } + + if ( st_ivas->nSCE ) + { + if ( ( error = create_sce_enc( st_ivas, 0, brate_SCE ) ) != IVAS_ERR_OK ) + { + return error; + } + /* restore information of the bitstream already written */ + st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list = ind_list + 0 * MAX_NUM_INDICES; + + /* only SCE in use => update bitstream info */ + st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->last_ind = last_ind; + st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_bits_tot = nb_bits_tot; + st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->next_ind = next_ind; + + /* in case of 2+1, this is not really used, but let's keep it for compatibility */ + st_ivas->hSCE[0]->hMetaData->ind_list = ind_list_metadata + 0 * MAX_BITS_METADATA; + reset_indices_enc( st_ivas->hSCE[0]->hMetaData, MAX_BITS_METADATA ); + + if ( last_mc_mode == MC_MODE_MCMASA ) + { + /* restore input buffer */ + mvr2r( input_buff[0], st_ivas->hSCE[0]->hCoreCoder[0]->input_buff, len_inp_memory ); + } + } + + if ( st_ivas->nCPE ) + { + if ( st_ivas->hMcMasa->separateChannelEnabled ) + { + st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; + } + if ( ( error = create_cpe_enc( st_ivas, 0, brate_CPE ) ) != IVAS_ERR_OK ) + { + return error; + } + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + st_ivas->hCPE[0]->hCoreCoder[n]->hBstr->ind_list = ind_list + ( 0 * CPE_CHANNELS + n + st_ivas->nSCE ) * MAX_NUM_INDICES; + + if ( ( st_ivas->nSCE > 0 ) || ( n > 0 ) ) /* the started bitstream is in SCE or in the first core channel of CPE => reset here */ + { + reset_indices_enc( st_ivas->hCPE[0]->hCoreCoder[n]->hBstr, MAX_NUM_INDICES ); + } + else + { + /* restore the beginning of the bitstream */ + st_ivas->hCPE[0]->hCoreCoder[n]->hBstr->last_ind = last_ind; + st_ivas->hCPE[0]->hCoreCoder[n]->hBstr->nb_bits_tot = nb_bits_tot; + st_ivas->hCPE[0]->hCoreCoder[n]->hBstr->next_ind = next_ind; + } + if ( hEncoderConfig->Opt_DTX_ON ) + { + st_ivas->hCPE[0]->hCoreCoder[n]->cng_sba_flag = 1; + } + + if ( last_mc_mode == MC_MODE_MCMASA ) + { + /* restore input buffer */ + mvr2r( st_ivas->hCPE[0]->hCoreCoder[n]->input_buff, input_buff[n + 1], len_inp_memory ); + } + } + st_ivas->hCPE[0]->hMetaData->ind_list = ind_list_metadata + st_ivas->nSCE * MAX_NUM_INDICES; + reset_indices_enc( st_ivas->hCPE[0]->hMetaData, MAX_BITS_METADATA ); + } + } /* end of McMASA special handling */ + else + { + n_CoreCoder_existing = min( st_ivas->nchan_transport, nchan_transport_old ); + + /* destroy superfluous core-coder elements */ + for ( sce_id = st_ivas->nSCE; sce_id < nSCE_old; sce_id++ ) + { + /* save input audio buffers */ + if ( n_CoreCoder_existing > sce_id ) + { + mvr2r( st_ivas->hSCE[sce_id]->hCoreCoder[0]->input_buff, input_buff[sce_id], len_inp_memory ); + } + + destroy_sce_enc( st_ivas->hSCE[sce_id] ); + st_ivas->hSCE[sce_id] = NULL; + } + + for ( cpe_id = st_ivas->nCPE; cpe_id < nCPE_old; cpe_id++ ) + { + /* save input audio buffers */ + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + if ( n_CoreCoder_existing > cpe_id * CPE_CHANNELS + n ) + { + mvr2r( st_ivas->hCPE[cpe_id]->hCoreCoder[0]->input_buff, input_buff[( cpe_id - st_ivas->nCPE ) * CPE_CHANNELS + n], len_inp_memory ); /* TODO VoiceAge: Please check if this should be hCoreCoder[n] */ + } + } + + destroy_cpe_enc( st_ivas->hCPE[cpe_id] ); + st_ivas->hCPE[cpe_id] = NULL; + } + + if ( st_ivas->nCPE <= 1 && st_ivas->hMCT != NULL ) + { + ivas_mct_enc_close( st_ivas->hMCT ); + st_ivas->hMCT = NULL; + } + + /* special case, if we have MCT now and had a single CPE before, remove the MDCT Stereo handles */ + if ( st_ivas->nCPE > 1 && nCPE_old == 1 ) + { + count_free( st_ivas->hCPE[0]->hStereoMdct ); + st_ivas->hCPE[0]->hStereoMdct = NULL; + } + + /* create missing core coder elements and set element bitrates for already existing ones */ + if ( st_ivas->nSCE > 0 ) + { + nSCE_existing = min( nSCE_old, st_ivas->nSCE ); + + for ( sce_id = 0; sce_id < nSCE_existing; sce_id++ ) + { + copy_encoder_config( st_ivas, st_ivas->hSCE[sce_id]->hCoreCoder[0], 0 ); + st_ivas->hSCE[sce_id]->element_brate = brate_SCE; + st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ + } + + for ( sce_id = nSCE_existing; sce_id < st_ivas->nSCE; sce_id++ ) + { + if ( ( error = create_sce_enc( st_ivas, sce_id, brate_SCE ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* propagate input audio buffers */ + if ( n_CoreCoder_existing > sce_id ) + { + mvr2r( input_buff[sce_id], st_ivas->hSCE[sce_id]->hCoreCoder[0]->input_buff, len_inp_memory ); + } + + /* prepare bitstream buffers */ + st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->ind_list = ind_list + sce_id * MAX_NUM_INDICES; + + /* only reset indices if it is not the first index list, this already contains the IVAS format bits */ + if ( sce_id > 0 ) + { + reset_indices_enc( st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr, MAX_NUM_INDICES ); + } + else + { + st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->last_ind = last_ind; + st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->nb_bits_tot = nb_bits_tot; + st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->next_ind = next_ind; + } + + st_ivas->hSCE[sce_id]->hMetaData->ind_list = ind_list_metadata + sce_id * MAX_BITS_METADATA; + reset_indices_enc( st_ivas->hSCE[sce_id]->hMetaData, MAX_BITS_METADATA ); + } + } + + if ( st_ivas->nCPE > 0 ) + { + nCPE_existing = min( nCPE_old, st_ivas->nCPE ); + + for ( cpe_id = 0; cpe_id < nCPE_existing; cpe_id++ ) + { + st_ivas->hCPE[cpe_id]->element_brate = brate_CPE; + + /* prepare bitstream buffers */ + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + copy_encoder_config( st_ivas, st_ivas->hCPE[cpe_id]->hCoreCoder[n], 0 ); + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ + } + } + + for ( cpe_id = nCPE_existing; cpe_id < st_ivas->nCPE; cpe_id++ ) + { + if ( ( error = create_cpe_enc( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* propagate input audio buffers */ + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + if ( n_CoreCoder_existing > cpe_id * CPE_CHANNELS + n ) + { + mvr2r( input_buff[n], st_ivas->hCPE[cpe_id]->hCoreCoder[0]->input_buff, len_inp_memory ); /* TODO VoiceAge: Please check if this should be hCoreCoder[n] */ + } + } + + /* prepare bitstream buffers */ + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->ind_list = ind_list + ( cpe_id * CPE_CHANNELS + n ) * MAX_NUM_INDICES; + if ( cpe_id * CPE_CHANNELS + n > 0 ) + { + reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, MAX_NUM_INDICES ); + } + else + { + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->last_ind = last_ind; + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_bits_tot = nb_bits_tot; + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->next_ind = next_ind; + } + + if ( hEncoderConfig->Opt_DTX_ON ) + { + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->cng_sba_flag = 1; + } + } + } + } + + if ( st_ivas->nCPE > 1 && nCPE_old <= 1 ) + { + if ( nCPE_old == 1 ) + { + /* set correct nominal bitrates and igf config already here, needed for the correct init of the MDCT Stereo handles for MCT */ + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + st_ivas->hCPE[0]->hCoreCoder[n]->total_brate = st_ivas->hCPE[0]->element_brate; + + st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal = (int16_t) ( st_ivas->hCPE[0]->element_brate / FRAMES_PER_SEC ); + st_ivas->hCPE[0]->hCoreCoder[n]->igf = getIgfPresent( st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, + st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal * FRAMES_PER_SEC, + st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, + st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode, + st_ivas->hCPE[0]->hCoreCoder[n]->mct_chan_mode ); + + if ( st_ivas->hCPE[0]->hCoreCoder[n]->igf ) + { + IGFEncSetMode( st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, + st_ivas->hCPE[0]->element_brate, + st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, + st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, + st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ); + } + } + } + + if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->hMCT != NULL && st_ivas->nCPE > 1 ) + { + if ( ( error = mct_enc_reconfigure( st_ivas, st_ivas->nchan_transport != nchan_transport_old ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* metadata handling for CPEs */ + if ( st_ivas->nCPE > 0 ) + { + if ( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData == NULL ) + { + if ( ( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData = (BSTR_ENC_HANDLE) count_malloc( sizeof( BSTR_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MetaData structure\n" ) ); + } + } + + st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->ind_list = ind_list_metadata; + reset_indices_enc( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData, MAX_BITS_METADATA ); + + for ( cpe_id = 0; cpe_id < st_ivas->nCPE - 1; cpe_id++ ) + { + if ( st_ivas->hCPE[cpe_id]->hMetaData != NULL ) + { + count_free( st_ivas->hCPE[cpe_id]->hMetaData ); + st_ivas->hCPE[cpe_id]->hMetaData = NULL; + } + } + } + + /* special case, if we have a single CPE and had MCT before we need to init the MDCT stereo handles here */ + if ( st_ivas->nCPE == 1 && nCPE_old > 1 ) + { + if ( ( st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct = (STEREO_MDCT_ENC_DATA_HANDLE) count_malloc( sizeof( STEREO_MDCT_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MDCT Stereo \n" ) ); + } + + /* set correct nominal bitrates and igf config already here, needed for the correct init of the MDCT Stereo handle */ + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + st_ivas->hCPE[0]->hCoreCoder[n]->total_brate = st_ivas->hCPE[0]->element_brate; + + st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal = (int16_t) ( st_ivas->hCPE[0]->element_brate / FRAMES_PER_SEC ); + st_ivas->hCPE[0]->hCoreCoder[n]->igf = getIgfPresent( st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, + st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal * FRAMES_PER_SEC, + st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, + st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode, + st_ivas->hCPE[0]->hCoreCoder[n]->mct_chan_mode ); + + if ( st_ivas->hCPE[0]->hCoreCoder[n]->igf ) + { + IGFEncSetMode( st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, + st_ivas->hCPE[0]->element_brate, + st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, + st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, + st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ); + } + + /* reset mct_chan_mode */ + st_ivas->hCPE[0]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_REGULAR; + } + + initMdctStereoEncData( st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct, hEncoderConfig->ivas_format, st_ivas->hCPE[st_ivas->nCPE - 1]->element_mode, st_ivas->hCPE[st_ivas->nCPE - 1]->element_brate, hEncoderConfig->max_bwidth, 0, NULL, 1 ); + st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->isSBAStereoMode = ( ( hEncoderConfig->ivas_format == SBA_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); + } + } + } +#else n_CoreCoder_existing = min( st_ivas->nchan_transport, nchan_transport_old ); /* destroy superfluous core-coder elements */ @@ -390,6 +785,7 @@ ivas_error ivas_corecoder_enc_reconfig( st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->isSBAStereoMode = ( ( hEncoderConfig->ivas_format == SBA_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); } } +#endif return error; } diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 15e3dcd6ba..dbc5f44a25 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -420,7 +420,11 @@ 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 MCMASA_BITRATE_SWITCHING + 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 /*----------------------------------------------------------------* @@ -821,7 +825,7 @@ ivas_error create_cpe_enc( /* we need the meta data handle also if we init as MC_FORMAT/MCT since it might be needed at a bit rate switch to ParamMC or McMASA and the metadata index list is only really reachable in the ivas_init_encoder() function and has to be connected to the MD handle there */ - if ( cpe_id == ( st_ivas->nCPE - 1 )) + if ( cpe_id == ( st_ivas->nCPE - 1 ) ) #else if ( !( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ) && ( cpe_id == ( st_ivas->nCPE - 1 ) ) ) #endif @@ -888,7 +892,7 @@ ivas_error create_cpe_enc( #ifdef DEBUGGING if ( hEncoderConfig->Opt_DTX_ON && ( hCPE->element_mode == IVAS_CPE_TD || hEncoderConfig->stereo_mode_cmdl == 1 ) && !( ivas_format == MASA_FORMAT && element_mode_init == IVAS_CPE_MDCT ) ) #else -if ( hEncoderConfig->Opt_DTX_ON && element_mode_init != IVAS_CPE_MDCT ) + if ( hEncoderConfig->Opt_DTX_ON && element_mode_init != IVAS_CPE_MDCT ) #endif { for ( n = 0; n < CPE_CHANNELS; n++ ) diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 4768eb3b24..e64c4e058b 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -617,6 +617,10 @@ ivas_error ivas_init_encoder( } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { +#ifdef MCMASA_BITRATE_SWITCHING + int32_t brate_sce, brate_cpe; +#endif + ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( hEncoderConfig->element_mode_init ), ivas_total_brate ); if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) @@ -634,8 +638,18 @@ ivas_error ivas_init_encoder( return error; } +#ifdef MCMASA_BITRATE_SWITCHING + ivas_mcmasa_split_brate( st_ivas->hMcMasa->separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &brate_sce, &brate_cpe ); +#endif + for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { +#ifdef MCMASA_BITRATE_SWITCHING + if ( ( error = create_sce_enc( st_ivas, sce_id, brate_sce ) ) != IVAS_ERR_OK ) + { + return error; + } +#else if ( st_ivas->hMcMasa->separateChannelEnabled ) { if ( ( error = create_sce_enc( st_ivas, sce_id, ivas_mcmasa_mono_brate( ivas_total_brate ) ) ) != IVAS_ERR_OK ) @@ -650,6 +664,7 @@ ivas_error ivas_init_encoder( return error; } } +#endif /* prepare bitstream buffers */ st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->ind_list = ind_list[sce_id]; @@ -661,6 +676,14 @@ ivas_error ivas_init_encoder( for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { +#ifdef MCMASA_BITRATE_SWITCHING + hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; + + if ( ( error = create_cpe_enc( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK ) + { + return error; + } +#else if ( st_ivas->hMcMasa->separateChannelEnabled ) { hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; @@ -677,6 +700,7 @@ ivas_error ivas_init_encoder( return error; } } +#endif /* prepare bitstream buffers */ for ( n = 0; n < CPE_CHANNELS; n++ ) diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index 8de7f442f5..238a58109b 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -282,7 +282,7 @@ ivas_error ivas_param_mc_reconfig( #ifdef DEBUGGING assert( hParamMC->hMetadataPMC.icc_map_full[i] != NULL ); #endif - if (hParamMC->hMetadataPMC.icc_map_full[i] != NULL) + if ( hParamMC->hMetadataPMC.icc_map_full[i] != NULL ) { count_free( hParamMC->hMetadataPMC.icc_map_full[i] ); hParamMC->hMetadataPMC.icc_map_full[i] = NULL; diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index a281ec4760..e79ac261ca 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -395,6 +395,50 @@ ivas_error ivas_mcmasa_enc_open( return error; } +#ifdef MCMASA_BITRATE_SWITCHING +/*------------------------------------------------------------------------- + * ivas_mcmasa_enc_reconfig() + * + * Reconfigure McMASA encoder + *------------------------------------------------------------------------*/ +ivas_error ivas_mcmasa_enc_reconfig( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +) +{ + int32_t ivas_total_brate; + ivas_error error; + + error = IVAS_ERR_OK; + + ivas_total_brate = st_ivas->hEncoderConfig->ivas_total_brate; + + if ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) + { + /* bitrate changed, may need to do something */ + + /* brute-force solution: close McMASA and re-instantiate with new settings */ + ivas_masa_enc_close( st_ivas->hMasa, st_ivas->nchan_transport, st_ivas->hEncoderConfig->ivas_format ); + ivas_mcmasa_enc_close( st_ivas->hMcMasa, st_ivas->hEncoderConfig->input_Fs ); + + /* Determine if to separate some channels from the analysis */ + ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->hEncoderConfig->element_mode_init ), ivas_total_brate ); + + if ( ( error = ivas_masa_enc_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = ivas_mcmasa_enc_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* core SCE, CPE reconfiguration happens later */ + } + + return error; +} +#endif /*--------------------------------------------------------------------------* * ivas_mcmasa_enc_close() @@ -1145,7 +1189,77 @@ void ivas_mcmasa_param_est_enc( return; } +#ifdef MCMASA_BITRATE_SWITCHING +void ivas_mcmasa_dmx_modify( + const int16_t n_samples, /* i : input frame length in samples */ + float dmx[][L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS )], /* i/o: downmix signal to be transformed into another format. TODO: buffer size into define? */ + const uint8_t n_chnls_dmx_old, /* i : number of downmix channels in the old format */ + const uint8_t n_chnls_dmx_new ) /* i : number of downmix channels in the target format */ +{ + /* assumed data ordering in **dmx: [sce][cpe_chnl0][cpe_chnl1], i.e., [c][l][r] */ + int16_t i; + + assert( ( n_chnls_dmx_old == 1 || n_chnls_dmx_old == 2 || n_chnls_dmx_old == 3 ) && "Input downmix may contain only 1-3 channels." ); + assert( ( n_chnls_dmx_new == 1 || n_chnls_dmx_new == 2 || n_chnls_dmx_new == 3 ) && "Output downmix may contain only 1-3 channels." ); + if ( n_chnls_dmx_old == n_chnls_dmx_new ) + { + /* same dmx layout -> nothing to do */ + return; + } + if ( n_chnls_dmx_old == 1 ) + { + /* split mono energy into identical channels */ + for ( i = 0; i < n_samples; i++ ) + { + if ( n_chnls_dmx_new == 2 ) + { + dmx[1][i] = dmx[0][i] * INV_SQRT2; + dmx[2][i] = dmx[1][i]; + } + else if ( n_chnls_dmx_new == 3 ) + { + dmx[0][i] = dmx[0][i] * INV_SQRT3; + } + } + } + else if ( n_chnls_dmx_old == 2 ) + { + for ( i = 0; i < n_samples; i++ ) + { + if ( n_chnls_dmx_new == 1 ) + { + /* sum l and r */ + dmx[0][i] = dmx[1][i] + dmx[2][i]; + } + else if ( n_chnls_dmx_new == 3 ) + { + dmx[0][i] = 0.5f * ( dmx[1][i] + dmx[2][i] ); + dmx[1][i] = dmx[1][i] - dmx[0][i]; + dmx[2][i] = dmx[2][i] - dmx[0][i]; + } + } + } + else if ( n_chnls_dmx_old == 3 ) + { + for ( i = 0; i < n_samples; i++ ) + { + if ( n_chnls_dmx_new == 1 ) + { + /* sum all channels */ + dmx[0][i] = dmx[0][i] + dmx[1][i] + dmx[2][i]; + } + else if ( n_chnls_dmx_new == 2 ) + { + /* mix center into sides */ + dmx[0][i] *= INV_SQRT2; + dmx[1][i] += dmx[0][i]; + dmx[2][i] += dmx[0][i]; + } + } + } +} +#endif /*--------------------------------------------------------------------------* * Local functions *--------------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index f4f8e6b8ee..0f2f2d4f01 100755 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -602,6 +602,9 @@ ivas_error ivas_mc_enc_reconfig( { int16_t nchan_transport_old, nSCE_old, nCPE_old; ivas_error error; +#ifdef MCMASA_BITRATE_SWITCHING + int32_t new_brate_SCE, new_brate_CPE; +#endif error = IVAS_ERR_OK; @@ -696,10 +699,17 @@ ivas_error ivas_mc_enc_reconfig( } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { +#ifdef MCMASA_BITRATE_SWITCHING + if ( last_mc_mode != MC_MODE_MCMASA ) + { + ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->hEncoderConfig->element_mode_init ), st_ivas->hEncoderConfig->ivas_total_brate ); + +#else ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->hEncoderConfig->element_mode_init ), st_ivas->hEncoderConfig->ivas_total_brate ); if ( last_mc_mode != MC_MODE_MCMASA ) { +#endif if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { return error; @@ -716,6 +726,17 @@ ivas_error ivas_mc_enc_reconfig( } } +#ifdef MCMASA_BITRATE_SWITCHING + else + { + /* reconfigure McMASA instance */ + if ( ( error = ivas_mcmasa_enc_reconfig( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif + if ( st_ivas->hParamMC != NULL ) { ivas_param_mc_enc_close( st_ivas->hParamMC, st_ivas->hEncoderConfig->input_Fs ); @@ -737,6 +758,19 @@ ivas_error ivas_mc_enc_reconfig( } } +#ifdef MCMASA_BITRATE_SWITCHING + if ( st_ivas->mc_mode != MC_MODE_MCMASA ) + { + if ( st_ivas->nchan_transport == 1 ) + { + st_ivas->hEncoderConfig->element_mode_init = IVAS_SCE; + } + else + { + st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; + } + } +#else if ( st_ivas->nchan_transport == 1 ) { st_ivas->hEncoderConfig->element_mode_init = IVAS_SCE; @@ -745,6 +779,7 @@ ivas_error ivas_mc_enc_reconfig( { st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; } +#endif /* re-configure core coder*/ /* special case: MCT->ParamMC with more than 2 TC, CPE 1 stays, but has the wrong mct_chan_mode in channel 1 @@ -789,8 +824,21 @@ ivas_error ivas_mc_enc_reconfig( st->mct_chan_mode = MCT_CHAN_MODE_LFE; } +#ifdef MCMASA_BITRATE_SWITCHING + if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + { + ivas_mcmasa_split_brate( st_ivas->hMcMasa->separateChannelEnabled, st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE ); + } + else + { + new_brate_SCE = st_ivas->hEncoderConfig->ivas_total_brate / st_ivas->nchan_transport; + new_brate_CPE = ( st_ivas->hEncoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS; + } + if ( ( error = ivas_corecoder_enc_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, new_brate_SCE, new_brate_CPE, last_mc_mode ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_corecoder_enc_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index e3564725f5..397a04e4a4 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -272,7 +272,11 @@ ivas_error ivas_sba_enc_reconfigure( * Allocate, initalize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ +#ifdef MCMASA_BITRATE_SWITCHING + ivas_corecoder_enc_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, ivas_total_brate / st_ivas->nchan_transport, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS, MC_MODE_NONE ); +#else ivas_corecoder_enc_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old ); +#endif #else if ( hEncoderConfig->nchan_transport == nchan_transport_old ) diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 651ba3b9e5..bd460c038c 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -178,7 +178,11 @@ 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 MCMASA_BITRATE_SWITCHING + 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 /*----------------------------------------------------------------* -- GitLab From 0b60f877dad9d8fdb6ff0f61d35d5b7b4d7d0575 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 28 Nov 2022 13:28:55 +0100 Subject: [PATCH 2/4] added missing new source file lib_dec/ivas_mcmasa_dec.c to the VS project --- Workspace_msvc/lib_dec.vcxproj | 1 + Workspace_msvc/lib_dec.vcxproj.filters | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 5860b0a970..2b44db88b2 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -291,6 +291,7 @@ + diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index 5476cf5588..df6c4bb090 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -584,6 +584,9 @@ dec_ivas_c + + dec_ivas_c + -- GitLab From 939dc7fca7d6399e3cc5bc81a33a89dad17b784a Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Tue, 6 Dec 2022 09:23:49 +0100 Subject: [PATCH 3/4] - removed cldfb analysis/synthesis reset after MC reconfig - removed special handling of McMASA in corecoder bitrate switching and merged the operations more in the common flow --- lib_dec/ivas_corecoder_dec_reconfig.c | 235 ++----------- lib_dec/ivas_mct_dec.c | 13 +- lib_enc/ivas_corecoder_enc_reconfig.c | 457 ++++++-------------------- 3 files changed, 132 insertions(+), 573 deletions(-) diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index 479ed862af..f2f37e1180 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -60,7 +60,7 @@ ivas_error ivas_corecoder_dec_reconfig( const int16_t nCPE_old, /* i : number of CPEs in previous frame */ const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ const int16_t sba_dirac_stereo_flag_old, /* i : signal stereo rendering using DFT upmix in previous frame */ - const int32_t brate_SCE, /* i : bitrate to be set for the SCEs      */ + const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */ const int32_t brate_CPE /* i : bitrate to be set for the CPEs */ #else Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -93,8 +93,8 @@ ivas_error ivas_corecoder_dec_reconfig( /* remove dummy CPE element for DFT stereo-like upmix */ #ifdef MCMASA_BITRATE_SWITCHING - if ( ( ( st_ivas->ivas_format == SBA_FORMAT ) && sba_dirac_stereo_flag_old && !st_ivas->sba_dirac_stereo_flag ) || - ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_MCMASA ) && sba_dirac_stereo_flag_old ) ) + if ( ( st_ivas->ivas_format == SBA_FORMAT && sba_dirac_stereo_flag_old && !st_ivas->sba_dirac_stereo_flag ) || + ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA && sba_dirac_stereo_flag_old && !st_ivas->sba_dirac_stereo_flag ) ) #else if ( st_ivas->ivas_format == SBA_FORMAT && sba_dirac_stereo_flag_old && !st_ivas->sba_dirac_stereo_flag ) #endif @@ -115,215 +115,28 @@ ivas_error ivas_corecoder_dec_reconfig( } #ifdef MCMASA_BITRATE_SWITCHING - if ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_MCMASA ) ) - { - float *save_synth, *save_hb_synth; - save_synth = NULL; - save_hb_synth = NULL; - - /* McMASA specific handling: delete anything old and create completely new ones. - * sba_dirac_stereo_flag: STEREO rendering from 1 transport channel with low delay using DFT stereo */ - if ( ( nSCE_old > 0 ) && sba_dirac_stereo_flag_old && st_ivas->sba_dirac_stereo_flag ) - { - /* save the old buffers, if they exist */ - save_synth = st_ivas->hSCE[0]->save_synth; - save_hb_synth = st_ivas->hSCE[0]->save_hb_synth; - st_ivas->hSCE[0]->save_synth = NULL; - st_ivas->hSCE[0]->save_hb_synth = NULL; - } - - for ( sce_id = 0; sce_id < nSCE_old; sce_id++ ) - { - destroy_sce_dec( st_ivas->hSCE[sce_id] ); - st_ivas->hSCE[sce_id] = NULL; - } - for ( cpe_id = 0; cpe_id < nCPE_old; cpe_id++ ) - { - destroy_cpe_dec( st_ivas->hCPE[cpe_id] ); - st_ivas->hCPE[cpe_id] = NULL; - } - for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) - { - if ( ( error = create_sce_dec( st_ivas, sce_id, brate_SCE ) ) != IVAS_ERR_OK ) - { - return error; - } - if ( ( sce_id == 0 ) && sba_dirac_stereo_flag_old && st_ivas->sba_dirac_stereo_flag ) - { - /* replace the newly created buffers with the old ones */ - if ( st_ivas->hSCE[0]->save_synth != NULL ) - { - count_free( st_ivas->hSCE[0]->save_synth ); - st_ivas->hSCE[0]->save_synth = NULL; - } - if ( st_ivas->hSCE[0]->save_hb_synth != NULL ) - { - count_free( st_ivas->hSCE[0]->save_hb_synth ); - st_ivas->hSCE[0]->save_hb_synth = NULL; - } - st_ivas->hSCE[0]->save_synth = save_synth; - st_ivas->hSCE[0]->save_hb_synth = save_hb_synth; - } - } - for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - if ( ( error = create_cpe_dec( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - else - { - /* non-McMASA */ - if ( ( st_ivas->nSCE == nSCE_old ) && ( st_ivas->nCPE == nCPE_old ) ) - { - for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) - { - st_ivas->hSCE[sce_id]->element_brate = brate_SCE; - st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ - } - - for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - st_ivas->hCPE[cpe_id]->element_brate = brate_CPE; - - /* prepare bitstream buffers */ - for ( n = 0; n < CPE_CHANNELS; n++ ) - { - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ - } - } - - if ( st_ivas->nCPE > 1 ) - { - if ( ( error = mct_dec_reconfigure( st_ivas, 0 ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - else - { - nSCE_existing = min( nSCE_old, st_ivas->nSCE ); - nCPE_existing = min( nCPE_old, st_ivas->nCPE ); - - // VE: TBV - try to reuse the CoreCoder - /* destroy superfluous core coder elements */ - for ( sce_id = st_ivas->nSCE; sce_id < nSCE_old; sce_id++ ) - { - destroy_sce_dec( st_ivas->hSCE[sce_id] ); - st_ivas->hSCE[sce_id] = NULL; - } - - for ( cpe_id = st_ivas->nCPE; cpe_id < nCPE_old; cpe_id++ ) - { - destroy_cpe_dec( st_ivas->hCPE[cpe_id] ); - st_ivas->hCPE[cpe_id] = NULL; - } - - if ( st_ivas->nCPE <= 1 && st_ivas->hMCT != NULL ) - { - ivas_mct_dec_close( &st_ivas->hMCT ); - } - - /* special case, if we have MCT now and had a single CPE before, remove the MDCT Stereo handles from the first CPE*/ - if ( st_ivas->nCPE > 1 && nCPE_old == 1 ) - { - count_free( st_ivas->hCPE[0]->hStereoMdct ); - st_ivas->hCPE[0]->hStereoMdct = NULL; - } - - for ( sce_id = 0; sce_id < nSCE_existing; sce_id++ ) - { - st_ivas->hSCE[sce_id]->element_brate = brate_SCE; - st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ - } - for ( ; sce_id < st_ivas->nSCE; sce_id++ ) - { - if ( ( error = create_sce_dec( st_ivas, sce_id, brate_SCE ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - for ( cpe_id = 0; cpe_id < nCPE_existing; cpe_id++ ) - { - st_ivas->hCPE[cpe_id]->element_brate = brate_CPE; - - /* prepare bitstream buffers */ - for ( n = 0; n < CPE_CHANNELS; n++ ) - { - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ - } - } - for ( ; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - if ( ( error = create_cpe_dec( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - if ( st_ivas->nCPE > 1 && nCPE_old <= 1 ) - { - if ( nCPE_old == 1 ) - { - /* set correct nominal bitrates and igf config already here, needed for the correct init of the MDCT Stereo handles for MCT */ - for ( n = 0; n < CPE_CHANNELS; n++ ) - { - st_ivas->hCPE[0]->hCoreCoder[n]->total_brate = st_ivas->hCPE[0]->element_brate; - st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal = (int16_t) ( st_ivas->hCPE[0]->element_brate / FRAMES_PER_SEC ); - st_ivas->hCPE[0]->hCoreCoder[n]->igf = 0; - } - } - - if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else if ( st_ivas->hMCT != NULL && st_ivas->nCPE > 1 ) - { - if ( ( error = mct_dec_reconfigure( st_ivas, st_ivas->nchan_transport != nchan_transport_old ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - /* special case, if we have a single CPE and had MCT before we need to init the MDCT stereo handles here */ - if ( st_ivas->nCPE == 1 && nCPE_old > 1 ) - { - if ( ( st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) count_malloc( sizeof( STEREO_MDCT_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MDCT Stereo \n" ) ); - } - - st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->use_itd = 0; - st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->reverse_dmx = 0; - st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->smooth_ratio = 1.f; - - for ( n = 0; n < CPE_CHANNELS; n++ ) - { - /* reset mct_chan_mode */ - st_ivas->hCPE[0]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_REGULAR; - } - } - } - } + if ( st_ivas->nchan_transport == nchan_transport_old && st_ivas->nSCE == nSCE_old && st_ivas->nCPE == nCPE_old ) #else if ( st_ivas->nchan_transport == nchan_transport_old ) +#endif { for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { +#ifdef MCMASA_BITRATE_SWITCHING + st_ivas->hSCE[sce_id]->element_brate = brate_SCE; +#else st_ivas->hSCE[sce_id]->element_brate = ivas_total_brate / st_ivas->nchan_transport; +#endif st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ } for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { +#ifdef MCMASA_BITRATE_SWITCHING + st_ivas->hCPE[cpe_id]->element_brate = brate_CPE; +#else st_ivas->hCPE[cpe_id]->element_brate = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS; - +#endif /* prepare bitstream buffers */ for ( n = 0; n < CPE_CHANNELS; n++ ) { @@ -372,12 +185,20 @@ ivas_error ivas_corecoder_dec_reconfig( for ( sce_id = 0; sce_id < nSCE_existing; sce_id++ ) { +#ifdef MCMASA_BITRATE_SWITCHING + st_ivas->hSCE[sce_id]->element_brate = brate_SCE; +#else st_ivas->hSCE[sce_id]->element_brate = ivas_total_brate / st_ivas->nchan_transport; +#endif st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ } for ( ; sce_id < st_ivas->nSCE; sce_id++ ) { +#ifdef MCMASA_BITRATE_SWITCHING + if ( ( error = create_sce_dec( st_ivas, sce_id, brate_SCE ) ) != IVAS_ERR_OK ) +#else if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -385,8 +206,11 @@ ivas_error ivas_corecoder_dec_reconfig( for ( cpe_id = 0; cpe_id < nCPE_existing; cpe_id++ ) { +#ifdef MCMASA_BITRATE_SWITCHING + st_ivas->hCPE[cpe_id]->element_brate = brate_CPE; +#else st_ivas->hCPE[cpe_id]->element_brate = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS; - +#endif /* prepare bitstream buffers */ for ( n = 0; n < CPE_CHANNELS; n++ ) { @@ -395,7 +219,11 @@ ivas_error ivas_corecoder_dec_reconfig( } for ( ; cpe_id < st_ivas->nCPE; cpe_id++ ) { +#ifdef MCMASA_BITRATE_SWITCHING + if ( ( error = create_cpe_dec( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK ) +#else if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -446,12 +274,11 @@ ivas_error ivas_corecoder_dec_reconfig( } } } -#endif /* create dummy CPE element for DFT stereo-like upmix */ #ifdef MCMASA_BITRATE_SWITCHING - if ( ( ( st_ivas->ivas_format == SBA_FORMAT ) && st_ivas->sba_dirac_stereo_flag && !sba_dirac_stereo_flag_old ) || - ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_MCMASA ) && st_ivas->sba_dirac_stereo_flag ) ) + if ( ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_dirac_stereo_flag && !sba_dirac_stereo_flag_old ) || + ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->sba_dirac_stereo_flag && !sba_dirac_stereo_flag_old ) ) #else if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_dirac_stereo_flag && !sba_dirac_stereo_flag_old ) #endif diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index e91062ecc2..0c75a1ca65 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -681,6 +681,7 @@ ivas_error ivas_mc_dec_reconfig( { nchan_hp20_old = nchan_transport_old; } + st_ivas->sba_dirac_stereo_flag = 0; /* needs to be after getNumChanSynthesis() */ #endif /* renderer might have changed, reselect */ renderer_type_old = st_ivas->renderer_type; @@ -777,8 +778,8 @@ ivas_error ivas_mc_dec_reconfig( { #ifdef MCMASA_BITRATE_SWITCHING ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), st_ivas->hDecoderConfig->ivas_total_brate ); - #endif + if ( last_mc_mode != MC_MODE_MCMASA ) { if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) @@ -957,10 +958,6 @@ ivas_error ivas_mc_dec_reconfig( } } } - for ( i = 0; i < numCldfbAnalyses; i++ ) - { - cldfb_reset_memory( st_ivas->cldfbAnaDec[i] ); - } #endif /* Synthesis */ if ( numCldfbSyntheses_old > numCldfbSyntheses ) @@ -983,12 +980,6 @@ ivas_error ivas_mc_dec_reconfig( } } } -#ifdef MCMASA_BITRATE_SWITCHING - for ( i = 0; i < numCldfbSyntheses; i++ ) - { - cldfb_reset_memory( st_ivas->cldfbSynDec[i] ); - } -#endif /* Allocate the LFE handle that is coded separately after the allocation of the core coders */ if ( st_ivas->mc_mode == MC_MODE_MCT && st_ivas->hLFE == NULL ) diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index e76a73046a..371a376007 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -98,14 +98,12 @@ ivas_error ivas_corecoder_enc_reconfig( /*-----------------------------------------------------------------* * Switching between SCE(s)/CPE(s)/MCT *-----------------------------------------------------------------*/ - #ifdef MCMASA_BITRATE_SWITCHING - if ( ( st_ivas->nSCE == nSCE_old ) && ( st_ivas->nCPE == nCPE_old ) && ( st_ivas->mc_mode == last_mc_mode ) ) + if ( st_ivas->nchan_transport == nchan_transport_old && st_ivas->nSCE == nSCE_old && st_ivas->nCPE == nCPE_old ) /* in McMASA, nchan_transport may be the same, but nSCE/nCPE differs */ #else if ( st_ivas->nchan_transport == nchan_transport_old ) #endif { - /* transport layout (and mode) stays the same -> take a shortcut in reconfig */ for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { copy_encoder_config( st_ivas, st_ivas->hSCE[sce_id]->hCoreCoder[0], 0 ); @@ -124,7 +122,6 @@ ivas_error ivas_corecoder_enc_reconfig( #else st_ivas->hCPE[cpe_id]->element_brate = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS; #endif - /* prepare bitstream buffers */ for ( n = 0; n < CPE_CHANNELS; n++ ) { @@ -145,7 +142,26 @@ ivas_error ivas_corecoder_enc_reconfig( else { #ifdef MCMASA_BITRATE_SWITCHING - /* transport layout changes */ + int16_t nchan_transport_real, nchan_transport_old_real; + if ( last_mc_mode == MC_MODE_MCMASA ) + { + /* in SCE+CPE McMASA nchan_transport is still 2 */ + nchan_transport_old_real = nSCE_old + CPE_CHANNELS * nCPE_old; + } + else + { + nchan_transport_old_real = nchan_transport_old; + } + if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + { + nchan_transport_real = st_ivas->nSCE + CPE_CHANNELS * st_ivas->nCPE; + } + else + { + nchan_transport_real = st_ivas->nchan_transport; + } + + /* something in transport changes */ ind_list = NULL; ind_list_metadata = NULL; #else @@ -154,13 +170,7 @@ ivas_error ivas_corecoder_enc_reconfig( hBstr = NULL; hMetaData = NULL; -#ifdef MCMASA_BITRATE_SWITCHING - /* get the index list pointers - * taking the hBstr from the first active element gets the start of ind_list - * the same for the hMetaData */ -#else /* get the index list pointers */ -#endif if ( nSCE_old ) { hBstr = st_ivas->hSCE[0]->hCoreCoder[0]->hBstr; @@ -179,369 +189,41 @@ ivas_error ivas_corecoder_enc_reconfig( #endif /* save bitstream information */ -#ifdef MCMASA_BITRATE_SWITCHING ind_list = hBstr->ind_list; /* pointer to the beginning of the global list */ -#else - ind_list = hBstr->ind_list; -#endif nb_bits_tot = hBstr->nb_bits_tot; next_ind = hBstr->next_ind; last_ind = hBstr->last_ind; ind_list_metadata = hMetaData->ind_list; /* pointer to the beginning of the global list */ #ifdef MCMASA_BITRATE_SWITCHING - if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + if ( last_mc_mode == MC_MODE_MCMASA && st_ivas->mc_mode == MC_MODE_MCMASA ) { - int16_t buff_len; - buff_len = L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ); - - if ( last_mc_mode == MC_MODE_MCMASA ) + /* within McMASA we can modify the transport signals when switching */ + /* copy earlier dmx buffers */ + if ( nSCE_old > 0 ) { - /* copy earlier dmx buffers */ - if ( nSCE_old > 0 ) - { - set_zero( input_buff[0], buff_len ); - mvr2r( st_ivas->hSCE[0]->hCoreCoder[0]->input_buff, input_buff[0], len_inp_memory ); - } - for ( n = 0; n < CPE_CHANNELS; n++ ) - { - set_zero( input_buff[n + 1], buff_len ); - if ( nCPE_old > 0 ) - { - mvr2r( st_ivas->hCPE[0]->hCoreCoder[n]->input_buff, input_buff[n + 1], len_inp_memory ); - } - } - - /* modify the dmx format to match the new one */ - ivas_mcmasa_dmx_modify( buff_len, input_buff, nSCE_old + 2 * nCPE_old, st_ivas->nSCE + 2 * st_ivas->nCPE ); + set_zero( input_buff[0], len_inp_memory ); + mvr2r( st_ivas->hSCE[0]->hCoreCoder[0]->input_buff, input_buff[0], len_inp_memory ); } - - for ( sce_id = 0; sce_id < nSCE_old; sce_id++ ) - { - destroy_sce_enc( st_ivas->hSCE[sce_id] ); - st_ivas->hSCE[sce_id] = NULL; - } - for ( cpe_id = 0; cpe_id < nCPE_old; cpe_id++ ) - { - destroy_cpe_enc( st_ivas->hCPE[cpe_id] ); - st_ivas->hCPE[cpe_id] = NULL; - } - - if ( st_ivas->nSCE ) + for ( n = 0; n < CPE_CHANNELS; n++ ) { - if ( ( error = create_sce_enc( st_ivas, 0, brate_SCE ) ) != IVAS_ERR_OK ) + set_zero( input_buff[n + 1], len_inp_memory ); + if ( nCPE_old > 0 ) { - return error; - } - /* restore information of the bitstream already written */ - st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list = ind_list + 0 * MAX_NUM_INDICES; - - /* only SCE in use => update bitstream info */ - st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->last_ind = last_ind; - st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_bits_tot = nb_bits_tot; - st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->next_ind = next_ind; - - /* in case of 2+1, this is not really used, but let's keep it for compatibility */ - st_ivas->hSCE[0]->hMetaData->ind_list = ind_list_metadata + 0 * MAX_BITS_METADATA; - reset_indices_enc( st_ivas->hSCE[0]->hMetaData, MAX_BITS_METADATA ); - - if ( last_mc_mode == MC_MODE_MCMASA ) - { - /* restore input buffer */ - mvr2r( input_buff[0], st_ivas->hSCE[0]->hCoreCoder[0]->input_buff, len_inp_memory ); + mvr2r( st_ivas->hCPE[0]->hCoreCoder[n]->input_buff, input_buff[n + 1], len_inp_memory ); } } + ivas_mcmasa_dmx_modify( len_inp_memory, input_buff, nSCE_old + CPE_CHANNELS * nCPE_old, st_ivas->nSCE + CPE_CHANNELS * st_ivas->nCPE ); - if ( st_ivas->nCPE ) - { - if ( st_ivas->hMcMasa->separateChannelEnabled ) - { - st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; - } - - if ( ( error = create_cpe_enc( st_ivas, 0, brate_CPE ) ) != IVAS_ERR_OK ) - { - return error; - } - for ( n = 0; n < CPE_CHANNELS; n++ ) - { - st_ivas->hCPE[0]->hCoreCoder[n]->hBstr->ind_list = ind_list + ( 0 * CPE_CHANNELS + n + st_ivas->nSCE ) * MAX_NUM_INDICES; - - if ( ( st_ivas->nSCE > 0 ) || ( n > 0 ) ) /* the started bitstream is in SCE or in the first core channel of CPE => reset here */ - { - reset_indices_enc( st_ivas->hCPE[0]->hCoreCoder[n]->hBstr, MAX_NUM_INDICES ); - } - else - { - /* restore the beginning of the bitstream */ - st_ivas->hCPE[0]->hCoreCoder[n]->hBstr->last_ind = last_ind; - st_ivas->hCPE[0]->hCoreCoder[n]->hBstr->nb_bits_tot = nb_bits_tot; - st_ivas->hCPE[0]->hCoreCoder[n]->hBstr->next_ind = next_ind; - } - if ( hEncoderConfig->Opt_DTX_ON ) - { - st_ivas->hCPE[0]->hCoreCoder[n]->cng_sba_flag = 1; - } - - if ( last_mc_mode == MC_MODE_MCMASA ) - { - /* restore input buffer */ - mvr2r( st_ivas->hCPE[0]->hCoreCoder[n]->input_buff, input_buff[n + 1], len_inp_memory ); - } - } - st_ivas->hCPE[0]->hMetaData->ind_list = ind_list_metadata + st_ivas->nSCE * MAX_NUM_INDICES; - reset_indices_enc( st_ivas->hCPE[0]->hMetaData, MAX_BITS_METADATA ); - } - } /* end of McMASA special handling */ + n_CoreCoder_existing = 0; + } else { - n_CoreCoder_existing = min( st_ivas->nchan_transport, nchan_transport_old ); - - /* destroy superfluous core-coder elements */ - for ( sce_id = st_ivas->nSCE; sce_id < nSCE_old; sce_id++ ) - { - /* save input audio buffers */ - if ( n_CoreCoder_existing > sce_id ) - { - mvr2r( st_ivas->hSCE[sce_id]->hCoreCoder[0]->input_buff, input_buff[sce_id], len_inp_memory ); - } - - destroy_sce_enc( st_ivas->hSCE[sce_id] ); - st_ivas->hSCE[sce_id] = NULL; - } - - for ( cpe_id = st_ivas->nCPE; cpe_id < nCPE_old; cpe_id++ ) - { - /* save input audio buffers */ - for ( n = 0; n < CPE_CHANNELS; n++ ) - { - if ( n_CoreCoder_existing > cpe_id * CPE_CHANNELS + n ) - { - mvr2r( st_ivas->hCPE[cpe_id]->hCoreCoder[0]->input_buff, input_buff[( cpe_id - st_ivas->nCPE ) * CPE_CHANNELS + n], len_inp_memory ); /* TODO VoiceAge: Please check if this should be hCoreCoder[n] */ - } - } - - destroy_cpe_enc( st_ivas->hCPE[cpe_id] ); - st_ivas->hCPE[cpe_id] = NULL; - } - - if ( st_ivas->nCPE <= 1 && st_ivas->hMCT != NULL ) - { - ivas_mct_enc_close( st_ivas->hMCT ); - st_ivas->hMCT = NULL; - } - - /* special case, if we have MCT now and had a single CPE before, remove the MDCT Stereo handles */ - if ( st_ivas->nCPE > 1 && nCPE_old == 1 ) - { - count_free( st_ivas->hCPE[0]->hStereoMdct ); - st_ivas->hCPE[0]->hStereoMdct = NULL; - } - - /* create missing core coder elements and set element bitrates for already existing ones */ - if ( st_ivas->nSCE > 0 ) - { - nSCE_existing = min( nSCE_old, st_ivas->nSCE ); - - for ( sce_id = 0; sce_id < nSCE_existing; sce_id++ ) - { - copy_encoder_config( st_ivas, st_ivas->hSCE[sce_id]->hCoreCoder[0], 0 ); - st_ivas->hSCE[sce_id]->element_brate = brate_SCE; - st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ - } - - for ( sce_id = nSCE_existing; sce_id < st_ivas->nSCE; sce_id++ ) - { - if ( ( error = create_sce_enc( st_ivas, sce_id, brate_SCE ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* propagate input audio buffers */ - if ( n_CoreCoder_existing > sce_id ) - { - mvr2r( input_buff[sce_id], st_ivas->hSCE[sce_id]->hCoreCoder[0]->input_buff, len_inp_memory ); - } - - /* prepare bitstream buffers */ - st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->ind_list = ind_list + sce_id * MAX_NUM_INDICES; - - /* only reset indices if it is not the first index list, this already contains the IVAS format bits */ - if ( sce_id > 0 ) - { - reset_indices_enc( st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr, MAX_NUM_INDICES ); - } - else - { - st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->last_ind = last_ind; - st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->nb_bits_tot = nb_bits_tot; - st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->next_ind = next_ind; - } - - st_ivas->hSCE[sce_id]->hMetaData->ind_list = ind_list_metadata + sce_id * MAX_BITS_METADATA; - reset_indices_enc( st_ivas->hSCE[sce_id]->hMetaData, MAX_BITS_METADATA ); - } - } - - if ( st_ivas->nCPE > 0 ) - { - nCPE_existing = min( nCPE_old, st_ivas->nCPE ); - - for ( cpe_id = 0; cpe_id < nCPE_existing; cpe_id++ ) - { - st_ivas->hCPE[cpe_id]->element_brate = brate_CPE; - - /* prepare bitstream buffers */ - for ( n = 0; n < CPE_CHANNELS; n++ ) - { - copy_encoder_config( st_ivas, st_ivas->hCPE[cpe_id]->hCoreCoder[n], 0 ); - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ - } - } - - for ( cpe_id = nCPE_existing; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - if ( ( error = create_cpe_enc( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* propagate input audio buffers */ - for ( n = 0; n < CPE_CHANNELS; n++ ) - { - if ( n_CoreCoder_existing > cpe_id * CPE_CHANNELS + n ) - { - mvr2r( input_buff[n], st_ivas->hCPE[cpe_id]->hCoreCoder[0]->input_buff, len_inp_memory ); /* TODO VoiceAge: Please check if this should be hCoreCoder[n] */ - } - } - - /* prepare bitstream buffers */ - for ( n = 0; n < CPE_CHANNELS; n++ ) - { - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->ind_list = ind_list + ( cpe_id * CPE_CHANNELS + n ) * MAX_NUM_INDICES; - if ( cpe_id * CPE_CHANNELS + n > 0 ) - { - reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, MAX_NUM_INDICES ); - } - else - { - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->last_ind = last_ind; - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_bits_tot = nb_bits_tot; - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->next_ind = next_ind; - } - - if ( hEncoderConfig->Opt_DTX_ON ) - { - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->cng_sba_flag = 1; - } - } - } - } - - if ( st_ivas->nCPE > 1 && nCPE_old <= 1 ) - { - if ( nCPE_old == 1 ) - { - /* set correct nominal bitrates and igf config already here, needed for the correct init of the MDCT Stereo handles for MCT */ - for ( n = 0; n < CPE_CHANNELS; n++ ) - { - st_ivas->hCPE[0]->hCoreCoder[n]->total_brate = st_ivas->hCPE[0]->element_brate; - - st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal = (int16_t) ( st_ivas->hCPE[0]->element_brate / FRAMES_PER_SEC ); - st_ivas->hCPE[0]->hCoreCoder[n]->igf = getIgfPresent( st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, - st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal * FRAMES_PER_SEC, - st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, - st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode, - st_ivas->hCPE[0]->hCoreCoder[n]->mct_chan_mode ); - - if ( st_ivas->hCPE[0]->hCoreCoder[n]->igf ) - { - IGFEncSetMode( st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, - st_ivas->hCPE[0]->element_brate, - st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, - st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, - st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ); - } - } - } - - if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else if ( st_ivas->hMCT != NULL && st_ivas->nCPE > 1 ) - { - if ( ( error = mct_enc_reconfigure( st_ivas, st_ivas->nchan_transport != nchan_transport_old ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - /* metadata handling for CPEs */ - if ( st_ivas->nCPE > 0 ) - { - if ( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData == NULL ) - { - if ( ( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData = (BSTR_ENC_HANDLE) count_malloc( sizeof( BSTR_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MetaData structure\n" ) ); - } - } - - st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->ind_list = ind_list_metadata; - reset_indices_enc( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData, MAX_BITS_METADATA ); - - for ( cpe_id = 0; cpe_id < st_ivas->nCPE - 1; cpe_id++ ) - { - if ( st_ivas->hCPE[cpe_id]->hMetaData != NULL ) - { - count_free( st_ivas->hCPE[cpe_id]->hMetaData ); - st_ivas->hCPE[cpe_id]->hMetaData = NULL; - } - } - } - - /* special case, if we have a single CPE and had MCT before we need to init the MDCT stereo handles here */ - if ( st_ivas->nCPE == 1 && nCPE_old > 1 ) - { - if ( ( st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct = (STEREO_MDCT_ENC_DATA_HANDLE) count_malloc( sizeof( STEREO_MDCT_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MDCT Stereo \n" ) ); - } - - /* set correct nominal bitrates and igf config already here, needed for the correct init of the MDCT Stereo handle */ - for ( n = 0; n < CPE_CHANNELS; n++ ) - { - st_ivas->hCPE[0]->hCoreCoder[n]->total_brate = st_ivas->hCPE[0]->element_brate; - - st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal = (int16_t) ( st_ivas->hCPE[0]->element_brate / FRAMES_PER_SEC ); - st_ivas->hCPE[0]->hCoreCoder[n]->igf = getIgfPresent( st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, - st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal * FRAMES_PER_SEC, - st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, - st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode, - st_ivas->hCPE[0]->hCoreCoder[n]->mct_chan_mode ); - - if ( st_ivas->hCPE[0]->hCoreCoder[n]->igf ) - { - IGFEncSetMode( st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, - st_ivas->hCPE[0]->element_brate, - st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, - st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, - st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ); - } - - /* reset mct_chan_mode */ - st_ivas->hCPE[0]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_REGULAR; - } - - initMdctStereoEncData( st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct, hEncoderConfig->ivas_format, st_ivas->hCPE[st_ivas->nCPE - 1]->element_mode, st_ivas->hCPE[st_ivas->nCPE - 1]->element_brate, hEncoderConfig->max_bwidth, 0, NULL, 1 ); - st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->isSBAStereoMode = ( ( hEncoderConfig->ivas_format == SBA_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); - } + n_CoreCoder_existing = min( nchan_transport_real, nchan_transport_old_real ); } - } #else n_CoreCoder_existing = min( st_ivas->nchan_transport, nchan_transport_old ); +#endif /* destroy superfluous core-coder elements */ for ( sce_id = st_ivas->nSCE; sce_id < nSCE_old; sce_id++ ) @@ -563,7 +245,7 @@ ivas_error ivas_corecoder_enc_reconfig( { if ( n_CoreCoder_existing > cpe_id * CPE_CHANNELS + n ) { - mvr2r( st_ivas->hCPE[cpe_id]->hCoreCoder[0]->input_buff, input_buff[( cpe_id - st_ivas->nCPE ) * CPE_CHANNELS + n], len_inp_memory ); + mvr2r( st_ivas->hCPE[cpe_id]->hCoreCoder[0]->input_buff, input_buff[( cpe_id - st_ivas->nCPE ) * CPE_CHANNELS + n], len_inp_memory ); /* TODO VoiceAge: Please check if this should be hCoreCoder[n] */ } } @@ -592,13 +274,21 @@ ivas_error ivas_corecoder_enc_reconfig( for ( sce_id = 0; sce_id < nSCE_existing; sce_id++ ) { copy_encoder_config( st_ivas, st_ivas->hSCE[sce_id]->hCoreCoder[0], 0 ); +#ifdef MCMASA_BITRATE_SWITCHING + st_ivas->hSCE[sce_id]->element_brate = brate_SCE; +#else st_ivas->hSCE[sce_id]->element_brate = ivas_total_brate / st_ivas->nchan_transport; +#endif st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ } for ( sce_id = nSCE_existing; sce_id < st_ivas->nSCE; sce_id++ ) { +#ifdef MCMASA_BITRATE_SWITCHING + if ( ( error = create_sce_enc( st_ivas, sce_id, brate_SCE ) ) != IVAS_ERR_OK ) +#else if ( ( error = create_sce_enc( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -635,19 +325,44 @@ ivas_error ivas_corecoder_enc_reconfig( for ( cpe_id = 0; cpe_id < nCPE_existing; cpe_id++ ) { +#ifdef MCMASA_BITRATE_SWITCHING + st_ivas->hCPE[cpe_id]->element_brate = brate_CPE; +#else st_ivas->hCPE[cpe_id]->element_brate = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS; - +#endif /* prepare bitstream buffers */ for ( n = 0; n < CPE_CHANNELS; n++ ) { copy_encoder_config( st_ivas, st_ivas->hCPE[cpe_id]->hCoreCoder[n], 0 ); st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ + +#ifdef MCMASA_BITRATE_SWITCHING + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->ind_list = ind_list + ( cpe_id * CPE_CHANNELS + n + st_ivas->nSCE ) * MAX_NUM_INDICES; + if ( cpe_id * CPE_CHANNELS + n > 0 || ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->nSCE > 0 ) ) + { + reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, MAX_NUM_INDICES ); + } + else + { + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->last_ind = last_ind; + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_bits_tot = nb_bits_tot; + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->next_ind = next_ind; + } +#endif } } for ( cpe_id = nCPE_existing; cpe_id < st_ivas->nCPE; cpe_id++ ) { +#ifdef MCMASA_BITRATE_SWITCHING + if ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->hMcMasa->separateChannelEnabled ) + { + 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 ) +#endif { return error; } @@ -657,15 +372,20 @@ ivas_error ivas_corecoder_enc_reconfig( { if ( n_CoreCoder_existing > cpe_id * CPE_CHANNELS + n ) { - mvr2r( input_buff[n], st_ivas->hCPE[cpe_id]->hCoreCoder[0]->input_buff, len_inp_memory ); + mvr2r( input_buff[n], st_ivas->hCPE[cpe_id]->hCoreCoder[0]->input_buff, len_inp_memory ); /* TODO VoiceAge: Please check if this should be hCoreCoder[n] */ } } /* prepare bitstream buffers */ for ( n = 0; n < CPE_CHANNELS; n++ ) { +#ifdef MCMASA_BITRATE_SWITCHING + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->ind_list = ind_list + ( cpe_id * CPE_CHANNELS + n + st_ivas->nSCE ) * MAX_NUM_INDICES; + if ( cpe_id * CPE_CHANNELS + n > 0 || ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->nSCE > 0 ) ) +#else st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->ind_list = ind_list + ( cpe_id * CPE_CHANNELS + n ) * MAX_NUM_INDICES; if ( cpe_id * CPE_CHANNELS + n > 0 ) +#endif { reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, MAX_NUM_INDICES ); } @@ -684,6 +404,24 @@ ivas_error ivas_corecoder_enc_reconfig( } } +#ifdef MCMASA_BITRATE_SWITCHING + if ( last_mc_mode == MC_MODE_MCMASA && st_ivas->mc_mode == MC_MODE_MCMASA ) + { + /* restore modified transport signal */ + if ( st_ivas->nSCE ) + { + mvr2r( input_buff[0], st_ivas->hSCE[0]->hCoreCoder[0]->input_buff, len_inp_memory ); + } + if ( st_ivas->nCPE ) + { + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + mvr2r( input_buff[n + 1], st_ivas->hCPE[0]->hCoreCoder[n]->input_buff, len_inp_memory ); + } + } + } +#endif + if ( st_ivas->nCPE > 1 && nCPE_old <= 1 ) { if ( nCPE_old == 1 ) @@ -735,7 +473,11 @@ ivas_error ivas_corecoder_enc_reconfig( } } +#ifdef MCMASA_BITRATE_SWITCHING + st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->ind_list = ind_list_metadata + st_ivas->nSCE * MAX_NUM_INDICES; +#else st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->ind_list = ind_list_metadata; +#endif reset_indices_enc( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData, MAX_BITS_METADATA ); for ( cpe_id = 0; cpe_id < st_ivas->nCPE - 1; cpe_id++ ) @@ -785,7 +527,6 @@ ivas_error ivas_corecoder_enc_reconfig( st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->isSBAStereoMode = ( ( hEncoderConfig->ivas_format == SBA_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); } } -#endif return error; } -- GitLab From 83b9a8514499d5dc6c4e8aa18d6da1e87083b835 Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Tue, 6 Dec 2022 13:29:29 +0100 Subject: [PATCH 4/4] fix: re-instantiate CPE when bitrate switching McMASA<->non-McMASA as the internal settings depend from the MC-mode. clean-up DFT-stereo dummy-CPE --- lib_com/ivas_prot.h | 15 ++++++++------- lib_dec/ivas_corecoder_dec_reconfig.c | 22 ++++++++++++++++++---- lib_dec/ivas_mct_dec.c | 2 +- lib_dec/ivas_sba_dec.c | 2 +- lib_enc/ivas_mct_enc.c | 2 +- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 170c8eafa2..d6b64c8203 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -341,13 +341,14 @@ void ivas_mct_dec_close( #ifdef CORECODER_BITRATE_SWITCHING ivas_error ivas_corecoder_dec_reconfig( #ifdef MCMASA_BITRATE_SWITCHING - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSCE_old, /* i : number of SCEs in previous frame */ - const int16_t nCPE_old, /* i : number of CPEs in previous frame */ - const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ - const int16_t sba_dirac_stereo_flag_old, /* i : signal stereo rendering using DFT upmix in previous frame */ - const int32_t brate_SCE, /* i : bitrate to be set for the SCEs      */ - const int32_t brate_CPE /* i : bitrate to be set for the CPEs */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nSCE_old, /* i : number of SCEs in previous frame */ + int16_t nCPE_old, /* i : number of CPEs in previous frame */ + const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ + const int16_t sba_dirac_stereo_flag_old, /* i : signal stereo rendering using DFT upmix in previous frame */ + const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */ + const int32_t brate_CPE, /* i : bitrate to be set for the CPEs */ + const MC_MODE last_mc_mode /* i : MC mode in the previous frame */ #else Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSCE_old, /* i : number of SCEs in previous frame */ diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index f2f37e1180..811b7211ad 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -50,18 +50,19 @@ /*-------------------------------------------------------------------* * ivas_corecoder_dec_reconfig() * - * Allocate, initialize, and configure SCE/CPE/MCT handles in case of bitrate switching + * Allocate, initalize, and configure SCE/CPE/MCT handles in case of bitrate switching *-------------------------------------------------------------------*/ ivas_error ivas_corecoder_dec_reconfig( #ifdef MCMASA_BITRATE_SWITCHING Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSCE_old, /* i : number of SCEs in previous frame */ - const int16_t nCPE_old, /* i : number of CPEs in previous frame */ + int16_t nCPE_old, /* i : number of CPEs in previous frame */ const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ const int16_t sba_dirac_stereo_flag_old, /* i : signal stereo rendering using DFT upmix in previous frame */ const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */ - const int32_t brate_CPE /* i : bitrate to be set for the CPEs */ + const int32_t brate_CPE, /* i : bitrate to be set for the CPEs */ + const MC_MODE last_mc_mode /* i : MC mode in the previous frame */ #else Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSCE_old, /* i : number of SCEs in previous frame */ @@ -94,7 +95,7 @@ ivas_error ivas_corecoder_dec_reconfig( /* remove dummy CPE element for DFT stereo-like upmix */ #ifdef MCMASA_BITRATE_SWITCHING if ( ( st_ivas->ivas_format == SBA_FORMAT && sba_dirac_stereo_flag_old && !st_ivas->sba_dirac_stereo_flag ) || - ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA && sba_dirac_stereo_flag_old && !st_ivas->sba_dirac_stereo_flag ) ) + ( st_ivas->ivas_format == MC_FORMAT && last_mc_mode == MC_MODE_MCMASA && sba_dirac_stereo_flag_old && !st_ivas->sba_dirac_stereo_flag ) ) #else if ( st_ivas->ivas_format == SBA_FORMAT && sba_dirac_stereo_flag_old && !st_ivas->sba_dirac_stereo_flag ) #endif @@ -171,6 +172,19 @@ ivas_error ivas_corecoder_dec_reconfig( st_ivas->hCPE[cpe_id] = NULL; } +#ifdef MCMASA_BITRATE_SWITCHING + /* the CPE-internal settings depend from ivas_format and mc_mode, so clean-up when switching between mc_modes */ + if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode != last_mc_mode && ( st_ivas->mc_mode == MC_MODE_MCMASA || last_mc_mode == MC_MODE_MCMASA ) ) + { + for ( cpe_id = 0; cpe_id < nCPE_existing; cpe_id++ ) + { + destroy_cpe_dec( st_ivas->hCPE[cpe_id] ); + st_ivas->hCPE[cpe_id] = NULL; + } + nCPE_old = 0; + nCPE_existing = min( nCPE_old, st_ivas->nCPE ); + } +#endif if ( st_ivas->nCPE <= 1 && st_ivas->hMCT != NULL ) { ivas_mct_dec_close( &st_ivas->hMCT ); diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 0c75a1ca65..eed6452a4d 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -901,7 +901,7 @@ ivas_error ivas_mc_dec_reconfig( new_brate_SCE = 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; } - 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 ) + 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, last_mc_mode ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old ) ) != IVAS_ERR_OK ) #endif diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 08d263e8ac..0897393ca8 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -606,7 +606,7 @@ ivas_error ivas_sba_dec_reconfigure( #ifdef CORECODER_BITRATE_SWITCHING #ifdef MCMASA_BITRATE_SWITCHING - ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ); + ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS, MC_MODE_NONE ); #else ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old ); #endif diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 0f2f2d4f01..0abc613a8c 100755 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -845,4 +845,4 @@ ivas_error ivas_mc_enc_reconfig( return error; } -#endif \ No newline at end of file +#endif -- GitLab