From afbb8b8dcc4109db1d6053118e50b0054d909ea6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 22 Feb 2023 15:52:18 +0100 Subject: [PATCH] - maintenance: formatting, comments, empty lines, add "const" , add return errors --- lib_com/ivas_masa_com.c | 1 + lib_com/ivas_mc_com.c | 3 + lib_com/ivas_mc_param_com.c | 4 +- lib_com/ivas_mcmasa_com.c | 1 + lib_com/ivas_mct_com.c | 1 - lib_com/ivas_prot.h | 35 ++++----- lib_com/ivas_transient_det.c | 3 +- lib_com/prot.h | 2 +- lib_dec/fd_cng_dec.c | 2 +- lib_dec/ivas_cpe_dec.c | 8 +- lib_dec/ivas_dec.c | 42 ++++------- lib_dec/ivas_dirac_dec.c | 11 +-- lib_dec/ivas_init_dec.c | 35 +++++---- lib_dec/ivas_masa_dec.c | 10 +-- lib_dec/ivas_mc_param_dec.c | 15 ++-- lib_dec/ivas_mcmasa_dec.c | 4 +- lib_dec/ivas_mct_dec.c | 3 +- lib_dec/ivas_mdct_core_dec.c | 64 ++++++++-------- lib_dec/ivas_sba_dec.c | 16 +++- lib_dec/ivas_sba_dirac_stereo_dec.c | 104 ++++++++++---------------- lib_dec/ivas_sce_dec.c | 1 - lib_dec/ivas_spar_md_dec.c | 12 +-- lib_dec/ivas_stereo_dft_dec.c | 24 +++--- lib_dec/ivas_stereo_mdct_core_dec.c | 2 + lib_dec/ivas_stereo_mdct_stereo_dec.c | 2 + lib_dec/swb_tbe_dec.c | 5 +- lib_enc/ivas_enc.c | 19 +++-- lib_enc/ivas_init_enc.c | 4 +- lib_enc/ivas_masa_enc.c | 1 + lib_enc/ivas_mc_param_enc.c | 6 +- lib_enc/ivas_mcmasa_enc.c | 11 +-- lib_enc/ivas_mct_core_enc.c | 1 - lib_enc/ivas_mct_enc.c | 8 +- lib_enc/ivas_sba_enc.c | 5 ++ lib_enc/ivas_tcx_core_enc.c | 4 +- lib_enc/swb_tbe_enc.c | 32 ++++---- lib_rend/lib_rend.c | 42 ++++++++++- 37 files changed, 273 insertions(+), 270 deletions(-) diff --git a/lib_com/ivas_masa_com.c b/lib_com/ivas_masa_com.c index 421b2882f4..86f7676378 100644 --- a/lib_com/ivas_masa_com.c +++ b/lib_com/ivas_masa_com.c @@ -302,6 +302,7 @@ void ivas_masa_set_coding_config( return; } + /*--------------------------------------------------------------- * masa_sample_rate_band_correction() * diff --git a/lib_com/ivas_mc_com.c b/lib_com/ivas_mc_com.c index 1b3e00adb0..027b687686 100644 --- a/lib_com/ivas_mc_com.c +++ b/lib_com/ivas_mc_com.c @@ -115,6 +115,7 @@ MC_MODE ivas_mc_mode_select( return mc_mode; } + /*--------------------------------------------------------------- * ivas_mc_setup_get_num_channels() * @@ -154,6 +155,7 @@ int16_t ivas_mc_ls_setup_get_num_channels( return nchan; } + /*--------------------------------------------------------------- * ivas_mc_map_output_config_to_mc_ls_setup() * @@ -193,6 +195,7 @@ MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup( return mc_ls_setup; } + /*--------------------------------------------------------------- * ivas_mc_map_ls_setup_to_output_config * diff --git a/lib_com/ivas_mc_param_com.c b/lib_com/ivas_mc_param_com.c index 502f33b2b4..c6cfe0ed8f 100644 --- a/lib_com/ivas_mc_param_com.c +++ b/lib_com/ivas_mc_param_com.c @@ -212,7 +212,6 @@ void ivas_param_mc_metadata_close( { uint16_t i; - /* adaptive ICC mapping */ for ( i = 0; i < 2; i++ ) { @@ -422,6 +421,7 @@ static int16_t ivas_param_mc_get_num_param_bands( return num_parameter_bands; } + /*------------------------------------------------------------------------- * Local functions *------------------------------------------------------------------------*/ @@ -438,7 +438,6 @@ static void ivas_param_mc_set_coding_scheme( HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* i/o: Parametric MC metadata handle */ ) { - /* quantizer and coding tables */ switch ( mc_ls_setup ) { @@ -520,5 +519,6 @@ static void ivas_param_mc_set_coding_scheme( } hMetadataPMC->num_parameter_bands = ivas_param_mc_get_num_param_bands( mc_ls_setup, ivas_total_brate ); + return; } diff --git a/lib_com/ivas_mcmasa_com.c b/lib_com/ivas_mcmasa_com.c index 27becd16a8..1b7db4ff01 100644 --- a/lib_com/ivas_mcmasa_com.c +++ b/lib_com/ivas_mcmasa_com.c @@ -65,6 +65,7 @@ void ivas_mcmasa_setNumTransportChannels( return; } + /*--------------------------------------------------------------------------* * ivas_mcmasa_set_separate_channel_mode() * diff --git a/lib_com/ivas_mct_com.c b/lib_com/ivas_mct_com.c index 01dd172119..5ef4d29478 100644 --- a/lib_com/ivas_mct_com.c +++ b/lib_com/ivas_mct_com.c @@ -94,7 +94,6 @@ void splitAvailableBitsMCT( } } - for ( i = 0; i < nchan; i++ ) { if ( mct_chan_mode[i] != MCT_CHAN_MODE_LFE && mct_chan_mode[i] != MCT_CHAN_MODE_IGNORE ) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 7d0a42de93..4335929d8c 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1070,9 +1070,8 @@ ivas_error stereo_dft_dec_create( STEREO_DFT_DEC_DATA_HANDLE *hStereoDft, /* i/o: decoder DFT stereo handle */ const int32_t element_brate, /* i : element bitrate */ const int32_t output_Fs, /* i : output sampling rate */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ - , - const int16_t nchan_transport + const int16_t sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ + const int16_t nchan_transport /* i : number of transport channels */ ); void stereo_dft_dec_reset( @@ -1115,12 +1114,11 @@ void stereo_dft_dec( float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers */ float *input_mem, /* i/o: mem of buffer DFT analysis */ STEREO_CNG_DEC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ - , - ivas_spar_md_dec_state_t *hMdDec, /* SPAR MD handle for upmixing */ - int16_t cross_fade_start_offset, /* i: SPAR mixer delay compensation */ - int32_t output_Fs, /* i: Fs for delay calculation */ - int16_t nchan_transport /* i: number of transpor channels */ + const int16_t sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ + ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD handle for upmixing */ + const int16_t cross_fade_start_offset, /* i : SPAR mixer delay compensation */ + const int32_t output_Fs, /* i : Fs for delay calculation */ + const int16_t nchan_transport /* i : number of transpor channels */ ); void stereo_dft_res_ecu( @@ -3203,9 +3201,8 @@ int16_t ivas_sba_remapTCs( void ivas_sba_dirac_stereo_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float output[CPE_CHANNELS][L_FRAME48k], /* o : output synthesis signal */ - const int16_t output_frame /* i : output frame length per channel */ - , - const int16_t mcmasa + const int16_t output_frame, /* i : output frame length per channel */ + const int16_t mcmasa /* i : McMASA flag */ ); void ivas_sba_dirac_stereo_config( @@ -3213,11 +3210,10 @@ void ivas_sba_dirac_stereo_config( ); void ivas_sba_dirac_stereo_smooth_parameters( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i/o: encoder DFT stereo handle */ - , - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD handle for upmixing */ - int16_t cross_fade_start_offset, /* i: SPAR mixer delay compensation */ - int32_t output_Fs /* i: Fs for delay calculation */ + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: encoder DFT stereo handle */ + ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD handle for upmixing */ + const int16_t cross_fade_start_offset, /* i : SPAR mixer delay compensation */ + const int32_t output_Fs /* i : Fs for delay calculation */ ); void ivas_sba2mc_cldfb( @@ -4031,8 +4027,8 @@ ivas_error ivas_spar_md_dec_open( ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ const int16_t num_channels, /* i : number of internal channels */ - const int16_t sba_order /* i : SBA order */ - ,const int16_t sid_format + const int16_t sba_order, /* i : SBA order */ + const int16_t sid_format /* i : SID format */ ); void ivas_spar_md_dec_close( @@ -4362,7 +4358,6 @@ void ivas_quantise_real_values( const int16_t dim ); - void ivas_spar_get_uniform_quant_strat( ivas_spar_md_com_cfg *pSpar_md_com_cfg, const int16_t table_idx diff --git a/lib_com/ivas_transient_det.c b/lib_com/ivas_transient_det.c index 8fc2b92c99..e2f2dfb766 100644 --- a/lib_com/ivas_transient_det.c +++ b/lib_com/ivas_transient_det.c @@ -234,7 +234,6 @@ int16_t ivas_transient_det_process( #endif float mem = hTranDet->in_duck_gain; - #ifndef SMOOTH_WITH_TRANS_DET ivas_td_decorr_get_ducking_gains( hTranDet, pIn_pcm, NULL, NULL, frame_len, IVAS_TDET_ONLY ); @@ -269,7 +268,7 @@ int16_t ivas_transient_det_process( } mem = in_duck_gain[idx]; } - // dbgwrite( &transient_det[1], sizeof( int16_t ), 1, 1, "trans_det.raw" ); + return; #endif } diff --git a/lib_com/prot.h b/lib_com/prot.h index f47c2d65b2..12ae8a3c6f 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -8523,7 +8523,7 @@ void generate_comfort_noise_dec_hf( HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ #ifdef PARAM_ISM_DTX_CNG , - int16_t cng_flag /*i: CNG Flag */ + const int16_t cng_flag /*i : CNG Flag */ #endif ); diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 314d0534a7..043e21b2e6 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1351,7 +1351,7 @@ void generate_comfort_noise_dec_hf( HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ #ifdef PARAM_ISM_DTX_CNG , - int16_t cng_coh_flag /* i: CNG Flag for coherence handling */ + const int16_t cng_coh_flag /* i : CNG Flag for coherence handling */ #endif ) { diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index e45dc9c672..e96df0d637 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -291,7 +291,6 @@ ivas_error ivas_cpe_dec( } } else - { /* subtract metadata bitbudget */ /* IVAS_fmToDo: TBC whether it is not better to distribute the metadata bits equally between 2 channels */ sts[0]->bits_frame_channel -= nb_bits_metadata; @@ -406,8 +405,7 @@ ivas_error ivas_cpe_dec( } else { - stereo_dft_dec( hCPE->hStereoDft, sts[0], DFT, hCPE->input_mem[1], hCPE->hStereoCng, 0, - 0, 0, 0, 0 ); + stereo_dft_dec( hCPE->hStereoDft, sts[0], DFT, hCPE->input_mem[1], hCPE->hStereoCng, 0, 0, 0, 0, 0 ); } /* synthesis iFFT */ @@ -455,6 +453,7 @@ ivas_error ivas_cpe_dec( /*----------------------------------------------------------------* * Synthesis synchronization between CPE modes *----------------------------------------------------------------*/ + if ( !st_ivas->sba_dirac_stereo_flag ) { synchro_synthesis( ivas_total_brate, hCPE, output, output_frame, 0 ); @@ -707,8 +706,7 @@ ivas_error create_cpe_dec( if ( hCPE->element_mode == IVAS_CPE_DFT || ( st_ivas->sba_dirac_stereo_flag && hCPE->cpe_id == 0 ) ) { - if ( ( error = stereo_dft_dec_create( &( hCPE->hStereoDft ), hCPE->element_brate, output_Fs, st_ivas->sba_dirac_stereo_flag, - st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) + if ( ( error = stereo_dft_dec_create( &( hCPE->hStereoDft ), hCPE->element_brate, output_Fs, st_ivas->sba_dirac_stereo_flag, st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 47f550f570..de8dde9828 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -176,6 +176,7 @@ ivas_error ivas_dec( if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { ivas_param_ism_params_to_masa_param_mapping( st_ivas ); + ivas_dirac_dec_binaural( st_ivas, output, st_ivas->nchan_transport ); } else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) @@ -219,15 +220,7 @@ ivas_error ivas_dec( else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { #ifdef FIX_197_CREND_INTERFACE - if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, - AUDIO_CONFIG_7_1_4, - AUDIO_CONFIG_BINAURAL_ROOM, - NULL, - NULL, - NULL, - NULL, - output, - output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, NULL, NULL, NULL, NULL, output, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -322,8 +315,7 @@ ivas_error ivas_dec( ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi ); } - ivas_sba_dirac_stereo_dec( st_ivas, output, output_frame, - st_ivas->ivas_format == MC_FORMAT ); + ivas_sba_dirac_stereo_dec( st_ivas, output, output_frame, st_ivas->ivas_format == MC_FORMAT ); } else if ( st_ivas->ivas_format == MASA_FORMAT && ivas_total_brate < MASA_STEREO_MIN_BITRATE && ( ivas_total_brate > IVAS_SID_5k2 || ( ivas_total_brate <= IVAS_SID_5k2 && st_ivas->nCPE > 0 && st_ivas->hCPE[0]->nchan_out == 1 ) ) ) { @@ -383,18 +375,20 @@ ivas_error ivas_dec( { if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) { - ivas_sba_linear_renderer( output, output_frame, nchan_remapped, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); + if ( ( error = ivas_sba_linear_renderer( output, output_frame, nchan_remapped, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) + { + return error; + } } else if ( st_ivas->renderer_type == RENDERER_DIRAC ) { ivas_dirac_dec( st_ivas, output, nchan_remapped, NULL, NULL, -1 ); } } - else /* SBA_MODE_SPAR */ - if ( !st_ivas->sba_dirac_stereo_flag ) - { - ivas_sba_upmixer_renderer( st_ivas, output, output_frame ); /* Note: ivas_sba_linear_renderer() or ivas_dirac_dec() are called internally */ - } + else if ( !st_ivas->sba_dirac_stereo_flag ) + { + ivas_sba_upmixer_renderer( st_ivas, output, output_frame ); /* Note: ivas_sba_linear_renderer() or ivas_dirac_dec() are called internally */ + } } else if ( st_ivas->ivas_format == MC_FORMAT ) { @@ -437,15 +431,7 @@ ivas_error ivas_dec( if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { #ifdef FIX_197_CREND_INTERFACE - if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, - st_ivas->intern_config, - st_ivas->hOutSetup.output_config, - st_ivas->hDecoderConfig, - st_ivas->hHeadTrackData, - &st_ivas->hIntSetup, - st_ivas->hEFAPdata, - output, - output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hHeadTrackData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, output, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -466,6 +452,7 @@ ivas_error ivas_dec( else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { ivas_td_binaural_renderer( st_ivas, output, output_frame ); + ivas_binaural_add_LFE( st_ivas, output_frame, output ); } } @@ -568,8 +555,7 @@ ivas_error ivas_dec( if ( st_ivas->sba_dirac_stereo_flag ) /* use the flag to trigger the DFT upmix */ { - ivas_sba_dirac_stereo_dec( st_ivas, output, output_frame, - 1 ); + ivas_sba_dirac_stereo_dec( st_ivas, output, output_frame, 1 ); } /* HP filtering */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index e6d5f846a3..17718e86a3 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2118,7 +2118,6 @@ void ivas_dirac_dec( hDirAC->buffer_intensity_real[1][index - 1], hDirAC->buffer_intensity_real[2][index - 1], num_freq_bands, - hDirAC->azimuth[hDirAC->dirac_estimator_idx], hDirAC->elevation[hDirAC->dirac_estimator_idx] ); @@ -2331,7 +2330,6 @@ void ivas_dirac_dec( Cldfb_RealBuffer, Cldfb_ImagBuffer ); - /* Inverse CLDFB*/ for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { @@ -3220,6 +3218,7 @@ static void protoSignalComputation4( return; } + /*------------------------------------------------------------------------- * ivas_dirac_dec_compute_diffuse_proto() * @@ -3227,8 +3226,9 @@ static void protoSignalComputation4( *------------------------------------------------------------------------*/ static void ivas_dirac_dec_compute_diffuse_proto( - DIRAC_DEC_HANDLE hDirAC, /* i/o: DirAC handle */ - const int16_t slot_idx ) + DIRAC_DEC_HANDLE hDirAC, /* i/o: DirAC handle */ + const int16_t slot_idx /* i : slot index */ +) { int16_t k, l; int16_t num_freq_bands, num_freq_bands_diff; @@ -3236,7 +3236,6 @@ static void ivas_dirac_dec_compute_diffuse_proto( float *p_proto_diff, *p_power_smooth, *proto_frame_dec_f; DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params; DIRAC_OUTPUT_SYNTHESIS_STATE *h_dirac_output_synthesis_state; - int16_t m; float *p_hoa_enc; @@ -3348,6 +3347,7 @@ static void computeDirectionAngles( return; } + /*------------------------------------------------------------------------- * ivas_masa_init_stereotype_detection() * @@ -3510,6 +3510,7 @@ static void computeIntensityVector_dec( */ int16_t i; float real, img; + for ( i = 0; i < num_frequency_bands; ++i ) { real = Cldfb_RealBuffer[0][0][i]; diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 7f28bc4226..af6090168f 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -51,6 +51,7 @@ *-------------------------------------------------------------------*/ static ivas_error ivas_read_format( Decoder_Struct *st_ivas, int16_t *num_bits_read ); + static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); @@ -244,11 +245,13 @@ ivas_error ivas_dec_setup( st_ivas->element_mode_init = IVAS_CPE_MDCT; break; } - if ( ( st_ivas->ini_frame > 0 ) && ( st_ivas->ivas_format == SBA_FORMAT ) ) + + if ( st_ivas->ini_frame > 0 && st_ivas->ivas_format == SBA_FORMAT ) { int16_t nchan_transport_old, nchan_transport; SBA_MODE sba_mode_old; int32_t last_ivas_total_brate; + last_ivas_total_brate = st_ivas->last_active_ivas_total_brate; sba_mode_old = ivas_sba_mode_select( last_ivas_total_brate ); nchan_transport_old = st_ivas->nchan_transport; @@ -265,6 +268,7 @@ ivas_error ivas_dec_setup( { st_ivas->hDecoderConfig->ivas_total_brate = ( st_ivas->sba_mode == SBA_MODE_SPAR ) ? IVAS_24k4 : IVAS_13k2; } + if ( ( error = ivas_sba_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) { return error; @@ -308,6 +312,7 @@ ivas_error ivas_dec_setup( st->next_bit_pos = num_bits_read; st->total_brate = ACELP_8k00; /* only temporary initialization - this is needed for get_next_indice() in the frame following NO_DATA frame */ } + return error; } @@ -647,9 +652,9 @@ ivas_error ivas_init_decoder_front( return error; } - if ( ivas_render_config_init_from_rom( &st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM ) != IVAS_ERR_OK ) + if ( ( error = ivas_render_config_init_from_rom( &st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM ) ) != IVAS_ERR_OK ) { - return IVAS_ERR_INTERNAL_FATAL; + return error; } } @@ -712,6 +717,7 @@ ivas_error ivas_init_decoder( if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) { 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 ); } @@ -719,7 +725,10 @@ ivas_error ivas_init_decoder( if ( output_config == AUDIO_CONFIG_LS_CUSTOM ) { - ivas_ls_custom_output_init( st_ivas ); + if ( ( error = ivas_ls_custom_output_init( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } } ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); @@ -727,6 +736,7 @@ ivas_error ivas_init_decoder( if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) { ivas_mcmasa_set_separate_channel_mode( &( st_ivas->hIntSetup.separateChannelEnabled ), &( st_ivas->hIntSetup.separateChannelIndex ), ivas_total_brate ); + if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.separateChannelEnabled ) { st_ivas->hLsSetupCustom->separate_ch_found = 0; @@ -990,6 +1000,7 @@ ivas_error ivas_init_decoder( return error; } } + 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; @@ -1106,6 +1117,7 @@ ivas_error ivas_init_decoder( for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { 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; @@ -1247,22 +1259,14 @@ ivas_error ivas_init_decoder( #ifdef FIX_197_CREND_INTERFACE if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->ivas_format == MC_FORMAT && st_ivas->hDecoderConfig->Opt_Headrotation ) { - if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), - st_ivas->hIntSetup.ls_azimuth, - st_ivas->hIntSetup.ls_elevation, - st_ivas->hIntSetup.nchan_out_woLFE, - EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) + if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth, st_ivas->hIntSetup.ls_elevation, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) { return error; } } - if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), - st_ivas->intern_config, - st_ivas->hDecoderConfig->output_config, - st_ivas->hRenderConfig, st_ivas->hDecoderConfig->Opt_Headrotation, - st_ivas->hSetOfHRTF, - st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, + st_ivas->hRenderConfig, st_ivas->hDecoderConfig->Opt_Headrotation, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -1368,7 +1372,6 @@ ivas_error ivas_init_decoder( st_ivas->hLimiter = ivas_limiter_open( hDecoderConfig->nchan_out, output_Fs ); - return error; } diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 18d42cb910..cefade119f 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -169,7 +169,6 @@ ivas_error ivas_masa_decode( return error; } - /* If we are under metadata bit budget limit and joined subframes is not signalled, then read LBR mode. */ if ( hMasa->config.max_metadata_bits < MINIMUM_BIT_BUDGET_NORMAL_META && hMasa->config.joinedSubframes == FALSE ) { @@ -236,7 +235,6 @@ ivas_error ivas_masa_decode( return error; } - hQMetaData->numTwoDirBands = hMasa->config.numTwoDirBands; hQMetaData->useLowerRes = 0; @@ -254,8 +252,7 @@ ivas_error ivas_masa_decode( } tmp_elem_mode = -1; - *nb_bits_read += ivas_qmetadata_dec_sid_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), st_ivas->nchan_transport, &tmp_elem_mode, ivas_format, - SBA_MODE_NONE ); + *nb_bits_read += ivas_qmetadata_dec_sid_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), st_ivas->nchan_transport, &tmp_elem_mode, ivas_format, SBA_MODE_NONE ); if ( st_ivas->nchan_transport == 2 ) { @@ -276,8 +273,7 @@ ivas_error ivas_masa_decode( } if ( st_ivas->hDirAC != NULL ) { - ivas_qmetadata_to_dirac( hQMetaData, st_ivas->hDirAC, hMasa, ivas_total_brate, - SBA_MODE_NONE, 0 ); + ivas_qmetadata_to_dirac( hQMetaData, st_ivas->hDirAC, hMasa, ivas_total_brate, SBA_MODE_NONE, 0 ); } st->next_bit_pos = next_bit_pos_orig; @@ -425,7 +421,6 @@ static ivas_error ivas_masa_dec_config( ivas_error error; error = IVAS_ERR_OK; - hMasa = st_ivas->hMasa; ivas_masa_set_elements( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &st_ivas->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE ); @@ -440,7 +435,6 @@ static ivas_error ivas_masa_dec_config( return error; } - st_ivas->hQMetaData->numTwoDirBands = st_ivas->hMasa->config.numTwoDirBands; st_ivas->hQMetaData->useLowerRes = 0; diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 745e9c04ff..803ccdf86c 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -264,7 +264,6 @@ ivas_error ivas_param_mc_dec_open( hParamMC->max_param_band_abs_cov = ( k++ ); } - /*-----------------------------------------------------------------* * open sub-modules *-----------------------------------------------------------------*/ @@ -675,7 +674,6 @@ ivas_error ivas_param_mc_dec_reconfig( hParamMC->max_param_band_abs_cov = ( k++ ); } - /*-----------------------------------------------------------------* * open sub-modules *-----------------------------------------------------------------*/ @@ -723,6 +721,7 @@ ivas_error ivas_param_mc_dec_reconfig( hParamMC->proto_matrix_int = (float *) malloc( nchan_out_transport * nchan_transport * sizeof( float ) ); mvr2r( ivas_param_mc_conf[config_index].dmx_fac, hParamMC->proto_matrix_int, nchan_transport * nchan_out_transport ); } + if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) { matrix_product( hParamMC->ls_conv_dmx_matrix, nchan_out_cov, nchan_out_transport, 0, @@ -892,7 +891,6 @@ ivas_error ivas_param_mc_dec_reconfig( ivas_dirac_dec_output_synthesis_cov_close( ¶ms_old, &cov_state_old ); } - /*-----------------------------------------------------------------* * memory allocation *-----------------------------------------------------------------*/ @@ -907,6 +905,7 @@ ivas_error ivas_param_mc_dec_reconfig( return error; } + /*------------------------------------------------------------------------- * param_mc_get_num_cldfb_syntheses() * @@ -1258,7 +1257,6 @@ void ivas_param_mc_dec_read_BS( *nb_bits = bit_pos; - } /* if ( !st->bfi ) */ if ( st->bfi ) @@ -1809,6 +1807,7 @@ static int16_t ivas_param_mc_uniform_decoder( return n_bits; } + /*------------------------------------------------------------------------- * ivas_param_mc_range_decoder_LC() * @@ -1867,6 +1866,7 @@ static int16_t ivas_param_mc_range_decoder_LC( return cur_bit_pos; } + /*------------------------------------------------------------------------- * param_mc_compute_interpolator() * @@ -1942,9 +1942,11 @@ static void remove_lfe_from_cy( } ptrCy += nY; } + return; } + /*------------------------------------------------------------------------- * ivas_param_mc_get_mixing_matrices() * @@ -2321,6 +2323,7 @@ static void ivas_param_mc_get_mono_stereo_mixing_matrices( return; } + /*------------------------------------------------------------------------- * param_mc_update_mixing_matrices() * @@ -2355,6 +2358,7 @@ static void param_mc_update_mixing_matrices( return; } + /*------------------------------------------------------------------------- * ivas_param_mc_dequantize_cov() * @@ -2564,6 +2568,7 @@ static void param_mc_set_num_synth_bands( return; } + /*-------------------------------------------------------------------------* * param_mc_get_diff_proto_info() * @@ -2647,7 +2652,6 @@ static void param_mc_get_diff_proto_info( } } - /* set up the prototype info struct */ p_diff_proto_info->source_chan_idx = (int16_t **) malloc( p_diff_proto_info->num_protos_diff * sizeof( int16_t * ) ); p_diff_proto_info->proto_fac = (float **) malloc( p_diff_proto_info->num_protos_diff * sizeof( float * ) ); @@ -2672,7 +2676,6 @@ static void param_mc_get_diff_proto_info( } } - return; } diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec.c index 20b1ea49ad..f6d159083b 100644 --- a/lib_dec/ivas_mcmasa_dec.c +++ b/lib_dec/ivas_mcmasa_dec.c @@ -66,8 +66,10 @@ ivas_error ivas_mcmasa_dec_reconfig( /* 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 ); + /* transport channel settings may affect renderer */ ivas_renderer_select( st_ivas ); + /* renderer change may affect internal config */ 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 ); @@ -133,7 +135,7 @@ ivas_error ivas_mcmasa_dec_reconfig( 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 ) ) + if ( st_ivas->hDiracDecBin->useTdDecorr != ( 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 ); diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index b5ed8f8cc9..1623aad023 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -86,10 +86,9 @@ ivas_error ivas_mct_dec( int32_t ivas_total_brate; ivas_error error; - error = IVAS_ERR_OK; - push_wmops( "ivas_mct_dec" ); + error = IVAS_ERR_OK; nCPE = st_ivas->nCPE; hMCT = st_ivas->hMCT; diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 8f62a18642..7763290f87 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -49,9 +49,9 @@ /*-----------------------------------------------------------------* - * Function mdct_read_IGF_bits() * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - * read IGF side bits * + * Function mdct_read_IGF_bits() + * + * read IGF side bits *-----------------------------------------------------------------*/ void mdct_read_IGF_bits( @@ -90,9 +90,9 @@ void mdct_read_IGF_bits( /*-----------------------------------------------------------------* - * Function dec_prm_tcx_sidebits() * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - * decode TCX side parameters * + * Function dec_prm_tcx_sidebits() + * + * decode TCX side parameters *-----------------------------------------------------------------*/ static void dec_prm_tcx_sidebits( @@ -212,18 +212,18 @@ static void dec_prm_tcx_sidebits( /*-----------------------------------------------------------------* - * Function dec_prm_tcx_spec() * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - * decode TCX core parameters * + * Function dec_prm_tcx_spec() + * + * decode TCX core parameters *-----------------------------------------------------------------*/ static void dec_prm_tcx_spec( - Decoder_State *st, /* i/o: decoder memory state */ - int16_t param[], /* o : decoded parameters */ - int16_t *total_nbbits, /* i/o: number of bits / decoded bits */ - int16_t *bitsRead, /* o : number of read bits */ + Decoder_State *st, /* i/o: decoder memory state */ + int16_t param[], /* o : decoded parameters */ + int16_t *total_nbbits, /* i/o: number of bits / decoded bits */ + int16_t *bitsRead, /* o : number of read bits */ int16_t p_param[NB_DIV], /* o : pointer to parameters for next round of bs reading*/ - int16_t nTnsBitsTCX10[NB_DIV] /* i : number of TNS bits per TCX10 subframe*/ + int16_t nTnsBitsTCX10[NB_DIV] /* i : number of TNS bits per TCX10 subframe */ ) { int16_t nSubframes; @@ -288,9 +288,9 @@ static void dec_prm_tcx_spec( /*-----------------------------------------------------------------* - * Function ivas_mdct_dec_side_bits_frame_channel() * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - * Initialize TCX and read TCX side parameters * + * Function ivas_mdct_dec_side_bits_frame_channel() + * + * Initialize TCX and read TCX side parameters *-----------------------------------------------------------------*/ void ivas_mdct_dec_side_bits_frame_channel( @@ -427,9 +427,9 @@ void ivas_mdct_dec_side_bits_frame_channel( /*-----------------------------------------------------------------* - * ivas_mdct_core_invQ() * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - * Inverse processing steps up to inverse quantization * + * ivas_mdct_core_invQ() + * + * Inverse processing steps up to inverse quantization *-----------------------------------------------------------------*/ void ivas_mdct_core_invQ( @@ -720,14 +720,13 @@ void ivas_mdct_core_invQ( { TonalMdctConceal_create_concealment_noise( concealment_noise[ch], hCPE, L_frameTCX[ch], L_frame[ch], ch, k, st->core, st->hTcxDec->cummulative_damping_tcx, noise_gen_mode_bfi ); } + decoder_tcx_noisefilling( st, concealment_noise[ch], Aq[ch], L_frameTCX_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], NULL, &tmp_concealment_method, gain_tcx, prm_sqQ, nf_seed, bfi, MCT_flag, k ); - decoder_tcx_noiseshaping_igf( st, L_spec[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x[ch][k], - NULL, &tmp_concealment_method, bfi ); + decoder_tcx_noiseshaping_igf( st, L_spec[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x[ch][k], NULL, &tmp_concealment_method, bfi ); } } - if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) /*indicates LFE with no content*/ { set_f( &x[ch][0][MCT_LFE_MAX_LINE], 0.f, st->hTcxCfg->tcx_coded_lines - MCT_LFE_MAX_LINE ); @@ -740,9 +739,9 @@ void ivas_mdct_core_invQ( /*-----------------------------------------------------------------* - * ivas_mdct_core_reconstruct() * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - * reconstruct time signal * + * ivas_mdct_core_reconstruct() + * + * reconstruct time signal *-----------------------------------------------------------------*/ void ivas_mdct_core_reconstruct( @@ -943,7 +942,6 @@ void ivas_mdct_core_reconstruct( if ( !bfi && !MCT_flag && hCPE->element_mode == IVAS_CPE_MDCT ) { int16_t i; - float nrgL, nrgR, xcorr; nrgL = nrgR = xcorr = EPSILON; @@ -964,9 +962,9 @@ void ivas_mdct_core_reconstruct( /*-----------------------------------------------------------------* - * ivas_mdct_core_tns_ns() * - * ~~~~~~~~~~~~~~~~~~~~~~~ * - * reconstruct time signal * + * ivas_mdct_core_tns_ns() + * + * reconstruct time signal *-----------------------------------------------------------------*/ void ivas_mdct_core_tns_ns( @@ -1063,14 +1061,12 @@ void ivas_mdct_core_tns_ns( } } - decoder_tcx_tns( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], &x[ch][k][0], - fUseTns[ch][k], &tnsData[ch][k], bfi, k, 1 ); + decoder_tcx_tns( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], &x[ch][k][0], fUseTns[ch][k], &tnsData[ch][k], bfi, k, 1 ); sns_shape_spectrum( x[ch][k], st->hTcxCfg->psychParamsCurrent, &sns_int_scf[0], st->hTcxCfg->psychParamsCurrent->nBins ); v_multc( x[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sns_int_scf[FDNS_NPTS - 1], x[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, L_spec[ch] - st->hTcxCfg->psychParamsCurrent->nBins ); - decoder_tcx_tns( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], &x[ch][k][0], - fUseTns[ch][k], &tnsData[ch][k], bfi, k, 0 ); + decoder_tcx_tns( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], &x[ch][k][0], fUseTns[ch][k], &tnsData[ch][k], bfi, k, 0 ); } if ( bfi && st->tonal_mdct_plc_active ) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 8595aaf673..98fad8c094 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -70,9 +70,10 @@ ivas_error ivas_sba_dec_reconfigure( hDecoderConfig = st_ivas->hDecoderConfig; ivas_total_brate = hDecoderConfig->ivas_total_brate; last_ivas_total_brate = st_ivas->last_active_ivas_total_brate; - sba_mode_old = ivas_sba_mode_select( last_ivas_total_brate ); + sba_mode_old = ivas_sba_mode_select( last_ivas_total_brate ); st_ivas->sba_mode = sba_mode_old; + /*-----------------------------------------------------------------* * Set SBA high-level parameters * Save old SBA high-level parameters @@ -100,6 +101,7 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); st_ivas->sba_mode = ivas_sba_mode_select( ivas_total_brate ); + /*-----------------------------------------------------------------* * Allocate, initalize, and configure SBA handles *-----------------------------------------------------------------*/ @@ -124,9 +126,9 @@ ivas_error ivas_sba_dec_reconfigure( sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); nchan_internal = ivas_sba_get_nchan_metadata( sba_order_internal ); + if ( hSpar != NULL && nchan_transport_old != ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) ) { - // VE: dirty patch -> reconfiguration of SPAR modules should be used instead !! IVAS_FB_CFG *fb_cfg; int16_t active_w_mixing; @@ -184,6 +186,7 @@ ivas_error ivas_sba_dec_reconfigure( } hSpar->i_subframe = 0; } + /* PCA handle */ if ( hSpar != NULL ) { @@ -202,6 +205,7 @@ ivas_error ivas_sba_dec_reconfigure( hSpar->hPCA = NULL; } } + if ( hSpar == NULL && st_ivas->sba_mode == SBA_MODE_SPAR ) { if ( ( error = ivas_spar_dec_open( st_ivas ) ) != IVAS_ERR_OK ) @@ -225,15 +229,18 @@ ivas_error ivas_sba_dec_reconfigure( hDirAC = st_ivas->hDirAC; } - if ( ( hDirAC != NULL ) && ( sba_mode_old == st_ivas->sba_mode ) ) + + if ( hDirAC != NULL && sba_mode_old == st_ivas->sba_mode ) { ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE_MODE ); } + if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_mode, IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) != IVAS_ERR_OK ) { return error; } } + if ( st_ivas->nchan_transport == 1 ) { st_ivas->element_mode_init = IVAS_SCE; @@ -242,9 +249,11 @@ ivas_error ivas_sba_dec_reconfigure( { st_ivas->element_mode_init = IVAS_CPE_MDCT; } + /*-----------------------------------------------------------------* * Renderer selection *-----------------------------------------------------------------*/ + /* renderer might have changed */ intern_config_old = st_ivas->intern_config; RENDERER_TYPE old_renderer_type; @@ -333,6 +342,7 @@ ivas_error ivas_sba_dec_reconfigure( mvs2s( st_ivas->hDirAC->dirac_to_spar_md_bands, st_ivas->hSpar->dirac_to_spar_md_bands, DIRAC_MAX_NBANDS ); st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; } + /*-----------------------------------------------------------------* * Allocate, initalize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index ca5b161044..e184654eaa 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -90,9 +90,8 @@ void ivas_sba_dirac_stereo_config( static int16_t ivas_sba_dirac_stereo_band_config( int16_t *band_limits, /* o : DFT band limits */ const int32_t output_Fs, /* i : output sampling rate */ - const int16_t NFFT /* i : analysis/synthesis window length */ - , - const int16_t spar_flag /* i : SPAR or DirAC band grouping */ + const int16_t NFFT, /* i : analysis/synthesis window length */ + const int16_t spar_flag /* i : SPAR or DirAC band grouping */ ) { int16_t i; @@ -182,9 +181,9 @@ static void map_params_dirac_to_stereo( float synth[], /* i : decoded downmix signal */ float DFT[STEREO_DFT_BUF_MAX], /* i/o: DFT buffer */ const uint8_t b_wide_panning, /* i : flag indicating wider panning */ - const int16_t L_frame /* i : core signal length */ - , - const int16_t mcmasa ) + const int16_t L_frame, /* i : core signal length */ + const int16_t mcmasa /* i : McMASA flag */ +) { int16_t i, b, k; int16_t k_offset; @@ -449,13 +448,12 @@ static void ivas_sba_dirac_stereo_compute_hb_gain( *-------------------------------------------------------------------*/ static void ivas_sba_dirac_stereo_upmix_hb( - float hb_stereo_synth[CPE_CHANNELS][L_FRAME48k], /* i/o: stereo HB synthesis signal */ - float hb_synth[L_FRAME48k], /* i : HB signal */ - float hb_gain[NB_DIV], /* i : side gains for HB signal */ - const int16_t output_frame /* i : output frame length per channel */ - , - const int16_t mcmasa, - const STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i : Stereo DFT handle for mixing matrix */ + float hb_stereo_synth[CPE_CHANNELS][L_FRAME48k], /* i/o: stereo HB synthesis signal */ + float hb_synth[L_FRAME48k], /* i : HB signal */ + float hb_gain[NB_DIV], /* i : side gains for HB signal */ + const int16_t output_frame, /* i : output frame length per channel */ + const int16_t mcmasa, /* i : McMASA flag */ + const STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i : Stereo DFT handle for mixing matrix */ ) { int16_t i; @@ -520,11 +518,11 @@ static void ivas_sba_dirac_stereo_upmix_hb( *-------------------------------------------------------------------*/ static void ivas_sba_dirac_stereo_apply_td_stefi( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - float output[CPE_CHANNELS][L_FRAME48k], /* i/o: output synthesis signal */ - const int16_t output_frame /* i : output frame length per channel */ - , - const int16_t spar_flag ) + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ + float output[CPE_CHANNELS][L_FRAME48k], /* i/o: output synthesis signal */ + const int16_t output_frame, /* i : output frame length per channel */ + const int16_t spar_flag /* i : SPAR flag */ +) { int16_t i; int16_t dftOvlLen; @@ -532,7 +530,6 @@ static void ivas_sba_dirac_stereo_apply_td_stefi( float tmp; const float *win_dft; - if ( spar_flag ) { win_dft = hStereoDft->win32ms; @@ -610,16 +607,13 @@ static void ivas_sba_dirac_stereo_apply_td_stefi( *-------------------------------------------------------------------*/ void ivas_sba_dirac_stereo_smooth_parameters( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i/o: decoder DFT stereo handle */ - , - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD handle for upmixing */ - int16_t cross_fade_start_offset, /* i: SPAR mixer delay compensation */ - int32_t output_Fs /* i: Fs for delay calculation */ + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ + ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD handle for upmixing */ + const int16_t cross_fade_start_offset, /* i : SPAR mixer delay compensation */ + const int32_t output_Fs /* i : Fs for delay calculation */ ) { - int16_t i, j, k, i_sf; - int16_t b; int16_t k_offset; float *side_gain, *prev_side_gain; @@ -657,7 +651,6 @@ void ivas_sba_dirac_stereo_smooth_parameters( int16_t xfade_delay_subframes; int16_t i_hist; - xfade_start_ns = cross_fade_start_offset / (float) output_Fs * 1000000000.f - IVAS_FB_ENC_DELAY_NS; xfade_delay_subframes = (int16_t) ( xfade_start_ns / ( FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ) ); @@ -698,7 +691,7 @@ void ivas_sba_dirac_stereo_smooth_parameters( } } } - } // first_frame + } mvr2r( hMdDec->mixer_mat_prev[1][0][0], hMdDec->mixer_mat_prev[0][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); mvr2r( hMdDec->mixer_mat_prev[2][0][0], hMdDec->mixer_mat_prev[1][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); @@ -715,12 +708,11 @@ void ivas_sba_dirac_stereo_smooth_parameters( } } } - } // i_sf - } // k ( DFT block ) - hStereoDft->first_frame = 0; - + } + } - } // hMdDec != 0 + hStereoDft->first_frame = 0; + } return; } @@ -735,9 +727,9 @@ void ivas_sba_dirac_stereo_smooth_parameters( void ivas_sba_dirac_stereo_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float output[CPE_CHANNELS][L_FRAME48k], /* i/o: output synthesis signal */ - const int16_t output_frame /* i : output frame length per channel */ - , - const int16_t mcmasa ) + const int16_t output_frame, /* i : output frame length per channel */ + const int16_t mcmasa /* i : McMASA flag */ +) { int16_t dtx_flag, fd_cng_flag; int16_t memOffset; @@ -753,6 +745,7 @@ void ivas_sba_dirac_stereo_dec( hSCE = st_ivas->hSCE[0]; hCPE = st_ivas->hCPE[0]; hStereoDft = hCPE->hStereoDft; + if ( st_ivas->nchan_transport > 1 && !mcmasa ) { dtx_flag = 0; @@ -767,11 +760,7 @@ void ivas_sba_dirac_stereo_dec( memOffset = NS2SA( output_frame * FRAMES_PER_SEC, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); ivas_sba_dirac_stereo_config( hStereoDft->hConfig ); - hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( - hStereoDft->band_limits, - st_ivas->hDecoderConfig->output_Fs, - hStereoDft->NFFT, - ( st_ivas->sba_mode == SBA_MODE_SPAR && !mcmasa ) ); + hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, st_ivas->hDecoderConfig->output_Fs, hStereoDft->NFFT, ( st_ivas->sba_mode == SBA_MODE_SPAR && !mcmasa ) ); stereo_dft_dec_update( hStereoDft, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/ ); if ( st_ivas->nchan_transport > 1 ) @@ -794,14 +783,10 @@ void ivas_sba_dirac_stereo_dec( } /* mapping of DirAC parameters (azimuth, elevation, diffuseness) to DFT Stereo parameters (side gain, prediction gain) */ - map_params_dirac_to_stereo( - hStereoDft, - st_ivas->hQMetaData, - tmp_synth, - DFT[0], - st_ivas->ivas_format == MC_FORMAT, - ( st_ivas->sba_mode != SBA_MODE_SPAR || mcmasa ) ? hSCE->hCoreCoder[0]->L_frame : output_frame, - ( st_ivas->sba_mode != SBA_MODE_SPAR || mcmasa ) ); + map_params_dirac_to_stereo( hStereoDft, st_ivas->hQMetaData, tmp_synth, DFT[0], + st_ivas->ivas_format == MC_FORMAT, + ( st_ivas->sba_mode != SBA_MODE_SPAR || mcmasa ) ? hSCE->hCoreCoder[0]->L_frame : output_frame, + ( st_ivas->sba_mode != SBA_MODE_SPAR || mcmasa ) ); if ( st_ivas->sba_mode == SBA_MODE_SPAR && !mcmasa ) { @@ -809,12 +794,10 @@ void ivas_sba_dirac_stereo_dec( } /* DFT Stereo upmix */ - stereo_dft_dec( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/ - , + stereo_dft_dec( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1, /*st_ivas->sba_dirac_stereo_flag*/ ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : 0, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0, - st_ivas->hDecoderConfig->output_Fs, - st_ivas->nchan_transport ); + st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport ); /* DFT synthesis */ stereo_dft_dec_synthesize( hCPE, DFT, 0, output[0], output_frame ); @@ -840,23 +823,16 @@ void ivas_sba_dirac_stereo_dec( /* upmix ACELP BWE */ ivas_sba_dirac_stereo_compute_hb_gain( hStereoDft, hb_gain ); - { - ivas_sba_dirac_stereo_upmix_hb( - hb_synth_stereo, - hSCE->save_hb_synth, - hb_gain, - output_frame, - ( st_ivas->sba_mode != SBA_MODE_SPAR || mcmasa ), - hStereoDft ); - } + ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth, hb_gain, output_frame, + ( st_ivas->sba_mode != SBA_MODE_SPAR || mcmasa ), hStereoDft ); + /* add HB to ACELP core */ v_add( output[0], hb_synth_stereo[0], output[0], output_frame ); v_add( output[1], hb_synth_stereo[1], output[1], output_frame ); /* apply TD Stereo Filling as is done in ICBWE */ - ivas_sba_dirac_stereo_apply_td_stefi( hStereoDft, output, output_frame, - ( st_ivas->sba_mode == SBA_MODE_SPAR && !mcmasa ) ); + ivas_sba_dirac_stereo_apply_td_stefi( hStereoDft, output, output_frame, ( st_ivas->sba_mode == SBA_MODE_SPAR && !mcmasa ) ); } return; diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index a09c0bb4e7..ac948a59c4 100644 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -203,7 +203,6 @@ ivas_error ivas_sce_dec( st->flag_ACELP16k = set_ACELP_flag( IVAS_SCE, hSCE->element_brate, st->total_brate, 0, 0, -1, -1 ); } - /*TODO : check if is_SIDrate() can be used here*/ if ( is_DTXrate( ivas_total_brate ) ) { st->VAD = 0; diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 0cd2d53507..ff6f858d31 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -249,12 +249,12 @@ static ivas_error ivas_spar_md_dec_matrix_open( *------------------------------------------------------------------------*/ ivas_error ivas_spar_md_dec_open( - ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */ - const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const int16_t num_channels, /* i : number of internal channels */ - const int16_t sba_order /* i : SBA order */ - , - const int16_t sid_format ) + ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ + const int16_t num_channels, /* i : number of internal channels */ + const int16_t sba_order, /* i : SBA order */ + const int16_t sid_format /* i : SID format */ +) { ivas_spar_md_dec_state_t *hMdDec; ivas_error error; diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index 1a00522a7b..f1cbf180bd 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -251,9 +251,9 @@ ivas_error stereo_dft_dec_create( STEREO_DFT_DEC_DATA_HANDLE *hStereoDft, /* i/o: decoder DFT stereo handle */ const int32_t element_brate, /* i : element bitrate */ const int32_t output_Fs, /* i : output sampling rate */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ - , - const int16_t nchan_transport ) + const int16_t sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ + const int16_t nchan_transport /* i : number of transport channels */ +) { STEREO_DFT_DEC_DATA_HANDLE hStereoDft_loc; int16_t tmpS; @@ -311,11 +311,10 @@ ivas_error stereo_dft_dec_create( static void stereo_dft_dec_open( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const int32_t output_Fs /* i : output sampling rate */ - , - const int16_t nchan_transport ) + const int32_t output_Fs, /* i : output sampling rate */ + const int16_t nchan_transport /* i : number of transport channels */ +) { - /*Sizes*/ hStereoDft->N = (int16_t) ( STEREO_DFT_HOP_MAX * output_Fs / 48000 ); @@ -1126,12 +1125,11 @@ void stereo_dft_dec( float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers */ float *input_mem, /* i/o: mem of buffer DFT analysis */ STEREO_CNG_DEC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ - , - ivas_spar_md_dec_state_t *hMdDec, /* i: SPAR MD handle for upmixing */ - int16_t cross_fade_start_offset, /* i: SPAR mixer delay compensation */ - int32_t output_Fs, /* i: Fs for delay calculation */ - int16_t nchan_transport /* i: number of transpor channels */ + const int16_t sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ + ivas_spar_md_dec_state_t *hMdDec, /* i : SPAR MD handle for upmixing */ + const int16_t cross_fade_start_offset, /* i : SPAR mixer delay compensation */ + const int32_t output_Fs, /* i : Fs for delay calculation */ + const int16_t nchan_transport /* i : number of transpor channels */ ) { int16_t i, k, b, N_div, stop; diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c index a5955aa098..eb7c2df9db 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec.c +++ b/lib_dec/ivas_stereo_mdct_core_dec.c @@ -50,8 +50,10 @@ *-------------------------------------------------------------------------*/ static void apply_dmx_weights( CPE_DEC_HANDLE hCPE, float *x[CPE_CHANNELS][NB_DIV], int16_t transform_type_left[NB_DIV], int16_t transform_type_right[NB_DIV] ); + static void run_min_stats( Decoder_State **sts, float *x[CPE_CHANNELS][NB_DIV] ); + /*-------------------------------------------------------------------* * convert_coeffs_to_higher_res() * diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index 82cab39d4b..cccef8ec84 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -67,6 +67,7 @@ void parse_stereo_from_bitstream( #ifdef DEBUGGING int16_t nbits_start = st0->next_bit_pos; #endif + if ( !isSBAStereoMode ) { nSubframes = ( sts[0]->core == TCX_10_CORE || ( sts[0]->core != sts[1]->core ) ) ? NB_DIV : 1; @@ -176,6 +177,7 @@ void parse_stereo_from_bitstream( } } } + if ( !mct_on ) { hStereoMdct->split_ratio = SMDCT_EQUAL_RATIO_RANGE; /* Equal bits to both channels */ diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c index 5a75a8774f..79fe3b0e68 100644 --- a/lib_dec/swb_tbe_dec.c +++ b/lib_dec/swb_tbe_dec.c @@ -535,6 +535,7 @@ void swb_tbe_dec( { tilt_swb_fec = hBWE_TD->tilt_swb_fec; } + /* WB/SWB bandwidth switching */ if ( ( st->tilt_wb > 5 && st->clas_dec == UNVOICED_CLAS ) || st->tilt_wb > 10 ) { @@ -965,6 +966,7 @@ void swb_tbe_dec( /* convert from lsp to lsf */ lsp2lsf( lsp_temp, lsf_shb, LPC_SHB_ORDER, 1 ); } + mvr2r( lsf_diff + 1, hBWE_TD->prev_lsf_diff, LPC_SHB_ORDER - 2 ); hBWE_TD->prev_tilt_para = tilt_para; } @@ -1036,8 +1038,7 @@ void swb_tbe_dec( /* From low band excitation, generate highband excitation */ mvr2r( hBWE_TD->state_syn_shbexc, shaped_shb_excitation, L_SHB_LAHEAD ); GenShapedSHBExcitation( shaped_shb_excitation + L_SHB_LAHEAD, lpc_shb, White_exc16k, hBWE_TD->mem_csfilt, hBWE_TD->mem_genSHBexc_filt_down_shb, hBWE_TD->state_lpc_syn, st->coder_type, bwe_exc_extended, hBWE_TD->bwe_seed, vf_modified, st->extl, &( hBWE_TD->tbe_demph ), &( hBWE_TD->tbe_premph ), lpc_shb_sf, &shb_ener_sf, shb_res_gshape, shb_res_dummy, &vind, formant_fac, hBWE_TD->fb_state_lpc_syn, &( hBWE_TD->fb_tbe_demph ), st->total_brate, st->prev_bfi, st->element_mode, st->flag_ACELP16k, nlExc16k, mixExc16k, st->extl_brate, MSFlag, - NULL, &( hBWE_TD->prev_pow_exc16kWhtnd ), &( hBWE_TD->prev_mix_factor ), NULL, - NULL ); + NULL, &( hBWE_TD->prev_pow_exc16kWhtnd ), &( hBWE_TD->prev_mix_factor ), NULL, NULL ); /* fill-in missing SHB excitation */ if ( ( st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT ) && st->last_core_brate <= SID_2k40 ) diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 89887fed8d..5392fc8331 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -84,6 +84,7 @@ ivas_error ivas_enc( n_samples_chan = n_samples / nchan_inp; set_s( nb_bits_metadata, 0, MAX_SCE ); + /*----------------------------------------------------------------* * convert 'short' input data to 'float' *----------------------------------------------------------------*/ @@ -126,6 +127,7 @@ ivas_error ivas_enc( *----------------------------------------------------------------*/ n = getNumChanAnalysis( st_ivas ); + #ifndef DEBUG_SPAR_BYPASS_EVS_CODEC /* bypass EVS coding in float precision, emulating EVS encoder/decoder delay */ for ( i = 0; i < n; i++ ) @@ -165,7 +167,10 @@ ivas_error ivas_enc( else if ( ivas_format == ISM_FORMAT ) { /* select ISM format mode; reconfigure the ISM format encoder */ - ivas_ism_enc_config( st_ivas ); + if ( ( ivas_ism_enc_config( st_ivas ) ) ) + { + return error; + } if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { @@ -194,12 +199,11 @@ ivas_error ivas_enc( /* SBA/MASA configuration */ if ( ivas_format == SBA_FORMAT ) { + if ( ( error = ivas_sba_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) { - if ( ( error = ivas_sba_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } + st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; /* Write SBA planar flag */ @@ -276,7 +280,10 @@ ivas_error ivas_enc( else if ( ivas_format == MC_FORMAT ) { /* select MC format mode; write MC LS setup; reconfigure the MC format encoder */ - ivas_mc_enc_config( st_ivas ); + if ( ( ivas_mc_enc_config( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } hMetaData = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData : st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 78935211d7..9293e1a4ab 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -540,8 +540,8 @@ ivas_error ivas_init_encoder( else if ( ivas_format == MC_FORMAT ) { st_ivas->mc_mode = ivas_mc_mode_select( hEncoderConfig->mc_input_setup, ivas_total_brate ); - hEncoderConfig->nchan_inp = ivas_mc_ls_setup_get_num_channels( hEncoderConfig->mc_input_setup ); + hEncoderConfig->nchan_inp = ivas_mc_ls_setup_get_num_channels( hEncoderConfig->mc_input_setup ); if ( st_ivas->mc_mode == MC_MODE_MCT ) { @@ -562,6 +562,7 @@ ivas_error ivas_init_encoder( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->ind_list = ind_list[cpe_id * CPE_CHANNELS + n]; reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, MAX_NUM_INDICES ); } + /* Metadata only initialized for the last CPE index*/ if ( cpe_id == st_ivas->nCPE - 1 ) { @@ -596,7 +597,6 @@ ivas_error ivas_init_encoder( return error; } - /* prepare bitstream buffers */ for ( n = 0; n < CPE_CHANNELS; n++ ) { diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index f358a8ba2e..3a7ac61038 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -1678,6 +1678,7 @@ void ivas_masa_enc_reconfigure( int16_t n, tmp; int16_t sce_id, cpe_id; int32_t ivas_total_brate; + ivas_total_brate = st_ivas->hEncoderConfig->ivas_total_brate; if ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index 5de51576e9..1409683ba2 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -151,7 +151,6 @@ ivas_error ivas_param_mc_enc_open( return error; } - /* open/init parameter coding */ ivas_param_mc_metadata_open( mc_input_setup, hParamMC->lfe_index, ivas_total_brate, &hParamMC->hMetadataPMC ); @@ -275,7 +274,6 @@ ivas_error ivas_param_mc_enc_reconfig( /* get dmx factors */ hParamMC->dmx_factors = ivas_param_mc_conf[config_index].dmx_fac; - /* deallocate the full icc map, gets newly allocated in the metadata open function */ for ( i = 0; i < 2; i++ ) { @@ -639,8 +637,6 @@ static void ivas_param_mc_param_est_enc( push_wmops( "param_mc_prm_est" ); /* initializations */ - - l_ts = input_frame / PARAM_MC_MDFT_NO_SLOTS; num_time_slots = PARAM_MC_MDFT_NO_SLOTS; start_ts = hParamMC->hMetadataPMC.bAttackPresent ? hParamMC->hMetadataPMC.attackIndex : 0; @@ -912,7 +908,6 @@ static void ivas_param_mc_param_est_enc( hParamMC->hMetadataPMC.lfe_on = 1; } - pop_wmops(); return; @@ -1723,6 +1718,7 @@ static void ivas_param_mc_dec2bin( { bits[idx] = ( val >> ( N - 1 - idx ) ) & 1; } + return; } diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index e456cb3b70..4fdf162955 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -34,7 +34,6 @@ #include #include #include - #include "ivas_cnst.h" #include "ivas_prot.h" #include "options.h" @@ -457,9 +456,7 @@ void ivas_mcmasa_enc_close( { free( hMcMasa->delay_buffer_lfe[0] ); free( hMcMasa->delay_buffer_lfe[1] ); - } - if ( hMcMasa->separateChannelEnabled ) - { + for ( i = 0; i < 2; i++ ) { free( hMcMasa->lfeAnaRingBuffer[i] ); @@ -530,15 +527,12 @@ void ivas_mcmasa_enc( int16_t i, j, k; int16_t nBands = hMcMasa->nbands; int16_t nBlocks = MAX_PARAM_SPATIAL_SUBFRAMES; - uint8_t fixedDistance = 0; - float elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; float azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; float energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; float spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; float surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - float separatedChannelSignal[L_FRAME48k]; /* Compute low frequency energy */ @@ -765,7 +759,6 @@ void ivas_mcmasa_param_est_enc( set_zero( coherentEnergyRatio[0], hMcMasa->nbands ); } - /* Copy current frame to memory for delay compensation */ for ( i = 0; i < numAnalysisChannels; i++ ) { @@ -1182,6 +1175,7 @@ void ivas_mcmasa_param_est_enc( { numSubFramesForRatio = MAX_PARAM_SPATIAL_SUBFRAMES; } + for ( i = 0; i < numSubFramesForRatio; i++ ) { for ( j = 0; j < hMcMasa->nbands; j++ ) @@ -1387,7 +1381,6 @@ static void ivas_mcmasa_dmx( /* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ - static void compute_cov_mtx( float sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, real, s[ch][freq] */ float si[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, imag, s[ch][freq] */ diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 08e54c9bf9..5cbcb57daf 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -462,7 +462,6 @@ void ivas_mct_core_enc( FindChannelRatio( hMCT, sts, chBitRatios, nChannels ); - nAvailBits = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - NBITS_BWIDTH - hMCT->nBitsMCT - lfe_bits ); diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 5da41e279e..5e6511fce6 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -174,8 +174,7 @@ ivas_error ivas_mct_enc( /* joint MCT encoding */ ivas_mct_core_enc( ivas_format, hMCT, st_ivas->hCPE, hMCT->nchan_out_woLFE + hMCT->num_lfe, ivas_total_brate, switch_bw, - ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ) ? (int16_t) st_ivas->hLFE->lfe_bits : 0, - st_ivas->hEncoderConfig->sba_order ); + ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ) ? (int16_t) st_ivas->hLFE->lfe_bits : 0, st_ivas->hEncoderConfig->sba_order ); /* Spectrum quantization and coding */ for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) @@ -558,7 +557,10 @@ ivas_error ivas_mc_enc_config( /* MC format switching */ if ( st_ivas->hEncoderConfig->last_ivas_total_brate != st_ivas->hEncoderConfig->ivas_total_brate || st_ivas->mc_mode != last_mc_mode ) { - ivas_mc_enc_reconfig( st_ivas, last_mc_mode ); + if ( ( error = ivas_mc_enc_reconfig( st_ivas, last_mc_mode ) ) != IVAS_ERR_OK ) + { + return error; + } } return error; diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index e048103088..cabd6fddde 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -121,6 +121,7 @@ ivas_error ivas_sba_enc_reconfigure( #ifdef SBA_HPF_TUNING_ENC int16_t analysis_order_old; #endif + nchan_transport_old = st_ivas->nchan_transport; nCPE_old = st_ivas->nCPE; nSCE_old = st_ivas->nSCE; @@ -128,14 +129,17 @@ ivas_error ivas_sba_enc_reconfigure( st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, hEncoderConfig->sba_order ); st_ivas->sba_mode = ivas_sba_mode_select( ivas_total_brate ); + #ifdef SBA_HPF_TUNING_ENC analysis_order_old = ivas_sba_get_analysis_order( hEncoderConfig->last_ivas_total_brate, hEncoderConfig->sba_order ); if ( analysis_order_old != st_ivas->sba_analysis_order ) { int16_t n, i, n_old; float **old_mem_hp20_in; + n_old = ivas_sba_get_nchan_metadata( analysis_order_old ); n = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order ); + if ( n > n_old ) { /* save old mem_hp_20 pointer */ @@ -194,6 +198,7 @@ ivas_error ivas_sba_enc_reconfigure( } } #endif + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { if ( st_ivas->hSpar == NULL ) diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index 0005d8c6f6..3971c6740e 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -124,8 +124,8 @@ void stereo_tcx_core_enc( float lsp_new[], /* i : LSPs at the end of the frame */ float lsp_mid[], /* i : LSPs in the middle of the frame */ float pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */ - const int16_t last_element_mode, /* i : last element mode */ - const int16_t vad_hover_flag /* i : VAD hangover flag */ + const int16_t last_element_mode, /* i : last element mode */ + const int16_t vad_hover_flag /* i : VAD hangover flag */ ) { TCX_ENC_HANDLE hTcxEnc; diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c index bdd2483251..38a0fb73ff 100644 --- a/lib_enc/swb_tbe_enc.c +++ b/lib_enc/swb_tbe_enc.c @@ -63,7 +63,7 @@ static void return_M_Least( const float *inp, const int16_t n_cols, const float static void singlevectortest_gain( const float *inp, const int16_t dimen, const int16_t cb_size, int16_t *index, const float *weight, float *recon, const float *codebook ); static void determine_gain_weights( const float *gain, float *weights, const int16_t dims ); static void QuantizeSHBsubgains( Encoder_State *st, float *subgains, const int16_t extl ); -static void QuantizeSHBframegain( Encoder_State *st, float *GainFrame, const int16_t extl, const int32_t extl_brate, int16_t *rf_gainFrame_ind, int16_t flag_conservative ); +static void QuantizeSHBframegain( Encoder_State *st, float *GainFrame, const int16_t extl, const int32_t extl_brate, int16_t *rf_gainFrame_ind, const int16_t flag_conservative ); static int16_t closest_centroid( const float *data, const float *weights, const float *quantizer, const int16_t centroids, const int16_t length ); static void EstimateSHBFrameGain( const int16_t length, const float *oriSHB, const float *synSHB, float *subgain, float *GainFrame, const float *win_shb, const float *subwin ); static void EstimateSHBGainShape( const int16_t length, const float *oriSHB, const float *synSHB, float *subgain, const float *subwin ); @@ -429,7 +429,9 @@ void wb_tbe_enc( p2m_in = pow_off_pk_corrected( GainShape, NUM_SHB_SUBFR / 4, 1 ); } else + { p2m_in = pow_off_pk( GainShape, NUM_SHB_SUBFR / 4, 1 ); + } if ( st->extl_brate == WB_TBE_0k35 ) { @@ -452,7 +454,9 @@ void wb_tbe_enc( p2m_out = pow_off_pk_corrected( GainShape, NUM_SHB_SUBFR / 2, 2 ); } else + { p2m_out = pow_off_pk( GainShape, NUM_SHB_SUBFR / 2, 2 ); + } /* Estimate the gain parameter */ EstimateSHBFrameGain( SHB_OVERLAP_LEN / 2, hb_frame, shaped_wb_excitation, GainShape, &GainFrame, window_wb, subwin_wb ); @@ -499,13 +503,11 @@ void wb_tbe_enc( if ( st->rf_mode ) { - QuantizeSHBframegain( st, &GainFrame, st->extl, st->extl_brate, &st->hRF->RF_bwe_gainFr_ind, - 0 ); + QuantizeSHBframegain( st, &GainFrame, st->extl, st->extl_brate, &st->hRF->RF_bwe_gainFr_ind, 0 ); } else { - QuantizeSHBframegain( st, &GainFrame, st->extl, st->extl_brate, NULL, - 0 ); + QuantizeSHBframegain( st, &GainFrame, st->extl, st->extl_brate, NULL, 0 ); } /* Adjust the subframe and frame gain of the synthesized SHB signal */ @@ -581,7 +583,6 @@ void swb_tbe_enc( float sum_gain, normFact; float Env_error_part[NUM_SHB_SUBGAINS]; - Env_error = 0.0f; pitBufAvg = 0.0f; voicingBufAvg = 0.0f; @@ -1196,7 +1197,9 @@ void swb_tbe_enc( p2m_in = pow_off_pk_corrected( GainShape, NUM_SHB_SUBGAINS, 1 ); } else + { p2m_in = pow_off_pk( GainShape, NUM_SHB_SUBGAINS, 1 ); + } /* Quantization of the gain shape parameter */ QuantizeSHBsubgains( st, GainShape, st->extl ); @@ -1207,7 +1210,9 @@ void swb_tbe_enc( p2m_out = pow_off_pk_corrected( GainShape, NUM_SHB_SUBFR, 4 ); } else + { p2m_out = pow_off_pk( GainShape, NUM_SHB_SUBFR, 4 ); + } /* Gain shape smoothing after quantization */ if ( st->extl_brate == SWB_TBE_1k10 || st->extl_brate == SWB_TBE_1k75 ) @@ -1386,13 +1391,11 @@ void swb_tbe_enc( /* Quantization of the frame gain parameter */ if ( st->rf_mode ) { - QuantizeSHBframegain( st, &GainFrame, st->extl, 0, &st->hRF->RF_bwe_gainFr_ind, - 0 ); + QuantizeSHBframegain( st, &GainFrame, st->extl, 0, &st->hRF->RF_bwe_gainFr_ind, 0 ); } else { - QuantizeSHBframegain( st, &GainFrame, st->extl, 0, NULL, - ( st->extl_brate == SWB_TBE_1k10 || st->extl_brate == SWB_TBE_1k75 ) ? 1 : 0 ); + QuantizeSHBframegain( st, &GainFrame, st->extl, 0, NULL, ( st->extl_brate == SWB_TBE_1k10 || st->extl_brate == SWB_TBE_1k75 ) ? 1 : 0 ); } if ( hStereoICBWE != NULL ) @@ -1592,7 +1595,6 @@ static float pow_off_pk( * pow_off_pk_corrected() * * Sums squares of SWB shape gain parameters away from peak values - * VM: !! includes correction of indexing !! *-------------------------------------------------------------------*/ static float pow_off_pk_corrected( @@ -1998,7 +2000,6 @@ static void LVQQuant_BWE_LSF( int16_t i, c2, dim1 = 6; int16_t levels[1], numbits_VQ; - float w[8] = { 5.0f, 5.0f, 2.0f, 2.0f, 2.0f, 1.0f, 1.0f, 1.0f }; float cand[LPC_SHB_ORDER], quant[LPC_SHB_ORDER], e[2], ftmp; const float *cb_stage; @@ -2330,7 +2331,6 @@ static void Quant_shb_ener_sf( ) { int16_t idxSubEner; - float temp_shb_ener_sf, sum; sum = *shb_ener_sf; @@ -2368,6 +2368,7 @@ static void Quant_shb_res_gshape( for ( i = 0; i < NB_SUBFR16k; i++ ) { idxSubGain[i] = usquant( shb_res_gshape[i], &shb_res_gshape[i], 0.125, 0.125f, 1 << NUM_BITS_SHB_RES_GS ); + if ( st->codec_mode == MODE2 ) { st->hBWE_TD->idx_res_gs[i] = idxSubGain[i]; @@ -2393,7 +2394,7 @@ static void QuantizeSHBframegain( const int16_t extl, /* i : extension layer */ const int32_t extl_brate, /* i : extension layer bitrate */ int16_t *rf_gainFrame_ind, - int16_t flag_conservative /* i : flag to indicate more conservative gain quantization */ + const int16_t flag_conservative /* i : flag to indicate more conservative gain quantization */ ) { int16_t idxFrameGain; @@ -2658,7 +2659,6 @@ static void return_M_Least( return; } - /*-------------------------------------------------------------------* * fb_tbe_reset_enc() * @@ -2755,7 +2755,6 @@ void fb_tbe_enc( return; } - /*---------------------------------------------------------------------* * tbe_write_bitstream() * @@ -2835,7 +2834,6 @@ void tbe_write_bitstream( return; } - /*---------------------------------------------------------------------* * TBEreset_enc() * diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 8f868bd58f..81d4496151 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -322,6 +322,7 @@ static int32_t limitRendererOutput( * * *-------------------------------------------------------------------*/ + #ifdef FIX_197_CREND_INTERFACE AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig( #else @@ -3177,14 +3178,17 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + if ( ( error = validateCustomLsLayout( layout ) ) != IVAS_ERR_OK ) { return error; } + if ( ( error = getInputById( hIvasRend, inputId, (void **) &inputMc ) ) != IVAS_ERR_OK ) { return error; } + if ( inputMc->base.inConfig != IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) { /* Specifying details of custom speaker layout only makes sense if input config is set to custom speaker layout */ @@ -3207,6 +3211,7 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( return error; } } + if ( ( error = updateMcPanGains( inputMc, hIvasRend->outputConfig ) ) != IVAS_ERR_OK ) { return error; @@ -3239,6 +3244,7 @@ ivas_error IVAS_REND_SetInputGain( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + if ( ( error = getInputById( hIvasRend, inputId, (void **) &inputBase ) ) != IVAS_ERR_OK ) { return error; @@ -3275,10 +3281,12 @@ ivas_error IVAS_REND_SetInputLfeMtx( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + if ( ( error = getInputById( hIvasRend, inputId, (void **) &pInputBase ) ) != IVAS_ERR_OK ) { return error; } + if ( getAudioConfigType( pInputBase->inConfig ) != IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) { /* Custom LFE panning matrix only makes sense with channel-based input */ @@ -3327,10 +3335,12 @@ ivas_error IVAS_REND_SetInputLfePos( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + if ( ( error = getInputById( hIvasRend, inputId, (void **) &pInputBase ) ) != IVAS_ERR_OK ) { return error; } + if ( getAudioConfigType( pInputBase->inConfig ) != IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) { /* Custom LFE routing only makes sense with channel-based input */ @@ -3342,6 +3352,7 @@ ivas_error IVAS_REND_SetInputLfePos( pInputMc->lfeRouting.lfeInputGain = inputGain; pInputMc->lfeRouting.lfeOutputAzimuth = outputAzimuth; pInputMc->lfeRouting.lfeOutputElevation = outputElevation; + if ( ( error = updateMcPanGains( pInputMc, hIvasRend->outputConfig ) ) != IVAS_ERR_OK ) { return error; @@ -3373,6 +3384,7 @@ ivas_error IVAS_REND_RemoveInput( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + if ( ( error = getInputById( hIvasRend, inputId, (void **) &inputBase ) ) != IVAS_ERR_OK ) { return error; @@ -3428,6 +3440,7 @@ ivas_error IVAS_REND_GetInputNumChannels( { return error; } + if ( ( error = getRendInputNumChannels( pInput, numChannels ) ) != IVAS_ERR_OK ) { return error; @@ -3552,14 +3565,17 @@ ivas_error IVAS_REND_FeedInputAudio( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + if ( inputAudio.config.numSamplesPerChannel <= 0 || MAX_BUFFER_LENGTH_PER_CHANNEL < inputAudio.config.numSamplesPerChannel ) { return IVAS_ERR_INVALID_BUFFER_SIZE; } + if ( inputAudio.config.numChannels <= 0 || MAX_INPUT_CHANNELS < inputAudio.config.numChannels ) { return IVAS_ERR_WRONG_NUM_CHANNELS; } + if ( getAudioConfigType( hIvasRend->outputConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL && inputAudio.config.numSamplesPerChannel * 1000 != BINAURAL_RENDERING_FRAME_SIZE_MS * hIvasRend->sampleRateOut ) { @@ -3571,10 +3587,12 @@ ivas_error IVAS_REND_FeedInputAudio( { return error; } + if ( ( error = getRendInputNumChannels( inputBase, &numInputChannels ) ) != IVAS_ERR_OK ) { return error; } + if ( numInputChannels != inputAudio.config.numChannels ) { return IVAS_ERR_WRONG_NUM_CHANNELS; @@ -3614,10 +3632,12 @@ ivas_error IVAS_REND_FeedInputObjectMetadata( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + if ( ( error = getInputById( hIvasRend, inputId, (void **) &inputBase ) ) != IVAS_ERR_OK ) { return error; } + if ( inputBase->inConfig != IVAS_REND_AUDIO_CONFIG_OBJECT ) { /* Object metadata should only be fed for object inputs */ @@ -3656,10 +3676,12 @@ ivas_error IVAS_REND_FeedInputMasaMetadata( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + if ( ( error = getInputById( hIvasRend, inputId, (void **) &inputBase ) ) != IVAS_ERR_OK ) { return error; } + if ( getAudioConfigType( inputBase->inConfig ) != IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) { /* MASA metadata should only be fed for MASA inputs */ @@ -3842,6 +3864,7 @@ ivas_error IVAS_REND_SetHeadRotation( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + if ( getAudioConfigType( hIvasRend->outputConfig ) != IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) { /* Head rotation can be set only with binaural output */ @@ -4058,7 +4081,7 @@ static ivas_error rotateFrameMc( /* move gains to gains_prev */ for ( i = 0; i < nchan; i++ ) { - mvr2r( gains[i], gains_prev[i], (int16_t) nchan ); + mvr2r( gains[i], gains_prev[i], nchan ); } } @@ -4283,7 +4306,6 @@ static ivas_error renderIsmToBinauralRoom( copyBufferTo2dArray( tmpMcBuffer, tmpCrendBuffer ); - ivas_rend_crendProcess( #ifdef FIX_197_CREND_INTERFACE ismInput->crendWrapper, @@ -4301,7 +4323,6 @@ static ivas_error renderIsmToBinauralRoom( tmpCrendBuffer, *ismInput->base.ctx.pOutSampleRate ); - accumulate2dArrayToBuffer( tmpCrendBuffer, &outAudio ); free( tmpMcBuffer.data ); @@ -4692,7 +4713,6 @@ static ivas_error renderMcToBinauralRoom( accumulate2dArrayToBuffer( tmpCrendBuffer, &outAudio ); - /* TODO tmu : needs delay compensation */ renderLfeToBinaural( mcInput, outAudio ); @@ -4884,6 +4904,7 @@ static ivas_error renderInputMc( default: return IVAS_ERR_INVALID_OUTPUT_FORMAT; } + /* Check error here to keep switch statement more compact */ if ( error != IVAS_ERR_OK ) { @@ -4908,6 +4929,7 @@ static ivas_error renderActiveInputsMc( /* Skip inactive inputs */ continue; } + if ( ( error = renderInputMc( pCurrentInput, hIvasRend->outputConfig, outAudio ) ) != IVAS_ERR_OK ) { return error; @@ -4976,6 +4998,7 @@ static ivas_error renderSbaToBinaural( { tmpRotBuffer = sbaInput->base.inputBuffer; tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); + /* copy input for in-place rotation */ mvr2r( sbaInput->base.inputBuffer.data, tmpRotBuffer.data, tmpRotBuffer.config.numChannels * tmpRotBuffer.config.numSamplesPerChannel ); @@ -5150,6 +5173,7 @@ static ivas_error renderInputSba( default: return IVAS_ERR_INVALID_OUTPUT_FORMAT; } + /* Check error here to keep switch statement more compact */ if ( error != IVAS_ERR_OK ) { @@ -5329,6 +5353,7 @@ static ivas_error renderInputMasa( default: return IVAS_ERR_INVALID_OUTPUT_FORMAT; } + /* Check error here to keep switch statement more compact */ if ( error != IVAS_ERR_OK ) { @@ -5353,6 +5378,7 @@ static ivas_error renderActiveInputsMasa( /* Skip inactive inputs */ continue; } + if ( ( error = renderInputMasa( pCurrentInput, hIvasRend->outputConfig, outAudio ) ) != IVAS_ERR_OK ) { return error; @@ -5385,24 +5411,29 @@ ivas_error IVAS_REND_GetSamples( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + if ( outAudio.config.numSamplesPerChannel <= 0 || MAX_BUFFER_LENGTH_PER_CHANNEL < outAudio.config.numSamplesPerChannel ) { return IVAS_ERR_INVALID_BUFFER_SIZE; } + if ( outAudio.config.numChannels <= 0 || MAX_OUTPUT_CHANNELS < outAudio.config.numChannels ) { return IVAS_ERR_WRONG_NUM_CHANNELS; } + if ( getAudioConfigType( hIvasRend->outputConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL && outAudio.config.numSamplesPerChannel * 1000 != BINAURAL_RENDERING_FRAME_SIZE_MS * hIvasRend->sampleRateOut ) { /* Binaural rendering requires specific frame size */ return IVAS_ERR_INVALID_BUFFER_SIZE; } + if ( ( error = IVAS_REND_NumOutChannels( hIvasRend, &numOutChannels ) ) != IVAS_ERR_OK ) { return error; } + if ( numOutChannels != outAudio.config.numChannels ) { return IVAS_ERR_WRONG_NUM_CHANNELS; @@ -5415,14 +5446,17 @@ ivas_error IVAS_REND_GetSamples( { return error; } + if ( ( error = renderActiveInputsMc( hIvasRend, outAudio ) ) != IVAS_ERR_OK ) { return error; } + if ( ( error = renderActiveInputsSba( hIvasRend, outAudio ) ) != IVAS_ERR_OK ) { return error; } + if ( ( error = renderActiveInputsMasa( hIvasRend, outAudio ) ) != IVAS_ERR_OK ) { return error; -- GitLab