From 2b2fcff6ffe1133792dddff43ab9fbf992c5868f Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 20 Mar 2024 07:07:32 +0530 Subject: [PATCH] Sub-functions integration - 4 [x]Some sub-function conversion in MASA Path, BASOP and instrumentation changes. [x]td_bwe_dec_init_fx updates [x]swb_bwe_dec converted to fixed point [x]ISM path updates: - Integrated updt_dec_common function under ivas_core_dec function. - Removed some duplicate variables. - Converted all the calls to delay_signal_float function for ISM path. - save_synthesis_hq_fec float function call removed. [x] Intermediate conversions removal for aclep_core_dec --- lib_com/bits_alloc.c | 2 + lib_com/bits_alloc_fx.c | 73 ++ lib_com/bitstream.c | 3 + lib_com/gs_gains_fx.c | 20 +- lib_com/gs_preech.c | 4 +- lib_com/ivas_dirac_com.c | 119 ++- lib_com/ivas_masa_com.c | 74 +- lib_com/ivas_omasa_com.c | 1 + lib_com/ivas_prot.h | 35 +- lib_com/ivas_prot_fx.h | 33 + lib_com/ivas_qmetadata_com.c | 137 ++- lib_com/ivas_qspherical_com.c | 82 +- lib_com/ivas_tools.c | 87 +- lib_com/prot.h | 45 +- lib_com/prot_fx1.h | 15 + lib_com/prot_fx2.h | 28 +- lib_com/swb_bwe_com_fx.c | 4 + lib_com/tools.c | 71 ++ lib_com/tools_fx.c | 7 +- lib_com/wtda.c | 159 ++++ lib_dec/FEC_HQ_core_fx.c | 12 +- lib_dec/FEC_clas_estim_fx.c | 14 +- lib_dec/FEC_fx.c | 48 +- lib_dec/FEC_pitch_estim_fx.c | 2 +- lib_dec/acelp_core_dec.c | 16 +- lib_dec/acelp_core_dec_fx.c | 94 +- lib_dec/acelp_core_dec_ivas_fx.c | 996 +++++++++++---------- lib_dec/acelp_core_switch_dec_fx.c | 10 +- lib_dec/amr_wb_dec_fx.c | 48 +- lib_dec/cng_dec_fx.c | 30 +- lib_dec/core_dec_init_fx.c | 6 +- lib_dec/core_switching_dec.c | 10 + lib_dec/core_switching_dec_fx.c | 40 +- lib_dec/dec_LPD_fx.c | 26 +- lib_dec/dec_ace_fx.c | 16 +- lib_dec/dec_acelp_tcx_main_fx.c | 6 +- lib_dec/dec_gen_voic_fx.c | 48 +- lib_dec/dec_higher_acelp_fx.c | 8 +- lib_dec/dec_nelp_fx.c | 2 +- lib_dec/dec_pit_exc_fx.c | 12 +- lib_dec/dec_prm_fx.c | 4 +- lib_dec/dec_tcx_fx.c | 2 +- lib_dec/dec_tran_fx.c | 12 +- lib_dec/dec_uv_fx.c | 14 +- lib_dec/decision_matrix_dec_fx.c | 26 +- lib_dec/er_dec_acelp_fx.c | 32 +- lib_dec/er_dec_tcx_fx.c | 22 +- lib_dec/er_util_fx.c | 12 +- lib_dec/evs_dec.c | 1 + lib_dec/evs_dec_fx.c | 38 +- lib_dec/gain_dec_fx.c | 6 +- lib_dec/gs_dec_amr_wb_fx.c | 6 +- lib_dec/gs_dec_fx.c | 68 +- lib_dec/hq_core_dec_fx.c | 4 +- lib_dec/hq_lr_dec_fx.c | 4 +- lib_dec/init_dec.c | 13 +- lib_dec/init_dec_fx.c | 36 +- lib_dec/ivas_core_dec.c | 143 ++- lib_dec/ivas_dirac_dec.c | 4 +- lib_dec/ivas_masa_dec.c | 124 +-- lib_dec/ivas_qmetadata_dec.c | 1252 ++++++++++++++++++--------- lib_dec/ivas_qspherical_dec.c | 35 +- lib_dec/ivas_sce_dec.c | 3 + lib_dec/ivas_stereo_dft_dec_fx.c | 5 +- lib_dec/ivas_stereo_icbwe_dec.c | 14 +- lib_dec/ivas_stereo_switching_dec.c | 28 +- lib_dec/ivas_tcx_core_dec.c | 4 +- lib_dec/ivas_td_low_rate_dec.c | 8 +- lib_dec/lsf_dec_fx.c | 2 +- lib_dec/lsf_msvq_ma_dec_fx.c | 6 +- lib_dec/nelp_dec_fx.c | 10 +- lib_dec/pitch_extr_fx.c | 2 +- lib_dec/post_dec_fx.c | 2 +- lib_dec/rst_dec_fx.c | 4 +- lib_dec/stat_dec.h | 29 +- lib_dec/stat_noise_uv_dec_fx.c | 2 +- lib_dec/swb_bwe_dec.c | 594 +++++++++++++ lib_dec/swb_bwe_dec_fx.c | 20 +- lib_dec/swb_tbe_dec_fx.c | 46 +- lib_dec/updt_dec_fx.c | 145 ++-- lib_dec/voiced_dec_fx.c | 2 +- lib_enc/enc_gen_voic_fx.c | 2 +- lib_enc/enc_nelp_fx.c | 2 +- lib_enc/enc_pit_exc_fx.c | 2 +- lib_enc/enc_ppp_fx.c | 2 +- lib_enc/evs_enc.c | 3 + lib_enc/init_enc.c | 3 + lib_enc/init_enc_fx.c | 2 +- lib_enc/inov_enc_fx.c | 2 +- lib_enc/ivas_cpe_enc.c | 3 + lib_enc/ivas_ism_enc.c | 3 + lib_enc/ivas_qmetadata_enc.c | 3 + lib_enc/ivas_sce_enc.c | 3 + lib_enc/pit_enc_fx.c | 2 +- lib_enc/prot_fx_enc.h | 2 +- lib_enc/stat_enc.h | 2 +- lib_enc/swb_tbe_enc_fx.c | 10 +- 97 files changed, 3651 insertions(+), 1622 deletions(-) diff --git a/lib_com/bits_alloc.c b/lib_com/bits_alloc.c index fb7a5bfbd..973a114b1 100644 --- a/lib_com/bits_alloc.c +++ b/lib_com/bits_alloc.c @@ -1428,6 +1428,7 @@ static int16_t allocate_unused( *--------------------------------------------------------------------*/ /*! r: ACELP16k flag */ +#ifndef IVAS_FLOAT_FIXED int16_t set_ACELP_flag_IVAS( const int16_t element_mode, /* i : element mode */ const int32_t element_brate, /* i : element bitrate */ @@ -1485,3 +1486,4 @@ int16_t set_ACELP_flag_IVAS( return 0; } } +#endif diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c index 11868e523..c556a8386 100644 --- a/lib_com/bits_alloc_fx.c +++ b/lib_com/bits_alloc_fx.c @@ -1700,4 +1700,77 @@ Word16 set_ACELP_flag( } } #endif + +/*-------------------------------------------------------------------* + * set_ACELP_flag_IVAS() + * + * set ACELP@16kHz flag + *--------------------------------------------------------------------*/ + + /*! r: ACELP16k flag */ +#ifdef IVAS_FLOAT_FIXED +Word16 set_ACELP_flag_IVAS( + const Word16 element_mode, /* i : element mode */ + const Word32 element_brate, /* i : element bitrate */ + const Word32 total_brate, /* i : total bitrate per channel */ + const Word16 idchan, /* i : Channel id */ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 cng_type /* i : CNG type */ +) +{ + test(); + test(); + test(); + test(); + IF( EQ_16( element_mode, IVAS_CPE_DFT ) && EQ_16( idchan, 0 ) && LE_32( total_brate, SID_2k40 ) && EQ_16( bwidth, WB ) && EQ_16( cng_type, LP_CNG ) ) + { + return 1; + } + ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) ) + { + test(); + test(); + test(); + IF( GE_32( element_brate, IVAS_24k4 ) && EQ_16( idchan, 0 ) && ( EQ_16( tdm_LRTD_flag, 0 ) || GT_32( element_brate, IVAS_24k4 ) ) ) + { + return 1; + } + ELSE + { + return 0; + } + } + ELSE IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) + { + IF( GE_32( element_brate, IVAS_24k4 ) ) + { + return 1; + } + ELSE + { + return 0; + } + } + ELSE IF( EQ_16( element_mode, IVAS_SCE ) ) + { + IF( GE_32( element_brate, SCE_CORE_16k_LOW_LIMIT ) ) + { + return 1; + } + ELSE + { + return 0; + } + } + ELSE IF( GE_32( total_brate, ACELP_16k_LOW_LIMIT ) ) /* EVS_MONO */ + { + return 1; + } + ELSE + { + return 0; + } +} +#endif /*#endif IVAS_CODE*/ \ No newline at end of file diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index d78d7bc5f..d44daf6ad 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -47,6 +47,9 @@ #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif #define STEP_MAX_NUM_INDICES 100 /* increase the maximum number of allowed indices in the list by this amount */ diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index db0f0f1db..3d41b89eb 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -439,7 +439,7 @@ static void GSC_gain_adj_ivas_fx( /*--------------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ /* _ (Word16) pvq_bits_fx : core used Q0 */ -/* _ (Word16) coder_type_fx : coding type Q0 */ +/* _ (Word16) coder_type : coding type Q0 */ /* _ (Word16) core_fx : core used Q0 */ /* _ (Word16) bwidth_fx : input signal bandwidth Q0 */ /*--------------------------------------------------------------------------*/ @@ -457,7 +457,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ Word16 y_gainQ_fx[], /* o : quantized gain per band */ const Word32 core_brate_fx, /* i : core used */ Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */ - const Word16 coder_type_fx, /* i : coding type */ + const Word16 coder_type, /* i : coding type */ const Word16 bwidth_fx /* i : input signal bandwidth */ ) { @@ -467,7 +467,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ test(); test(); - IF( (EQ_16(coder_type_fx,AUDIO)||EQ_16(coder_type_fx,INACTIVE))&&EQ_16(bwidth_fx,NB)) + IF( (EQ_16(coder_type,AUDIO)||EQ_16(coder_type,INACTIVE))&&EQ_16(bwidth_fx,NB)) { idx_g_fx = (Word16) get_next_indice( st_fx, 6 ); VDQ_vec_fx(&mean_4g_fx, Gain_meanNB_fx, Gain_mean_dicNB_fx, idx_g_fx, 1 ); @@ -493,7 +493,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ VDQ_vec_fx(y_gainQ_fx+6, Mean_dic_NB_fx+6, Gain_dic3_NBHR_fx, idx_g_fx, 4 ); } test(); - IF( LE_32(core_brate_fx,ACELP_9k60)&&EQ_16(coder_type_fx,INACTIVE)) + IF( LE_32(core_brate_fx,ACELP_9k60)&&EQ_16(coder_type,INACTIVE)) { /* Some energy is needed in high band for stat_noise_uv_enc to be functional in inactive speech */ @@ -585,7 +585,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ } /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ - GSC_gain_adj(coder_type_fx, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx); + GSC_gain_adj(coder_type, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx); return mean_4g_fx; @@ -599,7 +599,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ /*--------------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ /* _ (Word16) pvq_bits_fx : core used Q0 */ -/* _ (Word16) coder_type_fx : coding type Q0 */ +/* _ (Word16) coder_type : coding type Q0 */ /* _ (Word16) core_fx : core used Q0 */ /* _ (Word16) bwidth_fx : input signal bandwidth Q0 */ /*--------------------------------------------------------------------------*/ @@ -617,7 +617,7 @@ Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain * Word16 y_gainQ_fx[], /* o : quantized gain per band */ const Word32 core_brate_fx, /* i : core used */ Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */ - const Word16 coder_type_fx, /* i : coding type */ + const Word16 coder_type, /* i : coding type */ const Word16 bwidth_fx /* i : input signal bandwidth */ ) { @@ -632,7 +632,7 @@ Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain * test(); test(); - IF((EQ_16(coder_type_fx, AUDIO) || EQ_16(coder_type_fx, INACTIVE)) && EQ_16(bwidth_fx, NB)) + IF((EQ_16(coder_type, AUDIO) || EQ_16(coder_type, INACTIVE)) && EQ_16(bwidth_fx, NB)) { idx_g_fx = (Word16)get_next_indice(st_fx, 6); VDQ_vec_fx(&mean_4g_fx, Gain_meanNB_fx, Gain_mean_dicNB_fx, idx_g_fx, 1); @@ -658,7 +658,7 @@ Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain * VDQ_vec_fx(y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NBHR_fx, idx_g_fx, 4); } test(); - IF(LE_32(core_brate_fx, ACELP_9k60) && EQ_16(coder_type_fx, INACTIVE)) + IF(LE_32(core_brate_fx, ACELP_9k60) && EQ_16(coder_type, INACTIVE)) { /* Some energy is needed in high band for stat_noise_uv_enc to be functional in inactive speech */ @@ -770,7 +770,7 @@ Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain * } /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ - GSC_gain_adj_ivas_fx(coder_type_fx, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx); + GSC_gain_adj_ivas_fx(coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx); return mean_4g_fx; diff --git a/lib_com/gs_preech.c b/lib_com/gs_preech.c index 324c7562a..cab7caacf 100644 --- a/lib_com/gs_preech.c +++ b/lib_com/gs_preech.c @@ -145,7 +145,7 @@ void pre_echo_att_fx( Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/ const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) */ const Word16 Q_new, - const Word16 last_coder_type_fx, /* i : Last coding mode */ + const Word16 last_coder_type, /* i : Last coding mode */ const Word16 L_frame /* i : Frame length*/ ) { @@ -159,7 +159,7 @@ void pre_echo_att_fx( Word16 att_len; test(); - IF(GT_16(gsc_attack_flag_fx, 0) && EQ_16(last_coder_type_fx, AUDIO)) /*gsc_attack_flag_fx does not get set for all the test cases */ + IF(GT_16(gsc_attack_flag_fx, 0) && EQ_16(last_coder_type, AUDIO)) /*gsc_attack_flag_fx does not get set for all the test cases */ { /*-------------------------------------------------------------------------* * Find where the onset (attack) occurs by computing the energy per section diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 492ebfc37..ec8c3e400 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -475,38 +475,46 @@ void ivas_dirac_config_bands_fx( { Copy( DirAC_band_grouping_5, band_grouping, 5 + 1 ); } - ELSE IF(EQ_16( nbands, 6 ) ) + ELSE IF( EQ_16( nbands, 6 ) ) { Copy( DirAC_band_grouping_6, band_grouping, 6 + 1 ); } - ELSE IF(EQ_16( nbands, 12 ) ) + ELSE IF( EQ_16( nbands, 12 ) ) { Word16 band; FOR( band = 0; band < DIRAC_MAX_NBANDS; band++ ) { dirac_to_spar_md_bands[band] = band; + move16(); } IF( hFbMdft != NULL ) { Word16 sb, idx1, idx2, b; idx1 = -1; + move16(); sb = 0; + move16(); FOR( b = 0; b < max_band; b++ ) { idx2 = hFbMdft->pFb->fb_bin_to_band.p_cldfb_map_to_spar_band[b]; + move16(); IF( GT_16( idx2, idx1 ) ) { band_grouping[sb++] = b; + move16(); idx1 = idx2; + move16(); } } band_grouping[sb] = max_band; + move16(); /* set the remaining bands to max_band to avoid problems for the DirAC parameter estimation with bw < FB */ FOR( b = sb; b <= nbands; b++ ) { band_grouping[b] = max_band; + move16(); } } ELSE @@ -518,25 +526,31 @@ void ivas_dirac_config_bands_fx( { Word16 step = DIRAC_LOW_BANDRES_STEP; Word16 reduced_band; - for ( band = add(enc_param_start_band , 2), reduced_band = add(enc_param_start_band , 1); band <= DIRAC_MAX_NBANDS; band = add(band, step), reduced_band++ ) + FOR( ( band = add( enc_param_start_band, 2 ), reduced_band = add( enc_param_start_band, 1 ) ); band <= DIRAC_MAX_NBANDS; ( band = add( band, step ), reduced_band++ ) ) { band_grouping[reduced_band] = band_grouping[band]; + move16(); } FOR( ; reduced_band <= DIRAC_MAX_NBANDS; reduced_band++ ) { band_grouping[reduced_band] = max_band; + move16(); } - for ( band = enc_param_start_band + ( DIRAC_MAX_NBANDS - enc_param_start_band ) / 2 - 1, reduced_band = DIRAC_MAX_NBANDS - 1; band >= enc_param_start_band; band--, reduced_band -= step ) + FOR( ( band = enc_param_start_band + ( DIRAC_MAX_NBANDS - enc_param_start_band ) / 2 - 1, reduced_band = DIRAC_MAX_NBANDS - 1 ); band >= enc_param_start_band; ( band--, reduced_band -= step ) ) { dirac_to_spar_md_bands[reduced_band] = dirac_to_spar_md_bands[band]; + move16(); dirac_to_spar_md_bands[reduced_band - 1] = dirac_to_spar_md_bands[band]; + move16(); } } ELSE { /* always code the last two fb bands together */ band_grouping[DIRAC_MAX_NBANDS - 1] = max_band; - dirac_to_spar_md_bands[DIRAC_MAX_NBANDS - 1] = DIRAC_MAX_NBANDS - 2; + move16(); + dirac_to_spar_md_bands[DIRAC_MAX_NBANDS - 1] = sub( DIRAC_MAX_NBANDS, 2 ); + move16(); } } ELSE @@ -546,11 +560,12 @@ void ivas_dirac_config_bands_fx( } /* Limit the band range to band max */ - FOR( i = 0; i < nbands + 1; i++ ) + FOR( i = 0; i < add( nbands, 1 ); i++ ) { IF( GT_16( band_grouping[i], max_band ) ) { band_grouping[i] = max_band; + move16(); } } @@ -1248,38 +1263,42 @@ Word32 deindex_azimuth_fx( Word16 flag_delta; Word32 dd_fx, delta_phi_fx; Word32 phi_hat_fx; - IF( ( mc_format != MC_LS_SETUP_INVALID ) && ( no_bits == 2 ) ) + test(); + IF( NE_32( mc_format, MC_LS_SETUP_INVALID ) && EQ_16( no_bits, 2 ) ) { - IF( id_phi % 2 == 0 ) + IF( EQ_16( s_and( id_phi, 1 ), 0 ) ) { - phi_hat_fx = cb_azi_chan_fx[id_phi / 2]; + phi_hat_fx = cb_azi_chan_fx[shr( id_phi, 1 )]; } ELSE { - phi_hat_fx = -cb_azi_chan_fx[( id_phi + 1 ) / 2]; + phi_hat_fx = L_negate( cb_azi_chan_fx[shr( add( id_phi, 1 ), 1 )] ); } return phi_hat_fx; } - flag_delta = ( id_th % 2 == 1 ); + flag_delta = (Word16) EQ_16( s_and( id_th, 1 ), 1 ); IF( remap ) { - id_phi = ivas_qmetadata_dereorder_generic( id_phi ) + ( no_phi_masa[no_bits - 1][id_th] >> 1 ); + id_phi = add( ivas_qmetadata_dereorder_generic( id_phi ), shr( no_phi_masa[sub( no_bits, 1 )][id_th], 1 ) ); } - delta_phi_fx = Mpy_32_32( 1509949440, no_phi_masa_inv_fx[no_bits - 1][id_th] ); // q = 22 - IF( ( flag_delta == 1 ) && ( no_phi_masa[no_bits - 1][id_th] > 2 ) && mc_format == MC_LS_SETUP_INVALID ) + delta_phi_fx = Mpy_32_32( 1509949440, no_phi_masa_inv_fx[sub( no_bits, 1 )][id_th] ); // q = 22 + test(); + test(); + IF( EQ_16( flag_delta, 1 ) && GT_16( no_phi_masa[sub( no_bits, 1 )][id_th], 2 ) && EQ_32( mc_format, MC_LS_SETUP_INVALID ) ) { dd_fx = Mpy_32_32( delta_phi_fx, 1073741824 ); // q = 22 } ELSE { dd_fx = 0; + move32(); } - id_phi -= ( ( no_phi_masa[no_bits - 1][id_th] ) >> 1 ); + id_phi = sub( id_phi, shr( no_phi_masa[sub( no_bits, 1 )][id_th], 1 ) ); phi_hat_fx = L_add( id_phi * delta_phi_fx, dd_fx ); - IF( mc_format != MC_LS_SETUP_INVALID ) + IF( NE_32( mc_format, MC_LS_SETUP_INVALID ) ) { phi_hat_fx = companding_azimuth_fx( phi_hat_fx, mc_format, ( id_th * delta_theta_masa[no_bits - 3] > MC_MASA_THR_ELEVATION ), -1 ); } @@ -1349,20 +1368,30 @@ void deindex_spherical_component_fx( { case 0: *az_fx = 0; + move32(); *el_fx = 0; + move32(); *az_idx = 0; + move16(); *el_idx = 0; + move16(); BREAK; case 1: *az_idx = sph_idx; - *az_fx = L_shl((*az_idx) * (-180), 22); + move16(); + *az_fx = L_shl( ( *az_idx ) * ( -180 ), 22 ); *el_fx = 0; + move32(); *el_idx = 0; + move16(); BREAK; case 2: *el_fx = 0; + move32(); *el_idx = 0; + move16(); *az_idx = sph_idx; + move16(); *az_fx = deindex_azimuth_fx( *az_idx, no_bits, 0, 0, mc_format ); BREAK; default: @@ -1719,25 +1748,32 @@ static UWord16 deindex_sph_idx_general_fx( const Word16 *n; id_th = 0; + move16(); id_phi = 0; + move16(); sign_theta = 1; + move16(); no_th = no_theta_masa[no_bits - 3]; + move16(); n = no_phi_masa[no_bits - 1]; - IF( mc_format != MC_LS_SETUP_INVALID ) + IF( NE_32( mc_format, MC_LS_SETUP_INVALID ) ) { /* indexing */ cum_n[0] = n[0]; - IF( idx_sph >= cum_n[0] ) + move16(); + IF( GE_16( idx_sph, cum_n[0] ) ) { FOR( i = 1; i < no_th; i++ ) { - cum_n[i] = cum_n[i - 1] + n[i]; - IF( idx_sph < cum_n[i] ) + cum_n[i] = add( cum_n[i - 1], n[i] ); + move16(); + IF( LT_16( idx_sph, cum_n[i] ) ) { id_th = i; - id_phi = idx_sph - cum_n[i - 1]; + move16(); + id_phi = sub( idx_sph, cum_n[i - 1] ); BREAK; } } @@ -1747,62 +1783,76 @@ static UWord16 deindex_sph_idx_general_fx( { /* Starting from Equator, alternating positive and negative */ cum_n[0] = n[0]; - IF( idx_sph >= cum_n[0] ) + move16(); + IF( GE_16( idx_sph, cum_n[0] ) ) { FOR( i = 1; i < no_th; i++ ) { - cum_n[2 * i - 1] = cum_n[2 * i - 2] + n[i]; + cum_n[2 * i - 1] = add( cum_n[2 * i - 2], n[i] ); + move16(); - IF( idx_sph < cum_n[2 * i - 1] ) + IF( LT_16( idx_sph, cum_n[2 * i - 1] ) ) { id_th = i; + move16(); sign_theta = 1; - id_phi = idx_sph - cum_n[2 * i - 2]; + move16(); + id_phi = sub( idx_sph, cum_n[2 * i - 2] ); BREAK; } - cum_n[2 * i] = cum_n[2 * i - 1] + n[i]; + cum_n[2 * i] = add( cum_n[2 * i - 1], n[i] ); + move16(); - IF( idx_sph < cum_n[2 * i] ) + IF( LT_16( idx_sph, cum_n[2 * i] ) ) { id_th = i; + move16(); sign_theta = -1; - id_phi = idx_sph - cum_n[2 * i - 1]; + move16(); + id_phi = sub( idx_sph, cum_n[2 * i - 1] ); BREAK; } - IF( i == ( no_th - 1 ) ) + IF( EQ_16( i, sub( no_th, 1 ) ) ) { id_th = i; + move16(); sign_theta = -1; + move16(); id_phi = 0; /* idx_sph - cum_n[2*i-1]; */ + move16(); BREAK; } } } } - IF( id_th == 0 ) + IF( EQ_32( id_th, 0 ) ) { id_phi = idx_sph; + move16(); } ELSE { - IF( ( id_th == no_th - 1 ) && ( no_bits > 4 ) ) + IF( EQ_32( id_th, sub( no_th, 1 ) ) && GT_16( no_bits, 4 ) ) { id_phi = 0; + move16(); } } q_id_th = norm_l( id_th ); id_th_fx = L_shl( id_th, q_id_th ); - *theta_dec_fx = L_shl( Mpy_32_32( id_th_fx, delta_theta_masa_fx[no_bits - 3] ), 31 - q_id_th ); + *theta_dec_fx = L_shl( Mpy_32_32( id_th_fx, delta_theta_masa_fx[no_bits - 3] ), sub( 31, q_id_th ) ); - IF( *theta_dec_fx >= L_shl( 90, 22 ) ) + IF( GE_32( *theta_dec_fx, L_shl( 90, Q22 ) ) ) { *theta_dec_fx = L_shl( 90, 22 ) * sign_theta; *phi_dec_fx = 0; + move32(); *p_id_phi = 0; + move16(); } ELSE { @@ -1810,6 +1860,7 @@ static UWord16 deindex_sph_idx_general_fx( *phi_dec_fx = deindex_azimuth_fx( id_phi, no_bits, id_th, 0, mc_format ); *p_id_phi = id_phi; + move16(); } return id_th; diff --git a/lib_com/ivas_masa_com.c b/lib_com/ivas_masa_com.c index 9f9494282..eb1c24937 100644 --- a/lib_com/ivas_masa_com.c +++ b/lib_com/ivas_masa_com.c @@ -534,7 +534,7 @@ void ivas_masa_set_coding_config_fx( move16(); } - WHILE( nbands == 0 && LT_16( i, IVAS_NUM_ACTIVE_BRATES ) ) + WHILE( EQ_16( nbands, 0 ) && LT_16( i, IVAS_NUM_ACTIVE_BRATES ) ) { IF( LE_32( ivas_total_brate, ivas_brate_tbl[i + SIZE_IVAS_BRATE_TBL - IVAS_NUM_ACTIVE_BRATES] ) ) { @@ -551,10 +551,13 @@ void ivas_masa_set_coding_config_fx( idx_bands = i; move16(); - IF( config->numberOfDirections > 1 ) + IF( GT_16( config->numberOfDirections, 1 ) ) { nTwoDirBands = config->joinedSubframes ? masa_twodir_bands_joined[i] : masa_twodir_bands[i]; + test(); + test(); + test(); IF( ( GT_32( ivas_total_brate, IVAS_96k ) && !config->joinedSubframes ) || ( GT_32( ivas_total_brate, IVAS_80k ) && config->joinedSubframes ) ) { idx_bands = sub( idx_bands, 1 ); @@ -573,16 +576,20 @@ void ivas_masa_set_coding_config_fx( config->max_metadata_bits = masa_bits_table[i]; move16(); - IF( EQ_32( ivas_total_brate, IVAS_64k ) && config->numberOfDirections > 1 ) + test(); + IF( EQ_32( ivas_total_brate, IVAS_64k ) && GT_16( config->numberOfDirections, 1 ) ) { /* At 64k, we increase metadata bit budget when there is two directions present. */ - config->max_metadata_bits += MASA_EXTRA_BAND_META_BITS; + config->max_metadata_bits = (UWord16) L_add( config->max_metadata_bits, MASA_EXTRA_BAND_META_BITS ); } + test(); + test(); + test(); IF( ( ( EQ_32( ivas_total_brate, IVAS_32k ) && EQ_16( nchan_transport, 2 ) ) || EQ_32( ivas_total_brate, IVAS_48k ) ) && config->joinedSubframes ) { /* At 32k and 48k, we increase metadata bit budget when joinedSubframes. */ - config->max_metadata_bits += ( MASA_SMALL_INC_META_BITS ); + config->max_metadata_bits = (UWord16) L_add( config->max_metadata_bits, MASA_SMALL_INC_META_BITS ); } } i = add( i, 1 ); @@ -590,7 +597,7 @@ void ivas_masa_set_coding_config_fx( config->numCodingBands = nbands; config->numTwoDirBands = nTwoDirBands; - IF( config->joinedSubframes == TRUE ) + IF( EQ_16( config->joinedSubframes, TRUE ) ) { config->mergeRatiosOverSubframes = FALSE; } @@ -616,7 +623,7 @@ void ivas_masa_set_coding_config_fx( BREAK; case MASA_FREQUENCY_BANDS: /* With input count of bands, no mapping is needed but for unified processing later, we store normal mapping */ - FOR( i = 0; i < MASA_FREQUENCY_BANDS + 1; i++ ) + FOR( i = 0; i < add( MASA_FREQUENCY_BANDS, 1 ); i++ ) { band_mapping[i] = i; move16(); @@ -627,6 +634,9 @@ void ivas_masa_set_coding_config_fx( } config->useCoherence = TRUE; + test(); + test(); + test(); IF( ( !isMcMasa && LT_32( ivas_total_brate, IVAS_48k ) ) || ( isMcMasa && LT_32( ivas_total_brate, IVAS_16k4 ) ) ) { config->useCoherence = FALSE; @@ -1007,12 +1017,14 @@ UWord16 index_theta_phi_16_fx( Word32 theta_fx, phi_fx; theta_fx = *p_theta; + move32(); phi_fx = *p_phi; + move32(); phi_hat_fx = 0; move32(); theta_hat_fx = 0; move32(); - phi_fx = phi_fx + ( 180 << Q22 ); + phi_fx = L_add( phi_fx, L_shl( 180, Q22 ) ); IF( LT_32( theta_fx, 0 ) ) { @@ -1023,6 +1035,7 @@ UWord16 index_theta_phi_16_fx( ELSE { abs_theta_fx = theta_fx; + move32(); sign_th = 1; move16(); } @@ -1032,7 +1045,7 @@ UWord16 index_theta_phi_16_fx( { IF( GT_16( gridData->no_phi[id_th], 1 ) ) { - id_phi = quantize_phi_masa_fx( phi_fx, ( id_th % 2 == 1 ), &phi_hat_fx, gridData->no_phi[id_th] ); + id_phi = quantize_phi_masa_fx( phi_fx, (Word16)EQ_16( s_and( id_th, 1 ), 1 ), &phi_hat_fx, gridData->no_phi[id_th] ); } ELSE { @@ -1043,7 +1056,7 @@ UWord16 index_theta_phi_16_fx( } ELSE { - id_phi = quantize_phi_masa_fx( phi_fx, ( id_th % 2 == 1 ), &phi_hat_fx, gridData->no_phi[id_th] ); + id_phi = quantize_phi_masa_fx( phi_fx, (Word16)EQ_16( s_and( id_th, 1 ), 1 ), &phi_hat_fx, gridData->no_phi[id_th] ); } *p_theta = theta_hat_fx; @@ -1077,17 +1090,17 @@ UWord16 index_theta_phi_16_fx( cum_n = cum_n_for_id_th[id_th]; move16(); - cum_n += gridData->no_phi[0]; + cum_n = (UWord16) L_add( cum_n, gridData->no_phi[0] ); IF( GT_16( sign_th, 0 ) ) { - cum_n -= shl( gridData->no_phi[id_th], 1 ); + cum_n = (UWord16) L_sub( cum_n, shl( gridData->no_phi[id_th], 1 ) ); } ELSE { - cum_n -= gridData->no_phi[id_th]; + cum_n = (UWord16) L_sub( cum_n, gridData->no_phi[id_th] ); } - idx_sph = cum_n + id_phi; + idx_sph = (UWord16) L_add( cum_n, id_phi ); } } @@ -1277,7 +1290,7 @@ static Word16 quantize_phi_masa_fx( tmp32 = L_add( L_sub( phi_fx, dd_fx ), L_shr( delta_phi_fx, 1 ) ); id_phi = BASOP_Util_Divide3232_Scale( tmp32, delta_phi_fx, &tmp_e ); - id_phi = shr( id_phi, ( 15 - tmp_e ) ); + id_phi = shr( id_phi, sub( 15, tmp_e ) ); IF( EQ_16( id_phi, n ) ) { @@ -1742,24 +1755,24 @@ void reconstruct_ism_ratios_fx( Word32 *q_energy_ratio_ism /* o : reconstructed ISM values Q30 */ ) { - int16_t i; + Word16 i; Word32 sum; sum = 0; move32(); - FOR ( i = 0; i < nchan_ism - 1; i++ ) + FOR( i = 0; i < sub( nchan_ism, 1 ); i++ ) { - q_energy_ratio_ism[i] = L_shl(L_mult(ratio_ism_idx[i], step), 14); // q0 + q15 + 1 + 14 = q30; + q_energy_ratio_ism[i] = L_shl( L_mult( ratio_ism_idx[i], step ), 14 ); // q0 + q15 + 1 + 14 = q30; move32(); - sum = L_add(sum, q_energy_ratio_ism[i]); + sum = L_add( sum, q_energy_ratio_ism[i] ); } - q_energy_ratio_ism[nchan_ism - 1] = L_sub(ONE_IN_Q30, sum); + q_energy_ratio_ism[nchan_ism - 1] = L_sub( ONE_IN_Q30, sum ); move32(); - - IF ( LT_32(q_energy_ratio_ism[nchan_ism - 1], 0) ) + + IF( LT_32( q_energy_ratio_ism[nchan_ism - 1], 0 ) ) { q_energy_ratio_ism[nchan_ism - 1] = 0; move32(); @@ -1999,7 +2012,7 @@ int32_t calculate_cpe_brate_MASA_ISM( /*! r: CPE bitrate value */ Word32 calculate_cpe_brate_MASA_ISM_fx( - const ISM_MODE ism_mode, /* i : ism mode */ + const ISM_MODE ism_mode, /* i : ism mode */ const Word32 ivas_total_brate, /* i : IVAS total bitrate */ const Word16 nchan_ism /* i : number of objects */ ) @@ -2010,23 +2023,24 @@ Word32 calculate_cpe_brate_MASA_ISM_fx( k = 0; move16(); - WHILE ( LT_16(k, SIZE_IVAS_BRATE_TBL) && NE_32(ivas_total_brate, ivas_brate_tbl[k]) ) + WHILE( LT_16( k, SIZE_IVAS_BRATE_TBL ) && NE_32( ivas_total_brate, ivas_brate_tbl[k] ) ) { - k = add(k, 1); + k = add( k, 1 ); } - IF ( EQ_16(ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ) || EQ_16(ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ) ) + test(); + IF( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_16( ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) { - cpe_brate = L_sub(ivas_total_brate, sep_object_brate[k - 2][0]); /* take data from the first column */ + cpe_brate = L_sub( ivas_total_brate, sep_object_brate[k - 2][0] ); /* take data from the first column */ } - ELSE IF ( EQ_16(ism_mode, ISM_MASA_MODE_DISC) ) + ELSE IF( EQ_16( ism_mode, ISM_MASA_MODE_DISC ) ) { cpe_brate = ivas_total_brate; move32(); - FOR ( sce_id = 0; sce_id < nchan_ism; sce_id++ ) + FOR( sce_id = 0; sce_id < nchan_ism; sce_id++ ) { - cpe_brate = L_sub(cpe_brate, sep_object_brate[k - 2][nchan_ism - 1]); + cpe_brate = L_sub( cpe_brate, sep_object_brate[k - 2][nchan_ism - 1] ); } } ELSE diff --git a/lib_com/ivas_omasa_com.c b/lib_com/ivas_omasa_com.c index 7beb8e3d4..a5a8af1cd 100644 --- a/lib_com/ivas_omasa_com.c +++ b/lib_com/ivas_omasa_com.c @@ -933,6 +933,7 @@ void calculate_nbits_meta_fx( ELSE { priority[0] = 536870912; + move32(); } /* decide parameters for ISM metadata quantization */ diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index c6672ea6e..db8bec884 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -756,9 +756,11 @@ int16_t is_DTXrate( const int32_t ivas_total_brate /* i : IVAS total bitrate */ ); +#ifndef IVAS_FLOAT_FIXED int16_t is_SIDrate( const int32_t ivas_total_brate /* i : IVAS total bitrate */ ); +#endif void ivas_mdft( const float *pIn, /* i : input time-domain signal */ @@ -820,7 +822,7 @@ float rand_triangular_signed( #ifdef IVAS_FLOAT_FIXED Word16 rand_triangular_signed_fx( - int16_t *seed, + Word16 *seed, Word16 *exp_fac); #endif Word64 var_32_fx( @@ -3608,10 +3610,10 @@ void ivas_qmetadata_to_dirac_fx( DIRAC_DEC_HANDLE hDirAC, /* i : DirAC decoder structure */ MASA_DECODER_HANDLE hMasa, /* i : MASA decoder structure */ SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + const Word32 ivas_total_brate, /* i : IVAS total bitrate */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ - int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ + const Word16 hodirac_flag, /* i : flag to indicate HO-DirAC mode */ + Word16 *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ); #else void ivas_qmetadata_to_dirac( @@ -3767,12 +3769,14 @@ int16_t quantize_phi( float *phi_hat, /* o : quantized azimuth */ const int16_t n /* i : azimuth codebook size */ ); -int16_t quantize_phi_fx( +#ifdef IVAS_FLOAT_FIXED +Word16 quantize_phi_fx( Word32 phi, /* i : azimuth value */ - const int16_t flag_delta, /* i : flag indicating if the azimuth codebook is translated or not */ + const Word16 flag_delta, /* i : flag indicating if the azimuth codebook is translated or not */ Word32 *phi_hat, /* o : quantized azimuth */ - const int16_t n /* i : azimuth codebook size */ + const Word16 n /* i : azimuth codebook size */ ); +#endif /*! r: decoded elevation value */ float deindex_elevation( uint16_t *id_th, /* i : input index */ @@ -3836,9 +3840,11 @@ uint16_t ivas_qmetadata_reorder_generic( const int16_t signed_value ); +#ifndef IVAS_FLOAT_FIXED int16_t ivas_qmetadata_dereorder_generic( const uint16_t uns_value /* i : unsigned value to reorder */ ); +#endif /*! r: projected azimuth index */ int16_t ivas_dirac_project_azimuth_index( @@ -5716,6 +5722,17 @@ void ivas_set_qmetadata_maxbit_req( const IVAS_FORMAT ivas_format /* i : IVAS format */ ); +#ifdef IVAS_FLOAT_FIXED +/*! r: Bits to be used for quantizing distribution ratio of direct-to-total ratios */ +Word16 ivas_get_df_ratio_bits_hodirac( + const Word16 index_diff /* i : index of quantized diffuse-to-total ratio */ +); + +/*! r: Bits to be used for quantizing distribution ratio of direct-to-total ratios */ +Word16 ivas_get_df_ratio_bits( + const Word16 index_diff /* i : index of quantized diffuse-to-total ratio */ +); +#else /*! r: Bits to be used for quantizing distribution ratio of direct-to-total ratios */ int16_t ivas_get_df_ratio_bits_hodirac( const int16_t index_diff /* i : Index of quantized diffuse-to-total ratio */ @@ -5725,6 +5742,8 @@ int16_t ivas_get_df_ratio_bits_hodirac( int16_t ivas_get_df_ratio_bits( const int16_t index_diff /* i : Index of quantized diffuse-to-total ratio */ ); +#endif + void masa_sample_rate_band_correction( MASA_CODEC_CONFIG *config, /* i/o: MASA codec config */ @@ -5748,6 +5767,7 @@ void invdct4_transform_fx( ); #endif +#ifndef IVAS_FLOAT_FIXED void update_bits_next_block( IVAS_QDIRECTION *q_direction, /* i/o: qdirection */ int16_t *p_diff, /* i/o: bits to be transferred */ @@ -5755,6 +5775,7 @@ void update_bits_next_block( const int16_t max_i, /* i : max number of subands */ const int16_t max_k /* i : max number of subframe */ ); +#endif void ivas_masa_prerender( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 8bc1bef86..6a4143b93 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1692,4 +1692,37 @@ void ivas_initFdCngDec_fx( void ivas_initFdCngCom_fx(HANDLE_FD_CNG_COM hFdCngCom, Word16 scale); +Word16 set_ACELP_flag_IVAS( + const Word16 element_mode, /* i : element mode */ + const Word32 element_brate, /* i : element bitrate */ + const Word32 total_brate, /* i : total bitrate per channel */ + const Word16 idchan, /* i : Channel id */ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 cng_type /* i : CNG type */ +); + +Word16 is_SIDrate( + const Word32 ivas_total_brate /* i : IVAS total bitrate */ +); + +Word16 is_DTXrate( + const Word32 ivas_total_brate /* i : IVAS total bitrate */ +); + +#ifdef IVAS_FLOAT_FIXED +Word16 ivas_qmetadata_dereorder_generic( + const UWord16 uns_value /* i : unsigned value result of ReorderGeneric */ +); +#endif + +#ifdef IVAS_FLOAT_FIXED +void update_bits_next_block( + IVAS_QDIRECTION *q_direction, /* i/o: qdirection */ + Word16 *p_diff, /* i/o: bits to be transferred */ + const Word16 j, /* i : subband to update bit alloc to*/ + const Word16 max_i, /* i : number of subbands */ + const Word16 max_k /* i : n umber of subframes */ +); +#endif #endif diff --git a/lib_com/ivas_qmetadata_com.c b/lib_com/ivas_qmetadata_com.c index f02e1c63c..e2a114758 100644 --- a/lib_com/ivas_qmetadata_com.c +++ b/lib_com/ivas_qmetadata_com.c @@ -430,6 +430,54 @@ ivas_error only_reduce_bits_direction( * Transfer the saved bits to the next subbands *---------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void update_bits_next_block( + IVAS_QDIRECTION *q_direction, /* i/o: qdirection */ + Word16 *p_diff, /* i/o: bits to be transferred */ + const Word16 j, /* i : subband to update bit alloc to*/ + const Word16 max_i, /* i : number of subbands */ + const Word16 max_k /* i : n umber of subframes */ +) +{ + Word16 diff; + Word16 k; + diff = *p_diff; + move16(); + IF( LT_16( diff, 0 ) ) + { + /* increase bits for next subbands */ + k = 0; + move16(); + WHILE( LT_16( diff, 0 ) && LT_16( j, max_i ) && LT_16( k, max_k ) ) + { + IF( LT_32( q_direction->band_data[j].bits_sph_idx[k], MASA_DIRECTION_MAX_BITS ) ) + { + q_direction->band_data[j].bits_sph_idx[k] = (UWord16) L_add( q_direction->band_data[j].bits_sph_idx[k], 1 ); + move16(); + diff++; + } + k++; + } + } + ELSE + { + k = 0; + WHILE( GT_16( diff, 0 ) && LT_16( k, max_k ) ) + { + IF( GT_32( q_direction->band_data[j].bits_sph_idx[k], 0 ) ) + { + q_direction->band_data[j].bits_sph_idx[k] = (UWord16) L_sub( q_direction->band_data[j].bits_sph_idx[k], 1 ); + move16(); + diff--; + } + } + } + *p_diff = diff; + move16(); + + return; +} +#else void update_bits_next_block( IVAS_QDIRECTION *q_direction, /* i/o: qdirection */ int16_t *p_diff, /* i/o: bits to be transferred */ @@ -471,6 +519,7 @@ void update_bits_next_block( return; } +#endif /*--------------------------------------------------------------- @@ -523,7 +572,7 @@ void invdct4_transform_fx( Word16 q ) { Word32 a_fx, b_fx, c_fx, d_fx; - int16_t i; + Word16 i; Word32 f_invdct_v_fx[4]; a_fx = L_add( v_fx[0], v_fx[2] ); @@ -531,23 +580,28 @@ void invdct4_transform_fx( c_fx = L_shl( L_add( Mpy_32_32( 1402911360, v_fx[1] ), Mpy_32_32( 581104896, v_fx[3] ) ), 31 - 30 ); d_fx = L_shl( L_sub( Mpy_32_32( 581104896, v_fx[1] ), Mpy_32_32( 1402911360, v_fx[3] ) ), 31 - 30 ); f_invdct_v_fx[0] = L_shl( L_add( a_fx, c_fx ), 7 ); + move32(); f_invdct_v_fx[1] = L_shl( L_add( b_fx, d_fx ), 7 ); + move32(); f_invdct_v_fx[2] = L_shl( L_sub( b_fx, d_fx ), 7 ); + move32(); f_invdct_v_fx[3] = L_shl( L_sub( a_fx, c_fx ), 7 ); + move32(); FOR( i = 0; i < 4; i++ ) { - IF( f_invdct_v_fx[i] < 0 ) + IF( LT_32( f_invdct_v_fx[i], 0 ) ) { invdct_v[i] = 0; } ELSE { - IF( f_invdct_v_fx[i] > L_shl( 255, q ) ) + IF( GT_32( f_invdct_v_fx[i], L_shl( 255, q ) ) ) { f_invdct_v_fx[i] = L_shl( 255, q ); + move32(); } - invdct_v[i] = (uint8_t) L_shr( f_invdct_v_fx[i], q ); + invdct_v[i] = (UWord8) L_shr( f_invdct_v_fx[i], q ); } } @@ -610,6 +664,26 @@ void masa_compensate_two_dir_energy_ratio_index( * Sets proper value for qmetadata_max_bit_req limit *--------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void ivas_set_qmetadata_maxbit_req( + IVAS_QMETADATA_HANDLE hQMetaData, /* o : qmetadata structure where the requirement value is set */ + const IVAS_FORMAT ivas_format /* i : IVAS format */ +) +{ + IF( EQ_32( ivas_format, SBA_FORMAT ) ) + { + hQMetaData->qmetadata_max_bit_req = QMETADATA_MAXBIT_REQ_SBA; + move16(); + } + ELSE /* MASA_FORMAT */ + { + hQMetaData->qmetadata_max_bit_req = QMETADATA_MAXBIT_REQ_MASA; + move16(); + } + + return; +} +#else void ivas_set_qmetadata_maxbit_req( IVAS_QMETADATA_HANDLE hQMetaData, /* o : qmetadata structure where the requirement value is set */ const IVAS_FORMAT ivas_format /* i : IVAS format */ @@ -626,6 +700,7 @@ void ivas_set_qmetadata_maxbit_req( return; } +#endif /*------------------------------------------------------------------------- @@ -727,6 +802,32 @@ void ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( *------------------------------------------------------------------------*/ /*! r: bits to be used for quantizing ratio of ratios */ +#ifdef IVAS_FLOAT_FIXED +Word16 ivas_get_df_ratio_bits_hodirac( + const Word16 index_diff /* i : index of quantized diffuse-to-total ratio */ +) +{ + Word16 dfRatio_bits; + + IF( GE_16( index_diff, DIFF_DFRATIO_1BIT_LIMIT_IDX ) ) + { + dfRatio_bits = 1; + move16(); + } + ELSE IF( GE_16( index_diff, DIFF_DFRATIO_2BIT_LIMIT_IDX_HODIRAC ) ) + { + dfRatio_bits = 2; + move16(); + } + ELSE + { + dfRatio_bits = 3; + move16(); + } + + return dfRatio_bits; +} +#else int16_t ivas_get_df_ratio_bits_hodirac( const int16_t index_diff /* i : index of quantized diffuse-to-total ratio */ ) @@ -748,6 +849,7 @@ int16_t ivas_get_df_ratio_bits_hodirac( return dfRatio_bits; } +#endif /*--------------------------------------------------------------- * ivas_get_df_ratio_bits() @@ -758,6 +860,32 @@ int16_t ivas_get_df_ratio_bits_hodirac( *--------------------------------------------------------------*/ /*! r: bits to be used for quantizing ratio of ratios */ +#ifdef IVAS_FLOAT_FIXED +Word16 ivas_get_df_ratio_bits( + const Word16 index_diff /* i : index of quantized diffuse-to-total ratio */ +) +{ + Word16 dfRatio_bits; + + IF( GE_16( index_diff, DIFF_DFRATIO_1BIT_LIMIT_IDX ) ) + { + dfRatio_bits = 1; + move16(); + } + ELSE IF( GE_16( index_diff, DIFF_DFRATIO_2BIT_LIMIT_IDX ) ) + { + dfRatio_bits = 2; + move16(); + } + ELSE + { + dfRatio_bits = 3; + move16(); + } + + return dfRatio_bits; +} +#else int16_t ivas_get_df_ratio_bits( const int16_t index_diff /* i : index of quantized diffuse-to-total ratio */ ) @@ -779,3 +907,4 @@ int16_t ivas_get_df_ratio_bits( return dfRatio_bits; } +#endif diff --git a/lib_com/ivas_qspherical_com.c b/lib_com/ivas_qspherical_com.c index b180c31df..17ad66752 100644 --- a/lib_com/ivas_qspherical_com.c +++ b/lib_com/ivas_qspherical_com.c @@ -72,6 +72,21 @@ uint16_t ivas_qmetadata_reorder_generic( *------------------------------------------------------------------------*/ /*! r: "Unfolded" value, positive or negative depending on the value of the input */ +#ifdef IVAS_FLOAT_FIXED +Word16 ivas_qmetadata_dereorder_generic( + const UWord16 uns_value /* i : unsigned value result of ReorderGeneric */ +) +{ + IF( NE_32( L_and( uns_value, 1 ), 0 ) ) + { + return sub( negate( extract_l( L_shr( uns_value, 1 ) ) ), 1 ); + } + ELSE + { + return extract_l( L_shr( uns_value, 1 ) ); + } +} +#else int16_t ivas_qmetadata_dereorder_generic( const uint16_t uns_value /* i : unsigned value result of ReorderGeneric */ ) @@ -85,6 +100,7 @@ int16_t ivas_qmetadata_dereorder_generic( return (int16_t) ( uns_value >> 1 ); } } +#endif /*------------------------------------------------------------------------- @@ -284,9 +300,9 @@ int16_t quantize_phi( } #ifdef IVAS_FLOAT_FIXED Word16 quantize_phi_fx( - Word32 phi, /* i : azimuth value */ + Word32 phi, /* i : azimuth value */ const Word16 flag_delta, /* i : flag indicating if the azimuth codebook is translated or not */ - Word32 *phi_hat, /* o : quantized azimuth */ + Word32 *phi_hat, /* o : quantized azimuth */ const Word16 n /* i : azimuth codebook size */ ) { @@ -298,20 +314,24 @@ Word16 quantize_phi_fx( delta_phi_fx = delta_phi_val[n]; inv_delta_phi_fx = inv_delta_phi_val[n]; - IF ( n == 1 ) + IF( EQ_16( n, 1 ) ) { *phi_hat = 0; + move32(); return 0; } - IF ( ( flag_delta == 1 ) && ( n > 2 ) ) + test(); + IF( EQ_16( flag_delta, 1 ) && GT_16( n, 2 ) ) { dd_fx = dd_val[n]; + move32(); } ELSE { dd_fx = 0; + move32(); } temp_res = Mpy_32_32( L_sub( L_sub( phi, DEGREE_180_Q_22 ), dd_fx ), inv_delta_phi_fx ); @@ -320,37 +340,37 @@ Word16 quantize_phi_fx( assert( L_sub( L_abs( temp_res ), abs( id_phi ) * ONE_IN_Q22 ) <= ONE_IN_Q21 ); - IF ( id_phi + ( n >> 1 ) < 0 ) + IF( LT_16( add( id_phi, shr( n, 1 ) ), 0 ) ) { - id_phi += 1; + id_phi = add( id_phi, 1 ); } - IF ( id_phi - ( n >> 1 ) >= 0 ) + IF( GE_16( sub( id_phi, shr( n, 1 ) ), 0 ) ) { - id_phi = -( n >> 1 ); + id_phi = negate( shr( n, 1 ) ); } - IF ( id_phi == -( ( n >> 1 ) + ( n % 2 ) ) ) + IF( EQ_16( id_phi, negate( add( shr( n, 1 ), ( n % 2 ) ) ) ) ) { - id_phi += ( n % 2 ); + id_phi = add( id_phi, ( n % 2 ) ); } ELSE { - IF ( id_phi == ( ( n >> 1 ) + ( n % 2 ) ) ) + IF( EQ_16( id_phi, add( shr( n, 1 ), ( n % 2 ) ) ) ) { - IF ( n % 2 ) + IF( n % 2 ) { - id_phi -= 1; + id_phi = sub( id_phi, 1 ); } ELSE { - id_phi = -id_phi; + id_phi = negate( id_phi ); } } } *phi_hat = L_add( L_add( ( id_phi * delta_phi_fx ), dd_fx ), DEGREE_180_Q_22 ); - id_phi += ( n >> 1 ); + id_phi = add( id_phi, shr( n, 1 ) ); return id_phi; } @@ -460,27 +480,36 @@ Word32 companding_azimuth_fx( Word16 i, not_done, start; Word32 abs_azi_fx; - IF( mc_format == MC_LS_SETUP_5_1 || mc_format == MC_LS_SETUP_5_1_2 || mc_format == MC_LS_SETUP_5_1_4 ) /* 5.1, 5.1+2 or 5.1+4*/ + test(); + test(); + IF( EQ_32( mc_format, MC_LS_SETUP_5_1 ) || EQ_32( mc_format, MC_LS_SETUP_5_1_2 ) || EQ_32( mc_format, MC_LS_SETUP_5_1_4 ) ) /* 5.1, 5.1+2 or 5.1+4*/ { start = 5; + move16(); } ELSE { start = 0; + move16(); } /* theta flag 1 is for non zero, larger than a threshold elevation */ - IF( ( theta_flag == 1 ) && ( ( mc_format == MC_LS_SETUP_5_1_2 ) || ( mc_format == MC_LS_SETUP_5_1_4 ) || ( mc_format == MC_LS_SETUP_7_1_4 ) ) ) /* 5.1+2, 5.1+4 or 7.1+4*/ + test(); + test(); + test(); + IF( ( EQ_16( theta_flag, 1 ) ) && ( ( EQ_32( mc_format, MC_LS_SETUP_5_1_2 ) ) || ( EQ_32( mc_format, MC_LS_SETUP_5_1_4 ) ) || ( EQ_32( mc_format, MC_LS_SETUP_7_1_4 ) ) ) ) /* 5.1+2, 5.1+4 or 7.1+4*/ { start = 10; + move16(); } no_points = 5; + move16(); pA_fx = &pointsA_fx[start]; pB_fx = &pointsB_fx[start]; pA = &pointsA[start]; - IF( direction == -1 ) /* inverse companding */ + IF( EQ_16( direction, -1 ) ) /* inverse companding */ { pA_fx = &pointsB_fx[start]; pB_fx = &pointsA_fx[start]; @@ -488,25 +517,29 @@ Word32 companding_azimuth_fx( } ELSE { - IF( direction != 1 ) + IF( NE_16( direction, 1 ) ) { printf( "Wrong direction in companding" ); } } not_done = 1; + move16(); abs_azi_fx = L_abs( azi_fx ); comp_azi_fx = azi_fx; + move32(); i = 0; - WHILE( not_done && ( i < no_points - 1 ) ) + move16(); + WHILE( not_done && ( LT_16( i, sub( no_points, 1 ) ) ) ) { - IF( abs_azi_fx <= pA_fx[i + 1] ) + IF( LE_32( abs_azi_fx, pA_fx[i + 1] ) ) { not_done = 0; + move16(); /* calculate companding */ comp_azi_fx = Mpy_32_32( L_sub( pB_fx[i + 1], pB_fx[i] ), L_sub( abs_azi_fx, pA_fx[i] ) ); - SWITCH( pA[i + 1] - pA[i] ) + SWITCH( sub( pA[i + 1], pA[i] ) ) { case 10: comp_azi_fx = Mpy_32_32( comp_azi_fx, 214748364 ); @@ -545,14 +578,15 @@ Word32 companding_azimuth_fx( } } - IF( azi_fx < 0 ) + IF( LT_32( azi_fx, 0 ) ) { comp_azi_fx = L_negate( comp_azi_fx ); } - IF( not_done == 1 ) + IF( EQ_16( not_done, 1 ) ) { comp_azi_fx = azi_fx; + move32(); } return comp_azi_fx; diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index c9d4aa587..0e3bf3f81 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -41,6 +41,9 @@ #include "ivas_rom_com.h" #include "prot_fx1.h" #include "prot_fx2.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif #ifndef IVAS_FLOAT_FIXED #include #endif @@ -1176,9 +1179,12 @@ Word16 matrix_product_fx( Word32 *Zp_fx = Z_fx; /* Processing */ - IF( transpX == 1 && transpY == 0 ) /* We use X transpose */ + test(); + test(); + test(); + IF( EQ_16( transpX, 1 ) && EQ_16( transpY, 0 ) ) /* We use X transpose */ { - IF( rowsX != rowsY ) + IF( NE_16( rowsX, rowsY ) ) { return EXIT_FAILURE; } @@ -1187,6 +1193,7 @@ Word16 matrix_product_fx( FOR( i = 0; i < colsX; ++i ) { ( *Zp_fx ) = 0; + move32(); FOR( k = 0; k < rowsX; ++k ) { ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ) ); @@ -1195,9 +1202,9 @@ Word16 matrix_product_fx( } } } - ELSE IF( transpX == 0 && transpY == 1 ) /* We use Y transpose */ + ELSE IF( EQ_16( transpX, 0 ) && EQ_16( transpY, 1 ) ) /* We use Y transpose */ { - IF( colsX != colsY ) + IF( NE_16( colsX, colsY ) ) { return EXIT_FAILURE; } @@ -1206,6 +1213,7 @@ Word16 matrix_product_fx( FOR( i = 0; i < rowsX; ++i ) { ( *Zp_fx ) = 0; + move32(); FOR( k = 0; k < colsX; ++k ) { ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ) ); @@ -1214,9 +1222,9 @@ Word16 matrix_product_fx( } } } - ELSE IF( transpX == 1 && transpY == 1 ) /* We use both transpose */ + ELSE IF( EQ_16( transpX, 1 ) && EQ_16( transpY, 1 ) ) /* We use both transpose */ { - IF( rowsX != colsY ) + IF( NE_16( rowsX, colsY ) ) { return EXIT_FAILURE; } @@ -1225,6 +1233,7 @@ Word16 matrix_product_fx( FOR( i = 0; i < colsX; ++i ) { ( *Zp_fx ) = 0; + move32(); FOR( k = 0; k < colsX; ++k ) { ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) ); @@ -1236,7 +1245,7 @@ Word16 matrix_product_fx( } ELSE /* Regular case */ { - IF( colsX != rowsY ) + IF( NE_16( colsX, rowsY ) ) { return EXIT_FAILURE; } @@ -1246,7 +1255,8 @@ Word16 matrix_product_fx( FOR( i = 0; i < rowsX; ++i ) { ( *Zp_fx ) = 0; - for ( k = 0; k < colsX; ++k ) + move32(); + FOR( k = 0; k < colsX; ++k ) { ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) ); } @@ -2332,6 +2342,24 @@ int16_t is_IVAS_bitrate( * identify DTX frame bitrates *-------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +Word16 is_DTXrate( + const Word32 ivas_total_brate /* i : IVAS total bitrate */ +) +{ + Word16 dtx_rate_flag = 0; + move16(); + + test(); + IF( is_SIDrate( ivas_total_brate ) || ( EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) ) + { + dtx_rate_flag = 1; + move16(); + } + + return dtx_rate_flag; +} +#else int16_t is_DTXrate( const int32_t ivas_total_brate /* i : IVAS total bitrate */ ) @@ -2345,6 +2373,7 @@ int16_t is_DTXrate( return dtx_rate_flag; } +#endif /*-------------------------------------------------------------------* * is_SIDrate() @@ -2352,6 +2381,27 @@ int16_t is_DTXrate( * identify SID frame bitrates *-------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +Word16 is_SIDrate( + const Word32 ivas_total_brate /* i : IVAS total bitrate */ +) +{ + Word16 sid_rate_flag = 0; + move16(); + + test(); + test(); + IF( EQ_32( ivas_total_brate, SID_1k75 ) || + EQ_32( ivas_total_brate, SID_2k40 ) || + EQ_32( ivas_total_brate, IVAS_SID_5k2 ) ) + { + sid_rate_flag = 1; + move16(); + } + + return sid_rate_flag; +} +#else int16_t is_SIDrate( const int32_t ivas_total_brate /* i : IVAS total bitrate */ ) @@ -2367,6 +2417,7 @@ int16_t is_SIDrate( return sid_rate_flag; } +#endif /*-------------------------------------------------------------------* @@ -2401,26 +2452,30 @@ Word16 rand_triangular_signed_fx( rand_val = Random( seed ); // q15 Word16 tmp1, tmp2; Word16 exp1, exp = 1; - if ( rand_val <= 0 ) + move16(); + IF( LE_16( rand_val, 0 ) ) { /* rand_val in [-1, 0] */ /*0.5f * (sqrtf(rand_val + 1.0f) - 1)*/ tmp1 = Sqrt16( add( shr( rand_val, 1 ), ONE_IN_Q14 ), &exp ); - exp1 = BASOP_Util_Add_MantExp(tmp1, exp, negate(ONE_IN_Q14), 1, &tmp2); - tmp2 = shr(tmp2, 1); + exp1 = BASOP_Util_Add_MantExp( tmp1, exp, negate( ONE_IN_Q14 ), 1, &tmp2 ); + tmp2 = shr( tmp2, 1 ); *exp_fac = exp1; + move16(); return tmp2; } - else + ELSE { /* rand_val in (0, 1) */ /*0.5f * ( 1 - sqrtf(1.0f - rand_val))*/ - Word16 one_minus_rand = sub(MAX16B, rand_val); + Word16 one_minus_rand = sub( MAX16B, rand_val ); exp = 0; - tmp1 = Sqrt16(one_minus_rand, &exp); // q15 - exp - exp1 = BASOP_Util_Add_MantExp(ONE_IN_Q14, 1, negate(tmp1), exp, &tmp2); - tmp2 = shr(tmp2, 1); + move16(); + tmp1 = Sqrt16( one_minus_rand, &exp ); // q15 - exp + exp1 = BASOP_Util_Add_MantExp( ONE_IN_Q14, 1, negate( tmp1 ), exp, &tmp2 ); + tmp2 = shr( tmp2, 1 ); *exp_fac = exp1; + move16(); return tmp2; } diff --git a/lib_com/prot.h b/lib_com/prot.h index 4c93e956b..15cd04ba1 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -272,12 +272,14 @@ int16_t minimum( float *min_val /* o : minimum value in the input vector */ ); +#ifndef IVAS_FLOAT_FIXED /*! r: index of the minimum value in the input vector */ int16_t minimum_s( const int16_t *vec, /* i : Input vector */ const int16_t lvec, /* i : Vector length */ int16_t *min_val /* o : minimum value in the input vector */ ); +#endif /*! r: return index with max energy value in vector */ int16_t emaximum( @@ -2898,6 +2900,18 @@ void swb_bwe_dec_flt( const int16_t output_frame /* i : frame length */ ); +#ifdef IVAS_FLOAT_FIXED +Word16 swb_bwe_dec_fx32( + Decoder_State *st, /* i/o: decoder state structure */ + Word32 output[], /* i : synthesis @internal Fs Q11 */ + Word32 *synth, /* i : ACELP core synthesis/final synthesis Q11 */ + Word32 *hb_synth, /* o : SHB synthesis/final synthesis */ + Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ + Word16 output_frame /* i : frame length */ +); +#endif // IVAS_FLOAT_FIXED + + void hr_bwe_dec_init_flt( HR_BWE_DEC_HANDLE hBWE_FD_HR /* i/o: HR BWE data handle */ ); @@ -4603,19 +4617,19 @@ ivas_error acelp_core_dec( #ifdef IVAS_FLOAT_FIXED ivas_error acelp_core_dec_ivas_fx( Decoder_State *st, /* i/o: decoder state structure */ - float output[], /* o : synthesis @internal Fs */ - float synth[], /* o : synthesis */ - float save_hb_synth[], /* o : HB synthesis */ - float bwe_exc_extended[], /* i/o: bandwidth extended excitation */ - float *voice_factors, /* o : voicing factors */ - float old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ + Word16 output[], /* o : synthesis @internal Fs */ + Word16 synth[], /* o : synthesis */ + Word16 save_hb_synth[], /* o : HB synthesis */ + Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */ + Word16 *voice_factors, /* o : voicing factors */ + Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ const int16_t sharpFlag, /* i : formant sharpening flag */ - float pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */ + Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */ int16_t *unbits, /* o : number of unused bits */ int16_t *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - const float tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */ - const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ + const Word16 tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */ + const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ const int16_t last_element_mode, /* i : last element mode */ const int32_t last_element_brate, /* i : last element bitrate */ @@ -5317,6 +5331,17 @@ void wtda( const int16_t L /* i : length */ ); +#ifdef IVAS_FLOAT_FIXED +void wtda_fx32( + const Word32 *new_audio, /* i : input audio Q11 */ + Word32 *wtda_audio, /* o : windowed audio Q11 */ + Word32 *old_wtda, /* i/o: windowed audio from previous frame Q11 */ + const Word16 left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */ + const Word16 right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ + const Word16 L /* i : length */ +); +#endif + void wtda_ext( const float *new_audio, /* i : input audio */ float *wtda_audio, /* o : windowed audio */ @@ -9342,6 +9367,7 @@ ivas_error config_acelp1_IVAS( ); /*! r: ACELP16k flag */ +#ifndef IVAS_FLOAT_FIXED int16_t set_ACELP_flag_IVAS( const int16_t element_mode, /* i : element mode */ const int32_t element_brate, /* i : element bitrate */ @@ -9351,6 +9377,7 @@ int16_t set_ACELP_flag_IVAS( const int16_t bwidth, /* i : audio bandwidth */ const int16_t cng_type /* i : CNG type */ ); +#endif void FEC_clas_estim( const float *syn, diff --git a/lib_com/prot_fx1.h b/lib_com/prot_fx1.h index 2b52ad8af..a5e46bc24 100644 --- a/lib_com/prot_fx1.h +++ b/lib_com/prot_fx1.h @@ -191,6 +191,21 @@ Word16 maximum_abs_32_fx( /* o : index of the maximum val const Word16 lvec, /* i : length of input vector */ Word32 *max_val /* o : maximum value in the input vector */ ); +#ifdef IVAS_FLOAT_FIXED +/*! r: index of the maximum value in the input vector */ +Word16 maximum_s( + const Word16 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *max /* o : maximum value in the input vector */ +); + +/*! r: index of the minimum value in the input vector */ +Word16 minimum_s( + const Word16 *vec, /* i : Input vector */ + const Word16 lvec, /* i : Vector length */ + Word16 *min_val /* o : minimum value in the input vector */ +); +#endif Word16 Exp16Array( const Word16 n, /* (i): Array size */ const Word16 *sx /* (i): Data array */ diff --git a/lib_com/prot_fx2.h b/lib_com/prot_fx2.h index 6f617fafa..a8a666cc0 100644 --- a/lib_com/prot_fx2.h +++ b/lib_com/prot_fx2.h @@ -1368,7 +1368,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ Word16 y_gainQ_fx[], /* o : quantized gain per band */ const Word32 core_brate_fx, /* i : core used */ Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */ - const Word16 coder_type_fx, /* i : coding type */ + const Word16 coder_type, /* i : coding type */ const Word16 bwidth_fx /* i : i signal bandwidth */ ); @@ -1378,7 +1378,7 @@ Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain * Word16 y_gainQ_fx[], /* o : quantized gain per band */ const Word32 core_brate_fx, /* i : core used */ Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */ - const Word16 coder_type_fx, /* i : coding type */ + const Word16 coder_type, /* i : coding type */ const Word16 bwidth_fx /* i : input signal bandwidth */ ); #endif @@ -1591,7 +1591,7 @@ void pre_echo_att_fx( Word16* exc_fx, /* i/o: Excitation of the current frame Q_new*/ const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) */ const Word16 Q_new, - const Word16 last_coder_type_fx, /* i : Last coding mode */ + const Word16 last_coder_type, /* i : Last coding mode */ const Word16 L_frame /* i : Frame length*/ ); @@ -1849,7 +1849,7 @@ void updat_prev_frm_fx( Word16 prev_SWB_peak_pos_tmp_fx[], /* o: update core coder last coded peaks*/ Word16 *prev_frm_hfe2_fx, /* o: update harmonics */ Word16 *prev_stab_hfe2_fx, /* o: update harmonics */ - Word16 bws_cnt_fx /* i: band width detector */ + Word16 bws_cnt /* i: band width detector */ ); void convert_lagIndices_pls2smp_fx( @@ -6362,7 +6362,7 @@ void GSC_dec_init_ivas_fx( void gain_dec_mless_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 coder_type_fx, /* i : coding type */ + const Word16 coder_type, /* i : coding type */ const Word16 i_subfr_fx, /* i : subframe number */ const Word16 tc_subfr_fx, /* i : TC subframe index */ const Word16 *code_fx, /* i : algebraic code excitation */ @@ -6501,7 +6501,7 @@ void GSC_dec_init_ivas_fx( void dec_pit_exc_fx( Decoder_State* st_fx, /* i/o: decoder static memory */ const Word16* Aq_fx, /* i : LP filter coefficient */ - const Word16 coder_type_fx, /* i : coding type */ + const Word16 coder_type, /* i : coding type */ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ Word16* pitch_buf_fx, /* o : floating pitch values for each subframe */ Word16* code_fx, /* o : innovation */ @@ -6518,7 +6518,7 @@ void GSC_dec_init_ivas_fx( void dec_pit_exc_ivas_fx( Decoder_State* st_fx, /* i/o: decoder static memory */ const Word16* Aq_fx, /* i : LP filter coefficient */ - const Word16 coder_type_fx, /* i : coding type */ + const Word16 coder_type, /* i : coding type */ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ Word16* pitch_buf_fx, /* o : floating pitch values for each subframe */ Word16* code_fx, /* o : innovation */ @@ -7646,7 +7646,7 @@ void generate_comfort_noise_dec_hf_ivas_fx( const Word16 *pitch_buf_fx, /* i : Decoded pitch buffer */ const Word16 Last_ener_fx, /* i : Last energy (Q8) */ const Word16 rate_switching_reset, /* i : rate switching reset flag */ - const Word16 last_coder_type_fx /* i : Last coder_type */ + const Word16 last_coder_type /* i : Last coder_type */ #ifdef ADD_IVAS_GS_DEC_IMPR , const Word16 VeryLowRateSTflag /* i : Enable the noise enhancement for very low rate stereo generic mode */ #endif @@ -7843,7 +7843,7 @@ void generate_comfort_noise_dec_hf_ivas_fx( void decod_unvoiced_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ - const Word16 coder_type_fx, /* Q0 i : coding type */ + const Word16 coder_type, /* Q0 i : coding type */ Word16 *tmp_noise_fx, /* Q5 o : long term temporary noise energy */ Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe */ Word16 *voice_factors_fx, /* Q15 o : voicing factors */ @@ -7858,7 +7858,7 @@ void generate_comfort_noise_dec_hf_ivas_fx( const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ const int16_t uc_two_stage_flag, /* i : flag indicating two-stage UC */ - const Word16 coder_type_fx, /* Q0 i : coding type */ + const Word16 coder_type, /* Q0 i : coding type */ Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ Word16 *voice_factors_fx, /* Q15 o : voicing factors */ @@ -9187,4 +9187,10 @@ void ivas_bw_switching_pre_proc_fx( Word32 *old_syn_12k8_16k_fx, Word16 Q, Word16 Q_audio -); \ No newline at end of file +); + +#ifdef IVAS_FLOAT_FIXED +/* float2fix and fix2float utilities (to be removed) */ +void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HANDLE hStereoCng); +void acelp_decoder_state_fix2float(Decoder_State *st, STEREO_CNG_DEC_HANDLE hStereoCng); +#endif \ No newline at end of file diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 0f10a3afd..fde86c0bb 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -1544,7 +1544,11 @@ void SWB_BWE_decoding_fx( exp = norm_s(SWB_FENV); tmp = div_s(shl(1,sub(14,exp)),SWB_FENV); /*Q(29-exp) */ L_tmp = Mult_32_16(L_energy,tmp); /*Q(1+29-exp+1)->Q(15-exp) */ +#ifdef BASOP_NOGLOB + EnergyL_16 = round_fx_sat(L_shl_sat(L_tmp, add(exp, 4))); /* Q3 */ +#else Energy_16 = round_fx(L_shl(L_tmp,add(exp,4))); /*Q3 */ +#endif IF(NE_16(last_extl, SWB_BWE) && NE_16(last_extl,FB_BWE)) { diff --git a/lib_com/tools.c b/lib_com/tools.c index c49940f6e..63d8bc6f8 100644 --- a/lib_com/tools.c +++ b/lib_com/tools.c @@ -595,6 +595,41 @@ int16_t maximum( /*! r: index of the maximum value in the input vector */ +#ifdef IVAS_FLOAT_FIXED +Word16 maximum_s( + const Word16 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *max /* o : maximum value in the input vector */ +) +{ + Word16 i, ind; + Word16 tmp; + + ind = 0; + move16(); + tmp = vec[0]; + move16(); + + FOR( i = 1; i < lvec; i++ ) + { + IF( GT_16( vec[i], tmp ) ) + { + ind = i; + move16(); + tmp = vec[i]; + move16(); + } + } + + IF( max != NULL ) + { + *max = tmp; + move16(); + } + + return ind; +} +#else int16_t maximum_s( const int16_t *vec, /* i : input vector */ const int16_t lvec, /* i : length of input vector */ @@ -623,6 +658,7 @@ int16_t maximum_s( return ind; } +#endif /*! r: index of the maximum value in the input vector */ Word16 maximum_l( @@ -733,6 +769,40 @@ int16_t minimum( *-------------------------------------------------------------------*/ /*! r: index of the minimum value in the input vector */ +#ifdef IVAS_FLOAT_FIXED +Word16 minimum_s( + const Word16 *vec, /* i : Input vector */ + const Word16 lvec, /* i : Vector length */ + Word16 *min_val /* o : minimum value in the input vector */ +) +{ + Word16 i, ind, tmp; + + ind = 0; + move16(); + tmp = vec[0]; + move16(); + + FOR( i = 1; i < lvec; i++ ) + { + IF( LT_16( vec[i], tmp ) ) + { + ind = i; + move16(); + tmp = vec[i]; + move16(); + } + } + + IF( min_val != NULL ) + { + *min_val = tmp; + move16(); + } + + return ind; +} +#else int16_t minimum_s( const int16_t *vec, /* i : Input vector */ const int16_t lvec, /* i : Vector length */ @@ -760,6 +830,7 @@ int16_t minimum_s( return ind; } +#endif /*-------------------------------------------------------------------* * minimum_l() diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 9eed201f8..463e64c1e 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -1052,20 +1052,21 @@ Word16 maximum_32_fx( /* o : index of the maximum value in the input ve tmp = vec[0]; move16(); - FOR ( j=1 ; j #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "prot_fx2.h" +#endif // IVAS_FLOAT_FIXED /*--------------------------------------------------------------------------* * mvr2r_inv() @@ -347,6 +350,162 @@ void wtda( return; } + +#ifdef IVAS_FLOAT_FIXED + +void wtda_fx32( + const Word32 *new_audio, /* i : input audio Q11 */ + Word32 *wtda_audio, /* o : windowed audio Q11 */ + Word32 *old_wtda, /* i/o: windowed audio from previous frame */ + const Word16 left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */ + const Word16 right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ + const Word16 L /* i : length */ +) +{ + Word16 i, decimate, decay; + Word16 idx1, idx2, idx3, idx4; + Word16 n, windecay48, windecay16; + const Word32 *allsig_l, *allsig_r; + Word16 win_right[R2_48]; + Word16 win_int_left[R1_16]; + Word16 win_left[R1_48]; + Word16 win_int_right[R2_16]; + + tcx_get_windows_mode1(left_mode, right_mode, win_left, win_right, win_int_left, win_int_right, L); + + decimate = 1; /* L_FRAME 48k */ + decay = 0; + windecay48 = (Word16)WINDECAY48; // (int16_t)(2 * ((float)L_FRAME48k * N_ZERO_MDCT_NS / FRAME_SIZE_NS)) + R1_48 + + IF (EQ_16(L, L_FRAME32k) || EQ_16(L, L_FRAME16k)) + { + decimate = 3; + decay = 1; + } + ELSE IF (EQ_16(L, L_FRAME8k)) + { + decimate = 6; + decay = 2; + } + + switch (L) // (int16_t)((float)L * N_ZERO_MDCT_NS / FRAME_SIZE_NS) + { + case L_FRAME16k: + n = 90; + break; + case L_FRAME32k: + n = 180; + break; + case L_FRAME48k: + n = 270; + break; + default: + n = (Word16)((L * N_ZERO_MDCT_NS) / FRAME_SIZE_NS); + break; + } + + windecay16 = (Word16)WINDECAY16; // (int16_t)(2 * ((float)L_FRAME16k * N_ZERO_MDCT_NS / FRAME_SIZE_NS)) + R1_16; + + /* algorithmic delay reduction */ + i = 0; + + if (old_wtda == NULL) + { + allsig_r = new_audio + n; + allsig_l = new_audio + n - L; + } + else + { + allsig_r = new_audio + n; + allsig_l = old_wtda + n; + } + + if (EQ_16(L, L_FRAME32k)) + { + for (i = 0; i < L / 2 - n; i += 2) + { + idx1 = L / 2 - i - 1; + idx2 = 3 * L_FRAME16k / 2 - i / 2 - 1 - windecay16; + idx3 = L / 2 + i; + idx4 = 3 * L_FRAME16k / 2 + i / 2 - windecay16; + wtda_audio[i] = L_sub_sat(Mpy_32_16_1(-allsig_r[idx1], win_int_right[idx2]), Mpy_32_16_1(allsig_r[idx3] , win_int_right[idx4])); + + idx1 = L / 2 - (i + 1) - 1; + idx2 = (3 * L_FRAME16k / 2 - i / 2 - 1) * decimate + decay - windecay48; + idx3 = L / 2 + i + 1; + idx4 = (3 * L_FRAME16k / 2 + 1 + i / 2) * decimate - decay - 1 - windecay48; + wtda_audio[i + 1] = L_sub_sat(Mpy_32_16_1(-allsig_r[idx1] , win_right[idx2]), Mpy_32_16_1(allsig_r[idx3] , win_right[idx4])); + } + + for (i = L / 2 - n; i < L / 2; i += 2) + { + wtda_audio[i] = -allsig_r[L / 2 - i - 1]; + wtda_audio[i + 1] = -allsig_r[L / 2 - (i + 1) - 1]; + } + for (i = 0; i < n; i += 2) + { + wtda_audio[i + L / 2] = L_sub_sat(Mpy_32_16_1(allsig_l[i] , win_left[(i / 2) * decimate + decay]), new_audio[n - i - 1]); + wtda_audio[i + L / 2 + 1] = L_sub_sat(Mpy_32_16_1(allsig_l[i + 1] , win_int_left[i / 2]), new_audio[n - (i + 1) - 1]); + } + + for (i = n; i < L / 2; i += 2) + { + idx1 = i; + idx2 = (i / 2) * decimate + decay; + idx3 = L - i - 1; + idx4 = (L / 2 - i / 2) * decimate - 1 - decay; + wtda_audio[i + L / 2] = L_sub_sat(Mpy_32_16_1(allsig_l[idx1] , win_left[idx2]), Mpy_32_16_1(allsig_l[idx3] , win_left[idx4])); + + idx1 = i + 1; + idx2 = i / 2; + idx3 = L - (i + 1) - 1; + idx4 = L / 2 - i / 2 - 1; + wtda_audio[i + L / 2 + 1] = L_sub_sat(Mpy_32_16_1(allsig_l[idx1] , win_int_left[idx2]), Mpy_32_16_1(allsig_l[idx3] , win_int_left[idx4])); + } + } + else + { + for (i = 0; i < L / 2 - n; i++) + { + idx1 = L / 2 - i - 1; + idx2 = 3 * L / 2 * decimate - (i + 1) * decimate + decay - windecay48; + idx3 = L / 2 + i; + idx4 = 3 * L / 2 * decimate - 1 + (i + 1) * decimate - decay - windecay48; + wtda_audio[i] = L_sub_sat(Mpy_32_16_1(-allsig_r[idx1] , win_right[idx2]), Mpy_32_16_1(allsig_r[idx3] , win_right[idx4])); + } + + for (i = L / 2 - n; i < L / 2; i++) + { + wtda_audio[i] = -allsig_r[L / 2 - i - 1]; + } + + for (i = 0; i < n; i++) + { + wtda_audio[i + L / 2] = L_sub_sat(Mpy_32_16_1(allsig_l[i] , win_left[i * decimate + decay]), new_audio[n - i - 1]); + } + + for (i = n; i < L / 2; i++) + { + idx1 = i; + idx2 = i * decimate + decay; + idx3 = L - i - 1; + idx4 = L * decimate - i * decimate - 1 - decay; + wtda_audio[i + L / 2] = L_sub_sat(Mpy_32_16_1(allsig_l[idx1] , win_left[idx2]) , Mpy_32_16_1(allsig_l[idx3] , win_left[idx4])); + } + } + + if (old_wtda != NULL) + { + Copy32(new_audio, old_wtda, L); + } + + return; +} + +#endif // IVAS_FLOAT_FIXED + + + void wtda_ext( const float *new_audio, /* i : input audio */ float *wtda_audio, /* o : windowed audio */ diff --git a/lib_dec/FEC_HQ_core_fx.c b/lib_dec/FEC_HQ_core_fx.c index 61620e003..7d21bf4bb 100644 --- a/lib_dec/FEC_HQ_core_fx.c +++ b/lib_dec/FEC_HQ_core_fx.c @@ -186,7 +186,7 @@ void HQ_FEC_processing_fx( } test(); test(); - if( EQ_16(st_fx->prev_old_bfi_fx, 1)&&EQ_16(st_fx->nbLostCmpt,1)&&EQ_16(output_frame,L_FRAME8k)) + if( EQ_16(st_fx->prev_old_bfi, 1)&&EQ_16(st_fx->nbLostCmpt,1)&&EQ_16(output_frame,L_FRAME8k)) { st_fx->nbLostCmpt = add(st_fx->nbLostCmpt, 1); } @@ -647,7 +647,7 @@ void ivas_HQ_FEC_Mem_update_fx( test(); test(); test(); - IF( ( LT_16( Min_ind, 5 ) ) && ( LT_16( abs_s( sub( Min_ind, hHQ_nbfec->old_Min_ind_fx ) ), 2 ) ) && ( LT_16( hHQ_nbfec->diff_energy_fx, ED_THRES_90P_fx ) ) && ( !st_fx->bfi ) && ( !st_fx->prev_bfi ) && ( !st_fx->prev_old_bfi_fx ) && ( !is_transient ) && ( !hHQ_core->old_is_transient_fx[1] ) && ( EQ_16( hHQ_nbfec->prev_last_core_fx, HQ_CORE ) ) && ( EQ_16( st_fx->last_core, HQ_CORE ) ) ) + IF( ( LT_16( Min_ind, 5 ) ) && ( LT_16( abs_s( sub( Min_ind, hHQ_nbfec->old_Min_ind_fx ) ), 2 ) ) && ( LT_16( hHQ_nbfec->diff_energy_fx, ED_THRES_90P_fx ) ) && ( !st_fx->bfi ) && ( !st_fx->prev_bfi ) && ( !st_fx->prev_old_bfi ) && ( !is_transient ) && ( !hHQ_core->old_is_transient_fx[1] ) && ( EQ_16( hHQ_nbfec->prev_last_core, HQ_CORE ) ) && ( EQ_16( st_fx->last_core, HQ_CORE ) ) ) { hHQ_nbfec->phase_mat_flag_fx = 1; move16(); @@ -937,8 +937,8 @@ void HQ_FEC_Mem_update_fx( test(); test(); test(); - IF ((LT_16(Min_ind, 5))&&(LT_16(abs_s(sub(Min_ind, hHQ_nbfec->old_Min_ind_fx)),2))&&(LT_16(hHQ_nbfec->diff_energy_fx,ED_THRES_90P_fx))&&(!st_fx->bfi)&&(!st_fx->prev_bfi)&&(!st_fx->prev_old_bfi_fx) - &&(!is_transient)&&(!hHQ_core->old_is_transient_fx[1]) && (hHQ_nbfec->prev_last_core_fx==HQ_CORE) && (st_fx->last_core==HQ_CORE)) + IF ((LT_16(Min_ind, 5))&&(LT_16(abs_s(sub(Min_ind, hHQ_nbfec->old_Min_ind_fx)),2))&&(LT_16(hHQ_nbfec->diff_energy_fx,ED_THRES_90P_fx))&&(!st_fx->bfi)&&(!st_fx->prev_bfi)&&(!st_fx->prev_old_bfi) + &&(!is_transient)&&(!hHQ_core->old_is_transient_fx[1]) && (hHQ_nbfec->prev_last_core==HQ_CORE) && (st_fx->last_core==HQ_CORE)) { hHQ_nbfec->phase_mat_flag_fx = 1; move16(); @@ -1861,7 +1861,7 @@ void time_domain_FEC_HQ_fx( Word16 tmp; tmp = 0; - if( GT_16(st_fx->old_bfi_cnt_fx,1)) + if( GT_16(st_fx->old_bfi_cnt,1)) { tmp = 1; } @@ -1869,7 +1869,7 @@ void time_domain_FEC_HQ_fx( *Q_synth = 0; move16(); } - ELSE IF(GT_16(st_fx->old_bfi_cnt_fx, 1)) + ELSE IF(GT_16(st_fx->old_bfi_cnt, 1)) { Next_good_after_burst_erasures_fx( wtda_audio_fx, out_fx, hHQ_core->old_out_fx, N_LEAD_NB ); *Q_synth = 0; diff --git a/lib_dec/FEC_clas_estim_fx.c b/lib_dec/FEC_clas_estim_fx.c index 786912b4c..47a0e307a 100644 --- a/lib_dec/FEC_clas_estim_fx.c +++ b/lib_dec/FEC_clas_estim_fx.c @@ -756,7 +756,7 @@ static Word16 FEC_dec_class_fx( clas = ONSET; move16(); - IF( NE_16(st_fx->coder_type_fx,VOICED)) + IF( NE_16(st_fx->coder_type,VOICED)) { /* decode the class */ tmpS = (Word16)get_next_indice( st_fx, FEC_BITS_CLS ); @@ -768,7 +768,7 @@ static Word16 FEC_dec_class_fx( } ELSE IF( EQ_16(tmpS,1)) { - IF( GE_16(st_fx->last_good_fx,VOICED_TRANSITION)) + IF( GE_16(st_fx->last_good,VOICED_TRANSITION)) { clas = VOICED_TRANSITION; move16(); @@ -821,10 +821,10 @@ Word16 FEC_pos_dec_fx( T0 = 0; move16(); - IF( GT_16(st_fx->coder_type_fx,UNVOICED)) + IF( GT_16(st_fx->coder_type,UNVOICED)) { /* decode the clas and energy information */ - IF( LT_16(st_fx->coder_type_fx,AUDIO)) + IF( LT_16(st_fx->coder_type,AUDIO)) { st_fx->clas_dec = FEC_dec_class_fx( st_fx, enr_q); move16(); @@ -832,7 +832,7 @@ Word16 FEC_pos_dec_fx( test(); test(); test(); - IF( EQ_16(st_fx->coder_type_fx,GENERIC) && EQ_16(st_fx->clas_dec,VOICED_CLAS) && (LE_16(st_fx->last_good_fx,UNVOICED_CLAS) || EQ_16(st_fx->last_good_fx,INACTIVE_CLAS))) + IF( EQ_16(st_fx->coder_type,GENERIC) && EQ_16(st_fx->clas_dec,VOICED_CLAS) && (LE_16(st_fx->last_good,UNVOICED_CLAS) || EQ_16(st_fx->last_good,INACTIVE_CLAS))) { st_fx->clas_dec = SIN_ONSET; move16(); @@ -840,11 +840,11 @@ Word16 FEC_pos_dec_fx( } test(); - IF( EQ_16(st_fx->coder_type_fx,GENERIC) && GT_16(st_fx->acelp_cfg.FEC_mode,2) ) + IF( EQ_16(st_fx->coder_type,GENERIC) && GT_16(st_fx->acelp_cfg.FEC_mode,2) ) { nBits = st_fx->acelp_cfg.pitch_bits[0]; /* The first pitch index is located right after the actual position + the last pulse position index + predicted innovation energy index */ bit_pos_pitch_index = st_fx->next_bit_pos + FEC_BITS_POS + nBits_es_Pred; - IF (GE_32(st_fx->core_brate, MIN_BRATE_AVQ_EXC) && LE_32(st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD) && EQ_16(st_fx->coder_type_fx, GENERIC)) + IF (GE_32(st_fx->core_brate, MIN_BRATE_AVQ_EXC) && LE_32(st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD) && EQ_16(st_fx->coder_type, GENERIC)) { /* Harmonic flag is present */ bit_pos_pitch_index = add(bit_pos_pitch_index, 1); diff --git a/lib_dec/FEC_fx.c b/lib_dec/FEC_fx.c index 06101344a..2c608b254 100644 --- a/lib_dec/FEC_fx.c +++ b/lib_dec/FEC_fx.c @@ -31,7 +31,7 @@ void gain_dec_bfi_fx(Word16 *past_qua_en); /* _ (Word16) st_fx->last_good : FEC - clas of last good received */ /* _ (Word16) st_fx->bfi_pitch_fx : LP filter coefficient */ /* _ (Word16) st_fx->upd_cnt : FEC counter of frames since last update*/ -/* _ (Word16) st_fx->last_coder_type_fx: previous coder type */ +/* _ (Word16) st_fx->last_coder_type: previous coder type */ /* _ (Word16) st_fx->Last_GSC_pit_band_idx_fx: AC mode (GSC)Last pitch band index*/ /* _ (Word16) st_fx->stab_fac_fx : LSF stability factor Q15 */ /* _ (Word16) st_fx->tilt_code : tilt of code Q15 */ @@ -162,7 +162,7 @@ void FEC_exc_estim_fx( pitch_pred_linear_fit( st_fx->nbLostCmpt, - st_fx->last_good_fx, + st_fx->last_good, st_fx->old_pitch_buf_fx, tmp_old_pitch, &predPitchLag, @@ -283,13 +283,13 @@ void FEC_exc_estim_fx( test(); test(); test(); - IF( st_fx->last_coder_type_fx == UNVOICED && LE_16(st_fx->nbLostCmpt, 3)) + IF( st_fx->last_coder_type == UNVOICED && LE_16(st_fx->nbLostCmpt, 3)) { /* last good frame was clearly unvoiced */ alpha = _ALPHA_UU_FX; move16(); } - ELSE IF( EQ_16(st_fx->last_coder_type_fx,AUDIO)||EQ_16(st_fx->last_good_fx,INACTIVE_CLAS)) + ELSE IF( EQ_16(st_fx->last_coder_type,AUDIO)||EQ_16(st_fx->last_good,INACTIVE_CLAS)) { test(); IF( hGSCDec->Last_GSC_pit_band_idx_fx > 0 && GT_16(st_fx->nbLostCmpt,1)) @@ -308,7 +308,7 @@ void FEC_exc_estim_fx( move16(); } } - ELSE IF( EQ_16(st_fx->last_good_fx,UNVOICED_CLAS)) + ELSE IF( EQ_16(st_fx->last_good,UNVOICED_CLAS)) { IF( LE_16(st_fx->nbLostCmpt,1)) { @@ -330,29 +330,29 @@ void FEC_exc_estim_fx( move16(); /* 0.4 go rapidly to CNG gain, pitch gain = 0 */ } } - ELSE IF( EQ_16(st_fx->last_good_fx,UNVOICED_TRANSITION)) + ELSE IF( EQ_16(st_fx->last_good,UNVOICED_TRANSITION)) { alpha = _ALPHA_UT_FX; move16(); } - ELSE IF( EQ_16(st_fx->last_good_fx,ONSET)&&LE_16(st_fx->nbLostCmpt,3)&&(EQ_16(st_fx->last_coder_type_fx,GENERIC)||EQ_16(st_fx->last_coder_type_fx,TRANSITION))) + ELSE IF( EQ_16(st_fx->last_good,ONSET)&&LE_16(st_fx->nbLostCmpt,3)&&(EQ_16(st_fx->last_coder_type,GENERIC)||EQ_16(st_fx->last_coder_type,TRANSITION))) { alpha = 26214; move16(); /* mild convergence to 0 for the first 3 erased frames 0.8 in Q15 */ } - ELSE IF( ( EQ_16(st_fx->last_good_fx,VOICED_CLAS)||EQ_16(st_fx->last_good_fx,ONSET))&&LE_16(st_fx->nbLostCmpt,3)) + ELSE IF( ( EQ_16(st_fx->last_good,VOICED_CLAS)||EQ_16(st_fx->last_good,ONSET))&&LE_16(st_fx->nbLostCmpt,3)) { alpha = _ALPHA_V_FX; move16(); /* constant for the first 3 erased frames */ } - ELSE IF( EQ_16(st_fx->last_good_fx,SIN_ONSET)) + ELSE IF( EQ_16(st_fx->last_good,SIN_ONSET)) { alpha = _ALPHA_S_FX; move16(); } test(); test(); - IF( GE_16(st_fx->last_good_fx,VOICED_CLAS)&<_16(st_fx->last_good_fx,INACTIVE_CLAS)&&NE_16(st_fx->last_coder_type_fx,AUDIO)) + IF( GE_16(st_fx->last_good,VOICED_CLAS)&<_16(st_fx->last_good,INACTIVE_CLAS)&&NE_16(st_fx->last_coder_type,AUDIO)) { IF( EQ_16(st_fx->nbLostCmpt,1)) /* if first erased frame in a block, reset harmonic gain */ { @@ -391,8 +391,8 @@ void FEC_exc_estim_fx( test(); test(); test(); - IF( (GE_16(st_fx->last_good_fx,UNVOICED_TRANSITION)&<_16(st_fx->last_good_fx,INACTIVE_CLAS))|| - ( (EQ_16(st_fx->last_coder_type_fx,AUDIO) || EQ_16(st_fx->last_good_fx,INACTIVE_CLAS) ) && hGSCDec->Last_GSC_pit_band_idx_fx > 0) ) + IF( (GE_16(st_fx->last_good,UNVOICED_TRANSITION)&<_16(st_fx->last_good,INACTIVE_CLAS))|| + ( (EQ_16(st_fx->last_coder_type,AUDIO) || EQ_16(st_fx->last_good,INACTIVE_CLAS) ) && hGSCDec->Last_GSC_pit_band_idx_fx > 0) ) { pt_exc = exc; @@ -445,7 +445,7 @@ void FEC_exc_estim_fx( } test(); test(); - IF( EQ_16(st_fx->last_good_fx,UNVOICED_TRANSITION)&&(EQ_16(st_fx->last_coder_type_fx,GENERIC)||EQ_16(st_fx->last_coder_type_fx,TRANSITION))) + IF( EQ_16(st_fx->last_good,UNVOICED_TRANSITION)&&(EQ_16(st_fx->last_coder_type,GENERIC)||EQ_16(st_fx->last_coder_type,TRANSITION))) { /* start of the frame gain */ gain = 0; @@ -467,7 +467,7 @@ void FEC_exc_estim_fx( /* end of the frame gain */ test(); - IF(!(GE_16(st_fx->last_good_fx,VOICED_CLAS)&<_16(st_fx->last_good_fx,INACTIVE_CLAS)&&NE_16(st_fx->last_coder_type_fx,AUDIO)&>_16(st_fx->nbLostCmpt,1))) + IF(!(GE_16(st_fx->last_good,VOICED_CLAS)&<_16(st_fx->last_good,INACTIVE_CLAS)&&NE_16(st_fx->last_coder_type,AUDIO)&>_16(st_fx->nbLostCmpt,1))) { st_fx->lp_gainp_fx = shr(alpha,1); /* alpha in Q15 */ } @@ -498,7 +498,7 @@ void FEC_exc_estim_fx( } test(); test(); - IF( (EQ_16(st_fx->last_coder_type_fx,AUDIO)||EQ_16(st_fx->last_good_fx,INACTIVE_CLAS))&& hGSCDec->Last_GSC_pit_band_idx_fx>0) + IF( (EQ_16(st_fx->last_coder_type,AUDIO)||EQ_16(st_fx->last_good,INACTIVE_CLAS))&& hGSCDec->Last_GSC_pit_band_idx_fx>0) { Diff_len = mfreq_loc_div_25[hGSCDec->Last_GSC_pit_band_idx_fx]; move16(); @@ -532,16 +532,16 @@ void FEC_exc_estim_fx( test(); test(); test(); - IF( EQ_16(st_fx->last_coder_type_fx,AUDIO)||(EQ_16(st_fx->last_good_fx,INACTIVE_CLAS)&&LE_32(st_fx->total_brate, MAX_GSC_INACTIVE_BRATE)&&!st_fx->Opt_AMR_WB)) + IF( EQ_16(st_fx->last_coder_type,AUDIO)||(EQ_16(st_fx->last_good,INACTIVE_CLAS)&&LE_32(st_fx->total_brate, MAX_GSC_INACTIVE_BRATE)&&!st_fx->Opt_AMR_WB)) { st_fx->GSC_noisy_speech_fx = st_fx->Last_GSC_noisy_speech_flag_fx; move16(); /* Replication of the last spectrum, with a slight downscaling of its dynamic */ if (st_fx->element_mode == EVS_MONO) { - gsc_dec_fx(st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx_fx, Diff_len, 0, st_fx->L_frame / L_SUBFR, st_fx->last_coder_type_fx, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc); + gsc_dec_fx(st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx_fx, Diff_len, 0, st_fx->L_frame / L_SUBFR, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc); } else { - gsc_dec_ivas_fx(st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx_fx, Diff_len, 0, st_fx->L_frame / L_SUBFR, st_fx->last_coder_type_fx, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc); + gsc_dec_ivas_fx(st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx_fx, Diff_len, 0, st_fx->L_frame / L_SUBFR, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc); } *tmp_noise = shr_r(st_fx->lp_gainc_fx,3); /*Q0*/ /* Transform back to time domain */ @@ -568,7 +568,7 @@ void FEC_exc_estim_fx( test(); test(); test(); - IF(!(GE_16(st_fx->last_good_fx,VOICED_CLAS)&<_16(st_fx->last_good_fx,INACTIVE_CLAS)&&NE_16(st_fx->last_coder_type_fx,AUDIO)&>_16(st_fx->nbLostCmpt,1))) + IF(!(GE_16(st_fx->last_good,VOICED_CLAS)&<_16(st_fx->last_good,INACTIVE_CLAS)&&NE_16(st_fx->last_coder_type,AUDIO)&>_16(st_fx->nbLostCmpt,1))) { /* Here alpha is in Q15 and lp_gainc_fx in Q3 */ /* st_fx->lp_gainc = alpha * st_fx->lp_gainc + (1.0f - alpha) * gainCNG; */ @@ -587,7 +587,7 @@ void FEC_exc_estim_fx( test(); test(); test(); - if( EQ_16(st_fx->last_good_fx,UNVOICED_TRANSITION)&&(EQ_16(st_fx->last_coder_type_fx,GENERIC)||EQ_16(st_fx->last_coder_type_fx,TRANSITION))&&gainCNG>0) + if( EQ_16(st_fx->last_good,UNVOICED_TRANSITION)&&(EQ_16(st_fx->last_coder_type,GENERIC)||EQ_16(st_fx->last_coder_type,TRANSITION))&&gainCNG>0) { st_fx->lp_gainc_fx = gainCNG; move16(); @@ -637,7 +637,7 @@ void FEC_exc_estim_fx( /* attenuate somewhat on unstable unvoiced */ test(); test(); - if( (EQ_16(st_fx->last_good_fx,UNVOICED_CLAS)||EQ_16(st_fx->last_good_fx,INACTIVE_CLAS))&&NE_16(st_fx->last_coder_type_fx,UNVOICED)) + if( (EQ_16(st_fx->last_good,UNVOICED_CLAS)||EQ_16(st_fx->last_good,INACTIVE_CLAS))&&NE_16(st_fx->last_coder_type,UNVOICED)) { gain_inov = mult_r(gain_inov, 26214); } @@ -685,12 +685,12 @@ void FEC_exc_estim_fx( test(); test(); test(); - IF( (EQ_16(st_fx->last_coder_type_fx,AUDIO)||EQ_16(st_fx->last_good_fx,INACTIVE_CLAS))&&LE_32(st_fx->total_brate, MAX_GSC_INACTIVE_BRATE)&&!st_fx->Opt_AMR_WB) + IF( (EQ_16(st_fx->last_coder_type,AUDIO)||EQ_16(st_fx->last_good,INACTIVE_CLAS))&&LE_32(st_fx->total_brate, MAX_GSC_INACTIVE_BRATE)&&!st_fx->Opt_AMR_WB) { /* For GSC - the excitation is already computed */ Copy( exc, exc2, st_fx->L_frame ); } - ELSE IF( GE_16(st_fx->last_good_fx,UNVOICED_TRANSITION)&<_16(st_fx->last_good_fx,INACTIVE_CLAS)) + ELSE IF( GE_16(st_fx->last_good,UNVOICED_TRANSITION)&<_16(st_fx->last_good,INACTIVE_CLAS)) { /* For voiced and generic signals - prepare a HP filter for the random part of excitation */ /* tmp = -(1-tilt_code) to correctly represent 1.0000 */ @@ -737,7 +737,7 @@ void FEC_exc_estim_fx( } } test(); - IF( EQ_16(st_fx->last_coder_type_fx,AUDIO)||EQ_16(st_fx->last_good_fx,INACTIVE_CLAS)) + IF( EQ_16(st_fx->last_coder_type,AUDIO)||EQ_16(st_fx->last_good,INACTIVE_CLAS)) { IF( EQ_16(st_fx->L_frame,L_FRAME)) { diff --git a/lib_dec/FEC_pitch_estim_fx.c b/lib_dec/FEC_pitch_estim_fx.c index 6d2445c88..705a8b205 100644 --- a/lib_dec/FEC_pitch_estim_fx.c +++ b/lib_dec/FEC_pitch_estim_fx.c @@ -19,7 +19,7 @@ /* _ (Word16) st_fx->Opt_AMR_WB: flag indicating AMR-WB IO mode */ /* _ (Word16) st_fx->L_frame_fx: length of the frame */ /* _ (Word16) st_fx->clas_dec: frame classification */ -/* _ (Word16) st_fx->last_good_fx: last good clas information */ +/* _ (Word16) st_fx->last_good: last good clas information */ /* _ (Word16[]) pitch : pitch values for each subframe Q6 */ /* _ (Word16[]) old_pitch_buf:pitch values for each subframe Q6 */ /*------------------------------------------------------------------------*/ diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c index c7786ea44..4a4372d33 100644 --- a/lib_dec/acelp_core_dec.c +++ b/lib_dec/acelp_core_dec.c @@ -1221,11 +1221,11 @@ ivas_error acelp_core_dec( #ifdef IVAS_FLOAT_FIXED Word16 prev_reset = st->hPFstat->reset; move16(); - nb_post_filt( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, st->coder_type_fx, st->BER_detect, 0 ); + nb_post_filt( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, st->coder_type, st->BER_detect, 0 ); /*----ftf conversions---*/ if ( !st->BER_detect ) { - if ( st->coder_type_fx == INACTIVE ) + if ( st->coder_type == INACTIVE ) { st->psf_lp_noise = fixedToFloat( st->psf_lp_noise_fx, Q8 ); } @@ -2553,7 +2553,7 @@ ivas_error acelp_core_dec( test(); test(); IF( ( EQ_16( st->L_frame, L_FRAME ) && NE_16( st->bwidth, NB ) && GE_16( output_frame, L_FRAME16k ) && - ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type_fx, AUDIO ) ) ) ) ) + ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type, AUDIO ) ) ) ) ) { Word16 tmp_exp = 0; floatToFixed_arr( Aq, Aq_fx, Q12, NB_SUBFR16k * ( M + 1 ) ); @@ -2710,7 +2710,7 @@ ivas_error acelp_core_dec( floatToFixed_arr(voice_factors, tmp_voice_factors_fx, Q15, NB_SUBFR16k); floatToFixed_arr(gain_buf, tmp_voice_factors_fx, Q14, NB_SUBFR16k); st->Last_GSC_noisy_speech_flag_fx = st->Last_GSC_noisy_speech_flag; - st->coder_type_fx = st->coder_type; + st->coder_type = st->coder_type; if (st->hGSCDec != NULL) { st->hGSCDec->Last_GSC_pit_band_idx_fx = st->hGSCDec->Last_GSC_pit_band_idx; @@ -2728,13 +2728,13 @@ ivas_error acelp_core_dec( floatToFixed_arr(st->hGSCDec->old_y_gain, st->hGSCDec->old_y_gain_fx, Q12, MBANDS_GN); floatToFixed_arr(st->hGSCDec->Last_GSC_spectrum, st->hGSCDec->Last_GSC_spectrum_fx, Q10, M); } - st->last_coder_type_fx = st->last_coder_type; + st->last_coder_type = st->last_coder_type; st->Last_GSC_noisy_speech_flag_fx = st->Last_GSC_noisy_speech_flag; if (st->hHQ_core != NULL) st->hHQ_core->HqVoicing_fx = st->hHQ_core->HqVoicing; st->old_ppp_mode_fx = st->old_ppp_mode; st->last_ppp_mode_dec_fx = st->last_ppp_mode_dec; - st->last_nelp_mode_dec_fx = st->last_nelp_mode_dec; + st->last_nelp_mode_dec = st->last_nelp_mode_dec; st->last_vbr_hw_BWE_disable_dec_fx = st->last_vbr_hw_BWE_disable_dec; floatToFixed_arr(st->old_exc, st->old_exc_fx, tmp_Q_exc, L_EXC_MEM_DEC); for (i = 0; i < M; i++) @@ -2757,7 +2757,7 @@ ivas_error acelp_core_dec( updt_dec_fx( st, tmp_old_exc_fx, tmp_pitch_buf_fx, tmp_Es_pred_fx, tmp_Aq_fx, tmp_lsf_new_fx, tmp_lsp_new_fx, tmp_voice_factors_fx, tmp_old_bwe_exc_fx, tmp_gain_buf_fx ); ////////////////////////////////////// Fixed to float starts here //////////////////////////////////////////// - st->last_coder_type = st->last_coder_type_fx; + st->last_coder_type = st->last_coder_type; if (st->hGSCDec != NULL) { st->hGSCDec->noise_lev = st->hGSCDec->noise_lev_fx; @@ -2768,7 +2768,7 @@ ivas_error acelp_core_dec( st->hHQ_core->HqVoicing = st->hHQ_core->HqVoicing_fx; st->old_ppp_mode = st->old_ppp_mode_fx; st->last_ppp_mode_dec = st->last_ppp_mode_dec_fx; - st->last_nelp_mode_dec = st->last_nelp_mode_dec_fx; + st->last_nelp_mode_dec = st->last_nelp_mode_dec; st->last_vbr_hw_BWE_disable_dec = st->last_vbr_hw_BWE_disable_dec_fx; fixedToFloat_arr(st->old_exc_fx, st->old_exc, tmp_Q_exc, L_EXC_MEM_DEC); IF(!st->Opt_AMR_WB && st->hBWE_TD != NULL) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index a83151265..428a19628 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -18,7 +18,7 @@ /* PURPOSE : ACELP core decoder */ /*--------------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* _ Word16 coder_type_fx i : coder type */ +/* _ Word16 coder_type i : coder type */ /*--------------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ @@ -268,7 +268,7 @@ ivas_error acelp_core_dec_fx( set_zero(hStereoCng->olapBufferSynth22, FFTLEN); } #endif - st_fx->clas_dec = st_fx->last_good_fx; + st_fx->clas_dec = st_fx->last_good; move16(); enr_q_fx = 0; move16(); @@ -572,7 +572,7 @@ ivas_error acelp_core_dec_fx( tc_subfr_fx = -1; move16(); - if( EQ_16(st_fx->coder_type_fx,TRANSITION)) + if( EQ_16(st_fx->coder_type,TRANSITION)) { tc_subfr_fx = tc_classif_fx( st_fx, st_fx->L_frame ); move16(); @@ -584,7 +584,7 @@ ivas_error acelp_core_dec_fx( st_fx->GSC_IVAS_mode = 0; IF (GT_16(st_fx->element_mode, EVS_MONO) && st_fx->idchan == 0 && !(EQ_32(st_fx->core_brate, FRAME_NO_DATA) || EQ_32(st_fx->core_brate, SID_2k40)) && !tdm_low_rate_mode) { - IF (EQ_16(st_fx->coder_type_fx, AUDIO) || (EQ_16(st_fx->coder_type_fx, INACTIVE) && LE_32(st_fx->total_brate, MAX_GSC_INACTIVE_BRATE))) + IF (EQ_16(st_fx->coder_type, AUDIO) || (EQ_16(st_fx->coder_type, INACTIVE) && LE_32(st_fx->total_brate, MAX_GSC_INACTIVE_BRATE))) { st_fx->GSC_IVAS_mode = get_next_indice(st_fx, 2); } @@ -742,12 +742,12 @@ ivas_error acelp_core_dec_fx( move16(); } - config_acelp1(DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech_fx, &(st_fx->acelp_cfg), st_fx->next_bit_pos, st_fx->coder_type_fx, tc_subfr_tmp, 1, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode); + config_acelp1(DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech_fx, &(st_fx->acelp_cfg), st_fx->next_bit_pos, st_fx->coder_type, tc_subfr_tmp, 1, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode); test(); test(); test(); - IF (EQ_16(st_fx->coder_type_fx, TRANSITION) && LT_16(tc_subfr_fx, L_SUBFR) && EQ_16(st_fx->L_frame, L_FRAME)) + IF (EQ_16(st_fx->coder_type, TRANSITION) && LT_16(tc_subfr_fx, L_SUBFR) && EQ_16(st_fx->L_frame, L_FRAME)) { - config_acelp1(DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, -1, &(st_fx->acelp_cfg), st_fx->next_bit_pos, st_fx->coder_type_fx, tc_subfr_fx, 2, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode); + config_acelp1(DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, -1, &(st_fx->acelp_cfg), st_fx->next_bit_pos, st_fx->coder_type, tc_subfr_fx, 2, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode); } } @@ -896,7 +896,7 @@ ivas_error acelp_core_dec_fx( st_fx->Q_exc = FEC_SinOnset_fx( old_exc_fx+L_EXC_MEM_DEC-L_EXC_MEM, last_pulse_pos, T0_tmp, enr_q_fx, Aq_fx, st_fx->L_frame, st_fx->Q_exc ); } - ELSE IF( (EQ_16(st_fx->coder_type_fx,GENERIC) || EQ_16(st_fx->coder_type_fx,VOICED)) && last_pulse_pos!=0 && EQ_16(st_fx->old_bfi_cnt_fx,1) && EQ_16(output_frame,L_FRAME16k) && st_fx->hWIDec != NULL) + ELSE IF( (EQ_16(st_fx->coder_type,GENERIC) || EQ_16(st_fx->coder_type,VOICED)) && last_pulse_pos!=0 && EQ_16(st_fx->old_bfi_cnt,1) && EQ_16(output_frame,L_FRAME16k) && st_fx->hWIDec != NULL) { do_WI_fx = FEC_enhACB_fx( st_fx->L_frame, st_fx->last_L_frame, old_exc_fx+L_EXC_MEM_DEC-L_EXC_MEM , T0_tmp, last_pulse_pos, st_fx->bfi_pitch_fx ); } @@ -911,7 +911,7 @@ ivas_error acelp_core_dec_fx( test(); test(); test(); - IF( st_fx->stab_fac_fx == 0 && st_fx->old_bfi_cnt_fx > 0 && NE_16(st_fx->clas_dec,VOICED_CLAS) && NE_16(st_fx->clas_dec,ONSET) && + IF( st_fx->stab_fac_fx == 0 && st_fx->old_bfi_cnt > 0 && NE_16(st_fx->clas_dec,VOICED_CLAS) && NE_16(st_fx->clas_dec,ONSET) && st_fx->relax_prev_lsf_interp_fx==0 && !(EQ_16(st_fx->element_mode, IVAS_CPE_TD) && EQ_16(st_fx->idchan, 1))) { int_lsp4_fx(st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 ); @@ -934,7 +934,7 @@ ivas_error acelp_core_dec_fx( #ifdef ADD_LRTD IF (tdm_low_rate_mode) /* tdm stereo low rate mode */ { - IF (LE_16(st_fx->coder_type_fx, UNVOICED)) + IF (LE_16(st_fx->coder_type, UNVOICED)) { tdm_low_rate_dec(st_fx, dct_exc_tmp, &tmp_noise, pitch_buf, voice_factors, exc, exc2, bwe_exc, lsf_new); } @@ -959,12 +959,12 @@ ivas_error acelp_core_dec_fx( move16(); decod_nelp_fx( st_fx, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx,voice_factors, bwe_exc_fx, &st_fx->Q_exc, st_fx->bfi, gain_buf ); - Rescale_exc(hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32)0, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, L_FRAME, st_fx->coder_type_fx); + Rescale_exc(hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32)0, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, L_FRAME, st_fx->coder_type); } - ELSE IF( EQ_16(st_fx->coder_type_fx,UNVOICED)) + ELSE IF( EQ_16(st_fx->coder_type,UNVOICED)) { /* UNVOICED frames */ - decod_unvoiced_fx( st_fx, Aq_fx, st_fx->coder_type_fx, &tmp_noise_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, gain_buf ); + decod_unvoiced_fx( st_fx, Aq_fx, st_fx->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, gain_buf ); } ELSE IF ( EQ_16(st_fx->ppp_mode_dec_fx,1)) { @@ -976,13 +976,13 @@ ivas_error acelp_core_dec_fx( return error; } - Rescale_exc(hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32)0, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, L_FRAME, st_fx->coder_type_fx ); + Rescale_exc(hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32)0, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, L_FRAME, st_fx->coder_type ); } - ELSE IF( EQ_16(st_fx->coder_type_fx,TRANSITION )) + ELSE IF( EQ_16(st_fx->coder_type,TRANSITION )) { decod_tran_fx( st_fx, st_fx->L_frame, tc_subfr_fx, Aq_fx, Es_pred_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf ); } - ELSE IF( EQ_16(st_fx->coder_type_fx,AUDIO) || (EQ_16(st_fx->coder_type_fx,INACTIVE) && LE_32(st_fx->core_brate, MAX_GSC_INACTIVE_BRATE))) + ELSE IF( EQ_16(st_fx->coder_type,AUDIO) || (EQ_16(st_fx->coder_type,INACTIVE) && LE_32(st_fx->core_brate, MAX_GSC_INACTIVE_BRATE))) { decod_audio_fx( st_fx, dct_exc_tmp, Aq_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf #ifdef ADD_LRTD @@ -1016,7 +1016,7 @@ ivas_error acelp_core_dec_fx( * Apply energy matching when switching to inactive frames *-----------------------------------------------------------------*/ - Inac_swtch_ematch_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type_fx, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode ); + Inac_swtch_ematch_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode ); /*------------------------------------------------------------* * Decode information and modify the excitation signal of stationary unvoiced frames *------------------------------------------------------------*/ @@ -1039,10 +1039,10 @@ ivas_error acelp_core_dec_fx( Copy(hMusicPF->dct_post_old_exc_fx, exc_buffer_fx, DCT_L_POST - OFFSET2); } test(); - IF(hMusicPF != NULL && ((EQ_16(st_fx->coder_type_fx, AUDIO) && EQ_16(st_fx->GSC_noisy_speech_fx, 0)) || (GE_16(st_fx->GSC_IVAS_mode, 1) && EQ_16(st_fx->L_frame, L_FRAME)))) + IF(hMusicPF != NULL && ((EQ_16(st_fx->coder_type, AUDIO) && EQ_16(st_fx->GSC_noisy_speech_fx, 0)) || (GE_16(st_fx->GSC_IVAS_mode, 1) && EQ_16(st_fx->L_frame, L_FRAME)))) { - Word16 last_coder_type = st_fx->last_coder_type_fx; + Word16 last_coder_type = st_fx->last_coder_type; if ( (EQ_16(st_fx->idchan, 1) && EQ_16(st_fx->element_mode, IVAS_CPE_TD)) || (GE_16(st_fx->GSC_IVAS_mode, 1) && st_fx->GSC_noisy_speech_fx == 0)) { @@ -1054,7 +1054,7 @@ ivas_error acelp_core_dec_fx( Prep_music_postP_fx(exc_buffer_fx, dct_buffer_fx, hMusicPF->filt_lfE_fx, st_fx->last_core, pitch_buf_fx, hMusicPF->LDm_enh_lp_gbin_fx, st_fx->Q_exc, &qdct); #else - Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, hMusicPF->filt_lfE_fx, st_fx->last_coder_type_fx, pitch_buf_fx, + Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, hMusicPF->filt_lfE_fx, st_fx->last_coder_type, pitch_buf_fx, hMusicPF->LDm_enh_lp_gbin_fx, st_fx->Q_exc, &qdct ); #endif /* LD music post-filter */ @@ -1071,7 +1071,7 @@ ivas_error acelp_core_dec_fx( /* Core synthesis at 12.8kHz or 16kHz */ i = 1; move16(); - if( EQ_16(st_fx->coder_type_fx,INACTIVE)) + if( EQ_16(st_fx->coder_type,INACTIVE)) { i = 0; move16(); @@ -1081,7 +1081,7 @@ ivas_error acelp_core_dec_fx( move16(); test(); test(); - if( EQ_16(st_fx->coder_type_fx, INACTIVE)&&st_fx->flag_cna&&GE_16(round_fx(L_shl(st_fx->lp_noise,1)),15<<7)) + if( EQ_16(st_fx->coder_type, INACTIVE)&&st_fx->flag_cna&&GE_16(round_fx(L_shl(st_fx->lp_noise,1)),15<<7)) { k = 1; move16(); @@ -1106,7 +1106,7 @@ ivas_error acelp_core_dec_fx( * FEC - Estimate the classification information *------------------------------------------------------------*/ - FEC_clas_estim_fx( st_fx, st_fx->Opt_AMR_WB, st_fx->L_frame, &st_fx->clas_dec, st_fx->coder_type_fx, pitch_buf_fx, + FEC_clas_estim_fx( st_fx, st_fx->Opt_AMR_WB, st_fx->L_frame, &st_fx->clas_dec, st_fx->coder_type, pitch_buf_fx, syn_fx, &st_fx->lp_ener_FER_fx, &st_fx->decision_hyst, NULL, NULL, NULL, NULL, 0, NULL, st_fx->core_brate, st_fx->Q_syn, temp_buf_fx, st_fx->mem_syn_clas_estim_fx, &st_fx->classifier_Q_mem_syn, @@ -1116,8 +1116,8 @@ ivas_error acelp_core_dec_fx( * FEC - Estimate pitch *------------------------------------------------------------*/ - FEC_pitch_estim_fx( st_fx->Opt_AMR_WB, st_fx->last_core, st_fx->L_frame, st_fx->clas_dec, st_fx->last_good_fx, pitch_buf_fx, st_fx->old_pitch_buf_fx, - &st_fx->bfi_pitch_fx, &st_fx->bfi_pitch_frame, &st_fx->upd_cnt, st_fx->coder_type_fx ); + FEC_pitch_estim_fx( st_fx->Opt_AMR_WB, st_fx->last_core, st_fx->L_frame, st_fx->clas_dec, st_fx->last_good, pitch_buf_fx, st_fx->old_pitch_buf_fx, + &st_fx->bfi_pitch_fx, &st_fx->bfi_pitch_frame, &st_fx->upd_cnt, st_fx->coder_type ); /*------------------------------------------------------------* * FEC - Smooth the speech energy evolution when recovering after a BAD frame @@ -1133,7 +1133,7 @@ ivas_error acelp_core_dec_fx( k++; } - FEC_scale_syn_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good_fx, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type_fx, LSF_Q_prediction, + FEC_scale_syn_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn , avoid_lpc_burst_on_recovery, 0 ); @@ -1152,7 +1152,7 @@ ivas_error acelp_core_dec_fx( ELSE { /* SC-VBR */ - if ( EQ_16(st_fx->last_nelp_mode_dec_fx,1)) + if ( EQ_16(st_fx->last_nelp_mode_dec,1)) { st_fx->nelp_mode_dec_fx = 1; move16(); @@ -1163,13 +1163,13 @@ ivas_error acelp_core_dec_fx( test(); if( GT_16(st_fx->nbLostCmpt,5)&&GE_16(st_fx->clas_dec,VOICED_CLAS)&<_16(st_fx->clas_dec,INACTIVE_CLAS)) { - st_fx->last_good_fx = VOICED_TRANSITION; + st_fx->last_good = VOICED_TRANSITION; move16(); } /* LSF estimation and A(z) calculation */ lsf_dec_bfi( MODE1, lsf_new_fx, st_fx->lsf_old_fx, st_fx->lsf_adaptive_mean_fx, NULL, st_fx->mem_MA_fx, st_fx->mem_AR_fx, - st_fx->stab_fac_fx, st_fx->last_coder_type_fx, st_fx->L_frame, st_fx->last_good_fx, + st_fx->stab_fac_fx, st_fx->last_coder_type, st_fx->L_frame, st_fx->last_good, st_fx->nbLostCmpt, 0, NULL, NULL, NULL, st_fx->hGSCDec->Last_GSC_pit_band_idx_fx, st_fx->Opt_AMR_WB, 0, st_fx->bwidth); FEC_lsf2lsp_interp( st_fx, st_fx->L_frame, Aq_fx, lsf_new_fx, lsp_new_fx ); @@ -1185,7 +1185,7 @@ ivas_error acelp_core_dec_fx( FEC_pitch_fx = pitch_buf_fx[3]; move16(); - Rescale_exc(hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32)0, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, L_FRAME, st_fx->coder_type_fx ); + Rescale_exc(hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32)0, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, L_FRAME, st_fx->coder_type ); } ELSE { @@ -1194,7 +1194,7 @@ ivas_error acelp_core_dec_fx( FEC_exc_estim_fx( st_fx, st_fx->L_frame, exc_fx, exc2_fx, dct_exc_tmp, pitch_buf_fx, voice_factors, &FEC_pitch_fx, bwe_exc_fx, lsf_new_fx, &st_fx->Q_exc, &tmp_noise_fx ); Rescale_exc( NULL, exc_fx, bwe_exc_fx, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, L_FRAME32k, (Word32)0, - &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, st_fx->L_frame, st_fx->last_coder_type_fx ); + &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, st_fx->L_frame, st_fx->last_coder_type ); tmp_noise_fx = shr_r(st_fx->lp_gainc_fx,3); /*Q0*/ @@ -1212,7 +1212,7 @@ ivas_error acelp_core_dec_fx( save_old_syn_fx( st_fx->L_frame, temp_buf_fx, old_syn_12k8_16k, hBWE_FD->old_syn_12k8_16k_fx, st_fx->preemph_fac, &hBWE_FD->mem_deemph_old_syn_fx ); } /* Apply energy matching when switching to inactive frames */ - Inac_swtch_ematch_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type_fx, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode ); + Inac_swtch_ematch_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode ); /* udate past excitation signals for LD music post-filter */ IF (hMusicPF != NULL) @@ -1239,7 +1239,7 @@ ivas_error acelp_core_dec_fx( move16(); test(); test(); - if( EQ_16(st_fx->coder_type_fx, INACTIVE)&&st_fx->flag_cna&&GE_16(round_fx(L_shl(st_fx->lp_noise,1)),15<<7)) + if( EQ_16(st_fx->coder_type, INACTIVE)&&st_fx->flag_cna&&GE_16(round_fx(L_shl(st_fx->lp_noise,1)),15<<7)) { k = 1; move16(); @@ -1283,19 +1283,19 @@ ivas_error acelp_core_dec_fx( * (smoothing is performed in the excitation domain and signal is resynthesized after) *------------------------------------------------------------*/ - FEC_scale_syn_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good_fx, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type_fx, LSF_Q_prediction, + FEC_scale_syn_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 ); } /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */ - /* fer_energy( st_fx->L_frame, st_fx->last_good_fx, syn_fx, FEC_pitch_fx, &st_fx->enr_old_fx, st_fx->L_frame ); */ - frame_ener_fx( st_fx->L_frame, st_fx->last_good_fx, syn_fx, shr(add(FEC_pitch_fx,32),6), &st_fx->enr_old_fx, st_fx->L_frame, st_fx->Q_syn, 3, 0 ); + /* fer_energy( st_fx->L_frame, st_fx->last_good, syn_fx, FEC_pitch_fx, &st_fx->enr_old_fx, st_fx->L_frame ); */ + frame_ener_fx( st_fx->L_frame, st_fx->last_good, syn_fx, shr(add(FEC_pitch_fx,32),6), &st_fx->enr_old_fx, st_fx->L_frame, st_fx->Q_syn, 3, 0 ); IF ( st_fx->nelp_mode_dec_fx !=1 ) { /* modify the excitation signal of stationary unvoiced frames */ - stat_noise_uv_mod_fx( st_fx->coder_type_fx, 0, st_fx->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st_fx->Q_exc, 1, &st_fx->ge_sm_fx, + stat_noise_uv_mod_fx( st_fx->coder_type, 0, st_fx->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st_fx->Q_exc, 1, &st_fx->ge_sm_fx, &st_fx->uv_count_fx, &st_fx->act_count_fx, st_fx->lspold_s_fx, &st_fx->noimix_seed_fx, &st_fx->min_alpha_fx, &st_fx->exc_pe_fx, st_fx->core_brate,st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); } @@ -1333,7 +1333,7 @@ ivas_error acelp_core_dec_fx( { st_fx->hPFstat->on = 1; move16(); - nb_post_filt( st_fx->L_frame, st_fx->hPFstat, &st_fx->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, st_fx->coder_type_fx, st_fx->BER_detect, 0 ); + nb_post_filt( st_fx->L_frame, st_fx->hPFstat, &st_fx->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, st_fx->coder_type, st_fx->BER_detect, 0 ); } ELSE { @@ -1408,7 +1408,7 @@ ivas_error acelp_core_dec_fx( { /*VAD only for non inactive frame*/ test(); - st_fx->VAD = st_fx->VAD && (st_fx->coder_type_fx != INACTIVE); + st_fx->VAD = st_fx->VAD && (st_fx->coder_type != INACTIVE); IF(st_fx->idchan == 0 && (st_fx->flag_cna || (EQ_16(st_fx->cng_type, FD_CNG) && LE_32(st_fx->total_brate, ACELP_32k)) || (EQ_16(st_fx->cng_type, LP_CNG) && LE_32(st_fx->total_brate, SID_2k40)))) @@ -1437,7 +1437,7 @@ ivas_error acelp_core_dec_fx( PMT("Code for IVAS_CODE_CNG_FIX185_PLC_FADEOUT not done") ApplyFdCng(syn, st_fx->Q_syn, NULL, realBuffer, imagBuffer, st, 0, (st->coder_type == AUDIO && !st->GSC_noisy_speech)); #else - ApplyFdCng(syn_fx, st_fx->Q_syn, realBuffer, imagBuffer, NULL, st_fx, 0, (EQ_16(st_fx->coder_type_fx, AUDIO) && st_fx->GSC_noisy_speech_fx == 0)); + ApplyFdCng(syn_fx, st_fx->Q_syn, realBuffer, imagBuffer, NULL, st_fx, 0, (EQ_16(st_fx->coder_type, AUDIO) && st_fx->GSC_noisy_speech_fx == 0)); #endif } /* CNA: Generate additional comfort noise to mask potential coding artefacts */ @@ -1539,11 +1539,11 @@ ivas_error acelp_core_dec_fx( } } #else - IF(st_fx->flag_cna && NE_16(st_fx->coder_type_fx, AUDIO)) + IF(st_fx->flag_cna && NE_16(st_fx->coder_type, AUDIO)) { generate_masking_noise(syn_fx, st_fx->Q_syn, st_fx->hFdCngDec->hFdCngCom, st_fx->hFdCngDec->hFdCngCom->frameSize, 0); } - ELSE IF(st_fx->flag_cna && st_fx->coder_type_fx == AUDIO && st_fx->last_core == ACELP_CORE && st_fx->last_coder_type_fx != AUDIO) + ELSE IF(st_fx->flag_cna && st_fx->coder_type == AUDIO && st_fx->last_core == ACELP_CORE && st_fx->last_coder_type != AUDIO) { FOR(i = 0; i < st_fx->hFdCngDec->hFdCngCom->frameSize / 2; i++) { @@ -1553,7 +1553,7 @@ ivas_error acelp_core_dec_fx( } } - IF(st_fx->flag_cna == 0 && EQ_16(st_fx->L_frame, L_FRAME16k) && st_fx->last_flag_cna == 1 && ((st_fx->last_core == ACELP_CORE && st_fx->last_coder_type_fx != AUDIO) || st_fx->last_core == AMR_WB_CORE)) + IF(st_fx->flag_cna == 0 && EQ_16(st_fx->L_frame, L_FRAME16k) && st_fx->last_flag_cna == 1 && ((st_fx->last_core == ACELP_CORE && st_fx->last_coder_type != AUDIO) || st_fx->last_core == AMR_WB_CORE)) { FOR(i = 0; i < st_fx->L_frame / 2; i++) { @@ -1563,7 +1563,7 @@ ivas_error acelp_core_dec_fx( } test(); - IF(st_fx->flag_cna == 0 || EQ_16(st_fx->coder_type_fx, AUDIO)) + IF(st_fx->flag_cna == 0 || EQ_16(st_fx->coder_type, AUDIO)) { set16_fx(st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st_fx->hFdCngDec->hFdCngCom->fftlen); } @@ -1607,7 +1607,7 @@ ivas_error acelp_core_dec_fx( } bass_psfilter_fx(st_fx->hBPF, st_fx->Opt_AMR_WB, syn_fx, st_fx->L_frame, pitch_buf_fx, st_fx->bpf_off, - st_fx->stab_fac_fx, &st_fx->stab_fac_smooth_fx, st_fx->coder_type_fx, st_fx->Q_syn, bpf_error_signal ); + st_fx->stab_fac_fx, &st_fx->stab_fac_smooth_fx, st_fx->coder_type, st_fx->Q_syn, bpf_error_signal ); } test(); IF (NE_16(st_fx->element_mode, IVAS_CPE_DFT) || use_cldfb_for_dft) @@ -1761,7 +1761,7 @@ ivas_error acelp_core_dec_fx( { test(); test(); test(); test(); test(); test(); test(); IF( (EQ_16(st_fx->L_frame,L_FRAME)&&NE_16(st_fx->bwidth,NB)&&GE_16(output_frame,L_FRAME16k)&& - ( EQ_16(st_fx->extl,-1) || EQ_16(st_fx->extl,SWB_CNG) || (EQ_16(st_fx->extl,WB_BWE) && st_fx->extl_brate == 0 && NE_16(st_fx->coder_type_fx,AUDIO) )) ) ) + ( EQ_16(st_fx->extl,-1) || EQ_16(st_fx->extl,SWB_CNG) || (EQ_16(st_fx->extl,WB_BWE) && st_fx->extl_brate == 0 && NE_16(st_fx->coder_type,AUDIO) )) ) ) { hf_synth_fx( st_fx->hBWE_zero, st_fx->core_brate, output_frame, Aq_fx, exc2_fx, syn_fx, synth_out, st_fx->Q_exc, st_fx->Q_syn2, st_fx->hBWE_zero->delay_syn_hf_fx, &hBWE_FD->memExp1, st_fx->hBWE_zero->mem_hp_interp_fx, st_fx->extl, st_fx->CNG_mode ); @@ -1792,7 +1792,7 @@ ivas_error acelp_core_dec_fx( IF(!st_fx->ppp_mode_dec_fx && (st_fx->idchan == 0 || NE_16(st_fx->element_mode, IVAS_CPE_TD) || (EQ_16(st_fx->idchan, 1) && EQ_16(st_fx->element_mode, IVAS_CPE_TD) && st_fx->tdm_LRTD_flag))) { non_linearity_fx(bwe_exc_fx, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, st_fx->Q_exc, - st_fx->coder_type_fx, voice_factors, st_fx->L_frame); + st_fx->coder_type, voice_factors, st_fx->L_frame); } test(); diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 893ae36aa..d7893bdbd 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -53,24 +53,22 @@ * * ACELP core decoder *-------------------------------------------------------------------*/ -static void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HANDLE hStereoCng); -static void acelp_decoder_state_fix2float(Decoder_State *st, STEREO_CNG_DEC_HANDLE hStereoCng); static void rescale_fdCngDec(HANDLE_FD_CNG_DEC hFdCngDec, Word16 old_NoiseExp); ivas_error acelp_core_dec_ivas_fx( Decoder_State *st, /* i/o: decoder state structure */ - float output[], /* o : synthesis @internal Fs */ - float synth[], /* o : synthesis */ - float save_hb_synth[], /* o : HB synthesis */ - float bwe_exc_extended[], /* i/o: bandwidth extended excitation */ - float *voice_factors, /* o : voicing factors */ - float old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ + Word16 output_fx[], /* o : synthesis @internal Fs */ + Word16 synth_fx16[], /* o : synthesis */ + Word16 save_hb_synth_fx16[], /* o : HB synthesis */ + Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */ + Word16 *voice_factors_fx, /* o : voicing factors */ + Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ const int16_t sharpFlag, /* i : formant sharpening flag */ - float pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */ + Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe */ int16_t *unbits, /* o : number of unused bits */ int16_t *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - const float tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */ - const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ + const Word16 tdm_lspQ_PCh_fx[M], /* i : Q LSPs for primary channel */ + const Word16 tdm_lsfQ_PCh_fx[M], /* i : Q LSFs for primary channel */ const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ const int16_t last_element_mode, /* i : last element mode */ const int32_t last_element_brate, /* i : last element bitrate */ @@ -80,48 +78,50 @@ ivas_error acelp_core_dec_ivas_fx( const int16_t read_sid_info /* i : read SID info flag */ ) { - Word16 /*output_fx[960], synth_fx[960], save_hb_synth_fx[960],*/ voice_factors_fx[NB_SUBFR16k], old_syn_12k8_16k_fx[960], pitch_buf_out_fx[NB_SUBFR16k], tdm_lspQ_PCh_fx[M], tdm_lsfQ_PCh_fx[M]; - - for (int i = 0; i < M; i++) { + //Word16 output_fx[960], synth_fx16[960],/* save_hb_synth_fx[960],*/ voice_factors_fx[NB_SUBFR16k], old_syn_12k8_16k_fx[960], pitch_buf_out_fx[NB_SUBFR16k], tdm_lspQ_PCh_fx[M], tdm_lsfQ_PCh_fx[M]; + Word32 synth_fx[960], save_hb_synth_fx[960]/*, bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]*/; + /*for (int i = 0; i < M; i++) { tdm_lsfQ_PCh_fx[i] = (Word16)(tdm_lsfQ_PCh[i] * 2.56f); } floatToFixed_arr((float *)tdm_lspQ_PCh, tdm_lspQ_PCh_fx, Q15, M); + if (save_hb_synth) { + floatToFixed_arrL(save_hb_synth, save_hb_synth_fx, 0, L_FRAME48k); + } + floatToFixed_arrL(bwe_exc_extended, bwe_exc_extended_fx, 0, L_FRAME32k + NL_BUFF_OFFSET);*/ - - //Word32 bwe_exc_extended_fx[960]; - float old_exc[L_EXC_DEC], *exc; /* excitation signal buffer */ + //float old_exc[L_EXC_DEC], *exc; /* excitation signal buffer */ Word16 old_exc_fx[L_EXC_DEC], *exc_fx; /* excitation signal buffer */ - float syn_tmp[L_FRAME16k + L_SUBFR], *syn; /* synthesis signal buffer */ + //float syn_tmp[L_FRAME16k + L_SUBFR], *syn; /* synthesis signal buffer */ Word16 syn_tmp_fx[L_FRAME16k + L_SUBFR], *psyn_fx; /* synthesis signal buffer */ int16_t output_frame; /* frame length at output sampling freq. */ - float lsf_new[M]; /* LSFs at the end of the frame */ + //float lsf_new[M]; /* LSFs at the end of the frame */ Word16 lsf_new_fx[M]; /* LSFs at the end of the frame Qlog2(2.56) */ - float lsp_new[M]; /* LSPs at the end of the frame */ + //float lsp_new[M]; /* LSPs at the end of the frame */ Word16 lsp_new_fx[M]; /* LSPs at the end of the frame Q15 */ - float lsp_mid[M]; /* LSPs in the middle of the frame */ + //float lsp_mid[M]; /* LSPs in the middle of the frame */ Word16 lsp_mid_fx[M]; /* LSPs in the middle of the frame */ - float Aq[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */ + //float Aq[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */ Word16 Aq_fx[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */ - float old_exc2[L_FRAME16k + L_EXC_MEM], *exc2; /* total excitation buffer */ + //float old_exc2[L_FRAME16k + L_EXC_MEM], *exc2; /* total excitation buffer */ Word16 old_exc2_fx[L_FRAME16k + L_EXC_MEM], *exc2_fx; /* total excitation buffer */ //float mem_tmp[M]; /* temporary synthesis filter memory */ Word16 mem_tmp_fx[M]; /* temporary synthesis filter memory */ //float enr_q; /* E information for FER protection */ Word32 enr_q_fx; /* E information for FER protection */ - float tmp_noise; /* Long term temporary noise energy */ + //float tmp_noise; /* Long term temporary noise energy */ Word16 tmp_noise_fx; /* Long term temporary noise energy */ - float Es_pred; /* predicted scaled innov. energy */ + //float Es_pred; /* predicted scaled innov. energy */ Word16 Es_pred_fx; /* predicted scaled innov. energy Q8 */ //float FEC_pitch; /* FEC pitch */ Word16 FEC_pitch_fx; /* FEC pitch */ - float old_bwe_exc[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */ + //float old_bwe_exc[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */ Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */ - float *bwe_exc; /* Excitation for SWB TBE */ + //float *bwe_exc; /* Excitation for SWB TBE */ Word16 *bwe_exc_fx; /* Excitation for SWB TBE */ int16_t i, j, int_fs; int16_t tc_subfr; int16_t allow_cn_step; - float temp_buf[L_FRAME16k + L_SYN_MEM]; + //float temp_buf[L_FRAME16k + L_SYN_MEM]; Word16 temp_buf_fx[L_FRAME16k + L_SYN_MEM]; int16_t last_pulse_pos; int16_t T0_tmp; @@ -132,10 +132,10 @@ ivas_error acelp_core_dec_ivas_fx( Word16 exc_buffer_fx[DCT_L_POST]; //float dct_exc_tmp[L_FRAME16k]; Word16 dct_exc_tmp_fx[L_FRAME16k]; - float bpf_error_signal[L_FRAME16k]; + //float bpf_error_signal[L_FRAME16k]; int16_t nb_bits; /* number of bits */ int16_t indice; /* parameter indices to write */ - float gain_buf[NB_SUBFR16k]; + //float gain_buf[NB_SUBFR16k]; Word16 gain_buf_fx[NB_SUBFR16k]; Word16 syn_fx_tmp2[L_FRAME_16k]; Word16 pitch_buf_tmp[NB_SUBFR16k]; @@ -146,14 +146,14 @@ ivas_error acelp_core_dec_ivas_fx( Word16 exc3_fx[L_FRAME16k]; //float syn1_tmp[L_FRAME16k + 2], *syn1; Word16 syn1_tmp_fx[L_FRAME16k + 2], *syn1_fx; - float *realBuffer[CLDFB_NO_COL_MAX], *imagBuffer[CLDFB_NO_COL_MAX]; + //float *realBuffer[CLDFB_NO_COL_MAX], *imagBuffer[CLDFB_NO_COL_MAX]; #ifdef IVAS_FLOAT_FIXED Word32 *realBuffer_fx[CLDFB_NO_COL_MAX], *imagBuffer_fx[CLDFB_NO_COL_MAX]; Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word32 imagBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; #endif // IVAS_FLOAT_FIXED - float realBufferTmp[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - float imagBufferTmp[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + //float realBufferTmp[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + //float imagBufferTmp[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; int16_t LSF_Q_prediction; /* LSF prediction mode */ Word16 avoid_lpc_burst_on_recovery; //float tmpF; @@ -182,8 +182,6 @@ ivas_error acelp_core_dec_ivas_fx( push_wmops( "acelp_core_dec" ); output_frame = (int16_t) ( st->output_Fs / FRAMES_PER_SEC ); - - acelp_decoder_state_float2fix(st, hStereoCng); /*----------------------------------------------------------------* * stereo SID and CNG frames processing *----------------------------------------------------------------*/ @@ -222,11 +220,11 @@ ivas_error acelp_core_dec_ivas_fx( }*/ ApplyFdCng_fx( NULL, 0, NULL, NULL, NULL, NULL, st, 0, 0 ); + if (st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0) { Scale_sig32(st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp); st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0; } - /*for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ ) { if ( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp <= 31 ) @@ -273,7 +271,7 @@ ivas_error acelp_core_dec_ivas_fx( Copy( lsp_new_fx, st->lsp_old_fx, M ); /*Local fix2float (to be removed)*/ - fixedToFloat_arr(st->Aq_cng, st->Aq_cng_float, Q14 - norm_s(st->Aq_cng[0]), M + 1); + //fixedToFloat_arr(st->Aq_cng, st->Aq_cng_float, Q14 - norm_s(st->Aq_cng[0]), M + 1); /*fixedToFloat_arr(Aq_fx, Aq, Q12, NB_SUBFR16k * (M + 1)); fixedToFloat_arr(lsp_new_fx, lsp_new, Q15, M); for (i = 0; i < M; i++) { @@ -281,14 +279,14 @@ ivas_error acelp_core_dec_ivas_fx( }*/ } - set_f( output, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ - set_f( synth, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */ + //set_f( output, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ + set_s( output_fx, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ + //set_f( synth, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */ + set_s( synth_fx16, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */ /* CN generation done in DFT domain */ pop_wmops(); - acelp_decoder_state_fix2float(st, hStereoCng); - return error; } @@ -297,13 +295,13 @@ ivas_error acelp_core_dec_ivas_fx( *----------------------------------------------------------------*/ /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ - for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + /*for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { set_f( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); set_f( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); realBuffer[i] = realBufferTmp[i]; imagBuffer[i] = imagBufferTmp[i]; - } + }*/ #ifdef IVAS_FLOAT_FIXED for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { @@ -318,9 +316,9 @@ ivas_error acelp_core_dec_ivas_fx( *----------------------------------------------------------------*/ LSF_Q_prediction = -1; - set_f( syn_tmp, 0, L_SUBFR ); + /*set_f( syn_tmp, 0, L_SUBFR ); syn = syn_tmp + L_SUBFR; - /*syn1_tmp[0] = 0; + syn1_tmp[0] = 0; syn1_tmp[1] = 0; syn1 = syn1_tmp + 2;*/ @@ -366,10 +364,10 @@ ivas_error acelp_core_dec_ivas_fx( set_s( hStereoCng->olapBufferSynth22_fx, 0, FFTLEN ); } - st->clas_dec = st->last_good_fx; + st->clas_dec = st->last_good; //enr_q = 0.0f; - Es_pred = 0.0f; - tmp_noise = 0.0f; + /*Es_pred = 0.0f; + tmp_noise = 0.0f;*/ enr_q_fx = 0; Es_pred_fx = 0; @@ -377,7 +375,7 @@ ivas_error acelp_core_dec_ivas_fx( //mvr2r( st->old_exc, old_exc, L_EXC_MEM_DEC ); Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); - exc = old_exc + L_EXC_MEM_DEC; + //exc = old_exc + L_EXC_MEM_DEC; exc_fx = old_exc_fx + L_EXC_MEM_DEC; if ( st->hWIDec != NULL ) @@ -390,19 +388,19 @@ ivas_error acelp_core_dec_ivas_fx( //set_f( old_exc2, 0, L_EXC_MEM ); set_s( old_exc2_fx, 0, L_EXC_MEM ); } - exc2 = old_exc2 + L_EXC_MEM; + //exc2 = old_exc2 + L_EXC_MEM; exc2_fx = old_exc2_fx + L_EXC_MEM; if ( st->hBWE_TD != NULL ) { //mvr2r( st->hBWE_TD->old_bwe_exc, old_bwe_exc, PIT16k_MAX * 2 ); Copy( st->hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 ); - bwe_exc = old_bwe_exc + PIT16k_MAX * 2; + //bwe_exc = old_bwe_exc + PIT16k_MAX * 2; bwe_exc_fx = old_bwe_exc_fx + PIT16k_MAX * 2; } else { - bwe_exc = NULL; + //bwe_exc = NULL; bwe_exc_fx = NULL; } @@ -412,7 +410,7 @@ ivas_error acelp_core_dec_ivas_fx( st->GSC_noisy_speech_fx = 0; //st->relax_prev_lsf_interp = 0; st->relax_prev_lsf_interp_fx = 0; - set_zero( gain_buf, NB_SUBFR16k ); + //set_zero( gain_buf, NB_SUBFR16k ); set_s( gain_buf_fx, 0, NB_SUBFR16k ); if ( st->L_frame == L_FRAME ) @@ -452,8 +450,6 @@ ivas_error acelp_core_dec_ivas_fx( tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag; //p_tdm_Pri_pitch_buf = hStereoTD->tdm_Pri_pitch_buf; p_tdm_Pri_pitch_buf_fx = hStereoTD->tdm_Pri_pitch_buf_fx; - /*local float2fix, to be removed*/ - floatToFixed_arr(hStereoTD->tdm_Pri_pitch_buf, hStereoTD->tdm_Pri_pitch_buf_fx, Q6, NB_SUBFR ); } else { @@ -675,10 +671,10 @@ ivas_error acelp_core_dec_ivas_fx( } /*Local fix2float (to be removed)*/ - fixedToFloat_arr(old_exc_fx, old_exc, st->Q_exc, L_EXC_DEC); + /*fixedToFloat_arr(old_exc_fx, old_exc, st->Q_exc, L_EXC_DEC); fixedToFloat_arr(old_exc2_fx, old_exc2, st->Q_exc, L_FRAME16k + L_EXC_MEM); fixedToFloat_arr(old_bwe_exc_fx, old_bwe_exc, st->Q_exc, ((PIT16k_MAX + (L_FRAME16k + 1) + L_SUBFR16k) * 2)); - fixedToFloat_arr(gain_buf_fx, gain_buf, Q14, NB_SUBFR16k); + fixedToFloat_arr(gain_buf_fx, gain_buf, Q14, NB_SUBFR16k);*/ if ( st->last_bwidth == NB && st->bwidth != NB && st->ini_frame != 0 ) { @@ -697,7 +693,7 @@ ivas_error acelp_core_dec_ivas_fx( *----------------------------------------------------------------*/ tc_subfr = -1; - if ( st->coder_type_fx == TRANSITION ) + if ( st->coder_type == TRANSITION ) { tc_subfr = tc_classif( st ); } @@ -708,7 +704,7 @@ ivas_error acelp_core_dec_ivas_fx( if ( st->element_mode > EVS_MONO && st->idchan == 0 && !( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) && !tdm_low_rate_mode ) { - if ( st->coder_type_fx == AUDIO || ( st->coder_type_fx == INACTIVE && st->total_brate <= MAX_GSC_INACTIVE_BRATE ) ) + if ( st->coder_type == AUDIO || ( st->coder_type == INACTIVE && st->total_brate <= MAX_GSC_INACTIVE_BRATE ) ) { st->GSC_IVAS_mode = get_next_indice( st, 2 ); } @@ -731,7 +727,7 @@ ivas_error acelp_core_dec_ivas_fx( } Copy( Aq_fx, st->Aq_cng, M + 1 ); /*Local fix2float (to be removed)*/ - fixedToFloat_arr(st->Aq_cng, st->Aq_cng_float, Q12, M + 1); + //fixedToFloat_arr(st->Aq_cng, st->Aq_cng_float, Q12, M + 1); /* comfort noise generation */ local_element_mode = st->element_mode; @@ -798,12 +794,12 @@ ivas_error acelp_core_dec_ivas_fx( Scale_sig32(st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp - new_cngNoiseLevelExp); st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = new_cngNoiseLevelExp; - ApplyFdCng_fx(psyn_fx, st->Q_syn, NULL, realBuffer, imagBuffer, NULL, st, 0, ( st->coder_type_fx == AUDIO && !st->GSC_noisy_speech_fx ) ); + ApplyFdCng_fx(psyn_fx, st->Q_syn, NULL, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech_fx ) ); + if (st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0) { Scale_sig32(st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp); st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0; } - /*for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ ) { if ( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp <= 31 ) @@ -894,7 +890,7 @@ ivas_error acelp_core_dec_ivas_fx( st->Q_exc_cng = st->Q_exc; /* reset the decoder */ //CNG_reset_dec( st, pitch_buf, voice_factors ); - CNG_reset_dec_fx( st, pitch_buf_out_fx, voice_factors_fx ); + CNG_reset_dec_fx( st, pitch_buf_fx, voice_factors_fx ); /* update st->mem_syn1 for ACELP core switching */ //mvr2r( st->mem_syn3, st->mem_syn1, M ); @@ -944,11 +940,11 @@ ivas_error acelp_core_dec_ivas_fx( nb_bits = -1; } - config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech_fx, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type_fx, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); + config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech_fx, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); - if ( st->coder_type_fx == TRANSITION && tc_subfr < L_SUBFR && st->L_frame == L_FRAME ) + if ( st->coder_type == TRANSITION && tc_subfr < L_SUBFR && st->L_frame == L_FRAME ) { - config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type_fx, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); + config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); } } @@ -1020,7 +1016,7 @@ ivas_error acelp_core_dec_ivas_fx( //pt_interp_2 = interpol_frac_12k8; pt_interp_2_fx = interpol_frac_fx; - if ( tdm_low_rate_mode == 1 && st->coder_type_fx > UNVOICED ) + if ( tdm_low_rate_mode == 1 && st->coder_type > UNVOICED ) { //pt_interp_2 = intercpol_frac2; pt_interp_2_fx = interpol_frac2_fx; @@ -1095,7 +1091,7 @@ ivas_error acelp_core_dec_ivas_fx( //FEC_SinOnset( old_exc + L_EXC_MEM_DEC - L_EXC_MEM, last_pulse_pos, T0_tmp, enr_q, Aq, st->L_frame ); FEC_SinOnset_fx( old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, last_pulse_pos, T0_tmp, enr_q_fx, Aq_fx, st->L_frame, st->Q_exc ); } - else if ( ( st->coder_type_fx == GENERIC || st->coder_type_fx == VOICED ) && last_pulse_pos != 0 && st->old_bfi_cnt == 1 && st->hWIDec != NULL ) + else if ( ( st->coder_type == GENERIC || st->coder_type == VOICED ) && last_pulse_pos != 0 && st->old_bfi_cnt == 1 && st->hWIDec != NULL ) { //do_WI = FEC_enhACB( st->L_frame, st->last_L_frame, old_exc + L_EXC_MEM_DEC - L_EXC_MEM, T0_tmp, last_pulse_pos, st->bfi_pitch ); do_WI = FEC_enhACB_fx( st->L_frame, st->last_L_frame, old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, T0_tmp, last_pulse_pos, st->bfi_pitch_fx ); @@ -1131,15 +1127,15 @@ ivas_error acelp_core_dec_ivas_fx( if ( tdm_low_rate_mode ) /* tdm stereo low rate mode */ { - if ( st->coder_type_fx <= UNVOICED ) + if ( st->coder_type <= UNVOICED ) { //tdm_low_rate_dec( st, dct_exc_tmp, &tmp_noise, pitch_buf, voice_factors, exc, exc2, bwe_exc, lsf_new ); - tdm_low_rate_dec_fx( st, dct_exc_tmp_fx/*, &tmp_noise*/, pitch_buf_out_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, st->Q_exc ); + tdm_low_rate_dec_fx( st, dct_exc_tmp_fx/*, &tmp_noise*/, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, st->Q_exc ); } else /* GENERIC */ { //decod_gen_2sbfr( st, sharpFlag, Aq, pitch_buf, voice_factors, exc, exc2, bwe_exc, gain_buf, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf ); - decod_gen_2sbfr_ivas_fx( st, sharpFlag, Aq_fx, pitch_buf_out_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx, st->Q_exc ); + decod_gen_2sbfr_ivas_fx( st, sharpFlag, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx, st->Q_exc ); if ( st->element_mode == IVAS_CPE_TD ) { @@ -1156,15 +1152,15 @@ ivas_error acelp_core_dec_ivas_fx( move16(); /* SC-VBR - NELP frames */ //decod_nelp( st, &tmp_noise, pitch_buf, exc, exc2, voice_factors, bwe_exc, st->bfi, gain_buf ); - decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_out_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx); - Rescale_exc(st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32)0, &(st->Q_exc), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type_fx); + decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx); + Rescale_exc(st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32)0, &(st->Q_exc), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type); } - else if ( st->coder_type_fx == UNVOICED ) + else if ( st->coder_type == UNVOICED ) { /* UNVOICED frames */ //decod_unvoiced( st, Aq, Es_pred, uc_two_stage_flag, &tmp_noise, pitch_buf, voice_factors, exc, exc2, bwe_exc, gain_buf ); //decod_unvoiced_fx( st, Aq_fx, st->coder_type, &tmp_noise_fx, pitch_buf_out_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx); - decod_unvoiced_ivas_fx( st, Aq_fx, Es_pred_fx, uc_two_stage_flag, st->coder_type_fx, &tmp_noise_fx, pitch_buf_out_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, st->Q_exc, gain_buf_fx); + decod_unvoiced_ivas_fx( st, Aq_fx, Es_pred_fx, uc_two_stage_flag, st->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, st->Q_exc, gain_buf_fx); tmp_noise_fx = shr_r(st->lp_gainc_fx, 3); /*Q0*/ } else if ( st->ppp_mode_dec_fx) @@ -1173,24 +1169,24 @@ ivas_error acelp_core_dec_ivas_fx( st->Q_exc = 0; /* SC-VBR - PPP frames */ //if ( ( error = decod_ppp( st, Aq, pitch_buf, exc, exc2, voice_factors, bwe_exc, gain_buf, st->bfi ) ) != IVAS_ERR_OK ) - if ( ( error = decod_ppp_fx( st, Aq_fx, pitch_buf_out_fx, exc_fx, exc2_fx, st->bfi, gain_buf_fx, voice_factors_fx, bwe_exc_fx ) ) != IVAS_ERR_OK ) + if ( ( error = decod_ppp_fx( st, Aq_fx, pitch_buf_fx, exc_fx, exc2_fx, st->bfi, gain_buf_fx, voice_factors_fx, bwe_exc_fx ) ) != IVAS_ERR_OK ) { return error; } - Rescale_exc(st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32)0, &(st->Q_exc), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type_fx); + Rescale_exc(st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32)0, &(st->Q_exc), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type); } - else if ( st->coder_type_fx == TRANSITION ) + else if ( st->coder_type == TRANSITION ) { //decod_tran( st, st->L_frame, tc_subfr, Aq, Es_pred, pitch_buf, voice_factors, exc, exc2, bwe_exc, unbits, sharpFlag, gain_buf ); - decod_tran_fx( st, st->L_frame, tc_subfr, Aq_fx, Es_pred_fx, pitch_buf_out_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf_fx); + decod_tran_fx( st, st->L_frame, tc_subfr, Aq_fx, Es_pred_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf_fx); } - else if ( st->coder_type_fx == AUDIO || ( st->coder_type_fx == INACTIVE && st->inactive_coder_type_flag ) ) + else if ( st->coder_type == AUDIO || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) ) { /* AUDIO and INACTIVE frames (coded by GSC technology) */ //decod_audio( st, dct_exc_tmp, Aq, &tmp_noise, pitch_buf, voice_factors, exc, exc2, bwe_exc, lsf_new, gain_buf, tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf ); - decod_audio_ivas_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_out_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx + decod_audio_ivas_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx #if 1//def ADD_LRTD , tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx #endif @@ -1202,7 +1198,7 @@ ivas_error acelp_core_dec_ivas_fx( /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */ //if ( ( error = decod_gen_voic( st, st->L_frame, sharpFlag, Aq, Es_pred, do_WI, pitch_buf, voice_factors, exc, exc2, bwe_exc, unbits, gain_buf, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf ) ) != IVAS_ERR_OK ) //if ( ( error = decod_gen_voic_fx( st, st->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI, pitch_buf_out_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf_fx/*, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx*/) ) != IVAS_ERR_OK ) - if ( ( error = decod_gen_voic_ivas_fx( st, st->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI, pitch_buf_out_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx) ) != IVAS_ERR_OK ) + if ( ( error = decod_gen_voic_ivas_fx( st, st->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx) ) != IVAS_ERR_OK ) { return error; } @@ -1231,7 +1227,7 @@ ivas_error acelp_core_dec_ivas_fx( *-----------------------------------------------------------------*/ //inact_switch_ematch( exc2, dct_exc_tmp, st->hGSCDec->lt_ener_per_band, st->coder_type, st->L_frame, st->total_brate, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode ); - Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type_fx, st->L_frame, st->total_brate, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode ); + Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->L_frame, st->total_brate, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode ); /*------------------------------------------------------------* * Decode information and modify the excitation signal of stationary unvoiced frames @@ -1259,9 +1255,9 @@ ivas_error acelp_core_dec_ivas_fx( Copy( st->hMusicPF->dct_post_old_exc_fx, exc_buffer_fx, DCT_L_POST - OFFSET2 ); } - if ( ( st->coder_type_fx == AUDIO && !st->GSC_noisy_speech_fx ) || ( st->GSC_IVAS_mode >= 1 && st->L_frame == L_FRAME ) ) + if ( ( st->coder_type == AUDIO && !st->GSC_noisy_speech_fx ) || ( st->GSC_IVAS_mode >= 1 && st->L_frame == L_FRAME ) ) { - int16_t last_coder_type = st->last_coder_type_fx; + int16_t last_coder_type = st->last_coder_type; if ( ( st->idchan == 1 && st->element_mode == IVAS_CPE_TD ) || ( st->GSC_IVAS_mode >= 1 && st->GSC_noisy_speech_fx == 0 ) ) { @@ -1271,7 +1267,7 @@ ivas_error acelp_core_dec_ivas_fx( Word16 qdct = 0; /* Extrapolation of the last future part, windowing and high resolution DCT transform */ //Prep_music_postP( exc_buffer, dct_buffer, st->hMusicPF->filt_lfE, st->last_core, pitch_buf, st->hMusicPF->LDm_enh_lp_gbin ); - Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_core, pitch_buf_out_fx, st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct); + Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_core, pitch_buf_fx, st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct); /* LD music post-filter */ //LD_music_post_filter( st->hMusicPF, dct_buffer, dct_buffer, st->core_brate, AUDIO, last_coder_type ); @@ -1290,7 +1286,7 @@ ivas_error acelp_core_dec_ivas_fx( /* Core synthesis at 12.8kHz or 16kHz */ i = 1; move16(); - if (EQ_16(st->coder_type_fx, INACTIVE)) + if (EQ_16(st->coder_type, INACTIVE)) { i = 0; move16(); @@ -1300,7 +1296,7 @@ ivas_error acelp_core_dec_ivas_fx( move16(); test(); test(); - if (EQ_16(st->coder_type_fx, INACTIVE) && st->flag_cna&&GE_16(round_fx(L_shl(st->lp_noise, 1)), 15 << 7)) + if (EQ_16(st->coder_type, INACTIVE) && st->flag_cna&&GE_16(round_fx(L_shl(st->lp_noise, 1)), 15 << 7)) { k = 1; move16(); @@ -1329,7 +1325,7 @@ ivas_error acelp_core_dec_ivas_fx( *------------------------------------------------------------*/ //FEC_clas_estim( syn, pitch_buf, st->L_frame, st->coder_type, st->codec_mode, st->mem_syn_clas_estim, &st->clas_dec, &st->lp_ener_bfi, st->Opt_AMR_WB, &st->decision_hyst, NULL, NULL, NULL, NULL, NULL, NULL, temp_buf, 0, 0, 0, 0, 0, 0, st->last_core_brate, st->acelp_cfg.FEC_mode ); - FEC_clas_estim_fx(st, st->Opt_AMR_WB, st->L_frame, &st->clas_dec, st->coder_type_fx, pitch_buf_out_fx, + FEC_clas_estim_fx(st, st->Opt_AMR_WB, st->L_frame, &st->clas_dec, st->coder_type, pitch_buf_fx, psyn_fx, &st->lp_ener_FER_fx, &st->decision_hyst, NULL, NULL, NULL, NULL, 0, NULL, st->core_brate, st->Q_syn, temp_buf_fx, st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn, @@ -1339,8 +1335,8 @@ ivas_error acelp_core_dec_ivas_fx( *------------------------------------------------------------*/ //FEC_pitch_estim( st->Opt_AMR_WB, st->last_core, st->L_frame, st->clas_dec, st->last_good, pitch_buf, st->old_pitch_buf, &st->bfi_pitch, &st->bfi_pitch_frame, &st->upd_cnt, st->coder_type ); - FEC_pitch_estim_fx(st->Opt_AMR_WB, st->last_core, st->L_frame, st->clas_dec, st->last_good_fx, pitch_buf_out_fx, st->old_pitch_buf_fx, - &st->bfi_pitch_fx, &st->bfi_pitch_frame, &st->upd_cnt, st->coder_type_fx); + FEC_pitch_estim_fx(st->Opt_AMR_WB, st->last_core, st->L_frame, st->clas_dec, st->last_good, pitch_buf_fx, st->old_pitch_buf_fx, + &st->bfi_pitch_fx, &st->bfi_pitch_frame, &st->upd_cnt, st->coder_type); /*------------------------------------------------------------* * FEC - Smooth the speech energy evolution when recovering after a BAD frame @@ -1348,9 +1344,9 @@ ivas_error acelp_core_dec_ivas_fx( *------------------------------------------------------------*/ move16(); - Copy_Scale_sig(pitch_buf_out_fx, pitch_buf_tmp, NB_SUBFR16k, -Q6); + Copy_Scale_sig(pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k, -Q6); //FEC_scale_syn( st->L_frame, st->clas_dec, st->last_good, syn, pitch_buf, st->enr_old, enr_q, st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av_float, &st->lp_ener_FEC_max_float, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, exc, exc2, Aq, &st->old_enr_LP_float, mem_tmp, st->mem_syn2, st->last_con_tcx && ( st->L_frameTCX_past != st->L_frame ) && ( st->last_core != ACELP_CORE ), 0 ); - FEC_scale_syn_fx(st->L_frame, &update_flg, st->clas_dec, st->last_good_fx, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type_fx, LSF_Q_prediction, + FEC_scale_syn_fx(st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0); @@ -1376,7 +1372,7 @@ ivas_error acelp_core_dec_ivas_fx( else { /* SC-VBR */ - IF(EQ_16(st->last_nelp_mode_dec_fx, 1)) + IF(EQ_16(st->last_nelp_mode_dec, 1)) { st->nelp_mode_dec_fx = 1; move16(); @@ -1385,13 +1381,13 @@ ivas_error acelp_core_dec_ivas_fx( /* long burst frame erasures */ IF(GT_16(st->nbLostCmpt, 5) && GE_16(st->clas_dec, VOICED_CLAS) && LT_16(st->clas_dec, INACTIVE_CLAS)) { - st->last_good_fx = VOICED_TRANSITION; + st->last_good = VOICED_TRANSITION; move16(); } /* LSF estimation and A(z) calculation */ //lsf_dec_bfi_flt( MODE1, lsf_new, st->lsf_old, st->lsf_adaptive_mean, NULL, st->mem_MA, st->mem_AR, st->stab_fac, st->last_coder_type, st->L_frame, st->last_good, st->nbLostCmpt, 0, NULL, NULL, NULL, st->hGSCDec->Last_GSC_pit_band_idx, st->Opt_AMR_WB, st->bwidth ); - lsf_dec_bfi(MODE1, lsf_new_fx, st->lsf_old_fx, st->lsf_adaptive_mean_fx, NULL, st->mem_MA_fx, st->mem_AR_fx, st->stab_fac_fx, st->last_coder_type_fx, st->L_frame, st->last_good_fx, st->nbLostCmpt, 0, NULL, NULL, NULL, st->hGSCDec->Last_GSC_pit_band_idx_fx, st->Opt_AMR_WB, 0, st->bwidth); + lsf_dec_bfi(MODE1, lsf_new_fx, st->lsf_old_fx, st->lsf_adaptive_mean_fx, NULL, st->mem_MA_fx, st->mem_AR_fx, st->stab_fac_fx, st->last_coder_type, st->L_frame, st->last_good, st->nbLostCmpt, 0, NULL, NULL, NULL, st->hGSCDec->Last_GSC_pit_band_idx_fx, st->Opt_AMR_WB, 0, st->bwidth); //FEC_lsf2lsp_interp_flt( st, st->L_frame, Aq, lsf_new, lsp_new ); FEC_lsf2lsp_interp(st, st->L_frame, Aq_fx, lsf_new_fx, lsp_new_fx); @@ -1407,19 +1403,19 @@ ivas_error acelp_core_dec_ivas_fx( move16(); //decod_nelp( st, &tmp_noise, pitch_buf, exc, exc2, voice_factors, bwe_exc, st->bfi, gain_buf ); - decod_nelp_fx(st, &tmp_noise_fx, pitch_buf_out_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx); - FEC_pitch_fx = pitch_buf_out_fx[3]; + decod_nelp_fx(st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx); + FEC_pitch_fx = pitch_buf_fx[3]; - Rescale_exc(st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32)0, &(st->Q_exc), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type_fx); + Rescale_exc(st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32)0, &(st->Q_exc), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type); } else { /* calculation of excitation signal */ //FEC_exc_estim( st, st->L_frame, exc, exc2, dct_exc_tmp, pitch_buf, voice_factors, &FEC_pitch, bwe_exc, lsf_new, &tmp_noise ); - FEC_exc_estim_fx(st, st->L_frame, exc_fx, exc2_fx, dct_exc_tmp_fx, pitch_buf_out_fx, voice_factors_fx, &FEC_pitch_fx, bwe_exc_fx, lsf_new_fx, &st->Q_exc, &tmp_noise_fx); + FEC_exc_estim_fx(st, st->L_frame, exc_fx, exc2_fx, dct_exc_tmp_fx, pitch_buf_fx, voice_factors_fx, &FEC_pitch_fx, bwe_exc_fx, lsf_new_fx, &st->Q_exc, &tmp_noise_fx); Rescale_exc(NULL, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, L_FRAME32k, (Word32)0, - &(st->Q_exc), st->Q_subfr, exc2_fx, st->L_frame, st->last_coder_type_fx); + &(st->Q_exc), st->Q_subfr, exc2_fx, st->L_frame, st->last_coder_type); //tmp_noise = st->lp_gainc; tmp_noise_fx = shr_r(st->lp_gainc_fx, 3); /*Q0*/ @@ -1442,7 +1438,7 @@ ivas_error acelp_core_dec_ivas_fx( /* Apply energy matching when switching to inactive frames */ //inact_switch_ematch( exc2, dct_exc_tmp, st->hGSCDec->lt_ener_per_band, st->coder_type, st->L_frame, st->total_brate, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode ); - Inac_switch_ematch_ivas_fx(exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type_fx, st->L_frame, st->total_brate, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode); + Inac_switch_ematch_ivas_fx(exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->L_frame, st->total_brate, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode); /* update past excitation signals for LD music post-filter */ if ( st->hMusicPF != NULL ) @@ -1473,7 +1469,7 @@ ivas_error acelp_core_dec_ivas_fx( move16(); test(); test(); - if (EQ_16(st->coder_type_fx, INACTIVE) && st->flag_cna&&GE_16(round_fx(L_shl(st->lp_noise, 1)), 15 << 7)) + if (EQ_16(st->coder_type, INACTIVE) && st->flag_cna&&GE_16(round_fx(L_shl(st->lp_noise, 1)), 15 << 7)) { k = 1; move16(); @@ -1511,23 +1507,23 @@ ivas_error acelp_core_dec_ivas_fx( if ( ( st->total_brate == ACELP_7k20 ) || ( st->total_brate == ACELP_8k00 ) ) { - Copy_Scale_sig(pitch_buf_out_fx, pitch_buf_tmp, NB_SUBFR16k, -Q6); + Copy_Scale_sig(pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k, -Q6); //FEC_scale_syn( st->L_frame, st->clas_dec, st->last_good, syn, pitch_buf, st->enr_old, enr_q, st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av_float, &st->lp_ener_FEC_max_float, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, exc, exc2, Aq, &st->old_enr_LP_float, mem_tmp, st->mem_syn2, st->last_con_tcx && ( st->L_frameTCX_past != st->L_frame ) && ( st->last_core != ACELP_CORE ), 0 ); - FEC_scale_syn_fx(st->L_frame, &update_flg, st->clas_dec, st->last_good_fx, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type_fx, LSF_Q_prediction, + FEC_scale_syn_fx(st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0); } /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */ //fer_energy( st->L_frame, st->last_good, syn, FEC_pitch, &st->enr_old, st->L_frame ); - frame_ener_fx(st->L_frame, st->last_good_fx, psyn_fx, shr(add(FEC_pitch_fx, 32), 6), &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0); + frame_ener_fx(st->L_frame, st->last_good, psyn_fx, shr(add(FEC_pitch_fx, 32), 6), &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0); if ( st->nelp_mode_dec_fx != 1 ) { /* modify the excitation signal of stationary unvoiced frames */ //stat_noise_uv_mod( st->coder_type, 0, st->lsp_old, lsp_new, lsp_new, Aq, exc2, 1, &st->ge_sm, &st->uv_count, &st->act_count, st->lspold_s, &st->noimix_seed, &st->min_alpha, &st->exc_pe, st->core_brate, st->bwidth ); - stat_noise_uv_mod_fx(st->coder_type_fx, 0, st->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st->Q_exc, 1, &st->ge_sm_fx, + stat_noise_uv_mod_fx(st->coder_type, 0, st->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st->Q_exc, 1, &st->ge_sm_fx, &st->uv_count_fx, &st->act_count_fx, st->lspold_s_fx, &st->noimix_seed_fx, &st->min_alpha_fx, &st->exc_pe_fx, st->core_brate, st->bwidth, &st->Q_stat_noise, &st->Q_stat_noise_ge); } @@ -1570,13 +1566,13 @@ ivas_error acelp_core_dec_ivas_fx( test(); IF(EQ_16(st->last_bwidth, NB) && st->hPFstat != NULL) { - Copy(pitch_buf_out_fx, pitch_buf_tmp, NB_SUBFR16k); + Copy(pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k); IF(EQ_16(st->bwidth, NB)) { st->hPFstat->on = 1; #ifdef IVAS_FLOAT_FIXED move16(); - nb_post_filt(st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, st->coder_type_fx, st->BER_detect, 0); + nb_post_filt(st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, st->coder_type, st->BER_detect, 0); #else nb_post_filt_ivas(st->L_frame, L_SUBFR, st->hPFstat, &st->psf_lp_noise, tmp_noise, syn, Aq, pitch_buf, st->coder_type, st->BER_detect, 0); @@ -1761,7 +1757,7 @@ ivas_error acelp_core_dec_ivas_fx( if (st->element_mode == IVAS_CPE_TD || st->flag_cna || (st->cng_type == FD_CNG && st->total_brate <= ACELP_32k) || (st->cng_type == LP_CNG && st->core_brate <= SID_2k40)) { /*VAD only for non inactive frame*/ - st->VAD = st->VAD && (st->coder_type_fx != INACTIVE); + st->VAD = st->VAD && (st->coder_type != INACTIVE); if (st->idchan == 0 && (st->flag_cna || (st->cng_type == FD_CNG && st->total_brate <= ACELP_32k) || (st->cng_type == LP_CNG && st->core_brate <= SID_2k40))) { @@ -1829,7 +1825,7 @@ ivas_error acelp_core_dec_ivas_fx( /*==========================================================*/ //ApplyFdCng_fx( syn_fx + L_SUBFR, st->Q_syn, NULL, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); - ApplyFdCng_fx(psyn_fx, st->Q_syn, NULL, realBuffer_fx, imagBuffer_fx, NULL, st, 0, (st->coder_type_fx == AUDIO && !st->GSC_noisy_speech_fx)); + ApplyFdCng_fx(psyn_fx, st->Q_syn, NULL, realBuffer_fx, imagBuffer_fx, NULL, st, 0, (st->coder_type == AUDIO && !st->GSC_noisy_speech_fx)); /*==========================================================*/ if (st->hFdCngDec->partNoiseShape_exp < 0) { Scale_sig32(st->hFdCngDec->partNoiseShape, NPART, st->hFdCngDec->partNoiseShape_exp); @@ -1961,7 +1957,7 @@ ivas_error acelp_core_dec_ivas_fx( if (!st->cna_dirac_flag) { /* CNA: Generate additional comfort noise to mask potential coding artefacts */ - if (st->flag_cna && !(st->coder_type_fx == AUDIO && !(st->element_mode > EVS_MONO && st->GSC_noisy_speech_fx))) + if (st->flag_cna && !(st->coder_type == AUDIO && !(st->element_mode > EVS_MONO && st->GSC_noisy_speech_fx))) { if (st->element_mode == IVAS_CPE_TD && nchan_out == 2) { @@ -2006,7 +2002,7 @@ ivas_error acelp_core_dec_ivas_fx( } } } - else if (st->flag_cna && st->coder_type_fx == AUDIO && ((st->last_core == ACELP_CORE && !(st->last_coder_type_fx == AUDIO && !(st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag_fx))) || st->last_core == TCX_20_CORE)) + else if (st->flag_cna && st->coder_type == AUDIO && ((st->last_core == ACELP_CORE && !(st->last_coder_type == AUDIO && !(st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag_fx))) || st->last_core == TCX_20_CORE)) { if (st->element_mode == IVAS_CPE_TD && nchan_out == 2) { @@ -2074,7 +2070,7 @@ ivas_error acelp_core_dec_ivas_fx( //st->hFdCngDec->partNoiseShape_exp = 31 - Q4; // Q4 //floatToFixed_arrL(st->hFdCngDec->partNoiseShape_float, st->hFdCngDec->partNoiseShape, Q31 - st->hFdCngDec->partNoiseShape_exp, NPART); - ApplyFdCng_fx(psyn_fx, st->Q_syn, NULL, realBuffer_fx, imagBuffer_fx, NULL, st, 0, (st->coder_type_fx == AUDIO && !st->GSC_noisy_speech_fx)); + ApplyFdCng_fx(psyn_fx, st->Q_syn, NULL, realBuffer_fx, imagBuffer_fx, NULL, st, 0, (st->coder_type == AUDIO && !st->GSC_noisy_speech_fx)); if (st->hFdCngDec->partNoiseShape_exp < 0) { Scale_sig32(st->hFdCngDec->partNoiseShape, NPART, -st->hFdCngDec->partNoiseShape_exp); st->hFdCngDec->partNoiseShape_exp = 0; @@ -2210,7 +2206,7 @@ ivas_error acelp_core_dec_ivas_fx( if (!st->cna_dirac_flag) { - if (st->flag_cna == 0 && st->L_frame == L_FRAME16k && st->last_flag_cna == 1 && ((st->last_core == ACELP_CORE && !(st->last_coder_type_fx == AUDIO && !(st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag_fx))) || st->last_core == AMR_WB_CORE)) + if (st->flag_cna == 0 && st->L_frame == L_FRAME16k && st->last_flag_cna == 1 && ((st->last_core == ACELP_CORE && !(st->last_coder_type == AUDIO && !(st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag_fx))) || st->last_core == AMR_WB_CORE)) { //v_multc(st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt + 5 * st->L_frame / 4, 256.f, temp_buf, st->L_frame / 2); //v_add(temp_buf, syn, syn, st->L_frame / 2); @@ -2221,7 +2217,7 @@ ivas_error acelp_core_dec_ivas_fx( } } - if (st->flag_cna == 0 || (st->coder_type_fx == AUDIO && !(st->element_mode > EVS_MONO && st->GSC_noisy_speech_fx))) + if (st->flag_cna == 0 || (st->coder_type == AUDIO && !(st->element_mode > EVS_MONO && st->GSC_noisy_speech_fx))) { if (st->idchan == 0) { @@ -2290,7 +2286,7 @@ ivas_error acelp_core_dec_ivas_fx( for (Word16 lp = 0; lp < lim; lp++) { //pitch_buf_fx[lp] = (Word32)(pitch_buf[lp] * (1u << 20)); - pitch_buf_fx_q20[lp] = L_shl(pitch_buf_out_fx[lp], Q14); + pitch_buf_fx_q20[lp] = L_shl(pitch_buf_fx[lp], Q14); } bpf_pitch_coherence_fx(st, pitch_buf_fx_q20); @@ -2443,85 +2439,8 @@ ivas_error acelp_core_dec_ivas_fx( } } - bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_out_fx, st->bpf_off, - st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type_fx, st->Q_syn, bpf_error_signal_16fx); - } - - { - /* Lccal fix2float (To be removed) */ - for (i = 0; i < L_FRAME16k; i++) - { - bpf_error_signal[i] = fixedToFloat(bpf_error_signal_16fx[i], st->Q_syn); - } - for (int nsf = 0; nsf < NB_SUBFR16k; nsf++) - { - fixedToFloat_arr(Aq_fx + (nsf * (M + 1)), Aq + (nsf * (M + 1)), Q14 - norm_s(Aq_fx[nsf * (M + 1)]), (M + 1)); - } - /*printf("\n"); - for (int nm = 0; nm < M + 1; nm++) { - printf("%f ", Aq[nm]); - }*/ - // Aq_fx[0] = ONE_IN_Q12; - if (st->hFdCngDec) - { - st->hFdCngDec->hFdCngCom->A_cng[0] = ONE_IN_Q12; - } - for (i = 0; i < M; i++) - { - lsf_new[i] = lsf_new_fx[i] / 2.56f; - } - fixedToFloat_arr(lsp_new_fx, lsp_new, Q15, M); - fixedToFloat_arr(lsp_mid_fx, lsp_mid, Q15, M); - float *tdm_lsfQ_PCh_out = (float *)tdm_lsfQ_PCh; - for (int idx = 0; idx < M; idx++) - { - tdm_lsfQ_PCh_out[idx] = tdm_lsfQ_PCh_fx[idx] / 2.56f; - } - fixedToFloat_arr(tdm_lspQ_PCh_fx, (float *)tdm_lspQ_PCh, Q15, M); - /*printf("\n"); - for (int nm = 0; nm < M; nm++) { - printf("%f ", lsf_new[nm]); - }*/ - fixedToFloat_arr(old_exc_fx, old_exc, st->Q_exc, L_EXC_DEC); // exc_fx - fixedToFloat_arr(old_exc2_fx, old_exc2, st->Q_exc, L_FRAME16k + L_EXC_MEM); // exc2_fx - fixedToFloat_arr(old_bwe_exc_fx, old_bwe_exc, st->Q_exc, ((PIT16k_MAX + (L_FRAME16k + 1) + L_SUBFR16k) * 2)); // bwe_exc_fx - fixedToFloat_arr(syn_tmp_fx, syn_tmp, st->Q_syn, L_FRAME16k + L_SUBFR); // psyn_fx - // fixedToFloat_arr(syn1_tmp_fx, syn1_tmp, st->Q_syn, L_FRAME16k + 2); - fixedToFloat_arr(temp_buf_fx, temp_buf, -1, L_FRAME16k + L_SYN_MEM); - Es_pred = fixedToFloat(Es_pred_fx, Q8); - // enr_q = fixedToFloat(enr_q_fx, 0); - - // fixedToFloat_arr(dct_exc_tmp_fx, dct_exc_tmp, st->Q_exc, L_FRAME16k); - // if (p_tdm_Pri_pitch_buf_fx) fixedToFloat_arr(p_tdm_Pri_pitch_buf_fx, p_tdm_Pri_pitch_buf, Q6, NB_SUBFR); - fixedToFloat_arr(gain_buf_fx, gain_buf, Q14, NB_SUBFR16k); - tmp_noise = fixedToFloat(tmp_noise_fx, 0); - // fixedToFloat_arr(mem_tmp_fx, mem_tmp, st->Q_syn, M); - fixedToFloat_arr(pitch_buf_out_fx, pitch_buf, Q6, NB_SUBFR16k); - fixedToFloat_arr(voice_factors_fx, voice_factors, Q15, NB_SUBFR16k); - fixedToFloat_arr(old_syn_12k8_16k_fx, old_syn_12k8_16k, -1, st->L_frame); - - acelp_decoder_state_fix2float(st, hStereoCng); - - // set_zero(Aq, NB_SUBFR16k * (M + 1)); - set16_fx(Aq_fx, 0, NB_SUBFR16k * (M + 1)); - // set_zero(temp_buf, L_FRAME16k + L_SYN_MEM); - // set_f(syn_tmp, 0, L_FRAME16k + L_SUBFR); - set_s(syn_tmp_fx, 0, L_FRAME16k + L_SUBFR); - - - /* Reconvert for below blocks */ - st->Q_syn = 0; - floatToFixed_arr(syn_tmp, syn_tmp_fx, st->Q_syn, L_FRAME16k); - // tmp_noise_fx = (Word16)floatToFixed(tmp_noise, 0); - if (st->last_bwidth == NB && st->hPFstat != NULL) - { - floatToFixed_arr(pitch_buf, pitch_buf_tmp, Q6, NB_SUBFR16k); - st->psf_lp_noise_fx = (Word16)floatToFixed(st->psf_lp_noise, Q8); - } - st->lp_noise = floatToFixed(st->lp_noise_float, Q23); - floatToFixed_arr(Aq, Aq_fx, Q12, NB_SUBFR16k * (M + 1)); - - /*---------------------*/ + bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_fx, st->bpf_off, + st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx); } Word32 syn_tmp_32_fx[L_FRAME16k + L_SUBFR], *syn_32_fx; @@ -2530,7 +2449,7 @@ ivas_error acelp_core_dec_ivas_fx( if (st->element_mode != IVAS_CPE_DFT || use_cldfb_for_dft) { - float realBufferSave[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + /*float realBufferSave[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; float imagBufferSave[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; float *pRealSave[CLDFB_NO_COL_MAX], *pImagSave[CLDFB_NO_COL_MAX]; for (i = 0; i < CLDFB_NO_COL_MAX; i++) @@ -2542,7 +2461,7 @@ ivas_error acelp_core_dec_ivas_fx( if (st->p_bpf_noise_buf_float) { mvr2r(bpf_error_signal, st->p_bpf_noise_buf_float, st->L_frame); - } + }*/ /* analysis of the synthesis at internal sampling rate */ @@ -2555,30 +2474,33 @@ ivas_error acelp_core_dec_ivas_fx( pRealSave_fx[i] = realBufferSave_fx[i]; pImagSave_fx[i] = imagBufferSave_fx[i]; } - floatToFixed_arrL(bpf_error_signal, bpf_error_signal_fx, st->Q_syn - 1, st->L_frame); + //floatToFixed_arrL(bpf_error_signal, bpf_error_signal_fx, st->Q_syn - 1, st->L_frame); + Copy_Scale_sig_16_32(bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1); //Q_syn-1 IF(st->p_bpf_noise_buf_32) { Copy32(bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame); } - floatToFixed_arr(syn, psyn_fx, st->Q_syn, L_FRAME16k); + //floatToFixed_arr(syn, psyn_fx, st->Q_syn, L_FRAME16k); for (i = 0; i < L_FRAME16k; i++) { - syn_32_fx[i] = L_shr(L_deposit_h(psyn_fx[i]), 4); + syn_32_fx[i] = L_shr(L_deposit_h(psyn_fx[i]), 4 + st->Q_syn); //Q12 } Word16 offset = sub(st->cldfbAna->p_filter_length, st->cldfbAna->no_channels); - floatToFixed_arrL(st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_fx, Q12, offset); + //floatToFixed_arrL(st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_fx, Q12, offset); + Scale_sig32(st->cldfbAna->cldfb_state_fx, offset, 1); //Q12 cldfbAnalysis_ivas_fx(syn_32_fx, realBuffer_fx, imagBuffer_fx, -1, st->cldfbAna); - fixedToFloat_arrL(st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_state, Q12, offset); + //fixedToFloat_arrL(st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_state, Q12, offset); + Scale_sig32(st->cldfbAna->cldfb_state_fx, offset, -1); //Q11 - for (i = 0; i < CLDFB_NO_COL_MAX; i++) + /*for (i = 0; i < CLDFB_NO_COL_MAX; i++) { - fixedToFloat_arrL(realBuffer_fx[i], realBuffer[i], Q12 - 5, CLDFB_NO_CHANNELS_MAX); - fixedToFloat_arrL(imagBuffer_fx[i], imagBuffer[i], Q12 - 5, CLDFB_NO_CHANNELS_MAX); - } + fixedToFloat_arrL(realBuffer_fx[i], realBuffer[i], Q12 - 5, CLDFB_NO_CHANNELS_MAX); //Q7 + fixedToFloat_arrL(imagBuffer_fx[i], imagBuffer[i], Q12 - 5, CLDFB_NO_CHANNELS_MAX); //Q7 + }*/ #else cldfbAnalysis_ivas(syn, realBuffer, imagBuffer, -1, st->cldfbAna); #endif @@ -2592,19 +2514,23 @@ ivas_error acelp_core_dec_ivas_fx( q_bpf_error_signal = Q6; // Float to fixed - floatToFixed_arrL(bpf_error_signal, tmp_bpf_error_signal_fx, q_bpf_error_signal, L_FRAME16k); + //floatToFixed_arrL(bpf_error_signal, tmp_bpf_error_signal_fx, q_bpf_error_signal, L_FRAME16k); + Copy_Scale_sig_16_32(bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, q_bpf_error_signal - st->Q_syn); // Q6 for (i = 0; i < CLDFB_NO_COL_MAX; i++) { - for (j = 0; j < CLDFB_NO_CHANNELS_MAX; j++) + /*for (j = 0; j < CLDFB_NO_CHANNELS_MAX; j++) { realBuffer_fx[i][j] = floatToFixed(realBuffer[i][j], q_bpf_error_signal - 6); imagBuffer_fx[i][j] = floatToFixed(imagBuffer[i][j], q_bpf_error_signal - 6); - } + }*/ + Scale_sig32(realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7); //Q0 + Scale_sig32(imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7); //Q0 } - for (i = 0; i < cldfb_state_offset; i++) + /*for (i = 0; i < cldfb_state_offset; i++) { st->cldfbBPF->cldfb_state_fx[i] = float_to_fix(st->cldfbBPF->cldfb_state[i], q_bpf_error_signal); - } + }*/ + Scale_sig32(st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, q_bpf_error_signal - Q10); //q_bpf_error_signal (Q6) tmp = -1; move16(); @@ -2617,7 +2543,7 @@ ivas_error acelp_core_dec_ivas_fx( addBassPostFilter_fx(tmp_bpf_error_signal_fx, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF); // Fixed to float - for (i = 0; i < CLDFB_NO_COL_MAX; i++) + /*for (i = 0; i < CLDFB_NO_COL_MAX; i++) { for (j = 0; j < CLDFB_NO_CHANNELS_MAX; j++) { @@ -2628,7 +2554,8 @@ ivas_error acelp_core_dec_ivas_fx( for (i = 0; i < cldfb_state_offset; i++) { st->cldfbBPF->cldfb_state[i] = fix_to_float(st->cldfbBPF->cldfb_state_fx[i], q_bpf_error_signal); - } + }*/ + Scale_sig32(st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, -(q_bpf_error_signal - Q10)); //Q10 #else addBassPostFilter(bpf_error_signal, st->bpf_off ? 0 : -1, realBuffer, imagBuffer, st->cldfbBPF); #endif @@ -2665,7 +2592,7 @@ ivas_error acelp_core_dec_ivas_fx( IF((EQ_32(st->core_brate, FRAME_NO_DATA) || EQ_32(st->core_brate, SID_2k40)) && (EQ_16(st->cng_type, FD_CNG)) && (LE_16(st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels))) { /* Float to fixed */ - f2me_buf(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, &st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN); + //f2me_buf(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, &st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN); // NOTE: this should be removed later. //st->hFdCngDec->hFdCngCom->q_cngNoiseLevel = 31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp; @@ -2676,11 +2603,13 @@ ivas_error acelp_core_dec_ivas_fx( /* Fixed to float */ FOR(i = 0; i < st->hFdCngDec->hFdCngCom->numSlots; i++) { - FOR( j = st->hFdCngDec->hFdCngCom->numCoreBands; j < st->hFdCngDec->hFdCngCom->regularStopBand; j++ ) + /*FOR( j = st->hFdCngDec->hFdCngCom->numCoreBands; j < st->hFdCngDec->hFdCngCom->regularStopBand; j++ ) { realBuffer[i][j] = me2f(realBuffer_fx[i][j], tmpBufferScale + 15); imagBuffer[i][j] = me2f(imagBuffer_fx[i][j], tmpBufferScale + 15); - } + }*/ + Scale_sig32(realBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, st->hFdCngDec->hFdCngCom->regularStopBand - st->hFdCngDec->hFdCngCom->numCoreBands, (tmpBufferScale + 15) - Q31); //Q0 + Scale_sig32(imagBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, st->hFdCngDec->hFdCngCom->regularStopBand - st->hFdCngDec->hFdCngCom->numCoreBands, (tmpBufferScale + 15) - Q31); //Q0 } IF(st->hFdCngDec->hFdCngCom->regularStopBand < st->cldfbSyn->no_channels) @@ -2713,34 +2642,42 @@ ivas_error acelp_core_dec_ivas_fx( } #endif - if (save_hb_synth != NULL) + if (save_hb_synth_fx16 != NULL) { /* save and then zero-out lowband */ #ifdef IVAS_FLOAT_FIXED - Word32 save_hb_synth_fx[L_FRAME48k]; - Word32 synth_fx[L_FRAME48k]; + //Word32 save_hb_synth_fx[L_FRAME48k]; + //Word32 synth_fx[L_FRAME48k]; Word16 Q_real = 0, Q_imag = 0; - float max_real = 0.f, max_imag = 0.f; + //float max_real = 0.f, max_imag = 0.f; + Word32 max_real = 0, max_imag = 0; for (i = 0; i < CLDFB_NO_COL_MAX; i++) { for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { - max_real = (float)max(max_real, fabs(realBuffer[i][j])); - max_imag = (float)max(max_imag, fabs(imagBuffer[i][j])); + //max_real = (float)max(max_real, fabs(realBuffer[i][j])); + max_real = max(max_real, L_abs(realBuffer_fx[i][j])); + //max_imag = (float)max(max_imag, fabs(imagBuffer[i][j])); + max_imag = max(max_imag, L_abs(imagBuffer_fx[i][j])); } } - float max_val = max(max_real, max_imag); + //float max_val = max(max_real, max_imag); + Word32 max_val = max(max_real, max_imag); Q_imag = norm_s((Word16)max_val); Q_real = Q_imag; for (i = 0; i < CLDFB_NO_COL_MAX; i++) { - floatToFixed_arrL(realBuffer[i], realBuffer_fx[i], Q_real, CLDFB_NO_CHANNELS_MAX); - floatToFixed_arrL(imagBuffer[i], imagBuffer_fx[i], Q_real, CLDFB_NO_CHANNELS_MAX); + //floatToFixed_arrL(realBuffer[i], realBuffer_fx[i], Q_real, CLDFB_NO_CHANNELS_MAX); + Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); + //floatToFixed_arrL(imagBuffer[i], imagBuffer_fx[i], Q_imag, CLDFB_NO_CHANNELS_MAX); + Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_imag); } - floatToFixed_arrL(st->cldfbSynHB->cldfb_state, st->cldfbSynHB->cldfb_state_fx, Q_real - 1, st->cldfbSynHB->p_filter_length); - floatToFixed_arrL(save_hb_synth, save_hb_synth_fx, Q_real - 1, L_FRAME48k); + //floatToFixed_arrL(st->cldfbSynHB->cldfb_state, st->cldfbSynHB->cldfb_state_fx, Q_real - 1, st->cldfbSynHB->p_filter_length); + Scale_sig32( st->cldfbSynHB->cldfb_state_fx, (Q_real - 1) - Q10, st->cldfbSynHB->p_filter_length); // (Q_real-1) + //floatToFixed_arrL(save_hb_synth, save_hb_synth_fx, Q_real - 1, L_FRAME48k); + Scale_sig32(save_hb_synth_fx, L_FRAME48k, Q_real - 1); FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { @@ -2758,8 +2695,10 @@ ivas_error acelp_core_dec_ivas_fx( cldfbSynthesis_ivas_fx(realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, st->cldfbSynHB); - fixedToFloat_arrL(synth_fx, synth, Q_real - 1, L_FRAME48k); - fixedToFloat_arrL(st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->cldfb_state, Q_real - 1, st->cldfbSynHB->p_filter_length); + //fixedToFloat_arrL(save_hb_synth_fx, save_hb_synth, Q_real - 1, L_FRAME48k); + Scale_sig32(save_hb_synth_fx, L_FRAME48k, -(Q_real - 1)); //Q0 + //fixedToFloat_arrL(st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->cldfb_state, Q_real - 1, st->cldfbSynHB->p_filter_length); + Scale_sig32(st->cldfbSynHB->cldfb_state_fx, Q10 - (Q_real - 1), st->cldfbSynHB->p_filter_length); // Q10 /* restore lowband */ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) @@ -2770,10 +2709,13 @@ ivas_error acelp_core_dec_ivas_fx( imagBuffer_fx[i][j] = imagBufferSave_fx[i][j]; } } - floatToFixed_arrL(st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q_real - 1, st->cldfbSyn->p_filter_length); + //floatToFixed_arrL(st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q_real - 1, st->cldfbSyn->p_filter_length); + Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, (Q_real - 1) - Q10); //Q_real-1 cldfbSynthesis_ivas_fx(pRealSave_fx, pImagSave_fx, synth_fx, -1, st->cldfbSyn); - fixedToFloat_arrL(synth_fx, synth, Q_real - 1, L_FRAME48k); - fixedToFloat_arrL(st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->cldfb_state, Q_real - 1, st->cldfbSynHB->p_filter_length); + //fixedToFloat_arrL(synth_fx, synth, Q_real - 1, L_FRAME48k); + Scale_sig32(synth_fx, L_FRAME48k, -(Q_real - 1)); + //fixedToFloat_arrL(st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->cldfb_state, Q_real - 1, st->cldfbSynHB->p_filter_length); + Scale_sig32(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, Q10 - (Q_real - 1)); //Q10 #else for (int16_t j = 0; j < CLDFB_NO_CHANNELS_MAX; j++) { @@ -2808,38 +2750,52 @@ ivas_error acelp_core_dec_ivas_fx( /* synthesis of the combined signal */ #ifdef IVAS_FLOAT_FIXED Word16 Q_real = 0, Q_imag = 0; - float max_real = 0.f, max_imag = 0.f; + //float max_real = 0.f, max_imag = 0.f; + Word32 max_real = 0, max_imag = 0; for (i = 0; i < CLDFB_NO_COL_MAX; i++) { - for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++) { - max_real = (float)max(max_real, fabs(realBuffer[i][j])); - max_imag = (float)max(max_imag, fabs(imagBuffer[i][j])); + for (j = 0; j < CLDFB_NO_CHANNELS_MAX; j++) + { + //max_real = (float)max(max_real, fabs(realBuffer[i][j])); + max_real = max(max_real, L_abs(realBuffer_fx[i][j])); + //max_imag = (float)max(max_imag, fabs(imagBuffer[i][j])); + max_imag = max(max_imag, L_abs(imagBuffer_fx[i][j])); } } - float max_val = max(max_real, max_imag); + //float max_val = max(max_real, max_imag); + Word32 max_val = max(max_real, max_imag); Q_imag = norm_s((Word16)max_val); Q_real = Q_imag; for (i = 0; i < CLDFB_NO_COL_MAX; i++) { - floatToFixed_arrL(realBuffer[i], realBuffer_fx[i], Q_real, CLDFB_NO_CHANNELS_MAX); - floatToFixed_arrL(imagBuffer[i], imagBuffer_fx[i], Q_real, CLDFB_NO_CHANNELS_MAX); + //floatToFixed_arrL(realBuffer[i], realBuffer_fx[i], Q_real, CLDFB_NO_CHANNELS_MAX); + Scale_sig32(realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); + //floatToFixed_arrL(imagBuffer[i], imagBuffer_fx[i], Q_real, CLDFB_NO_CHANNELS_MAX); + Scale_sig32(imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); } - floatToFixed_arrL(st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q_real - 1, st->cldfbSyn->p_filter_length); - Word32 synth_fx[L_FRAME48k]; - floatToFixed_arrL(synth, synth_fx, Q_real - 1, L_FRAME48k); + //floatToFixed_arrL(st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q_real - 1, st->cldfbSyn->p_filter_length); + Scale_sig32(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, (Q_real - 1) - Q10); //(Q_real - 1) + //Word32 synth_fx[L_FRAME48k]; + //floatToFixed_arrL(synth, synth_fx, Q_real - 1, L_FRAME48k); + Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1); cldfbSynthesis_ivas_fx(realBuffer_fx, imagBuffer_fx, synth_fx, -1, st->cldfbSyn); - fixedToFloat_arrL(synth_fx, synth, Q_real - 1, L_FRAME48k); - fixedToFloat_arrL(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, Q_real - 1, st->cldfbSyn->p_filter_length); + //fixedToFloat_arrL(synth_fx, synth, Q_real - 1, L_FRAME48k); + Scale_sig32(synth_fx, L_FRAME48k, -(Q_real - 1)); + //fixedToFloat_arrL(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, Q_real - 1, st->cldfbSyn->p_filter_length); + Scale_sig32(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, Q10 - (Q_real - 1)); //Q10 #else cldfbSynthesis_ivas(realBuffer, imagBuffer, synth, -1, st->cldfbSyn); #endif } /* save synthesis - needed in case of core switching */ - mvr2r(synth, st->previoussynth, output_frame); + //mvr2r(synth, st->previoussynth, output_frame); + Copy32(synth_fx, st->previoussynth_fx_32, output_frame); //Q0 + st->Q_syn2 = 0; + } else @@ -2848,24 +2804,26 @@ ivas_error acelp_core_dec_ivas_fx( /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */ #ifdef IVAS_FLOAT_FIXED - floatToFixed_arr(syn, psyn_fx, st->Q_syn, L_FRAME16k); + //floatToFixed_arr(syn, psyn_fx, st->Q_syn, L_FRAME16k); for (i = 0; i < L_FRAME16k; i++) { - syn_32_fx[i] = L_shr(L_deposit_h(psyn_fx[i]), 4); + syn_32_fx[i] = L_shr(L_deposit_h(psyn_fx[i]), 4 + st->Q_syn); } Word16 offset = sub(st->cldfbAna->p_filter_length, st->cldfbAna->no_channels); - floatToFixed_arrL(st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_fx, Q12, offset); + //floatToFixed_arrL(st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_fx, Q12, offset); + Scale_sig32(st->cldfbAna->cldfb_state_fx, offset, 1); //Q12 cldfbAnalysis_ivas_fx(syn_32_fx + st->L_frame - nSamples, realBuffer_fx, imagBuffer_fx, nSamples, st->cldfbAna); - fixedToFloat_arrL(st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_state, Q12, offset); + //fixedToFloat_arrL(st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_state, Q12, offset); + Scale_sig32(st->cldfbAna->cldfb_state_fx, offset, -1); //Q11 - for (i = 0; i < CLDFB_NO_COL_MAX; i++) + /*for (i = 0; i < CLDFB_NO_COL_MAX; i++) { fixedToFloat_arrL(realBuffer_fx[i], realBuffer[i], Q12 - 5, CLDFB_NO_CHANNELS_MAX); fixedToFloat_arrL(imagBuffer_fx[i], imagBuffer[i], Q12 - 5, CLDFB_NO_CHANNELS_MAX); - } + }*/ #else cldfbAnalysis_ivas(syn + st->L_frame - nSamples, realBuffer, imagBuffer, nSamples, st->cldfbAna); #endif @@ -2880,19 +2838,23 @@ ivas_error acelp_core_dec_ivas_fx( q_bpf_error_signal = Q6; // Float to fixed - floatToFixed_arrL(bpf_error_signal, tmp_bpf_error_signal_fx, q_bpf_error_signal, L_FRAME16k); + //floatToFixed_arrL(bpf_error_signal, tmp_bpf_error_signal_fx, q_bpf_error_signal, L_FRAME16k); + Copy_Scale_sig_16_32(bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, q_bpf_error_signal - st->Q_syn); // Q6 for (i = 0; i < CLDFB_NO_COL_MAX; i++) { - for (j = 0; j < CLDFB_NO_CHANNELS_MAX; j++) + /*for (j = 0; j < CLDFB_NO_CHANNELS_MAX; j++) { realBuffer_fx[i][j] = floatToFixed(realBuffer[i][j], q_bpf_error_signal - 6); imagBuffer_fx[i][j] = floatToFixed(imagBuffer[i][j], q_bpf_error_signal - 6); - } + }*/ + Scale_sig32(realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7); //Q0 + Scale_sig32(imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7); //Q0 } - for (i = 0; i < cldfb_state_offset; i++) + /*for (i = 0; i < cldfb_state_offset; i++) { st->cldfbBPF->cldfb_state_fx[i] = float_to_fix(st->cldfbBPF->cldfb_state[i], q_bpf_error_signal); - } + }*/ + Scale_sig32(st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, q_bpf_error_signal - Q10); //q_bpf_error_signal (Q6) tmp = 0; move16(); @@ -2904,7 +2866,7 @@ ivas_error acelp_core_dec_ivas_fx( addBassPostFilter_fx(tmp_bpf_error_signal_fx + st->L_frame - nSamples, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF); // Fixed to float - for (i = 0; i < CLDFB_NO_COL_MAX; i++) + /*for (i = 0; i < CLDFB_NO_COL_MAX; i++) { for (j = 0; j < CLDFB_NO_CHANNELS_MAX; j++) { @@ -2915,39 +2877,50 @@ ivas_error acelp_core_dec_ivas_fx( for (i = 0; i < cldfb_state_offset; i++) { st->cldfbBPF->cldfb_state[i] = fix_to_float(st->cldfbBPF->cldfb_state_fx[i], q_bpf_error_signal); - } + }*/ + Scale_sig32(st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, -(q_bpf_error_signal - Q10)); //Q10 #else addBassPostFilter(bpf_error_signal + st->L_frame - nSamples, st->bpf_off ? 0 : nSamples, realBuffer, imagBuffer, st->cldfbBPF); #endif /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */ #ifdef IVAS_FLOAT_FIXED Word16 Q_real = 0, Q_imag = 0; - float max_real = 0.f, max_imag = 0.f; + //float max_real = 0.f, max_imag = 0.f; + Word32 max_real = 0, max_imag = 0; for (i = 0; i < CLDFB_NO_COL_MAX; i++) { - for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + for (j = 0; j < CLDFB_NO_CHANNELS_MAX; j++) { - max_real = (float)max(max_real, fabs(realBuffer[i][j])); - max_imag = (float)max(max_imag, fabs(imagBuffer[i][j])); + //max_real = (float)max(max_real, fabs(realBuffer[i][j])); + max_real = max(max_real, L_abs(realBuffer_fx[i][j])); + //max_imag = (float)max(max_imag, fabs(imagBuffer[i][j])); + max_imag = max(max_imag, L_abs(imagBuffer_fx[i][j])); } } - float max_val = max(max_real, max_imag); + //float max_val = max(max_real, max_imag); + Word32 max_val = max(max_real, max_imag); Q_imag = norm_s((Word16)max_val); Q_real = Q_imag; for (i = 0; i < CLDFB_NO_COL_MAX; i++) { - floatToFixed_arrL(realBuffer[i], realBuffer_fx[i], Q_real, CLDFB_NO_CHANNELS_MAX); - floatToFixed_arrL(imagBuffer[i], imagBuffer_fx[i], Q_real, CLDFB_NO_CHANNELS_MAX); + //floatToFixed_arrL(realBuffer[i], realBuffer_fx[i], Q_real, CLDFB_NO_CHANNELS_MAX); + Scale_sig32(realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); + //floatToFixed_arrL(imagBuffer[i], imagBuffer_fx[i], Q_real, CLDFB_NO_CHANNELS_MAX); + Scale_sig32(imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); } - floatToFixed_arrL(st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q_real - 1, st->cldfbSyn->p_filter_length); - Word32 synth_fx[L_FRAME48k]; - floatToFixed_arrL(synth, synth_fx, Q_real - 1, L_FRAME48k); + //floatToFixed_arrL(st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q_real - 1, st->cldfbSyn->p_filter_length); + Scale_sig32(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, (Q_real - 1) - Q10); //(Q_real - 1) + //Word32 synth_fx[L_FRAME48k]; + //floatToFixed_arrL(synth, synth_fx, Q_real - 1, L_FRAME48k); + Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1); cldfbSynthesis_ivas_fx(realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA(st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/), st->cldfbSyn); - fixedToFloat_arrL(synth_fx, synth, Q_real - 1, L_FRAME48k); - fixedToFloat_arrL(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, Q_real - 1, st->cldfbSyn->p_filter_length); + //fixedToFloat_arrL(synth_fx, synth, Q_real - 1, L_FRAME48k); + Scale_sig32(synth_fx, L_FRAME48k, -(Q_real - 1)); + //fixedToFloat_arrL(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, Q_real - 1, st->cldfbSyn->p_filter_length); + Scale_sig32(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, Q10 - (Q_real - 1)); #else cldfbSynthesis_ivas(realBuffer, imagBuffer, synth /*dummy*/, NS2SA(st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/), st->cldfbSyn); @@ -2955,16 +2928,22 @@ ivas_error acelp_core_dec_ivas_fx( if (st->p_bpf_noise_buf_float) { - mvr2r(bpf_error_signal, st->p_bpf_noise_buf_float, st->L_frame); + //mvr2r(bpf_error_signal, st->p_bpf_noise_buf_float, st->L_frame); + Copy_Scale_sig_16_32(bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1); //Q_syn-1 + Copy32(bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame); } - set_f(synth, 0.0f, output_frame); + //set_f(synth, 0.0f, output_frame); + set_l(synth_fx, 0, output_frame); + } /* Copy output signal */ + Scale_sig(syn_tmp_fx, L_FRAME16k + L_SUBFR, -st->Q_syn); if (st->element_mode > EVS_MONO) { - mvr2r(syn, output, st->L_frame); + //mvr2r(syn, output, st->L_frame); + Copy(psyn_fx, output_fx, st->L_frame); } /*-----------------------------------------------------------------* @@ -2981,47 +2960,52 @@ ivas_error acelp_core_dec_ivas_fx( test(); test(); IF( ( EQ_16( st->L_frame, L_FRAME ) && NE_16( st->bwidth, NB ) && GE_16( output_frame, L_FRAME16k ) && - ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type_fx, AUDIO ) ) ) ) ) + ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type, AUDIO ) ) ) ) ) { Word16 tmp_exp = 0; - floatToFixed_arr( Aq, Aq_fx, Q12, NB_SUBFR16k * ( M + 1 ) ); + /* floatToFixed_arr( Aq, Aq_fx, Q12, NB_SUBFR16k * ( M + 1 ) ); Word16 exc_fx[L_FRAME + L_SUBFR], exp_exc = 0, Q_exc = 0; f2me_buf_16( exc, exc_fx, &exp_exc, L_FRAME ); Q_exc = 15 - exp_exc; Word16 Q_syn2 = 0; Word16 synth_fx[L_FRAME48k]; floatToFixed_arr( syn, psyn_fx, Q_syn2, L_FRAME + L_SUBFR ); - floatToFixed_arr( synth, synth_fx, Q_syn2, L_FRAME + L_SUBFR ); + floatToFixed_arr( synth, synth_fx, Q_syn2, L_FRAME + L_SUBFR );*/ - floatToFixed_arr( st->hBWE_zero->delay_syn_hf, st->hBWE_zero->delay_syn_hf_fx, Q_syn2, NS2SA( 16000, DELAY_CLDFB_NS ) - 15 ); + /*floatToFixed_arr( st->hBWE_zero->delay_syn_hf, st->hBWE_zero->delay_syn_hf_fx, Q_syn2, NS2SA( 16000, DELAY_CLDFB_NS ) - 15 ); floatToFixed_arr( st->hBWE_zero->mem_hp_interp, st->hBWE_zero->mem_hp_interp_fx, 0, INTERP_3_1_MEM_LEN ); floatToFixed_arr( st->hBWE_zero->mem_syn_hf, st->hBWE_zero->mem_syn_hf_fx, 0, M ); floatToFixed_arr( st->hBWE_zero->mem_hf, st->hBWE_zero->mem_hf_fx, -2 - tmp_exp, L_FIR - 1 ); - floatToFixed_arr( st->hBWE_zero->mem_hp400, st->hBWE_zero->mem_hp400_fx, Q_syn2, 6 ); - Word16 output_subfr = output_frame / NB_SUBFR; - + floatToFixed_arr( st->hBWE_zero->mem_hp400, st->hBWE_zero->mem_hp400_fx, Q_syn2, 6 );*/ + //Word16 output_subfr = output_frame / NB_SUBFR; + Copy_Scale_sig_32_16(synth_fx, synth_fx16, 0, L_FRAME48k); hf_synth_ivas_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc_fx, - psyn_fx, synth_fx, Q_exc, Q_syn2, st->hBWE_zero->delay_syn_hf_fx, &tmp_exp, + psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2, st->hBWE_zero->delay_syn_hf_fx, &tmp_exp, st->hBWE_zero->mem_hp_interp_fx, st->extl, st->CNG_mode, st->element_mode ); + Copy_Scale_sig_16_32(synth_fx16, synth_fx, 0, L_FRAME48k); IF( st->hBWE_FD != NULL ) { st->hBWE_FD->memExp1 = tmp_exp; } + ELSE + { + Scale_sig( st->hBWE_zero->mem_hf_fx, L_FIR - 1, -tmp_exp ); + } - fixedToFloat_arr( synth_fx, synth, Q_syn2, output_subfr ); + /*fixedToFloat_arr( synth_fx, synth, Q_syn2, output_subfr ); fixedToFloat_arr( psyn_fx, syn, Q_syn2 - 2, L_SUBFR ); fixedToFloat_arr( st->hBWE_zero->delay_syn_hf_fx, st->hBWE_zero->delay_syn_hf, 0, NS2SA( 16000, DELAY_CLDFB_NS ) - 15 ); fixedToFloat_arr( st->hBWE_zero->mem_hp_interp_fx, st->hBWE_zero->mem_hp_interp, 0, INTERP_3_1_MEM_LEN ); fixedToFloat_arr( st->hBWE_zero->mem_syn_hf_fx, st->hBWE_zero->mem_syn_hf, 0, M ); fixedToFloat_arr( st->hBWE_zero->mem_hf_fx, st->hBWE_zero->mem_hf, -2 - tmp_exp, L_FIR - 1 ); - fixedToFloat_arr( st->hBWE_zero->mem_hp400_fx, st->hBWE_zero->mem_hp400, Q_syn2, 6 ); + fixedToFloat_arr( st->hBWE_zero->mem_hp400_fx, st->hBWE_zero->mem_hp400, Q_syn2, 6 );*/ } ELSE { hf_synth_reset_fx( st->hBWE_zero ); /*to be cleaned up*/ - hf_synth_reset( st->hBWE_zero ); + //hf_synth_reset( st->hBWE_zero ); } } #else @@ -3045,58 +3029,63 @@ ivas_error acelp_core_dec_ivas_fx( if (st->hBWE_TD != NULL) { - if ((!st->bfi && st->prev_bfi) || (st->last_vbr_hw_BWE_disable_dec == 1 && st->vbr_hw_BWE_disable_dec == 0) || ((st->extl == SWB_TBE || st->extl == WB_TBE || st->extl == FB_TBE) && st->last_extl != SWB_TBE && st->last_extl != WB_TBE && st->last_extl != FB_TBE) || (st->idchan == 1 && st->element_mode == IVAS_CPE_TD && !st->tdm_LRTD_flag)) + if ((!st->bfi && st->prev_bfi) || (st->last_vbr_hw_BWE_disable_dec_fx == 1 && st->vbr_hw_BWE_disable_dec_fx == 0) || ((st->extl == SWB_TBE || st->extl == WB_TBE || st->extl == FB_TBE) && st->last_extl != SWB_TBE && st->last_extl != WB_TBE && st->last_extl != FB_TBE) || (st->idchan == 1 && st->element_mode == IVAS_CPE_TD && !st->tdm_LRTD_flag)) { - st->hBWE_TD->bwe_non_lin_prev_scale = 0.0f; - set_f(st->hBWE_TD->old_bwe_exc_extended, 0.0f, NL_BUFF_OFFSET); + //st->hBWE_TD->bwe_non_lin_prev_scale = 0.0f; + st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + //set_f(st->hBWE_TD->old_bwe_exc_extended, 0.0f, NL_BUFF_OFFSET); + set_s(st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET); } if (!st->ppp_mode_dec && (st->idchan == 0 || st->element_mode != IVAS_CPE_TD || (st->idchan == 1 && st->element_mode == IVAS_CPE_TD && st->tdm_LRTD_flag))) { #ifdef IVAS_FLOAT_FIXED - Word16 voice_factors_fx[5]; - Word32 tmp_bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]; - Word32 tmp_old_bwe_exc_extended_fx[NL_BUFF_OFFSET]; - Word16 e1, e2; - set32_fx( tmp_bwe_exc_extended_fx, 0, L_FRAME32k + NL_BUFF_OFFSET ); - - // Extract exponents. - f2me_buf_16( bwe_exc, bwe_exc_fx, &e1, L_FRAME32k ); - f2me_buf( st->hBWE_TD->old_bwe_exc_extended, tmp_old_bwe_exc_extended_fx, &e2, NL_BUFF_OFFSET ); - st->Q_exc = 15 - s_max( e1, e2 ); - st->Q_exc = s_min( st->Q_exc, 14 ); // non_linearity_fx function crashes if Q == 15 - // Float to fixed - for ( i = 0; i < ( st->L_frame == L_FRAME16k ? 5 : 4 ); i++ ) - { - voice_factors_fx[i] = float_to_fix16( voice_factors[i], Q15 ); - } - for ( i = 0; i < NL_BUFF_OFFSET; i++ ) - { - tmp_old_bwe_exc_extended_fx[i] = floatToFixed( st->hBWE_TD->old_bwe_exc_extended[i], 2 * st->Q_exc ); - } - for ( i = 0; i < L_FRAME32k; i++ ) - { - bwe_exc_fx[i] = (Word16)floatToFixed( bwe_exc[i], st->Q_exc ); - if (bwe_exc[i] != 0 && bwe_exc_fx[i] == 0) - { - // NOTE: This is done to avoid zero values when float values are too small. - // Else it will lead to a crash later in Interpolate_allpass_steep_32. - bwe_exc_fx[i] = 1; - } - } - - /* update buffer memory */ - Copy32( tmp_old_bwe_exc_extended_fx, tmp_bwe_exc_extended_fx, NL_BUFF_OFFSET ); - - non_linearity_ivas_fx( bwe_exc_fx, tmp_bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); - - /* update buffer memory */ - Copy32( tmp_bwe_exc_extended_fx + L_FRAME32k, tmp_old_bwe_exc_extended_fx, NL_BUFF_OFFSET ); - - // Fixed to float - st->hBWE_TD->bwe_non_lin_prev_scale = fix_to_float( st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q30 ); - me2f_buf( tmp_bwe_exc_extended_fx, 31 - 2 * st->Q_exc, bwe_exc_extended, L_FRAME32k + NL_BUFF_OFFSET ); - me2f_buf( tmp_old_bwe_exc_extended_fx, 31 - 2 * st->Q_exc, st->hBWE_TD->old_bwe_exc_extended, NL_BUFF_OFFSET ); + //Word16 voice_factors_fx[5]; + //Word32 tmp_bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]; + //Word32 tmp_old_bwe_exc_extended_fx[NL_BUFF_OFFSET]; + //Word16 e1, e2; + //set32_fx( tmp_bwe_exc_extended_fx, 0, L_FRAME32k + NL_BUFF_OFFSET ); + + //// Extract exponents. + //f2me_buf_16( bwe_exc, bwe_exc_fx, &e1, L_FRAME32k ); + //f2me_buf( st->hBWE_TD->old_bwe_exc_extended, tmp_old_bwe_exc_extended_fx, &e2, NL_BUFF_OFFSET ); + //st->Q_exc = 15 - s_max( e1, e2 ); + //st->Q_exc = s_min( st->Q_exc, 14 ); // non_linearity_fx function crashes if Q == 15 + //// Float to fixed + //for ( i = 0; i < ( st->L_frame == L_FRAME16k ? 5 : 4 ); i++ ) + //{ + // voice_factors_fx[i] = float_to_fix16( voice_factors[i], Q15 ); + //} + //for ( i = 0; i < NL_BUFF_OFFSET; i++ ) + //{ + // tmp_old_bwe_exc_extended_fx[i] = floatToFixed( st->hBWE_TD->old_bwe_exc_extended[i], 2 * st->Q_exc ); + //} + //for ( i = 0; i < L_FRAME32k; i++ ) + //{ + // bwe_exc_fx[i] = (Word16)floatToFixed( bwe_exc[i], st->Q_exc ); + // if (bwe_exc[i] != 0 && bwe_exc_fx[i] == 0) + // { + // // NOTE: This is done to avoid zero values when float values are too small. + // // Else it will lead to a crash later in Interpolate_allpass_steep_32. + // bwe_exc_fx[i] = 1; + // } + //} + + ///* update buffer memory */ + //Copy32( tmp_old_bwe_exc_extended_fx, tmp_bwe_exc_extended_fx, NL_BUFF_OFFSET ); + Copy_Scale_sig_16_32(st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, 2 * st->Q_exc); + + //non_linearity_ivas_fx(bwe_exc_fx, tmp_bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame); + non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); + + ///* update buffer memory */ + //Copy32( tmp_bwe_exc_extended_fx + L_FRAME32k, tmp_old_bwe_exc_extended_fx, NL_BUFF_OFFSET ); + + //// Fixed to float + //st->hBWE_TD->bwe_non_lin_prev_scale = fix_to_float( st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q30 ); + //me2f_buf( tmp_bwe_exc_extended_fx, 31 - 2 * st->Q_exc, bwe_exc_extended, L_FRAME32k + NL_BUFF_OFFSET ); + //me2f_buf( tmp_old_bwe_exc_extended_fx, 31 - 2 * st->Q_exc, st->hBWE_TD->old_bwe_exc_extended, NL_BUFF_OFFSET ); + Copy_Scale_sig_32_16(bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, -(2 * st->Q_exc)); #else non_linearity( bwe_exc, bwe_exc_extended, st->hBWE_TD->old_bwe_exc_extended, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale, st->coder_type, voice_factors, st->L_frame ); #endif @@ -3104,88 +3093,88 @@ ivas_error acelp_core_dec_ivas_fx( if ( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) { - st->hBWE_TD->bwe_non_lin_prev_scale = 0.0f; + //st->hBWE_TD->bwe_non_lin_prev_scale = 0.0f; + st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; } } - /*----------------------------------------------------------------------* * Updates *----------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED ////////////////////////////////////// Float to fix starts here //////////////////////////////////////////////// - Word16 tmp_Q_exc = 0; - Word16 tmp_old_exc_fx[L_EXC_DEC]; // Q_exc - Word16 tmp_old_bwe_exc_fx[((PIT16k_MAX + (L_FRAME16k + 1) + L_SUBFR16k) * 2)]; // Q_exc - Word16 tmp_pitch_buf_fx[NB_SUBFR16k]; // Q6 - Word16 tmp_Es_pred_fx; // Q8 - Word16 tmp_Aq_fx[NB_SUBFR16k * (M + 1)]; // Q12 - Word16 tmp_lsf_new_fx[M]; // Qx2.56 - Word16 tmp_lsp_new_fx[M]; // Q15 - Word16 tmp_voice_factors_fx[NB_SUBFR16k]; // Q15 - Word16 tmp_gain_buf_fx[NB_SUBFR16k]; // Q14 - - floatToFixed_arr(old_exc, tmp_old_exc_fx, tmp_Q_exc, L_EXC_DEC); - floatToFixed_arr(old_bwe_exc, tmp_old_bwe_exc_fx, tmp_Q_exc, ((PIT16k_MAX + (L_FRAME16k + 1) + L_SUBFR16k) * 2)); - floatToFixed_arr(pitch_buf, tmp_pitch_buf_fx, Q6, NB_SUBFR16k); - tmp_Es_pred_fx = float_to_fix16(Es_pred, Q8); - floatToFixed_arr(Aq, tmp_Aq_fx, Q12, NB_SUBFR16k * (M + 1)); - for (i = 0; i < M; i++) - { - tmp_lsf_new_fx[i] = (Word16)(lsf_new[i] * 2.56f); - } - floatToFixed_arr(lsp_new, tmp_lsp_new_fx, Q15, M); - floatToFixed_arr(voice_factors, tmp_voice_factors_fx, Q15, NB_SUBFR16k); - floatToFixed_arr(gain_buf, tmp_voice_factors_fx, Q14, NB_SUBFR16k); - st->Last_GSC_noisy_speech_flag_fx = st->Last_GSC_noisy_speech_flag; - st->coder_type_fx = st->coder_type; - if (st->hGSCDec != NULL) - { - st->hGSCDec->Last_GSC_pit_band_idx_fx = st->hGSCDec->Last_GSC_pit_band_idx; - st->hGSCDec->seed_tcx_fx = st->hGSCDec->seed_tcx; - } - st->GSC_noisy_speech_fx = st->GSC_noisy_speech; - st->last_ppp_mode_dec_fx = st->last_ppp_mode_dec; - st->ppp_mode_dec_fx = st->ppp_mode_dec; - st->nelp_mode_dec_fx = st->nelp_mode_dec; - st->vbr_hw_BWE_disable_dec_fx = st->vbr_hw_BWE_disable_dec; - // just outputs: - if (st->hGSCDec != NULL) - { - st->hGSCDec->noise_lev_fx = st->hGSCDec->noise_lev; - floatToFixed_arr(st->hGSCDec->old_y_gain, st->hGSCDec->old_y_gain_fx, Q12, MBANDS_GN); - floatToFixed_arr(st->hGSCDec->Last_GSC_spectrum, st->hGSCDec->Last_GSC_spectrum_fx, Q10, M); - } - st->last_coder_type_fx = st->last_coder_type; - st->Last_GSC_noisy_speech_flag_fx = st->Last_GSC_noisy_speech_flag; - if (st->hHQ_core != NULL) - st->hHQ_core->HqVoicing_fx = st->hHQ_core->HqVoicing; - st->old_ppp_mode_fx = st->old_ppp_mode; - st->last_ppp_mode_dec_fx = st->last_ppp_mode_dec; - st->last_nelp_mode_dec_fx = st->last_nelp_mode_dec; - st->last_vbr_hw_BWE_disable_dec_fx = st->last_vbr_hw_BWE_disable_dec; - floatToFixed_arr(st->old_exc, st->old_exc_fx, tmp_Q_exc, L_EXC_MEM_DEC); - for (i = 0; i < M; i++) - { - st->lsf_old_fx[i] = (Word16)(st->lsf_old[i] * 2.56f); - } - floatToFixed_arr(st->lsp_old, st->lsp_old_fx, Q15, M); - st->last_voice_factor_fx = float_to_fix16(st->last_voice_factor, Q15); - floatToFixed_arrL(st->old_pitch_buf, st->old_pitch_buf_fx, Q16, 2 * NB_SUBFR16k + 2); - floatToFixed_arr(st->mem_pitch_gain_float, st->mem_pitch_gain, Q14, 2 * NB_SUBFR16k + 2); - for (i = 0; i < M; i++) - { - st->lsfoldbfi1[i] = (Word16)(st->lsfoldbfi1_fx[i] * 2.56f); - st->lsfoldbfi0[i] = (Word16)(st->lsfoldbfi0_fx[i] * 2.56f); - } - floatToFixed_arr(st->old_Aq_12_8, st->old_Aq_12_8_fx, Q12, M + 1); - st->old_Es_pred_fx = float_to_fix16(st->old_Es_pred, Q8); + //Word16 tmp_Q_exc = 0; + //Word16 tmp_old_exc_fx[L_EXC_DEC]; // Q_exc + //Word16 tmp_old_bwe_exc_fx[((PIT16k_MAX + (L_FRAME16k + 1) + L_SUBFR16k) * 2)]; // Q_exc + //Word16 tmp_pitch_buf_fx[NB_SUBFR16k]; // Q6 + //Word16 tmp_Es_pred_fx; // Q8 + //Word16 tmp_Aq_fx[NB_SUBFR16k * (M + 1)]; // Q12 + //Word16 tmp_lsf_new_fx[M]; // Qx2.56 + //Word16 tmp_lsp_new_fx[M]; // Q15 + //Word16 tmp_voice_factors_fx[NB_SUBFR16k]; // Q15 + //Word16 tmp_gain_buf_fx[NB_SUBFR16k]; // Q14 + + //floatToFixed_arr(old_exc, tmp_old_exc_fx, tmp_Q_exc, L_EXC_DEC); + //floatToFixed_arr(old_bwe_exc, tmp_old_bwe_exc_fx, tmp_Q_exc, ((PIT16k_MAX + (L_FRAME16k + 1) + L_SUBFR16k) * 2)); + //floatToFixed_arr(pitch_buf, tmp_pitch_buf_fx, Q6, NB_SUBFR16k); + //tmp_Es_pred_fx = float_to_fix16(Es_pred, Q8); + //floatToFixed_arr(Aq, tmp_Aq_fx, Q12, NB_SUBFR16k * (M + 1)); + //for (i = 0; i < M; i++) + //{ + // tmp_lsf_new_fx[i] = (Word16)(lsf_new[i] * 2.56f); + //} + //floatToFixed_arr(lsp_new, tmp_lsp_new_fx, Q15, M); + //floatToFixed_arr(voice_factors, tmp_voice_factors_fx, Q15, NB_SUBFR16k); + //floatToFixed_arr(gain_buf, tmp_voice_factors_fx, Q14, NB_SUBFR16k); + //st->Last_GSC_noisy_speech_flag_fx = st->Last_GSC_noisy_speech_flag; + //st->coder_type_fx = st->coder_type; + //if (st->hGSCDec != NULL) + //{ + // st->hGSCDec->Last_GSC_pit_band_idx_fx = st->hGSCDec->Last_GSC_pit_band_idx; + // st->hGSCDec->seed_tcx_fx = st->hGSCDec->seed_tcx; + //} + //st->GSC_noisy_speech_fx = st->GSC_noisy_speech; + //st->last_ppp_mode_dec_fx = st->last_ppp_mode_dec; + //st->ppp_mode_dec_fx = st->ppp_mode_dec; + //st->nelp_mode_dec_fx = st->nelp_mode_dec; + //st->vbr_hw_BWE_disable_dec_fx = st->vbr_hw_BWE_disable_dec; + //// just outputs: + //if (st->hGSCDec != NULL) + //{ + // st->hGSCDec->noise_lev_fx = st->hGSCDec->noise_lev; + // floatToFixed_arr(st->hGSCDec->old_y_gain, st->hGSCDec->old_y_gain_fx, Q12, MBANDS_GN); + // floatToFixed_arr(st->hGSCDec->Last_GSC_spectrum, st->hGSCDec->Last_GSC_spectrum_fx, Q10, M); + //} + //st->last_coder_type_fx = st->last_coder_type; + //st->Last_GSC_noisy_speech_flag_fx = st->Last_GSC_noisy_speech_flag; + //if (st->hHQ_core != NULL) + // st->hHQ_core->HqVoicing_fx = st->hHQ_core->HqVoicing; + //st->old_ppp_mode_fx = st->old_ppp_mode; + //st->last_ppp_mode_dec_fx = st->last_ppp_mode_dec; + //st->last_nelp_mode_dec_fx = st->last_nelp_mode_dec; + //st->last_vbr_hw_BWE_disable_dec_fx = st->last_vbr_hw_BWE_disable_dec; + //floatToFixed_arr(st->old_exc, st->old_exc_fx, tmp_Q_exc, L_EXC_MEM_DEC); + //for (i = 0; i < M; i++) + //{ + // st->lsf_old_fx[i] = (Word16)(st->lsf_old[i] * 2.56f); + //} + //floatToFixed_arr(st->lsp_old, st->lsp_old_fx, Q15, M); + //st->last_voice_factor_fx = float_to_fix16(st->last_voice_factor, Q15); + //floatToFixed_arrL(st->old_pitch_buf, st->old_pitch_buf_fx, Q16, 2 * NB_SUBFR16k + 2); + //floatToFixed_arr(st->mem_pitch_gain_float, st->mem_pitch_gain, Q14, 2 * NB_SUBFR16k + 2); + //for (i = 0; i < M; i++) + //{ + // st->lsfoldbfi1[i] = (Word16)(st->lsfoldbfi1_fx[i] * 2.56f); + // st->lsfoldbfi0[i] = (Word16)(st->lsfoldbfi0_fx[i] * 2.56f); + //} + //floatToFixed_arr(st->old_Aq_12_8, st->old_Aq_12_8_fx, Q12, M + 1); + //st->old_Es_pred_fx = float_to_fix16(st->old_Es_pred, Q8); ////////////////////////////////////// Float to fix ends here //////////////////////////////////////////////// - updt_dec_fx( st, tmp_old_exc_fx, tmp_pitch_buf_fx, tmp_Es_pred_fx, tmp_Aq_fx, tmp_lsf_new_fx, tmp_lsp_new_fx, tmp_voice_factors_fx, tmp_old_bwe_exc_fx, tmp_gain_buf_fx ); + updt_dec_fx( st, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, voice_factors_fx, old_bwe_exc_fx, gain_buf_fx ); ////////////////////////////////////// Fixed to float starts here //////////////////////////////////////////// - st->last_coder_type = st->last_coder_type_fx; + /*st->last_coder_type = st->last_coder_type_fx; if (st->hGSCDec != NULL) { st->hGSCDec->noise_lev = st->hGSCDec->noise_lev_fx; @@ -3196,7 +3185,7 @@ ivas_error acelp_core_dec_ivas_fx( st->hHQ_core->HqVoicing = st->hHQ_core->HqVoicing_fx; st->old_ppp_mode = st->old_ppp_mode_fx; st->last_ppp_mode_dec = st->last_ppp_mode_dec_fx; - st->last_nelp_mode_dec = st->last_nelp_mode_dec_fx; + st->last_nelp_mode_dec = st->last_nelp_mode_dec; st->last_vbr_hw_BWE_disable_dec = st->last_vbr_hw_BWE_disable_dec_fx; fixedToFloat_arr(st->old_exc_fx, st->old_exc, tmp_Q_exc, L_EXC_MEM_DEC); IF(!st->Opt_AMR_WB && st->hBWE_TD != NULL) @@ -3220,7 +3209,7 @@ ivas_error acelp_core_dec_ivas_fx( st->lsfoldbfi0[i] = st->lsfoldbfi0_fx[i] / 2.56f; } fixedToFloat_arr(st->old_Aq_12_8_fx, st->old_Aq_12_8, Q12, M+1); - st->old_Es_pred = fix16_to_float(st->old_Es_pred_fx, Q8); + st->old_Es_pred = fix16_to_float(st->old_Es_pred_fx, Q8);*/ ////////////////////////////////////// Fixed to float ends here ////////////////////////////////////////////// #else updt_dec( st, old_exc, pitch_buf, Es_pred, Aq, lsf_new, lsp_new, voice_factors, old_bwe_exc, gain_buf ); @@ -3229,30 +3218,30 @@ ivas_error acelp_core_dec_ivas_fx( #ifdef IVAS_FLOAT_FIXED IF( GT_32( st->core_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL ) { - /* update CNG parameters in active frames */ - Word16 lsp_new_fx[M]; - Word16 exc_fx[L_EXC_DEC], Q_exc, exp_exc; - f2me_buf_16( exc, exc_fx, &exp_exc, st->L_frame ); - Q_exc = 15 - exp_exc; - floatToFixed_arr( lsp_new, lsp_new_fx, Q15, M ); - floatToFixed_arr( exc, exc_fx, Q_exc, st->L_frame ); - floatToFixed_arrL( st->hTdCngDec->ho_ener_circ, st->hTdCngDec->ho_ener_circ_fx, Q6, HO_HIST_SIZE ); - st->hTdCngDec->ho_circ_size_fx = st->hTdCngDec->ho_circ_size; - st->hTdCngDec->ho_circ_ptr_fx = st->hTdCngDec->ho_circ_ptr; - floatToFixed_arr( st->hTdCngDec->ho_lsp_circ, st->hTdCngDec->ho_lsp_circ_fx, Q15, HO_HIST_SIZE * M ); - floatToFixed_arrL( st->hTdCngDec->ho_env_circ, st->hTdCngDec->ho_env_circ_fx, Q6, HO_HIST_SIZE * NUM_ENV_CNG ); + ///* update CNG parameters in active frames */ + //Word16 lsp_new_fx[M]; + //Word16 exc_fx[L_EXC_DEC], Q_exc, exp_exc; + //f2me_buf_16( exc, exc_fx, &exp_exc, st->L_frame ); + //Q_exc = 15 - exp_exc; + //floatToFixed_arr( lsp_new, lsp_new_fx, Q15, M ); + //floatToFixed_arr( exc, exc_fx, Q_exc, st->L_frame ); + //floatToFixed_arrL( st->hTdCngDec->ho_ener_circ, st->hTdCngDec->ho_ener_circ_fx, Q6, HO_HIST_SIZE ); + //st->hTdCngDec->ho_circ_size_fx = st->hTdCngDec->ho_circ_size; + //st->hTdCngDec->ho_circ_ptr_fx = st->hTdCngDec->ho_circ_ptr; + //floatToFixed_arr( st->hTdCngDec->ho_lsp_circ, st->hTdCngDec->ho_lsp_circ_fx, Q15, HO_HIST_SIZE * M ); + //floatToFixed_arrL( st->hTdCngDec->ho_env_circ, st->hTdCngDec->ho_env_circ_fx, Q6, HO_HIST_SIZE * NUM_ENV_CNG ); cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr_fx, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size_fx, - st->hTdCngDec->ho_lsp_circ_fx, Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, + st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth ); - fixedToFloat_arr( lsp_new_fx, lsp_new, Q15, M ); - fixedToFloat_arr( exc_fx, exc, Q_exc, st->L_frame ); - fixedToFloat_arrL( st->hTdCngDec->ho_ener_circ_fx, st->hTdCngDec->ho_ener_circ, Q6, HO_HIST_SIZE ); - st->hTdCngDec->ho_circ_size = st->hTdCngDec->ho_circ_size_fx; - st->hTdCngDec->ho_circ_ptr = st->hTdCngDec->ho_circ_ptr_fx; - fixedToFloat_arr( st->hTdCngDec->ho_lsp_circ_fx, st->hTdCngDec->ho_lsp_circ, Q15, HO_HIST_SIZE * M ); - fixedToFloat_arrL( st->hTdCngDec->ho_env_circ_fx, st->hTdCngDec->ho_env_circ, Q6, HO_HIST_SIZE * NUM_ENV_CNG ); + //fixedToFloat_arr( lsp_new_fx, lsp_new, Q15, M ); + //fixedToFloat_arr( exc_fx, exc, Q_exc, st->L_frame ); + //fixedToFloat_arrL( st->hTdCngDec->ho_ener_circ_fx, st->hTdCngDec->ho_ener_circ, Q6, HO_HIST_SIZE ); + //st->hTdCngDec->ho_circ_size = st->hTdCngDec->ho_circ_size_fx; + //st->hTdCngDec->ho_circ_ptr = st->hTdCngDec->ho_circ_ptr_fx; + //fixedToFloat_arr( st->hTdCngDec->ho_lsp_circ_fx, st->hTdCngDec->ho_lsp_circ, Q15, HO_HIST_SIZE * M ); + //fixedToFloat_arrL( st->hTdCngDec->ho_env_circ_fx, st->hTdCngDec->ho_env_circ, Q6, HO_HIST_SIZE * NUM_ENV_CNG ); /* Set 16k LSP flag for CNG buffer */ st->hTdCngDec->ho_16k_lsp_fx[st->hTdCngDec->ho_circ_ptr_fx] = 0; @@ -3274,10 +3263,77 @@ ivas_error acelp_core_dec_ivas_fx( #endif pop_wmops(); + + + + { + /* Lccal fix2float (To be removed) */ + /*fixedToFloat_arrL(bwe_exc_extended_fx, bwe_exc_extended, 2 * st->Q_exc, L_FRAME32k + NL_BUFF_OFFSET); + fixedToFloat_arr(output_fx, output, 0, st->L_frame);*/ + if (save_hb_synth_fx16) { + //fixedToFloat_arrL(save_hb_synth_fx, save_hb_synth, 0, L_FRAME48k); + Copy_Scale_sig_32_16(save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0); + } + //fixedToFloat_arrL(synth_fx, synth, 0, L_FRAME48k); + Copy_Scale_sig_32_16(synth_fx, synth_fx16, L_FRAME48k, 0); + if (st->hFdCngDec) + { + st->hFdCngDec->hFdCngCom->A_cng[0] = ONE_IN_Q12; + } + /*for (i = 0; i < L_FRAME16k; i++) + { + bpf_error_signal[i] = fixedToFloat(bpf_error_signal_16fx[i], st->Q_syn); + }*/ + /*for (int nsf = 0; nsf < NB_SUBFR16k; nsf++) + { + fixedToFloat_arr(Aq_fx + (nsf * (M + 1)), Aq + (nsf * (M + 1)), Q14 - norm_s(Aq_fx[nsf * (M + 1)]), (M + 1)); + }*/ + /*printf("\n"); + for (int nm = 0; nm < M + 1; nm++) { + printf("%f ", Aq[nm]); + }*/ + // Aq_fx[0] = ONE_IN_Q12; + /*for (i = 0; i < M; i++) + { + lsf_new[i] = lsf_new_fx[i] / 2.56f; + }*/ + /*fixedToFloat_arr(lsp_new_fx, lsp_new, Q15, M); + fixedToFloat_arr(lsp_mid_fx, lsp_mid, Q15, M);*/ + /*float *tdm_lsfQ_PCh_out = (float *)tdm_lsfQ_PCh; + for (int idx = 0; idx < M; idx++) + { + tdm_lsfQ_PCh_out[idx] = tdm_lsfQ_PCh_fx[idx] / 2.56f; + } + fixedToFloat_arr(tdm_lspQ_PCh_fx, (float *)tdm_lspQ_PCh, Q15, M);*/ + /*printf("\n"); + for (int nm = 0; nm < M; nm++) { + printf("%f ", lsf_new[nm]); + }*/ + //fixedToFloat_arr(old_exc_fx, old_exc, st->Q_exc, L_EXC_DEC); // exc_fx + //fixedToFloat_arr(old_exc2_fx, old_exc2, st->Q_exc, L_FRAME16k + L_EXC_MEM); // exc2_fx + //fixedToFloat_arr(old_bwe_exc_fx, old_bwe_exc, st->Q_exc, ((PIT16k_MAX + (L_FRAME16k + 1) + L_SUBFR16k) * 2)); // bwe_exc_fx + //fixedToFloat_arr(syn_tmp_fx, syn_tmp, st->Q_syn, L_FRAME16k + L_SUBFR); // psyn_fx + //// fixedToFloat_arr(syn1_tmp_fx, syn1_tmp, st->Q_syn, L_FRAME16k + 2); + //fixedToFloat_arr(temp_buf_fx, temp_buf, -1, L_FRAME16k + L_SYN_MEM); + //Es_pred = fixedToFloat(Es_pred_fx, Q8); + // enr_q = fixedToFloat(enr_q_fx, 0); + + // fixedToFloat_arr(dct_exc_tmp_fx, dct_exc_tmp, st->Q_exc, L_FRAME16k); + // if (p_tdm_Pri_pitch_buf_fx) fixedToFloat_arr(p_tdm_Pri_pitch_buf_fx, p_tdm_Pri_pitch_buf, Q6, NB_SUBFR); + /*fixedToFloat_arr(gain_buf_fx, gain_buf, Q14, NB_SUBFR16k); + tmp_noise = fixedToFloat(tmp_noise_fx, 0);*/ + // fixedToFloat_arr(mem_tmp_fx, mem_tmp, st->Q_syn, M); + /*fixedToFloat_arr(pitch_buf_out_fx, pitch_buf, Q6, NB_SUBFR16k); + fixedToFloat_arr(voice_factors_fx, voice_factors, Q15, NB_SUBFR16k); + fixedToFloat_arr(old_syn_12k8_16k_fx, old_syn_12k8_16k, -1, st->L_frame);*/ + + /*---------------------*/ + } + return error; } -static void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HANDLE hStereoCng) { +void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HANDLE hStereoCng) { Word16 i; st->Q_exc = 0; st->Q_exc_cng = 0; @@ -3287,8 +3343,8 @@ static void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HAND st->Q_syn = 0; st->Q_syn_cng = 0; st->classifier_Q_mem_syn = 0; - st->coder_type_fx = st->coder_type; - st->last_coder_type_fx = st->last_coder_type; + st->coder_type = st->coder_type; + st->last_coder_type = st->last_coder_type; st->last_core_bs_fx = st->last_core_from_bs; #if 1 floatToFixed_arr(st->lsp_old, st->lsp_old_fx, Q15, M); @@ -3317,21 +3373,22 @@ static void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HAND /* st->mem_deemph_fx will need to be handled with proper Q */ st->mem_deemph_fx = (Word16)floatToFixed((Word16)check_bounds_l((Word32)st->mem_deemph, -32768, 32767), st->Q_syn); floatToFixed_arr(st->agc_mem2, st->agc_mem_fx, st->prev_Q_syn - 1, 2); + floatToFixed_arr(st->Aq_cng_float, st->Aq_cng, Q12, M + 1); + /*Flags (should be unified!)*/ st->last_nq_preQ_fx = st->last_nq_preQ; st->safety_net_fx = st->safety_net; st->nelp_mode_dec_fx = st->nelp_mode_dec; - st->last_nelp_mode_dec_fx = st->last_nelp_mode_dec; st->ppp_mode_dec_fx = st->ppp_mode_dec; st->relax_prev_lsf_interp_fx = st->relax_prev_lsf_interp; - st->last_good_fx = st->last_good; st->unv_cnt_fx = st->unv_cnt; st->uv_count_fx = st->uv_count; st->act_count_fx = st->act_count; st->GSC_noisy_speech_fx = st->GSC_noisy_speech; st->Last_GSC_noisy_speech_flag_fx = st->Last_GSC_noisy_speech_flag; st->mid_lsf_int_fx = st->mid_lsf_int; - st->old_bfi_cnt = st->old_bfi_cnt_fx; + st->last_vbr_hw_BWE_disable_dec_fx = st->last_vbr_hw_BWE_disable_dec; + st->vbr_hw_BWE_disable_dec_fx = st->vbr_hw_BWE_disable_dec; /* dec_exc */ st->lp_gainc_fx = float_to_fix16(st->lp_gainc, Q3); @@ -3376,10 +3433,18 @@ static void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HAND old_len_ana = st->cldfbAna->p_filter_length - st->cldfbAna->no_channels; old_len_bpf = st->cldfbBPF->p_filter_length - st->cldfbBPF->no_channels; + Word16 new_len; + new_len = 9 * (int16_t)(st->L_frame * FRAMES_PER_SEC * INV_CLDFB_BANDWIDTH + 0.5f); floatToFixed_arrL(st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_fx, Q11, old_len_ana); floatToFixed_arrL(st->cldfbBPF->cldfb_state, st->cldfbBPF->cldfb_state_fx, Q10, old_len_bpf); + if(st->cldfbSynHB) + floatToFixed_arrL(st->cldfbSynHB->cldfb_state, st->cldfbSynHB->cldfb_state_fx, Q10, st->cldfbSynHB->p_filter_length); + floatToFixed_arrL(st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q10, st->cldfbSyn->p_filter_length); st->stab_fac_smooth_fx = float_to_fix16(st->stab_fac_smooth, Q15); + //Word16 offset = sub(st->cldfbAna->p_filter_length, st->cldfbAna->no_channels); + + floatToFixed_arrL(st->previoussynth, st->previoussynth_fx_32, 0, L_FRAME48k); //hBPF if (st->hBPF) { @@ -3392,6 +3457,20 @@ static void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HAND st->hBPF->psf_att_fx = float_to_fix16(st->hBPF->psf_att, Q15); } + /*ZERO_BWE_DEC_HANDLE*/ + if (st->hBWE_zero) { + floatToFixed_arr(st->hBWE_zero->mem_hp400, st->hBWE_zero->mem_hp400_fx, 0, 4); + if (st->hBWE_FD) { + floatToFixed_arr(st->hBWE_zero->mem_hf, st->hBWE_zero->mem_hf_fx, -2 - st->hBWE_FD->memExp1, L_FIR - 1); + } + else { + floatToFixed_arr(st->hBWE_zero->mem_hf, st->hBWE_zero->mem_hf_fx, -2, L_FIR - 1); + } + floatToFixed_arr(st->hBWE_zero->mem_syn_hf, st->hBWE_zero->mem_syn_hf_fx, 0, M); + floatToFixed_arr(st->hBWE_zero->delay_syn_hf, st->hBWE_zero->delay_syn_hf_fx, 0, NS2SA(16000, DELAY_CLDFB_NS)); + floatToFixed_arr(st->hBWE_zero->mem_hp_interp, st->hBWE_zero->mem_hp_interp_fx, 0, INTERP_3_1_MEM_LEN); + } + //FdCng if ( st->hFdCngDec ) { @@ -3453,10 +3532,10 @@ static void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HAND st->hTdCngDec->old_enr_index_fx = st->hTdCngDec->old_enr_index; st->hTdCngDec->Enew_fx = floatToFixed(st->hTdCngDec->Enew, Q6); st->hTdCngDec->ho_hist_ptr_fx = st->hTdCngDec->ho_hist_ptr; - st->hTdCngDec->ho_hist_size_fx = st->hTdCngDec->ho_hist_size; + st->hTdCngDec->ho_hist_size = st->hTdCngDec->ho_hist_size; st->hTdCngDec->num_ho_fx = st->hTdCngDec->num_ho; - st->hTdCngDec->act_cnt2_fx = st->hTdCngDec->act_cnt2; - st->hTdCngDec->act_cnt_fx = st->hTdCngDec->act_cnt; + st->hTdCngDec->act_cnt2 = st->hTdCngDec->act_cnt2; + st->hTdCngDec->act_cnt = st->hTdCngDec->act_cnt; st->hTdCngDec->ho_circ_ptr_fx = st->hTdCngDec->ho_circ_ptr; st->hTdCngDec->ho_circ_size_fx = st->hTdCngDec->ho_circ_size; Copy(st->hTdCngDec->ho_16k_lsp, st->hTdCngDec->ho_16k_lsp_fx, HO_HIST_SIZE); @@ -3492,6 +3571,8 @@ static void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HAND if (st->hBWE_TD) { floatToFixed_arr(st->hBWE_TD->old_bwe_exc, st->hBWE_TD->old_bwe_exc_fx, st->Q_exc, PIT16k_MAX * 2); floatToFixed_arr(st->hBWE_TD->cur_sub_Aq, st->hBWE_TD->cur_sub_Aq_fx, Q12, M + 1); + floatToFixed_arr(st->hBWE_TD->old_bwe_exc_extended, st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET); + st->hBWE_TD->bwe_non_lin_prev_scale_fx = floatToFixed(st->hBWE_TD->bwe_non_lin_prev_scale, Q30); } /*GSC_DEC_HANDLE*/ @@ -3589,7 +3670,7 @@ static void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HAND st->lp_ener_FEC_av = floatToFixed(st->lp_ener_FEC_av_float, 0); st->lp_ener_FEC_max = floatToFixed(st->lp_ener_FEC_max_float, 0); st->old_enr_LP = float_to_fix16(st->old_enr_LP_float, st->Q_exc); - //st->last_good_fx = st->last_good; + //st->last_good = st->last_good; st->lp_ener_FER_fx = float_to_fix16(st->lp_ener_bfi, Q8); //st->relax_prev_lsf_interp_fx = st->relax_prev_lsf_interp; floatToFixed_arr(st->mem_syn_clas_estim, st->mem_syn_clas_estim_fx, st->Q_syn, L_SYN_MEM_CLAS_ESTIM); @@ -3665,14 +3746,13 @@ static void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HAND floatToFixed_arr(st->mem_syn_r_float, st->mem_syn_r, st->Q_syn, L_SYN_MEM); floatToFixed_arr(st->bpf_noise_buf_float, st->bpf_noise_buf, st->Q_syn, L_FRAME16k); st->prev_tilt_code_dec_fx = float_to_fix16(st->prev_tilt_code_dec, Q15); - st->last_coder_type_fx = st->last_coder_type; + st->last_coder_type = st->last_coder_type; #endif } -static void acelp_decoder_state_fix2float(Decoder_State *st, STEREO_CNG_DEC_HANDLE hStereoCng) { +void acelp_decoder_state_fix2float(Decoder_State *st, STEREO_CNG_DEC_HANDLE hStereoCng) { Word16 i; - st->coder_type = st->coder_type_fx; - st->last_coder_type = st->last_coder_type; + st->last_core_from_bs = st->last_core_bs_fx; st->prev_Q_syn = st->Q_syn; st->Q_syn2 = st->Q_syn; @@ -3701,22 +3781,22 @@ static void acelp_decoder_state_fix2float(Decoder_State *st, STEREO_CNG_DEC_HAND } st->mem_deemph = fixedToFloat(st->mem_deemph_fx, st->Q_syn); fixedToFloat_arr(st->agc_mem_fx, st->agc_mem2, st->Q_syn - 1, 2); + fixedToFloat_arr(st->Aq_cng, st->Aq_cng_float, Q14 - norm_s(st->Aq_cng[0]), M + 1); /*Flags (should be unified!)*/ st->last_nq_preQ = st->last_nq_preQ_fx; st->safety_net = st->safety_net_fx; st->nelp_mode_dec = st->nelp_mode_dec_fx; - st->last_nelp_mode_dec = st->last_nelp_mode_dec_fx; st->ppp_mode_dec = st->ppp_mode_dec_fx; st->relax_prev_lsf_interp = st->relax_prev_lsf_interp_fx; - st->last_good = st->last_good_fx; st->unv_cnt = st->unv_cnt_fx; st->uv_count = st->uv_count_fx; st->act_count = st->act_count_fx; st->GSC_noisy_speech = st->GSC_noisy_speech_fx; st->Last_GSC_noisy_speech_flag = st->Last_GSC_noisy_speech_flag_fx; st->mid_lsf_int = st->mid_lsf_int_fx; - st->old_bfi_cnt_fx = st->old_bfi_cnt; + st->last_vbr_hw_BWE_disable_dec = st->last_vbr_hw_BWE_disable_dec_fx; + st->vbr_hw_BWE_disable_dec = st->vbr_hw_BWE_disable_dec_fx; /* dec_exc */ st->lp_gainc = fixedToFloat(st->lp_gainc_fx, Q3); @@ -3759,8 +3839,18 @@ static void acelp_decoder_state_fix2float(Decoder_State *st, STEREO_CNG_DEC_HAND new_len = 9 * (int16_t)(st->L_frame * FRAMES_PER_SEC * INV_CLDFB_BANDWIDTH + 0.5f); fixedToFloat_arrL(st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_state, Q11, new_len); fixedToFloat_arrL(st->cldfbBPF->cldfb_state_fx, st->cldfbBPF->cldfb_state, Q10, new_len); + if (st->cldfbSynHB) + fixedToFloat_arrL(st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->cldfb_state, Q10, st->cldfbSynHB->p_filter_length); + fixedToFloat_arrL(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, Q10, st->cldfbSyn->p_filter_length); st->stab_fac_smooth = fixedToFloat(st->stab_fac_smooth_fx, Q15); + //Word16 offset = sub(st->cldfbAna->p_filter_length, st->cldfbAna->no_channels); + + IF(st->p_bpf_noise_buf_32) { + fixedToFloat_arrL(st->p_bpf_noise_buf_32, st->p_bpf_noise_buf_float, st->Q_syn-1, st->L_frame); + } + + fixedToFloat_arrL(st->previoussynth_fx_32, st->previoussynth, 0, L_FRAME48k); //hBPF if (st->hBPF) { @@ -3773,6 +3863,20 @@ static void acelp_decoder_state_fix2float(Decoder_State *st, STEREO_CNG_DEC_HAND st->hBPF->psf_att = fixedToFloat(st->hBPF->psf_att_fx, Q15); } + /*ZERO_BWE_DEC_HANDLE*/ + if (st->hBWE_zero) { + fixedToFloat_arr(st->hBWE_zero->mem_hp400_fx, st->hBWE_zero->mem_hp400, 0, 4); + if (st->hBWE_FD) { + fixedToFloat_arr(st->hBWE_zero->mem_hf_fx, st->hBWE_zero->mem_hf, -2 - st->hBWE_FD->memExp1, L_FIR - 1); + } + else { + fixedToFloat_arr(st->hBWE_zero->mem_hf_fx, st->hBWE_zero->mem_hf, -2, L_FIR - 1); + } + fixedToFloat_arr(st->hBWE_zero->mem_syn_hf_fx, st->hBWE_zero->mem_syn_hf, 0, M); + fixedToFloat_arr(st->hBWE_zero->delay_syn_hf_fx, st->hBWE_zero->delay_syn_hf, 0, NS2SA(16000, DELAY_CLDFB_NS)); + fixedToFloat_arr(st->hBWE_zero->mem_hp_interp_fx, st->hBWE_zero->mem_hp_interp, 0, INTERP_3_1_MEM_LEN); + } + //FdCng if ( st->hFdCngDec ) { @@ -3881,10 +3985,10 @@ static void acelp_decoder_state_fix2float(Decoder_State *st, STEREO_CNG_DEC_HAND st->hTdCngDec->old_enr_index = st->hTdCngDec->old_enr_index_fx; st->hTdCngDec->Enew = fixedToFloat(st->hTdCngDec->Enew_fx, Q6); st->hTdCngDec->ho_hist_ptr = st->hTdCngDec->ho_hist_ptr_fx; - st->hTdCngDec->ho_hist_size = st->hTdCngDec->ho_hist_size_fx; + st->hTdCngDec->ho_hist_size = st->hTdCngDec->ho_hist_size; st->hTdCngDec->num_ho = st->hTdCngDec->num_ho_fx; - st->hTdCngDec->act_cnt2 = st->hTdCngDec->act_cnt2_fx; - st->hTdCngDec->act_cnt = st->hTdCngDec->act_cnt_fx; + st->hTdCngDec->act_cnt2 = st->hTdCngDec->act_cnt2; + st->hTdCngDec->act_cnt = st->hTdCngDec->act_cnt; st->hTdCngDec->ho_circ_ptr = st->hTdCngDec->ho_circ_ptr_fx; st->hTdCngDec->ho_circ_size = st->hTdCngDec->ho_circ_size_fx; Copy(st->hTdCngDec->ho_16k_lsp_fx, st->hTdCngDec->ho_16k_lsp, HO_HIST_SIZE); @@ -3920,6 +4024,8 @@ static void acelp_decoder_state_fix2float(Decoder_State *st, STEREO_CNG_DEC_HAND if (st->hBWE_TD) { fixedToFloat_arr(st->hBWE_TD->old_bwe_exc_fx, st->hBWE_TD->old_bwe_exc, st->Q_exc, PIT16k_MAX * 2); fixedToFloat_arr(st->hBWE_TD->cur_sub_Aq_fx, st->hBWE_TD->cur_sub_Aq, Q12, M + 1); + fixedToFloat_arr(st->hBWE_TD->old_bwe_exc_extended_fx, st->hBWE_TD->old_bwe_exc_extended, 0, NL_BUFF_OFFSET); + st->hBWE_TD->bwe_non_lin_prev_scale = fixedToFloat(st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q30); } /*GSC_DEC_HANDLE*/ @@ -4011,7 +4117,7 @@ static void acelp_decoder_state_fix2float(Decoder_State *st, STEREO_CNG_DEC_HAND st->lp_ener_FEC_av_float = fixedToFloat(st->lp_ener_FEC_av, 0); st->lp_ener_FEC_max_float = fixedToFloat(st->lp_ener_FEC_max, 0); st->old_enr_LP_float = fixedToFloat(st->old_enr_LP, st->Q_exc); - //st->last_good = st->last_good_fx; + //st->last_good = st->last_good; st->lp_ener_bfi = fixedToFloat(st->lp_ener_FER_fx, Q8); //st->relax_prev_lsf_interp = st->relax_prev_lsf_interp_fx; fixedToFloat_arr(st->mem_syn_clas_estim_fx, st->mem_syn_clas_estim, st->Q_syn, L_SYN_MEM_CLAS_ESTIM); @@ -4086,7 +4192,7 @@ static void acelp_decoder_state_fix2float(Decoder_State *st, STEREO_CNG_DEC_HAND fixedToFloat_arr(st->mem_syn_r, st->mem_syn_r_float, st->Q_syn, L_SYN_MEM); fixedToFloat_arr(st->bpf_noise_buf, st->bpf_noise_buf_float, st->Q_syn, L_FRAME16k); st->prev_tilt_code_dec = fixedToFloat(st->prev_tilt_code_dec_fx, Q15); - st->last_coder_type = st->last_coder_type_fx; + st->last_coder_type = st->last_coder_type; #endif } diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index c2d6db0f4..6adfb6cdb 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -401,7 +401,7 @@ ivas_error acelp_core_switch_dec_bfi_fx( move16(); st_fx->bpf_off = 1; move16(); - st_fx->clas_dec = st_fx->last_good_fx; + st_fx->clas_dec = st_fx->last_good; move16(); tmp_noise = 0; move16(); @@ -433,7 +433,7 @@ ivas_error acelp_core_switch_dec_bfi_fx( move16(); /* SC-VBR */ - if( EQ_16(st_fx->last_nelp_mode_dec_fx, 1)) + if( EQ_16(st_fx->last_nelp_mode_dec, 1)) { st_fx->nelp_mode_dec_fx = 1; move16(); @@ -444,7 +444,7 @@ ivas_error acelp_core_switch_dec_bfi_fx( /* LSF estimation and A(z) calculation */ lsf_dec_bfi(MODE1, lsf_new, st_fx->lsf_old_fx, st_fx->lsf_adaptive_mean_fx, NULL, st_fx->mem_MA_fx, st_fx->mem_AR_fx, - st_fx->stab_fac_fx, st_fx->last_coder_type_fx, st_fx->L_frame, st_fx->last_good_fx, + st_fx->stab_fac_fx, st_fx->last_coder_type, st_fx->L_frame, st_fx->last_good, st_fx->nbLostCmpt, 0, NULL, NULL, NULL, st_fx->hGSCDec->Last_GSC_pit_band_idx_fx, st_fx->Opt_AMR_WB, 0, st_fx->bwidth); FEC_lsf2lsp_interp( st_fx, st_fx->L_frame, Aq, lsf_new, lsp_new); @@ -486,7 +486,7 @@ ivas_error acelp_core_switch_dec_bfi_fx( /* calculation of excitation signal */ FEC_exc_estim_fx( st_fx, st_fx->L_frame, exc, exc2, syn /* dummy buffer */, pitch_buf, voice_factors, &FEC_pitch, bwe_exc, lsf_new, &Q_exc, &tmp_noise ); Rescale_exc( NULL, exc, bwe_exc, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, L_FRAME32k, (Word32)0, - &Q_exc, st_fx->Q_subfr, exc2, st_fx->L_frame, st_fx->last_coder_type_fx); + &Q_exc, st_fx->Q_subfr, exc2, st_fx->L_frame, st_fx->last_coder_type); st_fx->seed = tmp_float[5]; move16(); @@ -512,7 +512,7 @@ ivas_error acelp_core_switch_dec_bfi_fx( syn_12k8_fx( st_fx->L_frame, Aq, exc2, syn, tmp_float, 1, Q_exc, st_fx->Q_syn ); tmp_float32 = st_fx->enr_old_fx; - frame_ener_fx( st_fx->L_frame, st_fx->last_good_fx, syn, shr(add(FEC_pitch,32),6), &tmp_float32, st_fx->L_frame, st_fx->Q_syn, 3, 0 ); + frame_ener_fx( st_fx->L_frame, st_fx->last_good, syn, shr(add(FEC_pitch,32),6), &tmp_float32, st_fx->L_frame, st_fx->Q_syn, 3, 0 ); /*------------------------------------------------------------------* * Perform fixed deemphasis through 1/(1 - g*z^-1) diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index aa1565efd..f57912ba8 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -131,7 +131,7 @@ ivas_error amr_wb_dec_fx( move16(); st_fx->bwidth = WB; move16(); - st_fx->coder_type_fx = GENERIC; + st_fx->coder_type = GENERIC; move16(); output_frame = st_fx->output_frame_fx; move16(); /* frame length of the input signal */ @@ -460,11 +460,11 @@ ivas_error amr_wb_dec_fx( vad_flag = (Word16)get_next_indice( st_fx, 1 ); - st_fx->coder_type_fx = GENERIC; + st_fx->coder_type = GENERIC; move16(); if ( vad_flag == 0 ) { - st_fx->coder_type_fx = INACTIVE; + st_fx->coder_type = INACTIVE; move16(); } @@ -488,7 +488,7 @@ ivas_error amr_wb_dec_fx( * Update ISP vector for CNG *------------------------------------------------------------*/ - IF( EQ_16(st_fx->coder_type_fx,INACTIVE)) + IF( EQ_16(st_fx->coder_type,INACTIVE)) { IF( GT_16(st_fx->unv_cnt_fx,20)) { @@ -524,7 +524,7 @@ ivas_error amr_wb_dec_fx( move16(); test(); test(); - if(EQ_16(st_fx->coder_type_fx,INACTIVE)&&st_fx->flag_cna&&GE_16(st_fx->psf_lp_noise_fx,15<<7)) + if(EQ_16(st_fx->coder_type,INACTIVE)&&st_fx->flag_cna&&GE_16(st_fx->psf_lp_noise_fx,15<<7)) { tmp16 = 1; move16(); @@ -538,7 +538,7 @@ ivas_error amr_wb_dec_fx( * FEC - Estimate the classification information *------------------------------------------------------------*/ - FEC_clas_estim_fx( st_fx, 1, L_FRAME, &st_fx->clas_dec, st_fx->coder_type_fx, pitch_buf_fx, + FEC_clas_estim_fx( st_fx, 1, L_FRAME, &st_fx->clas_dec, st_fx->coder_type, pitch_buf_fx, syn_fx, &st_fx->lp_ener_FER_fx, &st_fx->decision_hyst, &st_fx->hAmrwb_IO->UV_cnt_fx, &st_fx->hAmrwb_IO->LT_UV_cnt_fx, &st_fx->hAmrwb_IO->Last_ener_fx, &locattack, st_fx->hAmrwb_IO->lt_diff_etot_fx, &amr_io_class, st_fx->core_brate, st_fx->Q_syn, &class_para_fx, st_fx->mem_syn_clas_estim_fx, &st_fx->classifier_Q_mem_syn, @@ -551,7 +551,7 @@ ivas_error amr_wb_dec_fx( IF( NE_16(output_frame,L_FRAME8k)) { - IF ( EQ_16(st_fx->coder_type_fx,INACTIVE)) + IF ( EQ_16(st_fx->coder_type,INACTIVE)) { frame_energy_fx( L_FRAME, pitch_buf_fx, syn_fx, 0, &frame_e_fx, st_fx->Q_syn ); /*st->psf_lp_noise = 0.99f * st->psf_lp_noise + 0.01f * frame_e; */ @@ -561,12 +561,12 @@ ivas_error amr_wb_dec_fx( test(); test(); - IF( NE_16(amr_io_class,UNVOICED_CLAS)&&NE_16(st_fx->coder_type_fx,INACTIVE)&<_16(st_fx->psf_lp_noise_fx,15<<8)) + IF( NE_16(amr_io_class,UNVOICED_CLAS)&&NE_16(st_fx->coder_type,INACTIVE)&<_16(st_fx->psf_lp_noise_fx,15<<8)) { tmp_coder_type = AUDIO; move16(); test(); - if (EQ_16(st_fx->last_coder_type_fx,INACTIVE)||EQ_16(st_fx->last_coder_type_fx,UNVOICED)) + if (EQ_16(st_fx->last_coder_type,INACTIVE)||EQ_16(st_fx->last_coder_type,UNVOICED)) { tmp_coder_type = INACTIVE; move16(); @@ -588,8 +588,8 @@ ivas_error amr_wb_dec_fx( * Improvement for unvoiced and audio signals *------------------------------------------------------------*/ - improv_amr_wb_gs_fx(amr_io_class, st_fx->coder_type_fx, st_fx->core_brate, &st_fx->hGSCDec->seed_tcx_fx, st_fx->hAmrwb_IO->old_Aq_fx, st_fx->mem_syn2_fx, st_fx->hAmrwb_IO->lt_voice_fac_fx, - locattack, Aq_fx, exc2_fx, st_fx->Q_exc, mem_tmp_fx, syn_fx, st_fx->Q_syn, pitch_buf_fx, st_fx->hAmrwb_IO->Last_ener_fx, st_fx->rate_switching_reset, st_fx->last_coder_type_fx); + improv_amr_wb_gs_fx(amr_io_class, st_fx->coder_type, st_fx->core_brate, &st_fx->hGSCDec->seed_tcx_fx, st_fx->hAmrwb_IO->old_Aq_fx, st_fx->mem_syn2_fx, st_fx->hAmrwb_IO->lt_voice_fac_fx, + locattack, Aq_fx, exc2_fx, st_fx->Q_exc, mem_tmp_fx, syn_fx, st_fx->Q_syn, pitch_buf_fx, st_fx->hAmrwb_IO->Last_ener_fx, st_fx->rate_switching_reset, st_fx->last_coder_type); FOR( i = 0; i < DCT_L_POST; i++ ) { @@ -602,7 +602,7 @@ ivas_error amr_wb_dec_fx( * FEC - Estimate pitch *------------------------------------------------------------*/ - FEC_pitch_estim_fx( 1, st_fx->last_core, L_FRAME, st_fx->clas_dec, st_fx->last_good_fx, pitch_buf_fx, st_fx->old_pitch_buf_fx, &st_fx->bfi_pitch_fx, + FEC_pitch_estim_fx( 1, st_fx->last_core, L_FRAME, st_fx->clas_dec, st_fx->last_good, pitch_buf_fx, st_fx->old_pitch_buf_fx, &st_fx->bfi_pitch_fx, &st_fx->bfi_pitch_frame, &st_fx->upd_cnt, GENERIC ); /*------------------------------------------------------------* @@ -616,7 +616,7 @@ ivas_error amr_wb_dec_fx( move16(); } - FEC_scale_syn_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good_fx, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, MOVING_AVERAGE, + FEC_scale_syn_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, MOVING_AVERAGE, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 ); @@ -634,19 +634,19 @@ ivas_error amr_wb_dec_fx( test(); if( GT_16(st_fx->nbLostCmpt,5)&&GE_16(st_fx->clas_dec,VOICED_CLAS)) { - st_fx->last_good_fx = VOICED_TRANSITION; + st_fx->last_good = VOICED_TRANSITION; move16(); } vad_flag = st_fx->last_vad_fx; move16(); - amr_io_class = st_fx->last_good_fx; + amr_io_class = st_fx->last_good; move16(); class_para_fx = 0; move16(); /* LSF estimation and A(z) calculation */ lsf_dec_bfi( MODE1, lsf_new_fx, st_fx->lsf_old_fx, st_fx->lsf_adaptive_mean_fx, NULL, st_fx->mem_MA_fx, st_fx->mem_AR_fx, - st_fx->stab_fac_fx, st_fx->last_coder_type_fx, st_fx->L_frame, st_fx->last_good_fx, + st_fx->stab_fac_fx, st_fx->last_coder_type, st_fx->L_frame, st_fx->last_good, st_fx->nbLostCmpt, 0, NULL, NULL, NULL, st_fx->hGSCDec->Last_GSC_pit_band_idx_fx, st_fx->Opt_AMR_WB, 0, st_fx->bwidth); FEC_lsf2lsp_interp( st_fx, st_fx->L_frame, Aq_fx, lsf_new_fx, lsp_new_fx ); @@ -696,13 +696,13 @@ ivas_error amr_wb_dec_fx( * (smoothing is performed in the excitation domain and signal is resynthesized after) *------------------------------------------------------------*/ - FEC_scale_syn_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good_fx, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, + FEC_scale_syn_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, MOVING_AVERAGE, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, 0, 0 ); /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */ - frame_ener_fx( L_FRAME, st_fx->last_good_fx, syn_fx, shr(FEC_pitch_fx, 6), &st_fx->enr_old_fx, L_FRAME, st_fx->Q_syn, 3, 0 ); + frame_ener_fx( L_FRAME, st_fx->last_good, syn_fx, shr(FEC_pitch_fx, 6), &st_fx->enr_old_fx, L_FRAME, st_fx->Q_syn, 3, 0 ); } /*--------------------------------------------------------* @@ -720,7 +720,7 @@ ivas_error amr_wb_dec_fx( { st_fx->hPFstat->on = 1; move16(); - nb_post_filt( L_FRAME, st_fx->hPFstat, &st_fx->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, st_fx->coder_type_fx, st_fx->BER_detect, 0 ); + nb_post_filt( L_FRAME, st_fx->hPFstat, &st_fx->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, st_fx->coder_type, st_fx->BER_detect, 0 ); } ELSE { @@ -766,11 +766,11 @@ ivas_error amr_wb_dec_fx( flag_cna = 0; move16(); test(); - IF( (GE_16(st_fx->psf_lp_noise_fx,15<<8))||(st_fx->coder_type_fx==INACTIVE)) + IF( (GE_16(st_fx->psf_lp_noise_fx,15<<8))||(st_fx->coder_type==INACTIVE)) { /*VAD only for non inactive frame*/ test(); - IF( EQ_16(st_fx->VAD, 1)&&NE_16(st_fx->coder_type_fx,INACTIVE)) + IF( EQ_16(st_fx->VAD, 1)&&NE_16(st_fx->coder_type,INACTIVE)) { st_fx->VAD = 1; move16(); @@ -825,7 +825,7 @@ ivas_error amr_wb_dec_fx( test(); test(); test(); - IF( EQ_16(st_fx->last_flag_cna,1)&&((EQ_16(st_fx->last_core,ACELP_CORE)&&NE_16(st_fx->last_coder_type_fx,AUDIO))||EQ_16(st_fx->last_core,AMR_WB_CORE))) + IF( EQ_16(st_fx->last_flag_cna,1)&&((EQ_16(st_fx->last_core,ACELP_CORE)&&NE_16(st_fx->last_coder_type,AUDIO))||EQ_16(st_fx->last_core,AMR_WB_CORE))) { FOR (i=0; i < L_FRAME/2; i++) { @@ -977,7 +977,7 @@ ivas_error amr_wb_dec_fx( { st_fx->last_total_brate = st_fx->total_brate; move32(); - st_fx->last_good_fx = st_fx->clas_dec; + st_fx->last_good = st_fx->clas_dec; move16(); } st_fx->last_vad_fx = vad_flag; @@ -994,7 +994,7 @@ ivas_error amr_wb_dec_fx( if( st_fx->bfi ) { /* calculate another loss frame to fill gap in case of switching frame loss */ - if ((error = acelp_core_switch_dec_bfi_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type_fx )) != IVAS_ERR_OK) + if ((error = acelp_core_switch_dec_bfi_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type )) != IVAS_ERR_OK) { return error; } diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index bc698d2b2..33f8ed1ac 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -238,7 +238,7 @@ void CNG_dec_fx( test(); IF ( EQ_16(st_fx->bwidth,WB) && st_fx->first_CNG!=0 && NE_16(st_fx->L_frame,st_fx->last_CNG_L_frame)) { - hTdCngDec->ho_hist_size_fx = 0; + hTdCngDec->ho_hist_size = 0; move16(); } } @@ -277,7 +277,7 @@ void CNG_dec_fx( test(); test(); IF( ( st_fx->Opt_AMR_WB || EQ_16(st_fx->bwidth,WB)) - && ( !st_fx->first_CNG || GE_16(hTdCngDec->act_cnt2_fx,MIN_ACT_CNG_UPD) ) ) + && ( !st_fx->first_CNG || GE_16(hTdCngDec->act_cnt2,MIN_ACT_CNG_UPD) ) ) { IF( GT_32(st_fx->last_active_brate,ACELP_16k40)) { @@ -293,7 +293,7 @@ void CNG_dec_fx( /* If first sid after active burst update LSF history from circ buffer */ burst_ho_cnt = s_min(burst_ho_cnt, hTdCngDec->ho_circ_size_fx); /* MODE1_DTX_IN_CODEC_B_FIX */ - hTdCngDec->act_cnt_fx = 0; + hTdCngDec->act_cnt = 0; move16(); s_ptr = add(sub(hTdCngDec->ho_circ_ptr_fx, burst_ho_cnt),1); move16(); @@ -326,11 +326,11 @@ void CNG_dec_fx( hTdCngDec->ho_sid_bw_fx = L_shl(L_and(hTdCngDec->ho_sid_bw_fx, (Word32) 0x3fffffffL ), 1); Copy32(&(hTdCngDec->ho_env_circ_fx[s_ptr*NUM_ENV_CNG]), &(hTdCngDec->ho_env_hist_fx[hTdCngDec->ho_hist_ptr_fx*NUM_ENV_CNG]), NUM_ENV_CNG ); - hTdCngDec->ho_hist_size_fx = add(hTdCngDec->ho_hist_size_fx,1); + hTdCngDec->ho_hist_size = add(hTdCngDec->ho_hist_size,1); - if (GT_16(hTdCngDec->ho_hist_size_fx, HO_HIST_SIZE)) + if (GT_16(hTdCngDec->ho_hist_size, HO_HIST_SIZE)) { - hTdCngDec->ho_hist_size_fx = HO_HIST_SIZE; + hTdCngDec->ho_hist_size = HO_HIST_SIZE; move16(); } @@ -342,7 +342,7 @@ void CNG_dec_fx( } } - IF(hTdCngDec->ho_hist_size_fx > 0 ) /* can be -1 at init MODE1_DTX_IN_CODEC_B_FIX */ + IF(hTdCngDec->ho_hist_size > 0 ) /* can be -1 at init MODE1_DTX_IN_CODEC_B_FIX */ { /* *allow_cn_step |= ( st_fx->ho_ener_hist[st_fx->ho_hist_ptr] > 4.0f * st_fx->lp_ener );*/ L_tmp1 = L_shr(hTdCngDec->ho_ener_hist_fx[hTdCngDec->ho_hist_ptr_fx], 2); @@ -360,7 +360,7 @@ void CNG_dec_fx( move16(); } test(); - IF ( *allow_cn_step == 0 && hTdCngDec->ho_hist_size_fx > 0 ) + IF ( *allow_cn_step == 0 && hTdCngDec->ho_hist_size > 0 ) { /* Use average of energies below last energy */ ptr = hTdCngDec->ho_hist_ptr_fx; @@ -380,7 +380,7 @@ void CNG_dec_fx( m = 1; move16(); - FOR( k=1; k< hTdCngDec->ho_hist_size_fx; k++ ) + FOR( k=1; k< hTdCngDec->ho_hist_size; k++ ) { ptr = sub(ptr,1); if( ptr < 0 ) @@ -638,10 +638,10 @@ void CNG_dec_fx( hTdCngDec->ho_sid_bw_fx = L_or(hTdCngDec->ho_sid_bw_fx, 0x1L); } - hTdCngDec->ho_hist_size_fx = add(hTdCngDec->ho_hist_size_fx,1); - if( GT_16(hTdCngDec->ho_hist_size_fx,HO_HIST_SIZE)) + hTdCngDec->ho_hist_size = add(hTdCngDec->ho_hist_size,1); + if( GT_16(hTdCngDec->ho_hist_size,HO_HIST_SIZE)) { - hTdCngDec->ho_hist_size_fx = HO_HIST_SIZE; + hTdCngDec->ho_hist_size = HO_HIST_SIZE; move16(); } } @@ -1344,8 +1344,8 @@ void td_cng_dec_init( set16_fx(hTdCngDec->ho_lsp_hist_fx, 0, HO_HIST_SIZE* M); set32_fx(hTdCngDec->ho_ener_hist_fx, 0, HO_HIST_SIZE); set32_fx(hTdCngDec->ho_env_hist_fx, 0, HO_HIST_SIZE* NUM_ENV_CNG); - hTdCngDec->ho_hist_size_fx = 0; move16(); - hTdCngDec->act_cnt_fx = 0; move16(); + hTdCngDec->ho_hist_size = 0; move16(); + hTdCngDec->act_cnt = 0; move16(); hTdCngDec->ho_circ_ptr_fx = -1; move16(); set16_fx(hTdCngDec->ho_lsp_circ_fx, 0, HO_HIST_SIZE* M); set32_fx(hTdCngDec->ho_ener_circ_fx, 0, HO_HIST_SIZE); @@ -1353,7 +1353,7 @@ void td_cng_dec_init( hTdCngDec->ho_circ_size_fx = 0; move16(); set16_fx(hTdCngDec->ho_16k_lsp_fx, 0, HO_HIST_SIZE); - hTdCngDec->act_cnt2_fx = 0; move16(); + hTdCngDec->act_cnt2 = 0; move16(); hTdCngDec->num_ho_fx = 0; move16(); hTdCngDec->last_cng_type_fx = -1; move16(); set32_fx(hTdCngDec->lp_env_fx, 0, NUM_ENV_CNG); diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index 6823346db..b80fbef39 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -206,7 +206,7 @@ void open_decoder_LPD( } /* Initialize TBE */ - st->prev_coder_type_fx = GENERIC; + st->prev_coder_type = GENERIC; if (st->hBWE_TD != NULL) { set16_fx(hBWE_TD->prev_lsf_diff_fx, 16384, LPC_SHB_ORDER - 2); @@ -722,7 +722,7 @@ void open_decoder_LPD( st->last_core_bfi = -1; move16(); } - st->prev_old_bfi_fx = 0; + st->prev_old_bfi = 0; move16(); /*st->noise_filling_index = 0;*/ /* not in BASOP */ @@ -755,7 +755,7 @@ void open_decoder_LPD( } ELSE { - st->last_good_fx = UNVOICED_CLAS; /* last good received frame for concealment */ move16(); + st->last_good = UNVOICED_CLAS; /* last good received frame for concealment */ move16(); st->enr_old_fx = L_deposit_l(0); /* energy at the end of the previous frame */ } st->Mode2_lp_gainc = L_deposit_l(0); diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index c1da36b10..5163ed75b 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -1296,7 +1296,17 @@ ivas_error core_switching_post_dec( } /* delay HQ synthesis to synchronize with ACELP synthesis */ +#ifdef IVAS_FLOAT_FIXED + floatToFixed_arrL(synth, synth_fx, Q11, 960); + floatToFixed_arrL(st->delay_buf_out, st->delay_buf_out32_fx, Q11, 60); + + delay_signal_fx( synth_fx, output_frame, st->delay_buf_out32_fx, delay_comp ); + + fixedToFloat_arrL(synth_fx, synth, Q11, 960); + fixedToFloat_arrL(st->delay_buf_out32_fx, st->delay_buf_out, Q11, 60); +#else delay_signal_float( synth, output_frame, st->delay_buf_out, delay_comp ); +#endif if ( st->element_mode == EVS_MONO && st->core == HQ_CORE ) /* ACELP->HQ-CORE */ { diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 6f62e8e20..8bc519645 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -27,8 +27,8 @@ void bandwidth_switching_detect_fx( IF ((EQ_16(st_fx->element_mode, IVAS_CPE_TD) && EQ_16(st_fx->idchan, 1) ) || EQ_16(st_fx->element_mode, IVAS_CPE_MDCT)) { /* there is no BWE in TD stereo secondary channel and in MDCT stereo, IGF is part of the core decoding -> no BW switching -> reset BWS counters */ - st_fx->prev_bws_cnt_fx = 0; - st_fx->bws_cnt_fx = 0; + st_fx->prev_bws_cnt = 0; + st_fx->prev_bws_cnt = 0; st_fx->bws_cnt1_fx = 0; move16(); move16(); move16(); @@ -53,12 +53,12 @@ void bandwidth_switching_detect_fx( { IF( LT_16(st_fx->bwidth, st_fx->last_bwidth)) { - st_fx->bws_cnt_fx = sub( shl(sub(N_NS2W_FRAMES, st_fx->bws_cnt1_fx), 1), 1 ); + st_fx->bws_cnt = sub( shl(sub(N_NS2W_FRAMES, st_fx->bws_cnt1_fx), 1), 1 ); move16(); } ELSE { - st_fx->bws_cnt_fx = 0; + st_fx->bws_cnt = 0; move16(); } @@ -86,22 +86,22 @@ void bandwidth_switching_detect_fx( test(); test(); test(); - IF( GE_16(st_fx->bws_cnt_fx, N_WS2N_FRAMES)) + IF( GE_16(st_fx->prev_bws_cnt, N_WS2N_FRAMES)) { - st_fx->bws_cnt_fx = 0; + st_fx->prev_bws_cnt = 0; move16(); } ELSE IF( LT_32(st_fx->total_brate, ACELP_9k60)&>_32(st_fx->last_core_brate,ACELP_9k60) && LT_16(st_fx->bwidth, st_fx->last_bwidth) && EQ_16(st_fx->bwidth, WB) ) { - st_fx->bws_cnt_fx = add(st_fx->bws_cnt_fx,1); + st_fx->prev_bws_cnt = add(st_fx->prev_bws_cnt,1); move16(); } - ELSE IF( st_fx->bws_cnt_fx > 0 ) + ELSE IF( st_fx->prev_bws_cnt > 0 ) { IF( GT_16(st_fx->bwidth, st_fx->last_bwidth)) { - st_fx->bws_cnt1_fx = shr(sub(N_WS2N_FRAMES, st_fx->bws_cnt_fx), 1); + st_fx->bws_cnt1_fx = shr(sub(N_WS2N_FRAMES, st_fx->prev_bws_cnt), 1); move16(); } ELSE @@ -112,19 +112,19 @@ void bandwidth_switching_detect_fx( IF( GT_16(st_fx->bwidth, st_fx->last_bwidth)) { - st_fx->bws_cnt_fx = 0; + st_fx->prev_bws_cnt = 0; move16(); } ELSE { IF( EQ_16(st_fx->bwidth, WB)) { - st_fx->bws_cnt_fx = add(st_fx->bws_cnt_fx,1); + st_fx->prev_bws_cnt = add(st_fx->prev_bws_cnt,1); move16(); } ELSE { - st_fx->bws_cnt_fx = 0; + st_fx->prev_bws_cnt = 0; move16(); } } @@ -708,7 +708,7 @@ ivas_error core_switching_pre_dec_fx( { st_fx->last_ppp_mode_dec_fx = 0; move16(); - st_fx->last_nelp_mode_dec_fx =0; + st_fx->last_nelp_mode_dec =0; move16(); } @@ -797,7 +797,7 @@ ivas_error core_switching_pre_dec_fx( st_fx->dm_fx.prev_state = 0; move16(); - st_fx->last_coder_type_fx = GENERIC; + st_fx->last_coder_type = GENERIC; move16(); frame_ener_fx( output_frame, UNVOICED_CLAS, st_fx->previoussynth_fx, -1, &st_fx->enr_old_fx, 1, 0, 0, 0 ); @@ -1143,7 +1143,7 @@ ivas_error core_switching_post_dec_fx( test(); test(); test(); IF( EQ_16(st_fx->core, ACELP_CORE)&&st_fx->bfi && hHQ_core != NULL && !st_fx->con_tcx) { - if ((error = acelp_core_switch_dec_bfi_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type_fx )) != IVAS_ERR_OK) + if ((error = acelp_core_switch_dec_bfi_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type )) != IVAS_ERR_OK) { return error; } /*the output at Q0*/ @@ -1349,7 +1349,7 @@ ivas_error core_switching_post_dec_fx( test(); test(); test(); - IF(st_fx->bws_cnt_fx == 0 || (st_fx->bws_cnt_fx > 0 && NE_16(st_fx->coder_type_fx, INACTIVE)&&NE_16(st_fx->coder_type_fx,AUDIO))) + IF(st_fx->prev_bws_cnt == 0 || (st_fx->prev_bws_cnt > 0 && NE_16(st_fx->coder_type, INACTIVE)&&NE_16(st_fx->coder_type,AUDIO))) { st_fx->attenu_fx = 3277; move16(); @@ -1358,8 +1358,8 @@ ivas_error core_switching_post_dec_fx( IF( ( NE_16(st_fx->last_extl, SWB_BWE)&&EQ_16(st_fx->extl,SWB_BWE))||(NE_16(st_fx->last_extl,FB_BWE)&&EQ_16(st_fx->extl,FB_BWE))|| ((EQ_16(st_fx->last_core, HQ_CORE) || EQ_16(st_fx->last_extl, SWB_TBE) ) && st_fx->extl < 0 && NE_16(st_fx->core, HQ_CORE) ) || (EQ_16(st_fx->last_core,ACELP_CORE) && EQ_16(st_fx->core,ACELP_CORE) - && ((NE_16(st_fx->prev_coder_type_fx,INACTIVE) && EQ_16(st_fx->coder_type_fx,INACTIVE) ) || (NE_16(st_fx->prev_coder_type_fx,AUDIO) && EQ_16(st_fx->coder_type_fx,AUDIO) )) - && st_fx->bws_cnt_fx > 0) + && ((NE_16(st_fx->prev_coder_type,INACTIVE) && EQ_16(st_fx->coder_type,INACTIVE) ) || (NE_16(st_fx->prev_coder_type,AUDIO) && EQ_16(st_fx->coder_type,AUDIO) )) + && st_fx->prev_bws_cnt > 0) ) { set16_fx(hBWE_FD->L_old_wtda_swb_fx, 0, output_frame ); @@ -1426,8 +1426,8 @@ ivas_error core_switching_post_dec_fx( IF( (( EQ_16(st_fx->extl, SWB_TBE)||EQ_16(st_fx->extl,FB_TBE)||EQ_16(st_fx->extl,SWB_CNG))&& ( NE_16(st_fx->L_frame, st_fx->last_L_frame) || ( NE_16(st_fx->last_extl, SWB_TBE) && NE_16(st_fx->last_extl, FB_TBE) ) || EQ_16(st_fx->last_core, HQ_CORE) )) || ( LT_16(st_fx->bwidth, st_fx->last_bwidth) && NE_16(st_fx->last_extl, SWB_TBE) ) || st_fx->old_ppp_mode_fx - || ((EQ_16(st_fx->prev_coder_type_fx, AUDIO) || EQ_16(st_fx->prev_coder_type_fx, INACTIVE) ) && st_fx->bws_cnt_fx > 0) - || (st_fx->bws_cnt_fx == 0 && EQ_16(st_fx->prev_bws_cnt_fx, N_WS2N_FRAMES)) ) + || ((EQ_16(st_fx->prev_coder_type, AUDIO) || EQ_16(st_fx->prev_coder_type, INACTIVE) ) && st_fx->prev_bws_cnt > 0) + || (st_fx->prev_bws_cnt == 0 && EQ_16(st_fx->prev_bws_cnt, N_WS2N_FRAMES)) ) { swb_tbe_reset_fx(hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, hBWE_TD->syn_overlap_fx, hBWE_TD->state_syn_shbexc_fx, &(hBWE_TD->tbe_demph_fx), &(hBWE_TD->tbe_premph_fx) diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c index 8d532ea11..dbad19cfb 100644 --- a/lib_dec/dec_LPD_fx.c +++ b/lib_dec/dec_LPD_fx.c @@ -150,10 +150,10 @@ void decoder_LPD( move16(); tcx_current_overlap_mode = st->hTcxCfg->tcx_curr_overlap_mode; move16(); - dec_prm(&st->coder_type_fx, param, param_lpc, total_nbbits, st, L_frame, bitsRead); + dec_prm(&st->coder_type, param, param_lpc, total_nbbits, st, L_frame, bitsRead); IF(!st->rate_switching_init && EQ_16((st->last_codec_mode), MODE2)&&st->BER_detect) { - st->coder_type_fx = st->last_coder_type_fx; + st->coder_type = st->last_coder_type; move16(); st->last_core = st->second_last_core; move16(); @@ -182,7 +182,7 @@ void decoder_LPD( test(); IF( st->use_partial_copy && GE_16(st->rf_frame_type, RF_TCXFD)&&LE_16(st->rf_frame_type,RF_TCXTD2)) { - dec_prm( &st->coder_type_fx, param, param_lpc, total_nbbits, st, L_frame, bitsRead ); + dec_prm( &st->coder_type, param, param_lpc, total_nbbits, st, L_frame, bitsRead ); } if (GT_16(st->nbLostCmpt, 1)) @@ -274,7 +274,7 @@ void decoder_LPD( IF( EQ_16(st->core,ACELP_CORE)&&EQ_16(st->last_core,ACELP_CORE) && LT_32(lsp_diff, 52428 )&>_32(lsp_diff,3932)&&EQ_16(st->next_coder_type,GENERIC) - && !st->prev_use_partial_copy && EQ_16(st->last_coder_type_fx,UNVOICED) && GE_16(st->rf_frame_type,RF_GENPRED) ) + && !st->prev_use_partial_copy && EQ_16(st->last_coder_type,UNVOICED) && GE_16(st->rf_frame_type,RF_GENPRED) ) { Copy( &lsp[0], &lsp[M], M ); } @@ -298,7 +298,7 @@ void decoder_LPD( } ELSE { - tcx_lpc_cdk = tcxlpc_get_cdk(st->coder_type_fx); /* inlined */ + tcx_lpc_cdk = tcxlpc_get_cdk(st->coder_type); /* inlined */ } Copy(st->lsf_old_fx, &lsf[0], M); @@ -332,10 +332,10 @@ void decoder_LPD( } ELSE { - lpc_unquantize( st, lsf, lsp, M, param_lpc, lspmid, lsfmid, st->coder_type_fx, &LSF_Q_prediction); + lpc_unquantize( st, lsf, lsp, M, param_lpc, lspmid, lsfmid, st->coder_type, &LSF_Q_prediction); IF(EQ_16(st->prev_use_partial_copy,1)&&EQ_16(st->last_core,ACELP_CORE)&&EQ_16(st->core,ACELP_CORE) - && GE_16(st->prev_rf_frame_type, RF_GENPRED) && EQ_16(st->coder_type_fx, UNVOICED)) + && GE_16(st->prev_rf_frame_type, RF_GENPRED) && EQ_16(st->coder_type, UNVOICED)) { IF ( st->lpcQuantization && st->acelp_cfg.midLpc ) { @@ -388,7 +388,7 @@ void decoder_LPD( move16(); xsfBase = PlcGetLsfBase (st->lpcQuantization, (Word16)st->narrowBand, st->sr_core); - dlpc_bfi( st->L_frame,xsfnew_uw,st->lsfold_uw,st->last_good_fx,st->nbLostCmpt,st->mem_MA_fx,st->mem_AR_fx, + dlpc_bfi( st->L_frame,xsfnew_uw,st->lsfold_uw,st->last_good,st->nbLostCmpt,st->mem_MA_fx,st->mem_AR_fx, &(st->stab_fac_fx), st->lsf_adaptive_mean_fx, st->numlpc, st->lsf_cng, (Word8)st->plcBackgroundNoiseUpdated, st->lsf_q_cng, st->old_lsf_q_cng, xsfBase, (Word8)st->tcxonly); hTcxDec->envWeighted = 0; @@ -451,7 +451,7 @@ void decoder_LPD( test(); test(); test(); - IF( (st->prev_bfi!=0) && (bfi==0) && (EQ_16(st->coder_type_fx,VOICED))&>_16(st->prev_nbLostCmpt,4)) + IF( (st->prev_bfi!=0) && (bfi==0) && (EQ_16(st->coder_type,VOICED))&>_16(st->prev_nbLostCmpt,4)) { st->dec_glr_idx = 1; move16(); @@ -520,7 +520,7 @@ void decoder_LPD( test(); test(); test(); - IF ( EQ_16(st->clas_dec, UNVOICED_CLAS)||EQ_16(st->clas_dec,SIN_ONSET)||EQ_16(st->clas_dec,INACTIVE_CLAS)||EQ_16(st->coder_type_fx,GENERIC)||EQ_16(st->coder_type_fx,TRANSITION)) + IF ( EQ_16(st->clas_dec, UNVOICED_CLAS)||EQ_16(st->clas_dec,SIN_ONSET)||EQ_16(st->clas_dec,INACTIVE_CLAS)||EQ_16(st->coder_type,GENERIC)||EQ_16(st->coder_type,TRANSITION)) { st->relax_prev_lsf_interp_fx = 1; move16(); @@ -532,7 +532,7 @@ void decoder_LPD( test(); test(); test(); - IF (st->stab_fac_fx == 0 && st->old_bfi_cnt_fx > 0 && NE_16(st->clas_dec, VOICED_CLAS)&&NE_16(st->clas_dec,ONSET)&&st->relax_prev_lsf_interp_fx==0) + IF (st->stab_fac_fx == 0 && st->old_bfi_cnt > 0 && NE_16(st->clas_dec, VOICED_CLAS)&&NE_16(st->clas_dec,ONSET)&&st->relax_prev_lsf_interp_fx==0) { st->relax_prev_lsf_interp_fx = 2; move16(); @@ -688,7 +688,7 @@ void decoder_LPD( E_LPC_f_lsp_a_conversion(lspind, Aind, M); } /* TCX decoder */ - decoder_tcx(st->hTcxCfg,prm,Aq,Aind,L_frame,L_frameTCX,st->hTcxCfg->tcx_coded_lines,&synth[0],&synthFB[0],st, st->coder_type_fx, bfi,0,st->stab_fac_fx); + decoder_tcx(st->hTcxCfg,prm,Aq,Aind,L_frame,L_frameTCX,st->hTcxCfg->tcx_coded_lines,&synth[0],&synthFB[0],st, st->coder_type, bfi,0,st->stab_fac_fx); } @@ -716,7 +716,7 @@ void decoder_LPD( IGFDecRestoreTCX10SubFrameData( st->hIGFDec, k ); decoder_tcx(st->hTcxCfg,prm,Aq,Aind,shr(L_frame, 1),shr(L_frameTCX, 1), - shr(st->hTcxCfg->tcx_coded_lines, 1),&synth[k*L_frame/2],&synthFB[k*L_frameTCX/2],st, st->coder_type_fx, bfi, k, st->stab_fac_fx ); + shr(st->hTcxCfg->tcx_coded_lines, 1),&synth[k*L_frame/2],&synthFB[k*L_frameTCX/2],st, st->coder_type, bfi, k, st->stab_fac_fx ); } } diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index d659e3277..110e09167 100644 --- a/lib_dec/dec_ace_fx.c +++ b/lib_dec/dec_ace_fx.c @@ -211,7 +211,7 @@ void decoder_acelp( * Fast recovery flag *------------------------------------------------------------------------*/ test(); - if(st->prev_bfi && EQ_16(st->coder_type_fx,VOICED)) + if(st->prev_bfi && EQ_16(st->coder_type,VOICED)) { /*Force BPF to be applied fully*/ st->bpf_gain_param=3; @@ -444,7 +444,7 @@ void decoder_acelp( { gain_pit = mult(gain_pit,sub(26214, mult(i_subfr,51))); } - ELSE IF( !st->prev_use_partial_copy && EQ_16(st->last_coder_type_fx,UNVOICED)&&NE_16(st->next_coder_type,UNVOICED)&<_32(gain_code,gain_code_pre)) + ELSE IF( !st->prev_use_partial_copy && EQ_16(st->last_coder_type,UNVOICED)&&NE_16(st->next_coder_type,UNVOICED)&<_32(gain_code,gain_code_pre)) { gain_code = 0; @@ -489,7 +489,7 @@ void decoder_acelp( L_SUBFR, #endif i_subfr, gain_pit, gain_code, code, st->voice_fac, &voice_factors[i_subfr/L_SUBFR], bwe_exc, - gain_preQ, code_preQ, st->Q_exc, T0, T0_frac, st->coder_type_fx, st->core_brate + gain_preQ, code_preQ, st->Q_exc, T0, T0_frac, st->coder_type, st->core_brate #ifdef ADD_IVAS_TBE_CODE , st->element_mode, st->idchan, st->hBWE_TD != NULL, 0 #endif @@ -500,7 +500,7 @@ void decoder_acelp( * Enhance the excitation * *---------------------------------------------------------*/ E_UTIL_enhancer( st->voice_fac, stab_fac, st->past_gcode, gain_inov, &(st->gc_threshold_fx), code, &exc2[i_subfr], - gain_pit, & st->dm_fx.prev_gain_code, st->dm_fx.prev_gain_pit, & st->dm_fx.prev_state, st->coder_type_fx, + gain_pit, & st->dm_fx.prev_gain_code, st->dm_fx.prev_gain_pit, & st->dm_fx.prev_state, st->coder_type, acelp_cfg.fixed_cdk_index[i_subfr/L_SUBFR], L_SUBFR, st->L_frame, st->Q_exc ); } /* !RF_NELP frame partial copy */ @@ -548,7 +548,7 @@ void decoder_acelp( int_lsp_fx( st->L_frame, st->old_lsp_q_cng, st->lsp_q_cng, st->Aq_cng, M, interpol_frac_fx, 0 ); p_A = st->Aq_cng; - IF(st->last_good_fx < UNVOICED_TRANSITION ) + IF(st->last_good < UNVOICED_TRANSITION ) { Copy(st->mem_syn2_fx, mem_syn, M ); } @@ -618,14 +618,14 @@ void decoder_acelp( test(); test(); test(); - IF ( (EQ_16(st->clas_dec,ONSET))||((GE_16(st->last_good_fx,VOICED_TRANSITION))&&(LT_16(st->last_good_fx,INACTIVE_CLAS)))) + IF ( (EQ_16(st->clas_dec,ONSET))||((GE_16(st->last_good,VOICED_TRANSITION))&&(LT_16(st->last_good,INACTIVE_CLAS)))) { force_scale_syn = 1; move16(); } - FEC_scale_syn_fx( st->L_frame, &update_flg,st->clas_dec, st->last_good_fx, syn, pBuf_scaleSyn, st->enr_old_fx, 0, - st->coder_type_fx, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, + FEC_scale_syn_fx( st->L_frame, &update_flg,st->clas_dec, st->last_good, syn, pBuf_scaleSyn, st->enr_old_fx, 0, + st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, exc, exc2, A, &(st->old_enr_LP), mem_back, mem_syn, st->Q_exc, st->Q_syn , avoid_lpc_burst_on_recovery , force_scale_syn); } /* update ACELP synthesis memory */ diff --git a/lib_dec/dec_acelp_tcx_main_fx.c b/lib_dec/dec_acelp_tcx_main_fx.c index 2ccef40cc..fdff3de11 100644 --- a/lib_dec/dec_acelp_tcx_main_fx.c +++ b/lib_dec/dec_acelp_tcx_main_fx.c @@ -475,7 +475,7 @@ Word16 dec_acelp_tcx_frame( test(); IF(st->core == ACELP_CORE && st->igf != 0 && st->con_tcx == 0) { - non_linearity_fx(ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type_fx, voice_factors, st->L_frame); + non_linearity_fx(ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors, st->L_frame); /* update the old BWE exe memory */ Copy(&old_bwe_exc[L_FRAME32k], hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2); } @@ -509,7 +509,7 @@ Word16 dec_acelp_tcx_frame( /* updates */ st->last_voice_factor_fx = voice_factors[st->nb_subfr-1];; move16(); - st->last_coder_type_fx = st->coder_type_fx; + st->last_coder_type = st->coder_type; } ELSE { @@ -522,7 +522,7 @@ Word16 dec_acelp_tcx_frame( /* updates */ st->last_voice_factor_fx = 0; move16(); - st->last_coder_type_fx = INACTIVE; + st->last_coder_type = INACTIVE; move16(); } diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index bc9aceb53..489aba798 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -126,7 +126,7 @@ ivas_error decod_gen_voic_fx( move16(); test(); test(); - IF( (GE_32(st_fx->core_brate, MIN_BRATE_AVQ_EXC)&&LE_32(st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD))&&EQ_16(st_fx->coder_type_fx,GENERIC)) + IF( (GE_32(st_fx->core_brate, MIN_BRATE_AVQ_EXC)&&LE_32(st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD))&&EQ_16(st_fx->coder_type,GENERIC)) { harm_flag_acelp = (Word16)get_next_indice( st_fx, 1 ); } @@ -151,7 +151,7 @@ ivas_error decod_gen_voic_fx( * Decode pitch lag *----------------------------------------------------------------------*/ - *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 0, L_frame, i_subfr_fx, st_fx->coder_type_fx, &pitch_limit_flag_fx, + *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 0, L_frame, i_subfr_fx, st_fx->coder_type, &pitch_limit_flag_fx, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_SUBFR ); move16(); /*Q6*/ @@ -172,7 +172,7 @@ ivas_error decod_gen_voic_fx( *-----------------------------------------------------------------*/ test(); - IF( GE_32(st_fx->core_brate, MIN_BRATE_AVQ_EXC)&&NE_16(st_fx->coder_type_fx,INACTIVE)) + IF( GE_32(st_fx->core_brate, MIN_BRATE_AVQ_EXC)&&NE_16(st_fx->coder_type,INACTIVE)) { gain_code_fx = 0; move16(); @@ -192,7 +192,7 @@ ivas_error decod_gen_voic_fx( IF( LE_32(st_fx->core_brate,ACELP_8k00)) { - gain_dec_lbr_fx( st_fx, st_fx->coder_type_fx, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_SUBFR); + gain_dec_lbr_fx( st_fx, st_fx->coder_type, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_SUBFR); } ELSE IF( GT_32(st_fx->core_brate,ACELP_32k)) { @@ -200,7 +200,7 @@ ivas_error decod_gen_voic_fx( } ELSE { - gain_dec_mless_fx( st_fx, L_frame, st_fx->coder_type_fx, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); + gain_dec_mless_fx( st_fx, L_frame, st_fx->coder_type, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); } st_fx->tilt_code_fx = est_tilt_fx( exc_fx+i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc ); @@ -208,7 +208,7 @@ ivas_error decod_gen_voic_fx( * Transform domain contribution decoding *-----------------------------------------------------------------*/ test(); - IF( GE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE) && EQ_16(st_fx->coder_type_fx,INACTIVE)) + IF( GE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE) && EQ_16(st_fx->coder_type,INACTIVE)) { transf_cdbk_dec_fx( st_fx, harm_flag_acelp, i_subfr_fx, Es_pred_fx, gain_code_fx, &gain_preQ_fx, &norm_gain_preQ_fx, code_preQ_fx, unbits ); } @@ -223,7 +223,7 @@ ivas_error decod_gen_voic_fx( IF ( EQ_16(L_frame,L_FRAME)) /* Rescaling for 12.8k core */ { Rescale_exc(hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[i_subfr_fx * HIBND_ACB_L_FAC], hGSCDec->last_exc_dct_in_fx, - L_SUBFR, L_SUBFR * HIBND_ACB_L_FAC, gain_code_fx, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, i_subfr_fx, st_fx->coder_type_fx ); + L_SUBFR, L_SUBFR * HIBND_ACB_L_FAC, gain_code_fx, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, i_subfr_fx, st_fx->coder_type ); } ELSE /* Rescaling for 16k core */ @@ -231,7 +231,7 @@ ivas_error decod_gen_voic_fx( L_tmp_GC = L_max(gain_code_fx, L_shl(gain_preQ_fx,16)); /* Chose the maximum of gain_code or the prequantizer excitation x4 to keep some room*/ Rescale_exc(hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[i_subfr_fx * 2], hGSCDec->last_exc_dct_in_fx, - L_SUBFR, L_SUBFR * 2, L_tmp_GC, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, i_subfr_fx, st_fx->coder_type_fx ); + L_SUBFR, L_SUBFR * 2, L_tmp_GC, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, i_subfr_fx, st_fx->coder_type ); } gain_code16 = round_fx(L_shl(gain_code_fx,st_fx->Q_exc)); /*Q_exc*/ @@ -274,7 +274,7 @@ ivas_error decod_gen_voic_fx( prep_tbe_exc_fx( L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, &voice_factors_fx[i_subfr_fx/L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, - st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type_fx, st_fx->core_brate ); + st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate ); /*----------------------------------------------------------------* @@ -282,13 +282,13 @@ ivas_error decod_gen_voic_fx( *----------------------------------------------------------------*/ test(); - IF( GT_32(st_fx->core_brate,ACELP_32k)||EQ_16(st_fx->coder_type_fx,INACTIVE)) + IF( GT_32(st_fx->core_brate,ACELP_32k)||EQ_16(st_fx->coder_type,INACTIVE)) { Copy( exc_fx+i_subfr_fx, exc2_fx+i_subfr_fx, L_SUBFR ); } ELSE { - enhancer_fx( st_fx->core_brate, 0, st_fx->coder_type_fx, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx, + enhancer_fx( st_fx->core_brate, 0, st_fx->coder_type, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx, norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &(st_fx->dm_fx), st_fx->Q_exc ); } @@ -585,7 +585,7 @@ ivas_error decod_gen_voic_ivas_fx( move16(); test(); test(); - IF((GE_32(st_fx->core_brate, MIN_BRATE_AVQ_EXC) && LE_32(st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD)) && EQ_16(st_fx->coder_type_fx, GENERIC)) + IF((GE_32(st_fx->core_brate, MIN_BRATE_AVQ_EXC) && LE_32(st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD)) && EQ_16(st_fx->coder_type, GENERIC)) { harm_flag_acelp = (Word16)get_next_indice(st_fx, 1); } @@ -610,9 +610,9 @@ ivas_error decod_gen_voic_ivas_fx( * Decode pitch lag *----------------------------------------------------------------------*/ - /**pt_pitch_fx = pit_decode_fx(st_fx, st_fx->core_brate, 0, L_frame, i_subfr_fx, st_fx->coder_type_fx, &pitch_limit_flag_fx, + /**pt_pitch_fx = pit_decode_fx(st_fx, st_fx->core_brate, 0, L_frame, i_subfr_fx, st_fx->coder_type, &pitch_limit_flag_fx, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_SUBFR);*/ - *pt_pitch_fx = pit_decode_ivas_fx(st_fx, st_fx->core_brate, 0, L_frame, i_subfr_fx, st_fx->coder_type_fx, &pitch_limit_flag_fx, + *pt_pitch_fx = pit_decode_ivas_fx(st_fx, st_fx->core_brate, 0, L_frame, i_subfr_fx, st_fx->coder_type, &pitch_limit_flag_fx, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_SUBFR, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf); move16(); /*Q6*/ @@ -634,7 +634,7 @@ ivas_error decod_gen_voic_ivas_fx( *-----------------------------------------------------------------*/ test(); - IF(GE_32(st_fx->core_brate, MIN_BRATE_AVQ_EXC) && NE_16(st_fx->coder_type_fx, INACTIVE)) + IF(GE_32(st_fx->core_brate, MIN_BRATE_AVQ_EXC) && NE_16(st_fx->coder_type, INACTIVE)) { gain_code_fx = 0; move16(); @@ -654,7 +654,7 @@ ivas_error decod_gen_voic_ivas_fx( IF(LE_32(st_fx->core_brate, ACELP_8k00)) { - gain_dec_lbr_fx(st_fx, st_fx->coder_type_fx, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_SUBFR); + gain_dec_lbr_fx(st_fx, st_fx->coder_type, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_SUBFR); } ELSE IF(GT_32(st_fx->core_brate, ACELP_32k)) { @@ -662,7 +662,7 @@ ivas_error decod_gen_voic_ivas_fx( } ELSE { - gain_dec_mless_fx(st_fx, L_frame, st_fx->coder_type_fx, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx); + gain_dec_mless_fx(st_fx, L_frame, st_fx->coder_type, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx); } st_fx->tilt_code_fx = est_tilt_ivas_fx(exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0); @@ -670,7 +670,7 @@ ivas_error decod_gen_voic_ivas_fx( * Transform domain contribution decoding *-----------------------------------------------------------------*/ test(); - IF(GE_32(st_fx->total_brate, MAX_GSC_INACTIVE_BRATE) && EQ_16(st_fx->coder_type_fx, INACTIVE)) + IF(GE_32(st_fx->total_brate, MAX_GSC_INACTIVE_BRATE) && EQ_16(st_fx->coder_type, INACTIVE)) { transf_cdbk_dec_fx(st_fx, harm_flag_acelp, i_subfr_fx, Es_pred_fx, gain_code_fx, &gain_preQ_fx, &norm_gain_preQ_fx, code_preQ_fx, unbits); } @@ -685,7 +685,7 @@ ivas_error decod_gen_voic_ivas_fx( IF(EQ_16(L_frame, L_FRAME)) /* Rescaling for 12.8k core */ { Rescale_exc(hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[i_subfr_fx * HIBND_ACB_L_FAC], hGSCDec->last_exc_dct_in_fx, - L_SUBFR, L_SUBFR * HIBND_ACB_L_FAC, gain_code_fx, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, i_subfr_fx, st_fx->coder_type_fx); + L_SUBFR, L_SUBFR * HIBND_ACB_L_FAC, gain_code_fx, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, i_subfr_fx, st_fx->coder_type); } ELSE /* Rescaling for 16k core */ @@ -693,7 +693,7 @@ ivas_error decod_gen_voic_ivas_fx( L_tmp_GC = L_max(gain_code_fx, L_shl(gain_preQ_fx,16)); /* Chose the maximum of gain_code or the prequantizer excitation x4 to keep some room*/ Rescale_exc(hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[i_subfr_fx * 2], hGSCDec->last_exc_dct_in_fx, - L_SUBFR, L_SUBFR * 2, L_tmp_GC, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, i_subfr_fx, st_fx->coder_type_fx); + L_SUBFR, L_SUBFR * 2, L_tmp_GC, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, i_subfr_fx, st_fx->coder_type); } gain_code16 = round_fx(L_shl(gain_code_fx, st_fx->Q_exc)); /*Q_exc*/ @@ -736,10 +736,10 @@ ivas_error decod_gen_voic_ivas_fx( /*prep_tbe_exc_fx(L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, - st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type_fx, st_fx->core_brate);*/ + st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate);*/ prep_tbe_exc_ivas_fx(L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, - st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type_fx, st_fx->core_brate, + st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate, st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag); @@ -748,13 +748,13 @@ ivas_error decod_gen_voic_ivas_fx( *----------------------------------------------------------------*/ test(); - IF(GT_32(st_fx->core_brate, ACELP_32k) || EQ_16(st_fx->coder_type_fx, INACTIVE)) + IF(GT_32(st_fx->core_brate, ACELP_32k) || EQ_16(st_fx->coder_type, INACTIVE)) { Copy(exc_fx + i_subfr_fx, exc2_fx + i_subfr_fx, L_SUBFR); } ELSE { - enhancer_fx(st_fx->core_brate, 0, st_fx->coder_type_fx, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx, + enhancer_fx(st_fx->core_brate, 0, st_fx->coder_type, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx, norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &(st_fx->dm_fx), st_fx->Q_exc); } diff --git a/lib_dec/dec_higher_acelp_fx.c b/lib_dec/dec_higher_acelp_fx.c index 1e41cc6f0..de01c152b 100644 --- a/lib_dec/dec_higher_acelp_fx.c +++ b/lib_dec/dec_higher_acelp_fx.c @@ -65,7 +65,7 @@ void transf_cdbk_dec_fx( index = (Word16)get_next_indice(st_fx, G_AVQ_BITS ); - IF(EQ_16(st_fx->coder_type_fx, INACTIVE)) + IF(EQ_16(st_fx->coder_type, INACTIVE)) { IF(GT_32(st_fx->core_brate, 56000)) { @@ -110,7 +110,7 @@ void transf_cdbk_dec_fx( #ifdef IVAS_CODE trgtSvPos =sub(Nsv, 1); test(); test(); test(); test(); test(); - IF (avq_bit_sFlag && GT_16(nBits, 85) && !harm_flag_acelp && (EQ_16(st_fx->coder_type_fx, GENERIC) || EQ_16(st_fx->coder_type_fx, TRANSITION) || EQ_16(st_fx->coder_type_fx, INACTIVE) )) + IF (avq_bit_sFlag && GT_16(nBits, 85) && !harm_flag_acelp && (EQ_16(st_fx->coder_type, GENERIC) || EQ_16(st_fx->coder_type, TRANSITION) || EQ_16(st_fx->coder_type, INACTIVE) )) { trgtSvPos = 2; avq_bit_sFlag = 2; @@ -146,7 +146,7 @@ void transf_cdbk_dec_fx( test(); test(); - IF( EQ_16(st_fx->coder_type_fx,INACTIVE) || GT_32(st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD)||harm_flag_acelp) + IF( EQ_16(st_fx->coder_type,INACTIVE) || GT_32(st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD)||harm_flag_acelp) { qdct = 0; move16(); @@ -158,7 +158,7 @@ void transf_cdbk_dec_fx( } #ifdef IVAS_CODE_AVQ /* TD pre-quantizer: in extreme cases at subframe boundaries, lower the preemphasis memory to avoid a saturation */ - IF (GT_16(st_fx->element_mode, EVS_MONO) && NE_16(st_fx->coder_type_fx, INACTIVE) && GE_32(st_fx->core_brate, MIN_BRATE_AVQ_EXC) && LE_32(st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD) && !harm_flag_acelp && code_preQ[0] != 0) + IF (GT_16(st_fx->element_mode, EVS_MONO) && NE_16(st_fx->coder_type, INACTIVE) && GE_32(st_fx->core_brate, MIN_BRATE_AVQ_EXC) && LE_32(st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD) && !harm_flag_acelp && code_preQ[0] != 0) { //PMT("Fixed point taking accound of the scaling needs to be done here ") IF (GT_16(abs_s(st_fx->last_code_preq), shl_sat(abs_s(code_preQ[0]),4))) diff --git a/lib_dec/dec_nelp_fx.c b/lib_dec/dec_nelp_fx.c index 7ac5ac5bb..7df109adc 100644 --- a/lib_dec/dec_nelp_fx.c +++ b/lib_dec/dec_nelp_fx.c @@ -64,7 +64,7 @@ void decod_nelp_fx( } ELSE { - coder_type = st_fx->coder_type_fx; + coder_type = st_fx->coder_type; move16(); } diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index 1d7194092..b954820ac 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -16,7 +16,7 @@ /*--------------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ /* _ (Word16*) Aq_fx : LP filter coefficient Q12 */ -/* _ (Word16) coder_type_fx : coding type Q0 */ +/* _ (Word16) coder_type : coding type Q0 */ /* _ (Word16) nb_subfr_fx :Number of subframe considered */ /* _ (Word16) Es_pred_fx :predicted scaled innov. energy */ /*--------------------------------------------------------------------------*/ @@ -34,7 +34,7 @@ void dec_pit_exc_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 coder_type_fx, /* i : coding type */ + const Word16 coder_type, /* i : coding type */ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ Word16 *code_fx, /* o : innovation */ @@ -248,7 +248,7 @@ void dec_pit_exc_fx( *----------------------------------------------------------------------*/ Rescale_exc(hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[i_subfr_fx * HIBND_ACB_L_FAC], hGSCDec->last_exc_dct_in_fx, - L_subfr_fx, L_subfr_fx * HIBND_ACB_L_FAC, gain_code_fx, &(st_fx->Q_exc), st_fx->Q_subfr, NULL, i_subfr_fx, coder_type_fx); + L_subfr_fx, L_subfr_fx * HIBND_ACB_L_FAC, gain_code_fx, &(st_fx->Q_exc), st_fx->Q_subfr, NULL, i_subfr_fx, coder_type); gain_code16 = round_fx(L_shl(gain_code_fx,st_fx->Q_exc)); /*Q_exc*/ @@ -411,7 +411,7 @@ void dec_pit_exc_fx( /*--------------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ /* _ (Word16*) Aq_fx : LP filter coefficient Q12 */ -/* _ (Word16) coder_type_fx : coding type Q0 */ +/* _ (Word16) coder_type : coding type Q0 */ /* _ (Word16) nb_subfr_fx :Number of subframe considered */ /* _ (Word16) Es_pred_fx :predicted scaled innov. energy */ /*--------------------------------------------------------------------------*/ @@ -429,7 +429,7 @@ void dec_pit_exc_fx( void dec_pit_exc_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 coder_type_fx, /* i : coding type */ + const Word16 coder_type, /* i : coding type */ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ Word16 *code_fx, /* o : innovation */ @@ -644,7 +644,7 @@ void dec_pit_exc_ivas_fx( *----------------------------------------------------------------------*/ Rescale_exc(hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[i_subfr_fx * HIBND_ACB_L_FAC], hGSCDec->last_exc_dct_in_fx, - L_subfr_fx, L_subfr_fx * HIBND_ACB_L_FAC, gain_code_fx, &(st_fx->Q_exc), st_fx->Q_subfr, NULL, i_subfr_fx, coder_type_fx); + L_subfr_fx, L_subfr_fx * HIBND_ACB_L_FAC, gain_code_fx, &(st_fx->Q_exc), st_fx->Q_subfr, NULL, i_subfr_fx, coder_type); gain_code16 = round_fx(L_shl(gain_code_fx, st_fx->Q_exc)); /*Q_exc*/ diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c index fe1f73521..ad2fa53cd 100644 --- a/lib_dec/dec_prm_fx.c +++ b/lib_dec/dec_prm_fx.c @@ -572,7 +572,7 @@ void dec_prm( { st->clas_dec = UNVOICED_TRANSITION; move16(); - if( GE_16(st->last_good_fx, VOICED_TRANSITION)) + if( GE_16(st->last_good, VOICED_TRANSITION)) { st->clas_dec = VOICED_TRANSITION; move16(); @@ -1321,7 +1321,7 @@ void dec_prm( } ELSE IF( EQ_16(ind, 1)) { - IF( GE_16(st->last_good_fx, VOICED_TRANSITION)) + IF( GE_16(st->last_good, VOICED_TRANSITION)) { st->clas_dec = VOICED_TRANSITION; move16(); diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index c06de0611..a5ff481b5 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -500,7 +500,7 @@ void decoder_tcx( } ELSE { - hTcxDec->damping = Damping_fact(coder_type, st->nbLostCmpt, st->last_good_fx, stab_fac, &(st->Mode2_lp_gainp), st->last_core); + hTcxDec->damping = Damping_fact(coder_type, st->nbLostCmpt, st->last_good, stab_fac, &(st->Mode2_lp_gainp), st->last_core); gain_tcx = hTcxDec->old_gaintcx_bfi; move16(); gain_tcx_e = hTcxDec->old_gaintcx_bfi_e; diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index f3ff2dfec..47b5c3a94 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -17,7 +17,7 @@ /* _ (Struct) st_fx : decoder static memory */ /* _ (Word16) L_frame_fx : length of the frame Q0 */ /* _ (Word16[]) Aq_fx : LP filter coefficient Q12 */ -/* _ (Word16) coder_type_fx : coding type Q12 */ +/* _ (Word16) coder_type : coding type Q12 */ /* _ (Word16) Es_pred_fx : predicted scaled innov. energy Q8 */ /* _ (Word16[]) pitch_buf_fx : floating pitch values for each subframe Q6*/ /* _ (Word16[]) voice_factors_fx: frame error rate Q15 */ @@ -147,7 +147,7 @@ void decod_tran_fx( } ELSE { - gain_dec_mless_fx( st_fx, L_frame_fx, st_fx->coder_type_fx, i_subfr, tc_subfr_fx , code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); + gain_dec_mless_fx( st_fx, L_frame_fx, st_fx->coder_type, i_subfr, tc_subfr_fx , code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); } } @@ -164,12 +164,12 @@ void decod_tran_fx( IF ( EQ_16(L_frame_fx,L_FRAME)) /* Rescaling for 12.8k core */ { Rescale_exc(hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr], &bwe_exc_fx[i_subfr * HIBND_ACB_L_FAC], hGSCDec->last_exc_dct_in_fx, - L_SUBFR, L_SUBFR * HIBND_ACB_L_FAC, gain_code_fx, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, i_subfr, st_fx->coder_type_fx ); + L_SUBFR, L_SUBFR * HIBND_ACB_L_FAC, gain_code_fx, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, i_subfr, st_fx->coder_type ); } ELSE /* Rescaling for 16k core */ { Rescale_exc(hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr], &bwe_exc_fx[i_subfr * 2], hGSCDec->last_exc_dct_in_fx, - L_SUBFR, L_SUBFR * 2, gain_code_fx, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, i_subfr,st_fx->coder_type_fx ); + L_SUBFR, L_SUBFR * 2, gain_code_fx, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, i_subfr,st_fx->coder_type ); } gain_code16 = round_fx(L_shl(gain_code_fx,st_fx->Q_exc)); /*Q_exc*/ @@ -209,7 +209,7 @@ void decod_tran_fx( prep_tbe_exc_fx( L_frame_fx, i_subfr, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, &voice_factors_fx[i_subfr/L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, - st_fx->Q_exc, T0, T0_frac, st_fx->coder_type_fx, st_fx->core_brate ); + st_fx->Q_exc, T0, T0_frac, st_fx->coder_type, st_fx->core_brate ); /*----------------------------------------------------------------* * Excitation enhancements (update of total excitation signal) @@ -221,7 +221,7 @@ void decod_tran_fx( } ELSE { - enhancer_fx( st_fx->core_brate, 0, st_fx->coder_type_fx, i_subfr, L_frame_fx, voice_fac_fx, st_fx->stab_fac_fx, + enhancer_fx( st_fx->core_brate, 0, st_fx->coder_type, i_subfr, L_frame_fx, voice_fac_fx, st_fx->stab_fac_fx, norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &(st_fx->dm_fx), st_fx->Q_exc ); } diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index 8fe4e3afa..861201dcb 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -30,7 +30,7 @@ static void gain_dec_gacelp_uv( void decod_unvoiced_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ - const Word16 coder_type_fx, /* Q0 i : coding type */ + const Word16 coder_type, /* Q0 i : coding type */ Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ Word16 *voice_factors_fx, /* Q15 o : voicing factors */ @@ -51,7 +51,7 @@ void decod_unvoiced_fx( Word16 *pt_pitch_fx; test(); - IF ( EQ_16(st_fx->last_ppp_mode_dec_fx,1)||EQ_16(st_fx->last_nelp_mode_dec_fx,1)) + IF ( EQ_16(st_fx->last_ppp_mode_dec_fx,1)||EQ_16(st_fx->last_nelp_mode_dec,1)) { /* SC_VBR - reset the decoder, to avoid memory not updated issue for this unrealistic case */ CNG_reset_dec_fx( st_fx, pitch_buf_fx, voice_factors_fx ); @@ -77,7 +77,7 @@ void decod_unvoiced_fx( * Excitation enhancements (update of total excitation signal) *----------------------------------------------------------------*/ - enhancer_fx( st_fx->core_brate, 0, coder_type_fx, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx, + enhancer_fx( st_fx->core_brate, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx, norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &(st_fx->dm_fx), st_fx->Q_exc ); voice_factors_fx[i_subfr_fx/L_SUBFR] = 0; @@ -112,7 +112,7 @@ void decod_unvoiced_ivas_fx( const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ const int16_t uc_two_stage_flag, /* i : flag indicating two-stage UC */ - const Word16 coder_type_fx, /* Q0 i : coding type */ + const Word16 coder_type, /* Q0 i : coding type */ Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ Word16 *voice_factors_fx, /* Q15 o : voicing factors */ @@ -136,7 +136,7 @@ void decod_unvoiced_ivas_fx( Word16 code2_fx[L_SUBFR]; test(); - IF(EQ_16(st_fx->last_ppp_mode_dec_fx, 1) || EQ_16(st_fx->last_nelp_mode_dec_fx, 1)) + IF(EQ_16(st_fx->last_ppp_mode_dec_fx, 1) || EQ_16(st_fx->last_nelp_mode_dec, 1)) { /* SC_VBR - reset the decoder, to avoid memory not updated issue for this unrealistic case */ CNG_reset_dec_fx(st_fx, pitch_buf_fx, voice_factors_fx); @@ -216,9 +216,9 @@ void decod_unvoiced_ivas_fx( * Excitation enhancements (update of total excitation signal) *----------------------------------------------------------------*/ - /*enhancer_fx(st_fx->core_brate, 0, coder_type_fx, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx, + /*enhancer_fx(st_fx->core_brate, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx, norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &(st_fx->dm_fx), st_fx->Q_exc);*/ - enhancer_ivas_fx(MODE1, st_fx->core_brate, uc_two_stage_flag, 0, coder_type_fx, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx, + enhancer_ivas_fx(MODE1, st_fx->core_brate, uc_two_stage_flag, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx, norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx/*Q9/Q12?*/, exc2_fx, gain_pit_fx, &(st_fx->dm_fx), st_fx->Q_exc); voice_factors_fx[i_subfr_fx / L_SUBFR] = 0; diff --git a/lib_dec/decision_matrix_dec_fx.c b/lib_dec/decision_matrix_dec_fx.c index 1eb45e6ca..51a7712f2 100644 --- a/lib_dec/decision_matrix_dec_fx.c +++ b/lib_dec/decision_matrix_dec_fx.c @@ -152,7 +152,7 @@ void decision_matrix_dec_fx( { st->ppp_mode_dec_fx = 1; move16(); - st->coder_type_fx = VOICED; + st->coder_type = VOICED; move16(); st->bwidth = NB; move16(); @@ -161,7 +161,7 @@ void decision_matrix_dec_fx( { st->ppp_mode_dec_fx = 1; move16(); - st->coder_type_fx = VOICED; + st->coder_type = VOICED; move16(); st->bwidth = WB; move16(); @@ -170,7 +170,7 @@ void decision_matrix_dec_fx( { st->nelp_mode_dec_fx = 1; move16(); - st->coder_type_fx = UNVOICED; + st->coder_type = UNVOICED; move16(); st->bwidth = NB; move16(); @@ -179,7 +179,7 @@ void decision_matrix_dec_fx( { st->nelp_mode_dec_fx = 1; move16(); - st->coder_type_fx = UNVOICED; + st->coder_type = UNVOICED; move16(); st->bwidth = WB; move16(); @@ -257,8 +257,8 @@ void decision_matrix_dec_fx( ind = acelp_sig_tbl[start_idx]; /* convert signaling indice into signaling information */ - st->coder_type_fx = extract_l(L_and(ind,0x7L)); - IF(EQ_16(st->coder_type_fx, LR_MDCT)) + st->coder_type = extract_l(L_and(ind,0x7L)); + IF(EQ_16(st->coder_type, LR_MDCT)) { st->core = HQ_CORE; move16(); @@ -293,10 +293,10 @@ void decision_matrix_dec_fx( ( GE_32(ind,1<<7) ) || ( LE_32(st->total_brate,ACELP_13k20) && EQ_16(st->bwidth,FB) ) || ( GE_32(st->total_brate,ACELP_32k) && EQ_16(st->bwidth,NB) ) || - ( GE_32(st->total_brate,ACELP_32k) && !(EQ_16(st->coder_type_fx,GENERIC) || EQ_16(st->coder_type_fx,TRANSITION) || EQ_16(st->coder_type_fx,INACTIVE) ) ) || - ( LT_32(st->total_brate,ACELP_13k20) && NE_16(st->bwidth,NB) && EQ_16(st->coder_type_fx,LR_MDCT) ) || - ( GE_32(st->total_brate,ACELP_13k20) && EQ_16(st->coder_type_fx,UNVOICED) ) || - ( GE_32(st->total_brate,ACELP_13k20) && EQ_16(st->coder_type_fx,AUDIO) && EQ_16(st->bwidth,NB) ) + ( GE_32(st->total_brate,ACELP_32k) && !(EQ_16(st->coder_type,GENERIC) || EQ_16(st->coder_type,TRANSITION) || EQ_16(st->coder_type,INACTIVE) ) ) || + ( LT_32(st->total_brate,ACELP_13k20) && NE_16(st->bwidth,NB) && EQ_16(st->coder_type,LR_MDCT) ) || + ( GE_32(st->total_brate,ACELP_13k20) && EQ_16(st->coder_type,UNVOICED) ) || + ( GE_32(st->total_brate,ACELP_13k20) && EQ_16(st->coder_type,AUDIO) && EQ_16(st->bwidth,NB) ) ) { st->BER_detect = 0; @@ -317,7 +317,7 @@ void decision_matrix_dec_fx( } ELSE IF( EQ_32(st->last_total_brate, -1)) /* can happen in case of BER when no good frame was received before */ { - st->coder_type_fx = st->last_coder_type_fx; + st->coder_type = st->last_coder_type; move16(); st->bwidth = st->last_bwidth; move16(); @@ -354,7 +354,7 @@ void decision_matrix_dec_fx( } ELSE { - st->coder_type_fx = st->last_coder_type_fx; + st->coder_type = st->last_coder_type; move16(); st->bwidth = st->last_bwidth; move16(); @@ -652,7 +652,7 @@ void decision_matrix_dec_fx( st->L_frame = st->last_L_frame; move16(); } - ELSE IF( EQ_32(st->core_brate,SID_2k40)&&EQ_16(st->bwidth,WB)&&st->first_CNG&<_16(st->hTdCngDec->act_cnt2_fx,MIN_ACT_CNG_UPD)) + ELSE IF( EQ_32(st->core_brate,SID_2k40)&&EQ_16(st->bwidth,WB)&&st->first_CNG&<_16(st->hTdCngDec->act_cnt2,MIN_ACT_CNG_UPD)) { /* prevent "L_frame" changes in SID frame after short segment of active frames */ st->L_frame = st->last_CNG_L_frame; diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index bc7c27a2f..b51e8268d 100644 --- a/lib_dec/er_dec_acelp_fx.c +++ b/lib_dec/er_dec_acelp_fx.c @@ -138,7 +138,7 @@ void con_acelp( move16(); } - pitch_pred_linear_fit(st->nbLostCmpt, st->last_good_fx, + pitch_pred_linear_fit(st->nbLostCmpt, st->last_good, st->old_pitch_buf_fx, &st->old_fpitch, &predPitchLag, st->pit_min, st->pit_max, st->mem_pitch_gain, 0, @@ -184,7 +184,7 @@ void con_acelp( /* PLC: [ACELP: Fade-out] * PLC: calculate damping factor */ - alpha = Damping_fact(coder_type, st->nbLostCmpt, st->last_good_fx, stab_fac, &(st->Mode2_lp_gainp), 0); /*Q14*/ + alpha = Damping_fact(coder_type, st->nbLostCmpt, st->last_good, stab_fac, &(st->Mode2_lp_gainp), 0); /*Q14*/ st->cummulative_damping = shl(mult(st->cummulative_damping,alpha),1);/*shl(Q15*Q14,1)=shl(Q14,1) = Q15*/ if (EQ_16(st->nbLostCmpt,1)) { @@ -196,7 +196,7 @@ void con_acelp( * PLC: Construct the harmonic part of excitation *-----------------------------------------------------------------*/ - IF( GE_16(st->last_good_fx , UNVOICED_TRANSITION )) + IF( GE_16(st->last_good , UNVOICED_TRANSITION )) { /*---------------------------------------------------------------* @@ -373,7 +373,7 @@ void con_acelp( test(); test();/*test();*/ - IF (LE_16(st->last_good_fx , UNVOICED_TRANSITION) + IF (LE_16(st->last_good , UNVOICED_TRANSITION) && (EQ_16(coder_type , GENERIC ) ) && GT_32(pc , 6*2*32768/*6(15Q16)*/ ) /*&& (stab_fac <= 0.5f)*/ ) @@ -580,13 +580,13 @@ void con_acelp( s_16 = BASOP_Util_Add_MantExp(tmp_16,s_16,tmp2,s2,&tmp_16); st->Mode2_lp_gainc = L_shl(L_deposit_l(tmp_16),add(s_16,1)); test(); - IF( (EQ_16(st->last_good_fx, UNVOICED_TRANSITION))&&(EQ_16(coder_type,GENERIC))) + IF( (EQ_16(st->last_good, UNVOICED_TRANSITION))&&(EQ_16(coder_type,GENERIC))) { st->Mode2_lp_gainc = L_deposit_h(gainCNG);/*Q21*/ st->Mode2_lp_gainc = L_shr(st->Mode2_lp_gainc,sub(5,gainCNG_e)); /*15Q16, no scaling*/ } - highPassFiltering(st->last_good_fx, add(st->L_frame,shr(l_fir_fer,1)), noise_buf, hp_filt, l_fir_fer); + highPassFiltering(st->last_good, add(st->L_frame,shr(l_fir_fer,1)), noise_buf, hp_filt, l_fir_fer); pt_exc = noise_buf + l_fir_fer/2; @@ -628,12 +628,12 @@ void con_acelp( step_32 = L_shr(step_32, 7); /* 15Q16 */ test(); - if ((EQ_16(st->last_good_fx ,UNVOICED_CLAS))&&(NE_16(coder_type,UNVOICED))) /* Attenuate somewhat on unstable unvoiced */ + if ((EQ_16(st->last_good ,UNVOICED_CLAS))&&(NE_16(coder_type,UNVOICED))) /* Attenuate somewhat on unstable unvoiced */ { gain_inov = mult_r(gain_inov, 26214/*0.8f Q15*/); /*Q15 * 2^s_gain_inov*/ } - IF ( GE_16(st->last_good_fx , UNVOICED_TRANSITION)) + IF ( GE_16(st->last_good , UNVOICED_TRANSITION)) { Word16 tilt_code; @@ -697,7 +697,7 @@ void con_acelp( * PLC: Construct the total excitation *-----------------------------------------------------------------*/ - IF( st->last_good_fx < UNVOICED_TRANSITION ) + IF( st->last_good < UNVOICED_TRANSITION ) { bufferCopyFx(noise_buf+l_fir_fer/2, exc, add(st->L_frame,shr(st->L_frame,1)), 0, *Qf_exc, negate(g_e), 0); /*copy between different formats*/ Copy(harmonic_exc_buf+st->L_frame, st->old_exc_fx, L_EXC_MEM_DEC); @@ -710,7 +710,7 @@ void con_acelp( } /* Compute total excitation in noisebuffer to save memories */ - IF( GE_16( st->last_good_fx, UNVOICED_TRANSITION )) + IF( GE_16( st->last_good, UNVOICED_TRANSITION )) { Vr_add(exc, exc_unv, noise_buf, add(st->L_frame, 1)); } @@ -741,7 +741,7 @@ void con_acelp( IF (EQ_16(st->nbLostCmpt,1)) { - IF( st->last_good_fx < UNVOICED_TRANSITION ) + IF( st->last_good < UNVOICED_TRANSITION ) { Copy(st->mem_syn2_fx, mem_syn_unv, M ); } @@ -756,7 +756,7 @@ void con_acelp( } /* voiced synth */ - IF(st->last_good_fx >= UNVOICED_TRANSITION) + IF(st->last_good >= UNVOICED_TRANSITION) { p_A = A; FOR (i_subfr = 0; i_subfr < st->L_frame; i_subfr += L_SUBFR) @@ -915,7 +915,7 @@ void con_acelp( } Copy(mem_syn_unv,st->mem_syn_unv_back,M); - IF(LT_16(st->last_good_fx,UNVOICED_TRANSITION)) + IF(LT_16(st->last_good,UNVOICED_TRANSITION)) { Copy(mem_syn_unv,mem_syn,M); /* unvoiced for ola */ @@ -927,7 +927,7 @@ void con_acelp( { /*scale back mem_syn_unv, exc_unv and synthesis*/ Scale_sig(mem_syn_unv,M,negate(s_16)); - IF(LT_16(st->last_good_fx,UNVOICED_TRANSITION)) + IF(LT_16(st->last_good,UNVOICED_TRANSITION)) { Scale_sig(mem_syn,M,negate(s_16)); Scale_sig(syn_unv, add(shr(st->L_frame,1),st->L_frame) ,negate(s_16)); @@ -943,7 +943,7 @@ void con_acelp( } /* add separate synthesis buffers */ - IF (GE_16(st->last_good_fx,UNVOICED_TRANSITION)) + IF (GE_16(st->last_good,UNVOICED_TRANSITION)) { FOR( i=0 ; i < st->L_frame; i++ ) { @@ -1000,7 +1000,7 @@ void con_acelp( Copy32(pitch_buf, &st->old_pitch_buf_fx[st->nb_subfr], st->nb_subfr); /*updating enr_old parameters*/ - frame_ener_fx( st->L_frame, st->last_good_fx, syn, round_fx(tmp_tc), &(st->enr_old_fx), 1, 0, 0, 0 ); + frame_ener_fx( st->L_frame, st->last_good, syn, round_fx(tmp_tc), &(st->enr_old_fx), 1, 0, 0, 0 ); st->enr_old_fx = L_shl(st->enr_old_fx,shl(negate(Qf_syn),1)); diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 9ea6d2082..ca81d2706 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -285,7 +285,7 @@ void con_tcx( Copy(st->old_Aq_12_8_fx, A_local, M+1); offset = shr(L_frame,1); - IF(GE_16(st->last_good_fx, UNVOICED_TRANSITION)) + IF(GE_16(st->last_good, UNVOICED_TRANSITION)) { tmp16 = s_max(Tc - shr(L_frame,1), 0); Copy_Scale_sig(hTcxDec->old_excFB_fx, &(exc[-tmp16]), offset+tmp16, Q_exc-st->Q_exc); @@ -301,7 +301,7 @@ void con_tcx( test(); test(); - IF( GT_16(st->last_good_fx, UNVOICED_CLAS)&&!(EQ_16(st->last_good_fx,UNVOICED_TRANSITION)&&EQ_16(st->core_ext_mode,GENERIC))) + IF( GT_16(st->last_good, UNVOICED_CLAS)&&!(EQ_16(st->last_good,UNVOICED_TRANSITION)&&EQ_16(st->core_ext_mode,GENERIC))) { IF ( EQ_16(st->nbLostCmpt,1)|| hTcxDec->tcxConceal_recalc_exc) @@ -347,7 +347,7 @@ void con_tcx( pitch_pred_linear_fit( st->nbLostCmpt, - st->last_good_fx, + st->last_good, old_pitch_buf, &(st->old_fpitchFB), &predPitchLag, @@ -517,7 +517,7 @@ void con_tcx( alpha = Damping_fact(st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &(st->lp_gainp), 0); } #else - alpha = Damping_fact(st->core_ext_mode, st->nbLostCmpt, st->last_good_fx, st->stab_fac_fx, &(st->Mode2_lp_gainp), 0);/*Q14*/ + alpha = Damping_fact(st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac_fx, &(st->Mode2_lp_gainp), 0);/*Q14*/ #endif IF ( EQ_16(st->nbLostCmpt , 1)) { @@ -601,7 +601,7 @@ void con_tcx( alpha = Damping_fact(st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &(st->lp_gainp), 0); } #else - alpha = Damping_fact(st->core_ext_mode, st->nbLostCmpt, st->last_good_fx, st->stab_fac_fx, &(st->Mode2_lp_gainp), 0);/*Q14*/ + alpha = Damping_fact(st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac_fx, &(st->Mode2_lp_gainp), 0);/*Q14*/ #endif } @@ -670,7 +670,7 @@ void con_tcx( } } test(); - IF (EQ_16(st->last_good_fx , VOICED_CLAS)||EQ_16(st->last_good_fx,ONSET)) + IF (EQ_16(st->last_good , VOICED_CLAS)||EQ_16(st->last_good,ONSET)) { tmp16 = 19661/*0.6f Q15*/; move16(); @@ -703,11 +703,11 @@ void con_tcx( } IF ( EQ_16(st->nbLostCmpt,1)) { - highPassFiltering(st->last_good_fx, add(add(L_frame, shr(L_frame,1)),L_FIR_FER2), noise, hp_filt, L_FIR_FER2); + highPassFiltering(st->last_good, add(add(L_frame, shr(L_frame,1)),L_FIR_FER2), noise, hp_filt, L_FIR_FER2); } ELSE { - IF(GT_16( st->last_good_fx , UNVOICED_TRANSITION)) + IF(GT_16( st->last_good , UNVOICED_TRANSITION)) { tmp_loop = add(add(L_frame,shr(L_frame,1)),L_FIR_FER2); gain_tmp = negate(add(-32768,st->cummulative_damping));/*Q15*/ @@ -811,11 +811,11 @@ void con_tcx( move16(); test(); test(); - IF (EQ_16(st->last_good_fx , UNVOICED_CLAS)&&NE_16(st->core_ext_mode,UNVOICED)) + IF (EQ_16(st->last_good , UNVOICED_CLAS)&&NE_16(st->core_ext_mode,UNVOICED)) { gain_inov = mult_r(gain_inov,26214/*0.8f Q15*/); } - ELSE IF (!( EQ_16(st->last_good_fx , UNVOICED_CLAS)||EQ_16(st->last_good_fx,UNVOICED_TRANSITION))) + ELSE IF (!( EQ_16(st->last_good , UNVOICED_CLAS)||EQ_16(st->last_good,UNVOICED_TRANSITION))) { /*gain_inov *= (1.1f- 0.75*st->lp_gainp);*/ L_tmp = Mpy_32_16_1(L_sub(590558016l/*1.1f Q29*/, Mpy_32_16_1(st->Mode2_lp_gainp,24576))/*Q29*/,gain_inov/*Q15,gain_inov_e*/);/*Q29,gain_inov_e*/ @@ -864,7 +864,7 @@ void con_tcx( * Construct the total excitation *-----------------------------------------------------------------*/ - IF( GE_16(st->last_good_fx , UNVOICED_TRANSITION)) + IF( GE_16(st->last_good , UNVOICED_TRANSITION)) { tmp16 = add(L_frame,shr(L_frame,1)); FOR( i=0 ; i< tmp16; i++ ) diff --git a/lib_dec/er_util_fx.c b/lib_dec/er_util_fx.c index 43270dcde..34968d8f7 100644 --- a/lib_dec/er_util_fx.c +++ b/lib_dec/er_util_fx.c @@ -471,7 +471,7 @@ Word16 GetPLCModeDecision_ivas_fx( IF ((GT_16(numIndices,10)) || ((GT_16(numIndices,5) ) && (LT_32(L_abs(L_sub(hTcxDec->tcxltp_third_last_pitch, hTcxDec->tcxltp_second_last_pitch)),32768l/*0.5f Q16*/) )) - || ((numIndices > 0) && ((LE_16(st->last_good_fx,UNVOICED_TRANSITION))||(LE_16(hTcxDec->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/))) + || ((numIndices > 0) && ((LE_16(st->last_good,UNVOICED_TRANSITION))||(LE_16(hTcxDec->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/))) && (LT_32(L_abs(L_sub(hTcxDec->tcxltp_third_last_pitch, hTcxDec->tcxltp_second_last_pitch)),32768l/*0.5f Q16*/) ))) { core = TCX_20_CORE; @@ -479,7 +479,7 @@ Word16 GetPLCModeDecision_ivas_fx( st->tonal_mdct_plc_active = 1; move16(); } - ELSE IF (LE_16(st->last_good_fx,UNVOICED_TRANSITION)||LE_16(hTcxDec->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/)) + ELSE IF (LE_16(st->last_good,UNVOICED_TRANSITION)||LE_16(hTcxDec->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/)) { core = TCX_20_CORE; move16(); @@ -488,7 +488,7 @@ Word16 GetPLCModeDecision_ivas_fx( ELSE IF (st->last_core != ACELP_CORE) { test(); - if (LE_16(st->last_good_fx,UNVOICED_TRANSITION)||LE_16(hTcxDec->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/)) + if (LE_16(st->last_good,UNVOICED_TRANSITION)||LE_16(hTcxDec->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/)) { core = st->last_core; move16(); @@ -613,7 +613,7 @@ Word16 GetPLCModeDecision( IF ((GT_16(numIndices,10)) || ((GT_16(numIndices,5) ) && (LT_32(L_abs(L_sub(hTcxDec->tcxltp_third_last_pitch, hTcxDec->tcxltp_second_last_pitch)),32768l/*0.5f Q16*/) )) - || ((numIndices > 0) && ((LE_16(st->last_good_fx,UNVOICED_TRANSITION))||(LE_16(hTcxDec->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/))) + || ((numIndices > 0) && ((LE_16(st->last_good,UNVOICED_TRANSITION))||(LE_16(hTcxDec->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/))) && (LT_32(L_abs(L_sub(hTcxDec->tcxltp_third_last_pitch, hTcxDec->tcxltp_second_last_pitch)),32768l/*0.5f Q16*/) ))) { core = TCX_20_CORE; @@ -621,7 +621,7 @@ Word16 GetPLCModeDecision( st->tonal_mdct_plc_active = 1; move16(); } - ELSE IF (LE_16(st->last_good_fx,UNVOICED_TRANSITION)||LE_16(hTcxDec->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/)) + ELSE IF (LE_16(st->last_good,UNVOICED_TRANSITION)||LE_16(hTcxDec->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/)) { core = TCX_20_CORE; move16(); @@ -630,7 +630,7 @@ Word16 GetPLCModeDecision( ELSE IF (st->last_core != ACELP_CORE) { test(); - if (LE_16(st->last_good_fx,UNVOICED_TRANSITION)||LE_16(hTcxDec->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/)) + if (LE_16(st->last_good,UNVOICED_TRANSITION)||LE_16(hTcxDec->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/)) { core = st->last_core; move16(); diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c index 744daf9a5..2499d03c1 100644 --- a/lib_dec/evs_dec.c +++ b/lib_dec/evs_dec.c @@ -44,6 +44,7 @@ #ifdef IVAS_FLOAT_FIXED #include "prot_fx1.h" #include "prot_fx2.h" +#include "ivas_prot_fx.h" #endif #ifdef IVAS_FLOAT_FIXED diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 5f178a044..298d7886a 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -127,16 +127,16 @@ ivas_error evs_dec_fx( IF( EQ_16(st_fx->bfi,1)) { - hq_core_type = hHQ_core->last_hq_core_type_fx; + hq_core_type = hHQ_core->last_hq_core_type; move16(); - st_fx->coder_type_fx = st_fx->last_coder_type_fx; + st_fx->coder_type = st_fx->last_coder_type; move16(); } ELSE { hq_core_type = -1; move16(); - st_fx->coder_type_fx = INACTIVE; + st_fx->coder_type = INACTIVE; move16(); } @@ -215,7 +215,7 @@ ivas_error evs_dec_fx( IF( NE_16(frameMode,FRAMEMODE_MISSING)) /* frame mode normal or future frame */ { - getPartialCopyInfo(st_fx, &st_fx->coder_type_fx, &sharpFlag); + getPartialCopyInfo(st_fx, &st_fx->coder_type, &sharpFlag); frameMode = st_fx->bfi; } @@ -379,9 +379,9 @@ ivas_error evs_dec_fx( IF ( EQ_16(st_fx->extl,WB_TBE)) { /* WB TBE decoder */ - wb_tbe_dec_fx( st_fx, st_fx->coder_type_fx, bwe_exc_extended_fx, st_fx->Q_exc, voice_factors_fx, hb_synth_fx, &hb_synth_fx_exp ); + wb_tbe_dec_fx( st_fx, st_fx->coder_type, bwe_exc_extended_fx, st_fx->Q_exc, voice_factors_fx, hb_synth_fx, &hb_synth_fx_exp ); } - ELSE IF ( EQ_16(st_fx->extl,WB_BWE)&&st_fx->bws_cnt_fx==0) + ELSE IF ( EQ_16(st_fx->extl,WB_BWE)&&st_fx->bws_cnt==0) { /* WB BWE decoder */ hb_synth_fx_exp = wb_bwe_dec_fx( @@ -412,11 +412,11 @@ ivas_error evs_dec_fx( test(); test(); IF ( EQ_16(st_fx->extl,SWB_TBE)||EQ_16(st_fx->extl,FB_TBE) - || (NE_16(st_fx->coder_type_fx,AUDIO) && NE_16(st_fx->coder_type_fx,INACTIVE) && GT_32(st_fx->core_brate,SID_2k40) && EQ_16(st_fx->core,ACELP_CORE) - && GE_32(st_fx->output_Fs,32000) && GT_16(st_fx->bwidth,NB) && st_fx->bws_cnt_fx > 0 && !st_fx->ppp_mode_dec_fx + || (NE_16(st_fx->coder_type,AUDIO) && NE_16(st_fx->coder_type,INACTIVE) && GT_32(st_fx->core_brate,SID_2k40) && EQ_16(st_fx->core,ACELP_CORE) + && GE_32(st_fx->output_Fs,32000) && GT_16(st_fx->bwidth,NB) && st_fx->bws_cnt > 0 && !st_fx->ppp_mode_dec_fx && !( EQ_16( st_fx->nelp_mode_dec_fx, 1) && EQ_16( st_fx->bfi, 1) ) ) ) { - swb_tbe_dec_fx( st_fx, st_fx->coder_type_fx, bwe_exc_extended_fx, st_fx->Q_exc, voice_factors_fx, + swb_tbe_dec_fx( st_fx, st_fx->coder_type, bwe_exc_extended_fx, st_fx->Q_exc, voice_factors_fx, old_syn_12k8_16k_fx, fb_exc_fx, &Q_fb_exc, hb_synth_fx, &hb_synth_fx_exp, pitch_buf_fx ); /* FB TBE decoder/synthesis */ test(); @@ -426,7 +426,7 @@ ivas_error evs_dec_fx( } } ELSE IF( EQ_16(st_fx->extl,SWB_BWE)||EQ_16(st_fx->extl,FB_BWE)|| - (GE_32(st_fx->output_Fs,32000) && EQ_16(st_fx->core,ACELP_CORE) && GT_16(st_fx->bwidth,NB) && st_fx->bws_cnt_fx > 0 && !st_fx->ppp_mode_dec_fx + (GE_32(st_fx->output_Fs,32000) && EQ_16(st_fx->core,ACELP_CORE) && GT_16(st_fx->bwidth,NB) && st_fx->bws_cnt > 0 && !st_fx->ppp_mode_dec_fx && !( EQ_16( st_fx->nelp_mode_dec_fx, 1) && EQ_16( st_fx->bfi, 1) ) ) ) { /* SWB BWE decoder */ @@ -486,7 +486,7 @@ ivas_error evs_dec_fx( swb_CNG_dec_fx( st_fx, synth_fx, hb_synth_fx, sid_bw, Qpostd ); test(); - if( LE_32(st_fx->core_brate, SID_2k40)&&st_fx->bws_cnt_fx==0) + if( LE_32(st_fx->core_brate, SID_2k40)&&st_fx->bws_cnt==0) { hb_synth_fx_exp = 3; move16(); @@ -569,7 +569,7 @@ ivas_error evs_dec_fx( test(); test(); - IF ( NE_16(st_fx->extl,-1)||(st_fx->bws_cnt_fx>0&&EQ_16(st_fx->core,ACELP_CORE))) + IF ( NE_16(st_fx->extl,-1)||(st_fx->bws_cnt>0&&EQ_16(st_fx->core,ACELP_CORE))) { /* Calculate an additional delay of extension layer components to be synchronized with ACELP synthesis */ IF ( EQ_16(st_fx->L_frame,L_FRAME)) @@ -676,7 +676,7 @@ ivas_error evs_dec_fx( test(); test(); test(); - IF( ( st_fx->ppp_mode_dec_fx || (EQ_16(st_fx->nelp_mode_dec_fx,1)&&EQ_16(st_fx->bfi,1)))&&EQ_16(st_fx->L_frame,st_fx->last_L_frame)&&(st_fx->bws_cnt_fx>1||st_fx->last_extl!=-1)) + IF( ( st_fx->ppp_mode_dec_fx || (EQ_16(st_fx->nelp_mode_dec_fx,1)&&EQ_16(st_fx->bfi,1)))&&EQ_16(st_fx->L_frame,st_fx->last_L_frame)&&(st_fx->bws_cnt>1||st_fx->last_extl!=-1)) { Copy(hBWE_TD->old_hb_synth_fx, hb_synth_fx, output_frame ); @@ -871,7 +871,7 @@ ivas_error evs_dec_fx( st_fx->core_brate = L_sub(st_fx->total_brate, st_fx->extl_brate); - st_fx->bws_cnt_fx = 0; + st_fx->bws_cnt = 0; move16(); st_fx->bws_cnt1_fx = 0; move16(); @@ -887,12 +887,12 @@ ivas_error evs_dec_fx( test(); IF( EQ_16(st_fx->extl, WB_TBE)) { - wb_tbe_dec_fx( st_fx, st_fx->coder_type_fx, bwe_exc_extended_fx, st_fx->Q_exc, voice_factors_fx, hb_synth_fx, &hb_synth_fx_exp ); + wb_tbe_dec_fx( st_fx, st_fx->coder_type, bwe_exc_extended_fx, st_fx->Q_exc, voice_factors_fx, hb_synth_fx, &hb_synth_fx_exp ); } ELSE IF( EQ_16(st_fx->extl, SWB_TBE)||EQ_16(st_fx->extl,FB_TBE)) { /* SWB TBE decoder */ - swb_tbe_dec_fx( st_fx, st_fx->coder_type_fx, bwe_exc_extended_fx, st_fx->Q_exc, voice_factors_fx, hBWE_TD->old_core_synth_fx, + swb_tbe_dec_fx( st_fx, st_fx->coder_type, bwe_exc_extended_fx, st_fx->Q_exc, voice_factors_fx, hBWE_TD->old_core_synth_fx, fb_exc_fx, &Q_fb_exc, hb_synth_fx, &hb_synth_fx_exp, pitch_buf_fx ); test(); IF( EQ_16(st_fx->extl, FB_TBE)&&EQ_16(output_frame,L_FRAME48k)) @@ -1014,7 +1014,7 @@ ivas_error evs_dec_fx( test(); test(); IF( st_fx->flag_cna == 0 && EQ_16(st_fx->L_frame,L_FRAME16k)&&EQ_16(st_fx->last_flag_cna,1) - && ( (st_fx->last_core == ACELP_CORE && NE_16(st_fx->last_coder_type_fx,AUDIO) ) || EQ_16(st_fx->last_core,TCX_20_CORE) || EQ_16(st_fx->last_core,AMR_WB_CORE) ) ) + && ( (st_fx->last_core == ACELP_CORE && NE_16(st_fx->last_coder_type,AUDIO) ) || EQ_16(st_fx->last_core,TCX_20_CORE) || EQ_16(st_fx->last_core,AMR_WB_CORE) ) ) { FOR (i=0; i < st_fx->L_frame/2; i++) { @@ -1044,13 +1044,13 @@ ivas_error evs_dec_fx( Copy( st_fx->hFdCngDec->hFdCngCom->timeDomainBuffer, timeDomainBuffer, st_fx->L_frame ); Copy( st_fx->hFdCngDec->hFdCngCom->A_cng, A, M+1 ); - update_decoder_LPD_cng( st_fx, st_fx->coder_type_fx, timeDomainBuffer, A, st_fx->p_bpf_noise_buf ); + update_decoder_LPD_cng( st_fx, st_fx->coder_type, timeDomainBuffer, A, st_fx->p_bpf_noise_buf ); /* Generate additional comfort noise to mask potential coding artefacts */ IF( st_fx->flag_cna ) { generate_masking_noise( timeDomainBuffer, 0, st_fx->hFdCngDec->hFdCngCom, st_fx->hFdCngDec->hFdCngCom->frameSize, 0 ); } - ELSE IF( EQ_16(st_fx->L_frame,L_FRAME16k)&&EQ_16(st_fx->last_flag_cna,1)&&((EQ_16(st_fx->last_core,ACELP_CORE)&&NE_16(st_fx->last_coder_type_fx,AUDIO))||EQ_16(st_fx->last_core,TCX_20_CORE)||EQ_16(st_fx->last_core,AMR_WB_CORE))) + ELSE IF( EQ_16(st_fx->L_frame,L_FRAME16k)&&EQ_16(st_fx->last_flag_cna,1)&&((EQ_16(st_fx->last_core,ACELP_CORE)&&NE_16(st_fx->last_coder_type,AUDIO))||EQ_16(st_fx->last_core,TCX_20_CORE)||EQ_16(st_fx->last_core,AMR_WB_CORE))) { FOR( i=0; i < st_fx->L_frame/2; i++ ) { diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index ae2980894..5ce86f952 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -341,7 +341,7 @@ void gain_dec_tc_ivas_fx( /* INPUT ARGUMENTS : */ /* _ (Word32) core_brate_fx : core bitrate */ /* _ (Word16) L_frame_fx : length of the frame */ -/* _ (Word16) coder_type_fx : coding type */ +/* _ (Word16) coder_type : coding type */ /* _ (Word16) i_subfr_fx : subframe index */ /* _ (Word16) tc_subfr_fx : TC subframe index */ /* _ (Word16*[]) code_fx : algebraic code excitation (Q12) */ @@ -365,7 +365,7 @@ void gain_dec_tc_ivas_fx( void gain_dec_mless_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 coder_type_fx, /* i : coding type */ + const Word16 coder_type, /* i : coding type */ const Word16 i_subfr_fx, /* i : subframe number */ const Word16 tc_subfr_fx, /* i : TC subframe index */ const Word16 *code_fx, /* i : algebraic code excitation */ @@ -497,7 +497,7 @@ void gain_dec_mless_fx( } test(); - if( EQ_16(coder_type_fx,INACTIVE)&&EQ_16(nBits,6)) + if( EQ_16(coder_type,INACTIVE)&&EQ_16(nBits,6)) { nBits = sub(nBits, 1); } diff --git a/lib_dec/gs_dec_amr_wb_fx.c b/lib_dec/gs_dec_amr_wb_fx.c index 69f37c2d3..2f709cb84 100644 --- a/lib_dec/gs_dec_amr_wb_fx.c +++ b/lib_dec/gs_dec_amr_wb_fx.c @@ -397,7 +397,7 @@ void improv_amr_wb_gs_fx( const Word16 *pitch_buf_fx, /* i : Decoded pitch buffer Q6 */ const Word16 Last_ener_fx, /* i : Last energy (Q8) */ const Word16 rate_switching_reset, /* i : rate switching reset flag */ - const Word16 last_coder_type_fx /* i : Last coder_type */ + const Word16 last_coder_type /* i : Last coder_type */ #ifdef ADD_IVAS_GS_DEC_IMPR ,const Word16 VeryLowRateSTflag /* i : Enable the noise enhancement for very low rate stereo generic mode */ #endif @@ -440,11 +440,11 @@ void improv_amr_wb_gs_fx( * LP filter smoothing for inactive parts *------------------------------------------------------------*/ *seed_tcx = extract_l(L_mult0(pitch_buf_fx[0],pitch_buf_fx[3])); - /* last_coder_type_fx == UNVOICED should be understand as INACTIVE, but it is forced to UNVOICED in update_dec */ + /* last_coder_type == UNVOICED should be understand as INACTIVE, but it is forced to UNVOICED in update_dec */ test(); test(); test(); - IF( EQ_16(coder_type, INACTIVE)&>_16(Last_ener_fx,-3*256)&&EQ_16(last_coder_type_fx,UNVOICED)&&rate_switching_reset==0) /* 3.0 x 256 to Go to Q8 */ + IF( EQ_16(coder_type, INACTIVE)&>_16(Last_ener_fx,-3*256)&&EQ_16(last_coder_type,UNVOICED)&&rate_switching_reset==0) /* 3.0 x 256 to Go to Q8 */ { FOR(i =0; i < NB_SUBFR; i++) diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index 73d726591..5ff8ae1e9 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -75,7 +75,7 @@ void decod_audio_fx( /* decode GSC SWB speech flag */ test(); #if !defined ADD_LRTD - IF( NE_16(st_fx->coder_type_fx,INACTIVE)&&GE_32(st_fx->total_brate,ACELP_13k20)) + IF( NE_16(st_fx->coder_type,INACTIVE)&&GE_32(st_fx->total_brate,ACELP_13k20)) #else if (st_fx->GSC_IVAS_mode >= 1 || (st_fx->coder_type != INACTIVE && ((st_fx->element_mode == EVS_MONO && st_fx->total_brate >= ACELP_13k20) || (st_fx->element_mode > EVS_MONO && st_fx->total_brate > MIN_BRATE_GSC_NOISY_FLAG && st_fx->bwidth >= SWB && !st_fx->flag_ACELP16k)))) @@ -95,9 +95,9 @@ void decod_audio_fx( } /* set bit-allocation */ #ifdef ADD_LRTD - config_acelp1(DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech_fx, &(st_fx->acelp_cfg), st_fx->next_bit_pos, st_fx->coder_type_fx, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode); + config_acelp1(DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech_fx, &(st_fx->acelp_cfg), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode); #else - config_acelp1(DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech_fx, &(st_fx->acelp_cfg), st_fx->next_bit_pos, st_fx->coder_type_fx, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode); + config_acelp1(DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech_fx, &(st_fx->acelp_cfg), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode); #endif /*---------------------------------------------------------------* * Decode energy dynamics @@ -211,7 +211,7 @@ void decod_audio_fx( nbits = 3; move16(); test(); - if( LT_32(st_fx->core_brate,ACELP_9k60)&&(EQ_16(st_fx->coder_type_fx,INACTIVE))) + if( LT_32(st_fx->core_brate,ACELP_9k60)&&(EQ_16(st_fx->coder_type,INACTIVE))) { nbits = 1; move16(); @@ -223,7 +223,7 @@ void decod_audio_fx( move16(); } test(); - IF( LT_32(st_fx->core_brate,ACELP_9k60)&&NE_16(st_fx->coder_type_fx,INACTIVE)) + IF( LT_32(st_fx->core_brate,ACELP_9k60)&&NE_16(st_fx->coder_type,INACTIVE)) { pit_band_idx = 1; move16(); @@ -294,7 +294,7 @@ void decod_audio_fx( #ifdef ADD_LRTD dec_pit_exc_fx(st_fx, Aq, coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf); #else - dec_pit_exc_fx(st_fx, Aq, st_fx->coder_type_fx, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf); + dec_pit_exc_fx(st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf); #endif IF( LT_32(st_fx->core_brate,ACELP_9k60)) { @@ -440,9 +440,9 @@ void decod_audio_fx( test(); #if defined ADD_LRTD test(); - if( EQ_16(st_fx->coder_type_fx,INACTIVE) && LE_32(st_fx->core_brate,ACELP_9k60) && st_fx->idchan == 0) + if( EQ_16(st_fx->coder_type,INACTIVE) && LE_32(st_fx->core_brate,ACELP_9k60) && st_fx->idchan == 0) #else - if (EQ_16(st_fx->coder_type_fx, INACTIVE) && LE_32(st_fx->core_brate, ACELP_9k60)) + if (EQ_16(st_fx->coder_type, INACTIVE) && LE_32(st_fx->core_brate, ACELP_9k60)) #endif { tmp_nb_bits_tot = add(tmp_nb_bits_tot,5); @@ -458,7 +458,7 @@ void decod_audio_fx( } } #endif - gsc_dec_fx(st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type_fx, &last_bin, lsf_new, exc_wo_nf, st_fx->Q_exc ); + gsc_dec_fx(st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, st_fx->Q_exc ); /*--------------------------------------------------------------------------------------* * iDCT transform *--------------------------------------------------------------------------------------*/ @@ -470,7 +470,7 @@ void decod_audio_fx( *----------------------------------------------------------------------*/ pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, gsc_attack_flag - ,st_fx->Q_exc ,st_fx->last_coder_type_fx, st_fx->L_frame); + ,st_fx->Q_exc ,st_fx->last_coder_type, st_fx->L_frame); /*--------------------------------------------------------------------------------------* * Update BWE excitation @@ -572,9 +572,9 @@ void decod_audio_ivas_fx( /* decode GSC SWB speech flag */ test(); #if 0// !defined ADD_LRTD - IF(NE_16(st_fx->coder_type_fx, INACTIVE) && GE_32(st_fx->total_brate, ACELP_13k20)) + IF(NE_16(st_fx->coder_type, INACTIVE) && GE_32(st_fx->total_brate, ACELP_13k20)) #else - if (st_fx->GSC_IVAS_mode >= 1 || (st_fx->coder_type_fx != INACTIVE && ((st_fx->element_mode == EVS_MONO && st_fx->total_brate >= ACELP_13k20) || + if (st_fx->GSC_IVAS_mode >= 1 || (st_fx->coder_type != INACTIVE && ((st_fx->element_mode == EVS_MONO && st_fx->total_brate >= ACELP_13k20) || (st_fx->element_mode > EVS_MONO && st_fx->total_brate > MIN_BRATE_GSC_NOISY_FLAG && st_fx->bwidth >= SWB && !st_fx->flag_ACELP16k)))) #endif { @@ -592,9 +592,9 @@ void decod_audio_ivas_fx( } /* set bit-allocation */ #if 1//def ADD_LRTD - config_acelp1_IVAS(DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech_fx, &(st_fx->acelp_cfg), st_fx->next_bit_pos, st_fx->coder_type_fx, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode); + config_acelp1_IVAS(DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech_fx, &(st_fx->acelp_cfg), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode); #else - config_acelp1(DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech_fx, &(st_fx->acelp_cfg), st_fx->next_bit_pos, st_fx->coder_type_fx, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode); + config_acelp1(DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech_fx, &(st_fx->acelp_cfg), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode); #endif /*---------------------------------------------------------------* * Decode energy dynamics @@ -647,7 +647,7 @@ void decod_audio_ivas_fx( * Decode number of subframes *---------------------------------------------------------------*/ #if 1//def ADD_LRTD - if (st_fx->L_frame == L_FRAME16k && (st_fx->core_brate <= ACELP_13k20 || st_fx->coder_type_fx == INACTIVE)) + if (st_fx->L_frame == L_FRAME16k && (st_fx->core_brate <= ACELP_13k20 || st_fx->coder_type == INACTIVE)) { hGSCDec->cor_strong_limit_fx = 0; nb_subfr = 1; @@ -708,7 +708,7 @@ void decod_audio_ivas_fx( nbits = 3; move16(); test(); - if (LT_32(st_fx->core_brate, ACELP_9k60) && (EQ_16(st_fx->coder_type_fx, INACTIVE))) + if (LT_32(st_fx->core_brate, ACELP_9k60) && (EQ_16(st_fx->coder_type, INACTIVE))) { nbits = 1; move16(); @@ -720,7 +720,7 @@ void decod_audio_ivas_fx( move16(); } test(); - IF(LT_32(st_fx->core_brate, ACELP_9k60) && NE_16(st_fx->coder_type_fx, INACTIVE)) + IF(LT_32(st_fx->core_brate, ACELP_9k60) && NE_16(st_fx->coder_type, INACTIVE)) { pit_band_idx = 1; move16(); @@ -789,9 +789,9 @@ void decod_audio_ivas_fx( Es_pred_dec_fx(&Es_pred, indice, nbits, 0); } #if 1//def ADD_LRTD - dec_pit_exc_ivas_fx(st_fx, Aq, st_fx->coder_type_fx, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf); + dec_pit_exc_ivas_fx(st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf); #else - dec_pit_exc_fx(st_fx, Aq, st_fx->coder_type_fx, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf); + dec_pit_exc_fx(st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf); #endif IF(LT_32(st_fx->core_brate, ACELP_9k60)) { @@ -937,9 +937,9 @@ void decod_audio_ivas_fx( test(); #if 1//defined ADD_LRTD test(); - if (EQ_16(st_fx->coder_type_fx, INACTIVE) && LE_32(st_fx->core_brate, ACELP_9k60) && st_fx->idchan == 0) + if (EQ_16(st_fx->coder_type, INACTIVE) && LE_32(st_fx->core_brate, ACELP_9k60) && st_fx->idchan == 0) #else - if (EQ_16(st_fx->coder_type_fx, INACTIVE) && LE_32(st_fx->core_brate, ACELP_9k60)) + if (EQ_16(st_fx->coder_type, INACTIVE) && LE_32(st_fx->core_brate, ACELP_9k60)) #endif { tmp_nb_bits_tot = add(tmp_nb_bits_tot, 5); @@ -955,8 +955,8 @@ void decod_audio_ivas_fx( } } #endif - //gsc_dec_fx(st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type_fx, &last_bin, lsf_new, exc_wo_nf, st_fx->Q_exc ); - gsc_dec_ivas_fx(st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type_fx, &last_bin, lsf_new, exc_wo_nf, st_fx->Q_exc); + //gsc_dec_fx(st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, st_fx->Q_exc ); + gsc_dec_ivas_fx(st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, st_fx->Q_exc); /*--------------------------------------------------------------------------------------* * iDCT transform *--------------------------------------------------------------------------------------*/ @@ -968,7 +968,7 @@ void decod_audio_ivas_fx( *----------------------------------------------------------------------*/ pre_echo_att_fx(&hGSCDec->Last_frame_ener_fx, exc, gsc_attack_flag - , st_fx->Q_exc, st_fx->last_coder_type_fx, st_fx->L_frame); + , st_fx->Q_exc, st_fx->last_coder_type, st_fx->L_frame); /*--------------------------------------------------------------------------------------* * Update BWE excitation @@ -1163,7 +1163,7 @@ void gsc_dec_fx( move16(); #endif test(); - IF( EQ_16(st_fx->last_good_fx,INACTIVE_CLAS)||EQ_16(st_fx->Last_GSC_noisy_speech_flag_fx,1)) + IF( EQ_16(st_fx->last_good,INACTIVE_CLAS)||EQ_16(st_fx->Last_GSC_noisy_speech_flag_fx,1)) { FOR( i=0; iL_frame; i++ ) { @@ -1229,8 +1229,8 @@ void gsc_dec_fx( seed_init =add(seed_init,inpulses_fx[j]); } test(); - IF( NE_16(st_fx->last_coder_type_fx, AUDIO) /* First audio frame */ - && NE_16(st_fx->last_coder_type_fx, UNVOICED) )/* last_coder_type == INACTIVE is overwritten in update_dec to UNVOICED */ + IF( NE_16(st_fx->last_coder_type, AUDIO) /* First audio frame */ + && NE_16(st_fx->last_coder_type, UNVOICED) )/* last_coder_type == INACTIVE is overwritten in update_dec to UNVOICED */ { FOR( j = 0; j < shl(nb_subbands,4); j++ ) { @@ -1292,7 +1292,7 @@ void gsc_dec_fx( else #endif { - freq_dnw_scaling_fx(hGSCDec->cor_strong_limit_fx, st_fx->coder_type_fx, hGSCDec->noise_lev_fx, st_fx->core_brate, exc_diffQ, Qexc_diffQ, st_fx->L_frame); + freq_dnw_scaling_fx(hGSCDec->cor_strong_limit_fx, st_fx->coder_type, hGSCDec->noise_lev_fx, st_fx->core_brate, exc_diffQ, Qexc_diffQ, st_fx->L_frame); } } @@ -1301,7 +1301,7 @@ void gsc_dec_fx( *--------------------------------------------------------------------------------------*/ highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, *last_bin, Diff_len, hGSCDec->noise_lev_fx, pit_band_idx, exc_diffQ, - &hGSCDec->seed_tcx_fx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type_fx, bitallocation_band, lsf_new, + &hGSCDec->seed_tcx_fx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new, hGSCDec->last_exc_dct_in_fx, &hGSCDec->last_ener_fx, hGSCDec->last_bitallocation_band_fx, bitallocation_exc, st_fx->bfi, coder_type, st_fx->bwidth, exc_wo_nf, Qexc_diffQ, Q_exc, st_fx->GSC_noisy_speech_fx, hGSCDec->lt_ener_per_band_fx , st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode @@ -1477,7 +1477,7 @@ void gsc_dec_ivas_fx( move16(); #endif test(); - IF(EQ_16(st_fx->last_good_fx, INACTIVE_CLAS) || EQ_16(st_fx->Last_GSC_noisy_speech_flag_fx, 1)) + IF(EQ_16(st_fx->last_good, INACTIVE_CLAS) || EQ_16(st_fx->Last_GSC_noisy_speech_flag_fx, 1)) { FOR(i = 0; i < st_fx->L_frame; i++) { @@ -1554,8 +1554,8 @@ void gsc_dec_ivas_fx( seed_init = add(seed_init,inpulses_fx[j]); } test(); - IF(NE_16(st_fx->last_coder_type_fx, AUDIO) /* First audio frame */ - && NE_16(st_fx->last_coder_type_fx, UNVOICED))/* last_coder_type == INACTIVE is overwritten in update_dec to UNVOICED */ + IF(NE_16(st_fx->last_coder_type, AUDIO) /* First audio frame */ + && NE_16(st_fx->last_coder_type, UNVOICED))/* last_coder_type == INACTIVE is overwritten in update_dec to UNVOICED */ { FOR(j = 0; j < shl(nb_subbands,4); j++) { @@ -1619,7 +1619,7 @@ void gsc_dec_ivas_fx( ELSE #endif { - freq_dnw_scaling_fx(hGSCDec->cor_strong_limit_fx, st_fx->coder_type_fx, hGSCDec->noise_lev_fx, st_fx->core_brate, exc_diffQ, Qexc_diffQ, st_fx->L_frame); + freq_dnw_scaling_fx(hGSCDec->cor_strong_limit_fx, st_fx->coder_type, hGSCDec->noise_lev_fx, st_fx->core_brate, exc_diffQ, Qexc_diffQ, st_fx->L_frame); } } @@ -1628,7 +1628,7 @@ void gsc_dec_ivas_fx( *--------------------------------------------------------------------------------------*/ highband_exc_dct_in_ivas_fx(st_fx->core_brate, mfreq_bindiv_loc, *last_bin, Diff_len, hGSCDec->noise_lev_fx, pit_band_idx, exc_diffQ, - &hGSCDec->seed_tcx_fx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type_fx, bitallocation_band, lsf_new, + &hGSCDec->seed_tcx_fx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new, hGSCDec->last_exc_dct_in_fx, &hGSCDec->last_ener_fx, hGSCDec->last_bitallocation_band_fx, bitallocation_exc, st_fx->bfi, coder_type, st_fx->bwidth, exc_wo_nf, Qexc_diffQ, Q_exc, st_fx->GSC_noisy_speech_fx, hGSCDec->lt_ener_per_band_fx , st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index d84ec8a14..ecd20bf4c 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -1220,7 +1220,7 @@ void HQ_core_dec_init( hHQ_core->Q_old_out = 0; hHQ_core->Q_old_outLB = 0; - hHQ_core->last_hq_core_type_fx = -1; + hHQ_core->last_hq_core_type = -1; set16_fx(hHQ_core->old_is_transient_fx, 0, 3); hHQ_core->mem_norm_fx[0] = 31; @@ -1306,7 +1306,7 @@ void HQ_nbfec_init( { int16_t i, j; - hHQ_nbfec->prev_last_core_fx = -1; + hHQ_nbfec->prev_last_core = -1; hHQ_nbfec->diff_energy_fx = 0; hHQ_nbfec->stat_mode_out_fx = 0; hHQ_nbfec->stat_mode_old_fx = 0; diff --git a/lib_dec/hq_lr_dec_fx.c b/lib_dec/hq_lr_dec_fx.c index d6e9eee5b..34203c87c 100644 --- a/lib_dec/hq_lr_dec_fx.c +++ b/lib_dec/hq_lr_dec_fx.c @@ -913,7 +913,7 @@ void hq_lr_dec_fx( } test(); - IF( !(GE_16(st_fx->last_inner_frame, L_FRAME16k)&&st_fx->bws_cnt_fx>0)) + IF( !(GE_16(st_fx->last_inner_frame, L_FRAME16k)&&st_fx->bws_cnt>0)) { k1_fx = sub(bands_fx,2); if(NE_16(*is_transient_fx,1)) @@ -935,7 +935,7 @@ void hq_lr_dec_fx( } updat_prev_frm_fx( L_y2, L_yout, L_bwe_br, length_fx, inner_frame, bands_fx, st_fx->bwidth, *is_transient_fx, hqswb_clas_fx, &hHQ_core->prev_hqswb_clas_fx, - hHQ_core->prev_SWB_peak_pos_fx, prev_SWB_peak_pos_tmp_fx, &hHQ_core->prev_frm_hfe2_fx, &hHQ_core->prev_stab_hfe2_fx, st_fx->bws_cnt_fx ); + hHQ_core->prev_SWB_peak_pos_fx, prev_SWB_peak_pos_tmp_fx, &hHQ_core->prev_frm_hfe2_fx, &hHQ_core->prev_stab_hfe2_fx, st_fx->bws_cnt ); return; } diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index d9e1c0a25..953380aaa 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -417,10 +417,11 @@ ivas_error init_decoder( td_bwe_dec_init( st->hBWE_TD, st->extl, st->output_Fs ); #ifdef IVAS_FLOAT_FIXED - st->prev_Q_bwe_exc = 31; - st->prev_Qx = 0; - st->prev_ener_fx_Q = 31; - st->prev_frame_pow_exp = 0; + td_bwe_dec_init_fx(st, st->hBWE_TD, +#ifdef ADD_IVAS_BWE + st->extl,//not needed +#endif + st->output_Fs); #endif } else @@ -444,9 +445,7 @@ ivas_error init_decoder( fd_bwe_dec_init_flt( st->hBWE_FD ); #ifdef IVAS_FLOAT_FIXED - st->hBWE_FD->old_wtda_swb_fx_exp = 0; - st->hBWE_FD->mem_imdct_exp_fx = 0; - st->prev_Q_synth = 0; + fd_bwe_dec_init(st, st->hBWE_FD); #endif } else diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 3283fc721..01f371f4a 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -71,7 +71,7 @@ ivas_error init_decoder_fx( move16(); - st_fx->last_coder_type_fx = GENERIC; + st_fx->last_coder_type = GENERIC; move16(); st_fx->last_L_frame = st_fx->L_frame; move16(); @@ -103,7 +103,7 @@ ivas_error init_decoder_fx( st_fx->tilt_code_fx = 0; move16(); st_fx->gc_threshold_fx = L_deposit_l(0); - st_fx->last_good_fx = UNVOICED_CLAS; + st_fx->last_good = UNVOICED_CLAS; move16(); st_fx->clas_dec = UNVOICED_CLAS; move16(); @@ -442,8 +442,8 @@ ivas_error init_decoder_fx( move16(); move16(); } st_fx->Qprev_synth_buffer_fx = 15; - st_fx->old_bfi_cnt_fx = 0; - st_fx->prev_old_bfi_fx = 0; + st_fx->old_bfi_cnt = 0; + st_fx->prev_old_bfi = 0; set16_fx(st_fx->delay_buf_out_fx, 0, HQ_DELTA_MAX* HQ_DELAY_COMP); set16_fx(st_fx->previoussynth_fx, 0, L_FRAME48k); IF (EQ_16(st_fx->element_mode, EVS_MONO ) ) @@ -497,7 +497,7 @@ ivas_error init_decoder_fx( { st_fx->hTcxCfg = NULL; } - st_fx->prev_coder_type_fx = GENERIC; + st_fx->prev_coder_type = GENERIC; move16(); move16(); @@ -545,9 +545,9 @@ ivas_error init_decoder_fx( move16(); st_fx->prev_fractive_fx = 0; move16(); - st_fx->prev_bws_cnt_fx = 0; + st_fx->prev_bws_cnt = 0; move16(); - st_fx->bws_cnt_fx = N_WS2N_FRAMES; + st_fx->bws_cnt = N_WS2N_FRAMES; move16(); st_fx->bws_cnt1_fx = N_NS2W_FRAMES; move16(); @@ -720,7 +720,7 @@ ivas_error init_decoder_fx( move16(); st_fx->ppp_mode_dec_fx = 0; move16(); - st_fx->last_nelp_mode_dec_fx = 0; + st_fx->last_nelp_mode_dec = 0; move16(); st_fx->nelp_mode_dec_fx = 0; move16(); @@ -817,7 +817,7 @@ ivas_error init_decoder_fx( st_fx->low_rate_mode = 0; /* low-rate mode flag */ st_fx->last_low_rate_mode = 0; /* low-rate mode flag */ //st_fx->cng_ism_flag = 0; - //st_fx->coder_type_fx = GENERIC; /* low-rate mode flag */ + //st_fx->coder_type = GENERIC; /* low-rate mode flag */ #endif #ifdef DEBUGGING @@ -884,9 +884,9 @@ ivas_error init_decoder_ivas_fx( st_fx->coder_type = GENERIC; st_fx->last_coder_type = GENERIC; #endif - st_fx->coder_type_fx = GENERIC; /* low-rate mode flag */ + st_fx->coder_type = GENERIC; /* low-rate mode flag */ move16(); - st_fx->last_coder_type_fx = GENERIC; + st_fx->last_coder_type = GENERIC; move16(); st_fx->inactive_coder_type_flag = 0; move16(); @@ -935,7 +935,7 @@ ivas_error init_decoder_ivas_fx( #ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED st_fx->last_good = UNVOICED_CLAS; #endif - st_fx->last_good_fx = UNVOICED_CLAS; + st_fx->last_good = UNVOICED_CLAS; move16(); st_fx->clas_dec = UNVOICED_CLAS; move16(); @@ -1130,7 +1130,7 @@ ivas_error init_decoder_ivas_fx( st_fx->exc_pe_fx = 0; move16(); - st_fx->prev_coder_type_fx = GENERIC; + st_fx->prev_coder_type = GENERIC; move16(); st_fx->tilt_wb_fx = 0; @@ -1143,7 +1143,7 @@ ivas_error init_decoder_ivas_fx( st_fx->Qprev_synth_buffer_fx = 15; move16(); - st_fx->old_bfi_cnt_fx = 0; + st_fx->old_bfi_cnt = 0; move16(); /*-----------------------------------------------------------------* @@ -1346,7 +1346,7 @@ ivas_error init_decoder_ivas_fx( set_f(st_fx->delay_buf_out, 0, HQ_DELTA_MAX * HQ_DELAY_COMP); set_f(st_fx->previoussynth, 0, L_FRAME48k); #endif - st_fx->prev_old_bfi_fx = 0; + st_fx->prev_old_bfi = 0; set16_fx(st_fx->delay_buf_out_fx, 0, HQ_DELTA_MAX* HQ_DELAY_COMP); set16_fx(st_fx->previoussynth_fx, 0, L_FRAME48k); @@ -1482,9 +1482,9 @@ ivas_error init_decoder_ivas_fx( move16(); st_fx->prev_fractive_fx = 0; move16(); - st_fx->prev_bws_cnt_fx = 0; + st_fx->prev_bws_cnt = 0; move16(); - st_fx->bws_cnt_fx = N_WS2N_FRAMES; + st_fx->bws_cnt = N_WS2N_FRAMES; move16(); st_fx->bws_cnt1_fx = N_NS2W_FRAMES; move16(); @@ -1733,7 +1733,7 @@ ivas_error init_decoder_ivas_fx( move16(); st_fx->ppp_mode_dec_fx = 0; move16(); - st_fx->last_nelp_mode_dec_fx = 0; + st_fx->last_nelp_mode_dec = 0; move16(); st_fx->nelp_mode_dec_fx = 0; move16(); diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 8a4d1d9bb..d64bf3ac5 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -777,10 +777,46 @@ ivas_error ivas_core_dec( { /* ACELP core decoder */ #ifdef IVAS_FLOAT_FIXED - if ( ( error = acelp_core_dec_ivas_fx( st, output[n], synth[n], save_hb_synth, bwe_exc_extended[n], voice_factors[n], old_syn_12k8_16k[n], sharpFlag[n], pitch_buf[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh, tdm_lsfQ_PCh, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hCPE == NULL ? NULL : hCPE->hStereoCng, read_sid_info ) ) != IVAS_ERR_OK ) + Word16 output_fx[L_FRAME48k], synth_fx[L_FRAME48k], old_syn_12k8_16k_fx[L_FRAME16k], pitch_buf_fx[NB_SUBFR16k], tdm_lspQ_PCh_fx[M], tdm_lsfQ_PCh_fx[M]; + set_s(output_fx, 0, L_FRAME48k); + Word16 save_hb_synth_fx_arr[L_FRAME48k], *save_hb_synth_fx; + if (save_hb_synth) { + save_hb_synth_fx = save_hb_synth_fx_arr; + } + else { + save_hb_synth_fx = NULL; + } + Word32 bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]; + floatToFixed_arrL(bwe_exc_extended[n], bwe_exc_extended_fx, 0, L_FRAME32k + NL_BUFF_OFFSET); + floatToFixed_arr((float *)tdm_lspQ_PCh, tdm_lspQ_PCh_fx, Q15, M); + for ( i = 0; i < M; i++) { + tdm_lsfQ_PCh_fx[i] = (Word16)(tdm_lsfQ_PCh[i] * 2.56f); + } + /* float2fix, to be removed */ + acelp_decoder_state_float2fix(st, hCPE == NULL ? NULL : hCPE->hStereoCng); + if (hStereoTD) { + floatToFixed_arr(hStereoTD->tdm_Pri_pitch_buf, hStereoTD->tdm_Pri_pitch_buf_fx, Q6, NB_SUBFR); + } + if ( ( error = acelp_core_dec_ivas_fx( st, output_fx, synth_fx, save_hb_synth_fx, bwe_exc_extended_fx, voice_factors_fx[n], old_syn_12k8_16k_fx, sharpFlag[n], pitch_buf_fx, &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh_fx, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hCPE == NULL ? NULL : hCPE->hStereoCng, read_sid_info ) ) != IVAS_ERR_OK ) { return error; } + /* fix2float, to be removed */ + acelp_decoder_state_fix2float(st, hCPE == NULL ? NULL : hCPE->hStereoCng); + fixedToFloat_arr(output_fx, output[n], 0, L_FRAME48k); + fixedToFloat_arr(synth_fx, synth[n], 0, L_FRAME48k); + if (save_hb_synth) { + fixedToFloat_arr(save_hb_synth_fx, save_hb_synth, 0, L_FRAME48k); + } + fixedToFloat_arrL(bwe_exc_extended_fx, bwe_exc_extended[n], 2*st->Q_exc, L_FRAME32k + NL_BUFF_OFFSET); + fixedToFloat_arr(voice_factors_fx[n], voice_factors[n], Q15, NB_SUBFR16k); + fixedToFloat_arr(old_syn_12k8_16k_fx, old_syn_12k8_16k[n], -1, L_FRAME16k); + fixedToFloat_arr(pitch_buf_fx, pitch_buf[n], Q6, NB_SUBFR16k); + fixedToFloat_arr(tdm_lspQ_PCh_fx, (float *)tdm_lspQ_PCh, Q15, M); + for (i = 0; i < M; i++) + { + tdm_lsfQ_PCh[i] = tdm_lsfQ_PCh_fx[i] / 2.56f; + } #else if ((error = acelp_core_dec(st, output[n], synth[n], save_hb_synth, bwe_exc_extended[n], voice_factors[n], old_syn_12k8_16k[n], sharpFlag[n], pitch_buf[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh, tdm_lsfQ_PCh, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hCPE == NULL ? NULL : hCPE->hStereoCng, read_sid_info)) != IVAS_ERR_OK) { @@ -1432,11 +1468,11 @@ ivas_error ivas_core_dec( floatToFixed_arr( synth[n], synth_fx_16[n], st->Q_syn, L_FRAME48k ); st->prev_tilt_code_dec_fx = (Word16) floatToFixed( st->prev_tilt_code_dec, Q15 ); - st->bws_cnt_fx = st->bws_cnt; + st->bws_cnt = st->bws_cnt; floatToFixed_arr( pitch_buf[n], pitch_buf_fx[n], Q6, NB_SUBFR16k ); - st->prev_coder_type_fx = st->prev_coder_type; + st->prev_coder_type = st->prev_coder_type; st->tilt_wb_fx = (Word16) floatToFixed( st->tilt_wb, Q11 ); } @@ -1491,7 +1527,7 @@ ivas_error ivas_core_dec( hBWE_FD->prev_L_swb_norm_fx = hBWE_FD->prev_L_swb_norm; hBWE_FD->Seed_fx = hBWE_FD->Seed; hBWE_FD->prev_flag_fx = hBWE_FD->prev_flag; - st->coder_type_fx = st->coder_type; + st->coder_type = st->coder_type; } #endif test(); @@ -1527,7 +1563,7 @@ ivas_error ivas_core_dec( st->prev_tilt_code_dec = fixedToFloat( st->prev_tilt_code_dec_fx, Q15 ); fixedToFloat_arr( pitch_buf_fx[n], pitch_buf[n], Q6, NB_SUBFR16k ); - st->prev_coder_type = st->prev_coder_type_fx; + st->prev_coder_type = st->prev_coder_type; st->tilt_wb = fixedToFloat( st->tilt_wb_fx, Q11 ); } @@ -1568,7 +1604,7 @@ ivas_error ivas_core_dec( fixedToFloat_arr( hBWE_FD->mem_imdct_fx, hBWE_FD->mem_imdct, hBWE_FD->mem_imdct_exp_fx, L_FRAME48k ); fixedToFloat_arr( hBWE_FD->L_old_wtda_swb_fx, hBWE_FD->old_wtda_swb, hBWE_FD->old_wtda_swb_fx_exp, L_FRAME48k ); hBWE_FD->prev_Energy_wb = fixedToFloat( hBWE_FD->prev_Energy_wb_fx, st->prev_Q_synth ); - st->coder_type = st->coder_type_fx; + st->coder_type = st->coder_type; } #endif #else @@ -1607,8 +1643,66 @@ ivas_error ivas_core_dec( else if ( st->extl == SWB_BWE || st->extl == FB_BWE || ( output_Fs >= 32000 && st->core == ACELP_CORE && st->bwidth > NB && st->bws_cnt > 0 && !st->ppp_mode_dec && !( st->nelp_mode_dec == 1 && st->bfi == 1 ) ) ) { /* SWB BWE decoder */ +#ifdef IVAS_FLOAT_FIXED + Word32 output_fx32[L_FRAME48k]; + Word32 synth_fx32[L_FRAME48k]; + Word32 hb_synth_fx32[L_FRAME48k], Q_syn_hb; + + for (i = 0; i < output_frame; i++) { + st->hBWE_FD->mem_imdct_fx[i] = (Word16)(st->hBWE_FD->mem_imdct[i] * (1 << st->hBWE_FD->mem_imdct_exp_fx)); + output_fx32[i] = (Word32)(output[n][i] * (1 << 11)); + synth_fx32[i] = (Word32)(synth[n][i] * (1 << 11)); + st->hBWE_FD->L_old_wtda_swb_fx32[i] = (Word32)(st->hBWE_FD->old_wtda_swb[i] * (1 << 11)); + } + + for (int i = 0; i < 14; i++) + st->hBWE_FD->prev_SWB_fenv_fx[i] = (Word16)(st->hBWE_FD->prev_SWB_fenv[i] * (1 << 1)); + + st->bws_cnt = st->bws_cnt; + st->bws_cnt1_fx = st->bws_cnt1; + st->hBWE_FD->prev_mode_fx = st->hBWE_FD->prev_mode; + st->hBWE_FD->prev_Energy_fx = (Word16)(st->hBWE_FD->prev_Energy * (1 << 3)); + st->hBWE_FD->prev_L_swb_norm_fx = st->hBWE_FD->prev_L_swb_norm; + st->tilt_wb_fx = (Word16)(st->tilt_wb * (1 << 11)); + st->hBWE_FD->Seed_fx = st->hBWE_FD->Seed; + st->hBWE_FD->prev_weight_fx = (Word16)(st->hBWE_FD->prev_weight*(1 << 15)); + st->hBWE_FD->prev_frica_flag_fx = st->hBWE_FD->prev_frica_flag; + st->hBWE_FD->prev_td_energy_fx = (Word16)st->hBWE_FD->prev_td_energy; + st->attenu_fx = (Word16)(st->attenu1 * (1 << 15)); + + Q_syn_hb = swb_bwe_dec_fx32( st, output_fx32, synth_fx32, hb_synth_fx32, use_cldfb_for_dft, output_frame ); + + // Output + st->hBWE_FD->prev_td_energy = (float)st->hBWE_FD->prev_td_energy_fx; + st->prev_ener_shb = (float)st->prev_ener_shb_fx / 2; + st->attenu1 = (float)st->attenu_fx / (1 << 15); + + st->hBWE_FD->prev_frica_flag = st->hBWE_FD->prev_frica_flag_fx; + st->hBWE_FD->prev_mode = st->hBWE_FD->prev_mode_fx; + + + st->hBWE_FD->prev_Energy = ((float)st->hBWE_FD->prev_Energy_fx / (1 << 3)); + st->hBWE_FD->prev_L_swb_norm = st->hBWE_FD->prev_L_swb_norm_fx; + st->tilt_wb = ((float)st->tilt_wb_fx / (1 << 11)); + st->hBWE_FD->Seed = st->hBWE_FD->Seed_fx; + st->hBWE_FD->prev_weight = ((float)st->hBWE_FD->prev_weight_fx / (1 << 15)); + + st->hBWE_FD->prev_td_energy_fx = (Word16)st->hBWE_FD->prev_td_energy; + + + for (int i = 0; i < 14; i++) + st->hBWE_FD->prev_SWB_fenv[i] = ((float)st->hBWE_FD->prev_SWB_fenv_fx[i] / (1 << 1)); + + for (i = 0; i < output_frame; i++) { + hb_synth[n][i] = (float)hb_synth_fx32[i] / (1 << Q_syn_hb); + st->hBWE_FD->old_wtda_swb[i] = (float)st->hBWE_FD->L_old_wtda_swb_fx32[i] / (1 << 11); + st->hBWE_FD->mem_imdct[i] = ((float)st->hBWE_FD->mem_imdct_fx[i] / (1 << st->hBWE_FD->mem_imdct_exp_fx)); + } + +#else // IVAS_FLOAT_FIXED swb_bwe_dec_flt( st, output[n], synth[n], hb_synth[n], use_cldfb_for_dft, output_frame ); - } +#endif + } /*---------------------------------------------------------------------* * FEC - recovery after lost HQ core (smoothing of the BWE component) @@ -1835,7 +1929,18 @@ ivas_error ivas_core_dec( if ( ( st->element_mode != IVAS_CPE_TD && !use_cldfb_for_dft ) || ( hCPE->element_mode == IVAS_CPE_TD && tdm_LRTD_flag ) ) { /* Delay hb_synth */ +#ifdef IVAS_FLOAT_FIXED + Word32 hb_synth_fx[960], hb_prev_synth_buffer_fx_32[111]; + floatToFixed_arrL(hb_synth[n], hb_synth_fx, Q11, 960); + floatToFixed_arrL(st->hb_prev_synth_buffer, hb_prev_synth_buffer_fx_32, Q11, 111); + + delay_signal_fx( hb_synth_fx, output_frame, hb_prev_synth_buffer_fx_32, tmps ); + + fixedToFloat_arrL(hb_synth_fx, hb_synth[n], Q11, 960); + fixedToFloat_arrL(hb_prev_synth_buffer_fx_32, st->hb_prev_synth_buffer, Q11, 111); +#else delay_signal_float( hb_synth[n], output_frame, st->hb_prev_synth_buffer, tmps ); +#endif } else { @@ -2336,7 +2441,7 @@ ivas_error ivas_core_dec( } } save_synthesis_hq_fec_fx( st, output_fx_loc, output_frame, hCPE ); - save_synthesis_hq_fec(st, output[n], output_frame, hCPE); + //save_synthesis_hq_fec(st, output[n], output_frame, hCPE); if ( ( st->codec_mode == MODE1 && st->hTcxDec != NULL ) && ( ( st->core == ACELP_CORE && !( st->bfi == 1 && st->con_tcx == 1 ) ) || st->core == HQ_CORE ) ) { /*dumps*/ @@ -2357,7 +2462,29 @@ ivas_error ivas_core_dec( #endif /* Updates */ +#ifdef IVAS_FLOAT_FIXED +#if 1 // Conversion + floatToFixed_arrL(output[n], output_fx_loc, 11, 960); + floatToFixed_arr(st->tilt_code_dec, st->tilt_code_dec_fx, 15, 5); + floatToFixed_arr(st->old_synth_sw, st->old_synth_sw_fx, -2, 429); + st->prev_tilt_code_dec_fx = floatToFixed(st->prev_tilt_code_dec, Q15); + FOR(Word16 ind = 0; ind < 16; ind++) { + st->mem_AR_fx[ind] = (Word16)(st->mem_AR[ind] * 2.56f); + } + fixedToFloat_arr(st->old_synth_sw_fx, st->old_synth_sw, 0, 429); + +#endif + ivas_updt_dec_common_fx( st, NORMAL_HQ_CORE, -1, output_fx_loc, 11 ); +#if 1 + fixedToFloat_arr(st->old_synth_sw_fx, st->old_synth_sw, -2, 429); + FOR(Word16 ind = 0; ind < 16; ind++) { + st->mem_AR[ind] = st->mem_AR_fx[ind] / 2.56f; + } + st->prev_tilt_code_dec = fixedToFloat(st->prev_tilt_code_dec_fx, Q15); +#endif +#else updt_dec_common( st, NORMAL_HQ_CORE, -1, output[n] ); +#endif } /* n_channels loop */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 1c90efff4..2024ddf54 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2314,8 +2314,8 @@ void ivas_qmetadata_to_dirac_fx( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ const Word32 ivas_total_brate, /* i : IVAS total bitrate */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ - int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ + const Word16 hodirac_flag, /* i : flag to indicate HO-DirAC mode */ + Word16 *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ) { Word16 block, band; diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 25c52f4ee..7e505ea3a 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -2177,6 +2177,7 @@ static void index_16bits_fx( { hQMetaData->q_direction[d].band_data[band].spherical_index[block] = index_theta_phi_16_fx( &( hQMetaData->q_direction[d].band_data[band].elevation_fx[block] ), &( hQMetaData->q_direction[d].band_data[band].azimuth_fx[block] ), Sph_Grid16 ); + move16(); } } } @@ -2243,13 +2244,14 @@ static void replicate_subframes_fx( ndirs = hQMetaData->no_directions; move16(); - FOR ( sf = 1; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) + FOR( sf = 1; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { - FOR ( band = 0; band < nbands; band++ ) + FOR( band = 0; band < nbands; band++ ) { - FOR ( dir = 0; dir < ndirs; dir++ ) + FOR( dir = 0; dir < ndirs; dir++ ) { hQMetaData->q_direction[dir].band_data[band].spherical_index[sf] = hQMetaData->q_direction[dir].band_data[band].spherical_index[0]; + move16(); hQMetaData->q_direction[dir].band_data[band].azimuth_fx[sf] = hQMetaData->q_direction[dir].band_data[band].azimuth_fx[0]; move32(); hQMetaData->q_direction[dir].band_data[band].elevation_fx[sf] = hQMetaData->q_direction[dir].band_data[band].elevation_fx[0]; @@ -2257,13 +2259,13 @@ static void replicate_subframes_fx( hQMetaData->q_direction[dir].band_data[band].energy_ratio_fx[sf] = hQMetaData->q_direction[dir].band_data[band].energy_ratio_fx[0]; move32(); - IF ( hQMetaData->q_direction[dir].coherence_band_data != NULL ) + IF( hQMetaData->q_direction[dir].coherence_band_data != NULL ) { hQMetaData->q_direction[dir].coherence_band_data[band].spread_coherence[sf] = hQMetaData->q_direction[dir].coherence_band_data[band].spread_coherence[0]; } } - IF ( hQMetaData->surcoh_band_data != NULL ) + IF( hQMetaData->surcoh_band_data != NULL ) { hQMetaData->surcoh_band_data[band].surround_coherence[sf] = hQMetaData->surcoh_band_data[band].surround_coherence[0]; } @@ -2360,17 +2362,17 @@ static void restore_lowbitrate_masa_fx( { Word16 sf, band; - IF ( EQ_16(low_bitrate_mode, 1) ) + IF( EQ_16( low_bitrate_mode, 1 ) ) { /* With signal 1, we are in 5 frequency bands, 1 subframe mode. */ /* Replicate data to all subframes */ - FOR ( sf = 1; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) + FOR( sf = 1; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { - FOR ( band = 0; band < numCodingBands; band++ ) + FOR( band = 0; band < numCodingBands; band++ ) { hQMetaData->q_direction[0].band_data[band].spherical_index[sf] = hQMetaData->q_direction[0].band_data[band].spherical_index[0]; - + move16(); hQMetaData->q_direction[0].band_data[band].azimuth_fx[sf] = hQMetaData->q_direction[0].band_data[band].azimuth_fx[0]; move32(); hQMetaData->q_direction[0].band_data[band].elevation_fx[sf] = hQMetaData->q_direction[0].band_data[band].elevation_fx[0]; @@ -2378,11 +2380,11 @@ static void restore_lowbitrate_masa_fx( hQMetaData->q_direction[0].band_data[band].energy_ratio_fx[sf] = hQMetaData->q_direction[0].band_data[band].energy_ratio_fx[0]; move32(); - IF ( hQMetaData->q_direction[0].coherence_band_data != NULL ) + IF( hQMetaData->q_direction[0].coherence_band_data != NULL ) { hQMetaData->q_direction[0].coherence_band_data[band].spread_coherence[sf] = hQMetaData->q_direction[0].coherence_band_data[band].spread_coherence[0]; } - IF ( hQMetaData->surcoh_band_data != NULL ) + IF( hQMetaData->surcoh_band_data != NULL ) { hQMetaData->surcoh_band_data[band].surround_coherence[sf] = hQMetaData->surcoh_band_data[band].surround_coherence[0]; } @@ -2395,11 +2397,12 @@ static void restore_lowbitrate_masa_fx( { /* With signal 0, we are in 1 frequency bands, 4 subframes mode. */ /* Replicate data to all bands */ - FOR ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) + FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { - FOR ( band = 1; band < numCodingBands; band++ ) + FOR( band = 1; band < numCodingBands; band++ ) { hQMetaData->q_direction[0].band_data[band].spherical_index[sf] = hQMetaData->q_direction[0].band_data[0].spherical_index[sf]; + move16(); hQMetaData->q_direction[0].band_data[band].azimuth_fx[sf] = hQMetaData->q_direction[0].band_data[0].azimuth_fx[sf]; move32(); hQMetaData->q_direction[0].band_data[band].elevation_fx[sf] = hQMetaData->q_direction[0].band_data[0].elevation_fx[sf]; @@ -2407,11 +2410,11 @@ static void restore_lowbitrate_masa_fx( hQMetaData->q_direction[0].band_data[band].energy_ratio_fx[sf] = hQMetaData->q_direction[0].band_data[0].energy_ratio_fx[sf]; move32(); - IF ( hQMetaData->q_direction[0].coherence_band_data != NULL ) + IF( hQMetaData->q_direction[0].coherence_band_data != NULL ) { hQMetaData->q_direction[0].coherence_band_data[band].spread_coherence[sf] = hQMetaData->q_direction[0].coherence_band_data[0].spread_coherence[sf]; } - IF ( hQMetaData->surcoh_band_data != NULL ) + IF( hQMetaData->surcoh_band_data != NULL ) { hQMetaData->surcoh_band_data[band].surround_coherence[sf] = hQMetaData->surcoh_band_data[0].surround_coherence[sf]; } @@ -2894,6 +2897,7 @@ static Word16 decode_lfe_to_total_energy_ratio_fx( lfeBitsRead = 0; move16(); byteBuffer = bitstream[( *index )--]; + move16(); lfeBitsRead = add( lfeBitsRead, 1 ); lfeToTotalEnergyRatioIndices[0] = byteBuffer; /* First LFE index */ move16(); @@ -2943,9 +2947,9 @@ static Word16 decode_lfe_to_total_energy_ratio_fx( } ELSE { - byteBuffer = bitstream[( *index )--] << 2; - byteBuffer += bitstream[( *index )--] << 1; - byteBuffer += bitstream[( *index )--]; + byteBuffer = (UWord16) L_shl( bitstream[( *index )--], 2 ); + byteBuffer = (UWord16) L_add( byteBuffer, L_shl( bitstream[( *index )--], 1 ) ); + byteBuffer = (UWord16) L_add( byteBuffer, bitstream[( *index )--] ); lfeBitsRead = add( lfeBitsRead, 3 ); lfeToTotalEnergyRatioIndices[1] = byteBuffer; /* Scalar index */ move16(); @@ -2960,24 +2964,29 @@ static Word16 decode_lfe_to_total_energy_ratio_fx( case 0: case 1: VQBits = 0; - break; + move16(); + BREAK; case 2: VQBits = 1; - break; + move16(); + BREAK; case 3: VQBits = 2; - break; + move16(); + BREAK; case 4: VQBits = 3; - break; + move16(); + BREAK; default: VQBits = 4; + move16(); } byteBuffer = 0; move16(); FOR( i = 0; i < VQBits; i++ ) { - byteBuffer += bitstream[( *index )--] << ( sub( sub( VQBits, 1 ), i ) ); + byteBuffer = (UWord16) L_add( byteBuffer, L_shl( bitstream[( *index )--], sub( sub( VQBits, 1 ), i ) ) ); lfeBitsRead = add( lfeBitsRead, 1 ); } lfeToTotalEnergyRatioIndices[2] = byteBuffer; /* VQ index */ @@ -4051,12 +4060,12 @@ static void create_masa_ext_out_meta_fx( descMeta = &hMasa->data.extOutMeta->descriptiveMeta; /* Construct descriptive meta */ - FOR ( i = 0; i < 8; i++ ) + FOR( i = 0; i < 8; i++ ) { descMeta->formatDescriptor[i] = ivasmasaFormatDescriptor[i]; } descMeta->numberOfDirections = numDirections - 1; - descMeta->numberOfChannels = (UWord8) ( sub(nchan_transport, 1) ); + descMeta->numberOfChannels = (UWord8) ( sub( nchan_transport, 1 ) ); /* Following correspond to "unknown" values until transmission is implemented */ descMeta->sourceFormat = 0x0u; descMeta->transportDefinition = 0x0u; @@ -4065,14 +4074,14 @@ static void create_masa_ext_out_meta_fx( descMeta->channelLayout = 0x0u; /* Construct spatial metadata from qmetadata */ - FOR ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) + FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { - FOR ( dir = 0; dir < numDirections; dir++ ) + FOR( dir = 0; dir < numDirections; dir++ ) { /* Spherical index */ - FOR ( b_old = 0; b_old < numCodingBands; b_old++ ) + FOR( b_old = 0; b_old < numCodingBands; b_old++ ) { - FOR ( b_new = bandMap[b_old]; b_new < bandMap[b_old + 1]; b_new++ ) + FOR( b_new = bandMap[b_old]; b_new < bandMap[b_old + 1]; b_new++ ) { extOutMeta->directionIndex[dir][sf][b_new] = hQMetaData->q_direction[dir].band_data[b_old].spherical_index[sf]; move16(); @@ -4080,21 +4089,21 @@ static void create_masa_ext_out_meta_fx( } /* Direct-to-total ratio */ - FOR ( b_old = 0; b_old < numCodingBands; b_old++ ) + FOR( b_old = 0; b_old < numCodingBands; b_old++ ) { - FOR ( b_new = bandMap[b_old]; b_new < bandMap[b_old + 1]; b_new++ ) + FOR( b_new = bandMap[b_old]; b_new < bandMap[b_old + 1]; b_new++ ) { - UWord8 tmp = (UWord8)L_shr(hQMetaData->q_direction[dir].band_data[b_old].energy_ratio_fx[sf], Q30 - 8); + UWord8 tmp = (UWord8) L_shr( hQMetaData->q_direction[dir].band_data[b_old].energy_ratio_fx[sf], Q30 - 8 ); extOutMeta->directToTotalRatio[dir][sf][b_new] = tmp; } } /* Spread coherence */ - IF ( hQMetaData->q_direction[dir].coherence_band_data != NULL ) + IF( hQMetaData->q_direction[dir].coherence_band_data != NULL ) { - FOR ( b_old = 0; b_old < numCodingBands; b_old++ ) + FOR( b_old = 0; b_old < numCodingBands; b_old++ ) { - FOR ( b_new = bandMap[b_old]; b_new < bandMap[b_old + 1]; b_new++ ) + FOR( b_new = bandMap[b_old]; b_new < bandMap[b_old + 1]; b_new++ ) { extOutMeta->spreadCoherence[dir][sf][b_new] = hQMetaData->q_direction[dir].coherence_band_data[b_old].spread_coherence[sf]; } @@ -4102,7 +4111,7 @@ static void create_masa_ext_out_meta_fx( } ELSE { - FOR ( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) + FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) { extOutMeta->spreadCoherence[dir][sf][i] = 0; } @@ -4110,20 +4119,20 @@ static void create_masa_ext_out_meta_fx( } /* Fill second direction with zero energy data for EXT output */ - IF ( numDirections == 1 ) + IF( EQ_16( numDirections, 1 ) ) { - FOR ( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) + FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) { extOutMeta->directionIndex[1][sf][i] = SPH_IDX_FRONT; move16(); } - FOR ( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) + FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) { extOutMeta->directToTotalRatio[1][sf][i] = 0; } - FOR ( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) + FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) { extOutMeta->spreadCoherence[1][sf][i] = 0; } @@ -4131,25 +4140,25 @@ static void create_masa_ext_out_meta_fx( /* Common spatial meta */ /* Diffuse-to-total ratio = 1 - sum(direct-to-total ratios) */ - FOR ( b_old = 0; b_old < numCodingBands; b_old++ ) + FOR( b_old = 0; b_old < numCodingBands; b_old++ ) { - FOR ( b_new = bandMap[b_old]; b_new < bandMap[b_old + 1]; b_new++ ) + FOR( b_new = bandMap[b_old]; b_new < bandMap[b_old + 1]; b_new++ ) { extOutMeta->diffuseToTotalRatio[sf][b_new] = UINT8_MAX; - FOR ( dir = 0; dir < numDirections; dir++ ) + FOR( dir = 0; dir < numDirections; dir++ ) { - UWord8 tmp = (UWord8)L_shr(hQMetaData->q_direction[dir].band_data[b_old].energy_ratio_fx[sf], Q30 - 8); + UWord8 tmp = (UWord8) L_shr( hQMetaData->q_direction[dir].band_data[b_old].energy_ratio_fx[sf], Q30 - 8 ); extOutMeta->diffuseToTotalRatio[sf][b_new] -= tmp; } } } /* Surround coherence */ - IF ( hQMetaData->surcoh_band_data != NULL ) + IF( hQMetaData->surcoh_band_data != NULL ) { - FOR ( b_old = 0; b_old < numCodingBands; b_old++ ) + FOR( b_old = 0; b_old < numCodingBands; b_old++ ) { - FOR ( b_new = bandMap[b_old]; b_new < bandMap[b_old + 1]; b_new++ ) + FOR( b_new = bandMap[b_old]; b_new < bandMap[b_old + 1]; b_new++ ) { extOutMeta->surroundCoherence[sf][b_new] = hQMetaData->surcoh_band_data[b_old].surround_coherence[sf]; } @@ -4157,7 +4166,7 @@ static void create_masa_ext_out_meta_fx( } ELSE { - FOR ( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) + FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) { extOutMeta->surroundCoherence[sf][i] = 0; } @@ -4237,7 +4246,7 @@ static void decode_index_slice_fx( move16(); ratio_idx_ism[1] = sub(K, ratio_idx_ism[0]); move16(); - break; + BREAK; case 3: case 4: { @@ -4254,14 +4263,14 @@ static void decode_index_slice_fx( j = sub(j,1); base[0] = 1; move16(); - FOR ( i = 1; i < nchan_ism - 1; i++ ) + FOR ( i = 1; i < sub(nchan_ism, 1); i++ ) { base[i] = i_mult(base[i - 1], 10); move16(); } sum = 0; move16(); - FOR ( i = nchan_ism - 2; i >= 0; i-- ) + FOR ( i = sub(nchan_ism, 2); i >= 0; i-- ) { IF(EQ_16(j, 0)) { @@ -4588,6 +4597,7 @@ static void read_ism_ratio_index_fx( IF( GT_16( idx_sep_obj, -1 ) ) { + test(); IF( EQ_16( idx_sep_obj, sub( nchan_ism, 1 ) ) && GT_16( nchan_ism, 2 ) ) { idx_sep_obj_local = 0; @@ -4597,7 +4607,7 @@ static void read_ism_ratio_index_fx( b_signif = 0; move16(); - no_levels_ratio_ism = ( ( 1 << PARAM_ISM_POW_RATIO_NBITS ) - 1 ); + no_levels_ratio_ism = sub( shl( 1, PARAM_ISM_POW_RATIO_NBITS ), 1 ); move16(); test(); @@ -4620,7 +4630,7 @@ static void read_ism_ratio_index_fx( bits_index = bits_index_ism_ratio( nchan_ism ); /* read coding type */ - IF( bit_stream[( *next_bit_pos )--] == 1 ) + IF( EQ_32( bit_stream[( *next_bit_pos )--], 1 ) ) { /* independent coding*/ FOR( b = 0; b < numCodingBands; b++ ) @@ -4634,6 +4644,7 @@ static void read_ism_ratio_index_fx( index = add( shl( index, 1 ), (Word16) bit_stream[( *next_bit_pos )--] ); } decode_index_slice_fx( index, ratio_ism_idx[b], nchan_ism, no_levels_ratio_ism ); + test(); IF( GT_16( idx_sep_obj, -1 ) && EQ_16( ratio_ism_idx[b][idx_sep_obj_local], 0 ) ) { ( *num_zeros )++; @@ -4656,6 +4667,7 @@ static void read_ism_ratio_index_fx( index = add( shl( index, 1 ), (Word16) bit_stream[( *next_bit_pos )--] ); } decode_index_slice_fx( index, ratio_ism_idx[b_signif], nchan_ism, no_levels_ratio_ism ); + test(); IF( GT_16( idx_sep_obj, -1 ) && EQ_16( ratio_ism_idx[b_signif][idx_sep_obj_local], 0 ) ) { ( *num_zeros )++; @@ -4686,6 +4698,7 @@ static void read_ism_ratio_index_fx( move16(); } Copy( ratio_ism_idx[b], ratio_ism_idx_ref, nchan_ism ); + test(); IF( GT_16( idx_sep_obj, -1 ) && EQ_16( ratio_ism_idx[b][idx_sep_obj_local], 0 ) ) { ( *num_zeros )++; @@ -4716,13 +4729,15 @@ static void read_ism_ratio_index_fx( IF( EQ_16( *num_zeros, numCodingBands ) ) { shift_one = 1; + move16(); } ELSE { shift_one = 0; + move16(); } - move16(); + test(); IF( EQ_16( shift_one, 1 ) && EQ_16( nchan_ism, 2 ) ) { /* nothing has been sent ; values can be inferred */ @@ -4827,6 +4842,7 @@ static void read_ism_ratio_index_fx( ratio_ism_idx[b_signif][i] = add( ratio_ism_idx[b_signif][i], ratio_ism_idx_prev_sf[b_signif][i] ); move16(); + test(); IF( NE_16( shift_one, 0 ) && EQ_16( i, idx_sep_obj_local ) ) { ratio_ism_idx[b_signif][i] = 0; diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index 437f1f948..d751de8c2 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -1262,14 +1262,16 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( Word64 W_nrg_ratio[2][MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES]; start_index_0 = *index; + move16(); /* read number of higher inactive/not encoded bands */ IF( bitstream[( *index )--] ) { - codedBands = MASA_MAXIMUM_CODING_SUBBANDS - ivas_qmetadata_DecodeExtendedGR( bitstream, index, MASA_MAXIMUM_CODING_SUBBANDS, 1 ) - 1; + codedBands = sub( sub( MASA_MAXIMUM_CODING_SUBBANDS, ivas_qmetadata_DecodeExtendedGR( bitstream, index, MASA_MAXIMUM_CODING_SUBBANDS, 1 ) ), 1 ); } ELSE { codedBands = MASA_MAXIMUM_CODING_SUBBANDS; + move16(); } FOR( b = codedBands; b < ncoding_bands_config; b++ ) { @@ -1277,92 +1279,119 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( { hQMetaData->q_direction[0].band_data[b].azimuth_fx[m] = 0; + move32(); hQMetaData->q_direction[0].band_data[b].elevation_fx[m] = 0; + move32(); hQMetaData->q_direction[0].band_data[b].energy_ratio_fx[m] = 0; + move32(); W_nrg_ratio[0][b][m] = 0; + move64(); + test(); IF( hQMetaData->coherence_flag && hQMetaData->q_direction[0].coherence_band_data != NULL ) { hQMetaData->q_direction[0].coherence_band_data[b].spread_coherence[m] = 0u; } - IF( hQMetaData->no_directions == 2 ) + IF( EQ_32( hQMetaData->no_directions, 2 ) ) { hQMetaData->q_direction[1].band_data[b].azimuth_fx[m] = 0; + move32(); hQMetaData->q_direction[1].band_data[b].elevation_fx[m] = 0; + move32(); hQMetaData->q_direction[1].band_data[b].energy_ratio_fx[m] = 0; + move32(); W_nrg_ratio[1][b][m] = 0; + move64(); + test(); IF( hQMetaData->coherence_flag && hQMetaData->q_direction[1].coherence_band_data != NULL ) { hQMetaData->q_direction[1].coherence_band_data[b].spread_coherence[m] = 0u; } } + test(); IF( hQMetaData->coherence_flag && hQMetaData->surcoh_band_data != NULL ) { hQMetaData->surcoh_band_data[b].surround_coherence[m] = 0u; } } - IF( hQMetaData->no_directions == 2 ) + IF( EQ_32( hQMetaData->no_directions, 2 ) ) { hQMetaData->twoDirBands[b] = 0; } } sf_nbands0 = hQMetaData->q_direction[0].cfg.nbands; + move16(); hQMetaData->q_direction[0].cfg.nbands = codedBands; + move16(); /*Coherence flag decoding*/ all_coherence_zero = 1; + move16(); IF( hQMetaData->coherence_flag ) { /* read if coherence is zero */ all_coherence_zero = bitstream[( *index )--]; + move16(); } hQMetaData->all_coherence_zero = (UWord8) all_coherence_zero; - IF( hQMetaData->no_directions == 2 ) + IF( EQ_32( hQMetaData->no_directions, 2 ) ) { set_c( (Word8 *) hQMetaData->twoDirBands, 1, hQMetaData->q_direction[0].cfg.nbands ); } - IF( bits_sph_idx == 11 && hQMetaData->no_directions == 2 ) + test(); + IF( EQ_16( bits_sph_idx, 11 ) && EQ_32( hQMetaData->no_directions, 2 ) ) { /* Read which bands have 2 directions */ hQMetaData->q_direction[1].cfg.nbands = hQMetaData->numTwoDirBands; + move16(); sf_nbands1 = hQMetaData->q_direction[1].cfg.nbands; - IF( hQMetaData->q_direction[1].cfg.nbands > codedBands ) + move16(); + IF( GT_16( hQMetaData->q_direction[1].cfg.nbands, codedBands ) ) { hQMetaData->q_direction[1].cfg.nbands = codedBands; + move16(); } set_c( (Word8 *) hQMetaData->twoDirBands, 0, hQMetaData->q_direction[0].cfg.nbands ); d = *index; + move16(); dif_p[0] = ivas_qmetadata_DecodeExtendedGR( bitstream, index, MASA_MAXIMUM_CODING_SUBBANDS, 0 ); + move16(); p[0] = dif_p[0]; + move16(); hQMetaData->twoDirBands[p[0]] = 1; FOR( b = 1; b < hQMetaData->q_direction[1].cfg.nbands; b++ ) { dif_p[b] = ivas_qmetadata_DecodeExtendedGR( bitstream, index, MASA_MAXIMUM_CODING_SUBBANDS, 0 ); - p[b] = p[b - 1] + dif_p[b] + 1; + move16(); + p[b] = add( add( p[b - 1], dif_p[b] ), 1 ); + move16(); hQMetaData->twoDirBands[p[b]] = 1; } } - IF( bits_sph_idx == 16 && hQMetaData->no_directions == 2 ) + test(); + IF( EQ_16( bits_sph_idx, 16 ) && EQ_32( hQMetaData->no_directions, 2 ) ) { sf_nbands1 = hQMetaData->q_direction[1].cfg.nbands; - IF( hQMetaData->q_direction[1].cfg.nbands > codedBands ) + move16(); + IF( GT_16( hQMetaData->q_direction[1].cfg.nbands, codedBands ) ) { hQMetaData->q_direction[1].cfg.nbands = codedBands; + move16(); } } ivas_qmetadata_entropy_decode_diffuseness_hr_512( bitstream, index, &( hQMetaData->q_direction[0] ) ); - IF( hQMetaData->no_directions == 2 ) + IF( EQ_32( hQMetaData->no_directions, 2 ) ) { ivas_qmetadata_entropy_decode_diffuseness_hr_512( bitstream, index, &( hQMetaData->q_direction[1] ) ); } @@ -1373,18 +1402,20 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( FOR( m = 0; m < hQMetaData->q_direction[0].cfg.nblocks; m++ ) { W_nrg_ratio[0][b][m] = W_sub( ONE_IN_Q62, diffuseness_reconstructions_hr_fx[hQMetaData->q_direction[0].band_data[b].energy_ratio_index[m]] ); + move64(); } } - IF( hQMetaData->no_directions == 2 ) + IF( EQ_32( hQMetaData->no_directions, 2 ) ) { Word32 ratioSum; - IF( bits_sph_idx == 16 ) + IF( EQ_16( bits_sph_idx, 16 ) ) { FOR( b = hQMetaData->q_direction[1].cfg.start_band; b < hQMetaData->q_direction[1].cfg.nbands; b++ ) { FOR( m = 0; m < hQMetaData->q_direction[1].cfg.nblocks; m++ ) { W_nrg_ratio[1][b][m] = W_sub( ONE_IN_Q62, diffuseness_reconstructions_hr_fx[hQMetaData->q_direction[1].band_data[b].energy_ratio_index[m]] ); + move64(); /* Scale energy ratios that sum to over one */ ratioSum = W_round64_L( W_add( W_nrg_ratio[0][b][m], W_nrg_ratio[1][b][m] ) ); @@ -1392,7 +1423,9 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( IF( GT_32( ratioSum, ONE_IN_Q30 ) ) { W_nrg_ratio[0][b][m] = W_shl( (Word64) ( W_nrg_ratio[0][b][m] / ratioSum ), 30 ); // Q62 + move64(); W_nrg_ratio[1][b][m] = W_shl( (Word64) ( W_nrg_ratio[1][b][m] / ratioSum ), 30 ); // Q62 + move64(); } } } @@ -1401,16 +1434,19 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( { Word16 pos_2dir_band[MASA_MAXIMUM_CODING_SUBBANDS]; d = 0; + move16(); FOR( b = hQMetaData->q_direction[0].cfg.start_band; b < hQMetaData->q_direction[0].cfg.nbands; b++ ) { - IF( hQMetaData->twoDirBands[b] == 1 ) + IF( EQ_16( hQMetaData->twoDirBands[b], 1 ) ) { pos_2dir_band[d] = b; + move16(); d++; } ELSE { pos_2dir_band[d] = 0; + move16(); } } FOR( b = hQMetaData->q_direction[1].cfg.start_band; b < hQMetaData->q_direction[1].cfg.nbands; b++ ) @@ -1419,27 +1455,32 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( { W_nrg_ratio[1][b][m] = W_sub( ONE_IN_Q62, diffuseness_reconstructions_hr_fx[hQMetaData->q_direction[1].band_data[b].energy_ratio_index[m]] ); + move64(); ratioSum = W_round64_L( W_add( W_nrg_ratio[0][pos_2dir_band[b]][m], W_nrg_ratio[1][b][m] ) ); IF( GT_32( ratioSum, ONE_IN_Q30 ) ) { W_nrg_ratio[0][pos_2dir_band[b]][m] = W_shl( (Word64) ( W_nrg_ratio[0][pos_2dir_band[b]][m] / ratioSum ), 30 ); + move64(); W_nrg_ratio[1][b][m] = W_shl( (Word64) ( W_nrg_ratio[1][b][m] / ratioSum ), 30 ); + move64(); } } } } } - IF( hQMetaData->no_directions == 2 ) + IF( EQ_32( hQMetaData->no_directions, 2 ) ) { FOR( b = hQMetaData->q_direction[1].cfg.start_band; b < hQMetaData->q_direction[1].cfg.nbands; b++ ) { FOR( m = 0; m < hQMetaData->q_direction[1].cfg.nblocks; m++ ) { hQMetaData->q_direction[1].band_data[b].energy_ratio_index_mod[m] = hQMetaData->q_direction[1].band_data[b].energy_ratio_index[m]; + move16(); hQMetaData->q_direction[1].band_data[b].bits_sph_idx[m] = bits_sph_idx; + move16(); } } } @@ -1449,11 +1490,13 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( FOR( m = 0; m < hQMetaData->q_direction[0].cfg.nblocks; m++ ) { hQMetaData->q_direction[0].band_data[b].energy_ratio_index_mod[m] = hQMetaData->q_direction[0].band_data[b].energy_ratio_index[0]; + move16(); hQMetaData->q_direction[0].band_data[b].bits_sph_idx[m] = bits_sph_idx; + move16(); } } - IF( all_coherence_zero == 0 ) + IF( EQ_32( all_coherence_zero, 0 ) ) { read_surround_coherence_hr_fx( bitstream, index, hQMetaData, W_nrg_ratio ); } @@ -1473,18 +1516,16 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( { q_direction = &hQMetaData->q_direction[d]; nbands = q_direction->cfg.nbands; + move16(); start_band = q_direction->cfg.start_band; + move16(); /* Read coherence, IF any */ - IF( all_coherence_zero == 0 ) + IF( EQ_32( all_coherence_zero, 0 ) ) { -#ifdef IVAS_FLOAT_FIXED read_coherence_data_hr_512_fx( bitstream, index, hQMetaData, d, bits_sp_coh ); -#else - read_coherence_data_hr_512( bitstream, index, hQMetaData, d, bits_sp_coh ); -#endif } - else + ELSE { /*Surround coherence*/ FOR( b = 0; b < hQMetaData->q_direction[0].cfg.nbands; b++ ) @@ -1506,18 +1547,19 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( ivas_qmetadata_raw_decode_dir_512_fx( q_direction, bitstream, index, nbands, start_band, sph_grid16 ); } - IF( hQMetaData->no_directions == 2 ) + IF( EQ_32( hQMetaData->no_directions, 2 ) ) { /* move 2 dir data to its correct subband */ - IF( bits_sph_idx == 11 ) + IF( EQ_16( bits_sph_idx, 11 ) ) { Word16 nblocks; - d = hQMetaData->q_direction[1].cfg.nbands - 1; + d = sub( hQMetaData->q_direction[1].cfg.nbands, 1 ); nblocks = hQMetaData->q_direction[0].cfg.nblocks; + move16(); FOR( b = hQMetaData->q_direction[0].cfg.nbands - 1; b >= 0; b-- ) { - IF( hQMetaData->twoDirBands[b] == 1 ) + IF( EQ_16( hQMetaData->twoDirBands[b], 1 ) ) { Copy32( hQMetaData->q_direction[1].band_data[d].azimuth_fx, hQMetaData->q_direction[1].band_data[b].azimuth_fx, nblocks ); @@ -1556,7 +1598,9 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( IF( GT_32( ratioSum, ONE_IN_Q30 ) ) { W_nrg_ratio[0][b][m] = W_shl( (Word64) ( W_nrg_ratio[0][b][m] / ratioSum ), 30 ); + move64(); W_nrg_ratio[1][b][m] = W_shl( (Word64) ( W_nrg_ratio[1][b][m] / ratioSum ), 30 ); + move64(); } } } @@ -1567,30 +1611,36 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( FOR( m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES; m++ ) { hQMetaData->q_direction[0].band_data[b].energy_ratio_fx[m] = W_round64_L( W_nrg_ratio[0][b][m] ); + move32(); } } - IF( hQMetaData->no_directions == 2 ) + IF( EQ_32( hQMetaData->no_directions, 2 ) ) { FOR( b = 0; b < MASA_MAXIMUM_CODING_SUBBANDS; b++ ) { FOR( m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES; m++ ) { hQMetaData->q_direction[1].band_data[b].energy_ratio_fx[m] = W_round64_L( W_nrg_ratio[1][b][m] ); + move32(); } } } /* Store status information for renderer use */ hQMetaData->ec_flag = 0; + move16(); hQMetaData->dir_comp_ratio_fx = MAX_WORD16; + move16(); hQMetaData->q_direction[0].cfg.nbands = sf_nbands0; - IF( hQMetaData->no_directions == 2 ) + move16(); + IF( EQ_32( hQMetaData->no_directions, 2 ) ) { hQMetaData->q_direction[1].cfg.nbands = sf_nbands1; + move16(); } - return ( start_index_0 - *index ); + return sub( start_index_0, *index ); } #else int16_t ivas_qmetadata_dec_decode_hr_384_512( @@ -1955,7 +2005,7 @@ Word16 ivas_qmetadata_dec_sid_decode( Word16 metadata_sid_bits; /* bits allocated to SID for metadata */ Word16 bits_delta, bits_dir; - IF( ivas_format == SBA_FORMAT ) + IF( EQ_16( ivas_format, SBA_FORMAT ) ) { metadata_sid_bits = (Word16) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - 2 - SID_FORMAT_NBITS; /* -1 for inactive mode header bit*/ } @@ -1965,100 +2015,118 @@ Word16 ivas_qmetadata_dec_sid_decode( } start_index = *index; + move16(); /* read MASA SID descriptor */ - IF( ivas_format == MASA_FORMAT && nchan_transport == 2 ) + test(); + IF( EQ_16( ivas_format, MASA_FORMAT ) && EQ_16( nchan_transport, 2 ) ) { b = bitstream[( *index )--]; + move16(); IF( b ) { *element_mode = IVAS_CPE_MDCT; + move16(); } ELSE { *element_mode = IVAS_CPE_DFT; + move16(); } } /* Fix configuration for SID */ q_direction = &hQMetaData->q_direction[0]; /* only 1 direction */ - IF( ivas_format == SBA_FORMAT ) + IF( EQ_16( ivas_format, SBA_FORMAT ) ) { nbands = DIRAC_DTX_BANDS; /* only 2 bands transmitted */ + move16(); } ELSE { nbands = 5; /* only 5 bands transmitted */ + move16(); } nblocks = q_direction->cfg.nblocks; /* only 1 block transmitted but up to 4 blocks re-generated */ - start_band = 0; /* start from band 0 */ + move16(); + start_band = 0; /* start from band 0 */ + move16(); /* Read 2D signaling*/ - IF( ivas_format != SBA_FORMAT ) + IF( NE_16( ivas_format, SBA_FORMAT ) ) { q_direction->not_in_2D = bitstream[( *index )--]; + move16(); } ELSE { q_direction->not_in_2D = 1; + move16(); } bits_dir = 0; - IF( ivas_format != SBA_FORMAT ) + move16(); + IF( NE_16( ivas_format, SBA_FORMAT ) ) { /* Decode diffuseness*/ FOR( b = start_band; b < nbands; b++ ) { - diffuseness_index[b] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, DIRAC_DIFFUSE_LEVELS - 4 ) + 4; + diffuseness_index[b] = (UWord16) L_add( ivas_qmetadata_DecodeQuasiUniform( bitstream, index, DIRAC_DIFFUSE_LEVELS - 4 ), 4 ); + move16(); q_direction->band_data[b].energy_ratio_index[0] = diffuseness_index[b]; + move16(); q_direction->band_data[b].bits_sph_idx[0] = bits_direction_masa[diffuseness_index[b]]; - bits_dir += q_direction->band_data[b].bits_sph_idx[0]; + move16(); + bits_dir = extract_l( L_add( bits_dir, q_direction->band_data[b].bits_sph_idx[0] ) ); q_direction->band_data[b].azimuth_m_alphabet[0] = no_phi_masa[q_direction->band_data[b].bits_sph_idx[0] - 1][0]; + move16(); } - bits_delta = metadata_sid_bits - ( start_index - *index ) - bits_dir; /* bit_diff is already read */ + bits_delta = sub( sub( metadata_sid_bits, sub( start_index, *index ) ), bits_dir ); /* bit_diff is already read */ - IF( bits_delta > 0 ) + IF( GT_16( bits_delta, 0 ) ) { - WHILE( bits_delta > 0 ) + WHILE( GT_16( bits_delta, 0 ) ) { FOR( b = start_band; b < nbands && ( bits_delta > 0 ); b++ ) { - IF( q_direction->band_data[b].bits_sph_idx[0] < 11 ) + IF( LT_32( q_direction->band_data[b].bits_sph_idx[0], 11 ) ) { - bits_delta -= 1; + bits_delta = sub( bits_delta, 1 ); q_direction->band_data[b].bits_sph_idx[0]++; } } } - IF( q_direction->not_in_2D == 0 ) + IF( EQ_16( q_direction->not_in_2D, 0 ) ) { FOR( b = start_band; b < nbands; b++ ) { - q_direction->band_data[b].azimuth_m_alphabet[0] = 1 << ( min( 8, q_direction->band_data[b].bits_sph_idx[0] ) ); + q_direction->band_data[b].azimuth_m_alphabet[0] = shl( 1, extract_l( L_min( 8, q_direction->band_data[b].bits_sph_idx[0] ) ) ); + move16(); } } } ELSE { - WHILE( bits_delta < 0 ) + WHILE( LT_16( bits_delta, 0 ) ) { FOR( b = nbands - 1; b >= start_band && ( bits_delta < 0 ); b-- ) { - IF( q_direction->band_data[b].bits_sph_idx[0] >= 4 ) + IF( GE_32( q_direction->band_data[b].bits_sph_idx[0], 4 ) ) { - bits_delta += 1; + bits_delta = add( bits_delta, 1 ); q_direction->band_data[b].bits_sph_idx[0]--; } } - IF( q_direction->not_in_2D == 0 ) + IF( EQ_16( q_direction->not_in_2D, 0 ) ) { FOR( b = start_band; b < nbands; b++ ) { - q_direction->band_data[b].azimuth_m_alphabet[0] = 1 << ( min( 8, q_direction->band_data[b].bits_sph_idx[0] ) ); + q_direction->band_data[b].azimuth_m_alphabet[0] = shl( 1, extract_l( L_min( 8, q_direction->band_data[b].bits_sph_idx[0] ) ) ); + move16(); } } } @@ -2069,35 +2137,43 @@ Word16 ivas_qmetadata_dec_sid_decode( /* Decode diffuseness*/ FOR( b = start_band; b < nbands; b++ ) { - diffuseness_index[b] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, DIRAC_DIFFUSE_LEVELS - 4 ) + 4; + diffuseness_index[b] = (UWord16) L_add( ivas_qmetadata_DecodeQuasiUniform( bitstream, index, DIRAC_DIFFUSE_LEVELS - 4 ), 4 ); + move16(); q_direction->band_data[b].energy_ratio_index[0] = diffuseness_index[b]; + move16(); q_direction->band_data[b].bits_sph_idx[0] = bits_direction_masa[diffuseness_index[b]]; + move16(); q_direction->band_data[b].azimuth_m_alphabet[0] = no_phi_masa[q_direction->band_data[b].bits_sph_idx[0] - 1][0]; + move16(); } } FOR( b = start_band; b < nbands; b++ ) { q_direction->band_data[b].energy_ratio_fx[0] = L_sub( ONE_IN_Q30, diffuseness_reconstructions_fx[diffuseness_index[b]] ); + move32(); FOR( i = 0; i < nblocks; i++ ) { q_direction->band_data[b].energy_ratio_fx[i] = q_direction->band_data[b].energy_ratio_fx[0]; + move32(); } } /* Decoder DOAs*/ - IF( q_direction->not_in_2D > 0 ) + IF( GT_16( q_direction->not_in_2D, 0 ) ) { FOR( b = start_band; b < nbands; b++ ) { value = 0; + move16(); FOR( i = 0; i < q_direction->band_data[b].bits_sph_idx[0]; i++ ) { - value = ( value << 1 ) + bitstream[( *index )--]; + value = (UWord16) L_add( L_shl( value, 1 ), bitstream[( *index )--] ); } FOR( i = 0; i < nblocks; i++ ) { q_direction->band_data[b].spherical_index[i] = value; + move16(); } deindex_spherical_component_fx( q_direction->band_data[b].spherical_index[0], &avg_azimuth_fx, &avg_elevation_fx, &q_direction->band_data[b].azimuth_index[0], &q_direction->band_data[b].elevation_index[0], q_direction->band_data[b].bits_sph_idx[0], q_direction->cfg.mc_ls_setup ); @@ -2110,9 +2186,9 @@ Word16 ivas_qmetadata_dec_sid_decode( FOR( m = 0; m < nblocks - 1; m++ ) { v_add_32( direction_vector_fx, avg_direction_vector_fx, direction_vector_fx, 3 ); - ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( direction_vector_fx, 30 - 5, &q_direction->band_data[b].azimuth_fx[m], &q_direction->band_data[b].elevation_fx[m] ); + ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( direction_vector_fx, sub( 30, 5 ), &q_direction->band_data[b].azimuth_fx[m], &q_direction->band_data[b].elevation_fx[m] ); } - ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( avg_direction_vector_fx, 30 - 5, &q_direction->band_data[b].azimuth_fx[nblocks - 1], &q_direction->band_data[b].elevation_fx[nblocks - 1] ); + ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( avg_direction_vector_fx, sub( 30, 5 ), &q_direction->band_data[b].azimuth_fx[nblocks - 1], &q_direction->band_data[b].elevation_fx[nblocks - 1] ); } } ELSE @@ -2120,18 +2196,22 @@ Word16 ivas_qmetadata_dec_sid_decode( FOR( b = start_band; b < nbands; b++ ) { Word32 temp_result; - IF( ivas_format == SBA_FORMAT ) + IF( EQ_16( ivas_format, SBA_FORMAT ) ) { - q_direction->band_data[b].azimuth_m_alphabet[0] = 1 << ( min( 5, q_direction->band_data[b].bits_sph_idx[0] ) ); + q_direction->band_data[b].azimuth_m_alphabet[0] = shl( 1, extract_l( L_min( 5, q_direction->band_data[b].bits_sph_idx[0] ) ) ); + move16(); } q_direction->band_data[b].azimuth_index[0] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, q_direction->band_data[b].azimuth_m_alphabet[0] ); - q_direction->band_data[b].azimuth_index[0] = ivas_qmetadata_dereorder_generic( q_direction->band_data[b].azimuth_index[0] ) + ( q_direction->band_data[b].azimuth_m_alphabet[0] >> 1 ); + move16(); + q_direction->band_data[b].azimuth_index[0] = add( ivas_qmetadata_dereorder_generic( q_direction->band_data[b].azimuth_index[0] ), shr( q_direction->band_data[b].azimuth_m_alphabet[0], 1 ) ); + move16(); temp_result = div_s( ( q_direction->band_data[b].azimuth_index[0] << 6 ), ( q_direction->band_data[b].azimuth_m_alphabet[0] << 6 ) ); temp_result = Mpy_32_16_1( DEGREE_360_Q_22, (Word16) temp_result ); - avg_azimuth_fx = temp_result - DEGREE_180_Q_22; + avg_azimuth_fx = L_sub( temp_result, DEGREE_180_Q_22 ); avg_elevation_fx = 0; + move32(); ivas_qmetadata_azimuth_elevation_to_direction_vector_fx( avg_azimuth_fx, avg_elevation_fx, avg_direction_vector_fx ); ivas_qmetadata_azimuth_elevation_to_direction_vector_fx( q_direction->band_data[b].azimuth_fx[nblocks - 1], q_direction->band_data[b].elevation_fx[nblocks - 1], direction_vector_fx ); @@ -2141,25 +2221,27 @@ Word16 ivas_qmetadata_dec_sid_decode( FOR( m = 0; m < nblocks - 1; m++ ) { v_add_32( direction_vector_fx, avg_direction_vector_fx, direction_vector_fx, 3 ); - ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( direction_vector_fx, 30 - 5, &q_direction->band_data[b].azimuth_fx[m], &q_direction->band_data[b].elevation_fx[m] ); + ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( direction_vector_fx, sub( 30, 5 ), &q_direction->band_data[b].azimuth_fx[m], &q_direction->band_data[b].elevation_fx[m] ); } - ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( avg_direction_vector_fx, 30 - 5, &q_direction->band_data[b].azimuth_fx[nblocks - 1], &q_direction->band_data[b].elevation_fx[nblocks - 1] ); + ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( avg_direction_vector_fx, sub( 30, 5 ), &q_direction->band_data[b].azimuth_fx[nblocks - 1], &q_direction->band_data[b].elevation_fx[nblocks - 1] ); FOR( i = 0; i < nblocks; i++ ) { q_direction->band_data[b].spherical_index[i] = q_direction->band_data[b].azimuth_index[0]; + move16(); } } } /*Read filling bits*/ - WHILE( start_index - *index < metadata_sid_bits ) + WHILE( LT_16( sub( start_index, *index ), metadata_sid_bits ) ) { b = bitstream[( *index )--]; + move16(); } - return ( start_index - *index ); + return sub( start_index, *index ); } #else @@ -2488,35 +2570,41 @@ static Word16 ivas_qmetadata_entropy_decode_diffuseness( Word16 start_band; index_start = *index; + move16(); nbands = q_direction->cfg.nbands; + move16(); start_band = q_direction->cfg.start_band; + move16(); /* diffuseness decoding */ /* Handle one band as special case*/ - IF( nbands == 1 ) + IF( EQ_16( nbands, 1 ) ) { q_direction->band_data[0].energy_ratio_index[0] = 0; + move16(); FOR( b = 0; b < MASA_BITS_ER; b++ ) { - q_direction->band_data[0].energy_ratio_index[0] = ( q_direction->band_data[0].energy_ratio_index[0] << 1 ) + bitstream[( *index )--]; + q_direction->band_data[0].energy_ratio_index[0] = (UWord16) L_add( L_shl( q_direction->band_data[0].energy_ratio_index[0], 1 ), bitstream[( *index )--] ); } *diffuseness_index_max_ec_frame = 5; + move16(); return MASA_BITS_ER; } - IF( bitstream[( *index )--] == 0 ) /* dif_use_raw_coding */ + IF( EQ_32( bitstream[( *index )--], 0 ) ) /* dif_use_raw_coding */ { /* Decode with similarity strategy with low band count. On higher band counts, decode with Huffman-coding strategy. */ - IF( nbands < DIFF_EC_HUFF_BAND_LIMIT ) + IF( LT_16( nbands, DIFF_EC_HUFF_BAND_LIMIT ) ) { - IF( bitstream[( *index )--] != 0 ) /* dif_have_unique_value */ + IF( NE_32( bitstream[( *index )--], 0 ) ) /* dif_have_unique_value */ { dif_min = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, DIRAC_DIFFUSE_LEVELS ); /* dif_unique_value */ FOR( b = start_band; b < nbands; b++ ) { q_direction->band_data[b].energy_ratio_index[0] = dif_min; + move16(); } } ELSE /* all diffuseness values are dif_min_value or dif_min_value + 1 */ @@ -2525,49 +2613,56 @@ static Word16 ivas_qmetadata_entropy_decode_diffuseness( FOR( b = start_band; b < nbands; b++ ) { - q_direction->band_data[b].energy_ratio_index[0] = dif_min + bitstream[( *index )--]; /* dif_bit_offset_values */ + q_direction->band_data[b].energy_ratio_index[0] = (UWord16) L_add( dif_min, bitstream[( *index )--] ); /* dif_bit_offset_values */ + move16(); } } } ELSE { - int16_t av; + Word16 av; /* read average on 3 bits*/ av = 0; + move16(); FOR( b = 0; b < MASA_BITS_ER; b++ ) { - av += bitstream[( *index )--] * ( 1 << ( MASA_BITS_ER - 1 - b ) ); + av = add( av, i_mult( (Word16) bitstream[( *index )--], shl( 1, sub( sub( MASA_BITS_ER, 1 ), b ) ) ) ); } dif_min = DIRAC_DIFFUSE_LEVELS; + move16(); /* read average removed data (average is added inside)*/ FOR( b = start_band; b < nbands; b++ ) { q_direction->band_data[b].energy_ratio_index[0] = ivas_diffuseness_huff_ec_decode_fx( bitstream, index, av ); - dif_min = min( dif_min, q_direction->band_data[b].energy_ratio_index[0] ); + move16(); + dif_min = (UWord16) L_min( dif_min, q_direction->band_data[b].energy_ratio_index[0] ); } } } ELSE /* different values for diffuseness */ { dif_min = DIRAC_DIFFUSE_LEVELS; + move16(); FOR( b = start_band; b < nbands; b++ ) { q_direction->band_data[b].energy_ratio_index[0] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, DIRAC_DIFFUSE_LEVELS ); - dif_min = min( dif_min, q_direction->band_data[b].energy_ratio_index[0] ); + move16(); + dif_min = (UWord16) L_min( dif_min, q_direction->band_data[b].energy_ratio_index[0] ); } } *diffuseness_index_max_ec_frame = 5; + move16(); /* adaptively select the diffuseness_index_max_ec threshold */ - IF( dif_min > 5 ) + IF( GT_32( dif_min, 5 ) ) { - *diffuseness_index_max_ec_frame = DIRAC_DIFFUSE_LEVELS - 1; + *diffuseness_index_max_ec_frame = (UWord16) sub( DIRAC_DIFFUSE_LEVELS, 1 ); } - return ( index_start - *index ); + return sub( index_start, *index ); } #else static int16_t ivas_qmetadata_entropy_decode_diffuseness( @@ -2685,18 +2780,24 @@ static Word16 ivas_qmetadata_entropy_decode_diffuseness_hr_512( Word16 start_band; index_start = *index; + move16(); nbands = q_direction->cfg.nbands; + move16(); nblocks = q_direction->cfg.nblocks; + move16(); start_band = q_direction->cfg.start_band; + move16(); /* diffuseness decoding */ /* Handle one band as special case*/ - IF( nbands == 1 ) + IF( EQ_16( nbands, 1 ) ) { q_direction->band_data[0].energy_ratio_index[0] = 0; + move16(); FOR( b = 0; b < MASA_BITS_ER_HR; b++ ) { - q_direction->band_data[0].energy_ratio_index[0] = ( q_direction->band_data[0].energy_ratio_index[0] << 1 ) + bitstream[( *index )--]; + q_direction->band_data[0].energy_ratio_index[0] = (UWord16) L_add( (UWord16) L_shl( q_direction->band_data[0].energy_ratio_index[0], 1 ), bitstream[( *index )--] ); + move16(); } return MASA_BITS_ER_HR; @@ -2707,10 +2808,11 @@ static Word16 ivas_qmetadata_entropy_decode_diffuseness_hr_512( FOR( k = 0; k < nblocks; k++ ) { q_direction->band_data[b].energy_ratio_index[k] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, HR_MASA_ER_LEVELS ); + move16(); } } - return ( index_start - *index ); + return sub( index_start, *index ); } #else static int16_t ivas_qmetadata_entropy_decode_diffuseness_hr_512( @@ -2779,81 +2881,98 @@ static Word16 ivas_qmetadata_entropy_decode_df_ratio( Word16 max_alphabet_size; index_start = *index; + move16(); nbands = q_direction->cfg.nbands; + move16(); start_band = q_direction->cfg.start_band; + move16(); /* Handle one band as special case*/ - IF( nbands == 1 ) + IF( EQ_16( nbands, 1 ) ) { q_direction->band_data[0].energy_ratio_index[0] = 0; + move16(); FOR( b = 0; b < dfRatio_bits[0]; b++ ) { - q_direction->band_data[0].energy_ratio_index[0] = ( q_direction->band_data[0].energy_ratio_index[0] << 1 ) + bitstream[( *index )--]; + // q_direction->band_data[0].energy_ratio_index[0] = ( q_direction->band_data[0].energy_ratio_index[0] << 1 ) + bitstream[( *index )--]; + q_direction->band_data[0].energy_ratio_index[0] = (UWord16) L_add( L_shl( q_direction->band_data[0].energy_ratio_index[0], 1 ), bitstream[( *index )--] ); } return dfRatio_bits[0]; } /* Calculate raw coding bits and decide what modes are possible */ bits_raw = 0; + move16(); max_dfRatio_bits = 0; + move16(); FOR( b = start_band; b < nbands; b++ ) { - bits_raw += dfRatio_bits[b]; - max_dfRatio_bits = max( max_dfRatio_bits, dfRatio_bits[b] ); + // bits_raw += dfRatio_bits[b]; + bits_raw = add( bits_raw, dfRatio_bits[b] ); + max_dfRatio_bits = s_max( max_dfRatio_bits, dfRatio_bits[b] ); } /* Decide what modes are possible */ - IF( bits_raw >= max_dfRatio_bits + 2 + nbands ) + IF( GE_16( bits_raw, add( add( max_dfRatio_bits, 2 ), nbands ) ) ) { ec_mode = 2; + move16(); } - ELSE IF( bits_raw >= max_dfRatio_bits + 1 ) + ELSE IF( GE_16( bits_raw, add( max_dfRatio_bits, 1 ) ) ) { ec_mode = 1; + move16(); } ELSE { ec_mode = 0; + move16(); } - max_alphabet_size = 1 << max_dfRatio_bits; + max_alphabet_size = shl( 1, max_dfRatio_bits ); dec_mode = 2; /* Default to raw decoding */ - IF( ec_mode == 1 ) + move16(); + IF( EQ_16( ec_mode, 1 ) ) { - IF( bitstream[( *index )--] == 0 ) + IF( EQ_32( bitstream[( *index )--], 0 ) ) { dec_mode = 1; /* Switch to one value EC coding */ + move16(); } } - ELSE IF( ec_mode == 2 ) + ELSE IF( EQ_16( ec_mode, 2 ) ) { - IF( bitstream[( *index )--] == 0 ) + IF( EQ_32( bitstream[( *index )--], 0 ) ) { - IF( bitstream[( *index )--] == 0 ) + IF( EQ_32( bitstream[( *index )--], 0 ) ) { dec_mode = 1; /* Switch to one value EC coding */ + move16(); } ELSE { dec_mode = 0; /* Use one-bit diff bandwise mode */ + move16(); } } } - IF( dec_mode == 2 ) /* Raw decoding */ + IF( EQ_16( dec_mode, 2 ) ) /* Raw decoding */ { FOR( b = start_band; b < nbands; b++ ) { - q_direction->band_data[b].energy_ratio_index[0] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, 1 << dfRatio_bits[b] ); + q_direction->band_data[b].energy_ratio_index[0] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, (UWord16) L_shl( 1, dfRatio_bits[b] ) ); + move16(); } } - ELSE IF( dec_mode == 1 ) /* One value decoding */ + ELSE IF( EQ_16( dec_mode, 1 ) ) /* One value decoding */ { ratio_min = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, max_alphabet_size ); /* dif_unique_value */ FOR( b = start_band; b < nbands; b++ ) { q_direction->band_data[b].energy_ratio_index[0] = ratio_min; + move16(); } } ELSE /* Bandwise 1-bit diff decoding */ @@ -2862,11 +2981,12 @@ static Word16 ivas_qmetadata_entropy_decode_df_ratio( FOR( b = start_band; b < nbands; b++ ) { - q_direction->band_data[b].energy_ratio_index[0] = ratio_min + bitstream[( *index )--]; /* dif_bit_offset_values */ + q_direction->band_data[b].energy_ratio_index[0] = (UWord16) L_add( ratio_min, bitstream[( *index )--] ); /* dif_bit_offset_values */ + move16(); } } - return ( index_start - *index ); + return sub( index_start, *index ); } #else static int16_t ivas_qmetadata_entropy_decode_df_ratio( @@ -3017,37 +3137,45 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( Word16 use_adapt_avg, idx; index_start = *index; + move16(); nblocks = q_direction->cfg.nblocks; + move16(); diff_idx_min = DIRAC_DIFFUSE_LEVELS; + move16(); /*Raw coding for high diffuseness*/ - for ( b = start_band; b < nbands; b++ ) + FOR( b = start_band; b < nbands; b++ ) { IF( hrmasa_flag ) { diff_idx = 0; + move16(); } ELSE { diff_idx = q_direction->band_data[b].energy_ratio_index_mod[0]; + move16(); } - diff_idx_min = min( diff_idx_min, diff_idx ); - IF( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) + diff_idx_min = s_min( diff_idx_min, diff_idx ); + IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) ) { - elev_alph[b] = no_theta_masa[bits_direction_masa[diff_idx] - 3]; + elev_alph[b] = no_theta_masa[sub( bits_direction_masa[diff_idx], 3 )]; + move16(); } ELSE { - elev_alph[b] = no_theta_masa[bits_direction_masa[diff_idx] - 3] * 2 - 1; + elev_alph[b] = sub( shl( no_theta_masa[sub( bits_direction_masa[diff_idx], 3 )], 1 ), 1 ); + move16(); } - IF( q_direction->band_data[b].energy_ratio_index_mod[0] > diffuseness_index_max_ec_frame ) + IF( GT_32( q_direction->band_data[b].energy_ratio_index_mod[0], diffuseness_index_max_ec_frame ) ) { bands_entropic[b] = 0; + move16(); - IF( q_direction->not_in_2D > 0 ) + IF( GT_16( q_direction->not_in_2D, 0 ) ) { decode_fixed_rate_fx( q_direction, bitstream, index, b, nblocks ); } @@ -3057,39 +3185,47 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( FOR( m = 0; m < nblocks; m++ ) { q_direction->band_data[b].elevation_fx[m] = 0; + move32(); q_direction->band_data[b].elevation_index[m] = 0; + move16(); - azith_alph[b][m] = no_phi_masa[bits_direction_masa[diff_idx] - 1][0]; + azith_alph[b][m] = no_phi_masa[sub( bits_direction_masa[diff_idx], 1 )][0]; + move16(); q_direction->band_data[b].azimuth_index[m] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, azith_alph[b][m] ); + move16(); q_direction->band_data[b].azimuth_fx[m] = deindex_azimuth_fx( q_direction->band_data[b].azimuth_index[m], q_direction->band_data[b].bits_sph_idx[m], 0, 1, q_direction->cfg.mc_ls_setup ); + move32(); } } } ELSE { bands_entropic[b] = 1; + move16(); } } /*EC for the low diffuseness*/ /*Elevation only if not 2D */ - IF( q_direction->not_in_2D > 0 ) + IF( GT_16( q_direction->not_in_2D, 0 ) ) { - IF( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) + IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) ) { - avg_elevation_alphabet = no_theta_masa[bits_direction_masa[diff_idx_min] - 3]; + avg_elevation_alphabet = no_theta_masa[sub( bits_direction_masa[diff_idx_min], 3 )]; + move16(); avg_elevation_idx = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, avg_elevation_alphabet ); } ELSE { - avg_elevation_alphabet = no_theta_masa[bits_direction_masa[diff_idx_min] - 3] * 2 - 1; + avg_elevation_alphabet = sub( shl( no_theta_masa[sub( bits_direction_masa[diff_idx_min], 3 )], 1 ), 1 ); avg_elevation_idx = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, avg_elevation_alphabet ); - avg_elevation_idx = ivas_qmetadata_dereorder_generic( avg_elevation_idx ) + ( avg_elevation_alphabet >> 1 ); + avg_elevation_idx = add( ivas_qmetadata_dereorder_generic( avg_elevation_idx ), shr( avg_elevation_alphabet, 1 ) ); } gr_param_elev = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, 4 + 1 ); - IF( gr_param_elev == 4 ) /* all the elevation distances are zero */ + move16(); + IF( EQ_32( gr_param_elev, 4 ) ) /* all the elevation distances are zero */ { FOR( b = start_band; b < nbands; b++ ) { @@ -3099,13 +3235,14 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( IF( hrmasa_flag ) { diff_idx = 0; + move16(); } ELSE { diff_idx = q_direction->band_data[b].energy_ratio_index_mod[0]; } - IF( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) + IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) ) { avg_elevation_index_projected = ivas_chan_project_elevation_index( avg_elevation_idx, avg_elevation_alphabet, elev_alph[b] ); } @@ -3114,34 +3251,39 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( avg_elevation_index_projected = ivas_dirac_project_elevation_index( avg_elevation_idx, avg_elevation_alphabet, elev_alph[b] ); /*reorder elevation indexing*/ - tmp_index = avg_elevation_index_projected - ( elev_alph[b] >> 1 ); - IF( tmp_index < 0 ) + tmp_index = sub( avg_elevation_index_projected, shr( elev_alph[b], 1 ) ); + IF( LT_16( tmp_index, 0 ) ) { - tmp_index = tmp_index * -2; + tmp_index = negate( shl( tmp_index, 1 ) ); } - ELSE IF( tmp_index > 0 ) + ELSE IF( GT_16( tmp_index, 0 ) ) { - tmp_index = tmp_index * 2 - 1; + tmp_index = sub( shl( tmp_index, 1 ), 1 ); } avg_elevation_index_projected = tmp_index; + move16(); } FOR( m = 0; m < nblocks; m++ ) { q_direction->band_data[b].elevation_index[m] = avg_elevation_index_projected; + move16(); /*deduce aplhabet for azimuth*/ - IF( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) + IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) ) { - azith_alph[b][m] = no_phi_masa[bits_direction_masa[diff_idx] - 1][q_direction->band_data[b].elevation_index[m]]; + azith_alph[b][m] = no_phi_masa[sub( bits_direction_masa[diff_idx], 1 )][q_direction->band_data[b].elevation_index[m]]; + move16(); } ELSE { - azith_alph[b][m] = no_phi_masa[bits_direction_masa[diff_idx] - 1][( q_direction->band_data[b].elevation_index[m] + 1 ) >> 1]; + azith_alph[b][m] = no_phi_masa[sub( bits_direction_masa[diff_idx], 1 )][extract_l( L_shr( L_add( q_direction->band_data[b].elevation_index[m], 1 ), 1 ) )]; + move16(); } /*decode elevation*/ q_direction->band_data[b].elevation_fx[m] = deindex_elevation_fx( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->cfg.mc_ls_setup ); + move32(); } } } @@ -3155,31 +3297,35 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( IF( hrmasa_flag ) { diff_idx = 0; + move16(); } ELSE { diff_idx = q_direction->band_data[b].energy_ratio_index_mod[0]; + move16(); } FOR( m = 0; m < nblocks; m++ ) { Word16 tmp_index; - IF( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) + IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) ) { avg_elevation_index_projected = ivas_chan_project_elevation_index( avg_elevation_idx, avg_elevation_alphabet, elev_alph[b] ); - tmp_index = ivas_qmetadata_DecodeExtendedGR( bitstream, index, 2 * elev_alph[b] - 1, gr_param_elev ); - IF( tmp_index % 2 ) + tmp_index = ivas_qmetadata_DecodeExtendedGR( bitstream, index, sub( shl( elev_alph[b], 1 ), 1 ), gr_param_elev ); + IF( s_and( tmp_index, 1 ) ) { - tmp_index = avg_elevation_index_projected + ( ( tmp_index + 1 ) >> 1 ); + tmp_index = add( avg_elevation_index_projected, shr( add( tmp_index, 1 ), 1 ) ); } ELSE { - tmp_index = avg_elevation_index_projected - ( tmp_index >> 1 ); + tmp_index = sub( avg_elevation_index_projected, shr( tmp_index, 1 ) ); } q_direction->band_data[b].elevation_index[m] = tmp_index; + move16(); /*deduce aplhabet for azimuth*/ - azith_alph[b][m] = no_phi_masa[bits_direction_masa[diff_idx] - 1][q_direction->band_data[b].elevation_index[m]]; + azith_alph[b][m] = no_phi_masa[sub( bits_direction_masa[diff_idx], 1 )][q_direction->band_data[b].elevation_index[m]]; + move16(); } ELSE { @@ -3189,23 +3335,26 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( tmp_index = ivas_qmetadata_ReorderElevationDecoded( tmp_index, avg_elevation_index_projected, elev_alph[b] ); /*reorder elevation indexing*/ - tmp_index = tmp_index - ( elev_alph[b] >> 1 ); - IF( tmp_index < 0 ) + tmp_index = sub( tmp_index, shr( elev_alph[b], 1 ) ); + IF( LT_16( tmp_index, 0 ) ) { - tmp_index = tmp_index * -2; + tmp_index = negate( shl( tmp_index, 1 ) ); } - ELSE IF( tmp_index > 0 ) + ELSE IF( GT_16( tmp_index, 0 ) ) { - tmp_index = tmp_index * 2 - 1; + tmp_index = sub( shl( tmp_index, 1 ), 1 ); } q_direction->band_data[b].elevation_index[m] = tmp_index; + move16(); /*deduce aplhabet for azimuth*/ - azith_alph[b][m] = no_phi_masa[bits_direction_masa[diff_idx] - 1][( q_direction->band_data[b].elevation_index[m] + 1 ) >> 1]; + azith_alph[b][m] = no_phi_masa[sub( bits_direction_masa[diff_idx], 1 )][extract_l( L_shr( L_add( q_direction->band_data[b].elevation_index[m], 1 ), 1 ) )]; + move16(); } /*decode elevation*/ q_direction->band_data[b].elevation_fx[m] = deindex_elevation_fx( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->cfg.mc_ls_setup ); + move32(); } } } @@ -3220,41 +3369,48 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( IF( hrmasa_flag ) { diff_idx = 0; + move16(); } ELSE { diff_idx = q_direction->band_data[b].energy_ratio_index_mod[0]; + move16(); } FOR( m = 0; m < nblocks; m++ ) { q_direction->band_data[b].elevation_index[m] = 0; + move16(); /*deduce alphabet for azimuth*/ - IF( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) + IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) ) { - azith_alph[b][m] = no_phi_masa[bits_direction_masa[diff_idx] - 1][q_direction->band_data[b].elevation_index[m]]; + azith_alph[b][m] = no_phi_masa[sub( bits_direction_masa[diff_idx], 1 )][q_direction->band_data[b].elevation_index[m]]; + move16(); } ELSE { - azith_alph[b][m] = no_phi_masa[bits_direction_masa[diff_idx] - 1][( q_direction->band_data[b].elevation_index[m] + 1 ) >> 1]; + azith_alph[b][m] = no_phi_masa[sub( bits_direction_masa[diff_idx], 1 )][extract_l( L_shr( L_add( q_direction->band_data[b].elevation_index[m], 1 ), 1 ) )]; + move16(); } /*decode elevation*/ q_direction->band_data[b].elevation_fx[m] = deindex_elevation_fx( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->cfg.mc_ls_setup ); + move32(); } } } } /*Azimuth*/ - avg_azimuth_alphabet = no_phi_masa[bits_direction_masa[diff_idx_min] - 1][0]; /* average azimuth is quantized on the equatorial plane */ + avg_azimuth_alphabet = no_phi_masa[sub( bits_direction_masa[diff_idx_min], 1 )][0]; /* average azimuth is quantized on the equatorial plane */ + move16(); avg_azimuth_index = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, avg_azimuth_alphabet ); avg_azimuth_index = ivas_qmetadata_dereorder_generic( avg_azimuth_index ); - avg_azimuth_index = avg_azimuth_index + ( avg_azimuth_alphabet >> 1 ); + avg_azimuth_index = add( avg_azimuth_index, shr( avg_azimuth_alphabet, 1 ) ); gr_param_azith = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, 5 + 1 ); - IF( gr_param_azith == 5 ) /* all the azimuth distances are zero */ + IF( EQ_32( gr_param_azith, 5 ) ) /* all the azimuth distances are zero */ { FOR( b = start_band; b < nbands; b++ ) { @@ -3263,14 +3419,17 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( FOR( m = 0; m < nblocks; m++ ) { q_direction->band_data[b].azimuth_index[m] = ivas_dirac_project_azimuth_index( avg_azimuth_index, avg_azimuth_alphabet, azith_alph[b][m] ); + move16(); - IF( azith_alph[b][m] == 1 ) + IF( EQ_16( azith_alph[b][m], 1 ) ) { q_direction->band_data[b].azimuth_fx[m] = 0; + move32(); } ELSE { q_direction->band_data[b].azimuth_fx[m] = deindex_azimuth_fx( q_direction->band_data[b].azimuth_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->band_data[b].elevation_index[m], 0, q_direction->cfg.mc_ls_setup ); + move32(); } } } @@ -3280,7 +3439,9 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( { set32_fx( avg_direction_vector_fx, 0, 3 ); use_adapt_avg = 0; + move16(); idx = 0; + move16(); FOR( b = start_band; b < nbands; b++ ) { @@ -3288,26 +3449,31 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( { FOR( m = 0; m < nblocks; m++ ) { - IF( ( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) && ( idx == MASA_LIMIT_IDX_AVG_AZI ) && ( nblocks > 1 ) ) + IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) && EQ_16( idx, MASA_LIMIT_IDX_AVG_AZI ) && GT_16( nblocks, 1 ) ) { use_adapt_avg = bitstream[*index]; + move16(); ( *index )--; } avg_azimuth_index_projected = ivas_dirac_project_azimuth_index( avg_azimuth_index, avg_azimuth_alphabet, azith_alph[b][m] ); q_direction->band_data[b].azimuth_index[m] = ivas_qmetadata_DecodeExtendedGR( bitstream, index, azith_alph[b][m], gr_param_azith ); + move16(); q_direction->band_data[b].azimuth_index[m] = ivas_qmetadata_ReorderElevationDecoded( q_direction->band_data[b].azimuth_index[m], avg_azimuth_index_projected, azith_alph[b][m] ); + move16(); - IF( azith_alph[b][m] == 1 ) + IF( EQ_16( azith_alph[b][m], 1 ) ) { q_direction->band_data[b].azimuth_fx[m] = 0; + move32(); } ELSE { q_direction->band_data[b].azimuth_fx[m] = deindex_azimuth_fx( q_direction->band_data[b].azimuth_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->band_data[b].elevation_index[m], 0, q_direction->cfg.mc_ls_setup ); + move32(); } - IF( ( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) && ( nblocks > 1 ) ) + IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) && GT_16( nblocks, 1 ) ) { - IF( idx < MASA_LIMIT_IDX_AVG_AZI ) + IF( LT_16( idx, MASA_LIMIT_IDX_AVG_AZI ) ) { ivas_qmetadata_azimuth_elevation_to_direction_vector_fx( q_direction->band_data[b].azimuth_fx[m], q_direction->band_data[b].elevation_fx[m], direction_vector_fx ); v_shr_32( direction_vector_fx, direction_vector_fx, 3, 5 ); @@ -3315,13 +3481,14 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( } ELSE { - IF( use_adapt_avg == 1 ) + IF( EQ_16( use_adapt_avg, 1 ) ) { - IF( m == 0 ) + IF( EQ_16( m, 0 ) ) { FOR( Word16 l = 0; l < 3; l++ ) { avg_direction_vector_fx[l] = L_shr( avg_direction_vector_fx[l], 1 ); + move32(); } } /*compute the average direction per already coded subband */ @@ -3339,7 +3506,7 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( } } - return ( index_start - *index ); + return sub( index_start, *index ); } #else static int16_t ivas_qmetadata_entropy_decode_dir( @@ -3712,20 +3879,24 @@ static Word16 ivas_qmetadata_raw_decode_dir_512_fx( UWord16 value; index_start = *index; + move16(); nblocks = q_direction->cfg.nblocks; + move16(); FOR( b = start_band; b < nbands; b++ ) { FOR( m = 0; m < nblocks; m++ ) { value = 0; + move16(); FOR( i = 0; i < q_direction->band_data[b].bits_sph_idx[m]; i++ ) { - value = ( value << 1 ) + bitstream[( *index )--]; + value = (UWord16) L_add( (UWord16) L_shl( value, 1 ), bitstream[( *index )--] ); } q_direction->band_data[b].spherical_index[m] = value; + move16(); - IF( q_direction->band_data[b].bits_sph_idx[m] == 16 ) + IF( EQ_32( q_direction->band_data[b].bits_sph_idx[m], 16 ) ) { deindex_sph_idx_fx( value, sph_grid16, &( q_direction->band_data[b].elevation_fx[m] ), &( q_direction->band_data[b].azimuth_fx[m] ) ); } @@ -3736,7 +3907,7 @@ static Word16 ivas_qmetadata_raw_decode_dir_512_fx( } } - return ( index_start - *index ); + return sub( index_start, *index ); } #else static int16_t ivas_qmetadata_raw_decode_dir_512( @@ -3799,11 +3970,13 @@ static Word16 ivas_qmetadata_raw_decode_dir_fx( Word16 index_start; index_start = *index; + move16(); nblocks = q_direction->cfg.nblocks; + move16(); FOR( b = start_band; b < nbands; b++ ) { - IF( q_direction->not_in_2D > 0 ) + IF( GT_16( q_direction->not_in_2D, 0 ) ) { decode_fixed_rate_fx( q_direction, bitstream, index, b, nblocks ); } @@ -3812,24 +3985,31 @@ static Word16 ivas_qmetadata_raw_decode_dir_fx( IF( hrmasa_flag ) { diff_idx = 0; + move16(); } ELSE { diff_idx = q_direction->band_data[b].energy_ratio_index_mod[0]; + move16(); } FOR( m = 0; m < nblocks; m++ ) { q_direction->band_data[b].elevation_fx[m] = 0; + move32(); q_direction->band_data[b].elevation_index[m] = 0; - azith_alph = no_phi_masa[bits_direction_masa[diff_idx] - 1][0]; + move16(); + azith_alph = no_phi_masa[sub( bits_direction_masa[diff_idx], 1 )][0]; + move16(); q_direction->band_data[b].azimuth_index[m] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, azith_alph ); + move16(); q_direction->band_data[b].azimuth_fx[m] = deindex_azimuth_fx( q_direction->band_data[b].azimuth_index[m], q_direction->band_data[b].bits_sph_idx[m], 0, 1, q_direction->cfg.mc_ls_setup ); + move32(); } } } - return ( index_start - *index ); + return sub( index_start, *index ); } #else /*------------------------------------------------------------------------- @@ -3905,18 +4085,19 @@ static UWord16 ivas_qmetadata_DecodeQuasiUniform( UWord16 tresh, value; - bits = 30 - norm_l( alphabet_size ); /* bits = floor(log2(alphabet_size)) */ - tresh = ( 1U << ( bits + 1 ) ) - alphabet_size; + bits = sub( 30, norm_l( alphabet_size ) ); /* bits = floor(log2(alphabet_size)) */ + tresh = (UWord16) L_sub( (UWord16) L_shl( 1U, add( bits, 1 ) ), alphabet_size ); value = 0; + move16(); FOR( i = 0; i < bits; i++ ) { - value = ( value << 1 ) + bitstream[( *index )--]; + value = (UWord16) L_add( (UWord16) L_shl( value, 1 ), bitstream[( *index )--] ); } - IF( value >= tresh ) + IF( GE_32( value, tresh ) ) { - value = ( value << 1 ) - tresh + bitstream[( *index )--]; + value = (UWord16) L_add( (UWord16) L_sub( (UWord16) L_shl( value, 1 ), tresh ), bitstream[( *index )--] ); } return value; @@ -3971,35 +4152,37 @@ Word16 ivas_qmetadata_DecodeExtendedGR( UWord16 value; Word16 msb, lsb; - msb_size = ( alph_size + ( 1 << gr_param ) - 1 ) >> gr_param; /* ceil division */ - IF( msb_size <= 3 ) + msb_size = shr( add( alph_size, sub( shl( 1, gr_param ), 1 ) ), gr_param ); /* ceil division */ + IF( LE_16( msb_size, 3 ) ) { value = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, alph_size ); } ELSE { msb = 0; - WHILE( ( msb < msb_size - 1 ) && ( bitstream[*index] != 0 ) ) + move16(); + WHILE( LT_16( msb, sub( msb_size, 1 ) ) && NE_32( bitstream[*index], 0 ) ) { msb++; ( *index )--; } - IF( msb == msb_size - 1 ) + IF( EQ_16( msb, sub( msb_size, 1 ) ) ) { - lsb = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, alph_size - ( ( msb_size - 1 ) << gr_param ) ); + lsb = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, sub( alph_size, shl( sub( msb_size, 1 ), gr_param ) ) ); } ELSE { ( *index )--; lsb = 0; + move16(); FOR( i = 0; i < gr_param; i++ ) { - lsb = ( lsb << 1 ) + bitstream[( *index )--]; + lsb = extract_l( L_add( shl( lsb, 1 ), bitstream[( *index )--] ) ); } } - value = ( msb << gr_param ) + lsb; + value = (UWord16) add( shl( msb, gr_param ), lsb ); } return value; @@ -4069,15 +4252,15 @@ static Word16 ivas_qmetadata_ReorderElevationDecoded( Word16 elev_index_reorder; dist_reorder = ivas_qmetadata_dereorder_generic( elev_dist ); - elev_index_reorder = elev_avg + dist_reorder; + elev_index_reorder = add( elev_avg, dist_reorder ); - IF( elev_index_reorder < 0 ) + IF( LT_16( elev_index_reorder, 0 ) ) { - elev_index_reorder += elev_alph; + elev_index_reorder = add( elev_index_reorder, elev_alph ); } - ELSE IF( elev_index_reorder >= elev_alph ) + ELSE IF( GE_16( elev_index_reorder, elev_alph ) ) { - elev_index_reorder -= elev_alph; + elev_index_reorder = sub( elev_index_reorder, elev_alph ); } return elev_index_reorder; @@ -4132,115 +4315,140 @@ static Word16 read_directions_fx( Word16 *bits_dir0; bit_pos = *pbit_pos; + move16(); diff = 0; + move16(); IF( q_direction->not_in_2D ) { - IF( coding_subbands > 1 ) + IF( GT_16( coding_subbands, 1 ) ) { - j = ind_order[coding_subbands - 1]; + j = ind_order[sub( coding_subbands, 1 )]; + move16(); allowed_bits = 0; + move16(); FOR( k = 0; k < masa_subframes; k++ ) { - allowed_bits += q_direction->band_data[j].bits_sph_idx[k]; + allowed_bits = extract_l( L_add( allowed_bits, q_direction->band_data[j].bits_sph_idx[k] ) ); } - last_j = j - ( allowed_bits == 0 ); + last_j = sub( j, (Word16) EQ_16( allowed_bits, 0 ) ); FOR( j = 0; j < last_j; j++ ) { i = ind_order[j]; + move16(); bits_dir0 = (Word16 *) q_direction->band_data[i].bits_sph_idx; nbits = 0; - allowed_bits = sum_s( bits_dir0, q_direction->cfg.nblocks ); + move16(); + allowed_bits = sum16_fx( bits_dir0, q_direction->cfg.nblocks ); use_vq = 0; + move16(); max_nb_idx = 0; + move16(); FOR( k = 0; k < q_direction->cfg.nblocks; k++ ) { - IF( bits_dir0[k] > use_vq ) + IF( GT_16( bits_dir0[k], use_vq ) ) { use_vq = bits_dir0[k]; + move16(); max_nb_idx = k; + move16(); } } - IF( q_direction->cfg.nblocks == 1 ) + IF( EQ_16( q_direction->cfg.nblocks, 1 ) ) { byteBuffer = 0; + move16(); } ELSE { byteBuffer = 0; - IF( use_vq <= 1 ) + move16(); + IF( LE_16( use_vq, 1 ) ) { byteBuffer = 1; + move16(); } - IF( use_vq > 1 && use_vq <= LIMIT_USE_COMMON ) + test(); + IF( GT_16( use_vq, 1 ) && LE_16( use_vq, LIMIT_USE_COMMON ) ) { - bits_dir0[max_nb_idx] -= 1; - allowed_bits -= 1; + bits_dir0[max_nb_idx] = sub( bits_dir0[max_nb_idx], 1 ); + move16(); + allowed_bits = sub( allowed_bits, 1 ); /* read 1 bit to tell if joint of VQ coding */ byteBuffer = bitstream[bit_pos--]; + move16(); } } FOR( k = 0; k < masa_subframes; k++ ) { q_direction->band_data[i].bits_sph_idx[k] = bits_dir0[k]; - IF( bits_dir0[k] > 2 ) + move16(); + IF( GT_16( bits_dir0[k], 2 ) ) { - IF( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) + IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) ) { - q_direction->band_data[i].elevation_m_alphabet[k] = no_theta_masa[bits_dir0[k] - 3]; + q_direction->band_data[i].elevation_m_alphabet[k] = no_theta_masa[sub( bits_dir0[k], 3 )]; + move16(); } ELSE { - q_direction->band_data[i].elevation_m_alphabet[k] = no_theta_masa[bits_dir0[k] - 3] * 2 - 1; + q_direction->band_data[i].elevation_m_alphabet[k] = sub( shl( no_theta_masa[sub( bits_dir0[k], 3 )], 1 ), 1 ); + move16(); } } ELSE { q_direction->band_data[i].elevation_m_alphabet[k] = 1; + move16(); } } - IF( allowed_bits > 0 ) + IF( GT_16( allowed_bits, 0 ) ) { - IF( byteBuffer == 1 ) + IF( EQ_32( byteBuffer, 1 ) ) { nbits = read_common_direction_fx( bitstream, q_direction, i, masa_subframes, allowed_bits, &bit_pos ); } ELSE { - IF( q_direction->cfg.nblocks == 1 && q_direction->band_data[i].bits_sph_idx[0] <= MASA_MIN_BITS_TF + 1 ) + test(); + IF( EQ_16( q_direction->cfg.nblocks, 1 ) && LE_32( q_direction->band_data[i].bits_sph_idx[0], L_add( MASA_MIN_BITS_TF, 1 ) ) ) { /* there is fixed rate only, no need to read */ fixed_rate = 1; + move16(); nbits = 0; + move16(); } ELSE { /* check if fixed_rate */ fixed_rate = bitstream[bit_pos--]; + move16(); nbits = 1; + move16(); } - IF( fixed_rate == 1 ) + IF( EQ_16( fixed_rate, 1 ) ) { /* decode_fixed_rate()*/ - nbits += decode_fixed_rate_fx( q_direction, bitstream, &bit_pos, i, masa_subframes ); + nbits = add( nbits, decode_fixed_rate_fx( q_direction, bitstream, &bit_pos, i, masa_subframes ) ); } ELSE { /* decode elevation */ - nbits += decode_elevation_fx( q_direction, bitstream, &bit_pos, i, masa_subframes ); + nbits = add( nbits, decode_elevation_fx( q_direction, bitstream, &bit_pos, i, masa_subframes ) ); /* decode azimuth */ - nbits += decode_azimuth_fx( q_direction, bitstream, &bit_pos, i, masa_subframes ); + nbits = add( nbits, decode_azimuth_fx( q_direction, bitstream, &bit_pos, i, masa_subframes ) ); } } } @@ -4249,7 +4457,7 @@ static Word16 read_directions_fx( set_zero_direction_fx( q_direction, i, masa_subframes ); } - diff += nbits - allowed_bits; + diff = add( diff, sub( nbits, allowed_bits ) ); /* update bits for next block */ update_bits_next_block( q_direction, &diff, ind_order[j + 1], coding_subbands, masa_subframes ); @@ -4258,56 +4466,69 @@ static Word16 read_directions_fx( ELSE { last_j = q_direction->cfg.start_band; + move16(); } FOR( j = last_j; j < coding_subbands; j++ ) { i = ind_order[j]; + move16(); bits_dir0 = (Word16 *) q_direction->band_data[i].bits_sph_idx; nbits = 0; - allowed_bits = sum_s( bits_dir0, q_direction->cfg.nblocks ); - IF( allowed_bits > 0 && masa_subframes == 1 ) + move16(); + allowed_bits = sum16_fx( bits_dir0, q_direction->cfg.nblocks ); + test(); + IF( GT_16( allowed_bits, 0 ) && EQ_16( masa_subframes, 1 ) ) { - nbits += decode_fixed_rate_fx( q_direction, bitstream, &bit_pos, i, masa_subframes ); + nbits = add( nbits, decode_fixed_rate_fx( q_direction, bitstream, &bit_pos, i, masa_subframes ) ); } ELSE { - IF( allowed_bits > 0 ) + IF( GT_16( allowed_bits, 0 ) ) { use_vq = 0; + move16(); max_nb_idx = 0; + move16(); FOR( k = 0; k < masa_subframes; k++ ) { - IF( bits_dir0[k] > use_vq ) + IF( GT_16( bits_dir0[k], use_vq ) ) { use_vq = bits_dir0[k]; + move16(); max_nb_idx = k; + move16(); } } byteBuffer = 0; + move16(); - IF( use_vq > 1 && use_vq <= LIMIT_USE_COMMON ) + test(); + IF( GT_16( use_vq, 1 ) && LE_16( use_vq, LIMIT_USE_COMMON ) ) { - bits_dir0[max_nb_idx] -= 1; - allowed_bits -= 1; + bits_dir0[max_nb_idx] = sub( bits_dir0[max_nb_idx], 1 ); + move16(); + allowed_bits = sub( allowed_bits, 1 ); /* read 1 bit to tell if joint of VQ coding */ byteBuffer = bitstream[bit_pos--]; + move16(); } - IF( allowed_bits > 0 ) + IF( GT_16( allowed_bits, 0 ) ) { - IF( byteBuffer == 1 || use_vq <= 1 ) + test(); + IF( EQ_32( byteBuffer, 1 ) || LE_16( use_vq, 1 ) ) { nbits = read_common_direction_fx( bitstream, q_direction, i, masa_subframes, allowed_bits, &bit_pos ); } ELSE { /* decode_fixed_rate()*/ - nbits += decode_fixed_rate_fx( q_direction, bitstream, &bit_pos, i, masa_subframes ); + nbits = add( nbits, decode_fixed_rate_fx( q_direction, bitstream, &bit_pos, i, masa_subframes ) ); } } ELSE @@ -4330,14 +4551,17 @@ static Word16 read_directions_fx( FOR( k = 0; k < q_direction->cfg.nblocks; k++ ) { q_direction->band_data[j].elevation_fx[k] = 0; + move32(); q_direction->band_data[j].elevation_index[k] = 0; + move16(); } } nbits = decode_azimuth2D_fx( q_direction, bitstream, coding_subbands, &bit_pos, masa_subframes ); } - nbits = *pbit_pos - bit_pos; + nbits = sub( *pbit_pos, bit_pos ); *pbit_pos = bit_pos; + move16(); return nbits; } @@ -4589,63 +4813,77 @@ static Word16 decode_azimuth_fx( Word16 j_az, max_val; nbits = 0; + move16(); bit_pos = *pbit_pos; + move16(); byteBuffer = 0; + move16(); j_az = 0; + move16(); /* check number of valid indexes to decode */ FOR( k = 0; k < masa_subframes; k++ ) { - IF( q_direction->band_data[idx_subband].azimuth_index[k] < MASA_NO_INDEX ) + IF( LT_32( q_direction->band_data[idx_subband].azimuth_index[k], MASA_NO_INDEX ) ) { j_az++; } ELSE { q_direction->band_data[idx_subband].azimuth_fx[k] = 0; /*To be in sync with encoder values.*/ + move32(); } } - IF( j_az == 0 ) + IF( EQ_16( j_az, 0 ) ) { return nbits; } - IF( byteBuffer == 0 ) + IF( EQ_32( byteBuffer, 0 ) ) { /* use context */ use_context = 0; + move16(); FOR( k = 0; k < masa_subframes; k++ ) { - IF( q_direction->band_data[idx_subband].bits_sph_idx[k] <= 1 ) + IF( LE_32( q_direction->band_data[idx_subband].bits_sph_idx[k], 1 ) ) { use_context = 1; + move16(); } } - IF( use_context == 1 ) + IF( EQ_32( use_context, 1 ) ) { FOR( k = 0; k < masa_subframes; k++ ) { - IF( q_direction->band_data[idx_subband].bits_sph_idx[k] == 0 ) + IF( EQ_32( q_direction->band_data[idx_subband].bits_sph_idx[k], 0 ) ) { q_direction->band_data[idx_subband].azimuth_index[k] = 0; + move16(); q_direction->band_data[idx_subband].azimuth_fx[k] = 0; + move32(); } ELSE { - IF( q_direction->band_data[idx_subband].bits_sph_idx[k] == 1 ) + IF( EQ_32( q_direction->band_data[idx_subband].bits_sph_idx[k], 1 ) ) { byteBuffer = bitstream[bit_pos--]; + move16(); q_direction->band_data[idx_subband].azimuth_index[k] = byteBuffer; + move16(); - q_direction->band_data[idx_subband].azimuth_fx[k] = L_shl( q_direction->band_data[idx_subband].azimuth_index[k] * ( -180 ), 22 ); + q_direction->band_data[idx_subband].azimuth_fx[k] = L_shl( q_direction->band_data[idx_subband].azimuth_index[k] * ( -180 ), Q22 ); + move32(); } ELSE { - q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - ( q_direction->band_data[idx_subband].bits_sph_idx[k] == 2 ) ); + q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[idx_subband].azimuth_m_alphabet[k], sub( MASA_GR_ORD_AZ, (Word16) EQ_32( q_direction->band_data[idx_subband].bits_sph_idx[k], 2 ) ) ); + move16(); q_direction->band_data[idx_subband].azimuth_fx[k] = deindex_azimuth_fx( q_direction->band_data[idx_subband].azimuth_index[k], q_direction->band_data[idx_subband].bits_sph_idx[k], q_direction->band_data[idx_subband].elevation_index[k], 1, q_direction->cfg.mc_ls_setup ); + move32(); } } } @@ -4654,31 +4892,39 @@ static Word16 decode_azimuth_fx( { /* read bit to check if min removed encoding */ byteBuffer = bitstream[bit_pos--]; - IF( byteBuffer == 0 ) /* regular GR coding5 */ + move16(); + IF( EQ_32( byteBuffer, 0 ) ) /* regular GR coding5 */ { /* read GR_order */ byteBuffer = bitstream[bit_pos--]; - nbits += 1; + move16(); + nbits = add( nbits, 1 ); FOR( k = 0; k < masa_subframes; k++ ) { - IF( q_direction->band_data[idx_subband].bits_sph_idx[k] > 0 ) + IF( GT_32( q_direction->band_data[idx_subband].bits_sph_idx[k], 0 ) ) { - IF( no_phi_masa[q_direction->band_data[idx_subband].bits_sph_idx[k] - 1][q_direction->band_data[idx_subband].elevation_index[k]] > 1 ) + IF( GT_16( no_phi_masa[L_sub( q_direction->band_data[idx_subband].bits_sph_idx[k], 1 )][q_direction->band_data[idx_subband].elevation_index[k]], 1 ) ) { - q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - byteBuffer ); + q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[idx_subband].azimuth_m_alphabet[k], extract_l( L_sub( MASA_GR_ORD_AZ, byteBuffer ) ) ); + move16(); q_direction->band_data[idx_subband].azimuth_fx[k] = deindex_azimuth_fx( q_direction->band_data[idx_subband].azimuth_index[k], q_direction->band_data[idx_subband].bits_sph_idx[k], q_direction->band_data[idx_subband].elevation_index[k], 1, q_direction->cfg.mc_ls_setup ); + move32(); } ELSE { q_direction->band_data[idx_subband].azimuth_fx[k] = 0; + move32(); q_direction->band_data[idx_subband].azimuth_index[k] = 0; + move16(); } } ELSE { q_direction->band_data[idx_subband].azimuth_fx[k] = 0; + move32(); q_direction->band_data[idx_subband].azimuth_index[k] = 0; + move16(); } } } @@ -4687,39 +4933,48 @@ static Word16 decode_azimuth_fx( /* min removed GR coding */ /* read GR_order */ byteBuffer = bitstream[bit_pos--]; + move16(); /* read min index value */ maximum_s( q_direction->band_data[idx_subband].azimuth_m_alphabet, masa_subframes, &max_val ); min_idx = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, max_val, MASA_GR_ORD_AZ ); FOR( k = 0; k < masa_subframes; k++ ) { - IF( q_direction->band_data[idx_subband].bits_sph_idx[k] > 0 ) + IF( GT_32( q_direction->band_data[idx_subband].bits_sph_idx[k], 0 ) ) { - IF( no_phi_masa[q_direction->band_data[idx_subband].bits_sph_idx[k] - 1][q_direction->band_data[idx_subband].elevation_index[k]] > 1 ) + IF( GT_16( no_phi_masa[sub( q_direction->band_data[idx_subband].bits_sph_idx[k], 1 )][q_direction->band_data[idx_subband].elevation_index[k]], 1 ) ) { - q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - 1 - byteBuffer ); - q_direction->band_data[idx_subband].azimuth_index[k] += min_idx; + q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[idx_subband].azimuth_m_alphabet[k], extract_l( L_sub( L_sub( MASA_GR_ORD_AZ, 1 ), byteBuffer ) ) ); + move16(); + q_direction->band_data[idx_subband].azimuth_index[k] = (UWord16) L_add( q_direction->band_data[idx_subband].azimuth_index[k], min_idx ); + move16(); q_direction->band_data[idx_subband].azimuth_fx[k] = deindex_azimuth_fx( q_direction->band_data[idx_subband].azimuth_index[k], q_direction->band_data[idx_subband].bits_sph_idx[k], q_direction->band_data[idx_subband].elevation_index[k], 1, q_direction->cfg.mc_ls_setup ); + move32(); } ELSE { q_direction->band_data[idx_subband].azimuth_fx[k] = 0; + move32(); q_direction->band_data[idx_subband].azimuth_index[k] = 0; + move16(); } } ELSE { q_direction->band_data[idx_subband].azimuth_fx[k] = 0; + move32(); q_direction->band_data[idx_subband].azimuth_index[k] = 0; + move16(); } } } } } - nbits = *pbit_pos - bit_pos; + nbits = sub( *pbit_pos, bit_pos ); *pbit_pos = bit_pos; + move16(); return nbits; } @@ -4898,32 +5153,42 @@ static Word16 decode_elevation_fx( UWord16 same_idx; nr_NO_INDEX = 0; + move16(); nbits = 0; + move16(); bit_pos = *pbit_pos; + move16(); FOR( k = 0; k < masa_subframes; k++ ) { q_direction->band_data[j].elevation_index[k] = 0; + move16(); q_direction->band_data[j].elevation_fx[k] = 0; + move32(); - IF( q_direction->band_data[j].bits_sph_idx[k] > 0 ) + IF( GT_32( q_direction->band_data[j].bits_sph_idx[k], 0 ) ) { - IF( q_direction->band_data[j].bits_sph_idx[k] <= 2 ) + IF( LE_32( q_direction->band_data[j].bits_sph_idx[k], 2 ) ) { q_direction->band_data[j].elevation_index[k] = MASA_NO_INDEX; - nr_NO_INDEX += 1; + move16(); + nr_NO_INDEX = add( nr_NO_INDEX, 1 ); q_direction->band_data[j].elevation_fx[k] = 0; + move32(); q_direction->band_data[j].elevation_m_alphabet[k] = 1; + move16(); } ELSE { - IF( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) + IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) ) { - q_direction->band_data[j].elevation_m_alphabet[k] = no_theta_masa[q_direction->band_data[j].bits_sph_idx[k] - 3]; + q_direction->band_data[j].elevation_m_alphabet[k] = no_theta_masa[sub( q_direction->band_data[j].bits_sph_idx[k], 3 )]; + move16(); } ELSE { - q_direction->band_data[j].elevation_m_alphabet[k] = no_theta_masa[q_direction->band_data[j].bits_sph_idx[k] - 3] * 2 - 1; + q_direction->band_data[j].elevation_m_alphabet[k] = sub( shl( no_theta_masa[sub( q_direction->band_data[j].bits_sph_idx[k], 3 )], 1 ), 1 ); + move16(); } } } @@ -4933,24 +5198,29 @@ static Word16 decode_elevation_fx( } } - IF( nr_NO_INDEX < masa_subframes ) + IF( LT_16( nr_NO_INDEX, masa_subframes ) ) { { /* read if same or not */ byteBuffer = bitstream[bit_pos--]; - IF( byteBuffer == 1 ) /* same value */ + move16(); + IF( EQ_32( byteBuffer, 1 ) ) /* same value */ { /* read value */ byteBuffer = bitstream[bit_pos--]; - byteBuffer = ( byteBuffer << 1 ) + bitstream[bit_pos--]; + move16(); + byteBuffer = (UWord16) L_add( L_shl( byteBuffer, 1 ), bitstream[bit_pos--] ); same_idx = byteBuffer; + move16(); FOR( k = 0; k < masa_subframes; k++ ) { - IF( q_direction->band_data[j].elevation_index[k] < MASA_NO_INDEX ) + IF( LT_32( q_direction->band_data[j].elevation_index[k], MASA_NO_INDEX ) ) { q_direction->band_data[j].elevation_index[k] = same_idx; + move16(); q_direction->band_data[j].elevation_fx[k] = deindex_elevation_fx( &q_direction->band_data[j].elevation_index[k], q_direction->band_data[j].bits_sph_idx[k], q_direction->cfg.mc_ls_setup ); + move32(); } } } @@ -4958,14 +5228,17 @@ static Word16 decode_elevation_fx( { /* not same; decode mean removed GR */ byteBuffer = bitstream[bit_pos--]; - GR_ord_elevation = MASA_GR_ORD_EL - byteBuffer; + move16(); + GR_ord_elevation = extract_l( L_sub( MASA_GR_ORD_EL, byteBuffer ) ); FOR( k = 0; k < masa_subframes; k++ ) { - IF( q_direction->band_data[j].elevation_index[k] < MASA_NO_INDEX ) + IF( LT_32( q_direction->band_data[j].elevation_index[k], MASA_NO_INDEX ) ) { q_direction->band_data[j].elevation_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[j].elevation_m_alphabet[k], GR_ord_elevation ); + move16(); q_direction->band_data[j].elevation_fx[k] = deindex_elevation_fx( &q_direction->band_data[j].elevation_index[k], q_direction->band_data[j].bits_sph_idx[k], q_direction->cfg.mc_ls_setup ); + move32(); } } } @@ -4974,29 +5247,37 @@ static Word16 decode_elevation_fx( FOR( k = 0; k < masa_subframes; k++ ) { - IF( ( q_direction->band_data[j].elevation_index[k] < MASA_NO_INDEX ) && - ( no_phi_masa[q_direction->band_data[j].bits_sph_idx[k] - 1][q_direction->band_data[j].elevation_index[k]] <= 1 ) ) + test(); + IF( LT_32( q_direction->band_data[j].elevation_index[k], MASA_NO_INDEX ) && + LE_16( no_phi_masa[sub( q_direction->band_data[j].bits_sph_idx[k], 1 )][q_direction->band_data[j].elevation_index[k]], 1 ) ) { q_direction->band_data[j].azimuth_index[k] = MASA_NO_INDEX; + move16(); q_direction->band_data[j].azimuth_m_alphabet[k] = 1; + move16(); } ELSE { q_direction->band_data[j].azimuth_index[k] = 0; - IF( q_direction->band_data[j].elevation_index[k] < MASA_NO_INDEX ) + move16(); + IF( LT_32( q_direction->band_data[j].elevation_index[k], MASA_NO_INDEX ) ) { - q_direction->band_data[j].azimuth_m_alphabet[k] = no_phi_masa[q_direction->band_data[j].bits_sph_idx[k] - 1][q_direction->band_data[j].elevation_index[k]]; + q_direction->band_data[j].azimuth_m_alphabet[k] = no_phi_masa[sub( q_direction->band_data[j].bits_sph_idx[k], 1 )][q_direction->band_data[j].elevation_index[k]]; + move16(); } ELSE { - q_direction->band_data[j].azimuth_m_alphabet[k] = no_phi_masa[q_direction->band_data[j].bits_sph_idx[k] - 1][0]; + q_direction->band_data[j].azimuth_m_alphabet[k] = no_phi_masa[sub( q_direction->band_data[j].bits_sph_idx[k], 1 )][0]; + move16(); q_direction->band_data[j].elevation_index[k] = 0; + move16(); } } } - nbits = *pbit_pos - bit_pos; + nbits = sub( *pbit_pos, bit_pos ); *pbit_pos = bit_pos; + move16(); return nbits; } @@ -5134,17 +5415,20 @@ static Word16 decode_fixed_rate_fx( UWord16 value; nbits = 0; + move16(); FOR( m = 0; m < nblocks; m++ ) { value = 0; + move16(); FOR( i = 0; i < q_direction->band_data[b].bits_sph_idx[m]; i++ ) { - value = ( value << 1 ) + bitstream[( *pbit_pos )--]; + value = (UWord16) L_add( L_shl( value, 1 ), bitstream[( *pbit_pos )--] ); } q_direction->band_data[b].spherical_index[m] = value; - nbits += q_direction->band_data[b].bits_sph_idx[m]; + move16(); + nbits = extract_l( L_add( nbits, q_direction->band_data[b].bits_sph_idx[m] ) ); deindex_spherical_component_fx( q_direction->band_data[b].spherical_index[m], &q_direction->band_data[b].azimuth_fx[m], &q_direction->band_data[b].elevation_fx[m], &q_direction->band_data[b].azimuth_index[m], &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->cfg.mc_ls_setup ); } @@ -5213,40 +5497,47 @@ static Word16 decode_azimuth2D_fx( Word16 *bits_dir0; bit_pos = *pbit_pos; + move16(); nbits = 0; + move16(); FOR( j = 0; j < coding_subbands; j++ ) { bits_dir0 = (Word16 *) q_direction->band_data[j].bits_sph_idx; - allowed_bits = sum_s( bits_dir0, no_frames ); + allowed_bits = sum16_fx( bits_dir0, no_frames ); - IF( allowed_bits > 0 ) + IF( GT_16( allowed_bits, 0 ) ) { use_vq = 0; + move16(); FOR( k = 0; k < no_frames; k++ ) { q_direction->band_data[j].elevation_fx[k] = 0; + move32(); q_direction->band_data[j].elevation_index[k] = 0; + move16(); - IF( bits_dir0[k] > use_vq ) + IF( GT_16( bits_dir0[k], use_vq ) ) { use_vq = bits_dir0[k]; + move16(); } } - IF( use_vq <= 3 && allowed_bits <= 11 ) + test(); + IF( LE_16( use_vq, 3 ) && LE_16( allowed_bits, 11 ) ) { - IF( allowed_bits <= no_frames + 1 ) + IF( LE_16( allowed_bits, add( no_frames, 1 ) ) ) { - set_l( q_direction->band_data[j].azimuth_fx, 0, no_frames ); - FOR( k = 0; k < min( allowed_bits, no_frames ); k++ ) + set32_fx( q_direction->band_data[j].azimuth_fx, 0, no_frames ); + FOR( k = 0; k < s_min( allowed_bits, no_frames ); k++ ) { - q_direction->band_data[j].azimuth_fx[k] = L_shl( -180 * bitstream[bit_pos--], 22 ); - nbits += 1; + q_direction->band_data[j].azimuth_fx[k] = L_shl( -180 * bitstream[bit_pos--], Q22 ); + nbits = add( nbits, 1 ); } } ELSE { - nbits += read_truncGR_azimuth_fx( bitstream, q_direction, j, no_frames, &bit_pos ); + nbits = add( nbits, read_truncGR_azimuth_fx( bitstream, q_direction, j, no_frames, &bit_pos ) ); } } ELSE @@ -5254,22 +5545,26 @@ static Word16 decode_azimuth2D_fx( FOR( k = 0; k < no_frames; k++ ) { Buffer = 0; + move16(); FOR( i = 0; i < bits_dir0[k]; i++ ) { - Buffer = ( Buffer << 1 ) + bitstream[bit_pos--]; + Buffer = (UWord16) L_add( L_shl( Buffer, 1 ), bitstream[bit_pos--] ); } - nbits += bits_dir0[k]; + nbits = add( nbits, bits_dir0[k] ); - IF( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) + IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) ) { - q_direction->band_data[j].azimuth_fx[k] = L_shl( 360, 22 - bits_dir0[k] ) * Buffer - L_shl( 180, 22 ); + q_direction->band_data[j].azimuth_fx[k] = L_shl( 360, Q22 - bits_dir0[k] ) * Buffer - L_shl( 180, Q22 ); + move32(); q_direction->band_data[j].azimuth_fx[k] = companding_azimuth_fx( q_direction->band_data[j].azimuth_fx[k], q_direction->cfg.mc_ls_setup, ( q_direction->band_data[j].elevation_fx[k] > MC_MASA_THR_ELEVATION * ( 1 << 22 ) ), -1 ); + move32(); } ELSE { - q_direction->band_data[j].azimuth_fx[k] = L_shl( 360, 22 - bits_dir0[k] ) * Buffer - L_shl( 180, 22 ); + q_direction->band_data[j].azimuth_fx[k] = L_shl( 360, Q22 - bits_dir0[k] ) * Buffer - L_shl( 180, Q22 ); + move32(); } } } @@ -5280,6 +5575,7 @@ static Word16 decode_azimuth2D_fx( } } *pbit_pos = bit_pos; + move16(); return nbits; } @@ -5388,10 +5684,15 @@ static void set_zero_direction_fx( FOR( k = 0; k < len; k++ ) { q_direction->band_data[idx_band].azimuth_fx[k] = 0; + move32(); q_direction->band_data[idx_band].azimuth_index[k] = 0; + move16(); q_direction->band_data[idx_band].elevation_fx[k] = 0; + move32(); q_direction->band_data[idx_band].elevation_index[k] = 0; + move16(); q_direction->band_data[idx_band].spherical_index[k] = 0; + move16(); } return; @@ -5438,19 +5739,22 @@ static Word16 read_truncGR_azimuth_fx( UWord16 idx; Word16 no_symb, allowed_bits; - allowed_bits = sum_s( (Word16 *) q_direction->band_data[j].bits_sph_idx, no_subframes ); + allowed_bits = sum16_fx( (Word16 *) q_direction->band_data[j].bits_sph_idx, no_subframes ); nbits = 0; - IF( allowed_bits <= no_subframes + 1 ) + move16(); + IF( LE_16( allowed_bits, add( no_subframes, 1 ) ) ) { FOR( i = 0; i < min( allowed_bits, no_subframes ); i++ ) { - IF( bitstream[( *pbit_pos )--] == 0 ) + IF( EQ_32( bitstream[( *pbit_pos )--], 0 ) ) { q_direction->band_data[j].azimuth_fx[i] = 0; + move32(); } ELSE { q_direction->band_data[j].azimuth_fx[i] = L_shl( -180, 22 ); + move32(); } nbits++; } @@ -5458,37 +5762,45 @@ static Word16 read_truncGR_azimuth_fx( return nbits; } - IF( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) + IF( NE_16( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) ) { no_symb = 9; + move16(); } ELSE { no_symb = 8; + move16(); } nbits = 0; + move16(); nbits = *pbit_pos; + move16(); FOR( i = 0; i < no_subframes; i++ ) { idx = ivas_qmetadata_DecodeExtendedGR( bitstream, pbit_pos, no_symb, 0 ); q_direction->band_data[j].azimuth_index[i] = idx; - IF( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) + move16(); + IF( NE_16( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) ) { - q_direction->band_data[j].azimuth_fx[i] = cb_azi_chan_fx[( idx + 1 ) >> 1]; - IF( idx % 2 > 0 ) + q_direction->band_data[j].azimuth_fx[i] = cb_azi_chan_fx[(UWord16) L_shr( (UWord16) L_add( idx, 1 ), 1 )]; + move32(); + IF( GT_32( L_and( idx, 1 ), 0 ) ) { - q_direction->band_data[j].azimuth_fx[i] = -q_direction->band_data[j].azimuth_fx[i]; + q_direction->band_data[j].azimuth_fx[i] = L_negate( q_direction->band_data[j].azimuth_fx[i] ); + move32(); } } ELSE { q_direction->band_data[j].azimuth_fx[i] = azimuth_cb_fx[idx]; + move32(); } } - nbits -= *pbit_pos; + nbits = sub( nbits, *pbit_pos ); return nbits; } @@ -5586,24 +5898,29 @@ static Word16 read_common_direction_fx( Word16 bits_el; bit_pos = *pbit_pos; + move16(); nbits = 0; + move16(); set_zero_direction_fx( q_direction, j, no_subframes ); - IF( bits_total == 0 ) + IF( EQ_16( bits_total, 0 ) ) { return nbits; } - IF( bits_total <= no_subframes + 1 ) + IF( LE_16( bits_total, add( no_subframes, 1 ) ) ) { - FOR( i = 0; i < min( no_subframes, bits_total ); i++ ) + FOR( i = 0; i < s_min( no_subframes, bits_total ); i++ ) { byteBuffer = bitstream[bit_pos--]; + move16(); /*qdirection->azimuth_index[j][i] = (uint16_t)byteBuffer; */ q_direction->band_data[j].azimuth_fx[i] = azimuth_cb_fx[byteBuffer]; - nbits += 1; + move32(); + nbits = add( nbits, 1 ); } *pbit_pos = bit_pos; + move16(); /*nbits += read_truncGR_azimuth(bitstream, qdirection, j, no_subframes, pbit_pos); */ return nbits; @@ -5611,73 +5928,84 @@ static Word16 read_common_direction_fx( byteBuffer = bitstream[bit_pos--]; + move16(); bits_el = 1; - nbits += 1; + move16(); + nbits = add( nbits, 1 ); /* elevation is already set to 0*/ - IF( byteBuffer == 1 ) + IF( EQ_32( byteBuffer, 1 ) ) { byteBuffer = bitstream[bit_pos--]; - bits_el += 1; - nbits += 1; - IF( byteBuffer == 0 ) + move16(); + bits_el = add( bits_el, 1 ); + nbits = add( nbits, 1 ); + IF( EQ_32( byteBuffer, 0 ) ) { FOR( i = 0; i < no_subframes; i++ ) { q_direction->band_data[j].elevation_fx[i] = delta_theta_masa_fx[2]; + move32(); } } ELSE { byteBuffer = bitstream[bit_pos--]; - bits_el += 1; - nbits += 1; - IF( byteBuffer == 0 ) + move16(); + bits_el = add( bits_el, 1 ); + nbits = add( nbits, 1 ); + IF( EQ_32( byteBuffer, 0 ) ) { FOR( i = 0; i < no_subframes; i++ ) { - q_direction->band_data[j].elevation_fx[i] = -delta_theta_masa_fx[2]; + q_direction->band_data[j].elevation_fx[i] = L_negate( delta_theta_masa_fx[2] ); + move32(); } } ELSE { /* theta is +/- 90; no azimuth is read */ byteBuffer = bitstream[bit_pos--]; - nbits += 1; - IF( byteBuffer == 0 ) + move16(); + nbits = add( nbits, 1 ); + IF( EQ_32( byteBuffer, 0 ) ) { - set32_fx( q_direction->band_data[j].elevation_fx, 90 << 22, no_subframes ); + set32_fx( q_direction->band_data[j].elevation_fx, L_shl( 90, Q22 ), no_subframes ); set32_fx( q_direction->band_data[j].azimuth_fx, 0, no_subframes ); } ELSE { - set32_fx( q_direction->band_data[j].elevation_fx, -90, no_subframes ); + set32_fx( q_direction->band_data[j].elevation_fx, L_shl( -90, Q22 ), no_subframes ); set32_fx( q_direction->band_data[j].azimuth_fx, 0, no_subframes ); } *pbit_pos = bit_pos; + move16(); return nbits; } } } - bits_el = sum_s( (Word16 *) q_direction->band_data[j].bits_sph_idx, no_subframes ) - bits_el; + bits_el = sub( sum16_fx( (Word16 *) q_direction->band_data[j].bits_sph_idx, no_subframes ), bits_el ); - IF( bits_el <= no_subframes + 1 ) + IF( LE_16( bits_el, add( no_subframes, 1 ) ) ) { - nbits += min( no_subframes, bits_el ); - FOR( i = 0; i < min( no_subframes, bits_el ); i++ ) + nbits = add( nbits, s_min( no_subframes, bits_el ) ); + FOR( i = 0; i < s_min( no_subframes, bits_el ); i++ ) { byteBuffer = bitstream[bit_pos--]; + move16(); /*qdirection->azimuth_index[j][i] = (uint16_t) byteBuffer; */ q_direction->band_data[j].azimuth_fx[i] = azimuth_cb_fx[byteBuffer]; + move32(); } } ELSE { - nbits += read_truncGR_azimuth_fx( bitstream, q_direction, j, no_subframes, &bit_pos ); + nbits = add( nbits, read_truncGR_azimuth_fx( bitstream, q_direction, j, no_subframes, &bit_pos ) ); } *pbit_pos = bit_pos; + move16(); return nbits; } @@ -5817,51 +6145,56 @@ static void decode_spread_coherence_fx( Word16 min_index; coding_subbands_0 = hQMetaData->q_direction[0].cfg.nbands; + move16(); coding_subbands = hQMetaData->q_direction[idx_d].cfg.nbands; - IF( coding_subbands_0 <= 5 ) + move16(); + IF( LE_16( coding_subbands_0, 5 ) ) { FOR( j = 0; j < 5; j++ ) { MASA_grouping[j] = j; + move16(); } } ELSE { - IF( coding_subbands_0 <= 8 ) + IF( LE_16( coding_subbands_0, 8 ) ) { - mvs2s( MASA_grouping_8_to_5, MASA_grouping, 8 ); + Copy( MASA_grouping_8_to_5, MASA_grouping, 8 ); } - ELSE IF( coding_subbands_0 <= 12 ) + ELSE IF( LE_16( coding_subbands_0, 12 ) ) { - mvs2s( MASA_grouping_12_to_5, MASA_grouping, 12 ); + Copy( MASA_grouping_12_to_5, MASA_grouping, 12 ); } - ELSE IF( coding_subbands_0 <= 18 ) + ELSE IF( LE_16( coding_subbands_0, 18 ) ) { - mvs2s( MASA_grouping_18_to_5, MASA_grouping, 18 ); + Copy( MASA_grouping_18_to_5, MASA_grouping, 18 ); } ELSE { - IF( coding_subbands_0 <= 24 ) + IF( LE_16( coding_subbands_0, 24 ) ) { - mvs2s( MASA_grouping_24_to_5, MASA_grouping, 24 ); + Copy( MASA_grouping_24_to_5, MASA_grouping, 24 ); } } } - IF( coding_subbands < coding_subbands_0 ) + IF( LT_16( coding_subbands, coding_subbands_0 ) ) { d = 0; + move16(); FOR( j = 0; j < coding_subbands_0; j++ ) { - IF( hQMetaData->twoDirBands[j] == 1 ) + IF( EQ_16( hQMetaData->twoDirBands[j], 1 ) ) { two_dir_band[d++] = j; + move16(); } } } ELSE { - set_s( two_dir_band, 0, coding_subbands ); + set16_fx( two_dir_band, 0, coding_subbands ); } q_direction = &hQMetaData->q_direction[idx_d]; @@ -5872,37 +6205,42 @@ static void decode_spread_coherence_fx( IF( hrmasa_flag ) { minimum_s( (Word16 *) ( q_direction->band_data[i].energy_ratio_index ), q_direction->cfg.nblocks, &min_index ); - min_index = min_index >> 1; + min_index = shr( min_index, 1 ); } ELSE { min_index = q_direction->band_data[i].energy_ratio_index[0]; + move16(); } - IF( var_azi_fx < L_shl( MASA_DELTA_AZI_DCT0, 22 ) ) + IF( LT_64( var_azi_fx, L_shl( MASA_DELTA_AZI_DCT0, 22 ) ) ) { - idx_sub_cb = MASA_NO_CV_COH * min_index; + idx_sub_cb = i_mult( MASA_NO_CV_COH, min_index ); } ELSE { - idx_sub_cb = MASA_NO_CV_COH * ( min_index + DIRAC_DIFFUSE_LEVELS ); /* NO_CV_COH = 8 */ + idx_sub_cb = i_mult( MASA_NO_CV_COH, add( min_index, DIRAC_DIFFUSE_LEVELS ) ); /* NO_CV_COH = 8 */ } dct_coh_fx[i][0] = coherence_cb0_masa_fx[idx_sub_cb + q_direction->coherence_band_data[i].spread_coherence_dct0_index]; + move32(); - IF( coding_subbands < coding_subbands_0 ) + IF( LT_16( coding_subbands, coding_subbands_0 ) ) { assert( idx_d == 1 ); dct_coh_fx[i][1] = coherence_cb1_masa_fx[MASA_grouping[two_dir_band[i]] * MASA_NO_CV_COH1 + q_direction->coherence_band_data[i].spread_coherence_dct1_index]; + move32(); } ELSE { dct_coh_fx[i][1] = coherence_cb1_masa_fx[MASA_grouping[i] * MASA_NO_CV_COH1 + q_direction->coherence_band_data[i].spread_coherence_dct1_index]; + move32(); } FOR( j = 2; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { dct_coh_fx[i][j] = 0; + move32(); } invdct4_transform_fx( dct_coh_fx[i], q_direction->coherence_band_data[i].spread_coherence, 21 ); @@ -6047,25 +6385,32 @@ static ivas_error read_huf( UWord16 i; end_pos = start_pos; + move16(); nbits = 0; + move16(); val = 0; - WHILE( ( done == 0 ) && ( nbits < max_len ) ) + move16(); + WHILE( EQ_16( done, 0 ) && LT_16( nbits, max_len ) ) { ByteBuffer = bitstream[end_pos--]; - val = val * 2 + ( ByteBuffer & 1 ); - nbits += 1; + move16(); + val = add( shl( val, 1 ), (Word16) L_and( ByteBuffer, 1 ) ); + nbits = add( nbits, 1 ); FOR( i = 0; i < len; i++ ) { - IF( val == huff_code[i] ) + IF( EQ_16( val, huff_code[i] ) ) { *out = i; + move16(); done = 1; + move16(); BREAK; } } } *num_bits_read = end_pos; + move16(); return IVAS_ERR_OK; } @@ -6132,40 +6477,51 @@ static Word16 read_GR_min_removed_data( Word16 min_index; bit_pos = *p_bit_pos; + move16(); /* read GR order */ byteBuffer = bitstream[bit_pos--]; + move16(); nbits = 1; + move16(); /* read min index */ bits_GR = bit_pos; + move16(); min_index = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, no_symb, 0 ); - nbits += bits_GR - bit_pos; + nbits = add( nbits, sub( bits_GR, bit_pos ) ); /* read GR data */ FOR( j = 0; j < no_data; j++ ) { bits_GR = bit_pos; - IF( no_cv_vec[j] > 1 ) + move16(); + IF( GT_16( no_cv_vec[j], 1 ) ) { - decoded_idx[j] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, no_cv_vec[j] - min_index, ( byteBuffer & 1 ) ); - nbits += bits_GR - bit_pos; + decoded_idx[j] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, sub( no_cv_vec[j], min_index ), extract_l( L_and( byteBuffer, 1 ) ) ); + move16(); + nbits = add( nbits, sub( bits_GR, bit_pos ) ); } ELSE { decoded_idx[j] = 0; + move16(); } } - FOR( j = 0; j < no_data; j++ ){ - IF( no_cv_vec[j] > 1 ){ - decoded_idx[j] += min_index; -} -} + FOR( j = 0; j < no_data; j++ ) + { + IF( GT_16( no_cv_vec[j], 1 ) ) + { + decoded_idx[j] = add( decoded_idx[j], min_index ); + move16(); + } + } -*p_bit_pos = bit_pos; + *p_bit_pos = bit_pos; + move16(); -return nbits; + return nbits; } #else static int16_t read_GR_min_removed_data( @@ -6250,29 +6606,35 @@ static Word16 decode_fixed_rate_composed_index_coherence_fx( Word16 no_bits_vec; bit_pos = *p_bit_pos; - set_s( (Word16 *) temp_index, 0, MASA_MAXIMUM_CODING_SUBBANDS ); + move16(); + set16_fx( (Word16 *) temp_index, 0, MASA_MAXIMUM_CODING_SUBBANDS ); no_cb = 1; + move64(); nbits = 0; - IF( no_bands > MASA_LIMIT_NO_BANDS_SUR_COH ) + move16(); + IF( GT_16( no_bands, MASA_LIMIT_NO_BANDS_SUR_COH ) ) { /* read 8-max_val with GR0 */ bits_GR = bit_pos; - no_vals_local = no_symb - ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, no_symb, 0 ); - nbits += bits_GR - bit_pos; + move16(); + no_vals_local = sub( no_symb, ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, no_symb, 0 ) ); + nbits = add( nbits, sub( bits_GR, bit_pos ) ); FOR( j = 0; j < no_bands; j++ ) { - IF( no_cv_vec[j] > no_vals_local ) + IF( GT_16( no_cv_vec[j], no_vals_local ) ) { no_cv_vec[j] = no_vals_local; + move16(); } } } - half_no_bands = no_bands / 2; - IF( sum_s( no_cv_vec, no_bands ) > MASA_COH_LIMIT_2IDX ) + half_no_bands = shr( no_bands, 1 ); + IF( GT_16( sum16_fx( no_cv_vec, no_bands ), MASA_COH_LIMIT_2IDX ) ) { no_cb = 1; + move64(); FOR( j = 0; j < half_no_bands; j++ ) { @@ -6280,6 +6642,7 @@ static Word16 decode_fixed_rate_composed_index_coherence_fx( } no_bits_vec = (Word16) ceil_log_2( no_cb ); no_cb = 1; + move64(); FOR( j = half_no_bands; j < no_bands; j++ ) { no_cb *= no_cv_vec[j]; @@ -6289,51 +6652,58 @@ static Word16 decode_fixed_rate_composed_index_coherence_fx( ELSE { no_cb = 1; + move64(); FOR( j = 0; j < no_bands; j++ ) { no_cb *= no_cv_vec[j]; } no_bits_vec = (Word16) ceil_log_2( no_cb ); no_bits_vec1 = 0; + move16(); } - IF( no_bits_vec1 > 0 ) + IF( GT_16( no_bits_vec1, 0 ) ) { idx_fr = 0; + move64(); FOR( j = 0; j < no_bits_vec; j++ ) { idx_fr = ( idx_fr << 1 ) + bitstream[bit_pos--]; } - nbits += no_bits_vec; + nbits = add( nbits, no_bits_vec ); decode_combined_index_fx( idx_fr, no_cv_vec, temp_index, half_no_bands ); idx_fr = 0; + move64(); FOR( j = 0; j < no_bits_vec1; j++ ) { idx_fr = ( idx_fr << 1 ) + bitstream[bit_pos--]; } - nbits += no_bits_vec1; + nbits = add( nbits, no_bits_vec1 ); decode_combined_index_fx( idx_fr, &no_cv_vec[half_no_bands], &temp_index[half_no_bands], half_no_bands ); } ELSE { idx_fr = 0; + move64(); FOR( j = 0; j < no_bits_vec; j++ ) { idx_fr = ( idx_fr << 1 ) + bitstream[bit_pos--]; } - nbits += no_bits_vec; + nbits = add( nbits, no_bits_vec ); decode_combined_index_fx( idx_fr, no_cv_vec, temp_index, no_bands ); } FOR( j = 0; j < no_bands; j++ ) { decoded_index[j] = temp_index[j]; + move16(); } - nbits = *p_bit_pos - bit_pos; + nbits = sub( *p_bit_pos, bit_pos ); *p_bit_pos = bit_pos; + move16(); return nbits; } @@ -6470,29 +6840,34 @@ static Word16 read_coherence_data_hr_512_fx( Word32 delta_fx, decoded_idx_fx; // q = 22, q = 9 nbands = hQMetaData->q_direction[idx_dir].cfg.nbands; + move16(); nblocks = hQMetaData->q_direction[idx_dir].cfg.nblocks; + move16(); - cb_size = 1 << nbits_coh; - delta_fx = L_shl( 256, 22 - nbits_coh ); + cb_size = shl( 1, nbits_coh ); + delta_fx = L_shl( 256, sub( 22, nbits_coh ) ); nbits = *p_bit_pos; + move16(); FOR( k = 0; k < nblocks; k++ ) { /* read method */ - IF( bitstream[( *p_bit_pos )--] == 1 ) + IF( EQ_32( bitstream[( *p_bit_pos )--], 1 ) ) { /* average removed */ /* read average index */ min_index = 0; + move16(); FOR( i = 0; i < nbits_coh; i++ ) { min_index = add( shl( min_index, 1 ), bitstream[( *p_bit_pos )--] ); } /* read GR param */ GR_param = bitstream[( *p_bit_pos )--]; + move16(); FOR( j = 0; j < nbands; j++ ) { - decoded_idx = ivas_qmetadata_DecodeExtendedGR( bitstream, p_bit_pos, 2 * cb_size, GR_param ); - IF( decoded_idx % 2 ) + decoded_idx = ivas_qmetadata_DecodeExtendedGR( bitstream, p_bit_pos, shl( cb_size, 1 ), GR_param ); + IF( EQ_16( s_and( decoded_idx, 1 ), 1 ) ) { decoded_idx = add( shr( add( decoded_idx, 1 ), 1 ), min_index ); } @@ -6508,6 +6883,7 @@ static Word16 read_coherence_data_hr_512_fx( { /* read min_index */ min_index = 0; + move16(); FOR( i = 0; i < nbits_coh; i++ ) { min_index = add( shl( min_index, 1 ), bitstream[( *p_bit_pos )--] ); @@ -6515,9 +6891,10 @@ static Word16 read_coherence_data_hr_512_fx( /* read GR param */ GR_param = bitstream[( *p_bit_pos )--]; + move16(); FOR( j = 0; j < nbands; j++ ) { - decoded_idx = ivas_qmetadata_DecodeExtendedGR( bitstream, p_bit_pos, cb_size - min_index, GR_param ) + min_index; + decoded_idx = add( ivas_qmetadata_DecodeExtendedGR( bitstream, p_bit_pos, cb_size - min_index, GR_param ), min_index ); decoded_idx_fx = L_shl( decoded_idx, 9 ); hQMetaData->q_direction[idx_dir].coherence_band_data[j].spread_coherence[k] = (UWord8) L_add( Mpy_32_32( decoded_idx_fx, delta_fx ), L_shr( delta_fx, 23 ) ); } @@ -6639,27 +7016,32 @@ static Word16 read_coherence_data_fx( Word32 res; coding_subbands = hQMetaData->q_direction[idx_dir].cfg.nbands; + move16(); extra_cv = (Word16) ( coding_subbands / MASA_FACTOR_CV_COH ); + move16(); q_direction = &( hQMetaData->q_direction[idx_dir] ); bit_pos = *p_bit_pos; + move16(); nbits = 0; + move16(); - IF( q_direction->cfg.nblocks == 1 ) + IF( EQ_16( q_direction->cfg.nblocks, 1 ) ) { FOR( j = 0; j < coding_subbands; j++ ) { IF( hrmasa_flag ) { - idx_ER = 7 - ( q_direction->band_data[j].energy_ratio_index_mod[0] >> 1 ) + extra_cv; + idx_ER = extract_l( L_add( L_sub( 7, L_shr( q_direction->band_data[j].energy_ratio_index_mod[0], 1 ) ), extra_cv ) ); } ELSE { - idx_ER = 7 - q_direction->band_data[j].energy_ratio_index_mod[0] + extra_cv; + idx_ER = extract_l( L_add( L_sub( 7, q_direction->band_data[j].energy_ratio_index_mod[0] ), extra_cv ) ); } - no_cv_vec[j] = idx_ER + 1; + no_cv_vec[j] = add( idx_ER, 1 ); + move16(); } - IF( sum_s( no_cv_vec, coding_subbands ) == coding_subbands ) + IF( EQ_16( sum16_fx( no_cv_vec, coding_subbands ), coding_subbands ) ) { FOR( j = 0; j < coding_subbands; j++ ) { @@ -6669,23 +7051,25 @@ static Word16 read_coherence_data_fx( return 0; } byteBuffer = bitstream[bit_pos--]; - nbits += 1; + move16(); + nbits = add( nbits, 1 ); - IF( byteBuffer & 1 ) + IF( L_and( byteBuffer, 1 ) ) { /* decode GR min removed */ - nbits += read_GR_min_removed_data( bitstream, &bit_pos, no_cv_vec, coding_subbands, decoded_idx, MASA_MAX_NO_CV_SUR_COH + extra_cv ); + nbits = add( nbits, read_GR_min_removed_data( bitstream, &bit_pos, no_cv_vec, coding_subbands, decoded_idx, MASA_MAX_NO_CV_SUR_COH + extra_cv ) ); FOR( j = 0; j < coding_subbands; j++ ) { - IF( no_cv_vec[j] > 1 ) + IF( GT_16( no_cv_vec[j], 1 ) ) { - num = decoded_idx[j] * 255; - den = 7 - ( q_direction->band_data[j].energy_ratio_index_mod[0] >> ( hrmasa_flag ) ) + coding_subbands / MASA_FACTOR_CV_COH; + num = i_mult( decoded_idx[j], 255 ); + move16(); + den = extract_l( L_add( L_sub( 7, L_shr( q_direction->band_data[j].energy_ratio_index_mod[0], hrmasa_flag ) ), coding_subbands / MASA_FACTOR_CV_COH ) ); q_den = norm_s( den ); - q_num = norm_s( num ) - 1; - res = div_s( num << q_num, den << q_den ); - q_res = 15 - q_den + q_num; - res = L_shl( res, 16 - q_res ); + q_num = sub( norm_s( num ), 1 ); + res = div_s( shl( num, q_num ), shl( den, q_den ) ); + q_res = add( sub( 15, q_den ), q_num ); + res = L_shl( res, sub( 16, q_res ) ); q_direction->coherence_band_data[j].spread_coherence[0] = (UWord8) ( round_fx( res ) ); } ELSE @@ -6698,18 +7082,19 @@ static Word16 read_coherence_data_fx( { UWord16 decoded_index[MASA_MAXIMUM_CODING_SUBBANDS]; /* decode joint index */ - nbits += decode_fixed_rate_composed_index_coherence_fx( bitstream, &bit_pos, coding_subbands, no_cv_vec, decoded_index, MASA_NO_CV_COH + coding_subbands / MASA_FACTOR_CV_COH ); + nbits = add( nbits, decode_fixed_rate_composed_index_coherence_fx( bitstream, &bit_pos, coding_subbands, no_cv_vec, decoded_index, add( MASA_NO_CV_COH, coding_subbands / MASA_FACTOR_CV_COH ) ) ); FOR( j = 0; j < coding_subbands; j++ ) { - IF( no_cv_vec[j] > 1 ) + IF( GT_16( no_cv_vec[j], 1 ) ) { - num = decoded_index[j] * 255; - den = 7 - ( q_direction->band_data[j].energy_ratio_index_mod[0] >> ( hrmasa_flag ) ) + coding_subbands / MASA_FACTOR_CV_COH; + num = i_mult( decoded_index[j], 255 ); + move16(); + den = extract_l( L_add( L_sub( 7, L_shr( q_direction->band_data[j].energy_ratio_index_mod[0], hrmasa_flag ) ), coding_subbands / MASA_FACTOR_CV_COH ) ); q_den = norm_s( den ); - q_num = norm_s( num ) - 1; - res = div_s( num << q_num, den << q_den ); - q_res = 15 - q_den + q_num; - res = L_shl( res, 16 - q_res ); + q_num = sub( norm_s( num ), 1 ); + res = div_s( shl( num, q_num ), shl( den, q_den ) ); + q_res = add( sub( 15, q_den ), q_num ); + res = L_shl( res, sub( 16, q_res ) ); q_direction->coherence_band_data[j].spread_coherence[0] = (UWord8) ( round_fx( res ) ); } ELSE @@ -6726,58 +7111,69 @@ static Word16 read_coherence_data_fx( IF( hrmasa_flag ) { minimum_s( (Word16 *) ( q_direction->band_data[j].energy_ratio_index ), q_direction->cfg.nblocks, &min_index ); - no_cv_vec[j] = len_cb_dct0_masa[min_index >> 1]; /* spread coherence DCT0*/ + no_cv_vec[j] = len_cb_dct0_masa[shr( min_index, 1 )]; + move16(); /* spread coherence DCT0*/ } ELSE { - no_cv_vec[j] = len_cb_dct0_masa[q_direction->band_data[j].energy_ratio_index[0]]; /* spread coherence DCT0*/ + no_cv_vec[j] = len_cb_dct0_masa[q_direction->band_data[j].energy_ratio_index[0]]; + move16(); /* spread coherence DCT0*/ } } - IF( sum_s( no_cv_vec, coding_subbands ) > MASA_COH_LIMIT_2IDX ) + IF( GT_16( sum16_fx( no_cv_vec, coding_subbands ), MASA_COH_LIMIT_2IDX ) ) { UWord16 spr_coh_temp_index[MASA_MAXIMUM_CODING_SUBBANDS]; no_cb = 1; + move64(); FOR( j = 0; j < coding_subbands / 2; j++ ) { no_cb *= no_cv_vec[j]; + move64(); } no_bits_vec = ceil_log_2( no_cb ); // (int16_t)ceilf(logf((float)no_cb) * INV_LOG_2); no_cb = 1; + move64(); FOR( j = coding_subbands / 2; j < coding_subbands; j++ ) { no_cb *= no_cv_vec[j]; + move64(); } no_bits_vec1 = ceil_log_2( no_cb ); // (int16_t) ceilf( logf( (float) no_cb ) * INV_LOG_2 ); dct0_index = 0; + move64(); FOR( j = 0; j < no_bits_vec; j++ ) { dct0_index = ( dct0_index << 1 ) + bitstream[bit_pos--]; + move64(); } - nbits += no_bits_vec; + nbits = add( nbits, no_bits_vec ); set_s( (Word16 *) spr_coh_temp_index, 0, MASA_MAXIMUM_CODING_SUBBANDS ); - decode_combined_index_fx( dct0_index, no_cv_vec, spr_coh_temp_index, coding_subbands / 2 ); + decode_combined_index_fx( dct0_index, no_cv_vec, spr_coh_temp_index, shr( coding_subbands, 1 ) ); dct0_index = 0; + move64(); FOR( j = 0; j < no_bits_vec1; j++ ) { dct0_index = ( dct0_index << 1 ) + bitstream[bit_pos--]; + move64(); } - nbits += no_bits_vec1; + nbits = add( nbits, no_bits_vec1 ); - decode_combined_index_fx( dct0_index, &no_cv_vec[coding_subbands / 2], &spr_coh_temp_index[coding_subbands / 2], coding_subbands / 2 ); + decode_combined_index_fx( dct0_index, &no_cv_vec[shr( coding_subbands, 1 )], &spr_coh_temp_index[shr( coding_subbands, 1 )], shr( coding_subbands, 1 ) ); FOR( j = 0; j < coding_subbands; j++ ) { q_direction->coherence_band_data[j].spread_coherence_dct0_index = spr_coh_temp_index[j]; + move16(); } } ELSE @@ -6786,10 +7182,12 @@ static Word16 read_coherence_data_fx( UWord16 spr_coh_temp_index[MASA_MAXIMUM_CODING_SUBBANDS]; no_cb = 1; + move64(); FOR( j = 0; j < coding_subbands; j++ ) { no_cb *= no_cv_vec[j]; + move64(); } no_bits_vec = ceil_log_2( no_cb ); // (int16_t)ceilf(logf((float)no_cb) * INV_LOG_2); @@ -6797,13 +7195,15 @@ static Word16 read_coherence_data_fx( /* read joint index for DCT0 */ no_bits_vec = ceil_log_2( no_cb ); // (int16_t)ceilf(logf((float)no_cb) * INV_LOG_2); dct0_index = 0; + move64(); FOR( j = 0; j < no_bits_vec; j++ ) { dct0_index = ( dct0_index << 1 ) + bitstream[bit_pos--]; + move64(); } - nbits += no_bits_vec; + nbits = add( nbits, no_bits_vec ); set_s( (Word16 *) spr_coh_temp_index, 0, MASA_MAXIMUM_CODING_SUBBANDS ); @@ -6812,6 +7212,7 @@ static Word16 read_coherence_data_fx( FOR( j = 0; j < coding_subbands; j++ ) { q_direction->coherence_band_data[j].spread_coherence_dct0_index = spr_coh_temp_index[j]; + move16(); } } @@ -6819,31 +7220,36 @@ static Word16 read_coherence_data_fx( FOR( j = 0; j < coding_subbands; j++ ) { bits_GR = bit_pos; - idx_dct1[j] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, 2 * MASA_NO_CV_COH1, 0 ); - nbits += bits_GR - bit_pos; + idx_dct1[j] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, shl( MASA_NO_CV_COH1, 1 ), 0 ); + move16(); + nbits = add( nbits, sub( bits_GR, bit_pos ) ); } - bits_GR = bit_pos; /* just to store the data */ + bits_GR = bit_pos; + move16(); /* just to store the data */ /* read average index */ read_huf( &bit_pos, bitstream, &av_index, bit_pos, MASA_NO_CV_COH1, huff_code_av_masa, 10 ); /* 10 is MAX_LEN*/ - nbits += ( bits_GR - bit_pos ); + nbits = ( nbits, sub( bits_GR, bit_pos ) ); /* write indexes in metadata structure */ FOR( j = 0; j < coding_subbands; j++ ) { - IF( idx_dct1[j] % 2 ) + IF( L_and( idx_dct1[j], 1 ) ) { - q_direction->coherence_band_data[j].spread_coherence_dct1_index = ( idx_dct1[j] + 1 ) / 2 + av_index; + q_direction->coherence_band_data[j].spread_coherence_dct1_index = (UWord16) L_add( L_shr( L_add( idx_dct1[j], 1 ), 1 ), av_index ); + move16(); } ELSE { - q_direction->coherence_band_data[j].spread_coherence_dct1_index = -idx_dct1[j] / 2 + av_index; + q_direction->coherence_band_data[j].spread_coherence_dct1_index = (UWord16) L_add( L_shr( -idx_dct1[j], 1 ), av_index ); + move16(); } } } - nbits = *p_bit_pos - bit_pos; + nbits = sub( *p_bit_pos, bit_pos ); *p_bit_pos = bit_pos; + move16(); return nbits; } @@ -7266,12 +7672,16 @@ static Word16 read_surround_coherence( q_direction = hQMetaData->q_direction; bits_sur_coherence = 0; + move16(); bit_pos = *p_bit_pos; + move16(); d = 0; + move16(); FOR( j = 0; j < coding_subbands; j++ ) { error_ratio_surr = ONE_IN_Q30; + move32(); IF( EQ_16( hQMetaData->no_directions, 2 ) ) { @@ -7294,17 +7704,22 @@ static Word16 read_surround_coherence( IF( LE_32( error_ratio_surr, 0 ) ) { error_ratio_surr = 0; + move32(); no_cv_vec[j] = 1; + move16(); idx_ER[j] = masa_sq_fx( 0, diffuseness_thresholds_fx, DIRAC_DIFFUSE_LEVELS ); + move16(); } ELSE { idx_ER[j] = masa_sq_fx( error_ratio_surr, diffuseness_thresholds_fx, DIRAC_DIFFUSE_LEVELS ); - no_cv_vec[j] = idx_cb_sur_coh_masa[idx_ER[j]] + 2; + move16(); + no_cv_vec[j] = add( idx_cb_sur_coh_masa[idx_ER[j]], 2 ); + move16(); } } - IF( EQ_16( sum_s( no_cv_vec, coding_subbands ), coding_subbands ) ) + IF( EQ_16( sum16_fx( no_cv_vec, coding_subbands ), coding_subbands ) ) { /* surround coherence is zero */ FOR( j = 0; j < coding_subbands; j++ ) @@ -7323,17 +7738,20 @@ static Word16 read_surround_coherence( /* read how the surround coherence is encoded */ byteBuffer = bitstream[bit_pos--]; + move16(); bits_sur_coherence = add( bits_sur_coherence, 1 ); - IF( byteBuffer & 1 ) + IF( L_and( byteBuffer, 1 ) ) { /* GR decoding */ /* read GR order */ byteBuffer = bitstream[bit_pos--]; + move16(); bits_sur_coherence = add( bits_sur_coherence, 1 ); /* read min index */ bits_GR = bit_pos; + move16(); min_index = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, MASA_MAX_NO_CV_SUR_COH, 0 ); bits_sur_coherence = add( bits_sur_coherence, sub( bits_GR, bit_pos ) ); @@ -7341,15 +7759,18 @@ static Word16 read_surround_coherence( FOR( j = 0; j < coding_subbands; j++ ) { bits_GR = bit_pos; + move16(); /* decoding for min removed */ IF( GT_16( no_cv_vec[j], 1 ) ) { idx_sur_coh[j] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, no_cv_vec[j] - min_index, ( byteBuffer & 1 ) ); + move16(); bits_sur_coherence = add( bits_sur_coherence, sub( bits_GR, bit_pos ) ); } ELSE { idx_sur_coh[j] = 0; + move16(); } } @@ -7358,10 +7779,12 @@ static Word16 read_surround_coherence( IF( GT_16( no_cv_vec[j], 1 ) ) { hQMetaData->surcoh_band_data[j].sur_coherence_index = add( idx_sur_coh[j], min_index ); + move16(); } ELSE { hQMetaData->surcoh_band_data[j].sur_coherence_index = idx_sur_coh[j]; + move16(); } hQMetaData->surcoh_band_data[j].surround_coherence[0] = sur_coherence_cb_masa[add( shl( idx_cb_sur_coh_masa[idx_ER[j]], 3 ), hQMetaData->surcoh_band_data[j].sur_coherence_index )]; @@ -7371,19 +7794,20 @@ static Word16 read_surround_coherence( { /* fixed rate */ UWord16 sur_coh_temp_index[MASA_MAXIMUM_CODING_SUBBANDS]; - set_s( (Word16 *) sur_coh_temp_index, 0, MASA_MAXIMUM_CODING_SUBBANDS ); + set16_fx( (Word16 *) sur_coh_temp_index, 0, MASA_MAXIMUM_CODING_SUBBANDS ); decode_fixed_rate_composed_index_coherence_fx( bitstream, &bit_pos, coding_subbands, no_cv_vec, sur_coh_temp_index, MASA_MAX_NO_CV_SUR_COH ); FOR( j = 0; j < coding_subbands; j++ ) { hQMetaData->surcoh_band_data[j].sur_coherence_index = sur_coh_temp_index[j]; + move16(); } /* deindex surround coherence */ FOR( j = 0; j < coding_subbands; j++ ) { - IF( no_cv_vec[j] > 1 ) + IF( GT_16( no_cv_vec[j], 1 ) ) { hQMetaData->surcoh_band_data[j].surround_coherence[0] = sur_coherence_cb_masa[add( shl( idx_cb_sur_coh_masa[idx_ER[j]], 3 ), hQMetaData->surcoh_band_data[j].sur_coherence_index )]; } @@ -7405,6 +7829,7 @@ static Word16 read_surround_coherence( /* Replace return value with the actual read bits. bits_sur_coherence might show wrong count at this point. */ bits_sur_coherence = sub( *p_bit_pos, bit_pos ); *p_bit_pos = bit_pos; + move16(); return bits_sur_coherence; } @@ -7849,82 +8274,100 @@ static void read_stream_dct_coeffs_omasa_fx( Word16 GR1, GR2; step = STEP_M2T_FX; + move32(); nbits = 0; + move16(); sign = 1; - IF( first_line == 0 ) + move16(); + IF( EQ_16( first_line, 0 ) ) { /* read sign */ sign = bit_stream[( *index )--]; - IF( sign == 0 ) + move16(); + IF( EQ_16( sign, 0 ) ) { sign = -1; + move16(); } nbits++; } - set_s( q_idx, 0, len_stream ); + set16_fx( q_idx, 0, len_stream ); /* read DCT 0 component */ FOR( i = 0; i < BITS_MASA2TOTTAL_DCT0; i++ ) { q_idx[0] = add( shl( q_idx[0], 1 ), bit_stream[( *index )--] ); + move16(); } - q_idx[0] *= sign; + q_idx[0] = i_mult( q_idx[0], sign ); + move16(); - IF( q_idx[0] != 0 ) + IF( NE_16( q_idx[0], 0 ) ) { - IF( len_stream >= 8 ) + IF( GE_16( len_stream, 8 ) ) { /* read index of last index encoded with GR2 */ i_min = 0; + move16(); j = 4; + move16(); FOR( i = 0; i < j; i++ ) { - i_min = ( i_min << 1 ) + bit_stream[( *index )--]; + i_min = extract_l( L_add( shl( i_min, 1 ), bit_stream[( *index )--] ) ); } - nbits += j; + nbits = add( nbits, j ); /* read GR orders */ - GR1 = bit_stream[( *index )--] + 1; - IF( GR1 == 2 ) + GR1 = extract_l( L_add( bit_stream[( *index )--], 1 ) ); + IF( EQ_16( GR1, 2 ) ) { GR2 = bit_stream[( *index )--]; + move16(); } ELSE { GR2 = 0; + move16(); } /* read GR data */ FOR( i = 1; i <= i_min; i++ ) { q_idx[i] = ivas_qmetadata_DecodeExtendedGR( bit_stream, index, 100, GR1 ); + move16(); } - FOR( i = i_min + 1; i < len_stream; i++ ) + FOR( i = add( i_min, 1 ); i < len_stream; i++ ) { q_idx[i] = ivas_qmetadata_DecodeExtendedGR( bit_stream, index, 100, GR2 ); + move16(); } } ELSE { /* read GR order (only one) */ GR1 = bit_stream[( *index )--]; + move16(); FOR( i = 1; i < len_stream; i++ ) { q_idx[i] = ivas_qmetadata_DecodeExtendedGR( bit_stream, index, 100, GR1 ); + move16(); } } } /* deindex */ - q_dct_data_fx[0] = L_shl( Mpy_32_16_1( step, shl( q_idx[0], 7) ), 2 ); // q = 25 + q_dct_data_fx[0] = L_shl( Mpy_32_16_1( step, shl( q_idx[0], 7 ) ), 2 ); // q = 25 + move32(); FOR( i = 1; i < len_stream; i++ ) { - IF( ( q_idx[i] % 2 ) == 0 ) + IF( EQ_16( s_and( q_idx[i], 1 ), 0 ) ) { q_dct_data_fx[i] = L_shl( Mpy_32_16_1( step, negate( shl( q_idx[i], 6 ) ) ), 2 ); + move32(); } ELSE { q_dct_data_fx[i] = L_shl( Mpy_32_16_1( step, shl( q_idx[i] + 1, 6 ) ), 2 ); + move32(); } } @@ -8041,7 +8484,7 @@ void ivas_omasa_decode_masa_to_total_fx( Word16 *index, Word32 masa_to_total_energy_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], const Word16 nbands, - const Word16 nblocks) + const Word16 nblocks ) { Word16 i, j, k; Word16 q_idx[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS]; @@ -8051,14 +8494,17 @@ void ivas_omasa_decode_masa_to_total_fx( /* Setup coding parameters */ n_streams = 1; - len_stream = nbands * nblocks; - IF( len_stream == 32 ) + move16(); + len_stream = i_mult( nbands, nblocks ); + IF( EQ_16( len_stream, 32 ) ) { n_streams = 4; + move16(); len_stream = 8; + move16(); } - set_s( q_idx, 0, nbands * nblocks ); + set16_fx( q_idx, 0, i_mult( nbands, nblocks ) ); FOR( i = 0; i < n_streams; i++ ) { read_stream_dct_coeffs_omasa_fx( &q_idx[i * len_stream], &q_dct_data_fx[i * len_stream], len_stream, bit_stream, index, i == 0 ); @@ -8096,35 +8542,37 @@ void ivas_omasa_decode_masa_to_total_fx( BREAK; } k = 0; + move16(); FOR( i = 0; i < nblocks; i++ ) { FOR( j = 0; j < nbands; j++ ) { - //masa_to_total_energy_ratio_fx[i][j] = L_max( 0, L_shl( q_dct_data_fx[k], *q - 25 ) ); - //masa_to_total_energy_ratio_fx[i][j] = L_min( 1 << *q, masa_to_total_energy_ratio_fx[i][j] ); - masa_to_total_energy_ratio_fx[i][j] = L_max( 0, L_shr(L_shl_sat(q_dct_data_fx[k], 31 - 25), 1) ); // Q30 + masa_to_total_energy_ratio_fx[i][j] = L_max( 0, L_shr( L_shl_sat( q_dct_data_fx[k], 31 - 25 ), 1 ) ); // Q30 + move32(); k++; } } - IF( nblocks == 1 ) + IF( EQ_16( nblocks, 1 ) ) { FOR( i = 1; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { FOR( j = 0; j < nbands; j++ ) { masa_to_total_energy_ratio_fx[i][j] = masa_to_total_energy_ratio_fx[0][j]; + move32(); } } } - IF( nbands == 1 ) + IF( EQ_16( nbands, 1 ) ) { FOR( j = 1; j < 5; j++ ) { FOR( i = 0; i < nblocks; i++ ) { masa_to_total_energy_ratio_fx[i][j] = masa_to_total_energy_ratio_fx[i][0]; + move32(); } } } diff --git a/lib_dec/ivas_qspherical_dec.c b/lib_dec/ivas_qspherical_dec.c index 3900cfcb0..9436d6d96 100644 --- a/lib_dec/ivas_qspherical_dec.c +++ b/lib_dec/ivas_qspherical_dec.c @@ -104,44 +104,45 @@ Word32 deindex_elevation_fx( ) { Word32 theta_hat_fx; - Word16 q_id_th = norm_l( *id_th ) - 1; + Word16 q_id_th = sub( norm_l( *id_th ), 1 ); Word32 id_th_fx = L_shl( *id_th, q_id_th ); - IF( *id_th == MASA_NO_INDEX ) + IF( EQ_32( *id_th, MASA_NO_INDEX ) ) { theta_hat_fx = 0; + move32(); } ELSE { - IF( mc_format != MC_LS_SETUP_INVALID ) + IF( NE_32( mc_format, MC_LS_SETUP_INVALID ) ) { - theta_hat_fx = L_shl( Mpy_32_32( id_th_fx, delta_theta_masa_fx[no_bits - 3] ), 31 - q_id_th ); - IF( theta_hat_fx > L_shl( 90, 22 ) ) + theta_hat_fx = L_shl( Mpy_32_32( id_th_fx, delta_theta_masa_fx[sub( no_bits, 3 )] ), sub( 31, q_id_th ) ); + IF( GT_32( theta_hat_fx, L_shl( 90, Q22 ) ) ) { - theta_hat_fx = L_shl( 90, 22 ); + theta_hat_fx = L_shl( 90, Q22 ); } } ELSE { - IF( *id_th % 2 == 0 ) + IF( EQ_32( L_and( *id_th, 1 ), 0 ) ) { /* theta is negative */ - *id_th = *id_th / 2; - id_th_fx = id_th_fx / 2; - theta_hat_fx = L_negate( L_shl( Mpy_32_32( id_th_fx, delta_theta_masa_fx[no_bits - 3] ), 31 - q_id_th ) ); - IF( theta_hat_fx < L_shl( -90, 22 ) ) + *id_th = (UWord16) L_shr( *id_th, 1 ); + id_th_fx = L_shr( id_th_fx, 1 ); + theta_hat_fx = L_negate( L_shl( Mpy_32_32( id_th_fx, delta_theta_masa_fx[sub( no_bits, 3 )] ), sub( 31, q_id_th ) ) ); + IF( LT_32( theta_hat_fx, L_shl( -90, Q22 ) ) ) { - theta_hat_fx = L_shl( -90, 22 ); + theta_hat_fx = L_shl( -90, Q22 ); } } ELSE { - *id_th = ( *id_th + 1 ) / 2; - id_th_fx = ( id_th_fx + ( 1 << q_id_th ) ) / 2; - theta_hat_fx = L_shl( Mpy_32_32( id_th_fx, delta_theta_masa_fx[no_bits - 3] ), 31 - q_id_th ); - IF( theta_hat_fx > L_shl( 90, 22 ) ) + *id_th = (UWord16) L_shr( L_add( *id_th, 1 ), 1 ); + id_th_fx = L_shr( L_add( id_th_fx, L_shl( 1, q_id_th ) ), 1 ); + theta_hat_fx = L_shl( Mpy_32_32( id_th_fx, delta_theta_masa_fx[sub( no_bits, 3 )] ), sub( 31, q_id_th ) ); + IF( GT_32( theta_hat_fx, L_shl( 90, Q22 ) ) ) { - theta_hat_fx = L_shl( 90, 22 ); + theta_hat_fx = L_shl( 90, Q22 ); } } } diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index ade7c3853..b6dda3c23 100644 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -42,6 +42,9 @@ #include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif /*--------------------------------------------------------------------------* diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 6f812b442..34d210a4d 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -2286,10 +2286,11 @@ void stereo_dft_generate_res_pred_fx( /* calculate band energies (low band only in case of ACELP) */ FOR ( i = hStereoDft->band_limits[b]; i < s_min( hStereoDft->band_limits[b + 1], bin0 ); i++ ) { - dmx_nrg = L_add(dmx_nrg, + /* Saturating below calculations (to be rechecked?) */ + dmx_nrg = L_add_sat(dmx_nrg, Madd_32_32(Mpy_32_32(pDFT_DMX[2 * i], pDFT_DMX[2 * i]), pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1])); - rev_nrg = L_add(rev_nrg, + rev_nrg = L_add_sat(rev_nrg, Madd_32_32(Mpy_32_32(ap_filt_DMX[2 * i], ap_filt_DMX[2 * i]), ap_filt_DMX[2 * i + 1], ap_filt_DMX[2 * i + 1])); } diff --git a/lib_dec/ivas_stereo_icbwe_dec.c b/lib_dec/ivas_stereo_icbwe_dec.c index 7edb3fd72..75b89bf70 100644 --- a/lib_dec/ivas_stereo_icbwe_dec.c +++ b/lib_dec/ivas_stereo_icbwe_dec.c @@ -1564,16 +1564,16 @@ void stereo_icBWE_decproc( /* reset BWE structs as they are only needed in the transition frame in MDCT Stereo */ td_bwe_dec_init( hCPE->hCoreCoder[0]->hBWE_TD, -1, output_Fs ); #ifdef IVAS_FLOAT_FIXED - hCPE->hCoreCoder[0]->prev_Q_bwe_exc = 31; - hCPE->hCoreCoder[0]->prev_Qx = 0; - hCPE->hCoreCoder[0]->prev_ener_fx_Q = 31; - hCPE->hCoreCoder[0]->prev_frame_pow_exp = 0; + td_bwe_dec_init_fx(hCPE->hCoreCoder[0], hCPE->hCoreCoder[0]->hBWE_TD, +#ifdef ADD_IVAS_BWE + hCPE->hCoreCoder[0]->extl, #endif + hCPE->hCoreCoder[0]->output_Fs); +#endif + fd_bwe_dec_init_flt( hCPE->hCoreCoder[0]->hBWE_FD ); #ifdef IVAS_FLOAT_FIXED - hCPE->hCoreCoder[0]->hBWE_FD->old_wtda_swb_fx_exp = 0; - hCPE->hCoreCoder[0]->hBWE_FD->mem_imdct_exp_fx = 0; - hCPE->hCoreCoder[0]->prev_Q_synth = 0; + fd_bwe_dec_init(hCPE->hCoreCoder[0], hCPE->hCoreCoder[0]->hBWE_FD); #endif } diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 1906e7e90..cdb9e7e75 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -889,12 +889,12 @@ ivas_error stereo_memory_dec( td_bwe_dec_init( st->hBWE_TD, -1, st->output_Fs ); #ifdef IVAS_FLOAT_FIXED - st->prev_Q_bwe_exc = 31; - st->prev_Qx = 0; - st->prev_ener_fx_Q = 31; - st->prev_frame_pow_exp = 0; + td_bwe_dec_init_fx(st, st->hBWE_TD, +#ifdef ADD_IVAS_BWE + st->extl,//not needed +#endif + st->output_Fs); #endif - if ( ( st->hBWE_FD = (FD_BWE_DEC_HANDLE) malloc( sizeof( FD_BWE_DEC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FD BWE\n" ) ); @@ -902,9 +902,7 @@ ivas_error stereo_memory_dec( fd_bwe_dec_init_flt( st->hBWE_FD ); #ifdef IVAS_FLOAT_FIXED - st->hBWE_FD->old_wtda_swb_fx_exp = 0; - st->hBWE_FD->mem_imdct_exp_fx = 0; - st->prev_Q_synth = 0; + fd_bwe_dec_init(st, st->hBWE_FD); #endif } @@ -1118,12 +1116,12 @@ ivas_error stereo_memory_dec( td_bwe_dec_init( st->hBWE_TD, -1, st->output_Fs ); #ifdef IVAS_FLOAT_FIXED - st->prev_Q_bwe_exc = 31; - st->prev_Qx = 0; - st->prev_ener_fx_Q = 31; - st->prev_frame_pow_exp = 0; + td_bwe_dec_init_fx(st, st->hBWE_TD, +#ifdef ADD_IVAS_BWE + -1, +#endif + st->output_Fs); #endif - if ( ( st->hBWE_FD = (FD_BWE_DEC_HANDLE) malloc( sizeof( FD_BWE_DEC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FD BWE\n" ) ); @@ -1131,9 +1129,7 @@ ivas_error stereo_memory_dec( fd_bwe_dec_init_flt( st->hBWE_FD ); #ifdef IVAS_FLOAT_FIXED - st->hBWE_FD->old_wtda_swb_fx_exp = 0; - st->hBWE_FD->mem_imdct_exp_fx = 0; - st->prev_Q_synth = 0; + fd_bwe_dec_init(st, st->hBWE_FD); #endif } } diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 7ae1e5b82..3b44fa529 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -466,7 +466,7 @@ void stereo_tcx_core_dec( st->old_fpitch = floatToFixed( st->old_fpitch_float, Q16 ); floatToFixed_arrL( st->old_pitch_buf, st->old_pitch_buf_fx, Q16, 2 * NB_SUBFR16k + 2 ); floatToFixed_arr( st->mem_pitch_gain_float, st->mem_pitch_gain, Q14, 2 * NB_SUBFR16k + 2 ); - st->last_good_fx = st->last_good; + st->last_good = st->last_good; floatToFixed_arr( st->hTonalMDCTConc->pTCI_float->phaseDiff_float, st->hTonalMDCTConc->pTCI_fix->phaseDiff, Q12, MAX_NUMBER_OF_IDX ); floatToFixed_arr( st->hTonalMDCTConc->pTCI_float->phase_currentFramePredicted_float, st->hTonalMDCTConc->pTCI_fix->phase_currentFramePredicted, Q13, MAX_NUMBER_OF_IDX * GROUP_LENGTH ); st->hTonalMDCTConc->pTCI_fix->numIndexes = st->hTonalMDCTConc->pTCI_float->numIndexes; @@ -551,7 +551,7 @@ void stereo_tcx_core_dec( st->hTcxDec->old_excFB_fx[p] = (Word16)(st->hTcxDec->old_excFB[p] * (1u << st->Q_exc)); } st->prev_Q_syn = st->Q_syn; - st->last_good_fx = st->last_good; + st->last_good = st->last_good; st->old_fpitchFB = (Word32)(st->old_fpitchFB_float * ONE_IN_Q16); st->old_fpitch = (Word32)(st->old_fpitch_float * ONE_IN_Q16); st->stab_fac_fx = (Word16)(st->stab_fac * MAX_16); diff --git a/lib_dec/ivas_td_low_rate_dec.c b/lib_dec/ivas_td_low_rate_dec.c index a7c9f40d5..662bce160 100644 --- a/lib_dec/ivas_td_low_rate_dec.c +++ b/lib_dec/ivas_td_low_rate_dec.c @@ -188,9 +188,9 @@ void tdm_low_rate_dec( st->bfi_pitch_fx = float_to_fix16(st->bfi_pitch, 0); st->tilt_code_fx = float_to_fix16(st->tilt_code, Q15); floatToFixed_arr(st->tilt_code_dec, st->tilt_code_dec_fx, Q15, NB_SUBFR16k); - st->last_good_fx = st->last_good; + st->last_good = st->last_good; st->Last_GSC_noisy_speech_flag_fx = st->Last_GSC_noisy_speech_flag; - st->last_coder_type_fx = st->last_coder_type; + st->last_coder_type = st->last_coder_type; /*hGSCDec end*/ Word16 dct_epit_fx[L_FRAME]; @@ -542,9 +542,9 @@ void decod_gen_2sbfr( st->dm_fx.prev_state = float_to_fix16(st->dispMem[0], 0); st->dm_fx.prev_gain_code = floatToFixed(st->dispMem[1], Q16); floatToFixed_arr(&(st->dispMem[2]), st->dm_fx.prev_gain_pit, Q14, 6); - st->last_good_fx = st->last_good; + st->last_good = st->last_good; st->Last_GSC_noisy_speech_flag_fx = st->Last_GSC_noisy_speech_flag; - st->last_coder_type_fx = st->last_coder_type; + st->last_coder_type = st->last_coder_type; /*hGSCDec end*/ st->gc_threshold_fx = floatToFixed(st->gc_threshold, Q16); diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index 333c20c5e..0546e4ec6 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -125,7 +125,7 @@ void lsf_dec_fx( (void)(tdm_low_rate_mode); #endif /* initialize */ - coder_type = st_fx->coder_type_fx; + coder_type = st_fx->coder_type; if ( EQ_32(st_fx->core_brate, SID_2k40) ) { coder_type = INACTIVE; diff --git a/lib_dec/lsf_msvq_ma_dec_fx.c b/lib_dec/lsf_msvq_ma_dec_fx.c index aac31151e..66db651e4 100644 --- a/lib_dec/lsf_msvq_ma_dec_fx.c +++ b/lib_dec/lsf_msvq_ma_dec_fx.c @@ -32,7 +32,7 @@ Word16 lsf_msvq_ma_decprm( Decoder_State * st, Word16 *param_lpc) move16(); test(); - IF ((EQ_32(st->sr_core, INT_FS_16k))&&(EQ_16(st->coder_type_fx,UNVOICED))) + IF ((EQ_32(st->sr_core, INT_FS_16k))&&(EQ_16(st->coder_type,UNVOICED))) { find_pred_mode(&predmode, GENERIC, sub(1, st->narrowBand) /*st->bwidth*/, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate); @@ -47,7 +47,7 @@ Word16 lsf_msvq_ma_decprm( Decoder_State * st, Word16 *param_lpc) } ELSE { - find_pred_mode(&predmode, st->coder_type_fx, sub(1, st->narrowBand)/*st->bwidth*/, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate ); + find_pred_mode(&predmode, st->coder_type, sub(1, st->narrowBand)/*st->bwidth*/, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate ); move16(); } } @@ -111,7 +111,7 @@ Word16 lsf_msvq_ma_decprm( Decoder_State * st, Word16 *param_lpc) test(); test(); - IF ( NE_16(st->coder_type_fx, VOICED) && st->core==0 && st->acelp_cfg.midLpc) + IF ( NE_16(st->coder_type, VOICED) && st->core==0 && st->acelp_cfg.midLpc) { *param_lpc = get_next_indice_fx(st, bits_midlpc); diff --git a/lib_dec/nelp_dec_fx.c b/lib_dec/nelp_dec_fx.c index 9aa4f3ae2..62f8c0632 100644 --- a/lib_dec/nelp_dec_fx.c +++ b/lib_dec/nelp_dec_fx.c @@ -108,9 +108,9 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1 hSC_VBR = st_fx->hSC_VBR; - if (EQ_16(st_fx->last_nelp_mode_dec_fx,1)&&NE_16(st_fx->bwidth,st_fx->last_bwidth)) + if (EQ_16(st_fx->last_nelp_mode_dec,1)&&NE_16(st_fx->bwidth,st_fx->last_bwidth)) { - st_fx->last_nelp_mode_dec_fx = 0; + st_fx->last_nelp_mode_dec = 0; } test(); @@ -118,7 +118,7 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1 test(); IF ( EQ_16(coder_type,UNVOICED)&&EQ_16(st_fx->bwidth,NB)) { - IF (NE_16(st_fx->last_nelp_mode_dec_fx,1)) + IF (NE_16(st_fx->last_nelp_mode_dec,1)) { BP1_ORDER = 7; move16(); @@ -130,13 +130,13 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1 { BP1_ORDER =4; move16(); - IF (NE_16(st_fx->last_nelp_mode_dec_fx,1)) + IF (NE_16(st_fx->last_nelp_mode_dec,1)) { set16_fx(hSC_VBR->bp1_filt_mem_wb_dec_fx, 0 , BP1_ORDER*2); } } - IF (NE_16(st_fx->last_nelp_mode_dec_fx,1)) + IF (NE_16(st_fx->last_nelp_mode_dec,1)) { set16_fx(hSC_VBR->shape1_filt_mem_dec_fx, 0, 10); set16_fx(hSC_VBR->shape2_filt_mem_dec_fx, 0, 10); diff --git a/lib_dec/pitch_extr_fx.c b/lib_dec/pitch_extr_fx.c index c45be91f7..7e46acdc4 100644 --- a/lib_dec/pitch_extr_fx.c +++ b/lib_dec/pitch_extr_fx.c @@ -140,7 +140,7 @@ void pitch_pred_linear_fit( FOR (i=0; icoder_type_fx; + Word16 coder_type = st->coder_type; move16(); // if (st->hPFstat != NULL || st->hBPF == NULL) diff --git a/lib_dec/rst_dec_fx.c b/lib_dec/rst_dec_fx.c index 2e7848c70..8c134ad15 100644 --- a/lib_dec/rst_dec_fx.c +++ b/lib_dec/rst_dec_fx.c @@ -39,7 +39,7 @@ void CNG_reset_dec_fx( /* last good received frame for FEC in ACELP */ st_fx->clas_dec = UNVOICED_CLAS; move16(); - st_fx->last_good_fx = UNVOICED_CLAS; + st_fx->last_good = UNVOICED_CLAS; move16(); /* LP-filtered pitch gain set to 0 */ @@ -81,7 +81,7 @@ void CNG_reset_dec_fx( /* Reset active frame counter */ if (st_fx->hTdCngDec != NULL) { - st_fx->hTdCngDec->act_cnt2_fx = 0; + st_fx->hTdCngDec->act_cnt2 = 0; } move16(); diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 85e21bfab..2437d08d3 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -867,7 +867,7 @@ typedef struct td_cng_dec_structure Word16 last_allow_cn_step_fx; /*Q0*/ int16_t ho_hist_size; /* DTX/CNG - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ - Word16 ho_hist_size_fx; /* CNG and DTX - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ + // Word16 ho_hist_size; /* CNG and DTX - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ int16_t ho_hist_ptr; /* DTX/CNG - pointer for averaging buffers */ Word16 ho_hist_ptr_fx; /* CNG and DTX - pointer for averaging buffers */ @@ -886,7 +886,7 @@ typedef struct td_cng_dec_structure int16_t act_cnt; /* DTX/CNG - counter of active frames */ - Word16 act_cnt_fx; /* CNG and DTX - counter of active frames */ + // Word16 act_cnt; /* CNG and DTX - counter of active frames */ int16_t ho_circ_size; /* DTX/CNG - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ Word16 ho_circ_size_fx; /* CNG and DTX - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ @@ -913,7 +913,7 @@ typedef struct td_cng_dec_structure int16_t act_cnt2; /* DTX/CNG - counter of active frames for CNG_mode switching */ - Word16 act_cnt2_fx; /* DTX/CNG - counter of active frames for CNG_mode switching */ + // Word16 act_cnt2; /* DTX/CNG - counter of active frames for CNG_mode switching */ float old_env[20]; Word32 old_env_fx[20]; @@ -1056,7 +1056,7 @@ typedef struct sc_vbr_dec_structure typedef struct hq_nbfec_structure { int16_t prev_last_core; /* !!! note: the parameter is identical to last_core in IVAS */ - Word16 prev_last_core_fx; /* !!! note: the parameter is identical to last_core in IVAS */ + //Word16 prev_last_core; /* !!! note: the parameter is identical to last_core in IVAS */ float diff_energy; Word16 diff_energy_fx; @@ -1148,7 +1148,7 @@ typedef struct hq_dec_structure Word16 Q_old_postdec; /*scaling of the output of core_switching_post_dec_fx() */ int16_t last_hq_core_type; - Word16 last_hq_core_type_fx; /*Q0*/ + //Word16 last_hq_core_type; /*Q0*/ int16_t old_is_transient[3]; /* HQ core - previous transient flag (for FEC and BWE/NF) */ Word16 old_is_transient_fx[3]; /* HQ core - previous transient flag (for FEC) */ @@ -1573,6 +1573,7 @@ typedef struct fd_bwe_dec_structure float old_wtda_swb[L_FRAME48k]; Word16 L_old_wtda_swb_fx[L_FRAME48k]; + Word32 L_old_wtda_swb_fx32[L_FRAME48k]; Word16 old_wtda_swb_fx_exp; @@ -1908,7 +1909,7 @@ typedef struct Decoder_State Word16 stab_fac_smooth_fx; /* low-pass filtered stability factor Q15*/ int16_t last_coder_type; /* previous coder type */ - Word16 last_coder_type_fx; /* previous coder type Q0*/ + //Word16 last_coder_type; /* previous coder type Q0*/ float agc_mem2[2]; /* memory of AGC for saturation control */ Word16 agc_mem_fx[2]; /* memory of AGC for saturation control Q0*/ @@ -2052,7 +2053,7 @@ typedef struct Decoder_State int16_t decision_hyst; /* FEC - hysteresis of the music/speech decision */ //Word16 decision_hyst_fx; /* FEC - hysteresis of the music/speech decision Q0*/ - Word16 last_good_fx; /* FEC - clas of last good received Q0*/ + //Word16 last_good; /* FEC - clas of last good received Q0*/ Word16 lp_ener_FER_fx; /* FEC - long-term active-signal average energy Q8*/ @@ -2172,7 +2173,7 @@ typedef struct Decoder_State Word16 ppp_mode_dec_fx; /*Q0*/ int16_t last_nelp_mode_dec; - Word16 last_nelp_mode_dec_fx; + // Word16 last_nelp_mode_dec; int16_t nelp_mode_dec; Word16 nelp_mode_dec_fx; /* Q0 */ @@ -2255,8 +2256,8 @@ typedef struct Decoder_State float old_Es_pred; /* old Es_pred for core switching */ Word16 old_Es_pred_fx; /* old Es_pred for core switching */ - Word16 old_bfi_cnt_fx; /* HQ core - # of bfi until previous frame(for FEC) */ - Word16 prev_old_bfi_fx; + // Word16 old_bfi_cnt; /* HQ core - # of bfi until previous frame(for FEC) */ + //Word16 prev_old_bfi; HQ_NBFEC_HANDLE hHQ_nbfec; @@ -2298,10 +2299,10 @@ typedef struct Decoder_State Word16 prev_fractive_fx; int16_t prev_bws_cnt; - Word16 prev_bws_cnt_fx; + // Word16 prev_bws_cnt; int16_t bws_cnt; - Word16 bws_cnt_fx; + // Word16 bws_cnt; int16_t bws_cnt1; Word16 bws_cnt1_fx; @@ -2360,7 +2361,7 @@ typedef struct Decoder_State *----------------------------------------------------------------------------------*/ FD_BWE_DEC_HANDLE hBWE_FD; - Word16 prev_coder_type_fx; + // Word16 prev_coder_type; /*----------------------------------------------------------------------------------* * SWB DTX/CNG parameters @@ -2666,7 +2667,7 @@ typedef struct Decoder_State int16_t is_ism_format; /* Indication whether the codec operates in ISM format */ Word16 last_element_mode; /* element mode */ - Word16 coder_type_fx; /* low-rate mode flag */ + // Word16 coder_type; /* low-rate mode flag */ Word32 prev_synth_buffer32_fx[NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS)]; #ifdef DEBUGGING diff --git a/lib_dec/stat_noise_uv_dec_fx.c b/lib_dec/stat_noise_uv_dec_fx.c index d55c10ce7..0a576f1f5 100644 --- a/lib_dec/stat_noise_uv_dec_fx.c +++ b/lib_dec/stat_noise_uv_dec_fx.c @@ -24,7 +24,7 @@ void stat_noise_uv_dec_fx( { Word16 noisiness = 0, i; Word32 L_tmp; - Word16 coder_type = st_fx->coder_type_fx; + Word16 coder_type = st_fx->coder_type; /*-----------------------------------------------------------------* diff --git a/lib_dec/swb_bwe_dec.c b/lib_dec/swb_bwe_dec.c index cd4b855d0..e71e1ed98 100644 --- a/lib_dec/swb_bwe_dec.c +++ b/lib_dec/swb_bwe_dec.c @@ -45,6 +45,11 @@ #include "basop_proto_func.h" #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "prot_fx1.h" +#endif // IVAS_FLOAT_FIXED + + /*-------------------------------------------------------------------* * para_pred_bws() * @@ -214,6 +219,296 @@ static int16_t para_pred_bws( return mode; } +#ifdef IVAS_FLOAT_FIXED + +static +Word16 para_pred_bws_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *signal_wb_fx, /* i : wideband frequency signal */ + Word16 *SWB_fenv_fx, /* o : frequency-domain BWE envelope */ + Word16 Q_syn +) +{ + Word16 i, j, k; + Word16 mode; + Word16 tmp, tmp_den, tmp_num; + Word32 L_tmp, L_tmp_max; + Word16 exp; + Word16 *input_hi_fx; + Word32 *mea; + Word16 peak_fx, mag_fx; + Word32 mean_fx[7], peak_32_fx; + Word32 avrg1_fx, avrg2_fx, min_fx; + Word16 att_fx; + Word16 coder_type = st_fx->coder_type; + + mode = NORMAL; + move16(); + + k = 0; + move16(); + input_hi_fx = &signal_wb_fx[SHARP_WIDTH]; + move16(); + FOR(i = 0; i < 7; i++) + { + peak_fx = 0; + move16(); + mean_fx[i] = 0; + move16(); + FOR(j = 0; j < SHARP_WIDTH; j++) + { + mag_fx = abs_s(*input_hi_fx); + peak_fx = s_max(peak_fx, mag_fx); + /*IF (sub(mag_fx, peak_fx) > 0) */ + /*{ */ + /* peak_fx = mag_fx; */ + /*} */ + mean_fx[i] = L_add(mean_fx[i], L_deposit_l(mag_fx)); + move32(); + input_hi_fx++; + } + + IF(Q_syn < 11) + { + tmp = 1; + move16(); + } + ELSE + { + tmp = 0; + move16(); + if (GT_16(shr(peak_fx, 3), shl(1, Q_syn))) + { + tmp = 1; + move16(); + } + } + IF(tmp > 0) + { + L_tmp = L_msu0(Mult_32_16(L_shl(mean_fx[i], 10), 18432), peak_fx, 4544); + if (L_tmp < 0) + { + k = add(k, 1); + } + } + } + + avrg1_fx = L_deposit_l(0); + avrg2_fx = L_deposit_l(0); + FOR(i = 1; i < 4; i++) + { + avrg1_fx = L_add(avrg1_fx, mean_fx[i]); + avrg2_fx = L_add(avrg2_fx, mean_fx[i + 3]); + } + avrg1_fx = Mult_32_16(avrg1_fx, 10923); + avrg2_fx = Mult_32_16(avrg2_fx, 10923); /* 1/3 -> Q15 -> 10923 */ + + min_fx = L_add(2147483647, 0); /*2^31 */ + peak_32_fx = L_deposit_l(0); + FOR(i = 4; i < 7; i++) + { + IF(GT_32(mean_fx[i], L_shl(avrg2_fx, 1))) + { + exp = norm_l(mean_fx[i]); + IF(LT_16(exp, 16)) + { + tmp_den = extract_l(L_shr(mean_fx[i], sub(16, exp))); /*Qsyn - 16 + exp */ + tmp_num = extract_l(L_shr(avrg2_fx, sub(15, exp))); /*//Qsyn - 16 + exp */ + } + ELSE + { + tmp_den = extract_l(mean_fx[i]); + tmp_num = extract_l(L_shl(avrg2_fx, 1)); + } + + tmp_den = div_s(1, tmp_den); + + tmp = i_mult(tmp_num, tmp_den); /*Q15 */ + + mean_fx[i] = Mult_32_16(mean_fx[i], tmp); + move32(); + } + min_fx = L_min(min_fx, mean_fx[i]); + peak_32_fx = L_max(peak_32_fx, mean_fx[i]); + /*IF(L_sub(mean_fx[i], min_fx) < 0) */ + /*{ */ + /* min_fx = mean_fx[i]; */ + /*} */ + /*IF(L_sub(mean_fx[i], peak_32_fx) > 0) */ + /*{ */ + /* peak_32_fx = mean_fx[i]; */ + /*} */ + } + + IF(GT_16(st_fx->tilt_wb_fx, 16384)) + { + IF(GT_16(st_fx->tilt_wb_fx, 30720)) + { + min_fx = peak_32_fx; + } + ELSE + { + tmp = extract_l(L_shr(L_mult0(st_fx->tilt_wb_fx, 17476), 14)); /*Q15 */ + min_fx = Mult_32_16(peak_32_fx, tmp); + } + } + + test(); + IF(peak_32_fx == 0 || min_fx == 0) + { + set16_fx(SWB_fenv_fx, 0, SWB_FENV); + } + ELSE + { + exp = norm_l(peak_32_fx); + IF(LT_16(exp, 16)) + { + tmp_den = extract_l(L_shr(peak_32_fx, sub(16, exp))); /*Qsyn - 16 + exp */ + tmp = div_s(16384, tmp_den); /*Q15+14 - (Qsyn - 16 + exp) */ + tmp_num = extract_l(L_shr(min_fx, sub(16, exp))); /*Qsyn - 16 + exp */ + + tmp = extract_l(L_shr(L_mult0(tmp_num, tmp), 14)); /*Q15 */ + } + ELSE + { + tmp_den = extract_l(peak_32_fx); /*Qsyn */ + exp = norm_s(tmp_den); + tmp = div_s(shl(1, sub(14,exp)), tmp_den); /*Q 29-exp - Qsyn */ + tmp_num = extract_l(min_fx); /*Qsyn */ + + tmp = extract_l(L_shr(L_mult0(tmp_num, tmp), sub(14, exp))); /*Q15 */ + } + + j = 0; + move16(); + mea = &mean_fx[4]; + move16(); + L_tmp_max = L_shl(32767, add(Q_syn, 5)); + FOR(i = 0; i < SWB_FENV; i++) + { + IF(j == 5) + { + mea++; + move16(); + j = 0; + move16(); + } + j++; + move16(); + L_tmp = L_min(Mult_32_16(*mea, tmp), L_tmp_max); + SWB_fenv_fx[i] = extract_l(L_shr(L_tmp, add(Q_syn, 5))); + } + } + + j = 0; + move16(); + FOR(i = shr(SWB_FENV, 1); i < SWB_FENV; i++) + { + tmp = sub(32767, i_mult(j, 2341)); + move16(); + SWB_fenv_fx[i] = mult_r(SWB_fenv_fx[i], tmp); + move16(); + j++; + move16(); + } + + IF(GT_32(avrg1_fx, L_shl(avrg2_fx, 3))) + { + FOR(i = 0; i < SWB_FENV; i++) + { + SWB_fenv_fx[i] = shr(SWB_fenv_fx[i], 1); + move16(); + } + } + + test(); + test(); + test(); + test(); + test(); + IF(NE_16(st_fx->last_core, HQ_CORE) && EQ_16(st_fx->last_codec_mode, MODE1) && + (GT_32(st_fx->enerLH_fx, L_shr(st_fx->prev_enerLH_fx, 1)) && LT_32(L_shr(st_fx->enerLH_fx, 1), st_fx->prev_enerLH_fx)) && + (GT_32(st_fx->enerLL_fx, L_shr(st_fx->prev_enerLL_fx, 1)) && LT_32(L_shr(st_fx->enerLL_fx, 1), st_fx->prev_enerLL_fx))) + { + FOR(i = 0; i < SWB_FENV; i++) + { + test(); + IF(NE_16(st_fx->prev_coder_type, coder_type) && GT_16(mult_r(SWB_fenv_fx[i], 16384), st_fx->prev_SWB_fenv_fx[i])) + { + /*SWB_fenv_fx[i] = add(mult_r(SWB_fenv_fx[i], 3277), mult_r(st_fx->prev_SWB_fenv_fx[i], 29491)); */ + SWB_fenv_fx[i] = round_fx(L_mac(L_mult(SWB_fenv_fx[i], 3277), st_fx->prev_SWB_fenv_fx[i], 29491)); + } + ELSE + { + /*SWB_fenv_fx[i] = add(mult_r(SWB_fenv_fx[i], st_fx->attenu_fx), mult_r(st_fx->prev_SWB_fenv_fx[i], sub(32767, st_fx->attenu_fx))); */ + SWB_fenv_fx[i] = round_fx(L_mac(L_mult(SWB_fenv_fx[i], st_fx->attenu_fx), st_fx->prev_SWB_fenv_fx[i], sub(32767, st_fx->attenu_fx))); + } + } + + IF(LT_16(st_fx->attenu_fx, 29491)) + { + st_fx->attenu_fx = add(st_fx->attenu_fx, 1638); + move16(); + } + } + ELSE + { + test(); + test(); + test(); + test(); + IF(NE_32(st_fx->core_brate, st_fx->last_core_brate) || (GT_32(st_fx->enerLH_fx,L_shr(st_fx->prev_enerLH_fx,1)) && LT_32(L_shr(st_fx->enerLH_fx,1),st_fx->prev_enerLH_fx)) || + (GT_32(st_fx->enerLL_fx, L_shr(st_fx->prev_enerLL_fx, 1)) && LT_32(L_shr(st_fx->enerLL_fx, 1), st_fx->prev_enerLL_fx))) + { + FOR(i = 0; i < SWB_FENV; i++) + { + if (GT_16(mult_r(SWB_fenv_fx[i], 16384), st_fx->prev_SWB_fenv_fx[i])) + { + SWB_fenv_fx[i] = st_fx->prev_SWB_fenv_fx[i]; + move16(); + } + } + } + + FOR(i = 0; i < SWB_FENV; i++) + { + /*SWB_fenv_fx[i] = add(mult_r(SWB_fenv_fx[i], 29491), mult_r(st_fx->prev_SWB_fenv_fx[i], 3277)); */ + SWB_fenv_fx[i] = round_fx(L_mac(L_mult(SWB_fenv_fx[i], 29491), st_fx->prev_SWB_fenv_fx[i], 3277)); + } + st_fx->attenu_fx = 3277; + move16(); + } + + if (GT_16(k, 3)) + { + mode = HARMONIC; + move16(); + } + + + att_fx = i_mult(sub(N_WS2N_FRAMES, st_fx->bws_cnt), 819); + move16();/*15 */ + IF(EQ_16(st_fx->L_frame, L_FRAME16k)) + { + FOR(i = 0; i < 4; i++) + { + SWB_fenv_fx[i] = mult_r(SWB_fenv_fx[i], att_fx); + move16(); /*Q1 */ + } + } + + FOR(i = 4; i < SWB_FENV; i++) + { + SWB_fenv_fx[i] = mult_r(SWB_fenv_fx[i], att_fx); + move16(); /*Q1 */ + } + + return mode; +} + +#endif // IVAS_FLOAT_FIXED + + /*-------------------------------------------------------------------* * WB_BWE_gain_deq() * @@ -757,6 +1052,305 @@ void swb_bwe_dec_flt( return; } + +#ifdef IVAS_FLOAT_FIXED + +Word16 swb_bwe_dec_fx32( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word32 output_fx[], /* i : synthesis @internal Fs Q11 */ + Word32 *synth_fx, /* i : ACELP core synthesis/final synthesis Q11 */ + Word32 *hb_synth_fx, /* o : SHB synthesis/final synthesis */ + Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ + Word16 output_frame /* i : frame length */ +) +{ + Word16 L; + Word16 mode; + Word16 idxGain; + Word16 i, j, l_subfr; + Word16 fb_band_begin; + Word16 frica_flag = 0; + Word16 ener_adjust_quan_fx; + Word16 fb_ener_adjust_fx = 0; + Word16 scl, new_input_fx_exp, ysynth_frame_size; + Word16 Q_syn, Q_syn_hb, tmp, tmp2, q_tmp, Qsynth_fx16; + + Word16 ysynth_fx[L_FRAME48k]; + Word16 SWB_fenv_fx[SWB_FENV]; + Word16 SWB_tenv_fx[SWB_TENV]; + Word16 synth_fx16[L_FRAME48k]; + Word16 hb_synth_fx16[L_FRAME48k]; + + Word32 L_tmp; + Word32 yerror_fx[L_FRAME48k]; + Word32 ysynth_fx32[L_FRAME48k]; + Word32 SWB_tenv_tmp_fx[SWB_TENV]; + Word32 wtda_synth_fx[2 * L_FRAME48k]; + + FD_BWE_DEC_HANDLE hBWE_FD; + hBWE_FD = st_fx->hBWE_FD; + + /*---------------------------------------------------------------------* + * SWB BWE decoding + *---------------------------------------------------------------------*/ + + IF (EQ_16(st_fx->element_mode, IVAS_CPE_DFT) && !use_cldfb_for_dft) + { + /* todo - wtda() does not support L_FRAME length; thus temporarily resample the signal */ + /* todo - delay output[] by 1.25ms ? */ + L_lerp_fx_q11(output_fx, ysynth_fx32, L_FRAME16k, st_fx->L_frame); + + /* windowing of the ACELP core synthesis */ + wtda_fx32(ysynth_fx32, wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx32, ALDO_WINDOW, ALDO_WINDOW, /*st_fx->L_frame*/ L_FRAME16k); + + /* DCT of the ACELP core synthesis */ + new_input_fx_exp = 11; + direct_transform_fx(wtda_synth_fx, ysynth_fx32, 0, /*st_fx->L_frame*/ L_FRAME16k, &new_input_fx_exp,st_fx->element_mode); + ysynth_frame_size = L_FRAME16k; + } + ELSE + { + /* windowing of the ACELP core synthesis */ + //wtda(synth, wtda_synth, hBWE_FD->old_wtda_swb, ALDO_WINDOW, ALDO_WINDOW, output_frame); + wtda_fx32(synth_fx, wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx32, ALDO_WINDOW, ALDO_WINDOW, output_frame); + + /* DCT of the ACELP core synthesis */ + //direct_transform(wtda_synth, ysynth, 0, output_frame, st_fx->element_mode); + new_input_fx_exp = 11; + direct_transform_fx(wtda_synth_fx, ysynth_fx32, 0, output_frame, &new_input_fx_exp,st_fx->element_mode); + ysynth_frame_size = output_frame; + } + + /* Convert to 16 Bits (Calc Shift Required to Stay within MAX_Q_NEW_INPUT) */ + scl = sub(16 + 11, new_input_fx_exp); + /* Possible to Upscale? */ + IF(GT_16(scl, 0)) + { + /* Yes */ + /* Calc Room to Upscale */ + Q_syn = Find_Max_Norm32(ysynth_fx32, ysynth_frame_size)-3; + /* Stay within MAX_Q_NEW_INPUT */ + scl = s_min(Q_syn, scl); + } + /*Don't upscale if already in 15 bits*/ + IF(GT_16(scl, 15)) { + FOR(i = 0; i < ysynth_frame_size; i++) { + ysynth_fx[i] = extract_l(ysynth_fx32[i]); + } + Q_syn = new_input_fx_exp; + } + ELSE{ + Copy_Scale_sig32_16(ysynth_fx32, ysynth_fx, ysynth_frame_size, scl); + Q_syn = add(sub(new_input_fx_exp, 16), scl); + } + + IF (!st_fx->bfi) + { + IF (GT_16( st_fx->bws_cnt, 0)) + { + /* estimate parameters */ + mode = para_pred_bws_fx(st_fx, ysynth_fx, SWB_fenv_fx, Q_syn); + } + ELSE + { + /* de-quantization */ + mode = swb_bwe_gain_deq_fx(st_fx, ACELP_CORE, SWB_tenv_fx, SWB_fenv_fx, 0, -1); + } + + L = SWB_FENV; + IF (EQ_16(mode, TRANSIENT)) + { + L = SWB_FENV_TRANS; + } + + L_tmp = 0; + FOR (i = 0; i < L; i++) + { + L_tmp = L_add(L_tmp, L_deposit_l(SWB_fenv_fx[i])); + } + q_tmp = norm_s(L); + tmp = div_s(shl(1, sub(14, q_tmp)), L);/*Q(29-q_tmp) */ + L_tmp = Mpy_32_16_1(L_tmp, tmp); /*Q(1+29-q_tmp+1-16)->Q(15-q_tmp) */ + st_fx->prev_ener_shb_fx = round_fx(L_shl(L_tmp, add(q_tmp, 2)));/*Q1 */ + } + ELSE + { + /* SHB FEC */ + + IF(NE_16(hBWE_FD->prev_mode_fx, TRANSIENT)) + { + mode = hBWE_FD->prev_mode_fx; + } + ELSE + { + mode = NORMAL; + } + + Copy(hBWE_FD->prev_SWB_fenv_fx, SWB_fenv_fx, SWB_FENV); + } + + /* reconstruction of MDCT spectrum of the error signal */ + set32_fx(yerror_fx, 0, output_frame); + + IF(EQ_16(st_fx->L_frame, L_FRAME16k)) + { + SWB_BWE_decoding_fx(ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, hBWE_FD->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm_fx, st_fx->tilt_wb_fx, &hBWE_FD->Seed_fx, 80, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl); + } + ELSE + { + SWB_BWE_decoding_fx(ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, hBWE_FD->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm_fx, st_fx->tilt_wb_fx, &hBWE_FD->Seed_fx, 6, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl); + } + + + IF(EQ_16(hBWE_FD->prev_frica_flag_fx, 1) && frica_flag == 0) + { + FOR (i = 0; i < L_SUBFR; i++) + { + tmp = sub(32767, extract_l(L_mult0(i, 512))); /*Q15 */ + hBWE_FD->mem_imdct_fx[i] = mult_r(hBWE_FD->mem_imdct_fx[i], tmp); + } + + FOR (; i < output_frame; i++) + { + hBWE_FD->mem_imdct_fx[i] = 0; + } + } + + /* decode information */ + IF(EQ_16(st_fx->extl, FB_BWE)) + { + IF (!st_fx->bfi) + { + idxGain = (Word16)get_next_indice(st_fx, NUM_BITS_FB_FRAMEGAIN); + fb_ener_adjust_fx = usdequant_fx(idxGain, FB_GAIN_QLOW_FX, FB_GAIN_QDELTA_FX); /*Q15 */ + } + ELSE IF (st_fx->bfi) + { + fb_ener_adjust_fx = st_fx->prev_fb_ener_adjust_fx; + } + + st_fx->prev_fb_ener_adjust_fx = fb_ener_adjust_fx; + IF(EQ_16(mode, TRANSIENT)) + { + ener_adjust_quan_fx = shr(fb_ener_adjust_fx, 2); + } + ELSE + { + IF (SWB_fenv_fx[7] != 0) + { + tmp = div_s(1, SWB_fenv_fx[7]); + ener_adjust_quan_fx = s_min(shr(i_mult_sat(SWB_fenv_fx[13], tmp), 2), 32767); + } + ELSE + { + ener_adjust_quan_fx = 0; + } + } + + fb_band_begin = FB_BAND_BEGIN; + IF (EQ_16(st_fx->L_frame, L_FRAME)) + { + fb_band_begin = FB_BAND_BEGIN_12k8; + } + + j = 0; + FOR (i = fb_band_begin; i < fb_band_begin + DE_OFFSET1; i++) + { + tmp = sub(32767, i_mult(j, 1024)); + tmp = mult_r(tmp, ener_adjust_quan_fx); /*Q13*/ + + tmp2 = i_mult(j, 256); /*Q13*/ + tmp2 = mult_r(tmp2, fb_ener_adjust_fx); /*Q13*/ + + tmp = add(tmp, tmp2); /*Q13*/ + yerror_fx[i] = L_shl(Mpy_32_16_1(yerror_fx[i - FB_BAND_WIDTH], tmp), 2);/*15+Q_syn */ + j = add(j, 1); + } + FOR (; i < FB_BAND_END; i++) + { + yerror_fx[i] = Mpy_32_16_1(yerror_fx[i - FB_BAND_WIDTH], fb_ener_adjust_fx);/*15+Q_syn */ + } + } + + /* iDCT of the error signal */ + Q_syn_hb = add(Q_syn, 15); + Inverse_Transform(yerror_fx, &Q_syn_hb, wtda_synth_fx, 0, output_frame, -1, st_fx->element_mode); + + /* inverse windowing of the error signal */ + window_ola_fx(wtda_synth_fx, hb_synth_fx16, &Q_syn_hb, hBWE_FD->mem_imdct_fx, &hBWE_FD->mem_imdct_exp_fx, output_frame, ALDO_WINDOW, ALDO_WINDOW, 0, 0, 0); + l_subfr = mult( output_frame , 8192); + + IF(EQ_16(mode, TRANSIENT)) + { + FOR (i = 0; i < SWB_TENV; i++) + { + SWB_tenv_tmp_fx[i] = L_mult0(SWB_tenv_fx[i], 26214); + } + + /* time envelope shaping when the current frame is TRANSIENT frame */ + time_envelop_shaping_fx(hb_synth_fx16, SWB_tenv_tmp_fx, output_frame, &Q_syn_hb); + Q_syn_hb = sub(Q_syn_hb, 3); + + hBWE_FD->prev_td_energy_fx = SWB_tenv_fx[3]; + } + ELSE IF (EQ_16(frica_flag, 1) && EQ_16(hBWE_FD->prev_frica_flag_fx, 0)) + { + Qsynth_fx16 = Find_Max_Norm32(synth_fx, output_frame); + Qsynth_fx16 = sub(Qsynth_fx16, shr(add(sub(15, norm_s(l_subfr)),1),1)); + Copy_Scale_sig32_16(synth_fx, synth_fx16, output_frame, Qsynth_fx16); + Qsynth_fx16 = add(sub(11, 16), Qsynth_fx16); + + /* IVAS_fmToDo: synth[] is @internal_Fs!!! */ + time_reduce_pre_echo_fx(synth_fx16, hb_synth_fx16, hBWE_FD->prev_td_energy_fx, l_subfr, Qsynth_fx16, Q_syn_hb); + } + ELSE + { + tmp = i_mult2(3, l_subfr); + L_tmp = L_deposit_l(0); + + FOR (i = 0; i < l_subfr; i++) + { + L_tmp = L_mac0_sat(L_tmp, hb_synth_fx16[tmp + i], hb_synth_fx16[tmp + i]); /*(2*Q_syn_hb) */ + } + + L_tmp = Mult_32_16(L_tmp, div_s(1, l_subfr)); /*(2*Q_syn_hb) */ + hBWE_FD->prev_td_energy_fx = 0; + + IF (NE_32(L_tmp, 0)) + { + q_tmp = norm_l(L_tmp); + tmp = extract_h(L_shl(L_tmp, q_tmp)); + q_tmp = sub(q_tmp, sub(30, shl(Q_syn_hb, 1))); + + tmp = div_s(16384, tmp); + L_tmp = L_deposit_h(tmp); + L_tmp = Isqrt_lc(L_tmp, &q_tmp); /*Q(31-exp) */ + hBWE_FD->prev_td_energy_fx = round_fx(L_shl(L_tmp, sub(q_tmp, 15))); /*Q0 */ + } + + } + + IF (EQ_16(st_fx->element_mode, IVAS_CPE_DFT) && !use_cldfb_for_dft) + { + Qsynth_fx16 = add(sub(16, 11), Q_syn_hb); + Copy_Scale_sig32_16(synth_fx, synth_fx16, output_frame, Qsynth_fx16); + + /* add HB synth from hf_synth() */ + v_add_16(hb_synth_fx16, synth_fx16, hb_synth_fx16, output_frame); + } + + hBWE_FD->prev_mode_fx = mode; + hBWE_FD->prev_frica_flag_fx = frica_flag; + + FOR(i = 0; i < output_frame; i++) { + hb_synth_fx[i] = L_deposit_l(hb_synth_fx16[i]); + } + + return Q_syn_hb; +} + +#endif // IVAS_FLOAT_FIXED + /*-------------------------------------------------------------------* * fd_bwe_dec_init_flt() * diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index ef505ae45..6bc9406c1 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -38,7 +38,7 @@ Word16 para_pred_bws_fx( Word32 mean_fx[7], peak_32_fx; Word32 avrg1_fx, avrg2_fx, min_fx; Word16 att_fx; - Word16 coder_type = st_fx->coder_type_fx; + Word16 coder_type = st_fx->coder_type; mode = NORMAL; move16(); @@ -231,7 +231,7 @@ Word16 para_pred_bws_fx( FOR(i=0; iprev_coder_type_fx, coder_type)&>_16(mult_r(SWB_fenv_fx[i],16384), st_fx->prev_SWB_fenv_fx[i])) + IF(NE_16(st_fx->prev_coder_type, coder_type)&>_16(mult_r(SWB_fenv_fx[i],16384), st_fx->prev_SWB_fenv_fx[i])) { /*SWB_fenv_fx[i] = add(mult_r(SWB_fenv_fx[i], 3277), mult_r(st_fx->prev_SWB_fenv_fx[i], 29491)); */ SWB_fenv_fx[i] = round_fx(L_mac(L_mult(SWB_fenv_fx[i], 3277), st_fx->prev_SWB_fenv_fx[i], 29491)); @@ -284,7 +284,7 @@ Word16 para_pred_bws_fx( } - att_fx = i_mult(sub(N_WS2N_FRAMES, st_fx->bws_cnt_fx), 819); + att_fx = i_mult(sub(N_WS2N_FRAMES, st_fx->bws_cnt), 819); move16();/*15 */ IF( EQ_16(st_fx->L_frame, L_FRAME16k)) { @@ -373,7 +373,7 @@ Word16 ivas_wb_bwe_dec_fx( Word16 i; FD_BWE_DEC_HANDLE hBWE_FD; - Word16 coder_type = st_fx->coder_type_fx; + Word16 coder_type = st_fx->coder_type; hBWE_FD = st_fx->hBWE_FD; @@ -438,7 +438,7 @@ Word16 ivas_wb_bwe_dec_fx( move16(); } - mode = WB_BWE_gain_pred_fx( WB_fenv_fx, ysynth_fx, coder_type, st_fx->prev_coder_type_fx, st_fx->prev_SWB_fenv_fx[0], + mode = WB_BWE_gain_pred_fx( WB_fenv_fx, ysynth_fx, coder_type, st_fx->prev_coder_type, st_fx->prev_SWB_fenv_fx[0], voice_factors_fx, pitch_buf_fx, tmp_brate, st_fx->last_wb_bwe_ener_fx, Q_syn, st_fx->last_extl, st_fx->tilt_wb_fx ); move16(); } @@ -472,7 +472,7 @@ Word16 ivas_wb_bwe_dec_fx( WB_BWE_decoding_fx( ysynth_fx, WB_fenv_fx, ysynth_32, L_FRAME16k, mode, st_fx->last_extl, &hBWE_FD->prev_Energy_wb_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm_fx, st_fx->extl, coder_type, st_fx->total_brate, &hBWE_FD->Seed_fx, &hBWE_FD->prev_flag_fx, - st_fx->prev_coder_type_fx, Q_syn, &Q_syn_hb ); + st_fx->prev_coder_type, Q_syn, &Q_syn_hb ); IF( EQ_32( st_fx->output_Fs, 32000 ) ) { set32_fx( &ysynth_32[L_FRAME16k], 0, L_FRAME16k ); @@ -522,7 +522,7 @@ Word16 wb_bwe_dec_fx( Word16 i; FD_BWE_DEC_HANDLE hBWE_FD; - Word16 coder_type = st_fx->coder_type_fx; + Word16 coder_type = st_fx->coder_type; hBWE_FD = st_fx->hBWE_FD; @@ -598,7 +598,7 @@ Word16 wb_bwe_dec_fx( move16(); } - mode = WB_BWE_gain_pred_fx( WB_fenv_fx, ysynth_fx, coder_type, st_fx->prev_coder_type_fx, st_fx->prev_SWB_fenv_fx[0], + mode = WB_BWE_gain_pred_fx( WB_fenv_fx, ysynth_fx, coder_type, st_fx->prev_coder_type, st_fx->prev_SWB_fenv_fx[0], voice_factors_fx, pitch_buf_fx, tmp_brate, st_fx->last_wb_bwe_ener_fx, Q_syn ,st_fx->last_extl, st_fx->tilt_wb_fx); move16(); @@ -633,7 +633,7 @@ Word16 wb_bwe_dec_fx( WB_BWE_decoding_fx( ysynth_fx, WB_fenv_fx, ysynth_32, L_FRAME16k, mode, st_fx->last_extl, &hBWE_FD->prev_Energy_wb_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm_fx, st_fx->extl, coder_type, st_fx->total_brate, &hBWE_FD->Seed_fx, &hBWE_FD->prev_flag_fx, - st_fx->prev_coder_type_fx, Q_syn, &Q_syn_hb ); + st_fx->prev_coder_type, Q_syn, &Q_syn_hb ); IF ( EQ_32(st_fx->output_Fs, 32000)) { set32_fx( &ysynth_32[L_FRAME16k], 0, L_FRAME16k ); @@ -987,7 +987,7 @@ Word16 swb_bwe_dec_fx( IF( !st_fx->bfi ) { - IF( st_fx->bws_cnt_fx > 0 ) + IF( st_fx->bws_cnt > 0 ) { /* estimate parameters */ mode = para_pred_bws_fx( st_fx, ysynth_fx, SWB_fenv_fx, Q_syn); diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 05a0fbe2f..ecd49ce3f 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -590,7 +590,7 @@ void ivas_wb_tbe_dec_fx( TD_BWE_DEC_HANDLE hBWE_TD; hBWE_TD = st_fx->hBWE_TD; - IF( st_fx->bws_cnt_fx == 0 ) + IF( st_fx->bws_cnt == 0 ) { /* Initialization */ set16_fx( GainShape, 11469 /*0.35f Q15*/, NUM_SHB_SUBFR ); @@ -618,7 +618,7 @@ void ivas_wb_tbe_dec_fx( /* Frame gain */ st_fx->rf_indx_tbeGainFr = s_and( st_fx->rf_indx_tbeGainFr, 0xF ); /* only four LSBs are valid */ Copy32( SHBCB_FrameGain16_fx + st_fx->rf_indx_tbeGainFr, &GainFrame, 1 ); - IF( EQ_16( st_fx->core, ACELP_CORE ) && EQ_16( st_fx->last_core, ACELP_CORE ) && !st_fx->prev_use_partial_copy && EQ_16( st_fx->prev_coder_type_fx, UNVOICED ) && NE_32( GainFrame, hBWE_TD->GainFrame_prevfrm_fx ) && EQ_16( st_fx->last_extl, WB_TBE ) ) + IF( EQ_16( st_fx->core, ACELP_CORE ) && EQ_16( st_fx->last_core, ACELP_CORE ) && !st_fx->prev_use_partial_copy && EQ_16( st_fx->prev_coder_type, UNVOICED ) && NE_32( GainFrame, hBWE_TD->GainFrame_prevfrm_fx ) && EQ_16( st_fx->last_extl, WB_TBE ) ) { /*GainFrame = 0.2f*GainFrame + 0.8f*st_fx->GainFrame_prevfrm_fx;*/ GainFrame = L_add( Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 26214 ), Mult_32_16( GainFrame, 6553 ) ); @@ -668,7 +668,7 @@ void ivas_wb_tbe_dec_fx( } IF( EQ_16( st_fx->core, ACELP_CORE ) && EQ_16( st_fx->last_core, ACELP_CORE ) ) { - IF( !st_fx->prev_use_partial_copy && EQ_16( st_fx->last_coder_type_fx, VOICED ) && EQ_16( st_fx->rf_frame_type, RF_GENPRED ) && LT_16( st_fx->prev_tilt_code_dec_fx, 1497 ) && GT_16( st_fx->prev_tilt_code_dec_fx, 200 ) ) + IF( !st_fx->prev_use_partial_copy && EQ_16( st_fx->last_coder_type, VOICED ) && EQ_16( st_fx->rf_frame_type, RF_GENPRED ) && LT_16( st_fx->prev_tilt_code_dec_fx, 1497 ) && GT_16( st_fx->prev_tilt_code_dec_fx, 200 ) ) { GainFrame = Mult_32_16( GainFrame, 9830 ); } @@ -1176,7 +1176,7 @@ void wb_tbe_dec_fx( TD_BWE_DEC_HANDLE hBWE_TD; hBWE_TD = st_fx->hBWE_TD; - IF( st_fx->bws_cnt_fx == 0 ) + IF( st_fx->bws_cnt == 0 ) { /* Initialization */ set16_fx(GainShape, 11469/*0.35f Q15*/, NUM_SHB_SUBFR); @@ -1205,7 +1205,7 @@ void wb_tbe_dec_fx( st_fx->rf_indx_tbeGainFr = s_and(st_fx->rf_indx_tbeGainFr, 0xF); /* only four LSBs are valid */ Copy32( SHBCB_FrameGain16_fx + st_fx->rf_indx_tbeGainFr, &GainFrame, 1 ); IF( EQ_16(st_fx->core,ACELP_CORE)&&EQ_16(st_fx->last_core,ACELP_CORE) - && !st_fx->prev_use_partial_copy && EQ_16(st_fx->prev_coder_type_fx,UNVOICED) + && !st_fx->prev_use_partial_copy && EQ_16(st_fx->prev_coder_type,UNVOICED) && NE_32(GainFrame, hBWE_TD->GainFrame_prevfrm_fx) && EQ_16(st_fx->last_extl, WB_TBE) ) { /*GainFrame = 0.2f*GainFrame + 0.8f*st_fx->GainFrame_prevfrm_fx;*/ @@ -1252,7 +1252,7 @@ void wb_tbe_dec_fx( } IF(EQ_16(st_fx->core,ACELP_CORE)&&EQ_16(st_fx->last_core,ACELP_CORE)) { - IF(!st_fx->prev_use_partial_copy && EQ_16(st_fx->last_coder_type_fx, VOICED)&&EQ_16(st_fx->rf_frame_type,RF_GENPRED) + IF(!st_fx->prev_use_partial_copy && EQ_16(st_fx->last_coder_type, VOICED)&&EQ_16(st_fx->rf_frame_type,RF_GENPRED) && LT_16(st_fx->prev_tilt_code_dec_fx,1497) && GT_16(st_fx->prev_tilt_code_dec_fx,200) ) { GainFrame = Mult_32_16(GainFrame,9830); @@ -1890,7 +1890,7 @@ void swb_tbe_dec_fx( } /* WB/SWB bandwidth switching */ - IF( st_fx->bws_cnt_fx > 0 ) + IF( st_fx->bws_cnt > 0 ) { f_fx = 1489; /*Q15*/ inc_fx = 1489; /*Q15*/ @@ -1983,7 +1983,7 @@ void swb_tbe_dec_fx( L_tmp = Pow2( 30, frac ); GainFrame = L_shl( L_tmp, sub( exp, 12 ) ); /*Q18*/ IF( EQ_16(st_fx->core,ACELP_CORE)&&EQ_16(st_fx->last_core,ACELP_CORE) - && !st_fx->prev_use_partial_copy && EQ_16(st_fx->prev_coder_type_fx,UNVOICED) + && !st_fx->prev_use_partial_copy && EQ_16(st_fx->prev_coder_type,UNVOICED) && NE_32(GainFrame, hBWE_TD->GainFrame_prevfrm_fx) && NE_16(st_fx->next_coder_type,GENERIC) && EQ_16(st_fx->last_extl, SWB_TBE) ) { /*GainFrame = 0.2f*GainFrame + 0.8f*st_fx->GainFrame_prevfrm_fx;*/ @@ -2029,7 +2029,7 @@ void swb_tbe_dec_fx( } IF(EQ_16(st_fx->core,ACELP_CORE)&&EQ_16(st_fx->last_core,ACELP_CORE)) { - IF(!st_fx->prev_use_partial_copy && EQ_16(st_fx->last_coder_type_fx, VOICED)&&EQ_16(st_fx->rf_frame_type,RF_GENPRED)&>_32(GainFrame,2097152)&<_32(GainFrame,3059606)) + IF(!st_fx->prev_use_partial_copy && EQ_16(st_fx->last_coder_type, VOICED)&&EQ_16(st_fx->rf_frame_type,RF_GENPRED)&>_32(GainFrame,2097152)&<_32(GainFrame,3059606)) { GainFrame = Mult_32_16(GainFrame,9830); } @@ -2238,7 +2238,7 @@ void swb_tbe_dec_fx( test(); test(); test(); - IF( st_fx->bws_cnt_fx == 0 && st_fx->bws_cnt1_fx == 0 && st_fx->prev_use_partial_copy == 0 && st_fx->use_partial_copy == 0 ) + IF( st_fx->prev_bws_cnt == 0 && st_fx->bws_cnt1_fx == 0 && st_fx->prev_use_partial_copy == 0 && st_fx->use_partial_copy == 0 ) { lsf_diff[0] = 16384; move16(); /*Q15*/ @@ -2275,7 +2275,7 @@ void swb_tbe_dec_fx( test(); test(); IF(!(GT_16(hBWE_TD->prev_tilt_para_fx,5120)&&(EQ_16(coder_type,TRANSITION)||LT_16(tilt_para,1024)))&& - !(((LT_16(hBWE_TD->prev_tilt_para_fx,3072) && GE_16(st_fx->prev_coder_type_fx,VOICED))) && GT_16(tilt_para,5120) )) + !(((LT_16(hBWE_TD->prev_tilt_para_fx,3072) && GE_16(st_fx->prev_coder_type,VOICED))) && GT_16(tilt_para,5120) )) { FOR( i = 1; i < LPC_SHB_ORDER-1; i++ ) { @@ -2601,7 +2601,7 @@ void swb_tbe_dec_fx( ener = s_max(1, round_fx( L_shl( L_ener, sub(19, shl(Q_bwe_exc, 1)) ) )); /* Q3: 2*Q_bwe_exc+19-2*Q_bwe_exc-16 */ /* WB/SWB bandwidth switching */ - IF( st_fx->bws_cnt_fx > 0 ) + IF( st_fx->bws_cnt > 0 ) { ener = mult(ener, 11587); /*bandwidth switching should be updated*/ @@ -2724,7 +2724,7 @@ void swb_tbe_dec_fx( } } - GainFrame = Mult_32_16(GainFrame, i_mult(sub(N_WS2N_FRAMES, st_fx->bws_cnt_fx), 819)); /*Q18*/ + GainFrame = Mult_32_16(GainFrame, i_mult(sub(N_WS2N_FRAMES, st_fx->bws_cnt), 819)); /*Q18*/ } ELSE { @@ -2857,8 +2857,8 @@ void swb_tbe_dec_fx( test(); test(); test(); - IF( ((GE_32(st_fx->total_brate, ACELP_24k40)&&EQ_16(st_fx->prev_coder_type_fx,coder_type)&&NE_16(coder_type,UNVOICED)) - || (LE_32(st_fx->total_brate, ACELP_16k40) && (EQ_16(st_fx->prev_coder_type_fx, coder_type) || (EQ_16(st_fx->prev_coder_type_fx, VOICED) && EQ_16(coder_type, GENERIC) ) || (EQ_16(st_fx->prev_coder_type_fx, GENERIC) && EQ_16(coder_type, VOICED) )))) + IF( ((GE_32(st_fx->total_brate, ACELP_24k40)&&EQ_16(st_fx->prev_coder_type,coder_type)&&NE_16(coder_type,UNVOICED)) + || (LE_32(st_fx->total_brate, ACELP_16k40) && (EQ_16(st_fx->prev_coder_type, coder_type) || (EQ_16(st_fx->prev_coder_type, VOICED) && EQ_16(coder_type, GENERIC) ) || (EQ_16(st_fx->prev_coder_type, GENERIC) && EQ_16(coder_type, VOICED) )))) && GT_16(pitch_fx, 4480 /*70 in Q6*/) && LT_16(st_fx->extl, FB_TBE) ) { FOR(i=0; iprev_swb_bwe_frame_pow_fx ))&& - ( GT_32(hBWE_TD->prev_swb_bwe_frame_pow_fx, L_tmp ) ) && EQ_16(st_fx->prev_coder_type_fx,UNVOICED) ) + ( GT_32(hBWE_TD->prev_swb_bwe_frame_pow_fx, L_tmp ) ) && EQ_16(st_fx->prev_coder_type,UNVOICED) ) { L_tmp = root_a_over_b_fx(hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow, curr_frame_pow_exp, &exp ); scale = round_fx( L_shl( L_tmp, exp ) ); /*Q15*/ @@ -3083,8 +3083,8 @@ void swb_tbe_dec_fx( test(); test(); IF( GT_32(curr_frame_pow, hBWE_TD->prev_swb_bwe_frame_pow_fx)&& - NE_16(st_fx->prev_coder_type_fx, UNVOICED) && - NE_16(st_fx->last_good_fx,UNVOICED_CLAS) ) + NE_16(st_fx->prev_coder_type, UNVOICED) && + NE_16(st_fx->last_good,UNVOICED_CLAS) ) { L_tmp = root_a_over_b_fx(hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow, curr_frame_pow_exp, &exp ); /*31 - exp*/ scale = round_fx( L_shl( L_tmp, sub(exp,3))); /*Q12*/ @@ -3095,7 +3095,7 @@ void swb_tbe_dec_fx( } ELSE IF( LT_32(curr_frame_pow, L_shr(hBWE_TD->prev_swb_bwe_frame_pow_fx,1))&&EQ_16(st_fx->nbLostCmpt,1)&& (GT_32(st_fx->enerLL_fx, L_shr( st_fx->prev_enerLL_fx,1)) || GT_32(st_fx->enerLH_fx, L_shr(st_fx->prev_enerLH_fx,1)) ) && - (EQ_16(st_fx->prev_coder_type_fx ,UNVOICED) || EQ_16(st_fx->last_good_fx, UNVOICED_CLAS) || GT_16(hBWE_TD->tilt_swb_fec_fx , 10240) )) + (EQ_16(st_fx->prev_coder_type ,UNVOICED) || EQ_16(st_fx->last_good, UNVOICED_CLAS) || GT_16(hBWE_TD->tilt_swb_fec_fx , 10240) )) { L_tmp = root_a_over_b_fx(hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow, curr_frame_pow_exp, &exp ); #ifdef BASOP_NOGLOB @@ -3131,7 +3131,7 @@ void swb_tbe_dec_fx( } ELSE IF( LT_32(curr_frame_pow, L_shr(hBWE_TD->prev_swb_bwe_frame_pow_fx,1))&& (GT_32(st_fx->enerLL_fx, L_shr( st_fx->prev_enerLL_fx,1)) || GT_32(st_fx->enerLH_fx, L_shr(st_fx->prev_enerLH_fx,1)) ) && - (st_fx->prev_coder_type_fx == UNVOICED || st_fx->last_good_fx == UNVOICED_CLAS || GT_16(hBWE_TD->tilt_swb_fec_fx , 10240)) ) + (st_fx->prev_coder_type == UNVOICED || st_fx->last_good == UNVOICED_CLAS || GT_16(hBWE_TD->tilt_swb_fec_fx , 10240)) ) { L_tmp = root_a_over_b_fx(hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow, curr_frame_pow_exp, &exp ); #ifdef BASOP_NOGLOB @@ -3441,7 +3441,7 @@ static void gradientGainShape( /* get the first gainshape template */ test(); test(); - IF( ( st_fx->prev_coder_type_fx == UNVOICED || st_fx->last_good_fx == UNVOICED_CLAS ) && GainGradFEC[0] > 0 ) + IF( ( st_fx->prev_coder_type == UNVOICED || st_fx->last_good == UNVOICED_CLAS ) && GainGradFEC[0] > 0 ) { GainShapeTemp[0] = add( shr( st_fx->GainShape_Delay[7], 1 ), GainGradFEC[0] ); move16(); @@ -3502,7 +3502,7 @@ static void gradientGainShape( test(); test(); test(); - IF( ( st_fx->prev_coder_type_fx == UNVOICED || st_fx->last_good_fx == UNVOICED_CLAS ) && st_fx->nbLostCmpt == 1 ) + IF( ( st_fx->prev_coder_type == UNVOICED || st_fx->last_good == UNVOICED_CLAS ) && st_fx->nbLostCmpt == 1 ) { FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) { @@ -3524,7 +3524,7 @@ static void gradientGainShape( } hBWE_TD->GainAttn_fx = mult_r(hBWE_TD->GainAttn_fx, 31129 ); } - ELSE IF( st_fx->prev_coder_type_fx == UNVOICED || st_fx->last_good_fx == UNVOICED_CLAS ) + ELSE IF( st_fx->prev_coder_type == UNVOICED || st_fx->last_good == UNVOICED_CLAS ) { FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) { diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index 27c4f551c..dd9b3c554 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -46,42 +46,42 @@ void updt_dec_fx( Copy( lsp_new_fx, st_fx->lsp_old_fx, M ); /* update last coding type */ - st_fx->last_coder_type_fx = st_fx->coder_type_fx; + st_fx->last_coder_type = st_fx->coder_type; test(); test(); test(); - if( EQ_16(st_fx->coder_type_fx,INACTIVE) || (EQ_16(st_fx->bpf_off,1) && NE_16(st_fx->coder_type_fx,AUDIO) && NE_16(st_fx->coder_type_fx,TRANSITION))) + if( EQ_16(st_fx->coder_type,INACTIVE) || (EQ_16(st_fx->bpf_off,1) && NE_16(st_fx->coder_type,AUDIO) && NE_16(st_fx->coder_type,TRANSITION))) { - st_fx->last_coder_type_fx = UNVOICED; + st_fx->last_coder_type = UNVOICED; move16(); } test(); test(); IF (st_fx->hGSCDec != NULL ) { - IF ((NE_16(st_fx->coder_type_fx, AUDIO) || st_fx->Last_GSC_noisy_speech_flag_fx != 0) && st_fx->hGSCDec->Last_GSC_pit_band_idx_fx > 0) + IF ((NE_16(st_fx->coder_type, AUDIO) || st_fx->Last_GSC_noisy_speech_flag_fx != 0) && st_fx->hGSCDec->Last_GSC_pit_band_idx_fx > 0) { st_fx->hGSCDec->Last_GSC_pit_band_idx_fx = 0; move16(); /*The temporal contribution of the GSC is meaningless after 1 frame lost for inactive & unvoiced content */ } } - /* this ensures that st_fx->last_coder_type_fx is never set to INACTIVE in case of AVQ inactive because the FEC does not distinguish between GSC inactive and AVQ inactive */ + /* this ensures that st_fx->last_coder_type is never set to INACTIVE in case of AVQ inactive because the FEC does not distinguish between GSC inactive and AVQ inactive */ test(); - if( GT_32(st_fx->total_brate,ACELP_24k40) && EQ_16(st_fx->coder_type_fx,INACTIVE)) + if( GT_32(st_fx->total_brate,ACELP_24k40) && EQ_16(st_fx->coder_type,INACTIVE)) { - st_fx->last_coder_type_fx = GENERIC; + st_fx->last_coder_type = GENERIC; move16(); } test(); test(); test(); - IF( EQ_16(st_fx->Opt_AMR_WB,1) && EQ_16(st_fx->coder_type_fx,INACTIVE) && + IF( EQ_16(st_fx->Opt_AMR_WB,1) && EQ_16(st_fx->coder_type,INACTIVE) && NE_32(st_fx->core_brate,SID_1k75) && NE_32(st_fx->core_brate,FRAME_NO_DATA)) { /* overwrite previous coding type to help FEC */ - st_fx->last_coder_type_fx = UNVOICED; + st_fx->last_coder_type = UNVOICED; move16(); st_fx->last_voice_factor_fx = voice_factors[NB_SUBFR-1]; move16(); @@ -100,7 +100,7 @@ void updt_dec_fx( } } test(); - IF(st_fx->hGSCDec != NULL && st_fx->coder_type_fx != AUDIO && st_fx->coder_type_fx != INACTIVE) + IF(st_fx->hGSCDec != NULL && st_fx->coder_type != AUDIO && st_fx->coder_type != INACTIVE) { st_fx->hGSCDec->noise_lev_fx = NOISE_LEVEL_SP3; move16(); @@ -170,7 +170,7 @@ void updt_dec_fx( hHQ_core->HqVoicing_fx = 1; move16(); test(); - if (!st_fx->Opt_AMR_WB && EQ_16(st_fx->coder_type_fx, UNVOICED)) + if (!st_fx->Opt_AMR_WB && EQ_16(st_fx->coder_type, UNVOICED)) { hHQ_core->HqVoicing_fx = 0; move16(); @@ -183,7 +183,7 @@ void updt_dec_fx( move16(); st_fx->last_ppp_mode_dec_fx = st_fx->ppp_mode_dec_fx; move16(); - st_fx->last_nelp_mode_dec_fx = st_fx->nelp_mode_dec_fx; + st_fx->last_nelp_mode_dec = st_fx->nelp_mode_dec_fx; move16(); st_fx->last_vbr_hw_BWE_disable_dec_fx = st_fx->vbr_hw_BWE_disable_dec_fx; move16(); @@ -353,7 +353,7 @@ void updt_IO_switch_dec_fx( /* reset VBR signalling */ st_fx->last_ppp_mode_dec_fx = 0; move16(); - st_fx->last_nelp_mode_dec_fx = 0; + st_fx->last_nelp_mode_dec = 0; move16(); st_fx->ppp_mode_dec_fx = 0; move16(); @@ -364,7 +364,7 @@ void updt_IO_switch_dec_fx( /* CNG - reset */ IF(st_fx->hTdCngDec != NULL) { - st_fx->hTdCngDec->ho_hist_size_fx = 0; + st_fx->hTdCngDec->ho_hist_size = 0; } move16(); @@ -413,7 +413,7 @@ void updt_bw_switching_fx( st_fx->last_inner_frame = L_FRAME32k; move16(); test(); - if( EQ_16(st_fx->bwidth, WB)&&st_fx->bws_cnt_fx==0) + if( EQ_16(st_fx->bwidth, WB)&&st_fx->bws_cnt==0) { st_fx->last_inner_frame = L_FRAME16k; move16(); @@ -424,13 +424,13 @@ void updt_bw_switching_fx( test(); test(); test(); - IF( !(GE_16(st_fx->last_inner_frame, L_FRAME16k)&&LE_16(inner_frame_tbl[st_fx->bwidth],L_FRAME16k)&&st_fx->bws_cnt_fx>0&<_16(st_fx->bws_cnt_fx,N_WS2N_FRAMES))) + IF( !(GE_16(st_fx->last_inner_frame, L_FRAME16k)&&LE_16(inner_frame_tbl[st_fx->bwidth],L_FRAME16k)&&st_fx->bws_cnt>0&<_16(st_fx->bws_cnt,N_WS2N_FRAMES))) { st_fx->last_inner_frame = inner_frame_tbl[st_fx->bwidth]; move16(); } } - st_fx->prev_bws_cnt_fx = st_fx->bws_cnt_fx; + st_fx->prev_bws_cnt = st_fx->bws_cnt; move16(); return; } @@ -463,12 +463,12 @@ void updt_dec_common_fx( st_fx->last_L_frame = st_fx->L_frame; move16(); - st_fx->prev_old_bfi_fx = st_fx->prev_bfi; + st_fx->prev_old_bfi = st_fx->prev_bfi; st_fx->prev_bfi = st_fx->bfi; move16(); if (NE_16(st_fx->core, AMR_WB_CORE)) { - st_fx->old_bfi_cnt_fx = st_fx->nbLostCmpt; + st_fx->old_bfi_cnt = st_fx->nbLostCmpt; move16(); } move16(); @@ -479,7 +479,7 @@ void updt_dec_common_fx( move16(); if(st_fx->hHQ_nbfec != NULL) { - st_fx->hHQ_nbfec->prev_last_core_fx = st_fx->last_core; + st_fx->hHQ_nbfec->prev_last_core = st_fx->last_core; } if(st_fx->hTcxDec != NULL) { @@ -491,12 +491,12 @@ void updt_dec_common_fx( { test();test(); test(); test(); - if( st_fx->bfi && (LE_16(st_fx->last_good_fx, UNVOICED_TRANSITION)) && (GT_16(st_fx->clas_dec,UNVOICED_TRANSITION)) && st_fx->last_con_tcx && st_fx->hTcxDec != NULL) + if( st_fx->bfi && (LE_16(st_fx->last_good, UNVOICED_TRANSITION)) && (GT_16(st_fx->clas_dec,UNVOICED_TRANSITION)) && st_fx->last_con_tcx && st_fx->hTcxDec != NULL) { hTcxDec->tcxConceal_recalc_exc = 1; move16(); } - st_fx->last_good_fx = st_fx->clas_dec; + st_fx->last_good = st_fx->clas_dec; move16(); } IF (st_fx->use_partial_copy) @@ -527,7 +527,7 @@ void updt_dec_common_fx( st_fx->last_core = st_fx->core; if (st_fx->hHQ_core != NULL) { - st_fx->hHQ_core->last_hq_core_type_fx = hq_core_type_fx; + st_fx->hHQ_core->last_hq_core_type = hq_core_type_fx; } } ELSE IF( EQ_16(st_fx->codec_mode,MODE2)) @@ -604,11 +604,11 @@ void updt_dec_common_fx( test(); IF(EQ_16(st_fx->use_partial_copy, 1) && EQ_16(st_fx->rf_frame_type, RF_NELP)) { - st_fx->last_nelp_mode_dec_fx = 1; + st_fx->last_nelp_mode_dec = 1; } ELSE { - st_fx->last_nelp_mode_dec_fx = 0; + st_fx->last_nelp_mode_dec = 0; } } @@ -630,34 +630,34 @@ void updt_dec_common_fx( IF (EQ_16(st_fx->core, HQ_CORE)) { - st_fx->prev_coder_type_fx = GENERIC; + st_fx->prev_coder_type = GENERIC; } ELSE IF (NE_16(st_fx->core, AMR_WB_CORE) ) { - st_fx->prev_coder_type_fx = st_fx->coder_type_fx; + st_fx->prev_coder_type = st_fx->coder_type; } test(); IF((GT_32(st_fx->core_brate, SID_2k40) || (GT_32(st_fx->core_brate, SID_1k75) && EQ_16(st_fx->core, AMR_WB_CORE))) && EQ_16(st_fx->first_CNG, 1) && st_fx->hTdCngDec != NULL) { - if (GE_16(st_fx->hTdCngDec->act_cnt_fx, BUF_DEC_RATE)) + if (GE_16(st_fx->hTdCngDec->act_cnt, BUF_DEC_RATE)) { - st_fx->hTdCngDec->act_cnt_fx = 0; + st_fx->hTdCngDec->act_cnt = 0; move16(); } - st_fx->hTdCngDec->act_cnt_fx = add(st_fx->hTdCngDec->act_cnt_fx, 1); + st_fx->hTdCngDec->act_cnt = add(st_fx->hTdCngDec->act_cnt, 1); test(); - if ((EQ_16(st_fx->hTdCngDec->act_cnt_fx, BUF_DEC_RATE)) && (st_fx->hTdCngDec->ho_hist_size_fx > 0)) + if ((EQ_16(st_fx->hTdCngDec->act_cnt, BUF_DEC_RATE)) && (st_fx->hTdCngDec->ho_hist_size > 0)) { - st_fx->hTdCngDec->ho_hist_size_fx = sub(st_fx->hTdCngDec->ho_hist_size_fx, 1); + st_fx->hTdCngDec->ho_hist_size = sub(st_fx->hTdCngDec->ho_hist_size, 1); } - st_fx->hTdCngDec->act_cnt2_fx = add(st_fx->hTdCngDec->act_cnt2_fx, 1); - if (GE_16(st_fx->hTdCngDec->act_cnt2_fx, MIN_ACT_CNG_UPD)) + st_fx->hTdCngDec->act_cnt2 = add(st_fx->hTdCngDec->act_cnt2, 1); + if (GE_16(st_fx->hTdCngDec->act_cnt2, MIN_ACT_CNG_UPD)) { - st_fx->hTdCngDec->act_cnt2_fx = MIN_ACT_CNG_UPD; + st_fx->hTdCngDec->act_cnt2 = MIN_ACT_CNG_UPD; move16(); } } @@ -690,8 +690,8 @@ void updt_dec_common_fx( { st_fx->last_bwidth = WB; - st_fx->prev_bws_cnt_fx = 0; - st_fx->bws_cnt_fx = 0; + st_fx->prev_bws_cnt = 0; + st_fx->bws_cnt = 0; st_fx->bws_cnt1_fx = 0; move16();move16();move16();move16(); @@ -703,7 +703,7 @@ void updt_dec_common_fx( ELSE { st_fx->last_bwidth = st_fx->bwidth; - st_fx->prev_bws_cnt_fx = st_fx->bws_cnt_fx; + st_fx->prev_bws_cnt = st_fx->bws_cnt; move32(); move16(); } @@ -771,7 +771,7 @@ static void ivas_updt_bw_switching_fx( st_fx->last_inner_frame = L_FRAME32k; move16(); test(); - IF( EQ_16(st_fx->bwidth, WB) && EQ_16(st_fx->bws_cnt_fx, 0)) + IF( EQ_16(st_fx->bwidth, WB) && EQ_16(st_fx->bws_cnt, 0)) { st_fx->last_inner_frame = L_FRAME16k; move16(); @@ -782,13 +782,13 @@ static void ivas_updt_bw_switching_fx( test(); test(); test(); - IF( !(GE_16(st_fx->last_inner_frame, L_FRAME16k)&&LE_16(inner_frame_tbl[st_fx->bwidth],L_FRAME16k)&&st_fx->bws_cnt_fx>0&<_16(st_fx->bws_cnt_fx,N_WS2N_FRAMES))) + IF( !(GE_16(st_fx->last_inner_frame, L_FRAME16k)&&LE_16(inner_frame_tbl[st_fx->bwidth],L_FRAME16k)&&st_fx->bws_cnt>0&<_16(st_fx->bws_cnt,N_WS2N_FRAMES))) { st_fx->last_inner_frame = inner_frame_tbl[st_fx->bwidth]; move16(); } } - st_fx->prev_bws_cnt_fx = st_fx->bws_cnt_fx; + st_fx->prev_bws_cnt = st_fx->bws_cnt; // TODO: Duplicate variables move16(); return; } @@ -815,12 +815,12 @@ void ivas_updt_dec_common_fx( st_fx->last_L_frame = st_fx->L_frame; move16(); - st_fx->prev_old_bfi_fx = st_fx->prev_bfi; + st_fx->prev_old_bfi = st_fx->prev_bfi; st_fx->prev_bfi = st_fx->bfi; move16(); IF (NE_16(st_fx->core, AMR_WB_CORE)) { - st_fx->old_bfi_cnt_fx = st_fx->nbLostCmpt; + st_fx->old_bfi_cnt = st_fx->nbLostCmpt; move16(); } move16(); @@ -831,8 +831,9 @@ void ivas_updt_dec_common_fx( move16(); IF(st_fx->hHQ_nbfec != NULL) { - st_fx->hHQ_nbfec->prev_last_core_fx = st_fx->last_core; + st_fx->hHQ_nbfec->prev_last_core = st_fx->last_core; } + IF(st_fx->hTcxDec != NULL) { hTcxDec->tcxConceal_recalc_exc = 0; @@ -843,12 +844,13 @@ void ivas_updt_dec_common_fx( { test();test(); test(); test(); - IF( st_fx->bfi && (LE_16(st_fx->last_good_fx, UNVOICED_TRANSITION)) && (GT_16(st_fx->clas_dec,UNVOICED_TRANSITION)) && st_fx->last_con_tcx && st_fx->hTcxDec != NULL) + + IF( st_fx->bfi && (LE_16(st_fx->last_good, UNVOICED_TRANSITION)) && (GT_16(st_fx->clas_dec,UNVOICED_TRANSITION)) && st_fx->last_con_tcx && st_fx->hTcxDec != NULL) { hTcxDec->tcxConceal_recalc_exc = 1; move16(); } - st_fx->last_good_fx = st_fx->clas_dec; + st_fx->last_good = st_fx->clas_dec; move16(); } IF (st_fx->use_partial_copy) @@ -860,7 +862,7 @@ void ivas_updt_dec_common_fx( st_fx->prev_rf_frame_type = INACTIVE; } - IF (EQ_16(st_fx->m_frame_type, ACTIVE_FRAME) && (st_fx->bfi!=1 || st_fx->use_partial_copy!=0)) + IF (EQ_16(st_fx->m_frame_type, ACTIVE_FRAME) && (st_fx->bfi!=0 || st_fx->use_partial_copy!=0)) { st_fx->rf_flag_last = st_fx->rf_flag; } @@ -876,10 +878,14 @@ void ivas_updt_dec_common_fx( move16(); move16(); - st_fx->last_core = st_fx->core; + if ( !st_fx->bfi || st_fx->element_mode == EVS_MONO ) + { + st_fx->last_core = st_fx->core; + } + st_fx->last_core_bfi = st_fx->core; /* also required for clean channel decoding */ if (st_fx->hHQ_core != NULL) { - st_fx->hHQ_core->last_hq_core_type_fx = hq_core_type_fx; + st_fx->hHQ_core->last_hq_core_type = hq_core_type_fx; } } ELSE IF( EQ_16(st_fx->codec_mode,MODE2)) @@ -956,11 +962,11 @@ void ivas_updt_dec_common_fx( test(); IF(EQ_16(st_fx->use_partial_copy, 1) && EQ_16(st_fx->rf_frame_type, RF_NELP)) { - st_fx->last_nelp_mode_dec_fx = 1; + st_fx->last_nelp_mode_dec = 1; } ELSE { - st_fx->last_nelp_mode_dec_fx = 0; + st_fx->last_nelp_mode_dec = 0; } } @@ -982,34 +988,37 @@ void ivas_updt_dec_common_fx( IF (EQ_16(st_fx->core, HQ_CORE)) { - st_fx->prev_coder_type_fx = GENERIC; + st_fx->prev_coder_type = GENERIC; } ELSE IF (NE_16(st_fx->core, AMR_WB_CORE) ) { - st_fx->prev_coder_type_fx = st_fx->coder_type_fx; + st_fx->prev_coder_type = st_fx->coder_type; } test(); IF((GT_32(st_fx->core_brate, SID_2k40) || (GT_32(st_fx->core_brate, SID_1k75) && EQ_16(st_fx->core, AMR_WB_CORE))) && EQ_16(st_fx->first_CNG, 1) && st_fx->hTdCngDec != NULL) { - IF (GE_16(st_fx->hTdCngDec->act_cnt_fx, BUF_DEC_RATE)) + + IF (GE_16(st_fx->hTdCngDec->act_cnt, BUF_DEC_RATE)) { - st_fx->hTdCngDec->act_cnt_fx = 0; + st_fx->hTdCngDec->act_cnt = 0; move16(); } - st_fx->hTdCngDec->act_cnt_fx = add(st_fx->hTdCngDec->act_cnt_fx, 1); + st_fx->hTdCngDec->act_cnt = add(st_fx->hTdCngDec->act_cnt, 1); test(); - IF ((EQ_16(st_fx->hTdCngDec->act_cnt_fx, BUF_DEC_RATE)) && (st_fx->hTdCngDec->ho_hist_size_fx > 0)) + + IF ((EQ_16(st_fx->hTdCngDec->act_cnt, BUF_DEC_RATE)) && (st_fx->hTdCngDec->ho_hist_size > 0)) { - st_fx->hTdCngDec->ho_hist_size_fx = sub(st_fx->hTdCngDec->ho_hist_size_fx, 1); + st_fx->hTdCngDec->ho_hist_size = sub(st_fx->hTdCngDec->ho_hist_size, 1); } - st_fx->hTdCngDec->act_cnt2_fx = add(st_fx->hTdCngDec->act_cnt2_fx, 1); - IF (GE_16(st_fx->hTdCngDec->act_cnt2_fx, MIN_ACT_CNG_UPD)) + //st_fx->hTdCngDec->act_cnt2 = add(st_fx->hTdCngDec->act_cnt2, 1); + + IF (GE_16(st_fx->hTdCngDec->act_cnt2, MIN_ACT_CNG_UPD)) { - st_fx->hTdCngDec->act_cnt2_fx = MIN_ACT_CNG_UPD; + st_fx->hTdCngDec->act_cnt2 = MIN_ACT_CNG_UPD; move16(); } } @@ -1042,9 +1051,9 @@ void ivas_updt_dec_common_fx( { st_fx->last_bwidth = WB; - st_fx->prev_bws_cnt_fx = 0; - st_fx->bws_cnt_fx = 0; - st_fx->bws_cnt1_fx = 0; + st_fx->prev_bws_cnt = 0; + st_fx->bws_cnt = 0; + st_fx->bws_cnt1 = 0; move16();move16();move16();move16(); } @@ -1055,7 +1064,7 @@ void ivas_updt_dec_common_fx( ELSE { st_fx->last_bwidth = st_fx->bwidth; - st_fx->prev_bws_cnt_fx = st_fx->bws_cnt_fx; + st_fx->prev_bws_cnt = st_fx->bws_cnt; move32(); move16(); } @@ -1065,8 +1074,8 @@ void ivas_updt_dec_common_fx( test(); IF(st_fx->hTdCngDec != NULL && (st_fx->bfi || (NE_32(st_fx->core_brate, FRAME_NO_DATA) && NE_32(st_fx->core_brate, SID_2k40))) && NE_16(st_fx->core, AMR_WB_CORE)) { - Random(&(st_fx->hTdCngDec->cng_seed_fx)); - Random(&(st_fx->hTdCngDec->cng_ener_seed_fx)); + Random(&(st_fx->hTdCngDec->cng_seed)); + Random(&(st_fx->hTdCngDec->cng_ener_seed)); } test();test();test(); @@ -1228,7 +1237,7 @@ void update_decoder_LPD_cng( move16(); move16(); st->nbLostCmpt = 0; - st->prev_old_bfi_fx = 0; + st->prev_old_bfi = 0; FOR (i=0; ilast_coder_type_fx,UNVOICED)) + if (EQ_16(st_fx->last_coder_type,UNVOICED)) { pl = l; move16(); /* if prev frame was sil/uv*/ diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index ed6e3efe7..bbe55a384 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -26,7 +26,7 @@ /* _ (Word16[]) Aq_fx : LP filter coefficient Q12 */ /* _ (Word16[]) A_fx : unquantized A(z) filter */ /* with bandwidth expansion Q12 */ -/* _ (Word16) coder_type_fx : coding type */ +/* _ (Word16) coder_type : coding type */ /* _ (Word16) Es_pred_fx : predicted scaled innov. energy Q8 */ /* _ (Word16[]) T_op_fx : open loop pitch Q0 */ /* _ (Word16[]) voicing_fx : floating pitch values for each subframe Q15*/ diff --git a/lib_enc/enc_nelp_fx.c b/lib_enc/enc_nelp_fx.c index 01b5113f9..f3a72bed2 100644 --- a/lib_enc/enc_nelp_fx.c +++ b/lib_enc/enc_nelp_fx.c @@ -23,7 +23,7 @@ /* _ (Word16[]) Aq_fx : 12k8 Lp coefficient Q12 */ /* _ (Word16[]) A_fx : unquantized A(z) filter */ /* with bandwidth expansion Q12 */ -/* _ (Word16) coder_type_fx : coding type */ +/* _ (Word16) coder_type : coding type */ /* _ (Word16[]) res_fx : residual signal Q_new */ /* _ (Word16*) Q_new : res qformat */ /* _ (Word16) shift */ diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index ceb64bad2..c5718ff8a 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -23,7 +23,7 @@ /* _ (Word16[]) Aq_fx : LP filter coefficient Q12 */ /* _ (Word16[]) A_fx : unquantized A(z) filter */ /* with bandwidth expansion Q12 */ -/* _ (Word16) coder_type_fx : coding type */ +/* _ (Word16) coder_type : coding type */ /* _ (Word16) Es_pred_fx : predicted scaled innov. energy Q8 */ /* _ (Word16[]) T_op_fx : open loop pitch Q0 */ /* _ (Word16[]) voicing_fx : floating pitch values for each subframe Q15*/ diff --git a/lib_enc/enc_ppp_fx.c b/lib_enc/enc_ppp_fx.c index 2b2f7d90c..a0c617dd0 100644 --- a/lib_enc/enc_ppp_fx.c +++ b/lib_enc/enc_ppp_fx.c @@ -23,7 +23,7 @@ void E_LPC_f_lsp_a_conversion(const Word16 *lsp, Word16 *a, const Word16 m); /* _ (Word16) speech_fx[], i : input speech Q_new */ /* _ (Word16) Aq_fx[], i : 12k8 Lp coefficient Q12 */ /* _ (Word16) A_fx[], i : unquantized A(z) filter with bandwidth expansion Q12*/ -/* _ (Word16) coder_type_fx, i : coding type */ +/* _ (Word16) coder_type, i : coding type */ /* _ (Word16) T_op_fx[], i : open loop pitch */ /* _ (Word16) voicing_fx[], i : voicing Q15 */ /* _ (Word16) *res_fx, i : residual signal Q_new */ diff --git a/lib_enc/evs_enc.c b/lib_enc/evs_enc.c index f23c044c9..5a14111f1 100644 --- a/lib_enc/evs_enc.c +++ b/lib_enc/evs_enc.c @@ -40,6 +40,9 @@ #include "rom_com.h" #include "prot.h" #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif /*-------------------------------------------------------------------* * Local function prototypes diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index 880f5c301..750173b41 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -43,6 +43,9 @@ #include "ivas_prot.h" #include "ivas_cnst.h" #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif /*-----------------------------------------------------------------------* * init_encoder() diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index ed557457d..4c5df31f3 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -919,7 +919,7 @@ ISM_MODE ism_mode = ISM_MODE_NONE; st_fx->element_brate = -1; /* element bitrate */ //PMT("element_mode and element_brate should be initialized at a proper place in ivas_dec_init eventually") st_fx->low_rate_mode = 0; /* low-rate mode flag */ - //st_fx->coder_type_fx = GENERIC; /* low-rate mode flag */ + //st_fx->coder_type = GENERIC; /* low-rate mode flag */ set16_fx(st_fx->pitch_fx, L_SUBFR, 3); set16_fx(st_fx->voicing_fx, 0, 3); diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index 79b4889cf..ca2d20f07 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -25,7 +25,7 @@ /* _ (Word16) L_frame_fx : length of the frame Q0 */ /* _ (Word16[]) h2 : weighted filter input response Q12 */ /* _ (Word16[]) xn2 : target vector Q_new */ -/* _ (Word16) coder_type_fx : coding type Q0 */ +/* _ (Word16) coder_type : coding type Q0 */ /* _ (Word16) i_subfr : current sub frame indicator Q0 */ /* _ (Word16[]) exc_fx : pointer to excitation signal frame Q_new */ /* _ (Word16) L_subfr : subframe length Q0 */ diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index ea86bfa0a..f15d9eb78 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -40,6 +40,9 @@ #include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif /*--------------------------------------------------------------------------* diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index c2c9be7d9..9d7ee9dbd 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -37,6 +37,9 @@ #include "ivas_prot.h" #include "ivas_stat_enc.h" #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index 44321962f..69d19b5db 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -42,6 +42,9 @@ #include "wmc_auto.h" #include "prot.h" +#include "prot_fx1.h" +#include "prot_fx2.h" +#include "ivas_prot_fx.h" /*-----------------------------------------------------------------------* * Local function prototypes diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 4088a526c..3c66fe56c 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -42,6 +42,9 @@ #include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif /*-------------------------------------------------------------------* diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index 34f8d2570..c90805ec2 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -37,7 +37,7 @@ static void limit_T0_voiced2( Word16 res, const Word16 *T_op, Word16 *T0_min, Wo /* _ (Word16) L_frame_fx : length of the frame Q0 */ /* _ (Word16[]) h1 : weighted filter input response Q15 */ /* _ (Word16[]) xn : target vector Q_new */ -/* _ (Word16) coder_type_fx : coding type Q0 */ +/* _ (Word16) coder_type : coding type Q0 */ /* _ (Word16) i_subfr : current sub frame indicator Q0 */ /* _ (Word16[]) exc_fx : pointer to excitation signal frame Q_new */ /* _ (Word16[]) L_subfr : subframe length Q0 */ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 28916532d..5eb452d7f 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -474,7 +474,7 @@ void swb_pre_proc_fx( void swb_tbe_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 coder_type_fx, /* i : coding type */ + const Word16 coder_type, /* i : coding type */ Word16 *new_speech_fx, /* i : original i signal */ Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation */ const Word16 voice_factors_fx[], /* i : voicing factors */ diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 67531bda9..e922d581f 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -2403,7 +2403,7 @@ typedef struct enc_core_structure // Word16 mCb1_fx; /* LSF quantizer - counter of stationary frames after a transition frame */ // Word16 coder_type_raw_fx; // Word16 last_coder_type_raw_fx; /* raw last_coder_type (coming from the sigal classification) */ -// Word16 last_coder_type_fx; /*Q0 previous coding type */ +// Word16 last_coder_type; /*Q0 previous coding type */ // Word16 ini_frame_fx; /* initialization frames counter */ // Word16 old_thres_fx; /* normalized correlation weighting in open-loop pitch Q15 */ // Word16 old_corr_fx; /* normalized correlation in previous frame (mean value) Q15 */ diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index b53dc5610..4dbc299c4 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -1126,7 +1126,7 @@ void fb_tbe_reset_enc_fx( /* PURPOSE : SWB TBE encoder, 6 - 14 kHz (or 7.5 - 15.5 kHz) band encoding module */ /*--------------------------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* _(Word16) coder_type_fx : coding type */ +/* _(Word16) coder_type : coding type */ /* _(Word16*) shb_speech_fx : SHB target signal (6-14kHz) at 16kHz Q0 */ /* _(Word16*) bwe_exc_extended :bandwidth extended exciatation Q0 */ /* _(Word16[]) voice_factors :voicing factors Q15 */ @@ -1147,7 +1147,7 @@ void fb_tbe_reset_enc_fx( void swb_tbe_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 coder_type_fx, /* i : coding type */ + const Word16 coder_type, /* i : coding type */ Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q_shb*/ Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation 2*Q_new*/ const Word16 voice_factors_fx[], /* i : voicing factors Q15*/ @@ -1362,7 +1362,7 @@ void swb_tbe_enc_fx( Copy( voice_factors_fx, vf_modified_fx, NB_SUBFR16k ); test(); - IF( EQ_16(coder_type_fx, VOICED)||GT_16(mean_vf,13107/*0.4f Q15*/)) + IF( EQ_16(coder_type, VOICED)||GT_16(mean_vf,13107/*0.4f Q15*/)) { FOR( i = 1; i < NB_SUBFR; i++ ) { @@ -1425,7 +1425,7 @@ void swb_tbe_enc_fx( test(); test(); test(); - IF(!(GT_16(hBWE_TD->prev_tilt_para_fx,5120)&&(EQ_16(coder_type_fx,TRANSITION)||LT_16(tilt_para,1024)))&& + IF(!(GT_16(hBWE_TD->prev_tilt_para_fx,5120)&&(EQ_16(coder_type,TRANSITION)||LT_16(tilt_para,1024)))&& !(((LT_16(hBWE_TD->prev_tilt_para_fx,3072) && GE_16(hBWE_TD->prev_coder_type,VOICED) )) && GT_16(tilt_para,5120) )) { FOR( i = 1; i < LPC_SHB_ORDER-1; i++ ) @@ -1622,7 +1622,7 @@ void swb_tbe_enc_fx( GenShapedSHBExcitation_fx( shaped_shb_excitation_fx + L_SHB_LAHEAD, lpc_shb_fx, White_exc16k_fx, hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, - coder_type_fx, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified_fx, st_fx->extl, + coder_type, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified_fx, st_fx->extl, &(hBWE_TD->tbe_demph_fx ), &(hBWE_TD->tbe_premph_fx ), lpc_shb_sf_fx, shb_ener_sf_Q31, shb_res_gshape_fx, shb_res_fx, &vf_ind_fx, formant_fac_fx, hBWE_TD->fb_state_lpc_syn_fx, &(hBWE_TD->fb_tbe_demph_fx), &Q_bwe_exc,&Q_bwe_exc_fb, Q_shb, n_mem2, st_fx->prev_Q_bwe_syn, st_fx->total_brate, 0 ); -- GitLab