Loading lib_dec/ivas_corecoder_dec_reconfig.c +25 −20 Original line number Diff line number Diff line Loading @@ -272,6 +272,10 @@ ivas_error ivas_corecoder_dec_reconfig( *-----------------------------------------------------------------*/ /// VE: this could be merged with part of ivas_init_decoder() #ifdef ISM_BITRATE_SWITCHING if ( st_ivas->ivas_format == SBA_FORMAT ) #endif { if ( st_ivas->sba_mode == SBA_MODE_SPAR && st_ivas->nchan_transport == 1 ) { /* skip as done in init function */ Loading Loading @@ -300,6 +304,7 @@ ivas_error ivas_corecoder_dec_reconfig( } } } } /* special case, if the decoder goes from 1TC DTX to 2TC active frame (in case the bitstream started with an SBA SID frame), allocate DTX memories */ if ( hDecoderConfig->last_ivas_total_brate <= IVAS_SID_5k2 && st_ivas->nCPE >= 1 ) Loading @@ -317,7 +322,7 @@ ivas_error ivas_corecoder_dec_reconfig( /*-------------------------------------------------------------------* * ivas_hp20_dec_reconfig() * * Allocate, initalize, and configure HP20 memory handles in case of bitrate switching * Allocate, initialize, and configure HP20 memory handles in case of bitrate switching *-------------------------------------------------------------------*/ ivas_error ivas_hp20_dec_reconfig( Loading lib_dec/ivas_ism_param_dec.c +32 −17 Original line number Diff line number Diff line Loading @@ -1005,32 +1005,44 @@ void ivas_param_ism_params_to_masa_param_mapping( #ifdef ISM_BITRATE_SWITCHING static ivas_error ivas_ism_format_bitrate_switching( /*-------------------------------------------------------------------------* * ivas_ism_bitrate_switching() * * *-------------------------------------------------------------------------*/ static ivas_error ivas_ism_bitrate_switching( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t last_nchan_trans, /* i : last number of SCE channels in the bitstream*/ const int16_t nchan_transport_old, /* i : last number of transport channels */ const ISM_MODE last_ism_mode, /* i : last ISM mode */ const int16_t num_obj /* i : number of objects in the bitstream */ ) { #ifndef CORECODER_BITRATE_SWITCHING int16_t sce_id; #endif ivas_error error; int32_t element_brate_tmp[MAX_NUM_OBJECTS]; error = IVAS_ERR_OK; ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, num_obj, NULL, NULL, NULL, element_brate_tmp, NULL, NULL ); st_ivas->nSCE = st_ivas->nchan_transport; if ( st_ivas->nchan_transport > last_nchan_trans ) #ifdef CORECODER_BITRATE_SWITCHING ivas_corecoder_dec_reconfig( st_ivas, nchan_transport_old, 0, nchan_transport_old, 0 ); #else if ( st_ivas->nchan_transport > nchan_transport_old ) { /* Initialize for new bitrate */ for ( sce_id = 0; sce_id < last_nchan_trans; sce_id++ ) for ( sce_id = 0; sce_id < nchan_transport_old; sce_id++ ) { st_ivas->hSCE[sce_id]->element_brate = st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport; 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() */ } /* Initialize some memories */ for ( sce_id = last_nchan_trans; sce_id < st_ivas->nchan_transport; sce_id++ ) for ( sce_id = nchan_transport_old; sce_id < st_ivas->nchan_transport; sce_id++ ) { if ( ( error = create_sce_dec( st_ivas, sce_id, element_brate_tmp[sce_id] ) ) != IVAS_ERR_OK ) { Loading @@ -1048,17 +1060,21 @@ static ivas_error ivas_ism_format_bitrate_switching( } /* Destroy the core coder memory */ for ( ; sce_id < last_nchan_trans; sce_id++ ) for ( ; sce_id < nchan_transport_old; sce_id++ ) { destroy_sce_dec( st_ivas->hSCE[sce_id] ); st_ivas->hSCE[sce_id] = NULL; } } #endif #ifdef CORECODER_BITRATE_SWITCHING ivas_hp20_dec_reconfig( st_ivas, nchan_transport_old ); #else /* destroy the memory of hp20*/ if ( st_ivas->mem_hp20_out != NULL ) { for ( sce_id = 0; sce_id < last_nchan_trans; sce_id++ ) for ( sce_id = 0; sce_id < nchan_transport_old; sce_id++ ) { count_free( st_ivas->mem_hp20_out[sce_id] ); st_ivas->mem_hp20_out[sce_id] = NULL; Loading Loading @@ -1091,7 +1107,7 @@ static ivas_error ivas_ism_format_bitrate_switching( set_f( st_ivas->mem_hp20_out[sce_id], 0.0f, L_HP20_MEM ); } #endif /* Initialize the needed renderer struct and destroy the unnecessary renderer struct */ Loading Loading @@ -1218,7 +1234,7 @@ ivas_error ivas_ism_dec_config( ISM_MODE last_ism_mode; ivas_error error; #ifdef ISM_BITRATE_SWITCHING int16_t last_nchan_trans; int16_t nchan_transport_old; #endif error = IVAS_ERR_OK; Loading @@ -1229,10 +1245,10 @@ ivas_error ivas_ism_dec_config( last_ism_mode = st_ivas->ism_mode; #ifdef ISM_BITRATE_SWITCHING /* Assumes that num of input objects are constant */ last_nchan_trans = num_obj; nchan_transport_old = num_obj; if ( last_ism_mode == ISM_MODE_PARAM ) { last_nchan_trans = 2; nchan_transport_old = 2; } #endif Loading @@ -1255,12 +1271,11 @@ ivas_error ivas_ism_dec_config( { #ifdef ISM_BITRATE_SWITCHING /* ISM bit-rate switching */ if ( ( st_ivas->hDecoderConfig->last_ivas_total_brate != IVAS_SID_5k2 ) && ( st_ivas->hDecoderConfig->last_ivas_total_brate != FRAME_NO_DATA ) ) if ( st_ivas->hDecoderConfig->last_ivas_total_brate != IVAS_SID_5k2 && st_ivas->hDecoderConfig->last_ivas_total_brate != FRAME_NO_DATA ) { if ( ( st_ivas->ism_mode != last_ism_mode ) || ( st_ivas->hDecoderConfig->ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) ) { ivas_ism_format_bitrate_switching( st_ivas, last_nchan_trans, last_ism_mode, num_obj ); st_ivas->nSCE = st_ivas->nchan_transport; ivas_ism_bitrate_switching( st_ivas, nchan_transport_old, last_ism_mode, num_obj ); } } #else Loading lib_enc/ivas_ism_param_enc.c +117 −11 Original line number Diff line number Diff line Loading @@ -42,6 +42,10 @@ #include "wmops.h" #ifdef CORECODER_BITRATE_SWITCHING static ivas_error ivas_hp20_reconfig( Encoder_Struct *st_ivas, const int16_t nchan_hp20_old ); #endif /*------------------------------------------------------------------------- * Local function definitions *------------------------------------------------------------------------*/ Loading Loading @@ -416,16 +420,16 @@ ivas_error ivas_ism_enc_config( ivas_error error; ISM_MODE last_ism_mode; #ifdef ISM_BITRATE_SWITCHING int16_t last_nSCE; #ifdef CORECODER_BITRATE_SWITCHING int16_t nchan_transport_old; #else int16_t nSCE_old, nchan_transport_old; int16_t sce_id, n; #endif #endif error = IVAS_ERR_OK; last_ism_mode = st_ivas->ism_mode; #ifdef ISM_BITRATE_SWITCHING last_nSCE = st_ivas->nSCE; #endif /* select ISM format mode */ st_ivas->ism_mode = ivas_ism_mode_select( st_ivas->hEncoderConfig->nchan_inp, st_ivas->hEncoderConfig->ivas_total_brate ); Loading @@ -435,7 +439,14 @@ ivas_error ivas_ism_enc_config( if ( ( st_ivas->ism_mode != last_ism_mode ) || ( st_ivas->hEncoderConfig->ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) ) { int32_t element_brate_tmp[MAX_NUM_OBJECTS]; #ifndef CORECODER_BITRATE_SWITCHING Indice *ind_list_sce, *ind_list_metadata; #endif #ifndef CORECODER_BITRATE_SWITCHING nSCE_old = st_ivas->nSCE; #endif nchan_transport_old = st_ivas->nchan_transport; /* Reset and Initialize */ if ( st_ivas->ism_mode == ISM_MODE_PARAM ) Loading @@ -452,10 +463,13 @@ ivas_error ivas_ism_enc_config( ivas_ism_config( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hEncoderConfig->nchan_inp, NULL, NULL, NULL, element_brate_tmp, NULL, NULL ); if ( st_ivas->nSCE > last_nSCE ) #ifdef CORECODER_BITRATE_SWITCHING ivas_corecoder_enc_reconfig( st_ivas, nchan_transport_old, 0, nchan_transport_old ); #else if ( st_ivas->nSCE > nSCE_old ) { /* Reconfigure the core coders */ for ( sce_id = 0; sce_id < last_nSCE; sce_id++ ) for ( sce_id = 0; sce_id < nSCE_old; sce_id++ ) { copy_encoder_config( st_ivas, st_ivas->hSCE[sce_id]->hCoreCoder[0], 0 ); st_ivas->hSCE[sce_id]->element_brate = st_ivas->hEncoderConfig->ivas_total_brate / st_ivas->nchan_transport; Loading @@ -466,7 +480,7 @@ ivas_error ivas_ism_enc_config( ind_list_sce = st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list; ind_list_metadata = st_ivas->hSCE[0]->hMetaData->ind_list; for ( sce_id = last_nSCE; sce_id < st_ivas->nSCE; sce_id++ ) for ( sce_id = nSCE_old; sce_id < st_ivas->nSCE; sce_id++ ) { /* Initialize the Core Coder */ if ( ( error = create_sce_enc( st_ivas, sce_id, element_brate_tmp[sce_id] ) ) != IVAS_ERR_OK ) Loading @@ -493,7 +507,7 @@ ivas_error ivas_ism_enc_config( } /* Delete the extra memory */ for ( sce_id = st_ivas->nSCE; sce_id < last_nSCE; sce_id++ ) for ( sce_id = st_ivas->nSCE; sce_id < nSCE_old; sce_id++ ) { if ( st_ivas->hSCE[sce_id] != NULL ) { Loading @@ -502,6 +516,7 @@ ivas_error ivas_ism_enc_config( } } } #endif if ( st_ivas->ism_mode == ISM_MODE_PARAM && last_ism_mode == ISM_MODE_DISC ) { Loading @@ -519,10 +534,13 @@ ivas_error ivas_ism_enc_config( st_ivas->hDirAC = NULL; } #ifdef CORECODER_BITRATE_SWITCHING ivas_hp20_reconfig( st_ivas, nchan_transport_old ); #else /* destroy the memory of hp20*/ if ( st_ivas->mem_hp20_in != NULL ) { for ( sce_id = 0; sce_id < last_nSCE; sce_id++ ) for ( sce_id = 0; sce_id < nSCE_old; sce_id++ ) { count_free( st_ivas->mem_hp20_in[sce_id] ); st_ivas->mem_hp20_in[sce_id] = NULL; Loading Loading @@ -556,6 +574,7 @@ ivas_error ivas_ism_enc_config( set_f( st_ivas->mem_hp20_in[sce_id], 0.0f, L_HP20_MEM ); } #endif } #else /* ISM format switching */ Loading @@ -568,3 +587,90 @@ ivas_error ivas_ism_enc_config( return error; } #ifdef CORECODER_BITRATE_SWITCHING // VE: this is the same function as at the decoder -> harmonize them to a new file ivas_corecoder_reconfig.c /*-------------------------------------------------------------------* * ivas_hp20_dec_reconfig() * * Allocate, initialize, and configure HP20 memory handles in case of bitrate switching *-------------------------------------------------------------------*/ static ivas_error ivas_hp20_reconfig( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ const int16_t nchan_hp20_old /* i : number of HP20 filters in previous frame */ ) { int16_t i, nchan_hp20; float **old_mem_hp20_out; ivas_error error; error = IVAS_ERR_OK; /*-----------------------------------------------------------------* * HP20 memories *-----------------------------------------------------------------*/ nchan_hp20 = getNumChanAnalysis( st_ivas ); if ( nchan_hp20 > nchan_hp20_old ) { /* save old mem_hp_20 pointer */ old_mem_hp20_out = st_ivas->mem_hp20_in; st_ivas->mem_hp20_in = NULL; if ( ( st_ivas->mem_hp20_in = (float **) count_malloc( nchan_hp20 * sizeof( float * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); } for ( i = 0; i < nchan_hp20_old; i++ ) { st_ivas->mem_hp20_in[i] = old_mem_hp20_out[i]; old_mem_hp20_out[i] = NULL; } /* create additional hp20 memories */ for ( ; i < nchan_hp20; i++ ) { if ( ( st_ivas->mem_hp20_in[i] = (float *) count_malloc( L_HP20_MEM * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); } set_f( st_ivas->mem_hp20_in[i], 0.0f, L_HP20_MEM ); } count_free( old_mem_hp20_out ); old_mem_hp20_out = NULL; } else if ( nchan_hp20 < nchan_hp20_old ) { /* save old mem_hp_20 pointer */ old_mem_hp20_out = st_ivas->mem_hp20_in; st_ivas->mem_hp20_in = NULL; if ( ( st_ivas->mem_hp20_in = (float **) count_malloc( nchan_hp20 * sizeof( float * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); } for ( i = 0; i < nchan_hp20; i++ ) { st_ivas->mem_hp20_in[i] = old_mem_hp20_out[i]; old_mem_hp20_out[i] = NULL; } /* remove superfluous hp20 memories */ for ( ; i < nchan_hp20_old; i++ ) { count_free( old_mem_hp20_out[i] ); old_mem_hp20_out[i] = NULL; } count_free( old_mem_hp20_out ); old_mem_hp20_out = NULL; } return error; } #endif Loading
lib_dec/ivas_corecoder_dec_reconfig.c +25 −20 Original line number Diff line number Diff line Loading @@ -272,6 +272,10 @@ ivas_error ivas_corecoder_dec_reconfig( *-----------------------------------------------------------------*/ /// VE: this could be merged with part of ivas_init_decoder() #ifdef ISM_BITRATE_SWITCHING if ( st_ivas->ivas_format == SBA_FORMAT ) #endif { if ( st_ivas->sba_mode == SBA_MODE_SPAR && st_ivas->nchan_transport == 1 ) { /* skip as done in init function */ Loading Loading @@ -300,6 +304,7 @@ ivas_error ivas_corecoder_dec_reconfig( } } } } /* special case, if the decoder goes from 1TC DTX to 2TC active frame (in case the bitstream started with an SBA SID frame), allocate DTX memories */ if ( hDecoderConfig->last_ivas_total_brate <= IVAS_SID_5k2 && st_ivas->nCPE >= 1 ) Loading @@ -317,7 +322,7 @@ ivas_error ivas_corecoder_dec_reconfig( /*-------------------------------------------------------------------* * ivas_hp20_dec_reconfig() * * Allocate, initalize, and configure HP20 memory handles in case of bitrate switching * Allocate, initialize, and configure HP20 memory handles in case of bitrate switching *-------------------------------------------------------------------*/ ivas_error ivas_hp20_dec_reconfig( Loading
lib_dec/ivas_ism_param_dec.c +32 −17 Original line number Diff line number Diff line Loading @@ -1005,32 +1005,44 @@ void ivas_param_ism_params_to_masa_param_mapping( #ifdef ISM_BITRATE_SWITCHING static ivas_error ivas_ism_format_bitrate_switching( /*-------------------------------------------------------------------------* * ivas_ism_bitrate_switching() * * *-------------------------------------------------------------------------*/ static ivas_error ivas_ism_bitrate_switching( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t last_nchan_trans, /* i : last number of SCE channels in the bitstream*/ const int16_t nchan_transport_old, /* i : last number of transport channels */ const ISM_MODE last_ism_mode, /* i : last ISM mode */ const int16_t num_obj /* i : number of objects in the bitstream */ ) { #ifndef CORECODER_BITRATE_SWITCHING int16_t sce_id; #endif ivas_error error; int32_t element_brate_tmp[MAX_NUM_OBJECTS]; error = IVAS_ERR_OK; ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, num_obj, NULL, NULL, NULL, element_brate_tmp, NULL, NULL ); st_ivas->nSCE = st_ivas->nchan_transport; if ( st_ivas->nchan_transport > last_nchan_trans ) #ifdef CORECODER_BITRATE_SWITCHING ivas_corecoder_dec_reconfig( st_ivas, nchan_transport_old, 0, nchan_transport_old, 0 ); #else if ( st_ivas->nchan_transport > nchan_transport_old ) { /* Initialize for new bitrate */ for ( sce_id = 0; sce_id < last_nchan_trans; sce_id++ ) for ( sce_id = 0; sce_id < nchan_transport_old; sce_id++ ) { st_ivas->hSCE[sce_id]->element_brate = st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport; 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() */ } /* Initialize some memories */ for ( sce_id = last_nchan_trans; sce_id < st_ivas->nchan_transport; sce_id++ ) for ( sce_id = nchan_transport_old; sce_id < st_ivas->nchan_transport; sce_id++ ) { if ( ( error = create_sce_dec( st_ivas, sce_id, element_brate_tmp[sce_id] ) ) != IVAS_ERR_OK ) { Loading @@ -1048,17 +1060,21 @@ static ivas_error ivas_ism_format_bitrate_switching( } /* Destroy the core coder memory */ for ( ; sce_id < last_nchan_trans; sce_id++ ) for ( ; sce_id < nchan_transport_old; sce_id++ ) { destroy_sce_dec( st_ivas->hSCE[sce_id] ); st_ivas->hSCE[sce_id] = NULL; } } #endif #ifdef CORECODER_BITRATE_SWITCHING ivas_hp20_dec_reconfig( st_ivas, nchan_transport_old ); #else /* destroy the memory of hp20*/ if ( st_ivas->mem_hp20_out != NULL ) { for ( sce_id = 0; sce_id < last_nchan_trans; sce_id++ ) for ( sce_id = 0; sce_id < nchan_transport_old; sce_id++ ) { count_free( st_ivas->mem_hp20_out[sce_id] ); st_ivas->mem_hp20_out[sce_id] = NULL; Loading Loading @@ -1091,7 +1107,7 @@ static ivas_error ivas_ism_format_bitrate_switching( set_f( st_ivas->mem_hp20_out[sce_id], 0.0f, L_HP20_MEM ); } #endif /* Initialize the needed renderer struct and destroy the unnecessary renderer struct */ Loading Loading @@ -1218,7 +1234,7 @@ ivas_error ivas_ism_dec_config( ISM_MODE last_ism_mode; ivas_error error; #ifdef ISM_BITRATE_SWITCHING int16_t last_nchan_trans; int16_t nchan_transport_old; #endif error = IVAS_ERR_OK; Loading @@ -1229,10 +1245,10 @@ ivas_error ivas_ism_dec_config( last_ism_mode = st_ivas->ism_mode; #ifdef ISM_BITRATE_SWITCHING /* Assumes that num of input objects are constant */ last_nchan_trans = num_obj; nchan_transport_old = num_obj; if ( last_ism_mode == ISM_MODE_PARAM ) { last_nchan_trans = 2; nchan_transport_old = 2; } #endif Loading @@ -1255,12 +1271,11 @@ ivas_error ivas_ism_dec_config( { #ifdef ISM_BITRATE_SWITCHING /* ISM bit-rate switching */ if ( ( st_ivas->hDecoderConfig->last_ivas_total_brate != IVAS_SID_5k2 ) && ( st_ivas->hDecoderConfig->last_ivas_total_brate != FRAME_NO_DATA ) ) if ( st_ivas->hDecoderConfig->last_ivas_total_brate != IVAS_SID_5k2 && st_ivas->hDecoderConfig->last_ivas_total_brate != FRAME_NO_DATA ) { if ( ( st_ivas->ism_mode != last_ism_mode ) || ( st_ivas->hDecoderConfig->ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) ) { ivas_ism_format_bitrate_switching( st_ivas, last_nchan_trans, last_ism_mode, num_obj ); st_ivas->nSCE = st_ivas->nchan_transport; ivas_ism_bitrate_switching( st_ivas, nchan_transport_old, last_ism_mode, num_obj ); } } #else Loading
lib_enc/ivas_ism_param_enc.c +117 −11 Original line number Diff line number Diff line Loading @@ -42,6 +42,10 @@ #include "wmops.h" #ifdef CORECODER_BITRATE_SWITCHING static ivas_error ivas_hp20_reconfig( Encoder_Struct *st_ivas, const int16_t nchan_hp20_old ); #endif /*------------------------------------------------------------------------- * Local function definitions *------------------------------------------------------------------------*/ Loading Loading @@ -416,16 +420,16 @@ ivas_error ivas_ism_enc_config( ivas_error error; ISM_MODE last_ism_mode; #ifdef ISM_BITRATE_SWITCHING int16_t last_nSCE; #ifdef CORECODER_BITRATE_SWITCHING int16_t nchan_transport_old; #else int16_t nSCE_old, nchan_transport_old; int16_t sce_id, n; #endif #endif error = IVAS_ERR_OK; last_ism_mode = st_ivas->ism_mode; #ifdef ISM_BITRATE_SWITCHING last_nSCE = st_ivas->nSCE; #endif /* select ISM format mode */ st_ivas->ism_mode = ivas_ism_mode_select( st_ivas->hEncoderConfig->nchan_inp, st_ivas->hEncoderConfig->ivas_total_brate ); Loading @@ -435,7 +439,14 @@ ivas_error ivas_ism_enc_config( if ( ( st_ivas->ism_mode != last_ism_mode ) || ( st_ivas->hEncoderConfig->ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) ) { int32_t element_brate_tmp[MAX_NUM_OBJECTS]; #ifndef CORECODER_BITRATE_SWITCHING Indice *ind_list_sce, *ind_list_metadata; #endif #ifndef CORECODER_BITRATE_SWITCHING nSCE_old = st_ivas->nSCE; #endif nchan_transport_old = st_ivas->nchan_transport; /* Reset and Initialize */ if ( st_ivas->ism_mode == ISM_MODE_PARAM ) Loading @@ -452,10 +463,13 @@ ivas_error ivas_ism_enc_config( ivas_ism_config( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hEncoderConfig->nchan_inp, NULL, NULL, NULL, element_brate_tmp, NULL, NULL ); if ( st_ivas->nSCE > last_nSCE ) #ifdef CORECODER_BITRATE_SWITCHING ivas_corecoder_enc_reconfig( st_ivas, nchan_transport_old, 0, nchan_transport_old ); #else if ( st_ivas->nSCE > nSCE_old ) { /* Reconfigure the core coders */ for ( sce_id = 0; sce_id < last_nSCE; sce_id++ ) for ( sce_id = 0; sce_id < nSCE_old; sce_id++ ) { copy_encoder_config( st_ivas, st_ivas->hSCE[sce_id]->hCoreCoder[0], 0 ); st_ivas->hSCE[sce_id]->element_brate = st_ivas->hEncoderConfig->ivas_total_brate / st_ivas->nchan_transport; Loading @@ -466,7 +480,7 @@ ivas_error ivas_ism_enc_config( ind_list_sce = st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list; ind_list_metadata = st_ivas->hSCE[0]->hMetaData->ind_list; for ( sce_id = last_nSCE; sce_id < st_ivas->nSCE; sce_id++ ) for ( sce_id = nSCE_old; sce_id < st_ivas->nSCE; sce_id++ ) { /* Initialize the Core Coder */ if ( ( error = create_sce_enc( st_ivas, sce_id, element_brate_tmp[sce_id] ) ) != IVAS_ERR_OK ) Loading @@ -493,7 +507,7 @@ ivas_error ivas_ism_enc_config( } /* Delete the extra memory */ for ( sce_id = st_ivas->nSCE; sce_id < last_nSCE; sce_id++ ) for ( sce_id = st_ivas->nSCE; sce_id < nSCE_old; sce_id++ ) { if ( st_ivas->hSCE[sce_id] != NULL ) { Loading @@ -502,6 +516,7 @@ ivas_error ivas_ism_enc_config( } } } #endif if ( st_ivas->ism_mode == ISM_MODE_PARAM && last_ism_mode == ISM_MODE_DISC ) { Loading @@ -519,10 +534,13 @@ ivas_error ivas_ism_enc_config( st_ivas->hDirAC = NULL; } #ifdef CORECODER_BITRATE_SWITCHING ivas_hp20_reconfig( st_ivas, nchan_transport_old ); #else /* destroy the memory of hp20*/ if ( st_ivas->mem_hp20_in != NULL ) { for ( sce_id = 0; sce_id < last_nSCE; sce_id++ ) for ( sce_id = 0; sce_id < nSCE_old; sce_id++ ) { count_free( st_ivas->mem_hp20_in[sce_id] ); st_ivas->mem_hp20_in[sce_id] = NULL; Loading Loading @@ -556,6 +574,7 @@ ivas_error ivas_ism_enc_config( set_f( st_ivas->mem_hp20_in[sce_id], 0.0f, L_HP20_MEM ); } #endif } #else /* ISM format switching */ Loading @@ -568,3 +587,90 @@ ivas_error ivas_ism_enc_config( return error; } #ifdef CORECODER_BITRATE_SWITCHING // VE: this is the same function as at the decoder -> harmonize them to a new file ivas_corecoder_reconfig.c /*-------------------------------------------------------------------* * ivas_hp20_dec_reconfig() * * Allocate, initialize, and configure HP20 memory handles in case of bitrate switching *-------------------------------------------------------------------*/ static ivas_error ivas_hp20_reconfig( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ const int16_t nchan_hp20_old /* i : number of HP20 filters in previous frame */ ) { int16_t i, nchan_hp20; float **old_mem_hp20_out; ivas_error error; error = IVAS_ERR_OK; /*-----------------------------------------------------------------* * HP20 memories *-----------------------------------------------------------------*/ nchan_hp20 = getNumChanAnalysis( st_ivas ); if ( nchan_hp20 > nchan_hp20_old ) { /* save old mem_hp_20 pointer */ old_mem_hp20_out = st_ivas->mem_hp20_in; st_ivas->mem_hp20_in = NULL; if ( ( st_ivas->mem_hp20_in = (float **) count_malloc( nchan_hp20 * sizeof( float * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); } for ( i = 0; i < nchan_hp20_old; i++ ) { st_ivas->mem_hp20_in[i] = old_mem_hp20_out[i]; old_mem_hp20_out[i] = NULL; } /* create additional hp20 memories */ for ( ; i < nchan_hp20; i++ ) { if ( ( st_ivas->mem_hp20_in[i] = (float *) count_malloc( L_HP20_MEM * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); } set_f( st_ivas->mem_hp20_in[i], 0.0f, L_HP20_MEM ); } count_free( old_mem_hp20_out ); old_mem_hp20_out = NULL; } else if ( nchan_hp20 < nchan_hp20_old ) { /* save old mem_hp_20 pointer */ old_mem_hp20_out = st_ivas->mem_hp20_in; st_ivas->mem_hp20_in = NULL; if ( ( st_ivas->mem_hp20_in = (float **) count_malloc( nchan_hp20 * sizeof( float * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); } for ( i = 0; i < nchan_hp20; i++ ) { st_ivas->mem_hp20_in[i] = old_mem_hp20_out[i]; old_mem_hp20_out[i] = NULL; } /* remove superfluous hp20 memories */ for ( ; i < nchan_hp20_old; i++ ) { count_free( old_mem_hp20_out[i] ); old_mem_hp20_out[i] = NULL; } count_free( old_mem_hp20_out ); old_mem_hp20_out = NULL; } return error; } #endif