From 338cc091494639e3e3133425e64ec1bec3cfa6e2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 26 Oct 2022 20:39:04 +0200 Subject: [PATCH 01/13] - improve comments - output_fs -> output_Fs --- lib_com/ivas_cnst.h | 21 +++++++++------------ lib_com/ivas_prot.h | 4 ++-- lib_dec/ivas_rotation.c | 4 ++-- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 0512cf27e6..b97cf5c70b 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1418,19 +1418,9 @@ typedef enum /*----------------------------------------------------------------------------------* - * Crend constants + * Orientation tracking constants *----------------------------------------------------------------------------------*/ -#define IVAS_REV_MAX_NR_BRANCHES 8 /* setup is for maximum */ - -#define IVAS_REV_MAX_IIR_FILTER_LENGTH 4 /* maximum nr of taps - MUST BE EVEN! */ - -#define RV_FILTER_MAX_FFT_SIZE ( 512 ) -#define RV_FILTER_MAX_HISTORY ( 512 - 160 ) /* for longest history */ - -#define RV_LENGTH_NR_FC ( RV_FILTER_MAX_FFT_SIZE / 2 ) + 1 - - /* Orientation tracking types */ #define IVAS_ORIENT_TRK_REF 0 #define IVAS_ORIENT_TRK_AVG 1 @@ -1440,14 +1430,21 @@ typedef enum OTR_TRACKING_NONE = IVAS_ORIENT_TRK_REF-1, /* track orientation relative to external reference orientation (default: yaw=pitch=roll=0) */ OTR_TRACKING_REF_ORIENT = IVAS_ORIENT_TRK_REF, /* track orientation relative to external reference orientation (default: yaw=pitch=roll=0) */ OTR_TRACKING_AVG_ORIENT = IVAS_ORIENT_TRK_AVG /* track orientation relative to average orientation */ -} OTR_TRACKING_T; +} OTR_TRACKING_T; /*----------------------------------------------------------------------------------* * Reverberator constants *----------------------------------------------------------------------------------*/ +#define IVAS_REV_MAX_NR_BRANCHES 8 /* setup is for maximum */ +#define IVAS_REV_MAX_IIR_FILTER_LENGTH 4 /* maximum nr of taps - MUST BE EVEN! */ + +#define RV_FILTER_MAX_FFT_SIZE ( 512 ) +#define RV_FILTER_MAX_HISTORY ( 512 - 160 ) /* for longest history */ +#define RV_LENGTH_NR_FC ( RV_FILTER_MAX_FFT_SIZE / 2 ) + 1 + #define IVAS_REVERB_DEFAULT_N_BANDS 31 #define IVAS_REVERB_DEFAULT_PRE_DELAY 0.016f #define IVAS_REVERB_DEFAULT_INPUT_DELAY 0.1f diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index f54f37414f..dbe5ec6e5d 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4578,7 +4578,7 @@ ivas_error ivas_headTrack_open( void rotateFrame_shd( HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ float output[][L_FRAME48k], /* i/o: unrotated HOA3 signal buffer in TD */ - const int32_t output_fs, /* i : output sampling frequency */ + const int32_t output_Fs, /* i : output sampling frequency */ const int16_t subframe_len, /* i : subframe length per channel */ const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ const int16_t subframe_idx /* i : subframe index */ @@ -4587,7 +4587,7 @@ void rotateFrame_shd( void rotateFrame_sd( HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ float output[][L_FRAME48k], /* i/o: unrotated SD signal buffer in TD */ - const int32_t output_fs, /* i : output sampling frequency */ + const int32_t output_Fs, /* i : output sampling frequency */ const int16_t subframe_len, /* i : subframe length per channel */ const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */ diff --git a/lib_dec/ivas_rotation.c b/lib_dec/ivas_rotation.c index 77809d8270..702dfd08a0 100644 --- a/lib_dec/ivas_rotation.c +++ b/lib_dec/ivas_rotation.c @@ -302,7 +302,7 @@ void rotateAziEle_DirAC( void rotateFrame_shd( HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ float output[][L_FRAME48k], /* i/o: unrotated HOA3 signal buffer in TD */ - const int32_t output_fs, /* i : output sampling frequency */ + const int32_t output_Fs, /* i : output sampling frequency */ const int16_t subframe_len, /* i : subframe length per channel */ const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ const int16_t subframe_idx /* i : subframe index */ @@ -321,7 +321,7 @@ void rotateFrame_shd( shd_rot_max_order = hTransSetup.ambisonics_order; /* 1ms linear crossfade */ - fade_len_smp = NS2SA( output_fs, 1000000 ); + fade_len_smp = NS2SA( output_Fs, 1000000 ); tmp = 1.0f / fade_len_smp; for ( i = 0; i < fade_len_smp; i++ ) { -- GitLab From ff3cc1dd50e6877b105778a19d50173e66bdb85f Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 26 Oct 2022 20:48:27 +0200 Subject: [PATCH 02/13] move local constants from ivas_cnst.h to the appropriate file --- lib_com/ivas_cnst.h | 13 +++---------- lib_com/ivas_mdft_imdft.c | 12 ++++++++++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index b97cf5c70b..851f965fcc 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -189,10 +189,12 @@ typedef enum #define IVAS_MAX_SBA_ORDER 3 /* Maximum supported Ambisonics order */ +#define IVAS_NUM_SUPPORTED_FS 3 /* number of supported sampling-rates in IVAS */ /*----------------------------------------------------------------------------------* * IVAS Bitrates *----------------------------------------------------------------------------------*/ + #define IVAS_SID_5k2 5200 /* SID frame bitrate */ #define IVAS_13k2 13200 #define IVAS_16k4 16400 @@ -1427,7 +1429,7 @@ typedef enum typedef enum { - OTR_TRACKING_NONE = IVAS_ORIENT_TRK_REF-1, /* track orientation relative to external reference orientation (default: yaw=pitch=roll=0) */ + OTR_TRACKING_NONE = IVAS_ORIENT_TRK_REF-1, /* track orientation relative to external reference orientation (default: yaw=pitch=roll=0) */ // VE: not really used in IVAS (only in unit-test) OTR_TRACKING_REF_ORIENT = IVAS_ORIENT_TRK_REF, /* track orientation relative to external reference orientation (default: yaw=pitch=roll=0) */ OTR_TRACKING_AVG_ORIENT = IVAS_ORIENT_TRK_AVG /* track orientation relative to average orientation */ @@ -1454,13 +1456,6 @@ typedef enum * FB mixer constants *----------------------------------------------------------------------------------*/ -#define IVAS_ONE_BY_960 0.001041666666666666f -#define IVAS_ONE_BY_640 0.0015625f -#define IVAS_ONE_BY_320 0.003125f -#define IVAS_ONE_BY_240 0.004166666666666667f -#define IVAS_ONE_BY_160 0.00625f -#define IVAS_ONE_BY_80 0.0125f - #define IVAS_960_PT_LEN 960 #define IVAS_640_PT_LEN 640 #define IVAS_480_PT_LEN 480 @@ -1470,8 +1465,6 @@ typedef enum #define IVAS_80_PT_LEN 80 #define IVAS_40_PT_LEN 40 -#define IVAS_NUM_SUPPORTED_FS 3 - /* FB windows ovlp */ #define IVAS_FB_4MS_48K_SAMP 192 #define IVAS_FB_1MS_48K_SAMP 48 diff --git a/lib_com/ivas_mdft_imdft.c b/lib_com/ivas_mdft_imdft.c index 4c986e84e5..61797d6746 100644 --- a/lib_com/ivas_mdft_imdft.c +++ b/lib_com/ivas_mdft_imdft.c @@ -42,6 +42,18 @@ #include "wmops.h" +/*-----------------------------------------------------------------------------------------* + * Local constants + *-----------------------------------------------------------------------------------------*/ + +#define IVAS_ONE_BY_960 0.001041666666666666f +#define IVAS_ONE_BY_640 0.0015625f +#define IVAS_ONE_BY_320 0.003125f +#define IVAS_ONE_BY_240 0.004166666666666667f +#define IVAS_ONE_BY_160 0.00625f +#define IVAS_ONE_BY_80 0.0125f + + /*-----------------------------------------------------------------------------------------* * Function ivas_get_mdft_twid_factors() * -- GitLab From f582b623da57ce6814ce100ffe4673f20a753975 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 27 Oct 2022 13:39:59 +0200 Subject: [PATCH 03/13] remove unused constant define --- lib_enc/lsf_enc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_enc/lsf_enc.c b/lib_enc/lsf_enc.c index a6d973b36e..1cbe2352a7 100644 --- a/lib_enc/lsf_enc.c +++ b/lib_enc/lsf_enc.c @@ -55,8 +55,7 @@ * Local constants *-----------------------------------------------------------------*/ -#define MSVQ_MAXCNT 3000 /* was 300 */ -#define LOWEMPH_LSFI 1.0f /* bigger value means more weight for lower frequencies */ +#define MSVQ_MAXCNT 3000 /*---------------------------------------------------------------------* @@ -1020,7 +1019,7 @@ void first_VQstages( dist[0] = dist_buf; dist[1] = dist_buf + maxC; - set_s( idx_buf, 0, ( const int16_t )( 2 * stagesVQ * maxC ) ); + set_s( idx_buf, 0, (const int16_t) ( 2 * stagesVQ * maxC ) ); set_s( parents, 0, maxC ); /* Set up inital distance vector */ -- GitLab From 43ba5d8ff6ab48c01b75dd8d87c4313b8c7f903d Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 31 Oct 2022 09:22:53 +0100 Subject: [PATCH 04/13] formatting, comments --- lib_com/cnst.h | 3 ++- lib_com/ivas_prot.h | 6 ++---- lib_dec/core_dec_switch.c | 3 +-- lib_dec/ivas_spar_decoder.c | 3 +-- lib_dec/ivas_spar_md_dec.c | 9 ++++----- lib_enc/ivas_dirac_enc.c | 5 ++--- lib_enc/ivas_mcmasa_enc.c | 6 +++++- lib_enc/ivas_spar_md_enc.c | 3 +++ 8 files changed, 20 insertions(+), 18 deletions(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index e62ef001dc..68981089d3 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -887,7 +887,7 @@ enum * TCX constants *---------------------------------------------------------------*/ -#define NBITS_TCX_GAIN 7 +#define NBITS_TCX_GAIN 7 #define NOISE_FILL_RANGES 1 #define NBITS_NOISE_FILL_LEVEL 3 /* Number of bits used for coding noise filling level for each range */ @@ -1019,6 +1019,7 @@ enum #define SIZE_BK22_36b 128 #define SIZE_BK23_36b 64 +/* Gain quantizer constants */ #define NB_QUA_GAIN5B 32 /* Number of quantization level */ #define NB_QUA_GAIN6B 64 /* Number of quantization level */ #define NB_QUA_GAIN7B 128 /* Number of quantization level */ diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 10901678b0..7181e36640 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3970,8 +3970,7 @@ void ivas_get_spar_md_from_dirac( ivas_error ivas_spar_md_dec_open( ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const int16_t num_channels /* i : number of internal channels */ - , + const int16_t num_channels, /* i : number of internal channels */ const int16_t sba_order /* i : SBA order */ ); @@ -4074,8 +4073,7 @@ void ivas_cov_smooth_process( float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], ivas_filterbank_t *pFb, /* i/o: FB handle */ const int16_t start_band, - const int16_t end_band - , + const int16_t end_band, const int16_t num_ch, const int16_t transient_det ); diff --git a/lib_dec/core_dec_switch.c b/lib_dec/core_dec_switch.c index 7b28143666..c1f8e590fb 100644 --- a/lib_dec/core_dec_switch.c +++ b/lib_dec/core_dec_switch.c @@ -56,8 +56,7 @@ void mode_switch_decoder_LPD( const int32_t total_brate, /* i : total bitrate */ const int32_t last_total_brate, /* i : last frame total bitrate */ const int16_t frame_size_index, /* i : index determining the frame size */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ - , + const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ const int16_t last_element_mode /* i : last element mode */ ) { diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 444a14457e..8fb28c826f 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -89,8 +89,7 @@ ivas_error ivas_spar_dec_open( } /* MD handle */ - if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, - sba_order_internal ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, sba_order_internal ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 5d39aee9a0..bf27f7d58c 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -247,11 +247,10 @@ static ivas_error ivas_spar_md_dec_matrix_open( *------------------------------------------------------------------------*/ ivas_error ivas_spar_md_dec_open( - ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */ - const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const int16_t num_channels /* i : number of internal channels */ - , - const int16_t sba_order /* i : SBA order */ + ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ + const int16_t num_channels, /* i : number of internal channels */ + const int16_t sba_order /* i : SBA order */ ) { ivas_spar_md_dec_state_t *hMdDec; diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index 96a005a0b3..d105cff616 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -507,9 +507,8 @@ void computeReferencePower_enc( float Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal */ float *reference_power, /* o : Estimated power */ const int16_t enc_param_start_band, /* i : first band to process */ - const int16_t num_freq_bands /* i : Number of frequency bands */ - , - const SBA_MODE sba_mode /* i : SBA mode */ + const int16_t num_freq_bands, /* i : Number of frequency bands */ + const SBA_MODE sba_mode /* i : SBA mode */ ) { int16_t brange[2]; diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index de816f3bf7..8d127e17d5 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -890,7 +890,11 @@ void ivas_mcmasa_param_est_enc( 0, num_freq_bands, intensity_even_real ); - computeReferencePower_enc( hMcMasa->band_grouping, FoaEven_RealBuffer, FoaEven_ImagBuffer, reference_power[ts], + + computeReferencePower_enc( hMcMasa->band_grouping, + FoaEven_RealBuffer, + FoaEven_ImagBuffer, + reference_power[ts], 0, num_freq_bands, SBA_MODE_NONE ); diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 4bd23dee47..6500019164 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -85,8 +85,11 @@ static void ivas_store_prior_coeffs( ivas_spar_md_enc_state_t *hMdEnc, const int static void ivas_write_spar_md_bitstream( ivas_spar_md_enc_state_t *hMdEnc, const int16_t nB, const int16_t bands_bw, BSTR_ENC_HANDLE hMetaData, const int32_t ivas_total_brate, const int16_t dtx_silence_mode, const int16_t strat, const int16_t qsi, const int16_t planarCP ); static ivas_error ivas_spar_md_enc_init( ivas_spar_md_enc_state_t *hMdEnc, const ENCODER_CONFIG_HANDLE hEncoderConfig, const int16_t sba_order ); + static void ivas_spar_quant_pred_coeffs_dtx( ivas_spar_md_t *pSpar_md, const float *pValues, const int16_t ndm, int16_t *pIndex, const int16_t dim1, float *pQuant ); + static void ivas_quant_p_per_band_dtx( float *pP_mat, const int16_t num_dec, const int16_t num_dmx, int16_t *ppIdx_pd, float *pP_out, const int16_t num_ch ); + static void ivas_write_parameter_bitstream_dtx( ivas_spar_md_t *pSpar_md, BSTR_ENC_HANDLE hMetaData, int16_t *num_dmx, int16_t *num_dec, const int16_t num_bands ); static void ivas_quant_p_per_band( ivas_band_coeffs_t *pband_coeffs, ivas_band_coeffs_ind_t *pBand_coeffs_idx, ivas_quant_strat_t *pQs, const int16_t num_ch ); -- GitLab From 506a8bfe6f27b0e8de39729d43efd20e5ec9f4db Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 31 Oct 2022 11:42:13 +0100 Subject: [PATCH 05/13] comments --- lib_dec/ivas_tcx_core_dec.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 8e56ed5ef7..e8ad580648 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -822,9 +822,9 @@ void stereo_tcx_core_dec( /*-----------------------------------------------------------------* - * Function dec_prm_tcx() * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - * decode TCX parameters + * Function dec_prm_tcx() + * + * Decode TCX parameters *-----------------------------------------------------------------*/ static void dec_prm_tcx( @@ -835,7 +835,7 @@ static void dec_prm_tcx( #ifdef FIX_TCX_DEC_RECONF_BFI const int16_t last_element_mode, #endif - int16_t *bitsRead /* o : number of read bits */ + int16_t *bitsRead /* o : number of read bits */ ) { int16_t start_bit_pos, bits_common; @@ -960,10 +960,16 @@ static void dec_prm_tcx( } #ifdef FIX_TCX_DEC_RECONF_BFI +/*-----------------------------------------------------------------* + * Function stereo_tcx_dec_mode_switch_reconf() + * + * Reconfigure stereo TCX parameters + *-----------------------------------------------------------------*/ + static void stereo_tcx_dec_mode_switch_reconf( - Decoder_State *st, - const int16_t MCT_flag, - const int16_t last_element_mode + Decoder_State *st, /* i/o: decoder state structure */ + const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ + const int16_t last_element_mode /* i : element mode of previous frame */ ) { int16_t frame_size_index; @@ -991,5 +997,7 @@ static void stereo_tcx_dec_mode_switch_reconf( /* Reconfigure Core */ mode_switch_decoder_LPD( st, st->bwidth, st->bits_frame_nominal * FRAMES_PER_SEC, st->last_bits_frame_nominal * FRAMES_PER_SEC, frame_size_index, MCT_flag, last_element_mode ); + + return; } #endif -- GitLab From 1e60bcb8074808ae7f903910ba9e2571fa890257 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 1 Nov 2022 23:46:10 +0100 Subject: [PATCH 06/13] Use hDecoderConfig intsead st_ivas->hDecoderConfig; --- lib_dec/ivas_spar_decoder.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 8fb28c826f..2882693a80 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1024,7 +1024,7 @@ void ivas_spar_dec_upmixer( *---------------------------------------------------------------------*/ /* set-up pointers */ - if ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) + if ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) { /* at this point, output channels are used as intermediate procesing buffers */ for ( in_ch = 0; in_ch < MAX_OUTPUT_CHANNELS; in_ch++ ) @@ -1065,7 +1065,7 @@ void ivas_spar_dec_upmixer( /* determine if we can skip certain data */ ivas_spar_get_skip_mat( hSpar, numch_out, numch_in, num_spar_bands, b_skip_mat ); /* this can be precomputed based on bitrate and format*/ - numch_out_dirac = st_ivas->hDecoderConfig->nchan_out; + numch_out_dirac = hDecoderConfig->nchan_out; for ( int16_t i_sf = 0; i_sf < MAX_PARAM_SPATIAL_SUBFRAMES; i_sf++ ) { @@ -1086,7 +1086,7 @@ void ivas_spar_dec_upmixer( for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { /* determine SPAR parameters for this time slots */ - ivas_spar_get_parameters( hSpar, st_ivas->hDecoderConfig, ts + i_sf * MAX_PARAM_SPATIAL_SUBFRAMES, numch_out, numch_in, num_spar_bands, mixer_mat ); + ivas_spar_get_parameters( hSpar, hDecoderConfig, ts + i_sf * MAX_PARAM_SPATIAL_SUBFRAMES, numch_out, numch_in, num_spar_bands, mixer_mat ); for ( cldfb_band = 0; cldfb_band < num_cldfb_bands; cldfb_band++ ) { @@ -1135,9 +1135,9 @@ void ivas_spar_dec_upmixer( } } - if ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_FOA + if ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA #ifdef SPAR_STEREO_NO_DIRAC - && st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO + && hDecoderConfig->output_config != AUDIO_CONFIG_STEREO && hDecoderConfig->output_config != AUDIO_CONFIG_MONO #endif ) { @@ -1164,8 +1164,7 @@ void ivas_spar_dec_upmixer( } else { - if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_FOA || - !( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM ) ) + if ( hDecoderConfig->output_config == AUDIO_CONFIG_FOA || !( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM ) ) { for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { -- GitLab From 6093927c519b6f5f7de613ff277a9fdb03fb750b Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 2 Nov 2022 10:38:57 +0100 Subject: [PATCH 07/13] formatting; add "const" to function input parameter --- lib_com/ivas_prot.h | 2 +- lib_com/ivas_spar_com.c | 5 +++-- lib_dec/ivas_spar_md_dec.c | 33 +++++++++++++-------------------- lib_enc/ivas_dirac_enc.c | 6 ++++-- lib_enc/ivas_spar_encoder.c | 14 +++----------- lib_enc/ivas_spar_md_enc.c | 36 +++++++++++++++++++----------------- 6 files changed, 43 insertions(+), 53 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 7181e36640..265f86c507 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3906,7 +3906,7 @@ ivas_error ivas_spar_md_enc_process( float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], float *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ - int16_t dtx_vad, + const int16_t dtx_vad, const int16_t nchan_inp, const int16_t sba_order /* i : Ambisonic (SBA) order */ ); diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index fa5e65460e..ad143e057f 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -912,7 +912,6 @@ static void ivas_calc_post_pred_per_band( { for ( k = 0; k < num_ch; k++ ) { - IVAS_RMULT_FLOAT( mixer_mat[i][k][band_idx], temp_mat[k][j], tmp_re ); postpred_cov_re[i][j] += tmp_re; } @@ -1213,6 +1212,7 @@ static void ivas_calc_c_coeffs_per_band( else { ivas_calc_mat_inv( cov_dd_re, num_dmx - 1, cov_dd_re_inv ); + for ( i = 0; i < num_ch - num_dmx; i++ ) { for ( j = 0; j < num_dmx - 1; j++ ) @@ -1390,6 +1390,7 @@ static void ivas_get_mat_cofactor( * * Calculate Invert of a matrix *-----------------------------------------------------------------------------------------*/ + static void ivas_calc_mat_inv( float in_re[MAX_MAT_DIM][MAX_MAT_DIM], const int16_t dim, @@ -1489,6 +1490,7 @@ static void ivas_calc_mat_inv( * * Check if matrix is invertible or not by checking if determinant is 0 or very close to 0 *-----------------------------------------------------------------------------------------*/ + static int16_t ivas_is_mat_inv( float in_re[MAX_MAT_DIM][MAX_MAT_DIM], const int16_t dim ) @@ -1624,7 +1626,6 @@ void ivas_compute_spar_params( } } - return; } diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index bf27f7d58c..99eae474c1 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -82,7 +82,9 @@ static void ivas_spar_md_fill_invalid_bands( ivas_spar_dec_matrices_t *pSpar_coe static ivas_error ivas_spar_set_dec_config( ivas_spar_md_dec_state_t *hMdDec, const int16_t nchan_transport, float *pFC ); static void ivas_parse_parameter_bitstream_dtx( ivas_spar_md_t *pSpar_md, Decoder_State *st, const int16_t bw, const int16_t num_bands, int16_t *num_dmx_per_band, int16_t *num_dec_per_band ); + static ivas_error ivas_deindex_real_index( const int16_t *index, const int16_t q_levels, const float min_value, const float max_value, float *quant, const int16_t num_ch_dim2 ); + static void ivas_spar_dec_parse_md_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, int16_t *nB, int16_t *bands_bw, int16_t *dtx_vad, const int32_t ivas_total_brate, const int16_t use_planar_coeff, const int16_t sba_inactive_mode ); @@ -443,8 +445,7 @@ ivas_error ivas_spar_md_dec_init( hMdDec->spar_md.num_bands = ( hMdDec->spar_hoa_md_flag ) ? IVAS_MAX_NUM_BANDS : min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); - ivas_spar_set_bitrate_config( &hMdDec->spar_md_cfg, hMdDec->table_idx, - hMdDec->spar_md.num_bands ); + ivas_spar_set_bitrate_config( &hMdDec->spar_md_cfg, hMdDec->table_idx, hMdDec->spar_md.num_bands ); nchan_transport = hMdDec->spar_md_cfg.nchan_transport; @@ -1207,7 +1208,6 @@ static void ivas_get_spar_matrices( for ( j = 1; j < numch_out; j++ ) { for ( k = dmx_ch; k < numch_out; k++ ) - { for ( m = 0; m < numch_out; m++ ) { @@ -1513,8 +1513,7 @@ static void ivas_spar_dec_parse_md_bs( } } - ivas_parse_parameter_bitstream_dtx( &hMdDec->spar_md, st0, *bands_bw, *nB, - hMdDec->spar_md_cfg.num_dmx_chans_per_band, hMdDec->spar_md_cfg.num_decorr_per_band ); + ivas_parse_parameter_bitstream_dtx( &hMdDec->spar_md, st0, *bands_bw, *nB, hMdDec->spar_md_cfg.num_dmx_chans_per_band, hMdDec->spar_md_cfg.num_decorr_per_band ); { int16_t ndec, b, idx; for ( i = *nB - 1; i >= 0; i-- ) @@ -1608,6 +1607,7 @@ static void ivas_spar_dec_parse_md_bs( int16_t ndec = hMdDec->spar_md_cfg.num_decorr_per_band[( *bands_bw ) * i]; int16_t ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[( *bands_bw ) * i]; float quant[IVAS_SPAR_MAX_C_COEFF]; + ivas_deindex_real_index( hMdDec->spar_md.band_coeffs_idx[i].pred_index_re, qs.PR.q_levels[0], qs.PR.min, qs.PR.max, hMdDec->spar_md.band_coeffs[i].pred_re, ndm + ndec - 1 ); j = 0; @@ -1620,6 +1620,7 @@ static void ivas_spar_dec_parse_md_bs( } } ivas_deindex_real_index( hMdDec->spar_md.band_coeffs_idx[i].drct_index_re, qs.C.q_levels[0], qs.C.min, qs.C.max, quant, ndec * ( ndm - 1 ) ); + j = 0; for ( ii = 0; ii < ndec; ii++ ) { @@ -1630,6 +1631,7 @@ static void ivas_spar_dec_parse_md_bs( } } ivas_deindex_real_index( hMdDec->spar_md.band_coeffs_idx[i].decd_index_re, qs.P_r.q_levels[0], qs.P_r.min, qs.P_r.max, hMdDec->spar_md.band_coeffs[i].P_re, ndm + ndec - 1 ); + /* Store prior coefficient indices */ for ( j = 0; j < ndm + ndec - 1; j++ ) { @@ -1749,7 +1751,7 @@ static void ivas_decode_arith_bs( const int16_t freq_diff, const int16_t planarCP ) { - int16_t i, ndm, ndec; + int16_t i, j, ndm, ndec; ivas_cell_dim_t pred_cell_dims[IVAS_MAX_NUM_BANDS]; ivas_cell_dim_t drct_cell_dims[IVAS_MAX_NUM_BANDS]; ivas_cell_dim_t decd_cell_dims[IVAS_MAX_NUM_BANDS]; @@ -1793,7 +1795,6 @@ static void ivas_decode_arith_bs( { if ( hMdDec->spar_hoa_md_flag ) { - int16_t j; for ( i = 0; i < nB; i++ ) { if ( i >= SPAR_DIRAC_SPLIT_START_BAND ) @@ -1816,7 +1817,6 @@ static void ivas_decode_arith_bs( if ( hMdDec->spar_hoa_md_flag ) { - int16_t j; for ( i = 0; i < nB; i++ ) { if ( i >= SPAR_DIRAC_SPLIT_START_BAND ) @@ -2092,8 +2092,7 @@ static void ivas_decode_huffman_bs( for ( j = pred_offset; j < pred_dim; j++ ) { - ivas_huffman_decode( &hMdDec->huff_coeffs.pred_huff_re[qsi], st0, - &hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j] ); + ivas_huffman_decode( &hMdDec->huff_coeffs.pred_huff_re[qsi], st0, &hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j] ); } if ( hMdDec->spar_hoa_md_flag ) @@ -2115,8 +2114,7 @@ static void ivas_decode_huffman_bs( } else { - ivas_huffman_decode( &hMdDec->huff_coeffs.drct_huff_re[qsi], st0, - &hMdDec->spar_md.band_coeffs_idx[i].drct_index_re[j] ); + ivas_huffman_decode( &hMdDec->huff_coeffs.drct_huff_re[qsi], st0, &hMdDec->spar_md.band_coeffs_idx[i].drct_index_re[j] ); } } @@ -2128,8 +2126,7 @@ static void ivas_decode_huffman_bs( } else { - ivas_huffman_decode( &hMdDec->huff_coeffs.decd_huff_re[qsi], st0, - &hMdDec->spar_md.band_coeffs_idx[i].decd_index_re[j] ); + ivas_huffman_decode( &hMdDec->huff_coeffs.decd_huff_re[qsi], st0, &hMdDec->spar_md.band_coeffs_idx[i].decd_index_re[j] ); } } } @@ -2758,9 +2755,7 @@ void ivas_spar_to_dirac( if ( hMdDec->spar_md_cfg.nchan_transport > 1 ) { ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, 1, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, - end_band, num_bands_out, - ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, - dtx_vad, NULL ); + end_band, num_bands_out, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL ); /* temporarily copy frame-wise prediction coefficients in DirAC bands*/ for ( pred_idx = 0; pred_idx < FOA_CHANNELS - 1; pred_idx++ ) @@ -2773,9 +2768,7 @@ void ivas_spar_to_dirac( } ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, MAX_PARAM_SPATIAL_SUBFRAMES, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, - end_band, num_bands_out, - ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, - dtx_vad, NULL ); + end_band, num_bands_out, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL ); /* expand DirAC TC 20ms MD for residual channels to all subframes*/ for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index d105cff616..223d23d695 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -334,8 +334,8 @@ void ivas_dirac_enc( set_zero( data_f[2], input_frame ); } - ivas_dirac_param_est_enc( hDirAC, &( hQMetaData->q_direction[0] ), hQMetaData->useLowerRes, data_f, NULL, NULL, input_frame, - SBA_MODE_DIRAC ); + ivas_dirac_param_est_enc( hDirAC, &( hQMetaData->q_direction[0] ), hQMetaData->useLowerRes, data_f, NULL, NULL, input_frame, SBA_MODE_DIRAC ); + /* encode parameters */ if ( sba_planar || hQMetaData->useLowerRes ) { @@ -427,6 +427,7 @@ void ivas_dirac_enc( { /*indicate whether SPAR or DiRAC mode*/ push_next_indice( hMetaData, 0, 1 ); + /* encode SID parameters */ ivas_qmetadata_enc_sid_encode( hMetaData, hQMetaData, -1, SBA_FORMAT, SBA_MODE_DIRAC ); } @@ -889,6 +890,7 @@ static void computeIntensityVector_enc( int16_t i, j; float real, img; int16_t brange[2]; + for ( i = 0; i < num_frequency_bands; i++ ) { brange[0] = hDirAC->band_grouping[i + enc_param_start_band]; diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 7e2d49310f..115ef94254 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -233,7 +233,6 @@ void ivas_spar_enc_close( hSpar->hFrontVad = NULL; } - num_chans = hSpar->hFbMixer->fb_cfg->num_in_chans; assert( num_chans <= nchan_inp ); @@ -436,10 +435,7 @@ static ivas_error ivas_spar_enc_process( * DirAC encoding *-----------------------------------------------------------------------------------------*/ - 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 ); - + 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 ); if ( hQMetaData->q_direction->cfg.nbands > 0 ) { @@ -502,7 +498,6 @@ static ivas_error ivas_spar_enc_process( if ( dtx_vad == 0 ) { - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].azimuth[i] = hQMetaData->q_direction[0].band_data[1].azimuth[0]; @@ -549,8 +544,7 @@ static ivas_error ivas_spar_enc_process( if ( hSpar->hMdEnc->table_idx != table_idx ) { hSpar->hMdEnc->table_idx = table_idx; - ivas_spar_set_bitrate_config( &hSpar->hMdEnc->spar_md_cfg, table_idx, - ( hSpar->hMdEnc->spar_hoa_md_flag ) ? IVAS_MAX_NUM_BANDS : SPAR_DIRAC_SPLIT_START_BAND ); + ivas_spar_set_bitrate_config( &hSpar->hMdEnc->spar_md_cfg, table_idx, ( hSpar->hMdEnc->spar_hoa_md_flag ) ? IVAS_MAX_NUM_BANDS : SPAR_DIRAC_SPLIT_START_BAND ); } nchan_transport = st_ivas->nchan_transport; @@ -604,9 +598,7 @@ static ivas_error ivas_spar_enc_process( } ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, 1, hSpar->hMdEnc->mixer_mat, &hSpar->hMdEnc->spar_md, &hSpar->hMdEnc->spar_md_cfg, - d_start_band, d_end_band, - ( hSpar->hMdEnc->spar_hoa_md_flag ) ? 1 : sba_order, - dtx_vad, Wscale_d ); + d_start_band, d_end_band, ( hSpar->hMdEnc->spar_hoa_md_flag ) ? 1 : sba_order, dtx_vad, Wscale_d ); } if ( hSpar->hMdEnc->spar_hoa_md_flag ) diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 6500019164..1f1802f419 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -325,8 +325,7 @@ static ivas_error ivas_spar_md_enc_init( table_idx = ivas_get_spar_table_idx( hEncoderConfig->ivas_total_brate, sba_order, SPAR_CONFIG_BW, NULL, NULL ); hMdEnc->spar_md_cfg.gen_bs = 1; - 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 ); + 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 ); /* get FB coefficients */ for ( i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) @@ -561,7 +560,7 @@ ivas_error ivas_spar_md_enc_process( float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], float *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ - int16_t dtx_vad, + const int16_t dtx_vad, const int16_t nchan_inp, const int16_t sba_order /* i : Ambisonic (SBA) order */ ) @@ -639,7 +638,6 @@ ivas_error ivas_spar_md_enc_process( next_ind_start = hMetaData->next_ind; last_ind_start = hMetaData->last_ind; - dmx_switch = 0; if ( dtx_vad == 0 ) @@ -661,8 +659,7 @@ ivas_error ivas_spar_md_enc_process( { for ( i = 0; i < FOA_CHANNELS - 1; i++ ) { - pred_coeffs_re_local[i][b] = - hMdEnc->spar_md.band_coeffs[b].pred_re[i]; + pred_coeffs_re_local[i][b] = hMdEnc->spar_md.band_coeffs[b].pred_re[i]; } } } @@ -773,15 +770,16 @@ ivas_error ivas_spar_md_enc_process( } else { - if ( ndm != num_ch ) { ivas_quant_p_per_band_dtx( hMdEnc->spar_md.band_coeffs[b].P_re, ndec, ndm, &hMdEnc->spar_md.band_coeffs_idx[b].decd_index_re[0], hMdEnc->spar_md.band_coeffs[b].P_quant_re, num_ch ); } + for ( i = 0; i < num_ch - 1; i++ ) { hMdEnc->spar_md.band_coeffs[b].pred_quant_re[i] = 0; } + ivas_spar_quant_pred_coeffs_dtx( &hMdEnc->spar_md, hMdEnc->spar_md.band_coeffs[b].pred_re, ndm, hMdEnc->spar_md.band_coeffs_idx[b].pred_index_re, num_ch - 1, hMdEnc->spar_md.band_coeffs[b].pred_quant_re ); } } @@ -1376,7 +1374,7 @@ static void ivas_get_arith_coded_bs( const int16_t qsi, const int16_t planarCP ) { - int16_t i, any_diff; + int16_t i, j, any_diff; ivas_cell_dim_t pred_cell_dims[IVAS_MAX_NUM_BANDS]; ivas_cell_dim_t drct_cell_dims[IVAS_MAX_NUM_BANDS]; ivas_cell_dim_t decd_cell_dims[IVAS_MAX_NUM_BANDS]; @@ -1417,7 +1415,6 @@ static void ivas_get_arith_coded_bs( } if ( hMdEnc->spar_hoa_md_flag ) { - int16_t j; for ( i = 0; i < nB; i++ ) { if ( i >= SPAR_DIRAC_SPLIT_START_BAND ) @@ -1426,6 +1423,7 @@ static void ivas_get_arith_coded_bs( { hMdEnc->spar_md.band_coeffs_idx[i].pred_index_re[j] = hMdEnc->spar_md.band_coeffs_idx[i].pred_index_re[j + ( FOA_CHANNELS - 1 )]; + if ( any_diff == 1 ) { hMdEnc->spar_md_prior.band_coeffs_idx_mapped[i].pred_index_re[j] = @@ -1439,8 +1437,7 @@ static void ivas_get_arith_coded_bs( if ( any_diff == 1 ) { - ivas_copy_band_coeffs_idx_to_arr( hMdEnc->spar_md_prior.band_coeffs_idx_mapped, nB, - symbol_arr_old_re, pred_cell_dims, PRED_COEFF, planarCP ); + ivas_copy_band_coeffs_idx_to_arr( hMdEnc->spar_md_prior.band_coeffs_idx_mapped, nB, symbol_arr_old_re, pred_cell_dims, PRED_COEFF, planarCP ); } ivas_arith_encode_cmplx_cell_array( &hMdEnc->arith_coeffs.pred_arith_re[qsi], &hMdEnc->arith_coeffs.pred_arith_re_diff[qsi], pDo_diff, nB, @@ -1448,7 +1445,6 @@ static void ivas_get_arith_coded_bs( if ( hMdEnc->spar_hoa_md_flag ) { - int16_t j; for ( i = 0; i < nB; i++ ) { if ( i >= SPAR_DIRAC_SPLIT_START_BAND ) @@ -1494,8 +1490,7 @@ static void ivas_get_arith_coded_bs( if ( any_diff == 1 ) { - ivas_copy_band_coeffs_idx_to_arr( hMdEnc->spar_md_prior.band_coeffs_idx_mapped, nB, - symbol_arr_old_re, decd_cell_dims, DECD_COEFF, planarCP ); + ivas_copy_band_coeffs_idx_to_arr( hMdEnc->spar_md_prior.band_coeffs_idx_mapped, nB, symbol_arr_old_re, decd_cell_dims, DECD_COEFF, planarCP ); } if ( planarCP ) @@ -1509,13 +1504,11 @@ static void ivas_get_arith_coded_bs( ivas_arith_encode_cmplx_cell_array( &hMdEnc->arith_coeffs.decd_arith_re[qsi], &hMdEnc->arith_coeffs.decd_arith_re_diff[qsi], pDo_diff, nB, symbol_arr_re, symbol_arr_old_re, decd_cell_dims, hMetaData, any_diff ); - ivas_copy_band_coeffs_idx_to_arr( hMdEnc->spar_md.band_coeffs_idx, nB, symbol_arr_re, decx_cell_dims, DECX_COEFF, planarCP ); if ( any_diff == 1 ) { - ivas_copy_band_coeffs_idx_to_arr( hMdEnc->spar_md_prior.band_coeffs_idx_mapped, nB, - symbol_arr_old_re, decx_cell_dims, DECX_COEFF, planarCP ); + ivas_copy_band_coeffs_idx_to_arr( hMdEnc->spar_md_prior.band_coeffs_idx_mapped, nB, symbol_arr_old_re, decx_cell_dims, DECX_COEFF, planarCP ); } return; @@ -1638,13 +1631,16 @@ static void ivas_spar_quant_pred_coeffs_dtx( int16_t i; int16_t q_lvl; float pr_min_max[2]; + pr_min_max[0] = pSpar_md->min_max[0]; pr_min_max[1] = pSpar_md->min_max[1]; + for ( i = 0; i < dim1; i++ ) { q_lvl = dtx_pr_real_q_levels[ndm - 1][i]; ivas_quantise_real_values( &pValues[i], q_lvl, pr_min_max[0], pr_min_max[1], &pIndex[i], &pQuant[i], 1 ); } + return; } @@ -1665,6 +1661,7 @@ static void ivas_quant_p_per_band_dtx( { int16_t i; int16_t dim = num_ch - num_dmx; + if ( num_dec == num_ch - 1 ) { for ( i = 0; i < dim; i++ ) @@ -1680,10 +1677,12 @@ static void ivas_quant_p_per_band_dtx( { assert( !"Not Supported!" ); } + for ( i = 0; i < dim; i++ ) { ivas_quantise_real_values( &pP_mat[i], dtx_pd_real_q_levels[num_ch - num_dec - 1][i], dtx_pd_real_min_max[0], dtx_pd_real_min_max[1], &ppIdx_pd[i], &pP_out[i], 1 ); } + return; } @@ -1762,6 +1761,7 @@ static void ivas_write_parameter_bitstream_dtx( { int16_t pr_q_lvls1, pr_q_lvls2; int16_t pr_idx1, pr_idx2, pr_pr_bits; + pr_q_lvls1 = dtx_pr_real_q_levels[ndm - 1][pr_idx_1 - 1]; pr_q_lvls2 = dtx_pr_real_q_levels[ndm - 1][pr_idx_2 - 1]; val = pr_min_max[0]; @@ -1814,6 +1814,7 @@ static void ivas_quant_pred_coeffs_per_band( const int16_t num_ch ) { ivas_quantise_real_values( pband_coeffs->pred_re, pQs->PR.q_levels[0], pQs->PR.min, pQs->PR.max, pBand_coeffs_idx->pred_index_re, pband_coeffs->pred_quant_re, ( num_ch - 1 ) ); + return; } @@ -1900,5 +1901,6 @@ static void ivas_quant_p_per_band( fprintf(stderr, "\n\n");*/ #endif ivas_quantise_real_values( pband_coeffs->P_re, pQs->P_r.q_levels[0], pQs->P_r.min, pQs->P_r.max, pBand_coeffs_idx->decd_index_re, pband_coeffs->P_quant_re, num_ch - 1 ); + return; } -- GitLab From 76d5747ca95b55a685acb38bb693fd6733252569 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 7 Nov 2022 12:36:47 +0100 Subject: [PATCH 08/13] formatting --- lib_dec/acelp_core_switch_dec.c | 3 +-- lib_enc/acelp_core_switch_enc.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib_dec/acelp_core_switch_dec.c b/lib_dec/acelp_core_switch_dec.c index 98854527e6..be34a95e31 100644 --- a/lib_dec/acelp_core_switch_dec.c +++ b/lib_dec/acelp_core_switch_dec.c @@ -158,8 +158,7 @@ ivas_error acelp_core_switch_dec( * Excitation decoding *----------------------------------------------------------------*/ - config_acelp1( DEC, st->total_brate, cbrate, st->core, -1, -1, st->last_L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, GENERIC, -1, -1, &decode_bwe /* dummy */, &i, st->element_mode, &i /*dummy*/, 0, 0, st->idchan, 0, 0, 0 /*st->GSC_IVAS_mode*/ - ); + config_acelp1( DEC, st->total_brate, cbrate, st->core, -1, -1, st->last_L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, GENERIC, -1, -1, &decode_bwe /* dummy */, &i, st->element_mode, &i /*dummy*/, 0, 0, st->idchan, 0, 0, 0 /*st->GSC_IVAS_mode*/ ); decod_gen_voic_core_switch( st, L_frame_for_cs, 0, Aq, exc, cbrate ); diff --git a/lib_enc/acelp_core_switch_enc.c b/lib_enc/acelp_core_switch_enc.c index 52c955732c..efabd35882 100644 --- a/lib_enc/acelp_core_switch_enc.c +++ b/lib_enc/acelp_core_switch_enc.c @@ -151,8 +151,7 @@ void acelp_core_switch_enc( * Excitation encoding *----------------------------------------------------------------*/ - config_acelp1( ENC, st->total_brate, cbrate, st->core, -1, -1, st->last_L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, GENERIC, -1, -1, &j, &i, st->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st->idchan, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ - ); + config_acelp1( ENC, st->total_brate, cbrate, st->core, -1, -1, st->last_L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, GENERIC, -1, -1, &j, &i, st->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st->idchan, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); encod_gen_voic_core_switch( st, st->last_L_frame, inp, Aq, A, T_op, st->voicing, exc, cbrate ); -- GitLab From 99944a885b59bc0b50a400b252def785da109cc2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 8 Nov 2022 10:19:08 +0100 Subject: [PATCH 09/13] [maintenance] formatting, comments --- lib_com/ivas_sba_config.c | 5 +++++ lib_dec/ivas_sba_dec.c | 8 +++----- lib_enc/ivas_sba_enc.c | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index 5b6cfd48cb..64635577b4 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -71,26 +71,31 @@ SBA_MODE ivas_sba_mode_select( return sba_mode; } + #ifdef SBA_BR_SWITCHING /*-------------------------------------------------------------------* * get_sba_reinit_flag() * * Get SBA reinitialisation flag *-------------------------------------------------------------------*/ + int16_t get_sba_reinit_flag( int32_t ivas_total_bitrate, /* i : Current bitrate */ int32_t last_ivas_total_brate /* i : Previous bitrate */ ) { int16_t sba_reinit_flag; + sba_reinit_flag = 0; if ( ivas_total_bitrate != last_ivas_total_brate && ( last_ivas_total_brate > IVAS_SID_5k2 ) && ( ivas_total_bitrate > IVAS_SID_5k2 ) ) { sba_reinit_flag = 1; } + return sba_reinit_flag; } #endif + /*-------------------------------------------------------------------* * ivas_sba_config() * diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index b027dcff77..2681493f08 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -309,11 +309,7 @@ void ivas_ism2sba( elevation = (int16_t) ( hIsmMetaData[i]->elevation + 0.5f ); /*get HOA gets for direction (ACN/SN3D)*/ - ivas_dirac_dec_get_response( - azimuth, - elevation, - gains, - sba_order ); + ivas_dirac_dec_get_response( azimuth, elevation, gains, sba_order ); for ( j = 0; j < sba_num_chans; j++ ) { @@ -335,6 +331,8 @@ void ivas_ism2sba( return; } + + #ifdef SBA_BR_SWITCHING /*-------------------------------------------------------------------* * ivas_sba_dec_reinit() diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index d987b41d51..003baa0fa0 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -313,6 +313,8 @@ ivas_error ivas_sba_enc_reinit( return error; } #endif + + /*-------------------------------------------------------------------* * ivas_sba_enc_reconfigure() * -- GitLab From cc9332825cfe8885fcb660e21c605e708458486e Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 8 Nov 2022 18:35:21 +0100 Subject: [PATCH 10/13] apply clang-format --- lib_dec/ivas_tcx_core_dec.c | 16 ++++++++-------- lib_enc/lsf_enc.c | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index a55ba37e02..3ca3033cb4 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -780,17 +780,17 @@ void stereo_tcx_core_dec( /*-----------------------------------------------------------------* * Function dec_prm_tcx() - * + * * Decode TCX parameters *-----------------------------------------------------------------*/ static void dec_prm_tcx( - Decoder_State *st, /* i/o: decoder memory state */ - int16_t param[], /* o : decoded parameters */ - int16_t param_lpc[], /* o : LPC parameters */ - int16_t *total_nbbits, /* i/o: number of bits / decoded bits */ - const int16_t last_element_mode, - int16_t *bitsRead /* o : number of read bits */ + Decoder_State *st, /* i/o: decoder memory state */ + int16_t param[], /* o : decoded parameters */ + int16_t param_lpc[], /* o : LPC parameters */ + int16_t *total_nbbits, /* i/o: number of bits / decoded bits */ + const int16_t last_element_mode, /* i : last element mode */ + int16_t *bitsRead /* o : number of read bits */ ) { int16_t start_bit_pos, bits_common; @@ -914,7 +914,7 @@ static void dec_prm_tcx( /*-----------------------------------------------------------------* * Function stereo_tcx_dec_mode_switch_reconf() - * + * * Reconfigure stereo TCX parameters *-----------------------------------------------------------------*/ diff --git a/lib_enc/lsf_enc.c b/lib_enc/lsf_enc.c index 1cbe2352a7..8e561c76e8 100644 --- a/lib_enc/lsf_enc.c +++ b/lib_enc/lsf_enc.c @@ -1019,7 +1019,7 @@ void first_VQstages( dist[0] = dist_buf; dist[1] = dist_buf + maxC; - set_s( idx_buf, 0, (const int16_t) ( 2 * stagesVQ * maxC ) ); + set_s( idx_buf, 0, 2 * stagesVQ * maxC ); set_s( parents, 0, maxC ); /* Set up inital distance vector */ -- GitLab From 0786425eece517828dbe57b7b96d7e0e76186227 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 8 Nov 2022 18:44:11 +0100 Subject: [PATCH 11/13] cleaning --- lib_com/tools.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/tools.c b/lib_com/tools.c index 3e6e56d5a0..2ab9952c0c 100644 --- a/lib_com/tools.c +++ b/lib_com/tools.c @@ -1313,7 +1313,7 @@ float var( float v; int16_t i; - m = mean( x, (const int16_t) len ); + m = mean( x, len ); v = 0.0f; for ( i = 0; i < len; i++ ) -- GitLab From 7664fbd673bb905884e02618a38f921bc8ab19a9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 9 Nov 2022 09:07:57 +0100 Subject: [PATCH 12/13] revert change of declaration of 'num_fade_frames' --- lib_dec/ivas_spar_md_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 6235cc3bb4..6b74f70f4f 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -2255,7 +2255,6 @@ static void ivas_spar_dec_compute_ramp_down_post_matrix( const int16_t bfi ) { int16_t num_in_ch, num_out_ch, i, j, b, i_ts; - int16_t num_fade_frames; int16_t gain_dB; float gain; float post_matrix[IVAS_SPAR_MAX_CH]; @@ -2279,6 +2278,7 @@ static void ivas_spar_dec_compute_ramp_down_post_matrix( if ( hMdDec->spar_plc_num_lost_frames > ivas_spar_dec_plc_num_frames_keep ) { + int16_t num_fade_frames; num_fade_frames = max( hMdDec->spar_plc_num_lost_frames - ivas_spar_dec_plc_num_frames_keep, 0 ); gain_dB = -min( num_fade_frames, ivas_spar_dec_plc_max_num_frames_ramp_down ) * ivas_spar_dec_plc_per_frame_ramp_down_gain_dB; gain = powf( 10, ( ( (float) gain_dB ) / 20 ) ); -- GitLab From ec67e270c8ca35db73a3c99450004e8160aff250 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 9 Nov 2022 09:57:45 +0100 Subject: [PATCH 13/13] revert change of declarations --- lib_dec/ivas_spar_md_dec.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 6b74f70f4f..f316c746cf 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -2136,7 +2136,7 @@ static void ivas_spar_md_fill_invalid_bands( const int16_t sba_order /* i : SBA order */ ) { - int16_t i, j, b, all_valid, i_ts; + int16_t i, j, b, all_valid; int16_t valid_band_idx[IVAS_MAX_NUM_BANDS], idx = -1; int16_t last_valid_band_idx[IVAS_MAX_NUM_BANDS]; float w = 0; @@ -2224,6 +2224,7 @@ static void ivas_spar_md_fill_invalid_bands( if ( valid_bands[b] == 0 ) { + int16_t i_ts; for ( i = 0; i < num_channels; i++ ) { for ( j = 0; j < num_channels; j++ ) @@ -2254,10 +2255,7 @@ static void ivas_spar_dec_compute_ramp_down_post_matrix( const int16_t num_bands_out, const int16_t bfi ) { - int16_t num_in_ch, num_out_ch, i, j, b, i_ts; - int16_t gain_dB; - float gain; - float post_matrix[IVAS_SPAR_MAX_CH]; + int16_t num_in_ch, num_out_ch, i, j, b; num_in_ch = hMdDec->spar_md_cfg.num_umx_chs; num_out_ch = hMdDec->spar_md_cfg.num_umx_chs; @@ -2279,6 +2277,10 @@ static void ivas_spar_dec_compute_ramp_down_post_matrix( if ( hMdDec->spar_plc_num_lost_frames > ivas_spar_dec_plc_num_frames_keep ) { int16_t num_fade_frames; + int16_t gain_dB; + float gain; + float post_matrix[IVAS_SPAR_MAX_CH]; + num_fade_frames = max( hMdDec->spar_plc_num_lost_frames - ivas_spar_dec_plc_num_frames_keep, 0 ); gain_dB = -min( num_fade_frames, ivas_spar_dec_plc_max_num_frames_ramp_down ) * ivas_spar_dec_plc_per_frame_ramp_down_gain_dB; gain = powf( 10, ( ( (float) gain_dB ) / 20 ) ); @@ -2290,7 +2292,7 @@ static void ivas_spar_dec_compute_ramp_down_post_matrix( } /* apply the post matrix */ - for ( i_ts = 0; i_ts < MAX_PARAM_SPATIAL_SUBFRAMES; i_ts++ ) + for ( int16_t i_ts = 0; i_ts < MAX_PARAM_SPATIAL_SUBFRAMES; i_ts++ ) { for ( i = 0; i < num_out_ch; i++ ) { @@ -2378,9 +2380,6 @@ static void ivas_parse_parameter_bitstream_dtx( int16_t pr_q_lvls, pr, pd, pd_q_lvls, pr_pd_bits; int16_t pr_q_lvls1, pr_q_lvls2, pr_idx1, pr_idx2, pr_pr_bits; int16_t zero_pad_bits, sid_bits_len; - int16_t pr_idx_1, pr_idx_2, pd_idx_1, pd_idx_2; - uint16_t value; - sid_bits_len = st0->next_bit_pos; pr_min_max[0] = pSpar_md->min_max[0]; pr_min_max[1] = pSpar_md->min_max[1]; @@ -2392,6 +2391,9 @@ static void ivas_parse_parameter_bitstream_dtx( for ( j = 0; j < FOA_CHANNELS - 1; j++ ) { + int16_t pr_idx_1, pr_idx_2, pd_idx_1, pd_idx_2; + uint16_t value; + pr_idx_1 = pr_pr_idx_pairs[ndm - 1][j][0]; pr_idx_2 = pr_pr_idx_pairs[ndm - 1][j][1]; pd_idx_1 = pr_pd_idx_pairs[ndm - 1][j][0]; -- GitLab