From 5276e7cf7035abd573b967b391080f16bb7e3b70 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 28 Sep 2023 13:13:37 +0200 Subject: [PATCH 01/16] - introduce ivas_mono_dmx_renderer_close(); - removal of leftovers --- lib_com/ivas_prot.h | 5 +++++ lib_dec/ivas_dec.c | 8 +------- lib_dec/ivas_init_dec.c | 8 ++------ lib_dec/ivas_mono_dmx_renderer.c | 22 ++++++++++++++++++++++ lib_dec/ivas_omasa_dec.c | 6 +----- lib_dec/ivas_sba_dec.c | 14 +++++--------- lib_enc/ivas_enc.c | 7 ++----- 7 files changed, 38 insertions(+), 32 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 817ba618be..1e74920e55 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5551,6 +5551,11 @@ ivas_error ivas_mono_dmx_renderer_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); + +void ivas_mono_dmx_renderer_close( + MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */ +); + void ivas_mono_downmix_render_passive( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output_f[], /* i/o: synthesized core-coder transport channels/mono output */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index ee08ba17df..763911db34 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -465,7 +465,6 @@ ivas_error ivas_dec( int16_t nchan_ism, nchan_transport_ism; int16_t dirac_bs_md_write_idx; - st = st_ivas->hCPE[0]->hCoreCoder[0]; set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); /* Set the number of objects for the parametric rendering */ @@ -482,7 +481,7 @@ ivas_error ivas_dec( } /* MASA metadata decoding */ - if ( ( error = ivas_masa_decode( st_ivas, st, &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_masa_decode( st_ivas, st_ivas->hCPE[0]->hCoreCoder[0], &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -490,8 +489,6 @@ ivas_error ivas_dec( /* Configuration of combined-format bit-budget distribution */ ivas_set_surplus_brate_dec( st_ivas, &ism_total_brate ); - st->bit_stream = &( st_ivas->bit_stream[( ism_total_brate / FRAMES_PER_SEC )] ); - /* set ISM parameters and decode ISM metadata in OMASA format */ if ( ( error = ivas_omasa_ism_metadata_dec( st_ivas, ism_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { @@ -595,7 +592,6 @@ ivas_error ivas_dec( /* core-decoding of transport channels */ if ( st_ivas->nSCE == 1 ) { - st = st_ivas->hSCE[0]->hCoreCoder[0]; if ( ( error = ivas_sce_dec( st_ivas, 0, &p_output[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; @@ -603,7 +599,6 @@ ivas_error ivas_dec( } else if ( st_ivas->nCPE == 1 ) { - st = st_ivas->hCPE[0]->hCoreCoder[0]; if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; @@ -611,7 +606,6 @@ ivas_error ivas_dec( } else if ( st_ivas->nCPE > 1 ) { - st = st_ivas->hCPE[0]->hCoreCoder[0]; if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 82ae35936f..64adcbf07a 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2682,12 +2682,8 @@ void ivas_destroy_dec( st_ivas->hLsSetupCustom = NULL; } - /* Downmix structure */ - if ( st_ivas->hMonoDmxRenderer != NULL ) - { - free( st_ivas->hMonoDmxRenderer ); - st_ivas->hMonoDmxRenderer = NULL; - } + /* Mono downmix structure */ + ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer ); /* OSBA structure */ ivas_osba_data_close( &st_ivas->hSbaIsmData ); diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 413a3d12b9..1b2d3af0d7 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -81,6 +81,28 @@ ivas_error ivas_mono_dmx_renderer_open( } +/*------------------------------------------------------------------------- + * ivas_mono_dmx_renderer_close() + * + * Close decoder downmix handle + *-------------------------------------------------------------------------*/ + +void ivas_mono_dmx_renderer_close( + MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */ +) +{ + if ( hMonoDmxRenderer == NULL || *hMonoDmxRenderer == NULL ) + { + return; + } + + free( *hMonoDmxRenderer ); + *hMonoDmxRenderer = NULL; + + return; +} + + /*------------------------------------------------------------------------- * ivas_mono_downmix_render_passive() * diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index b6846dfe93..ffe9ca40c1 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -308,11 +308,7 @@ ivas_error ivas_omasa_dec_config( } else { - if ( st_ivas->hMonoDmxRenderer != NULL ) - { - free( st_ivas->hMonoDmxRenderer ); - st_ivas->hMonoDmxRenderer = NULL; - } + ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer ); } } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index c4c2d73765..0586c094e8 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -397,17 +397,17 @@ ivas_error ivas_sba_dec_reconfigure( } #ifdef JBM_FOR_OSBA - if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && !st_ivas->hMonoDmxRenderer ) + if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && st_ivas->hMonoDmxRenderer == NULL ) { if ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - if ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->hMonoDmxRenderer != NULL ) + + if ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX ) { - free( st_ivas->hMonoDmxRenderer ); - st_ivas->hMonoDmxRenderer = NULL; + ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer ); } #endif @@ -523,11 +523,7 @@ ivas_error ivas_sba_dec_reconfigure( } else { - if ( st_ivas->hMonoDmxRenderer != NULL ) - { - free( st_ivas->hMonoDmxRenderer ); - st_ivas->hMonoDmxRenderer = NULL; - } + ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer ); } #endif diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 481d7e23bd..2cf50b2272 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -212,11 +212,8 @@ ivas_error ivas_enc( } else if ( ivas_format == SBA_FORMAT || ivas_format == MASA_FORMAT ) { - /* SBA/MASA configuration */ - if ( ivas_format == SBA_FORMAT ) - { - } - else + /* MASA configuration */ + if ( ivas_format == MASA_FORMAT ) { ivas_masa_enc_reconfigure( st_ivas ); } -- GitLab From d9d633007789a4cb60963dcb3a99a0483717a82e Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 28 Sep 2023 15:43:01 +0200 Subject: [PATCH 02/16] formatting --- lib_com/ivas_prot.h | 201 ++++++++++++++++----------------- lib_com/prot.h | 4 +- lib_dec/FEC_HQ_phase_ecu.c | 2 +- lib_dec/LD_music_post_filter.c | 12 +- lib_dec/ivas_dec.c | 4 +- lib_dec/ivas_dirac_dec.c | 7 +- lib_dec/ivas_init_dec.c | 10 +- lib_dec/ivas_jbm_dec.c | 159 ++++++++++++-------------- lib_dec/ivas_osba_dec.c | 24 ++-- lib_dec/ivas_output_config.c | 1 + lib_dec/ivas_sba_dec.c | 78 ++++++------- lib_dec/ivas_spar_decoder.c | 74 +++++------- lib_dec/ivas_stat_dec.h | 6 +- lib_dec/lib_dec.c | 10 +- lib_dec/swb_bwe_dec_lr.c | 8 +- lib_enc/init_enc.c | 5 +- lib_enc/ivas_osba_enc.c | 5 +- lib_rend/ivas_output_init.c | 8 +- lib_rend/ivas_prot_rend.h | 7 +- lib_rend/ivas_rotation.c | 2 +- lib_rend/lib_rend.c | 27 ++--- 21 files changed, 303 insertions(+), 351 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 1e74920e55..2f1cdb64b4 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -311,8 +311,8 @@ void stereo_dmx_evs_close_encoder( ivas_error ivas_dec( Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else int16_t *data /* o : output synthesis signal */ #endif @@ -322,10 +322,10 @@ ivas_error ivas_dec_setup( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ); @@ -667,10 +667,10 @@ ivas_error ivas_mc_dec_config( const int16_t idx, /* i : LS config. index */ uint16_t *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ); @@ -696,9 +696,9 @@ MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup( ); void smooth_dft2td_transition( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *output[CPE_CHANNELS], /* i/o: synthesis @external Fs */ - const int16_t output_frame /* i : output frame length */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + float *output[CPE_CHANNELS], /* i/o: synthesis @external Fs */ + const int16_t output_frame /* i : output frame length */ ); #ifdef DEBUG_MODE_INFO @@ -810,14 +810,14 @@ ivas_error ivas_jbm_dec_flush_renderer( const ISM_MODE ism_mode_old, /* i : old ISM mode */ uint16_t *nSamplesRendered, /* o : number of samples flushed */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ); -ivas_error ivas_jbm_dec_feed_tc_to_renderer( +void ivas_jbm_dec_feed_tc_to_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ @@ -854,17 +854,17 @@ int16_t ivas_jbm_dec_get_num_tc_channels( ); void ivas_jbm_dec_copy_tc_no_tsm( - Decoder_Struct *st_ivas, - float *tc[], - const int16_t output_frame + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + float *tc[], /* i : transport channels */ + const int16_t output_frame /* i : output frame size */ ); void ivas_jbm_dec_get_md_map_even_spacing( - const int16_t len, /* i : length of the modfied frames in metadata slots */ - const int16_t subframe_len, /* i : default length of a subframe */ - const int16_t offset, /* i : current read offset into the md buffer */ - const int16_t buf_len, /* i : length of the metadata buffer */ - int16_t *map /* o : metadata index map */ + const int16_t len, /* i : length of the modfied frames in metadata slots */ + const int16_t subframe_len, /* i : default length of a subframe */ + const int16_t offset, /* i : current read offset into the md buffer */ + const int16_t buf_len, /* i : length of the metadata buffer */ + int16_t *map /* o : metadata index map */ ); TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( @@ -876,7 +876,7 @@ int16_t ivas_jbm_dec_get_render_granularity( const RENDERER_TYPE rendererType, /* i : renderer type */ const IVAS_FORMAT ivas_format, /* i : ivas format */ const MC_MODE mc_mode, /* i : MC mode */ - const int32_t output_Fs /* i : sampling rate */ + const int32_t output_Fs /* i : sampling rate */ ); ivas_error ivas_jbm_dec_tc_buffer_open( @@ -1080,10 +1080,10 @@ ivas_error ivas_ism_dec_config( const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ uint16_t *nSamplesRendered, /* o : number of samples flushed on renderer change*/ #ifdef SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ); @@ -1113,10 +1113,10 @@ void ivas_param_ism_dec_digest_tc( ); void ivas_ism_param_dec_tc_gain_ajust( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamples, /* i : number of samples to be compensate */ - const uint16_t nFadeLength, /* i : length of the crossfade in samples */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamples, /* i : number of samples to be compensate */ + const uint16_t nFadeLength, /* i : length of the crossfade in samples */ + float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ); void ivas_param_ism_dec_render( @@ -2487,7 +2487,7 @@ void IGFDecApplyStereo( const int16_t *coreMsMask, const int16_t restrict_hopsize, const int16_t bfi, /* i : frame loss == 1, frame good == 0 */ - const int16_t bfi_apply_damping /* i : decoder element mode */ + const int16_t bfi_apply_damping /* i : decoder element mode */ ); void IGFEncStereoEncoder( @@ -3133,7 +3133,7 @@ void ivas_mct_dec_mct( void apply_MCT_dec( MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ Decoder_State **sts, /* i/o: decoder state structure */ - float *x[MCT_MAX_CHANNELS][NB_DIV] /* i/o: decoded and dequan. spect. input to MCT */ + float *x[MCT_MAX_CHANNELS][NB_DIV] /* i/o: decoded and dequan. spect. input to MCT */ ); void mctStereoIGF_dec( @@ -3467,12 +3467,12 @@ ivas_error ivas_sba_dec_reconfigure( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ #ifdef JBM_FOR_OSBA , - uint16_t *nSamplesFlushed, /* o : number of samples flushed */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + uint16_t *nSamplesFlushed, /* o : number of samples flushed */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif #endif ); @@ -3618,11 +3618,11 @@ ivas_error ivas_dirac_enc( IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ float *data_f[], /* i/o: SBA channels */ - float **ppIn_FR_real, /* o : real freq domain values */ - float **ppIn_FR_imag, /* o : imag freq domain values */ - const int16_t input_frame, /* i : input frame length */ - const int16_t dtx_vad, /* i : DTX vad flag */ - const IVAS_FORMAT ivas_format, /* i : ivas format */ + float **ppIn_FR_real, /* o : real freq domain values */ + float **ppIn_FR_imag, /* o : imag freq domain values */ + const int16_t input_frame, /* i : input frame length */ + const int16_t dtx_vad, /* i : DTX vad flag */ + const IVAS_FORMAT ivas_format, /* i : ivas format */ const int16_t hodirac_flag /* i : hodirac flag */ ); @@ -3673,7 +3673,7 @@ void ivas_dirac_dec_read_BS( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial rendering data handle */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q metadata */ int16_t *nb_bits, /* o : number of bits read */ - const int16_t last_bit_pos, /* i : last read bitstream position*/ + const int16_t last_bit_pos, /* i : last read bitstream position */ const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ); @@ -3808,18 +3808,18 @@ void ivas_mc_paramupmix_dec_read_BS( ); void ivas_mc_paramupmix_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - const int16_t nSamplesForRendering /* i : number of samples provided */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + const int16_t nSamplesForRendering /* i : number of samples provided */ ); void ivas_mc_paramupmix_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ float *input_f[], /* i : core-coder transport channels */ - float *output_f[] /* i/o: synthesized core-coder transport channels */ + float *output_f[] /* i/o: synthesized core-coder transport channels */ ); void ivas_param_mc_metadata_open( @@ -4366,7 +4366,7 @@ void ivas_spar_dec_digest_tc( const int16_t nSamplesForRendering /* i : number of samples provided */ ); -ivas_error ivas_sba_dec_digest_tc( +void ivas_sba_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const int16_t nCldfbSlots, /* i : number of CLDFB slots */ const int16_t nSamplesForRendering /* i : number of samples provided */ @@ -4377,7 +4377,7 @@ ivas_error ivas_sba_dec_render( const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + float *output_f[] /* o : rendered time signal */ ); void ivas_spar_dec_upmixer_sf( @@ -4414,8 +4414,8 @@ ivas_error ivas_spar_md_enc_process( const int16_t nchan_inp, const int16_t sba_order, /* i : Ambisonic (SBA) order */ float *prior_mixer[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH], /* i : prior mixer_matrix */ - const int16_t dyn_active_w_flag, /* i : flag to indicate dynamic active W */ - const int16_t dirac_mono_flag /* i : flag to indicate mono only mode in SBA */ + const int16_t dyn_active_w_flag, /* i : flag to indicate dynamic active W */ + const int16_t dirac_mono_flag /* i : flag to indicate mono only mode in SBA */ ); void ivas_compute_spar_params( @@ -4487,13 +4487,13 @@ int16_t ivas_get_spar_dec_md_num_subframes( ); ivas_error ivas_spar_md_dec_matrix_open( - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t num_channels, /* i : number of internal channels */ + ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ + const int16_t num_channels, /* i : number of internal channels */ const int16_t num_md_sub_frames ); void ivas_spar_md_dec_matrix_close( - ivas_spar_md_dec_state_t *hMdDecoder, /* i/o: SPAR MD decoder handle */ + ivas_spar_md_dec_state_t *hMdDecoder, /* i/o: SPAR MD decoder handle */ const int16_t num_channels /* i : number of internal channels */ ); @@ -4548,7 +4548,7 @@ void ivas_spar_update_md_hist( ); int16_t ivas_spar_chk_zero_coefs( - Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); void ivas_spar_smooth_md_dtx( @@ -5001,10 +5001,10 @@ ivas_error ivas_masa_dec_reconfigure( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ); @@ -5222,11 +5222,11 @@ void ivas_binRenderer_close( ); void ivas_binaural_hrtf_close( - HRTFS_FASTCONV_HANDLE *hHrtfFastConv /* i/o: decoder binaural hrtf handle */ + HRTFS_FASTCONV_HANDLE *hHrtfFastConv /* i/o: decoder binaural hrtf handle */ ); void ivas_init_binaural_hrtf( - HRTFS_FASTCONV *HrtfFastConv /* i/o: FASTCONV HRTF structure */ + HRTFS_FASTCONV *HrtfFastConv /* i/o: FASTCONV HRTF structure */ ); ivas_error ivas_allocate_binaural_hrtf( @@ -5684,15 +5684,14 @@ ivas_error ivas_osba_enc_reconfig( ); void ivas_osba_enc( - OSBA_ENC_HANDLE hOSba, /* i/o: OSBA encoder handle */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handle */ - float *data_in_f[], /* i/o: Input / transport audio signals */ - const int16_t input_frame, /* i : Input frame size */ - const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ - const ISM_MODE ism_mode, /* i : ISM mode */ - const int16_t sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */ - const int32_t input_Fs /* i : input sampling rate */ - , + OSBA_ENC_HANDLE hOSba, /* i/o: OSBA encoder handle */ + ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handle */ + float *data_in_f[], /* i/o: Input / transport audio signals */ + const int16_t input_frame, /* i : Input frame size */ + const int16_t nchan_ism, /* i : Number of objects for parameter analysis*/ + const ISM_MODE ism_mode, /* i : ISM mode */ + const int16_t sba_analysis_order, /* i : SBA order evaluated in SBA encoder */ + const int32_t input_Fs, /* i : input sampling rate */ const int16_t sba_planar /* i : planar SBA flag */ ); @@ -5700,18 +5699,16 @@ ivas_error ivas_osba_data_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); - #ifdef JBM_FOR_OSBA ivas_error ivas_osba_dirac_td_binaural_jbm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ); #endif - ivas_error ivas_osba_dirac_td_binaural( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output[], /* o : output synthesis signal */ @@ -5732,7 +5729,7 @@ ivas_error ivas_osba_render( ); void ivas_osba_data_close( - SBA_ISM_DATA_HANDLE *hSbaIsmData /* i/o: OSBA rendering handle */ + SBA_ISM_DATA_HANDLE *hSbaIsmData /* i/o: OSBA rendering handle */ ); @@ -5756,10 +5753,10 @@ ivas_error ivas_omasa_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ); @@ -5875,12 +5872,12 @@ ivas_error ivas_omasa_dirac_td_binaural( ); ivas_error ivas_omasa_dirac_td_binaural_jbm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of samples requested */ - uint16_t *nSamplesRendered, /* o : number of samples rendered */ - uint16_t *nSamplesAvailable, /* o : number of samples still to render */ - const int16_t nchan_transport, /* i : number of transport channels */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ + const int16_t nchan_transport, /* i : number of transport channels */ + float *output_f[] /* o : rendered time signal */ ); void ivas_omasa_dirac_rend( @@ -5896,12 +5893,12 @@ void ivas_omasa_rearrange_channels( ); void ivas_omasa_dirac_rend_jbm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of samples requested */ - uint16_t *nSamplesRendered, /* o : number of samples rendered */ - uint16_t *nSamplesAvailable, /* o : number of samples still to render */ - const int16_t nchan_transport, /* i : number of transport channels */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ + const int16_t nchan_transport, /* i : number of transport channels */ + float *output_f[] /* o : rendered time signal */ ); void ivas_omasa_preProcessStereoTransportsForMovedObjects( @@ -5928,11 +5925,11 @@ void ivas_omasa_separate_object_render( ); void ivas_omasa_separate_object_render_jbm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesRendered, /* i : number of samples rendered */ - float *output_f[], /* o : rendered time signal */ - const int16_t subframes_rendered, /* i : number of subframes rendered */ - const int16_t slots_rendered /* i : number of CLDFB slots rendered */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const uint16_t nSamplesRendered, /* i : number of samples rendered */ + float *output_f[], /* o : rendered time signal */ + const int16_t subframes_rendered, /* i : number of subframes rendered */ + const int16_t slots_rendered /* i : number of CLDFB slots rendered */ ); void ivas_omasa_encode_masa_to_total( diff --git a/lib_com/prot.h b/lib_com/prot.h index 30274b8fea..d3884cbf4f 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -2553,7 +2553,7 @@ void GenShapedSHBExcitation( float *shb_res_gshape, /* i : SHB LP residual gain shape */ float *shb_res, /* i : SHB residual used in encoder only */ int16_t *vf_ind, /* i/o: Mixing factor index */ - const float formant_fac, /* i : Formant sharpening factor [0..1] */ + const float formant_fac, /* i : Formant sharpening factor [0..1] */ float fb_state_lpc_syn[], /* i/o: memory */ float *fb_tbe_demph, /* i/o: fb de-emphasis memory */ const int32_t total_brate, /* i : overall bitrate */ @@ -6545,7 +6545,7 @@ void hq_ecu( const int16_t old_is_transient[2], /* i : flags indicating previous transient frames*/ float *mag_chg_1st, /* i/o: per band magnitude modifier for transients*/ float Xavg[LGW_MAX], /* i/o: Frequency group average gain to fade to */ - float *beta_mute, /* o : Factor for long-term mute */ + float *beta_mute, /* o : Factor for long-term mute */ const int16_t output_frame, /* i : frame length */ Decoder_State *st /* i/o: decoder state structure */ ); diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c index 71c0c6b728..28cafd4732 100644 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ b/lib_dec/FEC_HQ_phase_ecu.c @@ -2158,7 +2158,7 @@ void hq_ecu( const int16_t old_is_transient[2], /* i : flags indicating previous transient frames*/ float *mag_chg_1st, /* i/o: per band magnitude modifier for transients*/ float Xavg[LGW_MAX], /* i/o: Frequency group average gain to fade to */ - float *beta_mute, /* o : Factor for long-term mute */ + float *beta_mute, /* o : Factor for long-term mute */ const int16_t output_frame, /* i : frame length */ Decoder_State *st /* i/o: decoder state structure */ ) diff --git a/lib_dec/LD_music_post_filter.c b/lib_dec/LD_music_post_filter.c index 2a642d2647..b7885d35b4 100644 --- a/lib_dec/LD_music_post_filter.c +++ b/lib_dec/LD_music_post_filter.c @@ -81,12 +81,12 @@ static void find_enr_dct( const float data[], float band[], float *ptE, float *E *------------------------------------------------------------------------*/ void LD_music_post_filter( - MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */ - const float dtc_in[], /* i : input synthesis */ - float dtc_out[], /* o : output synthesis */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t coder_type, /* i : Coder type : -1 in case of IO */ - const int16_t Last_coder_type /* i : last Coder type */ + MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */ + const float dtc_in[], /* i : input synthesis */ + float dtc_out[], /* o : output synthesis */ + const int32_t core_brate, /* i : core bitrate */ + const int16_t coder_type, /* i : Coder type : -1 in case of IO */ + const int16_t Last_coder_type /* i : last Coder type */ ) { float DCT_buf[DCT_L_POST]; diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 763911db34..b43c73994b 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -734,7 +734,6 @@ ivas_error ivas_dec( #ifdef JBM_FOR_OSBA if ( ( error = ivas_sba_upmixer_renderer( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) #else - if ( ( error = ivas_sba_upmixer_renderer( st_ivas, &p_output[sba_ch_idx], output_frame ) ) != IVAS_ERR_OK ) #endif { @@ -854,6 +853,7 @@ ivas_error ivas_dec( { return error; } + #ifdef NONBE_FIX_802_PARAMUPMIX_HIGHPASS for ( n = 0; n < st_ivas->nchan_transport; n++ ) { @@ -863,7 +863,9 @@ ivas_error ivas_dec( } } #endif + ivas_mc_paramupmix_dec( st_ivas, p_output ); + #ifndef NONBE_FIX_802_PARAMUPMIX_HIGHPASS /* HP filtering */ if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 9244cc1284..7b5da49f75 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2385,7 +2385,6 @@ void ivas_dirac_dec_render_sf( if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { - #ifdef OSBA_ROOM_IR /* render objects in combined format onto the CICP19 channels for BINAURAL_ROOM_IR */ if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) @@ -2400,6 +2399,7 @@ void ivas_dirac_dec_render_sf( int16_t n_samples_to_render; int16_t interp_offset; float gain, prev_gain; + num_objects = st_ivas->nchan_ism; nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; n_slots_to_render = st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->subframes_rendered]; @@ -2408,9 +2408,7 @@ void ivas_dirac_dec_render_sf( if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] ) { - ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, - n_samples_to_render, - st_ivas->hIsmRendererData->interpolator ); + ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator ); interp_offset = 0; } @@ -2472,7 +2470,6 @@ void ivas_dirac_dec_render_sf( } #endif - #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 64adcbf07a..fd5b67bcea 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -363,12 +363,11 @@ ivas_error ivas_dec_setup( #ifdef JBM_FOR_OSBA , nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif data #endif - ) ) != IVAS_ERR_OK ) { return error; @@ -481,14 +480,13 @@ ivas_error ivas_dec_setup( /* set Ambisonic (SBA) order used for analysis and coding */ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); #endif - if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate ) { if ( ( error = ivas_sba_dec_reconfigure( st_ivas #ifdef JBM_FOR_OSBA , nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif data @@ -504,6 +502,7 @@ ivas_error ivas_dec_setup( /* set Ambisonic (SBA) order used for analysis and coding */ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); #endif + ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); /*correct number of CPEs for discrete ISM coding*/ @@ -632,7 +631,7 @@ ivas_error ivas_dec_setup( #ifdef JBM_FOR_OSBA , nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif data @@ -641,6 +640,7 @@ ivas_error ivas_dec_setup( { return error; } + st_ivas->last_active_ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 5d17cb4d8b..9acf348da5 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -342,8 +342,6 @@ ivas_error ivas_jbm_dec_tc( /* Configuration of combined-format bit-budget distribution */ ivas_set_surplus_brate_dec( st_ivas, &ism_total_brate ); - st->bit_stream = &( st_ivas->bit_stream[( ism_total_brate / FRAMES_PER_SEC )] ); - /* set ISM parameters and decode ISM metadata in OMASA format */ if ( ( error = ivas_omasa_ism_metadata_dec( st_ivas, ism_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { @@ -429,7 +427,6 @@ ivas_error ivas_jbm_dec_tc( /* core-decoding of transport channels */ if ( st_ivas->nSCE == 1 ) { - st = st_ivas->hSCE[0]->hCoreCoder[0]; if ( ( error = ivas_sce_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; @@ -437,7 +434,6 @@ ivas_error ivas_jbm_dec_tc( } else if ( st_ivas->nCPE == 1 ) { - st = st_ivas->hCPE[0]->hCoreCoder[0]; if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; @@ -445,7 +441,6 @@ ivas_error ivas_jbm_dec_tc( } else if ( st_ivas->nCPE > 1 ) { - st = st_ivas->hCPE[0]->hCoreCoder[0]; if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; @@ -461,9 +456,7 @@ ivas_error ivas_jbm_dec_tc( ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &p_output[sba_ch_idx] ); } - ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ) ); + ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); ivas_sba_dirac_stereo_dec( st_ivas, &p_output[sba_ch_idx], output_frame, 0 ); } @@ -508,7 +501,6 @@ ivas_error ivas_jbm_dec_tc( } else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); /* add W */ @@ -778,7 +770,7 @@ ivas_error ivas_jbm_dec_tc( * Feed decoded transport channels and metadata to the IVAS JBM renderer routine *--------------------------------------------------------------------------*/ -ivas_error ivas_jbm_dec_feed_tc_to_renderer( +void ivas_jbm_dec_feed_tc_to_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ @@ -788,10 +780,8 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( float data_f[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k]; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */ float *p_data_f[MAX_CLDFB_DIGEST_CHANNELS]; int16_t n, n_render_timeslots; - ivas_error error; push_wmops( "ivas_jbm_dec_feed_tc_to_rendererer" ); - for ( n = 0; n < MAX_CLDFB_DIGEST_CHANNELS; n++ ) { p_data_f[n] = &data_f[n][0]; @@ -843,10 +833,7 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( } else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { - if ( ( error = ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ) ) != IVAS_ERR_OK ) - { - return error; - } + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } #ifdef JBM_FOR_OSBA else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) @@ -892,10 +879,7 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); } - if ( ( error = ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ) ) != IVAS_ERR_OK ) - { - return error; - } + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { @@ -918,16 +902,12 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { - if ( ( error = ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ) ) != IVAS_ERR_OK ) - { - return error; - } + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } } pop_wmops(); - - return IVAS_ERR_OK; + return; } @@ -946,39 +926,32 @@ ivas_error ivas_jbm_dec_render( const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ) { int16_t n, nchan_out; int16_t nchan_transport; - float output[MAX_OUTPUT_CHANNELS #ifdef JBM_FOR_OSBA - + MAX_NUM_OBJECTS + float output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; /* 'float' buffer for output synthesis */ +#else + float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis */ #endif - ][L_FRAME48k]; /* 'float' buffer for output synthesis */ - int16_t nchan_remapped; int32_t output_Fs; AUDIO_CONFIG output_config; int16_t nSamplesAskedLocal; ivas_error error; - - float *p_output[MAX_OUTPUT_CHANNELS #ifdef JBM_FOR_OSBA - + MAX_NUM_OBJECTS -#endif - ]; - float *p_tc[MAX_TRANSPORT_CHANNELS -#ifdef JBM_FOR_OSBA - + MAX_NUM_OBJECTS + float *p_output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; + float *p_tc[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS]; +#else + float *p_output[MAX_OUTPUT_CHANNELS]; + float *p_tc[MAX_TRANSPORT_CHANNELS]; #endif - ]; - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; push_wmops( "ivas_dec_render" ); - /*----------------------------------------------------------------* * Initialization of local vars after struct has been set *----------------------------------------------------------------*/ @@ -990,12 +963,11 @@ ivas_error ivas_jbm_dec_render( output_config = st_ivas->hDecoderConfig->output_config; nSamplesAskedLocal = nSamplesAsked + st_ivas->hTcBuffer->n_samples_discard; - for ( n = 0; n < MAX_OUTPUT_CHANNELS #ifdef JBM_FOR_OSBA - + MAX_NUM_OBJECTS + for ( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) +#else + for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) #endif - ; - n++ ) { p_output[n] = &output[n][0]; } @@ -1146,9 +1118,7 @@ ivas_error ivas_jbm_dec_render( { nchan_remapped = st_ivas->nchan_transport; - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || - st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || - st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) { @@ -1173,7 +1143,6 @@ ivas_error ivas_jbm_dec_render( nchan_remapped = nchan_transport; /* Loudspeakers, Ambisonics or Binaural rendering */ - if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) @@ -1186,19 +1155,17 @@ ivas_error ivas_jbm_dec_render( else if ( st_ivas->renderer_type == RENDERER_OSBA_STEREO ) { *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + /* render objects */ ivas_ism_render_sf( st_ivas, p_output, *nSamplesRendered ); + /* add already rendererd SBA part */ for ( n = 0; n < nchan_out; n++ ) { v_add( p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered ); } } - else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS -#ifdef JBM_FOR_OSBA - || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM -#endif - ) + else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { float output_ism[MAX_OUTPUT_CHANNELS][L_FRAME48k]; float *p_output_ism[MAX_OUTPUT_CHANNELS]; @@ -1208,7 +1175,11 @@ ivas_error ivas_jbm_dec_render( p_output_ism[n] = &output_ism[n][0]; } - ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); + if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) + { + return error; + } + #ifdef OSBA_ROOM_IR if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) #endif @@ -1229,8 +1200,11 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) /*EXT output = individual objects + HOA3*/ { + if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, &p_output[st_ivas->nchan_ism] ) ) != IVAS_ERR_OK ) + { + return error; + } - ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, &p_output[st_ivas->nchan_ism] ); for ( n = 0; n < st_ivas->nchan_ism; n++ ) { mvr2r( st_ivas->hTcBuffer->tc[n] + st_ivas->hTcBuffer->n_samples_rendered, p_output[n], *nSamplesRendered ); @@ -1238,17 +1212,23 @@ ivas_error ivas_jbm_dec_render( } else { - ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); + if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) + { + return error; + } } } - else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || - st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); } else /* SBA_MODE_SPAR */ { - ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); + if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { #ifdef DEBUGGING @@ -1668,6 +1648,7 @@ ivas_error ivas_jbm_dec_flush_renderer( tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx + 2][hTcBuffer->n_samples_rendered]; mvr2r( st_ivas->hSbaIsmData->delayBuffer[ch_idx], tc_local[ch_idx], st_ivas->hSbaIsmData->delayBuffer_size ); } + /* transfer adapted sf info from hTcBuffer to SPAR and DirAC */ st_ivas->hSpar->nb_subframes = 1; st_ivas->hSpar->subframes_rendered = 0; @@ -1679,9 +1660,11 @@ ivas_error ivas_jbm_dec_flush_renderer( st_ivas->hSpatParamRendCom->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME; st_ivas->hSpatParamRendCom->slots_rendered = 0; st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME; + /* also adapt md maps, just use the last index */ set_s( st_ivas->hSpar->render_to_md_map, last_spar_md_idx, n_slots_still_available ); set_s( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available ); + /* render the last subframe */ if ( ( error = ivas_osba_dirac_td_binaural_jbm( st_ivas, (uint16_t) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) { @@ -1707,7 +1690,7 @@ ivas_error ivas_jbm_dec_flush_renderer( if ( st_ivas->hDecoderConfig->Opt_Limiter ) #endif { - if ( !( st_ivas->ivas_format == MONO_FORMAT ) ) + if ( st_ivas->ivas_format != MONO_FORMAT ) { #ifndef DISABLE_LIMITER ivas_limiter_dec( st_ivas->hLimiter, p_output, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect ); @@ -1830,7 +1813,7 @@ void ivas_jbm_dec_get_adapted_subframes( uint16_t nCldfbSlotsLocal = nCldfbTs; /* get last subframe size from previous frame, determine how many slots have to be processed - in the first subframe (i.e. potential leftover of a 5ms subframe) */ + in the first subframe (i.e. potential leftover of a 5ms subframe) */ nSlotsInFirstSubframe = ( PARAM_MC_MAX_NSLOTS_IN_SUBFRAME - subframe_nbslots[*nb_subframes - 1] ); *nb_subframes = 0; if ( nSlotsInFirstSubframe > 0 ) @@ -1890,7 +1873,7 @@ void ivas_jbm_dec_get_md_map( } /* changed part (first segment), interpolate index to parameters - (we do not want to interpolate and smooth acutal direction/diffuseness values even more) */ + (we do not want to interpolate and smooth acutal direction/diffuseness values even more) */ if ( src_idx >= 0 ) { dec = ( (float) ( src_idx + 1 ) ) / ( (float) jbm_segment_len ); @@ -2266,12 +2249,12 @@ ivas_error ivas_jbm_dec_tc_buffer_open( if ( hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_NONE ) { hTcBuffer->tc_buffer = NULL; - for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + #ifdef JBM_FOR_OSBA - + MAX_NUM_OBJECTS + for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) +#else + for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) #endif - ; - ch_idx++ ) { hTcBuffer->tc[ch_idx] = NULL; } @@ -2291,19 +2274,18 @@ ivas_error ivas_jbm_dec_tc_buffer_open( n_samp_residual = 0; } - nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; if ( nsamp_to_allocate == 0 ) { hTcBuffer->tc_buffer = NULL; - for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + #ifdef JBM_FOR_OSBA - + MAX_NUM_OBJECTS + for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) +#else + for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) #endif - ; - ch_idx++ ) { hTcBuffer->tc[ch_idx] = NULL; } @@ -2327,12 +2309,11 @@ ivas_error ivas_jbm_dec_tc_buffer_open( hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; offset += n_samp_residual; } - for ( ; ch_idx < MAX_TRANSPORT_CHANNELS #ifdef JBM_FOR_OSBA - + MAX_NUM_OBJECTS + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) +#else + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) #endif - ; - ch_idx++ ) { hTcBuffer->tc[ch_idx] = NULL; } @@ -2445,13 +2426,12 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; offset += n_samp_residual; } - for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + #ifdef JBM_FOR_OSBA - + MAX_NUM_OBJECTS + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) +#else + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) #endif - - ; - ch_idx++ ) { hTcBuffer->tc[ch_idx] = NULL; } @@ -2514,15 +2494,15 @@ void ivas_jbm_dec_tc_buffer_close( if ( *phTcBuffer != NULL ) { - for ( i = 0; i < MAX_TRANSPORT_CHANNELS #ifdef JBM_FOR_OSBA - + MAX_NUM_OBJECTS + for ( i = 0; i < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; i++ ) +#else + for ( i = 0; i < MAX_TRANSPORT_CHANNELS; i++ ) #endif - ; - i++ ) { ( *phTcBuffer )->tc[i] = NULL; } + if ( ( *phTcBuffer )->tc_buffer != NULL ) { free( ( *phTcBuffer )->tc_buffer ); @@ -2684,9 +2664,10 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( *--------------------------------------------------------------------------*/ void ivas_jbm_dec_copy_tc_no_tsm( - Decoder_Struct *st_ivas, - float *tc[], - const int16_t output_frame ) + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + float *tc[], /* i : transport channels */ + const int16_t output_frame /* i : output frame size */ +) { int16_t n_ch_full_copy; int16_t n_ch_cldfb; diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 7b5a44c64c..d389c137b3 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -119,14 +119,14 @@ void ivas_osba_data_close( /*--------------------------------------------------------------------------* - * ivas_osba_dirac_td_binaural() + * ivas_osba_dirac_td_binaural_jbm() * - * Binaural rendering in OSBA format + * Binaural rendering in JBM OSBA format *--------------------------------------------------------------------------*/ #ifdef JBM_FOR_OSBA ivas_error ivas_osba_dirac_td_binaural_jbm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ @@ -136,7 +136,10 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( int16_t n; ivas_error error; - ivas_sba_dec_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, &output_f[2] ); + if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, &output_f[2] ) ) != IVAS_ERR_OK ) + { + return error; + } if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK ) { @@ -156,6 +159,13 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( } #endif + +/*--------------------------------------------------------------------------* + * ivas_osba_dirac_td_binaural() + * + * Binaural rendering in OSBA format + *--------------------------------------------------------------------------*/ + ivas_error ivas_osba_dirac_td_binaural( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output[], /* o : output synthesis signal */ @@ -192,13 +202,11 @@ ivas_error ivas_osba_dirac_td_binaural( if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { - if ( ( error = ivas_sba_upmixer_renderer( st_ivas, #ifdef JBM_FOR_OSBA - output, + if ( ( error = ivas_sba_upmixer_renderer( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) #else - &output[channel_offset], + if ( ( error = ivas_sba_upmixer_renderer( st_ivas, &output[channel_offset], output_frame ) ) != IVAS_ERR_OK ) #endif - output_frame ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 88d2f96adf..365e758187 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -170,6 +170,7 @@ void ivas_renderer_select( { *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM; } + #ifdef OSBA_ROOM_IR if ( st_ivas->ivas_format == SBA_ISM_FORMAT && *renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 0586c094e8..ff0f8f4dba 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -105,7 +105,7 @@ ivas_error ivas_sba_dec_reconfigure( #ifdef JBM_FOR_OSBA , uint16_t *nSamplesFlushed, /* o : number of samples flushed */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else @@ -148,10 +148,11 @@ ivas_error ivas_sba_dec_reconfigure( * Set SBA high-level parameters * Save old SBA high-level parameters *-----------------------------------------------------------------*/ - nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old, last_ivas_total_brate ); + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old, last_ivas_total_brate ); ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); nchan_hp20_old = getNumChanSynthesis( st_ivas ); + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { if ( ivas_total_brate >= IVAS_256k ) @@ -192,12 +193,11 @@ ivas_error ivas_sba_dec_reconfigure( /* copy the logic from ivas_renderer_select(), because calling this function has too many side effects that would affect the flushing */ if ( ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) <= 2 ) { - - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL #ifdef SPLIT_REND_WITH_HEAD_ROT - || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL ) #endif - ) { renderer_type_new = RENDERER_BINAURAL_PARAMETRIC; } @@ -221,15 +221,17 @@ ivas_error ivas_sba_dec_reconfigure( renderer_type_new = RENDERER_BINAURAL_FASTCONV_ROOM; } } + /* determine new granularity */ granularity_new = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + /* this will change anyway only with binaural */ if ( renderer_type_new == RENDERER_BINAURAL_FASTCONV && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { granularity_new *= JBM_CLDFB_SLOTS_IN_SUBFRAME; } - /* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */ + /* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */ if ( granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { /* write back info for correct rendering of the flushable samples */ @@ -239,14 +241,16 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->sba_analysis_order = sba_analysis_order_old; #endif st_ivas->hDecoderConfig->ivas_total_brate = last_ivas_total_brate; - if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, granularity_new, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, st_ivas->mc_mode, ism_mode_old, nSamplesFlushed, + #ifdef SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, granularity_new, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, st_ivas->mc_mode, ism_mode_old, nSamplesFlushed, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, granularity_new, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, st_ivas->mc_mode, ism_mode_old, nSamplesFlushed, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) { return error; } + /* restore correct values for the current frame*/ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; @@ -283,9 +287,11 @@ ivas_error ivas_sba_dec_reconfigure( mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } } + /*-----------------------------------------------------------------* * Allocate, initialize, and configure SBA handles *-----------------------------------------------------------------*/ + int16_t sba_order_internal; SPAR_DEC_HANDLE hSpar; hSpar = st_ivas->hSpar; @@ -302,7 +308,6 @@ ivas_error ivas_sba_dec_reconfigure( if ( nchan_transport_old != ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) || ( last_ivas_total_brate >= IVAS_512k && ivas_total_brate < IVAS_512k ) || ( last_ivas_total_brate < IVAS_512k && ivas_total_brate >= IVAS_512k ) ) { - ivas_spar_dec_close( &( st_ivas->hSpar ), hDecoderConfig->output_Fs, 1 ); if ( ( error = ivas_spar_dec_open( st_ivas, 1 ) ) != IVAS_ERR_OK ) @@ -310,12 +315,9 @@ ivas_error ivas_sba_dec_reconfigure( return error; } } - else if ( last_ivas_total_brate < IVAS_24k4 && ivas_total_brate >= IVAS_24k4 ) { - num_channels = st_ivas->hSpar->hMdDec->spar_md_cfg.num_umx_chs; - ivas_spar_md_dec_matrix_close( st_ivas->hSpar->hMdDec, num_channels ); num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order_internal, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); @@ -324,8 +326,8 @@ ivas_error ivas_sba_dec_reconfigure( return error; } } - if ( ( hSpar->hPCA == NULL ) && - ( st_ivas->hDecoderConfig->ivas_total_brate == PCA_BRATE && st_ivas->sba_order == 1 ) && ( st_ivas->ivas_format == SBA_FORMAT ) ) + + if ( hSpar->hPCA == NULL && st_ivas->hDecoderConfig->ivas_total_brate == PCA_BRATE && st_ivas->sba_order == 1 && st_ivas->ivas_format == SBA_FORMAT ) { if ( ( hSpar->hPCA = (PCA_DEC_STATE *) malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL ) { @@ -334,6 +336,7 @@ ivas_error ivas_sba_dec_reconfigure( ivas_pca_dec_init( hSpar->hPCA ); } + ivas_spar_config( ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format ); } else @@ -355,7 +358,6 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->hSpar->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); #endif - if ( st_ivas->nchan_transport == 1 ) { st_ivas->element_mode_init = IVAS_SCE; @@ -458,6 +460,7 @@ ivas_error ivas_sba_dec_reconfigure( ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); + #ifdef NONBE_FIX_775_OSBA_BR_SWITCHING_CRASH if ( st_ivas->hDirAC ) { @@ -488,6 +491,7 @@ ivas_error ivas_sba_dec_reconfigure( if ( ism_mode_old == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { int32_t temp_brate[MAX_SCE]; + st_ivas->ism_mode = ISM_SBA_MODE_DISC; if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) { @@ -625,12 +629,12 @@ ivas_error ivas_sba_dec_reconfigure( /*-----------------------------------------------------------------* * JBM TC buffer *-----------------------------------------------------------------*/ - if ( st_ivas->hDecoderConfig->Opt_5ms == 1 + #ifdef JBM_FOR_OSBA - || st_ivas->ivas_format == SBA_ISM_FORMAT + if ( st_ivas->hDecoderConfig->Opt_5ms == 1 || st_ivas->ivas_format == SBA_ISM_FORMAT ) +#else + if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) #endif - - ) { int16_t tc_nchan_to_allocate; int16_t tc_nchan_tc; @@ -659,11 +663,12 @@ ivas_error ivas_sba_dec_reconfigure( { tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; } - else if ( st_ivas->ivas_format == SBA_FORMAT + #ifdef JBM_FOR_OSBA - || st_ivas->ivas_format == SBA_ISM_FORMAT + else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) +#else + else if ( st_ivas->ivas_format == SBA_FORMAT ) #endif - ) { tc_nchan_to_allocate = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); #ifdef JBM_FOR_OSBA @@ -681,19 +686,17 @@ ivas_error ivas_sba_dec_reconfigure( } } - if ( tc_nchan_tc != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || tc_buffer_mode != st_ivas->hTcBuffer->tc_buffer_mode #ifdef JBM_FOR_OSBA - || granularity_new != st_ivas->hTcBuffer->n_samples_granularity + if ( tc_nchan_tc != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || tc_buffer_mode != st_ivas->hTcBuffer->tc_buffer_mode || granularity_new != st_ivas->hTcBuffer->n_samples_granularity ) +#else + if ( tc_nchan_tc != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || tc_buffer_mode != st_ivas->hTcBuffer->tc_buffer_mode ) #endif - ) { - if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, #ifdef JBM_FOR_OSBA - granularity_new + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, granularity_new ) ) != IVAS_ERR_OK ) #else - NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -766,16 +769,13 @@ ivas_error ivas_sba_dec_reconfigure( * *-------------------------------------------------------------------*/ -ivas_error ivas_sba_dec_digest_tc( +void ivas_sba_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const int16_t nCldfbSlots, /* i : number of CLDFB slots */ const int16_t nSamplesForRendering /* i : number of samples provided */ ) { int16_t ch_idx; - ivas_error error; - - error = IVAS_ERR_OK; /* set the md map */ if ( st_ivas->hDirAC ) @@ -783,11 +783,11 @@ ivas_error ivas_sba_dec_digest_tc( ivas_dirac_dec_set_md_map( st_ivas, nCldfbSlots ); } - if ( st_ivas->ivas_format == SBA_FORMAT #ifdef JBM_FOR_OSBA - || st_ivas->ivas_format == SBA_ISM_FORMAT + if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) +#else + if ( st_ivas->ivas_format == SBA_FORMAT ) #endif - ) { ivas_spar_dec_digest_tc( st_ivas, st_ivas->nchan_transport, nCldfbSlots, nSamplesForRendering ); } @@ -844,7 +844,7 @@ ivas_error ivas_sba_dec_digest_tc( generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], nCldfbSlots, st->cna_dirac_flag && st->flag_cna ); } - return error; + return; } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index f89e288ff4..69cc79d6bd 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -211,13 +211,11 @@ ivas_error ivas_spar_dec_open( } /* allocate transport channels*/ - if ( - ( st_ivas->hDecoderConfig->Opt_5ms #ifdef JBM_FOR_OSBA - || st_ivas->ivas_format == SBA_ISM_FORMAT + if ( ( st_ivas->hDecoderConfig->Opt_5ms || st_ivas->ivas_format == SBA_ISM_FORMAT ) && st_ivas->hTcBuffer == NULL ) +#else + if ( ( st_ivas->hDecoderConfig->Opt_5ms ) && st_ivas->hTcBuffer == NULL ) #endif - ) && - st_ivas->hTcBuffer == NULL ) { int16_t nchan_to_allocate; int16_t nchan_tc; @@ -235,10 +233,7 @@ ivas_error ivas_spar_dec_open( { nchan_to_allocate += st_ivas->nchan_ism; } -#endif - -#ifdef JBM_FOR_OSBA granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); #endif @@ -279,18 +274,11 @@ ivas_error ivas_spar_dec_open( nchan_tc = 0; nchan_to_allocate = 0; } -#endif - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, - buffer_mode, - nchan_tc, - nchan_to_allocate, - nchan_to_allocate, -#ifdef JBM_FOR_OSBA - granularity + + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) #else - NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -1424,6 +1412,7 @@ void ivas_spar_dec_upmixer( nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; n_samples_sf = JBM_CLDFB_SLOTS_IN_SUBFRAME * NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + #ifdef JBM_FOR_OSBA nchan_internal_total = nchan_internal; sba_ch_offset = 0; @@ -1433,6 +1422,7 @@ void ivas_spar_dec_upmixer( sba_ch_offset = st_ivas->nchan_ism; } #endif + for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { #ifdef JBM_FOR_OSBA @@ -1558,31 +1548,28 @@ void ivas_spar_dec_upmixer_sf( ) { int16_t cldfb_band, num_cldfb_bands, numch_in, numch_out; - float *cldfb_in_ts_re[MAX_OUTPUT_CHANNELS #ifdef OSBA_ROOM_IR - + MAX_NUM_OBJECTS -#endif - ][CLDFB_NO_COL_MAX]; - float *cldfb_in_ts_im[MAX_OUTPUT_CHANNELS -#ifdef OSBA_ROOM_IR - + MAX_NUM_OBJECTS + float *cldfb_in_ts_re[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX]; + float *cldfb_in_ts_im[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX]; +#else + float *cldfb_in_ts_re[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX]; + float *cldfb_in_ts_im[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX]; #endif - ][CLDFB_NO_COL_MAX]; int16_t i, b, ts, out_ch, in_ch; int16_t num_spar_bands, spar_band, nchan_transport; int16_t num_in_ingest, split_band; int16_t slot_size, slot_idx_start; - float *p_tc[MAX_OUTPUT_CHANNELS #ifdef OSBA_ROOM_IR - + MAX_NUM_OBJECTS + float *p_tc[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; +#else + float *p_tc[MAX_OUTPUT_CHANNELS]; #endif - ]; int16_t md_idx; - float Pcm_tmp[MAX_OUTPUT_CHANNELS #ifdef OSBA_ROOM_IR - + MAX_NUM_OBJECTS + float Pcm_tmp[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; +#else + float Pcm_tmp[MAX_OUTPUT_CHANNELS][L_FRAME48k]; #endif - ][L_FRAME48k]; int16_t numch_out_dirac; float mixer_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS]; int16_t b_skip_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; @@ -1602,6 +1589,7 @@ void ivas_spar_dec_upmixer_sf( num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); slot_idx_start = hSpar->slots_rendered; + #ifdef JBM_FOR_OSBA if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { @@ -1701,12 +1689,11 @@ void ivas_spar_dec_upmixer_sf( if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA ) { /* at this point, output channels are used as intermediate procesing buffers */ - for ( in_ch = 0; in_ch < MAX_OUTPUT_CHANNELS #ifdef OSBA_ROOM_IR - + MAX_NUM_OBJECTS + for ( in_ch = 0; in_ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; in_ch++ ) +#else + for ( in_ch = 0; in_ch < MAX_OUTPUT_CHANNELS; in_ch++ ) #endif - ; - in_ch++ ) { for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { @@ -1749,14 +1736,10 @@ void ivas_spar_dec_upmixer_sf( { for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { - cldfbAnalysis_ts( - &p_tc[in_ch][ts * num_cldfb_bands], - cldfb_in_ts_re[in_ch][ts], - cldfb_in_ts_im[in_ch][ts], - num_cldfb_bands, - st_ivas->cldfbAnaDec[in_ch] ); + cldfbAnalysis_ts( &p_tc[in_ch][ts * num_cldfb_bands], cldfb_in_ts_re[in_ch][ts], cldfb_in_ts_im[in_ch][ts], num_cldfb_bands, st_ivas->cldfbAnaDec[in_ch] ); } } + #ifdef OSBA_ROOM_IR if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { @@ -1765,12 +1748,7 @@ void ivas_spar_dec_upmixer_sf( { for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { - cldfbAnalysis_ts( - &p_tc[in_ch][ts * num_cldfb_bands], - cldfb_in_ts_re[in_ch][ts], - cldfb_in_ts_im[in_ch][ts], - num_cldfb_bands, - st_ivas->cldfbAnaDec[in_ch] ); + cldfbAnalysis_ts( &p_tc[in_ch][ts * num_cldfb_bands], cldfb_in_ts_re[in_ch][ts], cldfb_in_ts_im[in_ch][ts], num_cldfb_bands, st_ivas->cldfbAnaDec[in_ch] ); } } } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index ceab947f3f..30c573fa0f 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -911,11 +911,11 @@ typedef struct ivas_masa_ism_data_structure typedef struct decoder_tc_buffer_structure { float *tc_buffer; /* the buffer itself */ - float *tc[MAX_TRANSPORT_CHANNELS #ifdef JBM_FOR_OSBA - + MAX_NUM_OBJECTS + float *tc[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS]; /* pointers into the buffer to the beginning of each tc */ +#else + float *tc[MAX_TRANSPORT_CHANNELS]; /* pointers into the buffer to the beginning of each tc */ #endif - ]; /* pointers into the buffer to the beginning of each tc */ TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ int16_t nchan_transport_jbm; /* number of TCs after TC decoding */ int16_t nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 27839b824a..45d9a0d59c 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -233,7 +233,6 @@ ivas_error IVAS_DEC_Open( st_ivas->sba_planar = 0; st_ivas->sba_analysis_order = 0; - return IVAS_ERR_OK; } @@ -876,7 +875,6 @@ ivas_error IVAS_DEC_GetSamples( #ifdef DEBUGGING assert( *nOutSamples == nSamplesAsked ); #endif - hIvasDec->nSamplesAvailableNext = 0; hIvasDec->nSamplesRendered = *nOutSamples; nSamplesRendered = *nOutSamples; @@ -1287,8 +1285,6 @@ static ivas_error IVAS_DEC_RendererFeedTcSamples( { Decoder_Struct *st_ivas; - ivas_error error; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -1297,9 +1293,9 @@ static ivas_error IVAS_DEC_RendererFeedTcSamples( st_ivas = hIvasDec->st_ivas; /* feed the TCs to the IVAS renderer */ - error = ivas_jbm_dec_feed_tc_to_renderer( st_ivas, nSamplesForRendering, nSamplesResidual, pcmBuf ); + ivas_jbm_dec_feed_tc_to_renderer( st_ivas, nSamplesForRendering, nSamplesResidual, pcmBuf ); - return error; + return IVAS_ERR_OK; } @@ -1351,7 +1347,7 @@ static ivas_error IVAS_DEC_GetRenderedSamples( static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *nSamplesBuffered /* o : number of samples still buffered */ + int16_t *nSamplesBuffered /* o : number of samples still buffered */ ) { *nSamplesBuffered = 0; diff --git a/lib_dec/swb_bwe_dec_lr.c b/lib_dec/swb_bwe_dec_lr.c index 0d5c64b5d9..c0ccb648c0 100644 --- a/lib_dec/swb_bwe_dec_lr.c +++ b/lib_dec/swb_bwe_dec_lr.c @@ -117,10 +117,10 @@ static void DecodeSWBSubbands( const int16_t *subband_search_offset, int16_t *prev_frm_hfe2, int16_t *prev_stab_hfe2, - int16_t band_width[], /* i : subband band widths */ - const int16_t *subband_offsets, /* i : subband offsets for sparse filling */ - const float spectra_ni[], /* i : core coder with sparseness filled */ - int16_t *ni_seed /* i/o: random seed for search buffer NI */ + int16_t band_width[], /* i : subband band widths */ + const int16_t *subband_offsets, /* i : subband offsets for sparse filling */ + const float spectra_ni[], /* i : core coder with sparseness filled */ + int16_t *ni_seed /* i/o: random seed for search buffer NI */ ) { int16_t i; diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index 071ae25c89..b813a2730d 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -60,9 +60,8 @@ ivas_error init_encoder( const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ const int16_t interval_SID, /* i : interval for SID update */ const int16_t vad_only_flag, /* i : flag to indicate front-VAD structure */ - const ISM_MODE ism_mode /* i : ISM mode */ - , - const int32_t element_brate /* i : element bitrate */ + const ISM_MODE ism_mode, /* i : ISM mode */ + const int32_t element_brate /* i : element bitrate */ ) { int16_t i; diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 96d0a30fea..788796d4a0 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -376,9 +376,8 @@ void ivas_osba_enc( const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ const ISM_MODE ism_mode, /* i : ISM mode */ const int16_t sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */ - const int32_t input_Fs /* i : input sampling rate */ - , - const int16_t sba_planar /* i : planar SBA flag */ + const int32_t input_Fs, /* i : input sampling rate */ + const int16_t sba_planar /* i : planar SBA flag */ ) { float data_out_f[MAX_INPUT_CHANNELS][L_FRAME48k]; diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 9ffa67978c..c6327b2867 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -264,10 +264,9 @@ void ivas_output_init( /*! r: number of decoder buffers */ int16_t ivas_get_nchan_buffers_dec( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ - , - const int16_t sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */ - const int32_t ivas_total_brate /* i : total IVAS bitrate */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t sba_analysis_order, /* i : SBA order evaluated in SBA decoder */ + const int32_t ivas_total_brate /* i : total IVAS bitrate */ ) { int16_t nchan_out_buff; @@ -377,6 +376,7 @@ int16_t ivas_get_nchan_buffers_dec( { nchan_out_buff = st_ivas->hDecoderConfig->nchan_out + st_ivas->nchan_ism; /*take into account sba_ch_idx' in ivas_dec() */ } + #ifdef JBM_FOR_OSBA if ( !( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) ) #endif diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index d9933c0488..d87a20c7c7 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -72,10 +72,9 @@ void ivas_output_init( /*! r: number of decoder buffers */ int16_t ivas_get_nchan_buffers_dec( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ - , - const int16_t sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */ - const int32_t ivas_total_brate /* i : total IVAS bitrate */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t sba_analysis_order, /* i : SBA order evaluated in SBA decoder */ + const int32_t ivas_total_brate /* i : total IVAS bitrate */ ); diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 5263bd5fda..ccba038fce 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -52,7 +52,7 @@ static ivas_error combine_external_and_head_orientations( IVAS_QUATERNION *headRotQuaternions, IVAS_VECTOR3 *listenerPos, #ifdef SPLIT_REND_WITH_HEAD_ROT - IVAS_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, /* i : split rend pose prediction axis*/ + IVAS_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, /* i : split rend pose prediction axis*/ #endif EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData ); diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 3df316dd64..4ac883690b 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -2233,12 +2233,11 @@ static ivas_error initMcBinauralRendering( if ( useTDRend ) { #endif - ivas_rend_closeCrend( &inputMc->crendWrapper #ifdef SPLIT_REND_WITH_HEAD_ROT - , - inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses + ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else + ivas_rend_closeCrend( &inputMc->crendWrapper ); #endif - ); #ifdef FIX_513_REND_MC_ALLOC } #endif @@ -2510,12 +2509,12 @@ static ivas_error setRendInputActiveMc( if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif { - if ( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg + #ifdef FIX_513_REND_MC_ALLOC - , - FALSE + if ( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, FALSE ) ) != IVAS_ERR_OK ) +#else + if ( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -4418,15 +4417,11 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( if ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif { - if ( ( error = initMcBinauralRendering( inputMc, - inputMc->base.inConfig, - hIvasRend->outputConfig, - hIvasRend->hRendererConfig #ifdef FIX_513_REND_MC_ALLOC - , - FALSE + if ( ( error = initMcBinauralRendering( inputMc, inputMc->base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, FALSE ) ) != IVAS_ERR_OK ) +#else + if ( ( error = initMcBinauralRendering( inputMc, inputMc->base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -8980,7 +8975,7 @@ static ivas_error getSamplesInternal( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, -- GitLab From 0689ef2c4d21e4770005fe1e4498d47db0534474 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 28 Sep 2023 17:24:55 +0200 Subject: [PATCH 03/16] formatting --- apps/encoder.c | 9 ------- apps/renderer.c | 6 ++--- lib_dec/ivas_output_config.c | 20 +++++++------- lib_dec/ivas_spar_decoder.c | 7 +++-- lib_enc/ivas_ism_metadata_enc.c | 3 ++- lib_enc/ivas_sba_enc.c | 4 +++ lib_enc/ivas_spar_md_enc.c | 10 +++---- lib_rend/lib_rend.c | 46 ++++++++++++--------------------- 8 files changed, 43 insertions(+), 62 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index b5162a5a02..e13297b987 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -234,7 +234,6 @@ int main( goto cleanup; } - /*------------------------------------------------------------------------------------------* * Open output bitstream file *------------------------------------------------------------------------------------------*/ @@ -492,7 +491,6 @@ int main( goto cleanup; } - /* Validate number of channels */ int16_t encInNumChannels = 0; if ( ( error = IVAS_ENC_GetNumInChannels( hIvasEnc, &encInNumChannels ) ) != IVAS_ERR_OK ) @@ -603,7 +601,6 @@ int main( int16_t numSamplesRead = 0; uint16_t bitStream[IVAS_MAX_BITS_PER_FRAME]; uint16_t numBits = 0; - #ifdef DEBUG_SBA #ifdef DEBUG_AGC ivas_open_agc_debug_files( (int16_t) arg.agc ); @@ -725,7 +722,6 @@ int main( } } #endif - /* Read ISM input metadata */ for ( i = 0; i < numIsmInputs; ++i ) { @@ -803,7 +799,6 @@ int main( #ifdef DEBUGGING print_snr(); #endif - /*------------------------------------------------------------------------------------------* * Close files and deallocate resources *------------------------------------------------------------------------------------------*/ @@ -856,7 +851,6 @@ cleanup: print_wmops(); print_mem( NULL ); #endif - #ifdef DEBUGGING dbgclose(); @@ -1606,7 +1600,6 @@ static bool parseCmdlIVAS_enc( usage_enc(); } } - else if ( strcmp( to_upper( argv[i] ), "-ISM_SBA" ) == 0 ) { arg->inputFormat = IVAS_ENC_INPUT_SBA_ISM; @@ -1695,7 +1688,6 @@ static bool parseCmdlIVAS_enc( } } } - else if ( strcmp( argv_to_upper, "-STEREO_DMX_EVS" ) == 0 ) { arg->inputFormat = IVAS_ENC_INPUT_MONO; @@ -1932,7 +1924,6 @@ static void usage_enc( void ) fprintf( stdout, "-mime : Mime output bitstream file format\n" ); fprintf( stdout, " The encoder produces TS26.445 Annex.2.6 Mime Storage Format, (not RFC4867 Mime Format).\n" ); fprintf( stdout, " default output bitstream file format is G.192\n" ); - fprintf( stdout, "-bypass mode : SBA PCA by-pass, mode = (1, 2), 1 = PCA off, 2 = signal adaptive, default is 1\n" ); fprintf( stdout, "-level level : Complexity level, level = (1, 2, 3), will be defined after characterisation. \n" ); fprintf( stdout, " Currently, all values default to level 3 (full functionality).\n" ); diff --git a/apps/renderer.c b/apps/renderer.c index f121eb241a..c80c43dafc 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1851,11 +1851,11 @@ int main( if ( delayNumSamples == -1 ) { - if ( args.delayCompensationEnabled #ifdef SPLIT_REND_WITH_HEAD_ROT - && !is_split_pre_rend_mode( &args ) + if ( args.delayCompensationEnabled && !is_split_pre_rend_mode( &args ) ) +#else + if ( args.delayCompensationEnabled ) #endif - ) { if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples, &delayTimeScale ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 365e758187..657fa827c4 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -89,11 +89,11 @@ void ivas_renderer_select( { if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL #ifdef SPLIT_REND_WITH_HEAD_ROT - || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL ) #endif - ) { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; } @@ -142,11 +142,12 @@ void ivas_renderer_select( else if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT || ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && st_ivas->nchan_transport <= 2 ) ) { *internal_config = output_config; - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL + #ifdef SPLIT_REND_WITH_HEAD_ROT - || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL ) #endif - ) { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; } @@ -158,6 +159,7 @@ void ivas_renderer_select( else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { *internal_config = IVAS_AUDIO_CONFIG_HOA3; + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB #ifdef SPLIT_REND_WITH_HEAD_ROT || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM @@ -206,11 +208,11 @@ void ivas_renderer_select( { *internal_config = output_config; - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL #ifdef SPLIT_REND_WITH_HEAD_ROT - || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL ) #endif - ) { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 69cc79d6bd..1d46872405 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1877,12 +1877,11 @@ void ivas_spar_dec_upmixer_sf( } else { - if ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || - !( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB + if ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || !( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB #ifdef SPLIT_REND_WITH_HEAD_ROT - || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM #endif - ) ) + ) ) #ifdef OSBA_ROOM_IR && !( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) #endif diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index e1a869d28e..849b7957ae 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -204,7 +204,6 @@ ivas_error ivas_ism_metadata_enc( ivas_error error; error = IVAS_ERR_OK; - push_wmops( "ism_meta_enc" ); /* initialization */ @@ -291,6 +290,7 @@ ivas_error ivas_ism_metadata_enc( /*----------------------------------------------------------------* * Rate importance of particular ISM streams *----------------------------------------------------------------*/ + if ( ism_mode != ISM_SBA_MODE_DISC ) { rate_ism_importance( nchan_transport, hIsmMeta, hSCE, lowrate_metadata_flag, ism_imp ); @@ -974,6 +974,7 @@ static void encode_radius( * * Encoding of an angle *----------------------------------------------------------------*/ + static void encode_angle_indices( BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ ISM_METADATA_ANGLE_HANDLE angle, /* i/o: angle handle */ diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 011cb3aded..ce2a9506d8 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -211,6 +211,7 @@ ivas_error ivas_sba_enc_reconfigure( { hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; } + if ( nchan_transport_old != st_ivas->nchan_transport || ( ivas_total_brate < IVAS_512k && hEncoderConfig->last_ivas_total_brate >= IVAS_512k ) || ( ivas_total_brate >= IVAS_512k && hEncoderConfig->last_ivas_total_brate < IVAS_512k ) ) { /* FB mixer handle */ @@ -227,11 +228,14 @@ ivas_error ivas_sba_enc_reconfigure( return error; } } + st_ivas->hSpar->spar_reconfig_flag = spar_reconfig_flag; + if ( ( error = ivas_dirac_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) { return error; } + if ( st_ivas->hQMetaData->q_direction->cfg.nbands != nbands_old || st_ivas->hQMetaData->no_directions != ndir_old ) { int16_t dir, j, i; diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 8b21c62a6b..c85a35def4 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -254,16 +254,14 @@ ivas_error ivas_spar_md_enc_init( hMdEnc->spar_md.prior_dyn_active_w_flag = 0; - ivas_spar_set_bitrate_config( &hMdEnc->spar_md_cfg, table_idx, ( hMdEnc->spar_hoa_md_flag ) ? IVAS_MAX_NUM_BANDS : SPAR_DIRAC_SPLIT_START_BAND, - hMdEnc->spar_hoa_dirac2spar_md_flag, 1, hEncoderConfig->Opt_PCA_ON, #ifndef DEBUG_AGC_ENCODER_CMD_OPTION - ivas_agc_enc_get_flag( ivas_spar_br_table_consts[table_idx].nchan_transport ) + ivas_spar_set_bitrate_config( &hMdEnc->spar_md_cfg, table_idx, ( hMdEnc->spar_hoa_md_flag ) ? IVAS_MAX_NUM_BANDS : SPAR_DIRAC_SPLIT_START_BAND, + hMdEnc->spar_hoa_dirac2spar_md_flag, 1, hEncoderConfig->Opt_PCA_ON, ivas_agc_enc_get_flag( ivas_spar_br_table_consts[table_idx].nchan_transport ) ); #else - ivas_agc_enc_get_flag( hEncoderConfig->Opt_AGC_ON, ivas_spar_br_table_consts[table_idx].nchan_transport ) + ivas_spar_set_bitrate_config( &hMdEnc->spar_md_cfg, table_idx, ( hMdEnc->spar_hoa_md_flag ) ? IVAS_MAX_NUM_BANDS : SPAR_DIRAC_SPLIT_START_BAND, + hMdEnc->spar_hoa_dirac2spar_md_flag, 1, hEncoderConfig->Opt_PCA_ON, ivas_agc_enc_get_flag( hEncoderConfig->Opt_AGC_ON, ivas_spar_br_table_consts[table_idx].nchan_transport ) ); #endif - ); - /* get FB coefficients */ for ( i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) { diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 4ac883690b..9fb797a383 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -2197,13 +2197,10 @@ static ivas_error initMcBinauralRendering( #endif /* if TD renderer was open and we need to use CREND, close it */ - if ( #ifdef FIX_513_REND_MC_ALLOC - !reconfigureFlag || ( !useTDRend && -#endif - inputMc->tdRendWrapper.hBinRendererTd != NULL ) -#ifdef FIX_513_REND_MC_ALLOC - ) + if ( !reconfigureFlag || ( !useTDRend && inputMc->tdRendWrapper.hBinRendererTd != NULL ) ) +#else + if ( inputMc->tdRendWrapper.hBinRendererTd != NULL ) #endif { ivas_td_binaural_close( &inputMc->tdRendWrapper.hBinRendererTd ); @@ -2321,11 +2318,11 @@ static ivas_error initMcBinauralRendering( #endif /* Initialise the EFAP handle for rotation on input layout */ - if ( inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM && inputMc->base.ctx.pHeadRotData->headRotEnabled #ifdef FIX_513_REND_MC_ALLOC - && inputMc->efapInWrapper.hEfap == NULL + if ( inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM && inputMc->base.ctx.pHeadRotData->headRotEnabled && inputMc->efapInWrapper.hEfap == NULL ) +#else + if ( inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM && inputMc->base.ctx.pHeadRotData->headRotEnabled ) #endif - ) { if ( ( error = initEfap( &inputMc->efapInWrapper, inConfig, NULL ) ) != IVAS_ERR_OK ) { @@ -3170,11 +3167,12 @@ static ivas_error initMasaDummyDecForBinauralOut( decDummy->mc_mode = MC_MODE_NONE; /* Todo Nokia: This should be also refactored in such way that it is not checked if not in MC mode */ ivas_output_init( &( decDummy->hOutSetup ), outConfig ); - if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL + #ifdef SPLIT_REND_WITH_HEAD_ROT - || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL ) #endif - ) { decDummy->renderer_type = RENDERER_BINAURAL_PARAMETRIC; } @@ -7111,8 +7109,7 @@ static ivas_error renderMcToSplitBinaural( #endif /* Render */ - if ( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &mcInput->tdRendWrapper : &mcInput->splitTdRendWrappers[pos_idx - 1], mcInput->base.inConfig, &mcInput->customLsInput, &pCombinedOrientationDataLocal, - NULL, mcInput->hReverb, 0, /* Ism Audio Metadata Delay Sync in ms for External Renderer */ *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &mcInput->tdRendWrapper : &mcInput->splitTdRendWrappers[pos_idx - 1], mcInput->base.inConfig, &mcInput->customLsInput, &pCombinedOrientationDataLocal, NULL, mcInput->hReverb, 0, /* Ism Audio Metadata Delay Sync in ms for External Renderer */ *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -7137,13 +7134,7 @@ static ivas_error renderMcToSplitBinaural( /* perform rotation in source format to tmpRotBuffer */ pCombinedOrientationDataLocal = &combinedOrientationDataLocal; - if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, &pCombinedOrientationDataLocal, -#ifdef SPLIT_REND_WITH_HEAD_ROT - mcInput->rot_gains_prev[pos_idx], -#else - mcInput->rot_gains_prev, -#endif - mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, &pCombinedOrientationDataLocal, mcInput->rot_gains_prev[pos_idx], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -7151,12 +7142,7 @@ static ivas_error renderMcToSplitBinaural( copyBufferTo2dArray( tmpRotBuffer, tmpRendBuffer ); /* call CREND (rotation already performed) */ - if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, - getNumSubframesInBuffer( &mcInput->base.inputBuffer, *mcInput->base.ctx.pOutSampleRate ), -#ifdef SPLIT_REND_WITH_HEAD_ROT - pos_idx -#endif - ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &mcInput->base.inputBuffer, *mcInput->base.ctx.pOutSampleRate ), pos_idx ) ) != IVAS_ERR_OK ) { return error; } @@ -8861,11 +8847,11 @@ static ivas_error getSamplesInternal( return error; } - if ( numOutChannels != outAudio.config.numChannels #ifdef SPLIT_REND_WITH_HEAD_ROT - && hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( numOutChannels != outAudio.config.numChannels && hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( numOutChannels != outAudio.config.numChannels ) #endif - ) { return IVAS_ERR_WRONG_NUM_CHANNELS; } -- GitLab From 22e41ec614eb7c1c00392d2736394b71cfa660c0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Oct 2023 09:27:30 +0200 Subject: [PATCH 04/16] formatting, comments,error returns --- apps/decoder.c | 5 +- apps/renderer.c | 22 +++-- lib_com/delay_comp.c | 11 +-- lib_com/ivas_cnst.h | 6 +- lib_com/ivas_prot.h | 12 +-- lib_dec/ivas_binRenderer_internal.c | 19 +++-- lib_dec/ivas_dec.c | 10 +-- lib_dec/ivas_init_dec.c | 2 - lib_dec/ivas_ism_dec.c | 9 +- lib_dec/ivas_ism_dtx_dec.c | 2 +- lib_dec/ivas_ism_metadata_dec.c | 4 +- lib_dec/ivas_ism_param_dec.c | 16 ++-- lib_dec/ivas_jbm_dec.c | 9 +- lib_dec/ivas_masa_dec.c | 10 +-- lib_dec/ivas_mc_param_dec.c | 2 +- lib_dec/ivas_mc_paramupmix_dec.c | 11 ++- lib_dec/ivas_mct_dec.c | 4 +- lib_dec/ivas_omasa_dec.c | 2 +- lib_dec/ivas_sba_dec.c | 18 ++-- lib_dec/ivas_sba_rendering_internal.c | 19 ++--- lib_dec/lib_dec.c | 18 ++-- lib_dec/lib_dec.h | 12 +-- lib_enc/ivas_agc_enc.c | 10 +-- lib_enc/ivas_init_enc.c | 2 +- lib_enc/ivas_sba_enc.c | 2 +- lib_enc/ivas_spar_encoder.c | 10 +-- lib_enc/lib_enc.h | 38 ++++----- lib_rend/ivas_crend.c | 40 ++++----- lib_rend/ivas_dirac_dec_binaural_functions.c | 6 +- lib_rend/ivas_dirac_output_synthesis_dec.c | 4 +- lib_rend/ivas_prot_rend.h | 46 ++++++----- lib_rend/lib_rend.c | 86 ++++++++++---------- lib_rend/lib_rend.h | 8 +- lib_util/render_config_reader.c | 2 +- 34 files changed, 239 insertions(+), 238 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index e09e8fe209..4efc1dac91 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1727,10 +1727,11 @@ static ivas_error initOnFirstGoodFrame( MasaFileWriter **ppMasaWriter, /* o : */ IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS], /* o : */ int16_t *pNumOutChannels, /* o : */ - uint16_t *pNumObj /* o : */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , + uint16_t *pNumObj, /* o : */ SplitFileReadWrite **splitRendWriter +#else + uint16_t *pNumObj /* o : */ #endif ) { diff --git a/apps/renderer.c b/apps/renderer.c index 8ce26fc85b..04ed6ce3bb 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -482,10 +482,11 @@ static int16_t getTotalNumInChannels( IVAS_REND_InputId mcIds[RENDERER_MAX_MC_INPUTS], IVAS_REND_InputId ismIds[RENDERER_MAX_ISM_INPUTS], IVAS_REND_InputId sbaIds[RENDERER_MAX_SBA_INPUTS], - IVAS_REND_InputId masaIds[RENDERER_MAX_MASA_INPUTS] #ifdef SPLIT_REND_WITH_HEAD_ROT - , + IVAS_REND_InputId masaIds[RENDERER_MAX_MASA_INPUTS], IVAS_REND_InputId splitBinIds[RENDERER_MAX_BIN_INPUTS] +#else + IVAS_REND_InputId masaIds[RENDERER_MAX_MASA_INPUTS] #endif ) { @@ -590,10 +591,11 @@ static void setupWithSingleFormatInput( CmdlnArgs args, char *audioFilePath, IsmPositionProvider *positionProvider, - MasaFileReader **masaReaders #ifdef SPLIT_REND_WITH_HEAD_ROT - , + MasaFileReader **masaReaders, SplitFileReadWrite **hhSplitRendFileReadWrite +#else + MasaFileReader **masaReaders #endif ) { @@ -609,7 +611,7 @@ static void setupWithSingleFormatInput( exit( -1 ); } - for ( int32_t i = 0; i < args.numInMetadataFiles; ++i ) + for ( int16_t i = 0; i < args.numInMetadataFiles; ++i ) { masaReaders[i] = MasaFileReader_open( args.inMetadataFilePaths[i] ); if ( masaReaders[i] == NULL ) @@ -3816,11 +3818,12 @@ static void convertInputBuffer( const int16_t numIntSamplesPerChannel, const int16_t numFloatSamplesPerChannel, const int16_t numChannels, - float *floatBuffer #ifdef SPLIT_REND_WITH_HEAD_ROT - , + float *floatBuffer, const int16_t cldfb_in_flag, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna +#else + float *floatBuffer #endif ) { @@ -3904,11 +3907,12 @@ static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, - int16_t *intBuffer #ifdef SPLIT_REND_WITH_HEAD_ROT - , + int16_t *intBuffer, const int16_t cldfb_in_flag, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn +#else + int16_t *intBuffer #endif ) { diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c index a8ad216a0e..9826da2474 100644 --- a/lib_com/delay_comp.c +++ b/lib_com/delay_comp.c @@ -51,13 +51,14 @@ /*! r: delay value in ns */ int32_t get_delay( - const int16_t enc_dec, /* i : encoder/decoder flag */ - const int32_t io_fs, /* i : input/output sampling frequency */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ + const int16_t enc_dec, /* i : encoder/decoder flag */ + const int32_t io_fs, /* i : input/output sampling frequency */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , + HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ const AUDIO_CONFIG output_config /* i : decoder output config */ +#else + HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ #endif ) { diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 5461f74253..e7f3bcaa2f 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1081,10 +1081,10 @@ enum #define IVAS_PCA_N1 91 #define IVAS_PCA_N1_EQ ( (IVAS_PCA_N1-1)/2 ) #define IVAS_PCA_BIT_LEN ( 1 + ( IVAS_PCA_QBITS - 1 + IVAS_PCA_QBITS ) ) -#define IVAS_PCA_INTERP 4 /* 4D (Quaternion) dimension */ -#define IVAS_PCA_N_SLOTS 40 //20 +#define IVAS_PCA_INTERP 4 +#define IVAS_PCA_N_SLOTS 40 #define IVAS_PCA_LEN_INTERP_Q ( IVAS_PCA_INTERP * IVAS_PCA_N_SLOTS ) -#define IVAS_PCA_DELAY_CMP 24 // 12 +#define IVAS_PCA_DELAY_CMP 24 #define IVAS_PCA_LEN_INTERP_EIG_DEC ( (IVAS_PCA_N_SLOTS+IVAS_PCA_DELAY_CMP)*16) #define IVAS_PCA_THRES_MIN_DOT 0.8f #define IVAS_PCA_THRES_MIN_DOT2 0.0f diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index effc50d3d6..13e18cba43 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1172,8 +1172,8 @@ void ivas_ism_metadata_sid_enc( ); void ivas_ism_metadata_sid_dec( - SCE_DEC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */ - const int32_t ism_total_brate, /* i : ISms total bitrate */ + SCE_DEC_HANDLE hSCE[MAX_SCE], /* i/o: SCE decoder structure */ + const int32_t ism_total_brate, /* i : ISM total bitrate */ const int16_t bfi, /* i : bfi flag */ const int16_t nchan_ism, /* i : number of objects */ const int16_t nchan_transport, /* i : number of transport channels */ @@ -1219,7 +1219,7 @@ void ivas_get_ism_sid_quan_bitbudget( ); void ivas_ism_dtx_limit_noise_energy_for_near_silence( - SCE_DEC_HANDLE hSCE[], /* i/o: SCE encoder structures */ + SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */ const int16_t sce_id_dtx, /* i : SCE DTX ID */ const int16_t nchan_transport /* i : number of transport channels */ ); @@ -4161,7 +4161,7 @@ ivas_error ivas_sba_linear_renderer( float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ const int16_t output_frame, /* i : output frame length per channel */ const int16_t nchan_in, /* i : number of input ambisonics channels */ - const int16_t nchan_ism, + const int16_t nchan_ism, /* i : number of objects */ const AUDIO_CONFIG output_config, /* i : output audio configuration */ const IVAS_OUTPUT_SETUP output_setup /* i : output format setup */ #ifndef REMOVE_UNUSED_FUNCTION @@ -4182,9 +4182,9 @@ void ivas_sba_mix_matrix_determiner( /*! r: AGC enable flag */ int16_t ivas_agc_enc_get_flag( #ifdef DEBUG_AGC_ENCODER_CMD_OPTION - int16_t agc_configuration, /* i : AGC configuration from command-line */ + const int16_t agc_configuration, /* i : AGC configuration from command-line */ #endif - int16_t nchan_transport /* i : number of transport channels */ + const int16_t nchan_transport /* i : number of transport channels */ ); ivas_error ivas_spar_agc_enc_open( diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index cda75af2ff..cbea8dd016 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -64,10 +64,11 @@ static void ivas_binRenderer_filterModule( float CLDFB_real[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : real part of LS signals */ float CLDFB_imag[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : imag part of LS signals */ const int16_t numTimeSlots, /* i : number of time slots to process */ - BINAURAL_RENDERER_HANDLE hBinRenderer /* i/o: fastconv binaural renderer handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , - const int16_t pos_idx + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ + const int16_t pos_idx /* i : pose index */ +#else + BINAURAL_RENDERER_HANDLE hBinRenderer /* i/o: fastconv binaural renderer handle */ #endif ) { @@ -140,10 +141,11 @@ static ivas_error ivas_binRenderer_convModuleOpen( const int16_t renderer_type, const int16_t isLoudspeaker, const AUDIO_CONFIG input_config, - const HRTFS_FASTCONV_HANDLE hHrtf #ifdef SPLIT_REND_WITH_HEAD_ROT - , + const HRTFS_FASTCONV_HANDLE hHrtf, const int16_t num_poses +#else + const HRTFS_FASTCONV_HANDLE hHrtf #endif ) { @@ -1286,10 +1288,11 @@ ivas_error ivas_binRenderer_open( *------------------------------------------------------------------------*/ static void ivas_binRenderer_convModuleClose( - BINAURAL_RENDERER_HANDLE *hBinRenderer /* i/o: fastconv binaural renderer handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , - const int16_t num_poses + BINAURAL_RENDERER_HANDLE *hBinRenderer, /* i/o: fastconv binaural renderer handle */ + const int16_t num_poses /* i : number of poses */ +#else + BINAURAL_RENDERER_HANDLE *hBinRenderer /* i/o: fastconv binaural renderer handle */ #endif ) { diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 127fa841e4..36b864f9bf 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -442,14 +442,12 @@ ivas_error ivas_dec( { if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) { - if ( ( error = ivas_sba_linear_renderer( p_output, output_frame, nchan_remapped, - 0, - output_config, st_ivas->hOutSetup #ifndef REMOVE_UNUSED_FUNCTION - , - st_ivas->hoa_dec_mtx + if ( ( error = ivas_sba_linear_renderer( p_output, output_frame, nchan_remapped, 0, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_sba_linear_renderer( p_output, output_frame, nchan_remapped, 0, output_config, st_ivas->hOutSetup ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) + { return error; } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index fd5b67bcea..65c8de48ed 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1972,7 +1972,6 @@ ivas_error ivas_init_decoder( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; @@ -1986,7 +1985,6 @@ ivas_error ivas_init_decoder( } } - if ( st_ivas->hDecoderConfig->Opt_5ms ) { granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 39c7c667d9..4987b7da20 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -146,11 +146,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { - if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, nSamplesRendered, #ifdef SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) { return error; } @@ -355,8 +355,9 @@ static ivas_error ivas_ism_bitrate_switching_dec( } /*-----------------------------------------------------------------* - * Reconfigure TC buffer + * JBM TC buffers *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->Opt_5ms ) { int16_t tc_nchan_full_new; diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index 0cd8cac356..8899696bec 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -171,7 +171,7 @@ ivas_error ivas_ism_dtx_dec( *-------------------------------------------------------------------*/ void ivas_ism_dtx_limit_noise_energy_for_near_silence( - SCE_DEC_HANDLE hSCE[], /* i/o: SCE encoder structures */ + SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */ const int16_t sce_id_dtx, /* i : SCE DTX ID */ const int16_t nchan_transport /* i : number of transport channels */ ) diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index cc2c7a8b46..bde79fcb5f 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -928,8 +928,8 @@ static int16_t decode_radius( *-------------------------------------------------------------------*/ void ivas_ism_metadata_sid_dec( - SCE_DEC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */ - const int32_t ism_total_brate, /* i : ISms total bitrate */ + SCE_DEC_HANDLE hSCE[MAX_SCE], /* i/o: SCE decoder structure */ + const int32_t ism_total_brate, /* i : ISM total bitrate */ const int16_t bfi, /* i : bfi flag */ const int16_t nchan_ism, /* i : number of objects */ const int16_t nchan_transport, /* i : number of transport channels*/ diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index c52d7dceb1..c8c7603672 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -626,6 +626,7 @@ ivas_error ivas_param_ism_dec_open( } set_zero( hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc, n_slots_to_alloc * nchan_transport * hSpatParamRendCom->num_freq_bands ); } + if ( st_ivas->hTcBuffer == NULL ) { if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) @@ -666,9 +667,9 @@ ivas_error ivas_param_ism_dec_open( *-------------------------------------------------------------------------*/ void ivas_param_ism_dec_close( - PARAM_ISM_DEC_HANDLE *hParamIsmDec_out, /* i/o: decoder DirAC handle */ - SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: common spatial renderer data */ - AUDIO_CONFIG output_config /* i : output audio configuration */ + PARAM_ISM_DEC_HANDLE *hParamIsmDec_out, /* i/o: decoder DirAC handle */ + SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: common spatial renderer data */ + AUDIO_CONFIG output_config /* i : output audio configuration */ ) { if ( hParamIsmDec_out != NULL && *hParamIsmDec_out != NULL ) @@ -1193,6 +1194,7 @@ void ivas_param_ism_dec_digest_tc( } } } + if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms ) { /*TODO : FhG to check*/ @@ -1201,9 +1203,7 @@ void ivas_param_ism_dec_digest_tc( for ( ch = 0; ch < nchan_transport; ch++ ) { - /*-----------------------------------------------------------------* - * CLDFB Analysis - *-----------------------------------------------------------------*/ + /* CLDFB Analysis */ for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms ) @@ -1260,8 +1260,8 @@ void ivas_ism_param_dec_tc_gain_ajust( for ( i = 0; i < nSamples; i++ ) { - ene_tc += transport_channels_f[0][i] * transport_channels_f[0][i] + transport_channels_f[1][i] * transport_channels_f[1][i]; // L*L + R*R - ene_sum += ( transport_channels_f[0][i] + transport_channels_f[1][i] ) * ( transport_channels_f[0][i] + transport_channels_f[1][i] ); // (L+R)*(L+R) + ene_tc += transport_channels_f[0][i] * transport_channels_f[0][i] + transport_channels_f[1][i] * transport_channels_f[1][i]; /* L*L + R*R */ + ene_sum += ( transport_channels_f[0][i] + transport_channels_f[1][i] ) * ( transport_channels_f[0][i] + transport_channels_f[1][i] ); /* (L+R)*(L+R) */ } gain = sqrtf( ene_tc / ( ene_sum + EPSILON ) ); if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 1 ) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 9a5b8819f4..bff2ff9abd 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1107,14 +1107,11 @@ ivas_error ivas_jbm_dec_render( mvr2r( st_ivas->hTcBuffer->tc[n] + st_ivas->hTcBuffer->n_samples_rendered, p_output[n], *nSamplesRendered ); } - if ( ( error = ivas_sba_linear_renderer( p_output, *nSamplesRendered, nchan_remapped, - 0, - output_config, st_ivas->hOutSetup #ifndef REMOVE_UNUSED_FUNCTION - , - st_ivas->hoa_dec_mtx + if ( ( error = ivas_sba_linear_renderer( p_output, *nSamplesRendered, nchan_remapped, 0, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_sba_linear_renderer( p_output, *nSamplesRendered, nchan_remapped, 0, output_config, st_ivas->hOutSetup ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 37cff3347e..a58e2b735a 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -622,9 +622,7 @@ ivas_error ivas_masa_dec_open( st_ivas->hMasa = hMasa; /* allocate transport channels*/ - if ( - st_ivas->hDecoderConfig->Opt_5ms && - st_ivas->hTcBuffer == NULL && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) + if ( st_ivas->hDecoderConfig->Opt_5ms && st_ivas->hTcBuffer == NULL && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) { int16_t nchan_to_allocate; TC_BUFFER_MODE buffer_mode; @@ -1483,11 +1481,11 @@ ivas_error ivas_masa_dec_reconfigure( { if ( n_samples_granularity < st_ivas->hTcBuffer->n_samples_granularity ) { - if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, #ifdef SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index fc8f4587bf..9089edf8c9 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -2061,7 +2061,7 @@ static int16_t ivas_param_mc_bin2dec( /*------------------------------------------------------------------------- - * ivas_param_mc_uniform_encoder() + * ivas_param_mc_uniform_decoder() * * decode a uniformily coded sequence of float values *------------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 7f6926402a..8eb2f51223 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -658,6 +658,7 @@ ivas_error ivas_mc_paramupmix_dec_open( /* allocate transport channels*/ hMCParamUpmix->free_param_interpolator = 0; hMCParamUpmix->param_interpolator = NULL; + #ifdef NONBE_FIX_808_JBM_PARAMUPMIX_RS if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) { @@ -670,6 +671,7 @@ ivas_error ivas_mc_paramupmix_dec_open( ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, DEFAULT_JBM_CLDFB_TIMESLOTS, hMCParamUpmix->param_interpolator ); } #endif + if ( st_ivas->hDecoderConfig->Opt_5ms == 1 && st_ivas->hTcBuffer == NULL ) { int16_t nchan_to_allocate; @@ -685,6 +687,7 @@ ivas_error ivas_mc_paramupmix_dec_open( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for interpolator\n" ) ); } #endif + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) { buffer_mode = TC_BUFFER_MODE_BUFFER; @@ -695,6 +698,7 @@ ivas_error ivas_mc_paramupmix_dec_open( { nchan_to_allocate = MC_PARAMUPMIX_MAX_INPUT_CHANS; } + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { return error; @@ -1005,11 +1009,12 @@ static void ps_pred_process_sf( static void ivas_mc_paramupmix_dec_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output_f[MAX_OUTPUT_CHANNELS] /* i/o: synthesized core-coder transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , + float *output_f[MAX_OUTPUT_CHANNELS], /* i/o: synthesized core-coder transport channels */ const int16_t slot_index_start +#else + float *output_f[MAX_OUTPUT_CHANNELS] /* i/o: synthesized core-coder transport channels */ #endif ) { diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 1fb4db5eb8..8383402f62 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1324,7 +1324,7 @@ static ivas_error ivas_mc_dec_reconfig( } /*-----------------------------------------------------------------* - * Reconfigure TC buffer + * JBM TC buffers *-----------------------------------------------------------------*/ if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) @@ -1337,11 +1337,13 @@ static ivas_error ivas_mc_dec_reconfig( tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas ); tc_nchan_allocate_new = tc_nchan_tc_new; tc_nchan_full_new = tc_nchan_tc_new; + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS; tc_nchan_full_new = tc_nchan_allocate_new; } + if ( st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO ) { tc_nchan_full_new = 0; diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index ffe9ca40c1..fd7e728631 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -342,7 +342,7 @@ ivas_error ivas_omasa_dec_config( ivas_td_binaural_close( &st_ivas->hBinRendererTd ); } - if ( st_ivas->hHrtfTD != NULL ) // VE: this is copied from ivas_ism_bitrate_switching() but a review is needed + if ( st_ivas->hHrtfTD != NULL ) // ToDo: this is copied from ivas_ism_bitrate_switching() but a review is needed { st_ivas->hHrtfTD = NULL; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index c5664065ed..91e2b8b601 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -627,7 +627,7 @@ ivas_error ivas_sba_dec_reconfigure( } /*-----------------------------------------------------------------* - * JBM TC buffer + * JBM TC buffers *-----------------------------------------------------------------*/ #ifdef JBM_FOR_OSBA @@ -868,9 +868,8 @@ ivas_error ivas_sba_dec_render( SPAR_DEC_HANDLE hSpar; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; float *output_f_local[MAX_OUTPUT_CHANNELS]; -#ifndef REMOVE_UNUSED_FUNCTION ivas_error error; -#endif + hSpar = st_ivas->hSpar; hSpatParamRendCom = st_ivas->hSpatParamRendCom; nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); @@ -914,14 +913,15 @@ ivas_error ivas_sba_dec_render( if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) { - ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, - 0, - st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup #ifndef REMOVE_UNUSED_FUNCTION - , - st_ivas->hoa_dec_mtx + if ( ( error = ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, 0, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) +#else + + if ( ( error = ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, 0, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup ) ) != IVAS_ERR_OK ) #endif - ); + { + return error; + } } if ( st_ivas->hDirAC != NULL && hSpar->slots_rendered == hSpar->num_slots ) diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 37635b0810..be5de1c4de 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -425,8 +425,6 @@ void ivas_ism2sba_sf( assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" ); assert( hIsmRendererData != NULL && "hIsmRendererData not allocated!" ); - - /* Init*/ sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 ); for ( j = 0; j < sba_num_chans; j++ ) @@ -471,7 +469,6 @@ ivas_error ivas_sba_upmixer_renderer( ivas_error error; push_wmops( "ivas_sba_upmixer_renderer" ); - nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); /* Upmixer + Renderer */ @@ -496,12 +493,11 @@ ivas_error ivas_sba_upmixer_renderer( output_f[ch] = output[ch]; } - if ( ( error = ivas_sba_linear_renderer( output_f, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->nchan_ism, output_config, st_ivas->hOutSetup #ifndef REMOVE_UNUSED_FUNCTION - , - st_ivas->hoa_dec_mtx + if ( ( error = ivas_sba_linear_renderer( output_f, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->nchan_ism, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_sba_linear_renderer( output_f, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->nchan_ism, output_config, st_ivas->hOutSetup ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -511,6 +507,7 @@ ivas_error ivas_sba_upmixer_renderer( return IVAS_ERR_OK; } + #ifndef REMOVE_UNUSED_FUNCTION /*-------------------------------------------------------------------* * ivas_sba_mtx_mult() @@ -579,10 +576,10 @@ static void ivas_sba_mtx_mult( *-------------------------------------------------------------------*/ ivas_error ivas_sba_linear_renderer( - float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t nchan_in, /* i : number of input ambisonics channels */ - const int16_t nchan_ism, + float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ + const int16_t output_frame, /* i : output frame length per channel */ + const int16_t nchan_in, /* i : number of input ambisonics channels */ + const int16_t nchan_ism, /* i : number of objects */ const AUDIO_CONFIG output_config, /* i : output audio configuration */ const IVAS_OUTPUT_SETUP output_setup /* i : output format setup */ #ifndef REMOVE_UNUSED_FUNCTION diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 45d9a0d59c..f5f09a521f 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1513,7 +1513,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( ivas_error IVAS_DEC_GetMasaMetadata( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to metadata from the most recently decoded frame */ - uint8_t getFromJbmBuffer /* i : get metadata from a JBM buffer */ + const uint8_t getFromJbmBuffer /* i : get metadata from a JBM buffer */ ) { if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) @@ -1544,13 +1544,14 @@ ivas_error IVAS_DEC_GetMasaMetadata( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_FeedHeadTrackData( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ - IVAS_VECTOR3 Pos, /* i : listener position */ - const int16_t subframe_idx /* i : subframe index */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ + IVAS_VECTOR3 Pos, /* i : listener position */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , - const IVAS_SPLIT_REND_ROT_AXIS rot_axis + const int16_t subframe_idx, /* i : subframe index */ + const IVAS_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ +#else + const int16_t subframe_idx /* i : subframe index */ #endif ) { @@ -3438,7 +3439,7 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( #ifdef SPLIT_REND_WITH_HEAD_ROT /*---------------------------------------------------------------------* - * IVAS_DEC_GetCldfbSamples() + * IVAS_DEC_GetSplitRendBits() * * *---------------------------------------------------------------------*/ @@ -3482,7 +3483,6 @@ ivas_error IVAS_DEC_GetCldfbSamples( ) { Decoder_Struct *st_ivas; - ivas_error error; int16_t ch, b, slot_idx, num_chs, maxBand, num_samples; if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index f541e49d63..bc42de423a 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -205,20 +205,21 @@ ivas_error IVAS_DEC_GetObjectMetadata( /*! r: error code */ ivas_error IVAS_DEC_GetMasaMetadata( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to metadata from the most recently decoded frame */ - uint8_t getFromJbmBuffer /* i : get metadata from a JBM buffer */ + const uint8_t getFromJbmBuffer /* i : get metadata from a JBM buffer */ ); /*! r: error code */ ivas_error IVAS_DEC_FeedHeadTrackData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ - IVAS_VECTOR3 Pos, /* i : listener position */ - const int16_t subframe_idx /* i : subframe index */ + IVAS_VECTOR3 Pos, /* i : listener position */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , + const int16_t subframe_idx, /* i : subframe index */ IVAS_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ +#else + const int16_t subframe_idx /* i : subframe index */ #endif ); @@ -227,6 +228,7 @@ ivas_error IVAS_DEC_FeedRefRotData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_QUATERNION rotation /* i : reference rotation data */ ); + /*! r: error code */ ivas_error IVAS_DEC_FeedRefVectorData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc.c index 03cb2aa2ed..09db68d7d6 100644 --- a/lib_enc/ivas_agc_enc.c +++ b/lib_enc/ivas_agc_enc.c @@ -49,16 +49,16 @@ #define AGC_MIN_DELTA ( 4.656612873077393e-10f ) /*2^-31*/ - +#ifdef DEBUG_AGC /*------------------------------------------------------------------------------------------* * Local functions declarations *------------------------------------------------------------------------------------------*/ -#ifdef DEBUG_AGC + extern FILE *agcOut; static int16_t ivas_agc_writeBits( FILE *stream, const int16_t n_channels, ivas_agc_enc_state_t *pState ); -#endif +#endif /*-----------------------------------------------------------------------------------------* * Function ivas_agc_enc_get_flag() @@ -69,9 +69,9 @@ static int16_t ivas_agc_writeBits( FILE *stream, const int16_t n_channels, ivas_ /*! r: AGC enable flag */ int16_t ivas_agc_enc_get_flag( #ifdef DEBUG_AGC_ENCODER_CMD_OPTION - int16_t agc_configuration, /* i : AGC configuration from command-line */ + const int16_t agc_configuration, /* i : AGC configuration from command-line */ #endif - int16_t nchan_transport /* i : number of transport channels */ + const int16_t nchan_transport /* i : number of transport channels */ ) { int16_t agc_flag; diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index a042e284fa..e1aa7113af 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -1246,7 +1246,7 @@ ivas_error ivas_initialize_MD_bstr_enc( /*------------------------------------------------------------------------- * ivas_destroy_MD_bstr_enc() * - * Destroy SCE/CPE MD bistream handle + * Destroy SCE/CPE MD bitstream handle *-------------------------------------------------------------------------*/ void ivas_destroy_MD_bstr_enc( diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 159f81bf7d..03446fcafa 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -290,7 +290,7 @@ int16_t ivas_sba_get_max_md_bits( max_bits = 500; } - max_md_bits = min( st_ivas->hQMetaData->metadata_max_bits + 1, max_bits ); // TODO: remove 500 once max MD bits has been defined at all bitrates in DirAC + max_md_bits = min( st_ivas->hQMetaData->metadata_max_bits + 1, max_bits ); if ( st_ivas->hEncoderConfig->ivas_format == SBA_FORMAT ) { max_md_bits += st_ivas->hSpar->hMdEnc->spar_md_cfg.max_md_bits_spar; diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index e4df299553..c7c87f0f2c 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -784,15 +784,11 @@ static ivas_error ivas_spar_enc_process( * FB mixer *-----------------------------------------------------------------------------------------*/ - ivas_fb_mixer_get_in_out_mapping( hSpar->hFbMixer->fb_cfg, #ifndef REMOVE_UNUSED_FUNCTION - nchan_transport, - - ENC, - - remix_order_set[hSpar->hMdEnc->spar_md_cfg.remix_unmix_order], + ivas_fb_mixer_get_in_out_mapping( hSpar->hFbMixer->fb_cfg, nchan_transport, ENC, remix_order_set[hSpar->hMdEnc->spar_md_cfg.remix_unmix_order], in_out_mixer_map ); +#else + ivas_fb_mixer_get_in_out_mapping( hSpar->hFbMixer->fb_cfg, in_out_mixer_map ); #endif - in_out_mixer_map ); #ifdef DEBUG_SBA_MD_DUMP { diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index a69bb1bf35..a22a2e40ca 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -158,7 +158,7 @@ typedef struct IVAS_ENC *IVAS_ENC_HANDLE; /*! r: error code */ ivas_error IVAS_ENC_Open( - IVAS_ENC_HANDLE *phIvasEnc /* i/o: pointer to an encoder handle to be opened */ + IVAS_ENC_HANDLE *phIvasEnc /* i/o: pointer to an encoder handle to be opened */ ); /*! r: error code */ @@ -169,7 +169,7 @@ ivas_error IVAS_ENC_ConfigureForMono( const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ - const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig, /* i : configuration of channel-aware mode, can by set to default by using IVAS_ENC_GetDefaultChannelAwareConfig() */ + const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig, /* i : configuration of channel-aware mode, can by set to default by using IVAS_ENC_GetDefaultChannelAwareConfig() */ const bool downmixFromStereo, /* i : if true, the encoder accepts a stereo input and internally downmixes it to mono before encoding */ const bool is_binaural /* i : if true, the input is binaural audio */ ); @@ -185,7 +185,7 @@ ivas_error IVAS_ENC_ConfigureForStereo( const bool is_binaural /* i : flag indicating if input is binaural audio */ #ifdef DEBUGGING , - const IVAS_ENC_STEREO_MODE stereoMode /* i : forces a specific stereo coding mode */ + const IVAS_ENC_STEREO_MODE stereoMode /* i : forces a specific stereo coding mode */ #endif ); @@ -203,26 +203,26 @@ ivas_error IVAS_ENC_ConfigureForObjects( /*! r: encoder error code */ ivas_error IVAS_ENC_ConfigureForMASAObjects( - IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the ouput bitstream */ - const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ - const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ - const uint16_t numObjects, /* i : number of objects to be encoded */ - const int16_t masaVariant /* i : index specifying the number of MASA transport channels */ + IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ + const int32_t inputFs, /* i : input sampling frequency */ + const int32_t bitrate, /* i : requested bitrate of the ouput bitstream */ + const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ + const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ + const uint16_t numObjects, /* i : number of objects to be encoded */ + const int16_t masaVariant /* i : index specifying the number of MASA transport channels */ ); /*! r: encoder error code */ ivas_error IVAS_ENC_ConfigureForSBAObjects( - IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the ouput bitstream */ - const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ - const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ - const uint16_t numObjects, /* i : number of objects to be encoded */ - const IVAS_ENC_SBA_ORDER order, /* i : order of the Ambisonics input */ - const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ - const bool Opt_PCA_ON /* i : PCA option flag */ + IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ + const int32_t inputFs, /* i : input sampling frequency */ + const int32_t bitrate, /* i : requested bitrate of the ouput bitstream */ + const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ + const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ + const uint16_t numObjects, /* i : number of objects to be encoded */ + const IVAS_ENC_SBA_ORDER order, /* i : order of the Ambisonics input */ + const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ + const bool Opt_PCA_ON /* i : PCA option flag */ ); /*! r: error code */ diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 6582fecbac..36268e7ac4 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1125,10 +1125,11 @@ static ivas_error ivas_er_init_handle( *------------------------------------------------------------------------*/ ivas_error ivas_rend_initCrendWrapper( - CREND_WRAPPER_HANDLE *pCrend #ifdef SPLIT_REND_WITH_HEAD_ROT - , + CREND_WRAPPER_HANDLE *pCrend, const int16_t num_poses +#else + CREND_WRAPPER_HANDLE *pCrend #endif ) { @@ -1238,10 +1239,11 @@ ivas_error ivas_rend_openCrend( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, HRTFS_CREND_HANDLE hSetOfHRTF, - const int32_t output_Fs #ifdef SPLIT_REND_WITH_HEAD_ROT - , + const int32_t output_Fs, const int16_t num_poses +#else + const int32_t output_Fs #endif ) { @@ -1418,10 +1420,11 @@ ivas_error ivas_rend_openCrend( *------------------------------------------------------------------------*/ void ivas_rend_closeCrend( - CREND_WRAPPER_HANDLE *pCrend #ifdef SPLIT_REND_WITH_HEAD_ROT - , + CREND_WRAPPER_HANDLE *pCrend, const int16_t num_poses +#else + CREND_WRAPPER_HANDLE *pCrend #endif ) { @@ -1574,10 +1577,11 @@ static ivas_error ivas_rend_crendConvolver( float *pcm_in[], float *pcm_out[], const int32_t output_Fs, - const int16_t i_ts #ifdef SPLIT_REND_WITH_HEAD_ROT - , + const int16_t i_ts, const int16_t pos_idx +#else + const int16_t i_ts #endif ) { @@ -1751,10 +1755,11 @@ ivas_error ivas_rend_crendProcess( EFAP_HANDLE hEFAPdata, float *output[], /* i/o: input/output audio channels */ const int32_t output_Fs, - const int16_t num_subframes /* i : number of subframes to render */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , + const int16_t num_subframes /* i : number of subframes to render */, const int16_t pos_idx +#else + const int16_t num_subframes /* i : number of subframes to render */ #endif ) { @@ -1787,7 +1792,6 @@ ivas_error ivas_rend_crendProcess( } push_wmops( "ivas_rend_crendProcess" ); - inConfigType = getAudioConfigType( inConfig ); if ( ( error = getAudioConfigNumChannels( outConfig, &nchan_out ) ) != IVAS_ERR_OK ) @@ -1871,7 +1875,6 @@ ivas_error ivas_rend_crendProcess( } pop_wmops(); - return IVAS_ERR_OK; } @@ -1923,7 +1926,6 @@ ivas_error ivas_rend_crendProcessSubframe( } push_wmops( "ivas_rend_crendProcessSubframe" ); - inConfigType = getAudioConfigType( inConfig ); if ( ( error = getAudioConfigNumChannels( outConfig, &nchan_out ) ) != IVAS_ERR_OK ) @@ -2155,17 +2157,7 @@ ivas_error ivas_rend_crendProcessSplitBin( { mvr2r( hCombinedOrientationData->Rmat_prev[pos_idx][i], pCombinedOrientationDataLocal->Rmat_prev[0][i], 3 ); } - if ( ( error = ivas_rend_crendProcess( pCrend, - inConfig, - outConfig, - hDecoderConfig, - pCombinedOrientationDataLocal, - hIntSetup, - hEFAPdata, - p_tmpInputBuffer, - output_Fs, - hCombinedOrientationData->num_subframes, - pos_idx ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcess( pCrend, inConfig, outConfig, hDecoderConfig, pCombinedOrientationDataLocal, hIntSetup, hEFAPdata, p_tmpInputBuffer, output_Fs, hCombinedOrientationData->num_subframes, pos_idx ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index ddc379d2cd..17ec758aaf 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -306,9 +306,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( #endif /* allocate transport channels*/ - if ( - st_ivas->hDecoderConfig->Opt_5ms && - st_ivas->hTcBuffer == NULL ) + if ( st_ivas->hDecoderConfig->Opt_5ms && st_ivas->hTcBuffer == NULL ) { int16_t nchan_to_allocate; int16_t n_samples_granularity; @@ -348,6 +346,7 @@ void ivas_dirac_dec_close_binaural_data( #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN int16_t pos_idx; #endif + if ( hBinaural == NULL || *hBinaural == NULL ) { return; @@ -667,7 +666,6 @@ static void ivas_dirac_dec_binaural_internal( DIFFUSE_DISTRIBUTION_DATA diffuseDistData; int16_t nBins, offsetSamples; int16_t i, j; - #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN int16_t pos_idx; MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index b29b5a312e..f10b7b2c22 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -1055,8 +1055,8 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( p_gains_dir++; p_gains_dir_prev++; - output_real[l * num_channels_dir + ch_idx] = 0.5f * gs1 * ( 1.772454e+00f * ( *p_proto ) + 1.023327e+00f * ( *p_proto2 ) ) + // s1 - 0.5f * gs2 * ( 1.772454e+00f * ( *p_proto ) - 1.023327e+00f * ( *p_proto2 ) ); // s2 + output_real[l * num_channels_dir + ch_idx] = 0.5f * gs1 * ( 1.772454e+00f * ( *p_proto ) + 1.023327e+00f * ( *p_proto2 ) ) + /* s1 */ + 0.5f * gs2 * ( 1.772454e+00f * ( *p_proto ) - 1.023327e+00f * ( *p_proto2 ) ); /* s2 */ p_proto++; p_proto2++; output_imag[l * num_channels_dir + ch_idx] = 0.5f * gs1 * ( 1.772454e+00f * ( *p_proto ) + 1.023327e+00f * ( *p_proto2 ) ) + diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index d87a20c7c7..d8d5549e0b 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -817,30 +817,33 @@ ivas_error ivas_rend_openCrend( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, HRTFS_CREND_HANDLE hSetOfHRTF, - const int32_t output_Fs #ifdef SPLIT_REND_WITH_HEAD_ROT - , + const int32_t output_Fs, const int16_t num_poses +#else + const int32_t output_Fs #endif ); -void ivas_rend_closeCrend( - CREND_WRAPPER_HANDLE *pCrend +void ivas_rend_closeCrend( #ifdef SPLIT_REND_WITH_HEAD_ROT - , + CREND_WRAPPER_HANDLE *pCrend , const int16_t num_poses +#else + CREND_WRAPPER_HANDLE *pCrend #endif ); ivas_error ivas_hrtf_init( - HRTFS_DATA *hHrtf /* i/o: HRTF handle */ + HRTFS_DATA *hHrtf /* i/o: HRTF handle */ ); ivas_error ivas_rend_initCrendWrapper( - CREND_WRAPPER_HANDLE *pCrend #ifdef SPLIT_REND_WITH_HEAD_ROT - , + CREND_WRAPPER_HANDLE *pCrend, const int16_t num_poses +#else + CREND_WRAPPER_HANDLE *pCrend #endif ); @@ -853,11 +856,12 @@ ivas_error ivas_rend_crendProcess( IVAS_OUTPUT_SETUP_HANDLE hIntSetup, EFAP_HANDLE hEFAPdata, float *output[], /* i/o: input/output audio channels */ - const int32_t output_Fs, - const int16_t num_subframes /* i : number of subframes to render */ + const int32_t output_Fs, #ifdef SPLIT_REND_WITH_HEAD_ROT - , - const int16_t pos_idx + const int16_t num_subframes, /* i : number of subframes to render */ + const int16_t pos_idx /* i : pose index */ +#else + const int16_t num_subframes /* i : number of subframes to render */ #endif ); @@ -1442,10 +1446,11 @@ void ivas_splitBinLCLDDecProcess( ivas_error ivas_splitBinPreRendOpen( BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - , - const int32_t output_Fs + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const int32_t output_Fs +#else + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData #endif ); @@ -1516,10 +1521,12 @@ void ivas_splitBinPostRendClose( void ivas_splitBinPostRendMdDec( ivas_split_rend_bits_t *pBits, - BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData + BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - ,BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend +#else + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData #endif ); @@ -1527,7 +1534,8 @@ ivas_error ivas_splitBinRendPLCOpen( SPLIT_REND_PLC_HANDLE* phSplitRendPLC ); -void ivas_splitBinRendPLCClose(SPLIT_REND_PLC_HANDLE* phSplitRendPLC +void ivas_splitBinRendPLCClose( + SPLIT_REND_PLC_HANDLE* phSplitRendPLC ); void ivas_splitBinRendPLCsaveState( diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 9fb797a383..0b48782a41 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -197,7 +197,6 @@ typedef struct #else rotation_gains rot_gains_prev; #endif - float *bufferData; DIRAC_ANA_HANDLE hDirAC; } input_sba; @@ -433,7 +432,7 @@ static void accumulateCLDFBArrayToBuffer( return; } -#endif /* SPLIT_REND_WITH_HEAD_ROT */ +#endif static void copyBufferTo2dArray( const IVAS_REND_AudioBuffer buffer, @@ -1436,6 +1435,7 @@ static ivas_error setRendInputActiveIsm( { return error; } + if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { if ( ( error = ivas_reverb_open( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, hRendCfg, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) @@ -1458,11 +1458,7 @@ static ivas_error setRendInputActiveIsm( } else if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -2163,10 +2159,11 @@ static ivas_error initMcBinauralRendering( input_mc *inputMc, const AUDIO_CONFIG inConfig, const AUDIO_CONFIG outConfig, - RENDER_CONFIG_DATA *hRendCfg #ifdef FIX_513_REND_MC_ALLOC - , - uint8_t reconfigureFlag + RENDER_CONFIG_DATA *hRendCfg, + const uint8_t reconfigureFlag +#else + RENDER_CONFIG_DATA *hRendCfg #endif ) { @@ -3249,10 +3246,11 @@ static DecoderDummy *initDecoderDummy( const int32_t sampleRate, const int16_t numTransChannels, const AUDIO_CONFIG outConfig, - const uint8_t enableRenderConfig #ifdef SPLIT_REND_WITH_HEAD_ROT - , + const uint8_t enableRenderConfig, const SPLIT_REND_WRAPPER *pSplitRendWrapper +#else + const uint8_t enableRenderConfig #endif ) { @@ -3295,6 +3293,7 @@ static DecoderDummy *initDecoderDummy( } } #endif + decDummy->hEFAPdata = NULL; decDummy->hCrendWrapper = NULL; decDummy->hHrtfTD = NULL; @@ -3302,6 +3301,7 @@ static DecoderDummy *initDecoderDummy( decDummy->hoa_dec_mtx = NULL; decDummy->hVBAPdata = NULL; // note: not used at the moment decDummy->hMasa = NULL; + #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN for ( i = 0; i < MAX_HEAD_ROT_POSES; i++ ) { @@ -3310,6 +3310,7 @@ static DecoderDummy *initDecoderDummy( #else decDummy->hDiracDecBin = NULL; #endif + decDummy->hDirACRend = NULL; decDummy->hSpatParamRendCom = NULL; decDummy->hQMetaData = NULL; @@ -5231,9 +5232,10 @@ ivas_error IVAS_REND_SetHeadRotation( const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ #ifdef SPLIT_REND_WITH_HEAD_ROT - IVAS_SPLIT_REND_ROT_AXIS rot_axis, + const IVAS_SPLIT_REND_ROT_AXIS rot_axis, /* i : external control for rotation axis for split rendering */ #endif - const int16_t sf_idx ) + const int16_t sf_idx /* i : subframe index */ +) { #ifdef FIX_513_REND_MC_ALLOC int16_t i; @@ -5256,20 +5258,19 @@ ivas_error IVAS_REND_SetHeadRotation( #ifdef FIX_513_REND_MC_ALLOC hIvasRend->headRotData.headRotEnabled = 1; - /* reconfigure binaural rendering to allocate - the necessary renderers and free unused ones */ + /* reconfigure binaural rendering to allocate the necessary renderers and free unused ones */ for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) { if ( hIvasRend->inputsMc[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) { - initMcBinauralRendering( &hIvasRend->inputsMc[i], - hIvasRend->inputsMc[i].base.inConfig, - hIvasRend->outputConfig, - hIvasRend->hRendererConfig, - TRUE ); + if ( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], hIvasRend->inputsMc[i].base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, TRUE ) ) != IVAS_ERR_OK ) + { + return error; + } } } #endif + /* check for Euler angle signaling */ if ( headRot.w == -3.0f ) { @@ -5307,7 +5308,9 @@ ivas_error IVAS_REND_DisableHeadRotation( { #ifdef FIX_513_REND_MC_ALLOC int16_t i; + ivas_error error; #endif + /* Validate function arguments */ if ( hIvasRend == NULL ) { @@ -5315,20 +5318,20 @@ ivas_error IVAS_REND_DisableHeadRotation( } hIvasRend->headRotData.headRotEnabled = 0; + #ifdef FIX_513_REND_MC_ALLOC - /* reconfigure binaural rendering to allocate - the necessary renderers and free unused ones */ + /* reconfigure binaural rendering to allocate the necessary renderers and free unused ones */ if ( getAudioConfigType( hIvasRend->outputConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) { for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) { if ( hIvasRend->inputsMc[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) { - initMcBinauralRendering( &hIvasRend->inputsMc[i], - hIvasRend->inputsMc[i].base.inConfig, - hIvasRend->outputConfig, - hIvasRend->hRendererConfig, - TRUE ); + if ( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], hIvasRend->inputsMc[i].base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, TRUE ) ) != IVAS_ERR_OK ) + { + + return error; + } } } } @@ -8276,10 +8279,11 @@ static void renderMasaToSba( static void renderMasaToBinaural( input_masa *masaInput, - IVAS_REND_AudioBuffer outAudio #ifdef SPLIT_REND_WITH_HEAD_ROT - , + IVAS_REND_AudioBuffer outAudio, const int16_t is_split_rend_mode +#else + IVAS_REND_AudioBuffer outAudio #endif ) { @@ -8759,11 +8763,12 @@ ivas_error IVAS_REND_SetIsmMetadataDelay( *-------------------------------------------------------------------*/ static ivas_error getSamplesInternal( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , + IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */, IVAS_REND_BitstreamBuffer *hBits /*i/o: buffer for input/output bitstream. Needed in split rendering mode*/ +#else + IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */ #endif ) { @@ -8782,8 +8787,7 @@ static ivas_error getSamplesInternal( #ifdef SPLIT_REND_WITH_HEAD_ROT cldfb2tdSampleFact = ( outAudio.config.is_cldfb ) ? 2 : 1; -#endif -#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( outAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 0 ) || ( ( MAX_BUFFER_LENGTH_PER_CHANNEL * cldfb2tdSampleFact ) < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 1 ) ) #else @@ -8868,10 +8872,7 @@ static ivas_error getSamplesInternal( int16_t num_poses_orig; num_poses_orig = hIvasRend->splitRendWrapper.multiBinPoseData.num_poses; outAudio = hIvasRend->splitRendEncBuffer; - ivas_renderSplitGetMultiBinPoseData( - &hIvasRend->hRendererConfig->split_rend_config, - &hIvasRend->splitRendWrapper.multiBinPoseData, - hIvasRend->headRotData.sr_pose_pred_axis ); + ivas_renderSplitGetMultiBinPoseData( &hIvasRend->hRendererConfig->split_rend_config, &hIvasRend->splitRendWrapper.multiBinPoseData, hIvasRend->headRotData.sr_pose_pred_axis ); assert( num_poses_orig == hIvasRend->splitRendWrapper.multiBinPoseData.num_poses && "number of poses should not change dynamically" ); /* Clear output buffer for split rendering bitstream */ @@ -8914,7 +8915,7 @@ static ivas_error getSamplesInternal( limitRendererOutput( hIvasRend->hLimiter, outAudio.data, outAudio.config.numSamplesPerChannel, IVAS_LIMITER_THRESHOLD ); #endif } -#else /* SPLIT_REND_WITH_HEAD_ROT */ +#else #ifndef DISABLE_LIMITER #ifdef DEBUGGING @@ -8922,7 +8923,7 @@ static ivas_error getSamplesInternal( #endif limitRendererOutput( hIvasRend->hLimiter, outAudio.data, outAudio.config.numSamplesPerChannel, IVAS_LIMITER_THRESHOLD ); #endif -#endif /* SPLIT_REND_WITH_HEAD_ROT */ +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT if ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) @@ -8961,7 +8962,7 @@ static ivas_error getSamplesInternal( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, @@ -8980,7 +8981,7 @@ static ivas_error getSamplesInternal( accumulate2dArrayToBuffer( tmpBinaural_buff, &outAudio ); } } -#endif /* SPLIT_REND_WITH_HEAD_ROT */ +#endif return IVAS_ERR_OK; } @@ -9000,7 +9001,6 @@ ivas_error IVAS_REND_GetSamples( #ifdef SPLIT_REND_WITH_HEAD_ROT return getSamplesInternal( hIvasRend, outAudio, NULL ); - #else return getSamplesInternal( hIvasRend, outAudio ); #endif diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index c1d7360a46..dd4c2849f5 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -272,12 +272,12 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( ivas_error IVAS_REND_SetHeadRotation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ - const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ + const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ + const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ #ifdef SPLIT_REND_WITH_HEAD_ROT - IVAS_SPLIT_REND_ROT_AXIS rot_axis, + const IVAS_SPLIT_REND_ROT_AXIS rot_axis, /* i : external control for rotation axis for split rendering*/ #endif - const int16_t sf_idx + const int16_t sf_idx /* i : subframe index */ ); /* Head rotation becomes enabled by calling IVAS_REND_SetHeadRotation. Use this to disable. */ diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 867282e6b2..1f1add3264 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2846,7 +2846,6 @@ ivas_error RenderConfigReader_getDirectivity( #endif bool idExists; - if ( pRenderConfigReader == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -2885,6 +2884,7 @@ ivas_error RenderConfigReader_getDirectivity( id[n] = last_specified_id; } #endif + for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) { idExists = false; -- GitLab From 28eafb0bec87e5ac01a9abced956c0bc5b055a4b Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Oct 2023 10:33:52 +0200 Subject: [PATCH 05/16] revert a removal --- lib_dec/ivas_dec.c | 2 ++ lib_dec/ivas_jbm_dec.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 36b864f9bf..51a98a1a2a 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -494,6 +494,8 @@ ivas_error ivas_dec( /* Configuration of combined-format bit-budget distribution */ ivas_set_surplus_brate_dec( st_ivas, &ism_total_brate ); + st_ivas->hCPE[0]->hCoreCoder[0]->bit_stream = &( st_ivas->bit_stream[( ism_total_brate / FRAMES_PER_SEC )] ); + /* set ISM parameters and decode ISM metadata in OMASA format */ if ( ( error = ivas_omasa_ism_metadata_dec( st_ivas, ism_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index bff2ff9abd..68b1a2155f 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -321,7 +321,6 @@ ivas_error ivas_jbm_dec_tc( int16_t nchan_ism, nchan_transport_ism; int16_t dirac_bs_md_write_idx; - st = st_ivas->hCPE[0]->hCoreCoder[0]; set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); /* Set the number of objects for the parametric rendering */ @@ -338,7 +337,7 @@ ivas_error ivas_jbm_dec_tc( } /* MASA metadata decoding */ - if ( ( error = ivas_masa_decode( st_ivas, st, &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_masa_decode( st_ivas, st_ivas->hCPE[0]->hCoreCoder[0], &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -346,6 +345,8 @@ ivas_error ivas_jbm_dec_tc( /* Configuration of combined-format bit-budget distribution */ ivas_set_surplus_brate_dec( st_ivas, &ism_total_brate ); + st_ivas->hCPE[0]->hCoreCoder[0]->bit_stream = &( st_ivas->bit_stream[( ism_total_brate / FRAMES_PER_SEC )] ); + /* set ISM parameters and decode ISM metadata in OMASA format */ if ( ( error = ivas_omasa_ism_metadata_dec( st_ivas, ism_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { -- GitLab From 816ea773436605c6db418c05a8beea3b56dc7af1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Oct 2023 11:05:33 +0200 Subject: [PATCH 06/16] harmonize calling of ivas_td_binaural_close() --- lib_dec/ivas_init_dec.c | 8 +++----- lib_dec/ivas_ism_dec.c | 11 ++--------- lib_dec/ivas_omasa_dec.c | 11 ++--------- lib_dec/ivas_sba_dec.c | 5 +---- 4 files changed, 8 insertions(+), 27 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 65c8de48ed..68c7211989 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2699,11 +2699,9 @@ void ivas_destroy_dec( ivas_combined_orientation_close( &st_ivas->hCombinedOrientationData ); /* Time Domain binaural renderer handle */ - if ( st_ivas->hBinRendererTd != NULL ) - { - ivas_td_binaural_close( &st_ivas->hBinRendererTd ); - } - else if ( st_ivas->hHrtfTD != NULL ) + ivas_td_binaural_close( &st_ivas->hBinRendererTd ); + + if ( st_ivas->hHrtfTD != NULL ) { BSplineModelEvalDealloc( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval ); diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 4987b7da20..2f649ac83e 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -272,15 +272,8 @@ static ivas_error ivas_ism_bitrate_switching_dec( /* Close the TD Binaural renderer */ if ( st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM == TRUE ) { - if ( st_ivas->hBinRendererTd != NULL ) - { - ivas_td_binaural_close( &st_ivas->hBinRendererTd ); - } - - if ( st_ivas->hHrtfTD != NULL ) - { - st_ivas->hHrtfTD = NULL; - } + ivas_td_binaural_close( &st_ivas->hBinRendererTd ); + st_ivas->hHrtfTD = NULL; if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index fd7e728631..ad6980a7f9 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -337,15 +337,8 @@ ivas_error ivas_omasa_dec_config( else { /* TD renderer handle */ - if ( st_ivas->hBinRendererTd != NULL ) - { - ivas_td_binaural_close( &st_ivas->hBinRendererTd ); - } - - if ( st_ivas->hHrtfTD != NULL ) // ToDo: this is copied from ivas_ism_bitrate_switching() but a review is needed - { - st_ivas->hHrtfTD = NULL; - } + ivas_td_binaural_close( &st_ivas->hBinRendererTd ); + st_ivas->hHrtfTD = NULL; /* ISM renderer handle + ISM data handle */ ivas_omasa_separate_object_renderer_close( st_ivas ); diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 91e2b8b601..08c04f5d76 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -564,10 +564,7 @@ ivas_error ivas_sba_dec_reconfigure( if ( st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM == TRUE ) { ivas_td_binaural_close( &st_ivas->hBinRendererTd ); - if ( st_ivas->hHrtfTD != NULL ) - { - st_ivas->hHrtfTD = NULL; - } + st_ivas->hHrtfTD = NULL; } } nchan_transport_old += st_ivas->nchan_ism; -- GitLab From 3251fe8dff745e017046740d8f177aa4fc198da8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Oct 2023 12:03:58 +0200 Subject: [PATCH 07/16] revert a condition removal --- lib_dec/ivas_init_dec.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 68c7211989..65c8de48ed 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2699,9 +2699,11 @@ void ivas_destroy_dec( ivas_combined_orientation_close( &st_ivas->hCombinedOrientationData ); /* Time Domain binaural renderer handle */ - ivas_td_binaural_close( &st_ivas->hBinRendererTd ); - - if ( st_ivas->hHrtfTD != NULL ) + if ( st_ivas->hBinRendererTd != NULL ) + { + ivas_td_binaural_close( &st_ivas->hBinRendererTd ); + } + else if ( st_ivas->hHrtfTD != NULL ) { BSplineModelEvalDealloc( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval ); -- GitLab From 8f730369c77c35602592eea1585192006795c147 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 4 Oct 2023 08:45:28 +0200 Subject: [PATCH 08/16] rename IVAS_ENC_INPUT_FORMAT member --- lib_enc/lib_enc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index a22a2e40ca..6108342a1f 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -52,7 +52,7 @@ typedef enum _IVAS_ENC_INPUT_FORMAT IVAS_ENC_INPUT_MC, IVAS_ENC_INPUT_MASA_ISM, IVAS_ENC_INPUT_SBA_ISM, - IVAS_DEC_INPUT_UNKNOWN = 0xffff + IVAS_ENC_INPUT_UNKNOWN = 0xffff } IVAS_ENC_INPUT_FORMAT; typedef enum _IVAS_ENC_BANDWIDTH -- GitLab From c4c3f82b75cdd6149e0d8709f2bae4ccdd926ade Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 4 Oct 2023 08:48:10 +0200 Subject: [PATCH 09/16] remove outdated comments --- lib_com/ivas_rom_com.c | 42 ++++++++++++++++++++--------------------- lib_com/ivas_spar_com.c | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 06232fe64e..50892fcf53 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -887,63 +887,63 @@ const ivas_spar_br_table_t ivas_spar_br_table_consts[IVAS_SPAR_BR_TABLE_LEN] = { /* When AGC is ON additional (AGC_BITS_PER_CH+1) bits may be taken from each core-coder channel so minimum core-coder bitrate per channel can be min core-coder bitrates as per the table - AGC_BITS_PER_CH */ - { 13200, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 10000, 8150, 13150 } }, + { 13200, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 10000, 8150, 13150 } }, { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, - { 16400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 13200, 11350, 16350 } }, - { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, + { 16400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 13200, 11350, 16350 } }, + { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, - { 24400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0,{ { 16400, 14850, 24350 } }, + { 24400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 16400, 14850, 24350 } }, { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, - { 32000, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0,{ { 24000, 20450, 31950 } }, + { 32000, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 24000, 20450, 31950 } }, { { 21, 1, 5, 1 },{ 15, 1, 5, 1 },{ 15, 1, 3, 1 } }, 0, 0, 0 }, - { 48000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0,{ { 24000, 21000, 31950 },{ 16000, 15000, 20400 } }, + { 48000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0, { { 24000, 21000, 31950 },{ 16000, 15000, 20400 } }, { { 15, 7, 5, 1 },{ 15, 7, 3, 1 },{ 7, 7, 3, 1 } }, 1, 0, 0 }, - { 64000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0,{ { 38000, 34050, 56000 },{ 16000, 15600, 20400 } },{ { 21, 7, 5, 1 },{ 15, 7, 5, 1 },{ 15, 7, 3, 1 } }, 1, 1, 0 }, + { 64000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0, { { 38000, 34050, 56000 },{ 16000, 15600, 20400 } },{ { 21, 7, 5, 1 },{ 15, 7, 5, 1 },{ 15, 7, 3, 1 } }, 1, 1, 0 }, - { 80000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0,{ { 46000, 43000, 56000 },{ 24000, 23000, 31950 } }, + { 80000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0, { { 46000, 43000, 56000 },{ 24000, 23000, 31950 } }, { { 21, 7, 5, 1 },{ 15, 7, 5, 1 },{ 15, 7, 3, 1 } }, 1, 0, 0 }, - { 96000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0,{ { 47000, 42600, 56000 },{ 23000, 22600, 31950 },{ 16000, 15600, 20400 } }, + { 96000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 47000, 42600, 56000 },{ 23000, 22600, 31950 },{ 16000, 15600, 20400 } }, { { 21, 9, 9, 1 },{ 21, 7, 5, 1 },{ 21, 7, 5, 1 } }, 1, 0, 0 }, - { 128000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0,{ { 55000, 50000, 56000 },{ 36000, 36000, 56000 },{ 27000, 27000, 31950 } }, + { 128000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 55000, 50000, 56000 },{ 36000, 36000, 56000 },{ 27000, 27000, 31950 } }, { { 21, 11, 9, 1 },{ 21, 9, 7, 1 },{ 21, 7, 7, 1 } }, 1, 0, 0 }, - { 160000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0,{ { 74000, 70900, 112000 },{ 41000, 40050, 56000 },{ 35000, 34050, 56000 } }, + { 160000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 74000, 70900, 112000 },{ 41000, 40050, 56000 },{ 35000, 34050, 56000 } }, { { 21, 11, 11, 1 },{ 21, 9, 9, 1 },{ 21, 7, 7, 1 } }, 1, 0, 0 }, - { 192000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0,{ { 90000, 87900, 112000 },{ 50000, 48050, 56000 },{ 42000, 41050, 56000 } }, + { 192000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 90000, 87900, 112000 },{ 50000, 48050, 56000 },{ 42000, 41050, 56000 } }, { { 21, 11, 11, 1 },{ 21, 9, 9, 1 },{ 21, 7, 7, 1 } }, 1, 0, 0 }, - { 256000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 90000, 85000, 112000 },{ 70000, 69000, 112000 },{ 50000, 48950, 56000 },{ 36400, 35600, 56000 } }, + { 256000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 90000, 85000, 112000 },{ 70000, 69000, 112000 },{ 50000, 48950, 56000 },{ 36400, 35600, 56000 } }, { { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - { 256000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 84650, 83000, 112000 },{ 65850, 64550, 56000 },{ 47000, 46100, 48000 },{ 28200, 27650, 40000 } }, + { 256000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 84650, 83000, 112000 },{ 65850, 64550, 56000 },{ 47000, 46100, 48000 },{ 28200, 27650, 40000 } }, { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - { 256000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 76300, 73550, 112000 },{ 59350, 57200, 56000 },{ 42400, 40850, 48000 },{ 25450, 24500, 40000 } }, + { 256000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 76300, 73550, 112000 },{ 59350, 57200, 56000 },{ 42400, 40850, 48000 },{ 25450, 24500, 40000 } }, { { 31, 11, 11, 1 },{ 1, 1, 1, 1 }, { 1, 1, 1, 1 } }, 1, 2, 0 }, - { 384000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 100000, 100000, 128000 },{ 79850, 79850, 104000 },{ 66600, 66600, 104000 } }, // not yet optimized + { 384000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 128000, 128000, 128000 },{ 100000, 100000, 128000 },{ 79850, 79850, 104000 },{ 66600, 66600, 104000 } }, { { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - { 384000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 105350, 103300, 112000 },{ 75200, 73750, 96000 },{ 45100, 44250, 48000 } }, // just added as a place holder, not necessarily operational + { 384000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 128000, 128000, 128000 },{ 105350, 103300, 112000 },{ 75200, 73750, 96000 },{ 45100, 44250, 48000 } }, { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - { 384000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 124300, 121550, 128000 },{ 96700, 94550, 112000 },{ 69050, 67500, 96000 },{ 41450, 40500, 48000 } }, // just added as a place holder, not necessarily operational + { 384000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 124300, 121550, 128000 },{ 96700, 94550, 112000 },{ 69050, 67500, 96000 },{ 41450, 40500, 48000 } }, { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - { 512000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 128000, 128000, 128000 }, {118450, 118450, 128000 } }, // not yet optimized + { 512000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 128000, 128000, 128000 }, {118450, 118450, 128000 } }, { { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - { 512000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 124000, 124000, 128000 },{ 124000, 124000, 128000 },{ 125200, 118450, 128000 },{ 76300, 73000, 128000 } }, // not yet optimized + { 512000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 124000, 124000, 128000 },{ 124000, 124000, 128000 },{ 125200, 118450, 128000 },{ 76300, 73000, 128000 } }, { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - { 512000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 118000, 118000, 128000 },{ 118000, 118000, 128000 },{ 117200, 109250, 128000 },{ 72300, 69000, 128000 } }, // not yet optimized + { 512000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 118000, 118000, 128000 },{ 118000, 118000, 128000 },{ 117200, 109250, 128000 },{ 72300, 69000, 128000 } }, { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, }; diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index d2ad98012f..aaaa1ce087 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -952,7 +952,7 @@ static void ivas_calc_p_coeffs_per_band( { if ( i == j ) { - pSparMd->band_coeffs[b_ts_idx].P_re[j - num_dmx] = cov_uu_re[i - num_dmx][j - num_dmx]; // can optimise here + pSparMd->band_coeffs[b_ts_idx].P_re[j - num_dmx] = cov_uu_re[i - num_dmx][j - num_dmx]; } } } -- GitLab From 7e298a5abc98cdc00d35b641e9e4b68324869024 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 4 Oct 2023 09:25:02 +0200 Subject: [PATCH 10/16] rename IVAS_ENC_CICP_UNDEFINED -> IVAS_ENC_MC_UNDEFINED --- lib_enc/lib_enc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 6108342a1f..13399ba0ca 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -86,7 +86,7 @@ typedef enum _IVAS_ENC_MC_LAYOUT IVAS_ENC_MC_5_1_2 = 14, IVAS_ENC_MC_5_1_4 = 16, IVAS_ENC_MC_7_1_4 = 19, - IVAS_ENC_CICP_UNDEFINED = 0xffff + IVAS_ENC_MC_UNDEFINED = 0xffff } IVAS_ENC_MC_LAYOUT; typedef enum _IVAS_ENC_MASA_VARIANT -- GitLab From a15eb53368ffb9936a0d6fa288141ffd106f5b9b Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 4 Oct 2023 10:56:51 +0200 Subject: [PATCH 11/16] formatting --- apps/decoder.c | 19 ++++++++----------- apps/encoder.c | 9 ++------- lib_rend/ivas_stat_rend.h | 16 ++++++++-------- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 4efc1dac91..aa0104b952 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -149,6 +149,7 @@ typedef struct int16_t Opt_dpid_on; #endif uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS]; + } DecArguments; @@ -157,22 +158,16 @@ typedef struct *------------------------------------------------------------------------------------------*/ static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); - static void usage_dec( void ); - #ifdef SPLIT_REND_WITH_HEAD_ROT static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, uint8_t *splitRendBitsBuf, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); #else static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); #endif - static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); - #ifdef DEBUGGING static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); - static int16_t app_own_random( int16_t *seed ); - static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( char *forcedRendModeChar ); #endif @@ -188,6 +183,13 @@ int main( { bool mainFailed = true; /* Assume main failed until cleanup is reached without errors */ DecArguments arg; + ivas_error error = IVAS_ERR_UNKNOWN; + int16_t pcmBuf[MAX_OUTPUT_PCM_BUFFER_SIZE]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + uint8_t splitRendBitsBuf[IVAS_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES]; +#endif + + /* Any handles that require cleanup must be declared here and initialized to NULL */ IVAS_DEC_HANDLE hIvasDec = NULL; BS_READER_HANDLE hBsReader = NULL; LsCustomFileReader *hLsCustomReader = NULL; @@ -196,11 +198,6 @@ int main( RotFileReader *externalOrientationFileReader = NULL; RotFileReader *refRotReader = NULL; Vector3PairFileReader *referenceVectorReader = NULL; - ivas_error error = IVAS_ERR_UNKNOWN; - int16_t pcmBuf[MAX_OUTPUT_PCM_BUFFER_SIZE]; -#ifdef SPLIT_REND_WITH_HEAD_ROT - uint8_t splitRendBitsBuf[IVAS_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES]; -#endif RenderConfigReader *renderConfigReader = NULL; #ifdef DEBUGGING int32_t noClipping; diff --git a/apps/encoder.c b/apps/encoder.c index e13297b987..9229cc6414 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -131,7 +131,6 @@ typedef struct const char *ca_config_file; bool mimeOutput; IVAS_ENC_COMPLEXITY_LEVEL complexityLevel; - #ifdef DEBUGGING IVAS_ENC_FORCED_MODE forcedMode; const char *forcedModeFile; @@ -178,7 +177,7 @@ int main( { bool mainFailed = true; /* Assume main failed until cleanup is reached without errors */ EncArguments arg; - int16_t i = 0; + int16_t i; ivas_error error = IVAS_ERR_UNKNOWN; /* Any handles that require cleanup must be declared here and initialized to NULL */ @@ -189,11 +188,7 @@ int main( FILE *f_bwProfile = NULL; JbmFileReader *jbmReader = NULL; MasaFileReader *masaReader = NULL; - IsmFileReader *ismReaders[IVAS_MAX_NUM_OBJECTS]; - for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) - { - ismReaders[i] = NULL; - } + IsmFileReader *ismReaders[IVAS_MAX_NUM_OBJECTS] = { NULL, NULL, NULL, NULL }; int16_t *pcmBuf = NULL; #ifdef DEBUGGING FILE *f_forcedModeProfile = NULL; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index d1a19e6317..c29679ba3d 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -668,6 +668,7 @@ typedef struct ivas_external_orientation_struct int16_t numFramesToTargetOrientation[MAX_PARAM_SPATIAL_SUBFRAMES]; /* Number of frames until target orientation is reached */ IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES]; /* External orientation in quaternions */ int16_t num_subframes; + } EXTERNAL_ORIENTATION_DATA, *EXTERNAL_ORIENTATION_HANDLE; /*----------------------------------------------------------------------------------* @@ -706,6 +707,7 @@ typedef struct ivas_combined_orientation_struct int8_t isExtOrientationFrozen; int8_t isHeadRotationFrozen; int16_t num_subframes; + } COMBINED_ORIENTATION_DATA, *COMBINED_ORIENTATION_HANDLE; @@ -829,8 +831,8 @@ typedef struct float soundspeed; float air_coeff; shoebox_config_t cal; -} shoebox_obj_t; +} shoebox_obj_t; typedef struct shoebox_data_t { @@ -839,7 +841,6 @@ typedef struct shoebox_data_t } shoebox_data_t; - typedef struct { uint16_t n_sources; @@ -851,6 +852,7 @@ typedef struct } shoebox_output_t; + /*----------------------------------------------------------------------------------* * Reflections structure *----------------------------------------------------------------------------------*/ @@ -1072,8 +1074,8 @@ typedef struct TDREND_SRC_REND_s float SrcGainMax_p[SPAT_BIN_MAX_INPUT_CHANNELS]; float DirGain_p[SPAT_BIN_MAX_INPUT_CHANNELS]; float DistGain_p[SPAT_BIN_MAX_INPUT_CHANNELS]; -} TDREND_SRC_REND_t; +} TDREND_SRC_REND_t; /* Source spatial parameters */ typedef struct @@ -1106,6 +1108,7 @@ typedef struct float mem_hrf_right[SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1]; float Gain; float prevGain; + } TDREND_SRC_t; /* Top level TD binaural renderer handle */ @@ -1224,7 +1227,7 @@ typedef struct ivas_binaural_rendering_struct #endif /*------------------------------------------------------------------------------------------* - * HRTF structures - htrfs from binary files + * HRTF structures - hrtfs from binary files *------------------------------------------------------------------------------------------*/ typedef struct ivas_hrtfs_crend_structure @@ -1237,9 +1240,7 @@ typedef struct ivas_hrtfs_crend_structure } HRTFS_CREND, *HRTFS_CREND_HANDLE; - /* Fastconv binaural data structure */ - typedef struct ivas_hrtfs_fastconv_struct { float FASTCONV_HOA3_latency_s; @@ -1279,7 +1280,6 @@ typedef struct ivas_hrtfs_fastconv_struct } HRTFS_FASTCONV, *HRTFS_FASTCONV_HANDLE; - typedef struct ivas_hrtfs_parambin_struct { float hrtfShCoeffsRe[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; @@ -1523,7 +1523,6 @@ typedef struct ivas_LS_setupconversion_struct } LSSETUP_CONVERSION_STRUCT, *LSSETUP_CONVERSION_HANDLE; - typedef struct ivas_LS_setupconversion_matrix { int16_t index; @@ -1578,6 +1577,7 @@ typedef struct int32_t binaural_latency_ns; BINAURAL_RENDERER_HANDLE hCldfbRend; HRTFS_FASTCONV_HANDLE hHrtfFastConv; + } CLDFB_REND_WRAPPER; #endif -- GitLab From cc3c125de73ff8fb681f558822ab1f5b8ab17f88 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 4 Oct 2023 12:11:33 +0200 Subject: [PATCH 12/16] remove unused IVAS_ERR_INVALID_SPAR_CONFIG error code --- lib_com/ivas_error.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index 48bbde5e2a..55d9e30bbf 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -68,7 +68,6 @@ typedef enum IVAS_ERR_DTX_NOT_SUPPORTED, IVAS_ERR_UNEXPECTED_NULL_POINTER, IVAS_ERR_METADATA_NOT_EXPECTED, - IVAS_ERR_INVALID_SPAR_CONFIG, IVAS_ERR_WRONG_PARAMS, IVAS_ERR_INIT_ERROR, IVAS_ERR_WRONG_MODE, @@ -82,7 +81,6 @@ typedef enum IVAS_ERR_INVALID_HRTF, IVAS_ERR_INVALID_INPUT_FORMAT, IVAS_ERR_INVALID_INDEX, - IVAS_ERR_NOT_SUPPORTED_OPTION, IVAS_ERR_NOT_IMPLEMENTED, IVAS_ERR_WAITING_FOR_BITSTREAM, @@ -135,7 +133,6 @@ typedef enum /*----------------------------------------* * renderer (lib_rend only) * *----------------------------------------*/ - IVAS_ERR_NUM_CHANNELS_UNKNOWN = 0x6000, IVAS_ERR_INVALID_CUSTOM_LS_LAYOUT, IVAS_ERR_INVALID_INPUT_ID, -- GitLab From 0863e11be4a677235b1d2e70157dc9d4b9532654 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 4 Oct 2023 18:02:10 +0200 Subject: [PATCH 13/16] clang-format --- lib_rend/lib_rend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 6f4152fe69..37ed26f635 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -8827,7 +8827,7 @@ static ivas_error getSamplesInternal( convertBitsBufferToInternalBitsBuff( *hBits, &bits ); if ( ( error = ivas_renderMultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From c1a7b6bf5e0f1b9d16ac493e52384243b3c9d7c9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 4 Oct 2023 19:38:03 +0200 Subject: [PATCH 14/16] formatting in PCA --- lib_dec/ivas_pca_dec.c | 4 ++-- lib_enc/ivas_pca_enc.c | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lib_dec/ivas_pca_dec.c b/lib_dec/ivas_pca_dec.c index 8dbbbded04..fc7c214b11 100644 --- a/lib_dec/ivas_pca_dec.c +++ b/lib_dec/ivas_pca_dec.c @@ -260,8 +260,9 @@ void ivas_pca_dec( return; } +#ifdef DEBUGGING assert( ivas_total_brate == PCA_BRATE ); /* the remaining code is defined at 256k where there are 4 dmx channel */ - +#endif if ( !bfi ) { /* set PCA by-pass mode indicator */ @@ -312,6 +313,5 @@ void ivas_pca_dec( pca_dec_update_dquat( hPCA, ql, qr ); hPCA->prev_pca_bypass = 0; - return; } diff --git a/lib_enc/ivas_pca_enc.c b/lib_enc/ivas_pca_enc.c index 8ecac8d208..f8b4c8e9a6 100644 --- a/lib_enc/ivas_pca_enc.c +++ b/lib_enc/ivas_pca_enc.c @@ -139,19 +139,17 @@ static void pca_enc_transform( quat_shortestpath( hPCA->prev_ql, ql, hPCA->prev_qr, qr ); - pca_interp_preproc( hPCA->prev_ql, hPCA->prev_qr, ql, qr, IVAS_PCA_N_SLOTS, ql_interp, qr_interp ); slot_len = (int16_t) ( input_frame / IVAS_PCA_N_SLOTS ); + for ( time_slot = 0; time_slot < IVAS_PCA_N_SLOTS; time_slot++ ) { /* convert from double quaternion to 4D matrix */ - dquat2mat( &ql_interp[IVAS_PCA_INTERP * time_slot], &qr_interp[IVAS_PCA_INTERP * time_slot], - eigVec_interp ); + dquat2mat( &ql_interp[IVAS_PCA_INTERP * time_slot], &qr_interp[IVAS_PCA_INTERP * time_slot], eigVec_interp ); pca_transform_sub( eigVec_interp, transformed_data, slot_len * time_slot, slot_len, n_channels ); } - return; } @@ -307,7 +305,6 @@ void ivas_pca_enc( return; } - /* handle bitrate switching */ if ( ivas_total_brate != PCA_BRATE ) { @@ -319,6 +316,7 @@ void ivas_pca_enc( /* copy input data into output directly as previous frame was already in by-pass mode */ for ( k = 0; k < n_channels; k++ ) { + // ToDo: TBV } } else @@ -334,8 +332,9 @@ void ivas_pca_enc( return; } +#ifdef DEBUGGING assert( ivas_total_brate == PCA_BRATE ); /* the remaining code is defined at 256k where there are 4 dmx channel */ - +#endif /*-----------------------------------------------------------------* * Covariance *-----------------------------------------------------------------*/ @@ -510,14 +509,22 @@ void ivas_pca_enc( dotl = dotp( hPCA->prev_ql, ql, 4 ); dotr = dotp( hPCA->prev_qr, qr, 4 ); if ( dotl < dotr ) + { min_dot = dotl; + } else + { min_dot = dotr; + } if ( ql[0] < qr[0] ) + { min_dot2 = ql[0]; + } else + { min_dot2 = qr[0]; + } bypass_decision = PCA_MODE_ACTIVE; if ( dist_alt < IVAS_PCA_THRES_DIST_ALT ) @@ -556,6 +563,7 @@ void ivas_pca_enc( pca_update_state( hPCA, ql, qr, eigVec, n_channels ); hPCA->prev_bypass_decision = PCA_MODE_INACTIVE; + return; } @@ -589,6 +597,5 @@ void ivas_pca_enc( hPCA->prev_bypass_decision = bypass_decision; pca_update_state( hPCA, ql, qr, eigVec, n_channels ); - return; } -- GitLab From 6eba8b437d118c16eb9021af192bf897c8a4f049 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 4 Oct 2023 19:45:19 +0200 Subject: [PATCH 15/16] remove outdated TODO comments --- apps/decoder.c | 1 - lib_dec/ivas_binRenderer_internal.c | 2 +- lib_dec/ivas_sba_dec.c | 2 +- lib_enc/core_switching_enc.c | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 598ce3352a..455087d713 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2430,7 +2430,6 @@ static ivas_error decodeG192( #ifdef WMOPS if ( vec_pos_update == 0 ) { - // update_mem(); TODO: verify this update_wmops(); update_mem(); #ifdef MEM_COUNT_DETAILS diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index cbea8dd016..842b147698 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1995,8 +1995,8 @@ void ivas_binRenderer( Quaternions_abs.y = Quaternions_abs.y + Quaternions_rel.y; Quaternions_abs.z = Quaternions_abs.z + Quaternions_rel.z; - QuatToRotMat( Quaternions_rel, Rmat_local ); + if ( hBinRenderer->hInputSetup->is_loudspeaker_setup ) { rotateFrame_sd_cldfb( Rmat_local, RealBuffer, ImagBuffer, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 863a69a1b4..0b0b5a8125 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -267,7 +267,7 @@ ivas_error ivas_sba_dec_reconfigure( if ( ism_mode_old != ISM_SBA_MODE_DISC ) #endif { - if ( st_ivas->hDirAC == NULL && st_ivas->hSpar != NULL ) // ToDo; this never happens + if ( st_ivas->hDirAC == NULL && st_ivas->hSpar != NULL ) { st_ivas->hTcBuffer->num_slots = st_ivas->hSpar->num_slots; st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpar->nb_subframes; diff --git a/lib_enc/core_switching_enc.c b/lib_enc/core_switching_enc.c index 2b16b49d46..e964f33c08 100644 --- a/lib_enc/core_switching_enc.c +++ b/lib_enc/core_switching_enc.c @@ -258,7 +258,7 @@ void core_switching_pre_enc( /* reset BWE memories */ if ( st->hBWE_TD != NULL ) { - set_f( st->hBWE_FD->old_syn_12k8_16k, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); /* TODO - TBV: this might not be needed */ + set_f( st->hBWE_FD->old_syn_12k8_16k, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); } } -- GitLab From 439a50969b27697dfece43356d0732be08499426 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 10 Oct 2023 15:36:54 +0200 Subject: [PATCH 16/16] maintenance --- lib_com/options.h | 5 ++++- lib_dec/ivas_ism_renderer.c | 8 ++------ lib_dec/ivas_mc_paramupmix_dec.c | 2 -- lib_enc/ivas_cpe_enc.c | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 73464a5c15..41ed34b2f7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -168,7 +168,7 @@ /* #################### End BE switches ################################## */ -#define BE_FIX_832_ASAN_ERROR_EFAP_OSBA /* FhG: issue #832: fix ASAN error caused by re-allocating EFAP memories in OSBA*/ + /* #################### Start NON-BE switches ############################ */ /* any switch which is non-be wrt selection floating point code */ @@ -187,6 +187,9 @@ #define NONBE_FIX_835_JBM_PARAMUPMIX_HEADROT /* FhG: issue #835: Resolve "JBM: ParamUpmix head rotation broken" */ #define NONBE_FIX_838_CRASH_24_4_WB /* FhG: Issue 838: fix encoder crashes for Unified Stereo and MASA 2 TC at 24.4 kbps WB due to missing IGF (re-) allocation */ #define NONBE_FIX_839_MC_RS_CHANNEL_ALLOC /* FhG: Issues #839: problems with reallocation of the channels on the heap in case of MC RS */ +#define BE_FIX_832_ASAN_ERROR_EFAP_OSBA /* FhG: issue #832: fix ASAN error caused by re-allocating EFAP memories in OSBA*/ + + /* ##################### End NON-BE switches ########################### */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 33c5c7183a..25167ac381 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -61,12 +61,11 @@ ivas_error ivas_ism_renderer_open( uint16_t init_interpolator_length; ivas_error error; - error = IVAS_ERR_OK; - if ( ( st_ivas->hIsmRendererData = (ISM_RENDERER_HANDLE) malloc( sizeof( ISM_RENDERER_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ISM renderer\n" ) ); } + #ifdef BE_FIX_832_ASAN_ERROR_EFAP_OSBA if ( st_ivas->hIntSetup.is_loudspeaker_setup && st_ivas->hIntSetup.ls_azimuth != NULL && st_ivas->hIntSetup.ls_elevation != NULL && st_ivas->hEFAPdata == NULL ) #else @@ -101,13 +100,12 @@ ivas_error ivas_ism_renderer_open( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ISM renderer interpolator\n" ) ); } - for ( i = 0; i < interpolator_length; i++ ) { st_ivas->hIsmRendererData->interpolator[i] = (float) i / ( (float) interpolator_length - 1 ); } - return error; + return IVAS_ERR_OK; } @@ -179,7 +177,6 @@ void ivas_ism_render( set_f( output_f[i], 0.0f, output_frame ); } - for ( i = 0; i < nchan_ism; i++ ) { if ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_STEREO ) @@ -287,7 +284,6 @@ void ivas_ism_render_sf( for ( i = 0; i < num_objects; i++ ) { - /* Combined rotation: rotate the object positions depending the head and external orientations */ if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) { diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 34b91006fe..ba20432e25 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -1166,7 +1166,6 @@ static void ivas_mc_paramupmix_dec_sf( } #endif -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hSplitBinRend.hCldfbDataOut != NULL ) { for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered]; slot_idx++ ) @@ -1180,7 +1179,6 @@ static void ivas_mc_paramupmix_dec_sf( st_ivas->hSplitBinRend.hCldfbDataOut->config = st_ivas->hIntSetup.output_config; } -#endif } #endif diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index b5d9d3cc6b..1eadfc77b4 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -111,7 +111,7 @@ ivas_error ivas_cpe_enc( int32_t cpe_brate; int32_t element_brate_ref; #ifdef NONBE_FIX_838_CRASH_24_4_WB - int16_t last_bits_frame_nominal; + int16_t last_bits_frame_nominal; /* last_bits_frame_nominal for M or PCh channel */ #endif error = IVAS_ERR_OK; -- GitLab