From d6209c76aa5081da3da6bc7433163eddfa06342d Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 20 Mar 2024 08:42:07 +0530 Subject: [PATCH] EVS JBM dec conformance fixes [x] 97 differences observed with EVS JBM dec test. Fix made and differences resolved. [x] JBM decode test still showing FAILED, logs analysis in progress. --- apps/decoder.c | 3 +- lib_com/swb_bwe_com_fx.c | 4 + lib_dec/acelp_core_dec_fx.c | 2 +- lib_dec/amr_wb_dec_fx.c | 2 +- lib_dec/cng_dec_fx.c | 4 +- lib_dec/core_switching_dec_fx.c | 38 +- lib_dec/evs_dec_fx.c | 2 +- lib_dec/hq_core_dec_fx.c | 12 +- lib_dec/hq_hr_dec_fx.c | 8 +- lib_dec/init_dec_fx.c | 6 +- lib_dec/ivas_core_dec.c | 2 +- lib_dec/ivas_jbm_dec.c | 6 +- lib_dec/jbm_pcmdsp_apa.c | 406 +++++++++++++++++++++- lib_dec/jbm_pcmdsp_similarityestimation.c | 63 +++- lib_dec/jbm_pcmdsp_similarityestimation.h | 9 +- lib_dec/jbm_pcmdsp_window.c | 29 +- lib_dec/jbm_pcmdsp_window.h | 4 +- lib_dec/lib_dec_fx.c | 7 + lib_dec/stat_dec.h | 6 +- lib_dec/swb_bwe_dec_fx.c | 4 +- lib_dec/swb_bwe_dec_hr_fx.c | 8 +- lib_dec/swb_tbe_dec_fx.c | 6 +- lib_dec/updt_dec_fx.c | 4 +- lib_rend/ivas_prot_rend.h | 7 + 24 files changed, 561 insertions(+), 81 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 0c57e2e4b..4ceb112ff 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2461,12 +2461,13 @@ static ivas_error decodeVoIP( } } + frame++; if ( !arg.quietModeEnabled ) { fprintf( stdout, "%-8d\b\b\b\b\b\b\b\b", frame ); } vec_pos_update = ( vec_pos_update + 1 ) % vec_pos_len; - frame++; + //frame++; systemTime_ms += systemTimeInc_ms; #ifdef WMOPS #ifndef DONT_COUNT diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index fde86c0bb..fc2bb1c34 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -1544,11 +1544,15 @@ void SWB_BWE_decoding_fx( exp = norm_s(SWB_FENV); tmp = div_s(shl(1,sub(14,exp)),SWB_FENV); /*Q(29-exp) */ L_tmp = Mult_32_16(L_energy,tmp); /*Q(1+29-exp+1)->Q(15-exp) */ +#ifdef EVS_FLOAT #ifdef BASOP_NOGLOB EnergyL_16 = round_fx_sat(L_shl_sat(L_tmp, add(exp, 4))); /* Q3 */ #else Energy_16 = round_fx(L_shl(L_tmp,add(exp,4))); /*Q3 */ #endif +#else + Energy_16 = round_fx(L_shl(L_tmp, add(exp, 4))); /*Q3 */ +#endif // EVS_FLOAT IF(NE_16(last_extl, SWB_BWE) && NE_16(last_extl,FB_BWE)) { diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 428a19628..6969b891d 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -611,7 +611,7 @@ ivas_error acelp_core_dec_fx( } #endif /* comfort noise generation */ - CNG_exc_fx( st_fx->core_brate, st_fx->L_frame, &st_fx->hTdCngDec->Enew_fx, &st_fx->hTdCngDec->cng_seed_fx, exc_fx, exc2_fx, &st_fx->lp_ener_fx, st_fx->last_core_brate, + CNG_exc_fx( st_fx->core_brate, st_fx->L_frame, &st_fx->hTdCngDec->Enew_fx, &st_fx->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st_fx->lp_ener_fx, st_fx->last_core_brate, &st_fx->first_CNG, &(st_fx->hTdCngDec->cng_ener_seed_fx), bwe_exc_fx, allow_cn_step_fx, &st_fx->hTdCngDec->last_allow_cn_step_fx, st_fx->prev_Q_exc, st_fx->Q_exc, st_fx->hTdCngDec->num_ho_fx, q_env, st_fx->hTdCngDec->lp_env_fx, st_fx->hTdCngDec->old_env_fx, st_fx->hTdCngDec->exc_mem_fx, st_fx->hTdCngDec->exc_mem1_fx, sid_bw, &st_fx->hTdCngDec->cng_ener_seed1_fx, exc3_fx ,st_fx->Opt_AMR_WB, st_fx->element_mode ); #if 1//def IVAS_CODE diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index f57912ba8..a9f43dee2 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -366,7 +366,7 @@ ivas_error amr_wb_dec_fx( CNG_dec_fx( st_fx, EVS_MONO, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, &sid_bw, q_env ); /* comfort noise generation */ - CNG_exc_fx( st_fx->core_brate, L_FRAME, &st_fx->hTdCngDec->Enew_fx, &st_fx->hTdCngDec->cng_seed_fx, exc_fx, exc2_fx, &st_fx->lp_ener_fx, st_fx->last_core_brate, + CNG_exc_fx( st_fx->core_brate, L_FRAME, &st_fx->hTdCngDec->Enew_fx, &st_fx->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st_fx->lp_ener_fx, st_fx->last_core_brate, &st_fx->first_CNG, &st_fx->hTdCngDec->cng_ener_seed_fx, dummy_buf_fx, allow_cn_step, &st_fx->hTdCngDec->last_allow_cn_step_fx, st_fx->prev_Q_exc, st_fx->Q_exc , st_fx->hTdCngDec->num_ho_fx, q_env, st_fx->hTdCngDec->lp_env_fx, st_fx->hTdCngDec->old_env_fx, st_fx->hTdCngDec->exc_mem_fx, st_fx->hTdCngDec->exc_mem1_fx, &sid_bw, &st_fx->hTdCngDec->cng_ener_seed1_fx, exc3, st_fx->Opt_AMR_WB, st_fx->element_mode); diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index 33f8ed1ac..29c4a92a3 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -929,7 +929,7 @@ static void shb_CNG_decod_fx( /* generate white noise excitation */ FOR ( i=0; iswb_cng_seed_fx), 8); + excTmp_fx[i] = shr_r(Random(&st_fx->swb_cng_seed), 8); move16();/*Q-8*/ } @@ -1319,7 +1319,7 @@ void td_cng_dec_init( hTdCngDec = st->hTdCngDec; - hTdCngDec->cng_seed_fx = RANDOM_INITSEED; move16(); + hTdCngDec->cng_seed = RANDOM_INITSEED; move16(); hTdCngDec->cng_ener_seed_fx = RANDOM_INITSEED; move16(); hTdCngDec->cng_ener_seed1_fx = RANDOM_INITSEED; move16(); hTdCngDec->old_enr_index_fx = -1; move16(); diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 8bc519645..0c3851a33 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -28,8 +28,8 @@ void bandwidth_switching_detect_fx( { /* there is no BWE in TD stereo secondary channel and in MDCT stereo, IGF is part of the core decoding -> no BW switching -> reset BWS counters */ st_fx->prev_bws_cnt = 0; - st_fx->prev_bws_cnt = 0; - st_fx->bws_cnt1_fx = 0; + st_fx->bws_cnt = 0; + st_fx->bws_cnt1 = 0; move16(); move16(); move16(); return; @@ -38,22 +38,22 @@ void bandwidth_switching_detect_fx( test(); test(); test(); - IF( GE_16(st_fx->bws_cnt1_fx, N_NS2W_FRAMES)) + IF( GE_16(st_fx->bws_cnt1, N_NS2W_FRAMES)) { - st_fx->bws_cnt1_fx = 0; + st_fx->bws_cnt1 = 0; move16(); } ELSE IF( GT_32(st_fx->total_brate, ACELP_9k60)&<_32(st_fx->last_core_brate,ACELP_9k60) && EQ_16(st_fx->bwidth, SWB) && EQ_16(st_fx->last_bwidth, WB) ) { - st_fx->bws_cnt1_fx = add(st_fx->bws_cnt1_fx,1); + st_fx->bws_cnt1 = add(st_fx->bws_cnt1,1); move16(); } - ELSE IF( st_fx->bws_cnt1_fx > 0 ) + ELSE IF( st_fx->bws_cnt1 > 0 ) { IF( LT_16(st_fx->bwidth, st_fx->last_bwidth)) { - st_fx->bws_cnt = sub( shl(sub(N_NS2W_FRAMES, st_fx->bws_cnt1_fx), 1), 1 ); + st_fx->bws_cnt = sub( shl(sub(N_NS2W_FRAMES, st_fx->bws_cnt1), 1), 1 ); move16(); } ELSE @@ -64,19 +64,19 @@ void bandwidth_switching_detect_fx( IF( LT_16(st_fx->bwidth, st_fx->last_bwidth)) { - st_fx->bws_cnt1_fx = 0; + st_fx->bws_cnt1 = 0; move16(); } ELSE { IF(EQ_16(st_fx->bwidth, SWB)) { - st_fx->bws_cnt1_fx = add(st_fx->bws_cnt1_fx,1); + st_fx->bws_cnt1 = add(st_fx->bws_cnt1,1); move16(); } ELSE { - st_fx->bws_cnt1_fx = 0; + st_fx->bws_cnt1 = 0; move16(); } } @@ -86,45 +86,45 @@ void bandwidth_switching_detect_fx( test(); test(); test(); - IF( GE_16(st_fx->prev_bws_cnt, N_WS2N_FRAMES)) + IF( GE_16(st_fx->bws_cnt, N_WS2N_FRAMES)) { - st_fx->prev_bws_cnt = 0; + st_fx->bws_cnt = 0; move16(); } ELSE IF( LT_32(st_fx->total_brate, ACELP_9k60)&>_32(st_fx->last_core_brate,ACELP_9k60) && LT_16(st_fx->bwidth, st_fx->last_bwidth) && EQ_16(st_fx->bwidth, WB) ) { - st_fx->prev_bws_cnt = add(st_fx->prev_bws_cnt,1); + st_fx->bws_cnt = add(st_fx->bws_cnt,1); move16(); } - ELSE IF( st_fx->prev_bws_cnt > 0 ) + ELSE IF( st_fx->bws_cnt > 0 ) { IF( GT_16(st_fx->bwidth, st_fx->last_bwidth)) { - st_fx->bws_cnt1_fx = shr(sub(N_WS2N_FRAMES, st_fx->prev_bws_cnt), 1); + st_fx->bws_cnt1 = shr(sub(N_WS2N_FRAMES, st_fx->bws_cnt), 1); move16(); } ELSE { - st_fx->bws_cnt1_fx = 0; + st_fx->bws_cnt1 = 0; move16(); } IF( GT_16(st_fx->bwidth, st_fx->last_bwidth)) { - st_fx->prev_bws_cnt = 0; + st_fx->bws_cnt = 0; move16(); } ELSE { IF( EQ_16(st_fx->bwidth, WB)) { - st_fx->prev_bws_cnt = add(st_fx->prev_bws_cnt,1); + st_fx->bws_cnt = add(st_fx->bws_cnt,1); move16(); } ELSE { - st_fx->prev_bws_cnt = 0; + st_fx->bws_cnt = 0; move16(); } } diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 298d7886a..117c0eaba 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -873,7 +873,7 @@ ivas_error evs_dec_fx( st_fx->bws_cnt = 0; move16(); - st_fx->bws_cnt1_fx = 0; + st_fx->bws_cnt1 = 0; move16(); st_fx->tilt_wb_fx = 0; move16(); diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index ecd20bf4c..a7a3f7a14 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -271,16 +271,16 @@ void hq_core_dec_fx( * Attenuate HFs in case of band-width switching (from higher BW to lower BW) *--------------------------------------------------------------------------*/ /* attenuate HFs in case of band-width switching */ - IF( st_fx->bws_cnt1_fx > 0 ) + IF( st_fx->bws_cnt1 > 0 ) { - IF( EQ_16(st_fx->bws_cnt1_fx,N_NS2W_FRAMES)) + IF( EQ_16(st_fx->bws_cnt1,N_NS2W_FRAMES)) { ener_match = 32767; move16(); /*Q15*/ } ELSE { - ener_match = div_s(st_fx->bws_cnt1_fx,N_NS2W_FRAMES); /*Q15*/ + ener_match = div_s(st_fx->bws_cnt1,N_NS2W_FRAMES); /*Q15*/ } IF( is_transient ) @@ -859,16 +859,16 @@ void ivas_hq_core_dec_fx( * Attenuate HFs in case of band-width switching (from higher BW to lower BW) *--------------------------------------------------------------------------*/ /* attenuate HFs in case of band-width switching */ - IF( GT_16( st_fx->bws_cnt1_fx, 0 ) ) + IF( GT_16( st_fx->bws_cnt1, 0 ) ) { - IF( EQ_16( st_fx->bws_cnt1_fx, N_NS2W_FRAMES ) ) + IF( EQ_16( st_fx->bws_cnt1, N_NS2W_FRAMES ) ) { ener_match = 32767; move16(); /*Q15*/ } ELSE { - ener_match = div_s( st_fx->bws_cnt1_fx, N_NS2W_FRAMES ); /*Q15*/ + ener_match = div_s( st_fx->bws_cnt1, N_NS2W_FRAMES ); /*Q15*/ } IF( is_transient ) diff --git a/lib_dec/hq_hr_dec_fx.c b/lib_dec/hq_hr_dec_fx.c index 06b1d056a..5511a70e8 100644 --- a/lib_dec/hq_hr_dec_fx.c +++ b/lib_dec/hq_hr_dec_fx.c @@ -296,9 +296,9 @@ void ivas_hq_hr_dec_fx( test(); test(); - IF( EQ_16( *hqswb_clas, HQ_GEN_SWB ) && GT_16(st_fx->bws_cnt1_fx, 0) && LT_32( st_fx->core_brate, HQ_32k ) ) + IF( EQ_16( *hqswb_clas, HQ_GEN_SWB ) && GT_16(st_fx->bws_cnt1, 0) && LT_32( st_fx->core_brate, HQ_32k ) ) { - tmp = i_mult( st_fx->bws_cnt1_fx, 1638 ); + tmp = i_mult( st_fx->bws_cnt1, 1638 ); move16(); IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { @@ -561,9 +561,9 @@ void hq_hr_dec_fx( test(); test(); - IF( EQ_16(*hqswb_clas, HQ_GEN_SWB) && st_fx->bws_cnt1_fx>0 && LT_32(st_fx->core_brate,HQ_32k)) + IF( EQ_16(*hqswb_clas, HQ_GEN_SWB) && st_fx->bws_cnt1>0 && LT_32(st_fx->core_brate,HQ_32k)) { - tmp = i_mult(st_fx->bws_cnt1_fx, 1638); + tmp = i_mult(st_fx->bws_cnt1, 1638); move16(); IF( EQ_16(st_fx->L_frame, L_FRAME16k)) { diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 01f371f4a..241327fa2 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -369,7 +369,7 @@ ivas_error init_decoder_fx( move16(); st_fx->last_shb_cng_ener_fx = -1541; move16(); - st_fx->swb_cng_seed_fx = RANDOM_INITSEED; + st_fx->swb_cng_seed = RANDOM_INITSEED; move16(); st_fx->CNG_mode = -1; @@ -549,7 +549,7 @@ ivas_error init_decoder_fx( move16(); st_fx->bws_cnt = N_WS2N_FRAMES; move16(); - st_fx->bws_cnt1_fx = N_NS2W_FRAMES; + st_fx->bws_cnt1 = N_NS2W_FRAMES; move16(); st_fx->attenu_fx = 3277; move16(); @@ -1486,7 +1486,7 @@ ivas_error init_decoder_ivas_fx( move16(); st_fx->bws_cnt = N_WS2N_FRAMES; move16(); - st_fx->bws_cnt1_fx = N_NS2W_FRAMES; + st_fx->bws_cnt1 = N_NS2W_FRAMES; move16(); st_fx->attenu_fx = 3277; move16(); diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index d64bf3ac5..20e29db41 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -1659,7 +1659,7 @@ ivas_error ivas_core_dec( st->hBWE_FD->prev_SWB_fenv_fx[i] = (Word16)(st->hBWE_FD->prev_SWB_fenv[i] * (1 << 1)); st->bws_cnt = st->bws_cnt; - st->bws_cnt1_fx = st->bws_cnt1; + st->bws_cnt1 = st->bws_cnt1; st->hBWE_FD->prev_mode_fx = st->hBWE_FD->prev_mode; st->hBWE_FD->prev_Energy_fx = (Word16)(st->hBWE_FD->prev_Energy * (1 << 3)); st->hBWE_FD->prev_L_swb_norm_fx = st->hBWE_FD->prev_L_swb_norm; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index d409451ab..939afbe52 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -849,9 +849,9 @@ ivas_error ivas_jbm_dec_tc( { Word16 q; float l_hb_nrg = 0.0, l_hb_nrg_subr = 0.0; - static int frame_counter = 0; - if ( frame_counter >= 200 ) - frame_counter = frame_counter; + //static int frame_counter = 0; + //if ( frame_counter >= 200 ) + // frame_counter = frame_counter; float max_val = 0.0; int i_max_val_psd, i_max_val_op; CPE_DEC_HANDLE hCPE = st_ivas->hCPE[0]; diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index 6af8bba39..08bc3c363 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -50,8 +50,12 @@ #include "jbm_pcmdsp_similarityestimation.h" #include "jbm_pcmdsp_window.h" #include "cnst.h" +#include "rom_dec.h" +#ifdef IVAS_FLOAT_FIXED +#include "prot_fx2.h" +#endif /*---------------------------------------------------------------------* * Local state structure *---------------------------------------------------------------------*/ @@ -62,15 +66,20 @@ /* definition of state struct */ struct apa_state_t { + Word16 signalScaleForCorrelation; + Word16 frmInScaled[2 * 48000 / 50]; /* output buffer */ bool evs_compat_mode; float *buf_out; uint16_t buf_out_capacity; uint16_t l_buf_out; + Word16 win_incrementor; + const Word16 *win_fx; /* Hann window */ float win[APA_BUF_PER_CHANNEL]; uint16_t l_halfwin; + Word16 l_halfwin_fx; /* sampling rate [Hz] */ uint16_t rate; @@ -124,9 +133,21 @@ struct apa_state_t *---------------------------------------------------------------------*/ static float apa_corrEnergy2dB( float energy, uint16_t corr_len ); +Word16 apa_corrEnergy2dB_fx(Word32 energy, Word16 energyExp, Word16 corr_len); +Word16 apa_getQualityIncreaseForLowEnergy_fx(Word16 energydB); static float apa_getQualityIncreaseForLowEnergy( float energydB ); +static Word8 logarithmic_search_fx( const apa_state_t *ps, + const Word16 *signal, + Word16 s_start, + Word16 inlen, + Word16 offset, + Word16 fixed_pos, + Word16 corr_len, + Word16 wss, + Word16 css, + Word16 *synchpos ); static bool logarithmic_search( const apa_state_t *ps, const float *signal, int16_t s_start, uint16_t inlen, uint16_t offset, uint16_t fixed_pos, uint16_t corr_len, uint16_t wss, uint16_t css, int16_t *synchpos ); static bool find_synch( apa_state_t *ps, const float *in, uint16_t l_in, int16_t s_start, uint16_t s_len, int16_t fixed_pos, uint16_t corr_len, uint16_t offset, float *energy, float *quality, int16_t *synch_pos ); @@ -180,7 +201,10 @@ ivas_error apa_init( void apa_reset( apa_state_t *ps ) { + ps->signalScaleForCorrelation = 0; /* init state struct */ + ps->win_fx = NULL; + ps->win_incrementor = 0; ps->l_buf_out = 0; ps->l_halfwin = 0; ps->rate = 0; @@ -314,6 +338,45 @@ bool apa_set_rate( /* (the resulting maximum pitch is then p_min+l_search = 240 samples at 16 kHz) */ ps->l_search = ( ps->rate / 80 ) * ps->num_channels; +#ifndef EVS_FLOAT_FIXED + ps->win_fx = pcmdsp_window_hann_640; + move16(); + ps->l_halfwin_fx = 320; + move16(); + ps->win_incrementor = 1; + move16(); + IF( EQ_32( ps->rate, 48000 ) ) + { + ps->win_fx = pcmdsp_window_hann_960; + move16(); + ps->l_halfwin_fx = 480; + move16(); + } + IF( EQ_32( ps->rate, 24000 ) ) + { + ps->win_fx = pcmdsp_window_hann_960; + move16(); + ps->l_halfwin_fx = 480; + move16(); + ps->win_incrementor = 2; + move16(); + } + /* sample rates 8k, 16k & 32k use a Hann window of length of 640, + * where 8k and 16k subsample */ + if ( EQ_32( ps->rate, 16000 ) ) + ps->win_incrementor = 2; + move16(); + if ( EQ_32( ps->rate, 8000 ) ) + ps->win_incrementor = 4; + move16(); + + /* set minimum pitch */ + /* set to 40 samples at 16 kHz */ + /* (defines min change in number of samples, i.e., abs(l_in-l_out) >= p_min) */ + /* before basop port was originally: ps->p_min = (ps->rate * ps->num_channels) / 400; + * but for simplicity can be taken as l_seg / 4 */ + ps->signalScaleForCorrelation = getSignalScaleForCorrelation( ps->rate ); +#endif return 0; } @@ -848,6 +911,124 @@ static void get_scaling_quality( } +static void get_scaling_quality_fx(const apa_state_t * ps, + const Word16 * signal, + Word16 s_len, + Word16 offset, + Word16 corr_len, + Word16 pitch, + Word16 * energydBQ8, + Word32 * qualityQ16) +{ + Word32 energy, maxEnergy; + Word32 qualityOfMaxEnergy; /* we measure the quality for all channels and select the one with highest energy */ + Word16 half_pitch_cn; + Word16 pitch_cn; + Word16 three_halves_pitch_cn; + Word16 double_pitch_cn; + Word32 pitch_energy; + Word32 half_pitch_energy; + Word32 three_halves_pitch_energy; + Word32 double_pitch_energy; + Word16 i; + + + maxEnergy = L_deposit_l(0); + qualityOfMaxEnergy = L_deposit_l(0); + + FOR(i = 0; i < ps->num_channels; i++) + { + offset = 0; + move16(); + + pitch_cn = normalized_cross_correlation_self_fx(signal, add(pitch, offset), offset, corr_len, + shl(ps->num_channels, 1), &pitch_energy); + IF(pitch_cn > 0) + { + /* calculate correlation for double pitch */ + IF(LE_16(add(add(shl(pitch, 1), offset), corr_len), s_len)) + { + double_pitch_cn = normalized_cross_correlation_self_fx(signal, add(shl(pitch, 1), offset), + offset, corr_len, shl(ps->num_channels, 1), &double_pitch_energy); + } + ELSE + { + double_pitch_cn = pitch_cn; + move16(); + double_pitch_energy = L_add(pitch_energy, 0); + } + /* calculate correlation for three/half pitch */ + IF(LE_16(add(add(shr(i_mult2(pitch, 3), 1), offset), corr_len), s_len)) + { + three_halves_pitch_cn = normalized_cross_correlation_self_fx(signal, add(shr(i_mult2(pitch, 3), 1), + offset), offset, corr_len, shl(ps->num_channels, 1), &three_halves_pitch_energy); + } + ELSE + { + three_halves_pitch_cn = pitch_cn; + move16(); + three_halves_pitch_energy = L_add(pitch_energy, 0); + } + /* calculate correlation for half pitch */ + IF(LE_16(add(add(shr(pitch, 1), offset), corr_len), s_len)) + { + half_pitch_cn = normalized_cross_correlation_self_fx(signal, add(shr(pitch, 1), offset), + offset, corr_len, shl(ps->num_channels, 1), &half_pitch_energy); + } + ELSE + { + half_pitch_cn = pitch_cn; + move16(); + half_pitch_energy = L_add(pitch_energy, 0); + } + + /* combine correlation results: Q15.16 */ + *qualityQ16 = L_shr(L_mac0(L_mult0(half_pitch_cn, three_halves_pitch_cn), + pitch_cn, double_pitch_cn), 14); + BASOP_SATURATE_WARNING_OFF_EVS + energy = L_add(L_add(L_add(pitch_energy, half_pitch_energy), three_halves_pitch_energy), double_pitch_energy); + BASOP_SATURATE_WARNING_ON_EVS + } + ELSE + { + *qualityQ16 = L_shl(L_deposit_l(pitch_cn), 1); /* value is negative, thus pass it */ + energy = L_add(pitch_energy, 0); + } + + /* update the quality by the quality of the signal with the highest energy */ + IF(GT_32(energy, maxEnergy)) + { + qualityOfMaxEnergy = L_add(*qualityQ16, 0); + maxEnergy = L_add(energy, 0); + } + + /* go to next channel */ + ++signal; + } + *qualityQ16 = qualityOfMaxEnergy; + move32(); + + /* increase calculated quality of signals with low energy */ + *energydBQ8 = apa_corrEnergy2dB_fx(maxEnergy, shl(ps->signalScaleForCorrelation, 1), corr_len); + *qualityQ16 = L_add(*qualityQ16, L_shl(L_deposit_l(apa_getQualityIncreaseForLowEnergy_fx(*energydBQ8)), 8)); +} + Word16 apa_corrEnergy2dB_fx(Word32 energy, Word16 energyExp, Word16 corr_len) + { + + Word16 result, tmpScale; + + /* normalise before dividing */ + tmpScale = norm_l(energy); + energy = L_shl(energy, tmpScale); + energyExp = sub(energyExp, tmpScale); + + /* divide energy by corr_len */ + result = BASOP_Util_Divide3216_Scale(energy, corr_len, &tmpScale); + energyExp = add(energyExp, tmpScale); + + result = BASOP_Util_lin2dB(L_deposit_l(result), energyExp, 1); + return result; + } /* Converts the correlation energy to dB. */ static float apa_corrEnergy2dB( float energy, @@ -886,6 +1067,44 @@ static float apa_getQualityIncreaseForLowEnergy( return qualIncForLowEnergy; } +Word16 apa_getQualityIncreaseForLowEnergy_fx(Word16 energydBQ8) +{ + Word16 qualIncreaseMinEnergy, qualIncreaseMaxEnergy, qualIncForLowEnergy; /* Q8 */ + + qualIncreaseMinEnergy = -65 * (1 << 8); + move16(); + qualIncreaseMaxEnergy = -40 * (1 << 8); + move16(); + qualIncForLowEnergy = 0; + move16(); + + /* increase calculated quality of signals with low energy */ + IF(LT_16(energydBQ8, qualIncreaseMaxEnergy)) + { + qualIncForLowEnergy = energydBQ8; + move16(); + if (LT_16(qualIncForLowEnergy, qualIncreaseMinEnergy)) + { + qualIncForLowEnergy = qualIncreaseMinEnergy; + move16(); + } + if (GT_16(qualIncForLowEnergy, qualIncreaseMaxEnergy)) + { + qualIncForLowEnergy = qualIncreaseMaxEnergy; + move16(); + } + /* -50: (-50 - -40) / (-65 - -40) * 20 + * = -10 / -25 * 20 + */ + qualIncForLowEnergy = divide1616(sub(qualIncForLowEnergy, qualIncreaseMaxEnergy), + sub(qualIncreaseMinEnergy, qualIncreaseMaxEnergy)); + /* apply factor 2 and scale back to Q8 */ + assert(qualIncForLowEnergy >= 0); + qualIncForLowEnergy = shr(qualIncForLowEnergy, 7 - 1); + assert(qualIncForLowEnergy >= 0 && qualIncForLowEnergy <= (2 << 8)); + } + return qualIncForLowEnergy; +} /* ******************************************************************************** @@ -980,6 +1199,90 @@ static bool logarithmic_search( } +static Word8 logarithmic_search_fx(const apa_state_t * ps, + const Word16 * signal, + Word16 s_start, + Word16 inlen, + Word16 offset, + Word16 fixed_pos, + Word16 corr_len, + Word16 wss, + Word16 css, + Word16 * synchpos) +{ + Word16 i; + Word32 coeff; + Word32 coeff_max; + Word16 s_start_old, s_len_old; + + DO + { + coeff_max = 0x80000000; /* will always be overwritten with result of first correlation */ move32(); + + FOR(i = s_start; i < s_start + inlen; i += css) + { + test(); + IF(EQ_16(wss,1) && EQ_16(ps->num_channels,1)) + { + coeff = cross_correlation_self_fx(signal, add(i, offset), add(fixed_pos, offset), corr_len); + } + ELSE + { + coeff = cross_correlation_subsampled_self_fx(signal, add(i, offset), add(fixed_pos, offset), + corr_len, i_mult2(wss, ps->num_channels)); + } + + /* update max corr */ + IF(LT_16(ps->scale, 100)) + { + /* shrinking: prefer greater synchpos for equal coeff */ + BASOP_SATURATE_WARNING_OFF_EVS + IF(GE_32(coeff, coeff_max)) + { + coeff_max = L_add(coeff, 0); + *synchpos = i; + move16(); + } + BASOP_SATURATE_WARNING_ON_EVS + } + ELSE + { + /* extending: prefer smaller synchpos for equal coeff */ + BASOP_SATURATE_WARNING_OFF_EVS + IF(GT_32(coeff, coeff_max)) + { + coeff_max = L_add(coeff, 0); + *synchpos = i; + move16(); + } + BASOP_SATURATE_WARNING_ON_EVS + } + } + /* backup old search range */ + s_start_old = s_start; + move16(); + s_len_old = inlen; + move16(); + + css = shr(css, 1); + inlen = shr(inlen, 1); + s_start_old = s_start; + move16(); + s_start = sub(*synchpos, shr(inlen, 1)); + + if (LT_16(s_start,s_start_old)) + { + s_start = s_start_old; + move16(); + } + + IF(GT_16(add(s_start,inlen), add(s_start_old,s_len_old))) + { + inlen = add(sub(s_start_old, s_start), s_len_old); + } + } WHILE(GT_16(css, 2)); + return 0; +} /* ******************************************************************************** * @@ -1052,6 +1355,44 @@ static bool find_synch( return 0; } +static Word16 find_synch_fx( apa_state_t *ps, + const Word16 *in, + Word16 l_in, + Word16 s_start, + Word16 s_len, + Word16 fixed_pos, + Word16 corr_len, + Word16 offset, + Word16 *energydBQ8, + Word32 *qualityQ16, + Word16 *synch_pos ) +{ + assert( ( corr_len - 1 + s_start + s_len - 1 + offset ) < l_in ); + assert( ( corr_len - 1 + fixed_pos + offset ) < l_in ); + + /* pass last pitch to search function as prediction value */ + *synch_pos = ps->last_pitch; + move16(); + logarithmic_search_fx( ps, + in, + s_start, + s_len, + offset, + fixed_pos, + corr_len, + ps->wss, + i_mult2( ps->css, ps->num_channels ), + synch_pos ); + /* assert synch_pos is cleanly divisible by number of channels */ + assert( *synch_pos % ps->num_channels == 0 ); + + *qualityQ16 = L_deposit_l( 0 ); + get_scaling_quality_fx( ps, in, l_in, offset, corr_len, + abs_s( sub( *synch_pos, fixed_pos ) ), energydBQ8, qualityQ16 ); + ps->last_pitch = *synch_pos; + move16(); + return 0; +} /* ******************************************************************************** @@ -1144,6 +1485,13 @@ static bool shrink_frm( /* only 2nd input frame is used */ frm_in += l_frm; +#ifndef EVS_FLOAT + Word16 frm_in_fx[960]; + for ( i = 0; i < 960; i++ ) + { + frm_in_fx[i] = (Word16) frm_in[i]; + } +#endif /* set search range */ s_start = ( ps->p_min / ps->num_channels ) * ps->num_channels; s_end = s_start + ps->l_search; @@ -1153,7 +1501,11 @@ static bool shrink_frm( } /* calculate overlap position */ +#ifndef EVS_FLOAT + if ( isSilence_fx( frm_in_fx, l_seg, 10 ) ) +#else if ( isSilence( frm_in, l_seg, 10 ) ) +#endif // !IVAS_FLOAT_FIXED { /* maximum scaling */ energy = -65; @@ -1189,7 +1541,16 @@ static bool shrink_frm( else { /* find synch */ +#ifndef EVS_FLOAT + Word16 energyQ8; + Word32 qualityQ16=0; + scaleSignal16( frm_in_fx, ps->frmInScaled, l_frm, ps->signalScaleForCorrelation ); + findSynchResult = find_synch_fx( ps, ps->frmInScaled, l_frm, s_start, (uint16_t) ( s_end - s_start ), 0, l_seg, 0, &energyQ8, &qualityQ16, &xtract ); + energy = fixedToFloat( energyQ8, 8 ); + quality = fixedToFloat( qualityQ16, 16 ); +#else findSynchResult = find_synch( ps, frm_in, l_frm, s_start, (uint16_t) ( s_end - s_start ), 0, l_seg, 0, &energy, &quality, &xtract ); +#endif } /* assert synch_pos is cleanly divisible by number of channels */ @@ -1232,14 +1593,21 @@ static bool shrink_frm( { return 1; } +#ifdef EVS_FLOAT if ( ps->evs_compat_mode == true ) { overlapAddEvs( frm_in, frm_in + xtract, frm_out, l_seg, ps->num_channels, ps->win + ps->l_halfwin, ps->win ); } else { - overlapAdd( frm_in, frm_in + xtract, frm_out, l_seg, ps->num_channels, ps->win + ps->l_halfwin, ps->win ); + overlapAdd_ivas( frm_in, frm_in + xtract, frm_out, l_seg, ps->num_channels, ps->win + ps->l_halfwin, ps->win ); } +#else + Word16 frm_out_fx[960]; + overlapAdd( frm_in_fx, frm_in_fx + xtract, frm_out_fx, l_seg, ps->num_channels, ps->win_fx + ps->l_halfwin_fx, ps->win_fx , ps->win_incrementor); + for ( i = 0; i < l_seg; i++ ) + frm_out[i] = (float)frm_out_fx[i]; +#endif // EVS_FLOAT } else { @@ -1383,11 +1751,22 @@ static bool extend_frm( over[n] = 0; /* don't search/overlap (just copy down) */ } } +#ifndef EVS_FLOAT + Word16 frm_in_fx[1920]; + for ( i = 0; i < 1920; i++ ) + { + frm_in_fx[i] = (Word16) frm_in[i]; + } +#endif // !EVS_FLOAT if ( over[n] ) { /* calculate overlap position */ +#ifndef EVS_FLOAT + if ( isSilence_fx( frm_in_fx, l_seg, 10 ) ) +#else if ( isSilence( frm_in, l_seg, 10 ) ) +#endif { /* maximum scaling */ energy = -65; @@ -1403,8 +1782,19 @@ static bool extend_frm( } else { +#ifndef EVS_FLOAT + Word16 energyQ8=0,*frmInScaled; + Word32 qualityQ16=0; + frmInScaled = ps->frmInScaled; + assert( sizeof( ps->frmInScaled ) / sizeof( ps->frmInScaled[0] ) >= 2 * (size_t) l_frm ); + scaleSignal16( frm_in_fx, frmInScaled, shl(l_frm, 1), ps->signalScaleForCorrelation ); + findSynchResult = find_synch_fx( ps, frmInScaled, 2 * l_frm, s_start, s_end - s_start, sync_start, l_seg, l_frm, &energyQ8, &qualityQ16, &xtract[n] ); + energy = fixedToFloat( energyQ8, 8 ); + quality = fixedToFloat( qualityQ16, 16 ); +#else /* find synch */ findSynchResult = find_synch( ps, frm_in, 2 * l_frm, s_start, s_end - s_start, sync_start, l_seg, l_frm, &energy, &quality, &xtract[n] ); +#endif } /* assert synch_pos is cleanly divisible by number of channels */ assert( xtract[n] % ps->num_channels == 0 ); @@ -1456,14 +1846,26 @@ static bool extend_frm( fadeOut = frm_in + l_frm + xtract[n - 1] + l_seg; fadeIn = frm_in + l_frm + xtract[n]; out = frm_out + ( n - 2 ) * l_seg; +#ifdef EVS_FLOAT if ( ps->evs_compat_mode == true ) { overlapAddEvs( fadeOut, fadeIn, out, l_seg, ps->num_channels, ps->win + ps->l_halfwin, ps->win ); } else { - overlapAdd( fadeOut, fadeIn, out, l_seg, ps->num_channels, ps->win + ps->l_halfwin, ps->win ); + overlapAdd_ivas( fadeOut, fadeIn, out, l_seg, ps->num_channels, ps->win + ps->l_halfwin, ps->win ); + } +#else + Word16 fadeOut_fx[960], fadeIn_fx[960], out_fx[960]; + for ( i = 0; i < 960; i++ ) + { + fadeOut_fx[i] = (Word16) fadeOut[i]; + fadeIn_fx[i] = (Word16) fadeIn[i]; } + overlapAdd( fadeOut_fx, fadeIn_fx, out_fx, l_seg, ps->num_channels, ps->win_fx + ps->l_halfwin_fx, ps->win_fx ,ps->win_incrementor); + for ( i = 0; i < l_seg; i++ ) + out[i] = (float) out_fx[i]; +#endif // EVS_FLOAT } else { diff --git a/lib_dec/jbm_pcmdsp_similarityestimation.c b/lib_dec/jbm_pcmdsp_similarityestimation.c index 37eaf760b..852d4b789 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation.c @@ -66,6 +66,36 @@ float cross_correlation_self( return c_c; } +#ifndef EVS_FLOAT +void scaleSignal16( const Word16 *src, Word16 *dst, Word16 n, Word16 rightShift ) +{ + Word16 i; + + FOR( i = 0; i < n; i++ ) + { + dst[i] = shr_r( src[i], rightShift ); + move16(); + } +} +#endif // !EVS_FLOAT +/* Calculates cross correlation coefficient for template segment. */ +Word32 cross_correlation_subsampled_self_fx( const Word16 *signal, + Word16 x, + Word16 y, + Word16 corr_len, + Word16 subsampling ) +{ + Word32 sum; + Word16 i; + + sum = L_deposit_l( 0 ); + FOR( i = 0; i < corr_len; i += subsampling ) + { + sum = L_mac0( sum, signal[x + i], signal[y + i] ); + } + + return sum; +} /* Calculates cross correlation coefficient for template segment. */ float cross_correlation_subsampled_self( @@ -216,23 +246,6 @@ Word16 normalized_cross_correlation_self_fx(const Word16 * signal, return cc; /* Q15 */ } - -#ifdef IVAS_FLOAT_FIXED -Word32 cross_correlation_self_fx(const Word16 * signal, - Word16 x, Word16 y, Word16 corr_len) -{ - Word32 sum; - Word16 i; - - sum = L_deposit_l(0); - FOR(i = 0; i < corr_len; i++) - { - sum = L_mac0(sum, signal[x + i], signal[y + i]); - } - - return sum; -} - Word16 getSignalScaleForCorrelation(Word32 sampleRate) { Word16 ret; @@ -256,6 +269,22 @@ Word16 getSignalScaleForCorrelation(Word32 sampleRate) return ret; } +Word32 cross_correlation_self_fx(const Word16 * signal, + Word16 x, Word16 y, Word16 corr_len) +{ + Word32 sum; + Word16 i; + + sum = L_deposit_l(0); + FOR(i = 0; i < corr_len; i++) + { + sum = L_mac0(sum, signal[x + i], signal[y + i]); + } + + return sum; +} + +#ifdef IVAS_FLOAT_FIXED Word8 isSilence_fx(const Word16 * signal, Word16 len, Word16 segments) { Word16 i, j, samplesPerSegment; diff --git a/lib_dec/jbm_pcmdsp_similarityestimation.h b/lib_dec/jbm_pcmdsp_similarityestimation.h index a8e86d08d..44936fa7a 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation.h +++ b/lib_dec/jbm_pcmdsp_similarityestimation.h @@ -155,11 +155,14 @@ bool isSilence( uint32_t len, uint32_t segments ); +Word32 cross_correlation_subsampled_self_fx(const Word16 * signal, + Word16 x, Word16 y, Word16 corr_len, Word16 subsampling); + +Word16 getSignalScaleForCorrelation(Word32 sampleRate); #ifdef IVAS_FLOAT_FIXED void scaleSignal16(const Word16 *src, Word16 *dst, Word16 n, Word16 rightShift); -Word32 cross_correlation_subsampled_self_fx(const Word16 * signal, - Word16 x, Word16 y, Word16 corr_len, Word16 subsampling); +#endif /* IVAS_FLOAT_FIXED */ Word16 normalized_cross_correlation_self_fx(const Word16 * signal, Word16 x, @@ -172,9 +175,7 @@ Word16 normalized_cross_correlation_self_fx(const Word16 * signal, Word32 cross_correlation_self_fx(const Word16 * signal, Word16 x, Word16 y, Word16 corr_len); -Word16 getSignalScaleForCorrelation(Word32 sampleRate); Word8 isSilence_fx(const Word16 * signal, Word16 len, Word16 segments); -#endif /* IVAS_FLOAT_FIXED */ #endif /* JBM_PCMDSP_SIMILARITYESTIMATION_H */ diff --git a/lib_dec/jbm_pcmdsp_window.c b/lib_dec/jbm_pcmdsp_window.c index 179b7e45a..d05b11257 100644 --- a/lib_dec/jbm_pcmdsp_window.c +++ b/lib_dec/jbm_pcmdsp_window.c @@ -76,7 +76,34 @@ void hannWindow( * Overlap/Add of two signal with a given window *-----------------------------------------------------------------------*/ -void overlapAdd( +#ifndef EVS_FLOAT +void overlapAdd( const Word16 *fadeOut, const Word16 *fadeIn, Word16 *out, Word16 n, Word16 nChannels, const Word16 *fadeOutWin, const Word16 *fadeInWin, Word16 hannIncrementor ) +{ + Word32 fdOutVal, fdInVal; + Word16 i, j, hannIter, combinedVal; + + + FOR( j = 0; j < nChannels; j++ ) + { + /* reset Hann window iterator to beginning (both channels use same window) */ + hannIter = 0; + move16(); + FOR( i = j; i < n; i += nChannels ) + { + fdOutVal = L_mult( fadeOut[i], fadeOutWin[hannIter] ); + fdInVal = L_mult( fadeIn[i], fadeInWin[hannIter] ); + /* round to 16bit value and saturate (L_add already applies saturation) */ + combinedVal = round_fx( L_add( fdOutVal, fdInVal ) ); + + out[i] = combinedVal; + move16(); + /* advance the Hann window iterator by incrementor (dependent on sample rate). */ + hannIter = add( hannIter, hannIncrementor ); + } + } +} +#endif // EVS_FLOAT +void overlapAdd_ivas( const float *fadeOut, const float *fadeIn, float *out, diff --git a/lib_dec/jbm_pcmdsp_window.h b/lib_dec/jbm_pcmdsp_window.h index 28e2ba4d1..cc090b781 100644 --- a/lib_dec/jbm_pcmdsp_window.h +++ b/lib_dec/jbm_pcmdsp_window.h @@ -61,9 +61,11 @@ void hannWindow( uint16_t n, float *w ); * @param[in] nChannels number of channels * @param[in] fadeOutWin window for fade out * @param[in] fadeInWin window for fade in */ -void overlapAdd( const float *fadeOut, const float *fadeIn, float *out, uint16_t n, uint16_t nChannels, const float *fadeOutWin, const float *fadeInWin ); +void overlapAdd_ivas( const float *fadeOut, const float *fadeIn, float *out, uint16_t n, uint16_t nChannels, const float *fadeOutWin, const float *fadeInWin ); void overlapAddEvs( const float *fadeOut, const float *fadeIn, float *out, uint16_t n, uint16_t nChannels, const float *fadeOutWin, const float *fadeInWin ); +void overlapAdd(const Word16 *fadeOut, const Word16 *fadeIn, Word16 *out, + Word16 n, Word16 nChannels, const Word16 *fadeOutWin, const Word16 *fadeInWin, Word16 hannIncrementor); #ifdef IVAS_FLOAT_FIXED void overlapAdd_fx(const Word16 *fadeOut, const Word16 *fadeIn, Word16 *out, Word16 n, Word16 nChannels, const Word16 *fadeOutWin, const Word16 *fadeInWin ); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index c77f1e33e..8a626e2ed 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2218,6 +2218,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { return IVAS_ERR_UNKNOWN; } +#ifndef EVS_FLOAT + if ( GT_16( maxScaling, 20 ) ) + { + maxScaling = 20; + move16(); + } +#endif // !EVS_FLOAT maxScaling = maxScaling * hDecoderConfig->output_Fs / 1000; /* avoid time scaling multiple times in one sound card slot */ diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 2437d08d3..f60baa9e4 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -849,7 +849,7 @@ typedef struct bass_postfilt_structure typedef struct td_cng_dec_structure { int16_t cng_seed; /* DTX/CNG - seed for white noise random generator */ - Word16 cng_seed_fx; /*CNG and DTX - seed for white noise random generator*/ + // Word16 cng_seed; /*CNG and DTX - seed for white noise random generator*/ float Enew; /* DTX/CNG - decoded residual energy */ Word32 Enew_fx; /* CNG and DTX - decoded residual energy Q6*/ @@ -2305,7 +2305,7 @@ typedef struct Decoder_State // Word16 bws_cnt; int16_t bws_cnt1; - Word16 bws_cnt1_fx; + // Word16 bws_cnt1; float attenu1; Word16 attenu_fx; @@ -2371,7 +2371,7 @@ typedef struct Decoder_State Word16 wb_cng_ener_fx; Word16 last_wb_cng_ener_fx; Word16 last_shb_cng_ener_fx; - Word16 swb_cng_seed_fx; + Word16 swb_cng_seed; Word16 lsp_shb_prev_prev_fx[LPC_SHB_ORDER]; Word16 lsp_shb_prev_fx[LPC_SHB_ORDER]; Word16 shb_dtx_count_fx; diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index 6bc9406c1..06b1e6821 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -745,9 +745,9 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class */ move16();/*Q1 */ } /* in case of band-width switching, attenuate frame gain */ - IF( st_fx->bws_cnt1_fx > 0 ) + IF( st_fx->bws_cnt1 > 0 ) { - tmp = i_mult(st_fx->bws_cnt1_fx, 1638); + tmp = i_mult(st_fx->bws_cnt1, 1638); FOR(n_band = 0; n_band < SWB_TENV; n_band++) { SWB_tenv[n_band] = mult_r(SWB_tenv[n_band], tmp); diff --git a/lib_dec/swb_bwe_dec_hr_fx.c b/lib_dec/swb_bwe_dec_hr_fx.c index e84c61779..0307a5797 100644 --- a/lib_dec/swb_bwe_dec_hr_fx.c +++ b/lib_dec/swb_bwe_dec_hr_fx.c @@ -735,12 +735,12 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ len = add(len, shr(output_frame, 2)); /* attenuate HFs in case of band-width switching */ - IF( st_fx->bws_cnt1_fx > 0 ) + IF( st_fx->bws_cnt1 > 0 ) { temp = shr(output_frame, 2); temp = i_mult(k, temp); temp = add(NUM_TRANS_START_FREQ_COEF, temp); - temp2 = i_mult(st_fx->bws_cnt1_fx, 1638); /*Q15*/ + temp2 = i_mult(st_fx->bws_cnt1, 1638); /*Q15*/ j = (2*END_FREQ_BWE_FULL_FB/50)/NUM_TIME_SWITCHING_BLOCKS - NUM_TRANS_START_FREQ_COEF; move16(); @@ -1284,9 +1284,9 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ move16(); /* attenuate HFs in case of band-width switching */ - IF( st_fx->bws_cnt1_fx > 0 ) + IF( st_fx->bws_cnt1 > 0 ) { - temp = i_mult(st_fx->bws_cnt1_fx, 1638); /*Q15*/ + temp = i_mult(st_fx->bws_cnt1, 1638); /*Q15*/ j = 2*END_FREQ_BWE_FULL_FB/50 - NUM_NONTRANS_START_FREQ_COEF; move16(); diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index ecd49ce3f..115b2270b 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -2238,7 +2238,7 @@ void swb_tbe_dec_fx( test(); test(); test(); - IF( st_fx->prev_bws_cnt == 0 && st_fx->bws_cnt1_fx == 0 && st_fx->prev_use_partial_copy == 0 && st_fx->use_partial_copy == 0 ) + IF( st_fx->prev_bws_cnt == 0 && st_fx->bws_cnt1 == 0 && st_fx->prev_use_partial_copy == 0 && st_fx->use_partial_copy == 0 ) { lsf_diff[0] = 16384; move16(); /*Q15*/ @@ -2728,9 +2728,9 @@ void swb_tbe_dec_fx( } ELSE { - IF(st_fx->bws_cnt1_fx > 0) + IF(st_fx->bws_cnt1 > 0) { - GainFrame = Mult_32_16(GainFrame, i_mult(st_fx->bws_cnt1_fx, 819)); /*Q18*/ + GainFrame = Mult_32_16(GainFrame, i_mult(st_fx->bws_cnt1, 819)); /*Q18*/ } IF(GE_16(st_fx->nbLostCmpt, 1)) { diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index dd9b3c554..5839ee214 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -692,7 +692,7 @@ void updt_dec_common_fx( st_fx->prev_bws_cnt = 0; st_fx->bws_cnt = 0; - st_fx->bws_cnt1_fx = 0; + st_fx->bws_cnt1 = 0; move16();move16();move16();move16(); } @@ -713,7 +713,7 @@ void updt_dec_common_fx( test(); IF(st_fx->hTdCngDec != NULL && (st_fx->bfi || (NE_32(st_fx->core_brate, FRAME_NO_DATA) && NE_32(st_fx->core_brate, SID_2k40))) && NE_16(st_fx->core, AMR_WB_CORE)) { - Random(&(st_fx->hTdCngDec->cng_seed_fx)); + Random(&(st_fx->hTdCngDec->cng_seed)); Random(&(st_fx->hTdCngDec->cng_ener_seed_fx)); } diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index bf8c6d014..42ab48088 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -2016,6 +2016,13 @@ void QuaternionProduct( IVAS_QUATERNION *const r ); +#ifdef IVAS_FLOAT_FIXED +void QuaternionProduct_fx( + const IVAS_QUATERNION_FX q1, + const IVAS_QUATERNION_FX q2, + IVAS_QUATERNION_FX *const r); +#endif + void QuaternionInverse( const IVAS_QUATERNION q, IVAS_QUATERNION *const r -- GitLab