From 5364eb337b42d7e84517540a1cbe73c863723fba Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 17 May 2023 11:22:18 +0200 Subject: [PATCH 1/8] HO-DirAC/HO-MASA merge improvements --- lib_com/ivas_masa_com.c | 21 +++++++++++++++++---- lib_com/ivas_prot.h | 15 --------------- lib_dec/ivas_jbm_dec.c | 4 ++-- lib_enc/ivas_spar_encoder.c | 4 ++-- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/lib_com/ivas_masa_com.c b/lib_com/ivas_masa_com.c index 7c0955436d..6be68475c1 100644 --- a/lib_com/ivas_masa_com.c +++ b/lib_com/ivas_masa_com.c @@ -49,7 +49,20 @@ *---------------------------------------------------------------*/ #define MASA_EXTRA_BAND_META_BITS 40 -#define MASA_SMALL_INC_META_BITS 10 + +#define MASA_SMALL_INC_META_BITS 10 + + +#ifdef HR_METADATA +/*--------------------------------------------------------------- + * Local prototypes + *---------------------------------------------------------------*/ + +static int16_t quantize_theta_masa( float x, const int16_t no_cb, float *xhat ); + +static int16_t quantize_phi_masa( float phi, const int16_t flag_delta, float *phi_hat, const int16_t n ); + +#endif /*--------------------------------------------------------------- @@ -451,7 +464,7 @@ uint16_t index_theta_phi_16( sign_th = 1; } - id_th = quantize_theta( abs_theta, gridData->no_theta, &theta_hat ); + id_th = quantize_theta_masa( abs_theta, gridData->no_theta, &theta_hat ); if ( gridData->no_theta > 1 ) { if ( gridData->no_phi[id_th] > 1 ) @@ -519,7 +532,7 @@ uint16_t index_theta_phi_16( *------------------------------------------------------------------------*/ /*! r: output index */ -int16_t quantize_theta( +static int16_t quantize_theta_masa( float x, /* i : theta value to be quantized */ const int16_t no_cb, /* i : number of codewords */ float *xhat /* o : quantized value */ @@ -561,7 +574,7 @@ int16_t quantize_theta( *------------------------------------------------------------------------*/ /*! r: index azimuth */ -int16_t quantize_phi_masa( +static int16_t quantize_phi_masa( float phi, /* i : azimuth value */ const int16_t flag_delta, /* i : flag indicating if the azimuth codebook is translated or not */ float *phi_hat, /* o : quantized azimuth */ diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 5d4faf0eb0..1766c64cf6 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3135,21 +3135,6 @@ uint16_t index_theta_phi_16( float * p_phi, /* i/o: input azimuth to be indexed */ const SPHERICAL_GRID_DATA *gridData /* i : generated grid data */ ); - -/*! r: output index */ -int16_t quantize_theta( - float x, /* i : theta value to be quantized */ - const int16_t no_cb, /* i : number of codewords */ - float *xhat /* o : quantized value */ -); - -/*! r: index azimuth */ -int16_t quantize_phi_masa( - float phi, /* i : azimuth value */ - const int16_t flag_delta, /* i : flag indicating if the azimuth codebook is translated or not */ - float *phi_hat, /* o : quantized azimuth */ - const int16_t n /* i : azimuth codebook size */ -); #endif void reset_metadata_spatial( diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index f33a5e01e6..6c32c6bc88 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -192,7 +192,7 @@ ivas_error ivas_jbm_dec_tc( { ivas_dirac_dec_read_BS( ivas_total_brate, st, st_ivas->hDirAC, st_ivas->hQMetaData, &nb_bits_metadata[0], st_ivas->sba_mode, #ifdef HODIRAC - st_ivas->sba_analysis_order > 1 && ivas_total_brate > IVAS_256k, + ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ), #endif 0 ); } @@ -217,7 +217,7 @@ ivas_error ivas_jbm_dec_tc( &nb_bits_metadata[0], st_ivas->sba_mode, #ifdef HODIRAC - st_ivas->sba_analysis_order > 1 && ivas_total_brate > IVAS_256k, + ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ), #endif st_ivas->hSpar->dirac_to_spar_md_bands ); } diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index a7c359b7c9..3d6280fcf9 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -609,8 +609,8 @@ static ivas_error ivas_spar_enc_process( ivas_dirac_param_est_enc( st_ivas->hDirAC, hQMetaData->q_direction, hQMetaData->useLowerRes, data_f, ppIn_FR_real, ppIn_FR_imag, input_frame, st_ivas->sba_mode #ifdef HODIRAC , - st_ivas->sba_analysis_order > 1 && ivas_total_brate > IVAS_256k, - st_ivas->sba_analysis_order > 1 && ivas_total_brate > IVAS_256k ? HOA2_CHANNELS : FOA_CHANNELS + ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ), + ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? HOA2_CHANNELS : FOA_CHANNELS #endif ); -- GitLab From b4912c8d602b2ecaabeeb19120ff165ddebca974 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 17 May 2023 16:33:38 +0200 Subject: [PATCH 2/8] introduce "hodirac_flag" in functions with multiple calls of ivas_get_hodirac_flag() --- lib_dec/ivas_dirac_dec.c | 3 +-- lib_dec/ivas_jbm_dec.c | 10 ++++++++-- lib_enc/ivas_spar_encoder.c | 15 ++++++++++----- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 2801c9c146..0921137856 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -295,7 +295,6 @@ ivas_error ivas_dirac_dec_config( hodirac_flag = ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ); #endif - if ( flag_config == DIRAC_RECONFIGURE ) { hDirAC = st_ivas->hDirAC; @@ -528,7 +527,7 @@ ivas_error ivas_dirac_dec_config( if ( nchan_transport_orig > 2 && hDirAC->hOutSetup.is_loudspeaker_setup && st_ivas->renderer_type == RENDERER_DIRAC #ifdef FIX_DIRAC_LS_SYNTHESIS_CONFIG - && !ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) + && !hodirac_flag #endif ) { diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 6c32c6bc88..c94ef4e667 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -69,6 +69,9 @@ ivas_error ivas_jbm_dec_tc( Decoder_State *st; /* used for bitstream handling */ float output[MAX_TRANSPORT_CHANNELS][L_FRAME48k]; /* 'float' buffer for transport channels, MAX_TRANSPORT_CHANNELS channels */ /* IVAS_fmToDo: buffer can be allocated dynamically based on the actual number of output channels */ int16_t nchan_remapped; +#ifdef HODIRAC + int16_t hodirac_flag; +#endif float output_lfe_ch[L_FRAME48k]; int16_t nb_bits_metadata[MAX_SCE]; int32_t output_Fs, ivas_total_brate; @@ -88,6 +91,9 @@ ivas_error ivas_jbm_dec_tc( nchan_out = st_ivas->hTcBuffer->nchan_transport_jbm; output_config = st_ivas->hDecoderConfig->output_config; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; +#ifdef HODIRAC + hodirac_flag = ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ); +#endif output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); @@ -192,7 +198,7 @@ ivas_error ivas_jbm_dec_tc( { ivas_dirac_dec_read_BS( ivas_total_brate, st, st_ivas->hDirAC, st_ivas->hQMetaData, &nb_bits_metadata[0], st_ivas->sba_mode, #ifdef HODIRAC - ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ), + hodirac_flag, #endif 0 ); } @@ -217,7 +223,7 @@ ivas_error ivas_jbm_dec_tc( &nb_bits_metadata[0], st_ivas->sba_mode, #ifdef HODIRAC - ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ), + hodirac_flag, #endif st_ivas->hSpar->dirac_to_spar_md_bands ); } diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 3d6280fcf9..fa3350aee1 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -429,10 +429,11 @@ static ivas_error ivas_spar_enc_process( float pcm_tmp[IVAS_SPAR_MAX_CH][L_FRAME48k * 2]; float *p_pcm_tmp[IVAS_SPAR_MAX_CH]; #endif - int16_t i, j, b, i_ts, input_frame, dtx_vad; int16_t transient_det[2]; - +#ifdef HODIRAC + int16_t hodirac_flag; +#endif int32_t ivas_total_brate, input_Fs; float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; float *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; @@ -605,12 +606,16 @@ static ivas_error ivas_spar_enc_process( /*-----------------------------------------------------------------------------------------* * DirAC encoding *-----------------------------------------------------------------------------------------*/ + /*tyagiri: TODO: HODIRAC should be disabled for 256 kbps and outputs should be BE w.r.t baseline*/ +#ifdef HODIRAC + hodirac_flag = ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ); +#endif + ivas_dirac_param_est_enc( st_ivas->hDirAC, hQMetaData->q_direction, hQMetaData->useLowerRes, data_f, ppIn_FR_real, ppIn_FR_imag, input_frame, st_ivas->sba_mode #ifdef HODIRAC , - ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ), - ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? HOA2_CHANNELS : FOA_CHANNELS + hodirac_flag, hodirac_flag ? HOA2_CHANNELS : FOA_CHANNELS #endif ); @@ -626,7 +631,7 @@ static ivas_error ivas_spar_enc_process( ivas_qmetadata_enc_encode( hMetaData, hQMetaData #ifdef HODIRAC , - ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) + hodirac_flag #endif ); } -- GitLab From acf5cd1517be2ab0d2a76eba4b84a3a5a9998ba0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 18 May 2023 12:12:34 +0200 Subject: [PATCH 3/8] remove outdated "tyagiri: TODO" comment --- lib_enc/ivas_spar_encoder.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index fa3350aee1..954995d10e 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -607,7 +607,6 @@ static ivas_error ivas_spar_enc_process( * DirAC encoding *-----------------------------------------------------------------------------------------*/ - /*tyagiri: TODO: HODIRAC should be disabled for 256 kbps and outputs should be BE w.r.t baseline*/ #ifdef HODIRAC hodirac_flag = ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ); #endif -- GitLab From 15941b5ce80cbd1f50ebc89defd01ddaa510ddbb Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 22 May 2023 10:42:37 +0200 Subject: [PATCH 4/8] fix compilation when DEBUGGING is deactivated --- lib_com/ivas_dirac_com.c | 7 ----- lib_com/ivas_prot.h | 56 +++++++++++++++++++--------------------- lib_enc/ivas_dirac_enc.c | 6 +++-- 3 files changed, 31 insertions(+), 38 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 7d11a0427d..d876c557ba 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -949,7 +949,6 @@ void deindex_spherical_component( void calculate_hodirac_sector_parameters( float RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : signal vector (L+1)^2 x N_bins, real part */ float ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : signal vector, imaginary part */ - const int16_t N_bins, /* i : number of bins */ const float beta, /* i : forgetting factor for average filtering */ const int16_t *band_grouping, /* i : indices of band groups */ const int16_t N_bands, /* i : number of bands (groups) */ @@ -961,9 +960,7 @@ void calculate_hodirac_sector_parameters( ) { int16_t i_sec, i_bin, i_band; - float p_real, p_imag, normI, energy, tmp_diff; - float sec_I_vec_x[NUM_ANA_SECTORS]; float sec_I_vec_y[NUM_ANA_SECTORS]; float sec_I_vec_z[NUM_ANA_SECTORS]; @@ -978,10 +975,6 @@ void calculate_hodirac_sector_parameters( static float azi_prev[NUM_ANA_SECTORS * IVAS_MAX_NUM_BANDS]; static float ele_prev[NUM_ANA_SECTORS * IVAS_MAX_NUM_BANDS]; -#ifdef DEBUGGING - assert( N_bins <= DIRAC_NO_FB_BANDS_MAX ); -#endif - for ( i_sec = 0; i_sec < NUM_ANA_SECTORS; i_sec++ ) { diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 9d8f3d0ae9..e7a723b607 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3894,9 +3894,8 @@ void ivas_dirac_dec_compute_directional_responses( const int16_t md_idx, #endif const float *surCohRatio, - const int16_t shd_rot_max_order, /* i : split-order rotation method */ - const float *p_Rmat /* i : rotation matrix */ - , + const int16_t shd_rot_max_order, /* i : split-order rotation method */ + const float *p_Rmat, /* i : rotation matrix */ const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ ); @@ -3906,38 +3905,37 @@ void ivas_dirac_dec_get_frequency_axis( const int16_t num_freq_bands ); /* i : number of frequency bands */ void calculate_hodirac_sector_parameters( - float RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : signal vector (L+1)^2 x N_bins, real part */ - float ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : signal vector, imaginary part */ - const int16_t N_bins, /* i : number of bins */ - const float beta, /* i : forgetting factor for average filtering */ - const int16_t *band_grouping, /* i : indices of band groups */ - const int16_t N_bands, /* i : number of bands (groups) */ - const int16_t enc_param_start_band, /* i : first band to process */ - float *azi, /* o : array of sector azimuth angles, flat */ - float *ele, /* o : array of sector elevation angles, flat */ - float *diff, /* o : array of sector diffuseness values, flat */ - float *ene /* o : array of sector energy values, flat */ + float RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX],/* i : signal vector (L+1)^2 x N_bins, real part */ + float ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX],/* i : signal vector, imaginary part */ + const float beta, /* i : forgetting factor for average filtering */ + const int16_t *band_grouping, /* i : indices of band groups */ + const int16_t N_bands, /* i : number of bands (groups) */ + const int16_t enc_param_start_band, /* i : first band to process */ + float *azi, /* o : array of sector azimuth angles, flat */ + float *ele, /* o : array of sector elevation angles, flat */ + float *diff, /* o : array of sector diffuseness values, flat */ + float *ene /* o : array of sector energy values, flat */ ); void ivas_mc_paramupmix_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */ - BSTR_ENC_HANDLE hMetaData, /* i/o: IVAS Metadata bitstream handle */ - float data_f[][L_FRAME48k], /* i/o: input: CICP6, CICP12, CICP14, CICP16 or CICP19 MC data */ - const int16_t input_frame /* i : input frame length */ + Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */ + BSTR_ENC_HANDLE hMetaData, /* i/o: IVAS Metadata bitstream handle */ + float data_f[][L_FRAME48k], /* i/o: input: CICP6, CICP12, CICP14, CICP16 or CICP19 MC data */ + const int16_t input_frame /* i : input frame length */ ); ivas_error ivas_mc_paramupmix_enc_open( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ + Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ); void ivas_mc_paramupmix_enc_close( - MC_PARAMUPMIX_ENC_HANDLE *hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */ + MC_PARAMUPMIX_ENC_HANDLE *hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */ const int32_t sampling_rate ); void ivas_mc_paramupmix_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float output_f[][L_FRAME48k] /* i/o: synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + float output_f[][L_FRAME48k] /* i/o: synthesized core-coder transport channels/DirAC output */ ); int16_t ivas_mc_paramupmix_getNumTransportChannels( @@ -3945,19 +3943,19 @@ int16_t ivas_mc_paramupmix_getNumTransportChannels( ); ivas_error ivas_mc_paramupmix_dec_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); void ivas_mc_paramupmix_dec_close( - MC_PARAMUPMIX_DEC_HANDLE *hMCParamUpmix_out /* i/o: Parametric MC decoder handle */ + MC_PARAMUPMIX_DEC_HANDLE *hMCParamUpmix_out /* i/o: Parametric MC decoder handle */ ); void ivas_mc_paramupmix_dec_read_BS( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - Decoder_State *st, /* i/o: decoder state structure */ - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, /* i/o: decoder MC Param-Upmix handle */ - int16_t *nb_bits /* o : number of bits written */ + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + Decoder_State *st, /* i/o: decoder state structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, /* i/o: decoder MC Param-Upmix handle */ + int16_t *nb_bits /* o : number of bits written */ ); void ivas_param_mc_metadata_open( diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index efeb322d85..c38f44a826 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -760,8 +760,10 @@ void ivas_dirac_param_est_enc( if ( hodirac_flag ) { - - calculate_hodirac_sector_parameters( Cldfb_RealBuffer, Cldfb_ImagBuffer, l_ts, 0.20f, hDirAC->band_grouping, hDirAC->hConfig->nbands, hDirAC->hConfig->enc_param_start_band, azi_secs, ele_secs, diff_secs, ene_secs ); +#ifdef DEBUGGING + assert( l_ts <= DIRAC_NO_FB_BANDS_MAX ); +#endif + calculate_hodirac_sector_parameters( Cldfb_RealBuffer, Cldfb_ImagBuffer, 0.20f, hDirAC->band_grouping, hDirAC->hConfig->nbands, hDirAC->hConfig->enc_param_start_band, azi_secs, ele_secs, diff_secs, ene_secs ); } if ( hodirac_flag ) -- GitLab From d65780fc8c1099b57acbff9d6f1c4b47f65fd90b Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 23 May 2023 08:38:57 +0200 Subject: [PATCH 5/8] move static buffers from calculate_hodirac_sector_parameters to hDirAC --- lib_com/ivas_dirac_com.c | 23 ++++++++++++++--------- lib_com/ivas_prot.h | 3 +++ lib_com/ivas_sba_config.c | 2 +- lib_com/options.h | 2 ++ lib_enc/ivas_dirac_enc.c | 18 +++++++++++++++++- lib_enc/ivas_stat_enc.h | 12 ++++++++++++ 6 files changed, 49 insertions(+), 11 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index d876c557ba..7a171f2923 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -947,6 +947,9 @@ void deindex_spherical_component( *-----------------------------------------------------------------*/ void calculate_hodirac_sector_parameters( +#ifdef FIX_485_STATIC_BUFFERS + DIRAC_ENC_HANDLE hDirAC, /* i : DirAC handle */ +#endif float RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : signal vector (L+1)^2 x N_bins, real part */ float ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : signal vector, imaginary part */ const float beta, /* i : forgetting factor for average filtering */ @@ -965,6 +968,7 @@ void calculate_hodirac_sector_parameters( float sec_I_vec_y[NUM_ANA_SECTORS]; float sec_I_vec_z[NUM_ANA_SECTORS]; +#ifndef FIX_485_STATIC_BUFFERS static int16_t firstrun_sector_params = 1; static float sec_I_vec_smth_x[NUM_ANA_SECTORS][IVAS_MAX_NUM_BANDS]; @@ -974,6 +978,7 @@ void calculate_hodirac_sector_parameters( static float energy_smth[NUM_ANA_SECTORS][IVAS_MAX_NUM_BANDS]; static float azi_prev[NUM_ANA_SECTORS * IVAS_MAX_NUM_BANDS]; static float ele_prev[NUM_ANA_SECTORS * IVAS_MAX_NUM_BANDS]; +#endif for ( i_sec = 0; i_sec < NUM_ANA_SECTORS; i_sec++ ) { @@ -1009,13 +1014,13 @@ void calculate_hodirac_sector_parameters( float *p_ene = &ene[i_sec * N_bands + i_band]; float *p_diff = &diff[i_sec * N_bands + i_band]; - float *p_azi_prev = &azi_prev[i_sec * N_bands + i_band]; - float *p_ele_prev = &ele_prev[i_sec * N_bands + i_band]; + float *p_azi_prev = &hDirAC->azi_prev[i_sec * N_bands + i_band]; + float *p_ele_prev = &hDirAC->ele_prev[i_sec * N_bands + i_band]; - float *p_energy_smth = &energy_smth[i_sec][i_band]; - float *p_sec_I_vec_smth_x = &sec_I_vec_smth_x[i_sec][i_band]; - float *p_sec_I_vec_smth_y = &sec_I_vec_smth_y[i_sec][i_band]; - float *p_sec_I_vec_smth_z = &sec_I_vec_smth_z[i_sec][i_band]; + float *p_energy_smth = &hDirAC->energy_smth[i_sec][i_band]; + float *p_sec_I_vec_smth_x = &hDirAC->sec_I_vec_smth_x[i_sec][i_band]; + float *p_sec_I_vec_smth_y = &hDirAC->sec_I_vec_smth_y[i_sec][i_band]; + float *p_sec_I_vec_smth_z = &hDirAC->sec_I_vec_smth_z[i_sec][i_band]; *p_sec_I_vec_x = 0.f; *p_sec_I_vec_y = 0.f; @@ -1083,7 +1088,7 @@ void calculate_hodirac_sector_parameters( } } - if ( firstrun_sector_params ) + if ( hDirAC->firstrun_sector_params ) { *p_sec_I_vec_smth_x = *p_sec_I_vec_x; *p_sec_I_vec_smth_y = *p_sec_I_vec_y; @@ -1125,7 +1130,7 @@ void calculate_hodirac_sector_parameters( } if ( tmp_diff > 0.5f ) { - if ( firstrun_sector_params ) + if ( hDirAC->firstrun_sector_params ) { *p_azi = 0.f; *p_ele = 0.f; @@ -1144,7 +1149,7 @@ void calculate_hodirac_sector_parameters( } } - firstrun_sector_params = 0; + hDirAC->firstrun_sector_params = 0; return; } diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index e7a723b607..9b6871695e 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3905,6 +3905,9 @@ void ivas_dirac_dec_get_frequency_axis( const int16_t num_freq_bands ); /* i : number of frequency bands */ void calculate_hodirac_sector_parameters( +#ifdef FIX_485_STATIC_BUFFERS + DIRAC_ENC_HANDLE hDirAC, +#endif float RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX],/* i : signal vector (L+1)^2 x N_bins, real part */ float ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX],/* i : signal vector, imaginary part */ const float beta, /* i : forgetting factor for average filtering */ diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index e7a448315f..62398f1dca 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -295,7 +295,7 @@ void ivas_sba_get_spar_hoa_md_flag( *spar_hoa_md_flag = 0; } - if ( sba_order > 1 && ivas_total_brate >= IVAS_512k ) + if ( sba_order > 1 && ivas_total_brate >= IVAS_384k ) { *spar_hoa_dirac2spar_md_flag = 0; } diff --git a/lib_com/options.h b/lib_com/options.h index 2d346ef591..9dc196207d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,6 +164,8 @@ #define FIX_482_DUMMYDEC_INIT /* Nokia: fix issue #428: missing inits for dummyDec in IVAS_rend */ #define FIX_468_16KHZ_PUPMIX /* Dlb: Fix issue 468 for Param Upmix at 16kHz sampling rate */ +#define FIX_485_STATIC_BUFFERS /* FhG: move static buffers in DirAC parameter estimator to the DirAC struct */ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index c38f44a826..3ce2f5d821 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -79,6 +79,9 @@ ivas_error ivas_dirac_enc_open( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC Config\n" ) ); } +#ifdef FIX_485_STATIC_BUFFERS + hDirAC->firstrun_sector_params = 1; +#endif /*-----------------------------------------------------------------* * DirAC main configuration @@ -763,7 +766,20 @@ void ivas_dirac_param_est_enc( #ifdef DEBUGGING assert( l_ts <= DIRAC_NO_FB_BANDS_MAX ); #endif - calculate_hodirac_sector_parameters( Cldfb_RealBuffer, Cldfb_ImagBuffer, 0.20f, hDirAC->band_grouping, hDirAC->hConfig->nbands, hDirAC->hConfig->enc_param_start_band, azi_secs, ele_secs, diff_secs, ene_secs ); + calculate_hodirac_sector_parameters( +#ifdef FIX_485_STATIC_BUFFERS + hDirAC, +#endif + Cldfb_RealBuffer, + Cldfb_ImagBuffer, + 0.20f, + hDirAC->band_grouping, + hDirAC->hConfig->nbands, + hDirAC->hConfig->enc_param_start_band, + azi_secs, + ele_secs, + diff_secs, + ene_secs ); } if ( hodirac_flag ) diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index daff0851ef..806899c343 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -600,6 +600,17 @@ typedef struct ivas_dirac_enc_data_structure float diffuseness_m[DIRAC_MAX_NBANDS]; int16_t band_grouping[DIRAC_MAX_NBANDS + 1]; int16_t block_grouping[5]; +#ifdef FIX_485_STATIC_BUFFERS + int16_t firstrun_sector_params; + + float sec_I_vec_smth_x[NUM_ANA_SECTORS][IVAS_MAX_NUM_BANDS]; + float sec_I_vec_smth_y[NUM_ANA_SECTORS][IVAS_MAX_NUM_BANDS]; + float sec_I_vec_smth_z[NUM_ANA_SECTORS][IVAS_MAX_NUM_BANDS]; + + float energy_smth[NUM_ANA_SECTORS][IVAS_MAX_NUM_BANDS]; + float azi_prev[NUM_ANA_SECTORS * IVAS_MAX_NUM_BANDS]; + float ele_prev[NUM_ANA_SECTORS * IVAS_MAX_NUM_BANDS]; +#endif int16_t dirac_to_spar_md_bands[DIRAC_MAX_NBANDS]; @@ -609,6 +620,7 @@ typedef struct ivas_dirac_enc_data_structure float **buffer_intensity_real[DIRAC_NUM_DIMS]; float *buffer_energy; + } DIRAC_ENC_DATA, *DIRAC_ENC_HANDLE; /*----------------------------------------------------------------------------------* -- GitLab From 16dd757a3686a723857ad2b8832a8d2f7c9d3f93 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 23 May 2023 09:09:57 +0200 Subject: [PATCH 6/8] fix compilation with FIX_485_STATIC_BUFFERS disabled --- lib_com/ivas_dirac_com.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 7a171f2923..95d122ba79 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -1014,6 +1014,7 @@ void calculate_hodirac_sector_parameters( float *p_ene = &ene[i_sec * N_bands + i_band]; float *p_diff = &diff[i_sec * N_bands + i_band]; +#ifdef FIX_485_STATIC_BUFFERS float *p_azi_prev = &hDirAC->azi_prev[i_sec * N_bands + i_band]; float *p_ele_prev = &hDirAC->ele_prev[i_sec * N_bands + i_band]; @@ -1021,7 +1022,15 @@ void calculate_hodirac_sector_parameters( float *p_sec_I_vec_smth_x = &hDirAC->sec_I_vec_smth_x[i_sec][i_band]; float *p_sec_I_vec_smth_y = &hDirAC->sec_I_vec_smth_y[i_sec][i_band]; float *p_sec_I_vec_smth_z = &hDirAC->sec_I_vec_smth_z[i_sec][i_band]; +#else + float *p_azi_prev = &azi_prev[i_sec * N_bands + i_band]; + float *p_ele_prev = &ele_prev[i_sec * N_bands + i_band]; + float *p_energy_smth = &energy_smth[i_sec][i_band]; + float *p_sec_I_vec_smth_x = &sec_I_vec_smth_x[i_sec][i_band]; + float *p_sec_I_vec_smth_y = &sec_I_vec_smth_y[i_sec][i_band]; + float *p_sec_I_vec_smth_z = &sec_I_vec_smth_z[i_sec][i_band]; +#endif *p_sec_I_vec_x = 0.f; *p_sec_I_vec_y = 0.f; *p_sec_I_vec_z = 0.f; @@ -1087,8 +1096,11 @@ void calculate_hodirac_sector_parameters( sec_z_real * sec_z_real + sec_z_imag * sec_z_imag ); } } - +#ifdef FIX_485_STATIC_BUFFERS if ( hDirAC->firstrun_sector_params ) +#else + if ( firstrun_sector_params ) +#endif { *p_sec_I_vec_smth_x = *p_sec_I_vec_x; *p_sec_I_vec_smth_y = *p_sec_I_vec_y; @@ -1130,7 +1142,11 @@ void calculate_hodirac_sector_parameters( } if ( tmp_diff > 0.5f ) { +#ifdef FIX_485_STATIC_BUFFERS if ( hDirAC->firstrun_sector_params ) +#else + if ( firstrun_sector_params ) +#endif { *p_azi = 0.f; *p_ele = 0.f; @@ -1149,7 +1165,11 @@ void calculate_hodirac_sector_parameters( } } +#ifdef FIX_485_STATIC_BUFFERS hDirAC->firstrun_sector_params = 0; +#else + firstrun_sector_params = 0; +#endif return; } -- GitLab From b4289c40577ec5aa1a7e2f40fd7559e4f3348a67 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 23 May 2023 09:34:17 +0200 Subject: [PATCH 7/8] fix pipeline errors --- lib_com/ivas_sba_config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index 62398f1dca..e7a448315f 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -295,7 +295,7 @@ void ivas_sba_get_spar_hoa_md_flag( *spar_hoa_md_flag = 0; } - if ( sba_order > 1 && ivas_total_brate >= IVAS_384k ) + if ( sba_order > 1 && ivas_total_brate >= IVAS_512k ) { *spar_hoa_dirac2spar_md_flag = 0; } -- GitLab From 2514546a3bf791a78f32d5d1b11daec35707180b Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 23 May 2023 10:53:12 +0200 Subject: [PATCH 8/8] fix msan errors --- lib_enc/ivas_dirac_enc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index 3ce2f5d821..283c51c4be 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -81,8 +81,13 @@ ivas_error ivas_dirac_enc_open( } #ifdef FIX_485_STATIC_BUFFERS hDirAC->firstrun_sector_params = 1; + set_zero( hDirAC->sec_I_vec_smth_x[0], NUM_ANA_SECTORS * IVAS_MAX_NUM_BANDS ); + set_zero( hDirAC->sec_I_vec_smth_y[0], NUM_ANA_SECTORS * IVAS_MAX_NUM_BANDS ); + set_zero( hDirAC->sec_I_vec_smth_z[0], NUM_ANA_SECTORS * IVAS_MAX_NUM_BANDS ); + set_zero( hDirAC->azi_prev, NUM_ANA_SECTORS * IVAS_MAX_NUM_BANDS ); + set_zero( hDirAC->ele_prev, NUM_ANA_SECTORS * IVAS_MAX_NUM_BANDS ); + set_zero( hDirAC->energy_smth[0], NUM_ANA_SECTORS * IVAS_MAX_NUM_BANDS ); #endif - /*-----------------------------------------------------------------* * DirAC main configuration *-----------------------------------------------------------------*/ -- GitLab