diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 91f723c35271b5acd4b3b212c4b0c65626fc3d9a..043e4ef677a32d58af9f9d394e74fab23f60b0e0 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5886,11 +5886,18 @@ void ivas_spar_get_cldfb_gains( ); /*! r: 1 if prediction residual channel */ +#ifndef IVAS_FLOAT_FIXED int16_t ivas_is_res_channel( const int16_t ch, /* i : ch index in WYZX ordering */ const int16_t nchan_transport /* i : number of transport channels (1-4) */ ); +#else +Word16 ivas_is_res_channel( + const Word16 ch, /* i : ch index in WYZX ordering */ + const Word16 nchan_transport /* i : number of transport channels (1-4) */ +); +#endif void ivas_spar_dec_agc_pca( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float *output[], /* i/o: input/output audio channels */ @@ -6758,6 +6765,14 @@ void ivas_map_prior_coeffs_quant( const int16_t nB ); +#ifdef IVAS_FLOAT_FIXED +void ivas_copy_band_coeffs_idx_to_arr( + ivas_band_coeffs_ind_t *pBands_idx, + const Word16 nB, + Word16 *pSymbol_re, + ivas_cell_dim_t *pCell_dims, + const ivas_coeffs_type_t coeff_type); +#else void ivas_copy_band_coeffs_idx_to_arr( ivas_band_coeffs_ind_t *pBands_idx, const int16_t nB, @@ -6765,6 +6780,7 @@ void ivas_copy_band_coeffs_idx_to_arr( ivas_cell_dim_t *pCell_dims, const ivas_coeffs_type_t coeff_type ); +#endif void ivas_clear_band_coeffs( ivas_band_coeffs_t *pband_coeffs, diff --git a/lib_com/ivas_spar_com_quant_util.c b/lib_com/ivas_spar_com_quant_util.c index a40f8c2acbd84c92ef2dd4d581b74109af695500..5f14acfe7d0dd4660cc31fb83905a82541ba2d4f 100644 --- a/lib_com/ivas_spar_com_quant_util.c +++ b/lib_com/ivas_spar_com_quant_util.c @@ -485,6 +485,54 @@ void ivas_spar_quant_dtx_init_fx( * Copy pred band coeffs to arr *-----------------------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void ivas_copy_band_coeffs_idx_to_arr( + ivas_band_coeffs_ind_t *pBands_idx, + const Word16 nB, + Word16 *pSymbol_re, + ivas_cell_dim_t *pCell_dims, + const ivas_coeffs_type_t coeff_type ) +{ + Word16 i, len; + Word16 *pPtr_idx = NULL; + + FOR( i = 0; i < nB; i++ ) + { + SWITCH( coeff_type ) + { + case PRED_COEFF: + { + pPtr_idx = pBands_idx[i].pred_index_re; + BREAK; + } + case DRCT_COEFF: + { + pPtr_idx = pBands_idx[i].drct_index_re; + BREAK; + } + case DECD_COEFF: + { + pPtr_idx = pBands_idx[i].decd_index_re; + BREAK; + } + case DECX_COEFF: + { + BREAK; + } + } + len = imult1616( pCell_dims[i].dim1, pCell_dims[i].dim2 ); + IF( NE_16( coeff_type, DECX_COEFF ) ) + { + Copy( pPtr_idx, pSymbol_re, len ); + pSymbol_re += len; + } + } + + + return; +} + +#else void ivas_copy_band_coeffs_idx_to_arr( ivas_band_coeffs_ind_t *pBands_idx, const int16_t nB, @@ -530,6 +578,7 @@ void ivas_copy_band_coeffs_idx_to_arr( return; } +#endif /*-----------------------------------------------------------------------------------------* diff --git a/lib_com/prot.h b/lib_com/prot.h index 66bb6a966e9cfb51417e288bf7df08256f9fc961..4e542b2fae2139cc8e19cdbf1cd4dded1622ef54 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -7807,6 +7807,7 @@ int16_t ari_done_cbr_encoding_14bits( int32_t bits, Tastat *s ); +#ifndef IVAS_FLOAT_FIXED int16_t ari_decode_14bits_pow_ivas( const int16_t *ptr, int16_t bp, @@ -7821,6 +7822,7 @@ int16_t ari_decode_14bits_sign_ivas( int16_t bits, uint16_t *res, Tastat *s ); +#endif // !IVAS_FLOAT_FIXED void tcx_arith_encode_envelope( float spectrum[], /* i/o: MDCT coefficients */ @@ -7863,7 +7865,7 @@ void tcx_arith_decode_envelope_ivas_fx( Word16 L_spec, /* i : length w/o BW limitation */ const Word16 A_ind[], /* i : quantised LPC coefficients */ const Word16 target_bits, /* i : number of available bits */ - const Word16 prm[], /* i : bitstream parameters */ + Word16 prm[], /* i : bitstream parameters */ const Word16 use_hm, /* i : use HM in current frame? */ const Word16 prm_hm[], /* i : HM parameter area */ Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index bbad9c4dcfeb1ec682d69695ad9c28fa31670a59..18a949cfd36cf8ea55b58310167539cba8dc404e 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10182,4 +10182,17 @@ void hq_generic_hf_encoding_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ Word16 *hq_generic_exc_clas, /* o : bwe excitation class */ Word16 length ); +Word16 ari_decode_14bits_pow_ivas( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s, + UWord16 base ); +Word16 ari_decode_14bits_sign_ivas( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s ); #endif diff --git a/lib_dec/ACcontextMapping_dec_fx.c b/lib_dec/ACcontextMapping_dec_fx.c index 92dddd54fa1de4e115fddb27348f923624e3fe52..89a7e1890f55c31ed324af8bbff5a60afc212bd1 100644 --- a/lib_dec/ACcontextMapping_dec_fx.c +++ b/lib_dec/ACcontextMapping_dec_fx.c @@ -114,6 +114,8 @@ Word16 ACcontextMapping_decode2_no_mem_s17_LC( ii[1] = 0; move16(); p1 = p2 = 0; /* to avoid compilation warnings */ + move16(); + move16(); get_next_coeff = get_next_coeff_mapped; move16(); @@ -153,7 +155,6 @@ Word16 ACcontextMapping_decode2_no_mem_s17_LC( /* Get context */ ctx = &c[s_or( p1, p2 )]; - move16(); t = add( *ctx, rateFlag ); IF( GT_16( idx, nt_half ) ) @@ -163,7 +164,7 @@ Word16 ACcontextMapping_decode2_no_mem_s17_LC( test(); /* BER detection: Check max value of context t leading to out-of-bound access to ari_lookup_s17_LC[]*/ - IF( GE_16( t, ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ) ) || LE_16( lsbs_bit_pos, 0 ) ) + IF( GE_16( t, ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ) ) || lsbs_bit_pos <= 0 ) { st->BER_detect = 1; move16(); @@ -368,13 +369,13 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( /*Decode number of ntuples*/ start_bit_pos = st->next_bit_pos; + move16(); lsbs_bit_pos = add( start_bit_pos, sub( nbbits, 1 ) ); n = 0; move16(); k = 1; move16(); nt_half = shr( nt, 1 ); - move16(); WHILE( LT_16( k, nt_half ) ) { n = add( n, 1 ); @@ -409,6 +410,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( IF( GT_16( nbbits, 400 ) ) { rateFlag = 2 << NBITS_CONTEXT; + move16(); } ELSE { @@ -424,6 +426,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( numPeakIndicesOrig = hm_cfg->numPeakIndices; move16(); hm_cfg->numPeakIndices = s_min( hm_cfg->numPeakIndices, lastnz ); + move16(); numHoleIndices = sub( lastnz, hm_cfg->numPeakIndices ); /* Mark hole indices beyond lastnz as pruned */ @@ -472,6 +475,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( IF( ( GE_16( t, ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ) ) ) || ( lsbs_bit_pos <= 0 ) ) { st->BER_detect = 1; + move16(); return 0; } @@ -483,6 +487,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( { esc_nb = s_min( lev, 3 ); pki = ari_lookup_s17_LC[add( t, Tab_esc_nb[esc_nb] )]; + move16(); r = rc_uni_dec_read_symbol_fastS_fx( &rc_st_dec, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 17, 14 ); /*Alphabet size = 17 (2^4 = 16 MSB symbols + 1 ESC symbol) */ /* r is the symbol read, the possible values are {0,1,....alphabet_size - 1} */ @@ -522,6 +527,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( /* Update bitstream pointer */ st->next_bit_pos = add( start_bit_pos, add( bits_tups, rc_uni_dec_virtual_finish_fx( &rc_st_dec ) ) ); + move16(); /* Confirm that there is no overflow */ #ifdef DEBUGGING @@ -549,6 +555,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( } *ctx = add( shl( s_and( *ctx, 0xf ), 4 ), t ); + move16(); } ELSE { @@ -561,7 +568,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( move16(); } - IF( idx2 & 1 ) + IF( s_and( idx2, 1 ) ) { /* update second context */ c[p2] = update_mixed_context( c[p2], b ); @@ -629,6 +636,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( a = b = 0; move16(); + move16(); esc_nb = 0; move16(); r = 0; @@ -638,6 +646,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( { esc_nb = s_min( lev, 3 ); pki = ari_lookup_s17_LC[add( t, add( shl( ( rateQ ), NBITS_CONTEXT ), Tab_esc_nb[esc_nb] ) )]; + move16(); r = rc_uni_dec_read_symbol_fastS_fx( &rc_st_dec, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 17, 14 ); /*Alphabet size = 17 (2^4 = 16 MSB symbols + 1 ESC symbol) */ /* r is the symbol read, the possible values are {0,1,....alphabet_size - 1} */ @@ -677,6 +686,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( /* Update bitstream pointer */ st->next_bit_pos = add( start_bit_pos, add( bits_tups, rc_uni_dec_virtual_finish_fx( &rc_st_dec ) ) ); + move16(); /* Confirm that there is no overflow */ #ifdef DEBUGGING diff --git a/lib_dec/FEC_HQ_core.c b/lib_dec/FEC_HQ_core.c index 5dd3351aace8647f9f7e9a86153354ef4d89727d..07f7d794e5994d84d6f9283a6e8150af21f17943 100644 --- a/lib_dec/FEC_HQ_core.c +++ b/lib_dec/FEC_HQ_core.c @@ -1549,17 +1549,17 @@ void save_synthesis_hq_fec_fx( SWITCH( st->element_mode ) { case EVS_MONO: - post_hq_delay = NS2SA( st->output_Fs, POST_HQ_DELAY_NS ); + post_hq_delay = NS2SA_FX2( st->output_Fs, POST_HQ_DELAY_NS ); move16(); BREAK; case IVAS_SCE: - post_hq_delay = NS2SA( st->output_Fs, DELAY_CLDFB_NS ); + post_hq_delay = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); move16(); BREAK; case IVAS_CPE_DFT: IF( EQ_16( hCPE->nchan_out, 1 ) && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) { - post_hq_delay = NS2SA( st->output_Fs, DELAY_CLDFB_NS ); + post_hq_delay = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); move16(); } ELSE @@ -1581,7 +1581,7 @@ void save_synthesis_hq_fec_fx( test(); IF( ( EQ_16( st->codec_mode, MODE1 ) && st->hTcxDec != NULL ) && ( ( EQ_16( st->core, ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) || EQ_16( st->core, HQ_CORE ) ) ) { - Copy( st->hTcxDec->synth_history_fx + output_frame, st->hTcxDec->synth_history_fx, add( sub( output_frame, post_hq_delay ), NS2SA( st->output_Fs, PH_ECU_MEM_NS ) ) ); + Copy( st->hTcxDec->synth_history_fx + output_frame, st->hTcxDec->synth_history_fx, add( sub( output_frame, post_hq_delay ), NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ) ); FOR( Word16 i = 0; i < output_frame; i++ ) { st->hTcxDec->old_synthFB_fx[sub( add( i, output_frame ), post_hq_delay )] = extract_h( output_fx[i] ); @@ -1596,24 +1596,24 @@ void save_synthesis_hq_fec_fx( set16_fx( st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), 0, post_hq_delay ); IF( GE_16( output_frame, L_FRAME16k ) ) { - Copy( st->prev_synth_buffer_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); + Copy( st->prev_synth_buffer_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); } ELSE { - Copy( st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); + Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); } IF( st->core != ACELP_CORE ) { IF( GE_16( output_frame, L_FRAME16k ) ) { - Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA( st->output_Fs, DELAY_CLDFB_NS ) ), NS2SA( st->output_Fs, DELAY_CLDFB_NS ) ); - Copy( st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); + Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ); + Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); } ELSE { - Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA( st->output_Fs, DELAY_CLDFB_NS ) ); - Copy( st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ), NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); + Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ); + Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); } } } @@ -1622,7 +1622,7 @@ void save_synthesis_hq_fec_fx( IF( st->core != ACELP_CORE ) { Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), post_hq_delay ); - Copy( st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); + Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); } } } diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c index 7d0a5f11c93cd10acdd1846d45528e5844cdea30..3ab4ca0ef1219d61f6cb5c8505df8faa9f3ece0c 100644 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ b/lib_dec/FEC_HQ_phase_ecu.c @@ -54,7 +54,8 @@ #define PHASE_DITH ( PI2 ) -#define DELTA_CORR 6 /* Range for phase correction around peak */ +#define DELTA_CORR 6 /* Range for phase correction around peak */ +#ifndef IVAS_FLOAT_FIXED #define THRESH_TR_dB 10.0f #define THRESH_TR_LIN (float) pow( 10.0f, THRESH_TR_dB / 10.0f ) #define THRESH_TR_LIN_INV (float) pow( 10.0f, -THRESH_TR_dB / 10.0f ) @@ -62,13 +63,16 @@ #define MAX_INCREASE_GRPOW_LIN (float) pow( 10.0f, MAX_INCREASE_GRPOW / 10.0f ) #define PHASE_DITH_SCALE (float) pow( 2.0, -16.0 ) /* for scaling random short values to +/- pi */ +#endif // !IVAS_FLOAT_FIXED #define BURST_PHDITH_THRESH ( 4 - 1 ) /* speech start phase dither with losses in a row */ #define BURST_PHDITH_RAMPUP_LEN 2 /* speech ramp up degree of phase dither over a length of frames */ #define BURST_ATT_THRESH ( 3 - 1 ) /* speech start attenuate with losses in a row */ #define ATT_PER_FRAME 4 /* speech attenuation in dB */ #define BETA_MUTE_THR 10 /* time threshold to start beta-noise attenuation */ -#define BETA_MUTE_FAC 0.5f /* attenuation factor per additional bad frame */ +#ifndef IVAS_FLOAT_FIXED +#define BETA_MUTE_FAC 0.5f /* attenuation factor per additional bad frame */ +#endif // !IVAS_FLOAT_FIXED #define LGW32k 7 #define LGW16k 6 @@ -77,12 +81,18 @@ #define L_TRANA_LOG32k 8 #define L_TRANA_LOG16k 7 -#define DELTA_CORR_F0_INT 2 /* Constant controls the bin range where Jacobsen is used */ -#define ST_PFIND_SENS 0.93f /* peakfinder sensitivity */ -#define L_PROT_NS 32000000L /* Prototype frame length in nanoseconds (32 ms) */ -#define PH_ECU_CORR_LIMIT 0.85f /* Correlation limit for IVAS Phase ECU activation */ -#define PH_ECU_N_LIMIT 56 /* fec_alg analysis frame limit for IVAS Phase ECU activation */ -#define PFIND_SENS 0.97f /* peakfinder sensitivity */ +#define DELTA_CORR_F0_INT 2 /* Constant controls the bin range where Jacobsen is used */ +#ifndef IVAS_FLOAT_FIXED +#define ST_PFIND_SENS 0.93f /* peakfinder sensitivity */ +#endif +#define L_PROT_NS 32000000L /* Prototype frame length in nanoseconds (32 ms) */ +#ifndef IVAS_FLOAT_FIXED +#define PH_ECU_CORR_LIMIT 0.85f /* Correlation limit for IVAS Phase ECU activation */ +#endif // !IVAS_FLOAT_FIXED +#define PH_ECU_N_LIMIT 56 /* fec_alg analysis frame limit for IVAS Phase ECU activation */ +#ifndef IVAS_FLOAT_FIXED +#define PFIND_SENS 0.97f /* peakfinder sensitivity */ +#endif // !IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* * Local functions diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index d31fa5a7f0320a88bcfcb7eefada2db4d5f4f9a8..9699ef419ebc0b4816aeac987c442ef8969e1a3c 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -49,9 +49,7 @@ #ifdef IVAS_FLOAT_FIXED #define DELTA_CORR_F0_INT 2 /* Constant controls the bin range where Jacobsen is used */ -#define ST_PFIND_SENS 0.93f /* peakfinder sensitivity */ #define L_PROT_NS 32000000L /* Prototype frame length in nanoseconds (32 ms) */ -#define PH_ECU_CORR_LIMIT 0.85f /* Correlation limit for IVAS Phase ECU activation */ #define PH_ECU_CORR_LIMIT_Q15 27853 /* 0.85 in Q15 */ #define PH_ECU_N_LIMIT 56 /* fec_alg analysis frame limit for IVAS Phase ECU activation */ #define CMPLMNT_ST_PFIND_SENS_FX 2293 /* (1.0 - st_pfind_sen) in Q15 */ @@ -157,7 +155,6 @@ static Word16 ivas_imax2_jacobsen_mag_fx( * * Where c_jacob is a window dependent constant */ -#define C_JACOB 1.1453f /* % assume 0.1875 hammrect window 'symmetric' */ #define C_JACOB_FX 18765 /* % assume 0.1875 hammrect window 'symmetric' */ /*Q14*/ /* Get the bin parameters into variables */ @@ -1819,7 +1816,7 @@ static void spec_ana_fx( #endif ) { - Word16 Lprot, LprotLog2Minus1 = 0, hamm_len2 = 0, Lprot2, Lprot2_1, m, n; + Word16 Lprot, LprotLog2Minus1, hamm_len2, Lprot2, Lprot2_1, m, n; const Word16 *pFftTbl = NULL; Word16 xfp[L_PROT48k]; Word32 magSq[L_PROT48k / 2 + 1], *pMagSq; @@ -1831,6 +1828,8 @@ static void spec_ana_fx( Word16 stop_band_start; Word16 stop_band_length; + LprotLog2Minus1 = 0; + hamm_len2 = 0; move16(); // LprotLog2Minus1 move16(); // hamm_len2 Lprot = 512; /* 1536=(2*output_frame)*1024/1280; */ @@ -2245,7 +2244,7 @@ static void ivas_subst_spec_fx( ELSE { // tmp = NS2SA(output_frame*50,PH_ECU_ALDO_OLP2_NS-PH_ECU_LOOKAHEAD_NS); - tmp = NS2SA( output_frame * 50, PH_ECU_ALDO_OLP2_NS ); + tmp = NS2SA_FX2( output_frame * 50, PH_ECU_ALDO_OLP2_NS ); move16(); tmp = sub( tmp, ph_ecu_lookahead ); tmp = add( tmp, sub( Lecu, shr( sub( Lecu, Lprot ), 1 ) ) ); diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 739e4de2eabd2f2d95c1c7063ea473cc670cb319..db5a5176991239fc2bc4f0f42142630dd0fb62b6 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -62,7 +62,7 @@ ivas_error acelp_core_dec_ivas_fx( Word16 *voice_factors_fx, /* o : voicing factors */ Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ const Word16 sharpFlag, /* i : formant sharpening flag */ - Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe */ + Word16 pitch_buf_fx[NB_SUBFR16k], /* o : Word16 pitch for each subframe */ Word16 *unbits, /* o : number of unused bits */ Word16 *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ @@ -86,7 +86,7 @@ ivas_error acelp_core_dec_ivas_fx( Word16 lsp_new_fx[M]; /* LSPs at the end of the frame Q15 */ Word16 lsp_mid_fx[M]; /* LSPs in the middle of the frame */ #ifdef MSAN_FIX - Word16 Aq_fx[NB_SUBFR16k * ( M + 1 )] = { 0 }; /* A(q) quantized for the 4 subframes */ + Word16 Aq_fx[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */ #else Word16 Aq_fx[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */ #endif @@ -97,7 +97,7 @@ ivas_error acelp_core_dec_ivas_fx( Word16 Es_pred_fx; /* predicted scaled innov. energy Q8 */ Word16 FEC_pitch_fx; /* FEC pitch */ #ifdef MSAN_FIX - Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )] = { 0 }; /* excitation buffer */ + Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */ #else Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */ #endif @@ -142,10 +142,13 @@ ivas_error acelp_core_dec_ivas_fx( #ifdef MSAN_FIX set16_fx( bpf_error_signal_16fx, 0, L_FRAME16k ); #endif + set16_fx( Aq_fx, 0, NB_SUBFR16k * ( M + 1 ) ); + set16_fx( old_bwe_exc_fx, 0, ( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 ) ); Word16 tmp; error = IVAS_ERR_OK; move32(); + test(); test(); test(); @@ -170,7 +173,8 @@ ivas_error acelp_core_dec_ivas_fx( IF( EQ_16( st->cng_type, FD_CNG ) ) { configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode ); - Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp; + Word16 old_NoiseEstExp; + old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp; move16(); /* Only run parameter decoding in SID frames */ IF( EQ_32( st->core_brate, SID_2k40 ) ) @@ -421,12 +425,13 @@ ivas_error acelp_core_dec_ivas_fx( Word16 mem_syn_r_size_old, mem_syn_r_size_new; mem_syn_r_size_old = mult_r( 2048, st->last_L_frame ); mem_syn_r_size_new = mult_r( 2048, st->L_frame ); - lerp( st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); - lerp( st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + lerp( st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old ); + lerp( st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old ); } /* convert quantized LSP vector */ st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 ); + move16(); /* convert old quantized LSF vector */ lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, int_fs ); @@ -640,7 +645,7 @@ ivas_error acelp_core_dec_ivas_fx( CNG_dec_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx ); FOR( Word32 nsf = 0; nsf < NB_SUBFR16k; nsf++ ) { - Scale_sig( Aq_fx + ( nsf * ( M + 1 ) ), M + 1, sub( norm_s( Aq_fx[imult3216( nsf, add( M, 1 ) )] ), Q2 ) ); + Scale_sig( Aq_fx + imult3216( nsf, ( M + 1 ) ), M + 1, sub( norm_s( Aq_fx[imult3216( nsf, add( M, 1 ) )] ), Q2 ) ); Aq_fx[imult3216( nsf, M + 1 )] = ONE_IN_Q12; move16(); } @@ -692,6 +697,27 @@ ivas_error acelp_core_dec_ivas_fx( } #endif ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); + Word16 new_sidNoiseEstExp = 31 - Q4; + move16(); + Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, new_sidNoiseEstExp ) ); + Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, new_sidNoiseEstExp ) ); + st->hFdCngDec->hFdCngCom->sidNoiseEstExp = new_sidNoiseEstExp; + move16(); + Word16 new_cngNoiseLevelExp = 31 - Q4; + move16(); + Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp - new_cngNoiseLevelExp ); + st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = new_cngNoiseLevelExp; + move16(); + + test(); + ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( EQ_16( st->coder_type, AUDIO ) && !st->GSC_noisy_speech ) ); + + IF( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 ) + { + Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ); + st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0; + move16(); + } } IF( !read_sid_info ) @@ -700,7 +726,7 @@ ivas_error acelp_core_dec_ivas_fx( noise_lvl_highest_fx = st->hFdCngDec->hFdCngCom->cngNoiseLevel[sub( sub( st->hFdCngDec->hFdCngCom->stopFFTbin, st->hFdCngDec->hFdCngCom->startBand ), 1 )]; move32(); - FOR( Word16 b = st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand; b < st->hFdCngDec->hFdCngCom->stopBand; b++ ) + FOR( Word16 b = sub( st->hFdCngDec->hFdCngCom->stopFFTbin, st->hFdCngDec->hFdCngCom->startBand ); b < st->hFdCngDec->hFdCngCom->stopBand; b++ ) { st->hFdCngDec->hFdCngCom->cngNoiseLevel[b] = noise_lvl_highest_fx; move32(); @@ -728,7 +754,7 @@ ivas_error acelp_core_dec_ivas_fx( IF( st->hMusicPF && st->hGSCDec ) { Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, - st->L_frame * HIBND_ACB_L_FAC, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); + imult1616( st->L_frame, HIBND_ACB_L_FAC ), 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); } IF( st->hPFstat != NULL ) { @@ -917,7 +943,7 @@ ivas_error acelp_core_dec_ivas_fx( FOR( Word32 nsf = 0; nsf < st->nb_subfr; nsf++ ) #endif { - Scale_sig( Aq_fx + ( nsf * ( M + 1 ) ), M + 1, sub( norm_s( Aq_fx[imult3216( nsf, M + 1 )] ), Q2 ) ); + Scale_sig( Aq_fx + imult3216( nsf, ( M + 1 ) ), M + 1, sub( norm_s( Aq_fx[imult3216( nsf, M + 1 )] ), Q2 ) ); Aq_fx[imult3216( nsf, M + 1 )] = ONE_IN_Q12; move16(); } @@ -925,15 +951,15 @@ ivas_error acelp_core_dec_ivas_fx( IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO ) { /* Prepare ACB memory from last HQ frame */ - old_exc_s_fx = st->old_exc_fx + L_EXC_MEM_DEC - st->L_frame; + old_exc_s_fx = st->old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ); tmpF_fx = *old_exc_s_fx; st->mem_deemph_fx = old_exc_s_fx[sub( st->L_frame, 1 )]; move16(); PREEMPH_FX( old_exc_s_fx, st->preemph_fac, L_FRAME16k, &tmpF_fx ); - Copy( old_exc_s_fx + st->L_frame - M, st->mem_syn2_fx, M ); - Residu3_fx( Aq_fx, old_exc_s_fx, old_exc_fx + L_EXC_MEM_DEC - st->L_frame, st->L_frame, 0 ); + Copy( old_exc_s_fx + sub( st->L_frame, M ), st->mem_syn2_fx, M ); + Residu3_fx( Aq_fx, old_exc_s_fx, old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, 0 ); #ifdef FIX_737_HQ_ACELP_SWITCH_SCALING_ERROR - Scale_sig( old_exc_fx + L_EXC_MEM_DEC - st->L_frame, st->L_frame, st->Q_exc ); + Scale_sig( old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, st->Q_exc ); #endif } test(); @@ -946,7 +972,7 @@ ivas_error acelp_core_dec_ivas_fx( } ELSE { - lerp( old_exc_fx, old_bwe_exc_fx, shl( L_EXC_MEM_DEC, 1 ), L_EXC_MEM_DEC ); + lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC << 1, L_EXC_MEM_DEC ); } } @@ -1263,7 +1289,7 @@ ivas_error acelp_core_dec_ivas_fx( FOR( Word32 nsf = 0; nsf < st->nb_subfr; nsf++ ) #endif { - Scale_sig( Aq_fx + ( nsf * ( M + 1 ) ), M + 1, sub( norm_s( Aq_fx[imult3216( nsf, M + 1 )] ), Q2 ) ); + Scale_sig( Aq_fx + imult3216( nsf, ( M + 1 ) ), M + 1, sub( norm_s( Aq_fx[imult3216( nsf, M + 1 )] ), Q2 ) ); Aq_fx[imult3216( nsf, M + 1 )] = ONE_IN_Q12; move16(); } @@ -1316,7 +1342,7 @@ ivas_error acelp_core_dec_ivas_fx( /* Filter energies update */ FOR( i = 0; i < DCT_L_POST; i++ ) { - st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( L_shl( 1228, ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) ); + st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( 1228 << 16, 22938, st->hMusicPF->filt_lfE_fx[i] ) ); move16(); } /* Update circular buffer, keep last energy difference unchanged */ @@ -1351,14 +1377,14 @@ ivas_error acelp_core_dec_ivas_fx( /* update buffer for classifier */ IF( st->hWIDec != NULL ) { - Copy( exc2_fx + st->L_frame - L_EXC_MEM, st->hWIDec->old_exc2_fx, L_EXC_MEM ); - Copy( psyn_fx + st->L_frame - L_EXC_MEM, st->hWIDec->old_syn2_fx, L_EXC_MEM ); + Copy( exc2_fx + sub( st->L_frame, L_EXC_MEM ), st->hWIDec->old_exc2_fx, L_EXC_MEM ); + Copy( psyn_fx + sub( st->L_frame, L_EXC_MEM ), st->hWIDec->old_syn2_fx, L_EXC_MEM ); } st->prev_Q_exc_fr = st->Q_exc; move16(); st->prev_Q_syn_fr = st->Q_syn; move16(); - Copy( psyn_fx + st->L_frame - L_SYN_MEM_CLAS_ESTIM, st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM ); + Copy( psyn_fx + sub( st->L_frame, L_SYN_MEM_CLAS_ESTIM ), st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM ); /*------------------------------------------------------------* * FEC - Smooth the speech energy evolution when recovering after a BAD frame @@ -1429,15 +1455,15 @@ ivas_error acelp_core_dec_ivas_fx( *-----------------------------------------------------------------*/ /* update old synthesis buffer - needed for ACELP internal sampling rate switching */ - Copy( psyn_fx + st->L_frame - L_SYN_MEM, st->mem_syn_r, L_SYN_MEM ); + Copy( psyn_fx + sub( st->L_frame, L_SYN_MEM ), st->mem_syn_r, L_SYN_MEM ); deemph_fx( psyn_fx, st->preemph_fac, st->L_frame, &( st->mem_deemph_fx ) ); unscale_AGC( psyn_fx, st->Q_syn, syn_fx_tmp2, st->agc_mem_fx, st->L_frame ); Copy( syn_fx_tmp2, psyn_fx, st->L_frame ); IF( st->hTcxDec != NULL ) { - Copy_Scale_sig( psyn_fx + st->L_frame / 2, st->hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, st->Q_syn ) ); /*Q-1*/ + Copy_Scale_sig( psyn_fx + shr( st->L_frame, 1 ), st->hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, st->Q_syn ) ); /*Q-1*/ } - Copy_Scale_sig( psyn_fx + st->L_frame - M - 1, st->syn, M + 1, sub( 0, st->Q_syn ) ); /*Q0*/ + Copy_Scale_sig( psyn_fx + sub( st->L_frame, M + 1 ), st->syn, M + 1, sub( 0, st->Q_syn ) ); /*Q0*/ /*------------------------------------------------------------------* * Formant post-filter @@ -1754,7 +1780,7 @@ ivas_error acelp_core_dec_ivas_fx( q_bpf_error_signal = Q6; move16(); #ifdef MSAN_FIX - Copy_Scale_sig_16_32( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, st->L_frame, q_bpf_error_signal - st->Q_syn ); // Q6 + Copy_Scale_sig_16_32( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, st->L_frame, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 #else Copy_Scale_sig_16_32( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, q_bpf_error_signal - st->Q_syn ); // Q6 #endif @@ -1763,7 +1789,7 @@ ivas_error acelp_core_dec_ivas_fx( Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 } - Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, q_bpf_error_signal - Q10 ); // q_bpf_error_signal (Q6) + Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6) st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal; move16(); tmp = -1; @@ -1804,7 +1830,6 @@ ivas_error acelp_core_dec_ivas_fx( move16(); generate_comfort_noise_dec_hf_ivas_fx( realBuffer_fx, imagBuffer_fx, /*realBuffer, imagBuffer,*/ &tmpBufferScale, st->hFdCngDec->hFdCngCom, st->cng_ism_flag ); - /* Fixed to float */ FOR( i = 0; i < st->hFdCngDec->hFdCngCom->numSlots; i++ ) { Scale_sig32( realBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0 @@ -1902,8 +1927,12 @@ ivas_error acelp_core_dec_ivas_fx( ELSE { /* synthesis of the combined signal */ - Word16 Q_real = 0, Q_imag = 0; - Word32 max_real = 0, max_imag = 0; + Word16 Q_real, Q_imag; + Word32 max_real, max_imag; + Q_real = 0; + Q_imag = 0; + max_real = 0; + max_imag = 0; move16(); move16(); move32(); @@ -1948,7 +1977,7 @@ ivas_error acelp_core_dec_ivas_fx( } ELSE { - Word16 nSamples = NS2SA( st->L_frame * FRAMES_PER_SEC, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */ + Word16 nSamples = NS2SA_FX2( st->L_frame * FRAMES_PER_SEC, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */ /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */ #ifndef MSAN_FIX @@ -1965,14 +1994,15 @@ ivas_error acelp_core_dec_ivas_fx( Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12 st->cldfbAna->Q_cldfb_state = Q12; move16(); - cldfbAnalysis_ivas_fx( syn_32_fx + st->L_frame - nSamples, realBuffer_fx, imagBuffer_fx, nSamples, st->cldfbAna ); + cldfbAnalysis_ivas_fx( syn_32_fx + sub( st->L_frame, nSamples ), realBuffer_fx, imagBuffer_fx, nSamples, st->cldfbAna ); Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11 st->cldfbAna->Q_cldfb_state = Q11; move16(); /* analysis and add the BPF error signal - needed for DFT stereo -> TD stereo switching */ Word32 tmp_bpf_error_signal_fx[L_FRAME16k]; Word16 q_bpf_error_signal; - Word16 cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels ); + Word16 cldfb_state_offset; + cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels ); // Get Q-factor q_bpf_error_signal = Q6; @@ -1993,15 +2023,19 @@ ivas_error acelp_core_dec_ivas_fx( tmp = nSamples; move16(); } - addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx + st->L_frame - nSamples, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF ); + addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx + sub( st->L_frame, nSamples ), tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF ); Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, -sub( q_bpf_error_signal, Q10 ) ); // Q10 st->cldfbBPF->Q_cldfb_state = Q10; move16(); /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */ - Word16 Q_real = 0, Q_imag = 0; - Word32 max_real = 0, max_imag = 0; + Word16 Q_real, Q_imag; + Word32 max_real, max_imag; + Q_real = 0; + Q_imag = 0; + max_real = 0; + max_imag = 0; move16(); move16(); move32(); diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 4d91463d85707cacd558120c8a88f74fdc8f384b..7d84788f532e9a9d5458f9c7b13a367e1a307af5 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -631,8 +631,6 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( Word32 *realBuffer[CLDFB_NO_COL_MAX_SWITCH_BFI], *imagBuffer[CLDFB_NO_COL_MAX_SWITCH_BFI]; Word32 realBufferTmp[CLDFB_NO_COL_MAX_SWITCH_BFI][CLDFB_NO_CHANNELS_MAX], imagBufferTmp[CLDFB_NO_COL_MAX_SWITCH_BFI][CLDFB_NO_CHANNELS_MAX]; Word16 i; - // CLDFB_SCALE_FACTOR scaleFactor; - // Word32 workBuffer[128*3]; Word32 synth32[L_FRAME48k]; MUSIC_POSTFILT_HANDLE hMusicPF; BPF_DEC_HANDLE hBPF; @@ -641,7 +639,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( hMusicPF = st_fx->hMusicPF; hBPF = st_fx->hBPF; error = IVAS_ERR_OK; - move16(); + move32(); FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH_BFI; i++ ) { @@ -826,11 +824,9 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( } /*cldfbAnalysisFiltering( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn, negate(st_fx->Q_syn), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer);*/ - cldfbAnalysis_ivas_fx( syn32, realBuffer, imagBuffer, st_fx->L_frame / 2, st_fx->cldfbAna ); + cldfbAnalysis_ivas_fx( syn32, realBuffer, imagBuffer, shr( st_fx->L_frame, 1 ), st_fx->cldfbAna ); cldfb_restore_memory_ivas_fx( st_fx->cldfbAna ); - // scaleFactor.hb_scale = scaleFactor.lb_scale; - /* CLDFB synthesis of the combined signal */ IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st_fx->cldfbSyn ) ), IVAS_ERR_OK ) ) { @@ -840,6 +836,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( negate(st_fx->Q_syn), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer );*/ Scale_sig32( st_fx->cldfbSyn->cldfb_state_fx, st_fx->cldfbSyn->cldfb_state_length, 1 ); st_fx->cldfbSyn->Q_cldfb_state = add( st_fx->cldfbSyn->Q_cldfb_state, 1 ); + move16(); Copy_Scale_sig_16_32( synth_out, synth32, L_FRAME48k, 5 ); /*11-5-1*/ // cldfbSynthesis_ivas_fx(realBuffer, imagBuffer, synth_out, (int16_t)(st_fx->output_Fs * 0.01f), st_fx->cldfbSyn); diff --git a/lib_dec/amr_wb_dec.c b/lib_dec/amr_wb_dec.c index 29b2e5a265eb496118a239e4552a41477825b33a..09242c2a3cbdc2e2ffbc3494a7ffc80d4d6a2cf6 100644 --- a/lib_dec/amr_wb_dec.c +++ b/lib_dec/amr_wb_dec.c @@ -42,9 +42,6 @@ #include "prot.h" #include "wmc_auto.h" -#ifdef IVAS_FLOAT_FIXED -#include "prot_fx.h" -#endif #ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------* diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index 132322c061d529d101f9cf96e888c6eab3039816..8894a571d79fc66cdb4b52b6c955c6f88587c577 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -48,7 +48,7 @@ ivas_error amr_wb_dec_fx( Word16 old_exc_fx[L_EXC_DEC], *exc_fx; /* excitation signal buffer */ Word16 syn_tmp_fx[L_FRAME + 2], *syn_fx; /* synthesis signal buffer */ Word32 L_tmp, L_tmp1; - Word16 pitch_buf_fx[NB_SUBFR], Qdct, tmp_coder_type; /* floating pitch for each subframe (Q6) */ + Word16 pitch_buf_fx[NB_SUBFR], Qdct, tmp_coder_type; /* Word16 pitch for each subframe (Q6) */ Word16 tmp16; Word16 sid_bw = 0; move16(); diff --git a/lib_dec/ari_dec.c b/lib_dec/ari_dec.c index e92565f6b4da9e63e1d973be243588f824b0e57f..7d63c3b342f0b7cd331828d23da8317718552fd2 100644 --- a/lib_dec/ari_dec.c +++ b/lib_dec/ari_dec.c @@ -55,6 +55,7 @@ * Start ArCo decoding *-------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ari_start_decoding_14bits_ivas( Decoder_State *st, Tastat *s ) @@ -100,6 +101,7 @@ int16_t ari_start_decoding_14bits_prm_ivas( return bp; } +#endif // !IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED Word16 ari_start_decoding_14bits_prm_ivas_fx( @@ -120,6 +122,7 @@ Word16 ari_start_decoding_14bits_prm_ivas_fx( val = L_or( L_shl( val, 1 ), *( p + i ) ); } s->low = L_deposit_l( 0 ); + move32(); s->high = ari_q4new; move32(); s->value = val; @@ -129,7 +132,265 @@ Word16 ari_start_decoding_14bits_prm_ivas_fx( } #endif -#ifndef IVAS_FLOAT_FIXED + +#ifdef IVAS_FLOAT_FIXED +Word16 ari_decode_14bits_pow_ivas( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s, + UWord16 base ) +{ + UWord16 symbol; + Word32 low, high; + UWord32 range, value, cum; + Word16 pows[12]; /* "base" to the power of 2, 4, 8,... 2^12 */ + Word16 lowlim, highlim, testval; + Word16 k; + + highlim = 0; + low = s->low; + high = L_add( s->high, 1 ); + value = s->value; + lowlim = 0; + symbol = 0; + move16(); + move32(); + move32(); + move16(); + move16(); + + range = (UWord32) W_sub( high, low ); + move32(); + + /* the value read from bitstream */ + assert( value >= (UWord32) low ); + cum = (UWord32) W_add( W_shl( ( W_sub( value, low ) ), stat_bitsnew ), ( 1 << stat_bitsnew ) - 1 ); + move32(); + + /* search for the interval where "cum" fits */ + IF( GT_64( W_mult0_32_32( L_shr( base, 1 ), range ), cum ) ) /* below pow-1 */ + { + pows[0] = testval = base; + move16(); + move16(); + /* increase exponent until it is smaller than "cum" */ + FOR( k = 1; k < 12; k++ ) + { + highlim = testval; + move16(); + pows[k] = mult_r( pows[k - 1], pows[k - 1] ); + move16(); + testval = mult_r( pows[k], base ); + IF( LE_64( W_mult0_32_32( shr( testval, 1 ), range ), cum ) ) /* found! big range is [lowlim,testval], (now narrow it down) */ + { + lowlim = testval; + move16(); + k = sub( k, 1 ); + symbol = (UWord16) L_shl( 1, k ); + move16(); + break; + } + } + assert( k < 12 ); /* maximum 2^10-1*/ + /* narrow the range down */ + FOR( k--; k > 0; k-- ) + { + testval = mult_r( highlim, pows[k] ); + IF( LE_64( W_mult0_32_32( shr( testval, 1 ), range ), cum ) ) + { + lowlim = testval; + move16(); + symbol = (UWord16) L_sub( symbol, L_shl( 1, sub( k, 1 ) ) ); + } + ELSE + { + highlim = testval; + move16(); + } + } + highlim = shr( highlim, 1 ); + lowlim = shr( lowlim, 1 ); + } + ELSE /* trivial case, above pow-1, that is, first symbol */ + { + symbol = 0; + lowlim = extract_l( L_shr( base, 1 ) ); + highlim = 16384; + move16(); + move16(); + move16(); + } + + + high = L_add( low, mul_sbc_14bits( range, highlim ) ); + + low = L_add( low, mul_sbc_14bits( range, lowlim ) ); + + /*ptr init for ptr*/ + FOR( ; bp < bits; ) + { + IF( GT_32( high, ari_q2new ) ) + { + IF( GE_32( low, ari_q2new ) ) + { + value = (UWord32) W_sub( value, ari_q2new ); + low = L_sub( low, ari_q2new ); + high = L_sub( high, ari_q2new ); + move32(); + } + ELSE + { + test(); + IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) ) + { + value = (UWord32) W_sub( value, ari_q1new ); + low = L_sub( low, ari_q1new ); + high = L_sub( high, ari_q1new ); + move32(); + } + ELSE + { + BREAK; + } + } + } + low = L_add( low, low ); + high = L_add( high, high ); + + assert( abs( ptr[bp] ) <= 1 && "AC expects reading binary values!!!" ); + + value = (UWord32) ( W_shl( value, 1 ) | ptr[bp++] ); + move32(); + } + + test(); + test(); + test(); + IF( !( NE_16( bp, bits ) || !( EQ_32( s->low, low ) && ( EQ_32( s->high, high ) ) && ( EQ_64( s->value, value ) ) ) ) ) + { + /* This should not happen except of bit errors. */ + s->high = s->low = 0; + move32(); + move32(); + *res = 0; + move16(); + return -1; + } + + s->low = low; + s->high = L_sub( high, 1 ); + s->value = value; + move32(); + move32(); + move32(); + + *res = symbol; + move16(); + return bp; +} + +Word16 ari_decode_14bits_sign_ivas( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s ) +{ + Word16 symbol; + Word32 low, high; + UWord32 range, value, cum; + + low = s->low; + high = L_add( s->high, 1 ); + value = s->value; + move32(); + move32(); + + range = (UWord32) W_sub( high, low ); + + IF( LT_16( bp, bits ) ) + { + assert( value >= (UWord32) low ); + cum = (UWord32) W_add( W_shl( ( W_sub( value, low ) ), stat_bitsnew ), ( 1 << stat_bitsnew ) - 1 ); + IF( GT_64( W_shl( range, 13 ), cum ) ) + { + symbol = 2; + move16(); + high = L_add( low, W_extract_l( W_shr( range, 1 ) ) ); + } + ELSE + { + symbol = 1; + move16(); + low = L_add( low, W_extract_l( W_shr( range, 1 ) ) ); + } + + /*ptr init for ptr*/ + FOR( ; bp < bits; ) + { + IF( GT_32( high, ari_q2new ) ) + { + IF( GE_32( low, ari_q2new ) ) + { + value = (UWord32) W_sub( value, ari_q2new ); + low = L_sub( low, ari_q2new ); + high = L_sub( high, ari_q2new ); + } + ELSE + { + IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) ) + { + value = (UWord32) W_sub( value, ari_q1new ); + low = L_sub( low, ari_q1new ); + high = L_sub( high, ari_q1new ); + } + ELSE + { + break; + } + } + } + low = L_add( low, low ); + high = L_add( high, high ); + + assert( abs( ptr[bp] ) <= 1 && "AC expects reading binary values!!!" ); + + value = (UWord32) ( W_shl( value, 1 ) | ptr[bp++] ); + } + } + ELSE + { + cum = (UWord32) W_sub( value, low ); + range = (UWord32) W_shr( range, 1 ); + IF( GT_64( range, cum ) ) + { + symbol = 2; + move16(); + high = L_add( low, range ); + } + ELSE + { + symbol = 1; + move16(); + low = L_add( low, range ); + } + } + + s->low = low; + s->high = L_sub( high, 1 ); + s->value = value; + move32(); + move32(); + move32(); + + *res = symbol; + move16(); + + return bp; +} +#else /*--------------------------------------------------------------- * ari_decode_14bits_s17_ext_ivas() * @@ -460,7 +721,6 @@ void ari_decode_14bits_bit_ext_ivas( return; } -#endif /*------------------------------------------------------------------------ * Function: ari_decode_14bits_pow_ivas() @@ -695,3 +955,4 @@ int16_t ari_decode_14bits_sign_ivas( return bp; } +#endif diff --git a/lib_dec/arith_coder_dec.c b/lib_dec/arith_coder_dec.c index 1d23d827d4d34cec79faa7706e2cca1f9699f447..a4f4d7409304ba16f7b6b1efc5e80f2746b454b4 100644 --- a/lib_dec/arith_coder_dec.c +++ b/lib_dec/arith_coder_dec.c @@ -123,24 +123,21 @@ static Word16 tcx_arith_decode_ivas_fx( const Word16 envelope[], /* i : scaled envelope (Q15-e) */ Word16 envelope_e, /* i : scaled envelope exponent (Q0) */ const Word16 target_bits, /* i : target bit budget */ - const Word16 prm[], /* i : bitstream parameters */ + Word16 prm[], /* i : bitstream parameters */ Word32 q_spectrum[], /* o : scalar quantized spectrum */ Word16 *q_spectrum_e /* o : spectrum exponent */ ) { Word16 bp, k, q; - UWord16 s; + Word16 s; Tastat as; UWord16 exp_k; Word16 tmp; - // Word32 L_tmp; bp = ari_start_decoding_14bits_prm_ivas_fx( prm, 0, &as ); tmp = sub( envelope_e, 1 ); - // L_tmp = L_deposit_l(0); - FOR( k = 0; k < L_frame; k++ ) { IF( EQ_16( envelope[k], 0 ) ) /* safety check in case of bit errors */ @@ -174,7 +171,7 @@ static Word16 tcx_arith_decode_ivas_fx( IF( LE_32( as.high, as.low ) ) { - IF( LT_16( bp, target_bits ) ) /* safety check in case of bit errors */ + if ( LT_16( bp, target_bits ) ) /* safety check in case of bit errors */ { bp = -1; move16(); @@ -306,7 +303,7 @@ void tcx_arith_decode_envelope_ivas_fx( Word16 L_spec, /* i : length w/o BW limitation */ const Word16 A_ind[], /* i : quantised LPC coefficients */ const Word16 target_bits, /* i : number of available bits */ - const Word16 prm[], /* i : bitstream parameters */ + Word16 prm[], /* i : bitstream parameters */ const Word16 use_hm, /* i : use HM in current frame? */ const Word16 prm_hm[], /* i : HM parameter area */ Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ @@ -330,6 +327,7 @@ void tcx_arith_decode_envelope_ivas_fx( test(); test(); test(); + test(); IF( GT_16( L_spec, N_MAX_ARI ) || ( EQ_16( st->element_mode, EVS_MONO ) && GT_16( target_bits, ( ACELP_13k20 / FRAMES_PER_SEC ) ) ) || ( EQ_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE / FRAMES_PER_SEC ) ) ) ) || ( GT_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE_CPE / FRAMES_PER_SEC ) ) ) ) || @@ -366,7 +364,7 @@ void tcx_arith_decode_envelope_ivas_fx( IF( use_hm != 0 ) { - IF( NE_16( prm_hm[0], 0 ) ) + IF( prm_hm[0] != 0 ) { tcx_hm_decode( L_spec, env, target_bits, st->coder_type, prm_hm, tcxltp_pitch, &hm_bits ); diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index ea829b9554eb37fd6917312a61ef810df4a82dab..9919e1f219a09c2898e14dd46133a2788a3494d3 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -305,7 +305,6 @@ void CNG_dec_fx( hTdCngDec->act_cnt = 0; move16(); s_ptr = add( sub( hTdCngDec->ho_circ_ptr, burst_ho_cnt ), 1 ); - move16(); IF( s_ptr < 0 ) { s_ptr = add( s_ptr, hTdCngDec->ho_circ_size ); @@ -391,6 +390,7 @@ void CNG_dec_fx( L_enr = Mult_32_16( hTdCngDec->ho_ener_hist_fx[ptr], W_DTX_HO_FX[0] ); /* Q6+15-15->Q6 */ weights = W_DTX_HO_FX[0]; /* Q15 */ + move16(); m = 1; move16(); @@ -494,6 +494,7 @@ void CNG_dec_fx( FOR( i = 0; i < M; i++ ) { L_tmp1 = 0; + move32(); FOR( j = 0; j < m; j++ ) { L_tmp1 = L_add( L_tmp1, L_deposit_l( tmp[add( i_mult( j, M ), i )] ) ); @@ -664,6 +665,7 @@ void CNG_dec_fx( exp_pow = sub( 14, temp_hi_fx ); L_tmp = Pow2( 14, temp_lo_fx ); /* Qexp_pow */ env[i] = L_shl( L_tmp, sub( 6, exp_pow ) ); /* Q6 */ + move32(); L_tmp = L_add( hTdCngDec->Enew_fx, hTdCngDec->Enew_fx ); env[i] = L_add( env[i], L_tmp ); /* Q6 */ move32(); @@ -804,6 +806,7 @@ void swb_CNG_dec_ivas_fx( st_fx->last_vad_fx = 1; move16(); st_fx->hTdCngDec->burst_cnt = add_sat( st_fx->hTdCngDec->burst_cnt, 1 ); // saturation reached? + move16(); if ( GT_16( st_fx->hTdCngDec->burst_cnt, 10 ) ) { st_fx->hTdCngDec->burst_cnt = 0; @@ -953,6 +956,7 @@ static void shb_CNG_decod_fx( tmp = sub( wb_ener16_fx, st_fx->wb_cng_ener_fx ); /*Q8 */ tmp = mult_r( tmp, 29491 ); /*Q8 */ st_fx->wb_cng_ener_fx = add( st_fx->wb_cng_ener_fx, tmp ); /*Q8 */ + move16(); } test(); test(); @@ -1140,14 +1144,16 @@ static void shb_CNG_decod_ivas_fx( Word16 exp, exp1; Word16 fra; Word32 L_tmp; - Word16 allow_cn_step_fx = 0; - move16(); + Word16 allow_cn_step_fx; Word16 q; TD_BWE_DEC_HANDLE hBWE_TD; hBWE_TD = st->hBWE_TD; + allow_cn_step_fx = 0; + move16(); IF( EQ_16( st->bfi, 0 ) ) { + test(); IF( EQ_32( st->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) ) { idx_ener = get_next_indice_fx( st, 4 ); @@ -1159,7 +1165,7 @@ static void shb_CNG_decod_ivas_fx( } /* de-quantization of SHB CNG parameters */ - IF( EQ_16( st->element_mode, EVS_MONO ) ) + IF( st->element_mode == EVS_MONO ) { st->hTdCngDec->last_shb_cng_ener_fx_32 = L_sub( L_mult0( idx_ener, 6850 ), 36991 ); // Q11 move32(); @@ -1199,8 +1205,6 @@ static void shb_CNG_decod_ivas_fx( Copy_Scale_sig( shb_lpcCNG_fx, shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), 2 ) ); /* Q12 */ - // mvs2s(shb_lpcCNG_fx, st->hTdCngDec->shb_lpcCNG_fx, LPC_SHB_ORDER + 1); - /* SHB energy estimation */ wb_ener_fx = L_deposit_l( 1 ); /*Q1 */ IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) @@ -1322,7 +1326,9 @@ static void shb_CNG_decod_ivas_fx( tmp = L_shr( Mpy_32_16_1( ener_fx, 3277 ), 3 ); /*Q8 */ IF( GT_32( tmp, 32767 ) ) abort(); - Word16 tmp_16 = (Word16) tmp; + Word16 tmp_16; + tmp_16 = (Word16) tmp; + move16(); L_tmp = L_mult( 27213, tmp_16 ); /*Q22, 27213=3.321928 in Q13 */ L_tmp = L_shr( L_tmp, 6 ); /*Q16 */ L_tmp = L_add( L_tmp, L_shl( 10, 16 ) ); @@ -1565,7 +1571,7 @@ void td_cng_dec_init_ivas_fx( FOR( i = 0; i < LPC_SHB_ORDER; i++ ) { - IF( NE_16( st->element_mode, EVS_MONO ) ) + IF( st->element_mode != EVS_MONO ) { hTdCngDec->lsp_shb_prev_fx[i] = ivas_lsp_shb_prev_tbl_fx[i]; move16(); diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index 6a023104a5c37de4872b1b35f702887ebcea62d4..da0cfec0d8dc6820d9c2955c55b6dc41f4704938 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -7,7 +7,7 @@ #include #include #include "options.h" -#include "prot.h" //Can be removed later +#include "prot.h" #include "prot_fx.h" #include "basop_util.h" #include "rom_com.h" @@ -117,6 +117,10 @@ void open_decoder_LPD_fx( test(); test(); test(); + test(); + test(); + test(); + test(); IF( ( EQ_16( st->element_mode, EVS_MONO ) && EQ_16( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, 32000 ) ) || ( GT_16( st->element_mode, EVS_MONO ) && EQ_16( st->L_frame, L_FRAME16k ) && LE_32( total_brate, MAX_ACELP_BRATE ) ) || @@ -147,6 +151,7 @@ void open_decoder_LPD_fx( IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) { st->pit_res_max = initPitchLagParameters( INT_FS_12k8, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max ); + move16(); IF( hTcxDec != NULL ) { // st->pit_res_max = initPitchLagParameters(12800, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max); @@ -502,7 +507,6 @@ void open_decoder_LPD_fx( test(); test(); test(); - test(); IF( EQ_16( st->last_codec_mode, MODE2 ) && NE_16( st->L_frame, st->last_L_frame ) && ( ( EQ_16( st->m_frame_type, SID_FRAME ) && ( st->last_core > ACELP_CORE ) ) || @@ -516,15 +520,17 @@ void open_decoder_LPD_fx( test(); test(); test(); + test(); + test(); IF( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->last_core, HQ_CORE ) ) { /*Codec switching from MDCT */ /*Reset of ACELP memories*/ - move16(); - move16(); st->rate_switching_reset = 1; st->tilt_code_fx = TILT_CODE; + move16(); + move16(); set16_fx( st->old_exc_fx, 0, L_EXC_MEM_DEC ); set16_fx( st->syn, 0, 1 + M ); set16_fx( st->mem_syn2_fx, 0, M ); @@ -542,27 +548,26 @@ void open_decoder_LPD_fx( } IF( st->hTcxCfg != NULL ) { - Copy_Scale_sig( hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->syn_OverlFB, st->hTcxCfg->tcx_mdct_window_lengthFB, negate( add( hHQ_core->Q_old_wtda, TCX_IMDCT_HEADROOM ) ) ); + Copy_Scale_sig( hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->syn_OverlFB, st->hTcxCfg->tcx_mdct_window_lengthFB, negate( add( hHQ_core->Q_old_wtda, TCX_IMDCT_HEADROOM ) ) ); - move16(); - move16(); st->hTcxCfg->last_aldo = 1; /*It was previously ALDO*/ st->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; + move16(); + move16(); } /*OLA for MDCT-LB always reset in codec switching cases*/ IF( st->hHQ_core != NULL ) { set16_fx( hHQ_core->old_out_LB_fx, 0, st->L_frame ); } - move16(); st->last_core_bfi = TCX_20_CORE; + move16(); - IF( st->hPFstat != NULL ) + if ( st->hPFstat != NULL ) { st->hPFstat->on = 0; move16(); } - move16(); /* reset CLDFB memories */ cldfb_reset_memory( st->cldfbAna ); cldfb_reset_memory( st->cldfbBPF ); @@ -583,6 +588,7 @@ void open_decoder_LPD_fx( /* convert quantized LSP vector */ st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 ); + move16(); IF( st->tcxonly == 0 ) { lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); @@ -796,7 +802,6 @@ void open_decoder_LPD_fx( st->clas_dec = UNVOICED_CLAS; move16(); - move16(); if ( !st->last_con_tcx ) { move16(); @@ -865,7 +870,6 @@ void open_decoder_LPD_fx( move16(); #endif } - move16(); st->cummulative_damping = 32767 /*1.0f Q15*/; move16(); @@ -912,6 +916,7 @@ void open_decoder_LPD_fx( } move16(); + test(); test(); test(); IF( hTcxLtpDec != NULL && ( EQ_16( st->ini_frame, 0 ) || ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) ) ) @@ -928,7 +933,6 @@ void open_decoder_LPD_fx( hTcxDec->tcxltp_last_gain_unmodified = 0; move16(); } - move16(); IF( st->ini_frame == 0 ) { set16_fx( hTcxLtpDec->tcxltp_mem_in, 0, TCXLTP_MAX_DELAY ); @@ -986,6 +990,7 @@ void open_decoder_LPD_fx( move16(); test(); test(); + test(); IF( EQ_16( bwidth, SWB ) && ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && EQ_16( st->element_mode, EVS_MONO ) ) { @@ -1007,9 +1012,6 @@ void open_decoder_LPD_fx( move16(); st->guidedT0 = st->T0_4th; move16(); - test(); - test(); - test(); st->enablePlcWaveadjust = 0; move16(); @@ -1167,6 +1169,7 @@ void acelp_plc_mdct_transition_fx( Word16 i; /*PLC*/ + test(); IF( st->prev_bfi != 0 && st->hTcxCfg != NULL ) { W1 = st->hTcxCfg->tcx_mdct_window_lengthFB; @@ -1202,8 +1205,7 @@ void acelp_plc_mdct_transition_fx( lerp( st->hHQ_core->old_out_fx, st->hHQ_core->old_out_LB_fx, st->L_frame, st->hTcxDec->L_frameTCX ); Copy( st->hHQ_core->old_out_fx + nz, st->hTcxDec->syn_Overl_TDACFB, shr( st->hTcxDec->L_frameTCX, 1 ) ); - nz = NS2SA( st->sr_core, N_ZERO_MDCT_NS ); - move16(); + nz = NS2SA_FX2( st->sr_core, N_ZERO_MDCT_NS ); Copy( st->hHQ_core->old_out_LB_fx + nz, st->hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ) ); st->hHQ_core->Q_old_wtda_LB = st->hHQ_core->Q_old_wtda; move16(); @@ -1294,7 +1296,6 @@ void open_decoder_LPD_ivas_fx( test(); test(); test(); - test(); IF( ( EQ_16( st->element_mode, EVS_MONO ) && EQ_16( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, 32000 ) ) || ( GT_16( st->element_mode, EVS_MONO ) && EQ_16( st->L_frame, L_FRAME16k ) && LE_32( total_brate, MAX_ACELP_BRATE ) ) || ( ( st->tcxonly != 0 ) && ( EQ_32( st->sr_core, 32000 ) || EQ_32( st->sr_core, 16000 ) ) ) ) @@ -1307,11 +1308,11 @@ void open_decoder_LPD_ivas_fx( st->nb_subfr = NB_SUBFR; move16(); } - move16(); st->bits_frame = extract_l( L_shr( Mpy_32_16_1( L_shl( st->total_brate, 1 ), 20972 ), 6 ) ); /* 20972 = 0.01 * 64 * 32768 */ // assert(FSCALE_DENOM == 512); // assert(st->fscale == 2 * st->L_frame); /* this assumption is true if operated in 20ms frames with FSCALE_DENOM == 512, which is the current default */ // assert(st->bits_frame == (int16_t)(((float)st->L_frame / (float)st->fscale) * (float)FSCALE_DENOM / 128.0f * (float)total_brate / 100.0f + 0.49f)); + move16(); st->TcxBandwidth = getTcxBandwidth( bwidth ); move16(); st->narrowBand = 0; @@ -1338,11 +1339,14 @@ void open_decoder_LPD_ivas_fx( ELSE { st->pit_res_max = initPitchLagParameters( st->sr_core, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max ); + move16(); IF( hTcxDec != NULL ) { i = mult_r( hTcxDec->L_frameTCX, getInvFrameLen( st->L_frame ) ); hTcxDec->pit_max_TCX = extract_l( L_shr( L_mult( st->pit_max, i ), 7 ) ); + move16(); hTcxDec->pit_min_TCX = extract_l( L_shr( L_mult( st->pit_min, i ), 7 ) ); + move16(); } } @@ -1369,7 +1373,6 @@ void open_decoder_LPD_ivas_fx( move16(); } - // gamma_float to be removed later st->inv_gamma = GAMMA1_INV; move16(); test(); @@ -1424,6 +1427,7 @@ void open_decoder_LPD_ivas_fx( { set16_fx( hBWE_TD->prev_lsf_diff_fx, 16384, LPC_SHB_ORDER - 2 ); hBWE_TD->prev_tilt_para_fx = 0; + move16(); set16_fx( hBWE_TD->cur_sub_Aq_fx, 0, M + 1 ); } @@ -1504,6 +1508,7 @@ void open_decoder_LPD_ivas_fx( /* Reset old_synth in case of core sampling rate switching and Mode 1/2 switching*/ test(); test(); + test(); IF( st->hTcxDec != NULL && ( NE_16( st->L_frame, st->last_L_frame ) || ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) ) ) { set16_fx( hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC ); @@ -1558,6 +1563,7 @@ void open_decoder_LPD_ivas_fx( /* Switching from Mode 1 ACELP */ st->last_core_bfi = ACELP_CORE; move16(); + test(); IF( NE_16( st->prev_bfi, 0 ) && st->hTcxCfg != NULL ) { acelp_plc_mdct_transition_fx( st ); @@ -1580,6 +1586,7 @@ void open_decoder_LPD_ivas_fx( test(); test(); test(); + test(); IF( EQ_16( st->last_codec_mode, MODE2 ) && NE_16( st->L_frame, st->last_L_frame ) && ( ( EQ_16( st->m_frame_type, SID_FRAME ) && ( st->last_core > ACELP_CORE ) ) || ( ( st->last_core > ACELP_CORE ) && ( st->core > ACELP_CORE ) ) || st->prev_bfi ) ) @@ -1591,8 +1598,6 @@ void open_decoder_LPD_ivas_fx( test(); test(); test(); - test(); - test(); IF( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->last_core, HQ_CORE ) ) { /* Switching from MDCT */ @@ -1617,7 +1622,7 @@ void open_decoder_LPD_ivas_fx( { hHQ_core->Q_old_wtda = -1; /*To be removed later when hHQ_core->Q_old_wtda vaue is updated*/ move16(); - Copy_Scale_sig( hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->syn_OverlFB, st->hTcxCfg->tcx_mdct_window_lengthFB, negate( add( hHQ_core->Q_old_wtda, TCX_IMDCT_HEADROOM ) ) ); + Copy_Scale_sig( hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->syn_OverlFB, st->hTcxCfg->tcx_mdct_window_lengthFB, negate( add( hHQ_core->Q_old_wtda, TCX_IMDCT_HEADROOM ) ) ); *Q_syn_OverlFB = *Q_old_out; move16(); st->hTcxCfg->last_aldo = 1; /*It was previously ALDO*/ @@ -1715,6 +1720,8 @@ void open_decoder_LPD_ivas_fx( { st->hTcxDec->old_synth_len = shl( st->L_frame, 1 ); st->hTcxDec->old_synth_lenFB = shl( hTcxDec->L_frameTCX, 1 ); + move16(); + move16(); } /* bass pf reset */ @@ -1746,6 +1753,7 @@ void open_decoder_LPD_ivas_fx( st->hPFstat->reset = 1; st->hPFstat->gain_prec = 16384; move16(); + move16(); } } ELSE IF( st->hPFstat->on ) @@ -1773,8 +1781,8 @@ void open_decoder_LPD_ivas_fx( // Scale_sig(st->hPFstat->mem_pf_in, L_SUBFR, negate(st->Q_syn)); /* WB post_filter mem */ // Scale_sig(st->hPFstat->mem_stp, L_SUBFR, negate(st->Q_syn)); /* WB post_filter mem */ //-------------- - lerp( st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); - lerp( st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + lerp( st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old ); + lerp( st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old ); } } } @@ -1829,7 +1837,9 @@ void open_decoder_LPD_ivas_fx( Copy( st->lsp_old_fx, st->old_lsp_q_cng, M ); set16_fx( st->mem_syn_unv_back, 0, M ); st->last_gain_syn_deemph = 32768 / 2; /* 1.f Q14*/ + move16(); + test(); IF( EQ_16( st->last_codec_mode, MODE1 ) || ( st->ini_frame == 0 ) ) { /* this assumes that MODE1 fades out in the frequency domain - @@ -1841,6 +1851,7 @@ void open_decoder_LPD_ivas_fx( if ( hTcxDec != NULL ) { hTcxDec->conceal_eof_gain = 32768 / 2; /*Q14*/ + move16(); } } /* Post processing */ @@ -1890,7 +1901,8 @@ void open_decoder_LPD_ivas_fx( IF( st->prev_bfi ) { /* calculate energy at the end of the previous frame */ - IF( EQ_16( st->core, ACELP_CORE ) && EQ_16( st->last_core, HQ_CORE ) ) + test(); + IF( st->core == ACELP_CORE && EQ_16( st->last_core, HQ_CORE ) ) { st->output_frame_fx = st->hTcxDec->L_frameTCX; move16(); @@ -1908,9 +1920,9 @@ void open_decoder_LPD_ivas_fx( move32(); st->Mode2_lp_gainp = L_deposit_l( 0 ); move32(); - st->lp_gainc_fx = (Word16) L_deposit_l( 0 ); + st->lp_gainc_fx = 0; move16(); - st->lp_gainp_fx = (Word16) L_deposit_l( 0 ); + st->lp_gainp_fx = 0; move16(); IF( st->hTcxDec != NULL ) @@ -1996,7 +2008,7 @@ void open_decoder_LPD_ivas_fx( move32(); test(); test(); - IF( ( st->ini_frame == 0 ) || ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) ) + IF( ( st->ini_frame == 0 ) || ( EQ_16( st->last_codec_mode, MODE1 ) && st->element_mode == EVS_MONO ) ) { hTcxDec->tcxltp_last_gain_unmodified = 0; move16(); @@ -2022,6 +2034,7 @@ void open_decoder_LPD_ivas_fx( move32(); } st->mem_error = L_deposit_l( 0 ); + move32(); IF( st->tcxonly ) { st->p_bpf_noise_buf = NULL; @@ -2037,7 +2050,7 @@ void open_decoder_LPD_ivas_fx( test(); test(); test(); - IF( EQ_16( bwidth, SWB ) && ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && EQ_16( st->element_mode, EVS_MONO ) ) + IF( EQ_16( bwidth, SWB ) && ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && st->element_mode == EVS_MONO ) { st->tec_tfa = 1; move16(); @@ -2067,12 +2080,12 @@ void open_decoder_LPD_ivas_fx( move16(); test(); test(); - IF( st->hPlcInfo != NULL && GE_32( total_brate, HQ_48k ) && EQ_16( st->element_mode, EVS_MONO ) ) + IF( st->hPlcInfo != NULL && GE_32( total_brate, HQ_48k ) && st->element_mode == EVS_MONO ) { st->enablePlcWaveadjust = 1; move16(); - IF( st->hTcxDec != NULL && ( EQ_16( st->ini_frame, 0 ) || LT_32( last_total_brate, HQ_48k ) || EQ_16( st->last_codec_mode, MODE1 ) || st->force_lpd_reset ) ) + IF( st->hTcxDec != NULL && ( st->ini_frame == 0 || LT_32( last_total_brate, HQ_48k ) || EQ_16( st->last_codec_mode, MODE1 ) || st->force_lpd_reset ) ) { concealment_init_ivas_fx( st->hTcxDec->L_frameTCX, st->hPlcInfo ); } @@ -2109,7 +2122,7 @@ void open_decoder_LPD_ivas_fx( st->second_last_core = -1; move16(); - IF( st->hTcxCfg != NULL && NE_16( st->element_mode, EVS_MONO ) ) + IF( st->hTcxCfg != NULL && st->element_mode != EVS_MONO ) { Word32 gettns_temp; IF( is_init ) @@ -2134,8 +2147,7 @@ void open_decoder_LPD_ivas_fx( test(); test(); test(); - test(); - IF( ( EQ_32( total_brate, ACELP_9k60 ) || EQ_32( total_brate, ACELP_16k40 ) || EQ_32( total_brate, ACELP_24k40 ) ) && EQ_32( st->element_mode, EVS_MONO ) ) + IF( ( EQ_32( total_brate, ACELP_9k60 ) || EQ_32( total_brate, ACELP_16k40 ) || EQ_32( total_brate, ACELP_24k40 ) ) && st->element_mode == EVS_MONO ) { st->dec_glr = 1; move16(); diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index a0e74feb6197e4de132a2888af4ff893a57c52af..85a301239474b0c6ce0a8e8a1204005262df662a 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -33,6 +33,8 @@ void bandwidth_switching_detect_fx( Decoder_State *st_fx /* i/o: encoder state structure */ ) { + test(); + test(); IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { /* there is no BWE in TD stereo secondary channel and in MDCT stereo, IGF is part of the core decoding -> no BW switching -> reset BWS counters */ @@ -157,6 +159,7 @@ static Word32 Calc_freq_ener_fx( Word32 L_tmp, const Word16 Q_syn2 ) IF( L_tmp == 0 ) { enerLL_fx = L_deposit_l( 0 ); + move32(); } ELSE { @@ -191,6 +194,7 @@ void bw_switching_pre_proc_fx( Word32 L_tmp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif #ifdef IVAS_CODE_SWITCHING IF( GT_16( st_fx->element_mode, EVS_MONO ) ) @@ -226,6 +230,7 @@ void bw_switching_pre_proc_fx( #ifdef BASOP_NOGLOB st_fx->tilt_wb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_syn_12k8_16k_fx, -1, st_fx->L_frame ), 3, &Overflow ), &Overflow ); + move16(); #else st_fx->tilt_wb_fx = round_fx( L_shl( calc_tilt_bwe_fx( old_syn_12k8_16k_fx, -1, st_fx->L_frame ), 3 ) ); #endif @@ -246,6 +251,7 @@ void bw_switching_pre_proc_fx( } L_tmp = L_shr( L_tmp, 7 ); /*2*(st_fx->Q_syn2-1)*/ st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); + move32(); L_tmp = L_deposit_l( 0 ); FOR( ; i < L_FRAME; i++ ) { @@ -257,6 +263,7 @@ void bw_switching_pre_proc_fx( } L_tmp = L_shr( L_tmp, 7 ); /*2*(st_fx->Q_syn2-1)*/ st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); + move32(); } ELSE { @@ -273,6 +280,7 @@ void bw_switching_pre_proc_fx( } L_tmp = L_shr( L_tmp, 5 ); /*st_fx->Q_syn2-1*/ st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); + move32(); L_tmp = L_deposit_l( 0 ); FOR( ; i < 64; i++ ) { @@ -284,6 +292,7 @@ void bw_switching_pre_proc_fx( } L_tmp = L_shr( L_tmp, 5 ); /*st_fx->Q_syn2-1*/ st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); + move32(); } ELSE { @@ -298,6 +307,7 @@ void bw_switching_pre_proc_fx( } L_tmp = L_shr( L_tmp, 7 ); /*st_fx->Q_syn2-1*/ st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); + move32(); L_tmp = L_deposit_l( 0 ); FOR( ; i < L_FRAME; i++ ) { @@ -309,6 +319,7 @@ void bw_switching_pre_proc_fx( } L_tmp = L_shr( L_tmp, 7 ); /*st_fx->Q_syn2-1*/ st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); + move32(); } } @@ -318,13 +329,15 @@ void bw_switching_pre_proc_fx( test(); test(); test(); + test(); + test(); IF( st_fx->last_bwidth == 0 && LE_16( st_fx->extl, SWB_CNG ) ) { st_fx->prev_ener_shb_fx = 0; move16(); set16_fx( st_fx->prev_SWB_fenv_fx, 0, SWB_FENV ); } - ELSE if ( ( ( EQ_16( st_fx->core, ACELP_CORE ) && ( EQ_16( st_fx->last_core, HQ_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) || EQ_16( st_fx->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st_fx->core, st_fx->last_core ) && NE_16( st_fx->extl, st_fx->last_extl ) ) ) && GE_16( st_fx->last_bwidth, SWB ) ) + ELSE IF( ( ( st_fx->core == ACELP_CORE && ( EQ_16( st_fx->last_core, HQ_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) || EQ_16( st_fx->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st_fx->core, st_fx->last_core ) && NE_16( st_fx->extl, st_fx->last_extl ) ) ) && GE_16( st_fx->last_bwidth, SWB ) ) { st_fx->attenu_fx = 3277; move16(); @@ -334,6 +347,7 @@ void bw_switching_pre_proc_fx( test(); test(); test(); + test(); IF( EQ_16( st_fx->last_core, HQ_CORE ) || ( EQ_16( st_fx->last_core, ACELP_CORE ) && !( EQ_16( st_fx->last_extl, WB_TBE ) || EQ_16( st_fx->last_extl, SWB_TBE ) || EQ_16( st_fx->last_extl, FB_TBE ) ) && GT_32( st_fx->core_brate, ACELP_8k00 ) ) ) { st_fx->prev_fractive = 0; @@ -512,11 +526,12 @@ ivas_error core_switching_pre_dec_fx( hTcxDec = st_fx->hTcxDec; error = IVAS_ERR_OK; + move32(); test(); test(); test(); /* Codec switching */ - IF( EQ_16( st_fx->last_codec_mode, MODE2 ) || ( ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) && GT_16( st_fx->element_mode, EVS_MONO ) ) ) + IF( EQ_16( st_fx->last_codec_mode, MODE2 ) || ( ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) && st_fx->element_mode > EVS_MONO ) ) { st_fx->mem_deemph_fx = st_fx->syn[M]; move16(); @@ -535,6 +550,8 @@ ivas_error core_switching_pre_dec_fx( set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st_fx->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */ hBPF->pst_mem_deemp_err_fx = 0; + move16(); + move16(); } move16(); st_fx->psf_lp_noise_fx = round_fx( L_shl( st_fx->lp_noise, 1 ) ); @@ -548,6 +565,7 @@ ivas_error core_switching_pre_dec_fx( { st_fx->old_bwe_delay = NS2SA_FX2( st_fx->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); } + move16(); set16_fx( st_fx->hb_prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); /* reset upd_cnt */ @@ -565,6 +583,7 @@ ivas_error core_switching_pre_dec_fx( /* reset BWE memories */ set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); + move32(); } test(); @@ -605,11 +624,11 @@ ivas_error core_switching_pre_dec_fx( test(); IF( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) { - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + IF( st_fx->element_mode == EVS_MONO ) { st_fx->last_core = HQ_CORE; move16(); - Copy( hTcxDec->FBTCXdelayBuf, st_fx->prev_synth_buffer_fx, NS2SA( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); + Copy( hTcxDec->FBTCXdelayBuf, st_fx->prev_synth_buffer_fx, NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); } IF( hHQ_core != NULL ) { @@ -641,6 +660,8 @@ ivas_error core_switching_pre_dec_fx( delay_comp = NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ); + test(); + test(); IF( !st_fx->last_con_tcx && st_fx->last_core_bfi == ACELP_CORE && EQ_16( st_fx->core, HQ_CORE ) ) { @@ -682,7 +703,6 @@ ivas_error core_switching_pre_dec_fx( cldfb_restore_memory( st_fx->cldfbSyn ); } - test(); test(); test(); IF( !st_fx->last_con_tcx && st_fx->last_core_bfi == ACELP_CORE && EQ_16( st_fx->core, HQ_CORE ) ) @@ -823,6 +843,7 @@ ivas_error core_switching_pre_dec_fx( st_fx->gc_threshold_fx = 0; move16(); st_fx->dm_fx.prev_gain_code = L_deposit_l( 0 ); + move32(); set16_fx( st_fx->dm_fx.prev_gain_pit, 0, 6 ); st_fx->dm_fx.prev_state = 0; move16(); @@ -849,6 +870,7 @@ ivas_error core_switching_pre_dec_fx( L_tmp = Isqrt_lc( L_tmp, &exp ); st_fx->lp_gainc_fx = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* In Q3 */ + move16(); } @@ -881,13 +903,14 @@ ivas_error core_switching_pre_dec_fx( set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); } + test(); IF( GE_32( st_fx->output_Fs, 16000L ) && st_fx->hBWE_zero != NULL ) { hf_synth_reset_fx( st_fx->hBWE_zero ); } IF( hBWE_FD != NULL ) { - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); + set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_NS ) ); } } #ifdef IVAS_CODE_SWITCHING @@ -944,11 +967,13 @@ ivas_error core_switching_pre_dec_fx( set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); hHQ_core->last_max_pos_pulse = 0; + move16(); set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM ); hHQ_core->prev_frm_hfe2 = 0; hHQ_core->prev_stab_hfe2 = 0; - + move16(); + move16(); IF( GT_32( st_fx->output_Fs, 16000 ) ) { set32_fx( hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); @@ -983,16 +1008,19 @@ ivas_error core_switching_pre_dec_fx( set16_fx( hHQ_core->old_out_fx, 0, output_frame ); hHQ_core->Q_old_wtda_LB = 15; hHQ_core->Q_old_wtda = 15; + move16(); #ifdef IVAS_CODE_SWITCHING set_f( st->hHQ_core->old_outLB, 0, L_FRAME16k ); #endif } } + test(); /* handle switching cases where preecho_sb was not called in the last frame (memory not up to date) */ IF( hHQ_core != NULL ) { hHQ_core->pastpre = sub( hHQ_core->pastpre, 1 ); + move16(); IF( hHQ_core->pastpre <= 0 ) { reset_preecho_dec_fx( hHQ_core ); @@ -1021,12 +1049,14 @@ ivas_error core_switching_pre_dec_fx( } /*switch on CNA on active frames*/ - test(); - test(); - test(); - test(); IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) /* for IVAS modes, st->flag_cna is set earlier */ { + test(); + test(); + test(); + test(); + test(); + test(); IF( NE_16( st_fx->core, AMR_WB_CORE ) && st_fx->VAD && LE_32( st_fx->total_brate, CNA_MAX_BRATE ) ) { st_fx->flag_cna = 1; @@ -1094,23 +1124,25 @@ ivas_error core_switching_pre_dec_fx( lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferAna + st_fx->last_L_frame, st_fx->hFdCngDec->hFdCngCom->olapBufferAna + st_fx->L_frame, st_fx->L_frame, st_fx->last_L_frame ); } #endif - lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, st_fx->L_frame * 2, st_fx->last_L_frame * 2 ); + lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st_fx->L_frame, 1 ), shl( st_fx->last_L_frame, 1 ) ); test(); IF( LE_32( st_fx->total_brate, SID_2k40 ) && LE_32( st_fx->last_total_brate, SID_2k40 ) ) { - lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth, st_fx->hFdCngDec->hFdCngCom->olapBufferSynth, st_fx->L_frame * 2, st_fx->last_L_frame * 2 ); + lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth, st_fx->hFdCngDec->hFdCngCom->olapBufferSynth, shl( st_fx->L_frame, 1 ), shl( st_fx->last_L_frame, 1 ) ); IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { - FOR( i = 0; i < st_fx->L_frame * 2; i++ ) + FOR( i = 0; i < shl( st_fx->L_frame, 1 ); i++ ) { st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i], 20480 ); + move16(); } } ELSE { - FOR( i = 0; i < st_fx->L_frame * 2; i++ ) + FOR( i = 0; i < shl( st_fx->L_frame, 1 ); i++ ) { st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( shl( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i], 1 ), 26214 ); + move16(); } } } @@ -1169,6 +1201,7 @@ ivas_error core_switching_post_dec_fx( hBWE_FD = st_fx->hBWE_FD; hHQ_core = st_fx->hHQ_core; error = IVAS_ERR_OK; + move32(); // PMT("core_switching_post_dec_fx : Only handles has been converted, code needs to be entirely reviewed ") @@ -1176,11 +1209,12 @@ ivas_error core_switching_post_dec_fx( tmp = Find_Max_Norm16( synth, output_frame ); Scale_sig( synth, output_frame, tmp ); *Qsynth = add( *Qsynth, tmp ); + move16(); test(); test(); test(); - IF( EQ_16( st_fx->core, ACELP_CORE ) && st_fx->bfi && hHQ_core != NULL && !st_fx->con_tcx ) + IF( st_fx->core == ACELP_CORE && st_fx->bfi && hHQ_core != NULL && !st_fx->con_tcx ) { if ( ( error = acelp_core_switch_dec_bfi_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK ) { @@ -1230,6 +1264,7 @@ ivas_error core_switching_post_dec_fx( { Copy( st_fx->delay_buf_out_fx, synth_subfr_out, delay_comp ); Qsubfr = hHQ_core->Q_old_postdec; + move16(); } /* delay HQ synthesis to synchronize with ACELP synthesis */ @@ -1257,7 +1292,7 @@ ivas_error core_switching_post_dec_fx( test(); test(); test(); - IF( core_switching_flag && EQ_16( st_fx->last_L_frame, st_fx->last_L_frame_ori ) && ( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) + IF( core_switching_flag && EQ_16( st_fx->last_L_frame, st_fx->last_L_frame_ori ) && ( st_fx->last_core == ACELP_CORE || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) { /* mem_over_hp_fx : Qsubfr */ core_switching_OLA_fx( mem_synth, st_fx->last_L_frame, st_fx->output_Fs, synth, synth_subfr_out, synth_subfr_bwe, output_frame, st_fx->bwidth, Qsynth, &Qsubfr ); @@ -1288,7 +1323,7 @@ ivas_error core_switching_post_dec_fx( tmpF = add( tmpF, tmp ); } } - ELSE IF( ( !core_switching_flag && EQ_16( st_fx->core, HQ_CORE ) && ( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) /* ACELP | TRANSITION | HQ with TRANSITION lost */ + ELSE IF( ( !core_switching_flag && EQ_16( st_fx->core, HQ_CORE ) && ( st_fx->last_core == ACELP_CORE || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) /* ACELP | TRANSITION | HQ with TRANSITION lost */ || ( core_switching_flag && st_fx->prev_bfi && NE_16( st_fx->last_L_frame, st_fx->last_L_frame_ori ) ) ) { /* Overlapp between CELP estimation (BFI) and good HQ frame on L/2 */ @@ -1307,6 +1342,7 @@ ivas_error core_switching_post_dec_fx( #else *ptmp1 = round_fx( L_mac( L_tmp, add( sub( 24576, tmpF ), 8192 ), ( *ptmp2 ) ) ); /*Qsynth*/ #endif + move16(); tmpF = add( tmpF, tmp ); ptmp1++; ptmp2++; @@ -1314,6 +1350,7 @@ ivas_error core_switching_post_dec_fx( } hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); + move32(); IF( !( EQ_16( inner_frame_tbl[st_fx->bwidth], L_FRAME16k ) && EQ_32( st_fx->core_brate, HQ_32k ) ) ) { set32_fx( hHQ_core->prev_env_fx, 0, SFM_N_WB ); @@ -1359,6 +1396,7 @@ ivas_error core_switching_post_dec_fx( FOR( i = 0; i < shift; i++ ) { *ptmp1 = add( mult_r( tmpF, *ptmp1 ), mult_r( sub( 32767, tmpF ), *ptmp2++ ) ); + move16(); ptmp1++; tmpF = add( tmpF, tmp ); } @@ -1379,6 +1417,16 @@ ivas_error core_switching_post_dec_fx( test(); test(); test(); + IF( st_fx->bws_cnt == 0 || ( st_fx->bws_cnt > 0 && NE_16( st_fx->coder_type, INACTIVE ) && NE_16( st_fx->coder_type, AUDIO ) ) ) + { + st_fx->attenu_fx = 3277; + move16(); + } + + test(); + test(); + test(); + test(); test(); test(); test(); @@ -1388,14 +1436,8 @@ ivas_error core_switching_post_dec_fx( test(); test(); test(); - IF( st_fx->bws_cnt == 0 || ( st_fx->bws_cnt > 0 && NE_16( st_fx->coder_type, INACTIVE ) && NE_16( st_fx->coder_type, AUDIO ) ) ) - { - st_fx->attenu_fx = 3277; - move16(); - } - IF( ( NE_16( st_fx->last_extl, SWB_BWE ) && EQ_16( st_fx->extl, SWB_BWE ) ) || ( NE_16( st_fx->last_extl, FB_BWE ) && EQ_16( st_fx->extl, FB_BWE ) ) || - ( ( EQ_16( st_fx->last_core, HQ_CORE ) || EQ_16( st_fx->last_extl, SWB_TBE ) ) && st_fx->extl < 0 && NE_16( st_fx->core, HQ_CORE ) ) || ( EQ_16( st_fx->last_core, ACELP_CORE ) && EQ_16( st_fx->core, ACELP_CORE ) && ( ( NE_16( st_fx->prev_coder_type, INACTIVE ) && EQ_16( st_fx->coder_type, INACTIVE ) ) || ( NE_16( st_fx->prev_coder_type, AUDIO ) && EQ_16( st_fx->coder_type, AUDIO ) ) ) && st_fx->bws_cnt > 0 ) ) + ( ( EQ_16( st_fx->last_core, HQ_CORE ) || EQ_16( st_fx->last_extl, SWB_TBE ) ) && st_fx->extl < 0 && NE_16( st_fx->core, HQ_CORE ) ) || ( st_fx->last_core == ACELP_CORE && st_fx->core == ACELP_CORE && ( ( NE_16( st_fx->prev_coder_type, INACTIVE ) && EQ_16( st_fx->coder_type, INACTIVE ) ) || ( NE_16( st_fx->prev_coder_type, AUDIO ) && EQ_16( st_fx->coder_type, AUDIO ) ) ) && st_fx->bws_cnt > 0 ) ) { set16_fx( hBWE_FD->L_old_wtda_swb_fx, 0, output_frame ); hBWE_FD->old_wtda_swb_fx_exp = 0; @@ -1458,6 +1500,10 @@ ivas_error core_switching_post_dec_fx( test(); test(); test(); + test(); + test(); + test(); + test(); IF( ( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) || EQ_16( st_fx->extl, SWB_CNG ) ) && ( NE_16( st_fx->L_frame, st_fx->last_L_frame ) || ( NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) ) || EQ_16( st_fx->last_core, HQ_CORE ) ) ) || ( LT_16( st_fx->bwidth, st_fx->last_bwidth ) && NE_16( st_fx->last_extl, SWB_TBE ) ) || st_fx->old_ppp_mode || ( ( EQ_16( st_fx->prev_coder_type, AUDIO ) || EQ_16( st_fx->prev_coder_type, INACTIVE ) ) && st_fx->bws_cnt > 0 ) || ( st_fx->bws_cnt == 0 && EQ_16( st_fx->prev_bws_cnt, N_WS2N_FRAMES ) ) ) @@ -1505,6 +1551,7 @@ ivas_error core_switching_post_dec_fx( { set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); hBWE_TD->fb_tbe_demph_fx = 0; + move16(); fb_tbe_reset_synth_fx( hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, &hBWE_TD->prev_fbbwe_ratio_fx ); } @@ -1554,12 +1601,13 @@ ivas_error core_switching_post_dec_ivas_fx( int16_t offset; L_tmp = 0; - + move32(); hBWE_TD = st_fx->hBWE_TD; hBWE_FD = st_fx->hBWE_FD; hHQ_core = st_fx->hHQ_core; error = IVAS_ERR_OK; + move32(); // PMT("core_switching_post_dec_fx : Only handles has been converted, code needs to be entirely reviewed ") @@ -1567,11 +1615,12 @@ ivas_error core_switching_post_dec_ivas_fx( tmp = Find_Max_Norm16( synth, output_frame ); Scale_sig( synth, output_frame, tmp ); *Qsynth = add( *Qsynth, tmp ); + move16(); test(); test(); test(); - IF( EQ_16( st_fx->core, ACELP_CORE ) && st_fx->bfi && hHQ_core != NULL && !st_fx->con_tcx ) + IF( st_fx->core == ACELP_CORE && st_fx->bfi && hHQ_core != NULL && !st_fx->con_tcx ) { /*needed to be converted to fixed curretnly using evs implementation not in line*/ if ( ( error = acelp_core_switch_dec_bfi_ivas_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK ) @@ -1594,8 +1643,18 @@ ivas_error core_switching_post_dec_ivas_fx( /* set delay compensation between HQ synthesis and ACELP synthesis */ delay_comp = i_mult2( delta, HQ_DELAY_COMP ); /*needed to add more condition in if*/ + test(); + test(); + test(); + test(); + test(); IF( ( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft ) && ( !sba_dirac_stereo_flag || ( sba_dirac_stereo_flag && EQ_32( st_fx->core_brate, SID_2k40 ) && EQ_16( st_fx->cng_type, FD_CNG ) ) ) ) { + test(); + test(); + test(); + test(); + test(); IF( EQ_16( st_fx->core, HQ_CORE ) || EQ_16( st_fx->core, TCX_20_CORE ) || EQ_16( st_fx->core, TCX_10_CORE ) || ( EQ_16( st_fx->core, ACELP_CORE ) && EQ_16( st_fx->bfi, 1 ) && EQ_16( st_fx->con_tcx, 1 ) ) ) { st_fx->use_acelp_preq = 0; @@ -1607,14 +1666,15 @@ ivas_error core_switching_post_dec_ivas_fx( IF( st_fx->hBWE_FD != NULL ) { hBWE_FD->mem_deemph_old_syn_fx = 0; + move16(); } - move16(); test(); - test(); - test(); - IF( EQ_16( st_fx->element_mode, EVS_MONO ) && EQ_16( st_fx->core, HQ_CORE ) ) + IF( st_fx->element_mode == EVS_MONO && EQ_16( st_fx->core, HQ_CORE ) ) { + test(); + test(); + test(); IF( core_switching_flag && EQ_16( st_fx->last_L_frame, st_fx->last_L_frame_ori ) && ( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) { IF( ( error = acelp_core_switch_dec_fx( st_fx, synth_subfr_out, synth_subfr_bwe, output_frame, core_switching_flag, mem_synth, &Qsubfr ) ) != IVAS_ERR_OK ) @@ -1629,6 +1689,7 @@ ivas_error core_switching_post_dec_ivas_fx( { Copy( st_fx->delay_buf_out_fx, synth_subfr_out, delay_comp ); Qsubfr = hHQ_core->Q_old_postdec; + move16(); } } /* delay HQ synthesis to synchronize with ACELP synthesis */ @@ -1643,8 +1704,8 @@ ivas_error core_switching_post_dec_ivas_fx( Word16 temp_buffer[L_FRAME48k]; Copy( st_fx->delay_buf_out_fx, temp_buffer, delay_comp ); - Copy( synth + output_frame - delay_comp, st_fx->delay_buf_out_fx, delay_comp ); - Copy( synth, synth + delay_comp, output_frame - delay_comp ); + Copy( synth + sub( output_frame, delay_comp ), st_fx->delay_buf_out_fx, delay_comp ); + Copy( synth, synth + delay_comp, sub( output_frame, delay_comp ) ); Copy( temp_buffer, synth, delay_comp ); test(); @@ -1652,16 +1713,20 @@ ivas_error core_switching_post_dec_ivas_fx( test(); test(); test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st_fx->element_mode, EVS_MONO ) && EQ_16( st_fx->core, HQ_CORE ) ) + IF( st_fx->element_mode == EVS_MONO && EQ_16( st_fx->core, HQ_CORE ) ) { - - IF( core_switching_flag && EQ_16( st_fx->last_L_frame, st_fx->last_L_frame_ori ) && ( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( core_switching_flag && EQ_16( st_fx->last_L_frame, st_fx->last_L_frame_ori ) && ( st_fx->last_core == ACELP_CORE || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) { /* mem_over_hp_fx : Qsubfr */ core_switching_OLA_fx( mem_synth, st_fx->last_L_frame, st_fx->output_Fs, synth, synth_subfr_out, synth_subfr_bwe, output_frame, st_fx->bwidth, Qsynth, &Qsubfr ); @@ -1692,7 +1757,7 @@ ivas_error core_switching_post_dec_ivas_fx( tmpF = add( tmpF, tmp ); } } - ELSE IF( ( !core_switching_flag && EQ_16( st_fx->core, HQ_CORE ) && ( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) /* ACELP | TRANSITION | HQ with TRANSITION lost */ + ELSE IF( ( !core_switching_flag && EQ_16( st_fx->core, HQ_CORE ) && ( st_fx->last_core == ACELP_CORE || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) /* ACELP | TRANSITION | HQ with TRANSITION lost */ || ( core_switching_flag && st_fx->prev_bfi && NE_16( st_fx->last_L_frame, st_fx->last_L_frame_ori ) ) ) { /* Overlapp between CELP estimation (BFI) and good HQ frame on L/2 */ @@ -1711,13 +1776,14 @@ ivas_error core_switching_post_dec_ivas_fx( #else *ptmp1 = round_fx( L_mac( L_tmp, add( sub( 24576, tmpF ), 8192 ), ( *ptmp2 ) ) ); /*Qsynth*/ #endif + move16(); tmpF = add( tmpF, tmp ); ptmp1++; ptmp2++; } } } - ELSE IF( ( ( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core_bfi, ACELP_CORE ) ) && !( EQ_16( st_fx->prev_bfi, 1 ) && EQ_16( st_fx->last_con_tcx, 1 ) ) ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) + ELSE IF( ( ( st_fx->last_core == ACELP_CORE || st_fx->last_core_bfi == ACELP_CORE ) && !( EQ_16( st_fx->prev_bfi, 1 ) && EQ_16( st_fx->last_con_tcx, 1 ) ) ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) { test(); test(); @@ -1727,7 +1793,6 @@ ivas_error core_switching_post_dec_ivas_fx( test(); test(); test(); - test(); IF( ( ( NE_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_core_brate, FRAME_NO_DATA ) ) || ( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) && NE_16( st_fx->element_mode, IVAS_CPE_TD ) ) || EQ_16( nchan_out, 1 ) ) && !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( st_fx->idchan, 1 ) && ( EQ_16( nchan_out, 1 ) || EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) ) { Scale_sig32( output_fx, L_FRAME48k, Q10 - Q4 ); @@ -1743,16 +1808,20 @@ ivas_error core_switching_post_dec_ivas_fx( { L_tmp = 0; L_tmp2 = 0; + move32(); + move32(); tmp = st_fx->previoussynth_fx[i + delay_comp]; L_tmp = L_mac0( L_tmp, div_s( i, tmpDelta ), synth[i + delay_comp] ); L_tmp = L_shl( L_tmp, 1 ); L_tmp2 = L_mac0( L_tmp2, div_s( sub( tmpDelta, i ), tmpDelta ), tmp ); L_tmp2 = L_shl( L_tmp2, 1 ); synth[i + delay_comp] = round_fx( L_add( L_tmp, L_tmp2 ) ); + move16(); } test(); test(); test(); + test(); IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || ( EQ_16( ivas_format, ISM_FORMAT ) && EQ_16( st_fx->core, TCX_20_CORE ) /* <- means TCX in general, TCX10 is forbidden after ACELP */ ) ) && LE_32( st_fx->last_core_brate, SID_2k40 ) && GT_32( st_fx->core_brate, SID_2k40 ) ) { /* smooth transitions to avoid pops in car noise items */ @@ -1776,13 +1845,16 @@ ivas_error core_switching_post_dec_ivas_fx( IF( st_fx->cldfbAna != NULL ) { delta = st_fx->cldfbAna->no_channels; + move16(); offset = sub( st_fx->cldfbAna->p_filter_length, st_fx->cldfbAna->no_channels ); tmp = div_s( 1, delta ); alpha = tmp; + move16(); FOR( i = 0; i < delta; i++ ) { st_fx->cldfbAna->cldfb_state_fx[offset - delta + i] = Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q4 ), alpha ); + move32(); IF( alpha < sub( 32767, tmp ) ) { alpha = add( alpha, tmp ); @@ -1794,9 +1866,10 @@ ivas_error core_switching_post_dec_ivas_fx( } } st_fx->cldfbAna->Q_cldfb_state = Q10; + move16(); } } - ELSE IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + ELSE IF( st_fx->element_mode != EVS_MONO ) { /*needed to be filled with ivas specific code*/ /* Reset memories of CLDFBs */ @@ -1804,8 +1877,8 @@ ivas_error core_switching_post_dec_ivas_fx( { IF( NE_16( i_mult( st_fx->cldfbAna->no_channels, st_fx->cldfbAna->no_col ), st_fx->L_frame ) ) { - configureCldfb_ivas_fx( st_fx->cldfbAna, st_fx->L_frame * FRAMES_PER_SEC ); - configureCldfb_ivas_fx( st_fx->cldfbBPF, L_min( 16000, st_fx->L_frame * FRAMES_PER_SEC ) ); + configureCldfb_ivas_fx( st_fx->cldfbAna, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) ); + configureCldfb_ivas_fx( st_fx->cldfbBPF, L_min( 16000, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) ) ); } cldfb_reset_memory_fx( st_fx->cldfbAna ); @@ -1822,13 +1895,16 @@ ivas_error core_switching_post_dec_ivas_fx( IF( st_fx->cldfbAna != NULL ) { delta = st_fx->cldfbAna->no_channels; + move16(); offset = sub( st_fx->cldfbAna->p_filter_length, st_fx->cldfbAna->no_channels ); tmp = div_s( 1, delta ); alpha = tmp; + move16(); FOR( i = 0; i < delta; i++ ) { st_fx->cldfbAna->cldfb_state_fx[offset - delta + i] = Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q4 ), alpha ); + move32(); IF( alpha < sub( 32767, tmp ) ) { alpha = add( alpha, tmp ); @@ -1840,11 +1916,13 @@ ivas_error core_switching_post_dec_ivas_fx( } } st_fx->cldfbAna->Q_cldfb_state = Q10; + move16(); } } IF( st_fx->hBWE_TD != NULL ) { hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); + move32(); } IF( st_fx->hHQ_core != NULL && !( EQ_16( inner_frame_tbl[st_fx->bwidth], L_FRAME16k ) && EQ_32( st_fx->core_brate, HQ_32k ) ) ) { @@ -1857,11 +1935,13 @@ ivas_error core_switching_post_dec_ivas_fx( IF( st_fx->hBPF != NULL ) { st_fx->hPFstat->on = 0; + move16(); } - move16(); } ELSE { + test(); + test(); IF( EQ_16( st_fx->last_core, HQ_CORE ) || st_fx->last_core == TCX_20_CORE || st_fx->last_core == TCX_10_CORE ) /* MDCT to ACELP transition */ { Qtmp = s_min( *Qsynth, 0 ); @@ -1892,7 +1972,9 @@ ivas_error core_switching_post_dec_ivas_fx( nzeroes = i_mult2( delta, N_ZERO_8 ); shift = i_mult2( Fs_kHz, 3 ); test(); - IF( st_fx->prev_bfi && st_fx->hHQ_core != NULL && hHQ_core->HqVoicing && st_fx->last_core == HQ_CORE ) + test(); + test(); + IF( st_fx->prev_bfi && st_fx->hHQ_core != NULL && hHQ_core->HqVoicing && EQ_16( st_fx->last_core, HQ_CORE ) ) { Copy_Scale_sig( hHQ_core->fer_samples_fx, &hHQ_core->old_out_fx[nzeroes], shift, *Qsynth ); } @@ -1904,9 +1986,10 @@ ivas_error core_switching_post_dec_ivas_fx( { ptmp2 = output_mem_fx; ptmp1 = &synth[delay_comp]; - FOR( i = 0; i < NS2SA( st_fx->output_Fs, 3000000 ); i++ ) + FOR( i = 0; i < NS2SA_FX2( st_fx->output_Fs, 3000000 ); i++ ) { *ptmp1 = add( mult_r( tmpF, *ptmp1 ), mult_r( sub( 32767, tmpF ), *ptmp2 ) ); + move16(); ptmp1++; ptmp2++; tmpF = add( tmpF, tmp ); @@ -1916,13 +1999,14 @@ ivas_error core_switching_post_dec_ivas_fx( { ptmp2 = &hHQ_core->old_out_fx[nzeroes]; ptmp1 = &synth[delay_comp]; - FOR( i = 0; i < NS2SA( st_fx->output_Fs, 3000000 ); i++ ) + FOR( i = 0; i < NS2SA_FX2( st_fx->output_Fs, 3000000 ); i++ ) { L_tmp = L_mult0( st_fx->hTcxDec->conceal_eof_gain, *ptmp2 ); L_tmp = L_shl( L_tmp, 1 ); tmpV = round_fx( L_tmp ); *ptmp1 = add( mult_r( tmpF, *ptmp1 ), mult_r( sub( 32767, tmpF ), tmpV ) ); + move16(); ptmp1++; ptmp2++; } @@ -1934,6 +2018,7 @@ ivas_error core_switching_post_dec_ivas_fx( FOR( i = 0; i < shift; i++ ) { *ptmp1 = add( mult_r( tmpF, *ptmp1 ), mult_r( sub( 32767, tmpF ), *ptmp2 ) ); + move16(); ptmp1++; ptmp2++; tmpF = add( tmpF, tmp ); @@ -1945,20 +2030,32 @@ ivas_error core_switching_post_dec_ivas_fx( IF( hHQ_core != NULL ) { hHQ_core->oldHqVoicing = 0; + move16(); } - move16(); } } ELSE { /* memory update needed for DFT stereo -> TD stereo switching, scaling synth to Q0 */ - Copy_Scale_sig( synth + output_frame - delay_comp, st_fx->delay_buf_out_fx, delay_comp, negate( *Qsynth ) ); + Copy_Scale_sig( synth + sub( output_frame, delay_comp ), st_fx->delay_buf_out_fx, delay_comp, negate( *Qsynth ) ); } /* reset SWB BWE buffers */ test(); test(); test(); + IF( st_fx->bws_cnt == 0 || ( st_fx->bws_cnt > 0 && NE_16( st_fx->coder_type, INACTIVE ) && NE_16( st_fx->coder_type, AUDIO ) ) ) + { + st_fx->attenu_fx = 3277; + move16(); + } + + test(); + test(); + test(); + test(); + test(); + test(); test(); test(); test(); @@ -1968,12 +2065,6 @@ ivas_error core_switching_post_dec_ivas_fx( test(); test(); test(); - IF( st_fx->bws_cnt == 0 || ( st_fx->bws_cnt > 0 && NE_16( st_fx->coder_type, INACTIVE ) && NE_16( st_fx->coder_type, AUDIO ) ) ) - { - st_fx->attenu_fx = 3277; - move16(); - } - IF( ( st_fx->hBWE_FD != NULL ) && ( ( NE_16( st_fx->last_extl, SWB_BWE ) && EQ_16( st_fx->extl, SWB_BWE ) ) || ( NE_16( st_fx->last_extl, FB_BWE ) && EQ_16( st_fx->extl, FB_BWE ) ) || ( ( EQ_16( st_fx->last_core, HQ_CORE ) || EQ_16( st_fx->last_extl, SWB_TBE ) ) && st_fx->extl < 0 && NE_16( st_fx->core, HQ_CORE ) ) || ( EQ_16( st_fx->last_core, ACELP_CORE ) && EQ_16( st_fx->core, ACELP_CORE ) && ( ( NE_16( st_fx->prev_coder_type, INACTIVE ) && EQ_16( st_fx->coder_type, INACTIVE ) ) || ( NE_16( st_fx->prev_coder_type, AUDIO ) && EQ_16( st_fx->coder_type, AUDIO ) ) ) && st_fx->bws_cnt > 0 ) ) ) { @@ -2003,6 +2094,7 @@ ivas_error core_switching_post_dec_ivas_fx( /* reset WB BWE buffers */ test(); + test(); IF( NE_16( st_fx->last_extl, WB_BWE ) && EQ_16( st_fx->extl, WB_BWE ) && st_fx->hBWE_FD != NULL ) { set16_fx( hBWE_FD->L_old_wtda_swb_fx, 0, output_frame ); @@ -2041,6 +2133,14 @@ ivas_error core_switching_post_dec_ivas_fx( test(); test(); test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); #ifdef FIX_747_TDBWE_ENERGY_BURST IF( ( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) || EQ_16( st_fx->extl, SWB_CNG ) ) && @@ -2062,6 +2162,8 @@ ivas_error core_switching_post_dec_ivas_fx( st_fx->hBWE_TD->prev_pow_exc16kWhtnd_fx32 = 1; /* Q0 1.f */ st_fx->hBWE_TD->prev_mix_factor_fx = 32767; /* Q15 1.f */ + move16(); + move16(); IF( EQ_16( output_frame, L_FRAME16k ) ) { @@ -2083,7 +2185,7 @@ ivas_error core_switching_post_dec_ivas_fx( hBWE_TD->gain_prec_swb_fx = 16384; move16(); /*Q14 = 1 */ } - ELSE IF( st_fx->hBWE_TD != NULL && ( st_fx->last_core == TCX_20_CORE || st_fx->last_core == TCX_10_CORE ) ) + ELSE IF( st_fx->hBWE_TD != NULL && ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) ) { TBEreset_dec_ivas_fx( st_fx ); } @@ -2095,6 +2197,7 @@ ivas_error core_switching_post_dec_ivas_fx( { set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); hBWE_TD->fb_tbe_demph_fx = 0; + move16(); fb_tbe_reset_synth_fx( hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, &hBWE_TD->prev_fbbwe_ratio_fx ); } @@ -2160,10 +2263,14 @@ void core_switching_hq_prepare_dec_fx( IF( GE_32( st_fx->core_brate, ACELP_11k60 ) ) { ( *num_bits ) = sub( ( *num_bits ), 1 ); /* LP_FLAG bit */ + move16(); } *num_bits = sub( ( *num_bits ), ACB_bits_tbl[BIT_ALLOC_IDX_fx( cbrate, GENERIC, 0, 0 )] ); /* pitch bits*/ *num_bits = sub( ( *num_bits ), gain_bits_tbl[BIT_ALLOC_IDX_fx( cbrate, TRANSITION, 0, 0 )] ); /* gain bits */ *num_bits = sub( ( *num_bits ), FCB_bits_tbl[BIT_ALLOC_IDX_fx( cbrate, GENERIC, 0, 0 )] ); /* FCB bits */ + move16(); + move16(); + move16(); } ELSE /* L_frame == L_FRAME16k */ { @@ -2184,10 +2291,14 @@ void core_switching_hq_prepare_dec_fx( IF( GE_32( st_fx->core_brate, ACELP_11k60 ) ) { ( *num_bits ) = sub( ( *num_bits ), 1 ); /* LP_FLAG bit */ + move16(); } *num_bits = sub( ( *num_bits ), ACB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( cbrate, GENERIC, 0, 0 )] ); /* pitch bits*/ *num_bits = sub( ( *num_bits ), gain_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( cbrate, GENERIC, 0, 0 )] ); /* gain bits */ *num_bits = sub( ( *num_bits ), FCB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( cbrate, GENERIC, 0, 0 )] ); /* FCB bits */ + move16(); + move16(); + move16(); } /* subtract BWE bits */ @@ -2196,6 +2307,7 @@ void core_switching_hq_prepare_dec_fx( IF( !( ( EQ_16( inner_frame_tbl[st_fx->bwidth], L_FRAME16k ) && EQ_16( st_fx->last_L_frame, L_FRAME16k ) ) || EQ_16( inner_frame_tbl[st_fx->bwidth], L_FRAME8k ) ) ) { *num_bits = sub( ( *num_bits ), ( NOOFGAINBITS1 + AUDIODELAYBITS ) ); + move16(); } /* reset state of old_out if switching */ @@ -2222,10 +2334,12 @@ static void core_switch_lb_upsamp_fx( set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); realBuffer_fx[i] = realBufferTmp_fx[i]; imagBuffer_fx[i] = imagBufferTmp_fx[i]; + move32(); + move32(); } /* check if the CLDFB works on the right sample rate */ - IF( NE_16( ( st->cldfbAna->no_channels * st->cldfbAna->no_col ), st->L_frame ) ) + IF( NE_16( imult1616( st->cldfbAna->no_channels, st->cldfbAna->no_col ), st->L_frame ) ) { resampleCldfb_ivas_fx( st->cldfbAna, L_mult0( st->L_frame, FRAMES_PER_SEC ) ); @@ -2234,7 +2348,7 @@ static void core_switch_lb_upsamp_fx( resampleCldfb_ivas_fx( st->cldfbBPF, L_mult0( st->L_frame, FRAMES_PER_SEC ) ); } - IF( GT_16( st->ini_frame, 0 ) ) + IF( st->ini_frame > 0 ) { st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); move16(); @@ -2254,6 +2368,7 @@ static void core_switch_lb_upsamp_fx( { /* set NB mask for upsampling */ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 ); + move16(); } ELSE IF( NE_16( st->cldfbSyn->bandsToZero, sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ) ) ) { @@ -2267,13 +2382,17 @@ static void core_switch_lb_upsamp_fx( /*rescaling whole buffer to a common Q*/ no_col = st->cldfbSyn->no_col; + move16(); - IF( CLDFB_OVRLP_MIN_SLOTS * st->cldfbSyn->no_channels > -1 ) + IF( GT_16( imult1616( CLDFB_OVRLP_MIN_SLOTS, st->cldfbSyn->no_channels ), -1 ) ) { - no_col = s_min( no_col, ( CLDFB_OVRLP_MIN_SLOTS * st->cldfbSyn->no_channels + st->cldfbSyn->no_channels - 1 ) / st->cldfbSyn->no_channels ); + Word16 temp, temp_e; + temp = BASOP_Util_Divide1616_Scale( ( add( imult1616( CLDFB_OVRLP_MIN_SLOTS, st->cldfbSyn->no_channels ), sub( st->cldfbSyn->no_channels, 1 ) ) ), st->cldfbSyn->no_channels, &temp_e ); /*Q=15-temp_e*/ + temp = shr( temp, sub( 15, temp_e ) ); /*Shifting to make Q 0*/ + no_col = s_min( no_col, temp ); } - Scale_sig32( output + no_col * st->cldfbSyn->no_channels, L_FRAME48k - no_col * st->cldfbSyn->no_channels, 4 - 10 ); + Scale_sig32( output + imult1616( no_col, st->cldfbSyn->no_channels ), sub( L_FRAME48k, imult1616( no_col, st->cldfbSyn->no_channels ) ), 4 - 10 ); /* save synthesis - needed in case of core switching */ IF( st->hTcxDec != NULL ) @@ -2298,13 +2417,15 @@ static void smoothTransitionDtxToTcx_fx( Word16 w, step, fade_in; Word32 mem; #ifdef MSAN_FIX - Word16 smoothing_input_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k] = { 0 }; - Word16 smoothing_out_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k] = { 0 }; + Word16 smoothing_input_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k]; + Word16 smoothing_out_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k]; #else Word16 smoothing_input_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k]; Word16 smoothing_out_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k]; #endif + set16_fx( smoothing_input_buffer, 0, 2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k ); + set16_fx( smoothing_out_buffer, 0, 2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k ); filter_len = TRANSITION_SMOOTHING_LEN_16k; move16(); IF( EQ_16( output_frame, L_FRAME32k ) ) diff --git a/lib_dec/dec4t64_fx.c b/lib_dec/dec4t64_fx.c index dd126cc2d2b069124cb0995f05dc1bd0f12e71a1..23561f30592bd1623896ab4e859a253e90a04176 100644 --- a/lib_dec/dec4t64_fx.c +++ b/lib_dec/dec4t64_fx.c @@ -558,6 +558,7 @@ static void dec_6p_6N2_fx( offsetA = offsetB = j; move16(); + move16(); logic16(); IF( L_and( L_shr( index, sub( n_6, 5 ) ), 1L ) == 0 ) { @@ -579,22 +580,18 @@ static void dec_6p_6N2_fx( case 0: dec_5p_5N_fx( L_shr( index, N ), n_1, offsetA, pos ); /* Dec_5p_5N(index>>N, n_1, offsetA, pos); */ dec_1p_N1_fx( index, n_1, offsetA, pos + 5 ); - move16(); BREAK; case 1: dec_5p_5N_fx( L_shr( index, N ), n_1, offsetA, pos ); /* Dec_5p_5N(index>>N, n_1, offsetA, pos); */ dec_1p_N1_fx( index, n_1, offsetB, pos + 5 ); - move16(); BREAK; case 2: dec_4p_4N_fx( L_shr( index, add( shl( n_1, 1 ), 1 ) ), n_1, offsetA, pos ); /* Dec_4p_4N(index>>((2*n_1)+1 ), n_1, offsetA, pos); */ dec_2p_2N1_fx( index, n_1, offsetB, pos + 4 ); - move16(); BREAK; case 3: dec_3p_3N1_fx( L_shr( index, add( add( shl( n_1, 1 ), n_1 ), 1 ) ), n_1, offset, pos ); /* Dec_3p_3N1(index>>((3*n_1)+ 1), n_1, offset, pos); */ dec_3p_3N1_fx( index, n_1, j, pos + 3 ); - move16(); BREAK; } } @@ -618,6 +615,7 @@ static Word32 fcb_decode_class_all_p_fx( /* o: The ind /* (*code_index) -= PI_offset[pulse_num][i-1];*/ ( *code_index ) = L_sub( ( *code_index ), PI_offset[pulse_num][i - 1] ); +move32(); /*pulse_pos_num = pulse_num - i + 2;*/ pulse_pos_num = add( sub( pulse_num, i ), 2 ); diff --git a/lib_dec/dec_acelp_fx.c b/lib_dec/dec_acelp_fx.c index 2ddb636586c657e08970e04a0190791a2c5a6000..16e7f882d37f7b38b8b594049cbc3620292990ae 100644 --- a/lib_dec/dec_acelp_fx.c +++ b/lib_dec/dec_acelp_fx.c @@ -142,7 +142,7 @@ void D_ACELP_indexing_fx( ELSE { fcb_pulse_track_joint_decode_fx( idxs, wordcnt, index_n, pulsestrack, num_tracks ); - FOR( track = num_tracks - 1; track >= 1; track-- ) + FOR( track = sub( num_tracks, 1 ); track >= 1; track-- ) { pulses = pulsestrack[track]; move16(); @@ -157,7 +157,7 @@ void D_ACELP_indexing_fx( } ELSE /* track is empty */ { - FOR( k = track; k < 16 * num_tracks; k += num_tracks ) + FOR( k = track; k < imult1616( 16, num_tracks ); k += num_tracks ) { code[k] = 0; move16(); @@ -184,7 +184,7 @@ void D_ACELP_indexing_fx( } ELSE { /* track is empty */ - FOR( k = 0; k < 16 * num_tracks; k += num_tracks ) + FOR( k = 0; k < imult1616( 16, num_tracks ); k += num_tracks ) { code[k] = 0; move16(); @@ -340,7 +340,7 @@ void fcb_pulse_track_joint_decode_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *in pulse_num1 = pulse_num[track_num1]; move16(); index = L_add( L_lshl( index, hi_to_low[pulse_num1] ), L_lshr( index_n[track_num1], low_len[pulse_num1] ) ); - FOR( track = ( track_num - 1 ); track > 0; track-- ) + FOR( track = sub( track_num, 1 ); track > 0; track-- ) { track_num1 = sub( track, 1 ); pulse_num0 = pulse_num[track_num1]; @@ -351,6 +351,7 @@ void fcb_pulse_track_joint_decode_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *in iDiv_and_mod_32( index, indx_fact[pulse_num1], &div_tmp, &indx_tmp, 0 ); index_n[track] = L_add( L_and( index_n[track], low_mask[pulse_num1] ), L_lshl( indx_tmp, low_len[pulse_num1] ) ); + move32(); index = L_add( div_tmp, 0 ); } pulse_num1 = pulse_num[0]; diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c index 03ae965aabbbe968eff0187734c4b68253de0e5a..ea3fa74f515e7518e6c4f836f22be613fef3dd32 100644 --- a/lib_dec/dec_amr_wb_fx.c +++ b/lib_dec/dec_amr_wb_fx.c @@ -77,7 +77,7 @@ void decod_amr_wb_fx( 0, NULL #endif ); - + move16(); /*--------------------------------------------------------------* * Find the adaptive codebook vector *--------------------------------------------------------------*/ @@ -106,6 +106,7 @@ void decod_amr_wb_fx( lp_gain_updt_fx( i_subfr, gain_pit_fx, L_norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, L_gain_code_fx, &voice_fac_fx, st_fx->Q_exc ); + move16(); Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr], NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_SUBFR, 0, L_gain_code_fx, &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, i_subfr, -1 ); @@ -131,7 +132,8 @@ void decod_amr_wb_fx( IF( EQ_32( st_fx->core_brate, ACELP_23k85 ) ) { - hf_gain_fx[shr( i_subfr, 6 )] = (Word16) get_next_indice( st_fx, 4 ); + hf_gain_fx[i_subfr / 64] = (Word16) get_next_indice( st_fx, 4 ); + move16(); } /*voice_fac = VF_0th_PARAM + VF_1st_PARAM * voice_fac + VF_2nd_PARAM * voice_fac * voice_fac;*/ @@ -139,7 +141,9 @@ void decod_amr_wb_fx( L_tmp = L_mac( L_tmp, VF_1st_PARAM_FX, voice_fac_fx ); voice_fac_fx = mac_r( L_tmp, VF_0th_PARAM_FX, 32767 ); - Word16 idx = 0; + Word16 idx; + idx = 0; + move16(); IF( i_subfr != 0 ) { idx = idiv1616( i_subfr, L_SUBFR ); @@ -157,6 +161,7 @@ void decod_amr_wb_fx( } hAmrwb_IO->lt_voice_fac_fx = round_fx( L_Voice_fac_ave ); + move16(); return; } diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index b8d17a1e3938937c3c0ab77da7b78feaf47b2a37..0be898ed2697bd19894f93fdefe499b16491d52c 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -106,6 +106,14 @@ ivas_error decod_gen_voic_fx( #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + hMusicPF = st_fx->hMusicPF; GSC_DEC_HANDLE hGSCDec; @@ -113,6 +121,7 @@ ivas_error decod_gen_voic_fx( ivas_error error; error = IVAS_ERR_OK; + move32(); T0_fx = PIT_MIN; move16(); @@ -201,6 +210,7 @@ ivas_error decod_gen_voic_fx( gain_dec_mless_fx( st_fx, L_frame, st_fx->coder_type, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); } st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc ); + move16(); /*-----------------------------------------------------------------* * Transform domain contribution decoding @@ -263,6 +273,7 @@ ivas_error decod_gen_voic_fx( L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here */ exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( L_tmp, Ltmp1 ) ); + move16(); #else L_tmp = L_shl( L_tmp, 5 ); L_tmp = L_mac( L_tmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); @@ -282,6 +293,7 @@ ivas_error decod_gen_voic_fx( *-----------------------------------------------------------------*/ Word16 idx = 0; + move16(); IF( i_subfr_fx != 0 ) { idx = idiv1616( i_subfr_fx, L_SUBFR ); @@ -464,10 +476,12 @@ ivas_error decod_gen_voic_fx( GetSinCosTab_fx( rint_bfi_pitch, S_fx, C_fx ); DTFS_to_fs_fx( st_fx->hWIDec->old_exc2_fx + shft_prev, rint_bfi_pitch, PREVP, (Word16) st_fx->output_Fs, do_WI_fx, S_fx, C_fx ); PREVP->Q = add( PREVP->Q, st_fx->prev_Q_exc_fr ); + move16(); GetSinCosTab_fx( rint_pitch, S_fx, C_fx ); DTFS_to_fs_fx( exc2_fx + shft_curr, rint_pitch, CURRP, (Word16) st_fx->output_Fs, do_WI_fx, S_fx, C_fx ); CURRP->Q = add( CURRP->Q, st_fx->Q_exc ); + move16(); ph_offset_fx = 0; move16(); @@ -533,7 +547,7 @@ ivas_error decod_gen_voic_ivas_fx( const Word16 *Aq_fx, /* i : LP filter coefficient */ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ const Word16 do_WI_fx, /* i : do interpolation after a FER */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe */ Word16 *voice_factors_fx, /* o : voicing factors */ Word16 *exc_fx, /* i/o: adapt. excitation exc */ Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ @@ -547,20 +561,20 @@ ivas_error decod_gen_voic_ivas_fx( Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */ - Word16 gain_pit_fx = 0; /* pitch gain Q14 */ - Word32 gain_code_fx = 0; /* gain/normalized gain of the algebraic excitation Q16 */ - Word32 norm_gain_code_fx = 0; /* normalized gain of the algebraic excitation Q16 */ - Word16 gain_inov_fx = 0; /* Innovation gain Q12 */ + Word16 gain_pit_fx; /* pitch gain Q14 */ + Word32 gain_code_fx; /* gain/normalized gain of the algebraic excitation Q16 */ + Word32 norm_gain_code_fx; /* normalized gain of the algebraic excitation Q16 */ + Word16 gain_inov_fx; /* Innovation gain Q12 */ Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */ Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes */ Word16 voice_fac_fx; /* voicing factor Q15 */ Word16 code_fx[L_SUBFR]; /* algebraic codevector Q12 */ const Word16 *p_Aq_fx; /* Pointer to frame LP coefficient Q12 */ - Word16 *pt_pitch_fx; /* pointer to floating pitch Q6 */ + Word16 *pt_pitch_fx; /* pointer to Word16 pitch Q6 */ Word16 i_subfr_fx, i; /* tmp variables */ - Word16 error_fx = 0; - Word16 gain_preQ_fx = 0; /* Gain of prequantizer excitation */ + Word16 error_fx; + Word16 gain_preQ_fx; /* Gain of prequantizer excitation */ Word16 code_preQ_fx[L_SUBFR]; /* Prequantizer excitation */ Word32 norm_gain_preQ_fx; Word16 pitch_limit_flag_fx; @@ -595,9 +609,23 @@ ivas_error decod_gen_voic_ivas_fx( Word16 pf_temp[MAXLAG_WI]; Word16 pf_n2[MAXLAG_WI]; MUSIC_POSTFILT_HANDLE hMusicPF; + gain_pit_fx = 0; + gain_code_fx = 0; + norm_gain_code_fx = 0; + gain_inov_fx = 0; + error_fx = 0; + gain_preQ_fx = 0; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + hMusicPF = st_fx->hMusicPF; GSC_DEC_HANDLE hGSCDec; @@ -605,6 +633,7 @@ ivas_error decod_gen_voic_ivas_fx( ivas_error error; error = IVAS_ERR_OK; + move32(); T0_fx = PIT_MIN; move16(); @@ -696,6 +725,7 @@ ivas_error decod_gen_voic_ivas_fx( gain_dec_mless_fx( st_fx, L_frame, st_fx->coder_type, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); } st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); + move16(); /*-----------------------------------------------------------------* * Transform domain contribution decoding @@ -757,6 +787,7 @@ ivas_error decod_gen_voic_ivas_fx( #ifdef BASOP_NOGLOB L_tmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( L_tmp, Ltmp1 ) ); + move16(); #else L_tmp = L_shl( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); exc2_fx[i + i_subfr_fx] = round_fx( L_add( L_tmp, Ltmp1 ) ); @@ -770,6 +801,7 @@ ivas_error decod_gen_voic_ivas_fx( L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here */ exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( L_tmp, Ltmp1 ) ); + move16(); #else L_tmp = L_shl( L_tmp, 5 ); L_tmp = L_mac( L_tmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); @@ -792,7 +824,9 @@ ivas_error decod_gen_voic_ivas_fx( &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate);*/ - Word16 idx = 0; + Word16 idx; + idx = 0; + move16(); IF( i_subfr_fx != 0 ) { idx = idiv1616( i_subfr_fx, L_SUBFR ); @@ -963,10 +997,12 @@ ivas_error decod_gen_voic_ivas_fx( GetSinCosTab_fx( rint_bfi_pitch, S_fx, C_fx ); DTFS_to_fs_fx( st_fx->hWIDec->old_exc2_fx + shft_prev, rint_bfi_pitch, PREVP, (Word16) st_fx->output_Fs, do_WI_fx, S_fx, C_fx ); PREVP->Q = add( PREVP->Q, st_fx->prev_Q_exc_fr ); + move16(); GetSinCosTab_fx( rint_pitch, S_fx, C_fx ); DTFS_to_fs_fx( exc2_fx + shft_curr, rint_pitch, CURRP, (Word16) st_fx->output_Fs, do_WI_fx, S_fx, C_fx ); CURRP->Q = add( CURRP->Q, st_fx->Q_exc ); + move16(); ph_offset_fx = 0; move16(); diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index fc06c6649dc80ded08dd0d17bca545295d17d490..37e1d2730ba7a5e36cacf6e2734b6985c94abc77 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -455,7 +455,7 @@ void dec_pit_exc_fx( /* _ (Word16) Es_pred_fx :predicted scaled innov. energy */ /*--------------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ -/* _ (Word16*) pitch_buf_fx : floating pitch values for each subframe Q6 */ +/* _ (Word16*) pitch_buf_fx : Word16 pitch values for each subframe Q6 */ /* _ (Word16*) code_fx : innovation */ /*--------------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ @@ -470,7 +470,7 @@ void dec_pit_exc_ivas_fx( const Word16 *Aq_fx, /* i : LP filter coefficient */ const Word16 coder_type, /* i : coding type */ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe */ Word16 *code_fx, /* o : innovation */ Word16 *exc_fx, /* i/o: adapt. excitation exc */ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ @@ -493,12 +493,12 @@ void dec_pit_exc_ivas_fx( Word16 voice_fac_fx; /* voicing factor Q15 */ Word16 L_subfr_fx, pit_idx_fx; const Word16 *p_Aq_fx; /* Pointer to frame LP coefficient Q12 */ - Word16 *pt_pitch_fx; /* pointer to floating pitch Q6 */ + Word16 *pt_pitch_fx; /* pointer to Word16 pitch Q6 */ Word16 i_subfr_fx, i; /* tmp variables */ Word32 Local_BR_fx, Pitch_BR_fx; Word16 pitch_limit_flag, Pitch_CT_fx; Word16 exc2_bidon[L_SUBFR * 2]; - Word16 *pt_gain; /* Pointer to floating gain values for each subframe */ + Word16 *pt_gain; /* Pointer to Word16 gain values for each subframe */ Word16 gain_code16, gain_pitx2; Word32 L_tmp; diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 11af1d430e9a4dc40bc252b7ffa8ce48f0c45df7..1891fc2ab03ae8b6097d094c91a9493c36580453 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -46,9 +46,7 @@ #include "wmc_auto.h" #include "ivas_rom_com.h" #include "ivas_prot_fx.h" -//#ifndef IVAS_FLOAT_FIXED_UNIT_TESTING #include "debug.h" -//#endif #ifndef IVAS_FLOAT_FIXED /*-----------------------------------------------------------------* diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 1ccab85534fd2d7b89a8337bc67977c7b3999970..1fac97786e366c0751b4ec664842ea28b52bdcc0 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -4916,7 +4916,8 @@ void decoder_tcx_noiseshaping_igf_fx( test(); IF( bfi && st->tonal_mdct_plc_active && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - Word16 tmp_x_fx_exp[L_FRAME48k], temp = -MAX_16, i; + Word16 tmp_x_fx_exp[L_FRAME48k], temp; + temp = -MAX_16; move16(); set16_fx( tmp_x_fx_exp, *x_e, L_frameTCX ); diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 6c41de1f4ed42565db561b3db285e54ad07bb476..25f7a88f82543a312546841ec4e0b4f6e7186c6a 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -53,12 +53,14 @@ /*------------------------------------------------------------------- * Local constants *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED +#define DELTA_MASKING_NOISE 1e-20f +#define ST_PERIODOG_FACT 0.9 /* short-term filter factor for periodogram */ +#define CNA_ACT_DN_FACT 0.7 /* downward updating factor for CNA during active frames */ +#endif // IVAS_FLOAT_FIXED -#define DELTA_MASKING_NOISE 1e-20f #define DELTA_MASKING_NOISE_Q31 0 #define CNA_ACT_DN_LARGE_PARTITION 50 /* index of the first larger partition */ -#define ST_PERIODOG_FACT 0.9 /* short-term filter factor for periodogram */ -#define CNA_ACT_DN_FACT 0.7 /* downward updating factor for CNA during active frames */ #define FIRST_CNA_NOISE_UPD_FRAMES 5 /* minimum number of CN initialization frames */ #define LOG_10_BASE_2 1783446566 /* Q29 */ #ifdef IVAS_FLOAT_FIXED @@ -116,55 +118,7 @@ ivas_error createFdCngDec( * * Initialize an instance of type FD_CNG *-------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED -void initFdCngDec( - DEC_CORE_HANDLE st /* i/o: decoder state structure */ -) -{ - HANDLE_FD_CNG_DEC hFdCngDec; - - hFdCngDec = st->hFdCngDec; - - /* Initialize common */ - initFdCngCom_flt( hFdCngDec->hFdCngCom, st->cldfbSyn->scale_flt ); - - /* Set some counters and flags */ - hFdCngDec->flag_dtx_mode = 0; - move16(); - - set16_fx( hFdCngDec->msLocalMinFlag, 0, NPART_SHAPING ); - set16_fx( hFdCngDec->msNewMinFlag, 0, NPART_SHAPING ); - - hFdCngDec->msPeriodogBufPtr = 0; - move16(); - hFdCngDec->nFFTpart_shaping = 0; - move16(); - - hFdCngDec->ms_last_inactive_bwidth = NB; - move16(); - hFdCngDec->ms_cnt_bw_up = 0; - move16(); - hFdCngDec->first_cna_noise_updated = 0; - move16(); - hFdCngDec->first_cna_noise_update_cnt = 0; - move16(); - hFdCngDec->cna_nbands = CNA_INIT_NBANDS; - move16(); - Copy( cna_init_bands, hFdCngDec->cna_band_limits, CNA_INIT_NBANDS + 1 ); - - hFdCngDec->cna_act_fact_fx = MAX_WORD16; - move16(); - hFdCngDec->cna_rescale_fact_fx = 0; - move16(); - hFdCngDec->cna_seed = 5687; - move16(); - - st->CNG_mode = -1; - move16(); - - return; -} -#else +#ifndef IVAS_FLOAT_FIXED void initFdCngDec( DEC_CORE_HANDLE st /* i/o: decoder state structure */ ) @@ -630,7 +584,7 @@ void configureFdCngDec_ivas_fx( * * Delete the instance of type FD_CNG *-------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED void deleteFdCngDec( HANDLE_FD_CNG_DEC *hFdCngDec ) { @@ -645,6 +599,7 @@ void deleteFdCngDec( return; } +#endif // !IVAS_FLOAT_FIXED /*------------------------------------------------------------------- diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 2dc687237f59983b56245c11bdd08cdb87278c42..7886c704036884266db0b63f39c7fa49cb61a133 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -269,10 +269,8 @@ void initFdCngDec_fx( hFdCngDec->hFdCngCom->periodog_exp = 0; move16(); set32_fx( hFdCngDec->smoothed_psd_fx, 0, L_FRAME16k ); -#ifdef IVAS_FLOAT_FIXED hFdCngDec->q_smoothed_psd = Q4; move16(); -#endif #ifdef IVAS_CODE_CNG set_f( hFdCngDec->hFdCngCom->sidNoiseEstLp, 0.0f, NPART ); @@ -3199,11 +3197,9 @@ void FdCng_decodeSID_fx( HANDLE_FD_CNG_COM st, Decoder_State *corest ) Word16 sidNoiseEst_Exp; Word16 preemph_fac; -#ifdef IVAS_FLOAT_FIXED Word32 *invTrfMatrix_fx; Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; invTrfMatrix_fx = (Word32 *) tmpRAM_fx; -#endif sidNoiseEst = st->sidNoiseEst; @@ -3226,14 +3222,12 @@ void FdCng_decodeSID_fx( HANDLE_FD_CNG_COM st, Decoder_State *corest ) index = get_next_indice_fx( corest, 7 ); /* MSVQ decoder */ -#ifdef IVAS_FLOAT_FIXED IF( corest->element_mode != EVS_MONO ) { create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, stages_37bits, N, maxN_37bits, indices, 1, invTrfMatrix_fx, v, NULL, 7 ); } ELSE -#endif { msvq_decoder( cdk_37bits, diff --git a/lib_dec/gs_dec_amr_wb.c b/lib_dec/gs_dec_amr_wb.c index ef18c1238a72a067fee154cc07ed917685aa0ac6..0f00401217aaffa64f2eb8f0da7cac2f5e5bd8c3 100644 --- a/lib_dec/gs_dec_amr_wb.c +++ b/lib_dec/gs_dec_amr_wb.c @@ -51,10 +51,12 @@ #define BIN_1k2 48 #define BAND_2k 12 #define BAND_0k4 4 -#define ALP 0.7f -#define MALP ( 1.0f - ALP ) -#define ALPMY ( 0.86f ) -#define ALPY 1.5f +#ifndef IVAS_FLOAT_FIXED +#define ALP 0.7f +#define MALP ( 1.0f - ALP ) +#define ALPMY ( 0.86f ) +#define ALPY 1.5f +#endif // !IVAS_FLOAT_FIXED #define CONTR_LIMIT 3012 /* Threshold to allow an increase in the contribution length */ diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index 4fa3ee0aeb163a5fa403e9e7c35f947a15c3a964..be2975db026b77e99c75974092008c1674c790e6 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -522,7 +522,7 @@ void decod_audio_fx( /* _(Word16) Q_exc :Q format of excitation */ /*-------------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ -/* _ (Word16[]) pitch_buf_fx : floating pitch values for each subframe Q6*/ +/* _ (Word16[]) pitch_buf_fx : Word16 pitch values for each subframe Q6*/ /* _ (Word16[]) voice_factors_fx: frame error rate Q15 */ /*--------------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ @@ -537,7 +537,7 @@ void decod_audio_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ Word16 dct_epit[], /* o : GSC excitation in DCT domain */ const Word16 *Aq, /* i : LP filter coefficient */ - Word16 *pitch_buf, /* o : floating pitch values for each subframe */ + Word16 *pitch_buf, /* o : Word16 pitch values for each subframe */ Word16 *voice_factors, /* o : voicing factors */ Word16 *exc, /* i/o: adapt. excitation exc */ Word16 *exc2, /* i/o: adapt. excitation/total exc */ diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index db8611ecec3d2c841cb4c70ba1d362989bb76874..09a88571982226f1b7cf7c0d17e86a972d5eb505 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -15,7 +15,6 @@ #include "cnst.h" #include "stat_dec.h" #include "basop_util.h" -// Temporarily added #define MID 57 /* (.89*1<<6)*/ #ifdef IVAS_FLOAT_FIXED #include "ivas_prot_fx.h" @@ -4089,10 +4088,6 @@ void IGFDecReplicateTCX10State_fx( Copy( &hIGFDec->flag_sparseBuf[( N_MAX_TCX - IGF_START_MN ) / 2], &hIGFDec->flag_sparseBuf[0], ( N_MAX_TCX - IGF_START_MN ) / 2 ); Copy( &hIGFDec->infoTCXNoise_evs[( IGF_START_MX ) / 2], &hIGFDec->infoTCXNoise_evs[0], ( IGF_START_MX ) / 2 ); - /* TODO: remove float dependency */ - // mvr2r( &hIGFDec->virtualSpecBuf[( N_MAX_TCX - IGF_START_MN ) / 2], &hIGFDec->virtualSpecBuf[0], ( N_MAX_TCX - IGF_START_MN ) / 2 ); - // mvr2r( &hIGFDec->igfData.pSpecFlatBuf[IGF_START_MX / 2], &hIGFDec->igfData.pSpecFlatBuf[0], IGF_START_MX / 2 ); - Copy32( &hIGFDec->virtualSpec[( N_MAX_TCX - IGF_START_MN ) / 2], &hIGFDec->virtualSpec[0], ( N_MAX_TCX - IGF_START_MN ) / 2 ); Copy32( &hIGFDec->igfData.pSpecFlatBuf_fx[IGF_START_MX / 2], &hIGFDec->igfData.pSpecFlatBuf_fx[0], IGF_START_MX / 2 ); diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 2bfd615b0bb8ffef84285cb0d43404eb167a83f2..17a1fcce22945b8cf0ea1f6d90274215f1a841c4 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -873,7 +873,7 @@ ivas_error ivas_core_dec_fx( ELSE { p_output_mem_16 = NULL; - set16_fx( output_mem_16_fx, 0, NS2SA( st->output_Fs, 3125000 ) ); + set16_fx( output_mem_16_fx, 0, NS2SA_FX2( st->output_Fs, 3125000 ) ); } Scale_sig32( output_32_fx[n], L_FRAME48k, sub( Q4, Q11 ) ); @@ -992,7 +992,7 @@ ivas_error ivas_core_dec_fx( test(); test(); test(); - IF( n == 0 && EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( st->last_core, ACELP_CORE ) && NE_16( st->core, ACELP_CORE ) && ( EQ_16( nchan_out, 1 ) || ( hCPE != NULL && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) ) ) ) + IF( n == 0 && EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->last_core == ACELP_CORE && st->core != ACELP_CORE && ( EQ_16( nchan_out, 1 ) || ( hCPE != NULL && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) ) ) ) { Copy( sts[0]->previoussynth_fx, sts[1]->previoussynth_fx, st->hTcxDec->L_frameTCX ); } @@ -1316,7 +1316,7 @@ ivas_error ivas_core_dec_fx( IF( EQ_16( st->L_frame, L_FRAME ) ) { /* TBE on top of ACELP@12.8kHz */ - tmps = NS2SA( output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS ); + tmps = NS2SA_FX2( output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS ); } ELSE { @@ -1324,12 +1324,12 @@ ivas_error ivas_core_dec_fx( IF( EQ_16( st->extl, SWB_BWE_HIGHRATE ) || EQ_16( st->extl, FB_BWE_HIGHRATE ) ) { /* HR SWB BWE on top of ACELP@16kHz */ - tmps = NS2SA( output_Fs, DELAY_BWE_TOTAL_NS ); + tmps = NS2SA_FX2( output_Fs, DELAY_BWE_TOTAL_NS ); } ELSE { /* TBE on top of ACELP@16kHz */ - tmps = NS2SA( output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); + tmps = NS2SA_FX2( output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); } } @@ -1432,6 +1432,7 @@ ivas_error ivas_core_dec_fx( } st->old_bwe_delay = tmps; + move16(); /* SWB CNG/DTX - calculate SHB energy */ test(); @@ -1476,7 +1477,6 @@ ivas_error ivas_core_dec_fx( L_tmp = L_shl( exp, exp2 ); exp = sub( Q31, exp2 ); L_tmp = BASOP_Util_Add_Mant32Exp( fra, 6, L_tmp, exp, &exp ); - // exp = sub( sub( 30, shl( sub( Q11, 0 ), 1 ) ), exp ); L_tmp = Mpy_32_16_1( L_tmp, 24660 ); exp = add( exp, 2 ); st->last_shb_ener_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 7 ) ) ); /*Q8*/ @@ -1601,17 +1601,17 @@ ivas_error ivas_core_dec_fx( move16(); move16(); - Copy_Scale_sig32_16( st->prev_synth_buffer32_fx, st->prev_synth_buffer_fx, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), negate( Q11 ) ); + Copy_Scale_sig32_16( st->prev_synth_buffer32_fx, st->prev_synth_buffer_fx, NS2SA_FX2( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), negate( Q11 ) ); st->q_prev_synth_buffer_fx = 0; move16(); exp_ouput = Find_Max_Norm32( output_32_fx[n], output_frame ); exp_ouput = add( exp_ouput, Q11 ); - exp_prev_synth_buffer = Find_Max_Norm16( st->prev_synth_buffer_fx, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); + exp_prev_synth_buffer = Find_Max_Norm16( st->prev_synth_buffer_fx, NS2SA_FX2( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); exp_prev_synth_buffer = add( exp_prev_synth_buffer, st->q_prev_synth_buffer_fx ); - exp_old_out = Find_Max_Norm16( st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), sub( add( NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ), NS2SA( st->output_Fs, N_ZERO_MDCT_NS ) ) ); - exp_delay_buf_out = Find_Max_Norm16( st->delay_buf_out_fx, NS2SA( st->output_Fs, DELAY_CLDFB_NS ) ); - exp_synth_history = Find_Max_Norm16( st->hTcxDec->synth_history_fx + output_frame, sub( add( sub( imult1616( 2, output_frame ), NS2SA( st->output_Fs, DELAY_CLDFB_NS ) ), NS2SA( st->output_Fs, PH_ECU_MEM_NS ) ), output_frame ) ); + exp_old_out = Find_Max_Norm16( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), sub( add( NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ), NS2SA( st->output_Fs, N_ZERO_MDCT_NS ) ) ); + exp_delay_buf_out = Find_Max_Norm16( st->delay_buf_out_fx, NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ); + exp_synth_history = Find_Max_Norm16( st->hTcxDec->synth_history_fx + output_frame, sub( add( sub( imult1616( 2, output_frame ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ), output_frame ) ); #ifndef FIX_740_HQ_CORE_OVA exp_synth_history += st->hTcxDec->q_synth_history_fx; #endif @@ -1623,10 +1623,10 @@ ivas_error ivas_core_dec_fx( Copy32( output_32_fx[n], output_fx_loc, output_frame ); Scale_sig32( output_fx_loc, output_frame, sub( exp_max, Q11 ) ); - Scale_sig( st->delay_buf_out_fx, NS2SA( st->output_Fs, DELAY_CLDFB_NS ), exp_max ); - Scale_sig( st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), sub( NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ), NS2SA( st->output_Fs, N_ZERO_MDCT_NS ) ), exp_max ); - Scale_sig( st->prev_synth_buffer_fx, NS2SA( 48000, L_sub( DELAY_BWE_TOTAL_NS, DELAY_CLDFB_NS ) ), sub( exp_max, st->q_prev_synth_buffer_fx ) ); - Scale_sig( st->hTcxDec->synth_history_fx + output_frame, sub( add( sub( imult1616( 2, output_frame ), NS2SA( st->output_Fs, DELAY_CLDFB_NS ) ), NS2SA( st->output_Fs, PH_ECU_MEM_NS ) ), output_frame ), sub( exp_max, st->Q_syn ) ); + Scale_sig( st->delay_buf_out_fx, NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ), exp_max ); + Scale_sig( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), sub( NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ), NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ) ), exp_max ); + Scale_sig( st->prev_synth_buffer_fx, NS2SA_FX2( 48000, L_sub( DELAY_BWE_TOTAL_NS, DELAY_CLDFB_NS ) ), sub( exp_max, st->q_prev_synth_buffer_fx ) ); + Scale_sig( st->hTcxDec->synth_history_fx + output_frame, sub( add( sub( imult1616( 2, output_frame ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ), output_frame ), sub( exp_max, st->Q_syn ) ); st->q_prev_synth_buffer_fx = sub( exp_max, st->q_prev_synth_buffer_fx ); } @@ -1637,7 +1637,7 @@ ivas_error ivas_core_dec_fx( ivas_updt_dec_common_fx( st, NORMAL_HQ_CORE, -1, output_32_fx[n], Q11 ); - Scale_sig( st->delay_buf_out_fx, NS2SA( st->output_Fs, DELAY_CLDFB_NS ), negate( exp_max ) ); + Scale_sig( st->delay_buf_out_fx, NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ), negate( exp_max ) ); } /* n_channels loop */ diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index f0e4bfeceee5d2622d72aad2f5a6a3f2dcd5f41e..298ffde1a78982a451bfe4e58fecca144cf35392 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -42,9 +42,6 @@ #include "ivas_rom_com.h" #include "wmc_auto.h" #include -#ifdef IVAS_FLOAT_FIXED -#include "ivas_prot_fx.h" -#endif /*--------------------------------------------------------------------------* diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index f33bb4fc7b8cb4fc922746076873bce5e6412d5e..5705d5dd52fb68eaa17c6857fc13d0a17b17ac5d 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -124,13 +124,6 @@ ivas_error ivas_cpe_dec_fx( * dynamically allocate data structures depending on the actual stereo mode *----------------------------------------------------------------*/ -#if 1 // Float to fix conversions - Word16 q_old_out_LB; - q_old_out_LB = 31; - move16(); - // q_output_mem = 11; - // q_buff_LBTCX_mem = 11; - // q_input_mem_LB = q_buff_LBTCX_mem; FOR( Word16 ind1 = 0; ind1 < 2; ind1++ ) { test(); @@ -139,24 +132,21 @@ ivas_error ivas_cpe_dec_fx( Copy_Scale_sig_16_32( hCPE->hCoreCoder[ind1]->hHQ_core->old_out_fx, hCPE->hCoreCoder[ind1]->hHQ_core->oldOut_fx, L_FRAME48k, sub( Q11, hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda ) ); } } - q_old_out_LB = Q11; - move16(); FOR( Word16 ind1 = 0; ind1 < 2; ind1++ ) { IF( hCPE->hCoreCoder[ind1]->hHQ_core ) { Copy_Scale_sig_16_32( hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[ind1]->hHQ_core->old_outLB_fx, L_FRAME32k, sub( Q11, hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda_LB ) ); - hCPE->hCoreCoder[ind1]->hHQ_core->q_old_outLB_fx = q_old_out_LB; + hCPE->hCoreCoder[ind1]->hHQ_core->q_old_outLB_fx = Q11; move16(); } } -#endif // Float to fix conversions IF( NE_32( ( error = stereo_memory_dec_fx( ivas_total_brate, hCPE, nb_bits_metadata, st_ivas->hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->nchan_transport ) ), IVAS_ERR_OK ) ) { return error; } -#if 1 // Fix to float conversions + FOR( Word16 ind1 = 0; ind1 < 2; ind1++ ) { IF( hCPE->hCoreCoder[ind1] && hCPE->hCoreCoder[ind1]->hHQ_core ) @@ -172,7 +162,6 @@ ivas_error ivas_cpe_dec_fx( Copy_Scale_sig_32_16( hCPE->hCoreCoder[ind1]->hHQ_core->old_outLB_fx, hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda_LB, Q11 ) ); } } -#endif /*------------------------------------------------------------------* * Initialization @@ -703,7 +692,6 @@ ivas_error ivas_cpe_dec_fx( /* decoding */ IF( EQ_16( hCPE->nchan_out, 1 ) ) { -#if 1 IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) { hCPE->hStereoDft->q_smoothed_nrg = hCPE->hStereoDft->q_dft; @@ -720,17 +708,13 @@ ivas_error ivas_cpe_dec_fx( scale_sig32( hCPE->hStereoDft->res_cod_mem_fx, STEREO_DFT_OVL_8k, sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_res_cod_mem_fx ) ); hCPE->hStereoDft->q_res_cod_mem_fx = hCPE->hStereoDft->q_dft; move16(); -#endif stereo_dft_unify_dmx_fx( hCPE->hStereoDft, sts[0], DFT_fx, hCPE->input_mem_fx[1], hCPE->hStereoCng->prev_sid_nodata ); -#if 1 scale_sig32( hCPE->hStereoDft->res_cod_mem_fx, STEREO_DFT_OVL_8k, sub( Q16, hCPE->hStereoDft->q_res_cod_mem_fx ) ); hCPE->hStereoDft->q_res_cod_mem_fx = Q16; move16(); -#endif } ELSE { -#if 1 { IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) { @@ -749,13 +733,10 @@ ivas_error ivas_cpe_dec_fx( hCPE->hStereoDft->q_res_cod_mem_fx = hCPE->hStereoDft->q_dft; move16(); } -#endif stereo_dft_dec_fx( hCPE->hStereoDft, sts[0], DFT_fx, hCPE->input_mem_fx[1], hCPE->hStereoCng, 0, 0, 0, 0, 0, 0, MAX_PARAM_SPATIAL_SUBFRAMES ); -#if 1 scale_sig32( hCPE->hStereoDft->res_cod_mem_fx, STEREO_DFT_OVL_8k, sub( Q16, hCPE->hStereoDft->q_res_cod_mem_fx ) ); hCPE->hStereoDft->q_res_cod_mem_fx = Q16; move16(); -#endif } FOR( n = 0; n < hCPE->nchan_out; n++ ) @@ -818,13 +799,6 @@ ivas_error ivas_cpe_dec_fx( /*----------------------------------------------------------------* * Update parameters for stereo CNA *----------------------------------------------------------------*/ - // Delete below - IF( hCPE->hStereoDft != NULL ) - { - // Word16 q_td_gain = Q_factor_arr( hCPE->hStereoDft->td_gain, STEREO_DFT_CORE_HIST_MAX ); - // floatToFixed_arrL( hCPE->hStereoDft->td_gain, hCPE->hStereoDft->td_gain_fx, q_td_gain, STEREO_DFT_CORE_HIST_MAX ); // Checking this. - } - //////Till here // stereo_cna_update_params( hCPE, output_flt, output_frame, tdm_ratio_idx ); stereo_cna_update_params_fx( hCPE, output, output_frame, tdm_ratio_idx ); @@ -865,12 +839,6 @@ ivas_error ivas_cpe_dec_fx( stereo_tca_dec_fx( hCPE, output, output_frame ); - // delete below - IF( hCPE->hStereoDft != NULL ) - { - // Word16 q_td_gain = Q_factor_arr( hCPE->hStereoDft->td_gain, STEREO_DFT_CORE_HIST_MAX ); - // fixedToFloat_arrL( hCPE->hStereoDft->td_gain_fx, hCPE->hStereoDft->td_gain, q_td_gain, STEREO_DFT_CORE_HIST_MAX ); // Checking this. - } /*----------------------------------------------------------------* * Common Stereo updates diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index f81110cb57cf22b79b921f2cc8eef76ea03c5e31..25f97c89e44ee9a8a1c36ccb9c45da85f922f8c8 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -47,7 +47,7 @@ * * Principal IVAS decoder routine *--------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ int16_t *data /* o : output synthesis signal */ @@ -61,3 +61,4 @@ ivas_error ivas_dec( return IVAS_ERR_OK; } +#endif diff --git a/lib_dec/ivas_decision_matrix_dec.c b/lib_dec/ivas_decision_matrix_dec.c index 111678e82e6e93f962bdb249ac56cd43c2df15b0..75bfecc1593707bdec966361bf35ce48babfccd0 100644 --- a/lib_dec/ivas_decision_matrix_dec.c +++ b/lib_dec/ivas_decision_matrix_dec.c @@ -556,8 +556,6 @@ void ivas_decision_matrix_dec_fx( st->hFdCngDec->hFdCngCom->coherence_fx = get_next_index_4_by_15[index]; move16(); - ///* TODO: remove floating point dependency */ - // st->hFdCngDec->hFdCngCom->coherence_flt = ( (float) get_next_index_4_by_15[index] ) / ( ( 1 << 15 ) - 1 ); /* read flag for no side noise shape */ st->hFdCngDec->hFdCngCom->no_side_flag = get_next_indice_fx( st, 1 ); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 168cb4fa1950234f2d2589b0f959ec05c0d63eeb..53891fc5121dc887006e13e960a9e87dae35c587 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -44,7 +44,6 @@ #ifdef IVAS_FLOAT_FIXED #include "prot_fx.h" #include "ivas_prot_fx.h" -#define IVAS_FLOAT_FIXED_TO_BE_REMOVED #endif // IVAS_FLOAT_FIXED @@ -1533,16 +1532,6 @@ ivas_error ivas_init_decoder_front( { return error; } -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - FOR( Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - st_ivas->hExtOrientationData->Quaternions[i].w = fixedToFloat_32( st_ivas->hExtOrientationData->Quaternions[i].w_fx, st_ivas->hExtOrientationData->Quaternions[i].q_fact ); - st_ivas->hExtOrientationData->Quaternions[i].x = fixedToFloat_32( st_ivas->hExtOrientationData->Quaternions[i].x_fx, st_ivas->hExtOrientationData->Quaternions[i].q_fact ); - st_ivas->hExtOrientationData->Quaternions[i].y = fixedToFloat_32( st_ivas->hExtOrientationData->Quaternions[i].y_fx, st_ivas->hExtOrientationData->Quaternions[i].q_fact ); - st_ivas->hExtOrientationData->Quaternions[i].z = fixedToFloat_32( st_ivas->hExtOrientationData->Quaternions[i].z_fx, st_ivas->hExtOrientationData->Quaternions[i].q_fact ); - } - -#endif } /*-------------------------------------------------------------------* @@ -1555,19 +1544,6 @@ ivas_error ivas_init_decoder_front( { return error; } -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - FOR( Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - st_ivas->hCombinedOrientationData->Quaternions[i].w = fixedToFloat_32( st_ivas->hCombinedOrientationData->Quaternions[i].w_fx, st_ivas->hCombinedOrientationData->Quaternions[i].q_fact ); - st_ivas->hCombinedOrientationData->Quaternions[i].x = fixedToFloat_32( st_ivas->hCombinedOrientationData->Quaternions[i].x_fx, st_ivas->hCombinedOrientationData->Quaternions[i].q_fact ); - st_ivas->hCombinedOrientationData->Quaternions[i].y = fixedToFloat_32( st_ivas->hCombinedOrientationData->Quaternions[i].y_fx, st_ivas->hCombinedOrientationData->Quaternions[i].q_fact ); - st_ivas->hCombinedOrientationData->Quaternions[i].z = fixedToFloat_32( st_ivas->hCombinedOrientationData->Quaternions[i].z_fx, st_ivas->hCombinedOrientationData->Quaternions[i].q_fact ); - - st_ivas->hCombinedOrientationData->listenerPos[i].x = fixedToFloat_32( st_ivas->hCombinedOrientationData->listenerPos[i].x_fx, st_ivas->hCombinedOrientationData->listenerPos[i].q_fact ); - st_ivas->hCombinedOrientationData->listenerPos[i].y = fixedToFloat_32( st_ivas->hCombinedOrientationData->listenerPos[i].y_fx, st_ivas->hCombinedOrientationData->listenerPos[i].q_fact ); - st_ivas->hCombinedOrientationData->listenerPos[i].z = fixedToFloat_32( st_ivas->hCombinedOrientationData->listenerPos[i].z_fx, st_ivas->hCombinedOrientationData->listenerPos[i].q_fact ); - } -#endif } /*-------------------------------------------------------------------* diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index cdd469225b75910efdd1f6c8c374e8117b8d8e9c..6ab1ad3b526dab8170082c1beb983c0283d46fd0 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -150,7 +150,7 @@ ivas_error ivas_ism_renderer_open_fx( IF( st_ivas->hDecoderConfig->Opt_tsm ) { Word32 res_dec, res_frac; - init_interpolator_length = NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_CLDFB_TIMESLOTS * CLDFB_SLOT_NS ); + init_interpolator_length = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_CLDFB_TIMESLOTS * CLDFB_SLOT_NS ); move16(); iDiv_and_mod_32( st_ivas->hDecoderConfig->output_Fs, FRAMES_PER_SEC, &res_dec, &res_frac, 0 ); interpolator_length = (UWord16) ( res_dec ); diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 3531d64ffbeddd8b1f1fe0c8a921c740ce81471e..741ddee3bf5c7490fb32ea825fe4a0e0c1077fcf 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -48,8 +48,6 @@ #endif #include "prot_fx.h" -#define float_to_fixed( n, factor ) ( round( n * ( 1 << factor ) ) ) -#define fixed_to_float( n, factor ) ( (float) n / ( 1 << factor ) ) /*-----------------------------------------------------------------------* * Local function prototypes @@ -2271,16 +2269,13 @@ ivas_error ivas_jbm_dec_tc( *--------------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED void ivas_jbm_dec_feed_tc_to_renderer_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ - int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ - Word32 *data_fx /* i : transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const Word16 nSamplesForRendering, /* i : number of TC samples available for rendering */ + Word16 *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ + Word32 *data_fx /* i : transport channels */ ) { - float data_f[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k] = { 0 }; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */ - float *p_data_f[MAX_CLDFB_DIGEST_CHANNELS]; -#ifdef IVAS_FLOAT_FIXED - Word32 data_f_fx[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k] = { 0 }; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */ + Word32 data_f_fx[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k] = { 0 }; /* Word32 buffer for transport channels that will be directly converted with the CLDFB */ Word32 *p_data_f_fx[MAX_CLDFB_DIGEST_CHANNELS]; IF( st_ivas->hTcBuffer ) @@ -2291,33 +2286,17 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( { st_ivas->hSpar->hMdDec->Q_mixer_mat = 31; } -#endif - Word16 n, n_render_timeslots, i; + Word16 n, n_render_timeslots; push_wmops( "ivas_jbm_dec_feed_tc_to_rendererer" ); FOR( n = 0; n < MAX_CLDFB_DIGEST_CHANNELS; n++ ) { - p_data_f[n] = &data_f[n][0]; -#ifdef IVAS_FLOAT_FIXED p_data_f_fx[n] = &data_f_fx[n][0]; -#endif } IF( st_ivas->hDecoderConfig->Opt_tsm ) { ivas_jbm_dec_copy_tc( st_ivas, nSamplesForRendering, nSamplesResidual, data_fx, p_data_f_fx, 11 ); - -#if 1 // To-be-removed - Word16 ch; - if ( st_ivas->hTcBuffer->nchan_transport_jbm - st_ivas->hTcBuffer->nchan_buffer_full > 0 ) - { - for ( ch = min( st_ivas->hTcBuffer->nchan_transport_jbm, st_ivas->hTcBuffer->nchan_buffer_full ); ch < st_ivas->hTcBuffer->nchan_transport_jbm; ch++ ) - { - fixedToFloat_arrL( p_data_f_fx[ch], p_data_f[ch], st_ivas->hTcBuffer->q_tc_fx, MAX_JBM_L_FRAME48k ); - } - } - -#endif } ELSE { @@ -2356,19 +2335,8 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { -#ifdef IVAS_FLOAT_FIXED - /////////////////////////// flt2fix /////////////////////// - floatToFixed_arr32( p_data_f[0], p_data_f_fx[0], Q11, MAX_CLDFB_DIGEST_CHANNELS * MAX_JBM_L_FRAME48k ); - /////////////////////////// flt2fix /////////////////////// ivas_param_ism_dec_digest_tc_fx( st_ivas, n_render_timeslots, p_data_f_fx, Q11 ); - - /////////////////////////// fix2flt /////////////////////// - fixedToFloat_arrL( p_data_f_fx[0], p_data_f[0], Q11, MAX_CLDFB_DIGEST_CHANNELS * MAX_JBM_L_FRAME48k ); -/////////////////////////// fix2flt /////////////////////// -#else - ivas_param_ism_dec_digest_tc( st_ivas, n_render_timeslots, p_data_f ); -#endif } } ELSE /* ISM_MODE_DISC */ @@ -2378,7 +2346,6 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_FORMAT ) ) { -#if 1 IF( st_ivas->hSCE[0] ) { Word16 shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); @@ -2389,7 +2356,6 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); } -#endif ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) @@ -2490,29 +2456,6 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) { -#ifdef IVAS_FLOAT_FIXED - Word16 j; - Word16 max_e = 0, input_q[MAX_CLDFB_DIGEST_CHANNELS], in_q; - FOR( i = 0; i < MAX_CLDFB_DIGEST_CHANNELS; i++ ) - { - f2me_buf( p_data_f[i], p_data_f_fx[i], &input_q[i], MAX_JBM_L_FRAME48k ); - } - - max_e = input_q[0]; - - FOR( i = 0; i < MAX_CLDFB_DIGEST_CHANNELS; i++ ) - { - IF( max_e < input_q[i] ) - max_e = input_q[i]; - } - - FOR( i = 0; i < MAX_CLDFB_DIGEST_CHANNELS; i++ ) - { - FOR( j = 0; j < MAX_JBM_L_FRAME48k; j++ ) - p_data_f_fx[i][j] = L_shr( p_data_f_fx[i][j], max_e - input_q[i] ); - } - - in_q = max_e; Word16 nchan_transport = st_ivas->nchan_transport; Word16 nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); @@ -2533,16 +2476,11 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( { nchan_out_cov = nchan_out_transport; } - // f2me_buf( st_ivas->hParamMC->h_output_synthesis_params.proto_matrix, st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_fx, &st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_e, nchan_out_cov * nchan_transport ); - - // Word16 shift_p = L_norm_arr(st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_fx, nchan_out_cov * nchan_transport); - // scale_sig32(st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_fx, nchan_out_cov * nchan_transport, shift_p); - // st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_e -= shift_p; scale_sig32( st_ivas->hParamMC->proto_matrix_int_fx, st_ivas->hParamMC->proto_matrix_int_len, -1 ); st_ivas->hParamMC->proto_matrix_int_e = 1; - ivas_param_mc_dec_digest_tc_fx( st_ivas, (uint8_t) n_render_timeslots, (Word32 **) p_data_f_fx, in_q ); + ivas_param_mc_dec_digest_tc_fx( st_ivas, (UWord8) n_render_timeslots, (Word32 **) p_data_f_fx, Q11 ); scale_sig32( st_ivas->hParamMC->proto_matrix_int_fx, st_ivas->hParamMC->proto_matrix_int_len, 1 ); @@ -2557,9 +2495,6 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_fx[param_band_idx], nchan_out_cov * nchan_out_cov, shift ); st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx], shift ); } -#else - ivas_param_mc_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, p_data_f ); -#endif } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { @@ -4531,7 +4466,7 @@ ivas_error ivas_jbm_dec_set_discard_samples( * * Get an interpolator that is adapted to time scale modified IVAS frame *--------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED void ivas_jbm_dec_get_adapted_linear_interpolator( const int16_t default_interp_length, /* i : default length of the (full-frame) interpolator */ const int16_t interp_length, /* i : length of the interpolator to be created */ @@ -4565,6 +4500,7 @@ void ivas_jbm_dec_get_adapted_linear_interpolator( return; } +#endif // !IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED void ivas_jbm_dec_get_adapted_linear_interpolator_fx( const Word16 default_interp_length, /* i : default length of the (full-frame) interpolator */ diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index 99509970cb4f005f550a02fbf6eebb859c1f0e2c..206cb95aaef64dd6937cf23541f06639ce968ce8 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -44,6 +44,7 @@ /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED #define LFE_PLC_DSF ( 48000 / LFE_PLC_FS ) #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT @@ -714,3 +715,5 @@ void ivas_lfe_tdplc( return; } + +#endif diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index f47cc5454085d336f3cfb5594ea5a75ec9bf70bd..9737868308a38be0ebb7ba9e8b13e6872fa5ee55 100644 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -40,8 +40,6 @@ #include "wmc_auto.h" #ifdef IVAS_FLOAT_FIXED #include "ivas_prot_fx.h" -#endif -#ifdef IVAS_FLOAT_FIXED #include "ivas_rom_com_fx.h" #endif @@ -55,8 +53,10 @@ #else #define LFE_PLC_LPCORD ( MAX_LP_FILTER_ORDER ) #endif -#define LFE_PLC_MAXITER ( 10 ) -#define POW_THR ( 1.0e-8f ) +#define LFE_PLC_MAXITER ( 10 ) +#ifndef IVAS_FLOAT_FIXED +#define POW_THR ( 1.0e-8f ) +#endif #define LFE_PLC_RECLEN_48K ( ( IVAS_LFE_NUM_COEFFS_IN_SUBGRP + 1 ) * L_FRAME48k / IVAS_LFE_NUM_COEFFS_IN_SUBGRP + LFE_PLC_FDEL ) #define LFE_PLC_RECLEN ( ( LFE_PLC_RECLEN_48K / LFE_PLC_DSF ) ) #define LFE_PLC_MUTE_THR ( 10 ) diff --git a/lib_dec/ivas_ls_custom_dec.c b/lib_dec/ivas_ls_custom_dec.c index 6c0b738a7d7b31e5488bbd291426cf41c9e81357..491f92ac9d03cccded361505505c473dbe8bdb50 100644 --- a/lib_dec/ivas_ls_custom_dec.c +++ b/lib_dec/ivas_ls_custom_dec.c @@ -199,6 +199,7 @@ ivas_error ivas_ls_custom_output_init_fx( } st_ivas->hDecoderConfig->nchan_out = add( st_ivas->hLsSetupCustom->num_spk, st_ivas->hLsSetupCustom->num_lfe ); + move16(); ivas_ls_custom_setup_fx( &( st_ivas->hOutSetup ), st_ivas->hLsSetupCustom ); ivas_ls_custom_setup_fx( &( st_ivas->hIntSetup ), st_ivas->hLsSetupCustom ); diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 7246f4010551c5562384bda9105ccbd6644d85b5..68054e048a34bf6437f4ac3e06c0a9c065693ce1 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -48,7 +48,6 @@ #ifdef IVAS_FLOAT_FIXED #include "prot_fx.h" #include "ivas_prot_fx.h" -#define IVAS_FLOAT_FIXED_TO_BE_REMOVED #endif #define INV_EPSILON_MANT 214748365 @@ -67,10 +66,11 @@ typedef struct parameter_band_mapping_struct { int16_t n_source_bands[20]; int16_t source_band_idx[20][4]; +#ifndef IVAS_FLOAT_FIXED float source_band_factor[20][4]; -#ifdef IVAS_FLOAT_FIXED +#else Word16 source_band_factor_fx[20][4]; /*Q15*/ -#endif // IVAS_FLOAT_FIXED +#endif // IVAS_FLOAT_FIXED } PARAM_MC_PARAMETER_BAND_MAPPING; @@ -139,15 +139,19 @@ static void ivas_param_mc_dec_compute_interpolator_fx( const UWord16 bAttackPres #ifndef IVAS_FLOAT_FIXED static void ivas_param_mc_dec_compute_interpolator( const uint16_t bAttackPresent, const uint16_t attackPos, const uint16_t interp_length, float *interpolator ); -#endif static void param_mc_set_num_synth_bands( const int32_t output_Fs, PARAM_MC_DEC_HANDLE hParamMC ); +#else +static void param_mc_set_num_synth_bands( const Word32 output_Fs, PARAM_MC_DEC_HANDLE hParamMC ); +#endif #ifndef IVAS_FLOAT_FIXED static ivas_error param_mc_get_diff_proto_info( const float *proto_mtx, const uint16_t nchan_transport, const uint16_t nchan_out_cov, PARAM_MC_DIFF_PROTO_INFO *p_diff_proto_info ); -#endif static void ivas_param_mc_get_param_band_mapping( const int16_t n_target_bands, const int16_t *target_band_grouping, const int16_t n_source_bands, const int16_t *source_band_grouping, PARAM_MC_PARAMETER_BAND_MAPPING *parameter_band_mapping ); +#else +static void ivas_param_mc_get_param_band_mapping( const Word16 n_target_bands, const Word16 *target_band_grouping, const Word16 n_source_bands, const Word16 *source_band_grouping, PARAM_MC_PARAMETER_BAND_MAPPING *parameter_band_mapping ); +#endif #ifndef IVAS_FLOAT_FIXED static void ivas_param_mc_bs_decode_parameter_values( uint16_t bit_buffer[], int16_t *bit_pos, const int16_t max_bits, int16_t *BER_detect, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParamCodingInfo, const int16_t map_size_wo_lfe, const int16_t map_size, const int16_t num_lfe_bands, const int16_t band_step, const int16_t num_param_bands, float *value_buffer ); @@ -159,7 +163,6 @@ static void ivas_param_mc_dequantize_cov_fx( PARAM_MC_DEC_HANDLE hParamMC, Word1 static ivas_error param_mc_get_diff_proto_info_fx( const Word32 *proto_mtx, const UWord16 nchan_transport, const UWord16 nchan_out_cov, PARAM_MC_DIFF_PROTO_INFO *p_diff_proto_info, Word16 Q_proto_mtx ); static void param_mc_update_mixing_matrices_fx( PARAM_MC_DEC_HANDLE hParamMC, Word32 *mixing_matrix[], Word16 *mixing_matrix_fx, Word32 *mixing_matrix_res[], Word16 *mixing_matrix_res_exp, const UWord16 nX, const UWord16 nY ); -// static ivas_error param_mc_get_diff_proto_info_fx(const Word32 *proto_mtx, const UWord16 nchan_transport, const UWord16 nchan_out_cov, PARAM_MC_DIFF_PROTO_INFO *p_diff_proto_info); static void param_mc_protoSignalComputation_fx( Word32 *RealBuffer_fx, Word32 *ImagBuffer_fx, Word32 *proto_frame_f_fx, const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, const int16_t num_freq_bands /*, Word16 RealBuffer_fx_e, Word16 ImagBuffer_fx_e, Word16 *common_e*/ ); #endif @@ -4521,7 +4524,7 @@ static Word16 ivas_param_mc_range_decoder_LC_fx( /* r is the symbol read, the possible values are {0,1,....alphabet_size - 1} */ /* Update bitstream pointer */ - cur_bit_pos = rc_uni_dec_virtual_finish( &rc_st_dec ); + cur_bit_pos = rc_uni_dec_virtual_finish_fx( &rc_st_dec ); /* Confirm that there is no overflow */ IF( GT_16( cur_bit_pos, nbbits ) ) diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 6921066aa007d69b33456ebadedb8abd83950abc..8d71571129fa5af0836d7627d9b0defe9f35844e 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -368,7 +368,6 @@ ivas_error ivas_mc_paramupmix_dec_open( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } compute_hoa_encoder_mtx_fx( st_ivas->hTransSetup.ls_azimuth_fx, st_ivas->hTransSetup.ls_elevation_fx, hMCParamUpmix->hoa_encoder_fx, st_ivas->hTransSetup.nchan_out_woLFE, HEAD_ROTATION_HOA_ORDER ); - // compute_hoa_encoder_mtx( st_ivas->hTransSetup.ls_azimuth, st_ivas->hTransSetup.ls_elevation, hMCParamUpmix->hoa_encoder, st_ivas->hTransSetup.nchan_out_woLFE, HEAD_ROTATION_HOA_ORDER ); } /* allocate transport channels*/ @@ -386,8 +385,8 @@ ivas_error ivas_mc_paramupmix_dec_open( IF( st_ivas->hTcBuffer == NULL ) { - int16_t nchan_to_allocate; - int16_t nchan_tc; + Word16 nchan_to_allocate; + Word16 nchan_tc; TC_BUFFER_MODE buffer_mode; buffer_mode = TC_BUFFER_MODE_RENDERER; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 91289552b4bbf096fc93300e50cd5bbb0f65aae9..66ced94fb9a552c996fe3f950af806092f9350ba 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1070,7 +1070,7 @@ ivas_error mct_dec_reconfigure_fx( /* st->bits_frame_nominal = (int16_t) ( st_ivas->hCPE[cpe_id]->element_brate / FRAMES_PER_SEC ); */ st->bits_frame_nominal = extract_l( Mpy_32_32( st_ivas->hCPE[cpe_id]->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); move16(); - st->igf = getIgfPresent_fx( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->rf_flag ); // no floating point so directly pluggable + st->igf = getIgfPresent_fx( st->element_mode, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), st->bwidth, st->rf_flag ); // no floating point so directly pluggable move16(); IF( st->igf ) diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index fabd897f50f26fb2238b9deecbc18ad7d80e39ae..57a658f4bf717898599f4fe874e8f691141a38e7 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -47,10 +47,13 @@ /*------------------------------------------------------------------------- * Local constants *------------------------------------------------------------------------*/ - -#define DOWNMIX_ALPHA 0.95f /* Smoothing coefficient */ -#define DOWNMIX_ALPHA_FX 31130 /* Smoothing coefficient */ -#define DOWNMIX_MAX_GAIN 4.0f /* Maximum allowed gain */ +#ifndef IVAS_FLOAT_FIXED +#define DOWNMIX_ALPHA 0.95f /* Smoothing coefficient */ +#endif // !IVAS_FLOAT_FIXED +#define DOWNMIX_ALPHA_FX 31130 /* Smoothing coefficient */ +#ifndef IVAS_FLOAT_FIXED +#define DOWNMIX_MAX_GAIN 4.0f /* Maximum allowed gain */ +#endif #define MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS 4 /*------------------------------------------------------------------------- diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 15d83a8e4ce3e7d0bad849180dbbe009199ff226..562225d1f46b7ee75258c5cc82b54acc8910ae53 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -41,17 +41,15 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx.h" -#ifdef IVAS_FLOAT_FIXED -#include "math.h" // temporary (for fabs) -#endif -#define IVAS_FLOAT_FIXED_TO_BE_REMOVED /*------------------------------------------------------------------------- * Local constants *------------------------------------------------------------------------*/ -#define OMASA_TDREND_MATCHING_GAIN 0.7943f +#ifndef IVAS_FLOAT_FIXED +#define OMASA_TDREND_MATCHING_GAIN 0.7943f +#endif // !IVAS_FLOAT_FIXED #define OMASA_TDREND_MATCHING_GAIN_FX 26026 /*-------------------------------------------------------------------* diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 4c8c8103eee490879f406e82e30ca9cecc86464d..1eba206fb80ba1b55945bca6cbeaf431aa1372bb 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -394,7 +394,6 @@ ivas_error ivas_osba_render_sf_fx( { scale_sig32( p_output[n], *nSamplesRendered, -1 ); } - // v_multc_fixed(p_output[n], 1073741824 /* 0.5f in Q31 */, p_output[n], *nSamplesRendered); } return IVAS_ERR_OK; diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index b9a28ae63041e4d08660304b56276f0f44c4c891..d386b3c85bc3922fe6e3e6f5133f2212df788997 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -51,9 +51,11 @@ * Local constants *----------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED #define LS_OUT_CONV_SMOOTHING_FACTOR 0.0435f #define LS_OUT_CONV_CLIP_FACTOR_MAX 2.0f #define LS_OUT_CONV_CLIP_FACTOR_MIN 0.3f +#endif // !IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED #define LS_OUT_CONV_SMOOTHING_FACTOR_Q31 93415539 @@ -348,7 +350,6 @@ static void get_custom_ls_conversion_matrix_fx( ELSE IF( NE_16( lfe_out_idx, ch_in ) ) { /* Set the values of hLsSetUpConversion->dmxMtx to EFAP gains, skipping LFE */ - /*angles float2fix conversion: to be removed*/ efap_determine_gains_fx( hEFAPdata, tmp_gains, hTransSetup.ls_azimuth_fx[ch_in_woLFE], hTransSetup.ls_elevation_fx[ch_in_woLFE], EFAP_MODE_EFAP ); FOR( ( ch_out = 0, ch_out_woLFE = 0 ); ch_out < nchan_out; ( ch_out++, ch_out_woLFE++ ) ) diff --git a/lib_dec/ivas_post_proc.c b/lib_dec/ivas_post_proc.c index ed7cc13c4d7b7677f1345f3afd42810f9b797f38..e5f6f4db02cb962e435f4ebc1f9a9eeba2740a4d 100644 --- a/lib_dec/ivas_post_proc.c +++ b/lib_dec/ivas_post_proc.c @@ -207,7 +207,6 @@ void ivas_post_proc_fx( test(); IF( EQ_16( EQ_16( sts[n]->element_mode, IVAS_CPE_DFT ) && EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ), 0 ) && NE_16( sts[n]->element_mode, IVAS_CPE_MDCT ) ) { - // mvr2r( sts[n]->prev_synth_buffer32_fx, sts[n]->hTcxDec->FBTCXdelayBuf_32, 0 ); Copy32( sts[n]->delay_buf_out32_fx, sts[n]->hTcxDec->FBTCXdelayBuf_32, delay_comp ); } ELSE IF( sba_dirac_stereo_flag && EQ_16( sts[n]->element_mode, IVAS_CPE_MDCT ) ) @@ -309,23 +308,22 @@ void stereo_dft_dec_core_switching_fx( move16(); /*TBE*/ - delay_tdbwe = NS2SA( output_Fs, DELAY_BWE_TOTAL_NS ); + delay_tdbwe = NS2SA_FX2( output_Fs, DELAY_BWE_TOTAL_NS ); move16(); - delay_dft_dec = NS2SA( output_Fs, STEREO_DFT_DELAY_DEC_BWE_NS ); + delay_dft_dec = NS2SA_FX2( output_Fs, STEREO_DFT_DELAY_DEC_BWE_NS ); move16(); - delay_dft_dec_lb = NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT_DELAY_DEC_BWE_NS ); + delay_dft_dec_lb = NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT_DELAY_DEC_BWE_NS ); move16(); /* TCX/ACELP/HQ-CORE->TCX */ - tmps = NS2SA( output_Fs, DELAY_BWE_TOTAL_NS ); /*cross-fading size @ FB*/ + tmps = NS2SA_FX2( output_Fs, DELAY_BWE_TOTAL_NS ); /*cross-fading size @ FB*/ move16(); - delay_comp = NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), DELAY_BWE_TOTAL_NS ); /*cross-fading size @ LB*/ + delay_comp = NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), DELAY_BWE_TOTAL_NS ); /*cross-fading size @ LB*/ move16(); calc_inv = W_shl( 1, 31 ); // Memory Tables ////////////////////////////////////////////////////////////////////////////// - Word32 mem_len_inv_tbl[] = { 85899345, 42949672, 28633115, 21474836, 17179869, 14316557 }; Word32 delay_comp_inv_tbl[] = { 2147483647, 306783378, 153391689, 97612893, 74051160, 58040098, 48806446, 42107522, 36398027, 32537631, 29020049 }; /////////////////////////////////////////////////////////////////////////////////////////////// @@ -334,13 +332,13 @@ void stereo_dft_dec_core_switching_fx( test(); IF( NE_16( st->last_L_frame, st->L_frame ) && LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) { - L_lerp_fx_q11( hCPE->input_mem_LB_fx[0], hCPE->input_mem_LB_fx[0], NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), NS2SA( L_mult0( st->last_L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); - L_lerp_fx_q11( hCPE->input_mem_BPF_fx[0], hCPE->input_mem_BPF_fx[0], NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), NS2SA( L_mult0( st->last_L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); + L_lerp_fx_q11( hCPE->input_mem_LB_fx[0], hCPE->input_mem_LB_fx[0], NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), NS2SA_FX2( L_mult0( st->last_L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); + L_lerp_fx_q11( hCPE->input_mem_BPF_fx[0], hCPE->input_mem_BPF_fx[0], NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), NS2SA_FX2( L_mult0( st->last_L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); } test(); test(); - if ( ( st->prev_bfi != 0 ) && EQ_16( EQ_16( st->last_core_bfi, ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ), 0 ) ) + if ( ( st->prev_bfi != 0 ) && EQ_16( ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ), 0 ) ) { /* last_core needed FOR correctly decoding ACELP->TCX/HQ switching frames in ivas_core_dec(). In the following steps the decoder needs to consider IF the core was changed due to a lost frame to apply the correct transition */ @@ -368,10 +366,10 @@ void stereo_dft_dec_core_switching_fx( test(); test(); test(); - IF( ( ( NE_16( st->last_core, ACELP_CORE ) || ( EQ_16( st->prev_bfi, 1 ) && EQ_16( st->last_core, ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ) ) ) && NE_16( st->last_core, AMR_WB_CORE ) ) || ( sba_dirac_stereo_dtx_flag && EQ_16( st->cng_type, FD_CNG ) ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ + IF( ( ( ( st->last_core != ACELP_CORE ) || ( EQ_16( st->prev_bfi, 1 ) && EQ_16( st->last_core, ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ) ) ) && NE_16( st->last_core, AMR_WB_CORE ) ) || ( sba_dirac_stereo_dtx_flag && EQ_16( st->cng_type, FD_CNG ) ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ { /* In case of a TCX to ACELP switch next frame */ - Copy32( &output_fx[st->L_frame - NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS )], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); + Copy32( &output_fx[st->L_frame - NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS )], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /* BPF */ test(); @@ -397,7 +395,7 @@ void stereo_dft_dec_core_switching_fx( test(); IF( LE_32( st->last_core_brate, SID_2k40 ) && LE_16( st->element_mode, IVAS_SCE ) ) { - Word16 mem_len = NS2SA( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ); + Word16 mem_len = NS2SA_FX2( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ); move16(); Word32 mem_len_inv = mem_len_inv_tbl[idiv1616( mem_len, 25 )]; move32(); @@ -414,8 +412,8 @@ void stereo_dft_dec_core_switching_fx( /* Update FB input buff with hb synth FOR last delay_tdbwe sampled */ FOR( i = 0; i < delay_tdbwe; i++ ) { - hCPE->input_mem_fx[0][add( sub( NS2SA( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_tdbwe ), i )] = - L_add( hCPE->input_mem_fx[0][NS2SA( L_add( L_sub( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_tdbwe ), i )], hb_synth_fx[i] ); + hCPE->input_mem_fx[0][add( sub( NS2SA_FX2( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_tdbwe ), i )] = + L_add( hCPE->input_mem_fx[0][NS2SA_FX2( L_add( L_sub( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_tdbwe ), i )], hb_synth_fx[i] ); move32(); } } @@ -424,7 +422,7 @@ void stereo_dft_dec_core_switching_fx( /* Update FB input buff with hb synth FOR last delay_tdbwe sampled */ FOR( i = 0; i < delay_tdbwe; i++ ) { - hCPE->input_mem_fx[0][add( sub( NS2SA( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_tdbwe ), i )] = hb_synth_fx[i]; + hCPE->input_mem_fx[0][add( sub( NS2SA_FX2( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_tdbwe ), i )] = hb_synth_fx[i]; move32(); } } @@ -467,7 +465,7 @@ void stereo_dft_dec_core_switching_fx( /* In case of TCX frames, output LB TCX is zeroed out until the end but in case of an TCX->ACELP switch, this memory is needed, hence it is backed up */ /* Unlike the case when DFT32MS is disabled, there is only 1 DFT analysis window, hence in the TCX frame we don't want to do a DFT analysis FOR LB TCX but in a potential ACELP frame, we want the memories of the LB TCX FOR the last OLA samples so that HB analysis can be skipped */ - Copy32( &output_fx[st->L_frame - NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS )], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); + Copy32( &output_fx[st->L_frame - NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS )], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /*zero the rest FOR avoiding adding contribution except the last samples which are not considered in DFT analysis (potentially used in next ACELP frame)*/ IF( GT_32( st->last_core_brate, SID_2k40 ) ) @@ -483,7 +481,7 @@ void stereo_dft_dec_core_switching_fx( /* BPF */ IF( st->p_bpf_noise_buf_32 ) { - set32_fx( hCPE->input_mem_BPF_fx[0], 0, NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hCPE->input_mem_BPF_fx[0], 0, NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); } } } @@ -496,8 +494,8 @@ void stereo_dft_dec_core_switching_fx( test(); IF( LE_32( st->core_brate, SID_2k40 ) && !sba_dirac_stereo_dtx_flag ) { - set32_fx( hCPE->input_mem_fx[0], 0, NS2SA( L_mult0( st->hTcxDec->L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); - set32_fx( hCPE->input_mem_LB_fx[0], 0, NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hCPE->input_mem_fx[0], 0, NS2SA_FX2( L_mult0( st->hTcxDec->L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hCPE->input_mem_LB_fx[0], 0, NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /* CNG generated in ivas_cpe_dec() */ } @@ -506,22 +504,22 @@ void stereo_dft_dec_core_switching_fx( IF( ( LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) || ( sba_dirac_stereo_dtx_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) ) { /* In case of a TCX to ACELP switch, retrieve the LB-TCX memories FOR the first STEREO_DFT32MS_OVL_NS NS of OLA */ - L_lerp_fx_q11( hCPE->hStereoDft->buff_LBTCX_mem_fx, hCPE->input_mem_LB_fx[0], NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), NS2SA( L_mult0( st->last_L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); + L_lerp_fx_q11( hCPE->hStereoDft->buff_LBTCX_mem_fx, hCPE->input_mem_LB_fx[0], NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), NS2SA_FX2( L_mult0( st->last_L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); } IF( sba_dirac_stereo_dtx_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) { Word16 nZeros; - nZeros = (Word16) ( NS2SA( st->output_Fs, N_ZERO_MDCT_NS ) ); + nZeros = (Word16) ( NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ) ); move16(); - delay_comp = NS2SA( st->output_Fs, DELAY_CLDFB_NS ); + delay_comp = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); move16(); - Copy32( &st->hHQ_core->oldOut_fx[sub( nZeros, add( delay_comp, NS2SA( L_mult0( output_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ) )], hCPE->input_mem_fx[0], NS2SA( L_mult0( output_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); + Copy32( &st->hHQ_core->oldOut_fx[sub( nZeros, add( delay_comp, NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ) )], hCPE->input_mem_fx[0], NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); Copy32( synth_fx, synth_tmp_fx, output_frame ); Word16 mem_len; - mem_len = NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ); + mem_len = NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ); move16(); Word16 qmem_len = norm_l( mem_len ); @@ -551,7 +549,7 @@ void stereo_dft_dec_core_switching_fx( ELSE { /* ACELP */ - FOR( i = 0; i < ( NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ); i++ ) + FOR( i = 0; i < ( NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ); i++ ) { hCPE->input_mem_LB_fx[0][i] = 0; move32(); @@ -561,11 +559,11 @@ void stereo_dft_dec_core_switching_fx( Word32 delay_dft_dec_lb_inv = (Word32) ( calc_inv / delay_dft_dec_lb ); FOR( i = 0; i < delay_dft_dec_lb; i++ ) { - hCPE->input_mem_LB_fx[0][add( sub( NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec_lb ), i )] = - Mpy_32_32( hCPE->input_mem_LB_fx[0][add( sub( NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec_lb ), i )], L_shl( i, qdelay_dft_dec_lb ) ); + hCPE->input_mem_LB_fx[0][add( sub( NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec_lb ), i )] = + Mpy_32_32( hCPE->input_mem_LB_fx[0][add( sub( NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec_lb ), i )], L_shl( i, qdelay_dft_dec_lb ) ); move32(); - hCPE->input_mem_LB_fx[0][add( sub( NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec_lb ), i )] = - L_shl( Mpy_32_32( hCPE->input_mem_LB_fx[0][add( sub( NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec_lb ), i )], delay_dft_dec_lb_inv ), sub( Q31, qdelay_dft_dec_lb ) ); + hCPE->input_mem_LB_fx[0][add( sub( NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec_lb ), i )] = + L_shl( Mpy_32_32( hCPE->input_mem_LB_fx[0][add( sub( NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec_lb ), i )], delay_dft_dec_lb_inv ), sub( Q31, qdelay_dft_dec_lb ) ); move32(); } stereo_dft_dec_analyze_fx( hCPE, output_fx, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_LB, 0, 0, q, q_DFT ); @@ -588,12 +586,12 @@ void stereo_dft_dec_core_switching_fx( Word32 delay_dft_dec_fx = L_shl( delay_dft_dec, qdelay_dft_dec ); FOR( i = 0; i < delay_dft_dec; i++ ) /* 1.25 ms of hb_synth fade-in and TCX fade-out */ { - hCPE->input_mem_fx[0][add( sub( NS2SA( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec ), i )] = L_add( + hCPE->input_mem_fx[0][add( sub( NS2SA_FX2( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec ), i )] = L_add( Mpy_32_32( hb_synth_fx[add( sub( delay_tdbwe, delay_dft_dec ), i )], L_shl( i, qdelay_dft_dec ) ), - Mpy_32_32( hCPE->input_mem_fx[0][add( sub( NS2SA( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec ), i )], L_sub( delay_dft_dec_fx, L_shl( i, qdelay_dft_dec ) ) ) ); + Mpy_32_32( hCPE->input_mem_fx[0][add( sub( NS2SA_FX2( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec ), i )], L_sub( delay_dft_dec_fx, L_shl( i, qdelay_dft_dec ) ) ) ); move32(); - hCPE->input_mem_fx[0][add( sub( NS2SA( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec ), i )] = L_shl( - Mpy_32_32( hCPE->input_mem_fx[0][add( sub( NS2SA( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec ), i )], delay_dft_dec_inv ), + hCPE->input_mem_fx[0][add( sub( NS2SA_FX2( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec ), i )] = L_shl( + Mpy_32_32( hCPE->input_mem_fx[0][add( sub( NS2SA_FX2( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec ), i )], delay_dft_dec_inv ), sub( Q31, qdelay_dft_dec ) ); move32(); } @@ -640,7 +638,7 @@ void stereo_dft_dec_core_switching_fx( /* this needs an indication FOR sba2stereo in general */ ELSE IF( EQ_16( hCPE->element_mode, IVAS_SCE ) && LE_32( st->last_core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) { - L_lerp_fx_q11( hCPE->input_mem_fx[0], hCPE->input_mem_LB_fx[0], NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), NS2SA( L_mult0( output_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); + L_lerp_fx_q11( hCPE->input_mem_fx[0], hCPE->input_mem_LB_fx[0], NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); } /* ACELP synthesis @ internal sampling rate */ @@ -703,7 +701,7 @@ void stereo_dft_dec_core_switching_fx( test(); IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && EQ_16( st->core, ACELP_CORE ) && EQ_16( st->con_tcx, 1 ) ) ) { - Word16 numZeros = (Word16) ( NS2SA( st->sr_core, N_ZERO_MDCT_NS ) ); + Word16 numZeros = (Word16) ( NS2SA_FX2( st->sr_core, N_ZERO_MDCT_NS ) ); Word32 tmp_fade_fx[max( STEREO_DFT_ALLPASS_FADELEN_12k8, STEREO_DFT_ALLPASS_FADELEN_16k )]; Copy32( st->hHQ_core->old_outLB_fx + numZeros, hCPE->hStereoDft->ap_fade_mem_fx, ap_fade_len ); @@ -755,7 +753,7 @@ void stereo_dft_dec_core_switching_fx( } } } - predelay = NS2SA( st->sr_core, DELAY_BWE_TOTAL_NS ); + predelay = NS2SA_FX2( st->sr_core, DELAY_BWE_TOTAL_NS ); move16(); /* apply predelay to have same overall filter delay FOR all cases */ diff --git a/lib_dec/ivas_range_uni_dec.c b/lib_dec/ivas_range_uni_dec.c index 2f93698054b1c23577f1f2cd640707e03ec80883..f2bbc1202fd08afb87200af3e5a6b39a8f1d8c19 100644 --- a/lib_dec/ivas_range_uni_dec.c +++ b/lib_dec/ivas_range_uni_dec.c @@ -40,6 +40,9 @@ #include "options.h" #include "prot.h" #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "prot_fx.h" +#endif /* @@ -56,11 +59,12 @@ /*-------------------------------------------------------------------* * Local function prototypes *-------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED static int16_t rc_uni_dec_read( RangeUniDecState *rc_st_dec ); +static void rc_uni_dec_update( RangeUniDecState *rc_st_dec, const uint16_t cum_freq, const uint16_t sym_freq ); +#endif static Word16 rc_uni_dec_read_fx( RangeUniDecState *rc_st_dec ); -static void rc_uni_dec_update( RangeUniDecState *rc_st_dec, const uint16_t cum_freq, const uint16_t sym_freq ); static void rc_uni_dec_update_fx( RangeUniDecState *rc_st_dec, const UWord16 cum_freq, const UWord16 sym_freq ); @@ -69,7 +73,7 @@ static void rc_uni_dec_update_fx( RangeUniDecState *rc_st_dec, const UWord16 cum * * Initialize the range decoder *-------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED void rc_uni_dec_init( RangeUniDecState *rc_st_dec, /* i/o: RC state handle */ uint16_t *bit_buffer, /* i : Bit buffer */ @@ -95,6 +99,7 @@ void rc_uni_dec_init( return; } +#endif void rc_uni_dec_init_fx( RangeUniDecState *rc_st_dec, /* i/o: RC state handle */ UWord16 *bit_buffer, /* i : Bit buffer */ @@ -129,6 +134,7 @@ void rc_uni_dec_init_fx( *-------------------------------------------------------------------*/ /*! r: Read symbol */ +#ifndef IVAS_FLOAT_FIXED uint16_t rc_uni_dec_read_symbol_fastS( RangeUniDecState *rc_st_dec, /* i/o: Decoder State */ const uint16_t cum_freq_table[], /* i : Cumulative frequency up to symbol */ @@ -202,6 +208,7 @@ uint16_t rc_uni_dec_read_symbol_fastS( return sym_begin; } +#endif UWord16 rc_uni_dec_read_symbol_fastS_fx( RangeUniDecState *rc_st_dec, /* i/o: Decoder State */ const UWord16 cum_freq_table[], /* i : Cumulative frequency up to symbol */ @@ -293,7 +300,7 @@ UWord16 rc_uni_dec_read_symbol_fastS_fx( * * Update the state for the symbol found after using get_cumulative *-------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED static void rc_uni_dec_update( RangeUniDecState *rc_st_dec, /* i/o: RC State handle */ const uint16_t cum_freq, /* i : Cumulative frequency */ @@ -317,6 +324,7 @@ static void rc_uni_dec_update( return; } +#endif // !IVAS_FLOAT_FIXED static void rc_uni_dec_update_fx( RangeUniDecState *rc_st_dec, /* i/o: RC State handle */ @@ -397,7 +405,7 @@ UWord16 rc_uni_dec_read_bit( /*basop comment : comparision of unsigned integers hence basops are not used*/ IF( range < 0x01000000 ) { - low = UL_addNsD( UL_lshl( low, 8 ), (UWord32) rc_uni_dec_read( rc_st_dec ) ); + low = UL_addNsD( UL_lshl( low, 8 ), (UWord32) rc_uni_dec_read_fx( rc_st_dec ) ); range = UL_lshl( range, 8 ); } @@ -523,11 +531,11 @@ UWord16 rc_uni_dec_read_bit_prob_fast( /*basop comment : comparision of unsigned integers hence basops are not used*/ IF( range < 0x01000000 ) { - low = UL_addNsD( UL_lshl( low, 8 ), (UWord32) rc_uni_dec_read( rc_st_dec ) ); + low = UL_addNsD( UL_lshl( low, 8 ), (UWord32) rc_uni_dec_read_fx( rc_st_dec ) ); range = UL_lshl( range, 8 ); IF( range < 0x01000000 ) { - low = UL_addNsD( UL_lshl( low, 8 ), (UWord32) rc_uni_dec_read( rc_st_dec ) ); + low = UL_addNsD( UL_lshl( low, 8 ), (UWord32) rc_uni_dec_read_fx( rc_st_dec ) ); range = UL_lshl( range, 8 ); } } @@ -609,6 +617,68 @@ uint16_t rc_uni_dec_read_bit_prob_fast( *-------------------------------------------------------------------*/ /*! r: Read bits */ +#ifdef IVAS_FLOAT_FIXED +UWord16 rc_uni_dec_read_bits( + RangeUniDecState *rc_st_dec, /* i/o: RC State handle */ + const Word16 bits /* i : Number of bits */ +) +{ + UWord32 val; + UWord32 low; /* local copy (2 to 6 uses) */ + UWord32 range; /* local copy (4 to 7 uses) */ + Word16 norm_range; + UWord32 temp1, temp2; + + low = rc_st_dec->rc_low; + range = rc_st_dec->rc_range; + move32(); + move32(); + + range = (UWord32) W_shr( range, bits ); + temp1 = (UWord32) W_shr( low, 1 ); + norm_range = sub( W_norm( range ), 31 ); + temp2 = (UWord32) W_shl( range, norm_range ); + val = (UWord32) W_shr( UL_div( temp1, temp2 ), sub( 32 - 1, norm_range ) ); + + /* in case of bitstream errors it is possible that val >= (1 << bits) */ + IF( W_shr( val, bits ) != 0 ) /* equivalent condition */ + { + rc_st_dec->bit_error_detected = 1; + move16(); + + /* for valid bitstreams, always low < range, therefore setting low = range */ + /* will always reach the bitstream error condition branch on the next call */ + rc_st_dec->rc_range = 0xFFFFFFFF; + rc_st_dec->rc_low = rc_st_dec->rc_range; + move32(); + move32(); + + /* the current value and all the following values are very likely incorrect */ + return 0; /* return the minimum valid value for the output */ + } + + low = (UWord32) W_sub( low, W_mult0_32_32( val, range ) ); + + /* rc_range was shifted right by up to 16, so at most two renormalizations are needed */ + IF( LT_64( range, 0x01000000 ) ) + { + low = (UWord32) W_add( W_shl( low, 8 ), rc_uni_dec_read_fx( rc_st_dec ) ); + range = (UWord32) W_shl( range, 8 ); + if ( LT_64( range, 0x01000000 ) ) + { + low = (UWord32) W_add( W_shl( low, 8 ), rc_uni_dec_read_fx( rc_st_dec ) ); + range = (UWord32) W_shl( range, 8 ); + } + } + + rc_st_dec->rc_low = low; + rc_st_dec->rc_range = range; + move32(); + move32(); + + return (UWord16) val; +} +#else uint16_t rc_uni_dec_read_bits( RangeUniDecState *rc_st_dec, /* i/o: RC State handle */ const int16_t bits /* i : Number of bits */ @@ -702,6 +772,8 @@ int16_t rc_uni_dec_virtual_finish( /* the function is completely equivalent with rc_uni_dec_finish */ return rc_st_dec->bit_count + norm_l( rc_st_dec->rc_range >> 24 ) - 53; } +#endif +#ifdef IVAS_FLOAT_FIXED Word16 rc_uni_dec_virtual_finish_fx( RangeUniDecState *rc_st_dec /* i : RC state handle */ ) @@ -710,6 +782,7 @@ Word16 rc_uni_dec_virtual_finish_fx( // Not adding basop because value of rc_st_dec->rc_range exceeds Word32 return add( rc_st_dec->bit_count, sub( norm_l( rc_st_dec->rc_range >> 24 ), 53 ) ); } +#else /*-------------------------------------------------------------------* @@ -755,6 +828,7 @@ static int16_t rc_uni_dec_read( return byte_read; } +#endif // !IVAS_FLOAT_FIXED static Word16 rc_uni_dec_read_fx( RangeUniDecState *rc_st_dec /* i/o: RC State handle */ diff --git a/lib_dec/ivas_rom_dec.h b/lib_dec/ivas_rom_dec.h index f03bc53cc4e7494466685cb55a1ea806160ece4b..6ab30892585d85d7b5af93e2556fbd332c971a9b 100644 --- a/lib_dec/ivas_rom_dec.h +++ b/lib_dec/ivas_rom_dec.h @@ -43,11 +43,13 @@ /*----------------------------------------------------------------------------------* * DFT stereo ROM tables *----------------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED extern const float dft_alpha_w_b2[STEREO_DFT_BAND_MAX]; extern const float dft_alpha_s_b2[STEREO_DFT_BAND_MAX]; extern const float dft_alpha_s2_b2[STEREO_DFT_BAND_MAX]; extern const float dft_bpf_weights[]; +#endif // !IVAS_FLOAT_FIXED + #ifdef IVAS_FLOAT_FIXED extern const Word16 dft_alpha_s_fx[STEREO_DFT_BAND_MAX]; extern const Word16 dft_alpha_w_fx[STEREO_DFT_BAND_MAX]; @@ -59,13 +61,15 @@ extern const Word32 dft_bpf_weights_fx[]; extern const Word32 dft_ap_gains_fx[5][3]; #endif - +#ifndef IVAS_FLOAT_FIXED extern const float dft_alpha_w[]; extern const float dft_alpha_s[]; extern const float dft_alpha_s2[]; extern const float dft_ap_gains[5][3]; +#endif extern const int16_t dft_ap_delays[3][3]; +#ifndef IVAS_FLOAT_FIXED extern const float dft_res_pred_weights[][STEREO_DFT_BAND_MAX]; extern const float dft_win232ms_8k[75]; @@ -73,7 +77,7 @@ extern const float dft_win232ms_12k8[120]; extern const float dft_win232ms_16k[150]; extern const float dft_win232ms_32k[300]; extern const float dft_win232ms_48k[450]; - +#endif #ifdef IVAS_FLOAT_FIXED extern const Word16 dft_win232ms_8k_fx[75]; extern const Word16 dft_win232ms_12k8_fx[120]; @@ -83,15 +87,18 @@ extern const Word16 dft_win232ms_48k_fx[450]; extern const Word16 dft_res_pred_weights_fx[][STEREO_DFT_BAND_MAX]; extern const Word16 dft_win_8k_fx[70]; #endif - +#ifndef IVAS_FLOAT_FIXED extern const float dft_win_8k[70]; +#endif extern const int16_t cna_init_bands[CNA_INIT_NBANDS + 1]; +#ifndef IVAS_FLOAT_FIXED extern const float min_smooth_gains1[SBA_DIRAC_STEREO_NUM_BANDS]; extern const float max_smooth_gains1[SBA_DIRAC_STEREO_NUM_BANDS]; extern const float min_smooth_gains2[SBA_DIRAC_STEREO_NUM_BANDS]; extern const float max_smooth_gains2[SBA_DIRAC_STEREO_NUM_BANDS]; +#endif #ifdef IVAS_FLOAT_FIXED extern const Word16 min_smooth_gains1_fx[SBA_DIRAC_STEREO_NUM_BANDS]; @@ -116,9 +123,10 @@ extern const uint16_t *const sym_freq_ECSQ_tab_abs_lsbs[1 + 4]; * DirAC ROM tables *----------------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED extern const float dirac_dithering_azi_scale[DIRAC_DIFFUSE_LEVELS]; extern const float dirac_dithering_ele_scale[DIRAC_DIFFUSE_LEVELS]; +#endif #ifdef IVAS_FLOAT_FIXED extern const Word16 dirac_dithering_azi_scale_fx[DIRAC_DIFFUSE_LEVELS]; @@ -128,11 +136,11 @@ extern const Word16 dirac_dithering_ele_scale_fx[DIRAC_DIFFUSE_LEVELS]; /*----------------------------------------------------------------------------------* * FASTCONV and PARAMETRIC binaural renderer ROM tables *----------------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED extern const float dmxmtx_table[BINAURAL_CHANNELS][11]; +#endif extern const Word32 dmxmtx_table_fx[BINAURAL_CHANNELS][11]; - /*----------------------------------------------------------------------* * MC ParamUpmix ROM tables *-----------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 2db9ed6a09ff3a0cd2e67f7c2fe306622a0e6410..02b6cc099117f0ab3b1cbb7f189d49d6618f3200 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -149,7 +149,7 @@ void ivas_sba2mc_cldfb_fixed( FOR( m = 0; m < nb_channels_in; m++ ) { - g_fx = hoa_dec_mtx[add( SBA_NHARM_HOA3 * n, m )]; // Q29 + g_fx = hoa_dec_mtx[add( imult1616( SBA_NHARM_HOA3, n ), m )]; // Q29 p_realOut_fx = realOut_fx[n]; p_imagOut_fx = imagOut_fx[n]; diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index e46846114ccba162e87dc9cd619e5974f684c136..3efb36ada4951df55f80ae75d98b3c062cbd11d9 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -292,7 +292,7 @@ ivas_error ivas_spar_dec_open_fx( error = IVAS_ERR_OK; move32(); - sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); + sba_order_internal = s_min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); move16(); num_channels_internal = ivas_sba_get_nchan_metadata_fx( sba_order_internal, st_ivas->hDecoderConfig->ivas_total_brate ); @@ -357,7 +357,7 @@ ivas_error ivas_spar_dec_open_fx( { return error; } - fb_cfg->pcm_offset = NS2SA( output_Fs, DELAY_FB_1_NS + IVAS_ENC_DELAY_NS + IVAS_DEC_DELAY_NS ); + fb_cfg->pcm_offset = NS2SA_FX2( output_Fs, DELAY_FB_1_NS + IVAS_ENC_DELAY_NS + IVAS_DEC_DELAY_NS ); move16(); fb_cfg->remix_order = remix_order_set[hSpar->hMdDec->spar_md_cfg.remix_unmix_order]; move16(); @@ -476,7 +476,7 @@ ivas_error ivas_spar_dec_open_fx( nchan_to_allocate = add( nchan_to_allocate, st_ivas->nchan_ism ); } - granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); move16(); test(); @@ -1159,6 +1159,9 @@ void ivas_spar_get_cldfb_gains_fx( Word16 ts, cf_cldfb_start, cf_cldfb_end; Word16 sample, num_cf_slots, num_samples; Word16 seed, split_band, slot_row, slot_col, slot, tmp_idx; + Word16 Q_cf_start_s; + Word16 Q_cf_len_s; + Word16 Q_weights; pt_len = cldfbAnaDec0->p_filter_length; move16(); @@ -1186,9 +1189,9 @@ void ivas_spar_get_cldfb_gains_fx( set32_fx( tgt_fx, 0, ( 3 - 1 ) * CLDFB_NO_CHANNELS_MAX + 10 * CLDFB_NO_CHANNELS_MAX ); cf_start_s_fx = divide3232( ( sub( cf_start, shr( decfb_delay, 1 ) ) ), output_Fs_fx ); cf_len_s_fx = divide3232( sub( hSpar->hFbMixer->cross_fade_end_offset, hSpar->hFbMixer->cross_fade_start_offset ), output_Fs_fx ); - Word16 Q_cf_start_s = sub( norm_s( cf_start_s_fx ), 1 ); - Word16 Q_cf_len_s = norm_s( cf_len_s_fx ); - Word16 Q_weights = add( 15, sub( Q_cf_start_s, Q_cf_len_s ) ); + Q_cf_start_s = sub( norm_s( cf_start_s_fx ), 1 ); + Q_cf_len_s = norm_s( cf_len_s_fx ); + Q_weights = add( 15, sub( Q_cf_start_s, Q_cf_len_s ) ); FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) { weights_fx[ts] = divide1616( shl( sub( divide3232( L_mult0( add( shl( ts, 1 ), 1 ), shr( stride, 1 ) ), output_Fs_fx ), cf_start_s_fx ), Q_cf_start_s ), shl( cf_len_s_fx, Q_cf_len_s ) ); @@ -1212,8 +1215,6 @@ void ivas_spar_get_cldfb_gains_fx( /* optimization*/ /* compute time-domain cross-fade for considered time slots*/ tmp_idx = sub( cf_start, imult1616( cf_cldfb_start, stride ) ); - // Word32 pFilterbank_cross_fade_fx[192];// Temporarily added to stored fixed value of hSpar->hFbMixer->pFilterbank_cross_fade_fx - // floatToFixed_arrL( (float *)hSpar->hFbMixer->pFilterbank_cross_fade, pFilterbank_cross_fade_fx, Q31, cf_len ); FOR( sample = 0; sample < cf_len; sample++ ) { tgt_fx[tmp_idx] = L_deposit_h( hSpar->hFbMixer->pFilterbank_cross_fade_fx[sample] ); @@ -1334,6 +1335,27 @@ void ivas_spar_get_cldfb_gains_fx( return; } +Word16 ivas_is_res_channel( + const Word16 ch, /* i : ch index in WYZX ordering */ + const Word16 nchan_transport /* i : number of transport channels (1-4) */ +) +{ + const Word16 rc_map[FOA_CHANNELS][FOA_CHANNELS] = { + { 0, 0, 0, 0 }, + { 0, 1, 0, 0 }, + { 0, 1, 0, 1 }, + { 0, 1, 1, 1 } + }; + + IF( GE_16( ch, FOA_CHANNELS ) ) + { + /* never transmitted */ + return 0; + } + assert( nchan_transport <= FOA_CHANNELS ); + + return ( rc_map[nchan_transport - 1][ch] ); +} #else void ivas_spar_get_cldfb_gains( SPAR_DEC_HANDLE hSpar, @@ -1515,7 +1537,6 @@ void ivas_spar_get_cldfb_gains( return; } -#endif // IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* @@ -1546,6 +1567,7 @@ int16_t ivas_is_res_channel( return ( rc_map[nchan_transport - 1][ch] ); } +#endif // IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 8fa79a7be0d316ce429b310294d36b38665ecb76..8e89e6b06381abe083f3767737cc468daa926242 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -68,15 +68,20 @@ static const int16_t ivas_spar_dec_plc_spatial_target[IVAS_SPAR_MAX_CH] = { 1, 0 #ifdef IVAS_FLOAT_FIXED static void ivas_get_spar_matrices_fx( ivas_spar_md_dec_state_t *hMdDec, const Word16 num_bands_out, const Word16 n_ts, const Word16 bw, const Word16 dtx_vad, const Word16 nB, const Word16 numch_out, const Word16 active_w_vlbr, const Word16 dyn_active_w_flag ); +static void ivas_decode_arith_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, const UWord16 qsi, const Word16 nB, const Word16 bands_bw, Word16 *pDo_diff, const Word16 strat, const Word32 ivas_total_brate ); + +static void ivas_decode_huffman_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, const UWord16 qsi, const Word16 nB, const Word16 bands_bw ); + +static void ivas_fill_band_coeffs_idx( ivas_band_coeffs_ind_t *pBands_idx, const Word16 nB, Word16 *pSymbol_re, ivas_cell_dim_t *pCell_dims, ivas_coeffs_type_t coeff_type ); #else static void ivas_get_spar_matrices( ivas_spar_md_dec_state_t *hMdDec, const int16_t num_bands_out, const int16_t n_ts, const int16_t bw, const int16_t dtx_vad, const int16_t nB, const int16_t numch_out, const int16_t active_w_vlbr, const int16_t dyn_active_w_flag ); -#endif static void ivas_decode_arith_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, const uint16_t qsi, const int16_t nB, const int16_t bands_bw, int16_t *pDo_diff, const int16_t strat, const int32_t ivas_total_brate ); static void ivas_decode_huffman_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, const uint16_t qsi, const int16_t nB, const int16_t bands_bw ); static void ivas_fill_band_coeffs_idx( ivas_band_coeffs_ind_t *pBands_idx, const int16_t nB, int16_t *pSymbol_re, ivas_cell_dim_t *pCell_dims, ivas_coeffs_type_t coeff_type ); +#endif #ifndef IVAS_FLOAT_FIXED static void ivas_mat_col_rearrange( float in_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const int16_t order[IVAS_SPAR_MAX_CH], const int16_t i_ts, float ***mixer_mat, const int16_t bands, const int16_t num_ch ); @@ -989,7 +994,7 @@ ivas_error ivas_spar_md_dec_init( } ELSE { - hMdDec->spar_md.num_bands = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); + hMdDec->spar_md.num_bands = s_min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); move16(); } @@ -3438,31 +3443,34 @@ static void ivas_spar_dec_parse_md_bs_fx( * Decode bitstream with arith decoder *-----------------------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED static void ivas_decode_arith_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/ - const uint16_t qsi, - const int16_t nB, - const int16_t bands_bw, - int16_t *pDo_diff, - const int16_t strat, - const int32_t ivas_total_brate ) + const UWord16 qsi, + const Word16 nB, + const Word16 bands_bw, + Word16 *pDo_diff, + const Word16 strat, + const Word32 ivas_total_brate ) { - int16_t i, ndm, ndec; - int16_t j; + Word16 i, ndm, ndec; + Word16 j; ivas_cell_dim_t pred_cell_dims[IVAS_MAX_NUM_BANDS]; ivas_cell_dim_t drct_cell_dims[IVAS_MAX_NUM_BANDS]; ivas_cell_dim_t decd_cell_dims[IVAS_MAX_NUM_BANDS]; ivas_cell_dim_t decx_cell_dims[IVAS_MAX_NUM_BANDS]; - int16_t symbol_arr_re[IVAS_MAX_INPUT_LEN]; - int16_t symbol_arr_old_re[IVAS_MAX_INPUT_LEN]; - int16_t any_diff; + Word16 symbol_arr_re[IVAS_MAX_INPUT_LEN]; + Word16 symbol_arr_old_re[IVAS_MAX_INPUT_LEN]; + Word16 any_diff; - for ( i = 0; i < nB; i++ ) + FOR( i = 0; i < nB; i++ ) { ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[bands_bw * i]; ndec = hMdDec->spar_md_cfg.num_decorr_per_band[bands_bw * i]; - if ( ( ivas_total_brate < IVAS_24k4 ) && ( strat > 3 ) && ( ( ( i % 2 == 1 ) && ( strat % 2 == 0 ) ) || ( ( i % 2 == 0 ) && ( strat % 2 == 1 ) ) ) ) + move16(); + move16(); + IF( LT_32( ivas_total_brate, IVAS_24k4 ) && GT_16( strat, 3 ) && ( ( EQ_16( i % 2, 1 ) && ( strat % 2 == 0 ) ) || ( ( i % 2 == 0 ) && EQ_16( strat % 2, 1 ) ) ) ) { pred_cell_dims[i].dim1 = 0; pred_cell_dims[i].dim2 = 0; @@ -3472,49 +3480,68 @@ static void ivas_decode_arith_bs( decd_cell_dims[i].dim2 = 0; decx_cell_dims[i].dim1 = 0; decx_cell_dims[i].dim2 = 0; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); } - else + ELSE { - pred_cell_dims[i].dim1 = ndm + ndec - 1; - if ( hMdDec->spar_hoa_md_flag && hMdDec->spar_hoa_dirac2spar_md_flag ) + pred_cell_dims[i].dim1 = add( ndm, sub( ndec, 1 ) ); + IF( hMdDec->spar_hoa_md_flag && hMdDec->spar_hoa_dirac2spar_md_flag ) { - if ( i >= SPAR_DIRAC_SPLIT_START_BAND ) + IF( GE_16( i, SPAR_DIRAC_SPLIT_START_BAND ) ) { - pred_cell_dims[i].dim1 -= ( FOA_CHANNELS - 1 ); + pred_cell_dims[i].dim1 = sub( pred_cell_dims[i].dim1, ( FOA_CHANNELS - 1 ) ); } } pred_cell_dims[i].dim2 = 1; drct_cell_dims[i].dim1 = ndec; - drct_cell_dims[i].dim2 = ndm - 1; + drct_cell_dims[i].dim2 = sub( ndm, 1 ); decd_cell_dims[i].dim1 = ndec; decd_cell_dims[i].dim2 = 1; - decx_cell_dims[i].dim1 = ( ndec * ( ndec - 1 ) ) >> 1; + decx_cell_dims[i].dim1 = shr( imult1616( ndec, sub( ndec, 1 ) ), 1 ); decx_cell_dims[i].dim2 = 1; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); } } any_diff = 0; - for ( i = 0; i < nB; i++ ) + move16(); + FOR( i = 0; i < nB; i++ ) { - if ( pDo_diff[i] != 0 ) + IF( pDo_diff[i] != 0 ) { any_diff = 1; + move16(); break; } } - if ( any_diff == 1 ) + IF( EQ_16( any_diff, 1 ) ) { - if ( hMdDec->spar_hoa_md_flag && hMdDec->spar_hoa_dirac2spar_md_flag ) + IF( hMdDec->spar_hoa_md_flag && hMdDec->spar_hoa_dirac2spar_md_flag ) { - for ( i = 0; i < nB; i++ ) + FOR( i = 0; i < nB; i++ ) { - if ( i >= SPAR_DIRAC_SPLIT_START_BAND ) + IF( GE_16( i, SPAR_DIRAC_SPLIT_START_BAND ) ) { - for ( j = 0; j < pred_cell_dims[i].dim1; j++ ) + FOR( j = 0; j < pred_cell_dims[i].dim1; j++ ) { hMdDec->spar_md_prev.band_coeffs_idx_mapped[i].pred_index_re[j] = hMdDec->spar_md_prev.band_coeffs_idx_mapped[i].pred_index_re[j + ( FOA_CHANNELS - 1 )]; + move16(); } } } @@ -3528,26 +3555,28 @@ static void ivas_decode_arith_bs( ivas_fill_band_coeffs_idx( hMdDec->spar_md.band_coeffs_idx, nB, symbol_arr_re, pred_cell_dims, PRED_COEFF ); - if ( hMdDec->spar_hoa_md_flag && hMdDec->spar_hoa_dirac2spar_md_flag ) + IF( hMdDec->spar_hoa_md_flag && hMdDec->spar_hoa_dirac2spar_md_flag ) { - for ( i = 0; i < nB; i++ ) + FOR( i = 0; i < nB; i++ ) { - if ( i >= SPAR_DIRAC_SPLIT_START_BAND ) + IF( GE_16( i, SPAR_DIRAC_SPLIT_START_BAND ) ) { - for ( j = pred_cell_dims[i].dim1 - 1; j >= 0; j-- ) + FOR( j = pred_cell_dims[i].dim1 - 1; j >= 0; j-- ) { hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j + ( FOA_CHANNELS - 1 )] = hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j]; + move16(); } - for ( j = 0; j < FOA_CHANNELS - 1; j++ ) + FOR( j = 0; j < FOA_CHANNELS - 1; j++ ) { hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j] = 0; + move16(); } } } } - if ( any_diff == 1 ) + IF( EQ_16( any_diff, 1 ) ) { ivas_copy_band_coeffs_idx_to_arr( hMdDec->spar_md_prev.band_coeffs_idx_mapped, nB, symbol_arr_old_re, drct_cell_dims, DRCT_COEFF ); } @@ -3557,7 +3586,7 @@ static void ivas_decode_arith_bs( ivas_fill_band_coeffs_idx( hMdDec->spar_md.band_coeffs_idx, nB, symbol_arr_re, drct_cell_dims, DRCT_COEFF ); - if ( any_diff == 1 ) + IF( EQ_16( any_diff, 1 ) ) { ivas_copy_band_coeffs_idx_to_arr( hMdDec->spar_md_prev.band_coeffs_idx_mapped, nB, symbol_arr_old_re, decd_cell_dims, DECD_COEFF ); } @@ -3567,7 +3596,7 @@ static void ivas_decode_arith_bs( ivas_fill_band_coeffs_idx( hMdDec->spar_md.band_coeffs_idx, nB, symbol_arr_re, decd_cell_dims, DECD_COEFF ); - if ( any_diff == 1 ) + IF( EQ_16( any_diff, 1 ) ) { ivas_copy_band_coeffs_idx_to_arr( hMdDec->spar_md_prev.band_coeffs_idx_mapped, nB, symbol_arr_old_re, decx_cell_dims, DECX_COEFF ); } @@ -3585,46 +3614,46 @@ static void ivas_decode_arith_bs( static void ivas_fill_band_coeffs_idx( ivas_band_coeffs_ind_t *pBands_idx, - const int16_t nB, - int16_t *pSymbol_re, + const Word16 nB, + Word16 *pSymbol_re, ivas_cell_dim_t *pCell_dims, const ivas_coeffs_type_t coeff_type ) { - int16_t i, len; - int16_t *pPtr_idx = NULL; + Word16 i, len; + Word16 *pPtr_idx = NULL; - for ( i = 0; i < nB; i++ ) + FOR( i = 0; i < nB; i++ ) { - switch ( coeff_type ) + SWITCH( coeff_type ) { case PRED_COEFF: { pPtr_idx = pBands_idx[i].pred_index_re; - break; + BREAK; } case DRCT_COEFF: { pPtr_idx = pBands_idx[i].drct_index_re; - break; + BREAK; } case DECD_COEFF: { pPtr_idx = pBands_idx[i].decd_index_re; - break; + BREAK; } case DECX_COEFF: { - break; + BREAK; } default: assert( !"unsupported config!" ); } - if ( coeff_type != DECX_COEFF ) + IF( NE_16( coeff_type, DECX_COEFF ) ) { - len = pCell_dims[i].dim1 * pCell_dims[i].dim2; - mvs2s( pSymbol_re, pPtr_idx, len ); + len = imult1616( pCell_dims[i].dim1, pCell_dims[i].dim2 ); + Copy( pSymbol_re, pPtr_idx, len ); pSymbol_re += len; } } @@ -3642,54 +3671,60 @@ static void ivas_fill_band_coeffs_idx( static void ivas_decode_huffman_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/ - const uint16_t qsi, - const int16_t nB, - const int16_t bands_bw ) + const UWord16 qsi, + const Word16 nB, + const Word16 bands_bw ) { - int16_t i, j; - int16_t ndm, ndec; - int16_t pred_dim, drct_dim, decd_dim, pred_offset; + Word16 i, j; + Word16 ndm, ndec; + Word16 pred_dim, drct_dim, decd_dim, pred_offset; - for ( i = 0; i < nB; i++ ) + FOR( i = 0; i < nB; i++ ) { ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[bands_bw * i]; ndec = hMdDec->spar_md_cfg.num_decorr_per_band[bands_bw * i]; + move16(); + move16(); - pred_dim = ndec + ndm - 1; - drct_dim = ndec * ( ndm - 1 ); + pred_dim = sub( add( ndec, ndm ), 1 ); + drct_dim = imult1616( ndec, sub( ndm, 1 ) ); decd_dim = ndec; pred_offset = 0; + move16(); + move16(); - if ( hMdDec->spar_hoa_md_flag && hMdDec->spar_hoa_dirac2spar_md_flag ) + IF( hMdDec->spar_hoa_md_flag && hMdDec->spar_hoa_dirac2spar_md_flag ) { - if ( i >= SPAR_DIRAC_SPLIT_START_BAND ) + IF( GE_16( i, SPAR_DIRAC_SPLIT_START_BAND ) ) { pred_offset = FOA_CHANNELS - 1; + move16(); } } - for ( j = pred_offset; j < pred_dim; j++ ) + FOR( j = pred_offset; j < pred_dim; j++ ) { ivas_huffman_decode( &hMdDec->huff_coeffs.pred_huff_re[qsi], st0, &hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j] ); } - if ( hMdDec->spar_hoa_md_flag && hMdDec->spar_hoa_dirac2spar_md_flag ) + IF( hMdDec->spar_hoa_md_flag && hMdDec->spar_hoa_dirac2spar_md_flag ) { - if ( i >= SPAR_DIRAC_SPLIT_START_BAND ) + IF( i >= SPAR_DIRAC_SPLIT_START_BAND ) { - for ( j = 0; j < pred_offset; j++ ) + FOR( j = 0; j < pred_offset; j++ ) { hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j] = 0; + move16(); } } } - for ( j = 0; j < drct_dim; j++ ) + FOR( j = 0; j < drct_dim; j++ ) { ivas_huffman_decode( &hMdDec->huff_coeffs.drct_huff_re[qsi], st0, &hMdDec->spar_md.band_coeffs_idx[i].drct_index_re[j] ); } - for ( j = 0; j < decd_dim; j++ ) + FOR( j = 0; j < decd_dim; j++ ) { ivas_huffman_decode( &hMdDec->huff_coeffs.decd_huff_re[qsi], st0, &hMdDec->spar_md.band_coeffs_idx[i].decd_index_re[j] ); } @@ -3699,43 +3734,49 @@ static void ivas_decode_huffman_bs( } static void ivas_spar_plc_get_band_age( - const int16_t *valid_bands, - int16_t *base_band_age, - const int16_t num_bands, - int16_t last_valid_band_idx[IVAS_MAX_NUM_BANDS], - int16_t valid_band_idx[IVAS_MAX_NUM_BANDS], - int16_t *all_valid, - int16_t *b_idx ) + const Word16 *valid_bands, + Word16 *base_band_age, + const Word16 num_bands, + Word16 last_valid_band_idx[IVAS_MAX_NUM_BANDS], + Word16 valid_band_idx[IVAS_MAX_NUM_BANDS], + Word16 *all_valid, + Word16 *b_idx ) { - int16_t b, idx; + Word16 b, idx; - set_s( valid_band_idx, 0, IVAS_MAX_NUM_BANDS ); - set_s( last_valid_band_idx, 0, IVAS_MAX_NUM_BANDS ); + set16_fx( valid_band_idx, 0, IVAS_MAX_NUM_BANDS ); + set16_fx( last_valid_band_idx, 0, IVAS_MAX_NUM_BANDS ); idx = -1; *all_valid = 1; - for ( b = 0; b < num_bands; b++ ) - { - if ( valid_bands[b] != 0 ) - { + move16(); + move16(); + FOR( b = 0; b < num_bands; b++ ){ + IF( valid_bands[b] != 0 ){ base_band_age[b] = 0; /* reset band age */ - idx++; - valid_band_idx[idx] = b; - } - else - { - base_band_age[b] += 1; /* increment the age of invalid bands */ + idx = add( idx, 1 ); + valid_band_idx[idx] = b; + move16(); + move16(); +} +ELSE +{ + base_band_age[b] = add( base_band_age[b], 1 ); /* increment the age of invalid bands */ - if ( base_band_age[b] > 3 ) - { - last_valid_band_idx[b] = idx; - } - *all_valid = 0; - } + IF( GT_16( base_band_age[b], 3 ) ) + { + last_valid_band_idx[b] = idx; + move16(); } - *b_idx = idx; + *all_valid = 0; + move16(); +} +} +*b_idx = idx; +move16(); - return; +return; } +#endif #ifndef IVAS_FLOAT_FIXED static void ivas_spar_get_plc_interp_weights( @@ -3767,7 +3808,7 @@ static void ivas_spar_get_plc_interp_weights( } return; } -#endif +#else static void ivas_spar_get_plc_interp_weights_fx( Word16 valid_band_idx[IVAS_MAX_NUM_BANDS], @@ -3815,6 +3856,7 @@ static void ivas_spar_get_plc_interp_weights_fx( } return; } +#endif #ifdef IVAS_FLOAT_FIXED /*-----------------------------------------------------------------------------------------* @@ -4316,10 +4358,8 @@ static void ivas_spar_unquant_dtx_indicies( { Word16 i, b; Word16 q_lvl; - // float val; Word32 val_fx; Word16 idx; - // float pr_min_max[2]; Word32 pr_min_max_fx[2]; pr_min_max_fx[0] = pSpar_md->min_max_fx[0]; @@ -5008,11 +5048,11 @@ void ivas_spar_to_dirac_fx( test(); active_w = EQ_16( dyn_active_w_flag, 1 ) || EQ_16( hMdDec->spar_md_cfg.active_w, 1 ); - sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); + sba_order_internal = s_min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); move16(); start_band = 0; move16(); - end_band = idiv1616( min( num_bands_out, SPAR_DIRAC_SPLIT_START_BAND ), bw ); + end_band = idiv1616( s_min( num_bands_out, SPAR_DIRAC_SPLIT_START_BAND ), bw ); hDirAC = st_ivas->hDirAC; hSpatParamRendCom = st_ivas->hSpatParamRendCom; @@ -5171,7 +5211,6 @@ void ivas_spar_to_dirac_fx( IF( EQ_16( st_ivas->nchan_transport, 1 ) ) { - // float w_en_norm, f_scale; Word32 w_en_norm_fx, f_scale_fx; Word16 q_w_en_norm_fx; IF( active_w ) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index b50850cfbfa7d752bcbdfa3a37d3382e36384350..a74a7536bf5bdf7b202d15aed3f1bf315d371828 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1616,7 +1616,7 @@ typedef struct Decoder_Struct int16_t ism_extmeta_cnt; /* Change frame counter for extended metadata */ #ifdef IVAS_FLOAT_FIXED Word32 **mem_hp20_out_fx; - Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* floating-point output audio buffers */ + Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* Word32-output audio buffers */ Word16 p_out_len;/*Stores the total no of channels for which memory is allocated to p_output_fx*/ Word16 num_src; Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 364b0316a25a48ef87d0d4266caa727fa57b8549..8ef692402e587e93291d12f0df28794d6d1a11ec 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -2281,13 +2281,6 @@ void stereo_cna_update_params_fx( hFdCngDec = sts[0]->hFdCngDec; - // delete below - // hFdCngDec->cna_act_fact_fx = (Word16)(hFdCngDec->cna_act_fact * (1 << 15)); - // hFdCngDec->cna_LR_LT_fx = (Word16)(hFdCngDec->cna_LR_LT * (1 << 15)); - // hFdCngDec->cna_ILD_LT_fx = (Word16)(hFdCngDec->cna_ILD_LT * (1 << 15)); - ///// - - IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { IF( GT_16( hCPE->nchan_out, 1 ) ) diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index 0a644465cc0c716f03331caa0f6c45f280b7c097..25caf19eb06446d46715570a2ea17051cce5e082 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -55,10 +55,13 @@ #define STEFI_DELAY_IND( d, buf_ind ) ( ( buf_ind ) + STEREO_DFT_PAST_MAX - ( d ) + 1 ) % STEREO_DFT_PAST_MAX +#ifndef IVAS_FLOAT_FIXED #define STEREO_DFT_RES_RATIO_LIMIT 0.18f +#endif #ifdef IVAS_FLOAT_FIXED #define STEREO_DFT_RES_RATIO_LIMIT_FX ( Word32 )( 0x170A3D71 ) #endif +#ifndef IVAS_FLOAT_FIXED #define STEREO_DFT_LT_PREDGAIN_UPD 0.1f #define STEREO_DFT_VR_PREDGAIN_UPD 0.1f #define STEREO_DFT_STEFFI_PG_THRESHOLD 0.6f @@ -66,11 +69,14 @@ #define STEREO_DFT_STEFFI_RATIO_DOWN_HIGH 0.05f #define STEREO_DFT_STEFFI_RATIO_UP_LOW 0.1f #define STEREO_DFT_STEFFI_RATIO_DOWN_LOW 0.001f -#define STEREO_DFT_STEFFI_DELAY_SHORT 2 -#define STEREO_DFT_STEFFI_DELAY_LONG 4 -#define STEREO_DFT_STEFFI_DELAY_OFFSET 2 -#define STEREO_DFT_STEFFI_GAIN_REST_AMT 0.6f -#define STEREO_DFT_STEFFI_GAIN_AMP 1.0f +#endif // !IVAS_FLOAT_FIXED +#define STEREO_DFT_STEFFI_DELAY_SHORT 2 +#define STEREO_DFT_STEFFI_DELAY_LONG 4 +#define STEREO_DFT_STEFFI_DELAY_OFFSET 2 +#ifndef IVAS_FLOAT_FIXED +#define STEREO_DFT_STEFFI_GAIN_REST_AMT 0.6f +#define STEREO_DFT_STEFFI_GAIN_AMP 1.0f +#endif // !IVAS_FLOAT_FIXED #define STEREO_DFT_BPF_SIZE 40 /* BPF: Number of weights for BPF in DFT: 40*40Hz=1.6kHz*/ @@ -792,21 +798,21 @@ void stereo_dft_dec_analyze_fx( } inputFs = L_mult0( input_frame, FRAMES_PER_SEC ); - delay_dec = NS2SA( inputFs, STEREO_DFT32MS_OVL_NS ); + delay_dec = NS2SA_FX2( inputFs, STEREO_DFT32MS_OVL_NS ); move16(); - zp = NS2SA( inputFs, STEREO_DFT32MS_ZP_NS ); + zp = NS2SA_FX2( inputFs, STEREO_DFT32MS_ZP_NS ); move16(); - ovl = NS2SA( inputFs, STEREO_DFT32MS_OVL_NS ); + ovl = NS2SA_FX2( inputFs, STEREO_DFT32MS_OVL_NS ); move16(); - NFFT = NS2SA( inputFs, STEREO_DFT32MS_N_NS ); + NFFT = NS2SA_FX2( inputFs, STEREO_DFT32MS_N_NS ); Word16 qfac_fx; fac_fx = BASOP_Util_Divide3232_Scale_cadence( hStereoDft->NFFT, NFFT, &qfac_fx ); qfac_fx = sub( 31, qfac_fx ); - ovl2 = NS2SA( inputFs, STEREO_DFT32MS_OVL2_NS ); + ovl2 = NS2SA_FX2( inputFs, STEREO_DFT32MS_OVL2_NS ); move16(); /* Offset FOR the time buffers */ - assert( ( delay >= -NS2SA( ( input_frame * FRAMES_PER_SEC ), STEREO_DFT_DELAY_DEC_BWE_NS + STEREO_DFT_OVL_NS / 2 ) ) && ( delay <= NS2SA( ( input_frame * FRAMES_PER_SEC ), STEREO_DFT_OVL_NS ) ) ); + assert( ( delay >= -NS2SA_FX2( ( input_frame * FRAMES_PER_SEC ), STEREO_DFT_DELAY_DEC_BWE_NS + STEREO_DFT_OVL_NS / 2 ) ) && ( delay <= NS2SA_FX2( ( input_frame * FRAMES_PER_SEC ), STEREO_DFT_OVL_NS ) ) ); mem_size = add( delay_dec, delay ); /* Update buffers */ @@ -850,7 +856,7 @@ void stereo_dft_dec_analyze_fx( ELSE { /* If OVL2 = OVL offset = 10ms */ - offset = NS2SA( inputFs, STEREO_DFT32MS_WIN_CENTER_NS - STEREO_DFT32MS_OVL2_NS / 2 ); + offset = NS2SA_FX2( inputFs, STEREO_DFT32MS_WIN_CENTER_NS - STEREO_DFT32MS_OVL2_NS / 2 ); move16(); } @@ -975,7 +981,7 @@ void stereo_dft_dec_analyze_fx( } ELSE IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_HB_ADD ) ) { - NFFT_core = NS2SA( L_mult0( hCPE->hCoreCoder[0]->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_N_NS ); + NFFT_core = NS2SA_FX2( L_mult0( hCPE->hCoreCoder[0]->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_N_NS ); move16(); FOR( i = NFFT_core; i < NFFT; i++ ) diff --git a/lib_dec/ivas_stereo_dft_dec_dmx.c b/lib_dec/ivas_stereo_dft_dec_dmx.c index bacc5a0abdaba8f318a3fafcb150bb3a67cf0e35..849a0bbe9812ab46ea38b0dd3316ffdd7fdfc698 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx.c @@ -72,21 +72,13 @@ void stereo_dft_dmx_out_reset_fx( STEREO_DFT_DMX_DATA_HANDLE hStereoDftDmx /* i/o: DFT stereo DMX decoder */ ) { -#if 0 /*TODO: Remove float dft_dmx_reset*/ - hStereoDftDmx->targetGain = 1.0f; - hStereoDftDmx->prevTargetGain = 1.0f; -#endif hStereoDftDmx->targetGain_fx = ONE_IN_Q29; move32(); hStereoDftDmx->prevTargetGain_fx = ONE_IN_Q29; move32(); -#if 0 /*TODO: Remove float dft_dmx_reset*/ - set_zero(hStereoDftDmx->memOutHB, NS2SA(48000, STEREO_DFT32MS_OVL_NS)); - set_zero(hStereoDftDmx->memTransitionHB, NS2SA(48000, STEREO_DFT32MS_OVL_NS)); -#endif - set32_fx( hStereoDftDmx->memOutHB_fx, 0, NS2SA( 48000, STEREO_DFT32MS_OVL_NS ) ); - set32_fx( hStereoDftDmx->memTransitionHB_fx, 0, NS2SA( 48000, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hStereoDftDmx->memOutHB_fx, 0, NS2SA_FX2( 48000, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hStereoDftDmx->memTransitionHB_fx, 0, NS2SA_FX2( 48000, STEREO_DFT32MS_OVL_NS ) ); return; } @@ -130,7 +122,7 @@ void stereo_dft_unify_dmx_fx( Word16 num_plocs; Word32 plocsi[STEREO_DFT_RES_N_PEAKS_MAX]; - output_frame = (Word16) ( st0->output_Fs / FRAMES_PER_SEC ); + output_frame = extract_l( Mult_32_16( st0->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); samp_ratio = BASOP_Util_Divide3232_Scale( st0->sr_core, st0->output_Fs, &q_samp_ratio ); samp_ratio = shr( samp_ratio, sub( Q15 - Q12, q_samp_ratio ) ); @@ -687,18 +679,10 @@ void add_HB_to_mono_dmx_fx( Word32 *memOutHB_fx, *memTransitionHB_fx; output_Fs = hCPE->hCoreCoder[0]->output_Fs; -#if 0 - Word16 q_memOutHB = Q_factor_arr(hCPE->hStereoDftDmx->memOutHB, NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS)); - floatToFixed_arrL(hCPE->hStereoDftDmx->memOutHB, hCPE->hStereoDftDmx->memOutHB_fx, q_memOutHB, NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS)); -#endif memOutHB_fx = hCPE->hStereoDftDmx->memOutHB_fx; -#if 0 - Word16 q_memTransitionHB = Q_factor_arr(hCPE->hStereoDftDmx->memTransitionHB, NS2SA(48000, STEREO_DFT32MS_OVL_NS)); - floatToFixed_arrL(hCPE->hStereoDftDmx->memTransitionHB, hCPE->hStereoDftDmx->memTransitionHB_fx, q_memTransitionHB, NS2SA(48000, STEREO_DFT32MS_OVL_NS)); -#endif memTransitionHB_fx = hCPE->hStereoDftDmx->memTransitionHB_fx; - memOffset = NS2SA( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); + memOffset = NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); move16(); test(); @@ -707,13 +691,13 @@ void add_HB_to_mono_dmx_fx( /* Resampled LB and HB offset */ Copy32( outputHB, temp_fx + memOffset, sub( output_frame, memOffset ) ); - decoderDelay = NS2SA( output_Fs, IVAS_DEC_DELAY_NS ); + decoderDelay = NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS ); move16(); IF( last_core != ACELP_CORE ) { /* hb_synth of mid band is faded out in the 1.25 ms prior to DFT analysis and the icbwe is faded in time domain */ - icbweOLASize = NS2SA( output_Fs, STEREO_DFT_DELAY_DEC_BWE_NS ); + icbweOLASize = NS2SA_FX2( output_Fs, STEREO_DFT_DELAY_DEC_BWE_NS ); move16(); FOR( i = 0; i < decoderDelay; i++ ) @@ -784,17 +768,17 @@ void add_HB_to_mono_dmx_fx( test(); test(); /* This is generated in the ACELP frame and windowed. This process is akin to GenTransition for IC-BWE */ - IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ) ) + IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && EQ_16( hCPE->nchan_out, 1 ) && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) { - v_add_32( output, outputHB, output, NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) ); + v_add_32( output, outputHB, output, NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ) ); } ELSE { - v_add_32( output, memTransitionHB_fx, output, NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) ); + v_add_32( output, memTransitionHB_fx, output, NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ) ); } set32_fx( memOutHB_fx, 0, memOffset ); - set32_fx( memTransitionHB_fx, 0, NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( memTransitionHB_fx, 0, NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ) ); } } diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index ef1084f61ff2fabdaa4d8ac0f3457295757525e1..0646ac8f9d1a6b1114312c68997624baba9144b1 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -104,7 +104,7 @@ void stereo_dft_dec_reset_fx( Word16 i; Word16 j, b; #ifdef MSAN_FIX - set_zero_fx( hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ) ); + set_zero_fx( hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( 16000, STEREO_DFT32MS_OVL_NS ) ); #endif /*Configuration*/ @@ -347,7 +347,7 @@ static void stereo_dft_dec_open_fx( hStereoDft->nbands = stereo_dft_band_config_fx( hStereoDft->band_limits, hStereoDft->band_res[0], hStereoDft->NFFT, DEC ); move16(); - hStereoDft->hb_stefi_delay = NS2SA( output_Fs, STEREO_DFT_TD_STEFI_DELAY_NS ); + hStereoDft->hb_stefi_delay = NS2SA_FX2( output_Fs, STEREO_DFT_TD_STEFI_DELAY_NS ); move16(); IF( GT_16( nchan_transport, 2 ) ) @@ -739,21 +739,21 @@ void stereo_dft_dec_synthesize_fx( outputFs = L_mult0( output_frame, FRAMES_PER_SEC ); - zp = NS2SA( outputFs, STEREO_DFT32MS_ZP_NS ); + zp = NS2SA_FX2( outputFs, STEREO_DFT32MS_ZP_NS ); move16(); - ovl = NS2SA( outputFs, STEREO_DFT32MS_OVL_NS ); + ovl = NS2SA_FX2( outputFs, STEREO_DFT32MS_OVL_NS ); move16(); win = hStereoDft->win32ms_fx; - NFFT = NS2SA( outputFs, STEREO_DFT32MS_N_NS ); + NFFT = NS2SA_FX2( outputFs, STEREO_DFT32MS_N_NS ); move16(); - ovl2 = NS2SA( outputFs, STEREO_DFT32MS_OVL2_NS ); + ovl2 = NS2SA_FX2( outputFs, STEREO_DFT32MS_OVL2_NS ); move16(); - flat_portion_end = NS2SA( outputFs, L_sub( STEREO_DFT32MS_WIN_CENTER_NS, L_shr( STEREO_DFT32MS_OVL2_NS, 1 ) ) ); + flat_portion_end = NS2SA_FX2( outputFs, L_sub( STEREO_DFT32MS_WIN_CENTER_NS, L_shr( STEREO_DFT32MS_OVL2_NS, 1 ) ) ); move16(); win2 = hStereoDft->win232ms_fx; p_DFT = DFT[chan]; - set32_fx( output, 0, NS2SA( outputFs, FRAME_SIZE_NS ) ); + set32_fx( output, 0, NS2SA_FX2( outputFs, FRAME_SIZE_NS ) ); /* deactivating the spectrum scrambling on active speech */ test(); @@ -1086,18 +1086,18 @@ void stereo_dft_dec_smooth_parameters_fx( hStereoDft->last_active_element_brate = element_brate; move32(); - FOR( k = hStereoDft->prm_res[k_offset] - 1; k < N_div; k += hStereoDft->prm_res[add( k, k_offset )] ) + FOR( k = sub( hStereoDft->prm_res[k_offset], 1 ); k < N_div; k += hStereoDft->prm_res[add( k, k_offset )] ) { max_res_pred_ind = 0; move32(); IF( EQ_16( hStereoDft->reverb_flag, 1 ) ) { - nbands = min( 10, hStereoDft->nbands_respred ); + nbands = s_min( 10, hStereoDft->nbands_respred ); move16(); /*Shift 2 last bands residual prediction gains for SWB/FB*/ IF( EQ_16( hStereoDft->band_res[k_offset], STEREO_DFT_BAND_RES_HIGH ) ) { - FOR( b = hStereoDft->nbands_respred - 1; b >= nbands; b-- ) + FOR( b = sub( hStereoDft->nbands_respred, 1 ); b >= nbands; b-- ) { hStereoDft->res_gains_ind_fx[1][b + STEREO_DFT_BAND_MAX] = hStereoDft->res_gains_ind_fx[1][b - STEREO_DFT_RES_PRED_BAND_MIN_RED + hStereoDft->res_pred_band_min + STEREO_DFT_BAND_MAX]; @@ -1108,7 +1108,7 @@ void stereo_dft_dec_smooth_parameters_fx( } /* Get maximal index */ - FOR( b = hStereoDft->res_pred_band_min; b < ( nbands - STEREO_DFT_RES_PRED_BAND_MIN_CONST ); b++ ) + FOR( b = hStereoDft->res_pred_band_min; b < sub( nbands, STEREO_DFT_RES_PRED_BAND_MIN_CONST ); b++ ) { IF( LT_32( max_res_pred_ind, hStereoDft->res_gains_ind_fx[1][b + STEREO_DFT_BAND_MAX] ) ) { @@ -1342,7 +1342,7 @@ void stereo_dft_dec_res_fx( set32_fx( hCPE->hStereoDft->res_cod_mem_fx, 0, STEREO_DFT_OVL_8k ); hCPE->hStereoDft->q_res_cod_mem_fx = Q16; move16(); - set32_fx( hCPE->input_mem_fx[1], 0, NS2SA( 8000, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hCPE->input_mem_fx[1], 0, NS2SA_FX2( 8000, STEREO_DFT32MS_OVL_NS ) ); set16_fx( hCPE->hStereoDft->hBpf->pst_old_syn_fx, 0, STEREO_DFT_NBPSF_PIT_MAX_8k ); hCPE->hStereoDft->hBpf->pst_mem_deemp_err_fx = 0; move16(); @@ -2392,12 +2392,7 @@ static void stereo_dft_compute_td_stefi_params_fx( IF( GT_16( sub( 15, q_div ), 15 ) ) { pred_g = L_shl( pred_g, q_div ); - // q_pred_g = 15; } - // ELSE - //{ - // q_pred_g = sub(15, q_div); - // } pred_gain_avg = BASOP_Util_Divide3232_Scale( pred_gain_avg, wsum, &q_div ); IF( GT_16( sub( 15, q_div ), 15 ) ) { @@ -2526,8 +2521,7 @@ void stereo_dft_generate_res_pred_fx( Word16 lb_stefi_start_band; /* variables for enhanced stereo filling */ - Word16 norm_fac, q_norm_fac = 0, lim_norm_fac; - move16(); + Word16 norm_fac, q_norm_fac, lim_norm_fac; Word16 q_sqrt; Word16 alpha; // gain_limit; @@ -2539,7 +2533,8 @@ void stereo_dft_generate_res_pred_fx( Word32 pred_gain_avg; Word32 g2; Word16 nbands_respred; - + q_norm_fac = 0; + move16(); push_wmops( "gen_respred" ); /* smoothing and limiting parameters */ @@ -2618,13 +2613,11 @@ void stereo_dft_generate_res_pred_fx( rev_nrg = L_shr( rev_nrg, shl( sub( hStereoDft->q_dft, hStereoDft->q_smoothed_nrg ), 1 ) ); dmx_nrg = L_shr( dmx_nrg, shl( sub( hStereoDft->q_dft, hStereoDft->q_smoothed_nrg ), 1 ) ); } -#if 1 ELSE IF( GT_16( hStereoDft->q_smoothed_nrg, hStereoDft->q_dft ) ) { 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 ) ); } -#endif /* 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 ) ); move32(); @@ -2706,13 +2699,11 @@ void stereo_dft_generate_res_pred_fx( move32(); } } -#if 1 IF( GT_16( hStereoDft->q_smoothed_nrg, hStereoDft->q_dft ) ) { hStereoDft->q_smoothed_nrg = hStereoDft->q_dft; move16(); } -#endif } ELSE IF( EQ_16( hStereoDft->res_pred_mode[k + STEREO_DFT_OFFSET], STEREO_DFT_RESPRED_STEFI ) ) { @@ -2956,7 +2947,7 @@ void stereo_dft_generate_res_pred_fx( } q_shift = sub( hStereoDft->q_dft, hStereoDft->q_DFT_past_DMX_fx[d_short_ind] ); move16(); - FOR( i = max( hStereoDft->band_limits[b], bin0 ); i < min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ); i++ ) + FOR( i = s_max( hStereoDft->band_limits[b], bin0 ); i < s_min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ); i++ ) { DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( g2, hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i] ), q_shift ); move32(); @@ -2966,10 +2957,8 @@ void stereo_dft_generate_res_pred_fx( } ELSE { - begin = max( hStereoDft->band_limits[b], bin0 ); - move16(); - end = min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ); - move16(); + begin = s_max( hStereoDft->band_limits[b], bin0 ); + end = s_min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ); set32_fx( DFT_PRED_RES + shl( begin, 1 ), 0, shl( sub( end, begin ), 1 ) ); } } @@ -3071,7 +3060,7 @@ void stereo_dft_generate_res_pred_fx( move32(); dmx_nrg = EPSILON_FIX; move32(); - FOR( i = max( hStereoDft->band_limits[b], bin0 ); i < min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ); i++ ) + FOR( i = s_max( hStereoDft->band_limits[b], bin0 ); i < s_min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ); i++ ) { dmx_nrg = L_add( dmx_nrg, Madd_32_32( Mpy_32_32( pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[add( shl( i, 1 ), 1 )], pDFT_DMX[add( shl( i, 1 ), 1 )] ) ); @@ -3098,7 +3087,7 @@ void stereo_dft_generate_res_pred_fx( g2 = L_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( (Word16) ( 0x7FFF ), STEREO_DFT_STEFFI_GAIN_REST_AMT_FX ) ), g2, STEREO_DFT_STEFFI_GAIN_REST_AMT_FX ) ); - FOR( i = max( hStereoDft->band_limits[b], bin0 ); i < min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ); i++ ) + FOR( i = s_max( hStereoDft->band_limits[b], bin0 ); i < s_min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ); i++ ) { DFT_PRED_RES[2 * i] = Mpy_32_32( g2, DFT_PRED_RES[2 * i] ); move32(); diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index d1e47ea95e2c2300ad9f11cc1cbf66a33c94b0f6..82b3b0a667dc6fe95d49d56250822a55e621d205 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -50,8 +50,9 @@ /*-------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------*/ - -#define DFT2TD_CORR_THRESH 0.9f +#ifndef IVAS_FLOAT_FIXED +#define DFT2TD_CORR_THRESH 0.9f +#endif #define DFT2TD_CORR_THRESH_FX 1932735283 /*-------------------------------------------------------------------* @@ -151,13 +152,6 @@ static ivas_error allocate_CoreCoder_TCX_fx( set16_fx( st->hTcxDec->syn_OverlFB, 0, L_FRAME48k / 2 ); set16_fx( st->hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC ); set16_fx( st->hTcxDec->synth_history_fx, 0, L_PROT48k + L_FRAME48k ); - -#if 1 // TODO: TO be removed later - // reset_tcx_overl_buf( st->hTcxDec ); - // set_zero( st->hTcxDec->syn_OverlFB_float, L_FRAME48k / 2 ); - // set_zero( st->hTcxDec->old_synth_float, OLD_SYNTH_INTERNAL_DEC ); - // set_zero( st->hTcxDec->synth_history, L_PROT48k + L_FRAME48k ); -#endif } IF( st->hTcxCfg == NULL ) @@ -1271,6 +1265,7 @@ ivas_error stereo_memory_dec_fx( Word16 div_m, div_e, tmp16; error = IVAS_ERR_OK; + move32(); assert( GE_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && "Switching from SCE to CPE is not a valid configuration!" ); @@ -1289,7 +1284,7 @@ ivas_error stereo_memory_dec_fx( test(); IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) || EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) ) { - delay_comp_DFT = NS2SA( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); + delay_comp_DFT = NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); move16(); /* redressing of the DFT OLA part */ @@ -1395,9 +1390,6 @@ ivas_error stereo_memory_dec_fx( } td_cng_dec_init_fx( st ); -#if 1 // TODO: To be removed later - // td_cng_dec_init( st ); -#endif } } @@ -1468,9 +1460,9 @@ ivas_error stereo_memory_dec_fx( { /* re-use an existing buffer for MDCT->TD stereo switching */ Word16 nZeros, len; - nZeros = extract_l( NS2SA( st->output_Fs, N_ZERO_MDCT_NS ) ); + nZeros = extract_l( NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ) ); move16(); - len = NS2SA( st->output_Fs, 3000000 ); + len = NS2SA_FX2( st->output_Fs, 3000000 ); move16(); Copy32( st->hHQ_core->oldOut_fx + nZeros, hCPE->output_mem_fx[1], len ); } @@ -1545,9 +1537,6 @@ ivas_error stereo_memory_dec_fx( st->prev_fb_ener_adjust_fx = 0; move16(); -#if 1 // TODO: To be removed later - // fd_bwe_dec_init_flt( st->hBWE_FD ); -#endif fd_bwe_dec_init( st, st->hBWE_FD ); st->hBWE_FD->old_wtda_swb_fx_exp = 0; move16(); @@ -1674,9 +1663,6 @@ ivas_error stereo_memory_dec_fx( /* Init FD-CNG */ initFdCngDec_ivas_fx( st, st->cldfbSyn->scale ); -#if 1 // TODO: To be removed later - initFdCngDec( st ); -#endif if ( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) ) { @@ -1710,14 +1696,8 @@ ivas_error stereo_memory_dec_fx( set16_fx( st->hTcxDec->FBTCXdelayBuf, 0, 111 ); set32_fx( st->hTcxDec->FBTCXdelayBuf_32, 0, 111 ); - st->hTcxDec->old_synthFB_fx = st->hTcxDec->synth_history_fx + NS2SA( st->output_Fs, PH_ECU_MEM_NS ); - st->hTcxDec->prev_good_synth_fx = st->hTcxDec->old_synthFB_fx + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ); - -#if 1 // To be removed later - // set_f( st->hTcxDec->FBTCXdelayBuf_float, 0.0f, 111 ); - // st->hTcxDec->old_synthFB = st->hTcxDec->synth_history + NS2SA( st->output_Fs, PH_ECU_MEM_NS ); - // st->hTcxDec->prev_good_synth = st->hTcxDec->old_synthFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ); -#endif + st->hTcxDec->old_synthFB_fx = st->hTcxDec->synth_history_fx + NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ); + st->hTcxDec->prev_good_synth_fx = st->hTcxDec->old_synthFB_fx + NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ); /* allocate and initialize MDCT stereo structure */ IF( ( hCPE->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_DEC_DATA ) ) ) == NULL ) @@ -1802,9 +1782,6 @@ ivas_error stereo_memory_dec_fx( st->prev_fb_ener_adjust_fx = 0; move16(); -#if 1 // TODO: To be removed later - // fd_bwe_dec_init_flt( st->hBWE_FD ); -#endif fd_bwe_dec_init( st, st->hBWE_FD ); st->hBWE_FD->old_wtda_swb_fx_exp = 0; move16(); @@ -2023,9 +2000,6 @@ ivas_error stereo_memory_dec_fx( return error; } initFdCngDec_ivas_fx( hCPE->hCoreCoder[i], hCPE->hCoreCoder[i]->cldfbSyn->scale ); -#if 1 - initFdCngDec( hCPE->hCoreCoder[i] ); -#endif } } } @@ -2474,14 +2448,14 @@ void synchro_synthesis_fx( } /* set delays */ - delay_comp_DFT = NS2SA( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); + delay_comp_DFT = NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); move16(); - delay_comp_TD = NS2SA( output_Fs, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); + delay_comp_TD = NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); move16(); delay_diff = sub( delay_comp_TD, delay_comp_DFT ); dft32ms_ovl = extract_l( Mpy_32_32( imult3216( output_Fs, STEREO_DFT32MS_OVL_MAX ), 44740 ) ); - delay_cldfb = NS2SA( output_Fs, DELAY_CLDFB_NS ); + delay_cldfb = NS2SA_FX2( output_Fs, DELAY_CLDFB_NS ); move16(); /* initialize pointers */ @@ -2729,11 +2703,11 @@ void synchro_synthesis_fx( { IF( EQ_16( sts[n]->core, ACELP_CORE ) ) { - L_lerp_fx_q11( hCPE->input_mem_LB_fx[n], tmp_out_TD_fx[n], dft32ms_ovl, NS2SA( sts[n]->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) ); + L_lerp_fx_q11( hCPE->input_mem_LB_fx[n], tmp_out_TD_fx[n], dft32ms_ovl, NS2SA_FX2( sts[n]->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) ); } ELSE /* TCX/HQ core */ { - L_lerp_fx_q11( hCPE->input_mem_LB_fx[n], tmp_out_TD_fx[n], dft32ms_ovl, NS2SA( sts[n]->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) ); + L_lerp_fx_q11( hCPE->input_mem_LB_fx[n], tmp_out_TD_fx[n], dft32ms_ovl, NS2SA_FX2( sts[n]->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) ); /* use TCX synchro memory (perfect signal is available) */ FOR( i = delay_diff; i < dft32ms_ovl; i++ ) @@ -3039,7 +3013,7 @@ void stereo_switching_dec( sts = hCPE->hCoreCoder; - delay_comp_TD = NS2SA( sts[0]->output_Fs, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); + delay_comp_TD = NS2SA_FX2( sts[0]->output_Fs, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); move16(); /* prevent CPE mode switching in the first received frame */ @@ -3122,10 +3096,6 @@ void stereo_switching_dec( FOR( i = 0; i < delay_comp_TD; i++ ) { Word64 temp_result; - // 16bit buffer - // temp_result = (Word64) hCPE->hCoreCoder[1]->prev_synth_buffer_fx[i] * tmpF_fx; - // hCPE->hCoreCoder[1]->prev_synth_buffer_fx[i] = saturate( W_extract_l(W_shr( temp_result, 27 )) ); - // 32bit buffer temp_result = W_mult0_32_32( hCPE->hCoreCoder[1]->prev_synth_buffer32_fx[i], tmpF_fx ); hCPE->hCoreCoder[1]->prev_synth_buffer32_fx[i] = W_sat_l( W_shr( temp_result, 27 ) ); move32(); @@ -3184,7 +3154,7 @@ void stereo_switching_dec( hCPE->hStereoDft->q_res_cod_mem_fx = Q16; move16(); - set32_fx( hCPE->input_mem_fx[1], 0, NS2SA( sts[0]->output_Fs, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hCPE->input_mem_fx[1], 0, NS2SA_FX2( sts[0]->output_Fs, STEREO_DFT32MS_OVL_NS ) ); } test(); @@ -3249,10 +3219,6 @@ void stereo_switching_dec( sts[1]->prev_bfi = sts[0]->prev_bfi; move16(); -#ifndef IVAS_FLOAT_FIXED - set_f( sts[1]->old_pitch_buf, (float) L_SUBFR, 2 * NB_SUBFR16k ); - sts[1]->old_fpitchFB_float = 2 * (float) L_SUBFR; -#endif // #ifndef IVAS_FLOAT_FIXED // fix need to do correctly set32_fx( sts[1]->old_pitch_buf_fx, L_deposit_h( L_SUBFR ), 2 * NB_SUBFR16k ); @@ -3292,9 +3258,6 @@ void stereo_switching_dec( sts[1]->last_coder_type = sts[0]->last_coder_type; move16(); -#ifndef IVAS_FLOAT_FIXED - mvr2r( sts[0]->delay_buf_out, sts[1]->delay_buf_out, HQ_DELTA_MAX * HQ_DELAY_COMP ); -#endif // #ifndef IVAS_FLOAT_FIXED // 32bit buffer Copy32( sts[0]->hHQ_core->oldOut_fx, sts[1]->hHQ_core->oldOut_fx, L_FRAME48k ); @@ -3332,9 +3295,6 @@ void stereo_switching_dec( move16(); sts[1]->hTcxDec->L_frameTCX = sts[0]->hTcxDec->L_frameTCX; move16(); -#ifndef IVAS_FLOAT_FIXED - sts[1]->hTcxDec->conceal_eof_gain_float = sts[0]->hTcxDec->conceal_eof_gain_float; -#endif sts[1]->hTcxDec->conceal_eof_gain = sts[0]->hTcxDec->conceal_eof_gain; move16(); } @@ -3698,11 +3658,11 @@ void stereo_td2dft_update_fx( /* initialization */ sts = hCPE->hCoreCoder; - ovl = NS2SA( i_mult( sts[n]->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ); + ovl = NS2SA_FX2( i_mult( sts[n]->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ); move16(); dft32ms_ovl = extract_l( Mpy_32_32( imult3216( sts[0]->output_Fs, STEREO_DFT32MS_OVL_MAX ), 44740 ) ); // 1/48000 = 44740 (Q31) move16(); - hq_delay_comp = NS2SA( sts[0]->output_Fs, DELAY_CLDFB_NS ); + hq_delay_comp = NS2SA_FX2( sts[0]->output_Fs, DELAY_CLDFB_NS ); move16(); test(); @@ -3751,7 +3711,7 @@ void stereo_td2dft_update_fx( /* TCX synthesis (it was already delayed in TD stereo in core_switching_post_dec()) */ IF( sts[n]->hTcxDec != NULL ) { - ovl_TCX = NS2SA( sts[n]->hTcxDec->L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ); + ovl_TCX = NS2SA_FX2( sts[n]->hTcxDec->L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ); move16(); Copy32( synth_fx + sts[n]->hTcxDec->L_frameTCX + hq_delay_comp - ovl_TCX, hCPE->input_mem_fx[n], ovl_TCX - hq_delay_comp ); Copy32( sts[n]->delay_buf_out32_fx, hCPE->input_mem_fx[n] + ovl_TCX - hq_delay_comp, hq_delay_comp ); @@ -3769,7 +3729,7 @@ void stereo_td2dft_update_fx( /* TCX synthesis (it was already delayed in TD stereo in core_switching_post_dec()) */ IF( sts[n]->hTcxDec != NULL ) { - ovl_TCX = NS2SA( sts[n]->hTcxDec->L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ); + ovl_TCX = NS2SA_FX2( sts[n]->hTcxDec->L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ); move16(); Copy32( synth_fx + add( sts[n]->hTcxDec->L_frameTCX, sub( hq_delay_comp, ovl_TCX ) ), hCPE->input_mem_fx[n], sub( ovl_TCX, hq_delay_comp ) ); Copy32( sts[n]->delay_buf_out32_fx, hCPE->input_mem_fx[n] + sub( ovl_TCX, hq_delay_comp ), hq_delay_comp ); @@ -3777,9 +3737,9 @@ void stereo_td2dft_update_fx( IF( EQ_16( n, 1 ) ) { - nsLB = NS2SA( L_mult0( sts[n]->L_frame, FRAMES_PER_SEC ), N_ZERO_MDCT_NS ); + nsLB = NS2SA_FX2( L_mult0( sts[n]->L_frame, FRAMES_PER_SEC ), N_ZERO_MDCT_NS ); move16(); - ns = NS2SA( sts[n]->output_Fs, N_ZERO_MDCT_NS ); + ns = NS2SA_FX2( sts[n]->output_Fs, N_ZERO_MDCT_NS ); move16(); old_outLB_len = extract_l( Mpy_32_32( ( L_mult0( STEREO_MDCT2DFT_FADE_LEN_48k * FRAMES_PER_SEC, i_mult( 3, sts[0]->L_frame ) ) ), 44740 ) ); move16(); diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 877cbb938cc3739575c250f363a5e17d535243cc..2f6a742665deb462aa870fd32cd953f1811a3f00 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -50,8 +50,6 @@ #ifndef IVAS_FLOAT_FIXED static void dec_prm_tcx( Decoder_State *st, int16_t param[], int16_t param_lpc[], int16_t *total_nbbits, const int16_t last_element_mode, int16_t *bitsRead ); -#endif // !IVAS_FLOAT_FIXED -#ifndef IVAS_FLOAT_FIXED static void stereo_tcx_dec_mode_switch_reconf( Decoder_State *st, const int16_t MCT_flag, const int16_t last_element_mode ); #endif @@ -290,7 +288,7 @@ void stereo_tcx_core_dec_fx( const FRAME_MODE frameMode, /* i : Decoder frame mode */ Word16 *signal_out_fx, /* o : synthesis @internal_Fs, Q0 */ Word16 *signal_outFB_fx, /* o : synthesis @output_Fs, Q0 */ - Word16 pitch_buf_fx[], /* o : floating pitch for each subframe, Q6 */ + Word16 pitch_buf_fx[], /* o : Word16 pitch for each subframe, Q6 */ const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ const Word16 last_element_mode, /* i : last element mode */ @@ -691,7 +689,6 @@ void stereo_tcx_core_dec_fx( E_LPC_f_lsp_a_conversion( &lsp_fx[imult1616( add( k, 1 ), M )], Aq_fx, M ); { - // IGFDecRestoreTCX10SubFrameData_flt( st->hIGFDec, k ); /*float call to be removed*/ IGFDecRestoreTCX10SubFrameData_fx( st->hIGFDec, k ); } @@ -1940,10 +1937,6 @@ static void dec_prm_tcx_ivas_fx( move16(); } -#if 1 /*Fixed to float changes*/ - // st->hTcxLtpDec->tcxltp_gain_float = fixedToFloat( st->hTcxLtpDec->tcxltp_gain, 15 ); - // st->hTcxDec->tcxltp_last_gain_unmodified_float = fixedToFloat( st->hTcxDec->tcxltp_last_gain_unmodified, 15 ); -#endif // Ends here return; } #endif // IVAS_FLOAT_FIXED diff --git a/lib_dec/ivas_td_low_rate_dec.c b/lib_dec/ivas_td_low_rate_dec.c index e1eaca3d3256429b99fcf3f9ac68f86add0fb6c2..0d1e8b9d7b79fa3501bb0792fea954ccb213cf91 100644 --- a/lib_dec/ivas_td_low_rate_dec.c +++ b/lib_dec/ivas_td_low_rate_dec.c @@ -219,10 +219,9 @@ void tdm_low_rate_dec( #endif #ifdef IVAS_FLOAT_FIXED void tdm_low_rate_dec_fx( - Decoder_State *st, /* i/o: decoder static memory */ - Word16 dct_epit[], /* o : GSC excitation in DCT domain Q_exc */ - // Word16 *tmp_noise, /* o : long term temporary noise energy Q3 */ - Word16 *pitch_buf, /* o : floating pitch values for each subframe Q6 */ + Decoder_State *st, /* i/o: decoder static memory */ + Word16 dct_epit[], /* o : GSC excitation in DCT domain Q_exc */ + Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6 */ Word16 *voice_factors, /* o : voicing factors Q15 */ Word16 *exc, /* i/o: adapt. excitation exc Q_exc */ Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc */ @@ -235,7 +234,6 @@ void tdm_low_rate_dec_fx( Word16 Diff_len, nb_subfr; Word16 attack_flag; Word16 last_bin; - // float exc_wo_nf[L_FRAME]; Word16 exc_wo_nf_fx[L_FRAME]; hGSCDec = st->hGSCDec; @@ -259,12 +257,8 @@ void tdm_low_rate_dec_fx( move16(); move16(); - // st->tilt_code = 0.0f; st->tilt_code_fx = 0; move16(); - // set_f(exc, 0, L_FRAME); - // set_f(dct_epit, 0, L_FRAME); - // set_f(pitch_buf, L_SUBFR, NB_SUBFR); set16_fx( exc, 0, L_FRAME ); set16_fx( dct_epit, 0, L_FRAME ); set16_fx( pitch_buf, shl( L_SUBFR, Q6 ), NB_SUBFR ); @@ -311,24 +305,20 @@ void tdm_low_rate_dec_fx( tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); } - // gsc_dec(st, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st->coder_type, &last_bin, lsf_new, exc_wo_nf, tmp_noise); gsc_dec_ivas_fx( st, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st->coder_type, &last_bin, lsf_new, exc_wo_nf_fx, st->Q_exc ); /*--------------------------------------------------------------------------------------* * iDCT transform *--------------------------------------------------------------------------------------*/ - // edct(dct_epit, exc, L_FRAME, IVAS_CPE_TD); edct_16fx( dct_epit, exc, L_FRAME, find_guarded_bits_fx( L_FRAME ), IVAS_CPE_TD ); - // edct(exc_wo_nf, exc_wo_nf, L_FRAME, IVAS_CPE_TD); edct_16fx( exc_wo_nf_fx, exc_wo_nf_fx, L_FRAME, find_guarded_bits_fx( L_FRAME ), IVAS_CPE_TD ); /*----------------------------------------------------------------------* * Remove potential pre-echo in case an onset has been detected *----------------------------------------------------------------------*/ - // pre_echo_att(&hGSCDec->Last_frame_ener, exc, attack_flag, st->last_coder_type, st->L_frame); pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, attack_flag, st->Q_exc, st->last_coder_type, st->L_frame ); @@ -336,19 +326,16 @@ void tdm_low_rate_dec_fx( * Update BWE excitation *--------------------------------------------------------------------------------------*/ - // set_f(voice_factors, 0.0f, NB_SUBFR16k); set16_fx( voice_factors, 0, NB_SUBFR16k ); IF( st->hBWE_TD != NULL ) { IF( st->tdm_LRTD_flag ) { - // interp_code_5over2(exc, bwe_exc, L_FRAME); interp_code_5over2_fx( exc, bwe_exc, L_FRAME ); } ELSE { - // set_f(bwe_exc, 0, L_FRAME32k); set16_fx( bwe_exc, 0, L_FRAME32k ); } } @@ -357,9 +344,7 @@ void tdm_low_rate_dec_fx( * Updates *--------------------------------------------------------------------------------------*/ - // mvr2r(exc, exc2, L_FRAME); Copy( exc, exc2, L_FRAME ); - // mvr2r(exc_wo_nf, exc, L_FRAME); Copy( exc_wo_nf_fx, exc, L_FRAME ); /*--------------------------------------------------------------------------------------* @@ -520,27 +505,18 @@ void decod_gen_2sbfr_ivas_fx( Decoder_State *st, /* i/o: decoder static memory */ const Word16 sharpFlag, /* i : formant sharpening flag */ const Word16 *Aq, /* i : LP filter coefficient Q12 */ - Word16 *pitch_buf, /* o : floating pitch values for each subframe Q6 */ + Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6 */ Word16 *voice_factors, /* o : voicing factors Q15 */ Word16 *exc, /* i/o: adapt. excitation exc Q_exc */ Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc */ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc */ - Word16 *gain_buf, /* o : floating pitch gain for each subframe Q14 */ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14 */ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[] /* i : pitch values for primary channel Q6 */ ) { Word16 T0, T0_frac, T0_min, T0_max; /* integer pitch variables */ - // float gain_pit = 0.0f; /* pitch gain */ - // float gain_code = 0.0f; /* gain/normalized gain of the algebraic excitation */ - // float norm_gain_code = 0.0f; /* normalized gain of the algebraic excitation */ - // float gain_inov = 0; /* Innovation gain */ - // float gains_mem[2 * (NB_SUBFR - 1)]; /* pitch gain and code gain from previous subframes */ - // float voice_fac; /* voicing factor */ - // float code[2 * L_SUBFR]; /* algebraic codevector */ - // const float *p_Aq; /* Pointer to frame LP coefficient */ - // float *pt_pitch; /* pointer to floating pitch */ - Word16 gain_pit = 0; /* pitch gain */ + Word16 gain_pit = 0; /* pitch gain */ move16(); Word32 gain_code = 0; /* gain/normalized gain of the algebraic excitation */ move32(); @@ -548,17 +524,15 @@ void decod_gen_2sbfr_ivas_fx( move32(); Word16 gain_inov = 0; /* Innovation gain */ move16(); - // Word16 gains_mem[2 * (NB_SUBFR - 1)]; /* pitch gain and code gain from previous subframes */ Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */ Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes */ Word16 voice_fac; /* voicing factor */ Word16 code[2 * L_SUBFR]; /* algebraic codevector */ const Word16 *p_Aq; /* Pointer to frame LP coefficient */ - Word16 *pt_pitch; /* pointer to floating pitch */ + Word16 *pt_pitch; /* pointer to Word16 pitch */ Word16 i_subfr; /* tmp variables */ Word16 L_frame; Word16 pitch_limit_flag; - // float error; Word16 error; /*------------------------------------------------------------------* @@ -591,10 +565,8 @@ void decod_gen_2sbfr_ivas_fx( * Decode pitch lag *----------------------------------------------------------------------*/ - //*pt_pitch = pit_decode_flt(st, st->core_brate, 0, L_frame, i_subfr, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, 2 * L_SUBFR, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf); *pt_pitch = pit_decode_ivas_fx( st, st->core_brate, 0, L_frame, i_subfr, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, 2 * L_SUBFR, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); - // tbe_celp_exc_flt(st->element_mode, st->idchan, bwe_exc, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, st->tdm_LRTD_flag); test(); test(); IF( !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) && !( st->tdm_LRTD_flag ) ) ) @@ -606,21 +578,18 @@ void decod_gen_2sbfr_ivas_fx( * Find the adaptive codebook vector *--------------------------------------------------------------*/ - // pred_lt4_flt(&exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, inter4_2, L_INTERPOL2, PIT_UP_SAMP); pred_lt4( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, inter4_2_fx_Q15, L_INTERPOL2, PIT_UP_SAMP ); /*--------------------------------------------------------------* * LP filtering of the adaptive excitation *--------------------------------------------------------------*/ - // lp_filt_exc_dec(st, MODE1, i_subfr, 2 * L_SUBFR, L_frame, st->acelp_cfg.ltf_mode, exc); lp_filt_exc_dec_fx( st, MODE1, i_subfr, 2 * L_SUBFR, L_frame, st->acelp_cfg.ltf_mode, exc ); /*--------------------------------------------------------------* * Innovation decoding *--------------------------------------------------------------*/ - // inov_decode(st, st->core_brate, 0, L_frame, sharpFlag, i_subfr, p_Aq, st->tilt_code, *pt_pitch, code, 2 * L_SUBFR); inov_decode_ivas_fx( st, st->core_brate, 0, L_frame, sharpFlag, i_subfr, p_Aq, st->tilt_code_fx, *pt_pitch, code, 2 * L_SUBFR ); /*--------------------------------------------------------------* @@ -628,16 +597,11 @@ void decod_gen_2sbfr_ivas_fx( * Estimate spectrum tilt and voicing *--------------------------------------------------------------*/ - // gain_dec_lbr(st, GENERIC, i_subfr, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, gains_mem, 2 * L_SUBFR); gain_dec_lbr_fx( st, GENERIC, i_subfr, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, gc_mem, gp_mem, 2 * L_SUBFR ); - // st->tilt_code = est_tilt(exc + i_subfr, gain_pit, code, gain_code, &voice_fac, 2 * L_SUBFR, 0); - // st->tilt_code_fx = est_tilt_fx(exc + i_subfr, gain_pit, code, gain_code, &voice_fac, Q_exc/*, 2 * L_SUBFR, 0*/); st->tilt_code_fx = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, st->Q_exc, 2 * L_SUBFR, 0 ); move16(); /* update LP filtered gains for the case of frame erasures */ - // lp_gain_updt(i_subfr, gain_pit, norm_gain_code, &st->lp_gainp, &st->lp_gainc, L_frame); - // lp_gain_updt(i_subfr + L_SUBFR, gain_pit, norm_gain_code, &st->lp_gainp, &st->lp_gainc, L_frame); lp_gain_updt_ivas_fx( i_subfr, gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame ); lp_gain_updt_ivas_fx( i_subfr + L_SUBFR, gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame ); @@ -713,12 +677,9 @@ void decod_gen_2sbfr_ivas_fx( move16(); st->tilt_code_dec_fx[shr( add( i_subfr, L_SUBFR ), 6 ) /*( i_subfr + L_SUBFR ) / L_SUBFR*/] = st->tilt_code_fx; move16(); - // st->tilt_code_dec[i_subfr / L_SUBFR] = st->tilt_code; - // st->tilt_code_dec[( i_subfr + L_SUBFR ) / L_SUBFR] = st->tilt_code; } /* SC-VBR */ - // st->prev_gain_pit_dec = gain_pit; st->prev_gain_pit_dec_fx = gain_pit; move16(); diff --git a/lib_dec/jbm_jb4sb.c b/lib_dec/jbm_jb4sb.c index 3ba8a4331423dc812037643a8719e3ef9af3491c..32c52ba3b29b3e04d2e6b2385acabd14b7c7e453 100644 --- a/lib_dec/jbm_jb4sb.c +++ b/lib_dec/jbm_jb4sb.c @@ -183,7 +183,6 @@ struct JB4 UWord32 FecOffWin[10]; UWord32 optimum_offset; - float netLossRate; Word32 netLossRate_fx; Word32 nPartialCopiesUsed; Word32 last_nLost; @@ -300,7 +299,6 @@ ivas_error JB4_Create( move32(); h->totWin = 0; move32(); - h->netLossRate = 0.0f; h->netLossRate_fx = 0; move32(); h->nPartialCopiesUsed = 0; @@ -643,13 +641,13 @@ Word16 JB4_getFECoffset( Word16 JB4_FECoffset( JB4_HANDLE h ) { - IF( h->netLossRate < 0.05 ) + IF( LT_32( h->netLossRate_fx, 1634 ) ) { - return 0; + return (Word16) 0; } ELSE { - return 1; + return (Word16) 1; } } @@ -1406,15 +1404,11 @@ static void JB4_popFromBuffer( test(); IF( lost != 0 && total_rec != 0 ) { - Word16 temp, exp; - temp = BASOP_Util_Divide3232_Scale( lost, total_rec, &exp ); - h->netLossRate_fx = L_shr( temp, sub( 15, exp ) ); - h->netLossRate = (float) lost / (float) total_rec; + h->netLossRate_fx = divide3232( lost, total_rec ); } ELSE { h->netLossRate_fx = 0; - h->netLossRate = 0.0f; } move32(); h->last_nLost = L_add( h->nLost, h->nPartialCopiesUsed ); @@ -1529,7 +1523,7 @@ static void JB4_popFromBuffer( /* separate concealments since last available pop in lost and stretched */ Word16 exp; nStretched = BASOP_Util_Divide3232_Scale( tsDiff, h->frameDuration, &exp ); - nStretched = (UWord32) W_shr( nStretched, 15 - exp ); + nStretched = (UWord32) W_shr( nStretched, sub( 15, exp ) ); assert( h->nLostOrStretched >= nStretched ); h->nLost = (UWord32) W_add( h->nLost, W_sub( h->nLostOrStretched, nStretched ) ); /* jitter-induced insertion (e.g. buffer underflow) */ @@ -1628,7 +1622,7 @@ static void JB4_dropFromBuffer( /* separate concealments since last available pop in lost and stretched */ Word16 exp; nStretched = BASOP_Util_Divide3232_Scale( tsDiff, (Word32) h->frameDuration, &exp ); - nStretched = (UWord32) W_shr( nStretched, 15 - exp ); + nStretched = (UWord32) W_shr( nStretched, sub( 15, exp ) ); assert( h->nLostOrStretched >= nStretched ); /* convert stretching followed by shrinking to late-loss */ diff --git a/lib_dec/jbm_pcmdsp_similarityestimation.c b/lib_dec/jbm_pcmdsp_similarityestimation.c index 34f882c96c6282309a31c311651a0ecdf14e88a8..ad858dc8fae8648c2bd6b5f064af6444a6c994f0 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation.c @@ -49,6 +49,7 @@ /* Calculates cross correlation coefficient for template segment. */ +#ifndef IVAS_FLOAT_FIXED float cross_correlation_self( const float *signal, uint16_t x, @@ -66,6 +67,7 @@ float cross_correlation_self( return c_c; } +#endif #ifdef IVAS_FLOAT_FIXED void scaleSignal16( const Word16 *src, Word16 *dst, Word16 n, Word16 rightShift ) { @@ -98,6 +100,7 @@ Word32 cross_correlation_subsampled_self_fx( const Word16 *signal, } /* Calculates cross correlation coefficient for template segment. */ +#ifndef IVAS_FLOAT_FIXED float cross_correlation_subsampled_self( const float *signal, uint16_t x, @@ -184,6 +187,7 @@ bool isSilence( return true; } +#endif // !IVAS_FLOAT_FIXED Word16 normalized_cross_correlation_self_fx( const Word16 *signal, Word16 x, diff --git a/lib_dec/jbm_pcmdsp_similarityestimation.h b/lib_dec/jbm_pcmdsp_similarityestimation.h index c681dbb1f8fbf73e4a1fb93a501cd25a89b0201b..349189119dda6aec9f7fabe5cf3f70fe01b52788 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation.h +++ b/lib_dec/jbm_pcmdsp_similarityestimation.h @@ -67,11 +67,13 @@ * ******************************************************************************** */ +#ifndef IVAS_FLOAT_FIXED float cross_correlation_self( const float *signal, uint16_t x, uint16_t y, uint16_t corr_len ); +#endif // !IVAS_FLOAT_FIXED /* ******************************************************************************** @@ -98,13 +100,14 @@ float cross_correlation_self( * ******************************************************************************** */ +#ifndef IVAS_FLOAT_FIXED float cross_correlation_subsampled_self( const float *signal, uint16_t x, uint16_t y, uint16_t corr_len, uint16_t subsampling ); - +#endif /* ******************************************************************************** * @@ -141,6 +144,7 @@ float cross_correlation_subsampled_self( * ******************************************************************************** */ +#ifndef IVAS_FLOAT_FIXED float normalized_cross_correlation_self( const float *signal, uint16_t x, @@ -148,7 +152,7 @@ float normalized_cross_correlation_self( uint16_t corr_len, uint16_t subsampling, float *energy ); - +#endif /* Splits the signal into segments and checks if all of them have very low energy. */ bool isSilence( const float *signal, diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index ff917c20df8829c466f536a824987febe5dc201f..93604547bfe678f75723ead0a3df02b2b8a8f876 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -430,11 +430,7 @@ ivas_error IVAS_DEC_Configure( const IVAS_HEAD_ORIENT_TRK_T orientation_tracking, /* i : head orientation tracking type */ const Word16 renderConfigEnabled, /* i : enable Renderer config. file for binaural output */ const Word16 Opt_non_diegetic_pan, /* i : diegetic or not */ -#ifdef IVAS_FLOAT_FIXED const Word16 non_diegetic_pan_gain_fx, /* i : non diegetic panning gain */ -#else - const float non_diegetic_pan_gain, /* i : non diegetic panning gain */ -#endif const Word16 Opt_dpid_on, /* i : enable directivity pattern option */ const UWord16 acousticEnvironmentId, /* i : Acoustic environment ID */ const Word16 delayCompensationEnabled /* i : enable delay compensation */ diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index a11047966353e43cf9553bd75b21d76d0e524805..c4e0b43df7b1bba18226d61cae986aa139ea3cc6 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -367,19 +367,6 @@ typedef struct #endif } TonalComponentsInfo; -// typedef struct -//{ -// Word16 numIndexes; -// Word16 indexOfTonalPeak[MAX_NUMBER_OF_IDX]; -// Word16 lowerIndex[MAX_NUMBER_OF_IDX]; -// Word16 upperIndex[MAX_NUMBER_OF_IDX]; -// -// Word16 phaseDiff[MAX_NUMBER_OF_IDX]; // Q12 /* This one can be stored with 16 bits in range 0..2*PI */ -// -// Word16 phase_currentFramePredicted[MAX_NUMBER_OF_IDX*GROUP_LENGTH]; // Q13 /* This one can be stored with 16 bits in range [-pi;pi] 2Q13, but the code has to be adapted to use moduo(2*PI) after adding */ -// -// } TonalComponentsInfo_fix; - typedef struct tonalmdctconceal { TCX_config *tcx_cfg; @@ -420,7 +407,6 @@ typedef struct tonalmdctconceal Word16 secondLastPowerSpectrum_exp; - // Word16 scaleFactorsBackground[FDNS_NPTS]; Word32 scaleFactorsBackground_fx[FDNS_NPTS]; #ifndef IVAS_FLOAT_FIXED float *secondLastPowerSpectrum_float; @@ -557,8 +543,6 @@ typedef struct igfdec_instance_struct int16_t infoIGFStartLine; int16_t infoIGFStopFreq; int16_t infoIGFStartFreq; - // uint8_t *infoTCXNoise; - // uint8_t infoTCXNoiseBuf[IGF_START_MX]; Word16 *infoTCXNoise_ptr; Word16 infoTCXNoise_evs[IGF_START_MX]; int16_t *flag_sparse; @@ -744,16 +728,11 @@ typedef struct tcx_dec_structure uint16_t kernel_type[2]; /* transform kernel type in each subframe (MDCT or MDST) */ int16_t prev_widow_left_rect; - // Word32 CngLevelBackgroundTrace_bfi_fx; /* PLC - long term gain estimate for background level, used for PLC fade out */ - // Word16 CngLevelBackgroundTrace_bfi_exp; /* state variables for the minimum statistics used for PLC */ #ifndef IVAS_FLOAT_FIXED float CngLevelBackgroundTrace_bfi; /* PLC - long term gain estimate for background level, used for PLC fade out */ float NoiseLevelMemory_bfi[PLC_MIN_STAT_BUFF_SIZE]; #endif -#ifdef IVAS_FLOAT_FIXED - // Word16 NoiseLevelMemory_bfi_fx[PLC_MIN_STAT_BUFF_SIZE]; -#endif // IVAS_FLOAT_FIXED int16_t NoiseLevelIndex_bfi; int16_t CurrLevelIndex_bfi; @@ -777,9 +756,6 @@ typedef struct tcx_dec_structure Word16 old_gaintcx_bfi, old_gaintcx_bfi_e; Word16 conceal_eof_gain; /*Q14*/ -#ifdef IVAS_FLOAT_FIXED - // Word32 conceal_eof_gain32; /*have been created for further calculation */ -#endif #ifndef IVAS_FLOAT_FIXED float damping_float; #endif @@ -811,7 +787,6 @@ typedef struct tcx_dec_structure typedef struct gsc_dec_structure { int16_t seed_tcx; /* AC mode (GSC) - seed for noise fill */ - // Word16 seed_tcx; /* AC mode (GSC) - seed for noise fill Q0*/ int16_t cor_strong_limit; /* AC mode (GSC) - Indicator about high spectral correlation per band */ // Word16 cor_strong_limit; /* AC mode (GSC) - Indicator about high spectral correlation per band */ @@ -891,13 +866,10 @@ typedef struct ld_music_postfilt_structure Word16 LDm_mem_etot_fx; /* LD music post-filter - total energy memory */ int16_t LDm_last_music_flag; /* LD music post-filter - last music flag */ - // Word16 LDm_last_music_flag; /* LD music post-filter - last music flag */ int16_t LDm_nb_thr_1; /* LD music post-filter - number of consecutive frames of level 1 */ - // Word16 LDm_nb_thr_1; /* LD music post-filter - number of consecutives frames of level 1 */ int16_t LDm_nb_thr_3; - // Word16 LDm_nb_thr_3; #ifndef IVAS_FLOAT_FIXED float dct_post_old_exc[DCT_L_POST - OFFSET2]; @@ -939,7 +911,6 @@ typedef struct ld_music_postfilt_structure Word16 filt_lfE_fx[DCT_L_POST]; int16_t last_nonfull_music; - // Word16 last_nonfull_music; Word16 Old_ener_Q; /* Old energy scaling factor */ @@ -968,7 +939,6 @@ typedef struct bass_postfilt_structure Word16 pst_lp_ener_fx; /* Bass post-filter - long-term energy Q8*/ int16_t Track_on_hist[L_TRACK_HIST]; /* Bass post-filter - History of half frame usage */ - // Word16 Track_on_hist[L_TRACK_HIST]; /* Bass post-filter - History of half frame usage */ int16_t vibrato_hist[L_TRACK_HIST]; /* Bass post-filter - History of frames declared as vibrato */ // Word16 vibrato_hist[L_TRACK_HIST]; /* Bass post-filter - History of frames declared as vibrato */ @@ -998,22 +968,16 @@ typedef struct td_cng_dec_structure Word32 Enew_fx; /* CNG and DTX - decoded residual energy Q6*/ int16_t old_enr_index; /* DTX/CNG - index of last encoded CNG energy */ - // Word16 old_enr_index; /* CNG and DTX - index of last encoded CNG energy Q0*/ int16_t cng_ener_seed; /* DTX/CNG - seed for random generator for variation of excitation energy */ - // Word16 cng_ener_seed; /*CNG and DTX - seed for random generator for variation of excitation energyQ0*/ int16_t cng_ener_seed1; - // Word16 cng_ener_seed1; int16_t last_allow_cn_step; - // Word16 last_allow_cn_step; /*Q0*/ int16_t ho_hist_size; /* DTX/CNG - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ - // Word16 ho_hist_size; /* CNG and DTX - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ int16_t ho_hist_ptr; /* DTX/CNG - pointer for averaging buffers */ - // Word16 ho_hist_ptr; /* CNG and DTX - pointer for averaging buffers */ int32_t ho_sid_bw; /* DTX/CNG - SID bandwidth flags */ // Word32 ho_sid_bw; /* CNG and DTX - SID bandwidth flags */ @@ -1032,10 +996,8 @@ typedef struct td_cng_dec_structure int16_t act_cnt; /* DTX/CNG - counter of active frames */ - // Word16 act_cnt; /* CNG and DTX - counter of active frames */ int16_t ho_circ_size; /* DTX/CNG - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ - // Word16 ho_circ_size; /* CNG and DTX - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ int16_t ho_circ_ptr; /* DTX/CNG - pointer for averaging buffers */ // Word16 ho_circ_ptr; /* CNG and DTX - pointer for averaging buffers */ @@ -1055,7 +1017,6 @@ typedef struct td_cng_dec_structure int16_t num_ho; /* DTX/CNG - number of selected hangover frames */ - // Word16 num_ho; /* DTX/CNG - number of selected hangover frames */ int16_t ho_16k_lsp[HO_HIST_SIZE]; /* DTX/CNG - 16k LSPs flags */ // Word16 ho_16k_lsp[HO_HIST_SIZE]; /* DTX/CNG - 16k LSPs flags */ @@ -1119,7 +1080,6 @@ typedef struct td_cng_dec_structure #endif int16_t burst_cnt; - // Word16 burst_cnt; #ifndef IVAS_FLOAT_FIXED float last_shb_ener; #endif @@ -1140,7 +1100,6 @@ typedef struct td_cng_dec_structure typedef struct sc_vbr_dec_structure { int16_t firstTime_voiceddec; - // Word16 firstTime_voiceddec; /*Q0*/ /* DTFS variables */ #ifndef IVAS_FLOAT_FIXED @@ -1153,13 +1112,10 @@ typedef struct sc_vbr_dec_structure Word16 dtfs_dec_b_fx[MAXLAG_WI]; /*Variable Q format in dtfs_dec_Q*/ int16_t dtfs_dec_lag; - // Word16 dtfs_dec_lag; int16_t dtfs_dec_nH; - // Word16 dtfs_dec_nH; int16_t dtfs_dec_nH_4kHz; - // Word16 dtfs_dec_nH_4kHz; /*Q0*/ #ifndef IVAS_FLOAT_FIXED float dtfs_dec_upper_cut_off_freq_of_interest; @@ -1213,7 +1169,6 @@ typedef struct sc_vbr_dec_structure int16_t nelp_dec_seed; - // Word16 nelp_dec_seed; /* Q0*/ Word16 FadeScale_fx; /*Q15*/ @@ -1235,20 +1190,15 @@ typedef struct hq_nbfec_structure Word16 diff_energy_fx; int16_t stat_mode_out; - // Word16 stat_mode_out; int16_t stat_mode_old; - // Word16 stat_mode_old; int16_t phase_mat_flag; - // Word16 phase_mat_flag; int16_t phase_mat_next; - // Word16 phase_mat_next; int16_t old_Min_ind; - // Word16 old_Min_ind; #ifndef IVAS_FLOAT_FIXED float old_auOut_2fr[L_FRAME8k * 2]; @@ -1279,7 +1229,6 @@ typedef struct hq_nbfec_structure int16_t HQ_FEC_seed; - // Word16 HQ_FEC_seed; #ifndef IVAS_FLOAT_FIXED float energy_MA_Curr[2]; @@ -1287,10 +1236,8 @@ typedef struct hq_nbfec_structure Word16 energy_MA_Curr_fx[2]; int16_t prev_sign_switch[HQ_FEC_SIGN_SFM]; - // Word16 prev_sign_switch[HQ_FEC_SIGN_SFM]; int16_t prev_sign_switch_2[HQ_FEC_SIGN_SFM]; - // Word16 prev_sign_switch_2[HQ_FEC_SIGN_SFM]; #ifndef IVAS_FLOAT_FIXED float old_coeffs[L_FRAME8k]; /* HQ core - old coefficients (for FEC) */ @@ -1340,18 +1287,13 @@ typedef struct hq_dec_structure Word16 Q_old_postdec; /*scaling of the output of core_switching_post_dec_fx() */ int16_t last_hq_core_type; - // Word16 last_hq_core_type; /*Q0*/ - // int16_t old_is_transient[3]; /* HQ core - previous transient flag (for FEC and BWE/NF) */ Word16 old_is_transient[3]; /* HQ core - previous transient flag (for FEC) */ - // int16_t mem_norm[SFM_N_ENV_STAB]; Word16 mem_norm[SFM_N_ENV_STAB]; /* Q0 */ - // int16_t mem_env_delta; Word16 mem_env_delta; /* Q11 */ - // int16_t no_att_hangover; Word16 no_att_hangover; /* Q0 */ #ifndef IVAS_FLOAT_FIXED @@ -1359,7 +1301,6 @@ typedef struct hq_dec_structure #endif Word32 energy_lt_fx; /* Q13 */ - // int16_t hq_generic_seed; Word16 hq_generic_seed; #ifndef IVAS_FLOAT_FIXED @@ -1367,10 +1308,8 @@ typedef struct hq_dec_structure #endif Word16 prev_noise_level_fx[2]; /* Q15 */ - // int16_t prev_hqswb_clas; Word16 prev_hqswb_clas; - // int16_t prev_R; /* the table of bit allocation of last frame */ Word16 prev_R; /* the table of bit allocation of last frame */ #ifndef IVAS_FLOAT_FIXED @@ -1382,7 +1321,6 @@ typedef struct hq_dec_structure Word16 prev_SWB_peak_pos_fx[SPT_SHORTEN_SBNUM]; - // int16_t HqVoicing; Word16 HqVoicing; #ifndef IVAS_FLOAT_FIXED float fer_samples[L_FRAME48k]; @@ -1413,7 +1351,6 @@ typedef struct hq_dec_structure #endif Word16 last_env_fx[BANDS_MAX]; - // int16_t last_max_pos_pulse; Word16 last_max_pos_pulse; /* pre-echo reduction */ @@ -1452,10 +1389,8 @@ typedef struct hq_dec_structure int16_t pastpre; - // int16_t prev_frm_hfe2; Word16 prev_frm_hfe2; - // int16_t prev_stab_hfe2; Word16 prev_stab_hfe2; #ifndef IVAS_FLOAT_FIXED @@ -1473,7 +1408,6 @@ typedef struct hq_dec_structure *----------------------------------------------------------------------------------*/ /* HQ PHASE ECU internal state */ - // int16_t time_offs; Word16 time_offs; #ifndef IVAS_FLOAT_FIXED @@ -1483,10 +1417,8 @@ typedef struct hq_dec_structure Word16 Q_X_sav; - // int16_t num_p; Word16 num_p; - // int16_t plocs[MAX_PLOCS]; Word16 plocs[MAX_PLOCS]; #ifndef IVAS_FLOAT_FIXED @@ -1499,10 +1431,8 @@ typedef struct hq_dec_structure #endif Word16 env_stab_fx; - // int16_t mem_norm_hqfec[SFM_N_ENV_STAB]; Word16 mem_norm_hqfec[SFM_N_ENV_STAB]; - // int16_t mem_env_delta_hqfec; Word16 mem_env_delta_hqfec; #ifndef IVAS_FLOAT_FIXED @@ -1515,7 +1445,6 @@ typedef struct hq_dec_structure #endif Word16 env_stab_state_p_fx[NUM_ENV_STAB_PLC_STATES]; - // int16_t envstabplc_hocnt; Word16 envstabplc_hocnt; #ifndef IVAS_FLOAT_FIXED @@ -1533,13 +1462,10 @@ typedef struct hq_dec_structure #endif Word16 beta_mute_fx; /* Factor for long-term mute */ - // int16_t last_fec; Word16 last_fec; - // int16_t ph_ecu_HqVoicing; Word16 ph_ecu_HqVoicing; - // int16_t oldHqVoicing; Word16 oldHqVoicing; #ifndef IVAS_FLOAT_FIXED @@ -1547,7 +1473,6 @@ typedef struct hq_dec_structure #endif Word16 oldgapsynth_fx[L_FRAME48k]; - // int16_t ph_ecu_active; /* Set to 1 if Phase ECU was used in last bad frame; Set to 2 if TCX TD PLC was used */ Word16 ph_ecu_active; /* Set if Phase ECU was used in last bad frame */ int16_t ni_seed_forfec; @@ -1649,7 +1574,6 @@ typedef struct td_bwe_dec_structure Word16 old_bwe_exc_fx[PIT16k_MAX * 2]; /*Q_exc*/ int16_t bwe_seed[2]; - // Word16 bwe_seed[2]; /*Q0*/ #ifndef IVAS_FLOAT_FIXED float bwe_non_lin_prev_scale; @@ -1717,7 +1641,6 @@ typedef struct td_bwe_dec_structure #ifndef IVAS_FLOAT_FIXED float prev_pow_exc16kWhtnd; /* power of the LB excitation signal in the previous frame */ #endif - // Word16 prev_pow_exc16kWhtnd_fx; /* power of the LB excitation signal in the previous frame */ - Don't use this Word32 prev_pow_exc16kWhtnd_fx32; /* power of the LB excitation signal in the previous frame */ #ifndef IVAS_FLOAT_FIXED float prev_mix_factor; /* mixing factor in the previous frame */ @@ -1725,7 +1648,6 @@ typedef struct td_bwe_dec_structure Word16 prev_mix_factor_fx; /* mixing factor in the previous frame */ int16_t syn_dm_phase; - // Word16 syn_dm_phase; #ifndef IVAS_FLOAT_FIXED float fbbwe_hpf_mem[4][4]; @@ -1759,11 +1681,6 @@ typedef struct td_bwe_dec_structure #endif Word16 fb_state_lpc_syn_fx[LPC_SHB_ORDER]; - // Word16 prev_Q_bwe_exc_fb; - // Word16 prev_Qx; - // Word16 prev_Q_bwe_exc; - // Word16 prev_Q_synth; - #ifndef IVAS_FLOAT_FIXED float fb_tbe_demph; #endif @@ -1840,37 +1757,26 @@ typedef struct td_bwe_dec_structure /* quantized data */ int16_t lsf_idx[NUM_Q_LSF]; - // Word16 lsf_idx[NUM_Q_LSF]; int16_t m_idx; - // Word16 m_idx; int16_t grid_idx; - // Word16 grid_idx; int16_t idxSubGains; - // Word16 idxSubGains; int16_t idxFrameGain; - // Word16 idxFrameGain; int16_t idx_shb_fr_gain; - // Word16 idx_shb_fr_gain; int16_t idx_res_gs[NB_SUBFR16k]; - // Word16 idx_res_gs[NB_SUBFR16k]; int16_t idx_mixFac; - // Word16 idx_mixFac; int16_t lsf_WB; - // Word16 lsf_WB; int16_t gFrame_WB; - // Word16 gFrame_WB; int16_t idxGain; - // Word16 idxGain; #ifndef IVAS_FLOAT_FIXED float old_core_synth[L_FRAME16k]; @@ -1931,12 +1837,10 @@ typedef struct fd_bwe_dec_structure Word16 mem_deemph_old_syn_fx; int16_t prev_mode; - // Word16 prev_mode; #ifndef IVAS_FLOAT_FIXED float prev_SWB_fenv[SWB_FENV]; #endif - // Word16 prev_SWB_fenv_fx[SWB_FENV]; // Don't use this. Use prev_SWB_fenv_fx present in Decoder_State #ifndef IVAS_FLOAT_FIXED float prev_Energy; @@ -1949,15 +1853,12 @@ typedef struct fd_bwe_dec_structure Word32 prev_Energy_wb_fx; int16_t prev_L_swb_norm; - // Word16 prev_L_swb_norm; int16_t Seed; - // Word16 Seed; Word16 memExp1; int16_t prev_frica_flag; - // Word16 prev_frica_flag; #ifndef IVAS_FLOAT_FIXED float mem_imdct[L_FRAME48k]; @@ -1977,23 +1878,14 @@ typedef struct fd_bwe_dec_structure Word16 prev_weight_fx; int16_t prev_flag; - // Word16 prev_flag; #ifndef IVAS_FLOAT_FIXED float last_wb_bwe_ener; #endif - // Word16 last_wb_bwe_ener_fx; // Don't use this. Use last_wb_bwe_ener_fx present in Decoder_State #ifndef IVAS_FLOAT_FIXED float prev_fb_ener_adjust; #endif - // Word16 prev_fb_ener_adjust_fx; // Don't use this. Use prev_fb_ener_adjust_fx present in Decoder_State - - // Word16 prev_frame_pow_exp; - // Word16 prev_Qx; - // Word16 prev_Q_bwe_exc; - // Word16 prev_Q_synth; - } FD_BWE_DEC_DATA, *FD_BWE_DEC_HANDLE; @@ -2166,10 +2058,8 @@ typedef struct Decoder_State int16_t last_codec_mode; /* last used codec mode */ uint16_t *bit_stream; /* pointer to bitstream buffer */ - // UWord16 *bit_stream_fx; int16_t next_bit_pos; /* position of the next bit to be read from the bitstream */ - // Word16 next_bit_pos; /* position of the next bit to be read from the bitstream */ Word16 bitstreamformat; /* Bitstream format flag (G.192/MIME/VOIP_G192_RTP/VOIP_RTPDUMP) */ Word16 sdp_hf_only; /* RTP payload format parameter: only Header-Full format without zero padding for size collision avoidance */ @@ -2179,18 +2069,15 @@ typedef struct Decoder_State int16_t BER_detect; /* flag to signal detected bit error in the bitstream */ int32_t output_Fs; /* output sampling rate */ - // Word32 output_Fs_fx; /* output sampling rate Q0*/ Word16 output_frame_fx; /* Output frame length Q0*/ int32_t total_brate; /* total bitrate in kbps of the codec */ - // Word32 total_brate_fx; /* total bitrate in kbps of the codec Q0*/ int32_t last_total_brate; /* last total bitrate in kbps of the codec */ // Word32 last_total_brate_fx; /* last total bitrate in kbps of the codec Q0*/ int32_t last_total_brate_ber; /* last total bitrate in kbps of the codec - used only when first frame is lost and BER is detected afterwards */ - // Word32 last_total_brate_ber_fx; /* last total bitrate in kbps of the codec - used only when first frame is lost and BER is detected afterwards */ int16_t bits_frame_nominal; /* avg bits per frame on active frame */ int32_t last_bits_frame_nominal; /* last avg bits per frame on active frame */ @@ -2199,43 +2086,33 @@ typedef struct Decoder_State int16_t side_bits_frame_channel; /* bits frame channel */ int16_t core; /* core (ACELP_CORE, TCX_20_CORE, TCX_10_CORE, HQ_CORE, AMR_WB_CORE) */ - // Word16 core_fx; /* core (ACELP_CORE, TCX_20_CORE, TCX_10_CORE, HQ_CORE, AMR_WB_CORE) */ int16_t coder_type; /* coder type */ int16_t transform_type[2]; /* TCX20/10/5 mode in each subframe */ int32_t core_brate; /* core bitrate */ - // Word32 core_brate_fx; /* core bitrate */ int32_t last_core_brate; /* previous frame core bitrate */ - // Word32 last_core_brate_fx; /* previous frame core bitrate Q0*/ int16_t extl; /* extension layer */ - // Word16 extl_fx; /* extension layer Q0*/ int16_t extl_orig; /* extension layer */ int16_t last_extl; /* previous extension layer */ - // Word16 last_extl_fx; /* previous extension layer Q0*/ int32_t extl_brate; /* extension layer bitrate */ - // Word32 extl_brate_fx; /* extension layer bitrate */ int32_t extl_brate_orig; /* extension layer bitrate */ int16_t L_frame; /* ACELP core internal frame length */ - // Word16 L_frame_fx; /* ACELP core internal frame length */ int16_t bwidth; /* encoded signal bandwidth */ - // Word16 bwidth_fx; /* encoded signal bandwidth */ int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ - // Word16 Opt_AMR_WB_fx; /* flag indicating AMR-WB IO mode Q0*/ Word16 Opt_VOIP_fx; /* flag indicating VOIP mode with JBM */ int16_t ini_frame; /* initialization frames counter */ - // Word16 ini_frame_fx; /* initialization frames counter */ int16_t prev_coder_type; /* coding type of last frame */ int16_t low_rate_mode; /* low-rate mode flag */ @@ -2289,15 +2166,12 @@ typedef struct Decoder_State Word16 stab_fac_smooth_fx; /* low-pass filtered stability factor Q15*/ int16_t last_coder_type; /* previous coder type */ - // Word16 last_coder_type; /* previous coder type Q0*/ Word16 agc_mem_fx[2]; /* memory of AGC for saturation control Q0*/ int16_t mid_lsf_int; - // Word16 mid_lsf_int; int16_t safety_net; - // Word16 safety_net; #ifndef IVAS_FLOAT_FIXED float stab_fac; /* LSF stability factor */ @@ -2323,12 +2197,10 @@ typedef struct Decoder_State int16_t GSC_noisy_speech; /* AC mode (GSC) - flag to indicate GSC on SWB noisy speech */ - // Word16 GSC_noisy_speech; /* AC mode (GSC) - flag to indicate GSC osn SWB noisy speech */ int16_t GSC_IVAS_mode; /* AC mode (GSC) - GSC IVAS mode */ int16_t Last_GSC_noisy_speech_flag; /* AC mode (GSC) - mem of the past flag to indicate GSC osn SWB noisy speech */ - // Word16 Last_GSC_noisy_speech_flag; /* AC mode (GSC) - mem of the past flag to indicate GSC osn SWB noisy speech */ GSC_DEC_HANDLE hGSCDec; @@ -2344,20 +2216,16 @@ typedef struct Decoder_State ZERO_BWE_DEC_HANDLE hBWE_zero; /* HF (6-7kHz) BWE */ int16_t unv_cnt; /* Stationary noise UV modification - unvoiced frame counter */ - // Word16 unv_cnt; /* Stationary noise UV modification - unvoiced frame counter Q0*/ int16_t uv_count; /* Stationary noise UV modification - unvoiced counter */ - // Word16 uv_count; /* Stationary noise UV modification - unvoiced counter Q0*/ int16_t act_count; /* Stationary noise UV modification - activation counter */ - // Word16 act_count; /* Stationary noise UV modification - activation counter Q0*/ Word32 ge_sm_fx; /* Stationary noise UV modification - smoothed excitation gain Q(GE_SHIFT)*/ Word16 lspold_s_fx[M]; /* Stationary noise UV modification - old LSP vector Q15*/ int16_t noimix_seed; /* Stationary noise UV modification - mixture seed */ - // Word16 noimix_seed; /* Stationary noise UV modification - mixture seed Q0*/ Word16 min_alpha_fx; /* Stationary noise UV modification - minimum alpha Q15*/ @@ -2375,10 +2243,8 @@ typedef struct Decoder_State int16_t bfi; /* FEC - bad frame indicator */ - // Word16 bfi_fx; /* FEC - bad frame indicator */ int16_t prev_bfi; /* FEC - previous bad frame indicator */ - // Word16 prev_bfi_fx; /* FEC - previous bad frame indicator Q0*/ int16_t prev_old_bfi; /* FEC - previous old bad frame indicator */ @@ -2410,13 +2276,11 @@ typedef struct Decoder_State Word16 bfi_pitch_fx; /* FEC - pitch for FEC */ int16_t bfi_pitch_frame; /* FEC - frame length when pitch for FEC is saved */ - // Word16 bfi_pitch_frame_fx; /*FEC - frame length when pitch for FEC is saved Q0*/ Word16 old_pitch_buf_16_fx[2 * NB_SUBFR16k + 2]; /* FEC - buffer of old subframe pitch values 15Q16 */ Word32 old_pitch_buf_fx[2 * NB_SUBFR16k + 2]; /* FEC - buffer of old subframe pitch values 15Q16 */ int16_t upd_cnt; /* FEC - counter of frames since last update */ - // Word16 upd_cnt_fx; /* FEC - counter of frames since last update Q0*/ int16_t scaling_flag; /* FEC - flag to indicate energy control of syn */ @@ -2445,16 +2309,13 @@ typedef struct Decoder_State Word16 lsf_adaptive_mean_fx[M]; /* FEC - adaptive mean LSF vector for FEC (Qx2.56)*/ int16_t decision_hyst; /* FEC - hysteresis of the music/speech decision */ - // Word16 decision_hyst_fx; /* FEC - hysteresis of the music/speech decision Q0*/ - // Word16 last_good; /* FEC - clas of last good received Q0*/ Word16 lp_ener_FER_fx; /* FEC - long-term active-signal average energy Q8*/ WI_DEC_HANDLE hWIDec; int16_t relax_prev_lsf_interp; - // Word16 relax_prev_lsf_interp; #ifndef IVAS_FLOAT_FIXED float mem_syn_clas_estim[L_SYN_MEM_CLAS_ESTIM]; /* FEC - memory of the synthesis signal for frame class estimation */ @@ -2462,18 +2323,14 @@ typedef struct Decoder_State Word16 mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM]; /* FEC - memory of the synthesis signal for frame class estimation */ int16_t bpf_off; /* Bass post-filter - do not use BPF when this flag is set to 1 */ - // Word16 bpf_off_fx; /* Bass post-filter - do not use BPF when this flag is set to 1 Q0*/ BPF_DEC_HANDLE hBPF; /* Bass post-filter handle */ HANDLE_CLDFB_FILTER_BANK cldfbAna; /* main analysis filter bank handle */ - // HANDLE_CLDFB_FILTER_BANK cldfbAna_fx; /* main analysis filter bank handle */ HANDLE_CLDFB_FILTER_BANK cldfbBPF; /* BPF analysis filter bank handle */ - // HANDLE_CLDFB_FILTER_BANK cldfbBPF_fx; /* BPF analysis filter bank handle */ HANDLE_CLDFB_FILTER_BANK cldfbSyn; /* main synthesis filter bank handle */ - // HANDLE_CLDFB_FILTER_BANK cldfbSyn_fx; /* main synthesis filter bank handle */ HANDLE_CLDFB_FILTER_BANK cldfbSynHB; /* high band synthesis filter bank needed in SBA2Stereo DTX handling */ @@ -2497,12 +2354,10 @@ typedef struct Decoder_State Word16 Ng_ener_ST_fx; /* Noise gate - short-term energy Q8*/ int16_t last_L_frame; /* ACELP@16kHz - last value of st->L_frame */ - // Word16 last_L_frame_fx; /* ACELP@16kHz - last value of st->L_frame */ Word16 mem_preemp_preQ_fx; /* ACELP@16kHz - prequantizer preemhasis memory */ int16_t last_nq_preQ; /* ACELP@16kHz - AVQ subquantizer number of the last sub-band of the last subframe */ - // Word16 last_nq_preQ; /* ACELP@16kHz - AVQ subquantizer number of the last sub-band of the last subframe */ int16_t last_code_preq; /* ACELP@16kHz - last coefficient of the pre-quantizer contribution */ @@ -2530,15 +2385,12 @@ typedef struct Decoder_State *----------------------------------------------------------------------------------*/ int16_t first_CNG; /* DTX/CNG - first CNG frame flag */ - // Word16 first_CNG_fx; /* CNG and DTX - first CNG frame flag Q0*/ int16_t cng_type; /* DTX/CNG - flag indicating LP or CLDFB based SID/CNG */ - // Word16 cng_type_fx; /* DTX/CNG - flag indicating LP or CLDFB based SID/CNG */ int16_t last_vad; int32_t last_active_brate; /* DTX/CNG - last active frame bitrate used for CNG_mode control */ - // Word32 last_active_brate_fx; /* DTX/CNG - last active frame bitrate used for CNG_mode control */ int16_t last_CNG_L_frame; /* DTX/CNG - last CNG frame length */ // Word16 last_CNG_L_frame_fx; /* DTX/CNG - last CNG frame length */ @@ -2569,16 +2421,12 @@ typedef struct Decoder_State SC_VBR_DEC_HANDLE hSC_VBR; int16_t last_ppp_mode_dec; - // Word16 last_ppp_mode_dec; /*Q0*/ int16_t ppp_mode_dec; - // Word16 ppp_mode_dec; /*Q0*/ int16_t last_nelp_mode_dec; - // Word16 last_nelp_mode_dec; int16_t nelp_mode_dec; - // Word16 nelp_mode_dec; /* Q0 */ Word16 prev_gain_pit_dec_fx; /*Q14*/ @@ -2591,10 +2439,8 @@ typedef struct Decoder_State Word16 prev_tilt_code_dec_fx; /*Q15*/ int16_t vbr_hw_BWE_disable_dec; - // Word16 vbr_hw_BWE_disable_dec; int16_t last_vbr_hw_BWE_disable_dec; - // Word16 last_vbr_hw_BWE_disable_dec; /*----------------------------------------------------------------------------------* * channel-aware mode @@ -2632,13 +2478,11 @@ typedef struct Decoder_State HQ_DEC_HANDLE hHQ_core; int16_t last_core; - // Word16 last_core_fx; /*Q0*/ int16_t last_core_from_bs; /* last frame core as coded in TCX bitstream */ // Word16 last_core_bs_fx; int16_t last_L_frame_ori; - // Word16 last_L_frame_ori_fx; Word16 previoussynth_fx[L_FRAME48k]; Word32 previoussynth_fx_32[L_FRAME48k]; @@ -2664,9 +2508,6 @@ typedef struct Decoder_State #endif Word16 old_Es_pred_fx; /* old Es_pred for core switching */ - // Word16 old_bfi_cnt; /* HQ core - # of bfi until previous frame(for FEC) */ - // Word16 prev_old_bfi; - HQ_NBFEC_HANDLE hHQ_nbfec; /*----------------------------------------------------------------------------------* @@ -2676,7 +2517,6 @@ typedef struct Decoder_State TD_BWE_DEC_HANDLE hBWE_TD; int16_t old_bwe_delay; - // Word16 old_bwe_delay; /*Q0*/ Word16 hb_prev_synth_buffer_fx[NS2SA( 48000, DELAY_BWE_TOTAL_NS )]; @@ -2709,16 +2549,12 @@ typedef struct Decoder_State Word32 prev_enerLL_fx; int16_t prev_fractive; - // Word16 prev_fractive; int16_t prev_bws_cnt; - // Word16 prev_bws_cnt; int16_t bws_cnt; - // Word16 bws_cnt; int16_t bws_cnt1; - // Word16 bws_cnt1; #ifndef IVAS_FLOAT_FIXED float attenu1; @@ -2727,10 +2563,8 @@ typedef struct Decoder_State Word16 attenu_fx; int16_t last_inner_frame; - // Word16 last_inner_frame_fx; /* (HQ_CORE) DCT length */ int16_t last_bwidth; - // Word16 last_bwidth_fx; Word16 t_audio_q_fx[L_FRAME]; @@ -2777,7 +2611,6 @@ typedef struct Decoder_State *----------------------------------------------------------------------------------*/ FD_BWE_DEC_HANDLE hBWE_FD; - // Word16 prev_coder_type; /*----------------------------------------------------------------------------------* * SWB DTX/CNG parameters @@ -2793,7 +2626,6 @@ typedef struct Decoder_State Word16 shb_dtx_count_fx; Word16 last_vad_fx; Word16 trans_cnt_fx; - // Word16 burst_cnt; Word16 last_shb_ener_fx; /*----------------------------------------------------------------------------------* @@ -3050,7 +2882,6 @@ typedef struct Decoder_State uint8_t m_old_frame_type; /*ZERO_FRAME/SID_FRAME/ACTIVE_FRAME*/ int16_t old_ppp_mode; - // Word16 old_ppp_mode; int16_t con_tcx; int16_t last_con_tcx; diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 00c909825f6688b0ddf65c40aa7667694857084d..0729c6cd884a558fc573e1f2453cd4f6b54bc0a6 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -745,9 +745,9 @@ typedef struct ivas_stereo_classifier_data_structure Word32 relE_0_1_LT_fx; Word32 unclr_relE_0_1_LT_fx[UNCLR_RC_ORDER]; Word32 unclr_wscore_fx; - Word32 unclr_fv_fx[SSC_MAX_NFEA]; /* UNCLR - feature vector */ // Q16 + Word32 unclr_fv_fx[SSC_MAX_NFEA]; /* UNCLR - feature vector */ // Q15 Word32 xtalk_score_buf_fx[XTALK_SCORE_BUF_LEN]; // Q31 - Word32 xtalk_fv_fx[SSC_MAX_NFEA]; /* xtalk - feature vector */ // Q16 + Word32 xtalk_fv_fx[SSC_MAX_NFEA]; /* xtalk - feature vector */ // Q15 Word32 xtalk_wscore_fx; Word32 xtalk_score_fx; // Q31 Word32 xtalk_score_wrelE_fx; diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd.c index 2cfa1b79a9fe14016492c758fe11f27af0f15c3d..b470b8309b53a72f005fdde9d43cd359ae988271 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd.c +++ b/lib_enc/ivas_stereo_dft_enc_itd.c @@ -536,7 +536,13 @@ static Word16 stereo_dft_enc_itd_vad_fx( Word32 Spd[STEREO_DFT_N_16k_ENC / 2 + 1]; Word16 Spd_e[STEREO_DFT_N_16k_ENC / 2 + 1]; +#ifdef FIX_828_PORT_1152_FROM_FLT_REPO + /* Spd is later only used starting at itd_vad_band_tbl[0], so only compute values starting from there */ + /* -> this avoids uninitialized values in Spd_L and Spd_R at index 0 to be used */ + FOR( i = itd_vad_band_tbl[0]; i < STEREO_DFT_N_16k_ENC / 2; i++ ) +#else FOR( i = 0; i <= STEREO_DFT_N_16k_ENC / 2; i++ ) +#endif { // Spd[i] = 0.5f * ( Spd_L[i] + Spd_R[i] ); Spd[i] = BASOP_Util_Add_Mant32Exp( Spd_L[i], Spd_L_e[i], Spd_R[i], Spd_R_e[i], &Spd_e[i] ); @@ -2362,18 +2368,19 @@ void stereo_dft_enc_compute_itd_fx( /*calculate total cohSNR for frame in dB*/ // THIS PART NEEDS TO BE RECHECKED AGAINST NEW FLOAT CODE - // cohSNR = 20 * log10f( mEr ); - Word16 NAN_flag; - if ( mEr < 0 ) +#ifdef FIX_BASOP_812_NAN_COHSNR + IF( BASOP_Util_Cmp_Mant32Exp( mEr, mEr_e, MAX_32, 0 ) > 0 ) { - cohSNR = 0; - NAN_flag = 1; +#endif + cohSNR = Mpy_32_32( 83886080, BASOP_Util_Log10( mEr, mEr_e ) ); // Q16 (cohSNR = 20 * log10f( mEr );) +#ifdef FIX_BASOP_812_NAN_COHSNR } - else + ELSE { - cohSNR = Mpy_32_32( 83886080, BASOP_Util_Log10( mEr, mEr_e ) ); // Q16 - NAN_flag = 0; + cohSNR = 0; + move32(); } +#endif /* collect UNCLR classifier parameters */ { @@ -2387,7 +2394,7 @@ void stereo_dft_enc_compute_itd_fx( } ELSE { - hStereoClassif->unclr_fv_fx[E_cohSNR] = Mpy_32_32( 41943040 /*20 in Q21*/, BASOP_Util_Log10( total_mEr, total_mEr_e ) ); // Q16 + hStereoClassif->unclr_fv_fx[E_cohSNR] = Mpy_32_32( 41943040 /*20 in Q21*/, BASOP_Util_Log10( total_mEr, total_mEr_e ) ); // Q15 move32(); } @@ -2473,7 +2480,7 @@ void stereo_dft_enc_compute_itd_fx( /*smooth cohSNR with time */ // if ( ( hItd->cohSNR - cohSNR ) < 10.0f ) - IF( LT_32( L_sub( hItd->cohSNR_fx, cohSNR ), 655360 ) && !NAN_flag ) + IF( LT_32( L_sub( hItd->cohSNR_fx, cohSNR ), 655360 ) ) { // tmpf1 = max( 0.05f, min( 0.25f, sfm_L * 0.5f ) ); tmpf1 = L_max( 107374182, L_min( ONE_IN_Q29, L_shr( sfm_L, 1 ) ) ); diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index bf3a28e73fef0d63d3b3931fa03307f0e6f388c7..59a8ef6b639ad310cb5a85b3b25137f9976c483c 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -6302,9 +6302,9 @@ static void ivas_masa_ext_dirac_render_sf_fx( { FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { - Scale_sig32( Cldfb_RealBuffer_fx[ch][slot_idx], + scale_sig32( Cldfb_RealBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( 11, q_cldfb ) ); - Scale_sig32( Cldfb_ImagBuffer_fx[ch][slot_idx], + scale_sig32( Cldfb_ImagBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( 11, q_cldfb ) ); } } @@ -6425,21 +6425,32 @@ static void ivas_masa_ext_dirac_render_sf_fx( Word16 outchannels; Word32 *RealBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; Word32 *ImagBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; + Word16 scale_factor = 31; + move16(); FOR( ch = 0; ch < hDirACRend->num_outputs_dir; ch++ ) { FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { - Scale_sig32( Cldfb_RealBuffer_fx[ch][slot_idx], - hSpatParamRendCom->num_freq_bands, sub( 10, q_cldfb ) ); - Scale_sig32( Cldfb_ImagBuffer_fx[ch][slot_idx], - hSpatParamRendCom->num_freq_bands, sub( 10, q_cldfb ) ); + scale_factor = s_min( scale_factor, getScaleFactor32( Cldfb_RealBuffer_fx[ch][slot_idx], + hSpatParamRendCom->num_freq_bands ) ); + scale_factor = s_min( scale_factor, getScaleFactor32( Cldfb_ImagBuffer_fx[ch][slot_idx], + hSpatParamRendCom->num_freq_bands ) ); } } - q_cldfb = 10; - move16(); - hMasaExtRend->cldfbSynRend[0]->Q_cldfb_state = q_cldfb; - move16(); + scale_factor = sub( scale_factor, 3 ); // guard bits + + FOR( ch = 0; ch < hDirACRend->num_outputs_dir; ch++ ) + { + FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + { + scale_sig32( Cldfb_RealBuffer_fx[ch][slot_idx], + hSpatParamRendCom->num_freq_bands, scale_factor ); + scale_sig32( Cldfb_ImagBuffer_fx[ch][slot_idx], + hSpatParamRendCom->num_freq_bands, scale_factor ); + } + } + q_cldfb = add( q_cldfb, scale_factor ); idx_in = 0; move16(); @@ -6465,19 +6476,21 @@ static void ivas_masa_ext_dirac_render_sf_fx( ELSE { /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ - + Word16 q_out = sub( q_cldfb, 1 ); + scale_sig32( hMasaExtRend->cldfbSynRend[idx_in]->cldfb_state_fx, hMasaExtRend->cldfbSynRend[idx_in]->cldfb_state_length, sub( q_out, hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state ) ); + hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state = q_out; + move16(); FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) { RealBuffer_fx[i] = Cldfb_RealBuffer_fx[idx_in][i]; ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[idx_in][i]; } - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx], hMasaExtRend->cldfbSynRend[idx_in] ); + Word16 out_size = imult1616( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, hMasaExtRend->cldfbSynRend[idx_in] ); + scale_sig32( &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, sub( 11, q_out ) ); idx_in++; } } - - hMasaExtRend->cldfbSynRend[0]->Q_cldfb_state = sub( q_cldfb, 1 ); - move16(); } hSpatParamRendCom->slots_rendered = add( hSpatParamRendCom->subframe_nbslots[subframe_idx], hSpatParamRendCom->slots_rendered ); move16();