From db5a6410739382302a50431a7d46c301a8ce651d Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 17 Dec 2024 15:45:01 +0530 Subject: [PATCH 1/2] Q info updates, basop instrumentation updates for lib_enc --- lib_com/prot_fx.h | 2 +- lib_enc/analy_sp_fx.c | 4 +- lib_enc/core_enc_ol_fx.c | 2 +- lib_enc/core_switching_enc_fx.c | 78 +++++----- lib_enc/corr_xh_fx.c | 34 ++--- lib_enc/decision_matrix_enc_fx.c | 40 ++--- lib_enc/detect_transient_fx.c | 64 ++++---- lib_enc/diffcod_fx.c | 24 ++- lib_enc/dtx_fx.c | 246 ++++++++++++++++--------------- lib_enc/enc_prm_fx.c | 2 +- lib_enc/evs_enc_fx.c | 2 +- lib_enc/ivas_mcmasa_enc.c | 2 - lib_enc/prot_fx_enc.h | 82 +++++------ 13 files changed, 299 insertions(+), 283 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index c0a5af265..13ab9bebd 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3818,7 +3818,7 @@ detect_transient_fx.c Word16 detect_transient_fx( const Word16 *in_fx, /*Q_new */ - const Word16 L, + const Word16 L, /*Q0*/ Word16 Q_new, Encoder_State *st_fx ); diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 3cef21224..6e4a2bb4d 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -1046,7 +1046,7 @@ static void ivas_find_enr1( // *ptE *= norm_val; /* normalization - corresponds to FFT normalization by 2/L_FFT */ Ltmp = Mpy_32_32( Ltmp, norm_val ); // 2 * Qfft + te_exp - 32 - *ptE = L_shl( Ltmp, sub( add( Q_new, QSCALE - 2 ), add( shl( q_data, Q1 ), sub( te_exp, 32 ) ) ) ); // Q_new + QSCALE - 2 + *ptE = L_shl_sat( Ltmp, sub( add( Q_new, QSCALE - 2 ), add( shl( q_data, Q1 ), sub( te_exp, 32 ) ) ) ); // Q_new + QSCALE - 2 move32(); *Bin_E++ = *ptE; // Q_new + QSCALE - 2 @@ -1095,7 +1095,7 @@ static void ivas_find_enr1( // *Bin_E *= norm_val; Ltmp = Mpy_32_32( Ltmp, norm_val ); // 2 * Qfft + te_exp - 32 - *Bin_E = L_shl( Ltmp, sub( add( Q_new, QSCALE - 2 ), add( shl( q_data, Q1 ), sub( te_exp, 32 ) ) ) ); // Q_new + QSCALE - 2 + *Bin_E = L_shl_sat( Ltmp, sub( add( Q_new, QSCALE - 2 ), add( shl( q_data, Q1 ), sub( te_exp, 32 ) ) ) ); // Q_new + QSCALE - 2 move32(); band[i] = L_add_sat( band[i], *Bin_E++ ); // Q_new + QSCALE - 2 diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c index 93c3e4df5..89bd8b524 100644 --- a/lib_enc/core_enc_ol_fx.c +++ b/lib_enc/core_enc_ol_fx.c @@ -353,7 +353,7 @@ void core_encode_openloop_fx( IF( EQ_16( st->mdct_sw, MODE1 ) ) { /* Account for core signaling bits difference: bandwidth and ACELP/TCX signaling bit are replaced */ - target_bits = add( target_bits, sub( add( FrameSizeConfig[st->frame_size_index].bandwidth_bits, 1 ), signalling_mode1_tcx20_enc( st, 0 ) ) ); + target_bits = add( target_bits, sub( add( FrameSizeConfig[st->frame_size_index].bandwidth_bits, 1 ), signalling_mode1_tcx20_enc_fx( st, 0 ) ) ); } ELSE if ( EQ_16( st->mdct_sw_enable, MODE2 ) ) { diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index fe470af2d..07468363f 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -20,10 +20,10 @@ void core_switching_pre_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz */ - const Word16 *old_inp_16k, /* i : old input signal @16kHz */ - const Word16 active_cnt, /* i : active frame counter */ - const Word16 last_element_mode /* i : last_element_mode */ + const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz Qx*/ + const Word16 *old_inp_16k, /* i : old input signal @16kHz Qx*/ + const Word16 active_cnt, /* i : active frame counter Q0*/ + const Word16 last_element_mode /* i : last_element_mode Q0*/ ) { Word16 Sample_Delay_HP, Sample_Delay_LP; @@ -46,7 +46,7 @@ void core_switching_pre_enc_fx( { st_fx->mem_deemph_fx = hLPDmem->syn[M]; move16(); - Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M ); + Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M ); /*hLPDmem->q_mem_syn*/ } if ( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) @@ -102,9 +102,9 @@ void core_switching_pre_enc_fx( test(); IF( ( EQ_16( st_fx->L_frame, L_FRAME16k ) ) && ( EQ_16( st_fx->last_L_frame, L_FRAME ) ) ) { - Copy( st_fx->lsp_old_fx, st_fx->lsp_old16k_fx, M ); + Copy( st_fx->lsp_old_fx, st_fx->lsp_old16k_fx, M ); /*Q15*/ - st_fx->rate_switching_reset_16kHz = lsp_convert_poly_fx( st_fx->lsp_old16k_fx, st_fx->L_frame, 0 ); + st_fx->rate_switching_reset_16kHz = lsp_convert_poly_fx( st_fx->lsp_old16k_fx, st_fx->L_frame, 0 ); /*Q0*/ } st_fx->use_acelp_preq = 0; @@ -141,7 +141,7 @@ void core_switching_pre_enc_fx( hHQ_core->prev_stab_hfe2 = 0; move16(); - if ( hTcxEnc != NULL ) + IF( hTcxEnc != NULL ) { set16_fx( hTcxEnc->old_out_fx, 0, L_FRAME32k ); } @@ -151,7 +151,7 @@ void core_switching_pre_enc_fx( within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */ test(); test(); - IF( EQ_16( st_fx->core, ACELP_CORE ) && ( NE_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) ) ) + IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) ) ) { IF( hSC_VBR != NULL ) { @@ -167,7 +167,7 @@ void core_switching_pre_enc_fx( test(); test(); test(); - IF( EQ_16( st_fx->core, ACELP_CORE ) && ( NE_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) || LE_32( st_fx->last_total_brate, PPP_NELP_2k80 ) ) ) + IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) || LE_32( st_fx->last_total_brate, PPP_NELP_2k80 ) ) ) { st_fx->act_count = 3; move16(); @@ -177,17 +177,17 @@ void core_switching_pre_enc_fx( test(); test(); - IF( ( ( EQ_16( st_fx->core, ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) || + IF( ( ( ( st_fx->core == ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) || ( ( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( active_cnt, 1 ) ) ) { IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { - Copy( TRWB2_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */ + Copy( TRWB2_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP Qlog2(2.56)*/ lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_16k ); } ELSE { - Copy( TRWB_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */ + Copy( TRWB_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP Qlog2(2.56)*/ lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX ); } @@ -217,7 +217,7 @@ void core_switching_pre_enc_fx( move16(); set16_fx( st_fx->mem_MA_fx, 0, M ); - Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); + Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); /*Qlog2(2.56)*/ init_gp_clip_fx( st_fx->clip_var_fx ); st_fx->last_coder_type = GENERIC; move16(); @@ -231,7 +231,7 @@ void core_switching_pre_enc_fx( move16(); } - Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); + Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); /*Q6*/ set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); /* Reset old ACELP buffers */ @@ -280,7 +280,7 @@ void core_switching_pre_enc_fx( move16(); tmp16 = shr( st_fx->L_frame, 6 ); - Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); + Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); /*Q6*/ set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); /* Reset old TD BWE buffers */ @@ -337,7 +337,7 @@ void core_switching_pre_enc_fx( } Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); } - Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); + Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/ } ELSE { @@ -352,11 +352,11 @@ void core_switching_pre_enc_fx( Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); } - Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); + Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/ } tmp = sub( L_LOOK_16k + L_SUBFR16k, Sample_Delay_HP ); - Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); + Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); /*Q(Q_shb_spch)*/ add( 0, 0 ); IF( NE_16( st_fx->last_extl, WB_BWE ) ) @@ -367,8 +367,8 @@ void core_switching_pre_enc_fx( move16(); } hBWE_FD->EnergyLF_fx = L_deposit_l( 0 ); - hBWE_FD->prev_L_swb_norm1 = 8; - move16(); /*8.0 in Q0 */ + hBWE_FD->prev_L_swb_norm1 = 8; /*8.0 in Q0 */ + move16(); st_fx->EnergyLT_fx_exp = 30; move16(); /* Set to a High Exponent so it is 1^-30 */ } @@ -428,7 +428,7 @@ void core_switching_post_enc_fx( test(); test(); - IF( ( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) && EQ_16( st_fx->element_mode, EVS_MONO ) ) /* core switching ==> CELP subframe encoding */ + IF( ( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) && EQ_16( st_fx->element_mode, EVS_MONO ) ) /* core switching ==> CELP subframe encoding */ { acelp_core_switch_enc_fx( st_fx, old_inp_12k8 + L_INP_MEM - NS2SA_FX2( INT_FS_FX, ACELP_LOOK_NS ), old_inp_16k + L_INP_MEM - NS2SA_FX2( INT_FS_16k, ACELP_LOOK_NS ), A, Qshift, Q_new ); @@ -513,8 +513,8 @@ void core_switching_post_enc_fx( set16_fx( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); set16_fx( hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER ); set16_fx( hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); - hBWE_TD->gain_prec_swb_fx = 16384; - move16(); /*Q14 = 1 */ + hBWE_TD->gain_prec_swb_fx = 16384; /*Q14 = 1 */ + move16(); } ELSE IF( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) { @@ -522,6 +522,8 @@ void core_switching_post_enc_fx( } test(); test(); + test(); + test(); IF( EQ_16( st_fx->extl, FB_TBE ) && ( ( NE_16( st_fx->last_extl, FB_TBE ) && NE_16( st_fx->last_core, TCX_20_CORE ) && NE_16( st_fx->last_core, TCX_10_CORE ) ) || NE_16( st_fx->L_frame, st_fx->last_L_frame ) ) ) { set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); @@ -551,10 +553,10 @@ void core_switching_post_enc_fx( void core_switching_hq_prepare_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *num_bits, /* i/o: bit budget update */ - const Word16 input_frame, /* i : frame length */ + Word16 *num_bits, /* i/o: bit budget update Q0*/ + const Word16 input_frame, /* i : frame length Q0*/ Word32 *wtda_audio, /* shall be q_audio + 15, audio allready scalled in wtda function */ - const Word16 *audio ) + const Word16 *audio /*q_audio*/ ) { Word16 delta, Loverlapp, i; Word16 tmp16; @@ -568,22 +570,22 @@ void core_switching_hq_prepare_enc_fx( case L_FRAME8k: delta = 1; move16(); - pt_cos = sin_switch_8; + pt_cos = sin_switch_8; /*Q15*/ BREAK; case L_FRAME16k: delta = 2; move16(); - pt_cos = sin_switch_16; + pt_cos = sin_switch_16; /*Q15*/ BREAK; case L_FRAME32k: delta = 4; move16(); - pt_cos = sin_switch_32; + pt_cos = sin_switch_32; /*Q15*/ BREAK; default: delta = 6; move16(); - pt_cos = sin_switch_48; + pt_cos = sin_switch_48; /*Q15*/ BREAK; } @@ -642,25 +644,25 @@ void core_switching_hq_prepare_enc_fx( } /* Transition window at the encoder */ - n = i_mult2( N_ZERO_8, delta ); - Loverlapp = i_mult2( SWITCH_OVERLAP_8k, delta ); + n = i_mult2( N_ZERO_8, delta ); /*Q0*/ + Loverlapp = i_mult2( SWITCH_OVERLAP_8k, delta ); /*Q0*/ /*Overflow=0; */ - pt_32 = wtda_audio + shr( input_frame, 1 ); - pt_16 = audio + sub( n, 1 ); + pt_32 = wtda_audio + shr( input_frame, 1 ); /*q_audio+15*/ + pt_16 = audio + sub( n, 1 ); /*q_audio*/ tmp16 = sub( shr( input_frame, 1 ), Loverlapp ); FOR( i = 0; i < tmp16; i++ ) { /* wtda_audio[i+input_frame/2] = - audio[n-i-1]; */ - *pt_32++ = L_negate( L_shr( L_deposit_h( *pt_16-- ), 1 ) ); /* Q +16 -1 */ + *pt_32++ = L_negate( L_shr( L_deposit_h( *pt_16-- ), 1 ) ); /*q_audio+15*/ } - pt_cos = pt_cos + Loverlapp - 1; + pt_cos = pt_cos + Loverlapp - 1; /*Q15*/ FOR( i = tmp16; i < shr( input_frame, 1 ); i++ ) { /* *pt_32++ = - audio[n-i-1] *(float)cos((i+1-input_frame/2+Loverlapp)*EVS_PI/(2*(Loverlapp+1))); win=cos() */ - *pt_32++ = L_negate( L_mult0( *pt_16--, *pt_cos-- ) ); + *pt_32++ = L_negate( L_mult0( *pt_16--, *pt_cos-- ) ); /*q_audio+15*/ } IF( hTcxEnc != NULL ) diff --git a/lib_enc/corr_xh_fx.c b/lib_enc/corr_xh_fx.c index 5a4eeb528..8a1c8c483 100644 --- a/lib_enc/corr_xh_fx.c +++ b/lib_enc/corr_xh_fx.c @@ -24,9 +24,9 @@ * y[i]=sum(j=i,l-1) x[j]*h[j-i], i=0,l-1 *-------------------------------------------------------------------*/ void corr_xh_fx( - const Word16 x[], /* i : target signal */ - Word16 dn[], /* o : correlation between x[] and h[] */ - const Word16 h[] /* i : impulse response (of weighted synthesis filter) */ + const Word16 x[], /* i : target signal Qx*/ + Word16 dn[], /* o : correlation between x[] and h[] Qdn = Qx+j-1*/ + const Word16 h[] /* i : impulse response (of weighted synthesis filter) Q14*/ ) { Word16 i, j, k; @@ -44,20 +44,20 @@ void corr_xh_fx( L_maxloc = L_deposit_l( 0 ); FOR( i = k; i < L_SUBFR; i += STEP ) { - L_tmp = L_mac( 1L, x[i], h[0] ); /* 1 -> to avoid null dn[] */ + L_tmp = L_mac( 1L, x[i], h[0] ); /* 1 -> to avoid null dn[] Qx+15*/ FOR( j = i; j < L_SUBFR - 1; j++ ) { #ifdef BASOP_NOGLOB - L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); + L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); /*Qx+15*/ #else L_tmp = L_mac( L_tmp, x[j + 1], h[j + 1 - i] ); #endif } - y32[i] = L_tmp; + y32[i] = L_tmp; /*Qx+15*/ move32(); L_tmp = L_abs( L_tmp ); - L_maxloc = L_max( L_tmp, L_maxloc ); + L_maxloc = L_max( L_tmp, L_maxloc ); /*Qx+15*/ } /* tot += 3*max / 8 */ L_maxloc = L_shr( L_maxloc, 2 ); @@ -77,7 +77,7 @@ void corr_xh_fx( FOR( i = 0; i < L_SUBFR; i++ ) { - dn[i] = round_fx( L_shl( y32[i], j ) ); + dn[i] = round_fx( L_shl( y32[i], j ) ); /*Qx+15+j-16*/ } return; } @@ -86,7 +86,7 @@ void corr_hh_ivas_fx( const Word16 *h, /* i : target signal e(norm_s(h1[0])+1) */ Word16 *y, /* o : correlation between x[] and h[] Q_new + 1 */ Word16 *Qy, - const Word16 L_subfr /* i : length of the subframe */ + const Word16 L_subfr /* i : length of the subframe Q0*/ ) { Word16 i, j, k; @@ -114,10 +114,10 @@ void corr_hh_ivas_fx( #endif } - y32[i] = L_tmp; + y32[i] = L_tmp; // 2*(15 - norm_s(h[0]) -3) - 1 move32(); L_tmp = L_abs( L_tmp ); - L_maxloc = L_max( L_tmp, L_maxloc ); + L_maxloc = L_max( L_tmp, L_maxloc ); // 2*(15 - norm_s(h[0]) -3) - 1 } /* tot += 3*max / 8 */ L_maxloc = L_shr( L_maxloc, 2 ); @@ -147,12 +147,12 @@ void corr_hh_ivas_fx( } void corr_xh_ivas_fx( - const Word16 x[], /* i : target signal */ + const Word16 x[], /* i : target signal Qx*/ const Word16 Qx, - Word16 dn[], /* o : correlation between x[] and h[] */ + Word16 dn[], /* o : correlation between x[] and h[] Qdn*/ Word16 *Qdn, - const Word16 h[], /* i : impulse response (of weighted synthesis filter) */ - const Word16 L_subfr /* i : length of the subframe */ + const Word16 h[], /* i : impulse response (of weighted synthesis filter) (Q15 - norm_s(h[0]))*/ + const Word16 L_subfr /* i : length of the subframe Q0*/ ) { Word16 i, j, k; @@ -180,10 +180,10 @@ void corr_xh_ivas_fx( #endif } - y32[i] = L_tmp; + y32[i] = L_tmp; // Qx+(15 - norm_s(h[0])) move32(); L_tmp = L_abs( L_tmp ); - L_maxloc = L_max( L_tmp, L_maxloc ); + L_maxloc = L_max( L_tmp, L_maxloc ); // Qx+(15 - norm_s(h[0])) } /* tot += 3*max / 8 */ L_maxloc = L_shr( L_maxloc, 2 ); diff --git a/lib_enc/decision_matrix_enc_fx.c b/lib_enc/decision_matrix_enc_fx.c index b2b464988..2ebb7289a 100644 --- a/lib_enc/decision_matrix_enc_fx.c +++ b/lib_enc/decision_matrix_enc_fx.c @@ -82,7 +82,7 @@ void decision_matrix_enc_fx( Encoder_State *st_fx, /* i : encoder state structure */ - Word16 *hq_core_type /* o : HQ core type */ + Word16 *hq_core_type /* o : HQ core type Q0*/ ) { SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; @@ -107,7 +107,7 @@ void decision_matrix_enc_fx( move16(); test(); - if ( GE_32( st_fx->input_Fs, 32000 ) && GE_16( st_fx->bwidth, SWB ) ) + IF( GE_32( st_fx->input_Fs, 32000 ) && GE_16( st_fx->bwidth, SWB ) ) { st_fx->extl = SWB_CNG; move16(); @@ -155,7 +155,7 @@ void decision_matrix_enc_fx( test(); test(); IF( EQ_16( st_fx->coder_type, UNVOICED ) && EQ_16( st_fx->vad_flag, 1 ) && - ( ( GE_16( st_fx->last_bwidth, SWB ) && st_fx->last_Opt_SC_VBR == 1 ) || LT_16( st_fx->last_bwidth, SWB ) ) && + ( ( GE_16( st_fx->last_bwidth, SWB ) && EQ_16( st_fx->last_Opt_SC_VBR, 1 ) ) || LT_16( st_fx->last_bwidth, SWB ) ) && ( NE_16( st_fx->last_core, HQ_CORE ) || NE_16( st_fx->bwidth, NB ) ) ) { /* NELP mode */ @@ -195,7 +195,7 @@ void decision_matrix_enc_fx( } #else test(); - if ( GE_32( st_fx->total_brate, HQCORE_NB_MIN_RATE ) && EQ_16( st_fx->sp_aud_decision1, 1 ) ) + IF( GE_32( st_fx->total_brate, HQCORE_NB_MIN_RATE ) && EQ_16( st_fx->sp_aud_decision1, 1 ) ) { st_fx->core = HQ_CORE; move16(); @@ -395,9 +395,9 @@ void decision_matrix_enc_fx( * write MODE1 TCX20 signalling information into the bitstream *---------------------------------------------------------------------*/ -Word16 signalling_mode1_tcx20_enc( +Word16 signalling_mode1_tcx20_enc_fx( Encoder_State *st, /* i : encoder state structure */ - Word16 push ) + Word16 push /*Q0*/ ) { Word16 num_bits; Word16 nBits, idx, start_idx; @@ -422,7 +422,7 @@ Word16 signalling_mode1_tcx20_enc( /* retrieve the number of bits for signalling */ idx = add( idx, 1 ); - nBits = extract_l( acelp_sig_tbl[idx] ); + nBits = extract_l( acelp_sig_tbl[idx] ); /*Q0*/ /* retrieve the signalling index */ idx = add( idx, 1 ); @@ -519,7 +519,7 @@ void signalling_enc_fx( /* write ACELP->HQ core switching flag */ test(); - IF( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) + IF( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) { push_indice_fx( hBstr, IND_HQ_SWITCHING_FLG, 1, 1 ); @@ -540,7 +540,7 @@ void signalling_enc_fx( return; } - IF( EQ_16( st_fx->core, ACELP_CORE ) ) + IF( ( st_fx->core == ACELP_CORE ) ) { Word16 ppp_mode, nelp_mode, sig; @@ -588,7 +588,7 @@ void signalling_enc_fx( push_indice_fx( hBstr, IND_PPP_NELP_MODE, 3, 2 ); } } - ELSE IF( NE_32( st_fx->core_brate, SID_2k40 ) && NE_32( st_fx->core_brate, FRAME_NO_DATA ) ) + ELSE IF( NE_32( st_fx->core_brate, SID_2k40 ) && ( st_fx->core_brate != FRAME_NO_DATA ) ) { /* write the ACELP/HQ core selection bit */ IF( GE_32( st_fx->total_brate, ACELP_24k40 ) ) @@ -607,7 +607,7 @@ void signalling_enc_fx( } idx++; } - total_brate_temp = brate_tbl[idx]; + total_brate_temp = brate_tbl[idx]; /*Q0*/ move32(); idx = 0; @@ -618,7 +618,7 @@ void signalling_enc_fx( } /* retrieve the number of bits for signalling */ - nBits = (Word16) acelp_sig_tbl[++idx]; + nBits = (Word16) acelp_sig_tbl[++idx]; /*Q0*/ move16(); /* retrieve the signalling index */ @@ -627,11 +627,11 @@ void signalling_enc_fx( IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->bwidth, SWB ) && LE_32( st_fx->total_brate, ACELP_9k60 ) ) { /* patch to signal SWB as NB in Stereo */ - sig = (Word16) SIG2IND( st_fx->coder_type, NB, st_fx->sharpFlag, st_fx->rf_mode ); + sig = (Word16) SIG2IND( st_fx->coder_type, NB, st_fx->sharpFlag, st_fx->rf_mode ); /*Q0*/ } ELSE { - sig = (Word16) SIG2IND( st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, st_fx->rf_mode ); + sig = (Word16) SIG2IND( st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, st_fx->rf_mode ); /*Q0*/ } WHILE( NE_16( (Word16) acelp_sig_tbl[idx], sig ) ) @@ -663,7 +663,7 @@ void signalling_enc_fx( { /* write ACELP->HQ switching frame flag */ test(); - IF( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) + IF( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) { push_indice_fx( hBstr, IND_HQ_SWITCHING_FLG, 1, 1 ); /* write ACELP L_frame info */ @@ -695,12 +695,12 @@ void signalling_enc_fx( } /* retrieve the number of bits for signalling */ - nBits = extract_l( acelp_sig_tbl[++idx] ); + nBits = extract_l( acelp_sig_tbl[++idx] ); /*Q0*/ /* retrieve the signalling index */ start_idx = ++idx; move16(); - k = SIG2IND_fx( LR_MDCT, st_fx->bwidth, 0, 0 ); + k = SIG2IND_fx( LR_MDCT, st_fx->bwidth, 0, 0 ); /*Q0*/ WHILE( NE_32( acelp_sig_tbl[idx], k ) ) { idx++; @@ -757,7 +757,7 @@ void signaling_enc_rf_fx( IF( EQ_16( st->rf_mode, 1 ) ) { enc_prm_rf_ivas_fx( st, hRF->rf_indx_frametype[st->rf_fec_offset], st->rf_fec_offset ); - hRF->rf_indx_tbeGainFr[0] = hRF->RF_bwe_gainFr_ind; + hRF->rf_indx_tbeGainFr[0] = hRF->RF_bwe_gainFr_ind; /*Q0*/ move16(); } @@ -819,7 +819,7 @@ void signaling_enc_rf_fx( return; } -void signalling_enc_rf( +void signalling_enc_rf_fx( Encoder_State *st /* i : encoder state structure */ ) { @@ -831,7 +831,7 @@ void signalling_enc_rf( IF( EQ_16( st->rf_mode, 1 ) ) { enc_prm_rf_fx( st, hRF->rf_indx_frametype[st->rf_fec_offset], st->rf_fec_offset ); - hRF->rf_indx_tbeGainFr[0] = hRF->RF_bwe_gainFr_ind; + hRF->rf_indx_tbeGainFr[0] = hRF->RF_bwe_gainFr_ind; /*Q0*/ } /* Shift the RF indices such that the partial copy associated with diff --git a/lib_enc/detect_transient_fx.c b/lib_enc/detect_transient_fx.c index e21579cd0..c4dbc6fe7 100644 --- a/lib_enc/detect_transient_fx.c +++ b/lib_enc/detect_transient_fx.c @@ -58,24 +58,25 @@ static void hp_filter_fx( Word16 *y, /*Q_new */ Word16 *oldy, /*Q_new */ Word16 *oldx, /*Q_new */ - const Word16 L ) + const Word16 L /*Q0*/ ) { Word16 i; Word32 L_tmp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif /*y[0] = 0.4931f * *oldy + 0.7466f*(x[0] - *oldx); */ #ifdef BASOP_NOGLOB - L_tmp = L_mult( sub_o( x[0], *oldx, &Overflow ), 24465 ); /*Q_new+16 */ -#else /* BASOP_NOGLOB */ + L_tmp = L_mult( sub_o( x[0], *oldx, &Overflow ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */ +#else /* BASOP_NOGLOB */ L_tmp = L_mult( sub( x[0], *oldx ), 24465 ); /*Q_new+16 */ -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ #ifdef BASOP_NOGLOB - L_tmp = L_mac_sat( L_tmp, *oldy, 16158 ); /*Q_new+16 */ - y[0] = round_fx_sat( L_tmp ); /*Q_new */ + L_tmp = L_mac_sat( L_tmp, *oldy, 16158 /*0.4931f in Q15*/ ); /*Q_new+16 */ + y[0] = round_fx_sat( L_tmp ); /*Q_new */ #else L_tmp = L_mac( L_tmp, *oldy, 16158 ); /*Q_new+16 */ y[0] = round_fx( L_tmp ); /*Q_new */ @@ -84,14 +85,14 @@ static void hp_filter_fx( { /*y[i] = 0.4931f*y[i-1] + 0.7466f*(x[i] - x[i-1]); */ #ifdef BASOP_NOGLOB - L_tmp = L_mult( sub_o( x[i], x[i - 1], &Overflow ), 24465 ); /*Q_new+16 */ - L_tmp = L_mac_o( L_tmp, y[i - 1], 16158, &Overflow ); /*Q_new+16 */ - y[i] = round_fx_o( L_tmp, &Overflow ); /*Q_new */ -#else /* BASOP_NOGLOB */ + L_tmp = L_mult( sub_o( x[i], x[i - 1], &Overflow ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */ + L_tmp = L_mac_o( L_tmp, y[i - 1], 16158 /*0.4931f in Q15*/, &Overflow ); /*Q_new+16 */ + y[i] = round_fx_o( L_tmp, &Overflow ); /*Q_new */ +#else /* BASOP_NOGLOB */ L_tmp = L_mult( sub( x[i], x[i - 1] ), 24465 ); /*Q_new+16 */ L_tmp = L_mac( L_tmp, y[i - 1], 16158 ); /*Q_new+16 */ y[i] = round_fx( L_tmp ); /*Q_new */ -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ } *oldx = x[L - 1]; @@ -114,7 +115,7 @@ static void hp_filter_fx( Word16 detect_transient_fx( const Word16 *in_fx, /*Q_new */ - const Word16 L, + const Word16 L, /*Q0*/ Word16 Q_new, Encoder_State *st_fx ) { @@ -133,6 +134,7 @@ Word16 detect_transient_fx( Word16 exp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif shift = 0; @@ -177,7 +179,7 @@ Word16 detect_transient_fx( } IF( EQ_16( L, L_FRAME8k ) ) { - Energy_in_fx[0] = st_fx->Energy_Old_fx; + Energy_in_fx[0] = st_fx->Energy_Old_fx; /*Q0*/ move32(); /* Compute block energy */ FOR( blk = 0; blk < 4; blk++ ) @@ -192,9 +194,9 @@ Word16 detect_transient_fx( #else Energy_fx = L_add( Energy_fx, L_mult0( temp16, temp16 ) ); #endif - temp16 = shr( in_fx[i + blk * ( L / 4 )], Q_new ); + temp16 = shr( in_fx[i + blk * ( L / 4 )], Q_new ); /*Q0*/ #ifdef BASOP_NOGLOB - Energy_in_fx[blk + 1] = L_add_o( Energy_in_fx[blk + 1], L_mult0( temp16, temp16 ), &Overflow ); + Energy_in_fx[blk + 1] = L_add_o( Energy_in_fx[blk + 1], L_mult0( temp16, temp16 ), &Overflow ); /*Q0*/ #else Energy_in_fx[blk + 1] = L_add( Energy_in_fx[blk + 1], L_mult0( temp16, temp16 ) ); #endif @@ -202,14 +204,14 @@ Word16 detect_transient_fx( } #ifdef BASOP_NOGLOB - E_in_fx = L_add_o( E_in_fx, Energy_in_fx[blk + 1], &Overflow ); - E_out_fx = L_add_o( E_out_fx, Energy_fx, &Overflow ); + E_in_fx = L_add_o( E_in_fx, Energy_in_fx[blk + 1], &Overflow ); /*Q0*/ + E_out_fx = L_add_o( E_out_fx, Energy_fx, &Overflow ); /*Q0*/ #else E_in_fx = L_add( E_in_fx, Energy_in_fx[blk + 1] ); E_out_fx = L_add( E_out_fx, Energy_fx ); #endif - Thres_fx = 2185; /*1 /15 */ + Thres_fx = 2185; /*1 /15 Q15*/ move16(); IF( GT_32( Mult_32_16( Energy_fx, 5461 ), EnergyLT ) ) { @@ -219,7 +221,7 @@ Word16 detect_transient_fx( move16(); } - EnergyLT = L_add( Mult_32_16( EnergyLT, 24576 ), Mult_32_16( Energy_fx, 8192 ) ); + EnergyLT = L_add( Mult_32_16( EnergyLT, 24576 /*Q15*/ ), Mult_32_16( Energy_fx, 8192 /*Q15*/ ) ); /*2Q_new*/ } } ELSE @@ -249,8 +251,8 @@ Word16 detect_transient_fx( } Overflow = 0; move16(); -#ifdef BASOP_NOGLOB /* Critical Overflow */ - Energy = L_add_o( L_tmp, L_tmp2, &Overflow ); +#ifdef BASOP_NOGLOB /* Critical Overflow */ + Energy = L_add_o( L_tmp, L_tmp2, &Overflow ); /*2Q_new */ #else Energy = L_add( L_tmp, L_tmp2 ); #endif @@ -263,8 +265,8 @@ Word16 detect_transient_fx( Overflow = 0; move16(); -#ifdef BASOP_NOGLOB /* shift is >= 0, not overflow possible for shr */ - Energy = L_add_o( L_shr( L_tmp, shift ), L_shr( L_tmp2, shift ), &Overflow ); +#ifdef BASOP_NOGLOB /* shift is >= 0, not overflow possible for shr */ + Energy = L_add_o( L_shr( L_tmp, shift ), L_shr( L_tmp2, shift ), &Overflow ); /*2Q_new - shift*/ #else Energy = L_add( L_shr( L_tmp, shift ), L_shr( L_tmp2, shift ) ); #endif @@ -309,8 +311,8 @@ Word16 detect_transient_fx( /*EnergyLT = 0.75f*EnergyLT + 0.25f*Energy; */ /*0.75f*EnergyLT in Q0 //0.25f*Energy in Q0 */ #ifdef BASOP_NOGLOB - EnergyLT = L_add_o( Mult_32_16( EnergyLT, 24576 ), Mult_32_16( Energy, shl( 8192, shift ) ), &Overflow ); /*2Q_new */ -#else /* BASOP_NOGLOB */ + EnergyLT = L_add_o( Mult_32_16( EnergyLT, 24576 /*0.75f in Q15*/ ), Mult_32_16( Energy, shl( 8192 /*0.25 in Q15*/, shift ) ), &Overflow ); /*2Q_new */ +#else /* BASOP_NOGLOB */ EnergyLT = L_add( Mult_32_16( EnergyLT, 24576 ), Mult_32_16( Energy, shl( 8192, shift ) ) ); /*2Q_new */ #endif } @@ -341,7 +343,7 @@ Word16 detect_transient_fx( /*blk++; */ blk = add( blk, 1 ); #ifdef BASOP_NOGLOB - E_low_fx = L_add_sat( E_low_fx, Energy_in_fx[i] ); + E_low_fx = L_add_sat( E_low_fx, Energy_in_fx[i] ); /*Q0*/ #else E_low_fx = L_add( E_low_fx, Energy_in_fx[i] ); #endif @@ -361,7 +363,7 @@ Word16 detect_transient_fx( /*blk++; */ blk = add( blk, 1 ); #ifdef BASOP_NOGLOB - E_high_fx = L_add_sat( E_high_fx, Energy_in_fx[i] ); + E_high_fx = L_add_sat( E_high_fx, Energy_in_fx[i] ); /*Q0*/ #else E_high_fx = L_add( E_high_fx, Energy_in_fx[i] ); #endif @@ -375,7 +377,7 @@ Word16 detect_transient_fx( test(); test(); - IF( LT_32( L_shr( E_high_fx, 1 ), E_low_fx ) && GT_32( E_high_fx, Mult_32_16( E_low_fx, 22938 ) ) && GT_32( Mult_32_16( E_in_fx, Thres_fx ), E_out_fx ) ) + IF( LT_32( L_shr( E_high_fx, 1 ), E_low_fx ) && GT_32( E_high_fx, Mult_32_16( E_low_fx, 22938 /*0.7 in Q15*/ ) ) && GT_32( Mult_32_16( E_in_fx, Thres_fx ), E_out_fx ) ) { IsTransient = 0; move16(); @@ -395,7 +397,7 @@ Word16 detect_transient_fx( { IF( IsTransient ) { - IF( EQ_16( position, 3 ) ) + if ( EQ_16( position, 3 ) ) { /* Set Hangover */ st_fx->TransientHangOver = 1; @@ -433,9 +435,9 @@ Word16 detect_transient_fx( } } - IF( EQ_16( L, L_FRAME8k ) ) + if ( EQ_16( L, L_FRAME8k ) ) { - st_fx->Energy_Old_fx = Energy_in_fx[4]; + st_fx->Energy_Old_fx = Energy_in_fx[4]; /*Q0*/ move32(); } diff --git a/lib_enc/diffcod_fx.c b/lib_enc/diffcod_fx.c index 7ff48d816..51a31fa8a 100644 --- a/lib_enc/diffcod_fx.c +++ b/lib_enc/diffcod_fx.c @@ -17,9 +17,9 @@ /*--------------------------------------------------------------------------*/ void diffcod_fx( - const Word16 N, /* i : number of sub-vectors */ - Word16 *y, /* i/o: indices of quantized norms */ - Word16 *difidx /* o : differential code */ + const Word16 N, /* i : number of sub-vectors Q0*/ + Word16 *y, /* i/o: indices of quantized norms Q0*/ + Word16 *difidx /* o : differential code Q0*/ ) { Word16 i, k, r; @@ -27,7 +27,9 @@ void diffcod_fx( FOR( i = N - 1; i > 0; i-- ) { r = sub( i, 1 ); + move16(); k = sub( y[i], y[r] ); + move16(); if ( LT_16( k, -15 ) ) { y[r] = add( y[i], 15 ); @@ -38,7 +40,9 @@ void diffcod_fx( FOR( i = 1; i < N; i++ ) { r = sub( i, 1 ); + move16(); k = sub( y[i], y[r] ); + move16(); IF( GT_16( k, 16 ) ) { k = 16; @@ -61,11 +65,11 @@ void diffcod_fx( *--------------------------------------------------------------------------*/ void diffcod_lrmdct_fx( - const Word16 N, /* i : number of sub-vectors */ - const Word16 be_ref, /* i : band energy reference */ - Word16 *y, /* i/o: indices of quantized norms */ - Word16 *difidx, /* o : differential code */ - const Word16 is_transient /* i : transient flag */ + const Word16 N, /* i : number of sub-vectors Q0*/ + const Word16 be_ref, /* i : band energy reference Q0*/ + Word16 *y, /* i/o: indices of quantized norms Q0*/ + Word16 *difidx, /* o : differential code Q0*/ + const Word16 is_transient /* i : transient flag Q0*/ ) { Word16 i, m, r; @@ -106,9 +110,11 @@ void diffcod_lrmdct_fx( } m = sub( N, 1 ); + move16(); FOR( i = m; i > 0; i-- ) { r = sub( i, 1 ); + move16(); k = sub( y[i], y[r] ); move16(); if ( LT_16( k, thr_l ) ) @@ -121,7 +127,9 @@ void diffcod_lrmdct_fx( FOR( i = 1; i < N; i++ ) { r = sub( i, 1 ); + move16(); k = sub( y[i], y[r] ); + move16(); IF( GT_16( k, thr_h ) ) { k = thr_h; diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index a052a1196..a8978c497 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -41,7 +41,7 @@ * Local function prototypes *-------------------------------------------------------------------*/ -static void update_SID_cnt( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate, const Word16 Opt_AMR_WB ); +static void update_SID_cnt_fx( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate, const Word16 Opt_AMR_WB ); /*==================================================================================*/ /* FUNCTION : dtx_ivas_fx() */ /*----------------------------------------------------------------------------------*/ @@ -65,9 +65,9 @@ static void update_SID_cnt( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate, con /*==================================================================================*/ void dtx_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 ivas_total_brate, /* i : IVAS total bitrate */ - const Word16 vad, /* i : vad flag for DTX */ - const Word16 speech[], /* i : Pointer to the speech frame */ + const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ + const Word16 vad, /* i : vad flag for DTX Q0*/ + const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ Word16 Q_speech /* i : Q factor for speech */ ) { @@ -262,7 +262,7 @@ void dtx_ivas_fx( test(); test(); - if ( ( st_fx->core_brate == FRAME_NO_DATA ) && ( st_fx->last_core != ACELP_CORE ) && !st_fx->Opt_AMR_WB ) + IF( ( st_fx->core_brate == FRAME_NO_DATA ) && ( st_fx->last_core != ACELP_CORE ) && !st_fx->Opt_AMR_WB ) { /* force SID frame when switching from HQ core or AMR-WB IO mode into inactive frame in ACELP core when DTX is on */ st_fx->core_brate = SID_2k40; @@ -281,7 +281,7 @@ void dtx_ivas_fx( test(); test(); test(); - if ( ( st_fx->element_mode == EVS_MONO ) && ( EQ_32( st_fx->total_brate, ACELP_9k60 ) || EQ_32( st_fx->total_brate, ACELP_16k40 ) || EQ_32( st_fx->total_brate, ACELP_24k40 ) || EQ_32( st_fx->total_brate, ACELP_48k ) || EQ_32( st_fx->total_brate, HQ_96k ) || EQ_32( st_fx->total_brate, HQ_128k ) ) ) + IF( ( st_fx->element_mode == EVS_MONO ) && ( EQ_32( st_fx->total_brate, ACELP_9k60 ) || EQ_32( st_fx->total_brate, ACELP_16k40 ) || EQ_32( st_fx->total_brate, ACELP_24k40 ) || EQ_32( st_fx->total_brate, ACELP_48k ) || EQ_32( st_fx->total_brate, HQ_96k ) || EQ_32( st_fx->total_brate, HQ_128k ) ) ) { st_fx->codec_mode = MODE2; move16(); @@ -298,7 +298,7 @@ void dtx_ivas_fx( test(); test(); test(); - if ( ( st_fx->element_mode == EVS_MONO ) && ( EQ_32( st_fx->total_brate, ACELP_9k60 ) || EQ_32( st_fx->total_brate, ACELP_16k40 ) || EQ_32( st_fx->total_brate, ACELP_24k40 ) ) ) + IF( ( st_fx->element_mode == EVS_MONO ) && ( EQ_32( st_fx->total_brate, ACELP_9k60 ) || EQ_32( st_fx->total_brate, ACELP_16k40 ) || EQ_32( st_fx->total_brate, ACELP_24k40 ) ) ) { st_fx->codec_mode = MODE2; move16(); @@ -448,15 +448,15 @@ void dtx_ivas_fx( Q_speech2 = add( shl( Q_speech, 1 ), 7 ); FOR( j = 0; j < 16; j++ ) { - L_tmp = L_mult0( *speech, *speech ); + L_tmp = L_mult0( *speech, *speech ); /*2*Q_speech*/ speech++; FOR( i = 1; i < L_FRAME / 16; i++ ) { #ifdef BASOP_NOGLOB - L_tmp = L_mac0_o( L_tmp, *speech, *speech, &Overflow ); -#else /* BASOP_NOGLOB */ + L_tmp = L_mac0_o( L_tmp, *speech, *speech, &Overflow ); /*2*Q_speech*/ +#else /* BASOP_NOGLOB */ L_tmp = L_mac0( L_tmp, *speech, *speech ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ speech++; } hDtxEnc->frame_ener_fx = L_add( hDtxEnc->frame_ener_fx, L_shr( L_tmp, Q_speech2 ) ); /* Q(-7) */ @@ -467,17 +467,17 @@ void dtx_ivas_fx( IF( EQ_16( st_fx->clas, VOICED_CLAS ) ) { - alpha = ALPHA_ENER_SLOW_FX; + alpha = ALPHA_ENER_SLOW_FX; /*Q15 */ move16(); if ( GT_32( hDtxEnc->frame_ener_fx, hDtxEnc->lt_ener_voiced_fx ) ) { - alpha = ALPHA_ENER_FAST_FX; - move16(); /*Q15 */ + alpha = ALPHA_ENER_FAST_FX; /*Q15 */ + move16(); } /*st_fx->lt_ener_voiced_fx = alpha * st_fx->lt_ener_voiced_fx + (1.0f-alpha) * st_fx->frame_ener_fx;*/ - L_tmp = L_sub( hDtxEnc->lt_ener_voiced_fx, hDtxEnc->frame_ener_fx ); - L_tmp = Mult_32_16( L_tmp, alpha ); + L_tmp = L_sub( hDtxEnc->lt_ener_voiced_fx, hDtxEnc->frame_ener_fx ); /*Q(-7)*/ + L_tmp = Mult_32_16( L_tmp, alpha ); /*Q(-7)*/ hDtxEnc->lt_ener_voiced_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /* Q(-7) */ move32(); @@ -490,17 +490,17 @@ void dtx_ivas_fx( /* Background noise */ ELSE IF( !st_fx->Opt_AMR_WB ) { - alpha = ALPHA_ENER_SLOW_FX; + alpha = ALPHA_ENER_SLOW_FX; /*Q15*/ move16(); if ( LT_32( hDtxEnc->frame_ener_fx, hDtxEnc->lt_ener_noise_fx ) ) { - alpha = ALPHA_ENER_FAST_FX; + alpha = ALPHA_ENER_FAST_FX; /*Q15*/ move16(); } /*st_fx->lt_ener_noise_fx = alpha * st_fx->lt_ener_noise_fx + (1.0f-alpha) * st_fx->frame_ener_fx;*/ - L_tmp = L_sub( hDtxEnc->lt_ener_noise_fx, hDtxEnc->frame_ener_fx ); - L_tmp = Mult_32_16( L_tmp, alpha ); + L_tmp = L_sub( hDtxEnc->lt_ener_noise_fx, hDtxEnc->frame_ener_fx ); /* Q(-7) */ + L_tmp = Mult_32_16( L_tmp, alpha ); /* Q(-7) */ hDtxEnc->lt_ener_noise_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /* Q(-7) */ move32(); @@ -514,7 +514,7 @@ void dtx_ivas_fx( } /* Update of the SID counter */ - update_SID_cnt( hDtxEnc, st_fx->core_brate, st_fx->Opt_AMR_WB ); + update_SID_cnt_fx( hDtxEnc, st_fx->core_brate, st_fx->Opt_AMR_WB ); /* Update encoded bandwidth */ test(); @@ -525,7 +525,7 @@ void dtx_ivas_fx( st_fx->bwidth = st_fx->last_bwidth; move16(); test(); - if ( GT_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate_cng, -1 ) ) + IF( GT_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate_cng, -1 ) ) { st_fx->bwidth = st_fx->last_bwidth_cng; move16(); @@ -614,8 +614,8 @@ void dtx_ivas_fx( /*==================================================================================*/ void dtx_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 vad, /* i : vad flag for DTX */ - const Word16 speech[], /* i : Pointer to the speech frame */ + const Word16 vad, /* i : vad flag for DTX Q0*/ + const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ Word16 Q_speech /* i : Q factor for speech */ ) @@ -628,6 +628,7 @@ void dtx_fx( Word16 last_br_cng_flag, last_br_flag, br_dtx_flag; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif #ifdef IVAS_CODE @@ -661,7 +662,7 @@ void dtx_fx( st_fx->cng_type = FD_CNG; move16(); test(); - if ( ( EQ_16( st_fx->codec_mode, MODE1 ) || st_fx->Opt_AMR_WB ) && EQ_16( st_fx->element_mode, IVAS_SCE ) && EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + IF( ( EQ_16( st_fx->codec_mode, MODE1 ) || st_fx->Opt_AMR_WB ) && EQ_16( st_fx->element_mode, IVAS_SCE ) && EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { st_fx->cng_type = LP_CNG; move16(); @@ -684,7 +685,7 @@ void dtx_fx( st_fx->total_brate = st_fx->last_total_brate_cng; move32(); test(); - if ( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) ) + IF( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) ) { st_fx->Opt_SC_VBR = 0; move16(); @@ -704,7 +705,7 @@ void dtx_fx( st_fx->total_brate = st_fx->last_total_brate; move32(); test(); - if ( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) ) + IF( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) ) { st_fx->Opt_SC_VBR = 0; move16(); @@ -715,7 +716,7 @@ void dtx_fx( test(); test(); test(); - if ( st_fx->rf_mode && st_fx->rf_fec_offset > 0 && EQ_32( st_fx->total_brate, ACELP_13k20 ) && NE_16( st_fx->bwidth, NB ) ) + IF( st_fx->rf_mode && st_fx->rf_fec_offset > 0 && EQ_32( st_fx->total_brate, ACELP_13k20 ) && NE_16( st_fx->bwidth, NB ) ) { st_fx->Opt_RF_ON = 1; move16(); @@ -724,7 +725,7 @@ void dtx_fx( move16(); st_fx->bwidth = st_fx->last_bwidth; move32(); - IF( GT_16( st_fx->element_mode, EVS_MONO ) ) + IF( ( st_fx->element_mode > EVS_MONO ) ) { st_fx->codec_mode = MODE1; move16(); @@ -763,6 +764,7 @@ void dtx_fx( { st_fx->last_total_brate_cng = -1; st_fx->last_rf_mode_cng = st_fx->rf_mode; + move32(); move16(); } ELSE @@ -770,6 +772,9 @@ void dtx_fx( st_fx->last_total_brate_cng = st_fx->total_brate; st_fx->last_bwidth_cng = st_fx->bwidth; st_fx->last_codec_mode_cng = st_fx->codec_mode; + move32(); + move16(); + move16(); } IF( hDtxEnc->cnt_SID == 0 ) @@ -795,7 +800,7 @@ void dtx_fx( test(); test(); - IF( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) && NE_16( st_fx->last_core, ACELP_CORE ) && !st_fx->Opt_AMR_WB ) + IF( ( st_fx->core_brate == FRAME_NO_DATA ) && ( st_fx->last_core != ACELP_CORE ) && !st_fx->Opt_AMR_WB ) { /* force SID frame when switching from HQ core or AMR-WB IO mode into inactive frame in ACELP core when DTX is on */ st_fx->core_brate = SID_2k40; @@ -820,7 +825,7 @@ void dtx_fx( test(); test(); test(); - IF( ( EQ_16( st_fx->cng_type, FD_CNG ) && ( LE_32( st_fx->total_brate, ACELP_24k40 ) || ( NE_16( st_fx->element_mode, EVS_MONO ) && LE_32( st_fx->total_brate, ACELP_32k ) ) ) ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) /* at highest bitrates, use exclusively LP_CNG */ + IF( ( EQ_16( st_fx->cng_type, FD_CNG ) && ( LE_32( st_fx->total_brate, ACELP_24k40 ) || ( ( st_fx->element_mode != EVS_MONO ) && LE_32( st_fx->total_brate, ACELP_32k ) ) ) ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) /* at highest bitrates, use exclusively LP_CNG */ { test(); test(); @@ -863,7 +868,7 @@ void dtx_fx( /* NB core bit rate can be "-1" at startup , so one can not use core_brate_fx <=2400 */ test(); test(); - IF( ( NE_32( st_fx->core_brate, SID_2k40 ) ) && ( NE_32( st_fx->core_brate, SID_1k75 ) ) && ( NE_32( st_fx->core_brate, FRAME_NO_DATA ) ) ) + IF( ( NE_32( st_fx->core_brate, SID_2k40 ) ) && ( NE_32( st_fx->core_brate, SID_1k75 ) ) && ( st_fx->core_brate != FRAME_NO_DATA ) ) { IF( hDtxEnc != NULL ) { @@ -968,15 +973,15 @@ void dtx_fx( Q_speech2 = add( shl( Q_speech, 1 ), 7 ); FOR( j = 0; j < 16; j++ ) { - L_tmp = L_mult0( *speech, *speech ); + L_tmp = L_mult0( *speech, *speech ); /*2*Q_speech*/ speech++; FOR( i = 1; i < L_FRAME / 16; i++ ) { #ifdef BASOP_NOGLOB - L_tmp = L_mac0_o( L_tmp, *speech, *speech, &Overflow ); -#else /* BASOP_NOGLOB */ + L_tmp = L_mac0_o( L_tmp, *speech, *speech, &Overflow ); /*2*Q_speech*/ +#else /* BASOP_NOGLOB */ L_tmp = L_mac0( L_tmp, *speech, *speech ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ speech++; } hDtxEnc->frame_ener_fx = L_add( hDtxEnc->frame_ener_fx, L_shr( L_tmp, Q_speech2 ) ); /*Q(-7) */ @@ -990,14 +995,14 @@ void dtx_fx( move16(); if ( GT_32( hDtxEnc->frame_ener_fx, hDtxEnc->lt_ener_voiced_fx ) ) { - alpha = ALPHA_ENER_FAST_FX; - move16(); /*Q15 */ + alpha = ALPHA_ENER_FAST_FX; /*Q15 */ + move16(); } /*st_fx->lt_ener_voiced_fx = alpha * st_fx->lt_ener_voiced_fx + (1.0f-alpha) * st_fx->frame_ener_fx;*/ - L_tmp = L_sub( hDtxEnc->lt_ener_voiced_fx, hDtxEnc->frame_ener_fx ); - L_tmp = Mult_32_16( L_tmp, alpha ); - hDtxEnc->lt_ener_voiced_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /*Q(-7) */ + L_tmp = L_sub( hDtxEnc->lt_ener_voiced_fx, hDtxEnc->frame_ener_fx ); /*Q(-7)*/ + L_tmp = Mult_32_16( L_tmp, alpha ); /*Q(-7)*/ + hDtxEnc->lt_ener_voiced_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /*Q(-7)*/ hDtxEnc->VarDTX_cnt_voiced = add( hDtxEnc->VarDTX_cnt_voiced, 1 ); @@ -1006,19 +1011,19 @@ void dtx_fx( /* Background noise */ ELSE IF( !st_fx->Opt_AMR_WB ) { - alpha = ALPHA_ENER_SLOW_FX; + alpha = ALPHA_ENER_SLOW_FX; /*Q15 */ move16(); if ( LT_32( hDtxEnc->frame_ener_fx, hDtxEnc->lt_ener_noise_fx ) ) { - alpha = ALPHA_ENER_FAST_FX; + alpha = ALPHA_ENER_FAST_FX; /*Q15 */ move16(); } /*st_fx->lt_ener_noise_fx = alpha * st_fx->lt_ener_noise_fx + (1.0f-alpha) * st_fx->frame_ener_fx;*/ - L_tmp = L_sub( hDtxEnc->lt_ener_noise_fx, hDtxEnc->frame_ener_fx ); - L_tmp = Mult_32_16( L_tmp, alpha ); - hDtxEnc->lt_ener_noise_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); - move32(); /*Q(-7) */ + L_tmp = L_sub( hDtxEnc->lt_ener_noise_fx, hDtxEnc->frame_ener_fx ); /*Q(-7)*/ + L_tmp = Mult_32_16( L_tmp, alpha ); /*Q(-7)*/ + hDtxEnc->lt_ener_noise_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /*Q(-7)*/ + move32(); hDtxEnc->VarDTX_cnt_noise = add( hDtxEnc->VarDTX_cnt_noise, 1 ); @@ -1028,7 +1033,7 @@ void dtx_fx( } /* Update of the SID counter */ - update_SID_cnt( hDtxEnc, st_fx->core_brate, st_fx->Opt_AMR_WB ); + update_SID_cnt_fx( hDtxEnc, st_fx->core_brate, st_fx->Opt_AMR_WB ); /* Update encoded bandwidth */ test(); @@ -1039,7 +1044,7 @@ void dtx_fx( st_fx->bwidth = st_fx->last_bwidth; move16(); test(); - if ( GT_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate_cng, -1 ) ) + IF( GT_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate_cng, -1 ) ) { st_fx->bwidth = st_fx->last_bwidth_cng; move16(); @@ -1067,6 +1072,7 @@ void dtx_fx( st_fx->Opt_RF_ON = 0; move16(); st_fx->rf_mode = 0; + move16(); } /* Set and limit the encoded bandwidth */ @@ -1109,10 +1115,10 @@ void dtx_fx( * Update of the SID counter *---------------------------------------------------------------------*/ -static void update_SID_cnt( +static void update_SID_cnt_fx( DTX_ENC_HANDLE hDtxEnc, /* i/o: common DTX handle */ - const Word32 core_brate, /* i : core coder core bitrate */ - const Word16 Opt_AMR_WB /* i : AMR BW IO mode? */ + const Word32 core_brate, /* i : core coder core bitrate Q0*/ + const Word16 Opt_AMR_WB /* i : AMR BW IO mode? Q0*/ ) { Word16 EstimatedSNR, delta, frac, exp; @@ -1133,12 +1139,12 @@ static void update_SID_cnt( exp = norm_l( L_tmp1 ); frac = Log2_norm_lc( L_shl( L_tmp1, exp ) ); exp = sub( 30, exp ); - L_tmp1 = L_Comp( exp, frac ); + L_tmp1 = L_Comp( exp, frac ); /*Q16*/ L_tmp2 = L_max( hDtxEnc->lt_ener_noise_fx, 1 ); exp = norm_l( L_tmp2 ); frac = Log2_norm_lc( L_shl( L_tmp2, exp ) ); exp = sub( 30, exp ); - L_tmp1 = L_sub( L_tmp1, L_Comp( exp, frac ) ); + L_tmp1 = L_sub( L_tmp1, L_Comp( exp, frac ) ); /*Q16*/ /* 10 x Log10(a/b) = 10 x Log10(2) x [Log2(a) - Log2(b)] */ /* 10 x Log10(2) = ~3.0103 */ L_tmp1 = Mpy_32_16_1( L_tmp1, 24660 ); /* mult by 3.0103 / 4 in Q15 */ @@ -1162,7 +1168,7 @@ static void update_SID_cnt( test(); - if ( Opt_AMR_WB == 0 || NE_16( hDtxEnc->max_SID, 3 ) ) + IF( Opt_AMR_WB == 0 || NE_16( hDtxEnc->max_SID, 3 ) ) { hDtxEnc->max_SID = hDtxEnc->interval_SID; move16(); /* change SID update rate */ @@ -1175,12 +1181,12 @@ static void update_SID_cnt( exp = norm_l( L_tmp1 ); frac = Log2_norm_lc( L_shl( L_tmp1, exp ) ); exp = sub( 30, exp ); - L_tmp1 = L_Comp( exp, frac ); + L_tmp1 = L_Comp( exp, frac ); /*Q16*/ L_tmp2 = L_max( hDtxEnc->lt_ener_last_SID_fx, 1 ); exp = norm_l( L_tmp2 ); frac = Log2_norm_lc( L_shl( L_tmp2, exp ) ); exp = sub( 30, exp ); - L_tmp1 = L_sub( L_tmp1, L_Comp( exp, frac ) ); + L_tmp1 = L_sub( L_tmp1, L_Comp( exp, frac ) ); /*Q16*/ /* 10 x Log10(a/b) = 10 x Log10(2) x [Log2(a) - Log2(b)] */ /* 10 x Log10(2) = ~3.0103 */ L_tmp1 = Mpy_32_16_1( L_tmp1, 24660 ); /* mult by 3.0103 / 4 in Q15 */ @@ -1188,10 +1194,10 @@ static void update_SID_cnt( delta = round_fx( L_tmp1 ); /* now in Q8 */ test(); test(); - if ( LT_16( delta, LTE_VAR_FX ) && EQ_16( hDtxEnc->VarDTX_cnt_voiced, MIN_CNT ) && EQ_16( hDtxEnc->VarDTX_cnt_noise, MIN_CNT ) ) + IF( LT_16( delta, LTE_VAR_FX ) && EQ_16( hDtxEnc->VarDTX_cnt_voiced, MIN_CNT ) && EQ_16( hDtxEnc->VarDTX_cnt_noise, MIN_CNT ) ) { /* Send SID frame, and reset lt_ener_noise */ - hDtxEnc->lt_ener_noise_fx = hDtxEnc->frame_ener_fx; + hDtxEnc->lt_ener_noise_fx = hDtxEnc->frame_ener_fx; /* Q(-7) */ move32(); } } @@ -1209,7 +1215,7 @@ static void update_SID_cnt( test(); test(); - if ( Opt_AMR_WB != 0 && EQ_16( hDtxEnc->max_SID, 3 ) && EQ_16( hDtxEnc->cnt_SID, 3 ) ) + IF( Opt_AMR_WB != 0 && EQ_16( hDtxEnc->max_SID, 3 ) && EQ_16( hDtxEnc->cnt_SID, 3 ) ) { /* set the size of CNG history buffer for averaging to DTX_HIST_SIZE frames */ /* be sure that DTX_HIST_SIZE >= INT_L */ @@ -1253,7 +1259,7 @@ static void update_SID_cnt( void dtx_hangover_control_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 lsp_new_fx[M] /* i : current frame LSPs */ + const Word16 lsp_new_fx[M] /* i : current frame LSPs Q15*/ ) { Word16 ptr; @@ -1288,7 +1294,7 @@ void dtx_hangover_control_fx( exp = norm_l( hTdCngEnc->ho_ener_circ_fx[hTdCngEnc->ho_circ_ptr] ); fra = Log2_norm_lc( L_shl( hTdCngEnc->ho_ener_circ_fx[hTdCngEnc->ho_circ_ptr], exp ) ); exp = sub( sub( 30, exp ), 6 ); - L_tmp = L_Comp( exp, fra ); + L_tmp = L_Comp( exp, fra ); /*Q16*/ enr_new = round_fx( L_shl( L_tmp, 8 ) ); /*Q8 */ if ( enr_new < 0 ) @@ -1298,17 +1304,17 @@ void dtx_hangover_control_fx( } /* get energies and lsps of hangover frames */ - ptr = sub( hTdCngEnc->ho_circ_ptr, sub( hTdCngEnc->burst_ho_cnt, 1 ) ); + ptr = sub( hTdCngEnc->ho_circ_ptr, sub( hTdCngEnc->burst_ho_cnt, 1 ) ); /*Q0*/ IF( ptr < 0 ) { - ptr = add( hTdCngEnc->ho_circ_size, ptr ); + ptr = add( hTdCngEnc->ho_circ_size, ptr ); /*Q0*/ } FOR( i = 0; i < hTdCngEnc->burst_ho_cnt - 1; i++ ) { - Copy( &( hTdCngEnc->ho_lsp_circ_fx[ptr * M] ), &( tmp_lsp[i * M] ), M ); - tmp_enr[i] = hTdCngEnc->ho_ener_circ_fx[ptr]; - move32(); /*Q6 */ + Copy( &( hTdCngEnc->ho_lsp_circ_fx[ptr * M] ), &( tmp_lsp[i * M] ), M ); /*Q15*/ + tmp_enr[i] = hTdCngEnc->ho_ener_circ_fx[ptr]; /*Q6 */ + move32(); ptr = add( ptr, 1 ); if ( EQ_16( ptr, hTdCngEnc->ho_circ_size ) ) @@ -1321,8 +1327,8 @@ void dtx_hangover_control_fx( /* get estimated CNG energy and lsps assuming terminate hangover at current frame */ ptr = sub( hTdCngEnc->burst_ho_cnt, 2 ); enr_est = Mpy_32_16_1( tmp_enr[ptr], W_DTX_HO_FX[0] ); /*Q6 */ - weights = W_DTX_HO_FX[0]; - move16(); /*Q15 */ + weights = W_DTX_HO_FX[0]; /*Q15 */ + move16(); Copy( &( tmp_lsp[ptr * M] ), tmp, M ); m = 1; move16(); @@ -1335,38 +1341,38 @@ void dtx_hangover_control_fx( { enr_est = L_add( enr_est, Mpy_32_16_1( tmp_enr[ptr - i], W_DTX_HO_FX[i] ) ); /*Q6 */ weights = add( weights, W_DTX_HO_FX[i] ); /*Q15 */ - Copy( &tmp_lsp[( ptr - i ) * M], &tmp[m * M], M ); + Copy( &tmp_lsp[( ptr - i ) * M], &tmp[m * M], M ); /*Q15*/ m = add( m, 1 ); } } exp = norm_l( enr_est ); #ifdef BASOP_NOGLOB - fra = round_fx_sat( L_shl_sat( enr_est, exp ) ); + fra = round_fx_sat( L_shl_sat( enr_est, exp ) ); /*Q6+exp-16*/ #else fra = round_fx( L_shl( enr_est, exp ) ); #endif exp2 = norm_s( weights ); - fra2 = shl( weights, exp2 ); + fra2 = shl( weights, exp2 ); /*Q15+exp2*/ exp = sub( sub( exp, 16 ), exp2 ); IF( GT_16( fra, fra2 ) ) { fra = shr( fra, 1 ); exp = sub( exp, 1 ); } - L_tmp = L_deposit_l( div_s( fra, fra2 ) ); - enr_est = L_shr( L_tmp, exp ); /*Q6 */ + L_tmp = L_deposit_l( div_s( fra, fra2 ) ); /*Q6+exp*/ + enr_est = L_shr( L_tmp, exp ); /*Q6 */ if ( LT_32( enr_est, 64 ) ) { - enr_est = 64; - move16(); /*Q6 */ + enr_est = 64; /*Q6 */ + move16(); } exp = norm_l( enr_est ); fra = Log2_norm_lc( L_shl( enr_est, exp ) ); exp = sub( sub( 30, exp ), 6 ); - L_tmp = L_Comp( exp, fra ); + L_tmp = L_Comp( exp, fra ); /*Q16*/ enr_est_log = round_fx( L_shl( L_tmp, 8 ) ); /*Q8 */ Denr_n2e = abs_s( sub( enr_new, enr_est_log ) ); /*Q8 */ @@ -1382,7 +1388,7 @@ void dtx_hangover_control_fx( exp = norm_l( enr_est ); fra = Log2_norm_lc( L_shl( enr_est, exp ) ); exp = sub( sub( 30, exp ), 6 ); - L_tmp = L_Comp( exp, fra ); + L_tmp = L_Comp( exp, fra ); /*Q16*/ enr_est_log = round_fx( L_shl( L_tmp, 8 ) ); /*Q8 */ if ( enr_est_log < 0 ) @@ -1399,7 +1405,7 @@ void dtx_hangover_control_fx( IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_FX ); - ftmp_fx = 964; + ftmp_fx = 964; /*6400.0f / ( M + 1 ) * 2.56*/ move16(); /*QX2.56 */ S_tmp = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */ C[i] = L_mult0( S_tmp, S_tmp ); /*QX6.5536 */ @@ -1407,7 +1413,7 @@ void dtx_hangover_control_fx( ELSE { lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_16k ); - ftmp_fx = 1205; + ftmp_fx = 1205; /*8000.0f/ ( M + 1 ) * 2.56*/ move16(); /*QX2.56 */ S_tmp = sub( 20480, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */ C[i] = L_mult0( S_tmp, S_tmp ); /*QX6.5536 */ @@ -1421,22 +1427,22 @@ void dtx_hangover_control_fx( C[i] = L_mac0( C[i], S_tmp, S_tmp ); /*QX6.5536 */ } - C[i] = Mpy_32_16_1( C[i], 1928 ); /*QX6.5536 */ + C[i] = Mpy_32_16_1( C[i], 1928 /*Q15*/ ); /*QX6.5536 */ IF( GT_32( C[i], max_val[0] ) ) { - max_val[1] = max_val[0]; + max_val[1] = max_val[0]; /*x6.5536*/ move16(); - max_idx[1] = max_idx[0]; + max_idx[1] = max_idx[0]; /*Q0*/ move16(); - max_val[0] = C[i]; + max_val[0] = C[i]; /*x6.5536*/ move16(); max_idx[0] = i; move16(); } ELSE IF( GT_32( C[i], max_val[1] ) ) { - max_val[1] = C[i]; + max_val[1] = C[i]; /*x6.5536*/ move16(); max_idx[1] = i; move16(); @@ -1445,14 +1451,14 @@ void dtx_hangover_control_fx( IF( EQ_16( m, 1 ) ) { - Copy( tmp, lsp_est, M ); + Copy( tmp, lsp_est, M ); /*Q15*/ } ELSE IF( LT_16( m, 4 ) ) { FOR( i = 0; i < M; i++ ) { - lsp_est[i] = 0; - move16(); /*Q15 */ + lsp_est[i] = 0; /*Q15 */ + move16(); FOR( j = 0; j < m; j++ ) { #ifdef BASOP_NOGLOB @@ -1471,8 +1477,8 @@ void dtx_hangover_control_fx( { FOR( i = 0; i < M; i++ ) { - lsp_est[i] = 0; - move16(); /*Q15 */ + lsp_est[i] = 0; /*Q15 */ + move16(); FOR( j = 0; j < m; j++ ) { #ifdef BASOP_NOGLOB @@ -1492,8 +1498,8 @@ void dtx_hangover_control_fx( } } - Dlsp_n2e = 0; - move16(); /*Q15 */ + Dlsp_n2e = 0; /*Q15 */ + move16(); FOR( i = 0; i < M; i++ ) { #ifdef BASOP_NOGLOB @@ -1527,13 +1533,13 @@ void dtx_hangover_control_fx( exp = norm_l( hTdCngEnc->lp_ener_fx ); fra = Log2_norm_lc( L_shl( hTdCngEnc->lp_ener_fx, exp ) ); exp = sub( sub( 30, exp ), 6 ); - L_tmp = L_Comp( exp, fra ); + L_tmp = L_Comp( exp, fra ); /*Q16*/ S_tmp = round_fx( L_shl( L_tmp, 8 ) ); /*Q8 */ Denr = abs_s( sub( S_tmp, enr_est_log ) ); /*Q8 */ /* make decision if DTX hangover can be terminated */ - hVAD->hangover_terminate_flag = 0; - move16(); /*Q0 */ + hVAD->hangover_terminate_flag = 0; /*Q0 */ + move16(); test(); test(); @@ -1550,8 +1556,8 @@ void dtx_hangover_control_fx( ( LT_16( Dlsp, 13107 ) && LT_16( Denr, 205 ) && LT_16( S_max, 3277 ) && LT_16( Dlsp_n2e, 13107 ) && LT_16( Denr_n2e, 205 ) && st_fx->Opt_SC_VBR == 0 ) ) { - hVAD->hangover_terminate_flag = 1; - move16(); /*Q0 */ + hVAD->hangover_terminate_flag = 1; /*Q0 */ + move16(); } return; @@ -1565,8 +1571,8 @@ void dtx_hangover_control_fx( void td_cng_enc_init_fx( TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */ - const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation */ - const Word16 max_bwidth /* i : maximum encoded bandwidth */ + const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ + const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ) { @@ -1638,14 +1644,14 @@ void td_cng_enc_init_fx( set32_fx( hTdCngEnc->old_env_fx, 0, NUM_ENV_CNG ); /* SWB CNG/DTX */ - hTdCngEnc->last_wb_cng_ener_fx = -1541; - move16(); /* Q8 */ - hTdCngEnc->last_shb_cng_ener_fx = -1541; - move16(); /* Q8 */ - hTdCngEnc->mov_wb_cng_ener_fx = -1541; - move16(); /* Q8 */ - hTdCngEnc->mov_shb_cng_ener_fx = -1541; - move16(); /* Q8 */ + hTdCngEnc->last_wb_cng_ener_fx = -1541; /* Q8 */ + move16(); + hTdCngEnc->last_shb_cng_ener_fx = -1541; /* Q8 */ + move16(); + hTdCngEnc->mov_wb_cng_ener_fx = -1541; /* Q8 */ + move16(); + hTdCngEnc->mov_shb_cng_ener_fx = -1541; /* Q8 */ + move16(); hTdCngEnc->shb_cng_ini_cnt = 1; move16(); hTdCngEnc->shb_NO_DATA_cnt = 0; @@ -1659,8 +1665,8 @@ void td_cng_enc_init_fx( void td_cng_enc_init_ivas_fx( TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */ - const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation */ - const Word16 max_bwidth /* i : maximum encoded bandwidth */ + const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ + const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ) { @@ -1732,14 +1738,14 @@ void td_cng_enc_init_ivas_fx( set16_fx( hTdCngEnc->cng_Qexc_buf, Q15, HO_HIST_SIZE ); /* SWB CNG/DTX */ - hTdCngEnc->last_wb_cng_ener_fx = -1541; - move16(); /* Q8 */ - hTdCngEnc->last_shb_cng_ener_fx = -1541; - move16(); /* Q8 */ - hTdCngEnc->mov_wb_cng_ener_fx = -1541; - move16(); /* Q8 */ - hTdCngEnc->mov_shb_cng_ener_fx = -1541; - move16(); /* Q8 */ + hTdCngEnc->last_wb_cng_ener_fx = -1541; /* Q8 */ + move16(); + hTdCngEnc->last_shb_cng_ener_fx = -1541; /* Q8 */ + move16(); + hTdCngEnc->mov_wb_cng_ener_fx = -1541; /* Q8 */ + move16(); + hTdCngEnc->mov_shb_cng_ener_fx = -1541; /* Q8 */ + move16(); hTdCngEnc->shb_cng_ini_cnt = 1; move16(); hTdCngEnc->shb_NO_DATA_cnt = 0; @@ -1762,8 +1768,8 @@ void td_cng_enc_init_ivas_fx( void dtx_enc_init_fx( Encoder_State *st, /* i : Encoder state handle */ - const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate */ - const Word16 interval_SID /* i : interval for SID update */ + const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate Q0*/ + const Word16 interval_SID /* i : interval for SID update Q0*/ ) { DTX_ENC_HANDLE hDtxEnc; @@ -1792,7 +1798,7 @@ void dtx_enc_init_fx( move32(); hDtxEnc->last_CNG_L_frame = L_FRAME; move16(); - hDtxEnc->var_SID_rate_flag = var_SID_rate_flag; + hDtxEnc->var_SID_rate_flag = var_SID_rate_flag; /*Q0*/ move16(); hDtxEnc->last_active_brate = ACELP_7k20; move32(); diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index edfe5619f..c67a3f447 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -520,7 +520,7 @@ void enc_prm_fx( st->bits_frame_core = add( st->bits_frame_core, FrameSizeConfig[st->frame_size_index].bandwidth_bits ); /* Write MODE1 core mode signaling */ - signalling_mode1_tcx20_enc( st, 1 ); + signalling_mode1_tcx20_enc_fx( st, 1 ); } /* Modes (ACE_GC, ACE_UC, TCX20, TCX10...) */ diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 4a706969e..787eb6c68 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -559,7 +559,7 @@ ivas_error evs_enc_fx( * Channel-aware mode - write signaling information into the bitstream *---------------------------------------------------------------------*/ - signalling_enc_rf( st ); + signalling_enc_rf_fx( st ); updt_enc_common_fx( st, Etot, Q_new ); diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index 43e16b81c..ad46c3e4a 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -1278,8 +1278,6 @@ void ivas_mcmasa_param_est_enc_fx( } Word16 div_q = sub( 31, max_e ); ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( dir_v_fx, div_q, &azimuth_m_values_fx[block_m_idx][band_m_idx], &elevation_m_values_fx[block_m_idx][band_m_idx] ); - elevation_m_values_fx[block_m_idx][band_m_idx] = L_add( elevation_m_values_fx[block_m_idx][band_m_idx], L_shr( elevation_m_values_fx[block_m_idx][band_m_idx], 5 ) ); - move32(); } /* Coherence processing */ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index cff02d911..ccf7d81c6 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -149,8 +149,8 @@ void bw_detect_fx( void core_switching_post_enc_fx( /*done */ Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 inp12k8[], /* i : i signal @12.8 kHz */ - const Word16 inp16k[], /* i : i signal @16 kHz */ + const Word16 inp12k8[], /* i : i signal @12.8 kHz Qinp*/ + const Word16 inp16k[], /* i : i signal @16 kHz Qinp*/ const Word16 A[], /* i : unquant. LP filter coefs. (Q12) */ Word16 Qshift, Word16 Q_new, @@ -160,10 +160,10 @@ void core_switching_post_enc_fx( /*done */ void core_switching_pre_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *old_inp_12k8, /* i : old i signal @12.8kHz */ - const Word16 *old_inp_16k, /* i : old i signal @16kHz */ - const Word16 active_cnt, /* i : active frame counter */ - const Word16 last_element_mode /* i : last_element_mode */ + const Word16 *old_inp_12k8, /* i : old i signal @12.8kHz Qx*/ + const Word16 *old_inp_16k, /* i : old i signal @16kHz Qx*/ + const Word16 active_cnt, /* i : active frame counter Q0*/ + const Word16 last_element_mode /* i : last_element_mode Q0*/ ); Word16 correlation_shift_fx( /* o : noise dependent voicing correction Q15 */ @@ -172,16 +172,16 @@ Word16 correlation_shift_fx( /* o : noise dependent void dtx_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 vad, /* i : vad flag */ - const Word16 speech[], /* i : Pointer to the speech frame */ + const Word16 vad, /* i : vad flag Q0*/ + const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ Word16 Q_speech /* i : Q factor for speech */ ); void dtx_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 ivas_total_brate, /* i : IVAS total bitrate */ - const Word16 vad, /* i : vad flag for DTX */ - const Word16 speech[], /* i : Pointer to the speech frame */ + const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ + const Word16 vad, /* i : vad flag for DTX Q0*/ + const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ Word16 Q_speech /* i : Q factor for speech */ ); @@ -1141,20 +1141,20 @@ void GSC_enc_init_fx( ); void td_cng_enc_init_fx( TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */ - const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation */ - const Word16 max_bwidth /* i : maximum encoded bandwidth */ + const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ + const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ); void td_cng_enc_init_ivas_fx( TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */ - const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation */ - const Word16 max_bwidth /* i : maximum encoded bandwidth */ + const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ + const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ); void dtx_enc_init_fx( Encoder_State *st, /* i : Encoder state handle */ - const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate */ - const Word16 interval_SID /* i : interval for SID update */ + const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate Q0*/ + const Word16 interval_SID /* i : interval for SID update Q0*/ ); void select_TC_fx( const Word16 codec_mode, /* i : codec mode */ @@ -2572,9 +2572,9 @@ Word16 Q_lsf_tcxlpc_fx( const Word32 *Bin_Ener, const Word16 Q_ener ); -Word16 signalling_mode1_tcx20_enc( +Word16 signalling_mode1_tcx20_enc_fx( Encoder_State *st, /* i : encoder state structure */ - Word16 push ); + Word16 push /*Q0*/ ); void coder_tcx_fx( Word16 n, @@ -2845,7 +2845,7 @@ Word16 IGFEncWriteConcatenatedBitstream_ivas_fx( void signaling_enc_rf_fx( Encoder_State *st /* i : encoder state structure */ ); -void signalling_enc_rf( +void signalling_enc_rf_fx( Encoder_State *st /* i : encoder state structure */ ); @@ -2894,25 +2894,25 @@ void core_coder_mode_switch_fx( const Word16 shift ); void corr_xh_fx( - const Word16 x[], /* i : target signal */ - Word16 dn[], /* o : correlation between x[] and h[] */ - const Word16 h[] /* i : impulse response (of weighted synthesis filter) */ + const Word16 x[], /* i : target signal Qx*/ + Word16 dn[], /* o : correlation between x[] and h[] Qdn*/ + const Word16 h[] /* i : impulse response (of weighted synthesis filter) Q14*/ ); void corr_hh_ivas_fx( const Word16 *h, /* i : target signal e(norm_s(h1[0])+1) */ Word16 *y, /* o : correlation between x[] and h[] Q_new + 1 */ Word16 *Qy, - const Word16 L_subfr /* i : length of the subframe */ + const Word16 L_subfr /* i : length of the subframe Q0*/ ); void corr_xh_ivas_fx( - const Word16 x[], /* i : target signal */ + const Word16 x[], /* i : target signal Qx*/ const Word16 Qx, - Word16 dn[], /* o : correlation between x[] and h[] */ + Word16 dn[], /* o : correlation between x[] and h[] Qdn*/ Word16 *Qdn, - const Word16 h[], /* i : impulse response (of weighted synthesis filter) */ - const Word16 L_subfr /* i : length of the subframe */ + const Word16 h[], /* i : impulse response (of weighted synthesis filter) (Q15 - norm_s(h[0]))*/ + const Word16 L_subfr /* i : length of the subframe Q0*/ ); void qlpc_avq_fx( @@ -3276,7 +3276,7 @@ void updt_enc_fx( void dtx_hangover_control_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 lsp_new_fx[M] /* i : current frame LSPs */ + const Word16 lsp_new_fx[M] /* i : current frame LSPs Q15*/ ); void update_average_rate_fx( @@ -4019,10 +4019,10 @@ Word16 pvq_core_enc_ivas_fx( ); void core_switching_hq_prepare_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *num_bits, /* i/o: bit budget update */ - const Word16 input_frame, /* i : frame length */ + Word16 *num_bits, /* i/o: bit budget update Q0*/ + const Word16 input_frame, /* i : frame length Q0*/ Word32 *wtda_audio, /* shall be q_audio + 15, audio allready scalled in wtda function */ - const Word16 *audio ); + const Word16 *audio /*q_audio*/ ); void hq_lr_enc_fx( Encoder_State *st_fx, /* i/o: : encoder state structure */ @@ -4068,9 +4068,9 @@ void reordernorm_fx( ); void diffcod_fx( - const Word16 N, /* (i) number of sub-vectors */ - Word16 *y, /* (i/o) indices of quantized norms */ - Word16 *difidx /* (o) differential code */ + const Word16 N, /* (i) number of sub-vectors Q0*/ + Word16 *y, /* (i/o) indices of quantized norms Q0*/ + Word16 *difidx /* (o) differential code Q0*/ ); Word16 hq_classifier_enc_fx( /* o : Consumed bits Q0 */ @@ -4239,11 +4239,11 @@ Word16 encode_envelope_indices_fx( /* o : Number of b const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ ); void diffcod_lrmdct_fx( - const Word16 N, /* i : number of sub-vectors */ - const Word16 be_ref, /* i : band energy reference */ - Word16 *y, /* i/o: indices of quantized norms */ - Word16 *difidx, /* o : differential code */ - const Word16 is_transient /* i : transient flag */ + const Word16 N, /* i : number of sub-vectors Q0*/ + const Word16 be_ref, /* i : band energy reference Q0*/ + Word16 *y, /* i/o: indices of quantized norms Q0*/ + Word16 *difidx, /* o : differential code Q0*/ + const Word16 is_transient /* i : transient flag Q0*/ ); Word16 peak_vq_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -4511,7 +4511,7 @@ void set_ppp_mode_fx( void decision_matrix_enc_fx( Encoder_State *st_fx, /* i : encoder state structure */ - Word16 *hq_core_type /* o : HQ core_fx type */ + Word16 *hq_core_type /* o : HQ core_fx type Q0*/ ); void pvq_encode_fx( -- GitLab From 4809aa1005fec1b258d08209c735a05f80ece7be Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 17 Dec 2024 17:07:11 +0530 Subject: [PATCH 2/2] Clang formatting changes --- lib_enc/analy_sp_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 6e4a2bb4d..d2e34b012 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -1045,7 +1045,7 @@ static void ivas_find_enr1( Ltmp = W_extract_h( te ); // 2 * Qfft + te_exp - 32 // *ptE *= norm_val; /* normalization - corresponds to FFT normalization by 2/L_FFT */ - Ltmp = Mpy_32_32( Ltmp, norm_val ); // 2 * Qfft + te_exp - 32 + Ltmp = Mpy_32_32( Ltmp, norm_val ); // 2 * Qfft + te_exp - 32 *ptE = L_shl_sat( Ltmp, sub( add( Q_new, QSCALE - 2 ), add( shl( q_data, Q1 ), sub( te_exp, 32 ) ) ) ); // Q_new + QSCALE - 2 move32(); @@ -1094,7 +1094,7 @@ static void ivas_find_enr1( Ltmp = W_extract_h( te ); // 2 * Qfft + te_exp - 32 // *Bin_E *= norm_val; - Ltmp = Mpy_32_32( Ltmp, norm_val ); // 2 * Qfft + te_exp - 32 + Ltmp = Mpy_32_32( Ltmp, norm_val ); // 2 * Qfft + te_exp - 32 *Bin_E = L_shl_sat( Ltmp, sub( add( Q_new, QSCALE - 2 ), add( shl( q_data, Q1 ), sub( te_exp, 32 ) ) ) ); // Q_new + QSCALE - 2 move32(); -- GitLab