diff --git a/apps/encoder.c b/apps/encoder.c index 4bd5e3ab4bf84ba4efb1ce2c347d344c20ca7b5a..df0cf8f9cac33660d8744d8573734d3864664ed6 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -122,7 +122,7 @@ typedef struct #ifdef DEBUG_AGC_ENCODER_CMD_OPTION IVAS_ENC_AGC agc; -#endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ +#endif bool pca; #ifdef DEBUG_FOA_AGC FILE *agcBitstream; /* temporary */ @@ -888,7 +888,7 @@ static void initArgStruct( EncArguments *arg ) #ifdef DEBUG_AGC_ENCODER_CMD_OPTION arg->agc = IVAS_ENC_AGC_UNDEFINED; -#endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ +#endif arg->pca = false; #ifdef DEBUG_FOA_AGC arg->agcBitstream = NULL; @@ -1660,7 +1660,7 @@ static void usage_enc( void ) fprintf( stdout, "-agc op : SBA Adaptive gain control, op = (0, 1). \n" ); fprintf( stdout, " By default op is 1 (activated) for bitrates between 24400 and 32000,\n" ); fprintf( stdout, " otherwise it is 0 (deactivated) for all other bitrates\n" ); -#endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ +#endif fprintf( stdout, "-bypass mode : SBA PCA by-pass, mode = (1, 2), 1 = PCA off, 2 = signal adaptive, default is 1\n" ); #ifdef DEBUGGING diff --git a/lib_com/cnst.h b/lib_com/cnst.h index be668b01c774ac67a50dff6d939a44bdac918426..eda4d0f1201e5a04f212bc71167742e95e5fe539 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -890,7 +890,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 */ @@ -1022,6 +1022,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_cnst.h b/lib_com/ivas_cnst.h index b42feca458c3be1f82883e0d9a88488fc1d57cbe..d56a0bec36c8a3df2f69ae1a379bc8afe81fbf04 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 @@ -1420,36 +1422,33 @@ 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 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 */ -} 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 @@ -1459,13 +1458,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 @@ -1475,8 +1467,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 4c986e84e546943d0d806c43a73407e9dfa80a99..61797d6746defa488ae35dc037f3607b59d9a5a4 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() * diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 82697d37c68d716e9110b10e97e0b7a4fd7f648e..b625646b5ba9602e0f33a9a13afe5f9fb07daf16 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3918,7 +3918,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 */ ); @@ -3982,8 +3982,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 */ ); @@ -4064,8 +4063,8 @@ void ivas_enc_cov_handler_process( float *cov_dtx_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 nchan_inp, + const int16_t end_band, + const int16_t nchan_inp, const int16_t dtx_vad, const int16_t transient_det ); @@ -4087,8 +4086,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 ); @@ -4560,7 +4558,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 */ @@ -4569,7 +4567,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_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index 5b6cfd48cbbff89d1286ab78e69f63d4d3148b2c..64635577b446f98d9c13a07a2d45ab263890cd1e 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_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index bf6e3908d508e58f85bc610d469a110dd276dac1..31db5f1bbc7e1275f14996a2a6959954712d8c39 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_com/tools.c b/lib_com/tools.c index 3e6e56d5a0aed488b98d1e843612187b7f137b69..2ab9952c0cf7ee4eee43e616cd7b1febde887380 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++ ) diff --git a/lib_dec/acelp_core_switch_dec.c b/lib_dec/acelp_core_switch_dec.c index 98854527e6d6c59fe8842f512fad63e198859163..be34a95e319ddfb93953c9700ce72c5791378231 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_dec/core_dec_switch.c b/lib_dec/core_dec_switch.c index 7b281436664c54d1823035167d33dd2f86dd2f0c..c1f8e590fbde31b39ec3024729aeb425938dd8ee 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_rotation.c b/lib_dec/ivas_rotation.c index 77809d8270e9e2b30a50800b5052fc2b696d827b..702dfd08a0a46685f40830045306227403302099 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++ ) { diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index b027dcff774b7be16a886349a2f49860c016c625..2681493f08ceb5cb88a03ac578d89095a4657406 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_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 0feda3a83c863cfb1035e7030f89ad70d8197c69..f316c746cf4635161a83859c498416dc27ff31f4 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -1207,7 +1207,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++ ) { diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 52c95fe4412b9896f0be9ecdb0b38b628df0df3f..3ca3033cb4a5c420faeb9175ae6e1fca9dd6e67e 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -779,18 +779,18 @@ void stereo_tcx_core_dec( /*-----------------------------------------------------------------* - * Function dec_prm_tcx() * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - * decode TCX parameters + * 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; @@ -912,10 +912,17 @@ static void dec_prm_tcx( return; } +/*-----------------------------------------------------------------* + * 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; @@ -942,4 +949,6 @@ 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; } diff --git a/lib_enc/acelp_core_switch_enc.c b/lib_enc/acelp_core_switch_enc.c index 52c955732c9d8959831a2e83fd5504c5ba642125..efabd35882de2da245307f8d97fb67eff1502175 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 ); diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index 96a005a0b3370d56b1e52f39f0c253293c55ad74..223d23d695cb720917abc71225a3c91e7c13d28c 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 ); } @@ -507,9 +508,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]; @@ -890,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_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index de816f3bf77f0308e8de426956d3821bda5c58d5..8d127e17d5fd20311e32a9d52e0cb736c945b899 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_sba_enc.c b/lib_enc/ivas_sba_enc.c index d987b41d51f40535f125f6d7693cbacbd7842ef4..003baa0fa03e1573cabaada8765d68696ef558c9 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() * diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 99f198ff616fdd72dc5399608adf6b368ac6861b..b08eeb5e4bf26d821e54fd4e48cc46ec483520f1 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -502,7 +502,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]; diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index e6e8b0db6118e98b212df9352f1978495555bcea..09c766b58106020f1f85a5cb8e320366021811a0 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -545,7 +545,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 */ ) @@ -616,7 +616,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 ) @@ -638,8 +637,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]; } } } @@ -750,15 +748,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 ); } } @@ -1344,7 +1343,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]; @@ -1385,7 +1384,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 ) @@ -1394,6 +1392,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] = @@ -1407,8 +1406,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, @@ -1416,7 +1414,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 ) @@ -1462,8 +1459,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 ) @@ -1477,13 +1473,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; @@ -1606,13 +1600,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; } @@ -1633,6 +1630,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++ ) @@ -1648,10 +1646,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; } @@ -1730,6 +1730,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]; @@ -1782,6 +1783,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; } @@ -1868,5 +1870,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; } diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 4dff969a4f3928fa04de45b2c27148731a4a2e89..e7957a47e5d26e43e9d8fccacf943c75e5f874eb 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -454,8 +454,8 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ #ifdef DEBUG_AGC_ENCODER_CMD_OPTION const IVAS_ENC_AGC Opt_AGC_ON, /* i : AGC on/off/undefined flag */ -#endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ - const bool Opt_PCA_ON /* i : PCA option flag */ +#endif + const bool Opt_PCA_ON /* i : PCA option flag */ #ifdef DEBUG_SBA_AUDIO_DUMP , int16_t *numTransportChannels @@ -485,7 +485,7 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( { return error; } -#endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ +#endif hEncoderConfig->Opt_PCA_ON = (int16_t) Opt_PCA_ON; @@ -886,7 +886,7 @@ static ivas_error configureEncoder( { return IVAS_ERROR( IVAS_ERR_NOT_SUPPORTED_OPTION, "AGC supported in SBA format at bitrates >= 24.4 kbps only." ); } -#endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ +#endif if ( hEncoderConfig->Opt_PCA_ON && !( hEncoderConfig->ivas_format == SBA_FORMAT && hEncoderConfig->ivas_total_brate == PCA_BRATE && hEncoderConfig->sba_order == SBA_FOA_ORDER ) ) @@ -1523,7 +1523,7 @@ static ivas_error printConfigInfo_enc( } #else fprintf( stdout, "- AGC default mode " ); -#endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ +#endif fprintf( stdout, "\n" ); } else if ( hEncoderConfig->ivas_format == MASA_FORMAT ) @@ -2217,7 +2217,7 @@ static void init_encoder_config( hEncoderConfig->sba_planar = 0; #ifdef DEBUG_AGC_ENCODER_CMD_OPTION hEncoderConfig->Opt_AGC_ON = SBA_AGC_DEFAULT; -#endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ +#endif hEncoderConfig->Opt_PCA_ON = 0; return; diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 09be11c6c816739c5b780c8be56d896c5b32ef94..fd0a4adfa2cba4785fada406fcc3d2b10a8f141f 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -130,7 +130,7 @@ typedef enum _IVAS_ENC_AGC IVAS_ENC_AGC_ENABLED, IVAS_ENC_AGC_UNDEFINED = 0xffff } IVAS_ENC_AGC; -#endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ +#endif /*---------------------------------------------------------------------* * Encoder structures @@ -199,7 +199,7 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ #ifdef DEBUG_AGC_ENCODER_CMD_OPTION const IVAS_ENC_AGC Opt_AGC_ON, /* i : AGC on/off/undefined flag */ -#endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ +#endif const bool Opt_PCA_ON /* i : PCA option flag */ #ifdef DEBUG_SBA_AUDIO_DUMP , diff --git a/lib_enc/lsf_enc.c b/lib_enc/lsf_enc.c index a6d973b36ef654c53bb9f23aae09e7343b982410..8e561c76e87315de90530dda3d536415de1ddf78 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, 2 * stagesVQ * maxC ); set_s( parents, 0, maxC ); /* Set up inital distance vector */