diff --git a/lib_com/hq2_noise_inject_fx.c b/lib_com/hq2_noise_inject_fx.c index c7326bd8e6b89b48cd25cae686d473677ceedc28..223462df43299c371c82a0e52464f59541dd9db9 100644 --- a/lib_com/hq2_noise_inject_fx.c +++ b/lib_com/hq2_noise_inject_fx.c @@ -110,7 +110,7 @@ void hq2_noise_inject_fx( test(); test(); test(); - IF( ( EQ_16( hqswb_clas, HQ_HARMONIC ) || EQ_16( hqswb_clas, HQ_NORMAL ) ) && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) && EQ_16( bwidth, SWB ) ) + IF( ( EQ_16( hqswb_clas, HQ_HARMONIC ) || hqswb_clas == HQ_NORMAL ) && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) && EQ_16( bwidth, SWB ) ) { sb = 17; move16(); @@ -608,6 +608,8 @@ void hq2_noise_inject_fx( IF( EQ_16( k, max_pos_pulse ) && add( sub( k, bands ), p2a_bands ) < 0 && NE_16( satur, 1 ) && NE_16( bwidth, SWB ) ) { j = 0; + move16(); + Q_speech = norm_l( ni_gain_fx[k] ); tmp = extract_h( L_shl( ni_gain_fx[k], Q_speech ) ); /*Q(Q_speech+1) */ IF( tmp != 0 ) @@ -654,6 +656,8 @@ void hq2_noise_inject_fx( { tmp = 0x7fff; Q_speech = 0; + move16(); + move16(); } tmp1 = sub( fac_fx, 4096 ); /*Q12 */ L_tmp = L_mult( tmp1, j ); /*Q13 */ diff --git a/lib_com/hq_bit_allocation_fx.c b/lib_com/hq_bit_allocation_fx.c index ef2f13e0564c2e7302593a9b2b3c129a04819cf8..b78d2b3746cf97b1c778af3664cdfe92be4bc9c6 100644 --- a/lib_com/hq_bit_allocation_fx.c +++ b/lib_com/hq_bit_allocation_fx.c @@ -279,15 +279,18 @@ void hq_bit_allocation_fx( IF( EQ_32( core_brate, HQ_32k ) ) { *num_bits = sub( *num_bits, HQ_GENERIC_SWB_NBITS2 ); + move16(); } ELSE { *num_bits = sub( *num_bits, HQ_GENERIC_SWB_NBITS ); + move16(); } if ( EQ_16( hqswb_clas, HQ_GEN_FB ) ) { *num_bits = sub( *num_bits, HQ_GENERIC_FB_NBITS ); + move16(); } } diff --git a/lib_com/hq_conf.c b/lib_com/hq_conf.c index d96448b02f216491c3fce4087f508b2b84de9d75..6c2b60c998f41b12934c40654fee1726b5231180 100644 --- a/lib_com/hq_conf.c +++ b/lib_com/hq_conf.c @@ -406,6 +406,7 @@ void hq_configure_fx( *nb_sfm = HVQ_THRES_SFM_24k; move16(); *num_env_bands = sub( *num_sfm, *nb_sfm ); + move16(); *start_norm = HVQ_THRES_SFM_24k; move16(); @@ -417,6 +418,7 @@ void hq_configure_fx( *nb_sfm = HVQ_THRES_SFM_32k; move16(); *num_env_bands = sub( *num_sfm, *nb_sfm ); + move16(); *start_norm = HVQ_THRES_SFM_32k; move16(); @@ -534,7 +536,7 @@ void hq_configure_fx( move16(); move16(); } - else + ELSE { Copy( p_sfmsize, sfmsize, *num_sfm ); Copy( p_sfm_start, sfm_start, *num_sfm ); diff --git a/lib_com/hq_conf_fx.c b/lib_com/hq_conf_fx.c index eb675986b941327f64030740700e97dcf40ef763..7dd8a23713f471549f35462272acb36cbc24b735 100644 --- a/lib_com/hq_conf_fx.c +++ b/lib_com/hq_conf_fx.c @@ -169,6 +169,7 @@ void ivas_hq_configure_fx( *nb_sfm = HVQ_THRES_SFM_24k; move16(); *num_env_bands = sub( *num_sfm, *nb_sfm ); + move16(); *start_norm = HVQ_THRES_SFM_24k; move16(); @@ -180,6 +181,7 @@ void ivas_hq_configure_fx( *nb_sfm = HVQ_THRES_SFM_32k; move16(); *num_env_bands = sub( *num_sfm, *nb_sfm ); + move16(); *start_norm = HVQ_THRES_SFM_32k; move16(); @@ -332,6 +334,7 @@ void hq_configure_evs_fx( Word16 i, bw_ext; bw_ext = 0; + move16(); *start_norm = 0; move16(); @@ -465,6 +468,7 @@ void hq_configure_evs_fx( *nb_sfm = HVQ_THRES_SFM_24k; move16(); *num_env_bands = sub( *num_sfm, *nb_sfm ); + move16(); *start_norm = HVQ_THRES_SFM_24k; move16(); @@ -476,6 +480,7 @@ void hq_configure_evs_fx( *nb_sfm = HVQ_THRES_SFM_32k; move16(); *num_env_bands = sub( *num_sfm, *nb_sfm ); + move16(); *start_norm = HVQ_THRES_SFM_32k; move16(); @@ -593,7 +598,7 @@ void hq_configure_evs_fx( move16(); move16(); } - else + ELSE { Copy( p_sfmsize, sfmsize, *num_sfm ); Copy( p_sfm_start, sfm_start, *num_sfm ); diff --git a/lib_com/hq_tools_fx.c b/lib_com/hq_tools_fx.c index d9f95a06b41553a518ce2dbf7c50e9f5315c5177..7b18fd127850e000848aeb163c668f874f822a11 100644 --- a/lib_com/hq_tools_fx.c +++ b/lib_com/hq_tools_fx.c @@ -410,7 +410,6 @@ void apply_noisefill_HQ_fx( Word32 L_E_cb_vec; Word32 L_E_corr; - test(); test(); IF( ( GE_16( length, L_FRAME32k ) ) || ( NE_32( L_core_brate, HQ_32k ) ) ) { @@ -864,7 +863,7 @@ void ivas_harm_bwe_fx( FOR( sfm = 0; sfm <= last_sfm; sfm++ ) { - IF( EQ_16( R[sfm], 0 ) ) + IF( R[sfm] == 0 ) { normq = dicn_fx[norm[sfm]]; /*Q14 */ move16(); @@ -1309,7 +1308,7 @@ void hvq_bwe_fx( } power_shift = shl( shift, 1 ); - L_E = L_shr( L_E, sub( power_shift, 28 - 2 * qin ) ); /* Q28 */ + L_E = L_shr( L_E, sub( power_shift, sub( 28, shl( qin, 1 ) ) ) ); /* Q28 */ /* E_L = (float)sqrt((sfm_end[norm_ind+1] - sfm_start[norm_ind])/E_L); */ L_E = Mult_32_16( L_E, inv_tbl_fx[band_size] ); /* Q28 (28+15+1-16) */ @@ -1623,15 +1622,15 @@ void noise_mix_fx( IF( L_tmp0 != 0 ) { /* Normalize with 1 bit headroom for addition */ - tmp = 30 - ( qin + 2 ); /* Assuming fixed Q values */ + tmp = sub( 30, add( qin, 2 ) ); /* Assuming fixed Q values */ tmp = s_min( norm_l( L_tmp0 ), tmp ); tmp = sub( tmp, 1 ); L_tmp0 = L_add( L_shl( L_tmp0, tmp ), L_deposit_l( lshr( lsb, sub( 16, tmp ) ) ) ); /* Qin+2+tmp */ L_tmp0 = L_add( L_tmp0, L_shr( L_mult0( noise_level, Random( seed ) ), sub( 30 - ( qin + 2 ), tmp ) ) ); /* Qin+2+tmp */ - tmp = round_fx( L_shl( L_tmp0, 27 - ( qin + 2 ) - tmp ) ); /* Q11 (Qin+2+tmp+27-qin-2-tmp-16) */ - Mpy_32_16_ss( L_normq, tmp, &L_tmp0, &lsb ); /* Q10 (14+11+1-16) */ + tmp = round_fx( L_shl( L_tmp0, sub( sub( 27, add( qin, 2 ) ), tmp ) ) ); /* Q11 (Qin+2+tmp+27-qin-2-tmp-16) */ + Mpy_32_16_ss( L_normq, tmp, &L_tmp0, &lsb ); /* Q10 (14+11+1-16) */ L_coeff_out[i] = L_add( L_shl( L_tmp0, qout - 10 ), L_deposit_l( lshr( lsb, 10 + 16 - qout ) ) ); move32(); /* Qout (10+qout-10) */ } @@ -2000,7 +1999,7 @@ Word16 calc_nor_delta_hf_fx( delta = max_delta; move16(); } - ELSE if ( LT_16( delta, min_delta ) ) + ELSE IF( LT_16( delta, min_delta ) ) { delta = min_delta; move16(); @@ -2103,6 +2102,9 @@ void hq_wb_nf_bwe_fx( /* the variance of bit allocation */ total_bit = 0; bitalloc_var_fx = 0; + move16(); + move16(); + FOR( sfm = 8; sfm <= last_sfm; sfm++ ) { tmp = abs_s( sub( R[sfm], R[sub( sfm, 1 )] ) ); @@ -2125,6 +2127,7 @@ void hq_wb_nf_bwe_fx( ELSE { bitalloc_var_fx = 0; /*Q14 */ + move16(); } /* calculate the peak-average ratio of saturable subbands */ num = 0; diff --git a/lib_com/hvq_pvq_bitalloc_fx.c b/lib_com/hvq_pvq_bitalloc_fx.c index 003f7864c71aaf3ab0a6f3f5fa454d6c8f8b2095..298547b539529b852761b74ceb8f385cbd9ff945 100644 --- a/lib_com/hvq_pvq_bitalloc_fx.c +++ b/lib_com/hvq_pvq_bitalloc_fx.c @@ -102,7 +102,7 @@ Word16 hvq_pvq_bitalloc_fx( } /* safety check in case of bit errors */ - if ( LT_16( num_bands, 1 ) ) + IF( LT_16( num_bands, 1 ) ) { return 0; } diff --git a/lib_com/igf_base.c b/lib_com/igf_base.c index 48985e9a94dbe53e63eed5b4a51dbf52b0cc1bb6..adad4c47c2b29b458c4a2d889a1020cc66f6d82d 100644 --- a/lib_com/igf_base.c +++ b/lib_com/igf_base.c @@ -503,7 +503,6 @@ static void IGF_gridSetUp_flt( hGrid->sbWrap[t - 1] = 0; hGrid->sfbWrap[t] = 0; } - return; } diff --git a/lib_com/igf_base_fx.c b/lib_com/igf_base_fx.c index 7796c5cb97b50eda02c8182b706e473677424c67..6b7b31be7a61c8951f0d930a4b337f353c7cf99a 100644 --- a/lib_com/igf_base_fx.c +++ b/lib_com/igf_base_fx.c @@ -22,7 +22,7 @@ Word16 IGF_ApplyTransFac( /**< ou { Word16 ret; - if ( EQ_16( transFac, 0x4000 ) ) + IF( EQ_16( transFac, 0x4000 ) ) { return val; } @@ -274,7 +274,7 @@ Word16 IGF_MapBitRateToIndex( } } /* EVS mono */ - else + ELSE { SWITCH( bwidth ) { @@ -1285,6 +1285,7 @@ Word16 IGFCommonFuncsIGFConfiguration( /* interface call for reading in settings */ hIGFInfo->bitRateIndex = IGF_MapBitRateToIndex( total_brate, bwidth, element_mode, rf_mode ); + move16(); IF( NE_16( hIGFInfo->bitRateIndex, IGF_BITRATE_UNKNOWN ) ) { @@ -1308,6 +1309,7 @@ Word16 IGFCommonFuncsIGFConfiguration( move16(); hIGFInfo->maxHopsize = maxHopsize; move16(); + hIGFInfo->nfSeedBuf[0] = 0; move16(); hIGFInfo->nfSeedBuf[1] = 0; @@ -1452,7 +1454,7 @@ Word16 IGFCommonFuncsIGFGetCFTables( bitRateIndex = IGF_MapBitRateToIndex( total_brate, bwidth, element_mode, rf_mode ); - IF( bitRateIndex != IGF_BITRATE_UNKNOWN ) + IF( NE_32( bitRateIndex, IGF_BITRATE_UNKNOWN ) ) { retValue = 1; /* no error */ move16(); @@ -1533,7 +1535,7 @@ Word16 IGFCommonFuncsIGFGetCFTables( case IGF_BITRATE_FB_16400: case IGF_BITRATE_FB_24400: case IGF_BITRATE_FB_32000: - bitRateIndex = bitRateIndex - IGF_BITRATE_FB_16400 + IGF_BITRATE_SWB_16400; + bitRateIndex = add( sub( bitRateIndex, IGF_BITRATE_FB_16400 ), IGF_BITRATE_SWB_16400 ); *cf_se00 = cf_se00_tab; *cf_se01 = cf_se01_tab[bitRateIndex]; *cf_off_se01 = cf_off_se01_tab[bitRateIndex]; @@ -1555,7 +1557,7 @@ Word16 IGFCommonFuncsIGFGetCFTables( BREAK; case IGF_BITRATE_FB_48000: case IGF_BITRATE_FB_64000: - bitRateIndex = bitRateIndex - IGF_BITRATE_FB_48000 + IGF_BITRATE_SWB_48000; + bitRateIndex = add( sub( bitRateIndex, IGF_BITRATE_FB_48000 ), IGF_BITRATE_SWB_48000 ); *cf_se00 = cf_se00_tab; *cf_se01 = cf_se01_tab[bitRateIndex]; *cf_off_se01 = cf_off_se01_tab[bitRateIndex]; diff --git a/lib_com/index_pvq_opt_fx.c b/lib_com/index_pvq_opt_fx.c index 3ca87f63825890d0c13eb85534e52d95ee28d7b5..650b3b76404b4a3b566e182b442075eb3cba045c 100644 --- a/lib_com/index_pvq_opt_fx.c +++ b/lib_com/index_pvq_opt_fx.c @@ -463,7 +463,7 @@ static UWord32 nm_h_prep_opt_fx( /* o: msize for dim */ } } - if ( NE_16( add_last_odd, 0 ) ) + if ( add_last_odd != 0 ) { /* add a last odd call as needed , not to be called if k_val_in is [0,1,2] */ h_saveB = UL_addNsD( h_saveB, f_even_exact_div_opt_fx( numDsub1, h_saveA, h_saveB, sub( k_val, 1 ) ) ); @@ -820,10 +820,12 @@ PvqEntry get_size_mpvq_calc_offset_fx( /* o : size, dim, k_val IF( GT_16( dim_in, N_OPT_FX ) ) /* non-direct solutions, use A+U relation */ { entry.size = nm_h_prep_opt_fx( entry.dim, entry.k_val, h_mem ); + move32(); } ELSE { entry.size = direct_msize_fx( dim_in, entry.k_val ); + move32(); } return entry; @@ -942,6 +944,7 @@ static void vec2mind_two_fx( lead_sign_ind_add = UL_deposit_l( 2 ); /* single op */ } *ind = UL_addNsD( UL_deposit_l( (UWord16) lshl( sub( abs1, 1 ), 1 ) ), lead_sign_ind_add ); + move32(); } ELSE { @@ -1174,6 +1177,7 @@ PvqEntry mpvq_encode_vec_fx( /* o : leading_sign_index, in result.size = direct_msize_fx( dim_in, k_val_local ); } result.lead_sign_ind = u_extract_l( lead_sign_ind ); + move16(); return result; } diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth.c index 73e17fe0b29c074a30d5dd513b0bd91b12fba120..00cd8c3f2b478f469f4324fa5f615f60e5622621 100644 --- a/lib_com/ivas_cov_smooth.c +++ b/lib_com/ivas_cov_smooth.c @@ -119,12 +119,12 @@ static void ivas_calculate_smoothning_factor_fx( { IF( LT_32( ivas_total_brate, IVAS_24k4 ) ) { - smooth_fact = (Word32) ( 0.5f * ONE_IN_Q31 ); + smooth_fact = (Word32) ( ONE_IN_Q30 ); move32(); } ELSE { - smooth_fact = (Word32) ( 0.75f * ONE_IN_Q31 ); + smooth_fact = (Word32) ( 1610612735 ); move32(); } diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index c810923c119eaa98bcfb62eb14a7c9276ec545e7..4aa1dcbc6ea64a9cea302856d103c7a20c06ab7a 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -70,6 +70,7 @@ Word16 ivas_get_hodirac_flag_fx( const Word16 sba_order /* i : Ambisonic (SBA) order */ ) { + test(); IF( GT_16( sba_order, 1 ) && GT_32( ivas_total_brate, IVAS_256k ) ) { return 1; @@ -713,10 +714,12 @@ void ivas_get_dirac_sba_max_md_bits_fx( move32(); Word16 exp_res = 0; + move16(); IF( var1 % 5 != 0 ) { var4 = BASOP_Util_Add_Mant32Exp( var2_32, exp, ONE_IN_Q30, 1, &exp_res ); exp = exp_res; + move16(); } Word16 flag = BASOP_Util_Cmp_Mant32Exp( MAX16B, 31, var4, exp ); Word32 tmp; @@ -1349,6 +1352,7 @@ void computeDiffuseness_fixed( Word32 energy_slow[CLDFB_NO_CHANNELS_MAX]; Word16 i, j, k; Word32 tmp = 0; + move32(); Word32 *p_tmp; const Word32 *p_tmp_c; Word16 min_q_shift1, min_q_shift2, exp1, exp2, q_tmp; diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 419a19992574815095f87766794f9d9b4b7e5a8b..b84a8b772421828ece91537939e4a693cb332c66 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -585,7 +585,7 @@ ivas_error ivas_FB_mixer_open_fx( IF( ( NE_16( fb_cfg->active_w_mixing, -1 ) ) && ( fb_cfg->num_out_chans > 0 ) ) { Word32 *pTemp_mem_fx; - IF( ( pTemp_mem_fx = (Word32 *) malloc( sizeof( Word32 ) * fb_cfg->num_out_chans * max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ) * IVAS_MAX_NUM_BANDS ) ) == NULL ) + IF( ( pTemp_mem_fx = (Word32 *) malloc( sizeof( Word32 ) * fb_cfg->num_out_chans * s_max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ) * IVAS_MAX_NUM_BANDS ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer" ); } @@ -2778,8 +2778,6 @@ static void ivas_get_ld_fb_resp_fx( move32(); move32(); - - // assert(fabs(scratch1[s]) - fabs(fix_to_float(scratc h1_fx[s], 30)) < 0.00001); } FOR( ; s < 2 * frame_len; s++ ) diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc.c index fd2d11522a59ea1fab92bfbdecf2df2205f17af6..d16f7b320360777799a331a18a6924ef4f725712 100644 --- a/lib_com/ivas_stereo_td_bit_alloc.c +++ b/lib_com/ivas_stereo_td_bit_alloc.c @@ -1139,7 +1139,7 @@ static void tdm_SCh_LSF_intra_pred_tri_diag_mat_fx( move16(); lsf_SCh_ptr_fx++; - FOR( i = 1; i < sub( M, 1 ); i++ ) + FOR( i = 1; i < M - 1; i++ ) { lsf_tmp_ptr1_fx = lsf_tmp_ptr2_fx; // Q2.56 *lsf_SCh_ptr_fx = mult_r( *lsf_tmp_ptr1_fx++, *prd_ptr_fx++ ); // Q2.56 + 15 -15 diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 644c53db8ebd9a67f47ce2924c94141f6896341a..9cdf084bbe2cc54d51208a4023fd585b124a2bd6 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6625,24 +6625,21 @@ Word16 pit_decode_fx( /* o : floating pitch value #endif ); -Word16 pit_decode_ivas_fx( /* o : floating pitch value */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - Word16 i_subfr, /* i : subframe index */ - const Word16 coder_type, /* i : coding type */ - Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ - Word16 *T0, /* o : close loop integer pitch */ - Word16 *T0_frac, /* o : close loop fractional part of the pitch */ - Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ - Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ - const Word16 L_subfr /* i : subframe length */ -#if 1 // def ADD_LRTD - , +Word16 pit_decode_ivas_fx( /* o : floating pitch value */ + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame, /* i : length of the frame */ + Word16 i_subfr, /* i : subframe index */ + const Word16 coder_type, /* i : coding type */ + Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ + Word16 *T0, /* o : close loop integer pitch */ + Word16 *T0_frac, /* o : close loop fractional part of the pitch */ + Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ + Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ + const Word16 L_subfr, /* i : subframe length */ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -#endif ); void pit_Q_dec_fx( @@ -7872,6 +7869,7 @@ void swb_hr_noise_fill_fx( Word16 *t_audio, /* i/o: mdct spectrum */ Word16 Q_audio ); +#ifdef IVAS_FLOAT_FIXED // stat_noise_uv_dec_fx.c void stat_noise_uv_dec_fx( Decoder_State *st_fx, /* i/o: Decoder static memory */ @@ -7882,6 +7880,7 @@ void stat_noise_uv_dec_fx( , const Word16 uc_two_stage_flag /* i : flag indicating two-stage UC */ ); +#endif // stat_noise_uv_mod_fx.c void stat_noise_uv_mod_fx( diff --git a/lib_dec/TonalComponentDetection.c b/lib_dec/TonalComponentDetection.c index 12908a001493d61153fab0aaafb6a171ee2f3a64..157b0daa13f5c87ed9fca3a9d89ffe695d9684ce 100644 --- a/lib_dec/TonalComponentDetection.c +++ b/lib_dec/TonalComponentDetection.c @@ -96,49 +96,7 @@ void DetectTonalComponents_flt( } else { -#ifdef IVAS_FLOAT_FIXED - Word32 pScaledMdctSpectrum_fx[L_FRAME_MAX], scaleFactors_fx[FDNS_NPTS]; - Word16 q_pScaledMdctSpectrum_fx = 31, q_scaleFactors_fx = 31; - FOR( Word16 k = 0; k < nSamplesCore; k++ ) - { - if ( abs( (Word32) pScaledMdctSpectrum[k] ) != 0 ) - q_pScaledMdctSpectrum_fx = s_min( q_pScaledMdctSpectrum_fx, norm_l( (Word32) pScaledMdctSpectrum[k] ) ); - } - FOR( Word16 k = 0; k < FDNS_NPTS; k++ ) - { - if ( abs( (Word32) scaleFactors[k] ) != 0 ) - q_scaleFactors_fx = s_min( q_scaleFactors_fx, norm_l( (Word32) scaleFactors[k] ) ); - } - q_pScaledMdctSpectrum_fx -= 1; - q_scaleFactors_fx -= 1; - FOR( Word16 c = 0; c < nSamplesCore; c++ ) - { - pScaledMdctSpectrum_fx[c] = (Word32) ( pScaledMdctSpectrum[c] * ( 1 << q_pScaledMdctSpectrum_fx ) ); - } - FOR( Word16 c = 0; c < FDNS_NPTS; c++ ) - { - scaleFactors_fx[c] = (Word32) ( scaleFactors[c] * ( 1 << q_scaleFactors_fx ) ); - } - - sns_shape_spectrum_fx( pScaledMdctSpectrum_fx, &q_pScaledMdctSpectrum_fx, psychParamsCurrent, scaleFactors_fx, q_scaleFactors_fx, nSamplesCore ); - - IF( q_pScaledMdctSpectrum_fx + 1 < 31 ) - { - FOR( Word16 c = 0; c < nSamplesCore; c++ ) - { - pScaledMdctSpectrum[c] = ( (float) pScaledMdctSpectrum_fx[c] / ( 1 << ( q_pScaledMdctSpectrum_fx + 1 ) ) ); - } - } - ELSE IF( q_pScaledMdctSpectrum_fx + 1 == 31 ) - { - FOR( Word16 c = 0; c < nSamplesCore; c++ ) - { - pScaledMdctSpectrum[c] = ( (float) pScaledMdctSpectrum_fx[c] / ONE_IN_Q31 ); - } - } -#else sns_shape_spectrum( pScaledMdctSpectrum, psychParamsCurrent, scaleFactors, nSamplesCore ); -#endif // IVAS_FLOAT_FIXED nBands = psychParamsCurrent->nBands; } diff --git a/lib_dec/TonalComponentDetection_fx.c b/lib_dec/TonalComponentDetection_fx.c index eab15970b9be9679b0a0fbd631ddaddd4eca41a1..fc05a7cfcdad36b6bef6292a7072c6c2eecd3faa 100644 --- a/lib_dec/TonalComponentDetection_fx.c +++ b/lib_dec/TonalComponentDetection_fx.c @@ -14,7 +14,7 @@ #include "prot_fx.h" #include "ivas_prot_fx.h" - +#ifdef IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ @@ -37,7 +37,7 @@ static void findTonalComponents( Word16 *indexOfTonalPeak, Word16 *lowerIndex, W * store them in indexOfTonalPeak. Updates lowerIndex, upperIndex, * pNumIndexes accordingly. *-------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED + void ivas_DetectTonalComponents_fx( Word16 indexOfTonalPeak[], Word16 lowerIndex[], @@ -127,7 +127,6 @@ void ivas_DetectTonalComponents_fx( /* Find peaks in the second last frame */ findTonalComponents( indexOfTonalPeak, lowerIndex, upperIndex, pNumIndexes, nSamples, secondLastPowerSpectrum, F0, thresholdModification, element_mode ); } -#endif void DetectTonalComponents( Word16 indexOfTonalPeak[], @@ -450,17 +449,17 @@ static void getEnvelope( } static void GetF0( - Word16 /*int*/ const nSamples, /*i - Q0 */ - Word16 /*int*/ const nSamplesCore, /*i - Q0 */ - Word32 /*float*/ const *const powerSpectrum, + Word16 /*short*/ const nSamples, /*i - Q0 */ + Word16 /*short*/ const nSamplesCore, /*i - Q0 */ + Word32 /*int*/ const *const powerSpectrum, /*i - Qx */ /*is justed handed over and given back*/ - Word32 /*float*/ const pitchLag, /*i - Q16*/ - Word16 /*float*/ *const pOrigF0, /*o - Q10*/ - Word16 /*float*/ *const pF0 ) /*o - Q10*/ + Word32 /*int*/ const pitchLag, /*i - Q16*/ + Word16 /*short*/ *const pOrigF0, /*o - Q10*/ + Word16 /*short*/ *const pF0 ) /*o - Q10*/ { - Word16 /*float*/ tmpPitchLag; - Word16 /*int*/ rgiStrongHarmonics[MAX_PEAKS_FROM_PITCH]; - Word16 /*int*/ nTotalHarmonics, nStrongHarmonics; + Word16 /*short*/ tmpPitchLag; + Word16 /*short*/ rgiStrongHarmonics[MAX_PEAKS_FROM_PITCH]; + Word16 /*short*/ nTotalHarmonics, nStrongHarmonics; Word16 tmp; @@ -595,14 +594,14 @@ static void findStrongestHarmonics( /* Use new F0, for which harmonics are most common in pHarmonicIndexes */ static void CorrectF0( - const Word16 /*int*/ *pHarmonicIndexes, /*I - Q0 */ - const Word16 /*int*/ nHarmonics, /*I - Q0 */ - Word16 /*float*/ *pF0 ) /*I/O - Q10 range: {0}, [4..18) */ + const Word16 /*short*/ *pHarmonicIndexes, /*I - Q0 */ + const Word16 /*short*/ nHarmonics, /*I - Q0 */ + Word16 /*short*/ *pF0 ) /*I/O - Q10 range: {0}, [4..18) */ { - Word16 /*int*/ i; - Word16 /*float*/ F0; - Word16 /*int*/ diff[MAX_PEAKS_FROM_PITCH - 1], sortedDiff[MAX_PEAKS_FROM_PITCH - 1]; - Word16 /*int*/ iMostCommonDiff, nMostCommonDiff, nSameDiff, iMult; + Word16 /*short*/ i; + Word16 /*short*/ F0; + Word16 /*short*/ diff[MAX_PEAKS_FROM_PITCH - 1], sortedDiff[MAX_PEAKS_FROM_PITCH - 1]; + Word16 /*short*/ iMostCommonDiff, nMostCommonDiff, nSameDiff, iMult; Word16 tmp; @@ -749,10 +748,10 @@ static void CorrectF0( } static void modifyThreshold( - Word16 /*int*/ i, /*I - Q0 */ - Word16 /*float*/ F0, /*I - Q10*/ - Word16 /*float*/ threshold, /*I - Q10*/ - Word16 * /*float*/ thresholdModification ) /*I/O - Q10*/ + Word16 /*short*/ i, /*I - Q0 */ + Word16 /*short*/ F0, /*I - Q10*/ + Word16 /*short*/ threshold, /*I - Q10*/ + Word16 * /*short*/ thresholdModification ) /*I/O - Q10*/ { Word32 harmonic; Word16 fractional /*Q15*/; @@ -775,9 +774,9 @@ static void modifyThreshold( } static void modifyThresholds( - Word16 /*float*/ F0, /*I - Q10*/ - Word16 /*float*/ origF0, /*I - Q10*/ - Word16 * /*float*/ thresholdModification ) /*I/O - Q10*/ + Word16 /*short*/ F0, /*I - Q10*/ + Word16 /*short*/ origF0, /*I - Q10*/ + Word16 * /*short*/ thresholdModification ) /*I/O - Q10*/ { Word16 /*int*/ i, /*int*/ nHarmonics; Word16 tmp, tmpM, tmpE; @@ -1144,3 +1143,4 @@ static void findTonalComponents( move16(); return; } +#endif diff --git a/lib_dec/bass_psfilter.c b/lib_dec/bass_psfilter.c index 5572077146782ef9b9b02586907b12fdcd04a752..3b161b7822840ce7c124c3ddb724414c3108f42e 100644 --- a/lib_dec/bass_psfilter.c +++ b/lib_dec/bass_psfilter.c @@ -53,14 +53,16 @@ * Local constants *---------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED +#define K_PC_DEC -0.0357f /* <45, 17> */ +#define C_PC_DEC 1.6071f +#endif + #define NBPSF_L_EXTRA 120 #define BPF_STOP_STOPBAND_16 16 - -#define K_PC_DEC -0.0357f /* <45, 17> */ -#define C_PC_DEC 1.6071f -#define K_PC_DEC_FX -1170 /* -0.0357f in Q15 */ -#define K_PC_DEC_FX32 -76665166 /* -0.0357f in Q31 */ -#define C_PC_DEC_FX 6583 /*in Q8*/ +#define K_PC_DEC_FX -1170 /* -0.0357f in Q15 */ +#define K_PC_DEC_FX32 -76665166 /* -0.0357f in Q31 */ +#define C_PC_DEC_FX 6583 /*in Q8*/ /*---------------------------------------------------------------------* * Local function prototypes @@ -68,14 +70,12 @@ #ifndef IVAS_FLOAT_FIXED static int16_t Pit_track( const float syn[], int16_t T ); -#endif /*---------------------------------------------------------------------* * bass_psfilter_init() * * Initialisation of postfiltering variables *---------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED void bass_psfilter_init( BPF_DEC_HANDLE hBPF /* o : BPF data handle */ ) @@ -819,7 +819,6 @@ void bpf_pitch_coherence_ivas_fx( { Word16 nb_subfr; Word32 pc, pcn1, pcn2, pcn3; - Word32 scaled_inv_L_frame; // Q8 + Q23 SWITCH( st->L_frame ) @@ -880,7 +879,6 @@ void bpf_pitch_coherence_ivas_fx( { st->hBPF->psf_att_fx = 13107; move16(); /*Q15*/ - // st->hBPF->psf_att = 0.4f; set16_fx( &st->hBPF->Track_on_hist[L_TRACK_HIST - nb_subfr], 1, nb_subfr ); } } diff --git a/lib_dec/core_dec_switch_fx.c b/lib_dec/core_dec_switch_fx.c index 8e13b3bb3137eeff9f14d555d49e33156eb531c2..06e96c6a333f60631d5c94c651b44ffbb1443502 100644 --- a/lib_dec/core_dec_switch_fx.c +++ b/lib_dec/core_dec_switch_fx.c @@ -219,7 +219,7 @@ void mode_switch_decoder_LPD_fx( test(); test(); test(); - IF( ( EQ_16( bwidth, SWB ) ) && ( EQ_32( total_brate, ACELP_16k40 ) || EQ_32( total_brate, ACELP_24k40 ) ) && EQ_16( st->element_mode, EVS_MONO ) ) + IF( ( EQ_16( bwidth, SWB ) ) && ( EQ_32( total_brate, ACELP_16k40 ) || EQ_32( total_brate, ACELP_24k40 ) ) && ( st->element_mode == EVS_MONO ) ) { if ( st->tec_tfa == 0 ) { @@ -244,7 +244,7 @@ void mode_switch_decoder_LPD_fx( move16(); test(); test(); - IF( GE_16( bwidth, WB ) && EQ_32( total_brate, 24400 ) && EQ_16( st->element_mode, EVS_MONO ) ) + IF( GE_16( bwidth, WB ) && EQ_32( total_brate, 24400 ) && ( st->element_mode == EVS_MONO ) ) { st->enableGplc = 1; move16(); @@ -462,7 +462,7 @@ void mode_switch_decoder_LPD_ivas_fx( test(); test(); test(); - IF( EQ_16( bwidth, SWB ) && ( EQ_32( total_brate, ACELP_16k40 ) || EQ_32( total_brate, ACELP_24k40 ) ) && EQ_16( st->element_mode, EVS_MONO ) ) + IF( EQ_16( bwidth, SWB ) && ( EQ_32( total_brate, ACELP_16k40 ) || EQ_32( total_brate, ACELP_24k40 ) ) && ( st->element_mode == EVS_MONO ) ) { IF( EQ_16( st->tec_tfa, 0 ) && st->hTECDec != NULL ) { diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index 43431ba309c92bce579a28ec6e655b7fd55592ae..d8cf5e5a8c94ba1b00c61ca9a3b15e94e484b5d8 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -1990,6 +1990,15 @@ void ivas_bw_switching_pre_proc_fx( IF( GT_16( st->element_mode, EVS_MONO ) ) { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); IF( EQ_16( st->core, ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) && st->hBWE_FD != NULL && !( LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) && !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) ) ) { /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */ @@ -2052,6 +2061,7 @@ void ivas_bw_switching_pre_proc_fx( IF( st->hHQ_core->old_is_transient[0] ) { Word32 tmp, L_tmp = 0; + move32(); FOR( i = 0; i < 32; i++ ) { L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index 78e685e7def82d058f50c481965868f9b59be2ff..977146b346d393691a3f9797cbd2ba37d16231eb 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -701,6 +701,7 @@ static void modify_pst_param_fx( Word32 L_tmp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif @@ -784,6 +785,7 @@ static void pst_ltp_fx( Word16 nb_sh_sig; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif @@ -1677,6 +1679,7 @@ void Filt_mu_fx( Word16 fact, sh_fact; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif @@ -1730,6 +1733,7 @@ void Filt_mu_fx( /*sig_out[n] = saturate(L_temp); move16();*/ #ifdef BASOP_NOGLOB sig_out[n] = round_fx_sat( L_temp ); + move16(); #else sig_out[n] = round_fx( L_temp ); #endif @@ -1757,6 +1761,7 @@ void Filt_mu_ivas_fx( Word16 fact, sh_fact; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif IF( EQ_16( extl, SWB_TBE ) ) @@ -1969,10 +1974,15 @@ void blend_subfr2_fx( #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif + move16(); + move16(); + move16(); + move16(); FOR( i = 0; i < L_SUBFR / 2; i++ ) { #ifdef BASOP_NOGLOB sigOut[i] = mac_ro( L_mult_o( fac1, sigIn1[i], &Overflow ), fac2, sigIn2[i], &Overflow ); + move16(); fac1 = sub_o( fac1, step, &Overflow ); fac2 = add_o( fac2, step, &Overflow ); #else diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 1fac97786e366c0751b4ec664842ea28b52bdcc0..6f1e2907521554873223826dc03d8ca36478849e 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -1931,7 +1931,7 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, { st_fx->mem_pitch_gain[sub( sub( shl( st_fx->nb_subfr, 1 ), 1 ), i )] = st_fx->mem_pitch_gain[sub( sub( st_fx->nb_subfr, 1 ), i )]; move16(); - st_fx->mem_pitch_gain[sub( sub( st_fx->nb_subfr, 1 ), i )] = hTcxDec->tcxltp_last_gain_unmodified; + st_fx->mem_pitch_gain[sub( sub( st_fx->nb_subfr, 1 ), i )] = shr( hTcxDec->tcxltp_last_gain_unmodified, 1 ); /* Q14 */ move16(); } } diff --git a/lib_dec/decision_matrix_dec_fx.c b/lib_dec/decision_matrix_dec_fx.c index fc727fa3b475903fa26f4960bd371d7506ca9d69..66c7440b1b6c38e01d813477f2cde203a0cc3da6 100644 --- a/lib_dec/decision_matrix_dec_fx.c +++ b/lib_dec/decision_matrix_dec_fx.c @@ -268,6 +268,7 @@ void decision_matrix_dec_fx( { st->bwidth = extract_l( L_and( L_shr( ind, 3 ), 0x7L ) ); *sharpFlag = extract_l( L_and( L_shr( ind, 6 ), 0x1L ) ); + move16(); } } diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 1998a3f8fd22ca59bb2423b389da9eb3dddfeb9f..3ffd7811a89e0ca6f8efe2a854d908a8608a2c25 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -1641,7 +1641,7 @@ void con_tcx_ivas_fx( { random1 = Random( &tmpSeed1 ); random2 = Random( &tmpSeed1 ); - noise[i] = add( shr( random1, noise_e ), shr( mult( alpha_coh, random2 ), noise_e ) ); + noise[i] = add( shr( random1, noise_e ), shr( mult( alpha_coh, random2 ), sub( noise_e, e ) ) ); move16(); } @@ -1656,7 +1656,7 @@ void con_tcx_ivas_fx( { random1 = Random( &tmpSeed1 ); random2 = Random( &tmpSeed1 ); - noise[i] = add( shr( random1, noise_e ), shr( mult( alpha_coh, random2 ), noise_e ) ); + noise[i] = add( shr( random1, noise_e ), shr( mult( alpha_coh, random2 ), sub( noise_e, e ) ) ); move16(); } } @@ -1992,6 +1992,8 @@ void con_tcx_ivas_fx( move16(); } + Scale_sig( lsp_fade, M, 1 ); /* Q14 -> Q15 */ + E_LPC_f_lsp_a_conversion( lsp_fade, A_local, M ); } } diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index a59d884e90a7387f5352956600d13a0e86fc9ae2..167da45f6b66e7f3c9e424d4d2ad5e3029f112a3 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -31,10 +31,8 @@ ivas_error init_decoder_fx( ivas_error error; error = IVAS_ERR_OK; - + move16(); Word16 newCldfbBands; - - st_fx->total_num_bits = -1; move16(); diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index b677a089123311790ef34cf2d78341564001e771..1a6961108b7dac7c4060d06cbf5f56d26bdbc50f 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -47,10 +47,10 @@ #include "prot_fx.h" #include "ivas_rom_com_fx.h" #include "debug.h" -#define NUM_TAPS_F0_6 ( Word16 )( 58 ) // (int16_t) ceil( 0.6f * hBinRenConvModule->numTaps ) -#define NUM_TAPS_F0_5 ( Word16 )( 48 ) // (int16_t) ceil( 0.5f * hBinRenConvModule->numTaps ) -#define NUM_TAPS_F0_4 ( Word16 )( 39 ) // (int16_t) ceil( 0.4f * hBinRenConvModule->numTaps ) -#define NUM_TAPS_F0_3 ( Word16 )( 29 ) // (int16_t) ceil( 0.3f * hBinRenConvModule->numTaps ) +#define NUM_TAPS_F0_6 ( Word16 )( 58 ) // (Word16) ceil( 0.6f * hBinRenConvModule->numTaps ) +#define NUM_TAPS_F0_5 ( Word16 )( 48 ) // (Word16) ceil( 0.5f * hBinRenConvModule->numTaps ) +#define NUM_TAPS_F0_4 ( Word16 )( 39 ) // (Word16) ceil( 0.4f * hBinRenConvModule->numTaps ) +#define NUM_TAPS_F0_3 ( Word16 )( 29 ) // (Word16) ceil( 0.3f * hBinRenConvModule->numTaps ) #endif #ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------- @@ -1725,6 +1725,7 @@ static void ivas_binaural_obtain_DMX_fx( FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { P_out_fx = 0; + move32(); FOR( k = 0; k < numTimeSlots; k++ ) { temp1_fx = realDMX[chOutIdx][k][bandIdx]; @@ -1744,7 +1745,7 @@ static void ivas_binaural_obtain_DMX_fx( Word16 div = divide3232( P_in_fx[bandIdx], P_out_fx ); Word16 exp = norm_l( div ); factEQ_fx = Sqrt32( L_shl( div, Q16 ), &exp ); - factEQ_fx = L_shl( factEQ_fx, exp - 1 ); // Q30 + factEQ_fx = L_shl( factEQ_fx, sub( exp, 1 ) ); // Q30 } if ( factEQ_fx <= 0 ) { @@ -2634,8 +2635,7 @@ void ivas_binaural_add_LFE_fx( Word32 *output_fx[] /* o : synthesized core-coder transport channels/DirAC output */ ) { - Word16 render_lfe, idx_lfe; - Word16 gain_fx; + Word16 render_lfe, idx_lfe, gain_fx; IF( st_ivas->hBinRenderer != NULL ) { @@ -2787,7 +2787,6 @@ void ivas_binRenderer_fx( Word32 inIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; ivas_binaural_obtain_DMX_fx( numTimeSlots, hBinRenderer, RealBuffer_fx, ImagBuffer_fx, inRe_fx, inIm_fx ); - // inRe_fx, inIm_fx Q = *Q_in - Q1 FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { @@ -2799,7 +2798,6 @@ void ivas_binRenderer_fx( } ivas_binaural_reverb_processSubframe_fx( hBinRenderer->hReverb, BINAURAL_CHANNELS, numTimeSlots, inRe_fx, inIm_fx, reverbRe_fx, reverbIm_fx ); - // reverbRe_fx, reverbIm_fx Q = *Q_in - 1 // FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { diff --git a/lib_dec/ivas_entropy_decoder.c b/lib_dec/ivas_entropy_decoder.c index b2c140e651c0407d5d46610dbcaa86a1398b9907..a3530dd402eadb8376f6efc3d3f250577897090c 100644 --- a/lib_dec/ivas_entropy_decoder.c +++ b/lib_dec/ivas_entropy_decoder.c @@ -315,6 +315,8 @@ void ivas_arith_decode_cmplx_cell_array( Word16 *pSymbol_re_old ) { Word16 i, j, len, all_diff = 1, any_diff = 0; + move16(); + move16(); Word16 cell_arr_diff[IVAS_MAX_INPUT_LEN]; Word16 cell_arr_no_diff[IVAS_MAX_INPUT_LEN]; Word16 cell_arr_diff_out[IVAS_MAX_INPUT_LEN]; diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index b4400be0916daedf9eca66aa0c694c2565bc7d90..39ff9d1bd2b916ce7f8c23101e4b82518159977a 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -2138,7 +2138,6 @@ void ivas_mdct_core_reconstruct_fx( } ELSE { - Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, norm_s( sub( st->hFdCngDec->hFdCngCom->A_cng[0], 1 ) ) ); IF( sts[1]->core != ACELP_CORE ) { con_tcx_ivas_fx( st, &synthFB_fx[0], hCPE->hStereoMdct->lastCoh_fx, &sts[0]->seed_acelp, 1, &st->hFdCngDec->hFdCngCom->A_cng[0] ); @@ -2152,11 +2151,11 @@ void ivas_mdct_core_reconstruct_fx( Scale_sig( synthFB_fx, st->hTcxDec->L_frameTCX, q_syn ); IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || ( st->hTcxDec->tcxConceal_recalc_exc != 0 ) ) { - Scale_sig( synthFB_fx - add( add( shr( st->hTcxDec->L_frameTCX, 1 ), st->hTcxDec->pit_max_TCX ), 2 * M ), sub( q_syn, sub( st->Q_exc, 1 ) ), add( add( shr( st->hTcxDec->L_frameTCX, 1 ), st->hTcxDec->pit_max_TCX ), 2 * M ) ); + Scale_sig( synthFB_fx - add( add( shr( st->hTcxDec->L_frameTCX, 1 ), st->hTcxDec->pit_max_TCX ), 2 * M ), add( add( shr( st->hTcxDec->L_frameTCX, 1 ), st->hTcxDec->pit_max_TCX ), 2 * M ), sub( q_syn, sub( st->Q_exc, 1 ) ) ); } ELSE { - Scale_sig( synthFB_fx - st->hTcxDec->L_frameTCX, sub( q_syn, sub( st->Q_exc, 1 ) ), st->hTcxDec->L_frameTCX ); + Scale_sig( synthFB_fx - st->hTcxDec->L_frameTCX, st->hTcxDec->L_frameTCX, sub( q_syn, sub( st->Q_exc, 1 ) ) ); } lerp( synthFB_fx, synth_fx, st->L_frame, st->hTcxDec->L_frameTCX ); diff --git a/lib_dec/ivas_sns_dec_fx.c b/lib_dec/ivas_sns_dec_fx.c index aa6906fb5761e50a59caae96352375ec788e1399..d33eb08b7abf3fc441e6aee4c8484567e417ecc4 100644 --- a/lib_dec/ivas_sns_dec_fx.c +++ b/lib_dec/ivas_sns_dec_fx.c @@ -400,7 +400,7 @@ void dequantize_sns_fx( } FOR( k = 0; k < nSubframes; ++k ) { - IF( sns_stereo_mode[k] == SNS_STEREO_MODE_MS ) + IF( EQ_16( sns_stereo_mode[k], SNS_STEREO_MODE_MS ) ) { inverseMS_fx( M, snsQ_out_fx[0][k], snsQ_out_fx[1][k], ONE_IN_Q31 ); } diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index 25caf19eb06446d46715570a2ea17051cce5e082..4e65044dabe4661b4b7f2fac2df736b199dc4bb4 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -1522,10 +1522,6 @@ void stereo_dft_dec( dmx_nrg = stereo_dft_dmx_swb_nrg( DFT[0], DFT[0] + STEREO_DFT32MS_N_MAX, min( hStereoDft->NFFT, STEREO_DFT32MS_N_32k ) ); } - -#ifdef DEBUG_PRINT - printf( "\nframe: %d\n", frame ); -#endif for ( k = 0; k < N_div; k++ ) { pDFT_DMX = DFT[0] + k * STEREO_DFT32MS_N_MAX; @@ -1548,23 +1544,6 @@ void stereo_dft_dec( pgIpd = hStereoDft->gipd + ( k + k_offset ); pPredGain = hStereoDft->res_pred_gain + ( k + k_offset ) * STEREO_DFT_BAND_MAX; -#ifdef DEBUG_PRINT - if ( k == 0 ) - { - printf( "Window0\n" ); - } - else - { - printf( "Window1\n" ); - } - for ( b = 0; b < hStereoDft->nbands; b++ ) - printf( "%.6f ", pSideGain[b] ); - printf( "\n" ); - for ( b = 0; b < hStereoDft->nbands; b++ ) - printf( "%.6f ", pPredGain[b] ); - printf( "\n" ); -#endif - /* Use coarse band partition in inactive frames */ if ( hStereoDft->frame_sid_nodata && !sba_dirac_stereo_flag ) { diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 0646ac8f9d1a6b1114312c68997624baba9144b1..a7bcb6285958acfc52dc71044ccf75c510ad0e01 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -90,7 +90,6 @@ static void stereo_dft_compute_td_stefi_params_fx( STEREO_DFT_DEC_DATA_HANDLE hS static void stereo_dft_adapt_sf_delay_fx( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, Word32 *pPredGain ); -#ifdef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------- * stereo_dft_dec_reset_fx() * @@ -508,9 +507,9 @@ static void stereo_dft_dequantize_res_gains_f_fx( FOR( i = 0; i < N; i++ ) { /* Ensure the indices are within range -- may go out of range due to frame loss */ - ind1[i] = check_bounds_l( ind1[i], 0, L_shl( 31, Q26 ) ); + ind1[i] = check_bounds_l( ind1[i], 0, 31 << Q26 ); move32(); - ind2[i] = check_bounds_l( ind2[i], 0, L_shl( 7, Q26 ) ); + ind2[i] = check_bounds_l( ind2[i], 0, 7 << Q26 ); move32(); /* compensate for the offset and extract/remove sign of first index */ @@ -548,7 +547,6 @@ static void stereo_dft_dequantize_res_gains_f_fx( fj = L_sub( ind2[i], L_shl( j1, Q26 ) ); /* choose base indices for interpolation */ - // ji = extract_l( L_min( fj < ONE_IN_Q25 ? j1 : j1 + 1, 7 ) ); IF( LT_32( fj, ONE_IN_Q25 ) ) { ji = extract_l( L_min( j1, 7 ) ); @@ -558,7 +556,6 @@ static void stereo_dft_dequantize_res_gains_f_fx( ji = extract_l( L_min( add( j1, 1 ), 7 ) ); } - // ij = extract_l( L_min( fi < ONE_IN_Q25 ? i1 : i1 + 1, 15 ) ); IF( LT_32( fi, ONE_IN_Q25 ) ) { ij = extract_l( L_min( i1, 15 ) ); @@ -759,17 +756,18 @@ void stereo_dft_dec_synthesize_fx( test(); test(); test(); - if ( ( EQ_16( chan, 0 ) && GT_16( hCPE->hCoreCoder[0]->last_coder_type, UNVOICED ) ) || EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) || LT_16( hCPE->last_element_mode, IVAS_CPE_DFT ) ) + if ( ( chan == 0 && GT_16( hCPE->hCoreCoder[0]->last_coder_type, UNVOICED ) ) || EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) || LT_16( hCPE->last_element_mode, IVAS_CPE_DFT ) ) { hCPE->stereo_switching_counter = 10; move16(); } - IF( EQ_16( hCPE->stereo_switching_counter, 0 ) ) + IF( hCPE->stereo_switching_counter == 0 ) { /* Set the level of dispersion */ Word16 tmp = extract_l( L_max( (Word16) 0xF333, L_min( (Word16) 0x3333, hCPE->lt_es_em_fx ) ) ); hCPE->NbFrameMod = extract_h( L_add( L_mult0( 12, tmp ), 0x0000D99A ) ); /* -0.1: -0.4 ; -0.1 -> 0, 0.4 -> 6*/ + move16(); } moffset = s_max( 0, sub( 6, hCPE->NbFrameMod ) ); @@ -874,6 +872,7 @@ void stereo_dft_dec_synthesize_fx( } hCPE->lt_es_em_fx = L_shl( hCPE->lt_es_em_fx, 9 ); // Q15 -> Q24 + move32(); pop_wmops(); return; @@ -930,6 +929,8 @@ void stereo_dft_dec_smooth_parameters_fx( hStereoDft->ipd_xfade_target_fx = L_sub( hStereoDft->gipd_fx[add( k, k_offset )], EVS_PI_FX_Q27 ); move32(); hStereoDft->ipd_xfade_step_fx = BASOP_Util_Divide3232_Scale( L_sub( hStereoDft->ipd_xfade_target_fx, hStereoDft->ipd_xfade_prev_fx ), L_shl( L_sub( STEREO_DFT_ITD_CNG_XFADE, hStereoDft->ipd_xfade_counter ), Q24 ), &q_val ); + move32(); + q_val = add( q_val, Q9 ); /* Q27 - (Q15 - q_val + (-3))*/ move32(); IF( GT_16( q_val, 32 ) ) @@ -939,6 +940,7 @@ void stereo_dft_dec_smooth_parameters_fx( ELSE { hStereoDft->ipd_xfade_step_fx = L_shl( hStereoDft->ipd_xfade_step_fx, q_val ); + move32(); } } ELSE IF( GT_32( L_sub( hStereoDft->ipd_xfade_prev_fx, hStereoDft->gipd_fx[add( k, k_offset )] ), EVS_PI_FX_Q27 ) ) @@ -955,6 +957,7 @@ void stereo_dft_dec_smooth_parameters_fx( ELSE { hStereoDft->ipd_xfade_step_fx = L_shl( hStereoDft->ipd_xfade_step_fx, q_val ); + move32(); } } ELSE @@ -971,6 +974,7 @@ void stereo_dft_dec_smooth_parameters_fx( ELSE { hStereoDft->ipd_xfade_step_fx = L_shl( hStereoDft->ipd_xfade_step_fx, q_val ); + move32(); } } } @@ -985,6 +989,7 @@ void stereo_dft_dec_smooth_parameters_fx( hStereoDft->ipd_xfade_prev_fx = hStereoDft->gipd_fx[add( k, k_offset )]; move32(); hStereoDft->ipd_xfade_counter = add( hStereoDft->ipd_xfade_counter, 1 ); + move16(); } } ELSE @@ -1027,6 +1032,7 @@ void stereo_dft_dec_smooth_parameters_fx( ELSE { hStereoDft->itd_xfade_step_fx = L_shl( hStereoDft->itd_xfade_step_fx, q_val ); + move32(); } move32(); } @@ -1038,7 +1044,7 @@ void stereo_dft_dec_smooth_parameters_fx( move32(); hStereoDft->itd_xfade_prev_fx = hStereoDft->itd_fx[add( k, k_offset )]; move32(); - hStereoDft->itd_xfade_counter++; + hStereoDft->itd_xfade_counter = add( hStereoDft->itd_xfade_counter, 1 ); } } ELSE @@ -1490,6 +1496,7 @@ void stereo_dft_dec_fx( Word16 *cna_seed = &( hFdCngCom->seed ); Word32 DFT_W, DFT_Y; Word16 q_samp_ratio = Q15; + move16(); output_frame = (Word16) Mpy_32_32( L_add( st0->output_Fs, FRAMES_PER_SEC_BY_2 ), ONE_BY_FRAMES_PER_SEC_Q31 ); @@ -1551,15 +1558,13 @@ void stereo_dft_dec_fx( dmx_nrg = stereo_dft_dmx_swb_nrg_fx( DFT[0], DFT[0] + STEREO_DFT32MS_N_MAX, s_min( hStereoDft->NFFT, STEREO_DFT32MS_N_32k ), 0, 0 ); } - -#ifdef DEBUG_PRINT - printf( "\nframe: %d\n", frame ); -#endif FOR( k = 0; k < N_div; k++ ) { pDFT_DMX = DFT[0] + i_mult( k, STEREO_DFT32MS_N_MAX ); pDFT_RES = DFT[1] + i_mult( k, STEREO_DFT32MS_N_MAX ); pDFT_DMX1 = 0; + move16(); + IF( GT_16( nchan_transport, 1 ) ) { pDFT_DMX1 = DFT[1] + i_mult( k, STEREO_DFT32MS_N_MAX ); @@ -1580,23 +1585,6 @@ void stereo_dft_dec_fx( pgIpd = hStereoDft->gipd_fx + add( k, k_offset ); pPredGain = hStereoDft->res_pred_gain_fx + i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ); -#ifdef DEBUG_PRINT - if ( k == 0 ) - { - printf( "Window0\n" ); - } - else - { - printf( "Window1\n" ); - } - for ( b = 0; b < hStereoDft->nbands; b++ ) - printf( "%.6f ", pSideGain[b] ); - printf( "\n" ); - for ( b = 0; b < hStereoDft->nbands; b++ ) - printf( "%.6f ", pPredGain[b] ); - printf( "\n" ); -#endif - /* Use coarse band partition in inactive frames */ test(); IF( hStereoDft->frame_sid_nodata && !sba_dirac_stereo_flag ) @@ -1749,7 +1737,7 @@ void stereo_dft_dec_fx( move32(); } - IF( NE_32( pgIpd[0], 0 ) ) + IF( pgIpd[0] != 0 ) { Word32 theta = pgIpd[0]; WHILE( GT_32( theta, EVS_2PI_FX_Q27 ) ) @@ -1797,7 +1785,7 @@ void stereo_dft_dec_fx( { IF( sba_mono_flag ) { - IF( EQ_16( b, 0 ) ) + IF( b == 0 ) { i = 0; move16(); @@ -1814,7 +1802,7 @@ void stereo_dft_dec_fx( DFT_R[add( shl( i, 1 ), 1 )] = 0; move32(); } - FOR( i = hStereoDft->band_limits[b]; i < min( stop, hStereoDft->band_limits[b + 1] ); i++ ) + FOR( i = hStereoDft->band_limits[b]; i < s_min( stop, hStereoDft->band_limits[b + 1] ); i++ ) { DFT_W = Madd_32_32( Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[2 * i] ), L_add( hStereoDft->mixer_mat_smooth_fx[0][1][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], @@ -1853,7 +1841,7 @@ void stereo_dft_dec_fx( } ELSE { - IF( EQ_16( b, 0 ) ) + IF( b == 0 ) { i = 0; move16(); @@ -1929,7 +1917,7 @@ void stereo_dft_dec_fx( } ELSE IF( GE_16( nchan_transport, 2 ) ) { - IF( EQ_16( b, 0 ) ) + IF( b == 0 ) { i = 0; move32(); @@ -1980,7 +1968,7 @@ void stereo_dft_dec_fx( } ELSE { - FOR( i = hStereoDft->band_limits[b]; i < min( stop, hStereoDft->band_limits[b + 1] ); i++ ) + FOR( i = hStereoDft->band_limits[b]; i < s_min( stop, hStereoDft->band_limits[b + 1] ); i++ ) { tmp = L_add( Madd_32_16( pDFT_RES[2 * i], pDFT_DMX[2 * i], g ), DFT_PRED_RES[2 * i] ); @@ -2129,20 +2117,21 @@ void stereo_dft_dec_fx( scale_fact0 = 0; move16(); - IF( GT_16( hFdCngDec->cna_rescale_fact_fx, 0 ) ) + IF( hFdCngDec->cna_rescale_fact_fx > 0 ) { Word16 q_scale_fact0 = 0; move16(); Word16 op = Sqrt16( shr( hFdCngDec->cna_rescale_fact_fx, 1 ), &q_scale_fact0 ); move16(); scale_fact0 = L_mult0( shr( output_frame, 1 ), op ); - IF( GT_16( q_scale_fact0, 0 ) ) + IF( q_scale_fact0 > 0 ) { assert( 0 ); } ELSE { scale_fact0 = L_shl( scale_fact0, q_scale_fact0 ); + move32(); } } @@ -2251,6 +2240,8 @@ void stereo_dft_dec_fx( /* update CNA re-scaling factor */ hFdCngDec->cna_rescale_fact_fx = extract_l( L_shr( L_mult0( (Word16) 0x6666, hFdCngDec->cna_act_fact_fx ), Q15 ) ); + move16(); + IF( !hFdCngDec->first_cna_noise_updated ) { hFdCngDec->cna_rescale_fact_fx = 0; @@ -2354,7 +2345,7 @@ static void stereo_dft_compute_td_stefi_params_fx( shift_g = sub( Q15, norm_s( sub( hStereoDft->nbands, band0 ) ) ); FOR( b = band0; b < hStereoDft->nbands; b++ ) { - IF( LT_32( L_min( hStereoDft->past_res_pred_gain_fx[STEFI_DELAY_IND( STEREO_DFT_TD_STEFI_SUBFR_DELAY + 1, pdmx_ind )][b], hStereoDft->past_res_pred_gain_fx[STEFI_DELAY_IND( STEREO_DFT_TD_STEFI_SUBFR_DELAY + 2, pdmx_ind )][b] ), 0 ) ) + IF( L_min( hStereoDft->past_res_pred_gain_fx[STEFI_DELAY_IND( STEREO_DFT_TD_STEFI_SUBFR_DELAY + 1, pdmx_ind )][b], hStereoDft->past_res_pred_gain_fx[STEFI_DELAY_IND( STEREO_DFT_TD_STEFI_SUBFR_DELAY + 2, pdmx_ind )][b] ) < 0 ) { hStereoDft->td_gain_fx[0] = 0; move32(); @@ -2378,7 +2369,7 @@ static void stereo_dft_compute_td_stefi_params_fx( #endif } - IF( EQ_16( nbands, 0 ) ) + IF( nbands == 0 ) { /* apparently, there is nothing to do here */ hStereoDft->td_gain_fx[0] = 0; @@ -2393,6 +2384,7 @@ static void stereo_dft_compute_td_stefi_params_fx( { pred_g = L_shl( pred_g, q_div ); } + pred_gain_avg = BASOP_Util_Divide3232_Scale( pred_gain_avg, wsum, &q_div ); IF( GT_16( sub( 15, q_div ), 15 ) ) { @@ -2455,8 +2447,6 @@ static void stereo_dft_compute_td_stefi_params_fx( return; } - -#ifdef IVAS_FLOAT_FIXED static void stereo_dft_dequantize_ipd_fx( Word16 *ind, Word32 *out_fx, @@ -2496,7 +2486,7 @@ static void stereo_dft_dequantize_ipd_fx( } return; } -#endif // IVAS_FLOAT_FIXED + /*------------------------------------------------------------------------- * stereo_dft_generate_res_pred_fx() * @@ -2617,6 +2607,8 @@ void stereo_dft_generate_res_pred_fx( { hStereoDft->smooth_res_nrg_fx[b] = L_shr( hStereoDft->smooth_res_nrg_fx[b], shl( sub( hStereoDft->q_smoothed_nrg, hStereoDft->q_dft ), 1 ) ); hStereoDft->smooth_dmx_nrg_fx[b] = L_shr( hStereoDft->smooth_dmx_nrg_fx[b], shl( sub( hStereoDft->q_smoothed_nrg, hStereoDft->q_dft ), 1 ) ); + move32(); + move32(); } /* smoothing */ hStereoDft->smooth_res_nrg_fx[b] = Madd_32_16( Mpy_32_16_1( hStereoDft->smooth_res_nrg_fx[b], alpha ), rev_nrg, sub( (Word16) ( 0x7FFF ), alpha ) ); @@ -2625,7 +2617,7 @@ void stereo_dft_generate_res_pred_fx( move32(); /* normalization factor */ - IF( NE_32( hStereoDft->smooth_res_nrg_fx[b], 0 ) ) + IF( hStereoDft->smooth_res_nrg_fx[b] != 0 ) { norm_fac = BASOP_Util_Divide3232_Scale( hStereoDft->smooth_dmx_nrg_fx[b], hStereoDft->smooth_res_nrg_fx[b], &q_norm_fac ); norm_fac = Sqrt16( norm_fac, &q_norm_fac ); @@ -2788,7 +2780,7 @@ void stereo_dft_generate_res_pred_fx( move32(); dmx_nrg = EPSILON_FIX; move32(); - FOR( i = hStereoDft->band_limits[b]; i < min( bin0, hStereoDft->band_limits[b + 1] ); i++ ) + FOR( i = hStereoDft->band_limits[b]; i < s_min( bin0, hStereoDft->band_limits[b + 1] ); i++ ) { dmx_nrg = Madd_32_32( Madd_32_32( dmx_nrg, pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[add( shl( i, 1 ), 1 )], pDFT_DMX[add( shl( i, 1 ), 1 )] ); @@ -2798,6 +2790,7 @@ void stereo_dft_generate_res_pred_fx( move32(); past_dmx_nrg = Madd_32_32( Madd_32_32( past_dmx_nrg, DFT_PRED_RES[2 * i], DFT_PRED_RES[2 * i] ), DFT_PRED_RES[add( shl( i, 1 ), 1 )], DFT_PRED_RES[add( shl( i, 1 ), 1 )] ); } + test(); IF( !bfi || GE_16( b, hStereoDft->res_cod_band_max ) ) { Word16 q_div; @@ -2813,9 +2806,9 @@ void stereo_dft_generate_res_pred_fx( pred_gain_avg = Madd_32_16( Mpy_32_16_1( hStereoDft->past_res_pred_gain_fx[d_short_ind][b], g_short ), hStereoDft->past_res_pred_gain_fx[d_long_ind][b], g_long ); - g2 = min( Mpy_32_16_1( pred_gain_avg, STEREO_DFT_STEFFI_GAIN_AMP_FX ), - Madd_32_16( Mpy_32_16_1( pred_gain_avg, sub( MAX_16, STEREO_DFT_STEFFI_GAIN_REST_AMT_FX ) ), - g2, STEREO_DFT_STEFFI_GAIN_REST_AMT_FX ) ); + g2 = s_min( Mpy_32_16_1( pred_gain_avg, STEREO_DFT_STEFFI_GAIN_AMP_FX ), + Madd_32_16( Mpy_32_16_1( pred_gain_avg, sub( MAX_16, STEREO_DFT_STEFFI_GAIN_REST_AMT_FX ) ), + g2, STEREO_DFT_STEFFI_GAIN_REST_AMT_FX ) ); q_sqrt = 0; move16(); } @@ -3017,6 +3010,7 @@ void stereo_dft_generate_res_pred_fx( } /* Avoid transient components */ + test(); IF( EQ_32( hStereoDft->past_res_pred_gain_fx[d_short_ind][b], MIN_32 ) && EQ_32( hStereoDft->past_res_pred_gain_fx[d_long_ind][b], MIN_32 ) ) { @@ -3050,7 +3044,7 @@ void stereo_dft_generate_res_pred_fx( move16(); } - IF( GT_16( s_max( g_short, g_long ), 0 ) ) + IF( s_max( g_short, g_long ) > 0 ) { Word16 q_div; Word32 op1; @@ -3190,7 +3184,7 @@ static void stereo_dft_adapt_sf_delay_fx( var_mean_ratio = STEREO_DFT_RES_RATIO_LIMIT_FX; move16(); - IF( GT_32( hStereoDft->lt_pred_gain_fx, 0 ) ) + IF( hStereoDft->lt_pred_gain_fx > 0 ) { Word32 opr2 = L_deposit_h( BASOP_Util_Divide3232_Scale( hStereoDft->lt_pred_gain_variation_fx, hStereoDft->lt_pred_gain_fx, &q_div ) ); IF( q_div < 0 ) @@ -3230,10 +3224,12 @@ static void stereo_dft_adapt_sf_delay_fx( IF( GT_16( extract_h( var_mean_ratio ), extract_h( hStereoDft->lt_var_mean_ratio_fx ) ) ) { hStereoDft->lt_var_mean_ratio_fx = Madd_32_32( Mpy_32_32( var_mean_ratio, alpha_up ), hStereoDft->lt_var_mean_ratio_fx, L_sub( MAX_32, alpha_up ) ); + move32(); } ELSE { hStereoDft->lt_var_mean_ratio_fx = Madd_32_32( Mpy_32_32( var_mean_ratio, alpha_down ), hStereoDft->lt_var_mean_ratio_fx, L_sub( MAX_32, alpha_down ) ); + move32(); } /* Calculate a target delay for the stereo filling. Set the stereo filling delay lower when the prediction gain @@ -3255,7 +3251,7 @@ static void stereo_dft_adapt_sf_delay_fx( hStereoDft->stefi_short_gain_fx = extract_l( L_shr( L_sub( L_shl( STEREO_DFT_STEFFI_DELAY_LONG, Q15 ), target_delay ), 1 ) ); q_sqrt = 0; move16(); - IF( hStereoDft->stefi_short_gain_fx == MIN_16 ) + IF( EQ_16( hStereoDft->stefi_short_gain_fx, MIN_16 ) ) { hStereoDft->stefi_short_gain_fx = MAX_16; move16(); @@ -3355,6 +3351,8 @@ void stereo_dft_dec_sid_coh_fx( bits_tmp = read_GR0( &st->bit_stream[st->next_bit_pos], &res_index, 1 ); *nb_bits = add( *nb_bits, bits_tmp ); st->next_bit_pos = add( st->next_bit_pos, bits_tmp ); + move16(); + move16(); } ELSE { @@ -3410,6 +3408,7 @@ void stereo_dft_dequantize_itd_fx( /*Convert back @ fs*/ *out_fx = L_mult( itd, divide3232( output_Fs, STEREO_DFT_ITD_FS << 1 ) ); /*Q-15*/ + move32(); return; } /*------------------------------------------------------------------------- @@ -3551,6 +3550,8 @@ void stereo_dft_dec_read_BS_fx( { hStereoDft->attackPresent = get_next_indice_fx( st, 1 ); ( *nb_bits ) = add( ( *nb_bits ), 1 ); + move16(); + move16(); } /* read res_cod_mode from bitstream */ @@ -3560,6 +3561,7 @@ void stereo_dft_dec_read_BS_fx( hStereoDft->res_cod_mode[k_offset] = get_next_indice_fx( st, 1 ); move16(); ( *nb_bits ) = add( ( *nb_bits ), 1 ); + move16(); } /* read number of bands in the bitstream - depends on the audio bandwidth and not to output_Fs */ @@ -3579,7 +3581,7 @@ void stereo_dft_dec_read_BS_fx( hStereoDft->res_cod_mode[k_offset] = STEREO_DFT_RES_COD_OFF; move16(); move16(); - hStereoDft->nbands = stereo_dft_band_config_fx( hStereoDft->band_limits, hStereoDft->band_res[k_offset], min( STEREO_DFT32MS_N_MAX, NFFT_inner ), DEC ); + hStereoDft->nbands = stereo_dft_band_config_fx( hStereoDft->band_limits, hStereoDft->band_res[k_offset], s_min( STEREO_DFT32MS_N_MAX, NFFT_inner ), DEC ); IF( hStereoDft->nbands > STEREO_DFT_COH_MAXBAND ) { @@ -3680,6 +3682,8 @@ void stereo_dft_dec_read_BS_fx( st->next_bit_pos = add( st->next_bit_pos, n_bits ); ( *nb_bits ) = add( ( *nb_bits ), n_bits ); + move16(); + move16(); } /*------------------------------------------------------------------* @@ -3690,12 +3694,13 @@ void stereo_dft_dec_read_BS_fx( { itd_mode = get_next_indice_fx( st, STEREO_DFT_ITD_MODE_NBITS ); ( *nb_bits ) = add( ( *nb_bits ), STEREO_DFT_ITD_MODE_NBITS ); /*ITD mode flag: 1bit*/ - + move16(); hStereoDft->itd_fx[k + k_offset] = 0; move32(); IF( itd_mode ) { ( *nb_bits ) = add( ( *nb_bits ), read_itd( st, &I ) ); + move16(); stereo_dft_dequantize_itd_fx( &I, hStereoDft->itd_fx + add( k, k_offset ), st->output_Fs ); } } @@ -3703,6 +3708,7 @@ void stereo_dft_dec_read_BS_fx( { itd_mode = get_next_indice_fx( st, STEREO_DFT_ITD_MODE_NBITS ); ( *nb_bits ) = add( ( *nb_bits ), STEREO_DFT_ITD_MODE_NBITS ); /*ITD mode flag: 1bit*/ + move16(); hStereoDft->itd_fx[add( k, k_offset )] = 0; move32(); @@ -3711,6 +3717,7 @@ void stereo_dft_dec_read_BS_fx( sign_flag = get_next_indice_fx( st, 1 ); I = get_next_indice_fx( st, STEREO_DFT_SID_ITD_NBITS ); ( *nb_bits ) = add( ( *nb_bits ), STEREO_DFT_SID_ITD_NBITS + 1 ); + move16(); I = shl( I, STEREO_DFT_SID_ITD_FAC ); I = add( I, shl( sign_flag, 8 ) ); stereo_dft_dequantize_itd_fx( &I, hStereoDft->itd_fx + add( k, k_offset ), st->output_Fs ); @@ -3766,6 +3773,8 @@ void stereo_dft_dec_read_BS_fx( st->next_bit_pos = add( st->next_bit_pos, n_bits ); ( *nb_bits ) = add( ( *nb_bits ), n_bits ); + move16(); + move16(); /*------------------------------------------------------------------* * read Residual parameters @@ -3795,6 +3804,8 @@ void stereo_dft_dec_read_BS_fx( { hStereoDft->reverb_flag = get_next_indice_fx( st, STEREO_DFT_REVERB_MODE_NBITS ); ( *nb_bits ) = add( ( *nb_bits ), STEREO_DFT_REVERB_MODE_NBITS ); + move16(); + move16(); nb = add( nb, STEREO_DFT_REVERB_MODE_NBITS ); IF( hStereoDft->reverb_flag ) { @@ -3887,6 +3898,8 @@ void stereo_dft_dec_read_BS_fx( st->next_bit_pos = add( st->next_bit_pos, n_bits ); ( *nb_bits ) = add( ( *nb_bits ), n_bits ); + move16(); + move16(); } ELSE { @@ -3931,13 +3944,15 @@ void stereo_dft_dec_read_BS_fx( *----------------------------------------------------------------*/ /* Residual coding not used in inactive frames */ + test(); IF( hStereoDft->res_cod_band_max > 0 && !hStereoDft->frame_sid_nodata ) { Word16 dec[STEREO_DFT_N_MAX_RES]; I = get_next_indice_fx( st, STEREO_DFT_RES_GLOBAL_GAIN_BITS ); ( *nb_bits ) = add( ( *nb_bits ), STEREO_DFT_RES_GLOBAL_GAIN_BITS ); - + move16(); + move16(); push_wmops( "residual_decode" ); IF( I != ECSQ_GLOBAL_GAIN_INDEX_ALL_ZERO ) @@ -3947,11 +3962,13 @@ void stereo_dft_dec_read_BS_fx( rc_uni_dec_init_fx( &range_uni_dec_state, bit_stream_side + *nb_bits, max_bits - *nb_bits ); hStereoDft->res_global_gain_fx = ECSQ_dequantize_gain_fx( I ); + move32(); #ifdef DEBUGGING dbgwrite_txt( (const float *) ( &hStereoDft->res_global_gain_fx ), 1, "fixed_res_global_gain.txt", NULL ); #endif ecsq_inst.config_index = sub( shl( hStereoDft->res_cod_mode[k_offset], 1 ), 1 ); + move16(); ECSQ_decode( &ecsq_inst, hStereoDft->res_cod_line_max, dec ); @@ -3996,12 +4013,13 @@ void stereo_dft_dec_read_BS_fx( IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_16( ivas_format, MASA_FORMAT ) ) { *nb_bits = (Word16) Mult_32_16( L_sub( element_brate, SID_2k40 ), INV_FRAME_PER_SEC_Q15 ); /* => hCPE->hCoreCoder[0]->total_brate = SID_2k40; */ + move16(); } { *total_brate = L_sub( element_brate, L_mult0( *nb_bits, FRAMES_PER_SEC ) ); + move32(); } return; } -#endif #endif // IVAS_FLOAT_FIXED diff --git a/lib_dec/ivas_stereo_dft_plc_fx.c b/lib_dec/ivas_stereo_dft_plc_fx.c index e0cd69ef6f5d22cc03908bec7b40616ea8130326..d46c25879334a2e75b976875a27b99a722b31c6a 100644 --- a/lib_dec/ivas_stereo_dft_plc_fx.c +++ b/lib_dec/ivas_stereo_dft_plc_fx.c @@ -163,6 +163,7 @@ void stereo_dft_res_ecu_fx( /*in case of burst error*/ hStereoDft->time_offs = add( hStereoDft->time_offs, L_FRAME8k ); + move16(); } set32_fx( DFT_PRED_RES, 0, shl( L_res, 1 ) ); @@ -207,7 +208,7 @@ Word32 imax_pos_fx( } y2i = Mpy_32_16_1( Mpy_32_16_1( y3_y1, BASOP_Util_Divide3232_Scale( y3_y1, ftmp_den1, &q_div_2i ) ), (Word16) ( 0xF000 ) ); - IF( LT_16( q_div_2i, 0 ) ) + IF( q_div_2i < 0 ) { y2i = L_shl( y2i, q_div_2i ); q_div_2i = 0; @@ -595,7 +596,7 @@ void stereo_dft_res_subst_spec_fx( /* Refine peaks */ FOR( i = 0; i < *num_plocs; i++ ) { - IF( EQ_16( plocs[i], 0 ) ) + IF( plocs[i] == 0 ) { plocsi[i] = L_add( L_deposit_h( plocs[i] ), L_shl( imax_pos_fx( &abs_res[plocs[i]] ), Q1 ) ); move32(); @@ -649,7 +650,7 @@ void stereo_dft_res_subst_spec_fx( FOR( i = *num_plocs - 1; i >= 0; i-- ) { Flag flg_ov; - IF( EQ_16( k, 0 ) ) + IF( k == 0 ) { Word32 op; Word16 q_div, q_shift; @@ -828,6 +829,7 @@ Word16 stereo_dft_sg_recovery_fx( ELSE { hStereoDft->sg_mean_fx = Madd_32_16( Mpy_32_16_1( sg_m, beta ), hStereoDft->sg_mean_fx, sub( MAX_16, beta ) ); /* LP filter delta_sg to obtain side gain stability measure */ + move32(); } } ELSE IF( GT_32( hStereoDft->sg_mean_fx, (Word32) 0x4CCCCCCD ) || LT_32( hStereoDft->sg_mean_fx, (Word32) ( 0xB3333333 ) ) ) diff --git a/lib_dec/ivas_stereo_eclvq_dec.c b/lib_dec/ivas_stereo_eclvq_dec.c index eb43309924b8253cf4f2d17a98254b3b7429797a..82ca7123fa81465aa630ffc364634e248f2472eb 100644 --- a/lib_dec/ivas_stereo_eclvq_dec.c +++ b/lib_dec/ivas_stereo_eclvq_dec.c @@ -306,7 +306,7 @@ void ECSQ_decode( param_zb = rc_uni_dec_read_symbol_fastS_fx( rc_st_dec, cum_freq_ECSQ_tab_param[ecsq_inst->config_index], sym_freq_ECSQ_tab_param[ecsq_inst->config_index], ECSQ_PARAM_COUNT, ECSQ_PROB_BITS ); shift = s_max( 0, sub( param_zb, 3 ) ); /* first nonzero shift of 1 is used for param 3 */ - IF( NE_16( param_zb, 0 ) ) /* not the ECSQ_ALL_ZERO_PARAM param */ + IF( param_zb != 0 ) /* not the ECSQ_ALL_ZERO_PARAM param */ { tab_vals_cum_freq = cum_freq_ECSQ_tab_vals[sub( param_zb, 1 )]; tab_vals_sym_freq = sym_freq_ECSQ_tab_vals[sub( param_zb, 1 )]; @@ -320,7 +320,8 @@ void ECSQ_decode( IF( shift != 0 ) { - IF( ( sym > 0 ) || ( shift > 4 ) ) + test(); + IF( ( sym > 0 ) || ( GT_16( shift, 4 ) ) ) { lsbs = rc_uni_dec_read_bits( rc_st_dec, shift ); } diff --git a/lib_dec/ivas_stereo_icbwe_dec.c b/lib_dec/ivas_stereo_icbwe_dec.c index 47da57810e32fc0984d4f727f5de20e4e540ead5..5476af31c91a412db9d4a9b8ba164787383c867b 100644 --- a/lib_dec/ivas_stereo_icbwe_dec.c +++ b/lib_dec/ivas_stereo_icbwe_dec.c @@ -1041,7 +1041,7 @@ void stereo_icBWE_dec_fx( curr_pow_fx = L_add( curr_pow_fx, Mpy_32_32( L_tmp, L_tmp ) ); } - IF( EQ_32( prev_pow_fx, 0 ) ) + IF( prev_pow_fx == 0 ) { e_scale_fx = 0; move16(); @@ -1055,7 +1055,7 @@ void stereo_icBWE_dec_fx( scale_fx = BASOP_Util_Divide3232_Scale( curr_pow_fx, prev_pow_fx, &e_scale_fx ); scale_fx = Sqrt16( scale_fx, &e_scale_fx ); } - IF( LT_16( e_scale_fx, 0 ) ) + IF( e_scale_fx < 0 ) { scale_fx = shl( scale_fx, e_scale_fx ); e_scale_fx = 0; @@ -1282,6 +1282,7 @@ void stereo_icBWE_dec_fx( move16(); *Q_syn = sub( *Q_syn, 1 ); + move16(); return; } diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 7eef8c14a5c8888c7a464c818212e4aca294839a..c72417928c9321a7d80e8aecf06fdabd8ad30c9d 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -514,7 +514,7 @@ void stereo_mdct_core_dec_fx( test(); test(); test(); - IF( EQ_16( hCPE->nchan_out, 1 ) && ( EQ_16( bfi, 0 ) || ( NE_16( bfi, 0 ) && NE_16( sts[0]->core, ACELP_CORE ) && NE_16( sts[1]->core, ACELP_CORE ) ) ) ) + IF( hCPE->nchan_out == 1 && ( bfi == 0 || ( bfi != 0 && sts[0]->core != ACELP_CORE && sts[1]->core != ACELP_CORE ) ) ) { apply_dmx_weights_fx( hCPE, x_fx, sts[0]->transform_type, sts[1]->transform_type ); } @@ -541,7 +541,7 @@ void stereo_mdct_core_dec_fx( } test(); test(); - IF( NE_16( sts[ch]->igf, 0 ) && sts[ch]->hIGFDec && sts[ch]->hIGFDec->virtualSpec_fx ) + IF( sts[ch]->igf != 0 && sts[ch]->hIGFDec && sts[ch]->hIGFDec->virtualSpec_fx ) { Scale_sig32( sts[ch]->hIGFDec->virtualSpec_fx + sub( sts[ch]->hIGFDec->infoIGFStartLine, IGF_START_MN ), s_min( sub( sts[ch]->hIGFDec->infoIGFStopLine, sts[ch]->hIGFDec->infoIGFStartLine ), 856 ), sub( sts[ch]->hIGFDec->virtualSpec_e, x_e[ch][0] ) ); sts[ch]->hIGFDec->virtualSpec_e = x_e[ch][0]; @@ -739,6 +739,7 @@ static void apply_dmx_weights_fx( move64(); Word32 sum_nrg_Mid, sum_abs, dot_prod_abs; Word16 val_div = 0; + move16(); IF( sfbConf->sfbOffset[b] == 0 ) { @@ -1010,11 +1011,13 @@ static void run_min_stats_fx( { spec_in = &x[ch][0][0]; spec_e = x_e[ch][0]; + move16(); } ELSE { spec_in = &x[( ch + 1 ) % 2][0][0]; spec_e = x_e[( ch + 1 ) % 2][0]; + move16(); /* patch VAD to zero so that estimation runs, will later be restored */ st->VAD = 0; move16(); @@ -1044,7 +1047,8 @@ static void run_min_stats_fx( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx = L_add( Mpy_32_32( Q31_0_99, st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx ), Mpy_32_32( st->hFdCngDec->hFdCngCom->flag_noisy_speech, Q31_0_01 ) ); st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = extract_h( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx ); - + move32(); + move32(); st->lp_noise = st->hFdCngDec->lp_noise; move32(); } @@ -1068,6 +1072,7 @@ static void run_min_stats_fx( /* restore VAD (see above) */ st->VAD = save_VAD[ch]; + move16(); } return; diff --git a/lib_dec/nelp_dec_fx.c b/lib_dec/nelp_dec_fx.c index c6714cb6dc60b4d6b109133885a350f41af29bdc..1f103223ea5585b608d2562b916278e3b657c094 100644 --- a/lib_dec/nelp_dec_fx.c +++ b/lib_dec/nelp_dec_fx.c @@ -30,8 +30,7 @@ #ifdef IVAS_FLOAT_FIXED static void normalize_arr( Word16 *arr, Word16 *qf, Word16 size, Word16 hdr ) { - Word16 i; - Word16 max_s = 0; + Word16 i, max_s = 0; move16(); FOR( i = 0; i < size; i++ ) @@ -123,7 +122,7 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1 test(); test(); test(); - IF( EQ_16( coder_type, UNVOICED ) && st_fx->bwidth == NB ) + IF( EQ_16( coder_type, UNVOICED ) && EQ_16( st_fx->bwidth, NB ) ) { IF( NE_16( st_fx->last_nelp_mode_dec, 1 ) ) { @@ -285,7 +284,7 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1 } test(); - IF( EQ_16( coder_type, UNVOICED ) && ( st_fx->bwidth == NB ) ) + IF( EQ_16( coder_type, UNVOICED ) && ( EQ_16( st_fx->bwidth, NB ) ) ) { BP1_ORDER = 7; move16(); diff --git a/lib_dec/peak_vq_dec_fx.c b/lib_dec/peak_vq_dec_fx.c index d5a5073fe02164d1105637463c42f970ac7d2bec..d3fa428b2c9799f9f5d64d9d6548afc6a33ca8f4 100644 --- a/lib_dec/peak_vq_dec_fx.c +++ b/lib_dec/peak_vq_dec_fx.c @@ -478,7 +478,7 @@ static Word16 hvq_dec_pos_fx( mode = get_next_indice_fx( st_fx, 1 ); num_bits = add( num_bits, 1 ); - IF( mode == HVQ_CP_DELTA ) + IF( EQ_16( mode, HVQ_CP_DELTA ) ) { huff_dec_fx( st_fx, num_peaks, HVQ_CP_HUFF_MAX_CODE, HVQ_CP_HUFF_NUM_LEN, hvq_cp_huff_thres, hvq_cp_huff_offset, hvq_cp_huff_tab, delta ); diff --git a/lib_dec/pit_dec_fx.c b/lib_dec/pit_dec_fx.c index 7acfa264d37382e427a84b009527bada422d39d0..a68cba5a88523e6b095d13e6b9af25bd922efcd3 100644 --- a/lib_dec/pit_dec_fx.c +++ b/lib_dec/pit_dec_fx.c @@ -218,7 +218,7 @@ void Mode2_abs_pit_dec( *T0_res = pit_res_max; move16(); } - ELSE IF( index < add( tmp1, tmp2 ) ) + ELSE IF( LT_16( index, add( tmp1, tmp2 ) ) ) { assert( pit_res_max > 1 ); @@ -601,24 +601,21 @@ Word16 pit_decode_fx( /* o : floating pitch value /*=======================================================================*/ -Word16 pit_decode_ivas_fx( /* o : floating pitch value */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - Word16 i_subfr, /* i : subframe index */ - const Word16 coder_type, /* i : coding type */ - Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ - Word16 *T0, /* o : close loop integer pitch */ - Word16 *T0_frac, /* o : close loop fractional part of the pitch */ - Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ - Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ - const Word16 L_subfr /* i : subframe length */ -#if 1 // def ADD_LRTD - , +Word16 pit_decode_ivas_fx( /* o : floating pitch value */ + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame, /* i : length of the frame */ + Word16 i_subfr, /* i : subframe index */ + const Word16 coder_type, /* i : coding type */ + Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ + Word16 *T0, /* o : close loop integer pitch */ + Word16 *T0_frac, /* o : close loop fractional part of the pitch */ + Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ + Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ + const Word16 L_subfr, /* i : subframe length */ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -#endif ) { Word16 pitch; /*Q2*/ @@ -748,7 +745,6 @@ Word16 pit_decode_ivas_fx( /* o : floating pitch value pit_Q_dec_fx( 0, pitch_index, nBits, 4, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect ); } -#if 1 // def ADD_LRTD ELSE IF( EQ_16( st_fx->idchan, 1 ) && ( EQ_16( tdm_Pitch_reuse_flag, 1 ) || EQ_16( nBits, 4 ) ) ) { /*-------------------------------------------------------* @@ -795,7 +791,6 @@ Word16 pit_decode_ivas_fx( /* o : floating pitch value move16(); } } -#endif ELSE { /*-------------------------------------------------------* @@ -1009,7 +1004,6 @@ void pit16k_Q_dec_fx( *T0 = add( PIT16k_FR2_EXTEND_10b, shr( index, 1 ) ); move16(); *T0_frac = sub( index, shl( sub( *T0, PIT16k_FR2_EXTEND_10b ), 1 ) ); - /*(*T0_frac) *= 2;*/ ( *T0_frac ) = shl( *T0_frac, 1 ); move16(); } diff --git a/lib_dec/post_dec_fx.c b/lib_dec/post_dec_fx.c index 14ea5b9e3604452124115367a9d2b0a74563f9e0..5f4d5e195f8feea67fade0a7737789e7390f33f6 100644 --- a/lib_dec/post_dec_fx.c +++ b/lib_dec/post_dec_fx.c @@ -81,7 +81,7 @@ void post_decoder( ELSE { /*Formant enhancement*/ - IF( st->last_bwidth == NB ) + IF( EQ_16( st->last_bwidth, NB ) ) { Copy( synth, synth2_pe, L_frame ); tmp = synth[-1]; @@ -106,7 +106,7 @@ void post_decoder( st->hPFstat->reset = 1; move16(); } - IF( st->bwidth == NB ) + IF( EQ_16( st->bwidth, NB ) ) { st->hPFstat->on = 1; move16(); @@ -268,7 +268,7 @@ void post_decoder_ivas_fx( st->hPFstat->reset = 1; move16(); } - IF( st->bwidth == NB ) + IF( EQ_16( st->bwidth, NB ) ) { st->hPFstat->on = 1; move16(); @@ -731,7 +731,8 @@ void cldfb_synth_set_bandsToZero( move32(); update_perc = 1; move16(); - if ( st->ini_frame >= 25 && tempQ31 < Mult_32_16( st->avg_nrg_LT, 164 ) ) + test(); + if ( GE_16( st->ini_frame, 25 ) && LT_32( tempQ31, Mult_32_16( st->avg_nrg_LT, 164 ) ) ) { update_perc = 0; move16(); @@ -739,7 +740,7 @@ void cldfb_synth_set_bandsToZero( flag = 1; move16(); - if ( max_nrg >= tempQ31 ) + if ( GE_32( max_nrg, tempQ31 ) ) { flag = 0; move16(); diff --git a/lib_dec/pvq_core_dec_fx.c b/lib_dec/pvq_core_dec_fx.c index 8584ea63e6b3ed032ee7037d1e338b289a9209f0..530c2c5b937a7c1bab95cd616a760aa861c49c54 100644 --- a/lib_dec/pvq_core_dec_fx.c +++ b/lib_dec/pvq_core_dec_fx.c @@ -5,9 +5,9 @@ #include #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ -#include "prot_fx.h" /* Function prototypes */ #include "rom_com.h" /* Static table prototypes */ #ifdef IVAS_FLOAT_FIXED +#include "prot_fx.h" /* Function prototypes */ #include "ivas_prot_fx.h" /*-------------------------------------------------------------------* @@ -80,6 +80,7 @@ static void pvq_decode_band_fx( FOR( j = 0; j < Np; j++ ) { g_part[j] = negate( g_part_neg[j] ); + move16(); } BASOP_SATURATE_WARNING_ON_EVS srt_vec_ind16_fx( g_part, sg_part, idx_sort, Np ); @@ -278,6 +279,7 @@ Word16 ivas_pvq_core_dec_fx( } apply_gain_fx( ord, sfm_start, sfm_end, nb_sfm, fg_pred, coefs_quant ); *Q_coefs = 12; + move16(); return bits_tot; } @@ -357,6 +359,7 @@ Word16 pvq_core_dec_fx( } apply_gain_fx( ord, sfm_start, sfm_end, nb_sfm, fg_pred, coefs_quant ); *Q_coefs = 12; + move16(); return bits_tot; } @@ -384,6 +387,7 @@ void decode_energies_fx( Word16 oppRQ3, qzero; Word16 l_gain, r_gain; Word16 index_phi = -1; + move16(); l_Np = shr( Np, 1 ); r_Np = sub( Np, l_Np ); @@ -472,8 +476,10 @@ static void densitySymbolIndexDecode_fx( UWord16 lsb; Word32 acc; Word16 alpha = 0; + move16(); #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif IF( s_and( (Word16) 0xFFFE, density ) == 0 ) { @@ -596,6 +602,7 @@ static void densitySymbolIndexDecode_fx( rc_dec_update_fx( st_fx, hPVQ, cum_freq, sym_freq ); *index_phi = alpha; + move16(); return; } diff --git a/lib_dec/pvq_decode_fx.c b/lib_dec/pvq_decode_fx.c index 12170735f922b5f95bb2011ab4311acc8ccd1844..ca8c8ed0af65172c38536177abebcdceb42d0226 100644 --- a/lib_dec/pvq_decode_fx.c +++ b/lib_dec/pvq_decode_fx.c @@ -44,7 +44,7 @@ void pvq_decode_fx( IF( NE_16( dim, 1 ) ) { - entry.lead_sign_ind = (short) rc_dec_bits_fx( st_fx, hPVQ, 1 ); + entry.lead_sign_ind = (Word16) rc_dec_bits_fx( st_fx, hPVQ, 1 ); entry.index = rc_dec_uniform_fx( st_fx, hPVQ, entry.size ); IF( st_fx->hHQ_core != NULL ) @@ -64,7 +64,7 @@ void pvq_decode_fx( } ELSE { - entry.lead_sign_ind = (short) rc_dec_bits_fx( st_fx, hPVQ, 1 ); /* always a single sign bit */ + entry.lead_sign_ind = (Word16) rc_dec_bits_fx( st_fx, hPVQ, 1 ); /* always a single sign bit */ entry.index = L_deposit_l( 0 ); } diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index c4e0b43df7b1bba18226d61cae986aa139ea3cc6..f7d66f35df133d187e8697d3610eafff9b37819a 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -593,7 +593,7 @@ typedef struct tcx_ltp_dec_structure #ifndef IVAS_FLOAT_FIXED float tcxltp_gain_float; #endif - Word16 tcxltp_gain; + Word16 tcxltp_gain; /* Q15 */ int16_t tcxltp_pitch_int; int16_t tcxltp_pitch_fr; @@ -648,7 +648,7 @@ typedef struct tcx_dec_structure #ifndef IVAS_FLOAT_FIXED float tcxltp_last_gain_unmodified_float; #endif - Word16 tcxltp_last_gain_unmodified; + Word16 tcxltp_last_gain_unmodified; /* Q15 */ int16_t tcx_hm_LtpPitchLag; int16_t tcx_lpc_shaped_ari; diff --git a/lib_dec/stat_noise_uv_dec_fx.c b/lib_dec/stat_noise_uv_dec_fx.c index 7f8823cd1aedbf0c17e1e7bfcceb9f5e728ee4c6..c1749a536ef2aaf1b6e2a3748b0e3d1c51765cac 100644 --- a/lib_dec/stat_noise_uv_dec_fx.c +++ b/lib_dec/stat_noise_uv_dec_fx.c @@ -6,7 +6,7 @@ #include "options.h" /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ - +#ifdef IVAS_FLOAT_FIXED /*---------------------------------------------------------* * stat_noise_uv_dec() * @@ -86,3 +86,4 @@ void stat_noise_uv_dec_fx( return; } +#endif diff --git a/lib_dec/swb_bwe_dec.c b/lib_dec/swb_bwe_dec.c index 798a022a32658394e790219b6d072a50cf35d169..a1f18d2daa2126bfdb951bd138fa9a5ba38ce7ab 100644 --- a/lib_dec/swb_bwe_dec.c +++ b/lib_dec/swb_bwe_dec.c @@ -217,7 +217,6 @@ static int16_t para_pred_bws( } #endif #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 */ @@ -350,16 +349,14 @@ static Word16 para_pred_bws_fx( 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 */ + 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 = 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 */ } @@ -484,7 +481,6 @@ static Word16 para_pred_bws_fx( return mode; } - #endif // IVAS_FLOAT_FIXED @@ -1094,11 +1090,9 @@ Word16 swb_bwe_dec_fx32( 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; move16(); direct_transform_fx( wtda_synth_fx, ysynth_fx32, 0, output_frame, &new_input_fx_exp, st_fx->element_mode ); diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index 3fc6c961788b1971a1aabf7d5e430ab3c6496c81..f72e89398f26795e589c932348ad949ab175f7f6 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -10,6 +10,7 @@ #include "rom_enc.h" #include "ivas_prot_fx.h" +#ifdef IVAS_FLOAT_FIXED #define MAX_Q_NEW_INPUT 8 #define Q_WTDA_FX 13 #define Q_32_BITS 15 @@ -348,7 +349,6 @@ Word16 WB_BWE_gain_deq_fx( * * WB BWE decoder (only for 16kHz signals) *-------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED Word16 ivas_wb_bwe_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 output[], /* i : suntehsis @ internal Fs */ @@ -513,7 +513,6 @@ Word16 ivas_wb_bwe_dec_fx( move16(); return Q_syn_hb; } -#endif Word16 wb_bwe_dec_fx( #ifdef ADD_IVAS_BWE @@ -602,18 +601,18 @@ Word16 wb_bwe_dec_fx( } ELSE { - int32_t tmp_brate; + Word32 tmp_brate; tmp_brate = st_fx->last_core_brate; move32(); -#if 1 // def ADD_IVAS_BWE + test(); if ( EQ_32( st_fx->last_total_brate, ACELP_9k60 ) && EQ_16( st_fx->last_extl, SWB_TBE ) ) { tmp_brate = ACELP_8k00; /* this is needed in order to stay BE wrt. EVS mono */ move32(); } -#endif + if ( NE_16( st_fx->last_extl, WB_BWE ) ) { st_fx->prev_SWB_fenv_fx[0] = 0; @@ -1306,3 +1305,4 @@ void fd_bwe_dec_init( return; } +#endif diff --git a/lib_dec/swb_bwe_dec_hr.c b/lib_dec/swb_bwe_dec_hr.c index 949b45481b52e5434463bb90f4ae7fa8c9bb8b99..2a4e3139b7c3c018b46a5f16a7b8b5a6eacd5689 100644 --- a/lib_dec/swb_bwe_dec_hr.c +++ b/lib_dec/swb_bwe_dec_hr.c @@ -273,11 +273,7 @@ void swb_bwe_dec_hr( *---------------------------------------------------------------------*/ Nsv = ( NUM_TRANS_END_FREQ_COEF - NUM_TRANS_START_FREQ_COEF ) / WIDTH_BAND; -#ifdef IVAS_FLOAT_FIXED - AVQ_demuxdec_fx( st, x_norm, &nBits, Nsv, nq, 0, Nsv - 1 ); -#else AVQ_demuxdec( st, x_norm, &nBits, Nsv, nq, 0, Nsv - 1 ); -#endif // IVAS_FLOAT_FIXED for ( i = 0; i < Nsv * WIDTH_BAND; i++ ) { t_audio[k * output_frame / NUM_TIME_SWITCHING_BLOCKS + NUM_TRANS_START_FREQ_COEF + i] = (float) ( x_norm[i] ); @@ -448,11 +444,7 @@ void swb_bwe_dec_hr( *---------------------------------------------------------------------*/ Nsv = i / WIDTH_BAND; -#ifdef IVAS_FLOAT_FIXED - AVQ_demuxdec_fx( st, x_norm, &nBits, Nsv, nq, 0, Nsv - 1 ); -#else AVQ_demuxdec( st, x_norm, &nBits, Nsv, nq, 0, Nsv - 1 ); -#endif // IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* * second stage decoding *---------------------------------------------------------------------*/ @@ -474,11 +466,7 @@ void swb_bwe_dec_hr( } nBits -= NBITS_GLOB_GAIN_BWE_HR; -#ifdef IVAS_FLOAT_FIXED - AVQ_demuxdec_fx( st, x_norm1, &nBits, Nsv2, nq2, 0, Nsv2 - 1 ); -#else AVQ_demuxdec( st, x_norm1, &nBits, Nsv2, nq2, 0, Nsv2 - 1 ); -#endif // IVAS_FLOAT_FIXED } /*---------------------------------------------------------------------* diff --git a/lib_dec/swb_bwe_dec_lr_fx.c b/lib_dec/swb_bwe_dec_lr_fx.c index fa9dcfc588f084f52a594e139e042f4cc1c95677..f2aa60a59f60d746c259952292162e17deef0529 100644 --- a/lib_dec/swb_bwe_dec_lr_fx.c +++ b/lib_dec/swb_bwe_dec_lr_fx.c @@ -7,6 +7,7 @@ #include "prot_fx.h" #include "rom_com.h" +#ifdef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * DecodeSWBGenericParameters() * @@ -345,3 +346,4 @@ void swb_bwe_dec_lr_fx( return; } +#endif diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c index 5b2e33cfe4fb3035dcfaaf8087a34a67fcd84e38..b238098997e621a6dc14319a992fc29b4926af57 100644 --- a/lib_dec/swb_tbe_dec.c +++ b/lib_dec/swb_tbe_dec.c @@ -587,9 +587,6 @@ static void rescale_genSHB_mem_dec( } } - if ( EQ_16( st_fx->extl, FB_TBE ) ) - { - } hBWE_TD->mem_csfilt_fx[0] = L_shl( hBWE_TD->mem_csfilt_fx[0], sf ); move32(); @@ -997,28 +994,7 @@ void find_max_mem_dec_m3( max3 = s_max( max3, tempQ15 ); } /* find max in prev genSHBsynth_state_lsyn_filt_shb_local_fx */ - // FOR(i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++) - //{ - // tempQ15 = abs_s(hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i]); - // max3 = s_max(max3, tempQ15); - // } - ///* find max in prev int_3_over_2_tbemem_dec_fx */ - // IF(EQ_32(st->output_Fs, 48000)) - //{ - // FOR(i = 0; i < INTERP_3_2_MEM_LEN; i++) - // { - // tempQ15 = abs_s(hBWE_TD->int_3_over_2_tbemem_dec_fx[i]); - // max3 = s_max(max3, tempQ15); - // } - // } - // IF(EQ_32(st->output_Fs, 16000)) - //{ - // FOR(i = 0; i < (2 * ALLPASSSECTIONS_STEEP + 1); i++) - // { - // tempQ15 = abs_s(hBWE_TD->mem_resamp_HB_32k_fx[i]); - // max3 = s_max(max3, tempQ15); - // } - // } + /* estimate the norm for 16-bit memories */ *n_mem3 = norm_s( max3 ); move16(); @@ -1027,26 +1003,6 @@ void find_max_mem_dec_m3( *n_mem3 = 15; move16(); } - - // Lmax3 = 0; - // IF(EQ_16(st->L_frame, L_FRAME)) - //{ - // /* find max in prev genSHBsynth_Hilbert_Mem_fx */ - // FOR(i = 0; i < HILBERT_MEM_SIZE; i++) - // { - // tempQ32 = L_abs(hBWE_TD->genSHBsynth_Hilbert_Mem_fx[i]); - // Lmax3 = L_max(Lmax3, tempQ32); - // } - // } - - ///* estimate the norm for 32-bit memories */ - // n_mem_32 = norm_l(Lmax3); - // if (Lmax3 == 0) n_mem_32 = 31; - - // tempQ15 = sub(s_min(*n_mem3, n_mem_32), 2); /* very important leave at least 2 bit head room - // because of the Hilber transform and Q14 coeffs */ - //*n_mem3 = s_max(tempQ15, 0); - ///* --------------------------------------------------------------*/ } #ifdef IVAS_FLOAT_FIXED @@ -4818,89 +4774,40 @@ void TBEreset_dec( if ( st->last_core != ACELP_CORE ) { -#ifndef IVAS_FLOAT_FIXED set_f( hBWE_TD->old_bwe_exc, 0.0f, PIT16k_MAX * 2 ); hBWE_TD->bwe_non_lin_prev_scale = 0.f; -#endif -#ifdef IVAS_FLOAT_FIXED - set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); - st->prev_Q_bwe_exc = 31; -#endif } if ( st->bwidth == WB ) { -#ifndef IVAS_FLOAT_FIXED wb_tbe_extras_reset( hBWE_TD->mem_genSHBexc_filt_down_wb2, hBWE_TD->mem_genSHBexc_filt_down_wb3 ); -#endif -#ifdef IVAS_FLOAT_FIXED - wb_tbe_extras_reset_fx( hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx ); -#endif wb_tbe_extras_reset_synth( hBWE_TD->state_lsyn_filt_shb, hBWE_TD->state_lsyn_filt_dwn_shb, hBWE_TD->mem_resamp_HB ); -#ifndef IVAS_FLOAT_FIXED set_f( hBWE_TD->mem_genSHBexc_filt_down_shb, 0, 7 ); set_f( hBWE_TD->state_lpc_syn, 0, 10 ); set_f( hBWE_TD->state_syn_shbexc, 0, L_SHB_LAHEAD / 4 ); -#endif -#ifdef IVAS_FLOAT_FIXED - set16_fx( hBWE_TD->mem_genSHBexc_filt_down_shb_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); - set16_fx( hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - set16_fx( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD / 4 ); -#endif set_f( hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD ); -#ifndef IVAS_FLOAT_FIXED set_f( hBWE_TD->mem_csfilt, 0, 2 ); -#endif -#ifdef IVAS_FLOAT_FIXED - set32_fx( hBWE_TD->mem_csfilt_fx, 0, 2 ); -#endif } else if ( st->bwidth == SWB || st->bwidth == FB ) { -#ifndef IVAS_FLOAT_FIXED swb_tbe_reset( hBWE_TD->mem_csfilt, hBWE_TD->mem_genSHBexc_filt_down_shb, hBWE_TD->state_lpc_syn, hBWE_TD->syn_overlap, hBWE_TD->state_syn_shbexc, &( hBWE_TD->tbe_demph ), &( hBWE_TD->tbe_premph ), hBWE_TD->mem_stp_swb, &( hBWE_TD->gain_prec_swb ) ); set_f( hBWE_TD->GainShape_Delay, 0, NUM_SHB_SUBFR / 2 ); -#endif -#ifdef IVAS_FLOAT_FIXED - 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 ), hBWE_TD->mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ) ); - - set16_fx( hBWE_TD->GainShape_Delay_fx, 0, NUM_SHB_SUBFR / 2 ); -#endif - set_f( hBWE_TD->int_3_over_2_tbemem_dec, 0.f, INTERP_3_2_MEM_LEN ); set_f( hBWE_TD->mem_resamp_HB_32k, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); -#ifndef IVAS_FLOAT_FIXED hBWE_TD->prev_pow_exc16kWhtnd = 1.0f; hBWE_TD->prev_mix_factor = 1.0f; swb_tbe_reset_synth( hBWE_TD->genSHBsynth_Hilbert_Mem, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local ); -#endif -#ifdef IVAS_FLOAT_FIXED - hBWE_TD->prev_pow_exc16kWhtnd_fx32 = 1; /* Q0 1.f */ - hBWE_TD->prev_mix_factor_fx = 32767; /*Q15 1.f*/ - - swb_tbe_reset_synth_ivas_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32 ); -#endif if ( st->bwidth == FB ) { if ( st->hBWE_FD != NULL ) { -#ifndef IVAS_FLOAT_FIXED st->hBWE_FD->prev_fb_ener_adjust = 0.0f; -#endif } -#ifndef IVAS_FLOAT_FIXED set_f( hBWE_TD->fb_state_lpc_syn, 0, LPC_SHB_ORDER ); hBWE_TD->fb_tbe_demph = 0; fb_tbe_reset_synth( hBWE_TD->fbbwe_hpf_mem, &hBWE_TD->prev_fbbwe_ratio ); -#endif -#ifdef IVAS_FLOAT_FIXED - set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - hBWE_TD->fb_tbe_demph_fx = 0; - fb_tbe_reset_synth_fx( hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, &hBWE_TD->prev_fbbwe_ratio_fx ); -#endif } } diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index eceaa1eafb1b6ad3143ee625b23a459b268011aa..d7c63d3fbcca036fdc11892ed6f73ee772716a96 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -18,7 +18,7 @@ * Local functions *-----------------------------------------------------------------*/ - +#ifdef IVAS_FLOAT_FIXED static void dequantizeSHBparams_fx_9_1( Decoder_State *st_fx, const Word16 extl, Word32 extl_brate, Word16 *Q_lsf, Word16 *Q_subgain, Word32 *Q_framegrain, Word16 *uv_flag, Word32 *Q_shb_ener_sf_32, Word16 *Q_shb_res_gshape, Word16 *Q_mixFactors ); static void find_max_mem_dec( Decoder_State *st_fx, Word16 *n_mem, Word16 *n_mem2, Word16 *n_mem3 ); @@ -31,7 +31,7 @@ static void Dequant_mirror_point_fx( const Word16 lsf_q[], const Word16 m_idx, W Word16 dotp_loc( const Word16 x[], /* i : vector x[] */ const Word32 y[], /* i : vector y[] */ - const int16_t n /* i : vector length */ + const Word16 n /* i : vector length */ ); /* gain shape concealment code */ @@ -411,8 +411,6 @@ void rescale_genWB_mem( Decoder_State *st_fx, Word16 sf ) } } - -#ifdef IVAS_FLOAT_FIXED void InitSWBdecBuffer_ivas_fx( Decoder_State *st_fx /* i/o: SHB decoder structure */ ) @@ -458,7 +456,8 @@ void InitSWBdecBuffer_ivas_fx( move16(); return; } -#endif + + void InitSWBdecBuffer_fx( Decoder_State *st_fx /* i/o: SHB decoder structure */ ) @@ -632,7 +631,6 @@ void ResetSHBbuffer_Dec_fx( Decoder_State *st_fx /* i/o: SHB encoder structure * /*--------------------------------------------------------------------------*/ /* CALLED FROM : */ /*==========================================================================*/ -#ifdef IVAS_FLOAT_FIXED void ivas_wb_tbe_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 coder_type, /* i : coding type */ @@ -1300,7 +1298,7 @@ void ivas_wb_tbe_dec_fx( return; } -#endif + void wb_tbe_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ @@ -2463,6 +2461,7 @@ void swb_tbe_dec_fx( /* get the gainshape delay */ Copy( &st_fx->GainShape_Delay[4], &st_fx->GainShape_Delay[0], NUM_SHB_SUBFR / 4 ); + test(); IF( ( st_fx->rf_flag != 0 ) || EQ_32( st_fx->total_brate, ACELP_9k60 ) ) { FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) @@ -4052,7 +4051,7 @@ static void Dequant_mirror_point_fx( Word16 dotp_loc( const Word16 x[], /* i : vector x[] */ const Word32 y[], /* i : vector y[] */ - const int16_t n /* i : vector length */ + const Word16 n /* i : vector length */ ) { Word16 i; @@ -4890,7 +4889,6 @@ void fb_tbe_dec_fx( return; } -#ifdef IVAS_FLOAT_FIXED void fb_tbe_dec_ivas_fx( Decoder_State *st, /* i/o: encoder state structure */ const Word16 fb_exc[], /* i : FB excitation from the SWB part */ @@ -4973,7 +4971,6 @@ void fb_tbe_dec_ivas_fx( } return; } -#endif void tbe_read_bitstream_fx( Decoder_State *st_fx ) @@ -5287,7 +5284,6 @@ void TBEreset_dec_fx( return; } -#ifdef IVAS_FLOAT_FIXED void TBEreset_dec_ivas_fx( Decoder_State *st /* i/o: decoder state structure */ ) @@ -5351,16 +5347,12 @@ void TBEreset_dec_ivas_fx( return; } -#endif // IVAS_FLOAT_FIXED - - /*-------------------------------------------------------------------* * td_bwe_dec_init() * * Initialize TD BWE state structure at the decoder *-------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED void td_bwe_dec_init_ivas_fx( Decoder_State *st_fx, /* i/o: SHB decoder structure */ TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ @@ -5431,7 +5423,8 @@ void td_bwe_dec_init_ivas_fx( return; } -#endif + + void td_bwe_dec_init_fx( Decoder_State *st_fx, /* i/o: SHB decoder structure */ TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ @@ -5507,3 +5500,5 @@ void td_bwe_dec_init_fx( return; } + +#endif diff --git a/lib_dec/syn_outp_fx.c b/lib_dec/syn_outp_fx.c index 0cdf219731e787f98811661b847a02f8d4bf9947..7d51c4341255eaf617b714d616ebc14dce0aa542 100644 --- a/lib_dec/syn_outp_fx.c +++ b/lib_dec/syn_outp_fx.c @@ -7,15 +7,16 @@ #include "cnst.h" /* Common constants */ #include "prot_fx.h" /* Debug prototypes */ +#ifdef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* - * syn_output() + * syn_output_fx() * * Output synthesis signal with compensation for saturation *-------------------------------------------------------------------*/ void syn_output_fx( const Word16 codec_mode, /* i : MODE1 or MODE2 */ - Word16 *synth, /* i/o: float synthesis signal */ + Word16 *synth, /* i/o: fixed point synthesis signal */ const Word16 output_frame, /* i : output frame length */ Word16 *synth_out, /* o : integer 16 bits synthesis signal */ const Word16 Q_syn2 /* i : Synthesis scaling factor */ @@ -130,3 +131,5 @@ void unscale_AGC( mem[1] = shr( x[i - 1], 1 ); move16(); } + +#endif diff --git a/lib_dec/tcq_core_dec_fx.c b/lib_dec/tcq_core_dec_fx.c index 0986f5d17677b77a0881b3ae717f40b8242bcc8b..41c83c71ec499a4ff961d2e13eea60e633f7f26d 100644 --- a/lib_dec/tcq_core_dec_fx.c +++ b/lib_dec/tcq_core_dec_fx.c @@ -13,6 +13,7 @@ * Main Generic Audio Decoder Routine for LR-MDCT *---------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED void tcq_core_LR_dec_fx( Decoder_State *st_fx, Word16 *inp_vector_fx, /* x5 */ @@ -497,3 +498,5 @@ void tcq_core_LR_dec_fx( return; } + +#endif diff --git a/lib_dec/tcx_utils_dec_fx.c b/lib_dec/tcx_utils_dec_fx.c index e6a0dd26200f7157e421ae139e283f2fc27100e2..e4b56eca9964566be04279a94992cefa24b82378 100644 --- a/lib_dec/tcx_utils_dec_fx.c +++ b/lib_dec/tcx_utils_dec_fx.c @@ -13,6 +13,7 @@ #include "basop_util.h" #include "rom_com.h" +#ifdef IVAS_FLOAT_FIXED /*--------------------------------------------------------------- * tcx_decoder_memory_update() * @@ -396,3 +397,4 @@ Word16 tcx_res_invQ_spec( return bits; } +#endif diff --git a/lib_dec/tns_base_dec_fx.c b/lib_dec/tns_base_dec_fx.c index 0631dad11f99245ea847f9793ed79ebc5f338379..4f44dab85d8aa15568f0f1303f286ffe342f39f3 100644 --- a/lib_dec/tns_base_dec_fx.c +++ b/lib_dec/tns_base_dec_fx.c @@ -16,6 +16,7 @@ * @param x the current input value. * @return the output of the filter. */ +#ifdef IVAS_FLOAT_FIXED typedef Word32 ( *TLinearPredictionFilter )( Word16 order, Word16 const parCoeff[], Word32 *state, Word32 x ); /********************************/ @@ -255,7 +256,7 @@ Word16 DecodeTnsData_ivas_fx( move16(); result = FALSE; - IF( GT_16( pTnsData->nFilters, 0 ) ) + if ( pTnsData->nFilters > 0 ) { move16(); result = TRUE; @@ -264,3 +265,5 @@ Word16 DecodeTnsData_ivas_fx( return result; } + +#endif diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index 328c00d184ff0059b2282f67adfcbdbcb8de3e5f..8a3ea526038c2274a3de24752ce226f79f5fca1c 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -69,13 +69,11 @@ ivas_error TonalMDCTConceal_Init_ivas( assert( ( hTonalMDCTConc->nScaleFactors == nScaleFactors ) || ( hTonalMDCTConc->nSamples != nSamples ) ); /* If nSamples doesn't change then also nScaleFactors must stay the same */ hTonalMDCTConc->tcx_cfg = hTcxCfg; -#ifndef IVAS_FLOAT_FIXED hTonalMDCTConc->lastBlockData.spectralData_float = hTonalMDCTConc->spectralDataBuffers_float[0]; hTonalMDCTConc->secondLastBlockData.spectralData_float = hTonalMDCTConc->spectralDataBuffers_float[1]; hTonalMDCTConc->secondLastPowerSpectrum_float = hTonalMDCTConc->secondLastBlockData.spectralData_float; hTonalMDCTConc->lastBlockData.scaleFactors_float = hTonalMDCTConc->scaleFactorsBuffers_float[0]; hTonalMDCTConc->secondLastBlockData.scaleFactors_float = hTonalMDCTConc->scaleFactorsBuffers_float[1]; -#endif hTonalMDCTConc->lastBlockData.blockIsValid = 0; hTonalMDCTConc->secondLastBlockData.blockIsValid = 0; hTonalMDCTConc->nSamples = 0; @@ -83,11 +81,8 @@ ivas_error TonalMDCTConceal_Init_ivas( hTonalMDCTConc->lastBlockData.blockIsConcealed = 0; hTonalMDCTConc->secondLastBlockData.blockIsConcealed = 0; - -#ifndef IVAS_FLOAT_FIXED hTonalMDCTConc->pTCI = (TonalComponentsInfo *) hTonalMDCTConc->timeDataBuffer_float; hTonalMDCTConc->lastPitchLag_float = 0; -#endif // #ifndef IVAS_FLOAT_FIXED if ( hTonalMDCTConc->nSamples != nSamples ) { @@ -97,17 +92,11 @@ ivas_error TonalMDCTConceal_Init_ivas( hTonalMDCTConc->nSamples = nSamples; hTonalMDCTConc->nSamplesCore = nSamplesCore; hTonalMDCTConc->nScaleFactors = nScaleFactors; -#ifdef IVAS_FLOAT_FIXED - set32_fx( hTonalMDCTConc->scaleFactorsBackground_fx, 0, FDNS_NPTS ); -#endif -#ifndef IVAS_FLOAT_FIXED set_zero( hTonalMDCTConc->scaleFactorsBackground_flt, FDNS_NPTS ); hTonalMDCTConc->scf_fadeout_flt = 1.0f; -#endif PsychoacousticParameters_Init( INT_FS_16k, L_FRAME16k, 64, 1, 1, &hTonalMDCTConc->psychParamsTCX20 ); PsychoacousticParameters_Init( INT_FS_16k, L_FRAME16k / 2, 64, 0, 1, &hTonalMDCTConc->psychParamsTCX10 ); hTonalMDCTConc->psychParams = NULL; -#ifndef IVAS_FLOAT_FIXED hTonalMDCTConc->last_block_nrg_flt = 0.0f; hTonalMDCTConc->curr_noise_nrg_flt = 0.0f; hTonalMDCTConc->faded_signal_nrg_flt = 0.0f; @@ -120,7 +109,6 @@ ivas_error TonalMDCTConceal_Init_ivas( /* If the second last frame was lost and concealed with tonal PLC, we reuse saved TonalComponentsInfo and don't update pcm buffers */ assert( sizeof( *hTonalMDCTConc->pTCI ) <= ( hTonalMDCTConc->lastPcmOut_float - hTonalMDCTConc->timeDataBuffer_float ) * sizeof( hTonalMDCTConc->timeDataBuffer_float[0] ) ); -#endif return IVAS_ERR_OK; } @@ -378,49 +366,7 @@ static void CalcPowerSpecAndDetectTonalComponents( } else { -#ifdef IVAS_FLOAT_FIXED - Word32 powerSpectrum_fx[L_FRAME_MAX], invScaleFactors_fx[FDNS_NPTS]; - Word16 q_ps = 31, q_isf = 31; - FOR( Word16 k = 0; k < hTonalMDCTConc->nSamplesCore; k++ ) - { - if ( abs( (Word32) powerSpectrum[k] ) != 0 ) - q_ps = s_min( q_ps, norm_l( (Word32) powerSpectrum[k] ) ); - } - FOR( Word16 k = 0; k < FDNS_NPTS; k++ ) - { - if ( abs( (Word32) invScaleFactors[k] ) != 0 ) - q_isf = s_min( q_isf, norm_l( (Word32) invScaleFactors[k] ) ); - } - q_ps -= 1; - q_isf -= 1; - FOR( Word16 c = 0; c < hTonalMDCTConc->nSamplesCore; c++ ) - { - powerSpectrum_fx[c] = (Word32) ( powerSpectrum[c] * ( 1 << q_ps ) ); - } - FOR( Word16 c = 0; c < FDNS_NPTS; c++ ) - { - invScaleFactors_fx[c] = (Word32) ( invScaleFactors[c] * ( 1 << q_isf ) ); - } - - sns_shape_spectrum_fx( powerSpectrum_fx, &q_ps, psychParamsCurrent, invScaleFactors_fx, q_isf, hTonalMDCTConc->nSamplesCore ); - - IF( q_ps + 1 < 31 ) - { - FOR( Word16 c = 0; c < hTonalMDCTConc->nSamplesCore; c++ ) - { - powerSpectrum[c] = ( (float) powerSpectrum_fx[c] / ( 1 << ( q_ps + 1 ) ) ); - } - } - ELSE IF( q_ps + 1 == 31 ) - { - FOR( Word16 c = 0; c < hTonalMDCTConc->nSamplesCore; c++ ) - { - powerSpectrum[c] = ( (float) powerSpectrum_fx[c] / ONE_IN_Q31 ); - } - } -#else sns_shape_spectrum( powerSpectrum, psychParamsCurrent, invScaleFactors, hTonalMDCTConc->nSamplesCore ); -#endif // IVAS_FLOAT_FIXED nBands = psychParamsCurrent->nBands; } @@ -939,49 +885,7 @@ void TonalMDCTConceal_Apply_ivas( } else { -#ifdef IVAS_FLOAT_FIXED - Word32 powerSpectrum_fx[L_FRAME_MAX], scaleFactors_fx[FDNS_NPTS]; - Word16 q_ps = 31, q_sf = 31; - FOR( Word16 k = 0; k < hTonalMDCTConc->nSamplesCore; k++ ) - { - if ( abs( (Word32) powerSpectrum[k] ) != 0 ) - q_ps = s_min( q_ps, norm_l( (Word32) powerSpectrum[k] ) ); - } - FOR( Word16 k = 0; k < FDNS_NPTS; k++ ) - { - if ( abs( (Word32) hTonalMDCTConc->secondLastBlockData.scaleFactors_float[k] ) != 0 ) - q_sf = s_min( q_sf, norm_l( (Word32) hTonalMDCTConc->secondLastBlockData.scaleFactors_float[k] ) ); - } - q_ps -= 1; - q_sf -= 1; - FOR( Word16 c = 0; c < hTonalMDCTConc->nSamplesCore; c++ ) - { - powerSpectrum_fx[c] = (Word32) ( powerSpectrum[c] * ( 1 << q_ps ) ); - } - FOR( Word16 c = 0; c < FDNS_NPTS; c++ ) - { - scaleFactors_fx[c] = (Word32) ( hTonalMDCTConc->secondLastBlockData.scaleFactors_float[c] * ( 1 << q_sf ) ); - } - - sns_shape_spectrum_fx( powerSpectrum_fx, &q_ps, psychParamsCurrent, scaleFactors_fx, q_sf, hTonalMDCTConc->nSamplesCore ); - - IF( q_ps + 1 < 31 ) - { - FOR( Word16 c = 0; c < hTonalMDCTConc->nSamplesCore; c++ ) - { - powerSpectrum[c] = ( (float) powerSpectrum_fx[c] / ( 1 << ( q_ps + 1 ) ) ); - } - } - ELSE IF( q_ps + 1 == 31 ) - { - FOR( Word16 c = 0; c < hTonalMDCTConc->nSamplesCore; c++ ) - { - powerSpectrum[c] = ( (float) powerSpectrum_fx[c] / ONE_IN_Q31 ); - } - } -#else sns_shape_spectrum( powerSpectrum, psychParamsCurrent, hTonalMDCTConc->secondLastBlockData.scaleFactors_float, hTonalMDCTConc->nSamplesCore ); -#endif // IVAS_FLOAT_FIXED nBands = psychParamsCurrent->nBands; } @@ -1093,9 +997,9 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( rnd_c = &hStereoMdct->noise_seed_common; /* determine start bin for IGF */ - IF( EQ_16( st->igf, 0 ) ) + IF( st->igf == 0 ) { - IF( EQ_16( st->narrowBand, 0 ) ) + IF( st->narrowBand == 0 ) { /* minimum needed for output with sampling rates lower then the nominal sampling rate */ @@ -1124,6 +1028,7 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( IF( !hTonalMDCTConc->lastBlockData.blockIsConcealed ) { *rnd = add( 1977, idchan ); + move16(); /* will be set twice when looping over two channels, but does not matter */ *rnd_c = 1979; move16(); @@ -1136,6 +1041,7 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( FOR( i = 0; i < max_noise_line; i++ ) { *rnd = own_random( rnd ); + move16(); concealment_noise[i] = *rnd; move32(); } @@ -1176,8 +1082,15 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( last_scf_e = hFdCngCom->cngNoiseLevelExp; move16(); - inc = GT_16( st->core, TCX_20_CORE ) ? 2 : 1; - move32(); + IF( GT_16( st->core, TCX_20_CORE ) ) + { + inc = 2; + } + ELSE + { + inc = 1; + } + move16(); start_idx = idiv1616( hFdCngCom->startBand, inc ); stop_idx = idiv1616( hFdCngCom->stopFFTbin, inc ); @@ -1233,6 +1146,7 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( hTonalMDCTConc->curr_noise_nrg_exp = 0; move16(); *concealment_noise_exp = add( 16, add( noise_shape_buffer_common_exp, c_e ) ); + move16(); temp_e = hTonalMDCTConc->curr_noise_nrg_exp; move16(); @@ -1249,9 +1163,12 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( *rnd = own_random( rnd ); *rnd_c = own_random( rnd_c ); + move16(); + move16(); + concealment_noise[i] = Mpy_32_32( L_add( L_shr( L_mult( c_inv, *rnd ), 1 ), L_shr( L_mult( c, *rnd_c ), 1 ) ), noise_shape_buffer[i] ); move32(); - IF( NE_32( concealment_noise[i], 0 ) ) + IF( concealment_noise[i] != 0 ) { hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, Mpy_32_32( concealment_noise[i], concealment_noise[i] ), shl( *concealment_noise_exp, 1 ), &temp_e ); } @@ -1266,10 +1183,12 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( { *rnd = own_random( rnd ); *rnd_c = own_random( rnd_c ); + move16(); + move16(); concealment_noise[i] = Mpy_32_32( L_add( L_shr( L_mult( c_inv, *rnd ), 1 ), L_shr( L_mult( c, *rnd_c ), 1 ) ), noise_shape_buffer[i] ); move32(); - IF( NE_32( concealment_noise[i], 0 ) ) + IF( concealment_noise[i] != 0 ) { hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, Mpy_32_32( concealment_noise[i], concealment_noise[i] ), shl( *concealment_noise_exp, 1 ), &temp_e ); } @@ -1277,6 +1196,7 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( move16(); *rnd_c = own_random( rnd_c ); + move16(); } } @@ -1507,53 +1427,10 @@ void TonalMdctConceal_whiten_noise_shape_ivas( if ( whitening_mode == ON_FIRST_LOST_FRAME ) { float scf[SNS_NPTS]; - -#ifdef IVAS_FLOAT_FIXED - Word32 scf_fx[SNS_NPTS]; - Word32 whitenend_noise_shape_fx[L_FRAME16k]; - Word32 scfs_int_fx[FDNS_NPTS], scfs_bg_fx[FDNS_NPTS]; - - Word16 q = 31; - FOR( Word16 k = 0; k < L_FRAME16k; k++ ) - { - if ( abs( (Word32) whitenend_noise_shape[k] ) != 0 ) - q = s_min( q, norm_l( (Word32) whitenend_noise_shape[k] ) ); - } - - q -= find_guarded_bits_fx( L_frame ) - 2; - // q -= 1; - - FOR( Word16 k = 0; k < L_FRAME16k; k++ ) - { - whitenend_noise_shape_fx[k] = q >= 0 ? ( (Word32) ( whitenend_noise_shape[k] * ( 1 << q ) ) ) : ( (Word32) ( whitenend_noise_shape[k] / ( 1 << q ) ) ); - } - - sns_compute_scf_fx( whitenend_noise_shape_fx, psychParams, L_frame, scf_fx, q ); - - sns_interpolate_scalefactors_fx( scfs_int_fx, scf_fx, ENC ); - sns_interpolate_scalefactors_fx( scfs_bg_fx, scf_fx, DEC ); - - FOR( Word16 k = 0; k < SNS_NPTS; k++ ) - { - scf[k] = ( (float) scf_fx[k] / ONE_IN_Q16 ); - - scfs_int[k * 4 + 0] = ( (float) scfs_int_fx[k * 4 + 0] / ONE_IN_Q16 ); - scfs_int[k * 4 + 1] = ( (float) scfs_int_fx[k * 4 + 1] / ONE_IN_Q16 ); - scfs_int[k * 4 + 2] = ( (float) scfs_int_fx[k * 4 + 2] / ONE_IN_Q16 ); - scfs_int[k * 4 + 3] = ( (float) scfs_int_fx[k * 4 + 3] / ONE_IN_Q16 ); - - scfs_bg[k * 4 + 0] = ( (float) scfs_bg_fx[k * 4 + 0] / ONE_IN_Q16 ); - scfs_bg[k * 4 + 1] = ( (float) scfs_bg_fx[k * 4 + 1] / ONE_IN_Q16 ); - scfs_bg[k * 4 + 2] = ( (float) scfs_bg_fx[k * 4 + 2] / ONE_IN_Q16 ); - scfs_bg[k * 4 + 3] = ( (float) scfs_bg_fx[k * 4 + 3] / ONE_IN_Q16 ); - } -#else sns_compute_scf( whitenend_noise_shape, psychParams, L_frame, scf ); sns_interpolate_scalefactors( scfs_int, scf, ENC ); sns_interpolate_scalefactors( scfs_bg, scf, DEC ); -#endif // IVAS_FLOAT_FIXED - scfs_for_shaping = &scfs_int[0]; } else /* whitening_mode == ON_FIRST_GOOD_FRAME */ @@ -1563,50 +1440,7 @@ void TonalMdctConceal_whiten_noise_shape_ivas( if ( sum_f( scfs_for_shaping, FDNS_NPTS ) > 0.0f ) { -#ifdef IVAS_FLOAT_FIXED - Word32 whitenend_noise_shape_fx[L_FRAME16k]; - Word32 scfs_for_shaping_fx[FDNS_NPTS]; - Word16 q_wns = 31, q_sfs = 31; - FOR( Word16 k = 0; k < L_FRAME16k; k++ ) - { - if ( abs( (Word32) whitenend_noise_shape[k] ) != 0 ) - q_wns = s_min( q_wns, norm_l( (Word32) whitenend_noise_shape[k] ) ); - } - FOR( Word16 k = 0; k < FDNS_NPTS; k++ ) - { - if ( abs( (Word32) scfs_for_shaping[k] ) != 0 ) - q_sfs = s_min( q_sfs, norm_l( (Word32) scfs_for_shaping[k] ) ); - } - q_wns -= 1; - q_sfs -= 1; - FOR( Word16 k = 0; k < L_FRAME16k; k++ ) - { - whitenend_noise_shape_fx[k] = (Word32) ( whitenend_noise_shape[k] * ( 1 << q_wns ) ); - } - FOR( Word16 k = 0; k < FDNS_NPTS; k++ ) - { - scfs_for_shaping_fx[k] = (Word32) ( scfs_for_shaping[k] * ( 1 << q_sfs ) ); - } - - sns_shape_spectrum_fx( whitenend_noise_shape_fx, &q_wns, psychParams, scfs_for_shaping_fx, q_sfs, L_frame ); - - IF( q_wns + 1 < 31 ) - { - FOR( Word16 k = 0; k < L_FRAME16k; k++ ) - { - whitenend_noise_shape[k] = ( (float) whitenend_noise_shape_fx[k] / ( 1 << ( q_wns + 1 ) ) ); - } - } - ELSE IF( q_wns + 1 == 31 ) - { - FOR( Word16 k = 0; k < L_FRAME16k; k++ ) - { - whitenend_noise_shape[k] = ( (float) whitenend_noise_shape_fx[k] / ONE_IN_Q31 ); - } - } -#else sns_shape_spectrum( whitenend_noise_shape, psychParams, scfs_for_shaping, L_frame ); -#endif // IVAS_FLOAT_FIXED mvr2r( whitenend_noise_shape + start_idx, hFdCngCom->cngNoiseLevel_flt, stop_idx - start_idx ); } else @@ -1694,13 +1528,13 @@ void TonalMdctConceal_whiten_noise_shape_ivas_fx( scfs_for_shaping = &scfs_bg[0]; } - IF( GT_32( sum32_sat( scfs_for_shaping, FDNS_NPTS ), 0 ) ) + IF( sum32_sat( scfs_for_shaping, FDNS_NPTS ) > 0 ) { q_wns = sub( 31, noiseLevelPtr_exp ); sns_shape_spectrum_fx( whitenend_noise_shape, &q_wns, psychParams, scfs_for_shaping, Q16, L_frame, NULL ); Copy32( whitenend_noise_shape + start_idx, hFdCngCom->cngNoiseLevel, sub( stop_idx, start_idx ) ); - hFdCngCom->cngNoiseLevelExp = sub( 30, q_wns ); + hFdCngCom->cngNoiseLevelExp = sub( Q30, q_wns ); } ELSE { diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index ec4e4abe79cd3794967edbfadd3960146e8d72db..7203bf992703a59aebbe4cd11e7cb4291803f3ab 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -497,8 +497,10 @@ void TonalMDCTConceal_SaveFreqSignal_ivas_fx( Word16 tmp = extract_h( mdctSpectrum[i] ); hTonalMDCTConc->last_block_nrg = L_add( hTonalMDCTConc->last_block_nrg, L_shr( L_mult0( tmp, tmp ), 16 ) ); + move32(); } hTonalMDCTConc->last_block_nrg_exp = sub( 31, sub( shl( sub( 15, mdctSpectrum_exp ), 1 ), 16 ) ); + move16(); /* Store new data */ s = getScaleFactor32( mdctSpectrum, nNewSamples ); @@ -732,6 +734,7 @@ static void FindPhaseDifferences( /* o L_tmp = L_sub( L_tmp, 421657440l /*+3*EVS_PI=-1*EVS_PI Q27*/ ); } phaseDiff[i] = round_fx( L_shl( L_tmp, 1 ) ); /*3Q12*/ + move16(); } } } @@ -1228,6 +1231,9 @@ void TonalMDCTConceal_Detect_ivas_fx( Word16 element_mode ) { Word32 secondLastMDST[L_FRAME_MAX]; +#ifdef MSAN_FIX + set32_fx( secondLastMDST, 0, L_FRAME_MAX ); +#endif Word32 secondLastMDCT[L_FRAME_MAX]; Word16 secondLastMDCT_exp; Word32 *powerSpectrum = secondLastMDST; @@ -1235,6 +1241,9 @@ void TonalMDCTConceal_Detect_ivas_fx( Word16 nSamples; // Word16 nBands; Word32 sns_int_scf_fx[FDNS_NPTS]; +#ifdef MSAN_FIX + set32_fx( sns_int_scf_fx, 0, FDNS_NPTS ); +#endif nSamples = hTonalMDCTConc->nSamples; move16(); @@ -1308,7 +1317,11 @@ void TonalMDCTConceal_Detect_ivas_fx( } ELSE { +#ifdef MSAN_FIX + Word16 power_spectrum_q = 0; +#else Word16 power_spectrum_q; +#endif FOR( i = 0; i < FDNS_NPTS; i++ ) { sns_int_scf_fx[i] = L_shl( hTonalMDCTConc->secondLastBlockData.scaleFactors[i], add( 1, hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i] ) ); // Q16 @@ -1406,6 +1419,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( /* based on what is done in tcx_noise_filling() */ /* always initialize these to avoid compiler warnings */ hTonalMDCTConc->faded_signal_nrg = L_deposit_h( 0 ); + move32(); L_tmp = 805306368l /*0.375f Q31*/; move32(); @@ -1445,7 +1459,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( { FOR( i = 0; i < crossOverFreq; i++ ) { - IF( GT_32( concealment_noise[i], 0 ) ) + IF( concealment_noise[i] > 0 ) { mdctSpectrum[i] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[i] ), 16 ); move32(); @@ -1500,7 +1514,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( (void) maximum_abs_32_fx( concealment_noise, crossOverFreq, &max_concealment_value ); IF( GT_32( max_concealment_value, 0 ) ) { - IF( GT_16( exp, 0 ) ) + IF( exp > 0 ) { g = shr( g, exp ); *mdctSpectrum_exp = hTonalMDCTConc->lastBlockData.spectralData_exp; @@ -1515,7 +1529,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( /*make a headroom for mdct_shaping*/ exp = sub( *mdctSpectrum_exp, SPEC_EXP_DEC ); /* assert(exp < 0);*/ - IF( LT_16( exp, 0 ) ) + IF( exp < 0 ) { *mdctSpectrum_exp = SPEC_EXP_DEC; move16(); @@ -1541,13 +1555,13 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( Word32 y = concealment_noise[i]; move32(); - IF( GT_16( g, 0 ) ) + IF( g > 0 ) { L_tmp = Mpy_32_16_1( y, g ); } L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); - IF( GT_32( y, 0 ) ) + IF( y > 0 ) { L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); } @@ -1594,6 +1608,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( last_block_nrg_correct = L_add( last_block_nrg_correct, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // exp = 2 * x_exp + ld y = L_negate( Mpy_32_32( y, y ) ); hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, y, 2 * concealment_noise_e, &hTonalMDCTConc->curr_noise_nrg_exp ); + move32(); } } } @@ -1619,7 +1634,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( { FOR( l = hTonalMDCTConc->pTCI->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI->lowerIndex[i]; l++ ) { - IF( GT_32( concealment_noise[l], 0 ) ) + IF( concealment_noise[l] > 0 ) { mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ); move32(); @@ -1634,7 +1649,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( FOR( l = hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1] + 1; l < crossOverFreq; l++ ) { - IF( GT_32( concealment_noise[l], 0 ) ) + IF( concealment_noise[l] > 0 ) { mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ); move32(); @@ -1705,7 +1720,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( /*make a headroom for mdct_shaping*/ exp = sub( *mdctSpectrum_exp, SPEC_EXP_DEC ); /* assert(exp < 0);*/ - IF( LT_16( exp, 0 ) ) + IF( exp < 0 ) { *mdctSpectrum_exp = SPEC_EXP_DEC; move16(); @@ -1731,13 +1746,13 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( Word32 y = concealment_noise[l]; move32(); - IF( GT_16( g, 0 ) ) + IF( g > 0 ) { L_tmp = Mpy_32_16_1( y, g ); } L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); - IF( GT_32( y, 0 ) ) + IF( y > 0 ) { L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); } @@ -1745,6 +1760,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( move32(); hTonalMDCTConc->faded_signal_nrg = L_add( hTonalMDCTConc->faded_signal_nrg, Mpy_32_32( mdctSpectrum[l], mdctSpectrum[l] ) ); + move32(); } FOR( i = 1; i < hTonalMDCTConc->pTCI->numIndexes; i++ ) @@ -1758,7 +1774,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( L_tmp = Mpy_32_16_1( y, g ); L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); - IF( GT_32( y, 0 ) ) + IF( y > 0 ) { L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); } @@ -1778,7 +1794,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( L_tmp = Mpy_32_16_1( y, g ); L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); - IF( GT_32( y, 0 ) ) + IF( y > 0 ) { L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); } @@ -1786,6 +1802,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( move32(); hTonalMDCTConc->faded_signal_nrg = L_add( hTonalMDCTConc->faded_signal_nrg, Mpy_32_32( mdctSpectrum[l], mdctSpectrum[l] ) ); + move32(); } FOR( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ ) @@ -1795,6 +1812,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( } hTonalMDCTConc->faded_signal_nrg_exp = shl( *mdctSpectrum_exp, 1 ); + move16(); } } diff --git a/lib_dec/transition_dec_fx.c b/lib_dec/transition_dec_fx.c index 4ebfeaf88045dfb41ea2a846926a86a6d4c0c273..73342e64cbf6fae43e4e861709d9b7ec5705a6f1 100644 --- a/lib_dec/transition_dec_fx.c +++ b/lib_dec/transition_dec_fx.c @@ -8,6 +8,7 @@ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" +#ifdef IVAS_FLOAT_FIXED /*----------------------------------------------------------------------* * Local function prototypes *----------------------------------------------------------------------*/ @@ -909,3 +910,5 @@ Word16 tc_classif_fx( return ( tc_subfr ); } + +#endif diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index 1518fa50c0ec4dd87335395a2ab41360a09d23e8..519f50a2ed9bdccab3bc210d6eea2c6a87cf5c18 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -9,6 +9,7 @@ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ +#ifdef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * updt_dec() * @@ -17,14 +18,14 @@ void updt_dec_fx( Decoder_State *st_fx, /* i/o: state structure */ const Word16 *old_exc_fx, /* i : buffer of excitation */ - const Word16 *pitch_buf_fx, /* i : floating pitch values for each subframe */ + const Word16 *pitch_buf_fx, /* i : fixed point pitch values for each subframe */ const Word16 Es_pred, /* i : predicited scaled innovation energy */ const Word16 *Aq, /* i : A(z) quantized for all subframes */ const Word16 *lsf_new_fx, /* i : current frame LSF vector */ const Word16 *lsp_new_fx, /* i : current frame LSP vector */ const Word16 voice_factors[], /* i : voicing factors */ const Word16 *old_bwe_exc_fx, /* i : buffer of excitation */ - const Word16 *gain_buf /* i : floating pitch gain for each subframe Q14*/ + const Word16 *gain_buf /* i : fixed point pitch gain for each subframe Q14*/ ) { Word16 i, len; @@ -395,7 +396,7 @@ void updt_IO_switch_dec_fx( void updt_bw_switching_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *synth, /* i : float synthesis signal */ + const Word16 *synth, /* i : fixed point synthesis signal */ const Word16 Qpost ) { test(); @@ -770,7 +771,7 @@ void updt_dec_common_fx( #ifdef IVAS_FLOAT_FIXED static void ivas_updt_bw_switching_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 *synth, /* i : float synthesis signal */ + const Word32 *synth, /* i : fixed point synthesis signal */ const Word16 Qpost ) { test(); @@ -1387,3 +1388,4 @@ void update_decoder_LPD_cng( return; } +#endif diff --git a/lib_dec/vlpc_1st_dec_fx.c b/lib_dec/vlpc_1st_dec_fx.c index 1ba7a64d0f188dd92a9a52d528506ac041d2fb1a..ad2c3fc2cf423d14615050ab18ee208902c26ddd 100644 --- a/lib_dec/vlpc_1st_dec_fx.c +++ b/lib_dec/vlpc_1st_dec_fx.c @@ -8,7 +8,7 @@ #include "prot_fx.h" #include "rom_com.h" - +#ifdef IVAS_FLOAT_FIXED void vlpc_1st_dec( Word16 index, /* input: codebook index */ Word16 *lsfq ) /* i/o: i:prediction o:quantized lsf */ @@ -26,3 +26,4 @@ void vlpc_1st_dec( p_dico++; } } +#endif diff --git a/lib_dec/vlpc_2st_dec_fx.c b/lib_dec/vlpc_2st_dec_fx.c index 3aa39e86aa543aa8b5302c1d328a7f3c02912800..6aacd0974d56211f85e72446a2d189fb64c885d6 100644 --- a/lib_dec/vlpc_2st_dec_fx.c +++ b/lib_dec/vlpc_2st_dec_fx.c @@ -10,6 +10,7 @@ #include //#endif +#ifdef IVAS_FLOAT_FIXED void vlpc_2st_dec( Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage */ Word16 *indx, /* i : index[] (4 bits per words) */ @@ -72,3 +73,4 @@ void vlpc_2st_dec( return; } +#endif diff --git a/lib_dec/voiced_dec_fx.c b/lib_dec/voiced_dec_fx.c index a0f47e75bec4e8aeb48a030c5cb6ee0555e34069..761f904ea572818cd3969a69e599cf800b4607f7 100644 --- a/lib_dec/voiced_dec_fx.c +++ b/lib_dec/voiced_dec_fx.c @@ -8,44 +8,45 @@ #include "rom_com.h" #include "log2.h" +#ifdef IVAS_FLOAT_FIXED /*===================================================================*/ -/* FUNCTION : void ppp_voiced_decoder_fx () */ +/* FUNCTION : void ppp_voiced_decoder_fx () */ /*-------------------------------------------------------------------*/ -/* PURPOSE : */ +/* PURPOSE : */ /*-------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* _ Word16 bfi_fx - Q0 bad frame indicator */ -/* _ const Word16 *lpc2_fx - Q12 current frame LPC */ -/* _ Word16 *exc_fx - Q0 previous frame excitation */ +/* _ Word16 bfi_fx - Q0 bad frame indicator */ +/* _ const Word16 *lpc2_fx - Q12 current frame LPC */ +/* _ Word16 *exc_fx - Q0 previous frame excitation */ /*-------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ -/* _ Decoder_State *st_fx: */ +/* _ Decoder_State *st_fx: */ /* _ lastLgainD_fx - Q11 */ /* _ lastHgainD_fx - Q11 */ /* _ lasterbD_fx - Q13 */ -/* _ Word16 *pitch - Q6 floating pitch values for each subframe */ -/* _ Word16 *out_fx - Q0 residual signal */ +/* _ Word16 *pitch - Q6 fixed pitch values for each subframe */ +/* _ Word16 *out_fx - Q0 residual signal */ /*-------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ -/* _ Decoder_State *st_fx: */ -/* _ lsp_old_fx - Q15 */ -/* _ st_fx->dtfs_dec_xxxx */ -/* _ a nd b in st_fx->dtfs_dec_Q */ -/* rest all in Q0 */ +/* _ Decoder_State *st_fx: */ +/* _ lsp_old_fx - Q15 */ +/* _ st_fx->dtfs_dec_xxxx */ +/* _ a nd b in st_fx->dtfs_dec_Q */ +/* rest all in Q0 */ /* _ gainp_ppp Q14 */ -/* _ Word16 *pitch_buf_fx - Q6 fixed pitch values for each subframe */ +/* _ Word16 *pitch_buf_fx - Q6 fixed pitch values for each subframe */ /*-------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ -/* _ None */ +/* _ None */ /*-------------------------------------------------------------------*/ -/* CALLED FROM : RX */ +/* CALLED FROM : RX */ /*===================================================================*/ ivas_error ppp_voiced_decoder_fx( Decoder_State *st_fx, /* i/o: state structure */ Word16 *out_fx, /* o : residual signal */ const Word16 *lpc2_fx, /* i : current frame LPC */ Word16 *exc_fx, /* i : previous frame excitation */ - Word16 *pitch, /* o : floating pitch values for each subframe */ + Word16 *pitch, /* o : fixed point pitch values for each subframe */ Word16 bfi /* i : Frame error rate */ ) { @@ -246,6 +247,7 @@ ivas_error ppp_voiced_decoder_fx( #ifdef BASOP_NOGLOB Ltemp = L_add_sat( L_sub_sat( Ltemp, Ltemp_q ), logLag ); /* Ltemp=10*log10(lag*eng), Q23 */ hSC_VBR->lastLgainD_fx = round_fx_sat( L_shl_sat( (Word32) Mpy_32_16( extract_h( Ltemp ), extract_l( Ltemp ), 0x6666 ), 1 ) ); /* Q11 */ + move16(); #else Ltemp = L_add( L_sub( Ltemp, Ltemp_q ), logLag ); /* Ltemp=10*log10(lag*eng), Q23 */ hSC_VBR->lastLgainD_fx = round_fx( L_shl( (Word32) Mpy_32_16( extract_h( Ltemp ), extract_l( Ltemp ), 0x6666 ), 1 ) ); /* Q11 */ @@ -260,6 +262,7 @@ ivas_error ppp_voiced_decoder_fx( #ifdef BASOP_NOGLOB Ltemp = L_add_sat( L_sub_sat( Ltemp, Ltemp_q ), logLag ); /* Ltemp=10*log10(lag*eng), Q23 */ hSC_VBR->lastHgainD_fx = round_fx_sat( L_shl_sat( (Word32) Mpy_32_16( extract_h( Ltemp ), extract_l( Ltemp ), 0x6666 ), 1 ) ); /* Q11 */ + move16(); #else Ltemp = L_add( L_sub( Ltemp, Ltemp_q ), logLag ); /* Ltemp=10*log10(lag*eng), Q23 */ hSC_VBR->lastHgainD_fx = round_fx( L_shl( (Word32) Mpy_32_16( extract_h( Ltemp ), extract_l( Ltemp ), 0x6666 ), 1 ) ); /* Q11 */ @@ -319,7 +322,7 @@ ivas_error ppp_voiced_decoder_fx( upper_cut_off_freq = (Word16) find_remd( Ltemp, 20971, &rem32 ); /*denormalize upper_cut_off_freq */ - /* temp32_fx = (Word32)divide_dp((Word40)819200,(Word40)L_shl((Word32)CURRP_Q_D_FX->lag_fx,6),-23,1);//Q6 */ + /* temp32_fx = (Word32)divide_dp((Word40)819200,(Word40)L_shl((Word32)CURRP_Q_D_FX->lag_fx,6),-23,1);//Q6 */ exp = norm_s( CURRP_Q_D_FX->lag_fx ); tmp = div_s( shl( 1, sub( 14, exp ) ), CURRP_Q_D_FX->lag_fx ); /*29-exp */ #ifdef BASOP_NOGLOB @@ -332,17 +335,20 @@ ivas_error ppp_voiced_decoder_fx( diff = round_fx( L_shl( temp32_fx, 16 - 6 ) ); /*Q0 */ CURRP_Q_D_FX->nH_fx = find_rem( upper_cut_off_freq, diff, &rem_fx ); /*Q0 */ + move16(); exp = norm_s( diff ); tmp = div_s( shl( 1, sub( 14, exp ) ), diff ); /*29-exp */ L_tmp = L_shl( L_mult0( 4000, tmp ), sub( exp, 7 ) ); tempnH_fx = extract_h( L_tmp ); CURRP_Q_D_FX->nH_4kHz_fx = round_fx( L_shl( tempnH_fx, 16 - 6 ) ); /*Q0 */ + move16(); IF( GE_16( sub( upper_cut_off_freq, shr( (Word16) L_mult( diff, CURRP_Q_D_FX->nH_fx ), 1 ) ), diff ) ) { CURRP_Q_D_FX->nH_fx = add( CURRP_Q_D_FX->nH_fx, 1 ); + move16(); } tempnH_fx = L_mult0( extract_l( temp32_fx ), CURRP_Q_D_FX->nH_4kHz_fx ); /* */ tempnH_fx = L_sub( (Word32) 256000, tempnH_fx ); /*Q6 */ @@ -350,6 +356,7 @@ ivas_error ppp_voiced_decoder_fx( if ( GE_32( tempnH_fx, temp32_fx ) ) { CURRP_Q_D_FX->nH_4kHz_fx = add( CURRP_Q_D_FX->nH_4kHz_fx, 1 ); + move16(); } CURRP_Q_D_FX->upper_cut_off_freq_fx = dtfs_temp_fx->upper_cut_off_freq_fx; @@ -445,3 +452,5 @@ void sc_vbr_dec_init( return; } + +#endif diff --git a/lib_dec/waveadjust_fec_dec_fx.c b/lib_dec/waveadjust_fec_dec_fx.c index 083c7854cc7fa7948d7042a7638537b455d7c99d..b090b22e5ff2df4015fe63c4f713baaf89e3f34b 100644 --- a/lib_dec/waveadjust_fec_dec_fx.c +++ b/lib_dec/waveadjust_fec_dec_fx.c @@ -13,6 +13,7 @@ #include "stl.h" /* FOR wmc_tool */ #include "vad_basop.h" +#ifdef IVAS_FLOAT_FIXED void get_maxConv_and_pitch_x( Word16 *s_LP, Word16 s, Word16 e, Word16 N, Word32 *maxConv, Word16 *maxConv_bits, Word16 *pitch ); Word16 get_voicing_x( Word16 *s_LP, Word16 pitch, Word32 covMax, Word16 maxConv_bits, Word16 Framesize ); Word32 con_Log10( Word32 i_s32Val, Word16 i_s16Q ); @@ -1716,3 +1717,4 @@ void concealment_signal_tuning_fx( Word16 bfi, Word16 curr_mode, Word16 *outx_ne } return; } +#endif diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index b87a0fe8a8397c7cac2e8b34d6171173fa99aaaf..e2757647a14c224fbc9f01bad11a10862555d83c 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -332,6 +332,9 @@ ivas_error ivas_mct_enc( #if 1 // float initialization to be removed hMCT->p_mdst_spectrum_long[cpe_id][n] = mdst_spectrum_long[cpe_id][n]; hMCT->p_orig_spectrum_long[cpe_id][n] = orig_spectrum_long[cpe_id][n]; +#ifdef MSAN_FIX + set_zero( mdst_spectrum_long[cpe_id][n], L_FRAME48k ); +#endif #endif hMCT->p_mdst_spectrum_long_fx[cpe_id][n] = mdst_spectrum_long_fx[cpe_id][n]; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index bfa3ccf239a5420eb33d37542858d5a68f90a325..e5d53b757149a412987c4e39517b874fb8784b2d 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -4363,16 +4363,6 @@ static void adaptTransportSignalsHeadtracked_fx( { FOR( bin = bin_lo; bin < bin_hi; bin++ ) { - test(); - IF( ( ch == 0 && slot == 0 ) ) - { - if ( EQ_16( bin, 1 ) ) - { - bin = bin; - move16(); - } - } - Word16 temp_shift = s_min( norm_l( inRe_fx[ch][slot][bin] ), norm_l( inIm_fx[ch][slot][bin] ) ); re = L_shl( inRe_fx[ch][slot][bin], temp_shift ); img = L_shl( inIm_fx[ch][slot][bin], temp_shift ); diff --git a/lib_util/ism_file_writer.c b/lib_util/ism_file_writer.c index ac838bb4f5eceb46e5c945eb4366ae294636d1f4..f9c2bbe3472a9b9c16999113245b9439b3361709 100644 --- a/lib_util/ism_file_writer.c +++ b/lib_util/ism_file_writer.c @@ -34,6 +34,9 @@ #include #include +#ifdef IVAS_FLOAT_FIXED +#include "prot_fx.h" +#endif #define META_LINE_LENGTH 200 /* max number of characters at one line of metadata input/output file */ @@ -98,9 +101,10 @@ ivas_error IsmFileWriter_open( *---------------------------------------------------------------------*/ /*! r: error code */ +#ifdef IVAS_FLOAT_FIXED ivas_error IsmFileWriter_writeFrame( - const IVAS_ISM_METADATA ismMetadata, /* i : decoded ISM metadata */ - IsmFileWriter *ismWriter /* o : IsmFileReader handle */ + IVAS_ISM_METADATA ismMetadata, /* i : decoded ISM metadata */ + IsmFileWriter *ismWriter /* o : IsmFileReader handle */ ) { char char_buff[META_LINE_LENGTH]; @@ -113,6 +117,16 @@ ivas_error IsmFileWriter_writeFrame( file = ismWriter->file; +#ifdef IVAS_FLOAT_FIXED + ismMetadata.azimuth = fixedToFloat( ismMetadata.azimuth_fx, Q22 ); + ismMetadata.elevation = fixedToFloat( ismMetadata.elevation_fx, Q22 ); + ismMetadata.radius = fix16_to_float( ismMetadata.radius_fx, Q9 ); + ismMetadata.spread = fixedToFloat( ismMetadata.spread_fx, Q22 ); + ismMetadata.gainFactor = fixedToFloat( ismMetadata.gainFactor_fx, Q31 ); + ismMetadata.yaw = fixedToFloat( ismMetadata.yaw_fx, Q22 ); + ismMetadata.pitch = fixedToFloat( ismMetadata.pitch_fx, Q22 ); +#endif + snprintf( char_buff, sizeof( char_buff ), "%+07.2f,%+06.2f,%05.2f,%06.2f,%04.2f,%+07.2f,%+06.2f,%d\n", ismMetadata.azimuth, ismMetadata.elevation, ismMetadata.radius, ismMetadata.spread, ismMetadata.gainFactor, ismMetadata.yaw, ismMetadata.pitch, ismMetadata.non_diegetic_flag ); if ( file ) { @@ -125,7 +139,35 @@ ivas_error IsmFileWriter_writeFrame( return IVAS_ERR_OK; } +#else +ivas_error IsmFileWriter_writeFrame( + IVAS_ISM_METADATA ismMetadata, /* i : decoded ISM metadata */ + IsmFileWriter *ismWriter /* o : IsmFileReader handle */ +) +{ + char char_buff[META_LINE_LENGTH]; + FILE *file; + + if ( ismWriter->file == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + file = ismWriter->file; + snprintf( char_buff, sizeof( char_buff ), "%+07.2f,%+06.2f,%05.2f,%06.2f,%04.2f,%+07.2f,%+06.2f,%d\n", ismMetadata.azimuth, ismMetadata.elevation, ismMetadata.radius, ismMetadata.spread, ismMetadata.gainFactor, ismMetadata.yaw, ismMetadata.pitch, ismMetadata.non_diegetic_flag ); + if ( file ) + { + fputs( char_buff, file ); + } + else + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + + return IVAS_ERR_OK; +} +#endif /*---------------------------------------------------------------------* * IsmFileWriter_close() diff --git a/lib_util/ism_file_writer.h b/lib_util/ism_file_writer.h index b4faa45988e08abdcfc68638e1e35cfad0bb2ab8..88b8b2ff0c0ea1c276f336588bcbdb410abbd890 100644 --- a/lib_util/ism_file_writer.h +++ b/lib_util/ism_file_writer.h @@ -48,10 +48,17 @@ ivas_error IsmFileWriter_open( ); /*! r: error code */ +#ifdef IVAS_FLOAT_FIXED +ivas_error IsmFileWriter_writeFrame( + IVAS_ISM_METADATA ismMetadata, /* i : decoded ISM metadata */ + IsmFileWriter *ismWriter /* o : IsmFileWriter handle */ +); +#else ivas_error IsmFileWriter_writeFrame( const IVAS_ISM_METADATA ismMetadata, /* i : decoded ISM metadata */ IsmFileWriter *ismWriter /* o : IsmFileWriter handle */ ); +#endif void IsmFileWriter_close( IsmFileWriter **ismWriter /* i/o: pointer to IsmFileWriter handle */