From 7b6cf17a7e0165faa2f8c5d9db9d9f9fa2217416 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 23 Oct 2024 13:29:47 +0530 Subject: [PATCH 1/2] Q information for decoder and renderer files - 2 --- lib_dec/dlpc_stoch_fx.c | 30 +- lib_dec/er_dec_acelp_fx.c | 234 ++--- lib_dec/er_dec_tcx_fx.c | 372 ++++---- lib_dec/ivas_decision_matrix_dec.c | 13 +- lib_dec/ivas_dirac_dec.c | 405 +++++---- lib_dec/ivas_dirac_output_synthesis_cov.c | 206 ++--- lib_dec/tonalMDCTconcealment.c | 58 +- lib_dec/tonalMDCTconcealment_fx.c | 506 +++++------ lib_dec/transition_dec_fx.c | 52 +- lib_dec/updt_dec_fx.c | 87 +- lib_dec/vlpc_1st_dec_fx.c | 6 +- lib_dec/vlpc_2st_dec_fx.c | 2 +- lib_dec/voiced_dec_fx.c | 12 +- lib_dec/waveadjust_fec_dec_fx.c | 130 +-- lib_rend/ivas_dirac_output_synthesis_dec.c | 965 +++++++++++---------- 15 files changed, 1578 insertions(+), 1500 deletions(-) diff --git a/lib_dec/dlpc_stoch_fx.c b/lib_dec/dlpc_stoch_fx.c index e06a2d515..6583c91de 100644 --- a/lib_dec/dlpc_stoch_fx.c +++ b/lib_dec/dlpc_stoch_fx.c @@ -15,14 +15,14 @@ void lpc_unquantize_fx( Decoder_State *st, - Word16 *lsf, - Word16 *lsp, + Word16 *lsf, /*x2.56*/ + Word16 *lsp, /*Q15*/ const Word16 m, - Word16 *param_lpc, - Word16 *lspmid, - Word16 *lsfmid, + Word16 *param_lpc, /*Q0*/ + Word16 *lspmid, /*Q15*/ + Word16 *lsfmid, /*x2.56*/ Word16 coder_type, - Word16 *LSF_Q_prediction /* o : LSF prediction mode */ + Word16 *LSF_Q_prediction /* o : LSF prediction mode Q0*/ ) { Word16 nb_indices, k; @@ -31,15 +31,15 @@ void lpc_unquantize_fx( nb_indices = 0; /* to avoid compilation warnings */ move16(); - Copy( st->lsf_old_fx, &lsf[0], m ); - Copy( st->lsp_old_fx, &lsp[0], m ); + Copy( st->lsf_old_fx, &lsf[0], m ); /*x2.56*/ + Copy( st->lsp_old_fx, &lsp[0], m ); /*x2.56*/ IF( st->lpcQuantization == 0 ) { - nb_indices = dlpc_avq_fx( param_lpc, &lsf[m], st->numlpc, st->sr_core ); + nb_indices = dlpc_avq_fx( param_lpc, &lsf[m], st->numlpc, st->sr_core ); /*Q0*/ FOR( k = 0; k < st->numlpc; k++ ) { - E_LPC_lsf_lsp_conversion( &lsf[imult1616( add( k, 1 ), m )], &lsp[imult1616( add( k, 1 ), m )], m ); + E_LPC_lsf_lsp_conversion( &lsf[( ( k + 1 ) * m )], &lsp[( ( k + 1 ) * m )], m ); /*Q15*/ } } ELSE IF( EQ_16( st->lpcQuantization, 1 ) ) @@ -76,7 +76,7 @@ void lpc_unquantize_fx( } } - lsf2lsp_fx( &lsf[m], &lsp[m], M, st->sr_core ); + lsf2lsp_fx( &lsf[m], &lsp[m], M, st->sr_core ); /*Q15*/ } ELSE { @@ -87,7 +87,7 @@ void lpc_unquantize_fx( move16(); FOR( i = nb_indices - 1; i >= 0; i-- ) { - st->seed_acelp = extract_l( L_mac0( L_mac0( 13849, shr( st->seed_acelp, 1 ), 31821 ), param_lpc[i], 31821 ) ); + st->seed_acelp = extract_l( L_mac0( L_mac0( 13849 /*Q0*/, shr( st->seed_acelp, 1 ), 31821 /*Q0*/ ), param_lpc[i], 31821 /*Q0*/ ) ); /*Q0*/ } /* Decoded mid-frame isf */ @@ -96,9 +96,9 @@ void lpc_unquantize_fx( test(); IF( st->lpcQuantization && st->acelp_cfg.midLpc && EQ_16( st->core, ACELP_CORE ) && st->rate_switching_reset == 0 ) { - midlsf_dec( &lsf[0], &lsf[m], param_lpc[nb_indices], lsfmid, coder_type, &( st->mid_lsf_int ), st->prev_bfi, st->safety_net ); - reorder_lsf_fx( lsfmid, LSF_GAP_MID_FX, M, st->sr_core ); - lsf2lsp_fx( lsfmid, lspmid, M, st->sr_core ); + midlsf_dec( &lsf[0], &lsf[m], param_lpc[nb_indices], lsfmid, coder_type, &( st->mid_lsf_int ), st->prev_bfi, st->safety_net ); /*3Q12*/ + reorder_lsf_fx( lsfmid, LSF_GAP_MID_FX, M, st->sr_core ); /*x2.56*/ + lsf2lsp_fx( lsfmid, lspmid, M, st->sr_core ); /*Q15*/ } diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index b093fb129..3d2fdee1c 100644 --- a/lib_dec/er_dec_acelp_fx.c +++ b/lib_dec/er_dec_acelp_fx.c @@ -37,11 +37,11 @@ void con_acelp_fx( Word16 *pgainT, /*mem_syn >rescaling done */ - Word16 *pitch_buffer, - Word16 *voice_factors, - Word16 *bwe_exc ) + const Word16 *Qf_exc, /*mem_syn >rescaling done */ + Word16 *pitch_buffer, /* Q0 */ + Word16 *voice_factors, /* Q6 */ + Word16 *bwe_exc /* Qx */ ) { Word16 i_subfr, i, T0; /*Q0*/ @@ -115,12 +115,12 @@ void con_acelp_fx( *------------------------------------------------------------------------*/ /* set ACELP synthesis memory */ - Copy( st->mem_syn2_fx, mem_syn, M ); + Copy( st->mem_syn2_fx, mem_syn, M ); /* Q_syn */ /* set excitation memory*/ - harmonic_exc_buf = buf + M; - exc = harmonic_exc_buf + L_EXC_MEM_DEC; - Copy( st->old_exc_fx, harmonic_exc_buf, L_EXC_MEM_DEC ); + harmonic_exc_buf = buf + M; /*Qf_exc*/ + exc = harmonic_exc_buf + L_EXC_MEM_DEC; /*Qf_exc*/ + Copy( st->old_exc_fx, harmonic_exc_buf, L_EXC_MEM_DEC ); /*Q_exc*/ exc[st->L_frame] = 0; move16(); @@ -139,7 +139,7 @@ void con_acelp_fx( &st->old_fpitch, &predPitchLag, st->pit_min, st->pit_max, st->mem_pitch_gain, 0, st->plc_use_future_lag, &extrapolationFailed, st->nb_subfr ); - T0 = round_fx( predPitchLag ); + T0 = round_fx( predPitchLag ); /*Q0*/ IF( extrapolationFailed != 0 ) { @@ -160,7 +160,7 @@ void con_acelp_fx( l = shl( L_SUBFR, 1 ); FOR( i = 0; i < l; i++ ) { - exc[i] = exc[sub( i, st->guidedT0 )]; + exc[i] = exc[( i - st->guidedT0 )]; /*Qf_exc*/ move16(); } } @@ -171,11 +171,11 @@ void con_acelp_fx( move16(); } - tmp_tc = st->old_fpitch; - move32(); /* take the previous frame last pitch*/ + tmp_tc = st->old_fpitch; /*15Q16*/ + move32(); /* take the previous frame last pitch*/ if ( nSubframes > 0 ) { - tmp_tc = L_deposit_h( st->guidedT0 ); /* take the transmit pitch*/ + tmp_tc = L_deposit_h( st->guidedT0 ); /* take the transmit pitch*/ /* Q16 */ } /* PLC: [ACELP: Fade-out] @@ -201,7 +201,7 @@ void con_acelp_fx( * Last pitch cycle of the previous frame is repeatedly copied. * *---------------------------------------------------------------*/ - Tc = round_fx( tmp_tc ); + Tc = round_fx( tmp_tc ); /* Q0 */ BASOP_SATURATE_WARNING_OFF_EVS /*if this ever saturates, it doesn't matter*/ #ifdef BASOP_NOGLOB tmp = sub( shl_sat( abs_s( sub( T0, Tc ) ), 6 ), mult( 19661 /*0.15f Q17*/, shl_sat( Tc, 4 ) ) /*Q6*/ ); @@ -221,16 +221,16 @@ void con_acelp_fx( pt_exc = exc; if ( st->enableGplc != 0 ) { - pt_exc = &exc[imult1616( nSubframes, L_SUBFR )]; + pt_exc = &exc[( nSubframes * L_SUBFR )]; /*Qf_exc*/ } - pt1_exc = pt_exc - Tc; + pt1_exc = pt_exc - Tc; /*Qf_exc*/ IF( fUseExtrapolatedPitch != 0 ) { /* Required because later pt1_exc[1] used in filtering points to exc[0]. To make it safe also for GPL pt_exc is used instead of exc */ pt_exc[0] = 0; move16(); - pt_exc = harmonic_exc_buf; + pt_exc = harmonic_exc_buf; /*Qf_exc*/ assert( pt_exc < pt1_exc - 1 ); } @@ -249,10 +249,10 @@ void con_acelp_fx( { /* *pt_exc++ = ( lpFiltAdapt[0] * pt1_exc[-1] + lpFiltAdapt[1] * pt1_exc[0] + lpFiltAdapt[2] * pt1_exc[1]);*/ - tmp_32 = L_mult( lpFiltAdapt[0], pt1_exc[-1] ); - tmp_32 = L_mac( tmp_32, lpFiltAdapt[1], pt1_exc[0] ); - tmp_16 = mac_r( tmp_32, lpFiltAdapt[2], pt1_exc[1] ); - *pt_exc = tmp_16; + tmp_32 = L_mult( lpFiltAdapt[0], pt1_exc[-1] ); /*Q16 + Qf_exc*/ + tmp_32 = L_mac( tmp_32, lpFiltAdapt[1], pt1_exc[0] ); /*Q16 + Qf_exc*/ + tmp_16 = mac_r( tmp_32, lpFiltAdapt[2], pt1_exc[1] ); /*Qf_exc*/ + *pt_exc = tmp_16; /*Qf_exc*/ move16(); pt_exc++; pt1_exc++; @@ -263,20 +263,20 @@ void con_acelp_fx( /* copy the first pitch cycle without low-pass filtering */ FOR( i = 0; i < Tc; i++ ) { - *pt_exc++ = *pt1_exc++; + *pt_exc++ = *pt1_exc++; /*Qf_exc*/ move16(); } } if ( fUseExtrapolatedPitch != 0 ) { - pt1_exc = harmonic_exc_buf; + pt1_exc = harmonic_exc_buf; /*Qf_exc*/ } l = add( st->L_frame, sub( imult1616( L_SUBFR, sub( 1, nSubframes ) ), Tc ) ); FOR( i = 0; i < l; i++ ) { - *pt_exc++ = *pt1_exc++; + *pt_exc++ = *pt1_exc++; /*Qf_exc*/ move16(); } @@ -287,9 +287,9 @@ void con_acelp_fx( IF( nSubframes > 0 ) { - pitch_buf[0] = L_deposit_h( st->guidedT0 ); + pitch_buf[0] = L_deposit_h( st->guidedT0 ); /*Q16*/ move32(); - pitch_buf[1] = L_deposit_h( st->guidedT0 ); + pitch_buf[1] = L_deposit_h( st->guidedT0 ); /*Q16*/ move32(); } @@ -301,7 +301,7 @@ void con_acelp_fx( if ( EQ_16( st->nb_subfr, 5 ) ) { /* for guided acelp cases and nSubframes=2, set pitch_buf[4] to avoid memory_access issues in post_decoder() */ - pitch_buf[4] = pitch_buf[3]; + pitch_buf[4] = pitch_buf[3]; /*Q16*/ move32(); } } @@ -315,7 +315,7 @@ void con_acelp_fx( } ELSE { - set32_fx( pitch_buf, st->old_fpitch, st->nb_subfr ); + set32_fx( pitch_buf, st->old_fpitch, st->nb_subfr ); /*15Q16*/ } } @@ -323,8 +323,8 @@ void con_acelp_fx( * PLC: [ACELP: adaptive codebook] * PLC: Create the harmonic part needed for the overlap-add. *------------------------------------------------------------*/ - pt_exc = exc + st->L_frame; - pt1_exc = pt_exc - T0; + pt_exc = exc + st->L_frame; /*Qf_exc*/ + pt1_exc = pt_exc - T0; /*Qf_exc*/ if ( T0 == 0 ) { pt1_exc = pt_exc - Tc; @@ -343,11 +343,11 @@ void con_acelp_fx( IF( fUseExtrapolatedPitch != 0 ) { - st->old_fpitch = predPitchLag; + st->old_fpitch = predPitchLag; /*Q16*/ move32(); if ( EQ_16( st->flagGuidedAcelp, 1 ) ) { - st->old_fpitch = L_deposit_h( T0 ); + st->old_fpitch = L_deposit_h( T0 ); /*Q16*/ move32(); } } @@ -371,8 +371,8 @@ void con_acelp_fx( /* mapping: floor(( 0.824[15Q15]-x[15Q0]*0.0733[0Q15] )*4) */ - pc = Mpy_32_16_1( L_shl( pc, 1 ) /*precompensate Q14 from table*/, /*15Q16*/ - T_256DIV_L_Frame[L_shr( L_msu0( 54000, shr( st->L_frame, 5 ), 2402 ), 15 - 2 )] ); + pc = Mpy_32_16_1( L_shl( pc, 1 ) /*precompensate Q14 from table*/, /*15Q16*/ + T_256DIV_L_Frame[L_shr( L_msu0( 54000, shr( st->L_frame, 5 ), 2402 ), 15 - 2 )] ); /*Q16*/ test(); test(); /*test();*/ @@ -421,9 +421,9 @@ void con_acelp_fx( { BASOP_SATURATE_WARNING_OFF_EVS #ifdef BASOP_NOGLOB - exc[i] = mult_r( exc[i], shl_sat( gain, 1 ) ); /*overflow is first iteration because gain may be 1 after shift*/ + exc[i] = mult_r( exc[i], shl_sat( gain, 1 ) ); /*overflow is first iteration because gain may be 1 after shift*/ /*Qf_exc*/ #else - exc[i] = mult_r( exc[i], shl( gain, 1 ) ); /*overflow is first iteration because gain may be 1 after shift*/ + exc[i] = mult_r( exc[i], shl( gain, 1 ) ); /*overflow is first iteration because gain may be 1 after shift*/ /*Qf_exc*/ #endif BASOP_SATURATE_WARNING_ON_EVS move16(); @@ -436,9 +436,9 @@ void con_acelp_fx( { BASOP_SATURATE_WARNING_OFF_EVS #ifdef BASOP_NOGLOB - exc[i] = mult_r( exc[i], shl_sat( gain, 1 ) ); /*overflow is first iteration because gain may become 1 due to shift*/ + exc[i] = mult_r( exc[i], shl_sat( gain, 1 ) ); /*overflow is first iteration because gain may become 1 due to shift*/ /*Qf_exc*/ #else - exc[i] = mult_r( exc[i], shl( gain, 1 ) ); /*overflow is first iteration because gain may become 1 due to shift*/ + exc[i] = mult_r( exc[i], shl( gain, 1 ) ); /*overflow is first iteration because gain may become 1 due to shift*/ /*Qf_exc*/ #endif BASOP_SATURATE_WARNING_ON_EVS move16(); @@ -449,12 +449,12 @@ void con_acelp_fx( { pT[i] = round_fx( pitch_buf[i] ); /*Q0*/ move16(); - pitch_buffer[i] = round_fx( pitch_buf[i] ); + pitch_buffer[i] = round_fx( pitch_buf[i] ); /*Q0*/ move16(); } /* update old exc without random part*/ - Copy( harmonic_exc_buf + st->L_frame, st->old_exc_fx, L_EXC_MEM_DEC ); + Copy( harmonic_exc_buf + st->L_frame, st->old_exc_fx, L_EXC_MEM_DEC ); /*Qf_exc*/ } ELSE { @@ -468,9 +468,9 @@ void con_acelp_fx( move32(); pgainT[i] = 0; move16(); - pT[i] = L_SUBFR; + pT[i] = L_SUBFR; /*Q0*/ move16(); - pitch_buffer[i] = L_SUBFR; + pitch_buffer[i] = L_SUBFR; /*Q0*/ move16(); } @@ -486,7 +486,7 @@ void con_acelp_fx( * * search for "Scale from randomized buffer to excitation buffer" *-----------------------------------------------------------------*/ - noise_buf = buf; + noise_buf = buf; /*Qf_exc*/ tmpSeed = st->seed_acelp; move16(); l = add( st->L_frame, sub( l_fir_fer, 1 ) ); @@ -516,7 +516,7 @@ void con_acelp_fx( /* PLC: [ACELP: Fade-out] * PLC: retrieve background level */ - tmp2 = shl( div_s( st->L_frame, shl( L_SUBFR, 3 ) ), 3 - 15 ); + tmp2 = shl( div_s( st->L_frame, shl( L_SUBFR, 3 ) ), 3 - 15 ); /*Q0*/ tmp = 32767 /*1.0f Q15*/; @@ -545,11 +545,11 @@ void con_acelp_fx( #ifdef BASOP_NOGLOB ftmp = round_fx_sat( L_shl_sat( gain_32, 1 ) ); /*Q0*/ #else - ftmp = round_fx( L_shl( gain_32, 1 ) ); /*Q0*/ + ftmp = round_fx( L_shl( gain_32, 1 ) ); /*Q0*/ #endif BASOP_SATURATE_WARNING_OFF_EVS #ifdef BASOP_NOGLOB - tmp_16 = sub( shl_sat( gainCNG, sub( gainCNG_e, 5 /*Q5*/ ) ), ftmp ); + tmp_16 = sub( shl_sat( gainCNG, sub( gainCNG_e, 5 /*Q5*/ ) ), ftmp ); /*Q0*/ #else tmp_16 = sub( shl( gainCNG, sub( gainCNG_e, 5 /*Q5*/ ) ), ftmp ); #endif @@ -594,7 +594,7 @@ void con_acelp_fx( s2 = sub( s2, 4 - 15 ); /*->Q15*/ s_16 = BASOP_Util_Add_MantExp( tmp_16, s_16, tmp2, s2, &tmp_16 ); - st->Mode2_lp_gainc = L_shl( L_deposit_l( tmp_16 ), add( s_16, 1 ) ); + st->Mode2_lp_gainc = L_shl( L_deposit_l( tmp_16 ), add( s_16, 1 ) ); /*Q16*/ move32(); test(); IF( ( EQ_16( st->last_good, UNVOICED_TRANSITION ) ) && ( EQ_16( coder_type, GENERIC ) ) ) @@ -607,13 +607,13 @@ void con_acelp_fx( highPassFiltering_fx( st->last_good, add( st->L_frame, shr( l_fir_fer, 1 ) ), noise_buf, hp_filt, l_fir_fer ); - pt_exc = noise_buf + shr( l_fir_fer, 1 ); + pt_exc = noise_buf + shr( l_fir_fer, 1 ); /*Qf_exc*/ /*** Find energy normalization factor ***/ /*gain_inov = 1.0f / (float)sqrt( dot_product( pt_exc, pt_exc, st->L_frame ) / st->L_frame );*/ /* normalize energy */ /*<--- FLC*/ - BASOP_SATURATE_WARNING_OFF_EVS /*norm_llQ31 at the end of Dot_productSq16HQ may throw an overflow, but result is okay*/ - tmp_32 = Dot_productSq16HQ( 0, pt_exc, st->L_frame, &s_32 ); + BASOP_SATURATE_WARNING_OFF_EVS /*norm_llQ31 at the end of Dot_productSq16HQ may throw an overflow, but result is okay*/ + tmp_32 = Dot_productSq16HQ( 0, pt_exc, st->L_frame, &s_32 ); /*Q31*/ BASOP_SATURATE_WARNING_ON_EVS s_32 = add( s_32, 31 - 1 ); /*scalingfactor is twice the headroom (at noise insertion onto the buffer), -1 (because of mult) +31 (Result is Q31) +s_32 (output scalingfactor of dot_product)*/ @@ -629,7 +629,7 @@ void con_acelp_fx( { s_gain_inov = s_32; move16(); - tmp_32 = ISqrt32( tmp_32, &s_gain_inov ); + tmp_32 = ISqrt32( tmp_32, &s_gain_inov ); /* Q31 - s_gain_inov */ } ELSE { @@ -640,7 +640,7 @@ void con_acelp_fx( } - gain_inov = round_fx( tmp_32 ); /*Inverse sqrt*/ /* Q15 * 2^s_gain_inov */ + gain_inov = round_fx( tmp_32 ); /*Inverse sqrt*/ /* Q15 * 2^s_gain_inov */ /* Q15 - s_gain_inov */ /* PLC: [ACELP: Fade-out] * PLC: Linearly attenuate the gain through the frame */ @@ -661,12 +661,12 @@ void con_acelp_fx( Word16 tilt_code; /*tilt_code = (float)(0.10f*(1.0f + st->voice_fac));*/ - tilt_code = mac_r( 214748368l /*0.1f Q31*/, 3277 /*0.1f Q15*/, st->voice_fac ); + tilt_code = mac_r( 214748368l /*0.1f Q31*/, 3277 /*0.1f Q15*/, st->voice_fac ); /*Q15*/ gain_inov = mult_r( gain_inov, sub( 32767 /*1.0f Q15*/, tilt_code ) ); /* Q15 * 2^s_gain_inov */ } - pt_exc = noise_buf; + pt_exc = noise_buf; /*Qf_exc*/ /* non-causal ringing of the FIR filter */ @@ -690,9 +690,9 @@ void con_acelp_fx( g_e = norm_s( round_fx( L_shl( Mpy_32_16_1( st->Mode2_lp_gainc, gain_inov ), add( 15, s_gain_inov ) ) ) ); /* norm_s for gain*gain_inov at the end of the following loops */ #endif g_e = s_min( norm_s( gain_16 ), g_e ); - gain_16 = shl( gain_16, g_e ); - gain_32 = L_shl( gain_32, g_e ); - step_32 = L_shl( step_32, g_e ); + gain_16 = shl( gain_16, g_e ); /*Q15 + g_e*/ + gain_32 = L_shl( gain_32, g_e ); /*Q31 + g_e*/ + step_32 = L_shl( step_32, g_e ); /*Q31 + g_e*/ l = shr( l_fir_fer, 1 ); FOR( i = 0; i < l; i++ ) { @@ -711,7 +711,7 @@ void con_acelp_fx( pt_exc++; gain_32 = L_sub( gain_32, step_32 ); - gain_16 = round_fx( gain_32 ); + gain_16 = round_fx( gain_32 ); /*Q15*/ } l = add( shr( st->L_frame, 1 ), shr( l_fir_fer, 1 ) ); @@ -735,36 +735,36 @@ void con_acelp_fx( IF( LT_16( st->last_good, UNVOICED_TRANSITION ) ) { - bufferCopyFx( noise_buf + shr( l_fir_fer, 1 ), exc, add( st->L_frame, shr( st->L_frame, 1 ) ), 0, *Qf_exc, negate( g_e ), 0 ); /*copy between different formats*/ - Copy( harmonic_exc_buf + st->L_frame, st->old_exc_fx, L_EXC_MEM_DEC ); - Copy( exc, exc_unv, add( st->L_frame, shr( st->L_frame, 1 ) ) ); /* Update exc_unv */ + bufferCopyFx( noise_buf + shr( l_fir_fer, 1 ), exc, add( st->L_frame, shr( st->L_frame, 1 ) ), 0, *Qf_exc, negate( g_e ), 0 ); /*copy between different formats*/ /*Qf_exc*/ + Copy( harmonic_exc_buf + st->L_frame, st->old_exc_fx, L_EXC_MEM_DEC ); /*Qf_exc*/ + Copy( exc, exc_unv, add( st->L_frame, shr( st->L_frame, 1 ) ) ); /* Update exc_unv */ /*Qf_exc*/ } ELSE { /* Update exc_unv */ - bufferCopyFx( noise_buf + shr( l_fir_fer, 1 ), exc_unv, add( st->L_frame, shr( st->L_frame, 1 ) ), 0, *Qf_exc, negate( g_e ), 0 ); /*copy between different formats*/ + bufferCopyFx( noise_buf + shr( l_fir_fer, 1 ), exc_unv, add( st->L_frame, shr( st->L_frame, 1 ) ), 0, *Qf_exc, negate( g_e ), 0 ); /*copy between different formats*/ /*Qf_exc*/ } /* Compute total excitation in noisebuffer to save memories */ IF( GE_16( st->last_good, UNVOICED_TRANSITION ) ) { - Vr_add( exc, exc_unv, noise_buf, add( st->L_frame, 1 ) ); + Vr_add( exc, exc_unv, noise_buf, add( st->L_frame, 1 ) ); /*Qf_exc*/ } ELSE { - noise_buf = exc_unv; + noise_buf = exc_unv; /*Qf_exc*/ } IF( st->hBWE_TD != NULL ) { IF( EQ_16( st->L_frame, L_FRAME ) ) { interp_code_5over2_fx( noise_buf, bwe_exc, st->L_frame ); - set16_fx( voice_factors, st->last_voice_factor_fx, NB_SUBFR ); + set16_fx( voice_factors, st->last_voice_factor_fx, NB_SUBFR ); /* Q6 */ } ELSE { interp_code_4over2_fx( noise_buf, bwe_exc, st->L_frame ); - set16_fx( voice_factors, st->last_voice_factor_fx, NB_SUBFR16k ); + set16_fx( voice_factors, st->last_voice_factor_fx, NB_SUBFR16k ); /* Q6 */ } } /*----------------------------------------------------------* @@ -773,13 +773,13 @@ void con_acelp_fx( /* Init syn buffer */ syn = buf + M; - Copy( st->mem_syn2_fx, buf, M ); + Copy( st->mem_syn2_fx, buf, M ); /*Q_syn*/ IF( EQ_16( st->nbLostCmpt, 1 ) ) { IF( LT_16( st->last_good, UNVOICED_TRANSITION ) ) { - Copy( st->mem_syn2_fx, mem_syn_unv, M ); + Copy( st->mem_syn2_fx, mem_syn_unv, M ); /*Q_syn*/ } ELSE { @@ -788,7 +788,7 @@ void con_acelp_fx( } ELSE { - Copy( st->mem_syn_unv_back, mem_syn_unv, M ); + Copy( st->mem_syn_unv_back, mem_syn_unv, M ); /*Q_syn*/ } /* voiced synth */ @@ -810,11 +810,11 @@ void con_acelp_fx( /* i_subfr / L_SUBFR */ tmp_16 = shr( i_subfr, Q6 ); /* gain_lpc[i_subfr/L_SUBFR] = 1.f/(float)sqrt(dotp( h1, h1, L_SUBFR)); */ - tmp_32 = Dot_productSq16HQ( 0, h1, L_SUBFR, &gain_lpc_e[tmp_16] ); + tmp_32 = Dot_productSq16HQ( 0, h1, L_SUBFR, &gain_lpc_e[tmp_16] ); /*Q31*/ tmp_32 = L_max( tmp_32, 1 ); gain_lpc_e[tmp_16] = add( gain_lpc_e[tmp_16], shl( scale_h1, 1 ) ); move16(); - gain_lpc[tmp_16] = round_fx( ISqrt32( tmp_32, &gain_lpc_e[tmp_16] ) ); + gain_lpc[tmp_16] = round_fx( ISqrt32( tmp_32, &gain_lpc_e[tmp_16] ) ); /* Q15 - gain_lpc_e[tmp_16] */ move16(); p_A += ( M + 1 ); /* Pointer move */ @@ -826,10 +826,10 @@ void con_acelp_fx( { /* i_subfr / L_SUBFR */ tmp_16 = shr( i_subfr, Q6 ); - g = mult_r( st->last_gain_syn_deemph, gain_lpc[tmp_16] ); + g = mult_r( st->last_gain_syn_deemph, gain_lpc[tmp_16] ); /* Q15 - gain_lpc_e[tmp_16] */ #ifdef BASOP_NOGLOB g_e = add_sat( st->last_gain_syn_deemph_e, gain_lpc_e[tmp_16] ); - g = shl_sat( g, g_e ); + g = shl_sat( g, g_e ); /* Q15 */ #else g_e = add( st->last_gain_syn_deemph_e, gain_lpc_e[tmp_16] ); g = shl( g, g_e ); @@ -838,14 +838,14 @@ void con_acelp_fx( FOR( i = 0; i < L_SUBFR; i++ ) { /* exc[i_subfr + i] *= st->last_gain_syn_deemph*gain_lpc[j]; */ - exc[i_subfr + i] = mult_r( exc[add( i_subfr, i )], g ); + exc[i_subfr + i] = mult_r( exc[( i_subfr + i )], g ); /*Qf_exc*/ move16(); } } l = add( st->L_frame, shr( st->L_frame, 1 ) ); FOR( i = st->L_frame; i < l; i++ ) { - exc[i] = mult_r( exc[i], g ); + exc[i] = mult_r( exc[i], g ); /*Qf_exc*/ move16(); } @@ -866,7 +866,7 @@ void con_acelp_fx( E_UTIL_synthesis( synthScaling, p_A, &exc[i_subfr], &syn[i_subfr], L_SUBFR, mem_syn, 1, M ); p_A += ( M + 1 ); } - Copy( mem_syn, mem_syn2, M ); + Copy( mem_syn, mem_syn2, M ); /*Qf_syn + s_16*/ /* synthesize ola*/ E_UTIL_synthesis( synthScaling, p_A - ( M + 1 ), &exc[i_subfr], &syn[i_subfr], shr( st->L_frame, 1 ), mem_syn2, 0, M ); } @@ -875,8 +875,8 @@ void con_acelp_fx( IF( GT_16( st->nbLostCmpt, 5 ) && ( s_16 > 0 ) ) { /*scale back mem_syn, exc and synthesis*/ - Scale_sig( mem_syn, M, negate( s_16 ) ); - Scale_sig( syn, add( shr( st->L_frame, 1 ), st->L_frame ), negate( s_16 ) ); + Scale_sig( mem_syn, M, negate( s_16 ) ); /* Qf_syn */ + Scale_sig( syn, add( shr( st->L_frame, 1 ), st->L_frame ), negate( s_16 ) ); /* Qf_syn */ /*Scale_sig(exc, add(shr(st->L_frame,1),st->L_frame) ,negate(s_16));*/ } @@ -900,11 +900,11 @@ void con_acelp_fx( /* i_subfr / L_SUBFR */ tmp_16 = shr( i_subfr, Q6 ); /* gain_lpc[i_subfr/L_SUBFR] = 1.f/(float)sqrt(dotp( h1, h1, L_SUBFR)); */ - tmp_32 = Dot_productSq16HQ( 0, h1, L_SUBFR, &gain_lpc_e[tmp_16] ); + tmp_32 = Dot_productSq16HQ( 0, h1, L_SUBFR, &gain_lpc_e[tmp_16] ); /*Q31*/ tmp_32 = L_max( tmp_32, 1 ); gain_lpc_e[tmp_16] = add( gain_lpc_e[tmp_16], shl( scale_h1, 1 ) ); move16(); - gain_lpc[tmp_16] = round_fx( ISqrt32( tmp_32, &gain_lpc_e[tmp_16] ) ); + gain_lpc[tmp_16] = round_fx( ISqrt32( tmp_32, &gain_lpc_e[tmp_16] ) ); /* Q15 - gain_lpc_e[tmp_16] */ move16(); p_A += ( M + 1 ); /* Pointer move */ @@ -916,24 +916,24 @@ void con_acelp_fx( { /* i_subfr / L_SUBFR */ tmp_16 = shr( i_subfr, Q6 ); - g = mult_r( st->last_gain_syn_deemph, gain_lpc[tmp_16] ); + g = mult_r( st->last_gain_syn_deemph, gain_lpc[tmp_16] ); /* Q15 - gain_lpc_e[tmp_16] */ g_e = add( st->last_gain_syn_deemph_e, gain_lpc_e[tmp_16] ); #ifdef BASOP_NOGLOB - g = shl_sat( g, g_e ); + g = shl_sat( g, g_e ); /*Q15*/ #else g = shl( g, g_e ); #endif FOR( i = 0; i < L_SUBFR; i++ ) { /* exc[i_subfr + i] *= st->last_gain_syn_deemph*gain_lpc[j]; */ - exc_unv[add( i_subfr, i )] = mult_r( exc_unv[add( i_subfr, i )], g ); + exc_unv[( i_subfr + i )] = mult_r( exc_unv[add( i_subfr, i )], g ); /*Qf_exc*/ move16(); } } l = add( st->L_frame, shr( st->L_frame, 1 ) ); FOR( i = st->L_frame; i < l; i++ ) { - exc_unv[i] = mult_r( exc_unv[i], g ); + exc_unv[i] = mult_r( exc_unv[i], g ); /*Qf_exc*/ move16(); } @@ -950,18 +950,18 @@ void con_acelp_fx( p_A = st->Aq_cng; /*in case of more than 5 consecutive concealed frames, improve precision of synthesis*/ - memsynPrecission_fx( st->nbLostCmpt, mem_syn_unv, exc_unv, st->L_frame, &s_16 ); + memsynPrecission_fx( st->nbLostCmpt, mem_syn_unv, exc_unv, st->L_frame, &s_16 ); /*Qf_syn + s_16*/ FOR( i_subfr = 0; i_subfr < st->L_frame; i_subfr += L_SUBFR ) { E_UTIL_synthesis( synthScaling, p_A, &exc_unv[i_subfr], &syn_unv[i_subfr], L_SUBFR, mem_syn_unv, 1, M ); p_A += ( M + 1 ); } - Copy( mem_syn_unv, st->mem_syn_unv_back, M ); + Copy( mem_syn_unv, st->mem_syn_unv_back, M ); /*Qf_syn + s_16*/ IF( LT_16( st->last_good, UNVOICED_TRANSITION ) ) { - Copy( mem_syn_unv, mem_syn, M ); + Copy( mem_syn_unv, mem_syn, M ); /*Qf_syn + s_16*/ /* unvoiced for ola */ E_UTIL_synthesis( synthScaling, p_A - ( M + 1 ), &exc_unv[i_subfr], &syn_unv[i_subfr], shr( st->L_frame, 1 ), mem_syn_unv, 0, M ); } @@ -970,18 +970,18 @@ void con_acelp_fx( IF( GT_16( st->nbLostCmpt, 5 ) && ( s_16 > 0 ) ) { /*scale back mem_syn_unv, exc_unv and synthesis*/ - Scale_sig( mem_syn_unv, M, negate( s_16 ) ); + Scale_sig( mem_syn_unv, M, negate( s_16 ) ); /*Qf_syn*/ IF( LT_16( st->last_good, UNVOICED_TRANSITION ) ) { - Scale_sig( mem_syn, M, negate( s_16 ) ); - Scale_sig( syn_unv, add( shr( st->L_frame, 1 ), st->L_frame ), negate( s_16 ) ); + Scale_sig( mem_syn, M, negate( s_16 ) ); /*Qf_syn*/ + Scale_sig( syn_unv, add( shr( st->L_frame, 1 ), st->L_frame ), negate( s_16 ) ); /*Qf_syn*/ } ELSE { - Scale_sig( syn_unv, st->L_frame, negate( s_16 ) ); + Scale_sig( syn_unv, st->L_frame, negate( s_16 ) ); /*Qf_syn*/ } - Scale_sig( st->mem_syn_unv_back, M, negate( s_16 ) ); + Scale_sig( st->mem_syn_unv_back, M, negate( s_16 ) ); /*Qf_syn*/ /*Scale_sig(exc_unv, add(shr(st->L_frame,1),st->L_frame) ,negate(s_16));*/ } @@ -992,7 +992,7 @@ void con_acelp_fx( FOR( i = 0; i < st->L_frame; i++ ) { #ifdef BASOP_NOGLOB - syn[i] = add_sat( syn[i], syn_unv[i] ); + syn[i] = add_sat( syn[i], syn_unv[i] ); /*Qf_syn*/ #else syn[i] = add( syn[i], syn_unv[i] ); #endif @@ -1001,7 +1001,7 @@ void con_acelp_fx( } ELSE { - Copy( syn_unv, syn, add( st->L_frame, shr( st->L_frame, 1 ) ) ); + Copy( syn_unv, syn, add( st->L_frame, shr( st->L_frame, 1 ) ) ); /*Qf_syn*/ } @@ -1072,21 +1072,21 @@ void con_acelp_fx( } /* Update Pitch Lag memory */ - Copy32( &st->old_pitch_buf_fx[st->nb_subfr], st->old_pitch_buf_fx, st->nb_subfr ); - Copy32( pitch_buf, &st->old_pitch_buf_fx[st->nb_subfr], st->nb_subfr ); + Copy32( &st->old_pitch_buf_fx[st->nb_subfr], st->old_pitch_buf_fx, st->nb_subfr ); /*15Q16*/ + Copy32( pitch_buf, &st->old_pitch_buf_fx[st->nb_subfr], st->nb_subfr ); /*15Q16*/ /*updating enr_old parameters*/ frame_ener_fx( st->L_frame, st->last_good, syn, round_fx( tmp_tc ), &( st->enr_old_fx ), 1, 0, 0, 0 ); #ifdef BASOP_NOGLOB - st->enr_old_fx = L_shl_sat( st->enr_old_fx, shl( negate( Qf_syn ), 1 ) ); + st->enr_old_fx = L_shl_sat( st->enr_old_fx, shl( negate( Qf_syn ), 1 ) ); /*Q0*/ #else st->enr_old_fx = L_shl( st->enr_old_fx, shl( negate( Qf_syn ), 1 ) ); #endif move32(); /* update ACELP synthesis memory */ - Copy( mem_syn, st->mem_syn2_fx, M ); - Copy( syn + st->L_frame - L_SYN_MEM, st->mem_syn_r, L_SYN_MEM ); + Copy( mem_syn, st->mem_syn2_fx, M ); /*Qf_syn*/ + Copy( syn + st->L_frame - L_SYN_MEM, st->mem_syn_r, L_SYN_MEM ); /*Qf_syn*/ /*Q_mem_syn_new = Q_mem_syn;*/ /*NOT "+synthScaling", cause mem_syn format is not changed*/ /* Deemphasis and output synth */ @@ -1103,13 +1103,13 @@ void con_acelp_fx( bufferCopyFx( syn + st->L_frame, hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); hTcxDec->Q_syn_Overl_TDAC = add( st->Q_syn, -1 ); move16(); - Copy( syn + sub( st->L_frame, M + 1 ), st->syn, 1 + M ); + Copy( syn + sub( st->L_frame, M + 1 ), st->syn, 1 + M ); /*Qf_syn*/ /* update old_Aq */ - Copy( p_A - ( M + 1 ), st->old_Aq_12_8_fx, M + 1 ); + Copy( p_A - ( M + 1 ), st->old_Aq_12_8_fx, M + 1 ); /*Q12*/ - Copy( syn + st->L_frame, hTcxDec->syn_Overl, shr( st->L_frame, 1 ) ); + Copy( syn + st->L_frame, hTcxDec->syn_Overl, shr( st->L_frame, 1 ) ); /*Qf_syn*/ /* create aliasing and windowing */ @@ -1119,7 +1119,7 @@ void con_acelp_fx( st->hTcxCfg->tcx_curr_overlap_mode = FULL_OVERLAP; move16(); - n = extract_h( L_mult( st->L_frame, 9216 /*(float)N_ZERO_MDCT_NS/(float)FRAME_SIZE_NS Q15*/ ) ); + n = extract_h( L_mult( st->L_frame, 9216 /*(float)N_ZERO_MDCT_NS/(float)FRAME_SIZE_NS Q15*/ ) ); /*Q0*/ hHQ_core->Q_old_wtda_LB = getScaleFactor16( syn + sub( st->L_frame, n ), sub( st->L_frame, n ) ); @@ -1128,15 +1128,15 @@ void con_acelp_fx( bufferCopyFx( syn + sub( st->L_frame, n ), hHQ_core->old_out_LB_fx, sub( st->L_frame, n ), 0, 0, hHQ_core->Q_old_wtda_LB, 0 ); FOR( i = 0; i < W2; i++ ) { - hHQ_core->old_out_LB_fx[add( i, n )] = round_fx( Mpy_32_16_1( L_mult( w[i].v.re, w[i].v.re ), hHQ_core->old_out_LB_fx[add( i, n )] ) ); + hHQ_core->old_out_LB_fx[( i + n )] = round_fx( Mpy_32_16_1( L_mult( w[i].v.re, w[i].v.re ), hHQ_core->old_out_LB_fx[( i + n )] ) ); /* hHQ_core->q_old_outLB_fx */ move16(); } FOR( ; i < W1; i++ ) { - hHQ_core->old_out_LB_fx[i + n] = round_fx( Mpy_32_16_1( L_mult( w[sub( W2, add( 1, sub( i, W2 ) ) )].v.im, w[sub( W2, add( 1, sub( i, W2 ) ) )].v.im ), hHQ_core->old_out_LB_fx[add( i, n )] ) ); + hHQ_core->old_out_LB_fx[i + n] = round_fx( Mpy_32_16_1( L_mult( w[( W2 - ( 1 + ( i - W2 ) ) )].v.im, w[( W2 - ( 1 + ( i - W2 ) ) )].v.im ), hHQ_core->old_out_LB_fx[( i + n )] ) ); /* hHQ_core->q_old_outLB_fx */ move16(); } - set16_fx( &hHQ_core->old_out_LB_fx[add( W1, n )], 0, n ); + set16_fx( &hHQ_core->old_out_LB_fx[( W1 + n )], 0, n ); hHQ_core->Q_old_wtda = hHQ_core->Q_old_wtda_LB; move16(); @@ -1144,38 +1144,38 @@ void con_acelp_fx( FOR( i = 0; i < W2; i++ ) { - buf[i] = mult_r( hTcxDec->syn_Overl_TDAC[i], w[i].v.re ); + buf[i] = mult_r( hTcxDec->syn_Overl_TDAC[i], w[i].v.re ); /*hTcxDec->Q_syn_Overl_TDAC*/ move16(); } FOR( ; i < W1; i++ ) { - buf[i] = mult_r( hTcxDec->syn_Overl_TDAC[i], w[sub( sub( W1, 1 ), i )].v.im ); + buf[i] = mult_r( hTcxDec->syn_Overl_TDAC[i], w[( ( W1 - 1 ) - i )].v.im ); /*hTcxDec->Q_syn_Overl_TDAC*/ move16(); } FOR( i = 0; i < W2; i++ ) { - hTcxDec->syn_Overl_TDAC[i] = add( buf[i], buf[sub( sub( W1, 1 ), i )] ); /* A-D */ + hTcxDec->syn_Overl_TDAC[i] = add( buf[i], buf[( ( W1 - 1 ) - i )] ); /* A-D */ /*hTcxDec->Q_syn_Overl_TDAC*/ move16(); } /*-2*/ FOR( i = 0; i < W2; i++ ) { - hTcxDec->syn_Overl_TDAC[add( W2, i )] = add( buf[add( W2, i )], buf[sub( sub( sub( W1, 1 ), W2 ), i )] ); /* B-C */ + hTcxDec->syn_Overl_TDAC[( W2 + i )] = add( buf[( W2 + i )], buf[( ( ( W1 - 1 ) - W2 ) - i )] ); /* B-C */ /*hTcxDec->Q_syn_Overl_TDAC*/ move16(); } FOR( i = 0; i < W2; i++ ) { - hTcxDec->syn_Overl_TDAC[i] = mult_r( hTcxDec->syn_Overl_TDAC[i], w[i].v.re ); + hTcxDec->syn_Overl_TDAC[i] = mult_r( hTcxDec->syn_Overl_TDAC[i], w[i].v.re ); /*hTcxDec->Q_syn_Overl_TDAC*/ move16(); } FOR( ; i < W1; i++ ) { - hTcxDec->syn_Overl_TDAC[i] = mult_r( hTcxDec->syn_Overl_TDAC[i], w[sub( sub( W1, 1 ), i )].v.im ); + hTcxDec->syn_Overl_TDAC[i] = mult_r( hTcxDec->syn_Overl_TDAC[i], w[( ( W1 - 1 ) - i )].v.im ); /*hTcxDec->Q_syn_Overl_TDAC*/ move16(); } @@ -1192,7 +1192,7 @@ void con_acelp_fx( lerp( exc, st->hWIDec->old_exc2_fx, L_EXC_MEM, st->L_frame ); lerp( syn, st->hWIDec->old_syn2_fx, L_EXC_MEM, st->L_frame ); } - st->bfi_pitch_fx = shl( round_fx( pitch_buf[sub( st->nb_subfr, 1 )] ), 6 ); + st->bfi_pitch_fx = shl( round_fx( pitch_buf[( st->nb_subfr - 1 )] ), 6 ); /*Q6*/ st->bfi_pitch_frame = st->L_frame; move16(); move16(); @@ -1200,7 +1200,7 @@ void con_acelp_fx( return; } -static void memsynPrecission_fx( Word16 nbLostCmpt, Word16 *mem_syn, Word16 *exc, Word16 len, Word16 *s_16 ) +static void memsynPrecission_fx( Word16 nbLostCmpt, Word16 *mem_syn /*Qx*/, Word16 *exc /*Qx*/, Word16 len, Word16 *s_16 ) { IF( GT_16( nbLostCmpt, 5 ) ) { @@ -1242,8 +1242,8 @@ static void memsynPrecission_fx( Word16 nbLostCmpt, Word16 *mem_syn, Word16 *exc } *s_16 = s_max( sub( s_min( sf_exc, sf_mem_syn ), 5 ), 0 ) /*5 bits of headroom, scaling not smaller than 0*/; move16(); - Scale_sig( mem_syn, M, *s_16 ); - Scale_sig( exc, add( shr( len, 1 ), len ), *s_16 ); + Scale_sig( mem_syn, M, *s_16 ); /*Qx + s_16*/ + Scale_sig( exc, add( shr( len, 1 ), len ), *s_16 ); /*Qx + s_16*/ } } } diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 4158368c6..1a1dbce92 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -14,7 +14,7 @@ /***************************************************** calcGainc calculates st->lp_gainc ******************************************************/ -static void calcGainc_fx( Word16 *exc, Word16 Q_exc, Word32 old_fpitch, Word16 L_subfr, Word32 lp_gainp, Word32 *lp_gainc ) +static void calcGainc_fx( Word16 *exc, Word16 Q_exc, Word32 old_fpitch /*Q16*/, Word16 L_subfr /*Q0*/, Word32 lp_gainp /*Q16*/, Word32 *lp_gainc /*Q16*/ ) { Word32 L_c; Word16 tmp16, tmp16_2, tmp16_3, tmp_e, tmp2_e, tmp_loop, i; @@ -49,7 +49,7 @@ static void calcGainc_fx( Word16 *exc, Word16 Q_exc, Word32 old_fpitch, Word16 L /*st->lp_gainc += ( exc[i-2*L_subfr] - st->Mode2_lp_gainp * exc[i-2*L_subfr-(int)(st->old_fpitch+0.5f)] ) * ( exc[i-2*L_subfr] - st->Mode2_lp_gainp * exc[i-2*L_subfr-(int)(st->old_fpitch+0.5f)] );*/ #ifdef BASOP_NOGLOB - tmp16_3 = sub_o( exc[sub( i, shl( L_subfr, 1 ) )] /*Q1*/, mult_r( tmp16_2 /*Q15*/, exc[sub( sub( i, shl( L_subfr, 1 ) ), tmp16 )] /*Q1*/ ) /*Q1*/, &Overflow ); + tmp16_3 = sub_o( exc[( i - ( L_subfr * 2 ) )] /*Q1*/, mult_r( tmp16_2 /*Q15*/, exc[( ( i - ( L_subfr * 2 ) ) - tmp16 )] /*Q1*/ ) /*Q1*/, &Overflow ); #else tmp16_3 = sub( exc[sub( i, shl( L_subfr, 1 ) )] /*Q1*/, mult_r( tmp16_2 /*Q15*/, exc[sub( sub( i, shl( L_subfr, 1 ) ), tmp16 )] /*Q1*/ ) /*Q1*/ ); #endif @@ -61,7 +61,7 @@ static void calcGainc_fx( Word16 *exc, Word16 Q_exc, Word32 old_fpitch, Word16 L Overflow = 0; move16(); #ifdef BASOP_NOGLOB - L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Accumulate Carrys*/ + L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Accumulate Carrys Q-1*/ #else L_c = L_macNs( L_c, 0, 0 ); /*Accumulate Carrys*/ #endif @@ -81,7 +81,7 @@ static void calcGainc_fx( Word16 *exc, Word16 Q_exc, Word32 old_fpitch, Word16 L move32(); } -static void calcGainc2_fx( Word16 *exc, Word16 Q_exc, Word16 L_subfr, Word32 *lp_gainc ) +static void calcGainc2_fx( Word16 *exc, Word16 Q_exc, Word16 L_subfr /*Q0*/, Word32 *lp_gainc /*Q16*/ ) { Word16 i, cnt, tmp16, tmp_e, tmp2_e; Word32 L_c, L_acc, L_tmp; @@ -106,15 +106,15 @@ static void calcGainc2_fx( Word16 *exc, Word16 Q_exc, Word16 L_subfr, Word32 *lp FOR( i = 0; i < cnt; i++ ) { /* *gainc += ( exc[i-2*L_subfr] ) * ( exc[i-2*L_subfr]); */ -#ifdef BASOP_NOGLOB /* Critical Carry/Overflow */ - L_acc = L_macNs_co( L_acc, exc[sub( i, shl( L_subfr, 1 ) )] /*Q1*/, exc[sub( i, shl( L_subfr, 1 ) )] /*Q1*/, &Carry, &Overflow ); /*Q3*/ +#ifdef BASOP_NOGLOB /* Critical Carry/Overflow */ + L_acc = L_macNs_co( L_acc, exc[( i - ( L_subfr * 2 ) )] /*Q1*/, exc[( i - ( L_subfr * 2 ) )] /*Q1*/, &Carry, &Overflow ); /*Q3*/ #else L_acc = L_macNs( L_acc, exc[sub( i, shl( L_subfr, 1 ) )] /*Q1*/, exc[sub( i, shl( L_subfr, 1 ) )] /*Q1*/ ); /*Q3*/ #endif Overflow = 0; move16(); #ifdef BASOP_NOGLOB /* Critical Carry/Overflow */ - L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /* Accumulate Carrys */ + L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /* Accumulate Carrys Q-1*/ #else L_c = L_macNs( L_c, 0, 0 ); /* Accumulate Carrys */ #endif @@ -144,16 +144,16 @@ con_tcx *******************************************************/ void con_tcx_fx( - Decoder_State *st, /* i/o: coder memory state */ - Word16 synth[] /* i/o: synth[] */ /*Q0 */ + Decoder_State *st, /* i/o: coder memory state */ + Word16 synth[] /* i/o: synth[] Q0*/ #ifdef IVAS_CODE_CON_TCX , - const Word16 coh, /* i : coherence of stereo signal */ - Word16 *noise_seed, /* i/o: noise seed for stereo */ - const Word16 only_left /* i : TD-PLC only in left channel */ + const Word16 coh, /* i : coherence of stereo signal Q14*/ + Word16 *noise_seed, /* i/o: noise seed for stereo Q0*/ + const Word16 only_left /* i : TD-PLC only in left channel Q0*/ #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT , - const float *A_cng /* i : CNG LP filter coefficients */ + const float *A_cng /* i : CNG LP filter coefficients Q14*/ #endif #endif @@ -211,20 +211,20 @@ void con_tcx_fx( move16(); /* Framing parameters */ - L_frame = hTcxDec->L_frameTCX; + L_frame = hTcxDec->L_frameTCX; /*Q0*/ move16(); /* L_subfr = st->L_frameTCX/st->nb_subfr */ - L_subfr = mult_r( hTcxDec->L_frameTCX, div_s( 1, st->nb_subfr ) ); + L_subfr = mult_r( hTcxDec->L_frameTCX, div_s( 1, st->nb_subfr ) ); /*Q0*/ assert( L_subfr == hTcxDec->L_frameTCX / st->nb_subfr ); move32(); - w = st->hTcxCfg->tcx_mdct_windowFB; /*pointer - no need to instrument*/ + w = st->hTcxCfg->tcx_mdct_windowFB; /*pointer - no need to instrument Q15*/ W1 = st->hTcxCfg->tcx_mdct_window_lengthFB; move16(); W2 = shr( st->hTcxCfg->tcx_mdct_window_lengthFB, 1 ); W12 = shr( W1, 1 ); /* take the previous frame last pitch */ - Tc = round_fx( st->old_fpitchFB ); + Tc = round_fx( st->old_fpitchFB ); /*Q0*/ set16_fx( buf, 0, OLD_EXC_SIZE_DEC + L_FRAME_MAX + L_FRAME_MAX / NB_SUBFR + 1 + L_FRAME_MAX / 2 ); /* initialize buf with 0 */ @@ -237,37 +237,37 @@ void con_tcx_fx( FOR( i = 0; i < 2 * NB_SUBFR16k + 2; i++ ) { - old_pitch_buf[i] = L_shl( Mpy_32_16_1( st->old_pitch_buf_fx[i], c ), s ); + old_pitch_buf[i] = L_shl( Mpy_32_16_1( st->old_pitch_buf_fx[i], c ), s ); /*Q16*/ move32(); } /* set excitation memory*/ - exc = buf + OLD_EXC_SIZE_DEC; - tmp_deemph = synth[-1]; + exc = buf + OLD_EXC_SIZE_DEC; /*Q_exc*/ + tmp_deemph = synth[-1]; /*Q0*/ move16(); - pre_emph_buf = synth[-1]; + pre_emph_buf = synth[-1]; /*Q0*/ move16(); test(); IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || hTcxDec->tcxConceal_recalc_exc ) { /* apply pre-emphasis to the signal */ - mem = synth[sub( -( add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), M + M ) ), 1 )]; + mem = synth[( -( ( ( ( L_frame / 2 ) + hTcxDec->pit_max_TCX ) + M + M ) ) - 1 )]; /*Q0*/ move16(); - Q_exc = E_UTIL_f_preemph3( &( synth[-add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), 2 * M )] ), st->preemph_fac, add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), shl( M, 1 ) ), &mem, 1 ); + Q_exc = E_UTIL_f_preemph3( &( synth[-( ( ( L_frame / 2 ) + hTcxDec->pit_max_TCX ) + 2 * M )] ), st->preemph_fac, add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), shl( M, 1 ) ), &mem, 1 ); st->Mode2_lp_gainc = L_deposit_l( 0 ); - st->Mode2_lp_gainp = get_gain2( synth - shl( L_subfr, 1 ), synth - add( shl( L_subfr, 1 ), Tc ), shl( L_subfr, 1 ) ); + st->Mode2_lp_gainp = get_gain2( synth - shl( L_subfr, 1 ), synth - add( shl( L_subfr, 1 ), Tc ), shl( L_subfr, 1 ) ); /*Q16*/ - st->Mode2_lp_gainp = L_max( st->Mode2_lp_gainp, 0 ); - st->Mode2_lp_gainp = L_min( st->Mode2_lp_gainp, 65536l /*1.0f Q16*/ ); - st->Mode2_lp_gainp = L_shl( st->Mode2_lp_gainp, 13 ); + st->Mode2_lp_gainp = L_max( st->Mode2_lp_gainp, 0 ); /*Q16*/ + st->Mode2_lp_gainp = L_min( st->Mode2_lp_gainp, 65536l /*1.0f Q16*/ ); /*Q16*/ + st->Mode2_lp_gainp = L_shl( st->Mode2_lp_gainp, 13 ); /*Q29*/ - ana_window = buf; + ana_window = buf; /*Q15*/ ham_cos_window( ana_window, mult( L_frame, 24576 /*0.75f Q15*/ ), shr( L_frame, 2 ) ); /* Autocorrelation */ - autocorr_fx( &( synth[sub( -L_frame, 1 )] ), M, r_h, r_l, &Q_r, L_frame, ana_window, 0, 0 ); + autocorr_fx( &( synth[( -L_frame - 1 )] ), M, r_h, r_l, &Q_r, L_frame, ana_window, 0, 0 ); /* Lag windowing */ lag_wind( r_h, r_l, M, st->output_Fs, LAGW_STRONG ); @@ -276,7 +276,7 @@ void con_tcx_fx( E_LPC_lev_dur( r_h, r_l, A_local, NULL, M, NULL ); /* copy for multiple frame loss */ - Copy( A_local, st->old_Aq_12_8_fx, M + 1 ); + Copy( A_local, st->old_Aq_12_8_fx, M + 1 ); /*Q12*/ /* Residu */ assert( ( 2 * L_subfr + Tc + 1 + M ) <= hTcxDec->old_synth_lenFB ); @@ -284,8 +284,8 @@ void con_tcx_fx( BASOP_SATURATE_WARNING_OFF_EVS /*saturation possible in case of spiky synthesis*/ Residu3_fx( A_local, - &( synth[-add( add( add( shl( L_subfr, 1 ), Tc ), 1 ), M )] ), /*Qx = Q0*/ - &( exc[-add( add( add( shl( L_subfr, 1 ), Tc ), 1 ), M )] ), /*Qx+1 = Q1*/ + &( synth[-( ( add( ( L_subfr * 2 ), Tc ) + 1 ) + M )] ), /*Qx = Q0*/ + &( exc[-( ( add( ( L_subfr * 2 ), Tc ) + 1 ) + M )] ), /*Qx+1 = Q1*/ add( add( add( shl( L_subfr, 1 ), Tc ), 1 ), M ), 1 ); BASOP_SATURATE_WARNING_ON_EVS @@ -293,20 +293,20 @@ void con_tcx_fx( ELSE { /* apply pre-emphasis to the signal */ - mem = synth[sub( -L_frame, 1 )]; + mem = synth[( -L_frame - 1 )]; /*Q0*/ move16(); Q_exc = E_UTIL_f_preemph3( &( synth[-L_frame] ), st->preemph_fac, L_frame, &mem, 1 ); - Copy( st->old_Aq_12_8_fx, A_local, M + 1 ); + Copy( st->old_Aq_12_8_fx, A_local, M + 1 ); /*Q12*/ offset = shr( L_frame, 1 ); IF( GE_16( st->last_good, UNVOICED_TRANSITION ) ) { tmp16 = s_max( sub( Tc, shr( L_frame, 1 ) ), 0 ); - Copy_Scale_sig( hTcxDec->old_excFB_fx, &( exc[-tmp16] ), add( offset, tmp16 ), sub( Q_exc, st->Q_exc ) ); + Copy_Scale_sig( hTcxDec->old_excFB_fx, &( exc[-tmp16] ), add( offset, tmp16 ), sub( Q_exc, st->Q_exc ) ); /*Q_exc*/ } ELSE { - Copy_Scale_sig( hTcxDec->old_excFB_fx, &( exc[-shl( L_subfr, 1 )] ), add( shl( L_subfr, 1 ), offset ), sub( Q_exc, st->Q_exc ) ); + Copy_Scale_sig( hTcxDec->old_excFB_fx, &( exc[-( L_subfr * 2 )] ), add( shl( L_subfr, 1 ), offset ), sub( Q_exc, st->Q_exc ) ); /*Q_exc*/ } } @@ -344,9 +344,9 @@ void con_tcx_fx( tcxltp_pitch_tmp = L_add( L_deposit_h( hTcxLtpDec->tcxltp_pitch_int ), L_shl( L_deposit_l( div_s( hTcxLtpDec->tcxltp_pitch_fr, st->pit_res_max ) ), 1 ) ); /*15Q16*/ scale_tmp = mult_r( hTcxDec->L_frameTCX, getInvFrameLen( st->L_frame ) ); /*getInvFrameLen()->9Q6*/ tmp_shift = norm_s( scale_tmp ); - predPitchLag = L_shl( Mpy_32_16_1( tcxltp_pitch_tmp, shl( scale_tmp, tmp_shift ) ), sub( 9, tmp_shift ) ); + predPitchLag = L_shl( Mpy_32_16_1( tcxltp_pitch_tmp, shl( scale_tmp, tmp_shift ) ), sub( 9, tmp_shift ) ); /*Q16*/ - T0 = round_fx( predPitchLag ); + T0 = round_fx( predPitchLag ); /*Q0*/ test(); test(); @@ -372,7 +372,7 @@ void con_tcx_fx( &extrapolationFailed, st->nb_subfr ); - T0 = round_fx( predPitchLag ); + T0 = round_fx( predPitchLag ); /*Q0*/ test(); test(); test(); @@ -386,12 +386,12 @@ void con_tcx_fx( fLowPassFilter = 0; move16(); - pt_exc = exc + offset; - pt1_exc = pt_exc - Tc; + pt_exc = exc + offset; /*Q_exc*/ + pt1_exc = pt_exc - Tc; /*Q_exc*/ if ( fUseExtrapolatedPitch != 0 ) { - pt_exc = buf; + pt_exc = buf; /*Q_exc*/ } test(); IF( LT_16( st->stab_fac_fx, 32767 /*1.f Q15*/ ) && EQ_16( st->nbLostCmpt, 1 ) ) @@ -414,7 +414,7 @@ void con_tcx_fx( 0 /* 0.0000f Q15*/, pt1_exc[2] ), -1442 /*-0.0440f Q15*/, pt1_exc[3] ), 0 /* 0.0000f Q15*/, pt1_exc[4] ), - 174 /* 0.0053f Q15*/, pt1_exc[5] ); + 174 /* 0.0053f Q15*/, pt1_exc[5] ); /*Q_exc*/ #else *pt_exc++ = mac_r( L_mac( L_mac( L_mac( L_mac( L_mac( L_mac( L_mac( L_mac( L_mac( L_mult( 174 /* 0.0053f Q15*/, pt1_exc[-5] ), @@ -449,7 +449,7 @@ void con_tcx_fx( 590 /* 0.0180f Q15*/, pt1_exc[2] ), -459 /*-0.0140f Q15*/, pt1_exc[3] ), -121 /*-0.0037f Q15*/, pt1_exc[4] ), - -174 /*-0.0053f Q15*/, pt1_exc[5] ); + -174 /*-0.0053f Q15*/, pt1_exc[5] ); /*Q_exc*/ #else *pt_exc++ = mac_r( L_mac( L_mac( L_mac( L_mac( L_mac( L_mac( L_mac( L_mac( L_mac( L_mult( -174 /*-0.0053f Q15*/, pt1_exc[-5] ), @@ -477,7 +477,7 @@ void con_tcx_fx( /* copy the first pitch cycle without low-pass filtering */ FOR( i = 0; i < Tc; i++ ) { - *pt_exc++ = *pt1_exc++; + *pt_exc++ = *pt1_exc++; /*Q_exc*/ move16(); } fLowPassFilter = 1; @@ -486,12 +486,12 @@ void con_tcx_fx( if ( fUseExtrapolatedPitch != 0 ) { - pt1_exc = buf; + pt1_exc = buf; /*Q_exc*/ } tmp16 = add( sub( L_frame, imult1616( fLowPassFilter, Tc ) ), L_subfr ); FOR( i = 0; i < tmp16; i++ ) { - *pt_exc++ = *pt1_exc++; + *pt_exc++ = *pt1_exc++; /*Q_exc*/ move16(); } @@ -512,7 +512,7 @@ void con_tcx_fx( } ELSE { - set32_fx( pitch_buf, st->old_fpitch, st->nb_subfr ); + set32_fx( pitch_buf, st->old_fpitch, st->nb_subfr ); /*Q16*/ } IF( EQ_16( st->nbLostCmpt, 1 ) ) @@ -530,14 +530,14 @@ void con_tcx_fx( tmp_loop = shr( L_frame, 1 ); FOR( i = 0; i < tmp_loop; i++ ) { - *pt_exc++ = *pt1_exc++; + *pt_exc++ = *pt1_exc++; /*Q_exc*/ move16(); } } if ( fUseExtrapolatedPitch != 0 ) { - st->old_fpitchFB = predPitchLag; + st->old_fpitchFB = predPitchLag; /*Q16*/ move32(); } st->bpf_gain_param = 0; @@ -599,7 +599,7 @@ void con_tcx_fx( #ifdef BASOP_NOGLOB exc[i] = mult_r( exc[i], round_fx_sat( gain32 ) ) /*Q1*/; move16(); - gain32 = L_sub_sat( gain32, step32 ); + gain32 = L_sub_sat( gain32, step32 ); /*Q31*/ #else exc[i] = mult_r( exc[i], round_fx( gain32 ) ) /*Q1*/; move16(); @@ -608,8 +608,8 @@ void con_tcx_fx( } /* update old exc without random part */ - offset = s_max( sub( round_fx( st->old_fpitchFB ), shr( L_frame, 1 ) ), 0 ); - Copy( exc + sub( L_frame, offset ), hTcxDec->old_excFB_fx, add( shr( L_frame, 1 ), offset ) ); + offset = s_max( sub( round_fx( st->old_fpitchFB ), shr( L_frame, 1 ) ), 0 ); /*Q0*/ + Copy( exc + sub( L_frame, offset ), hTcxDec->old_excFB_fx, add( shr( L_frame, 1 ), offset ) ); /*Q_exc*/ /* copy old_exc as 16kHz for acelp decoding */ IF( EQ_16( st->nbLostCmpt, 1 ) ) { @@ -617,7 +617,7 @@ void con_tcx_fx( } ELSE { - Copy( st->old_exc_fx + L_FRAME16k, st->old_exc_fx, L_FRAME16k / 2 ); + Copy( st->old_exc_fx + L_FRAME16k, st->old_exc_fx, L_FRAME16k / 2 ); /*Q_exc*/ lerp( exc, st->old_exc_fx + L_FRAME16k / 2, L_FRAME16k, L_frame ); } st->Q_exc = Q_exc; @@ -631,8 +631,8 @@ void con_tcx_fx( { calcGainc2_fx( &exc[0], Q_exc, L_subfr, &( st->Mode2_lp_gainc ) ); } - set32_fx( pitch_buf, L_deposit_h( L_SUBFR ), st->nb_subfr ); - /* PLC: calculate damping factor */ + set32_fx( pitch_buf, L_deposit_h( L_SUBFR ), st->nb_subfr ); /*Q16*/ + /* PLC: calculate damping factor */ #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT alpha = 1.0f; if ( st->element_mode == IVAS_CPE_MDCT && st->nbLostCmpt >= MDCT_ST_PLC_FADEOUT_START_FRAME ) @@ -699,7 +699,7 @@ void con_tcx_fx( FOR( i = 0; i < tmp_loop; i++ ) { Random( &tmpSeed ); - noise[i] = shr( tmpSeed, noise_e ); + noise[i] = shr( tmpSeed, noise_e ); /*Q: -noise_e*/ move16(); } st->seed_acelp = tmpSeed; @@ -709,7 +709,7 @@ void con_tcx_fx( FOR( ; i < tmp_loop; i++ ) { Random( &tmpSeed ); - noise[i] = shr( tmpSeed, noise_e ); + noise[i] = shr( tmpSeed, noise_e ); /*Q: -noise_e*/ move16(); } } @@ -733,7 +733,7 @@ void con_tcx_fx( { FOR( i = 0; i < L_FIR_FER2; i++ ) { - hp_filt[i] = h_high3_16[i]; + hp_filt[i] = h_high3_16[i]; /*Q15*/ move16(); } } @@ -741,7 +741,7 @@ void con_tcx_fx( { FOR( i = 0; i < L_FIR_FER2; i++ ) { - hp_filt[i] = h_high3_32[i]; + hp_filt[i] = h_high3_32[i]; /*Q15*/ move16(); } } @@ -762,7 +762,7 @@ void con_tcx_fx( move32(); FOR( j = 11; j > 0; j-- ) { - L_tmp2 = L_mac( L_tmp2, noise[add( i, sub( L_FIR_FER2, j ) )], hp_filt[sub( L_FIR_FER2, j )] ); + L_tmp2 = L_mac( L_tmp2, noise[( i + sub( L_FIR_FER2, j ) )], hp_filt[( L_FIR_FER2 - j )] ); } L_tmp2 = Mpy_32_16_1( L_tmp2, st->cummulative_damping /*Q15*/ ); /*Q0, noise_e*/ noise[i] = mac_r( L_tmp2, gain_tmp, noise[i] ); /*Q15, noise_e*/ @@ -784,7 +784,7 @@ void con_tcx_fx( #else tmp16 = 32767; move16(); - gainSynthDeemph = getLevelSynDeemph_fx( &( tmp16 ), A_local, M, shr( L_frame, 2 ), st->preemph_fac, 1, &gainSynthDeemph_e ); + gainSynthDeemph = getLevelSynDeemph_fx( &( tmp16 ), A_local, M, shr( L_frame, 2 ), st->preemph_fac, 1, &gainSynthDeemph_e ); /*Q5*/ #endif IF( st->tcxonly != 0 ) { @@ -820,10 +820,10 @@ void con_tcx_fx( test(); if ( EQ_16( st->rf_frame_type, RF_TCXTD1 ) && EQ_16( st->use_partial_copy, 1 ) ) { - gain32 = Mpy_32_16_1( gain32, 22938 /*0.7f Q15*/ ); + gain32 = Mpy_32_16_1( gain32, 22938 /*0.7f Q15*/ ); /*Q16*/ } -#ifdef BASOP_NOGLOB /* Critical Overflow */ - L_tmp = L_shl_sat( gain32, 1 ); +#ifdef BASOP_NOGLOB /* Critical Overflow */ + L_tmp = L_shl_sat( gain32, 1 ); /*Q16*/ #else L_tmp = L_shl( gain32, 1 ); #endif @@ -838,8 +838,8 @@ void con_tcx_fx( L_tmp = Mpy_32_16_1( st->Mode2_lp_gainc, alpha ) /*Q15*/; L_tmp2 = L_mult( sub( 16384 /*1.f Q14*/, alpha ) /*Q14*/, gainCNG /*Q15,gainCNG_e*/ ); /*Q30,gainCNG_e*/ - st->Mode2_lp_gainc = BASOP_Util_Add_Mant32Exp( L_tmp, 31 - 15, L_tmp2, add( gainCNG_e, 31 - 30 ), &tmp_e ); /*Q31*/ - st->Mode2_lp_gainc = L_shl( st->Mode2_lp_gainc, sub( tmp_e, 31 - 16 ) ); + st->Mode2_lp_gainc = BASOP_Util_Add_Mant32Exp( L_tmp, 31 - 15, L_tmp2, add( gainCNG_e, 31 - 30 ), &tmp_e ); /*Q31-tmp_e*/ + st->Mode2_lp_gainc = L_shl( st->Mode2_lp_gainc, sub( tmp_e, 31 - 16 ) ); /*Q16*/ move32(); move32(); @@ -864,7 +864,7 @@ void con_tcx_fx( test(); IF( EQ_16( st->last_good, UNVOICED_CLAS ) && NE_16( st->core_ext_mode, UNVOICED ) ) { - gain_inov = mult_r( gain_inov, 26214 /*0.8f Q15*/ ); + gain_inov = mult_r( gain_inov, 26214 /*0.8f Q15*/ ); /*Q30*/ } ELSE IF( !( EQ_16( st->last_good, UNVOICED_CLAS ) || EQ_16( st->last_good, UNVOICED_TRANSITION ) ) ) { @@ -901,7 +901,7 @@ void con_tcx_fx( step32_tmp = L_shl( step32 /*Q25*/, sub( tmp_e, 25 - 16 ) ); /*Q16,-tmp_e*/ FOR( i = 0; i < tmp16; i++ ) /* Actual filtered random part of excitation */ { - *pt_exc = mult_r( *pt_exc, gain_tmp ); + *pt_exc = mult_r( *pt_exc, gain_tmp ); /*Q-15,noise_e+gain_inov_e-tmp_e*/ move16(); pt_exc++; gain32 = L_sub( gain32 /*Q16,-tmp_e*/, step32_tmp ); /*Q16,-tmp_e*/ @@ -910,7 +910,7 @@ void con_tcx_fx( tmp16 = shr( L_frame, 1 ); FOR( i = 0; i < tmp16; i++ ) /* causal ringing of the FIR filter */ { - *pt_exc = mult_r( *pt_exc, gain_tmp ); + *pt_exc = mult_r( *pt_exc, gain_tmp ); /*Q-15,noise_e+gain_inov_e-tmp_e*/ move16(); pt_exc++; } @@ -938,7 +938,7 @@ void con_tcx_fx( ELSE { bufferCopyFx( noise + L_FIR_FER2 / 2, exc, add( L_frame, shr( L_frame, 1 ) ), 0 /*Q_noise*/, noise_e, Q_exc, 0 /*exc_e*/ ); - Copy( exc + sub( L_frame, shl( L_subfr, 1 ) ), hTcxDec->old_excFB_fx, add( shl( L_subfr, 1 ), shr( L_frame, 1 ) ) ); + Copy( exc + sub( L_frame, shl( L_subfr, 1 ) ), hTcxDec->old_excFB_fx, add( shl( L_subfr, 1 ), shr( L_frame, 1 ) ) ); /*Q_exc*/ /* copy old_exc as 16kHz for acelp decoding */ IF( EQ_16( st->nbLostCmpt, 1 ) ) { @@ -946,7 +946,7 @@ void con_tcx_fx( } ELSE { - Copy( st->old_exc_fx + L_FRAME16k, st->old_exc_fx, L_FRAME16k / 2 ); + Copy( st->old_exc_fx + L_FRAME16k, st->old_exc_fx, L_FRAME16k / 2 ); /*Q_exc*/ lerp( exc, st->old_exc_fx + L_FRAME16k / 2, L_FRAME16k, L_frame ); } st->Q_exc = Q_exc; @@ -956,15 +956,15 @@ void con_tcx_fx( /*buf[OLD_EXC_SIZE_DEC;3/2 L_frame] Q1*/ /* Update Pitch Lag memory */ - Copy32( &st->old_pitch_buf_fx[st->nb_subfr], st->old_pitch_buf_fx, st->nb_subfr ); - Copy32( pitch_buf, &st->old_pitch_buf_fx[st->nb_subfr], st->nb_subfr ); + Copy32( &st->old_pitch_buf_fx[st->nb_subfr], st->old_pitch_buf_fx, st->nb_subfr ); /*Q16*/ + Copy32( pitch_buf, &st->old_pitch_buf_fx[st->nb_subfr], st->nb_subfr ); /*Q16*/ /*----------------------------------------------------------* * - compute the synthesis speech * *----------------------------------------------------------*/ - syn = buf + M; - Copy( synth - M, buf, M ); + syn = buf + M; /*Q_syn*/ + Copy( synth - M, buf, M ); /*Q_syn*/ new_Q = sub( Q_exc, 3 ); new_Q = s_max( new_Q, -1 ); @@ -977,10 +977,10 @@ void con_tcx_fx( Q_syn = tmp16; move16(); - Copy_Scale_sig( buf, mem_syn, M, exp_scale ); + Copy_Scale_sig( buf, mem_syn, M, exp_scale ); /*Q: tmp16*/ #ifdef BASOP_NOGLOB - tmp_deemph = shl_sat( tmp_deemph, Q_syn ); + tmp_deemph = shl_sat( tmp_deemph, Q_syn ); /*Q_syn*/ #else tmp_deemph = shl( tmp_deemph, Q_syn ); #endif @@ -1031,37 +1031,37 @@ void con_tcx_fx( /*buf[0;M-1] Q0: mem_syn*/ /*buf[M;3/2 L_frame-1] Q-1: syn*/ - n = extract_h( L_mult( L_frame, 9216 /*(float)N_ZERO_MDCT_NS/(float)FRAME_SIZE_NS Q15*/ ) ); + n = extract_h( L_mult( L_frame, 9216 /*(float)N_ZERO_MDCT_NS/(float)FRAME_SIZE_NS Q15*/ ) ); /*q0*/ /* update ACELP synthesis memory */ mem_syn_r_size_old = shr( L_frame, 4 ); /* replace 1.25/20.0 by shr(4) */ /* copy mem_syn as 16kHz */ mem_syn_r_size_new = shr( L_FRAME16k, 4 ); /* replace 1.25/20.0 by shr(4) */ - Copy( syn + sub( L_frame, L_SYN_MEM ), st->mem_syn_r, L_SYN_MEM ); + Copy( syn + sub( L_frame, L_SYN_MEM ), st->mem_syn_r, L_SYN_MEM ); /*Q_syn*/ lerp( st->mem_syn_r + sub( L_SYN_MEM, mem_syn_r_size_old ), st->mem_syn_r + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old ); - Copy( st->mem_syn_r + L_SYN_MEM - M, st->mem_syn2_fx, M ); + Copy( st->mem_syn_r + L_SYN_MEM - M, st->mem_syn2_fx, M ); /*Q_syn*/ /* Deemphasis and output synth and ZIR */ deemph_fx( syn, st->preemph_fac, add( L_frame, shr( L_frame, 1 ) ), &tmp_deemph ); - bufferCopyFx( syn + sub( L_frame, M + 1 ), st->syn, 1 + M, Q_syn, 0, 0, 0 ); + bufferCopyFx( syn + sub( L_frame, M + 1 ), st->syn, 1 + M, Q_syn, 0, 0, 0 ); /*Q_syn*/ lerp( syn + sub( L_frame, shr( L_frame, 1 ) ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); - Copy( syn + sub( L_frame, n ), hHQ_core->old_out_fx, sub( L_frame, n ) ); + Copy( syn + sub( L_frame, n ), hHQ_core->old_out_fx, sub( L_frame, n ) ); /*Q_syn*/ FOR( i = 0; i < W12; i++ ) { - hHQ_core->old_out_fx[add( i, n )] = round_fx( Mpy_32_16_1( L_mult( w[i].v.re, w[i].v.re ), hHQ_core->old_out_fx[add( i, n )] ) ); + hHQ_core->old_out_fx[( i + n )] = round_fx( Mpy_32_16_1( L_mult( w[i].v.re, w[i].v.re ), hHQ_core->old_out_fx[( i + n )] ) ); /*Q_syn*/ move16(); } FOR( ; i < W1; i++ ) { - hHQ_core->old_out_fx[add( i, n )] = round_fx( Mpy_32_16_1( L_mult( w[sub( sub( W12, 1 ), sub( i, W12 ) )].v.im, w[sub( sub( W12, 1 ), sub( i, W12 ) )].v.im ), hHQ_core->old_out_fx[add( i, n )] ) ); + hHQ_core->old_out_fx[( i + n )] = round_fx( Mpy_32_16_1( L_mult( w[( ( W12 - 1 ) - ( i - W12 ) )].v.im, w[( ( W12 - 1 ) - ( i - W12 ) )].v.im ), hHQ_core->old_out_fx[( i + n )] ) ); /*Q_syn*/ move16(); } - set16_fx( &hHQ_core->old_out_fx[add( W1, n )], 0, n ); + set16_fx( &hHQ_core->old_out_fx[( W1 + n )], 0, n ); hHQ_core->Q_old_wtda = Q_syn; move16(); @@ -1069,10 +1069,10 @@ void con_tcx_fx( /* As long as there is no synth scaling factor introduced, which is given to the outside, there might occur overflows here */ BASOP_SATURATE_WARNING_OFF_EVS - bufferCopyFx( syn, synth, L_frame, Q_syn, 0, 0, 0 ); + bufferCopyFx( syn, synth, L_frame, Q_syn, 0, 0, 0 ); /*Q_syn*/ BASOP_SATURATE_WARNING_ON_EVS - Copy_Scale_sig( syn + L_frame, hTcxDec->syn_OverlFB, shr( L_frame, 1 ), negate( Q_syn ) ); + Copy_Scale_sig( syn + L_frame, hTcxDec->syn_OverlFB, shr( L_frame, 1 ), negate( Q_syn ) ); /*Q0*/ /* copy total excitation exc2 as 16kHz for acelp mode1 decoding */ IF( st->hWIDec != NULL ) @@ -1082,7 +1082,7 @@ void con_tcx_fx( } #ifdef BASOP_NOGLOB - st->bfi_pitch_fx /*Q6*/ = round_fx_sat( L_shl_sat( pitch_buf[sub( st->nb_subfr, 1 )] /*15Q16*/, 6 /*Q6*/ ) ); + st->bfi_pitch_fx /*Q6*/ = round_fx_sat( L_shl_sat( pitch_buf[( st->nb_subfr - 1 )] /*15Q16*/, 6 /*Q6*/ ) ); #else st->bfi_pitch_fx /*Q6*/ = round_fx( L_shl( pitch_buf[sub( st->nb_subfr, 1 )] /*15Q16*/, 6 /*Q6*/ ) ); #endif @@ -1097,12 +1097,12 @@ void con_tcx_fx( FOR( i = 0; i < W12; i++ ) { - buf[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[i].v.re ); + buf[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[i].v.re ); /*hTcxDec->Q_syn_Overl_TDACFB*/ move16(); } FOR( ; i < W1; i++ ) { - buf[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[sub( sub( W12, 1 ), sub( i, W12 ) )].v.im ); + buf[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[( ( W12 - 1 ) - ( i - W12 ) )].v.im ); /*hTcxDec->Q_syn_Overl_TDACFB*/ move16(); } @@ -1110,7 +1110,7 @@ void con_tcx_fx( FOR( i = 0; i < W2; i++ ) { #ifdef BASOP_NOGLOB - hTcxDec->syn_Overl_TDACFB[i] = add_sat( buf[i], buf[sub( sub( W1, 1 ), i )] ); + hTcxDec->syn_Overl_TDACFB[i] = add_sat( buf[i], buf[( ( W1 - 1 ) - i )] ); /*hTcxDec->Q_syn_Overl_TDACFB*/ #else hTcxDec->syn_Overl_TDACFB[i] = add( buf[i], buf[sub( sub( W1, 1 ), i )] ); #endif @@ -1120,7 +1120,7 @@ void con_tcx_fx( FOR( i = 0; i < W2; i++ ) { #ifdef BASOP_NOGLOB - hTcxDec->syn_Overl_TDACFB[add( W2, i )] = add_sat( buf[add( W2, i )], buf[sub( sub( sub( W1, 1 ), W2 ), i )] ); + hTcxDec->syn_Overl_TDACFB[( W2 + i )] = add_sat( buf[( W2 + i )], buf[( ( ( W1 - 1 ) - W2 ) - i )] ); /*hTcxDec->Q_syn_Overl_TDACFB*/ #else hTcxDec->syn_Overl_TDACFB[add( W2, i )] = add( buf[add( W2, i )], buf[sub( sub( sub( W1, 1 ), W2 ), i )] ); #endif @@ -1129,23 +1129,23 @@ void con_tcx_fx( FOR( i = 0; i < W12; i++ ) { - hTcxDec->syn_Overl_TDACFB[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[i].v.re ); + hTcxDec->syn_Overl_TDACFB[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[i].v.re ); /*hTcxDec->Q_syn_Overl_TDACFB*/ move16(); } FOR( ; i < W1; i++ ) { - hTcxDec->syn_Overl_TDACFB[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[sub( sub( W12, 1 ), sub( i, W12 ) )].v.im ); + hTcxDec->syn_Overl_TDACFB[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[( ( W12 - 1 ) - ( i - W12 ) )].v.im ); /*hTcxDec->Q_syn_Overl_TDACFB*/ move16(); } st->hTcxCfg->tcx_curr_overlap_mode = FULL_OVERLAP; move16(); - synth[-1] = pre_emph_buf; + synth[-1] = pre_emph_buf; /*Q0*/ move16(); /* update memory for low band */ - Scale_sig( hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, Q_syn ) ); + Scale_sig( hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, Q_syn ) ); /*Q_syn*/ lerp( hTcxDec->syn_OverlFB, hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); lerp( hTcxDec->syn_Overl_TDACFB, hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); hTcxDec->Q_syn_Overl_TDAC = hTcxDec->Q_syn_Overl_TDACFB; @@ -1163,10 +1163,10 @@ void con_tcx_ivas_fx( Decoder_State *st, /* i/o: coder memory state */ Word16 synth[], /* i/o: synth[] */ /*Q0 */ - const Word16 coh, /* i : coherence of stereo signal */ - Word16 *noise_seed, /* i/o: noise seed for stereo */ - const Word16 only_left, /* i : TD-PLC only in left channel */ - const Word16 *A_cng /* i : CNG LP filter coefficients */ + const Word16 coh, /* i : coherence of stereo signal Q14*/ + Word16 *noise_seed, /* i/o: noise seed for stereo Q0*/ + const Word16 only_left, /* i : TD-PLC only in left channel Q0*/ + const Word16 *A_cng /* i : CNG LP filter coefficients Q14*/ ) { Word16 i, s, c, L_frame, L_subfr, fLowPassFilter, T0; @@ -1224,16 +1224,16 @@ void con_tcx_ivas_fx( L_frame = hTcxDec->L_frameTCX; move16(); /* L_subfr = st->L_frameTCX/st->nb_subfr */ - L_subfr = mult_r( hTcxDec->L_frameTCX, div_s( 1, st->nb_subfr ) ); + L_subfr = mult_r( hTcxDec->L_frameTCX, div_s( 1, st->nb_subfr ) ); /*Q0*/ assert( L_subfr == hTcxDec->L_frameTCX / st->nb_subfr ); - w = st->hTcxCfg->tcx_mdct_windowFB; /*pointer - no need to instrument*/ + w = st->hTcxCfg->tcx_mdct_windowFB; /*pointer - no need to instrument Q15*/ W1 = st->hTcxCfg->tcx_mdct_window_lengthFB; move16(); W2 = shr( st->hTcxCfg->tcx_mdct_window_lengthFB, 1 ); W12 = shr( W1, 1 ); /* take the previous frame last pitch */ - Tc = round_fx( st->old_fpitchFB ); + Tc = round_fx( st->old_fpitchFB ); /*Q0*/ set16_fx( buf, 0, OLD_EXC_SIZE_DEC + L_FRAME_MAX + L_FRAME_MAX / NB_SUBFR + 1 + L_FRAME_MAX / 2 ); /* initialize buf with 0 */ @@ -1246,22 +1246,22 @@ void con_tcx_ivas_fx( FOR( i = 0; i < 2 * NB_SUBFR16k + 2; i++ ) { - old_pitch_buf[i] = L_shl( Mpy_32_16_1( st->old_pitch_buf_fx[i], c ), s ); + old_pitch_buf[i] = L_shl( Mpy_32_16_1( st->old_pitch_buf_fx[i], c ), s ); /*Q16*/ move32(); } /* set excitation memory*/ exc = buf + OLD_EXC_SIZE_DEC; - tmp_deemph = synth[-1]; + tmp_deemph = synth[-1]; /*Q0*/ move16(); - pre_emph_buf = synth[-1]; + pre_emph_buf = synth[-1]; /*Q0*/ move16(); test(); IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || hTcxDec->tcxConceal_recalc_exc ) { /* apply pre-emphasis to the signal */ - mem = synth[sub( -add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), M + M ), 1 )]; + mem = synth[( -( ( ( L_frame / 2 ) + hTcxDec->pit_max_TCX ) + M + M ) - 1 )]; /*Q0*/ move16(); Q_exc = E_UTIL_f_preemph3( &( synth[-add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), 2 * M )] ), st->preemph_fac, add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), shl( M, 1 ) ), &mem, 1 ); st->Mode2_lp_gainc = L_deposit_l( 0 ); @@ -1269,18 +1269,18 @@ void con_tcx_ivas_fx( st->Mode2_lp_gainp = get_gain2( synth - shl( L_subfr, 1 ), synth - add( shl( L_subfr, 1 ), Tc ), shl( L_subfr, 1 ) ); move32(); - st->Mode2_lp_gainp = L_max( st->Mode2_lp_gainp, 0 ); - st->Mode2_lp_gainp = L_min( st->Mode2_lp_gainp, 65536l /*1.0f Q16*/ ); - st->Mode2_lp_gainp = L_shl( st->Mode2_lp_gainp, 13 ); + st->Mode2_lp_gainp = L_max( st->Mode2_lp_gainp, 0 ); /*Q16*/ + st->Mode2_lp_gainp = L_min( st->Mode2_lp_gainp, 65536l /*1.0f Q16*/ ); /*Q16*/ + st->Mode2_lp_gainp = L_shl( st->Mode2_lp_gainp, 13 ); /*Q29*/ move32(); move32(); move32(); - ana_window = buf; + ana_window = buf; /*Q15*/ ham_cos_window( ana_window, mult( L_frame, 24576 /*0.75f Q15*/ ), shr( L_frame, 2 ) ); /* Autocorrelation */ - autocorr_fx( &( synth[sub( -L_frame, 1 )] ), M, r_h, r_l, &Q_r, L_frame, ana_window, 0, 0 ); + autocorr_fx( &( synth[( -L_frame - 1 )] ), M, r_h, r_l, &Q_r, L_frame, ana_window, 0, 0 ); /* Lag windowing */ lag_wind( r_h, r_l, M, st->output_Fs, LAGW_STRONG ); @@ -1289,7 +1289,7 @@ void con_tcx_ivas_fx( E_LPC_lev_dur( r_h, r_l, A_local, NULL, M, NULL ); /* copy for multiple frame loss */ - Copy( A_local, st->old_Aq_12_8_fx, M + 1 ); + Copy( A_local, st->old_Aq_12_8_fx, M + 1 ); /*Q14*/ /* Residu */ assert( ( 2 * L_subfr + Tc + 1 + M ) <= hTcxDec->old_synth_lenFB ); @@ -1306,20 +1306,20 @@ void con_tcx_ivas_fx( ELSE { /* apply pre-emphasis to the signal */ - mem = synth[sub( -L_frame, 1 )]; + mem = synth[( -L_frame - 1 )]; /*Q0*/ move16(); Q_exc = E_UTIL_f_preemph3( &( synth[-L_frame] ), st->preemph_fac, L_frame, &mem, 1 ); - Copy( st->old_Aq_12_8_fx, A_local, M + 1 ); + Copy( st->old_Aq_12_8_fx, A_local, M + 1 ); /*Q14*/ offset = shr( L_frame, 1 ); IF( GE_16( st->last_good, UNVOICED_TRANSITION ) ) { tmp16 = s_max( Tc - shr( L_frame, 1 ), 0 ); - Copy_Scale_sig( hTcxDec->old_excFB_fx, &( exc[-tmp16] ), add( offset, tmp16 ), sub( Q_exc, st->Q_exc ) ); + Copy_Scale_sig( hTcxDec->old_excFB_fx, &( exc[-tmp16] ), add( offset, tmp16 ), sub( Q_exc, st->Q_exc ) ); /*Q_exc*/ } ELSE { - Copy_Scale_sig( hTcxDec->old_excFB_fx, &( exc[-shl( L_subfr, 1 )] ), add( shl( L_subfr, 1 ), offset ), sub( Q_exc, st->Q_exc ) ); + Copy_Scale_sig( hTcxDec->old_excFB_fx, &( exc[-( L_subfr * 2 )] ), add( shl( L_subfr, 1 ), offset ), sub( Q_exc, st->Q_exc ) ); /*Q_exc*/ } } @@ -1358,9 +1358,9 @@ void con_tcx_ivas_fx( scale_tmp = mult_r( hTcxDec->L_frameTCX, getInvFrameLen( st->L_frame ) ); /*getInvFrameLen()->9Q6*/ tmp_shift = norm_s( scale_tmp ); - predPitchLag = L_shl( Mpy_32_16_1( tcxltp_pitch_tmp, shl( scale_tmp, tmp_shift ) ), sub( 9, tmp_shift ) ); + predPitchLag = L_shl( Mpy_32_16_1( tcxltp_pitch_tmp, shl( scale_tmp, tmp_shift ) ), sub( 9, tmp_shift ) ); /*Q16*/ - T0 = round_fx( predPitchLag ); + T0 = round_fx( predPitchLag ); /*Q0*/ test(); test(); @@ -1401,12 +1401,12 @@ void con_tcx_ivas_fx( fLowPassFilter = 0; move16(); - pt_exc = exc + offset; - pt1_exc = pt_exc - Tc; + pt_exc = exc + offset; /*Q_exc*/ + pt1_exc = pt_exc - Tc; /*Q_exc*/ if ( fUseExtrapolatedPitch != 0 ) { - pt_exc = buf; + pt_exc = buf; /*Q_exc*/ } test(); IF( LT_16( st->stab_fac_fx, 32767 /*1.f Q15*/ ) && EQ_16( st->nbLostCmpt, 1 ) ) @@ -1428,7 +1428,7 @@ void con_tcx_ivas_fx( 0 /* 0.0000f Q15*/, pt1_exc[2] ), -1442 /*-0.0440f Q15*/, pt1_exc[3] ), 0 /* 0.0000f Q15*/, pt1_exc[4] ), - 174 /* 0.0053f Q15*/, pt1_exc[5] ); + 174 /* 0.0053f Q15*/, pt1_exc[5] ); /*Q_exc*/ move16(); pt1_exc++; } @@ -1448,7 +1448,7 @@ void con_tcx_ivas_fx( 590 /* 0.0180f Q15*/, pt1_exc[2] ), -459 /*-0.0140f Q15*/, pt1_exc[3] ), -121 /*-0.0037f Q15*/, pt1_exc[4] ), - -174 /*-0.0053f Q15*/, pt1_exc[5] ); + -174 /*-0.0053f Q15*/, pt1_exc[5] ); /*Q_exc*/ move16(); pt1_exc++; } @@ -1462,7 +1462,7 @@ void con_tcx_ivas_fx( /* copy the first pitch cycle without low-pass filtering */ FOR( i = 0; i < Tc; i++ ) { - *pt_exc++ = *pt1_exc++; + *pt_exc++ = *pt1_exc++; /*Q_exc*/ move16(); } fLowPassFilter = 1; @@ -1476,7 +1476,7 @@ void con_tcx_ivas_fx( tmp16 = add( sub( L_frame, imult1616( fLowPassFilter, Tc ) ), L_subfr ); FOR( i = 0; i < tmp16; i++ ) { - *pt_exc++ = *pt1_exc++; + *pt_exc++ = *pt1_exc++; /*Q_exc*/ move16(); } @@ -1497,7 +1497,7 @@ void con_tcx_ivas_fx( } ELSE { - set32_fx( pitch_buf, st->old_fpitch, st->nb_subfr ); + set32_fx( pitch_buf, st->old_fpitch, st->nb_subfr ); /*Q16*/ } IF( EQ_16( st->nbLostCmpt, 1 ) ) @@ -1505,24 +1505,24 @@ void con_tcx_ivas_fx( pt_exc = exc + L_frame; IF( T0 == 0 ) { - pt1_exc = pt_exc - Tc; + pt1_exc = pt_exc - Tc; /*Q_exc*/ } ELSE { - pt1_exc = pt_exc - T0; + pt1_exc = pt_exc - T0; /*Q_exc*/ } tmp_loop = shr( L_frame, 1 ); FOR( i = 0; i < tmp_loop; i++ ) { - *pt_exc++ = *pt1_exc++; + *pt_exc++ = *pt1_exc++; /*Q_exc*/ move16(); } } if ( fUseExtrapolatedPitch != 0 ) { - st->old_fpitchFB = predPitchLag; + st->old_fpitchFB = predPitchLag; /*Q16*/ move32(); } st->bpf_gain_param = 0; @@ -1584,7 +1584,7 @@ void con_tcx_ivas_fx( #ifdef BASOP_NOGLOB exc[i] = mult_r( exc[i], round_fx_sat( gain32 ) ) /*Q1*/; move16(); - gain32 = L_sub_sat( gain32, step32 ); + gain32 = L_sub_sat( gain32, step32 ); /*Q31*/ #else exc[i] = mult_r( exc[i], round_fx( gain32 ) ) /*Q1*/; move16(); @@ -1593,8 +1593,8 @@ void con_tcx_ivas_fx( } /* update old exc without random part */ - offset = s_max( sub( round_fx( st->old_fpitchFB ), shr( L_frame, 1 ) ), 0 ); - Copy( exc + sub( L_frame, offset ), hTcxDec->old_excFB_fx, add( shr( L_frame, 1 ), offset ) ); + offset = s_max( sub( round_fx( st->old_fpitchFB ), shr( L_frame, 1 ) ), 0 ); /*Q0*/ + Copy( exc + sub( L_frame, offset ), hTcxDec->old_excFB_fx, add( shr( L_frame, 1 ), offset ) ); /*Q_exc*/ /* copy old_exc as 16kHz for acelp decoding */ IF( EQ_16( st->nbLostCmpt, 1 ) ) { @@ -1602,7 +1602,7 @@ void con_tcx_ivas_fx( } ELSE { - Copy( st->old_exc_fx + L_FRAME16k, st->old_exc_fx, L_FRAME16k / 2 ); + Copy( st->old_exc_fx + L_FRAME16k, st->old_exc_fx, L_FRAME16k / 2 ); /*Q_exc*/ lerp( exc, st->old_exc_fx + L_FRAME16k / 2, L_FRAME16k, L_frame ); } st->Q_exc = Q_exc; @@ -1616,8 +1616,8 @@ void con_tcx_ivas_fx( { calcGainc2_fx( &exc[0], Q_exc, L_subfr, &( st->Mode2_lp_gainc ) ); } - set32_fx( pitch_buf, L_deposit_h( L_SUBFR ), st->nb_subfr ); - /* PLC: calculate damping factor */ + set32_fx( pitch_buf, L_deposit_h( L_SUBFR ), st->nb_subfr ); /*Q16*/ + /* PLC: calculate damping factor */ #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT alpha = 1.0f; if ( st->element_mode == IVAS_CPE_MDCT && st->nbLostCmpt >= MDCT_ST_PLC_FADEOUT_START_FRAME ) @@ -1645,7 +1645,7 @@ void con_tcx_ivas_fx( Word16 e; tmpSeed1 = *noise_seed; - noise = buf; + noise = buf; /*Q15*/ noise_e = 2; move16(); e = 0; @@ -1653,9 +1653,9 @@ void con_tcx_ivas_fx( alpha_coh = 0; move16(); - IF( NE_16( coh, 16384 ) ) + IF( NE_16( coh, 16384 /*1.0f in Q14*/ ) ) { - alpha_coh = Sqrt16( div_s( sub( 16384, coh ), add( 16384, coh ) ), &e ); + alpha_coh = Sqrt16( div_s( sub( 16384 /*1.0f in Q14*/, coh ), add( 16384 /*1.0f in Q14*/, coh ) ), &e ); /* Q15 - e */ } if ( EQ_16( st->idchan, 1 ) ) { @@ -1688,7 +1688,7 @@ void con_tcx_ivas_fx( ELSE #endif /*IVAS_CODE_CON_TCX*/ { - tmpSeed = st->seed_acelp; + tmpSeed = st->seed_acelp; /*Q0*/ move16(); noise = buf; noise_e = 1; /*set exponent of noise to 1*/ @@ -1698,7 +1698,7 @@ void con_tcx_ivas_fx( FOR( i = 0; i < tmp_loop; i++ ) { Random( &tmpSeed ); - noise[i] = shr( tmpSeed, noise_e ); + noise[i] = shr( tmpSeed, noise_e ); /*Q: -noise_e*/ move16(); } st->seed_acelp = tmpSeed; @@ -1708,7 +1708,7 @@ void con_tcx_ivas_fx( FOR( ; i < tmp_loop; i++ ) { Random( &tmpSeed ); - noise[i] = shr( tmpSeed, noise_e ); + noise[i] = shr( tmpSeed, noise_e ); /*Q: -noise_e*/ move16(); } } @@ -1732,7 +1732,7 @@ void con_tcx_ivas_fx( { FOR( i = 0; i < L_FIR_FER2; i++ ) { - hp_filt[i] = h_high3_16[i]; + hp_filt[i] = h_high3_16[i]; /*Q15*/ move16(); } } @@ -1740,7 +1740,7 @@ void con_tcx_ivas_fx( { FOR( i = 0; i < L_FIR_FER2; i++ ) { - hp_filt[i] = h_high3_32[i]; + hp_filt[i] = h_high3_32[i]; /*Q15*/ move16(); } } @@ -1761,7 +1761,7 @@ void con_tcx_ivas_fx( move32(); FOR( j = 11; j > 0; j-- ) { - L_tmp2 = L_mac( L_tmp2, noise[add( i, sub( L_FIR_FER2, j ) )], hp_filt[sub( L_FIR_FER2, j )] ); + L_tmp2 = L_mac( L_tmp2, noise[( i + ( L_FIR_FER2 - j ) )], hp_filt[sub( L_FIR_FER2, j )] ); } L_tmp2 = Mpy_32_16_1( L_tmp2, st->cummulative_damping /*Q15*/ ); /*Q0, noise_e*/ noise[i] = mac_r( L_tmp2, gain_tmp, noise[i] ); /*Q15, noise_e*/ @@ -1776,11 +1776,11 @@ void con_tcx_ivas_fx( move16(); IF( A_cng != NULL ) { - gainSynthDeemph = shr( getLevelSynDeemph_fx( &( tmp16 ), A_cng, M, shr( L_frame, 2 ), st->preemph_fac, 1, &gainSynthDeemph_e ), 2 ); + gainSynthDeemph = shr( getLevelSynDeemph_fx( &( tmp16 ), A_cng, M, shr( L_frame, 2 ), st->preemph_fac, 1, &gainSynthDeemph_e ), 2 ); /*Q13*/ } ELSE { - gainSynthDeemph = getLevelSynDeemph_fx( &( tmp16 ), A_local, M, shr( L_frame, 2 ), st->preemph_fac, 1, &gainSynthDeemph_e ); + gainSynthDeemph = getLevelSynDeemph_fx( &( tmp16 ), A_local, M, shr( L_frame, 2 ), st->preemph_fac, 1, &gainSynthDeemph_e ); /*Q13*/ } #else tmp16 = 32767; @@ -1807,7 +1807,7 @@ void con_tcx_ivas_fx( { // gainCNG *= 1.f - (float)(st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME) / MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN; L_tmp = L_sub( ONE_IN_Q31, imult3216( 107374182 /* 1 / MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN in Q31*/, sub( st->nbLostCmpt, MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) ) ); /* Q31 */ - gainCNG = extract_l( Mpy_32_32( gainCNG, L_tmp ) ); + gainCNG = extract_l( Mpy_32_32( gainCNG, L_tmp ) ); /*Q15-gainCNG_e*/ } } #endif @@ -1824,9 +1824,9 @@ void con_tcx_ivas_fx( gain32 = L_add( st->Mode2_lp_gainc, 0 ); /* start-of-the-frame gain - Q16*/ IF( EQ_16( st->rf_frame_type, RF_TCXTD1 ) && EQ_16( st->use_partial_copy, 1 ) ) { - gain32 = Mpy_32_16_1( gain32, 22938 /*0.7f Q15*/ ); + gain32 = Mpy_32_16_1( gain32, 22938 /*0.7f Q15*/ ); /*Q16*/ } - L_tmp = L_shl( gain32, 1 ); + L_tmp = L_shl( gain32, 1 ); /*Q16*/ IF( GT_32( L_shl( L_deposit_h( gainCNG ), sub( gainCNG_e, 31 - 16 ) /*Q16*/ ), L_tmp ) ) { @@ -1839,8 +1839,8 @@ void con_tcx_ivas_fx( L_tmp = Mpy_32_16_1( st->Mode2_lp_gainc, alpha ) /*Q15*/; L_tmp2 = L_mult( sub( 16384 /*1.f Q14*/, alpha ) /*Q14*/, gainCNG /*Q15,gainCNG_e*/ ); /*Q30,gainCNG_e*/ - st->Mode2_lp_gainc = BASOP_Util_Add_Mant32Exp( L_tmp, 31 - 15, L_tmp2, add( gainCNG_e, 31 - 30 ), &tmp_e ); /*Q31*/ - st->Mode2_lp_gainc = L_shl( st->Mode2_lp_gainc, sub( tmp_e, 31 - 16 ) ); + st->Mode2_lp_gainc = BASOP_Util_Add_Mant32Exp( L_tmp, 31 - 15, L_tmp2, add( gainCNG_e, 31 - 30 ), &tmp_e ); /*Q31-tmp_e*/ + st->Mode2_lp_gainc = L_shl( st->Mode2_lp_gainc, sub( tmp_e, 31 - 16 ) ); /*Q16*/ move32(); move32(); @@ -1873,7 +1873,7 @@ void con_tcx_ivas_fx( test(); IF( EQ_16( st->last_good, UNVOICED_CLAS ) && NE_16( st->core_ext_mode, UNVOICED ) ) { - gain_inov = mult_r( gain_inov, 26214 /*0.8f Q15*/ ); + gain_inov = mult_r( gain_inov, 26214 /*0.8f Q15*/ ); /*Q30*/ } ELSE IF( !( EQ_16( st->last_good, UNVOICED_CLAS ) || EQ_16( st->last_good, UNVOICED_TRANSITION ) ) ) { @@ -1907,7 +1907,7 @@ void con_tcx_ivas_fx( step32_tmp = L_shl( step32 /*Q25*/, sub( tmp_e, 25 - 16 ) ); /*Q16,-tmp_e*/ FOR( i = 0; i < tmp16; i++ ) /* Actual filtered random part of excitation */ { - *pt_exc = mult_r( *pt_exc, gain_tmp ); + *pt_exc = mult_r( *pt_exc, gain_tmp ); /*Q-15,noise_e+gain_inov_e-tmp_e*/ move16(); pt_exc++; gain32 = L_sub( gain32 /*Q16,-tmp_e*/, step32_tmp ); /*Q16,-tmp_e*/ @@ -1916,7 +1916,7 @@ void con_tcx_ivas_fx( tmp16 = shr( L_frame, 1 ); FOR( i = 0; i < tmp16; i++ ) /* causal ringing of the FIR filter */ { - *pt_exc = mult_r( *pt_exc, gain_tmp ); + *pt_exc = mult_r( *pt_exc, gain_tmp ); /*Q-15,noise_e+gain_inov_e-tmp_e*/ move16(); pt_exc++; } @@ -1944,7 +1944,7 @@ void con_tcx_ivas_fx( ELSE { bufferCopyFx( noise + L_FIR_FER2 / 2, exc, add( L_frame, shr( L_frame, 1 ) ), 0 /*Q_noise*/, noise_e, Q_exc, 0 /*exc_e*/ ); - Copy( exc + sub( L_frame, shl( L_subfr, 1 ) ), hTcxDec->old_excFB_fx, add( shl( L_subfr, 1 ), shr( L_frame, 1 ) ) ); + Copy( exc + sub( L_frame, shl( L_subfr, 1 ) ), hTcxDec->old_excFB_fx, add( shl( L_subfr, 1 ), shr( L_frame, 1 ) ) ); /*Q_exc*/ /* copy old_exc as 16kHz for acelp decoding */ IF( EQ_16( st->nbLostCmpt, 1 ) ) { @@ -1952,7 +1952,7 @@ void con_tcx_ivas_fx( } ELSE { - Copy( st->old_exc_fx + L_FRAME16k, st->old_exc_fx, L_FRAME16k / 2 ); + Copy( st->old_exc_fx + L_FRAME16k, st->old_exc_fx, L_FRAME16k / 2 ); /*Q_exc*/ lerp( exc, st->old_exc_fx + L_FRAME16k / 2, L_FRAME16k, L_frame ); } st->Q_exc = Q_exc; @@ -1962,15 +1962,15 @@ void con_tcx_ivas_fx( /*buf[OLD_EXC_SIZE_DEC;3/2 L_frame] Q1*/ /* Update Pitch Lag memory */ - Copy32( &st->old_pitch_buf_fx[st->nb_subfr], st->old_pitch_buf_fx, st->nb_subfr ); - Copy32( pitch_buf, &st->old_pitch_buf_fx[st->nb_subfr], st->nb_subfr ); + Copy32( &st->old_pitch_buf_fx[st->nb_subfr], st->old_pitch_buf_fx, st->nb_subfr ); /*Q16*/ + Copy32( pitch_buf, &st->old_pitch_buf_fx[st->nb_subfr], st->nb_subfr ); /*Q16*/ /*----------------------------------------------------------* * - compute the synthesis speech * *----------------------------------------------------------*/ - syn = buf + M; - Copy( synth - M, buf, M ); + syn = buf + M; /*Q_syn*/ + Copy( synth - M, buf, M ); /*Q_syn*/ new_Q = sub( Q_exc, 3 ); new_Q = s_max( new_Q, -1 ); @@ -1984,7 +1984,7 @@ void con_tcx_ivas_fx( Q_syn = tmp16; move16(); - Copy_Scale_sig( buf, mem_syn, M, exp_scale ); + Copy_Scale_sig( buf, mem_syn, M, exp_scale ); /* Q: tmp16 */ #ifdef BASOP_NOGLOB tmp_deemph = shl_sat( tmp_deemph, Q_syn ); @@ -2001,11 +2001,11 @@ void con_tcx_ivas_fx( { Word16 alpha_delayed; - alpha_delayed = 16384; + alpha_delayed = 16384; /*1.0f in Q14*/ move16(); IF( GT_16( st->nbLostCmpt, MDCT_ST_PLC_FADEOUT_DELAY_4_LSP_FADE ) ) { - alpha_delayed = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_DELAY_4_LSP_FADE, st->last_good, st->stab_fac_fx, &( st->Mode2_lp_gainp ), ACELP_CORE ); + alpha_delayed = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_DELAY_4_LSP_FADE, st->last_good, st->stab_fac_fx, &( st->Mode2_lp_gainp ), ACELP_CORE ); /*Q14*/ } test(); @@ -2013,13 +2013,13 @@ void con_tcx_ivas_fx( { Word16 lsp_local[M], lsp_fade[M], alpha_inv; - alpha_inv = sub( 16384, alpha_delayed ); + alpha_inv = sub( 16384 /*Q.0f in Q14*/, alpha_delayed ); /*Q14*/ E_LPC_a_lsp_conversion( A_local, lsp_local, lsp_local, M ); FOR( i = 0; i < M; i++ ) { - lsp_fade[i] = add( mult_r( alpha_delayed, lsp_local[i] ), mult_r( alpha_inv, st->lspold_cng[i] ) ); + lsp_fade[i] = add( mult_r( alpha_delayed, lsp_local[i] ), mult_r( alpha_inv, st->lspold_cng[i] ) ); /*Q14*/ move16(); } @@ -2043,37 +2043,37 @@ void con_tcx_ivas_fx( /*buf[0;M-1] Q0: mem_syn*/ /*buf[M;3/2 L_frame-1] Q-1: syn*/ - n = extract_h( L_mult( L_frame, 9216 /*(float)N_ZERO_MDCT_NS/(float)FRAME_SIZE_NS Q15*/ ) ); + n = extract_h( L_mult( L_frame, 9216 /*(float)N_ZERO_MDCT_NS/(float)FRAME_SIZE_NS Q15*/ ) ); /*Q0*/ /* update ACELP synthesis memory */ mem_syn_r_size_old = shr( L_frame, 4 ); /* replace 1.25/20.0 by shr(4) */ /* copy mem_syn as 16kHz */ mem_syn_r_size_new = shr( L_FRAME16k, 4 ); /* replace 1.25/20.0 by shr(4) */ - Copy( syn + sub( L_frame, L_SYN_MEM ), st->mem_syn_r, L_SYN_MEM ); + Copy( syn + sub( L_frame, L_SYN_MEM ), st->mem_syn_r, L_SYN_MEM ); /*Q_syn*/ lerp( st->mem_syn_r + sub( L_SYN_MEM, mem_syn_r_size_old ), st->mem_syn_r + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old ); - Copy( st->mem_syn_r + L_SYN_MEM - M, st->mem_syn2_fx, M ); + Copy( st->mem_syn_r + L_SYN_MEM - M, st->mem_syn2_fx, M ); /*Q_syn*/ /* Deemphasis and output synth and ZIR */ deemph_fx( syn, st->preemph_fac, add( L_frame, shr( L_frame, 1 ) ), &tmp_deemph ); - bufferCopyFx( syn + sub( L_frame, M + 1 ), st->syn, 1 + M, Q_syn, 0, 0, 0 ); + bufferCopyFx( syn + sub( L_frame, M + 1 ), st->syn, 1 + M, Q_syn, 0, 0, 0 ); /*Q_syn*/ lerp( syn + sub( L_frame, shr( L_frame, 1 ) ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); - Copy( syn + sub( L_frame, n ), hHQ_core->old_out_fx, sub( L_frame, n ) ); + Copy( syn + sub( L_frame, n ), hHQ_core->old_out_fx, sub( L_frame, n ) ); /*Q_syn*/ FOR( i = 0; i < W12; i++ ) { - hHQ_core->old_out_fx[add( i, n )] = round_fx( Mpy_32_16_1( L_mult( w[i].v.re, w[i].v.re ), hHQ_core->old_out_fx[add( i, n )] ) ); + hHQ_core->old_out_fx[( i + n )] = round_fx( Mpy_32_16_1( L_mult( w[i].v.re, w[i].v.re ), hHQ_core->old_out_fx[( i + n )] ) ); /*Q_syn*/ move16(); } FOR( ; i < W1; i++ ) { - hHQ_core->old_out_fx[add( i, n )] = round_fx( Mpy_32_16_1( L_mult( w[sub( sub( W12, 1 ), sub( i, W12 ) )].v.im, w[sub( sub( W12, 1 ), sub( i, W12 ) )].v.im ), hHQ_core->old_out_fx[add( i, n )] ) ); + hHQ_core->old_out_fx[( i + n )] = round_fx( Mpy_32_16_1( L_mult( w[( ( W12 - 1 ) - ( i - W12 ) )].v.im, w[( ( W12 - 1 ) - ( i - W12 ) )].v.im ), hHQ_core->old_out_fx[( i + n )] ) ); /*Q_syn*/ move16(); } - set16_fx( &hHQ_core->old_out_fx[add( W1, n )], 0, n ); + set16_fx( &hHQ_core->old_out_fx[( W1 + n )], 0, n ); hHQ_core->Q_old_wtda = Q_syn; move16(); @@ -2081,10 +2081,10 @@ void con_tcx_ivas_fx( /* As long as there is no synth scaling factor introduced, which is given to the outside, there might occur overflows here */ BASOP_SATURATE_WARNING_OFF_EVS - bufferCopyFx( syn, synth, L_frame, Q_syn, 0, 0, 0 ); + bufferCopyFx( syn, synth, L_frame, Q_syn, 0, 0, 0 ); /*Q_syn*/ BASOP_SATURATE_WARNING_ON_EVS - Copy_Scale_sig( syn + L_frame, hTcxDec->syn_OverlFB, shr( L_frame, 1 ), negate( Q_syn ) ); + Copy_Scale_sig( syn + L_frame, hTcxDec->syn_OverlFB, shr( L_frame, 1 ), negate( Q_syn ) ); /*Q0*/ /* copy total excitation exc2 as 16kHz for acelp mode1 decoding */ IF( st->hWIDec != NULL ) @@ -2109,49 +2109,49 @@ void con_tcx_ivas_fx( FOR( i = 0; i < W12; i++ ) { - buf[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[i].v.re ); + buf[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[i].v.re ); /*hTcxDec->Q_syn_Overl_TDACFB*/ move16(); } FOR( ; i < W1; i++ ) { - buf[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[sub( sub( W12, 1 ), sub( i, W12 ) )].v.im ); + buf[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[( ( W12 - 1 ) - ( i - W12 ) )].v.im ); /*hTcxDec->Q_syn_Overl_TDACFB*/ move16(); } FOR( i = 0; i < W2; i++ ) { - hTcxDec->syn_Overl_TDACFB[i] = add_sat( buf[i], buf[sub( sub( W1, 1 ), i )] ); + hTcxDec->syn_Overl_TDACFB[i] = add_sat( buf[i], buf[( ( W1 - 1 ) - i )] ); /*hTcxDec->Q_syn_Overl_TDACFB*/ move16(); } FOR( i = 0; i < W2; i++ ) { - hTcxDec->syn_Overl_TDACFB[add( W2, i )] = add_sat( buf[add( W2, i )], buf[sub( sub( sub( W1, 1 ), W2 ), i )] ); + hTcxDec->syn_Overl_TDACFB[( W2 + i )] = add_sat( buf[( W2 + i )], buf[( ( ( W1 - 1 ) - W2 ) - i )] ); /*hTcxDec->Q_syn_Overl_TDACFB*/ move16(); } FOR( i = 0; i < W12; i++ ) { - hTcxDec->syn_Overl_TDACFB[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[i].v.re ); + hTcxDec->syn_Overl_TDACFB[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[i].v.re ); /*hTcxDec->Q_syn_Overl_TDACFB*/ move16(); } FOR( ; i < W1; i++ ) { - hTcxDec->syn_Overl_TDACFB[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[sub( sub( W12, 1 ), sub( i, W12 ) )].v.im ); + hTcxDec->syn_Overl_TDACFB[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[( ( W12 - 1 ) - ( i - W12 ) )].v.im ); /*hTcxDec->Q_syn_Overl_TDACFB*/ move16(); } st->hTcxCfg->tcx_curr_overlap_mode = FULL_OVERLAP; move16(); - synth[-1] = pre_emph_buf; + synth[-1] = pre_emph_buf; /*Q0*/ move16(); /* update memory for low band */ st->Q_syn = 0; move16(); - Scale_sig( hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, Q_syn ) ); + Scale_sig( hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, Q_syn ) ); /*Q_syn*/ lerp( hTcxDec->syn_OverlFB, hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); lerp( hTcxDec->syn_Overl_TDACFB, hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); hTcxDec->Q_syn_Overl_TDAC = hTcxDec->Q_syn_Overl_TDACFB; diff --git a/lib_dec/ivas_decision_matrix_dec.c b/lib_dec/ivas_decision_matrix_dec.c index 0a4e950f6..ec8de4900 100644 --- a/lib_dec/ivas_decision_matrix_dec.c +++ b/lib_dec/ivas_decision_matrix_dec.c @@ -514,7 +514,7 @@ void ivas_decision_matrix_dec_fx( test(); test(); test(); - IF( ( st->idchan == 0 && ( EQ_32( st->total_brate, FRAME_NO_DATA ) || EQ_32( st->total_brate, SID_2k40 ) ) ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LE_32( st->total_brate, SID_2k40 ) ) ) + IF( ( st->idchan == 0 && ( ( st->total_brate == FRAME_NO_DATA ) || EQ_32( st->total_brate, SID_2k40 ) ) ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LE_32( st->total_brate, SID_2k40 ) ) ) { st->core = ACELP_CORE; move16(); @@ -578,7 +578,7 @@ void ivas_decision_matrix_dec_fx( test(); test(); test(); - if ( EQ_32( st->total_brate, FRAME_NO_DATA ) && st->prev_bfi && !st->bfi && GT_16( st->L_frame, L_FRAME16k ) ) + if ( ( st->total_brate == FRAME_NO_DATA ) && st->prev_bfi && !st->bfi && GT_16( st->L_frame, L_FRAME16k ) ) { st->L_frame = st->last_CNG_L_frame; move16(); @@ -654,6 +654,7 @@ void ivas_decision_matrix_dec_fx( { *sharpFlag = 0; move16(); + test(); if ( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, VOICED ) ) { *sharpFlag = 1; @@ -678,6 +679,7 @@ void ivas_decision_matrix_dec_fx( IF( LT_32( element_brate, FRMT_SHP_MIN_BRATE_IVAS ) ) { st->coder_type = get_next_indice_fx( st, 3 ); + move16(); *sharpFlag = 0; move16(); @@ -694,9 +696,10 @@ void ivas_decision_matrix_dec_fx( { /* get coder_type info */ st->coder_type = get_next_indice_fx( st, 3 ); - + move16(); /* get sharpening flag */ *sharpFlag = get_next_indice_fx( st, 1 ); + move16(); } } } @@ -785,7 +788,7 @@ void ivas_decision_matrix_dec_fx( ELSE { st->extl = SWB_TBE; - move32(); + move16(); st->extl_brate = SWB_TBE_1k6; move32(); test(); @@ -878,7 +881,7 @@ void ivas_decision_matrix_dec_fx( test(); test(); test(); - if ( GE_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( st->core, ACELP_CORE ) && ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) + if ( GE_16( st->element_mode, IVAS_CPE_DFT ) && ( st->core == ACELP_CORE ) && ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) { icbwe_brate = L_add( icbwe_brate, STEREO_ICBWE_MSFLAG_BITS * FRAMES_PER_SEC ); } diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index a127cd1a4..155e03a17 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -278,6 +278,7 @@ static ivas_error ivas_dirac_rend_config_fx( IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { st_ivas->nchan_transport = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + move16(); } nchan_transport = st_ivas->nchan_transport; @@ -312,7 +313,7 @@ static ivas_error ivas_dirac_rend_config_fx( Copy32( hDirACRend->hOutSetup.ls_elevation_fx, ls_elevation_fx, nchan_out_woLFE ); } - IF( EQ_16( hDirACRend->hOutSetup.ambisonics_order, negate( (Word16) 1 ) ) ) + IF( EQ_16( hDirACRend->hOutSetup.ambisonics_order, -1 ) ) { hDirACRend->hOutSetup.ambisonics_order = SBA_HOA3_ORDER; /* Order 3 is used by default in DirAC for SHD processing */ move16(); @@ -340,6 +341,7 @@ static ivas_error ivas_dirac_rend_config_fx( { /* Remove the channel of the separated signal from the output setup of the spatial synthesis */ hDirACRend->hOutSetup.nchan_out_woLFE = sub( hDirACRend->hOutSetup.nchan_out_woLFE, 1 ); + move16(); nchan_out_woLFE = hDirACRend->hOutSetup.nchan_out_woLFE; move16(); Copy32( &ls_azimuth_fx[hDirACRend->hOutSetup.separateChannelIndex + 1], &ls_azimuth_fx[hDirACRend->hOutSetup.separateChannelIndex], sub( nchan_out_woLFE, hDirACRend->hOutSetup.separateChannelIndex ) ); @@ -470,7 +472,9 @@ static ivas_error ivas_dirac_rend_config_fx( /* Directional and diffuses components in SHD */ /* Diffuseness components up to 1st order */ hDirACRend->num_outputs_diff = mult0( ( add( s_min( hDirACRend->hOutSetup.ambisonics_order, 1 ), 1 ) ), ( add( s_min( hDirACRend->hOutSetup.ambisonics_order, 1 ), 1 ) ) ); + move16(); hDirACRend->num_outputs_dir = ivas_sba_get_nchan_fx( hDirACRend->hOutSetup.ambisonics_order, 0 ); + move16(); } ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) ) { @@ -893,7 +897,7 @@ static ivas_error ivas_dirac_rend_config_fx( } test(); - IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) || EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) + if ( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) || EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { hDirACRend->h_output_synthesis_psd_params.use_onset_filters = 0; move16(); @@ -934,6 +938,7 @@ static ivas_error ivas_dirac_rend_config_fx( } } hDirACRend->proto_frame_f_len = imult1616( 2, imult1616( hDirACRend->num_protos_diff, hSpatParamRendCom->num_freq_bands ) ); + move16(); } if ( EQ_16( flag_config, DIRAC_OPEN ) ) @@ -975,12 +980,13 @@ static ivas_error ivas_dirac_rend_config_fx( set32_fx( hDirACRend->buffer_energy_fx, 0, DIRAC_NO_COL_AVG_DIFF * CLDFB_NO_CHANNELS_MAX ); set16_fx( hDirACRend->q_buffer_energy, Q31, DIRAC_NO_COL_AVG_DIFF ); } - ELSE IF( ( EQ_16( flag_config, DIRAC_OPEN ) && EQ_16( hDirAC->hConfig->dec_param_estim, FALSE ) ) || ( EQ_16( flag_config, DIRAC_RECONFIGURE ) && ( EQ_16( hDirAC->hConfig->dec_param_estim, FALSE ) && EQ_16( dec_param_estim_old, TRUE ) ) ) ) + ELSE IF( ( EQ_16( flag_config, DIRAC_OPEN ) && hDirAC->hConfig->dec_param_estim == FALSE ) || ( EQ_16( flag_config, DIRAC_RECONFIGURE ) && ( ( hDirAC->hConfig->dec_param_estim == FALSE ) && EQ_16( dec_param_estim_old, TRUE ) ) ) ) { FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) { FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) { + test(); IF( EQ_16( flag_config, DIRAC_RECONFIGURE ) && hDirACRend->buffer_intensity_real_fx[i][j] ) { free( hDirACRend->buffer_intensity_real_fx[i][j] ); @@ -1702,7 +1708,7 @@ ivas_error ivas_dirac_dec_config_fx( move16(); test(); test(); - IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) && EQ_16( st_ivas->ivas_format, SBA_FORMAT ) && !hodirac_flag ) + if ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) && EQ_16( st_ivas->ivas_format, SBA_FORMAT ) && !hodirac_flag ) { sparfoa_flag = 1; move16(); @@ -1829,7 +1835,7 @@ ivas_error ivas_dirac_dec_config_fx( /* This is required to keep BE in rate switching. This probably means that 1TC and 2TC MASA perform differently. */ test(); test(); - IF( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params != NULL && !( st_ivas->ivas_format == MASA_FORMAT && st_ivas->nSCE > 0 ) ) + IF( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params != NULL && !( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && st_ivas->nSCE > 0 ) ) { ivas_dirac_dec_decorr_close_fx( &st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params, &st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state ); // done } @@ -2029,7 +2035,7 @@ ivas_error ivas_dirac_dec_config( * * Close DirAC memories *------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED void ivas_dirac_dec_close( DIRAC_DEC_HANDLE *hDirAC_out ) { @@ -2055,7 +2061,7 @@ void ivas_dirac_dec_close( return; } -#ifdef IVAS_FLOAT_FIXED +#else void ivas_dirac_dec_close_fx( DIRAC_DEC_HANDLE *hDirAC_out ) { @@ -2112,6 +2118,7 @@ void ivas_dirac_dec_read_BS_fx( move16(); iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &quo, &rem, 0 ); st->next_bit_pos = extract_l( L_sub( quo, 1 ) ); + move16(); if ( last_bit_pos > 0 ) { st->next_bit_pos = last_bit_pos; @@ -2155,7 +2162,7 @@ void ivas_dirac_dec_read_BS_fx( } FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { - FOR( j = sub( orig_dirac_bands, 2 ); j >= 0; j-- ) + FOR( j = ( orig_dirac_bands - 2 ); j >= 0; j-- ) { hQMetaData->q_direction[0].band_data[j].azimuth_fx[i] = hQMetaData->q_direction[0].band_data[0].azimuth_fx[0]; move32(); @@ -2239,7 +2246,7 @@ void ivas_dirac_dec_read_BS_fx( } FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { - FOR( j = sub( orig_dirac_bands, 2 ); j >= 0; j-- ) + FOR( j = ( orig_dirac_bands - 2 ); j >= 0; j-- ) { hQMetaData->q_direction[0].band_data[j].azimuth_fx[i] = hQMetaData->q_direction[0].band_data[0].azimuth_fx[0]; move32(); @@ -2421,7 +2428,7 @@ void ivas_qmetadata_to_dirac_fx( const Word32 ivas_total_brate, /* i : IVAS total bitrate */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ const Word16 hodirac_flag, /* i : flag to indicate HO-DirAC mode */ - Word16 *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ + Word16 *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands Q0*/ ) { Word16 block, band; @@ -2435,16 +2442,20 @@ void ivas_qmetadata_to_dirac_fx( Word16 *band_grouping; Word16 start_band; Word16 nbands = 0; + move16(); Word16 nblocks = 0; + move16(); Word16 qBand_idx; Word16 idx_sec = 0; + move16(); Word16 no_secs = 1; + move16(); q_direction = &( hQMetaData->q_direction[0] ); hSpatParamRendCom->numParametricDirections = hQMetaData->no_directions; move16(); hSpatParamRendCom->numSimultaneousDirections = add( hSpatParamRendCom->numParametricDirections, hSpatParamRendCom->numIsmDirections ); - + move16(); test(); IF( hMasa != NULL && GT_32( ivas_total_brate, IVAS_SID_5k2 ) ) { @@ -2642,7 +2653,6 @@ void ivas_qmetadata_to_dirac_fx( move16(); tmp_write_idx_band = add( tmp_write_idx_band, 1 ) % hSpatParamRendCom->dirac_md_buffer_length; - move16(); } } } @@ -2668,7 +2678,6 @@ void ivas_qmetadata_to_dirac_fx( IF( EQ_32( ivas_format, SBA_FORMAT ) ) { qBand_idx = sub( dirac_to_spar_md_bands[band], start_band ); - move16(); } ELSE { @@ -2740,14 +2749,13 @@ void ivas_qmetadata_to_dirac_fx( Word16 exp_factor = 0; move16(); a = rand_triangular_signed_fx( seed_ptr, &exp_factor ); // q = exp_factor - move16(); + tmp1 = mult( a, dirac_dithering_azi_scale_fx[diff_idx] ); // exp_factor + 5 Word32 tmp1_32 = L_deposit_h( tmp1 ); Word16 final_1_exp; Word32 final_1_32 = BASOP_Util_Add_Mant32Exp( azimuth_fx, 9, tmp1_32, exp_factor + 5, &final_1_exp ); - b_tmp = rand_triangular_signed_fx( seed_ptr, &exp_factor ); // q = exp_factor - move16(); + b_tmp = rand_triangular_signed_fx( seed_ptr, &exp_factor ); // q = exp_factor tmp4 = mult( b_tmp, dirac_dithering_ele_scale_fx[diff_idx] ); // exp_factor + 4 Word32 tmp4_32 = L_deposit_h( tmp4 ); @@ -2758,8 +2766,8 @@ void ivas_qmetadata_to_dirac_fx( final_1_32 = BASOP_Util_Add_Mant32Exp( final_1_32, final_1_exp, ONE_IN_Q30, 0, &final_1_exp ); /*0.5 in q31*/ final_2_32 = BASOP_Util_Add_Mant32Exp( final_2_32, final_2_exp, ONE_IN_Q30, 0, &final_2_exp ); - azi = extract_h( L_shr( final_1_32, 31 - final_1_exp - 16 ) ); - ele = extract_h( L_shr( final_2_32, 31 - final_2_exp - 16 ) ); + azi = extract_h( L_shr( final_1_32, sub( sub( 31, final_1_exp ), 16 ) ) ); + ele = extract_h( L_shr( final_2_32, sub( sub( 31, final_2_exp ), 16 ) ) ); /*addition of one to compensate precision loss*/ if ( azi < 0 ) @@ -2836,7 +2844,7 @@ void ivas_qmetadata_to_dirac_fx( } } tmp_write_idx_param_band = add( tmp_write_idx_param_band, 1 ) % hSpatParamRendCom->dirac_md_buffer_length; - move16(); + } /* for ( block =...) */ } /* for ( band = ...) */ @@ -2875,7 +2883,7 @@ void ivas_qmetadata_to_dirac_fx( } /* update buffer write index */ hSpatParamRendCom->dirac_bs_md_write_idx = add( hSpatParamRendCom->dirac_bs_md_write_idx, MAX_PARAM_SPATIAL_SUBFRAMES ) % hSpatParamRendCom->dirac_md_buffer_length; - + move16(); return; } #else @@ -3296,6 +3304,7 @@ void ivas_dirac_dec_set_md_map( } iDiv_and_mod_32( W_extract_l( W_shl_nosat( tmp_fx, 16 ) ), hSpatParamRendCom->subframe_nbslots[sf_idx], &quo, &rem, 0 ); hSpatParamRendCom->render_to_md_map[sf_idx] = add( round_fx( quo ), hSpatParamRendCom->dirac_read_idx ) % hSpatParamRendCom->dirac_md_buffer_length; + move16(); } set16_fx( &hSpatParamRendCom->render_to_md_map[hSpatParamRendCom->nb_subframes], 0, sub( MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME, hSpatParamRendCom->nb_subframes ) ); @@ -3458,15 +3467,12 @@ void ivas_dirac_dec_set_md_map_fx( norm_num = norm_l( tmp_fx ); num = L_shl( tmp_fx, norm_num ); exp_num = sub( exp_num, norm_num ); - move16(); norm_denom = norm_s( hSpatParamRendCom->subframe_nbslots[sf_idx] ); denom = shl( hSpatParamRendCom->subframe_nbslots[sf_idx], norm_denom ); exp_denom = sub( exp_denom, norm_denom ); - move16(); exp = sub( exp_num, exp_denom ); - move16(); IF( GT_32( num, L_deposit_l( denom ) ) ) { @@ -3478,7 +3484,7 @@ void ivas_dirac_dec_set_md_map_fx( ans_fix_32 = BASOP_Util_Add_Mant32Exp( ans, exp, L_deposit_h( hSpatParamRendCom->dirac_read_idx ), 15 /*31 - 16*/, &exp_final ); ans_fix_16 = round_fx( L_shr( ans_fix_32, sub( sub( Q31, exp_final ), Q16 ) ) ); - hSpatParamRendCom->render_to_md_map[sf_idx] = ans_fix_16 % hSpatParamRendCom->dirac_md_buffer_length; + hSpatParamRendCom->render_to_md_map[sf_idx] = ans_fix_16 % hSpatParamRendCom->dirac_md_buffer_length; // Q0 move16(); } set16_fx( &hSpatParamRendCom->render_to_md_map[hSpatParamRendCom->nb_subframes], 0, sub( MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME, hSpatParamRendCom->nb_subframes ) ); @@ -3500,7 +3506,7 @@ void ivas_dirac_dec_render_fx( const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ UWord16 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ - Word32 *output_fx[] /* o : rendered time signal */ + Word32 *output_fx[] /* o : rendered time signal Q(6-1)*/ ) { Word16 slots_to_render, first_sf, last_sf, subframe_idx; @@ -3520,7 +3526,7 @@ void ivas_dirac_dec_render_fx( set_zero_fx( output_f_local_fx[ch], nSamplesAsked ); } slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); // cL - move16(); + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = s_min( sub( hSpatParamRendCom->num_slots, hSpatParamRendCom->slots_rendered ), idiv1616( nSamplesAsked, slot_size ) ); @@ -3537,7 +3543,6 @@ void ivas_dirac_dec_render_fx( { slots_to_render = sub( slots_to_render, hSpatParamRendCom->subframe_nbslots[last_sf] ); last_sf = add( last_sf, 1 ); - move16(); } FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) @@ -3563,7 +3568,7 @@ void ivas_dirac_dec_render_fx( { test(); test(); - IF( !( L_and( ( st_ivas->hDirACRend->hOutSetup.separateChannelEnabled ), ( L_or( EQ_16( st_ivas->hDirACRend->hOutSetup.separateChannelIndex, ch ), EQ_16( add( st_ivas->hDirACRend->hOutSetup.separateChannelIndex, 1 ), ch ) ) ) ) ) ) + IF( !( ( st_ivas->hDirACRend->hOutSetup.separateChannelEnabled ) && ( ( EQ_16( st_ivas->hDirACRend->hOutSetup.separateChannelIndex, ch ) || EQ_16( add( st_ivas->hDirACRend->hOutSetup.separateChannelIndex, 1 ), ch ) ) ) ) ) { Copy32( output_f_local_buff_fx[ch], output_fx[ch], *nSamplesRendered ); } @@ -3572,16 +3577,16 @@ void ivas_dirac_dec_render_fx( IF( EQ_16( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->num_slots ) ){ IF( EQ_16( st_ivas->hDirAC->hConfig->dec_param_estim, 1 ) ){ temp = add( hSpatParamRendCom->dirac_read_idx, DEFAULT_JBM_CLDFB_TIMESLOTS ); - hSpatParamRendCom->dirac_read_idx = sub( temp, i_mult( idiv1616( temp, hSpatParamRendCom->dirac_md_buffer_length ), hSpatParamRendCom->dirac_md_buffer_length ) ); + hSpatParamRendCom->dirac_read_idx = sub( temp, i_mult( idiv1616( temp, hSpatParamRendCom->dirac_md_buffer_length ), hSpatParamRendCom->dirac_md_buffer_length ) ); // Q0 } ELSE { temp = add( hSpatParamRendCom->dirac_read_idx, DEFAULT_JBM_SUBFRAMES_5MS ); - hSpatParamRendCom->dirac_read_idx = sub( temp, i_mult( idiv1616( temp, hSpatParamRendCom->dirac_md_buffer_length ), hSpatParamRendCom->dirac_md_buffer_length ) ); + hSpatParamRendCom->dirac_read_idx = sub( temp, i_mult( idiv1616( temp, hSpatParamRendCom->dirac_md_buffer_length ), hSpatParamRendCom->dirac_md_buffer_length ) ); // Q0 } } -*nSamplesAvailableNext = i_mult( sub( hSpatParamRendCom->num_slots, hSpatParamRendCom->slots_rendered ), slot_size ); +*nSamplesAvailableNext = i_mult( sub( hSpatParamRendCom->num_slots, hSpatParamRendCom->slots_rendered ), slot_size ); // Q0 move16(); return; @@ -3677,11 +3682,12 @@ void ivas_dirac_dec_render( *------------------------------------------------------------------------*/ void ivas_dirac_dec_render_sf_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - Word32 *output_buf_fx[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const Word16 nchan_transport, /* i : number of transport channels */ - Word32 *pppQMfFrame_ts_re_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], - Word32 *pppQMfFrame_ts_im_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] ) + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Word32 *output_buf_fx[], /* i/o: synthesized core-coder transport channels/DirAC output Q(6-1)*/ + const Word16 nchan_transport, /* i : number of transport channels */ + Word32 *pppQMfFrame_ts_re_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], /*Q6*/ + Word32 *pppQMfFrame_ts_im_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] /*Q6*/ +) { Word16 i, ch, idx_in, idx_lfe; DIRAC_DEC_HANDLE hDirAC; @@ -3785,15 +3791,16 @@ void ivas_dirac_dec_render_sf_fx( } test(); - IF( L_or( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ), EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) ) ) + IF( ( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ) || EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) ) ) { IF( hDirACRend->h_output_synthesis_psd_params.max_band_decorr != 0 ) { DIRAC_OUTPUT_SYNTHESIS_STATE *state = &( hDirACRend->h_output_synthesis_psd_state ); tmp1 = L_norm_arr( state->proto_power_diff_smooth_fx, state->proto_power_diff_smooth_len ); - scale_sig32( state->proto_power_diff_smooth_fx, state->proto_power_diff_smooth_len, tmp1 ); + scale_sig32( state->proto_power_diff_smooth_fx, state->proto_power_diff_smooth_len, tmp1 ); // Q(proto_power_diff_smooth_q + tmp1) state->proto_power_diff_smooth_q = add( state->proto_power_diff_smooth_q, tmp1 ); + move16(); } } @@ -3813,7 +3820,7 @@ void ivas_dirac_dec_render_sf_fx( IF( h_dirac_output_synthesis_params->use_onset_filters && ( NE_16( hDirAC->hConfig->dec_param_estim, TRUE ) && NE_32( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) ) { tmp1 = getScaleFactor32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); - scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ), sub( tmp1, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ); + scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ), sub( tmp1, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ); // tmp1 h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = tmp1; move16(); } @@ -3823,18 +3830,20 @@ void ivas_dirac_dec_render_sf_fx( { Word16 shift; shift = L_norm_arr( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); - scale_sig32( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ), shift ); + scale_sig32( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ), shift ); // h_dirac_output_synthesis_state->q_cy_auto_dir_smooth + shift h_dirac_output_synthesis_state->q_cy_auto_dir_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, shift ); - + move16(); shift = L_norm_arr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); - scale_sig32( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ), shift ); + scale_sig32( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ), shift ); // h_dirac_output_synthesis_state->q_cy_auto_dir_smooth + shift h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = add( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, shift ); - + move16(); tmp1 = L_norm_arr( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); - scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ), tmp1 ); + scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ), tmp1 ); // h_dirac_output_synthesis_state->q_cy_auto_dir_smooth + tmp1 h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, tmp1 ); + move16(); } + test(); test(); IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) @@ -3845,7 +3854,7 @@ void ivas_dirac_dec_render_sf_fx( move16(); } } - ELSE IF( !L_or( EQ_16( st_ivas->ivas_format, SBA_FORMAT ), EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ) + ELSE IF( !( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ) { Word16 outchannels; idx_lfe = 0; @@ -3877,7 +3886,7 @@ void ivas_dirac_dec_render_sf_fx( FOR( ch = 0; ch < outchannels; ch++ ) { test(); - IF( L_and( hDirACRend->hOutSetup.num_lfe > 0, ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) ) + IF( ( hDirACRend->hOutSetup.num_lfe > 0 && ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) ) { IF( LT_16( idx_lfe, sub( hDirACRend->hOutSetup.num_lfe, 1 ) ) ) { @@ -3890,10 +3899,12 @@ void ivas_dirac_dec_render_sf_fx( { FOR( ch = 0; ch < outchannels; ch++ ) { + test(); test(); - IF( L_and( hDirACRend->hOutSetup.num_lfe > 0, ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) ) + IF( ( hDirACRend->hOutSetup.num_lfe > 0 && ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) ) { + test(); IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && !hDirACRend->hOutSetup.separateChannelEnabled ) { Word16 cldfbSynIdx; @@ -3925,7 +3936,7 @@ void ivas_dirac_dec_render_sf_fx( size_ho = size; move16(); } - scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, size, sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, size, sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q ) ); // Q26 hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q = Q26; move16(); @@ -3933,49 +3944,51 @@ void ivas_dirac_dec_render_sf_fx( { Word16 shift; shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, size_ho ); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, size_ho, shift ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, size_ho, shift ); // Q(hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth + shift) hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth = add( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, shift ); + move16(); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, size_ho, sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, size_ho, sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev ) ); // Q26 hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev = Q26; move16(); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, imult1616( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, imult1616( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth ) ); // Q26 hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth = Q26; move16(); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, imult1616( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, imult1616( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev ) ); // Q26 hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev = Q26; move16(); } ELSE { Word16 shift; - scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->hOutSetup.nchan_out_woLFE ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->hOutSetup.nchan_out_woLFE ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q ) ); // Q26 hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q = Q26; move16(); shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, size_ho ); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, size_ho, shift ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, size_ho, shift ); // Q( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev+ shift) hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev, shift ); - + move16(); shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, size_ho ); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, size_ho, shift ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, size_ho, shift ); // Q(hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev + shift) hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, shift ); - + move16(); tmp1 = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->hOutSetup.nchan_out_woLFE ) ); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->hOutSetup.nchan_out_woLFE ), tmp1 ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->hOutSetup.nchan_out_woLFE ), tmp1 ); // Q(hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev+ tmp1) hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, tmp1 ); - + move16(); tmp1 = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, imult1616( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ) ); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, imult1616( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ), tmp1 ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, imult1616( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ), tmp1 ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q tmp1) hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, tmp1 ); - + move16(); IF( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx != 0 ) { tmp1 = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, imult1616( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ) ); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, imult1616( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ), tmp1 ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, imult1616( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ), tmp1 ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q+ tmp1) hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q, tmp1 ); + move16(); } } @@ -4001,7 +4014,7 @@ void ivas_dirac_dec_render_sf_fx( subframe_idx = hSpatParamRendCom->subframes_rendered; move16(); - IF( EQ_16( hDirAC->hConfig->dec_param_estim, FALSE ) ) + IF( ( hDirAC->hConfig->dec_param_estim == FALSE ) ) { md_idx = hSpatParamRendCom->render_to_md_map[subframe_idx]; move16(); @@ -4013,7 +4026,7 @@ void ivas_dirac_dec_render_sf_fx( } /* copy parameters into local buffers*/ - IF( EQ_16( hDirAC->hConfig->dec_param_estim, FALSE ) ) + IF( ( hDirAC->hConfig->dec_param_estim == FALSE ) ) { Copy32( hSpatParamRendCom->diffuseness_vector_fx[hSpatParamRendCom->render_to_md_map[subframe_idx]], diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands ); q_diffuseness_vector = Q30; @@ -4028,7 +4041,7 @@ void ivas_dirac_dec_render_sf_fx( move16(); } - IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) + IF( NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { set_zero_fx( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands ); } @@ -4046,7 +4059,7 @@ void ivas_dirac_dec_render_sf_fx( { num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; move16(); - IF( EQ_16( hDirAC->hConfig->dec_param_estim, FALSE ) ) + IF( ( hDirAC->hConfig->dec_param_estim == FALSE ) ) { rotateAziEle_DirAC_fx( azimuth, elevation, num_freq_bands, hSpatParamRendCom->num_freq_bands, p_Rmat_fx ); } @@ -4055,13 +4068,14 @@ void ivas_dirac_dec_render_sf_fx( ELSE { p_Rmat_fx = 0; + move32(); } - IF( EQ_16( hDirAC->hConfig->dec_param_estim, FALSE ) ) + IF( ( hDirAC->hConfig->dec_param_estim == FALSE ) ) { Word16 *masa_band_mapping; /* compute response */ - IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) + IF( NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { ivas_dirac_dec_compute_power_factors_fx( hSpatParamRendCom->num_freq_bands, diffuseness_vector_fx, @@ -4089,7 +4103,7 @@ void ivas_dirac_dec_render_sf_fx( surCohRatio_fx[i] = BASOP_Util_Divide3232_Scale( surCohEner_fx, ( L_add( EPSILLON_FX, L_add( dirEne_fx, surCohEner_fx ) ) ), &temp_q ); move32(); - surCohRatio_fx[i] = L_shl( surCohRatio_fx[i], temp_q ); + surCohRatio_fx[i] = L_shl( surCohRatio_fx[i], temp_q ); // Q31 move32(); } } @@ -4114,13 +4128,16 @@ void ivas_dirac_dec_render_sf_fx( &max_exp_direct, &max_exp_diffusion ); hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q = sub( Q31, max_exp_direct ); + move16(); hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q = sub( Q31, max_exp_diffusion ); + move16(); IF( coherence_flag ) { FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) { surCohRatio_fx[i] = L_deposit_l( hSpatParamRendCom->surroundingCoherence_fx[md_idx][i] ); + move32(); } } ELSE @@ -4176,7 +4193,7 @@ void ivas_dirac_dec_render_sf_fx( } test(); - IF( L_and( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ), EQ_16( nchan_transport, 2 ) ) ) + IF( ( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( nchan_transport, 2 ) ) ) { FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { @@ -4198,7 +4215,7 @@ void ivas_dirac_dec_render_sf_fx( } test(); - IF( L_and( NE_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ), NE_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) ) + IF( ( NE_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && NE_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) ) { ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( st_ivas, Cldfb_RealBuffer_Temp_fx, Cldfb_ImagBuffer_Temp_fx, &cldfb_buf_q, hSpatParamRendCom->num_freq_bands, subframe_idx ); } @@ -4219,7 +4236,7 @@ void ivas_dirac_dec_render_sf_fx( } test(); test(); - IF( L_or( EQ_16( st_ivas->ivas_format, SBA_FORMAT ), EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ) + IF( ( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ) { FOR( ch = 0; ch < nchan_transport; ch++ ) { @@ -4229,7 +4246,7 @@ void ivas_dirac_dec_render_sf_fx( q_cldfb = Q6; move16(); } - ELSE IF( L_and( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ), EQ_16( nchan_transport, 2 ) ) ) + ELSE IF( ( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( nchan_transport, 2 ) ) ) { FOR( ch = 0; ch < nchan_transport; ch++ ) { @@ -4260,13 +4277,16 @@ void ivas_dirac_dec_render_sf_fx( test(); test(); test(); - IF( EQ_16( st_ivas->nchan_transport, 1 ) && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && !( L_or( EQ_16( st_ivas->ivas_format, SBA_FORMAT ), EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ) ) + IF( EQ_16( st_ivas->nchan_transport, 1 ) && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && !( ( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ) ) { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; Word16 Q_input = Q11; move16(); q_temp_cldfb = Q11; move16(); + test(); + test(); + test(); generate_masking_noise_dirac_ivas_fx( st->hFdCngDec->hFdCngCom, st_ivas->cldfbAnaDec[1], st_ivas->hTcBuffer->tc_fx[1], @@ -4274,9 +4294,9 @@ void ivas_dirac_dec_render_sf_fx( Cldfb_ImagBuffer_fx[1][0], index_slot, st->cna_dirac_flag && st->flag_cna, - ( L_or( EQ_32( st->core_brate, FRAME_NO_DATA ), EQ_32( st->core_brate, SID_2k40 ) ) ) && EQ_16( st->cng_type, FD_CNG ) && st->cng_sba_flag, Q_input, &q_temp_cldfb ); - Scale_sig32( Cldfb_RealBuffer_fx[1][0], CLDFB_NO_CHANNELS_MAX, sub( Q6, q_temp_cldfb ) ); - Scale_sig32( Cldfb_ImagBuffer_fx[1][0], CLDFB_NO_CHANNELS_MAX, sub( Q6, q_temp_cldfb ) ); + ( ( ( st->core_brate == FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) ) ) && EQ_16( st->cng_type, FD_CNG ) && st->cng_sba_flag, Q_input, &q_temp_cldfb ); + Scale_sig32( Cldfb_RealBuffer_fx[1][0], CLDFB_NO_CHANNELS_MAX, sub( Q6, q_temp_cldfb ) ); // Q6 + Scale_sig32( Cldfb_ImagBuffer_fx[1][0], CLDFB_NO_CHANNELS_MAX, sub( Q6, q_temp_cldfb ) ); // Q6 } /* LFE synthesis */ @@ -4450,6 +4470,7 @@ void ivas_dirac_dec_render_sf_fx( ELSE { hDirACRend->index_buffer_intensity = add( sub( hDirACRend->index_buffer_intensity, i_mult( idiv1616( hDirACRend->index_buffer_intensity, DIRAC_NO_COL_AVG_DIFF ), DIRAC_NO_COL_AVG_DIFF ) ), 1 ); /* averaging_length = 32 */ + move16(); } index = hDirACRend->index_buffer_intensity; @@ -4494,7 +4515,7 @@ void ivas_dirac_dec_render_sf_fx( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, hDirACRend->num_protos_diff, hDirACRend->proto_index_diff, - &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx[add( imult1616( imult1616( imult1616( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), hDirACRend->num_outputs_diff ), imult1616( imult1616( 2, hSpatParamRendCom->num_freq_bands ), s_min( 4, nchan_transport ) ) )], + &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx[( ( ( slot_idx * 2 ) * hSpatParamRendCom->num_freq_bands ) * hDirACRend->num_outputs_diff ) + ( ( 2 * hSpatParamRendCom->num_freq_bands ) * s_min( 4, nchan_transport ) )], &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, onset_filter_fx, hDirACRend->h_freq_domain_decorr_ap_params, @@ -4508,8 +4529,9 @@ void ivas_dirac_dec_render_sf_fx( ELSE { scale = L_norm_arr( hDirACRend->proto_frame_f_fx, proto_length ); - Scale_sig32( hDirACRend->proto_frame_f_fx, proto_length, scale ); + Scale_sig32( hDirACRend->proto_frame_f_fx, proto_length, scale ); // Q(proto_frame_f_q+scale) hDirACRend->proto_frame_f_q = add( hDirACRend->proto_frame_f_q, scale ); + move16(); ivas_dirac_dec_decorr_process_fx( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff, hDirACRend->num_protos_diff, @@ -4556,7 +4578,7 @@ void ivas_dirac_dec_render_sf_fx( * output synthesis *-----------------------------------------------------------------*/ test(); - IF( L_or( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ), EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) ) ) + IF( ( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ) || EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) ) ) { DIRAC_OUTPUT_SYNTHESIS_STATE *state; Word16 diffuse_start; @@ -4564,13 +4586,13 @@ void ivas_dirac_dec_render_sf_fx( diffuse_start = i_mult( i_mult( slot_idx, 2 ), i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ) ); exp = getScaleFactor32( hDirACRend->proto_frame_dec_f_fx, hDirACRend->proto_frame_dec_f_len ); - scale_sig32( hDirACRend->proto_frame_dec_f_fx, hDirACRend->proto_frame_dec_f_len, exp ); + scale_sig32( hDirACRend->proto_frame_dec_f_fx, hDirACRend->proto_frame_dec_f_len, exp ); // hDirACRend->proto_frame_dec_f_q + exp hDirACRend->proto_frame_dec_f_q = add( hDirACRend->proto_frame_dec_f_q, exp ); - + move16(); exp = getScaleFactor32( state->proto_diffuse_buffer_f_fx, diffuse_start ); - scale_sig32( state->proto_diffuse_buffer_f_fx, diffuse_start, exp ); + scale_sig32( state->proto_diffuse_buffer_f_fx, diffuse_start, exp ); // state->proto_diffuse_buffer_f_q + exp state->proto_diffuse_buffer_f_q = add( state->proto_diffuse_buffer_f_q, exp ); - + move16(); /*Compute diffuse prototypes*/ ivas_dirac_dec_compute_diffuse_proto_fx( hDirACRend, hSpatParamRendCom->num_freq_bands, slot_idx ); } @@ -4589,47 +4611,49 @@ void ivas_dirac_dec_render_sf_fx( test(); test(); - IF( L_and( h_dirac_output_synthesis_params->use_onset_filters, L_and( NE_16( hDirAC->hConfig->dec_param_estim, TRUE ), NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) ) ) + IF( ( h_dirac_output_synthesis_params->use_onset_filters && ( NE_16( hDirAC->hConfig->dec_param_estim, TRUE ) && NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) ) ) { - Scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, h_dirac_output_synthesis_state->diffuse_power_factor_q ) ); + Scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, h_dirac_output_synthesis_state->diffuse_power_factor_q ) ); // Q31 h_dirac_output_synthesis_state->diffuse_power_factor_q = Q31; move16(); exp = getScaleFactor32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); - scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), exp ); + scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), exp ); // h_dirac_output_synthesis_state->q_cy_auto_diff_smooth + exp h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, exp ); + move16(); } test(); - IF( L_and( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ), NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) ) + IF( ( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ) && NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) ) { - scale_sig32( h_dirac_output_synthesis_state->direct_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, h_dirac_output_synthesis_state->direct_power_factor_q ) ); + scale_sig32( h_dirac_output_synthesis_state->direct_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, h_dirac_output_synthesis_state->direct_power_factor_q ) ); // Q31 h_dirac_output_synthesis_state->direct_power_factor_q = Q31; move16(); - scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, h_dirac_output_synthesis_state->diffuse_power_factor_q ) ); + scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, h_dirac_output_synthesis_state->diffuse_power_factor_q ) ); // Q31 h_dirac_output_synthesis_state->diffuse_power_factor_q = Q31; move16(); - scale_sig32( h_dirac_output_synthesis_state->direct_responses_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), sub( Q31, h_dirac_output_synthesis_state->direct_responses_q ) ); + scale_sig32( h_dirac_output_synthesis_state->direct_responses_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), sub( Q31, h_dirac_output_synthesis_state->direct_responses_q ) ); // Q31 h_dirac_output_synthesis_state->direct_responses_q = Q31; move16(); - scale_sig32( h_dirac_output_synthesis_state->direct_responses_square_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), sub( Q31, h_dirac_output_synthesis_state->direct_responses_square_q ) ); + scale_sig32( h_dirac_output_synthesis_state->direct_responses_square_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), sub( Q31, h_dirac_output_synthesis_state->direct_responses_square_q ) ); // Q31 h_dirac_output_synthesis_state->direct_responses_square_q = Q31; move16(); exp = getScaleFactor32( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); - scale_sig32( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), exp ); + scale_sig32( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), exp ); // h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, exp h_dirac_output_synthesis_state->q_cy_auto_dir_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, exp ); - + move16(); exp = getScaleFactor32( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); - scale_sig32( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), exp ); + scale_sig32( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), exp ); // h_dirac_output_synthesis_state->q_cy_auto_dir_smooth+ exp h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = add( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, exp ); - + move16(); exp = getScaleFactor32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); - scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), exp ); + scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), exp ); // h_dirac_output_synthesis_state->q_cy_auto_diff_smooth+ exp h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, exp ); + move16(); } test(); @@ -4685,13 +4709,13 @@ void ivas_dirac_dec_render_sf_fx( IF( LT_16( q_diffuseness_vector, hSpatParamRendCom->q_diffuseness_vector ) ) { - scale_sig32( hSpatParamRendCom->diffuseness_vector_fx[md_idx], hSpatParamRendCom->num_freq_bands, sub( q_diffuseness_vector, hSpatParamRendCom->q_diffuseness_vector ) ); + scale_sig32( hSpatParamRendCom->diffuseness_vector_fx[md_idx], hSpatParamRendCom->num_freq_bands, sub( q_diffuseness_vector, hSpatParamRendCom->q_diffuseness_vector ) ); // q_diffuseness_vector hSpatParamRendCom->q_diffuseness_vector = q_diffuseness_vector; move16(); } ELSE { - scale_sig32( diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands, sub( hSpatParamRendCom->q_diffuseness_vector, q_diffuseness_vector ) ); + scale_sig32( diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands, sub( hSpatParamRendCom->q_diffuseness_vector, q_diffuseness_vector ) ); // q_diffuseness_vector q_diffuseness_vector = hSpatParamRendCom->q_diffuseness_vector; move16(); } @@ -4702,13 +4726,13 @@ void ivas_dirac_dec_render_sf_fx( { IF( LT_16( q_reference_power_smooth, DirAC_mem.reference_power_q ) ) { - scale_sig32( reference_power_fx, hSpatParamRendCom->num_freq_bands, sub( q_reference_power_smooth, DirAC_mem.reference_power_q ) ); + scale_sig32( reference_power_fx, hSpatParamRendCom->num_freq_bands, sub( q_reference_power_smooth, DirAC_mem.reference_power_q ) ); // q_reference_power_smooth DirAC_mem.reference_power_q = q_reference_power_smooth; move16(); } ELSE { - scale_sig32( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_q, q_reference_power_smooth ) ); + scale_sig32( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_q, q_reference_power_smooth ) ); // reference_power_q q_reference_power_smooth = DirAC_mem.reference_power_q; move16(); } @@ -4728,17 +4752,17 @@ void ivas_dirac_dec_render_sf_fx( { offset = i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, nchan_transport ) ); buff_len = i_mult( 2, i_mult( nchan_transport, hSpatParamRendCom->num_freq_bands ) ); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); // proto_direct_buffer_f_q offset = i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); - buff_len = 2 * hDirACRend->num_outputs_diff * hSpatParamRendCom->num_freq_bands; - scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, q_proto_diffuse_buffer[slot_idx] ) ); + buff_len = i_mult( 2, i_mult( hDirACRend->num_outputs_diff, hSpatParamRendCom->num_freq_bands ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, q_proto_diffuse_buffer[slot_idx] ) ); // proto_diffuse_buffer_f_q } ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) { offset = i_mult( slot_idx, i_mult( 4, hSpatParamRendCom->num_freq_bands ) ); buff_len = i_mult( 4, hSpatParamRendCom->num_freq_bands ); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); // proto_direct_buffer_f_q } ELSE { @@ -4750,7 +4774,7 @@ void ivas_dirac_dec_render_sf_fx( case 4: offset = i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); buff_len = i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); // proto_direct_buffer_f_q BREAK; case 2: IF( hDirACRend->hOutSetup.is_loudspeaker_setup ) @@ -4763,16 +4787,17 @@ void ivas_dirac_dec_render_sf_fx( offset = i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 ); buff_len = i_mult( 4, hSpatParamRendCom->num_freq_bands ); } - scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); // proto_direct_buffer_f_q BREAK; case 1: offset = i_mult( slot_idx, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); buff_len = i_mult( 2, hSpatParamRendCom->num_freq_bands ); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); // proto_direct_buffer_f_q BREAK; } } q_proto_direct_buffer[slot_idx] = hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q; + move16(); } ivas_dirac_dec_output_synthesis_get_interpolator_fx( &hDirACRend->h_output_synthesis_psd_params, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); @@ -4792,44 +4817,45 @@ void ivas_dirac_dec_render_sf_fx( { IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, Q26 ) ) { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, size_ho, sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, size_ho, sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth ) ); // Q26 hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth = Q26; + move16(); } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, Q26 ) ) { - scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, size_ho, sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, size_ho, sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev ) ); // Q26 } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, Q31 ) ) { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ) ); // Q31 } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.direct_responses_q, Q31 ) ) { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, size_ho, sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, size_ho, sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); // Q31 } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q, Q31 ) ) { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ) ); // Q31 } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth, Q26 ) ) { - scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, i_mult( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, i_mult( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth ) ); // Q26 } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, Q26 ) ) { - scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, i_mult( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, i_mult( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev ) ); // Q26 } IF( NE_16( q_diffuseness_vector, Q30 ) ) { - scale_sig32( diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands, sub( Q30, q_diffuseness_vector ) ); + scale_sig32( diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands, sub( Q30, q_diffuseness_vector ) ); // Q30 } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, Q26 ) ) { - scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, size, sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, size, sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q ) ); // Q26 } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q, Q26 ) ) { - scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, i_mult( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, i_mult( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q ) ); // Q26 } ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( Cldfb_RealBuffer_fx, @@ -4852,8 +4878,8 @@ void ivas_dirac_dec_render_sf_fx( { FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { - scale_sig32( Cldfb_RealBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, add( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, sub( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, 33 ) ) ) ); - scale_sig32( Cldfb_ImagBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, add( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, sub( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, 33 ) ) ) ); + scale_sig32( Cldfb_RealBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, add( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, sub( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, 33 ) ) ) ); // Q6 + scale_sig32( Cldfb_ImagBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, add( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, sub( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, 33 ) ) ) ); // Q6 } } } @@ -4863,8 +4889,8 @@ void ivas_dirac_dec_render_sf_fx( { FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { - scale_sig32( Cldfb_RealBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, add( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, sub( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, 33 ) ) ) ); - scale_sig32( Cldfb_ImagBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, add( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, sub( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, 33 ) ) ) ); + scale_sig32( Cldfb_RealBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, add( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, sub( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, 33 ) ) ) ); // Q6 + scale_sig32( Cldfb_ImagBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, add( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, sub( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, 33 ) ) ) ); // Q6 } } } @@ -4884,37 +4910,37 @@ void ivas_dirac_dec_render_sf_fx( IF( NE_16( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, Q31 ) ) { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ) ); // Q31 } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.direct_responses_q, Q31 ) ) { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, size, sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, size, sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); // Q31 } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q, Q31 ) ) { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ) ); // Q31 } IF( NE_16( q_diffuseness_vector, Q31 ) ) { - Scale_sig32( diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands, sub( Q31, q_diffuseness_vector ) ); + Scale_sig32( diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands, sub( Q31, q_diffuseness_vector ) ); // Q31 } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q, Q31 ) ) { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, i_mult( hDirACRend->num_outputs_dir, hSpatParamRendCom->num_freq_bands ), sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, i_mult( hDirACRend->num_outputs_dir, hSpatParamRendCom->num_freq_bands ), sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q ) ); // Q31 } exp = L_norm_arr( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands ); - scale_sig32( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, exp ); + scale_sig32( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, exp ); // q_reference_power_smooth + exp q_reference_power_smooth = add( q_reference_power_smooth, exp ); IF( LT_16( q_reference_power_smooth, hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q ) ) { - scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, hSpatParamRendCom->num_freq_bands, sub( q_reference_power_smooth, hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, hSpatParamRendCom->num_freq_bands, sub( q_reference_power_smooth, hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q ) ); // q_reference_power_smooth hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q = q_reference_power_smooth; move16(); } ELSE { - scale_sig32( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, sub( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, q_reference_power_smooth ) ); + scale_sig32( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, sub( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, q_reference_power_smooth ) ); // reference_power_smooth_prev_q q_reference_power_smooth = hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q; move16(); } @@ -4923,49 +4949,52 @@ void ivas_dirac_dec_render_sf_fx( { IF( LT_16( hDirACRend->masa_stereo_type_detect->q_subtract_power_y, hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth ) ) { - hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth_fx = L_shr( hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth_fx, sub( hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ) ); + hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth_fx = L_shr( hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth_fx, sub( hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ) ); // q_subtract_power_y + move32(); hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth = hDirACRend->masa_stereo_type_detect->q_subtract_power_y; move16(); } ELSE { - hDirACRend->masa_stereo_type_detect->subtract_power_y_fx = L_shr( hDirACRend->masa_stereo_type_detect->subtract_power_y_fx, sub( hDirACRend->masa_stereo_type_detect->q_subtract_power_y, hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth ) ); + hDirACRend->masa_stereo_type_detect->subtract_power_y_fx = L_shr( hDirACRend->masa_stereo_type_detect->subtract_power_y_fx, sub( hDirACRend->masa_stereo_type_detect->q_subtract_power_y, hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth ) ); // q_subtract_power_y + move32(); hDirACRend->masa_stereo_type_detect->q_subtract_power_y = hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth; move16(); } } exp = getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, proto_power_smooth_len ); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, proto_power_smooth_len, exp ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, proto_power_smooth_len, exp ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q + exp) hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, exp ); - + move16(); IF( LT_16( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) ) { - scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, i_mult( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, i_mult( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) ); // proto_power_smooth_q hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q; move16(); } ELSE { - scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, i_mult( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, i_mult( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ) ); // proto_power_smooth_prev_q hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q; move16(); } exp = getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ) ); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ), exp ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ), exp ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q + exp) hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, exp ); + move16(); IF( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx != 0 ) { IF( LT_16( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q ) ) { - scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q ) ); // proto_power_diff_smooth_q hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q = hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q; move16(); } ELSE { - scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q ) ); // proto_power_diff_smooth_prev_q hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q = hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q; move16(); } @@ -4973,15 +5002,15 @@ void ivas_dirac_dec_render_sf_fx( IF( NE_16( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, Q26 ) ) { - scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, size, sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, size, sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q ) ); // Q26 } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q, Q26 ) ) { - scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->hOutSetup.nchan_out_woLFE ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->hOutSetup.nchan_out_woLFE ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q ) ); // Q26 } IF( hDirACRend->proto_signal_decorr_on ) { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q ) ); // proto_direct_buffer_f_q hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q = hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q; move16(); } @@ -5015,8 +5044,8 @@ void ivas_dirac_dec_render_sf_fx( { FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { - scale_sig32( Cldfb_RealBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, q_Cldfb ) ); - scale_sig32( Cldfb_ImagBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, q_Cldfb ) ); + scale_sig32( Cldfb_RealBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, q_Cldfb ) ); // Q6 + scale_sig32( Cldfb_ImagBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, q_Cldfb ) ); // Q6 } } } @@ -5030,12 +5059,12 @@ void ivas_dirac_dec_render_sf_fx( test(); test(); - IF( L_or( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ), EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) + IF( ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) { /* render objects in combined format onto the CICP19 channels for BINAURAL_ROOM_IR */ test(); test(); - IF( L_and( L_and( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ), EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ), EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) + IF( ( ( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) { Word16 in_ch; FOR( in_ch = 0; in_ch < st_ivas->nchan_ism; in_ch++ ) @@ -5092,7 +5121,7 @@ void ivas_dirac_dec_render_sf_fx( for ( j = 0, j2 = 0; j < nchan_out_woLFE; j++, j2++ ) { test(); - IF( L_and( st_ivas->hIntSetup.num_lfe > 0, ( EQ_16( st_ivas->hIntSetup.index_lfe[lfe_index], j ) ) ) ) + IF( ( st_ivas->hIntSetup.num_lfe > 0 && ( EQ_16( st_ivas->hIntSetup.index_lfe[lfe_index], j ) ) ) ) { IF( LT_16( lfe_index, sub( st_ivas->hIntSetup.num_lfe, 1 ) ) ) { @@ -5109,28 +5138,30 @@ void ivas_dirac_dec_render_sf_fx( prev_gain_fx = st_ivas->hIsmRendererData->prev_gains_fx[i][j]; move32(); test(); - IF( L_or( L_abs( gain_fx ) > 0, L_abs( prev_gain_fx ) > 0 ) ) + IF( ( L_abs( gain_fx ) > 0 || L_abs( prev_gain_fx ) > 0 ) ) { Word32 *tc_re_fx, *tc_im_fx; Word16 *w1_fx, w2_fx; w1_fx = &st_ivas->hIsmRendererData->interpolator_fx[interp_offset]; - tc_re_fx = pppQMfFrame_ts_re_fx[add( nchan_transport, i )][0]; + tc_re_fx = pppQMfFrame_ts_re_fx[nchan_transport + i][0]; move32(); - tc_im_fx = pppQMfFrame_ts_im_fx[add( nchan_transport, i )][0]; + tc_im_fx = pppQMfFrame_ts_im_fx[nchan_transport + i][0]; move32(); FOR( k = 0; k < n_slots_to_render; k++ ) { Word32 g_fx; w2_fx = sub( MAX16B, *w1_fx ); - g_fx = L_add( Mpy_32_16_1( gain_fx, *w1_fx ), Mpy_32_16_1( prev_gain_fx, w2_fx ) ); + g_fx = L_add( Mpy_32_16_1( gain_fx, *w1_fx ), Mpy_32_16_1( prev_gain_fx, w2_fx ) ); // Q15 FOR( l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) { Word32 tmp; tmp = Mpy_32_32( g_fx, *tc_re_fx ); - Cldfb_RealBuffer_fx[j2][0][add( i_mult( k, hSpatParamRendCom->num_freq_bands ), l )] = L_add( Cldfb_RealBuffer_fx[j2][0][add( i_mult( k, hSpatParamRendCom->num_freq_bands ), l )], tmp ); + Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = L_add( Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], tmp ); + move32(); tc_re_fx++; tmp = Mpy_32_32( g_fx, *tc_im_fx ); - Cldfb_ImagBuffer_fx[j2][0][add( i_mult( k, hSpatParamRendCom->num_freq_bands ), l )] = L_add( Cldfb_ImagBuffer_fx[j2][0][add( i_mult( k, hSpatParamRendCom->num_freq_bands ), l )], tmp ); + Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = L_add( Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], tmp ); + move32(); tc_re_fx++; } w1_fx += hSpatParamRendCom->num_freq_bands; @@ -5159,14 +5190,14 @@ void ivas_dirac_dec_render_sf_fx( Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, &input_q ); - Scale_sig32( Cldfb_RealBuffer_Binaural_fx[0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); - Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); + Scale_sig32( Cldfb_RealBuffer_Binaural_fx[0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); // Q6 + Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); // Q6 /* Inverse CLDFB*/ FOR( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ - Word32 *synth_fx = &output_buf_fx[ch][i_mult( index_slot, hSpatParamRendCom->num_freq_bands )]; + Word32 *synth_fx = &output_buf_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands]; Word32 *RealBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; Word32 *ImagBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) @@ -5177,8 +5208,8 @@ void ivas_dirac_dec_render_sf_fx( move32(); } - scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( sub( Q6, 1 ), st_ivas->cldfbSynDec[ch]->Q_cldfb_state ) ); - st_ivas->cldfbSynDec[ch]->Q_cldfb_state = sub( Q6, 1 ); + scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( ( Q6 - 1 ), st_ivas->cldfbSynDec[ch]->Q_cldfb_state ) ); // Q6-1 + st_ivas->cldfbSynDec[ch]->Q_cldfb_state = ( Q6 - 1 ); move16(); cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, synth_fx, i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), st_ivas->cldfbSynDec[ch] ); @@ -5191,14 +5222,17 @@ void ivas_dirac_dec_render_sf_fx( move16(); IF( GT_16( samplesToProcess, -1 ) ) { - no_col = s_min( no_col, ( add( samplesToProcess, sub( st_ivas->cldfbSynDec[ch]->no_channels, 1 ) ) ) / st_ivas->cldfbSynDec[ch]->no_channels ); + Word16 tmp, tmp_e; + tmp = BASOP_Util_Divide1616_Scale( add( samplesToProcess, sub( st_ivas->cldfbSynDec[ch]->no_channels, 1 ) ), st_ivas->cldfbSynDec[ch]->no_channels, &tmp_e ); + tmp = shr( tmp, 15 - tmp_e ); + no_col = s_min( no_col, tmp ); } Word16 synth_len = imult1616( no_col, no_channels ); - scale_sig32( synth_fx, synth_len, sub( Q11, sub( Q6, 1 ) ) ); + scale_sig32( synth_fx, synth_len, ( Q11 - ( Q6 - 1 ) ) ); // Q11 } } - ELSE IF( L_or( EQ_16( st_ivas->ivas_format, SBA_FORMAT ), EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ) + ELSE IF( ( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ) { FOR( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE; ch++ ) { @@ -5252,9 +5286,10 @@ void ivas_dirac_dec_render_sf_fx( Copy32( &( output_buf_fx[LFE_CHANNEL][subframe_start_sample] ), tmp_lfe_fx, num_samples_subframe ); FOR( ch = 0; ch < outchannels; ch++ ) { + test(); test(); - IF( L_and( hDirACRend->hOutSetup.num_lfe > 0, ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) ) + IF( ( hDirACRend->hOutSetup.num_lfe > 0 && ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) ) { /* Move the LFE channel to the correct place */ Copy32( tmp_lfe_fx, &( output_buf_fx[ch][subframe_start_sample] ), num_samples_subframe ); @@ -5297,9 +5332,10 @@ void ivas_dirac_dec_render_sf_fx( { FOR( ch = 0; ch < outchannels; ch++ ) { + test(); test(); - IF( L_and( hDirACRend->hOutSetup.num_lfe > 0, ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) ) + IF( ( hDirACRend->hOutSetup.num_lfe > 0 && ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) ) { test(); test(); @@ -5307,18 +5343,18 @@ void ivas_dirac_dec_render_sf_fx( { FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) { - RealBuffer_fx[i] = Cldfb_RealBuffer_fx[sub( MAX_OUTPUT_CHANNELS, 1 )][i]; + RealBuffer_fx[i] = Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS - 1][i]; move32(); - ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[sub( MAX_OUTPUT_CHANNELS, 1 )][i]; + ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS - 1][i]; move32(); } Word16 cldfbSynIdx = add( hDirACRend->hOutSetup.nchan_out_woLFE, idx_lfe ); Word16 samplesToProcess = i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); - Word32 *p_out = &( output_buf_fx[ch][i_mult( index_slot, hSpatParamRendCom->num_freq_bands )] ); - - scale_sig32( st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state_fx, st_ivas->cldfbSynDec[cldfbSynIdx]->p_filter_length, sub( sub( Q6, 1 ), st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state ) ); - st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state = sub( Q6, 1 ); + Word32 *p_out = &( output_buf_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ); + scale_sig32( st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state_fx, st_ivas->cldfbSynDec[cldfbSynIdx]->p_filter_length, sub( ( Q6 - 1 ), st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state ) ); // Q6-1 + st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state = ( Q6 - 1 ); + move16(); cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, st_ivas->cldfbSynDec[cldfbSynIdx] ); // Calculating length of output @@ -5328,11 +5364,14 @@ void ivas_dirac_dec_render_sf_fx( move16(); IF( GT_16( samplesToProcess, -1 ) ) { - no_col = s_min( no_col, ( add( samplesToProcess, sub( st_ivas->cldfbSynDec[cldfbSynIdx]->no_channels, 1 ) ) ) / st_ivas->cldfbSynDec[cldfbSynIdx]->no_channels ); + Word16 tmp, tmp_e; + tmp = BASOP_Util_Divide1616_Scale( add( samplesToProcess, sub( st_ivas->cldfbSynDec[cldfbSynIdx]->no_channels, 1 ) ), st_ivas->cldfbSynDec[cldfbSynIdx]->no_channels, &tmp_e ); + tmp = shr( tmp, 15 - tmp_e ); + no_col = s_min( no_col, tmp ); } Word16 synth_len = imult1616( no_col, no_channels ); - scale_sig32( p_out, synth_len, sub( Q11, sub( Q6, 1 ) ) ); + scale_sig32( p_out, synth_len, ( Q11 - ( Q6 - 1 ) ) ); // Q11 } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && hDirACRend->hOutSetup.separateChannelEnabled ) { @@ -5340,7 +5379,7 @@ void ivas_dirac_dec_render_sf_fx( } ELSE { - set32_fx( &( output_buf_fx[ch][i_mult( index_slot, hSpatParamRendCom->num_freq_bands )] ), 0, imult1616( hSpatParamRendCom->subframe_nbslots[subframe_idx], hSpatParamRendCom->num_freq_bands ) ); + set32_fx( &( output_buf_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), 0, imult1616( hSpatParamRendCom->subframe_nbslots[subframe_idx], hSpatParamRendCom->num_freq_bands ) ); } IF( LT_16( idx_lfe, sub( hDirACRend->hOutSetup.num_lfe, 1 ) ) ) { @@ -5373,13 +5412,16 @@ void ivas_dirac_dec_render_sf_fx( move16(); IF( GT_16( samplesToProcess, -1 ) ) { - no_col = s_min( no_col, ( add( samplesToProcess, sub( st_ivas->cldfbSynDec[idx_in]->no_channels, 1 ) ) ) / st_ivas->cldfbSynDec[idx_in]->no_channels ); + Word16 tmp, tmp_e; + tmp = BASOP_Util_Divide1616_Scale( add( samplesToProcess, sub( st_ivas->cldfbSynDec[idx_in]->no_channels, 1 ) ), st_ivas->cldfbSynDec[idx_in]->no_channels, &tmp_e ); + tmp = shr( tmp, 15 - tmp_e ); + no_col = s_min( no_col, tmp ); } out_len = imult1616( no_col, no_channels ); // Scaling cldfb_state to Q6-1 - scale_sig32( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->p_filter_length, sub( sub( Q6, 1 ), st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state ) ); - st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = sub( Q6, 1 ); + scale_sig32( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->p_filter_length, sub( ( Q6 - 1 ), st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state ) ); + st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = ( Q6 - 1 ); move16(); cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, st_ivas->cldfbSynDec[idx_in] ); @@ -5394,7 +5436,9 @@ void ivas_dirac_dec_render_sf_fx( } hSpatParamRendCom->slots_rendered = add( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + move16(); hSpatParamRendCom->subframes_rendered = add( hSpatParamRendCom->subframes_rendered, 1 ); + move16(); IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) @@ -5411,7 +5455,7 @@ void ivas_dirac_dec_render_sf_fx( { FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) { - scale_sig32( st_ivas->cldfbSynDec[i]->cldfb_state_fx, st_ivas->cldfbSynDec[i]->cldfb_size, sub( Q11, st_ivas->cldfbSynDec[i]->Q_cldfb_state ) ); + scale_sig32( st_ivas->cldfbSynDec[i]->cldfb_state_fx, st_ivas->cldfbSynDec[i]->cldfb_size, sub( Q11, st_ivas->cldfbSynDec[i]->Q_cldfb_state ) ); // Q11 st_ivas->cldfbSynDec[i]->Q_cldfb_state = Q11; move16(); } @@ -5451,7 +5495,7 @@ void ivas_dirac_dec_render_sf_fx( FOR( ch = 0; ch < outchannels; ch++ ) { test(); - IF( L_and( hDirACRend->hOutSetup.num_lfe > 0, ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) ) + IF( ( hDirACRend->hOutSetup.num_lfe > 0 && ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) ) { IF( LT_16( idx_lfe, sub( hDirACRend->hOutSetup.num_lfe, 1 ) ) ) { @@ -5464,22 +5508,23 @@ void ivas_dirac_dec_render_sf_fx( { FOR( ch = 0; ch < outchannels; ch++ ) { + test(); test(); - IF( L_and( hDirACRend->hOutSetup.num_lfe > 0, ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) ) + IF( ( hDirACRend->hOutSetup.num_lfe > 0 && ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) ) { test(); IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && !hDirACRend->hOutSetup.separateChannelEnabled ) { Word16 cldfbSynIdx = add( hDirACRend->hOutSetup.nchan_out_woLFE, idx_lfe ); - scale_sig32( st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state_fx, st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_size, sub( Q11, st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state ) ); + scale_sig32( st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state_fx, st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_size, sub( Q11, st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state ) ); // Q11 st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state = Q11; move16(); } } ELSE IF( ( hDirACRend->hOutSetup.separateChannelEnabled == 0 ) || NE_16( hDirACRend->hOutSetup.separateChannelIndex, ch ) ) { - scale_sig32( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->cldfb_size, sub( Q11, st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state ) ); + scale_sig32( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->cldfb_size, sub( Q11, st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state ) ); // Q11 st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = Q11; move16(); idx_in = add( idx_in, 1 ); diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 4af727672..4bcfdc3e6 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -70,7 +70,7 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( const Word16 num_param_bands_residual, /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ const Word16 nchan_in, /* i : number of input (transport) channels */ const Word16 nchan_out, /* i : number of output channels */ - const Word32 *proto_matrix /* i : the prototype (upmix) matrix (only used if mode == 1) */ + const Word32 *proto_matrix /* i : the prototype (upmix) matrix (only used if mode == 1) Q(15-proto_matrix_e) */ ) { Word16 idx; @@ -89,7 +89,7 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n" ) ); } h_dirac_output_synthesis_params->proto_matrix_len = imult1616( nchan_out, nchan_in ); - + move16(); /* cov buffers */ FOR( idx = 0; idx < num_param_bands; idx++ ) { @@ -116,6 +116,7 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( } set_zero_fx( h_dirac_output_synthesis_state->mixing_matrix_fx[idx], imult1616( nchan_out, nchan_in ) ); h_dirac_output_synthesis_state->mixing_matrix_len = i_mult( nchan_out, nchan_in ); + move16(); } FOR( ; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { @@ -139,6 +140,7 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( } set_zero_fx( h_dirac_output_synthesis_state->mixing_matrix_res_fx[idx], imult1616( nchan_out, nchan_out ) ); h_dirac_output_synthesis_state->mixing_matrix_res_len = i_mult( nchan_out, nchan_out ); + move16(); } FOR( ; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { @@ -194,6 +196,7 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( FOR( idx = 1; idx <= interp_length; ++idx ) { h_dirac_output_synthesis_params->interpolator_fx[idx - 1] = div_s( idx, interp_length ); + move16(); } Copy32( proto_matrix, h_dirac_output_synthesis_params->proto_matrix_fx, imult1616( nchan_in, nchan_out ) ); h_dirac_output_synthesis_params->proto_matrix_e = 5; @@ -734,13 +737,13 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( *-------------------------------------------------------------------*/ #ifdef FIX_835_PARAMMC_BUFFER_VALUES void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( - Word32 *RealBuffer_fx, /* i : input channel filter bank samples (real part) */ + Word32 *RealBuffer_fx, /* i : input channel filter bank samples (real part) Q(31- RealBuffer_e)*/ Word16 RealBuffer_e, /* i : exponent input channel filter bank samples (real part)*/ - Word32 *ImagBuffer_fx, /* i : input channel filter bank samples (imaginary part */ + Word32 *ImagBuffer_fx, /* i : input channel filter bank samples (imaginary part Q(ImagBuffer_e)*/ Word16 ImagBuffer_e, /* i : exponent input channel filter bank samples (real part)*/ - Word32 cx_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (real part) */ + Word32 cx_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (real part) Q(31- cx_e)*/ Word16 *cx_e, /* i : exponent for accumulated input covariance (real part) */ - Word32 cx_imag_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (imaginary part) */ + Word32 cx_imag_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (imaginary part) Q(31- cx_imag_e)*/ Word16 *cx_imag_e, /* i : exponent accumulated input covariance (imag part) */ PARAM_MC_DEC_HANDLE hParamMC, /* i : handle to Parametric MC state */ const Word16 param_band, /* i : parameter band */ @@ -777,9 +780,9 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( band = add( brange[0], band_idx ); FOR( ch_idx = 0; ch_idx < nchan_in; ch_idx++ ) { - real_in_buffer_fx[add( band_idx, imult1616( num_bands, ch_idx ) )] = RealBuffer_fx[add( imult1616( ch_idx, hParamMC->num_freq_bands ), band )]; + real_in_buffer_fx[band_idx + num_bands * ch_idx] = RealBuffer_fx[band + hParamMC->num_freq_bands * ch_idx]; move32(); - imag_in_buffer_fx[add( band_idx, imult1616( num_bands, ch_idx ) )] = ImagBuffer_fx[add( imult1616( ch_idx, hParamMC->num_freq_bands ), band )]; + imag_in_buffer_fx[band_idx + num_bands * ch_idx] = ImagBuffer_fx[band + hParamMC->num_freq_bands * ch_idx]; move32(); } } @@ -788,8 +791,8 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( move16(); imag_in_e = ImagBuffer_e; move16(); - shift_real = sub( L_norm_arr( real_in_buffer_fx, imult1616( num_bands, nchan_in ) ), find_guarded_bits_fx( num_bands + 1 ) ); - shift_imag = sub( L_norm_arr( imag_in_buffer_fx, imult1616( num_bands, nchan_in ) ), find_guarded_bits_fx( num_bands + 1 ) ); + shift_real = sub( L_norm_arr( real_in_buffer_fx, imult1616( num_bands, nchan_in ) ), find_guarded_bits_fx( add( num_bands, 1 ) ) ); + shift_imag = sub( L_norm_arr( imag_in_buffer_fx, imult1616( num_bands, nchan_in ) ), find_guarded_bits_fx( add( num_bands, 1 ) ) ); real_in_e = sub( real_in_e, shift_real ); imag_in_e = sub( imag_in_e, shift_imag ); @@ -799,9 +802,9 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( FOR( i = 0; i < num_bands * nchan_in; ++i ) { - real_in_buffer_fx[i] = L_shr( real_in_buffer_fx[i], sub( output_e, RealBuffer_e ) ); + real_in_buffer_fx[i] = L_shr( real_in_buffer_fx[i], sub( output_e, RealBuffer_e ) ); // Q(31-output_e) move32(); - imag_in_buffer_fx[i] = L_shr( imag_in_buffer_fx[i], sub( output_e, ImagBuffer_e ) ); + imag_in_buffer_fx[i] = L_shr( imag_in_buffer_fx[i], sub( output_e, ImagBuffer_e ) ); // Q(31-output_e) move32(); } @@ -831,10 +834,10 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( FOR( j = 0; j < PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS; j++ ) { L_tmp = BASOP_Util_Add_Mant32Exp( cx_fx[j], cx_init_e, 0, 0, &tmp1_e ); - cx_fx[j] = L_shr( L_tmp, sub( tmp1, tmp1_e ) ); + cx_fx[j] = L_shr( L_tmp, sub( tmp1, tmp1_e ) ); // Q(31-tmp1) move32(); L_tmp = BASOP_Util_Add_Mant32Exp( cx_imag_fx[j], cx_init_imag_e, 0, 0, &tmp2_e ); - cx_imag_fx[j] = L_shr( L_tmp, sub( tmp2, tmp2_e ) ); + cx_imag_fx[j] = L_shr( L_tmp, sub( tmp2, tmp2_e ) ); // Q(31-tmp2) move32(); } @@ -1095,13 +1098,13 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot( } #else void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( - Word32 *Cldfb_RealBuffer_in_fx, - Word32 *Cldfb_ImagBuffer_in_fx, - Word32 Cldfb_RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (real part) */ - Word32 Cldfb_ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (imaginary part) */ - Word32 *mixing_matrix_fx[], /* i : parameter band wise mixing matrices (direct part) */ + Word32 *Cldfb_RealBuffer_in_fx, /*Q6*/ + Word32 *Cldfb_ImagBuffer_in_fx, /*Q6*/ + Word32 Cldfb_RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (real part) Q6*/ + Word32 Cldfb_ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (imaginary part) Q6*/ + Word32 *mixing_matrix_fx[], /* i : parameter band wise mixing matrices (direct part) Q(31-mixing_matrix_e)*/ Word16 *mixing_matrix_e, /* i : parameter band wise mixing matrices (direct part) */ - Word32 *mixing_matrix_res_fx[], /* i : parameter band wise mixing matrices (residual part) */ + Word32 *mixing_matrix_res_fx[], /* i : parameter band wise mixing matrices (residual part) Q(31-mixing_matrix_res_e)*/ Word16 *mixing_matrix_res_e, /* i : parameter band wise mixing matrices (residual part) */ const UWord16 slot_idx_sfr, /* i : time slot index for the current slot within the current subframe */ const UWord16 slot_idx_tot, /* i : time slot index for the current slot within the frame */ @@ -1118,6 +1121,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( Word16 mixing_matrix_smooth_e; Word32 mixing_matrix_res_smooth_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; Word16 mixing_matrix_res_smooth_e = 0; + move16(); Word32 mixing_matrix_buffer_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; Word16 mixing_matrix_buffer_e; Word32 input_f_real_fx[PARAM_MC_MAX_TRANSPORT_CHANS]; @@ -1145,7 +1149,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( move16(); brange[0] = hParamMC->band_grouping[param_band_idx]; move16(); - brange[1] = hParamMC->band_grouping[add( param_band_idx, 1 )]; + brange[1] = hParamMC->band_grouping[( param_band_idx + 1 )]; move16(); if ( LT_16( brange[0], hParamMC->h_output_synthesis_params.max_band_decorr ) ) @@ -1191,7 +1195,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( assert( LT_16( band, hParamMC->h_output_synthesis_params.max_band_decorr ) ); FOR( ch_idx = 0; ch_idx < nY; ch_idx++ ) { - diff_f_real_fx[ch_idx] = Cldfb_RealBuffer_fx[ch_idx][slot_idx_sfr][band]; // Q6 + diff_f_real_fx[ch_idx] = Cldfb_RealBuffer_fx[ch_idx][slot_idx_sfr][band]; move32(); diff_f_imag_fx[ch_idx] = Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band]; move32(); @@ -1200,17 +1204,17 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( /* apply residual mixing */ matrix_product_mant_exp_fx( mixing_matrix_res_smooth_fx, mixing_matrix_res_smooth_e, nY, nY, 0, diff_f_real_fx, 25, nY, 1, 0, output_f_real_fx, &output_f_real_e ); - scale_sig32( output_f_real_fx, nY, sub( Q6, sub( Q31, output_f_real_e ) ) ); + scale_sig32( output_f_real_fx, nY, sub( Q6, sub( Q31, output_f_real_e ) ) ); // Q6 matrix_product_mant_exp_fx( mixing_matrix_res_smooth_fx, mixing_matrix_res_smooth_e, nY, nY, 0, diff_f_imag_fx, 25, nY, 1, 0, output_f_imag_fx, &output_f_imag_e ); - scale_sig32( output_f_imag_fx, nY, sub( Q6, sub( Q31, output_f_imag_e ) ) ); + scale_sig32( output_f_imag_fx, nY, sub( Q6, sub( Q31, output_f_imag_e ) ) ); // Q6 FOR( ch_idx = 0; ch_idx < nY; ch_idx++ ) { Cldfb_RealBuffer_fx[ch_idx][slot_idx_sfr][band] = output_f_real_fx[ch_idx]; // Q6 move32(); - Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band] = output_f_imag_fx[ch_idx]; + Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band] = output_f_imag_fx[ch_idx]; // Q6 move32(); } } @@ -1229,20 +1233,20 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( FOR( ch_idx = 0; ch_idx < nX; ch_idx++ ) { - input_f_real_fx[ch_idx] = Cldfb_RealBuffer_in_fx[add( imult1616( ch_idx, hParamMC->num_freq_bands ), band )]; // Q6 + input_f_real_fx[ch_idx] = Cldfb_RealBuffer_in_fx[ch_idx * hParamMC->num_freq_bands + band]; // Q6 move32(); - input_f_imag_fx[ch_idx] = Cldfb_ImagBuffer_in_fx[add( imult1616( ch_idx, hParamMC->num_freq_bands ), band )]; + input_f_imag_fx[ch_idx] = Cldfb_ImagBuffer_in_fx[ch_idx * hParamMC->num_freq_bands + band]; // Q6 move32(); } /* apply mixing matrix */ matrix_product_mant_exp_fx( mixing_matrix_smooth_fx, mixing_matrix_smooth_e, nY, nX, 0, input_f_real_fx, 25, nX, 1, 0, output_f_real_fx, &output_f_real_e ); - scale_sig32( output_f_real_fx, MAX_CICP_CHANNELS, sub( 6, sub( 31, output_f_real_e ) ) ); + scale_sig32( output_f_real_fx, MAX_CICP_CHANNELS, sub( 6, sub( 31, output_f_real_e ) ) ); // Q6 matrix_product_mant_exp_fx( mixing_matrix_smooth_fx, mixing_matrix_smooth_e, nY, nX, 0, input_f_imag_fx, 25, nX, 1, 0, output_f_imag_fx, &output_f_imag_e ); - scale_sig32( output_f_imag_fx, MAX_CICP_CHANNELS, sub( 6, sub( 31, output_f_imag_e ) ) ); + scale_sig32( output_f_imag_fx, MAX_CICP_CHANNELS, sub( 6, sub( 31, output_f_imag_e ) ) ); // Q6 /* collect output */ FOR( ch_idx = 0; ch_idx < nY; ch_idx++ ) @@ -1529,20 +1533,20 @@ int16_t computeMixingMatrices( Word16 computeMixingMatrices_fx( const Word16 num_inputs, /* i : number of input channels */ const Word16 num_outputs, /* i : number of output channels */ - const Word32 *Cx, /* i : input channel covariance matrix */ + const Word32 *Cx, /* i : input channel covariance matrix Q(31-Cx_e) */ Word16 Cx_e, - const Word32 *Cy, /* i : target covariance matrix */ + const Word32 *Cy, /* i : target covariance matrix Q(31-Cy_e) */ Word16 Cy_e, - const Word32 *Q, /* i : prototype matrix (usually a upmix matrix) */ + const Word32 *Q, /* i : prototype matrix (usually a upmix matrix) Q_fx_e */ Word16 Q_fx_e, const Word16 energy_compensation_flag, /* i : flag indicating that the energy compensation should be performed (i.e. no residual mixing matrix will follow) */ const Word32 reg_Sx_fx, /* i : regularization factor for the input channel singular values */ Word16 reg_Sx_e, - const Word32 reg_ghat_fx, /* i : regularization factor for the normalization matrix */ + const Word32 reg_ghat_fx, /* i : regularization factor for the normalization matrix Q(31-reg_ghat_e) */ Word16 reg_ghat_e, - Word32 *mixing_matrix_fx, /* o : resulting mixing matrix */ + Word32 *mixing_matrix_fx, /* o : resulting mixing matrix Q(31-mixing_matrix_out_e) */ Word16 *mixing_matrix_out_e, - Word32 *Cr_fx, /* o : residual covariance matrix */ + Word32 *Cr_fx, /* o : residual covariance matrix Q(31-Cr_e) */ Word16 *Cr_e ) { Word16 i, j; @@ -1650,9 +1654,9 @@ Word16 computeMixingMatrices_fx( tmp_e = svd_s_buffer_e[j]; move16(); L_tmp = Sqrt32( svd_s_buffer_fx[j], &tmp_e ); - Ky_fx[add( i, imult1616( j, lengthCy ) )] = Mpy_32_32( svd_u_buffer_fx[i][j], L_tmp ); + Ky_fx[i + ( j * lengthCy )] = Mpy_32_32( svd_u_buffer_fx[i][j], L_tmp ); // Q(31-tmp_e) move32(); - Ky_fx_e[add( i, imult1616( j, lengthCy ) )] = tmp_e; + Ky_fx_e[i + ( j * lengthCy )] = tmp_e; move16(); } } @@ -1674,9 +1678,9 @@ Word16 computeMixingMatrices_fx( tmp_e = svd_s_buffer_e[j]; move16(); L_tmp = Sqrt32( svd_s_buffer_fx[j], &tmp_e ); - Kx_fx[add( i, imult1616( j, lengthCx ) )] = Mpy_32_32( svd_u_buffer_fx[i][j], L_tmp ); + Kx_fx[( i + ( j * lengthCx ) )] = Mpy_32_32( svd_u_buffer_fx[i][j], L_tmp ); // Q(31-tmp_e) move32(); - Kx_fx_e[add( i, imult1616( j, lengthCx ) )] = tmp_e; + Kx_fx_e[( i + ( j * lengthCx ) )] = tmp_e; move16(); } } @@ -1686,7 +1690,7 @@ Word16 computeMixingMatrices_fx( { tmp_e = svd_s_buffer_e[i]; move16(); - svd_s_buffer_fx[i] = Sqrt32( svd_s_buffer_fx[i], &tmp_e ); + svd_s_buffer_fx[i] = Sqrt32( svd_s_buffer_fx[i], &tmp_e ); // Q(31-tmp_e) move32(); svd_s_buffer_e[i] = tmp_e; move16(); @@ -1744,9 +1748,9 @@ Word16 computeMixingMatrices_fx( scale = add( scale, sub( Q31, svd_s_buffer_e[i] ) ); FOR( j = 0; j < lengthCx; ++j ) { - Kx_reg_inv_fx[add( i, imult1616( j, lengthCx ) )] = Mpy_32_16_1( svd_u_buffer_fx[j][i], reg_fac_fx ); + Kx_reg_inv_fx[i + j * lengthCx] = Mpy_32_16_1( svd_u_buffer_fx[j][i], reg_fac_fx ); // Q(31-scale) move32(); - Kx_reg_inv_e[add( i, imult1616( j, lengthCx ) )] = scale; + Kx_reg_inv_e[i + j * lengthCx] = scale; move16(); } } @@ -1780,7 +1784,7 @@ Word16 computeMixingMatrices_fx( #endif } #ifdef FIX_827_HIGH_MLD - L_tmp = Mpy_32_32( limit_fx, reg_ghat_fx ); + L_tmp = Mpy_32_32( limit_fx, reg_ghat_fx ); // limit_e+ reg_ghat_e limit_fx = L_add( L_tmp, EPSILON_FX ); limit_e = add( limit_e, reg_ghat_e ); #endif @@ -1798,7 +1802,7 @@ Word16 computeMixingMatrices_fx( move16(); } - tmp = BASOP_Util_Divide3232_Scale( Cy_fx[add( i, imult1616( i, lengthCy ) )], Cy_hat_diag_fx[i], &exp ); + tmp = BASOP_Util_Divide3232_Scale( Cy_fx[( i + ( i * lengthCy ) )], Cy_hat_diag_fx[i], &exp ); exp = add( exp, sub( Cy_fx_e, Cy_hat_diag_buff_e[i] ) ); L_tmp = Sqrt32( L_deposit_h( tmp ), &exp ); G_hat_fx[i] = L_tmp; @@ -1839,7 +1843,7 @@ Word16 computeMixingMatrices_fx( FOR( i = 0; i < lengthCy * lengthCx; i++ ) { - mat_mult_buffer1_fx[i] = L_shr( mat_mult_buffer1_fx[i], sub( exp, mat_mult_buffer1_fx_e[i] ) ); + mat_mult_buffer1_fx[i] = L_shr( mat_mult_buffer1_fx[i], sub( exp, mat_mult_buffer1_fx_e[i] ) ); // Q(31-exp) move32(); } @@ -1919,7 +1923,7 @@ Word16 computeMixingMatrices_fx( FOR( i = 0; i < lengthCy * lengthCx; i++ ) { - mixing_matrix_fx[i] = L_shr( mixing_matrix_fx[i], sub( exp, mixing_matrix_fx_e[i] ) ); + mixing_matrix_fx[i] = L_shr( mixing_matrix_fx[i], sub( exp, mixing_matrix_fx_e[i] ) ); // Q(31-exp) move32(); } @@ -1943,11 +1947,11 @@ Word16 computeMixingMatrices_fx( } /* Avoid Meaningless negative main diagonal elements */ - IF( BASOP_Util_Cmp_Mant32Exp( Cr_fx[add( i, imult1616( i, lengthCy ) )], exp, 0, 0 ) < 0 ) + IF( BASOP_Util_Cmp_Mant32Exp( Cr_fx[i + ( i * lengthCy )], exp, 0, 0 ) < 0 ) { - Cr_fx[add( i, imult1616( i, lengthCy ) )] = 0; + Cr_fx[i + ( i * lengthCy )] = 0; move32(); - Cr_e_arr[add( i, imult1616( i, lengthCy ) )] = 0; + Cr_e_arr[i + ( i * lengthCy )] = 0; move16(); } } @@ -1965,7 +1969,7 @@ Word16 computeMixingMatrices_fx( FOR( i = 0; i < lengthCy * lengthCy; i++ ) { - Cr_fx[i] = L_shr( Cr_fx[i], sub( exp, Cr_e_arr[i] ) ); + Cr_fx[i] = L_shr( Cr_fx[i], sub( exp, Cr_e_arr[i] ) ); // Q(31-exp) move32(); } @@ -1985,7 +1989,7 @@ Word16 computeMixingMatrices_fx( FOR( i = 0; i < lengthCy * lengthCy; i++ ) { - mat_mult_buffer2_fx[i] = L_shr( mat_mult_buffer2_fx[i], sub( exp, mat_mult_buffer2_fx_e[i] ) ); + mat_mult_buffer2_fx[i] = L_shr( mat_mult_buffer2_fx[i], sub( exp, mat_mult_buffer2_fx_e[i] ) ); // Q(31-exp) move32(); } @@ -2005,16 +2009,16 @@ Word16 computeMixingMatrices_fx( { /* Avoid correction for very small energies, main diagonal elements of Cy_tilde_p may be negative */ - IF( BASOP_Util_Cmp_Mant32Exp( Cy_tilde_p_fx[add( i, imult1616( i, lengthCy ) )], mat_mult_buffer2_e, 0, 0 ) < 0 ) + IF( BASOP_Util_Cmp_Mant32Exp( Cy_tilde_p_fx[i + ( i * lengthCy )], mat_mult_buffer2_e, 0, 0 ) < 0 ) { - adj_fx_p[i] = 1073741824; + adj_fx_p[i] = 1073741824; // 1.0f in Q30 move32(); adj_e[i] = 1; move16(); } ELSE { - tmp = BASOP_Util_Divide3232_Scale( Cy_fx[add( i, imult1616( i, lengthCy ) )], L_add( Cy_tilde_p_fx[add( i, imult1616( i, lengthCy ) )], EPSILON_FX ), &exp ); + tmp = BASOP_Util_Divide3232_Scale( Cy_fx[i + ( i * lengthCy )], L_add( Cy_tilde_p_fx[i + ( i * lengthCy )], EPSILON_FX ), &exp ); exp = add( exp, sub( Cy_fx_e, mat_mult_buffer2_e ) ); L_tmp = L_deposit_h( tmp ); L_tmp = Sqrt32( L_tmp, &exp ); @@ -2026,7 +2030,7 @@ Word16 computeMixingMatrices_fx( IF( BASOP_Util_Cmp_Mant32Exp( adj_fx_p[i], adj_e[i], 1073741824, 3 ) > 0 ) { - adj_fx_p[i] = 1073741824; + adj_fx_p[i] = 1073741824; // 1.0f in Q30 move32(); adj_e[i] = 3; move16(); @@ -2046,7 +2050,7 @@ Word16 computeMixingMatrices_fx( FOR( i = 0; i < lengthCy; i++ ) { - adj_fx[i] = L_shr( adj_fx_p[i], sub( exp, adj_e[i] ) ); + adj_fx[i] = L_shr( adj_fx_p[i], sub( exp, adj_e[i] ) ); // Q(31-exp) move32(); } adj_fx_e = exp; @@ -2054,7 +2058,7 @@ Word16 computeMixingMatrices_fx( diag_matrix_product_fx( adj_fx, adj_fx_e, lengthCy, mixing_matrix_fx, mixing_matrix_e, lengthCy, lengthCx, 0, mat_mult_buffer3_fx, &mat_mult_buffer3_e ); - Copy32( mat_mult_buffer3_fx, mixing_matrix_fx, imult1616( lengthCx, lengthCy ) ); + Copy32( mat_mult_buffer3_fx, mixing_matrix_fx, imult1616( lengthCx, lengthCy ) ); // Q(31-mat_mult_buffer3_e) mixing_matrix_e = mat_mult_buffer3_e; move16(); } @@ -2271,15 +2275,15 @@ int16_t computeMixingMatricesResidual( #else Word16 computeMixingMatricesResidual_fx( const Word32 num_outputs, /* i : number of output channels */ - const Word32 *Cx_fx, /* i : vector containing the diagonal diffuse prototype covariance */ + const Word32 *Cx_fx, /* i : vector containing the diagonal diffuse prototype covariance Q(31-Cx_e) */ const Word16 Cx_e, - const Word32 *Cy_fx, /* i : matrix containing the missing cov (Cr from computeMixingMatrices()) */ + const Word32 *Cy_fx, /* i : matrix containing the missing cov (Cr from computeMixingMatrices()) Q(31-Cy_fx_e) */ const Word16 Cy_fx_e, - const Word32 reg_Sx_fx, /* i : regularization factor for the input channel singular values */ + const Word32 reg_Sx_fx, /* i : regularization factor for the input channel singular values Q(31-reg_Sx_e) */ const Word16 reg_Sx_e, - const Word32 reg_ghat_fx, /* i : regularization factor for the normalization matrix */ + const Word32 reg_ghat_fx, /* i : regularization factor for the normalization matrix Q(31-reg_ghat_e) */ const Word16 reg_ghat_e, - Word32 *mixing_matrix_fx, /* o : resulting residual mixing matrix */ + Word32 *mixing_matrix_fx, /* o : resulting residual mixing matrix Q(31-mixing_matrix_ret_e) */ Word16 *mixing_matrix_ret_e ) { Word16 i, j; @@ -2359,7 +2363,7 @@ Word16 computeMixingMatricesResidual_fx( tmp_e = svd_s_buffer_e[j]; move16(); L_tmp = Sqrt32( svd_s_buffer_fx[j], &tmp_e ); - Ky_fx[i + j * lengthCy] = Mpy_32_32( svd_u_buffer_fx[i][j], L_tmp ); + Ky_fx[i + j * lengthCy] = Mpy_32_32( svd_u_buffer_fx[i][j], L_tmp ); // Q(31-tmp_e) move32(); Ky_fx_e[i + j * lengthCy] = tmp_e; move16(); @@ -2382,6 +2386,7 @@ Word16 computeMixingMatricesResidual_fx( exp = Cx_e; move16(); Kx_fx[i] = Sqrt32( Cx_fx[i], &exp ); + move32(); Kx_fx_e[i] = exp; move16(); } @@ -2405,7 +2410,7 @@ Word16 computeMixingMatricesResidual_fx( } } - L_tmp = Mpy_32_32( limit_fx, reg_Sx_fx ); + L_tmp = Mpy_32_32( limit_fx, reg_Sx_fx ); // limit_e + reg_Sx_e L_tmp = L_add( L_tmp, EPSILLON_FX ); limit_fx = L_tmp; move16(); @@ -2427,10 +2432,11 @@ Word16 computeMixingMatricesResidual_fx( exp = limit_e; move16(); } - tmp = BASOP_Util_Divide3232_Scale( 1073741824, div_tmp, &scale ); + tmp = BASOP_Util_Divide3232_Scale( 1073741824, div_tmp, &scale ); // 1073741824 -> 1.0f in Q30 scale = add( scale, sub( Q1, exp ) ); Kx_reg_inv_fx[i] = L_deposit_h( tmp ); + move32(); Kx_reg_inv_e[i] = scale; move16(); } @@ -2449,7 +2455,7 @@ Word16 computeMixingMatricesResidual_fx( *-----------------------------------------------------------------*/ /* Computing Cy_hat_diag */ - Copy32( Cx_fx, Cy_hat_diag_fx, extract_l( num_outputs ) ); + Copy32( Cx_fx, Cy_hat_diag_fx, extract_l( num_outputs ) ); // Q(31-Cx_e) Cy_hat_diag_e = Cx_e; move16(); @@ -2464,7 +2470,7 @@ Word16 computeMixingMatricesResidual_fx( } } - L_tmp = Mpy_32_32( limit_fx, reg_ghat_fx ); + L_tmp = Mpy_32_32( limit_fx, reg_ghat_fx ); // Q(limit_e+reg_ghat_e) limit_fx = L_add( L_tmp, EPSILON_FX ); limit_e = add( limit_e, reg_ghat_e ); @@ -2496,7 +2502,7 @@ Word16 computeMixingMatricesResidual_fx( FOR( i = 0; i < num_outputs; i++ ) { - L_tmp = Mpy_32_32( Kx_fx[i], G_hat_fx[i] ); + L_tmp = Mpy_32_32( Kx_fx[i], G_hat_fx[i] ); // Q(31-(Kx_fx_e+G_hag_e)) Kx_fx[i] = L_tmp; move32(); Kx_fx_e[i] = add( Kx_fx_e[i], G_hat_e[i] ); @@ -2511,10 +2517,11 @@ Word16 computeMixingMatricesResidual_fx( FOR( j = 0; j < num_outputs; j++ ) { - L_tmp = Mpy_32_32( Ky_fx[add( i, imult1616( j, extract_l( num_outputs ) ) )], fac_fx ); - mat_mult_buffer1_fx[add( i, imult1616( j, extract_l( num_outputs ) ) )] = L_tmp; + L_tmp = Mpy_32_32( Ky_fx[i + j * num_outputs], fac_fx ); // Q(31-(Ky_fx_e+Kx_fx_e)) + mat_mult_buffer1_fx[i + j * num_outputs] = L_tmp; move32(); - mat_mult_buffer1_buff_e[add( i, imult1616( j, extract_l( num_outputs ) ) )] = extract_l( L_add( Ky_fx_e[add( i, imult1616( j, extract_l( num_outputs ) ) )], Kx_fx_e[i] ) ); + mat_mult_buffer1_buff_e[i + j * num_outputs] = extract_l( L_add( Ky_fx_e[i + j * num_outputs], Kx_fx_e[i] ) ); + move16(); } } @@ -2531,7 +2538,7 @@ Word16 computeMixingMatricesResidual_fx( FOR( i = 0; i < num_outputs * num_outputs; i++ ) { - mat_mult_buffer1_fx[i] = L_shr( mat_mult_buffer1_fx[i], sub( mat_mult_buffer1_e, mat_mult_buffer1_buff_e[i] ) ); + mat_mult_buffer1_fx[i] = L_shr( mat_mult_buffer1_fx[i], sub( mat_mult_buffer1_e, mat_mult_buffer1_buff_e[i] ) ); // Q(31-mat_mult_buffer1_e) move32(); } @@ -2572,11 +2579,11 @@ Word16 computeMixingMatricesResidual_fx( FOR( j = 0; j < num_outputs; j++ ) { #ifdef FIX_827_HIGH_MLD - L_tmp = Mpy_32_32( mat_mult_buffer1_fx[add( j, imult1616( i, extract_l( num_outputs ) ) )], fac_fx ); - mixing_matrix_fx[add( j, imult1616( i, extract_l( num_outputs ) ) )] = L_tmp; + L_tmp = Mpy_32_32( mat_mult_buffer1_fx[j + i * num_outputs], fac_fx ); // Q(31-mat_mult_buffer1_e+Kx_reg_inv_e) + mixing_matrix_fx[j + i * num_outputs] = L_tmp; #else - L_tmp = Mpy_32_32( mat_mult_buffer1_fx[add( j, imult1616( j, extract_l( num_outputs ) ) )], fac_fx ); - mixing_matrix_fx[add( j, imult1616( j, extract_l( num_outputs ) ) )] = L_tmp; + L_tmp = Mpy_32_32( mat_mult_buffer1_fx[j + j * num_outputs], fac_fx ); // mat_mult_buffer1_e+Kx_reg_inv_e + mixing_matrix_fx[j + j * num_outputs] = L_tmp; #endif move32(); mixing_matrix_fx_e[j + i * num_outputs] = add( mat_mult_buffer1_buff_e[j + i * num_outputs], Kx_reg_inv_e[i] ); @@ -2608,7 +2615,7 @@ Word16 computeMixingMatricesResidual_fx( FOR( i = 0; i < num_outputs * num_outputs; i++ ) { - mixing_matrix_fx[i] = L_shr( mixing_matrix_fx[i], sub( exp, mixing_matrix_fx_e[i] ) ); + mixing_matrix_fx[i] = L_shr( mixing_matrix_fx[i], sub( exp, mixing_matrix_fx_e[i] ) ); // Q(31-exp) move32(); } mixing_matrix_e = exp; @@ -2627,7 +2634,7 @@ Word16 computeMixingMatricesResidual_fx( FOR( i = 0; i < num_outputs * num_outputs; i++ ) { - mat_mult_buffer1_fx[i] = L_shr( mat_mult_buffer1_fx[i], sub( exp, mat_mult_buffer1_buff_e[i] ) ); + mat_mult_buffer1_fx[i] = L_shr( mat_mult_buffer1_fx[i], sub( exp, mat_mult_buffer1_buff_e[i] ) ); // Q(31-exp) move32(); } mat_mult_buffer1_e = exp; @@ -2643,14 +2650,15 @@ Word16 computeMixingMatricesResidual_fx( FOR( i = 0; i < lengthCy; ++i ) { - tmp = BASOP_Util_Divide3232_Scale( Cy_fx[add( i, imult1616( lengthCy, i ) )], L_add( Cy_tilde_fx[i], EPSILON_FX ), &scale ); + tmp = BASOP_Util_Divide3232_Scale( Cy_fx[i + ( lengthCy * i )], L_add( Cy_tilde_fx[i], EPSILON_FX ), &scale ); scale = add( scale, sub( Cy_fx_e, Cy_tilde_e ) ); adj_fx_p[i] = Sqrt32( L_deposit_h( tmp ), &scale ); + move32(); adj_buff_e[i] = scale; move16(); - IF( BASOP_Util_Cmp_Mant32Exp( adj_fx_p[i], scale, 1073741824, 3 ) > 0 ) + IF( BASOP_Util_Cmp_Mant32Exp( adj_fx_p[i], scale, 1073741824, 3 ) > 0 ) // 1073741824 -> 1.0f in Q30 { - adj_fx_p[i] = 1073741824; + adj_fx_p[i] = 1073741824; // 1.0f in Q30 move32(); adj_buff_e[i] = 3; move16(); @@ -2672,7 +2680,7 @@ Word16 computeMixingMatricesResidual_fx( FOR( i = 0; i < lengthCy; i++ ) { - adj_fx[i] = L_shr( adj_fx_p[i], sub( adj_e, adj_buff_e[i] ) ); + adj_fx[i] = L_shr( adj_fx_p[i], sub( adj_e, adj_buff_e[i] ) ); // Q(31-adj_e) move32(); } @@ -2698,19 +2706,19 @@ Word16 computeMixingMatricesISM_fx( const Word16 num_inputs, const Word16 num_responses, const Word16 num_outputs, - const Word32 *responses_fx, + const Word32 *responses_fx, /*Q(31-responses_e) */ const Word16 responses_e, - const Word32 *ener_fx, + const Word32 *ener_fx, /*Q(31-ener_e) */ const Word16 ener_e, - const Word32 *Cx_diag_fx, + const Word32 *Cx_diag_fx, /*Q(31-diag_e) */ const Word16 Cx_diag_e, - const Word32 *Cy_diag_fx, + const Word32 *Cy_diag_fx, /*Q(31-diag_e) */ const Word16 Cy_diag_e, const Word16 *Q_16fx, // Q15 const Word16 energy_compensation_flag, - const Word32 reg_Sx_fx, - const Word32 reg_ghat_fx, - Word32 *mixing_matrix_fx, + const Word32 reg_Sx_fx, /*Q0*/ + const Word32 reg_ghat_fx, /*Q0*/ + Word32 *mixing_matrix_fx, /*Q(31-mixing_matrix_e) */ Word16 *mixing_matrix_e ) { Word16 i, out; @@ -2743,7 +2751,7 @@ Word16 computeMixingMatricesISM_fx( push_wmops( "dirac_cov_mix_mat" ); out = EXIT_SUCCESS; - move32(); + move16(); lengthCx = num_inputs; move16(); lengthCy = num_outputs; @@ -2787,13 +2795,13 @@ Word16 computeMixingMatricesISM_fx( } FOR( i = 0; i < lengthCx; i++ ) { - Kx_fx[i] = L_shr_r( Kx_fx[i], sub( Kx_e, temp_e[i] ) ); + Kx_fx[i] = L_shr_r( Kx_fx[i], sub( Kx_e, temp_e[i] ) ); // Q(31-Kx_e) move32(); } /* Regularization of Sx */ maximum_32_fx( Kx_fx, lengthCx, &limit_fx ); - limit_fx = Mpy_32_32( limit_fx, reg_Sx_fx ); + limit_fx = Mpy_32_32( limit_fx, reg_Sx_fx ); // Cy_hat_diag_e + reg_ghat_e FOR( i = 0; i < lengthCx; ++i ) { @@ -2845,7 +2853,7 @@ Word16 computeMixingMatricesISM_fx( } FOR( i = 0; i < lengthCx; i++ ) { - Kx_reg_inv_fx[i] = L_shr_r( Kx_reg_inv_fx[i], sub( Kx_reg_inv_e, temp_e[i] ) ); + Kx_reg_inv_fx[i] = L_shr_r( Kx_reg_inv_fx[i], sub( Kx_reg_inv_e, temp_e[i] ) ); // Q(31- Kx_reg_inv_e) move32(); } @@ -2893,7 +2901,7 @@ Word16 computeMixingMatricesISM_fx( } } - limit_fx = Mpy_32_32( limit_fx, reg_ghat_fx ); + limit_fx = Mpy_32_32( limit_fx, reg_ghat_fx ); // Cy_hat_diag_e + reg_ghat_e /* Computing G_hat */ FOR( i = 0; i < lengthCy; ++i ) @@ -2940,7 +2948,7 @@ Word16 computeMixingMatricesISM_fx( } FOR( i = 0; i < lengthCy; i++ ) { - G_hat_fx[i] = L_shr_r( G_hat_fx[i], sub( G_hat_e, temp_e[i] ) ); + G_hat_fx[i] = L_shr_r( G_hat_fx[i], sub( G_hat_e, temp_e[i] ) ); // Q(31-G_hat_e) move32(); } @@ -3006,7 +3014,7 @@ Word16 computeMixingMatricesISM_fx( FOR( i = 0; i < lengthCy; ++i ) { /* Avoid correction for very small energies, main diagonal elements of Cy_tilde_p may be negative */ - IF( Cy_tilde_p_fx[add( i, imult1616( i, lengthCy ) )] < 0 ) + IF( Cy_tilde_p_fx[( i + ( i * lengthCy ) )] < 0 ) { adj_fx[i] = MAX_32; move32(); @@ -3017,9 +3025,9 @@ Word16 computeMixingMatricesISM_fx( { IF( Cy_diag_fx[i] ) { - IF( Cy_tilde_p_fx[add( i, imult1616( i, lengthCy ) )] ) + IF( Cy_tilde_p_fx[i + ( i * lengthCy )] ) { - adj_fx[i] = BASOP_Util_Divide3232_Scale_cadence( Cy_diag_fx[i], Cy_tilde_p_fx[add( i, imult1616( i, lengthCy ) )], &temp_e[i] ); + adj_fx[i] = BASOP_Util_Divide3232_Scale_cadence( Cy_diag_fx[i], Cy_tilde_p_fx[i + ( i * lengthCy )], &temp_e[i] ); move32(); temp_e[i] = add( temp_e[i], sub( Cy_diag_e, mat_mult_buffer2_e ) ); move16(); @@ -3061,7 +3069,7 @@ Word16 computeMixingMatricesISM_fx( } FOR( i = 0; i < lengthCy; i++ ) { - adj_fx[i] = L_shr_r( adj_fx[i], sub( adj_e, temp_e[i] ) ); + adj_fx[i] = L_shr_r( adj_fx[i], sub( adj_e, temp_e[i] ) ); // Q(31-adj_e) move32(); } diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index f27836c0e..9bb027025 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -960,15 +960,15 @@ void TonalMDCTConceal_SaveTimeSignal_ivas( #ifdef IVAS_FLOAT_FIXED void TonalMdctConceal_create_concealment_noise_ivas_fx( - Word32 concealment_noise[L_FRAME48k], + Word32 concealment_noise[L_FRAME48k], // Q31-concealment_noise_exp Word16 *concealment_noise_exp, CPE_DEC_HANDLE hCPE, - const Word16 L_frameTCX, - const Word16 L_frame, - const Word16 idchan, - const Word16 subframe_idx, - const Word16 core, - const Word16 crossfade_gain, + const Word16 L_frameTCX, // Q0 + const Word16 L_frame, // Q0 + const Word16 idchan, // Q0 + const Word16 subframe_idx, // Q0 + const Word16 core, // Q0 + const Word16 crossfade_gain, // Q15 const TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode ) { STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct; @@ -1027,10 +1027,10 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( /* first lost frame is handled separately */ IF( !hTonalMDCTConc->lastBlockData.blockIsConcealed ) { - *rnd = add( 1977, idchan ); + *rnd = add( 1977, idchan ); // Q0 move16(); /* will be set twice when looping over two channels, but does not matter */ - *rnd_c = 1979; + *rnd_c = 1979; // Q0 move16(); } @@ -1042,7 +1042,7 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( { *rnd = own_random( rnd ); move16(); - concealment_noise[i] = *rnd; + concealment_noise[i] = *rnd; // Q31-concealment_noise_exp move32(); } *concealment_noise_exp = 31; @@ -1052,7 +1052,7 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( return; } - save_rnd_c = *rnd_c; + save_rnd_c = *rnd_c; // Q0 move16(); c_e = 1; @@ -1067,13 +1067,13 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( { IF( LT_16( c_e, c_inv_e ) ) { - c = shr( c, sub( c_inv_e, c_e ) ); + c = shr( c, sub( c_inv_e, c_e ) ); // Q0 c_e = c_inv_e; move16(); } ELSE { - c_inv = shr( c_inv, sub( c_e, c_inv_e ) ); + c_inv = shr( c_inv, sub( c_e, c_inv_e ) ); // Q0 } } @@ -1105,7 +1105,7 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( { noise_shape_buffer_e[i] = hFdCngCom->cngNoiseLevelExp; move16(); - noise_shape_buffer[i] = Sqrt32( *( cngNoiseLevelPtr ), &noise_shape_buffer_e[i] ); + noise_shape_buffer[i] = Sqrt32( *( cngNoiseLevelPtr ), &noise_shape_buffer_e[i] ); // Q31-noise_shape_buffer_e[i] move32(); noise_shape_buffer_common_exp = s_max( noise_shape_buffer_e[i], noise_shape_buffer_common_exp ); } @@ -1115,33 +1115,33 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( IF( NE_16( noise_shape_buffer_common_exp, noise_shape_buffer_e[i] ) ) { - noise_shape_buffer[i] = L_shr( noise_shape_buffer[i], sub( noise_shape_buffer_common_exp, noise_shape_buffer_e[i] ) ); + noise_shape_buffer[i] = L_shr( noise_shape_buffer[i], sub( noise_shape_buffer_common_exp, noise_shape_buffer_e[i] ) ); // Q31- (noise_shape_buffer_common_exp-noise_shape_buffer_e[i]) move32(); } } - last_scf = Sqrt32( *( cngNoiseLevelPtr - inc ), &last_scf_e ); + last_scf = Sqrt32( *( cngNoiseLevelPtr - inc ), &last_scf_e ); // Q31-last_scf_e IF( LT_16( noise_shape_buffer_common_exp, last_scf_e ) ) { - Scale_sig32( noise_shape_buffer, stop_idx, sub( noise_shape_buffer_common_exp, last_scf_e ) ); + Scale_sig32( noise_shape_buffer, stop_idx, sub( noise_shape_buffer_common_exp, last_scf_e ) ); // Q31- (noise_shape_buffer_common_exp-last_scf_e) noise_shape_buffer_common_exp = last_scf_e; move16(); } ELSE { - last_scf = L_shl( last_scf, sub( last_scf_e, noise_shape_buffer_common_exp ) ); + last_scf = L_shl( last_scf, sub( last_scf_e, noise_shape_buffer_common_exp ) ); // Q31-(last_scf_e-noise_shape_buffer_common_exp) } FOR( ; i < max_noise_line; i++ ) { - noise_shape_buffer[i] = last_scf; + noise_shape_buffer[i] = last_scf; // Q31 - noise_shape_buffer_common_exp move32(); } /* fill the noise vector */ - hTonalMDCTConc->curr_noise_nrg = MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG_Q31; + hTonalMDCTConc->curr_noise_nrg = MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG_Q31; // Q31 move32(); hTonalMDCTConc->curr_noise_nrg_exp = 0; move16(); @@ -1160,17 +1160,17 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( FOR( i = 0; i < max_noise_line; i++ ) { - *rnd = own_random( rnd ); + *rnd = own_random( rnd ); // Q0 *rnd_c = own_random( rnd_c ); move16(); move16(); - concealment_noise[i] = Mpy_32_32( L_add( L_shr( L_mult( c_inv, *rnd ), 1 ), L_shr( L_mult( c, *rnd_c ), 1 ) ), noise_shape_buffer[i] ); + concealment_noise[i] = Mpy_32_32( L_add( L_shr( L_mult( c_inv, *rnd ), 1 ), L_shr( L_mult( c, *rnd_c ), 1 ) ), noise_shape_buffer[i] ); // Q31 - *concealment_noise_exp move32(); IF( concealment_noise[i] != 0 ) { - hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, Mpy_32_32( concealment_noise[i], concealment_noise[i] ), shl( *concealment_noise_exp, 1 ), &temp_e ); + hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, Mpy_32_32( concealment_noise[i], concealment_noise[i] ), shl( *concealment_noise_exp, 1 ), &temp_e ); // Q31-temp_e } hTonalMDCTConc->curr_noise_nrg_exp = temp_e; move16(); @@ -1181,8 +1181,8 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( /* current channel is TCX10 and the other is TCX20 -> generate noise for "half-length" spectrum, but "increment" mid seed twice, to have the same seed in mid as the other (TCX20) channel for next frame */ FOR( i = 0; i < max_noise_line; i++ ) { - *rnd = own_random( rnd ); - *rnd_c = own_random( rnd_c ); + *rnd = own_random( rnd ); // Q0 + *rnd_c = own_random( rnd_c ); // Q0 move16(); move16(); @@ -1190,7 +1190,7 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( move32(); IF( concealment_noise[i] != 0 ) { - hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, Mpy_32_32( concealment_noise[i], concealment_noise[i] ), shl( *concealment_noise_exp, 1 ), &temp_e ); + hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, Mpy_32_32( concealment_noise[i], concealment_noise[i] ), shl( *concealment_noise_exp, 1 ), &temp_e ); // Q31-temp_e } hTonalMDCTConc->curr_noise_nrg_exp = temp_e; move16(); @@ -1521,11 +1521,11 @@ void TonalMdctConceal_whiten_noise_shape_ivas_fx( sns_interpolate_scalefactors_fx( scfs_int, scf, ENC ); sns_interpolate_scalefactors_fx( scfs_bg, scf, DEC ); - scfs_for_shaping = &scfs_int[0]; + scfs_for_shaping = &scfs_int[0]; // Q16 } ELSE /* whitening_mode == ON_FIRST_GOOD_FRAME */ { - scfs_for_shaping = &scfs_bg[0]; + scfs_for_shaping = &scfs_bg[0]; // Q16 } IF( sum32_sat( scfs_for_shaping, FDNS_NPTS ) > 0 ) @@ -1537,7 +1537,7 @@ void TonalMdctConceal_whiten_noise_shape_ivas_fx( { FOR( i = 0; i < sub( stop_idx, start_idx ); i++ ) { - hFdCngCom->cngNoiseLevel[i] = L_shr( whitenend_noise_shape[start_idx + i], sub( add( q_wns, hFdCngCom->cngNoiseLevelExp ), 30 ) ); + hFdCngCom->cngNoiseLevel[i] = L_shr( whitenend_noise_shape[start_idx + i], sub( add( q_wns, hFdCngCom->cngNoiseLevelExp ), 30 ) ); //(q_wns + 1) move32(); } } diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index fa49a85f3..b46d0abd5 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -118,8 +118,8 @@ ivas_error TonalMDCTConceal_Init( move16(); move16(); /* just the second half of the second last pcm output is needed */ - hTonalMDCTConc->secondLastPcmOut = &hTonalMDCTConc->timeDataBuffer[sub( ( 3 * L_FRAME_MAX ) / 2, shr( imult1616( 3, ( s_min( L_FRAME_MAX, nSamples ) ) ), 1 ) )]; - hTonalMDCTConc->lastPcmOut = &hTonalMDCTConc->timeDataBuffer[sub( ( 3 * L_FRAME_MAX ) / 2, s_min( L_FRAME_MAX, nSamples ) )]; + hTonalMDCTConc->secondLastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - ( 3 * ( min( L_FRAME_MAX, nSamples ) ) / 2 )]; + hTonalMDCTConc->lastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - min( L_FRAME_MAX, nSamples )]; /* If the second last frame was lost, we reuse saved TonalComponentsInfo and don't update pcm buffers */ assert( sizeof( *hTonalMDCTConc->pTCI ) <= ( hTonalMDCTConc->lastPcmOut - hTonalMDCTConc->timeDataBuffer ) * sizeof( hTonalMDCTConc->timeDataBuffer[0] ) ); @@ -231,8 +231,8 @@ ivas_error TonalMDCTConceal_Init_ivas_fx( move16(); move16(); /* just the second half of the second last pcm output is needed */ - hTonalMDCTConc->secondLastPcmOut = &hTonalMDCTConc->timeDataBuffer[sub( ( 3 * L_FRAME_MAX ) / 2, imult1616( 3, shr( s_min( L_FRAME_MAX, nSamples ), 1 ) ) )]; - hTonalMDCTConc->lastPcmOut = &hTonalMDCTConc->timeDataBuffer[sub( ( 3 * L_FRAME_MAX ) / 2, s_min( L_FRAME_MAX, nSamples ) )]; + hTonalMDCTConc->secondLastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - ( 3 * min( L_FRAME_MAX, nSamples ) / 2 )]; + hTonalMDCTConc->lastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - min( L_FRAME_MAX, nSamples )]; /* If the second last frame was lost, we reuse saved TonalComponentsInfo and don't update pcm buffers */ assert( sizeof( *hTonalMDCTConc->pTCI ) <= ( hTonalMDCTConc->lastPcmOut - hTonalMDCTConc->timeDataBuffer ) * sizeof( hTonalMDCTConc->timeDataBuffer[0] ) ); @@ -240,11 +240,11 @@ ivas_error TonalMDCTConceal_Init_ivas_fx( } void TonalMDCTConceal_SaveFreqSignal( TonalMDCTConcealPtr hTonalMDCTConc, - const Word32 *mdctSpectrum, + const Word32 *mdctSpectrum, // Q31-mdctSpectrum_exp const Word16 mdctSpectrum_exp, - Word16 nNewSamples, - Word16 nNewSamplesCore, - const Word16 *scaleFactors, + Word16 nNewSamples, // Q0 + Word16 nNewSamplesCore, // Q0 + const Word16 *scaleFactors, // Q31-scaleFactors_exp const Word16 *scaleFactors_exp, const Word16 gain_tcx_exp #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT @@ -375,7 +375,7 @@ void TonalMDCTConceal_SaveFreqSignal( FOR( i = 0; i < nNewSamples; i++ ) { - hTonalMDCTConc->lastBlockData.spectralData[i] = extract_h( L_shl( mdctSpectrum[i], s ) ); + hTonalMDCTConc->lastBlockData.spectralData[i] = extract_h( L_shl( mdctSpectrum[i], s ) ); // Q31-(mdctSpectrum_exp-s) move16(); } hTonalMDCTConc->lastBlockData.spectralData_exp = sub( mdctSpectrum_exp, s ); @@ -390,14 +390,14 @@ void TonalMDCTConceal_SaveFreqSignal( void TonalMDCTConceal_SaveFreqSignal_ivas_fx( TonalMDCTConcealPtr hTonalMDCTConc, - const Word32 *mdctSpectrum, - const Word16 mdctSpectrum_exp, - const Word16 nNewSamples, - const Word16 nNewSamplesCore, - const Word16 *scaleFactors, - const Word16 *scaleFactors_exp, - const Word16 gain_tcx_exp, - const Word16 infoIGFStartLine ) + const Word32 *mdctSpectrum, // Q31-mdctSpectrum_exp + const Word16 mdctSpectrum_exp, // Q0 + const Word16 nNewSamples, // Q0 + const Word16 nNewSamplesCore, // Q0 + const Word16 *scaleFactors, // Q15 - *scaleFactors_exp + const Word16 *scaleFactors_exp, // Q0 + const Word16 gain_tcx_exp, // Q0 + const Word16 infoIGFStartLine ) // Q0 { Word16 *temp; Word16 nOldSamples, temp_exp, s, i, max_exp; @@ -496,7 +496,7 @@ void TonalMDCTConceal_SaveFreqSignal_ivas_fx( { Word16 tmp = extract_h( mdctSpectrum[i] ); hTonalMDCTConc->last_block_nrg = L_add( hTonalMDCTConc->last_block_nrg, - L_shr( L_mult0( tmp, tmp ), 16 ) ); + L_shr( L_mult0( tmp, tmp ), 16 ) ); // Q31-last_block_nrg_exp move32(); } hTonalMDCTConc->last_block_nrg_exp = sub( 31, sub( shl( sub( 15, mdctSpectrum_exp ), 1 ), 16 ) ); @@ -526,7 +526,7 @@ void TonalMDCTConceal_SaveFreqSignal_ivas_fx( tmp = 1; move16(); } - hTonalMDCTConc->lastBlockData.spectralData[i] = extract_h( L_shl( mdctSpectrum[i], s ) ); + hTonalMDCTConc->lastBlockData.spectralData[i] = extract_h( L_shl( mdctSpectrum[i], s ) ); // 31 - mdctSpectrum_exp +s -16 = 15-(mdctSpectrum_exp -s) move16(); test(); @@ -549,9 +549,9 @@ void TonalMDCTConceal_SaveFreqSignal_ivas_fx( TONALMDCTCONCEAL_ERROR TonalMDCTConceal_UpdateState( TonalMDCTConcealPtr hTonalMDCTConc, - Word16 nNewSamples, - Word32 pitchLag, - Word16 badBlock, + Word16 nNewSamples, // Q0 + Word32 pitchLag, // Qx + Word16 badBlock, // Q0 Word8 tonalConcealmentActive ) { Word8 newBlockIsValid; @@ -596,8 +596,8 @@ TONALMDCTCONCEAL_ERROR TonalMDCTConceal_UpdateState( TonalMDCTConcealPtr hTonalM } static void FindPhases( /* o: currenc phase [-pi;pi] 2Q13 */ TonalMDCTConcealPtr const hTonalMDCTConc, /* i: pointer to internal structure */ - Word32 secondLastMDCT[], /* i: MDST spectrum data */ - Word32 secondLastMDST[], /* i: MDCT spectrum data */ + Word32 secondLastMDCT[], /* i: MDST spectrum data Qx +31 -diff_exp */ + Word32 secondLastMDST[], /* i: MDCT spectrum data Qx */ Word16 diff_exp ) /* i: exp_MDST - exp_MDCT */ { Word16 i; @@ -614,7 +614,7 @@ static void FindPhases( /* o: currenc /* in contrast to the float code, the parameter secondLastMDST[l] needs not to be negated - due to a different implementation of the MDST */ - *pCurrentPhase++ = BASOP_util_atan2( secondLastMDST[l], secondLastMDCT[l], diff_exp ); + *pCurrentPhase++ = BASOP_util_atan2( secondLastMDST[l], secondLastMDCT[l], diff_exp ); // Q13 move16(); } } @@ -630,7 +630,7 @@ static void FindPhases( /* o: currenc static void FindPhaseDifferences( /* o: Phase difference [-pi;pi] 2Q13*/ TonalMDCTConcealPtr const hTonalMDCTConc, /* i: Pointer to internal structure */ - Word32 powerSpectrum[] ) /* i: Power spectrum data */ + Word32 powerSpectrum[] ) /* i: Power spectrum data Qx */ { Word16 i, k; Word16 *phaseDiff; @@ -684,7 +684,7 @@ static void FindPhaseDifferences( /* o phaseDiff[i] = (float)atan(a) * (bandwidth/2.0f);*/ /*max divi=44.8 & sf=6*/ divi = BASOP_Util_Divide3232_uu_1616_Scale( powerSpectrum[k - 1], powerSpectrum[k + 1], &sf ); - Q = BASOP_Util_fPow( L_deposit_h( divi ), sf, G, 0, &sf ); + Q = BASOP_Util_fPow( L_deposit_h( divi ), sf, G, 0, &sf ); // Q31-sf L_tmp = Mpy_32_16_1( Q, s ); sfn = sub( sf, 2 ); @@ -743,11 +743,11 @@ static void FindPhaseDifferences( /* o #ifdef IVAS_FLOAT_FIXED static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( TonalMDCTConcealPtr const hTonalMDCTConc, - Word32 secondLastMDST[], + Word32 secondLastMDST[], // Q31 - secondLastMDST_exp Word16 secondLastMDST_exp, - Word32 secondLastMDCT[], + Word32 secondLastMDCT[], // Q31 - secondLastMDCT_exp Word16 secondLastMDCT_exp, - Word32 const pitchLag, + Word32 const pitchLag, /*15Q16*/ const PsychoacousticParameters *psychParamsCurrent, Word16 element_mode ) { @@ -823,14 +823,14 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( /*sqrtFLOAT(powerSpectrum, powerSpectrum, nSamples);*/ old_exp = powerSpectrum_exp; move16(); - powerSpectrum_exp = mult_r( sub( powerSpectrum_exp, 2 ), 1 << 14 ); /*remove 2 bits of headroom from CalcPowerSpec*/ + powerSpectrum_exp = mult_r( sub( powerSpectrum_exp, 2 ), ( 1 << 14 ) ); /*remove 2 bits of headroom from CalcPowerSpec*/ FOR( i = 0; i < nSamples; i++ ) { tmp_exp = old_exp; move16(); powerSpectrum[i] = Sqrt32( powerSpectrum[i], &tmp_exp ); move32(); - powerSpectrum[i] = L_shr( powerSpectrum[i], sub( powerSpectrum_exp, tmp_exp ) ); + powerSpectrum[i] = L_shr( powerSpectrum[i], sub( powerSpectrum_exp, tmp_exp ) ); // Q31-(powerSpectrum_exp-tmp_exp) move32(); } @@ -838,7 +838,7 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( { invScaleFactors_exp[i] = hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i]; move16(); - invScaleFactors[i] = Inv16( hTonalMDCTConc->secondLastBlockData.scaleFactors[i], &invScaleFactors_exp[i] ); + invScaleFactors[i] = Inv16( hTonalMDCTConc->secondLastBlockData.scaleFactors[i], &invScaleFactors_exp[i] ); // Q31-invScaleFactors_exp[i] move16(); } @@ -868,19 +868,19 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( } IF( LT_16( old_power_spectrum_q, power_spectrum_q ) ) { - Scale_sig32( powerSpectrum, length, sub( old_power_spectrum_q, power_spectrum_q ) ); + Scale_sig32( powerSpectrum, length, sub( old_power_spectrum_q, power_spectrum_q ) ); // Q(old_power_spectrum_q-power_spectrum_q) } ELSE { - Scale_sig32( powerSpectrum + length, sub( nSamples, length ), sub( power_spectrum_q, old_power_spectrum_q ) ); + Scale_sig32( powerSpectrum + length, sub( nSamples, length ), sub( power_spectrum_q, old_power_spectrum_q ) ); // Q(power_spectrum_q - old_power_spectrum_q) powerSpectrum_exp = sub( 31, power_spectrum_q ); } - Scale_sig32( powerSpectrum, nSamples, -3 ); /*Adding guard bits*/ + Scale_sig32( powerSpectrum, nSamples, -3 ); /*Adding guard bits*/ // Q(31 - powerSpectrum_exp )-3 powerSpectrum_exp = add( powerSpectrum_exp, 3 ); FOR( i = hTonalMDCTConc->nSamplesCore; i < nSamples; i++ ) { #ifdef BASOP_NOGLOB - powerSpectrum[i] = L_shl_sat( Mpy_32_16_1( powerSpectrum[i], invScaleFactors[nBands - 1] ), invScaleFactors_exp[nBands - 1] ); + powerSpectrum[i] = L_shl_sat( Mpy_32_16_1( powerSpectrum[i], invScaleFactors[nBands - 1] ), invScaleFactors_exp[nBands - 1] ); // Q(31 - powerSpectrum_exp) #else powerSpectrum[i] = L_shl( Mpy_32_16_1( powerSpectrum[i], invScaleFactors[nBands - 1] ), invScaleFactors_exp[nBands - 1] ); #endif @@ -895,7 +895,7 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( FOR( i = 0; i < nSamples; i++ ) { #ifdef BASOP_NOGLOB - hTonalMDCTConc->secondLastPowerSpectrum[i] = round_fx_o( powerSpectrum[i], &Overflow ); + hTonalMDCTConc->secondLastPowerSpectrum[i] = round_fx_o( powerSpectrum[i], &Overflow ); // Q31 - powerSpectrum_exp #else hTonalMDCTConc->secondLastPowerSpectrum[i] = round_fx( powerSpectrum[i] ); #endif @@ -910,11 +910,11 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( static void CalcPowerSpecAndDetectTonalComponents( TonalMDCTConcealPtr const hTonalMDCTConc, - Word32 secondLastMDST[], + Word32 secondLastMDST[], // Q31-secondLastMDST_exp Word16 secondLastMDST_exp, - Word32 secondLastMDCT[], + Word32 secondLastMDCT[], // Q31-secondLastMDCT_exp Word16 secondLastMDCT_exp, - Word32 const pitchLag, + Word32 const pitchLag, /*15Q16*/ Word16 element_mode #ifdef IVAS_CODE_MDCT_GSHAPE , @@ -995,8 +995,8 @@ static void CalcPowerSpecAndDetectTonalComponents( { tmp_exp = old_exp; move16(); - powerSpectrum[i] = Sqrt32( powerSpectrum[i], &tmp_exp ); - powerSpectrum[i] = L_shr( powerSpectrum[i], sub( powerSpectrum_exp, tmp_exp ) ); + powerSpectrum[i] = Sqrt32( powerSpectrum[i], &tmp_exp ); // Q31- tmp_exp + powerSpectrum[i] = L_shr( powerSpectrum[i], sub( powerSpectrum_exp, tmp_exp ) ); // Q31- tmp_exp move32(); } @@ -1005,7 +1005,7 @@ static void CalcPowerSpecAndDetectTonalComponents( move16(); move16(); invScaleFactors_exp[i] = hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i]; - invScaleFactors[i] = Inv16( hTonalMDCTConc->secondLastBlockData.scaleFactors[i], &invScaleFactors_exp[i] ); + invScaleFactors[i] = Inv16( hTonalMDCTConc->secondLastBlockData.scaleFactors[i], &invScaleFactors_exp[i] ); // Q31 - invScaleFactors_exp[i] } @@ -1027,7 +1027,7 @@ static void CalcPowerSpecAndDetectTonalComponents( FOR( i = hTonalMDCTConc->nSamplesCore; i < nSamples; i++ ) { #ifdef BASOP_NOGLOB - powerSpectrum[i] = L_shl_sat( Mpy_32_16_1( powerSpectrum[i], invScaleFactors[FDNS_NPTS - 1] ), invScaleFactors_exp[FDNS_NPTS - 1] ); + powerSpectrum[i] = L_shl_sat( Mpy_32_16_1( powerSpectrum[i], invScaleFactors[FDNS_NPTS - 1] ), invScaleFactors_exp[FDNS_NPTS - 1] ); // powerSpectrum_exp+ 2*invScaleFactors_exp -15 #else powerSpectrum[i] = L_shl( Mpy_32_16_1( powerSpectrum[i], invScaleFactors[FDNS_NPTS - 1] ), invScaleFactors_exp[FDNS_NPTS - 1] ); #endif @@ -1038,7 +1038,7 @@ static void CalcPowerSpecAndDetectTonalComponents( FOR( i = 0; i < nSamples; i++ ) { #ifdef BASOP_NOGLOB - hTonalMDCTConc->secondLastPowerSpectrum[i] = round_fx_o( powerSpectrum[i], &Overflow ); + hTonalMDCTConc->secondLastPowerSpectrum[i] = round_fx_o( powerSpectrum[i], &Overflow ); // Q31-powerSpectrum_exp #else hTonalMDCTConc->secondLastPowerSpectrum[i] = round_fx( powerSpectrum[i] ); #endif @@ -1055,8 +1055,8 @@ static void CalcPowerSpecAndDetectTonalComponents( static void CalcMDXT( const TonalMDCTConcealPtr hTonalMDCTConc, const Word16 type, - const Word16 *timeSignal, - Word32 *mdxtOutput, + const Word16 *timeSignal, // Qx + Word32 *mdxtOutput, // Q31-mdxtOutput_e Word16 *mdxtOutput_e ) { Word16 windowedTimeSignal[L_FRAME_PLUS + 2 * L_MDCT_OVLP_MAX]; @@ -1082,7 +1082,7 @@ static void CalcMDXT( void TonalMDCTConceal_Detect( const TonalMDCTConcealPtr hTonalMDCTConc, - const Word32 pitchLag, + const Word32 pitchLag, /*15Q16*/ Word16 *numIndices, Word16 element_mode #ifdef IVAS_CODE_MDCT_GSHAPE @@ -1184,8 +1184,8 @@ void TonalMDCTConceal_Detect( /* multFLOAT(powerSpectrum, powerSpectrum, powerSpectrum, nSamples); */ FOR( i = 0; i < nSamples; i++ ) { - Word32 const t = L_shl( powerSpectrum[i], powerSpectrum_exp ); - powerSpectrum[i] = Mpy_32_32( t, t ); + Word32 const t = L_shl( powerSpectrum[i], powerSpectrum_exp ); // Q(31-secondLastMDST_exp+powerSpectrum_exp) + powerSpectrum[i] = Mpy_32_32( t, t ); // Q2*(31-secondLastMDST_exp+powerSpectrum_exp) -31 move32(); } @@ -1225,7 +1225,7 @@ void TonalMDCTConceal_Detect( #ifdef IVAS_FLOAT_FIXED void TonalMDCTConceal_Detect_ivas_fx( const TonalMDCTConcealPtr hTonalMDCTConc, - const Word32 pitchLag, + const Word32 pitchLag, /*15Q16*/ Word16 *numIndices, const PsychoacousticParameters *psychParamsCurrent, Word16 element_mode ) @@ -1328,8 +1328,8 @@ void TonalMDCTConceal_Detect_ivas_fx( /* multFLOAT(powerSpectrum, powerSpectrum, powerSpectrum, nSamples); */ FOR( i = 0; i < nSamples; i++ ) { - Word32 const t = L_shl( powerSpectrum[i], powerSpectrum_exp ); - powerSpectrum[i] = Mpy_32_32( t, t ); + Word32 const t = L_shl( powerSpectrum[i], powerSpectrum_exp ); // Q(31-secondLastMDST_exp+powerSpectrum_exp) + powerSpectrum[i] = Mpy_32_32( t, t ); // Q(31-secondLastMDST_exp+powerSpectrum_exp) move32(); } } @@ -1345,8 +1345,8 @@ void TonalMDCTConceal_Detect_ivas_fx( FOR( i = 0; i < nSamples; i++ ) { - Word32 const t = L_shl( powerSpectrum[i], -3 ); - powerSpectrum[i] = Mpy_32_32( t, t ); + Word32 const t = L_shl( powerSpectrum[i], -3 ); // Q31 - powerSpectrum_exp -3 + powerSpectrum[i] = Mpy_32_32( t, t ); // 2*(Q31 - powerSpectrum_exp -3)-31 move32(); } } @@ -1387,17 +1387,17 @@ void TonalMDCTConceal_Detect_ivas_fx( void TonalMDCTConceal_InsertNoise_ivas_fx( const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, + Word32 *mdctSpectrum, // Q31-mdctSpectrum_exp Word16 *mdctSpectrum_exp, const Word16 tonalConcealmentActive, - Word16 *pSeed, /*IN/OUT*/ - const Word16 tiltCompFactor, - const Word16 crossfadeGain_const, - const Word32 concealment_noise[L_FRAME48k], + Word16 *pSeed, /*IN/OUT*/ + const Word16 tiltCompFactor, // Q15 + const Word16 crossfadeGain_const, // Q15 + const Word32 concealment_noise[L_FRAME48k], // Q31-concealment_noise_e const Word16 concealment_noise_e, - const Word32 cngLevelBackgroundTrace_bfi, + const Word32 cngLevelBackgroundTrace_bfi, // Q31-cngLevelBackgroundTrace_bfi_e const Word16 cngLevelBackgroundTrace_bfi_e, - const Word16 crossOverFreq ) + const Word16 crossOverFreq ) // Q0 { Word16 i, l, ld, fac; Word16 rnd; @@ -1438,11 +1438,11 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( move32(); inv_exp = 15; move16(); - inv_samples = Inv16( hTonalMDCTConc->lastBlockData.nSamples, &inv_exp ); - tiltFactor = round_fx( BASOP_Util_fPow( L_max( L_tmp, L_deposit_h( tiltCompFactor ) ), 0, L_deposit_h( inv_samples ), inv_exp, &exp ) ); - BASOP_SATURATE_WARNING_OFF_EVS /*next op may result in 32768*/ + inv_samples = Inv16( hTonalMDCTConc->lastBlockData.nSamples, &inv_exp ); // Q31-inv_exp + tiltFactor = round_fx( BASOP_Util_fPow( L_max( L_tmp, L_deposit_h( tiltCompFactor ) ), 0, L_deposit_h( inv_samples ), inv_exp, &exp ) ); // Q15 - exp + BASOP_SATURATE_WARNING_OFF_EVS /*next op may result in 32768*/ #ifdef BASOP_NOGLOB - tiltFactor = shl_sat( tiltFactor, exp ); + tiltFactor = shl_sat( tiltFactor, exp ); // Q15 #else tiltFactor = shl( tiltFactor, exp ); #endif @@ -1474,19 +1474,19 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( { IF( concealment_noise[i] > 0 ) { - mdctSpectrum[i] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[i] ), 16 ); + mdctSpectrum[i] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[i] ), 16 ); // Q31-spectralData_exp move32(); } ELSE { - mdctSpectrum[i] = L_negate( L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[i] ), 16 ) ); + mdctSpectrum[i] = L_negate( L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[i] ), 16 ) ); // Q31-spectralData_exp move32(); } } FOR( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ ) { - mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ); + mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ); // Q31-spectralData_exp move32(); } @@ -1508,14 +1508,14 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( num = L_shl( cngLevelBackgroundTrace_bfi, ld ); exp_num = sub( exp_num, ld ); ld = norm_l( hTonalMDCTConc->curr_noise_nrg ); - den = L_shl( hTonalMDCTConc->curr_noise_nrg, ld ); + den = L_shl( hTonalMDCTConc->curr_noise_nrg, ld ); // Q31- curr_noise_nrg_exp + ld exp_den = sub( exp_den, ld ); exp = sub( exp_num, exp_den ); IF( GT_32( num, den ) ) { - num = L_shr( num, 1 ); + num = L_shr( num, 1 ); // Q31-exp -1 exp = add( exp, 1 ); } #ifdef BASOP_NOGLOB @@ -1533,13 +1533,13 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( { IF( exp > 0 ) { - g = shr( g, exp ); + g = shr( g, exp ); // Q15-exp *mdctSpectrum_exp = hTonalMDCTConc->lastBlockData.spectralData_exp; move16(); } ELSE { - crossfadeGain = shl( crossfadeGain, exp ); + crossfadeGain = shl( crossfadeGain, exp ); // Q15 - e_crossfadeGain + exp e_crossfadeGain = sub( e_crossfadeGain, exp ); *mdctSpectrum_exp = sub( hTonalMDCTConc->lastBlockData.spectralData_exp, exp ); move16(); @@ -1568,25 +1568,25 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( FOR( i = 0; i < crossOverFreq; i++ ) { - Word16 x = hTonalMDCTConc->lastBlockData.spectralData[i]; + Word16 x = hTonalMDCTConc->lastBlockData.spectralData[i]; // Q15 - spectralData_exp move16(); - Word32 y = concealment_noise[i]; + Word32 y = concealment_noise[i]; // Q31-concealment_noise_e move32(); IF( g > 0 ) { - L_tmp = Mpy_32_16_1( y, g ); + L_tmp = Mpy_32_16_1( y, g ); // Q31-concealment_noise_e- spectralData_exp } - L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); + L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp IF( y > 0 ) { - L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); + L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp } - mdctSpectrum[i] = L_shl( L_tmp2, exp ); + mdctSpectrum[i] = L_shl( L_tmp2, exp ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + exp move32(); - hTonalMDCTConc->faded_signal_nrg = L_add( hTonalMDCTConc->faded_signal_nrg, Mpy_32_32( mdctSpectrum[i], mdctSpectrum[i] ) ); + hTonalMDCTConc->faded_signal_nrg = L_add( hTonalMDCTConc->faded_signal_nrg, Mpy_32_32( mdctSpectrum[i], mdctSpectrum[i] ) ); // Q31- faded_signal_nrg_exp move32(); } FOR( i = crossOverFreq; i < hTonalMDCTConc->lastBlockData.nSamples; i++ ) @@ -1621,11 +1621,11 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( { Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; move16(); - Word32 y = concealment_noise[l]; + Word32 y = concealment_noise[l];//concealment_noise_e move32(); last_block_nrg_correct = L_add( last_block_nrg_correct, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // exp = 2 * x_exp + ld - y = L_negate( Mpy_32_32( y, y ) ); - hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, y, 2 * concealment_noise_e, &hTonalMDCTConc->curr_noise_nrg_exp ); + y = L_negate( Mpy_32_32( y, y ) );//Q31-2* concealment_noise_e + hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, y, 2 * concealment_noise_e, &hTonalMDCTConc->curr_noise_nrg_exp ); // Q31- hTonalMDCTConc->curr_noise_nrg_exp move32(); } } @@ -1639,12 +1639,12 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( { IF( GT_32( concealment_noise[l], 0 ) ) { - mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ); + mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ); // hTonalMDCTConc->lastBlockData.spectralData_exp move32(); } ELSE { - mdctSpectrum[l] = L_negate( L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ) ); + mdctSpectrum[l] = L_negate( L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ) ); // hTonalMDCTConc->lastBlockData.spectralData_exp move32(); } } @@ -1654,12 +1654,12 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( { IF( concealment_noise[l] > 0 ) { - mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ); + mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ); // hTonalMDCTConc->lastBlockData.spectralData_exp move32(); } ELSE { - mdctSpectrum[l] = L_negate( L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ) ); + mdctSpectrum[l] = L_negate( L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ) ); // hTonalMDCTConc->lastBlockData.spectralData_exp move32(); } } @@ -1669,19 +1669,19 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( { IF( concealment_noise[l] > 0 ) { - mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ); + mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ); // hTonalMDCTConc->lastBlockData.spectralData_exp move32(); } ELSE { - mdctSpectrum[l] = L_negate( L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ) ); + mdctSpectrum[l] = L_negate( L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ) ); // hTonalMDCTConc->lastBlockData.spectralData_exp move32(); } } FOR( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ ) { - mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ); + mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), 16 ); // hTonalMDCTConc->lastBlockData.spectralData_exp move32(); } @@ -1700,17 +1700,17 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( move16(); ld = norm_l( cngLevelBackgroundTrace_bfi ); - num = L_shl( cngLevelBackgroundTrace_bfi, ld ); + num = L_shl( cngLevelBackgroundTrace_bfi, ld ); // Q15 - exp_num + ld exp_num = sub( exp_num, ld ); ld = norm_l( hTonalMDCTConc->curr_noise_nrg ); - den = L_shl( hTonalMDCTConc->curr_noise_nrg, ld ); + den = L_shl( hTonalMDCTConc->curr_noise_nrg, ld ); // Q15 - exp_den + ld exp_den = sub( exp_den, ld ); exp = sub( exp_num, exp_den ); IF( GT_32( num, den ) ) { - num = L_shr( num, 1 ); + num = L_shr( num, 1 ); // Q31- exp -1 exp = add( exp, 1 ); } tmp = div_l( num, round_fx( den ) ); @@ -1725,13 +1725,13 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( { IF( GT_16( exp, 0 ) ) { - g = shr( g, exp ); + g = shr( g, exp ); // Q15- exp *mdctSpectrum_exp = hTonalMDCTConc->lastBlockData.spectralData_exp; move16(); } ELSE { - crossfadeGain = shl( crossfadeGain, exp ); + crossfadeGain = shl( crossfadeGain, exp ); // Q15 - e_crossfadeGain e_crossfadeGain = sub( e_crossfadeGain, exp ); *mdctSpectrum_exp = add( e_crossfadeGain, hTonalMDCTConc->lastBlockData.spectralData_exp ); move16(); @@ -1760,25 +1760,25 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( FOR( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ ) { - Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; + Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; // Q15 - spectralData_exp move16(); - Word32 y = concealment_noise[l]; + Word32 y = concealment_noise[l]; // Q31-concealment_noise_e move32(); IF( g > 0 ) { - L_tmp = Mpy_32_16_1( y, g ); + L_tmp = Mpy_32_16_1( y, g ); // Q31-concealment_noise_e- spectralData_exp } - L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); + L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp IF( y > 0 ) { - L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); + L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp } - mdctSpectrum[l] = L_shl( L_tmp2, exp ); + mdctSpectrum[l] = L_shl( L_tmp2, exp ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + exp move32(); - hTonalMDCTConc->faded_signal_nrg = L_add( hTonalMDCTConc->faded_signal_nrg, Mpy_32_32( mdctSpectrum[l], mdctSpectrum[l] ) ); + hTonalMDCTConc->faded_signal_nrg = L_add( hTonalMDCTConc->faded_signal_nrg, Mpy_32_32( mdctSpectrum[l], mdctSpectrum[l] ) ); // Q31 - 2*mdctSpectrum_exp move32(); } @@ -1786,41 +1786,41 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( { FOR( l = hTonalMDCTConc->pTCI->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI->lowerIndex[i]; l++ ) { - Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; + Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; // Q15 - spectralData_exp move16(); - Word32 y = concealment_noise[l]; + Word32 y = concealment_noise[l]; // Q31-concealment_noise_e move32(); L_tmp = Mpy_32_16_1( y, g ); - L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); + L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp IF( y > 0 ) { - L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); + L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp } - mdctSpectrum[l] = L_shl( L_tmp2, exp ); + mdctSpectrum[l] = L_shl( L_tmp2, exp ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + exp move32(); - hTonalMDCTConc->faded_signal_nrg = L_add( hTonalMDCTConc->faded_signal_nrg, Mpy_32_32( mdctSpectrum[l], mdctSpectrum[l] ) ); + hTonalMDCTConc->faded_signal_nrg = L_add( hTonalMDCTConc->faded_signal_nrg, Mpy_32_32( mdctSpectrum[l], mdctSpectrum[l] ) ); // Q31- 2*mdctSpectrum_exp } } FOR( l = hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1] + 1; l < crossOverFreq; l++ ) { - Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; + Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; // Q15 - spectralData_exp move16(); - Word32 y = concealment_noise[l]; + Word32 y = concealment_noise[l]; // Q31-concealment_noise_e move32(); - L_tmp = Mpy_32_16_1( y, g ); - L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); + L_tmp = Mpy_32_16_1( y, g ); // Q31-concealment_noise_e- spectralData_exp + L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp IF( y > 0 ) { - L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); + L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp } - mdctSpectrum[l] = L_shl( L_tmp2, exp ); + mdctSpectrum[l] = L_shl( L_tmp2, exp ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + exp move32(); - hTonalMDCTConc->faded_signal_nrg = L_add( hTonalMDCTConc->faded_signal_nrg, Mpy_32_32( mdctSpectrum[l], mdctSpectrum[l] ) ); + hTonalMDCTConc->faded_signal_nrg = L_add( hTonalMDCTConc->faded_signal_nrg, Mpy_32_32( mdctSpectrum[l], mdctSpectrum[l] ) ); // Q31- 2*mdctSpectrum_exp move32(); } @@ -1845,26 +1845,26 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( Word16 num_exp, den_exp; Word32 num, den; - num = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->last_block_nrg, hTonalMDCTConc->last_block_nrg_exp, L_negate( last_block_nrg_correct ), last_block_nrg_correct_e, &num_exp ); + num = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->last_block_nrg, hTonalMDCTConc->last_block_nrg_exp, L_negate( last_block_nrg_correct ), last_block_nrg_correct_e, &num_exp ); // Q31-num_exp - den = hTonalMDCTConc->faded_signal_nrg; + den = hTonalMDCTConc->faded_signal_nrg; // Q31 - hTonalMDCTConc->faded_signal_nrg_exp move32(); den_exp = hTonalMDCTConc->faded_signal_nrg_exp; move16(); ld = norm_l( num ); - num = L_shl( num, ld ); + num = L_shl( num, ld ); // Q31-num_exp + ld num_exp = sub( num_exp, ld ); ld = norm_l( den ); - den = L_shl( den, ld ); + den = L_shl( den, ld ); // Q31-den_exp + ld den_exp = sub( den_exp, ld ); exp = sub( num_exp, den_exp ); IF( GT_32( num, den ) ) { - num = L_shr( num, 1 ); + num = L_shr( num, 1 ); // Q31- exp -1 exp = add( exp, 1 ); } tmp = div_l( num, round_fx( den ) ); @@ -1872,7 +1872,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( FOR( i = 0; i < crossOverFreq; i++ ) { - mdctSpectrum[i] = Mpy_32_16_1( mdctSpectrum[i], tmp ); + mdctSpectrum[i] = Mpy_32_16_1( mdctSpectrum[i], tmp ); // Q31-(*mdctSpectrum_exp+exp) move32(); } *mdctSpectrum_exp = add( *mdctSpectrum_exp, exp ); @@ -1914,20 +1914,20 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( IF( nrgWhiteNoise > 0 ) { ld = norm_l( nrgNoiseInLastFrame ); - nrgNoiseInLastFrame = L_shl( nrgNoiseInLastFrame, ld ); + nrgNoiseInLastFrame = L_shl( nrgNoiseInLastFrame, ld ); // Q31- exp_last + ld exp_last = sub( exp_last, ld ); ld = norm_l( nrgWhiteNoise ); - nrgWhiteNoise = L_shl( nrgWhiteNoise, ld ); + nrgWhiteNoise = L_shl( nrgWhiteNoise, ld ); // Q31 - exp_noise + ld exp_noise = sub( exp_noise, ld ); exp = sub( exp_last, exp_noise ); IF( GT_32( nrgNoiseInLastFrame, nrgWhiteNoise ) ) { - nrgNoiseInLastFrame = L_shr( nrgNoiseInLastFrame, 1 ); + nrgNoiseInLastFrame = L_shr( nrgNoiseInLastFrame, 1 ); // Q31-exp -1 exp = add( exp, 1 ); } - tmp = div_l( nrgNoiseInLastFrame, round_fx( nrgWhiteNoise ) ); + tmp = div_l( nrgNoiseInLastFrame, round_fx( nrgWhiteNoise ) ); // Q15 tmp = Sqrt16( tmp, &exp ); g = mult_r( g, tmp ); // exponent of g = exp @@ -1937,13 +1937,13 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( IF( exp > 0 ) { - g = shr( g, exp ); + g = shr( g, exp ); // Q15 - exp *mdctSpectrum_exp = hTonalMDCTConc->lastBlockData.spectralData_exp; move16(); } ELSE { - crossfadeGain = shl( crossfadeGain, exp ); + crossfadeGain = shl( crossfadeGain, exp ); // Q15-e_crossfadeGain+ exp e_crossfadeGain = sub( e_crossfadeGain, exp ); *mdctSpectrum_exp = add( e_crossfadeGain, hTonalMDCTConc->lastBlockData.spectralData_exp ); move16(); @@ -1964,29 +1964,29 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( } FOR( i = 0; i < crossOverFreq; i++ ) { - Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[i]; + Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[i]; // Q15 - spectralData_exp move16(); - Word32 const y = mdctSpectrum[i]; + Word32 const y = mdctSpectrum[i]; // Q31-mdctSpectrum_exp move32(); IF( g > 0 ) { - L_tmp = Mpy_32_16_1( y, g ); + L_tmp = Mpy_32_16_1( y, g ); // Q31-mdctSpectrum_exp- spectralData_exp } - L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); + L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp IF( GT_32( y, 0 ) ) { - L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); + L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp } - mdctSpectrum[i] = L_shl( L_tmp2, exp ); + mdctSpectrum[i] = L_shl( L_tmp2, exp ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + exp move32(); } } exp = sub( hTonalMDCTConc->lastBlockData.spectralData_exp, sub( *mdctSpectrum_exp, 16 ) ); FOR( i = crossOverFreq; i < hTonalMDCTConc->lastBlockData.nSamples; i++ ) { - mdctSpectrum[i] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[i] ), exp ); + mdctSpectrum[i] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[i] ), exp ); // Q15 - spectralData_exp + exp move32(); } } @@ -2002,12 +2002,12 @@ ELSE fac = shr( -32768, ld ); FOR( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ ) { - Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; + Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; // Q15 - spectralData_exp move16(); Word32 y; - rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); - y = L_mult( tilt, rnd ); // 15Q16 + rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); // Q0 + y = L_mult( tilt, rnd ); // 15Q16 nrgNoiseInLastFrame = L_add( nrgNoiseInLastFrame, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // Q(31 - x_exp - ld) + Q(15 - x_exp) - 15 = Q(31 - x_exp * 2 - ld) x = round_fx( y ); // 15Q16 -> Q15 @@ -2036,12 +2036,12 @@ ELSE } FOR( l = hTonalMDCTConc->pTCI->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI->lowerIndex[i]; l++ ) { - Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; + Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; // Q15 - spectralData_exp move16(); Word32 y; - rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); - y = L_mult( tilt, rnd ); + rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); // Q0 + y = L_mult( tilt, rnd ); // 15Q16 nrgNoiseInLastFrame = L_add( nrgNoiseInLastFrame, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // Q(31 - hTonalMDCTConc->lastBlockData.spectralData_exp * 2 - ld) x = round_fx( y ); // Q15 @@ -2067,20 +2067,20 @@ ELSE FOR( l = add( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1], 1 ); l < crossOverFreq; l++ ) { - Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; + Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; // Q15 - spectralData_exp move16(); Word32 y; - rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); - y = L_mult( tilt, rnd ); + rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); // Q0 + y = L_mult( tilt, rnd ); // 15Q16 - nrgNoiseInLastFrame = L_add( nrgNoiseInLastFrame, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); - x = round_fx( y ); - nrgWhiteNoise = L_add( nrgWhiteNoise, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); + nrgNoiseInLastFrame = L_add( nrgNoiseInLastFrame, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // Q(31 - hTonalMDCTConc->lastBlockData.spectralData_exp * 2 - ld) + x = round_fx( y ); // Q15 + nrgWhiteNoise = L_add( nrgWhiteNoise, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // Q(1 - ld) mdctSpectrum[l] = y; /* 15Q16 L_deposit_l(y);*/ move32(); - tilt = mult_r( tilt, tiltFactor ); + tilt = mult_r( tilt, tiltFactor ); // Q15 } IF( EQ_32( nrgNoiseInLastFrame, 0 ) ) @@ -2095,17 +2095,17 @@ ELSE exp_noise = add( ld, shl( 15, 1 ) ); ld = norm_l( nrgNoiseInLastFrame ); - nrgNoiseInLastFrame = L_shl( nrgNoiseInLastFrame, ld ); + nrgNoiseInLastFrame = L_shl( nrgNoiseInLastFrame, ld ); // Q31-exp_last+ld exp_last = sub( exp_last, ld ); ld = norm_l( nrgWhiteNoise ); - nrgWhiteNoise = L_shl( nrgWhiteNoise, ld ); + nrgWhiteNoise = L_shl( nrgWhiteNoise, ld ); // Q31 - exp_noise + ld exp_noise = sub( exp_noise, ld ); exp = sub( exp_last, exp_noise ); IF( GT_32( nrgNoiseInLastFrame, nrgWhiteNoise ) ) { - nrgNoiseInLastFrame = L_shr( nrgNoiseInLastFrame, 1 ); + nrgNoiseInLastFrame = L_shr( nrgNoiseInLastFrame, 1 ); // Q31 - Qexp -1 exp = add( exp, 1 ); } tmp = div_l( nrgNoiseInLastFrame, extract_h( nrgWhiteNoise ) ); @@ -2117,7 +2117,7 @@ ELSE exp = sub( ld, exp ); IF( exp > 0 ) { - g = shr( g, exp ); + g = shr( g, exp ); // Q15 - exp *mdctSpectrum_exp = hTonalMDCTConc->lastBlockData.spectralData_exp; move16(); } @@ -2144,22 +2144,22 @@ ELSE FOR( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ ) { - Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; + Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; // Q15 - spectralData_exp move16(); - Word32 const y = mdctSpectrum[l]; + Word32 const y = mdctSpectrum[l]; // Q31-mdctSpectrum_exp move32(); - IF( GT_16( g, 0 ) ) + IF( g > 0 ) { - L_tmp = Mpy_32_16_1( y, g ); + L_tmp = Mpy_32_16_1( y, g ); // Q31-mdctSpectrum_exp- spectralData_exp } - L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); - IF( GT_32( y, 0 ) ) + L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + IF( y > 0 ) { - L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); + L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp } - mdctSpectrum[l] = L_shl( L_tmp2, exp ); + mdctSpectrum[l] = L_shl( L_tmp2, exp ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + exp move32(); } @@ -2167,22 +2167,22 @@ ELSE { FOR( l = hTonalMDCTConc->pTCI->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI->lowerIndex[i]; l++ ) { - Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; + Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; // Q15 - spectralData_exp move16(); - Word32 const y = mdctSpectrum[l]; + Word32 const y = mdctSpectrum[l]; // Q31-mdctSpectrum_exp move32(); - IF( GT_16( g, 0 ) ) + IF( g > 0 ) { - L_tmp = Mpy_32_16_1( y, g ); + L_tmp = Mpy_32_16_1( y, g ); // Q31-mdctSpectrum_exp- spectralData_exp } - L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); - IF( GT_32( y, 0 ) ) + L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + IF( y > 0 ) { - L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); + L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp } - mdctSpectrum[l] = L_shl( L_tmp2, exp ); + mdctSpectrum[l] = L_shl( L_tmp2, exp ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + exp move32(); } } @@ -2202,29 +2202,29 @@ ELSE FOR( l = add( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1], 1 ); l < crossOverFreq; l++ ) { - Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; + Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; // Q15 - spectralData_exp move16(); - Word32 const y = mdctSpectrum[l]; + Word32 const y = mdctSpectrum[l]; // Q31-mdctSpectrum_exp move32(); IF( GT_16( g, 0 ) ) { - L_tmp = Mpy_32_16_1( y, g ); + L_tmp = Mpy_32_16_1( y, g ); // Q31-mdctSpectrum_exp- spectralData_exp } - L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); + L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp IF( GT_32( y, 0 ) ) { - L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); + L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp } - mdctSpectrum[l] = L_shl( L_tmp2, exp ); + mdctSpectrum[l] = L_shl( L_tmp2, exp ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + exp move32(); } } exp = sub( hTonalMDCTConc->lastBlockData.spectralData_exp, sub( *mdctSpectrum_exp, 16 ) ); FOR( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ ) { - mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), exp ); + mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), exp ); // Q15 - spectralData_exp move32(); } } @@ -2241,12 +2241,12 @@ return; void TonalMDCTConceal_InsertNoise( const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, /*OUT*/ + Word32 *mdctSpectrum, // Q31- *mdctSpectrum_exp /*OUT*/ Word16 *mdctSpectrum_exp, /*OUT*/ const Word16 tonalConcealmentActive, - Word16 *pSeed, /*IN/OUT*/ - const Word16 tiltCompFactor, - Word16 crossfadeGain, + Word16 *pSeed, /*IN/OUT*/ + const Word16 tiltCompFactor, // Q15 + Word16 crossfadeGain, // Q15 #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT const Word16concealment_noise[L_FRAME48k], const float cngLevelBackgroundTrace_bfi, @@ -2488,7 +2488,7 @@ void TonalMDCTConceal_InsertNoise( tiltFactor = round_fx( BASOP_Util_fPow( L_max( L_tmp, L_deposit_h( tiltCompFactor ) ), 0, L_deposit_h( inv_samples ), inv_exp, &exp ) ); BASOP_SATURATE_WARNING_OFF_EVS /*next op may result in 32768*/ #ifdef BASOP_NOGLOB - tiltFactor = shl_sat( tiltFactor, exp ); + tiltFactor = shl_sat( tiltFactor, exp ); // Q15- 2*exp #else tiltFactor = shl( tiltFactor, exp ); #endif @@ -2510,20 +2510,20 @@ void TonalMDCTConceal_InsertNoise( FOR( i = 0; i < crossOverFreq; i++ ) { - Word16 x = hTonalMDCTConc->lastBlockData.spectralData[i]; + Word16 x = hTonalMDCTConc->lastBlockData.spectralData[i]; // Q15 - spectralData_exp move16(); Word32 y; - rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); - y = L_mult( tilt, rnd ); + rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); // Q0 + y = L_mult( tilt, rnd ); /* 15Q16 */ - nrgNoiseInLastFrame = L_add( nrgNoiseInLastFrame, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); - x = round_fx( y ); - nrgWhiteNoise = L_add( nrgWhiteNoise, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); + nrgNoiseInLastFrame = L_add( nrgNoiseInLastFrame, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // Q(31 - hTonalMDCTConc->lastBlockData.spectralData_exp * 2 - ld) + x = round_fx( y ); // Q15 + nrgWhiteNoise = L_add( nrgWhiteNoise, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // Q(1 - ld) mdctSpectrum[i] = y; /* 15Q16 */ move32(); - tilt = mult_r( tilt, tiltFactor ); + tilt = mult_r( tilt, tiltFactor ); // Q15 } IF( nrgNoiseInLastFrame == 0 ) @@ -2540,17 +2540,17 @@ void TonalMDCTConceal_InsertNoise( IF( nrgWhiteNoise > 0 ) { ld = norm_l( nrgNoiseInLastFrame ); - nrgNoiseInLastFrame = L_shl( nrgNoiseInLastFrame, ld ); + nrgNoiseInLastFrame = L_shl( nrgNoiseInLastFrame, ld ); // Q31-exp_last + ld exp_last = sub( exp_last, ld ); ld = norm_l( nrgWhiteNoise ); - nrgWhiteNoise = L_shl( nrgWhiteNoise, ld ); + nrgWhiteNoise = L_shl( nrgWhiteNoise, ld ); // Q31-exp_noise + ld exp_noise = sub( exp_noise, ld ); exp = sub( exp_last, exp_noise ); IF( GT_32( nrgNoiseInLastFrame, nrgWhiteNoise ) ) { - nrgNoiseInLastFrame = L_shr( nrgNoiseInLastFrame, 1 ); + nrgNoiseInLastFrame = L_shr( nrgNoiseInLastFrame, 1 ); // Q31- exp - 1 exp = add( exp, 1 ); } tmp = div_l( nrgNoiseInLastFrame, round_fx( nrgWhiteNoise ) ); @@ -2591,27 +2591,27 @@ void TonalMDCTConceal_InsertNoise( { Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[i]; move16(); - Word32 const y = mdctSpectrum[i]; + Word32 const y = mdctSpectrum[i]; // Q31-mdctSpectrum_exp move32(); if ( g > 0 ) { - L_tmp = Mpy_32_16_1( y, g ); + L_tmp = Mpy_32_16_1( y, g ); // Q31-mdctSpectrum_exp- spectralData_exp } - L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); + L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp if ( y > 0 ) { - L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); + L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp } - mdctSpectrum[i] = L_shl( L_tmp2, exp ); + mdctSpectrum[i] = L_shl( L_tmp2, exp ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + exp move32(); } } exp = sub( hTonalMDCTConc->lastBlockData.spectralData_exp, sub( *mdctSpectrum_exp, 16 ) ); FOR( i = crossOverFreq; i < hTonalMDCTConc->lastBlockData.nSamples; i++ ) { - mdctSpectrum[i] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[i] ), exp ); + mdctSpectrum[i] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[i] ), exp ); // Q15 - spectralData_exp + exp move32(); } } @@ -2630,20 +2630,20 @@ void TonalMDCTConceal_InsertNoise( fac = shr( -32768, ld ); FOR( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ ) { - Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; + Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; // Q15 - spectralData_exp move16(); Word32 y; - rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); - y = L_mult( tilt, rnd ); + rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); // Q0 + y = L_mult( tilt, rnd ); // 15Q16 - nrgNoiseInLastFrame = L_add( nrgNoiseInLastFrame, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); - x = round_fx( y ); - nrgWhiteNoise = L_add( nrgWhiteNoise, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); + nrgNoiseInLastFrame = L_add( nrgNoiseInLastFrame, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // Q(31 - hTonalMDCTConc->lastBlockData.spectralData_exp * 2 - ld) + x = round_fx( y ); // Q15 + nrgWhiteNoise = L_add( nrgWhiteNoise, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // Q(1-ld) mdctSpectrum[l] = y; /* 15Q16 L_deposit_l(y);*/ move32(); - tilt = mult_r( tilt, tiltFactor ); + tilt = mult_r( tilt, tiltFactor ); // Q15 } FOR( i = 1; i < hTonalMDCTConc->pTCI->numIndexes; i++ ) @@ -2661,27 +2661,27 @@ void TonalMDCTConceal_InsertNoise( FOR( l = hTonalMDCTConc->pTCI->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI->lowerIndex[i]; l++ ) { - Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; + Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; // Q15 - spectralData_exp move16(); Word32 y; - rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); - y = L_mult( tilt, rnd ); + rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); // Q0 + y = L_mult( tilt, rnd ); // 15Q16 - nrgNoiseInLastFrame = L_add( nrgNoiseInLastFrame, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); - x = round_fx( y ); - nrgWhiteNoise = L_add( nrgWhiteNoise, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); + nrgNoiseInLastFrame = L_add( nrgNoiseInLastFrame, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // Q(31 - hTonalMDCTConc->lastBlockData.spectralData_exp * 2 - ld) + x = round_fx( y ); // Q15 + nrgWhiteNoise = L_add( nrgWhiteNoise, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // Q(1-ld) mdctSpectrum[l] = y; /* 15Q16 L_deposit_l(y);*/ move32(); - tilt = mult_r( tilt, tiltFactor ); + tilt = mult_r( tilt, tiltFactor ); // Q15 } } tmp = round_fx( BASOP_Util_fPow( L_deposit_h( tiltFactor ), 0, L_deposit_h( (UWord16) L_add( L_sub( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1], hTonalMDCTConc->pTCI->lowerIndex[hTonalMDCTConc->pTCI->numIndexes - 1] ), 1 ) ), 15, &exp ) ); BASOP_SATURATE_WARNING_OFF_EVS /*next op may result in 32768*/ #ifdef BASOP_NOGLOB - tmp = shl_sat( tmp, exp ); + tmp = shl_sat( tmp, exp ); // Q15 - 2*exp #else tmp = shl( tmp, exp ); #endif @@ -2690,20 +2690,20 @@ void TonalMDCTConceal_InsertNoise( FOR( l = add( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1], 1 ); l < crossOverFreq; l++ ) { - Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; + Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; // Q15 - spectralData_exp move16(); Word32 y; - rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); - y = L_mult( tilt, rnd ); + rnd = extract_l( L_mac0( 13849, rnd, 31821 ) ); // Q0 + y = L_mult( tilt, rnd ); // 15Q16 - nrgNoiseInLastFrame = L_add( nrgNoiseInLastFrame, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); - x = round_fx( y ); - nrgWhiteNoise = L_add( nrgWhiteNoise, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); + nrgNoiseInLastFrame = L_add( nrgNoiseInLastFrame, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // Q(31 - hTonalMDCTConc->lastBlockData.spectralData_exp * 2 - ld) + x = round_fx( y ); // Q15 + nrgWhiteNoise = L_add( nrgWhiteNoise, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // Q(1-ld) mdctSpectrum[l] = y; /* 15Q16 L_deposit_l(y);*/ move32(); - tilt = mult_r( tilt, tiltFactor ); + tilt = mult_r( tilt, tiltFactor ); // Q15 } IF( nrgNoiseInLastFrame == 0 ) @@ -2718,17 +2718,17 @@ void TonalMDCTConceal_InsertNoise( exp_noise = add( ld, shl( 15, 1 ) ); ld = norm_l( nrgNoiseInLastFrame ); - nrgNoiseInLastFrame = L_shl( nrgNoiseInLastFrame, ld ); + nrgNoiseInLastFrame = L_shl( nrgNoiseInLastFrame, ld ); // Q31 - exp_last + ld exp_last = sub( exp_last, ld ); ld = norm_l( nrgWhiteNoise ); - nrgWhiteNoise = L_shl( nrgWhiteNoise, ld ); + nrgWhiteNoise = L_shl( nrgWhiteNoise, ld ); // Q31 - exp_last + ld exp_noise = sub( exp_noise, ld ); exp = sub( exp_last, exp_noise ); IF( GT_32( nrgNoiseInLastFrame, nrgWhiteNoise ) ) { - nrgNoiseInLastFrame = L_shr( nrgNoiseInLastFrame, 1 ); + nrgNoiseInLastFrame = L_shr( nrgNoiseInLastFrame, 1 ); // Q31 - exp -1 exp = add( exp, 1 ); } tmp = div_l( nrgNoiseInLastFrame, round_fx( nrgWhiteNoise ) ); @@ -2766,22 +2766,22 @@ void TonalMDCTConceal_InsertNoise( FOR( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ ) { - Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; + Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; // Q15 - spectralData_exp move16(); - Word32 const y = mdctSpectrum[l]; + Word32 const y = mdctSpectrum[l]; // Q31-mdctSpectrum_exp move32(); if ( g > 0 ) { - L_tmp = Mpy_32_16_1( y, g ); + L_tmp = Mpy_32_16_1( y, g ); // Q31-mdctSpectrum_exp- spectralData_exp } - L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); + L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp if ( y > 0 ) { - L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); + L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp } - mdctSpectrum[l] = L_shl( L_tmp2, exp ); + mdctSpectrum[l] = L_shl( L_tmp2, exp ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + exp move32(); } @@ -2789,22 +2789,22 @@ void TonalMDCTConceal_InsertNoise( { FOR( l = hTonalMDCTConc->pTCI->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI->lowerIndex[i]; l++ ) { - Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; + Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; // Q15 - spectralData_exp move16(); - Word32 const y = mdctSpectrum[l]; + Word32 const y = mdctSpectrum[l]; // Q31-mdctSpectrum_exp move32(); if ( g > 0 ) { - L_tmp = Mpy_32_16_1( y, g ); + L_tmp = Mpy_32_16_1( y, g ); // Q31-mdctSpectrum_exp- spectralData_exp } - L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); + L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp if ( y > 0 ) { - L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); + L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp } - mdctSpectrum[l] = L_shl( L_tmp2, exp ); + mdctSpectrum[l] = L_shl( L_tmp2, exp ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + exp move32(); } } @@ -2824,29 +2824,29 @@ void TonalMDCTConceal_InsertNoise( FOR( l = add( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1], 1 ); l < crossOverFreq; l++ ) { - Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; + Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; // Q15 - spectralData_exp move16(); - Word32 const y = mdctSpectrum[l]; + Word32 const y = mdctSpectrum[l]; // Q31-mdctSpectrum_exp move32(); if ( g > 0 ) { - L_tmp = Mpy_32_16_1( y, g ); + L_tmp = Mpy_32_16_1( y, g ); // Q31-mdctSpectrum_exp- spectralData_exp } - L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); + L_tmp2 = L_msu( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp if ( y > 0 ) { - L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); + L_tmp2 = L_mac( L_tmp, crossfadeGain, x ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp } - mdctSpectrum[l] = L_shl( L_tmp2, exp ); + mdctSpectrum[l] = L_shl( L_tmp2, exp ); // Q15 - e_crossfadeGain + Q15 - spectralData_exp + exp move32(); } } exp = sub( hTonalMDCTConc->lastBlockData.spectralData_exp, sub( *mdctSpectrum_exp, 16 ) ); FOR( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ ) { - mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), exp ); + mdctSpectrum[l] = L_shl( L_deposit_l( hTonalMDCTConc->lastBlockData.spectralData[l] ), exp ); // Q15 - spectralData_exp + exp move32(); } } @@ -2860,7 +2860,7 @@ void TonalMDCTConceal_InsertNoise( void TonalMDCTConceal_Apply( const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, /*IN/OUT*/ + Word32 *mdctSpectrum, // Q31-*mdctSpectrum_exp /*IN/OUT*/ Word16 *mdctSpectrum_exp /*IN */ #ifdef IVAS_CODE_MDCT_GSHAPE , @@ -2964,7 +2964,7 @@ void TonalMDCTConceal_Apply( #ifdef IVAS_FLOAT_FIXED void TonalMDCTConceal_Apply_ivas_fx( TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, /*IN/OUT*/ + Word32 *mdctSpectrum, // Q31-*mdctSpectrum_exp /*IN/OUT*/ Word16 mdctSpectrum_exp[L_FRAME_MAX], /*IN */ const PsychoacousticParameters *psychParamsCurrent ) @@ -2990,7 +2990,7 @@ void TonalMDCTConceal_Apply_ivas_fx( /* Creating 32-bit scaleFactors with common exponent. */ FOR( i = 0; i < FDNS_NPTS; i++ ) { - scaleFactors[i] = L_shr( L_deposit_h( hTonalMDCTConc->secondLastBlockData.scaleFactors[i] ), sub( hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e, hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i] ) ); + scaleFactors[i] = L_shr( L_deposit_h( hTonalMDCTConc->secondLastBlockData.scaleFactors[i] ), sub( hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e, hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i] ) ); // Q31- scaleFactors_max_e+scaleFactors_exp[i] move32(); } @@ -3004,7 +3004,7 @@ void TonalMDCTConceal_Apply_ivas_fx( FOR( i = 0; i < nSamples; i++ ) { - powerSpectrum[i] = L_deposit_h( tmp_secondLastPowerSpectrum[i] ); + powerSpectrum[i] = L_deposit_h( tmp_secondLastPowerSpectrum[i] ); // Q31 - secondLastPowerSpectrum_exp move16(); } powerSpectrum_exp = tmp_secondLastPowerSpectrum_exp; @@ -3030,7 +3030,7 @@ void TonalMDCTConceal_Apply_ivas_fx( q_ps = sub( q_ps, 1 ); FOR( Word16 c = 0; c < hTonalMDCTConc->nSamplesCore; c++ ) { - powerSpectrum[c] = L_shr( powerSpectrum[c], 1 ); + powerSpectrum[c] = L_shr( powerSpectrum[c], 1 ); // q_ps -1 move32(); } @@ -3038,7 +3038,7 @@ void TonalMDCTConceal_Apply_ivas_fx( q_sf = sub( q_sf, 1 ); FOR( Word16 c = 0; c < FDNS_NPTS; c++ ) { - scaleFactors[c] = L_shr( scaleFactors[c], 1 ); + scaleFactors[c] = L_shr( scaleFactors[c], 1 ); // q_sf - 1 move32(); } @@ -3057,7 +3057,7 @@ void TonalMDCTConceal_Apply_ivas_fx( FOR( Word16 c = hTonalMDCTConc->nSamplesCore; c < nSamples; c++ ) { - powerSpectrum[c] = Mpy_32_16_1( powerSpectrum[c], hTonalMDCTConc->secondLastBlockData.scaleFactors[nBands - 1] ); + powerSpectrum[c] = Mpy_32_16_1( powerSpectrum[c], hTonalMDCTConc->secondLastBlockData.scaleFactors[nBands - 1] ); // Q31 -(exp_right + scaleFactors_exp[]) move32(); } exp_right = add( exp_right, hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[nBands - 1] ); @@ -3071,12 +3071,12 @@ void TonalMDCTConceal_Apply_ivas_fx( test(); IF( GE_16( c, hTonalMDCTConc->nSamplesCore ) && LT_16( c, nSamples ) && GT_16( max_e, exp_right ) ) { - powerSpectrum[c] = L_shr( powerSpectrum[c], sub( max_e, exp_right ) ); + powerSpectrum[c] = L_shr( powerSpectrum[c], sub( max_e, exp_right ) ); // Q31-max_e move32(); } ELSE IF( ( LT_16( c, hTonalMDCTConc->nSamplesCore ) || GT_16( c, nSamples ) ) && GT_16( max_e, exp_left ) ) { - powerSpectrum[c] = L_shr( powerSpectrum[c], sub( max_e, exp_left ) ); + powerSpectrum[c] = L_shr( powerSpectrum[c], sub( max_e, exp_left ) ); // Q31-max_e move32(); } } @@ -3146,7 +3146,7 @@ void TonalMDCTConceal_Apply_ivas_fx( void TonalMDCTConceal_SaveTimeSignal( TonalMDCTConcealPtr hTonalMDCTConc, - Word16 *timeSignal, + Word16 *timeSignal, // Qx Word16 nNewSamples ) @@ -3164,13 +3164,13 @@ void TonalMDCTConceal_SaveTimeSignal( return; } static void CalcPowerSpec( - const Word32 *mdctSpec, /* i: MDCT spectrum Q31,mdctSpec_exp */ + const Word32 *mdctSpec, /* i: MDCT spectrum Q31-mdctSpec_exp */ const Word16 mdctSpec_exp, /* i: exponent of MDCT spectrum */ - const Word32 *mdstSpec, /* i: MDST spectrum Q31,mdstSpec_exp */ + const Word32 *mdstSpec, /* i: MDST spectrum Q31-mdstSpec_exp */ const Word16 mdstSpec_exp, /* i: exponent of MDST spectrum */ const Word16 nSamples, /* i: frame size */ const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins Q0 */ - Word32 *powerSpec, /* o: power spectrum */ + Word32 *powerSpec, /* o: power spectrum Q31- powerSpec_exp */ Word16 *powerSpec_exp ) /* o: exponent of power spectrum */ { Word16 k, s1, s2, tmp; diff --git a/lib_dec/transition_dec_fx.c b/lib_dec/transition_dec_fx.c index 73342e64c..ab6a76cac 100644 --- a/lib_dec/transition_dec_fx.c +++ b/lib_dec/transition_dec_fx.c @@ -37,19 +37,19 @@ static void tc_dec_fx( Decoder_State *st_fx, const Word16 L_frame, Word16 exc[], void transition_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 tc_subfr, /* i : TC subframe index */ - Word16 *Jopt_flag, /* i : joint optimization flag */ - Word16 *exc, /* o : excitation signal */ - Word16 *T0, /* o : close loop integer pitch */ - Word16 *T0_frac, /* o : close loop fractional part of the pitch */ - Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ - Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ - Word16 **pt_pitch, /* o : floating pitch values */ - Word16 *position, /* i/o: first glottal impulse position in frame */ - Word16 *bwe_exc, /* o : excitation for SWB TBE */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */ + const Word16 L_frame, /* i : length of the frame Q0 */ + const Word16 i_subfr, /* i : subframe index Q0 */ + const Word16 tc_subfr, /* i : TC subframe index Q0 */ + Word16 *Jopt_flag, /* i : joint optimization flag Q0*/ + Word16 *exc, /* o : excitation signal Q0 */ + Word16 *T0, /* o : close loop integer pitch Q0 */ + Word16 *T0_frac, /* o : close loop fractional part of the pitch Q0*/ + Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 Q0 */ + Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 Q0 */ + Word16 **pt_pitch, /* o : floating pitch values Q6 */ + Word16 *position, /* i/o: first glottal impulse position in frame Q0*/ + Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc */ Word16 *Q_exc /*i/o : scaling of excitation */ ) { @@ -110,8 +110,8 @@ void transition_dec_fx( /* glottal shape codebook contribution construction */ tc_dec_fx( st_fx, L_frame, exc, T0, T0_frac, i_subfr, tc_subfr, position, bwe_exc, Q_exc ); - **pt_pitch = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); - move16(); /* save subframe pitch values Q6 */ + **pt_pitch = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); // Q6 + move16(); /* save subframe pitch values Q6 */ *Jopt_flag = 1; move16(); @@ -620,14 +620,14 @@ void transition_dec_fx( static void tc_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 L_frame, /* i : length of the frame */ - Word16 exc[], /* o : glottal codebook contribution */ - Word16 *T0, /* o : close-loop pitch period */ - Word16 *T0_frac, /* o : close-loop pitch period - fractional part */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 tc_subfr, /* i : TC subframe index */ - Word16 *position, /* o : first glottal impulse position in frame */ - Word16 bwe_exc[], /* o : excitation for SWB TBE */ + const Word16 L_frame, /* i : length of the frame Q0*/ + Word16 exc[], /* o : glottal codebook contribution Q0*/ + Word16 *T0, /* o : close-loop pitch period Q0 */ + Word16 *T0_frac, /* o : close-loop pitch period - fractional part Q0 */ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 tc_subfr, /* i : TC subframe index Q0 */ + Word16 *position, /* o : first glottal impulse position in frame Q0*/ + Word16 bwe_exc[], /* o : excitation for SWB TBE Q_exc */ Word16 *Q_exc /*i/o : scaling of excitation */ ) { @@ -829,9 +829,9 @@ return; * TC subframe classification decoding *-------------------------------------------------------------------*/ -Word16 tc_classif_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 L_frame /* i : length of the frame */ +Word16 tc_classif_fx( /*o: Q0*/ + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 L_frame /* i : length of the frame Q0 */ ) { Word16 tc_subfr, indice; diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index 4c8df0899..d21bde643 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -17,14 +17,14 @@ *-------------------------------------------------------------------*/ void updt_dec_fx( Decoder_State *st_fx, /* i/o: state structure */ - const Word16 *old_exc_fx, /* i : buffer of excitation */ - const Word16 *pitch_buf_fx, /* i : fixed point pitch values for each subframe */ - const Word16 Es_pred, /* i : predicited scaled innovation energy */ - const Word16 *Aq, /* i : A(z) quantized for all subframes */ - const Word16 *lsf_new_fx, /* i : current frame LSF vector */ - const Word16 *lsp_new_fx, /* i : current frame LSP vector */ - const Word16 voice_factors[], /* i : voicing factors */ - const Word16 *old_bwe_exc_fx, /* i : buffer of excitation */ + const Word16 *old_exc_fx, /* i : buffer of excitation Q_exc */ + const Word16 *pitch_buf_fx, /* i : fixed point pitch values for each subframe Q6*/ + const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ + const Word16 *Aq, /* i : A(z) quantized for all subframes Q12 */ + const Word16 *lsf_new_fx, /* i : current frame LSF vector Qlog2(2.56)*/ + const Word16 *lsp_new_fx, /* i : current frame LSP vector Q15*/ + const Word16 voice_factors[], /* i : voicing factors Q15*/ + const Word16 *old_bwe_exc_fx, /* i : buffer of excitation Q_syn*/ const Word16 *gain_buf /* i : fixed point pitch gain for each subframe Q14*/ ) { @@ -85,7 +85,7 @@ void updt_dec_fx( /* overwrite previous coding type to help FEC */ st_fx->last_coder_type = UNVOICED; move16(); - st_fx->last_voice_factor_fx = voice_factors[NB_SUBFR - 1]; + st_fx->last_voice_factor_fx = voice_factors[NB_SUBFR - 1]; // Q15 move16(); } @@ -131,32 +131,32 @@ void updt_dec_fx( Copy32( &st_fx->old_pitch_buf_fx[len], st_fx->old_pitch_buf_fx, len ); FOR( i = 0; i < len; i++ ) { - st_fx->old_pitch_buf_fx[len + i] = L_mult0( pitch_buf_fx[i], 1 << 10 ); + st_fx->old_pitch_buf_fx[len + i] = L_mult0( pitch_buf_fx[i], 1 << 10 ); /* 15Q16 */ move32(); } Copy( &st_fx->mem_pitch_gain[2], &st_fx->mem_pitch_gain[add( st_fx->L_frame / L_SUBFR, 2 )], st_fx->L_frame / L_SUBFR ); IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { - st_fx->mem_pitch_gain[2] = gain_buf[3]; + st_fx->mem_pitch_gain[2] = gain_buf[3]; // Q14 move16(); - st_fx->mem_pitch_gain[3] = gain_buf[2]; + st_fx->mem_pitch_gain[3] = gain_buf[2]; // Q14 move16(); - st_fx->mem_pitch_gain[4] = gain_buf[1]; + st_fx->mem_pitch_gain[4] = gain_buf[1]; // Q14 move16(); - st_fx->mem_pitch_gain[5] = gain_buf[0]; + st_fx->mem_pitch_gain[5] = gain_buf[0]; // Q14 move16(); } ELSE { - st_fx->mem_pitch_gain[2] = gain_buf[4]; + st_fx->mem_pitch_gain[2] = gain_buf[4]; // Q14 move16(); - st_fx->mem_pitch_gain[3] = gain_buf[3]; + st_fx->mem_pitch_gain[3] = gain_buf[3]; // Q14 move16(); - st_fx->mem_pitch_gain[4] = gain_buf[2]; + st_fx->mem_pitch_gain[4] = gain_buf[2]; // Q14 move16(); - st_fx->mem_pitch_gain[5] = gain_buf[1]; + st_fx->mem_pitch_gain[5] = gain_buf[1]; // Q14 move16(); - st_fx->mem_pitch_gain[6] = gain_buf[0]; + st_fx->mem_pitch_gain[6] = gain_buf[0]; // Q14 move16(); } @@ -268,7 +268,7 @@ void updt_IO_switch_dec_fx( fb_tbe_reset_synth_fx( hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, &hBWE_TD->prev_fbbwe_ratio_fx ); } hBWE_FD->prev_Energy_wb_fx = L_deposit_l( 0 ); - hBWE_FD->prev_weight_fx = 6554; + hBWE_FD->prev_weight_fx = 6554; /*0.2 in Q15*/ move16(); } @@ -294,7 +294,7 @@ void updt_IO_switch_dec_fx( /* reset the unvoiced/audio signal improvement memories */ if ( st_fx->hGSCDec != NULL ) { - st_fx->hGSCDec->seed_tcx = 15687; + st_fx->hGSCDec->seed_tcx = 15687; // Q0 move16(); } st_fx->hAmrwb_IO->UV_cnt_fx = 30; @@ -396,22 +396,22 @@ void updt_IO_switch_dec_fx( void updt_bw_switching_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *synth, /* i : fixed point synthesis signal */ + const Word16 *synth, /* i : fixed point synthesis signal Qpost */ const Word16 Qpost ) { test(); IF( EQ_32( st_fx->output_Fs, 32000 ) && EQ_16( st_fx->bwidth, SWB ) ) { #ifdef BASOP_NOGLOB - st_fx->tilt_swb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( synth, Qpost, L_FRAME32k ), 3 ) ); + st_fx->tilt_swb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( synth, Qpost, L_FRAME32k ), 3 ) ); // Q27 - 16 = Q11 #else st_fx->tilt_swb_fx = round_fx( L_shl( calc_tilt_bwe_fx( synth, Qpost, L_FRAME32k ), 3 ) ); #endif } - st_fx->prev_enerLH_fx = st_fx->enerLH_fx; + st_fx->prev_enerLH_fx = st_fx->enerLH_fx; // enerLH_fx_Q move32(); - st_fx->prev_enerLL_fx = st_fx->enerLL_fx; + st_fx->prev_enerLL_fx = st_fx->enerLL_fx; // enerLL_fx_Q move32(); st_fx->last_bwidth = st_fx->bwidth; move32(); @@ -453,7 +453,7 @@ void updt_dec_common_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 hq_core_type_fx, /* i : HQ core type */ const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word16 *synth, /* i : decoded synthesis */ + const Word16 *synth, /* i : decoded synthesis Qpostd */ const Word16 Qpostd /* i : Synthesis Q value */ ) @@ -771,7 +771,7 @@ void updt_dec_common_fx( #ifdef IVAS_FLOAT_FIXED static void ivas_updt_bw_switching_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 *synth, /* i : fixed point synthesis signal */ + const Word32 *synth, /* i : fixed point synthesis signal Qpost */ const Word16 Qpost ) { test(); @@ -784,9 +784,9 @@ static void ivas_updt_bw_switching_fx( #endif } - st_fx->prev_enerLH_fx = st_fx->enerLH_fx; + st_fx->prev_enerLH_fx = st_fx->enerLH_fx; // enerLH_fx_Q move32(); - st_fx->prev_enerLL_fx = st_fx->enerLL_fx; + st_fx->prev_enerLL_fx = st_fx->enerLL_fx; // enerLL_fx_Q move32(); st_fx->last_bwidth = st_fx->bwidth; move32(); @@ -818,13 +818,13 @@ static void ivas_updt_bw_switching_fx( return; } -static Word32 sum_32_32_fx( const Word32 *x, Word16 length ) +static Word32 sum_32_32_fx( const Word32 *x, Word16 length ) // Qx { Word64 sum = 0; Word16 i; FOR( i = 0; i < length; i++ ) { - sum = W_add( sum, W_mult_32_32( x[i], x[i] ) ); + sum = W_add( sum, W_mult_32_32( x[i], x[i] ) ); // 2*Qx -1 } return W_round64_L( sum ); } @@ -833,7 +833,7 @@ void ivas_updt_dec_common_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 hq_core_type_fx, /* i : HQ core type */ const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word32 *synth, /* i : decoded synthesis Q(Qpostd) */ + const Word32 *synth, /* i : decoded synthesis Qpostd */ const Word16 Qpostd /* i : Synthesis Q value */ ) @@ -996,22 +996,22 @@ void ivas_updt_dec_common_fx( Word16 q_div = sub( Q31, shl( Qpostd, 1 ) ); Word16 output_frame = NS2SA_FX2( st_fx->output_Fs, FRAME_SIZE_NS ); move16(); - Word32 sum_val = sum_32_32_fx( synth, output_frame ); + Word32 sum_val = sum_32_32_fx( synth, output_frame ); // 2*Q_syn -1 Word32 div_val = BASOP_Util_Divide3232_Scale( sum_val, output_frame, &q_div ); Word32 log_energy = L_add( L_shl( L_deposit_l( add( q_div, sub( Q31, shl( Qpostd, 1 ) ) ) ), Q15 ), - L_shr( BASOP_Util_Log2( L_shl( L_add( div_val, EPSILON_FX ), Q16 ) ), Q10 ) ); - Word32 log_energy_diff = L_abs( L_sub( st_fx->log_energy_old_fx, log_energy ) ); - st_fx->log_energy_old_fx = log_energy; + L_shr( BASOP_Util_Log2( L_shl( L_add( div_val, EPSILON_FX ), Q16 ) ), Q10 ) ); // Q15 + Word32 log_energy_diff = L_abs( L_sub( st_fx->log_energy_old_fx, log_energy ) ); // Q15 + st_fx->log_energy_old_fx = log_energy; // Q15 move32(); - st_fx->log_energy_diff_lt_fx = Madd_32_16( Mpy_32_16_1( log_energy_diff, ENV_SMOOTH_FAC_FX ), st_fx->log_energy_diff_lt_fx, sub( MAX_16, ENV_SMOOTH_FAC_FX ) ); + st_fx->log_energy_diff_lt_fx = Madd_32_16( Mpy_32_16_1( log_energy_diff, ENV_SMOOTH_FAC_FX ), st_fx->log_energy_diff_lt_fx, sub( MAX_16, ENV_SMOOTH_FAC_FX ) ); // Q15 IF( EQ_16( st_fx->core, HQ_CORE ) ) { - st_fx->stab_fac_fx = extract_l( L_min( MAX_16, L_add( L_shr( STAB_FAC_EST1_FX, Q15 ), Madd_32_32( Mpy_32_16_1( STAB_FAC_EST2_FX, st_fx->hHQ_core->mem_env_delta ), STAB_FAC_EST3_FX, st_fx->log_energy_diff_lt_fx ) ) ) ); - st_fx->stab_fac_fx = s_max( 0, st_fx->stab_fac_fx ); + st_fx->stab_fac_fx = extract_l( L_min( MAX_16, L_add( L_shr( STAB_FAC_EST1_FX, Q15 ), Madd_32_32( Mpy_32_16_1( STAB_FAC_EST2_FX, st_fx->hHQ_core->mem_env_delta ), STAB_FAC_EST3_FX, st_fx->log_energy_diff_lt_fx ) ) ) ); // Q15 + st_fx->stab_fac_fx = s_max( 0, st_fx->stab_fac_fx ); // Q15 } st_fx->stab_fac_smooth_lt_fx = extract_h( L_add( L_mult( ENV_SMOOTH_FAC_FX, st_fx->stab_fac_fx ), - L_mult( sub( MAX_16, ENV_SMOOTH_FAC_FX ), st_fx->stab_fac_smooth_lt_fx ) ) ); + L_mult( sub( MAX_16, ENV_SMOOTH_FAC_FX ), st_fx->stab_fac_smooth_lt_fx ) ) ); // Q15 } #endif @@ -1209,9 +1209,10 @@ void ivas_updt_dec_common_fx( void update_decoder_LPD_cng( Decoder_State *st, Word16 coder_type, - Word16 *timeDomainBuffer, - Word16 *A, - Word16 *bpf_noise_buf ) + Word16 *timeDomainBuffer, /*QtimeDomainBuffer*/ + Word16 *A, /*Q12*/ + Word16 *bpf_noise_buf /*Qbpf_noise_buf*/ +) { Word16 i; Word16 lsp[M], lsf[M]; diff --git a/lib_dec/vlpc_1st_dec_fx.c b/lib_dec/vlpc_1st_dec_fx.c index ad2c3fc2c..cd79792c2 100644 --- a/lib_dec/vlpc_1st_dec_fx.c +++ b/lib_dec/vlpc_1st_dec_fx.c @@ -11,17 +11,17 @@ #ifdef IVAS_FLOAT_FIXED void vlpc_1st_dec( Word16 index, /* input: codebook index */ - Word16 *lsfq ) /* i/o: i:prediction o:quantized lsf */ + Word16 *lsfq ) /* i/o: i:prediction o:quantized lsf 14Q1*1.28 */ { Word16 i; const Word16 *p_dico; assert( index < 256 ); - p_dico = &dico_lsf_abs_8b[index * M]; + p_dico = &dico_lsf_abs_8b[index * M]; /*14Q1*1.28*/ FOR( i = 0; i < M; i++ ) { - lsfq[i] = add( lsfq[i], *p_dico ); + lsfq[i] = add( lsfq[i], *p_dico ); /*14Q1*1.28*/ move16(); p_dico++; } diff --git a/lib_dec/vlpc_2st_dec_fx.c b/lib_dec/vlpc_2st_dec_fx.c index 6aacd0974..74b53369c 100644 --- a/lib_dec/vlpc_2st_dec_fx.c +++ b/lib_dec/vlpc_2st_dec_fx.c @@ -12,7 +12,7 @@ #ifdef IVAS_FLOAT_FIXED void vlpc_2st_dec( - Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage */ + Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage 14Q1*1.28*/ Word16 *indx, /* i : index[] (4 bits per words) */ Word16 mode, /* i : 0=abs, >0=rel */ Word32 sr_core /* i : internal sampling rate */ diff --git a/lib_dec/voiced_dec_fx.c b/lib_dec/voiced_dec_fx.c index 761f904ea..c9ef8b473 100644 --- a/lib_dec/voiced_dec_fx.c +++ b/lib_dec/voiced_dec_fx.c @@ -43,11 +43,11 @@ /*===================================================================*/ ivas_error ppp_voiced_decoder_fx( Decoder_State *st_fx, /* i/o: state structure */ - Word16 *out_fx, /* o : residual signal */ - const Word16 *lpc2_fx, /* i : current frame LPC */ - Word16 *exc_fx, /* i : previous frame excitation */ - Word16 *pitch, /* o : fixed point pitch values for each subframe */ - Word16 bfi /* i : Frame error rate */ + Word16 *out_fx, /* o : residual signal Q0*/ + const Word16 *lpc2_fx, /* i : current frame LPC Q12*/ + Word16 *exc_fx, /* i : previous frame excitation Q0*/ + Word16 *pitch, /* o : fixed point pitch values for each subframe Q6*/ + Word16 bfi /* i : Frame error rate Q0*/ ) { Word16 k, delta_lag_D = 0, temp, Ql, Qh, diff; @@ -258,7 +258,7 @@ ivas_error ppp_voiced_decoder_fx( Ltemp = DTFS_setEngyHarm_fx( 2828, upper_cut_off_freq_of_interest, 2828, upper_cut_off_freq, 1, 0, &Qh, TMPDTFS_FX ); - Ltemp = log10_fx( Ltemp ); + Ltemp = log10_fx( Ltemp ); // Q23 #ifdef BASOP_NOGLOB Ltemp = L_add_sat( L_sub_sat( Ltemp, Ltemp_q ), logLag ); /* Ltemp=10*log10(lag*eng), Q23 */ hSC_VBR->lastHgainD_fx = round_fx_sat( L_shl_sat( (Word32) Mpy_32_16( extract_h( Ltemp ), extract_l( Ltemp ), 0x6666 ), 1 ) ); /* Q11 */ diff --git a/lib_dec/waveadjust_fec_dec_fx.c b/lib_dec/waveadjust_fec_dec_fx.c index b090b22e5..070447cd4 100644 --- a/lib_dec/waveadjust_fec_dec_fx.c +++ b/lib_dec/waveadjust_fec_dec_fx.c @@ -19,12 +19,12 @@ Word16 get_voicing_x( Word16 *s_LP, Word16 pitch, Word32 covMax, Word16 maxConv_ Word32 con_Log10( Word32 i_s32Val, Word16 i_s16Q ); Word16 Spl_GetScalingSquare_x( const Word16 *in_vector, const Word16 in_vector_length, Word16 times ); -Word16 vadmin( Word16 a, Word16 b ) +Word16 vadmin( Word16 a, Word16 b ) /*i/o: Qx */ { return s_min( a, b ); } -void set_state( Word16 *state, Word16 num, Word16 N ) +void set_state( Word16 *state, Word16 num, Word16 N ) /*i/o: Qx */ { Word16 i, tmp; @@ -38,7 +38,7 @@ void set_state( Word16 *state, Word16 num, Word16 N ) move16(); } -void concealment_update_x( Word16 bfi, Word16 curr_mode, Word16 tonality, Word32 *invkoef, Word16 *invkoef_scale, void *_plcInfo ) +void concealment_update_x( Word16 bfi, Word16 curr_mode, Word16 tonality, Word32 *invkoef /*Qinvkoef_scale*/, Word16 *invkoef_scale, void *_plcInfo ) { T_PLCInfo *plcInfo = (T_PLCInfo *) _plcInfo; Word32 *data_reci2 = plcInfo->data_reci2_fx; @@ -99,46 +99,46 @@ void concealment_update_x( Word16 bfi, Word16 curr_mode, Word16 tonality, Word32 return; } -static Word16 zero_pass_w32_x( const Word16 *s, const Word16 N ) +static Word16 zero_pass_w32_x( const Word16 *s, const Word16 N ) /* i: Qx*/ /* o: 2*Qx-31*/ { Word16 i; Word32 temp, zp = L_deposit_l( 0 ); FOR( i = 1; i < N; i++ ) { - temp = L_mac0( -1L, s[i], s[i - 1] ); - zp = L_sub( zp, L_shr( temp, 31 ) ); + temp = L_mac0( -1L, s[i], s[i - 1] ); // 2*Qx + zp = L_sub( zp, L_shr( temp, 31 ) ); // 2*Qx-31 } return extract_l( zp ); } -Word16 Sqrt_x_fast( Word32 value ) +Word16 Sqrt_x_fast( Word32 value /*Qvalue*/ ) /*o : Q11-(2*norm+1)*/ { Word16 norm; Word16 result, index; norm = sub( 23, norm_l( value ) ); index = extract_l( L_shr_r( value, add( norm, s_and( norm, 1 ) ) ) ); - result = shr( sqrt_table_pitch_search[index], sub( 11, shr( add( norm, 1 ), 1 ) ) ); + result = shr( sqrt_table_pitch_search[index], sub( 11, shr( add( norm, 1 ), 1 ) ) ); // Q11-(2*norm+1) return result; } -Word32 dot_w32_accuracy_x( Word16 *s1, Word16 *s2, Word16 nbits, Word16 N ) +Word32 dot_w32_accuracy_x( Word16 *s1 /*Qs1*/, Word16 *s2 /*Qs2*/, Word16 nbits, Word16 N ) { Word16 i; Word32 eng = L_deposit_l( 0 ), temp; FOR( i = 0; i < N; i++ ) { - temp = L_mult0( s1[i], s2[i] ); - eng = L_add( eng, L_shr( temp, nbits ) ); + temp = L_mult0( s1[i], s2[i] ); /*Qs1+ Qs2*/ + eng = L_add( eng, L_shr( temp, nbits ) ); /*Qs1+ Qs2-nbits*/ } return eng; } -Word16 int_div_s_x( Word16 a, Word16 b ) +Word16 int_div_s_x( Word16 a, Word16 b ) /*i/o : Q0*/ { Word16 result = 0; Word16 norm, left = 0, i; @@ -170,7 +170,7 @@ Word16 int_div_s_x( Word16 a, Word16 b ) return result; } -Word16 GetW32Norm_x( Word32 *s, Word16 N ) +Word16 GetW32Norm_x( Word32 *s, Word16 N ) /*i : Qx, o: Q0*/ { Word32 smax = L_deposit_l( 0 ); Word16 smax_norm, i; @@ -185,7 +185,7 @@ Word16 GetW32Norm_x( Word32 *s, Word16 N ) return smax_norm; } -Word16 harmo_x( Word32 *X, Word16 Framesize, Word16 pitch ) +Word16 harmo_x( Word32 *X, Word16 Framesize, Word16 pitch ) /*i : Qx, o: Q15*/ { Word16 h, k, result = 0; Word32 ener = L_deposit_l( 0 ), ener_harmo = L_deposit_l( 0 ); @@ -229,7 +229,7 @@ Word16 harmo_x( Word32 *X, Word16 Framesize, Word16 pitch ) return result; } -static Word16 get_low_freq_eng_rate_x( Word32 *mdct_data, +static Word16 get_low_freq_eng_rate_x( Word32 *mdct_data, /*i: Qx*/ /*o: Q0*/ Word16 curr_mode, Word16 N ) { @@ -276,7 +276,7 @@ static Word16 get_low_freq_eng_rate_x( Word32 *mdct_data, return ( L_sub( low_eng, smax ) <= 0 ); } -void LpFilter2_x( Word16 *x, Word16 *y, Word16 N ) +void LpFilter2_x( Word16 *x, Word16 *y, Word16 N ) /*i/o : Qx*/ { Word16 i; Word16 smax, norm; @@ -305,7 +305,7 @@ void LpFilter2_x( Word16 *x, Word16 *y, Word16 N ) } } -void sig_tilt_x( Word16 *s, Word16 FrameSize, Word32 *enr1, Word32 *enr2 ) +void sig_tilt_x( Word16 *s /*Qx*/, Word16 FrameSize, Word32 *enr1 /*2*Qx-nbits*/, Word32 *enr2 /*2*Qx-nbits*/ ) { Word16 subFrameSize, shIFt; Word16 *p1, *p2; @@ -323,7 +323,7 @@ void sig_tilt_x( Word16 *s, Word16 FrameSize, Word32 *enr1, Word32 *enr2 ) move32(); } -void get_maxConv_and_pitch_x( Word16 *s_LP, Word16 s, Word16 e, Word16 N, Word32 *maxConv, Word16 *maxConv_bits, Word16 *pitch ) +void get_maxConv_and_pitch_x( Word16 *s_LP /*Qx*/, Word16 s /*Q0*/, Word16 e /*Q0*/, Word16 N, Word32 *maxConv /*2*Qx-nbits*/, Word16 *maxConv_bits, Word16 *pitch /*Q0*/ ) { Word16 t, cov_size, size = N; Word32 tmp_sigma = L_deposit_l( 0 ), cov_max_sigma = L_deposit_l( 0 ); @@ -399,7 +399,7 @@ void get_maxConv_and_pitch_x( Word16 *s_LP, Word16 s, Word16 e, Word16 N, Word32 move16(); } -Word16 get_voicing_x( Word16 *s_LP, Word16 pitch, Word32 covMax, Word16 maxConv_bits, Word16 Framesize ) +Word16 get_voicing_x( Word16 *s_LP /*Qx*/, Word16 pitch /*Q0*/, Word32 covMax /*2*Qx-nbits*/, Word16 maxConv_bits, Word16 Framesize ) /*o : Q15*/ { Word32 eng1 = L_deposit_l( 0 ), eng2 = L_deposit_l( 0 ); Word16 voicing, norm; @@ -447,7 +447,7 @@ Word16 get_voicing_x( Word16 *s_LP, Word16 pitch, Word32 covMax, Word16 maxConv_ } } -void pitch_modify_x( Word16 *s_LP, Word16 *voicing, Word16 *pitch, Word16 FrameSize ) +void pitch_modify_x( Word16 *s_LP /*Qx*/, Word16 *voicing /*Q15*/, Word16 *pitch /*Q0*/, Word16 FrameSize ) { Word32 eng1, eng2, eng3; Word16 shIFt = shr( *pitch, 1 ); @@ -513,7 +513,7 @@ void pitch_modify_x( Word16 *s_LP, Word16 *voicing, Word16 *pitch, Word16 FrameS } } -Word16 Is_Periodic_x( Word32 *mdct_data, Word16 cov_max, Word16 zp, Word32 ener, Word32 ener_mean, Word16 pitch, Word16 Framesize ) +Word16 Is_Periodic_x( Word32 *mdct_data /*Qx*/, Word16 cov_max /*Q15*/, Word16 zp, Word32 ener /*Q8*/, Word32 ener_mean /*Q8*/, Word16 pitch /*Q0*/, Word16 Framesize ) /*o: Q0*/ { Word16 flag = 0; Word16 harm; @@ -561,7 +561,7 @@ Word16 Is_Periodic_x( Word32 *mdct_data, Word16 cov_max, Word16 zp, Word32 ener, return flag; } -Word16 get_conv_relation_x( Word16 *s_LP, Word16 shIFt, Word16 N ) +Word16 get_conv_relation_x( Word16 *s_LP /*Qx*/, Word16 shIFt, Word16 N ) /*o :Q0*/ { Word32 eng1, eng2, eng3; Word16 eng1_w, eng2_w; @@ -607,14 +607,14 @@ Word16 get_conv_relation_x( Word16 *s_LP, Word16 shIFt, Word16 N ) return tmp; } -static Word16 pitch_search_fx( Word16 *s, /* lastPcmOut */ - Word16 *outx_new, +static Word16 pitch_search_fx( Word16 *s /*Qs*/, /* lastPcmOut */ + Word16 *outx_new /*Qoutx_new*/, Word16 Framesize, - Word16 *voicing, - Word16 zp, - Word32 ener, - Word32 ener_mean, - Word32 *mdct_data, + Word16 *voicing /*Q15*/, + Word16 zp, /*Q0*/ + Word32 ener /*Q8*/, + Word32 ener_mean /*Q8*/, + Word32 *mdct_data /*Qmdct*/, Word16 curr_mode ) { Word16 pitch = 0; @@ -901,14 +901,14 @@ void concealment_init_ivas_fx( #endif // IVAS_FLOAT_FIXED static Word16 own_random_fix( /* o : output random value */ - Word16 *seed /* i/o: random seed */ + Word16 *seed /* i/o: random seed Q0 */ ) { *seed = extract_l( L_mac0( 13849L, *seed, 31821 ) ); return ( *seed ); } -void concealment_decode_fix( Word16 curr_mode, Word32 *invkoef, Word16 *invkoef_scale, void *_plcInfo ) +void concealment_decode_fix( Word16 curr_mode, Word32 *invkoef /*Qinvkoef_scale*/, Word16 *invkoef_scale, void *_plcInfo ) { T_PLCInfo *plcInfo = (T_PLCInfo *) _plcInfo; Word16 i; @@ -940,7 +940,7 @@ void concealment_decode_fix( Word16 curr_mode, Word32 *invkoef, Word16 *invkoef_ } -Word16 Spl_GetScalingSquare_x( const Word16 *in_vector, const Word16 in_vector_length, Word16 times ) +Word16 Spl_GetScalingSquare_x( const Word16 *in_vector /*Qin_vector*/, const Word16 in_vector_length, Word16 times ) /*o : Q0*/ { Word16 nbits = sub( 15, norm_s( times ) ) /*Spl_GetSizeInBits_x(times)*/; Word16 i; @@ -973,7 +973,7 @@ Word16 Spl_GetScalingSquare_x( const Word16 *in_vector, const Word16 in_vector_l } -Word32 Spl_Energy_x( const Word16 *vector, const Word16 vector_length, Word16 *scale_factor ) +Word32 Spl_Energy_x( const Word16 *vector /*Qvector*/, const Word16 vector_length, Word16 *scale_factor ) { Word32 en = L_deposit_l( 0 ); Word32 i; @@ -990,7 +990,7 @@ Word32 Spl_Energy_x( const Word16 *vector, const Word16 vector_length, Word16 *s return en; } -void Log10OfEnergy_x( const Word16 *s, Word32 *enerlogval, const Word16 len ) +void Log10OfEnergy_x( const Word16 *s /* Qs */, Word32 *enerlogval /* Q8 */, const Word16 len ) { Word32 energy = L_deposit_l( 0 ), tmp2 = L_deposit_l( 0 ); Word16 shfts = 0; @@ -1013,7 +1013,7 @@ void Log10OfEnergy_x( const Word16 *s, Word32 *enerlogval, const Word16 len ) } } -static Word32 fnLog2( Word32 L_Input ) +static Word32 fnLog2( Word32 L_Input /*QL_Input*/ ) /*o :Q26*/ { Word16 swC0 = -0x2b2a, swC1 = 0x7fc5, swC2 = -0x54d0; @@ -1067,7 +1067,7 @@ static Word32 fnLog2( Word32 L_Input ) return ( LwIn ); } -static Word32 fnLog10( Word32 L_Input ) +static Word32 fnLog10( Word32 L_Input /*QL_Input*/ ) /*o :Q26*/ { Word16 Scale = 9864; /* 0.30103 = log10(2) */ @@ -1088,7 +1088,7 @@ static Word32 fnLog10( Word32 L_Input ) return ( LwIn ); } -Word32 con_Log10( Word32 i_s32Val, Word16 i_s16Q ) +Word32 con_Log10( Word32 i_s32Val /*Qi_s32Val*/, Word16 i_s16Q /*Q0*/ ) /*o; Q26*/ { Word32 s32Out; Word32 s32Correct; /* corrected (31-q)*log10(2) */ @@ -1111,7 +1111,7 @@ Word32 con_Log10( Word32 i_s32Val, Word16 i_s16Q ) return s32Out; } -void concealment_update2_x( const Word16 *outx_new, void *_plcInfo, const Word16 FrameSize ) +void concealment_update2_x( const Word16 *outx_new /*Qoutx_new*/, void *_plcInfo, const Word16 FrameSize ) { T_PLCInfo *plcInfo = (T_PLCInfo *) _plcInfo; @@ -1129,7 +1129,7 @@ void concealment_update2_x( const Word16 *outx_new, void *_plcInfo, const Word16 return; } -static Word16 array_max_indx_fx( Word16 *s, Word16 N ) +static Word16 array_max_indx_fx( Word16 *s /*Qs*/, Word16 N ) { Word16 i, indx = 0; move16(); @@ -1145,7 +1145,7 @@ static Word16 array_max_indx_fx( Word16 *s, Word16 N ) } Word16 ffr_getSfWord16( /* o: measured headroom in range [0..15], 0 IF all x[i] == 0 */ - Word16 *x, /* i: array containing 16-bit data */ + Word16 *x, /* i: array containing 16-bit data Qx*/ Word16 len_x ) /* i: length of the array to scan */ { Word16 i, i_min, i_max; @@ -1189,7 +1189,7 @@ Word16 ffr_getSfWord16( /* o: measured headroom in range [0..15], return i; } -static Word16 OverlapAdd_fx( Word16 *pitch125_data, Word16 *sbuf, Word16 n, Word16 pitch, Word16 Framesize ) +static Word16 OverlapAdd_fx( Word16 *pitch125_data /*Qx*/, Word16 *sbuf /*Qx*/, Word16 n, Word16 pitch /*Q0*/, Word16 Framesize ) { Word16 n1, n2, s, s16MaxCoefNorm, s16MaxCoefNorm2, tmp16; Word16 i; @@ -1236,12 +1236,12 @@ static Word16 OverlapAdd_fx( Word16 *pitch125_data, Word16 *sbuf, Word16 n, Word return pitch; } -static void add_noise( Word16 *const sbuf, - Word16 *const outx_new_n1, - Word16 const *const noise_seg, +static void add_noise( Word16 *const sbuf, /*Qsbuf*/ + Word16 *const outx_new_n1, /*Q0*/ + Word16 const *const noise_seg, /*Q0*/ Word16 const Len, - Word16 *const gain, - Word16 const *const gain_n, + Word16 *const gain, /*Q15*/ + Word16 const *const gain_n, /*Q15*/ Word8 const firstFrame ) { Word16 i; @@ -1283,18 +1283,18 @@ static void add_noise( Word16 *const sbuf, return; } -static Word16 waveform_adj_fix( Word16 *overlapbuf, - Word16 *outdata2, - Word16 *outx_new, - Word16 *data_noise, - Word16 *outx_new_n1, - Word16 *nsapp_gain, - Word16 *nsapp_gain_n, +static Word16 waveform_adj_fix( Word16 *overlapbuf, /*Qoverlapbuf*/ + Word16 *outdata2, /*Qoutdata2*/ + Word16 *outx_new, /*Qoutx_new*/ + Word16 *data_noise, /*Qoutx_new*/ + Word16 *outx_new_n1, /*Q0*/ + Word16 *nsapp_gain, /*Q15*/ + Word16 *nsapp_gain_n, /*Q15*/ Word16 Framesize, Word8 T_bfi, - Word16 voicing, + Word16 voicing, /*Q15*/ Word16 curr_mode, - Word16 pitch ) + Word16 pitch /*Q0*/ ) { Word16 i, zp1, zp2, Framesizediv2, s16MaxCoefNorm; Word16 sbuf[L_FRAME_MAX]; @@ -1429,15 +1429,15 @@ static Word16 waveform_adj_fix( Word16 *overlapbuf, return pitch; } -void waveform_adj2_fix( Word16 *overlapbuf, - Word16 *outx_new, - Word16 *data_noise, - Word16 *outx_new_n1, - Word16 *nsapp_gain, - Word16 *nsapp_gain_n, - Word16 *recovery_gain, - Word16 step_concealgain, - Word16 pitch, +void waveform_adj2_fix( Word16 *overlapbuf, /*Qoverlapbuf*/ + Word16 *outx_new, /*Qoutx_new*/ + Word16 *data_noise, /*Qoutx_new*/ + Word16 *outx_new_n1, /*Q0*/ + Word16 *nsapp_gain, /*Q15*/ + Word16 *nsapp_gain_n, /*Q15*/ + Word16 *recovery_gain, /*Q14*/ + Word16 step_concealgain, /*Q15*/ + Word16 pitch, /*Q0*/ Word16 Framesize, Word16 delay, Word16 bfi_cnt, @@ -1612,7 +1612,7 @@ void waveform_adj2_fix( Word16 *overlapbuf, return; } -void concealment_signal_tuning_fx( Word16 bfi, Word16 curr_mode, Word16 *outx_new_fx, void *_plcInfo, Word16 nbLostCmpt, Word16 pre_bfi, Word16 *OverlapBuf_fx, Word16 past_core_mode, Word16 *outdata2_fx, Decoder_State *st ) +void concealment_signal_tuning_fx( Word16 bfi, Word16 curr_mode, Word16 *outx_new_fx /*Qoutx_new_fx*/, void *_plcInfo, Word16 nbLostCmpt, Word16 pre_bfi, Word16 *OverlapBuf_fx /*QOverlapBuf_fx*/, Word16 past_core_mode, Word16 *outdata2_fx /*Qoutdata2_fx*/, Decoder_State *st ) { T_PLCInfo *plcInfo = (T_PLCInfo *) _plcInfo; Word16 FrameSize = plcInfo->FrameSize; diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 4c93bcdc1..ef7f34e82 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -54,18 +54,24 @@ * Local constants *------------------------------------------------------------------------*/ -#define DIRAC_AVG_LENGTH_SYNTH_MS 20 /*averaging length in ms for DirAC synthesis*/ -#define DIRAC_ALPHA_MAX 0.1f -#define DIRAC_ALPHA_MAX_Q15 3276 +#define DIRAC_AVG_LENGTH_SYNTH_MS 20 /*averaging length in ms for DirAC synthesis*/ +#ifndef IVAS_FLOAT_FIXED +#define DIRAC_ALPHA_MAX 0.1f +#endif +#define DIRAC_ALPHA_MAX_Q15 3276 /*0.1f q15*/ #define DIRAC_AVG_LENGTH_SYNTH_MS_FAST 10 -#define DIRAC_ALPHA_MAX_FAST 0.12f -#define DIRAC_ALPHA_MAX_FAST_Q15 3932 -#define DIRECTION_SMOOTHNESS_ALPHA 0.01f -#define DIRECTION_SMOOTHNESS_ALPHA_Q31 ( 21474836 ) +#ifndef IVAS_FLOAT_FIXED +#define DIRAC_ALPHA_MAX_FAST 0.12f +#endif +#define DIRAC_ALPHA_MAX_FAST_Q15 3932 /*0.12f q15*/ +#ifndef IVAS_FLOAT_FIXED +#define DIRECTION_SMOOTHNESS_ALPHA 0.01f +#endif +#define DIRECTION_SMOOTHNESS_ALPHA_Q31 ( 21474836 ) /*0.01f q31*/ #ifdef IVAS_FLOAT_FIXED -#define POINT_3679_Q31 790059234 -#define POINT_1175_Q31 252329329 +#define POINT_3679_Q31 790059234 /*.3679 q31*/ +#define POINT_1175_Q31 252329329 /*.1175 q31*/ #endif /*------------------------------------------------------------------------- @@ -83,7 +89,7 @@ static void computeTargetPSDs_diffuse_subframe_fx( const Word16 num_channels, co static void computeTargetPSDs_diffuse_with_onsets_fx( const Word16 num_channels, const Word16 num_freq_bands, const Word16 num_decorr_freq_bands, const Word16 *proto_frame_diff_index, const Word32 *diffuse_power_factor, const Word32 *reference_power, const Word16 *q_reference_power, const Word32 *diffuse_responses_square, const Word32 *onset_filter, Word32 *cy_auto_diff_smooth, Word16 *q_cy_auto_diff_smooth ); -static void computeAlphaSynthesis_fx( Word16 *alpha_synthesis_fx, const Word16 averaging_length_ms, const Word16 maxAlpha_fx, Word16 *numAlphas, const Word16 slot_size, const Word16 num_freq_bands, Word16 *frequency_axis_fx, const Word32 output_Fs ); +static void computeAlphaSynthesis_fx( Word16 *alpha_synthesis_fx /*q15*/, const Word16 averaging_length_ms, const Word16 maxAlpha_fx /*q15*/, Word16 *numAlphas, const Word16 slot_size, const Word16 num_freq_bands, Word16 *frequency_axis_fx /*q0*/, const Word32 output_Fs ); static void spreadCoherencePanningHoa_fx( const Word16 azimuth, const Word16 elevation, const Word16 spreadCoh_fx, Word32 *direct_response_fx, Word16 *Q_direct_response_hoa, const Word16 num_channels_dir, const Word16 ambisonics_order ); @@ -321,7 +327,7 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } - Copy( temp_alpha_synthesis_fx, dirac_output_synthesis_params->alpha_synthesis_fx, dirac_output_synthesis_params->numAlphas ); + Copy( temp_alpha_synthesis_fx, dirac_output_synthesis_params->alpha_synthesis_fx, dirac_output_synthesis_params->numAlphas ); /*q15*/ computeAlphaSynthesis_fx( temp_alpha_synthesis_fx, DIRAC_AVG_LENGTH_SYNTH_MS_FAST, DIRAC_ALPHA_MAX_FAST_Q15, &dirac_output_synthesis_params->numAlphasFast, hSpatParamRendCom->slot_size, hSpatParamRendCom->num_freq_bands, hDirACRend->frequency_axis_fx, output_Fs ); @@ -329,7 +335,7 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } - Copy( temp_alpha_synthesis_fx, dirac_output_synthesis_params->alpha_synthesis_fast_fx, dirac_output_synthesis_params->numAlphasFast ); + Copy( temp_alpha_synthesis_fx, dirac_output_synthesis_params->alpha_synthesis_fast_fx, dirac_output_synthesis_params->numAlphasFast ); /*q15*/ IF( ( dirac_output_synthesis_state->reference_power_smooth_prev_fx = (Word32 *) malloc( hSpatParamRendCom->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) { @@ -377,10 +383,10 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( FOR( ch_idx = 0; ch_idx < num_diffuse_responses; ++ch_idx ) { /*dirac_output_synthesis_state->diffuse_responses_square[ch_idx] = pow(dirac_output_synthesis_params->diffuse_response_function[ch_idx]/max_response, 2.0f);*/ - tmp_fx = hDirACRend->diffuse_response_function_fx[ch_idx]; + tmp_fx = hDirACRend->diffuse_response_function_fx[ch_idx]; /*q15*/ move16(); - dirac_output_synthesis_state->diffuse_responses_square_fx[ch_idx] = L_mult( tmp_fx, tmp_fx ); /* Q15 + Q15 -> Q31 */ + dirac_output_synthesis_state->diffuse_responses_square_fx[ch_idx] = L_mult( tmp_fx, tmp_fx ); /* Q15 + Q15 + 1 -> Q31 */ move32(); } } @@ -418,28 +424,28 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { diff_nrg_fx = L_shr( L_mult0( hDirACRend->diffuse_response_function_fx[ch_idx], hDirACRend->diffuse_response_function_fx[ch_idx] ), gaurd_bits ); // Q30 - gaurd_bits - diff_nrg_total_fx = L_add( diff_nrg_total_fx, diff_nrg_fx ); + diff_nrg_total_fx = L_add( diff_nrg_total_fx, diff_nrg_fx ); // Q30 - gaurd_bits /* is it a transport channel?*/ test(); if ( ch_idx == 0 || hDirACRend->proto_index_dir[ch_idx] != 0 ) { - diff_nrg_trans_fx = L_add( diff_nrg_trans_fx, diff_nrg_fx ); + diff_nrg_trans_fx = L_add( diff_nrg_trans_fx, diff_nrg_fx ); // Q30 - gaurd_bits } /* is it a decorrelated or transport channel?*/ if ( LT_16( ch_idx, hDirACRend->num_outputs_diff ) ) { - diff_nrg_decorr_fx = L_add( diff_nrg_decorr_fx, diff_nrg_fx ); + diff_nrg_decorr_fx = L_add( diff_nrg_decorr_fx, diff_nrg_fx ); // Q30 - gaurd_bits } } Word16 exp_1 = 0, exp_2 = 0, tmp; move16(); move16(); - tmp = BASOP_Util_Divide3232_Scale( diff_nrg_total_fx, diff_nrg_trans_fx, &exp_1 ); // (Q15 - exp_diff) + tmp = BASOP_Util_Divide3232_Scale( diff_nrg_total_fx, diff_nrg_trans_fx, &exp_1 ); // Q(15 - exp_1) dirac_output_synthesis_params->diffuse_compensation_factor_fx = L_shl( L_deposit_l( tmp ), add( Q12, exp_1 ) ); // Q27 move32(); - tmp = BASOP_Util_Divide3232_Scale( diff_nrg_total_fx, diff_nrg_decorr_fx, &exp_2 ); // (Q15 - exp_diff) + tmp = BASOP_Util_Divide3232_Scale( diff_nrg_total_fx, diff_nrg_decorr_fx, &exp_2 ); // (Q15 - exp_2) dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx = L_shl( L_deposit_l( tmp ), add( Q14, exp_2 ) ); // Q29 move32(); } @@ -1319,17 +1325,17 @@ void ivas_dirac_dec_output_synthesis_process_slot( } #else void ivas_dirac_dec_output_synthesis_process_slot_fx( - const Word32 *reference_power, /* i : Estimated power */ - const Word16 q_reference_power, /* i : Estimated power */ - const Word32 *onset, /* i : onset filter */ + const Word32 *reference_power, /* i : Estimated power Q(q_reference_power)*/ + const Word16 q_reference_power, /* i : Estimated power Q */ + const Word32 *onset, /* i : onset filter Q31*/ const Word16 *azimuth, const Word16 *elevation, - const Word32 *diffuseness, + const Word32 *diffuseness, /* Q(q_diffuseness)*/ Word16 q_diffuseness, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ const Word16 sh_rot_max_order, - const Word32 *p_Rmat, /* i : rotation matrix */ + const Word32 *p_Rmat, /* i : rotation matrix Q30*/ const VBAP_HANDLE hVBAPdata, /* i : VBAP structure */ const IVAS_OUTPUT_SETUP hOutSetup, /* i : output setup structure */ const Word16 nchan_transport, /* i : number of transport channels*/ @@ -1348,7 +1354,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( h_dirac_output_synthesis_params = &( hDirACRend->h_output_synthesis_psd_params ); h_dirac_output_synthesis_state = &( hDirACRend->h_output_synthesis_psd_state ); - h_dirac_output_synthesis_state->onset_filter_fx = onset; + h_dirac_output_synthesis_state->onset_filter_fx = onset; /*Q31*/ /*-----------------------------------------------------------------* * processing @@ -1390,14 +1396,14 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( IF( h_dirac_output_synthesis_state->direct_responses_square_fx ) { - Scale_sig32( h_dirac_output_synthesis_state->direct_responses_square_fx, imult1616( num_channels_dir, num_freq_bands ), sub( 31, h_dirac_output_synthesis_state->direct_responses_square_q ) ); + Scale_sig32( h_dirac_output_synthesis_state->direct_responses_square_fx, imult1616( num_channels_dir, num_freq_bands ), sub( 31, h_dirac_output_synthesis_state->direct_responses_square_q ) ); /* h_dirac_output_synthesis_state->direct_responses_square_q->Q31*/ h_dirac_output_synthesis_state->direct_responses_square_q = 31; move16(); } - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( 31, h_dirac_output_synthesis_state->direct_responses_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( 31, h_dirac_output_synthesis_state->direct_responses_q ) ); /*h_dirac_output_synthesis_state->direct_responses_q->Q31*/ IF( hodirac_flag ) { - Scale_sig32( &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( 31, h_dirac_output_synthesis_state->direct_responses_q ) ); + Scale_sig32( &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir], i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( 31, h_dirac_output_synthesis_state->direct_responses_q ) ); /*h_dirac_output_synthesis_state->direct_responses_q->Q31*/ } h_dirac_output_synthesis_state->direct_responses_q = 31; move16(); @@ -1409,23 +1415,23 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - v_multc_fixed( hSpatParamRendCom->energy_ratio1_fx[md_idx], -MAX_32, aux_buf, num_freq_bands ); - v_addc_fixed( aux_buf, ONE_IN_Q30, aux_buf, num_freq_bands ); + v_multc_fixed( hSpatParamRendCom->energy_ratio1_fx[md_idx], -MAX_32 /*-1 Q31*/, aux_buf, num_freq_bands ); /* 30 + 31 - 31 -> 30 */ + v_addc_fixed( aux_buf, ONE_IN_Q30 /*1 Q30*/, aux_buf, num_freq_bands ); /*30*/ Copy32( hSpatParamRendCom->energy_ratio1_fx[md_idx], h_dirac_output_synthesis_state->direct_power_factor_fx, - num_freq_bands ); + num_freq_bands ); /*Q30*/ Copy32( aux_buf, h_dirac_output_synthesis_state->diffuse_power_factor_fx, - num_freq_bands ); + num_freq_bands ); /*Q30*/ - v_multc_fixed( hSpatParamRendCom->energy_ratio2_fx[md_idx], -MAX_32, aux_buf, num_freq_bands ); - v_addc_fixed( aux_buf, ONE_IN_Q30, aux_buf, num_freq_bands ); + v_multc_fixed( hSpatParamRendCom->energy_ratio2_fx[md_idx], -MAX_32 /*-1 Q31*/, aux_buf, num_freq_bands ); /*30+31-31->30*/ + v_addc_fixed( aux_buf, ONE_IN_Q30 /*1 Q30*/, aux_buf, num_freq_bands ); /*30*/ Copy32( hSpatParamRendCom->energy_ratio2_fx[md_idx], &h_dirac_output_synthesis_state->direct_power_factor_fx[hSpatParamRendCom->num_freq_bands], - num_freq_bands ); + num_freq_bands ); /*Q30*/ Copy32( aux_buf, &h_dirac_output_synthesis_state->diffuse_power_factor_fx[hSpatParamRendCom->num_freq_bands], - num_freq_bands ); + num_freq_bands ); /*Q30*/ h_dirac_output_synthesis_state->diffuse_power_factor_q = 30; move16(); @@ -1462,14 +1468,14 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { IF( h_dirac_output_synthesis_state->direct_responses_square_fx ) { - Scale_sig32( h_dirac_output_synthesis_state->direct_responses_square_fx, imult1616( num_channels_dir, num_freq_bands ), sub( 31, h_dirac_output_synthesis_state->direct_responses_square_q ) ); + Scale_sig32( h_dirac_output_synthesis_state->direct_responses_square_fx, imult1616( num_channels_dir, num_freq_bands ), sub( 31, h_dirac_output_synthesis_state->direct_responses_square_q ) ); /*h_dirac_output_synthesis_state->direct_responses_square_q->Q31*/ h_dirac_output_synthesis_state->direct_responses_square_q = 31; move16(); } - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( 31, h_dirac_output_synthesis_state->direct_responses_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( 31, h_dirac_output_synthesis_state->direct_responses_q ) ); /*h_dirac_output_synthesis_state->direct_responses_q->Q31*/ IF( hodirac_flag ) { - Scale_sig32( &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( 31, h_dirac_output_synthesis_state->direct_responses_q ) ); + Scale_sig32( &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir], i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( 31, h_dirac_output_synthesis_state->direct_responses_q ) ); /*h_dirac_output_synthesis_state->direct_responses_q->Q31*/ } h_dirac_output_synthesis_state->direct_responses_q = 31; move16(); @@ -1487,13 +1493,13 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( h_dirac_output_synthesis_state->diffuse_power_factor_q = sub( 31, h_dirac_output_synthesis_state->diffuse_power_factor_q ); v_multc_fixed( h_dirac_output_synthesis_state->direct_power_factor_fx, - ONE_IN_Q29, + ONE_IN_Q29 /*0.25f Q31*/, h_dirac_output_synthesis_state->direct_power_factor_fx, - num_freq_bands ); + num_freq_bands ); /*h_dirac_output_synthesis_state->direct_power_factor_q+Q31-Q31->h_dirac_output_synthesis_state->direct_power_factor_q*/ v_multc_fixed( h_dirac_output_synthesis_state->diffuse_power_factor_fx, - ONE_IN_Q29, + ONE_IN_Q29 /*0.25f Q31*/, h_dirac_output_synthesis_state->diffuse_power_factor_fx, - num_freq_bands ); + num_freq_bands ); /*h_dirac_output_synthesis_state->diffuse_power_factor_q+Q31-Q31->h_dirac_output_synthesis_state->diffuse_power_factor_q*/ /*Direct gain*/ @@ -1519,9 +1525,9 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( /*Directonal sound gain nrg compensation*/ FOR( k = 0; k < num_freq_bands_diff; k++ ) { - a = h_dirac_output_synthesis_state->direct_responses_fx[add( i_mult( ch_idx, num_freq_bands ), k )]; // Q = h_dirac_output_synthesis_state->q_direct_responses + a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses move32(); - IF( reference_power[add( k, num_freq_bands )] == 0 ) + IF( reference_power[k + num_freq_bands] == 0 ) { b = 0; move16(); @@ -1530,68 +1536,68 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } ELSE { - b = BASOP_Util_Divide3232_Scale( reference_power[add( k, num_freq_bands )], L_add( reference_power[add( k, imult1616( add( ch_idx, 1 ), num_freq_bands ) )], EPSILON_FX ), &b_exp ); + b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], L_add( reference_power[k + ( ch_idx + 1 ) * num_freq_bands], EPSILON_FX ), &b_exp ); /*Q(15-b_exp)*/ } - c = L_add( ONE_IN_Q29, Mpy_32_16_1( L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, ONE_IN_Q29 ), 5461 ) ); /*Diffuseness modellling nrg compensation*/ /* 1.0 / 6.0 = 5461 in Q15*/ + c = L_add( ONE_IN_Q29 /*1 Q29*/, Mpy_32_16_1( L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, ONE_IN_Q29 /*1 Q29*/ ), 5461 /*1.0 / 6.0 Q15*/ ) ); /*Diffuseness modellling nrg compensation*/ /*Q29*/ - mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (31 - b_exp) - 31) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 - mpy_diff_aab = Mpy_32_32( L_sub( L_shl( 1, q_diffuseness ), diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 - mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q = q_diffuseness - 2 + mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 + mpy_diff_aab = Mpy_32_32( L_sub( L_shl( 1, q_diffuseness ), diffuseness[k] ), mpy_a_a_b ); // Q(q_diff_aab) = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 + mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q(q_diff_c) = q_diffuseness - 2 - q_diff_aab = add( sub( add( h_dirac_output_synthesis_state->direct_responses_q, sub( 31, b_exp ) ), 31 ), add( sub( h_dirac_output_synthesis_state->direct_responses_q, 31 ), sub( q_diffuseness, 31 ) ) ); + q_diff_aab = add( sub( add( h_dirac_output_synthesis_state->direct_responses_q, sub( 15, b_exp ) ), 15 ), add( sub( h_dirac_output_synthesis_state->direct_responses_q, 31 ), sub( q_diffuseness, 31 ) ) ); q_diff_c = sub( q_diffuseness, 2 ); test(); IF( mpy_diff_c != 0 && mpy_diff_aab != 0 ) { - sqr_inp = BASOP_Util_Add_Mant32Exp( mpy_diff_c, sub( 31, q_diff_c ), mpy_diff_aab, sub( 31, q_diff_aab ), &sqr_exp ); + sqr_inp = BASOP_Util_Add_Mant32Exp( mpy_diff_c, sub( 31, q_diff_c ), mpy_diff_aab, sub( 31, q_diff_aab ), &sqr_exp ); /*Q(31-sqr_exp)*/ } ELSE { IF( mpy_diff_c == 0 ) { - sqr_inp = mpy_diff_aab; + sqr_inp = mpy_diff_aab; /*Q(q_diff_aab)*/ move32(); sqr_exp = sub( 31, q_diff_aab ); } ELSE { - sqr_inp = mpy_diff_c; + sqr_inp = mpy_diff_c; /*Q(q_diff_c)*/ move32(); sqr_exp = sub( 31, q_diff_c ); } } - sqr = Sqrt32( sqr_inp, &sqr_exp ); - sqr = L_shr( sqr, 2 ); - IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] != 0 ) + sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ + sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ + IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) { IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth-> (31-sqr_exp) */ move32(); - Q_temp_cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = sub( 31, sqr_exp ); + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } ELSE { - sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); - Q_temp_cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; + sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); /*( 31- sqr_exp )-> h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; move16(); } - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )], sqr ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx*/ move32(); } ELSE { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )], sqr ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*31-sqr_exp*/ move32(); - Q_temp_cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = sub( 31, sqr_exp ); + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } } FOR( ; k < num_freq_bands; k++ ) { - a = h_dirac_output_synthesis_state->direct_responses_fx[add( i_mult( ch_idx, num_freq_bands ), k )]; // Q = h_dirac_output_synthesis_state->q_direct_responses + a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses move32(); IF( reference_power[k + num_freq_bands] == 0 ) { @@ -1602,37 +1608,37 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } ELSE { - IF( reference_power[add( k, imult1616( add( ch_idx, 1 ), num_freq_bands ) )] == 0 ) + IF( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] == 0 ) { - b = MAXVAL_WORD16; + b = MAXVAL_WORD16; /*Q(-9)*/ move16(); b_exp = 40; move16(); } ELSE { - b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], reference_power[add( k, imult1616( add( ch_idx, 1 ), num_freq_bands ) )], &b_exp ); + b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], reference_power[k + ( ch_idx + 1 ) * num_freq_bands], &b_exp ); /*q(15-b_exp)*/ } } - c = L_add( ONE_IN_Q29, Mpy_32_16_1( L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, ONE_IN_Q29 ), 5461 ) ); /*Diffuseness modellling nrg compensation*/ /* 1.0 / 6.0 = 5461 in Q15*/ + c = L_add( ONE_IN_Q29 /*1 Q29*/, Mpy_32_16_1( L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, ONE_IN_Q29 /*1 Q29*/ ), 5461 ) ); /*Diffuseness modellling nrg compensation*/ /* 1.0 / 6.0 = 5461 in Q15*/ /*Q29*/ - mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (31 - b_exp) - 31) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 + mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 mpy_diff_aab = Mpy_32_32( L_sub( L_shl( 1, q_diffuseness ), diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q = q_diffuseness - 2 - q_diff_aab = add( h_dirac_output_synthesis_state->direct_responses_q + sub( sub( 31, b_exp ), 31 ), add( sub( h_dirac_output_synthesis_state->direct_responses_q, 31 ), sub( q_diffuseness, 31 ) ) ); + q_diff_aab = add( h_dirac_output_synthesis_state->direct_responses_q + sub( sub( 15, b_exp ), 15 ), add( sub( h_dirac_output_synthesis_state->direct_responses_q, 31 ), sub( q_diffuseness, 31 ) ) ); q_diff_c = sub( q_diffuseness, 2 ); test(); IF( mpy_diff_c != 0 && mpy_diff_aab != 0 ) { - sqr_inp = BASOP_Util_Add_Mant32Exp( mpy_diff_c, sub( 31, q_diff_c ), mpy_diff_aab, sub( 31, q_diff_aab ), &sqr_exp ); + sqr_inp = BASOP_Util_Add_Mant32Exp( mpy_diff_c, sub( 31, q_diff_c ), mpy_diff_aab, sub( 31, q_diff_aab ), &sqr_exp ); /*q(31-sqr_exp)*/ } ELSE { IF( mpy_diff_c == 0 ) { - sqr_inp = mpy_diff_aab; + sqr_inp = mpy_diff_aab; /*q_diff_aab*/ move32(); sqr_exp = sub( 31, q_diff_aab ); } @@ -1640,34 +1646,34 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { sqr_inp = mpy_diff_c; move32(); - sqr_exp = sub( 31, q_diff_c ); + sqr_exp = sub( 31, q_diff_c ); /*q_diff_c*/ } } - sqr = Sqrt32( sqr_inp, &sqr_exp ); - sqr = L_shr( sqr, 2 ); - IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] != 0 ) + sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ + sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ + IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) { IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q( 31- sqr_exp )*/ move32(); - Q_temp_cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = sub( 31, sqr_exp ); + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } ELSE { - sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); - Q_temp_cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; + sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); /*Q(31- sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; move16(); } - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )], sqr ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ move32(); } ELSE { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )], sqr ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31- sqr_exp)*/ move32(); - Q_temp_cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = sub( 31, sqr_exp ); + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } } @@ -1679,73 +1685,74 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( /*Diffuseness modellling nrg compensation*/ FOR( k = 0; k < num_freq_bands_diff; k++ ) { - mpy_diff = Mpy_32_32( diffuseness[k], L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, ONE_IN_Q29 ) ); // Q = q_diff - 1 - sqr_inp = L_add( L_shl( 1, sub( q_diffuseness, 1 ) ), mpy_diff ); + /*diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ) )*/ + mpy_diff = Mpy_32_32( diffuseness[k], L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx /*q29=0.5 * q30*/, ONE_IN_Q29 /*0.5 Q30*/ ) /*q30*/ ); // Q = q_diffuseness - 1 + sqr_inp = L_add( L_shl( 1, sub( q_diffuseness, 1 ) ), mpy_diff ); // Q = q_diffuseness - 1 sqr_exp = sub( 31, sub( q_diffuseness, 1 ) ); - sqr = Sqrt32( sqr_inp, &sqr_exp ); - sqr = L_shr( sqr, 2 ); - IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] != 0 ) + sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ + sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ + IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) { IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q(31- sqr_exp)*/ move32(); - Q_temp_cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = sub( 31, sqr_exp ); + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } ELSE { - sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); - Q_temp_cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; + sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); /*Q(31-sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; move16(); } - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )], sqr ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ move32(); } ELSE { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )], sqr ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31-sqr_exp)*/ move32(); - Q_temp_cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = sub( 31, sqr_exp ); + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } } FOR( ; k < num_freq_bands; k++ ) { - mpy_diff = Mpy_32_32( diffuseness[k], L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, ONE_IN_Q29 ) ); // Q = q_diff - 1 - sqr_inp = L_add( L_shl( 1, sub( q_diffuseness, 1 ) ), mpy_diff ); + mpy_diff = Mpy_32_32( diffuseness[k], L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, ONE_IN_Q29 /*1 Q29*/ ) ); // Q = q_diffuseness - 1 + sqr_inp = L_add( L_shl( 1, sub( q_diffuseness, 1 ) ), mpy_diff ); // Q = q_diffuseness - 1 sqr_exp = sub( 31, sub( q_diffuseness, 1 ) ); - sqr = Sqrt32( sqr_inp, &sqr_exp ); - sqr = L_shr( sqr, 2 ); - IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] != 0 ) + sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ + sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ + IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) { IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, Q( 31- sqr_exp )*/ move32(); - Q_temp_cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = sub( 31, sqr_exp ); + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } ELSE { - sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); - Q_temp_cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; + sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); /*Q( 31- sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; move16(); } - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )], sqr ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ move32(); } ELSE { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )], sqr ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31-sqr_exp)*/ move32(); - Q_temp_cy_cross_dir_smooth_fx[L_add( i_mult( ch_idx, num_freq_bands ), k )] = sub( 31, sqr_exp ); + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } } } } - Word16 temp = MAX_16; + Word16 temp = MAX_16; /*q0*/ move16(); tmp16 = imult1616( num_freq_bands, num_channels_dir ); FOR( Word16 kk = 0; kk < tmp16; kk++ ) @@ -1756,7 +1763,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); FOR( Word16 kk = 0; kk < tmp16; kk++ ) { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( temp, Q_temp_cy_cross_dir_smooth_fx[kk] ) ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( temp, Q_temp_cy_cross_dir_smooth_fx[kk] ) ); /*Q_temp_cy_cross_dir_smooth_fx[kk]->temp*/ move32(); } free( Q_temp_cy_cross_dir_smooth_fx ); @@ -1766,7 +1773,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { FOR( Word16 kk = 0; kk < tmp16; kk++ ) { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ->temp_q*/ move32(); } h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = temp_q; @@ -1775,33 +1782,37 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( FOR( ch_idx = s_min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) { v_mult_fixed( h_dirac_output_synthesis_state->direct_power_factor_fx, - &h_dirac_output_synthesis_state->direct_responses_fx[i_mult( ch_idx, num_freq_bands )], + &h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands], aux_buf, - num_freq_bands ); + num_freq_bands ); /*temp_q*/ IF( NE_16( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) { - Scale_sig32( aux_buf, num_freq_bands, sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, temp_q ) ); + Scale_sig32( aux_buf, num_freq_bands, sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, temp_q ) ); /*temp_q->(h_dirac_output_synthesis_state->q_cy_cross_dir_smooth)*/ } v_add_fixed( aux_buf, - &h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[imult1616( ch_idx, num_freq_bands )], - &h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[imult1616( ch_idx, num_freq_bands )], - num_freq_bands, 0 ); // Todo:Hdrm + &h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], + &h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], + num_freq_bands, 0 ); /*Q(h_dirac_output_synthesis_state->q_cy_cross_dir_smooth)*/ } /*Diffuse gain*/ FOR( ch_idx = s_min( 4, nchan_transport ); ch_idx < num_channels_diff; ch_idx++ ) { - v_multc_fixed( h_dirac_output_synthesis_state->diffuse_power_factor_fx, - hDirACRend->diffuse_response_function_fx[ch_idx], - aux_buf, - num_freq_bands_diff ); - + v_multc_fixed_16( h_dirac_output_synthesis_state->diffuse_power_factor_fx, + hDirACRend->diffuse_response_function_fx[ch_idx], + aux_buf, + num_freq_bands_diff ); /* h_dirac_output_synthesis_state->diffuse_power_factor_q+15-15*/ + temp_q = h_dirac_output_synthesis_state->diffuse_power_factor_q; + IF( NE_16( temp_q, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ) + { + Scale_sig32( aux_buf, num_freq_bands, sub( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, temp_q ) ); /*temp_q->(h_dirac_output_synthesis_state->q_cy_auto_diff_smooth)*/ + } v_add_fixed( aux_buf, - &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[imult1616( ch_idx, num_freq_bands_diff )], - &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[imult1616( ch_idx, num_freq_bands_diff )], - num_freq_bands_diff, 0 ); // Todo:Hdrm + &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], + &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], + num_freq_bands_diff, 0 ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth*/ } return; @@ -1815,8 +1826,8 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( h_dirac_output_synthesis_state->direct_power_factor_fx, h_dirac_output_synthesis_state->diffuse_power_factor_fx ); - Scale_sig32( h_dirac_output_synthesis_state->direct_power_factor_fx, num_freq_bands, 2 ); - Scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, num_freq_bands, 2 ); + Scale_sig32( h_dirac_output_synthesis_state->direct_power_factor_fx, num_freq_bands, 2 ); /*q29->q31*/ + Scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, num_freq_bands, 2 ); /*q29->q31*/ h_dirac_output_synthesis_state->diffuse_power_factor_q = 31; move16(); h_dirac_output_synthesis_state->direct_power_factor_q = 31; @@ -1928,32 +1939,32 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( /*Direct gain*/ FOR( ch_idx = 0; ch_idx < nchan_transport_foa; ch_idx++ ) { - v_multc_fixed( diffuseness, // Q30 - ONE_IN_Q31, // Q31 - &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[imult1616( ch_idx, num_freq_bands )], // Q30 + v_multc_fixed( diffuseness, // Q30 + ONE_IN_Q31, // Q31 + &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], // Q30 num_freq_bands ); - v_multc_fixed( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[imult1616( ch_idx, num_freq_bands )], // Q30 - L_sub( h_dirac_output_synthesis_params.diffuse_compensation_factor_fx, ONE_IN_Q27 ), // Q27 - &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[imult1616( ch_idx, num_freq_bands )], // Q26 + v_multc_fixed( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], // Q30 + L_sub( h_dirac_output_synthesis_params.diffuse_compensation_factor_fx, ONE_IN_Q27 ), // Q27 + &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], // Q26 num_freq_bands ); FOR( l = 0; l < num_freq_bands; l++ ) { exp = Q31 - Q26; - h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[add( imult1616( ch_idx, num_freq_bands ), l )] = - Sqrt32( L_add( ONE_IN_Q26, h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[add( imult1616( ch_idx, num_freq_bands ), l )] ), + h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + l] = + Sqrt32( L_add( ONE_IN_Q26 /*1 in Q26*/, h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + l] ), &exp ); // (Q31 - exp) move32(); } // Scale to bring in common Q-factor q_com = s_min( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, sub( Q31, exp ) ); - Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[imult1616( ch_idx, num_freq_bands )], + Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], num_freq_bands, - sub( q_com, sub( Q31, exp ) ) ); - Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[imult1616( ch_idx, num_freq_bands )], + sub( q_com, sub( Q31, exp ) ) ); /*Q( Q31- exp)->q_com*/ + Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[ch_idx * num_freq_bands], num_freq_bands, - sub( q_com, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ); + sub( q_com, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev->q_com*/ } /*Directional gain*/ @@ -1963,38 +1974,38 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { aux_buf[l] = L_sub( ONE_IN_Q30, diffuseness[l] ); // Q30 move32(); - ratio_float[l] = L_sub( ONE_IN_Q31, h_dirac_output_synthesis_state.direct_power_factor_fx[add( num_freq_bands, l )] ); // Q31 + ratio_float[l] = L_sub( ONE_IN_Q31, h_dirac_output_synthesis_state.direct_power_factor_fx[num_freq_bands + l] ); // Q31 move32(); - ratio_float[add( l, num_freq_bands )] = L_sub( ONE_IN_Q31, ratio_float[l] ); // Q31 + ratio_float[l + num_freq_bands] = L_sub( ONE_IN_Q31, ratio_float[l] ); // Q31 move32(); } v_mult_fixed( aux_buf, ratio_float, ratio_float, num_freq_bands ); //(Q30, Q31) -> Q30 v_mult_fixed( aux_buf, &ratio_float[num_freq_bands], &ratio_float[num_freq_bands], num_freq_bands ); //(Q30, Q31) -> Q30 - v_mult_fixed( ratio_float, // Q30 - &h_dirac_output_synthesis_state.direct_responses_fx[imult1616( ch_idx, num_freq_bands )], // Q31 - &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[imult1616( ch_idx, num_freq_bands )], //(Q30, Q31) -> Q30 + v_mult_fixed( ratio_float, // Q30 + &h_dirac_output_synthesis_state.direct_responses_fx[ch_idx * num_freq_bands], // Q31 + &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], //(Q30, Q31) -> Q30 num_freq_bands ); - v_mult_fixed( &ratio_float[num_freq_bands], // Q30 - &h_dirac_output_synthesis_state.direct_responses_fx[add( imult1616( ch_idx, num_freq_bands ), imult1616( num_freq_bands, num_channels_dir ) )], // Q31 - &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[add( imult1616( ch_idx, num_freq_bands ), imult1616( num_freq_bands, num_channels_dir ) )], //(Q30, Q31) -> Q30 + v_mult_fixed( &ratio_float[num_freq_bands], // Q30 + &h_dirac_output_synthesis_state.direct_responses_fx[ch_idx * num_freq_bands + num_freq_bands * num_channels_dir], // Q31 + &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + num_freq_bands * num_channels_dir], //(Q30, Q31) -> Q30 num_freq_bands ); // Scale to bring in common Q-factor q_com = s_min( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, Q30 ); - Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[imult1616( ch_idx, num_freq_bands )], + Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], num_freq_bands, - sub( q_com, Q30 ) ); - Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[add( imult1616( ch_idx, num_freq_bands ), imult1616( num_freq_bands, num_channels_dir ) )], + sub( q_com, Q30 ) ); /*Q30->q_com*/ + Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + num_freq_bands * num_channels_dir], num_freq_bands, - sub( q_com, Q30 ) ); - Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[imult1616( ch_idx, num_freq_bands )], + sub( q_com, Q30 ) ); /*Q30->q_com*/ + Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[ch_idx * num_freq_bands], num_freq_bands, - sub( q_com, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ); - Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[add( imult1616( ch_idx, num_freq_bands ), imult1616( num_freq_bands, num_channels_dir ) )], + sub( q_com, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev->q_com*/ + Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[ch_idx * num_freq_bands + num_freq_bands * num_channels_dir], num_freq_bands, - sub( q_com, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ); + sub( q_com, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev->q_com*/ } h_dirac_output_synthesis_state.q_cy_cross_dir_smooth = q_com; @@ -2005,19 +2016,19 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( /*Diffuse gain*/ FOR( ch_idx = nchan_transport_foa; ch_idx < num_channels_diff; ch_idx++ ) { - v_multc_fixed_16( h_dirac_output_synthesis_state.diffuse_power_factor_fx, // Q31 - hDirACRend->diffuse_response_function_fx[ch_idx], // Q15 - &h_dirac_output_synthesis_state.cy_auto_diff_smooth_fx[imult1616( ch_idx, num_freq_bands_diff )], // Q31 + v_multc_fixed_16( h_dirac_output_synthesis_state.diffuse_power_factor_fx, // Q31 + hDirACRend->diffuse_response_function_fx[ch_idx], // Q15 + &h_dirac_output_synthesis_state.cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], // Q31 num_freq_bands_diff ); // Scale to bring in common Q-factor q_com = s_min( h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev, Q31 ); - Scale_sig32( &h_dirac_output_synthesis_state.cy_auto_diff_smooth_fx[imult1616( ch_idx, num_freq_bands_diff )], + Scale_sig32( &h_dirac_output_synthesis_state.cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], num_freq_bands_diff, - sub( q_com, Q31 ) ); - Scale_sig32( &h_dirac_output_synthesis_state.cy_auto_diff_smooth_prev_fx[imult1616( ch_idx, num_freq_bands_diff )], + sub( q_com, Q31 ) ); /*q31->q_com*/ + Scale_sig32( &h_dirac_output_synthesis_state.cy_auto_diff_smooth_prev_fx[ch_idx * num_freq_bands_diff], num_freq_bands_diff, - sub( q_com, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev ) ); + sub( q_com, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev ) ); /* h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev->q_com*/ } h_dirac_output_synthesis_state.q_cy_auto_diff_smooth = q_com; @@ -2030,54 +2041,54 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( /*Direct gain*/ FOR( ch_idx = 0; ch_idx < nchan_transport_foa; ch_idx++ ) { - v_mult_fixed( h_dirac_output_synthesis_state.diffuse_power_factor_fx, // Q31 - h_dirac_output_synthesis_state.diffuse_power_factor_fx, // Q31 - &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[imult1616( ch_idx, num_freq_bands )], // Q31 + v_mult_fixed( h_dirac_output_synthesis_state.diffuse_power_factor_fx, // Q31 + h_dirac_output_synthesis_state.diffuse_power_factor_fx, // Q31 + &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], // Q31 num_freq_bands ); - v_multc_fixed( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[imult1616( ch_idx, num_freq_bands )], // Q31 + v_multc_fixed( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], // Q31 L_sub( L_shr( h_dirac_output_synthesis_params.diffuse_compensation_factor_decorr_fx, Q3 ), ONE_IN_Q26 ), // Q26 - &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[imult1616( ch_idx, num_freq_bands )], // Q26 + &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], // Q26 num_freq_bands_diff ); - v_multc_fixed( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[add( imult1616( ch_idx, num_freq_bands ), num_freq_bands_diff )], // Q31 - L_sub( L_shr( h_dirac_output_synthesis_params.diffuse_compensation_factor_fx, Q1 ), ONE_IN_Q26 ), // Q26 - &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[add( imult1616( ch_idx, num_freq_bands ), num_freq_bands_diff )], // Q26 + v_multc_fixed( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + num_freq_bands_diff], // Q31 + L_sub( L_shr( h_dirac_output_synthesis_params.diffuse_compensation_factor_fx, Q1 ), ONE_IN_Q26 ), // Q26 + &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + num_freq_bands_diff], // Q26 num_freq_bands - num_freq_bands_diff ); FOR( l = 0; l < num_freq_bands; l++ ) { exp = Q31 - Q26; - h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[add( imult1616( ch_idx, num_freq_bands ), l )] = - Sqrt32( L_add( ONE_IN_Q26, h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[add( imult1616( ch_idx, num_freq_bands ), l )] ), + h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + l] = + Sqrt32( L_add( ONE_IN_Q26, h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + l] ), &exp ); // (Q31 - exp) move32(); } // Scale to bring in common Q-factor q_com = s_min( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, sub( Q31, exp ) ); - Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[imult1616( ch_idx, num_freq_bands )], + Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], num_freq_bands, - sub( q_com, sub( Q31, exp ) ) ); - Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[imult1616( ch_idx, num_freq_bands )], + sub( q_com, sub( Q31, exp ) ) ); /*( Q31- exp )->q_com*/ + Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[ch_idx * num_freq_bands], num_freq_bands, - sub( q_com, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ); + sub( q_com, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev->q_com*/ } /*Directional gain*/ FOR( ch_idx = nchan_transport_foa; ch_idx < num_channels_dir; ch_idx++ ) { - v_mult_fixed( h_dirac_output_synthesis_state.direct_power_factor_fx, // Q31 - &h_dirac_output_synthesis_state.direct_responses_fx[imult1616( ch_idx, num_freq_bands )], // Q31 - &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[imult1616( ch_idx, num_freq_bands )], // Q31 + v_mult_fixed( h_dirac_output_synthesis_state.direct_power_factor_fx, // Q31 + &h_dirac_output_synthesis_state.direct_responses_fx[ch_idx * num_freq_bands], // Q31 + &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], // Q31 num_freq_bands ); // Scale to bring in common Q-factor q_com = s_min( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, Q31 ); - Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[imult1616( ch_idx, num_freq_bands )], + Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], num_freq_bands, - sub( q_com, Q31 ) ); - Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[imult1616( ch_idx, num_freq_bands )], + sub( q_com, Q31 ) ); /*q31->q_com*/ + Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[ch_idx * num_freq_bands], num_freq_bands, - sub( q_com, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ); + sub( q_com, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev->q_com*/ } h_dirac_output_synthesis_state.q_cy_cross_dir_smooth = q_com; @@ -2088,19 +2099,19 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( /*Diffuse gain*/ FOR( ch_idx = nchan_transport_foa; ch_idx < num_channels_diff; ch_idx++ ) { - v_multc_fixed_16( h_dirac_output_synthesis_state.diffuse_power_factor_fx, // Q31 - hDirACRend->diffuse_response_function_fx[ch_idx], // Q15 - &h_dirac_output_synthesis_state.cy_auto_diff_smooth_fx[imult1616( ch_idx, num_freq_bands_diff )], // Q31 + v_multc_fixed_16( h_dirac_output_synthesis_state.diffuse_power_factor_fx, // Q31 + hDirACRend->diffuse_response_function_fx[ch_idx], // Q15 + &h_dirac_output_synthesis_state.cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], // Q31 num_freq_bands_diff ); // Scale to bring in common Q-factor q_com = s_min( h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev, Q31 ); - Scale_sig32( &h_dirac_output_synthesis_state.cy_auto_diff_smooth_fx[imult1616( ch_idx, num_freq_bands_diff )], + Scale_sig32( &h_dirac_output_synthesis_state.cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], num_freq_bands_diff, - sub( q_com, Q31 ) ); - Scale_sig32( &h_dirac_output_synthesis_state.cy_auto_diff_smooth_prev_fx[imult1616( ch_idx, num_freq_bands_diff )], + sub( q_com, Q31 ) ); /*q31->q_com*/ + Scale_sig32( &h_dirac_output_synthesis_state.cy_auto_diff_smooth_prev_fx[ch_idx * num_freq_bands_diff], num_freq_bands_diff, - sub( q_com, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev ) ); + sub( q_com, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev ) ); /*h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev->q_com*/ } h_dirac_output_synthesis_state.q_cy_auto_diff_smooth = q_com; @@ -2228,9 +2239,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( p_gains_dir_prev = h_dirac_output_synthesis_state.gains_dir_prev_fx; FOR( ch_idx = 0; ch_idx < num_channels_dir; ch_idx++ ) { - Scale_sig32( &h_dirac_output_synthesis_state.gains_dir_prev_fx[imult1616( ch_idx, num_freq_bands )], + Scale_sig32( &h_dirac_output_synthesis_state.gains_dir_prev_fx[ch_idx * num_freq_bands], num_freq_bands, - sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, h_dirac_output_synthesis_state.gains_dir_prev_q ) ); + sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, h_dirac_output_synthesis_state.gains_dir_prev_q ) ); /*h_dirac_output_synthesis_state.gains_dir_prev_q->h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev*/ } h_dirac_output_synthesis_state.gains_dir_prev_q = h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev; move16(); @@ -2239,14 +2250,14 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { p_proto_diff = h_dirac_output_synthesis_state.proto_diffuse_buffer_f_fx + shl( i_mult( buf_idx, i_mult( num_freq_bands, num_channels_diff ) ), Q1 ) + - shl( i_mult( ch_idx, num_freq_bands ), Q1 ); + shl( ch_idx * num_freq_bands, Q1 ); FOR( l = 0; l < num_freq_bands; l++ ) { g = Madd_32_32( Mpy_32_32( g1, ( *( p_gains_dir++ ) ) ), g2, ( *( p_gains_dir_prev++ ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) - output_real[add( imult1616( l, num_channels_dir ), ch_idx )] = Mpy_32_32( g, ( *( p_proto_diff++ ) ) ); // (p_gains_dir_q, p_proto_diff_q) -> (p_gains_dir_q + p_proto_diff_q - 31) + output_real[l * num_channels_dir + ch_idx] = Mpy_32_32( g, ( *( p_proto_diff++ ) ) ); // (p_gains_dir_q, p_proto_diff_q) -> (p_gains_dir_q + p_proto_diff_q - 31) move32(); - output_imag[add( imult1616( l, num_channels_dir ), ch_idx )] = Mpy_32_32( g, ( *( p_proto_diff++ ) ) ); // (p_gains_dir_q, p_proto_diff_q) -> (p_gains_dir_q + p_proto_diff_q - 31) + output_imag[l * num_channels_dir + ch_idx] = Mpy_32_32( g, ( *( p_proto_diff++ ) ) ); // (p_gains_dir_q, p_proto_diff_q) -> (p_gains_dir_q + p_proto_diff_q - 31) move32(); } } @@ -2274,7 +2285,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( p_gains_dir_prev++; // ((p_gains_dir_q, p_proto_dir_q) >> 1) -> (p_gains_dir_q + p_proto_dir_q - 31) - output_real[add( imult1616( l, num_channels_dir ), ch_idx )] = + output_real[l * num_channels_dir + ch_idx] = Madd_32_32( Mpy_32_32( gs1, ( L_add( Mpy_32_32( 1903158016 /* 1.772454e+00f / 2 in Q31 */, ( *p_proto ) ), Mpy_32_32( 1098788992 /* 1.023327e+00f / 2 in Q31 */, ( *p_proto2 ) ) ) ) ), /* s1 */ gs2, L_sub( Mpy_32_32( 1903158016 /* 1.772454e+00f / 2 in Q31 */, ( *p_proto ) ), Mpy_32_32( 1098788992 /* 1.023327e+00f / 2 in Q31 */, ( *p_proto2 ) ) ) ); /* s2 */ @@ -2283,7 +2294,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( p_proto2++; // ((p_gains_dir_q, p_proto_dir_q) >> 1) -> (p_gains_dir_q + p_proto_dir_q - 31) - output_imag[add( imult1616( l, num_channels_dir ), ch_idx )] = + output_imag[l * num_channels_dir + ch_idx] = Madd_32_32( Mpy_32_32( gs1, ( L_add( Mpy_32_32( 1903158016 /* 1.772454e+00f / 2 in Q31 */, ( *p_proto ) ), Mpy_32_32( 1098788992 /* 1.023327e+00f / 2 in Q31 */, ( *p_proto2 ) ) ) ) ), gs2, L_sub( Mpy_32_32( 1903158016 /* 1.772454e+00f / 2 in Q31 */, ( *p_proto ) ), Mpy_32_32( 1098788992 /* 1.023327e+00f / 2 in Q31 */, ( *p_proto2 ) ) ) ); @@ -2302,9 +2313,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( p_gains_dir++; p_gains_dir_prev++; - output_real[add( imult1616( l, num_channels_dir ), ch_idx )] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) + output_real[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); - output_imag[add( imult1616( l, num_channels_dir ), ch_idx )] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) + output_imag[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); } } @@ -2320,9 +2331,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { g = Madd_32_32( Mpy_32_32( g1, ( *( p_gains_dir++ ) ) ), g2, ( *( p_gains_dir_prev++ ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) - output_real[add( imult1616( l, num_channels_dir ), ch_idx )] = Mpy_32_32( g, ( *( p_proto++ ) ) ); // (p_gains_dir_q, p_proto_dir_q) -> (p_gains_dir_q + p_proto_dir_q - 31) + output_real[l * num_channels_dir + ch_idx] = Mpy_32_32( g, ( *( p_proto++ ) ) ); // (p_gains_dir_q, p_proto_dir_q) -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); - output_imag[add( imult1616( l, num_channels_dir ), ch_idx )] = Mpy_32_32( g, ( *( p_proto++ ) ) ); // (p_gains_dir_q, p_proto_dir_q) -> (p_gains_dir_q + p_proto_dir_q - 31) + output_imag[l * num_channels_dir + ch_idx] = Mpy_32_32( g, ( *( p_proto++ ) ) ); // (p_gains_dir_q, p_proto_dir_q) -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); } } @@ -2333,9 +2344,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( p_gains_dir++; p_gains_dir_prev++; - output_real[add( imult1616( l, num_channels_dir ), ch_idx )] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) + output_real[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); - output_imag[add( imult1616( l, num_channels_dir ), ch_idx )] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) + output_imag[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); } } @@ -2347,9 +2358,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( p_gains_diff_prev = h_dirac_output_synthesis_state.gains_diff_prev_fx + i_mult( nchan_transport_foa, num_freq_bands_diff ); FOR( ch_idx = nchan_transport_foa; ch_idx < num_channels_diff; ch_idx++ ) { - Scale_sig32( &h_dirac_output_synthesis_state.gains_diff_prev_fx[imult1616( ch_idx, num_freq_bands_diff )], + Scale_sig32( &h_dirac_output_synthesis_state.gains_diff_prev_fx[ch_idx * num_freq_bands_diff], num_freq_bands_diff, - sub( h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev, h_dirac_output_synthesis_state.gains_diff_prev_q ) ); + sub( h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev, h_dirac_output_synthesis_state.gains_diff_prev_q ) ); /*h_dirac_output_synthesis_state.gains_diff_prev_q->h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev*/ } h_dirac_output_synthesis_state.gains_diff_prev_q = h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev; move16(); @@ -2369,14 +2380,14 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( g = Madd_32_32( Mpy_32_32( g1, ( *( p_gains_diff++ ) ) ), g2, ( *( p_gains_diff_prev++ ) ) ); // (Q31, p_gains_diff_q) -> p_gains_diff_q // ((p_gains_diff_q, p_proto_diff_q) >> Q1) -> (p_gains_diff_q + p_proto_diff_q - 31) - output_real[add( imult1616( l, num_channels_dir ), hDirACRend->sba_map_tc[ch_idx] )] = - Madd_32_32( output_real[add( imult1616( l, num_channels_dir ), hDirACRend->sba_map_tc[ch_idx] )], + output_real[l * num_channels_dir + hDirACRend->sba_map_tc[ch_idx]] = + Madd_32_32( output_real[l * num_channels_dir + hDirACRend->sba_map_tc[ch_idx]], g, ( *( p_proto++ ) ) ); move32(); // ((p_gains_diff_q, p_proto_diff_q) >> Q1) -> (p_gains_diff_q + p_proto_diff_q - 31) - output_imag[add( imult1616( l, num_channels_dir ), hDirACRend->sba_map_tc[ch_idx] )] = - Madd_32_32( output_imag[add( imult1616( l, num_channels_dir ), hDirACRend->sba_map_tc[ch_idx] )], + output_imag[l * num_channels_dir + hDirACRend->sba_map_tc[ch_idx]] = + Madd_32_32( output_imag[l * num_channels_dir + hDirACRend->sba_map_tc[ch_idx]], g, ( *( p_proto++ ) ) ); move32(); } @@ -2396,6 +2407,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( *-----------------------------------------------------------------*/ test(); + /*q=(p_gains_dir_q + p_proto_dir_q - 31)*/ IF( hDirACRend->hOutSetup.is_loudspeaker_setup && hDirACRend->hoa_decoder != NULL ) { Word32 *p_real, *p_imag; @@ -2405,8 +2417,8 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( FOR( ch_idx = 0; ch_idx < hDirACRend->hOutSetup.nchan_out_woLFE; ch_idx++ ) { - p_real = RealBuffer[ch_idx][buf_idx]; - p_imag = ImagBuffer[ch_idx][buf_idx]; + p_real = RealBuffer[ch_idx][buf_idx]; /*q - Q2*/ + p_imag = ImagBuffer[ch_idx][buf_idx]; /*q - Q2*/ FOR( l = 0; l < num_freq_bands; l++ ) { @@ -2433,9 +2445,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - RealBuffer[ch_idx][buf_idx][l] = L_shr( output_real[add( imult1616( l, num_channels_dir ), ch_idx )], Q2 ); + RealBuffer[ch_idx][buf_idx][l] = L_shr( output_real[l * num_channels_dir + ch_idx], Q2 ); /* q - Q2*/ move32(); - ImagBuffer[ch_idx][buf_idx][l] = L_shr( output_imag[add( imult1616( l, num_channels_dir ), ch_idx )], Q2 ); + ImagBuffer[ch_idx][buf_idx][l] = L_shr( output_imag[l * num_channels_dir + ch_idx], Q2 ); /* q - Q2*/ move32(); } } @@ -2449,16 +2461,16 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( /* store estimates for next synthesis block */ IF( hodirac_flag ) { - Copy32( h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx, h_dirac_output_synthesis_state.gains_dir_prev_fx, imult1616( num_freq_bands, num_channels_dir ) * DIRAC_HO_NUMSECTORS ); + Copy32( h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx, h_dirac_output_synthesis_state.gains_dir_prev_fx, imult1616( num_freq_bands, num_channels_dir ) * DIRAC_HO_NUMSECTORS ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev*/ } ELSE { - Copy32( h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx, h_dirac_output_synthesis_state.gains_dir_prev_fx, imult1616( num_freq_bands, num_channels_dir ) ); + Copy32( h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx, h_dirac_output_synthesis_state.gains_dir_prev_fx, imult1616( num_freq_bands, num_channels_dir ) ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev*/ } *q_cy_cross_dir_smooth_prev = h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev; move16(); - Copy32( h_dirac_output_synthesis_state.cy_auto_diff_smooth_prev_fx, h_dirac_output_synthesis_state.gains_diff_prev_fx, imult1616( num_freq_bands_diff, num_channels_diff ) ); + Copy32( h_dirac_output_synthesis_state.cy_auto_diff_smooth_prev_fx, h_dirac_output_synthesis_state.gains_diff_prev_fx, imult1616( num_freq_bands_diff, num_channels_diff ) ); /* h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev*/ *q_cy_auto_diff_smooth_prev = h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev; move16(); @@ -2925,15 +2937,15 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( *------------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( - Word32 RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ - Word32 ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ + Word32 RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q(q_Cldfb)*/ + Word32 ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q(q_Cldfb)*/ SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ const Word16 nbslots, /* i : number of slots to process */ - Word32 *diffuseness_vector, /* i : diffuseness (needed for direction smoothing)*/ - Word32 *reference_power_smooth, + Word32 *diffuseness_vector, /* i : diffuseness (needed for direction smoothing) Q(31)*/ + Word32 *reference_power_smooth, /*Q(q_reference_power_smooth)*/ Word16 *q_reference_power_smooth, - Word32 qualityBasedSmFactor, + Word32 qualityBasedSmFactor, /*Q(31)*/ const Word16 enc_param_start_band, Word16 *q_Cldfb ) { @@ -3036,11 +3048,11 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( IF( diff_start_band != 0 ) { q_com = s_min( *q_reference_power_smooth, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ); - scale_sig32( reference_power_smooth, num_freq_bands, sub( q_com, *q_reference_power_smooth ) ); - scale_sig32( h_dirac_output_synthesis_state->reference_power_smooth_prev_fx, num_freq_bands, sub( q_com, *q_reference_power_smooth ) ); + scale_sig32( reference_power_smooth, num_freq_bands, sub( q_com, *q_reference_power_smooth ) ); /**q_reference_power_smooth->q_com*/ + scale_sig32( h_dirac_output_synthesis_state->reference_power_smooth_prev_fx, num_freq_bands, sub( q_com, *q_reference_power_smooth ) ); /**q_reference_power_smooth->q_com*/ scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, i_mult( num_freq_bands, nchan_target_psds ), - sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ); + sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth -> q_com*/ *q_reference_power_smooth = q_com; move16(); h_dirac_output_synthesis_state->reference_power_smooth_prev_q = q_com; @@ -3095,7 +3107,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( q_target_power_y1 = add( sub( Q31, exp1 ), sub( q_com, sub( Q31, exp ) ) ); q_target_power_y1 = sub( q_target_power_y1, 1 ); - target_power_y = L_add( L_shl( target_power_y, sub( s_min( q_target_power_y1, q_target_power_y ), q_target_power_y ) ), L_shl( target_power_y1, sub( s_min( q_target_power_y1, q_target_power_y ), q_target_power_y1 ) ) ); + target_power_y = L_add( L_shl( target_power_y, sub( s_min( q_target_power_y1, q_target_power_y ), q_target_power_y ) ), L_shl( target_power_y1, sub( s_min( q_target_power_y1, q_target_power_y ), q_target_power_y1 ) ) ); /*min(q_target_power_y1, q_target_power_y )*/ exp = s_min( q_target_power_y1, q_target_power_y ); } ELSE @@ -3190,8 +3202,8 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( exp = 0; move16(); - tmp = BASOP_Util_Divide3232_Scale( weightedDirectionSmoothness, L_add( sumWeight, EPSILON_FX ), &exp ); - smoothedDirectionSmoothness = L_shl_sat( L_deposit_l( tmp ), add( sub( Q31, Q15 ), exp ) ); // Q31 + tmp = BASOP_Util_Divide3232_Scale( weightedDirectionSmoothness, L_add( sumWeight, EPSILON_FX ), &exp ); /*Q(15-exp)*/ + smoothedDirectionSmoothness = L_shl_sat( L_deposit_l( tmp ), add( sub( Q31, Q15 ), exp ) ); // Q31 h_dirac_output_synthesis_state->direction_smoothness_prev_fx[l] = smoothedDirectionSmoothness; // Q31 move32(); @@ -3235,20 +3247,20 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( IF( EQ_32( *( p_power_smooth_prev ), EPSILON_FX ) ) { p_power_smooth_prev++; - L_tmp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q31, EPSILON_FX, &exp ); - exp_arr[add( i_mult( k, num_freq_bands ), l )] = exp; + L_tmp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q31, EPSILON_FX, &exp ); /*Q=31-(exp-(31-q_proto_power_smooth))*/ + exp_arr[k * num_freq_bands + l] = exp; move16(); - *( p_power_smooth++ ) = L_tmp; + *( p_power_smooth++ ) = L_tmp; /*Q=31-(exp-(31-q_proto_power_smooth))*/ move32(); } ELSE { - L_tmp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q31, *( p_power_smooth_prev++ ), &exp ); - exp_arr[add( i_mult( k, num_freq_bands ), l )] = exp; + L_tmp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q31, *( p_power_smooth_prev++ ), &exp ); /*Q=31-(exp-(31-q_proto_power_smooth))*/ + exp_arr[k * num_freq_bands + l] = exp; move16(); - *( p_power_smooth++ ) = L_tmp; + *( p_power_smooth++ ) = L_tmp; /*Q=31-(exp-(31-q_proto_power_smooth))*/ move32(); } } @@ -3264,9 +3276,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - IF( GT_16( exp_arr[add( i_mult( k, num_freq_bands ), l )], min_exp ) ) + IF( GT_16( exp_arr[k * num_freq_bands + l], min_exp ) ) { - min_exp = exp_arr[add( i_mult( k, num_freq_bands ), l )]; + min_exp = exp_arr[k * num_freq_bands + l]; move16(); } } @@ -3279,7 +3291,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - *p_power_smooth = L_shr( *p_power_smooth, sub( min_exp, exp_arr[add( i_mult( k, num_freq_bands ), l )] ) ); + *p_power_smooth = L_shr( *p_power_smooth, sub( min_exp, exp_arr[k * num_freq_bands + l] ) ); /*(31-(exp-(31-q_proto_power_smooth)))->(31-(min_exp-(31-q_proto_power_smooth)))*/ move32(); p_power_smooth++; q_tmp = add( sub( Q31, min_exp ), sub( Q31, h_dirac_output_synthesis_state->proto_power_smooth_q ) ); @@ -3305,12 +3317,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( { q_cy_auto_dir_smooth_prev_local[k] = getScaleFactor32( p_cy_auto_dir_smooth_prev + imult1616( k, num_freq_bands ), num_freq_bands ); move16(); - scale_sig32( p_cy_auto_dir_smooth_prev + imult1616( k, num_freq_bands ), num_freq_bands, q_cy_auto_dir_smooth_prev_local[k] ); + scale_sig32( p_cy_auto_dir_smooth_prev + imult1616( k, num_freq_bands ), num_freq_bands, q_cy_auto_dir_smooth_prev_local[k] ); /*q_cy_auto_dir_smooth_prev_local[k]+h_dirac_output_synthesis_state -> q_cy_auto_dir_smooth_prev*/ q_cy_auto_dir_smooth_prev_local[k] = add( q_cy_auto_dir_smooth_prev_local[k], h_dirac_output_synthesis_state->q_cy_auto_dir_smooth_prev ); move16(); q_com = s_min( q_cy_auto_dir_smooth_local[k], q_cy_auto_dir_smooth_prev_local[k] ); - scale_sig32( p_cy_auto_dir_smooth + imult1616( k, num_freq_bands ), num_freq_bands, sub( q_com, q_cy_auto_dir_smooth_local[k] ) ); - scale_sig32( p_cy_auto_dir_smooth_prev + imult1616( k, num_freq_bands ), num_freq_bands, sub( q_com, q_cy_auto_dir_smooth_prev_local[k] ) ); + scale_sig32( p_cy_auto_dir_smooth + imult1616( k, num_freq_bands ), num_freq_bands, sub( q_com, q_cy_auto_dir_smooth_local[k] ) ); /*q_cy_auto_dir_smooth_local -> q_com*/ + scale_sig32( p_cy_auto_dir_smooth_prev + imult1616( k, num_freq_bands ), num_freq_bands, sub( q_com, q_cy_auto_dir_smooth_prev_local[k] ) ); /*q_cy_auto_dir_smooth_prev_local -> q_com*/ q_cy_auto_dir_smooth_local[k] = q_cy_auto_dir_smooth_prev_local[k] = q_com; move16(); move16(); @@ -3320,8 +3332,8 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( p_cy_cross_dir_smooth = h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx; p_cy_cross_dir_smooth_prev = h_dirac_output_synthesis_state->cy_cross_dir_smooth_prev_fx; q_com = s_min( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth_prev ); - scale_sig32( p_cy_cross_dir_smooth, imult1616( nchan_out_woLFE, num_freq_bands ), sub( q_com, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); - scale_sig32( p_cy_cross_dir_smooth_prev, imult1616( nchan_out_woLFE, num_freq_bands ), sub( q_com, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth_prev ) ); + scale_sig32( p_cy_cross_dir_smooth, imult1616( nchan_out_woLFE, num_freq_bands ), sub( q_com, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth -> q_com*/ + scale_sig32( p_cy_cross_dir_smooth_prev, imult1616( nchan_out_woLFE, num_freq_bands ), sub( q_com, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth_prev ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth_prev -> q_com*/ h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth_prev = q_com; move16(); move16(); @@ -3329,8 +3341,8 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( p_cy_auto_diff_smooth = h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx; p_cy_auto_diff_smooth_prev = h_dirac_output_synthesis_state->cy_auto_diff_smooth_prev_fx; q_com = s_min( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev ); - scale_sig32( p_cy_auto_diff_smooth, imult1616( nchan_out_woLFE, num_freq_bands ), sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ); - scale_sig32( p_cy_auto_diff_smooth_prev, imult1616( nchan_out_woLFE, num_freq_bands ), sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev ) ); + scale_sig32( p_cy_auto_diff_smooth, imult1616( nchan_out_woLFE, num_freq_bands ), sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth -> q_com*/ + scale_sig32( p_cy_auto_diff_smooth_prev, imult1616( nchan_out_woLFE, num_freq_bands ), sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev ) ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev -> q_com*/ h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev = q_com; move16(); move16(); @@ -3352,7 +3364,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( Mpy_32_32( g2, ( *( p_cy_cross_dir_smooth_prev ) ) ) ); // (Q31, q_cy_cross_dir_smooth_prev) -> q_cy_cross_dir_smooth_prev move32(); - power_smooth_temp = L_shl( *p_power_smooth, norm_l( *p_power_smooth ) ); + power_smooth_temp = L_shl( *p_power_smooth, norm_l( *p_power_smooth ) ); // proto_power_smooth_q + norm_l( *p_power_smooth ) L_tmp = Mpy_32_32( power_smooth_temp, ( *( p_cy_auto_dir_smooth_prev++ ) ) ); // proto_power_smooth_q + norm_l( *p_power_smooth ) ) + q_cy_auto_dir_smooth_prev_local - 31 exp = sub( Q31, sub( add( add( h_dirac_output_synthesis_state->proto_power_smooth_q, norm_l( *p_power_smooth ) ), q_cy_auto_dir_smooth_prev_local[k] ), @@ -3371,13 +3383,13 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( } ELSE IF( GT_32( *( p_gains_dir ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q ) ), Q5 ) ) ) ) { - *( p_gains_dir ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q ) ), Q5 ) ); + *( p_gains_dir ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q ) ), Q5 ) ); /*26 + h_dirac_output_synthesis_state->gains_dir_prev_q + 1 + 5 - 32 -> h_dirac_output_synthesis_state->gains_dir_prev_q*/ move32(); } IF( *( p_cy_cross_dir_smooth_prev++ ) < 0 ) { - *( p_gains_dir ) = L_negate( *( p_gains_dir ) ); + *( p_gains_dir ) = L_negate( *( p_gains_dir ) ); /*h_dirac_output_synthesis_state->gains_dir_prev_q*/ move32(); } p_gains_dir++; @@ -3406,9 +3418,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( *( p_gains_diff ) = 0; move32(); } - ELSE IF( GT_32( *( p_gains_diff ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q ) ), Q5 ) ) ) ) + ELSE IF( GT_32( *( p_gains_diff ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q ) ), Q5 ) ) ) ) /*h_dirac_output_synthesis_state->gains_diff_prev_q*/ { - *( p_gains_diff ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q ) ), Q5 ) ); + *( p_gains_diff ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q ) ), Q5 ) ); /*h_dirac_output_synthesis_state->gains_diff_prev_q*/ move32(); } p_gains_diff++; @@ -3422,10 +3434,10 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( move32(); g2 = L_sub( ONE_IN_Q31, g1 ); // Q31 W_temp = W_add( W_mult_32_32( g1, ( *( p_cy_auto_dir_smooth++ ) ) ), - W_mult_32_32( g2, ( *( p_cy_auto_dir_smooth_prev ) ) ) ); + W_mult_32_32( g2, ( *( p_cy_auto_dir_smooth_prev ) ) ) ); /*32+q_cy_auto_dir_smooth_prev_local*/ q_tmp = W_norm( W_temp ); - L_tmp = W_extract_h( W_shl( W_temp, q_tmp ) ); // q_cy_auto_dir_smooth_prev_local + q_tmp - *( p_cy_auto_dir_smooth_prev++ ) = L_shr_r( L_tmp, q_tmp ); + L_tmp = W_extract_h( W_shl( W_temp, q_tmp ) ); // q_cy_auto_dir_smooth_prev_local + q_tmp + *( p_cy_auto_dir_smooth_prev++ ) = L_shr_r( L_tmp, q_tmp ); // q_cy_auto_dir_smooth_prev_local move32(); *( p_cy_cross_dir_smooth_prev ) = L_add( Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ), @@ -3448,15 +3460,15 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( *( p_gains_dir ) = 0; move32(); } - ELSE IF( GT_32( *( p_gains_dir ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q ) ), Q5 ) ) ) ) + ELSE IF( GT_32( *( p_gains_dir ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q ) ), Q5 ) ) ) ) /*gains_dir_prev_q*/ { - *( p_gains_dir ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q ) ), Q5 ) ); + *( p_gains_dir ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q ) ), Q5 ) ); /*gains_dir_prev_q*/ move32(); } IF( *( p_cy_cross_dir_smooth_prev++ ) < 0 ) { - *( p_gains_dir ) = L_negate( *( p_gains_dir ) ); + *( p_gains_dir ) = L_negate( *( p_gains_dir ) ); /*gains_dir_prev_q*/ move32(); } p_gains_dir++; @@ -3466,14 +3478,14 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( Mpy_32_32( g2, ( *( p_cy_auto_diff_smooth_prev ) ) ) ); // (Q31, q_cy_auto_diff_smooth_prev) -> q_cy_auto_diff_smooth_prev move32(); - power_smooth_temp = L_shl( *p_power_smooth, norm_l( *p_power_smooth ) ); + power_smooth_temp = L_shl( *p_power_smooth, norm_l( *p_power_smooth ) ); // proto_power_smooth_q + norm_l( *p_power_smooth ) L_tmp = Mpy_32_32( power_smooth_temp, ( *( p_cy_auto_diff_smooth_prev++ ) ) ); // proto_power_smooth_q + norm_l( *p_power_smooth ) ) + q_cy_auto_diff_smooth_prev - 31 exp = sub( Q31, sub( add( add( h_dirac_output_synthesis_state->proto_power_smooth_q, norm_l( *p_power_smooth ) ), h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev ), Q31 ) ); p_power_smooth++; - *( p_gains_diff ) = Sqrt32( L_tmp, &exp ); + *( p_gains_diff ) = Sqrt32( L_tmp, &exp ); /*31-exp*/ move32(); *( p_gains_diff ) = L_shl_sat( *( p_gains_diff ), sub( h_dirac_output_synthesis_state->gains_diff_prev_q, sub( Q31, exp ) ) ); // gains_diff_prev_q move32(); @@ -3483,9 +3495,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( *( p_gains_diff ) = 0; move32(); } - ELSE IF( GT_32( *( p_gains_diff ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q ) ), Q5 ) ) ) ) + ELSE IF( GT_32( *( p_gains_diff ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q ) ), Q5 ) ) ) ) // gains_diff_prev_q { - *( p_gains_diff ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q ) ), Q5 ) ); + *( p_gains_diff ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q ) ), Q5 ) ); // gains_diff_prev_q move32(); } p_gains_diff++; @@ -3567,7 +3579,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( { g = L_add( Mpy_32_32( g1, *( p_gain_1++ ) ), Mpy_32_32( g2, *( p_gain_2++ ) ) ); // (Q31, gains_diff_prev_q) -> gains_diff_prev_q Cldfb_RealBuffer64_fx[k][buf_idx][l] = W_add( Cldfb_RealBuffer64_fx[k][buf_idx][l], - W_mult0_32_32( g, ( *( p_power_smooth++ ) ) ) ); // (gains_diff_prev_q, q_proto_direct_buffer) >> Q1 -> gains_diff_prev_q + q_proto_direct_buffer - 32 + W_mult0_32_32( g, ( *( p_power_smooth++ ) ) ) ); // (gains_diff_prev_q, q_proto_direct_buffer) -> gains_diff_prev_q + q_proto_direct_buffer move64(); if ( LT_64( W_temp, W_abs( Cldfb_RealBuffer64_fx[k][buf_idx][l] ) ) ) @@ -3576,12 +3588,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( } Cldfb_ImagBuffer64_fx[k][buf_idx][l] = W_add( Cldfb_ImagBuffer64_fx[k][buf_idx][l], - W_mult0_32_32( g, ( *( p_power_smooth++ ) ) ) ); // (gains_diff_prev_q, q_proto_direct_buffer) >> Q1 -> gains_diff_prev_q + q_proto_direct_buffer - 32 + W_mult0_32_32( g, ( *( p_power_smooth++ ) ) ) ); // (gains_diff_prev_q, q_proto_direct_buffer) -> gains_diff_prev_q + q_proto_direct_buffer move64(); if ( LT_64( W_temp, W_abs( Cldfb_ImagBuffer64_fx[k][buf_idx][l] ) ) ) { - W_temp = W_abs( Cldfb_ImagBuffer64_fx[k][buf_idx][l] ); + W_temp = W_abs( Cldfb_ImagBuffer64_fx[k][buf_idx][l] ); // gains_diff_prev_q + q_proto_direct_buffer } } } @@ -3593,9 +3605,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - RealBuffer[k][buf_idx][l] = W_extract_h( W_shl( Cldfb_RealBuffer64_fx[k][buf_idx][l], q_align ) ); + RealBuffer[k][buf_idx][l] = W_extract_h( W_shl( Cldfb_RealBuffer64_fx[k][buf_idx][l], q_align ) ); /*( ( ( h_dirac_output_synthesis_state->proto_direct_buffer_f_q+h_dirac_output_synthesis_state->gains_dir_prev_q )+ q_align )- 32 )*/ move32(); - ImagBuffer[k][buf_idx][l] = W_extract_h( W_shl( Cldfb_ImagBuffer64_fx[k][buf_idx][l], q_align ) ); + ImagBuffer[k][buf_idx][l] = W_extract_h( W_shl( Cldfb_ImagBuffer64_fx[k][buf_idx][l], q_align ) ); /*( ( ( h_dirac_output_synthesis_state->proto_direct_buffer_f_q+h_dirac_output_synthesis_state->gains_dir_prev_q )+ q_align )- 32 )*/ move32(); } } @@ -3609,8 +3621,8 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( *-----------------------------------------------------------------*/ /* store estimates for next synthesis block */ - Copy32( gains_dir, h_dirac_output_synthesis_state->gains_dir_prev_fx, imult1616( num_freq_bands, nchan_out_woLFE ) ); - Copy32( gains_diff, h_dirac_output_synthesis_state->gains_diff_prev_fx, imult1616( num_freq_bands, nchan_out_woLFE ) ); + Copy32( gains_dir, h_dirac_output_synthesis_state->gains_dir_prev_fx, imult1616( num_freq_bands, nchan_out_woLFE ) ); /*gains_dir_prev_q*/ + Copy32( gains_diff, h_dirac_output_synthesis_state->gains_diff_prev_fx, imult1616( num_freq_bands, nchan_out_woLFE ) ); /*gains_diff_prev_q*/ /* reset values */ set_zero_fx( h_dirac_output_synthesis_state->proto_power_smooth_fx, imult1616( num_freq_bands, num_protos_dir ) ); @@ -3622,7 +3634,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( minimum_fx( q_cy_auto_dir_smooth_prev_local, nchan_out_woLFE, &h_dirac_output_synthesis_state->q_cy_auto_dir_smooth_prev ); FOR( k = 0; k < nchan_out_woLFE; k++ ) { - scale_sig32( h_dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx + ( k * num_freq_bands ), num_freq_bands, sub( h_dirac_output_synthesis_state->q_cy_auto_dir_smooth_prev, q_cy_auto_dir_smooth_prev_local[k] ) ); + scale_sig32( h_dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx + ( k * num_freq_bands ), num_freq_bands, sub( h_dirac_output_synthesis_state->q_cy_auto_dir_smooth_prev, q_cy_auto_dir_smooth_prev_local[k] ) ); /*q_cy_auto_dir_smooth_prev_local[k] -> h_dirac_output_synthesis_state->q_cy_auto_dir_smooth_prev*/ } set_zero_fx( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, imult1616( num_freq_bands, nchan_out_woLFE ) ); @@ -4003,9 +4015,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( #ifdef IVAS_FLOAT_FIXED static void ivas_dirac_dec_get_response_split_order_fx( - const Word16 azimuth, - const Word16 elevation, - Word32 *response, + const Word16 azimuth, /*q0*/ + const Word16 elevation, /*q0*/ + Word32 *response, /*q_response*/ const Word16 shd_rot_max_order, const Word32 *p_Rmat /* Q30 */, Word16 *q_response ) @@ -4040,13 +4052,13 @@ static void ivas_dirac_dec_get_response_split_order_fx( IF( GT_16( index_elevation, 90 ) ) { - e = -ONE_IN_Q14; + e = -ONE_IN_Q14; /*-1 in Q14*/ move16(); el = sub( 180, index_elevation ); } ELSE { - e = ONE_IN_Q14; + e = ONE_IN_Q14; /*1 in Q14*/ move16(); el = index_elevation; move16(); @@ -4055,21 +4067,21 @@ static void ivas_dirac_dec_get_response_split_order_fx( IF( GT_16( index_azimuth, 180 ) ) { az = sub( 360, index_azimuth ); - f = -ONE_IN_Q30; + f = -ONE_IN_Q30; /*-1 Q30*/ move32(); } ELSE { az = index_azimuth; move16(); - f = ONE_IN_Q30; + f = ONE_IN_Q30; /*1 Q30*/ move32(); } // dirac_gains_trg_term_int Q30 cos_1 = L_shr( dirac_gains_trg_term_int[az][0], 1 ); // Q29 cos_2 = L_shl( Mpy_32_32( cos_1, cos_1 ), 2 ); // Q29 - sin_1 = Mpy_32_32( f, dirac_gains_trg_term_int[az][1] ); // Q29] + sin_1 = Mpy_32_32( f, dirac_gains_trg_term_int[az][1] ); // Q29 cos_az[0] = cos_1; // Q29 move32(); @@ -4173,13 +4185,13 @@ static void ivas_dirac_dec_get_response_split_order_fx( IF( GT_16( index_elevation, 90 ) ) { - e = -ONE_IN_Q14; + e = -ONE_IN_Q14; /*-1 Q14*/ move16(); el = sub( 180, index_elevation ); } ELSE { - e = ONE_IN_Q14; + e = ONE_IN_Q14; /*1 Q14*/ move16(); el = index_elevation; move16(); @@ -4188,14 +4200,14 @@ static void ivas_dirac_dec_get_response_split_order_fx( IF( GT_16( index_azimuth, 180 ) ) { az = sub( 360, index_azimuth ); - f = -ONE_IN_Q30; + f = -ONE_IN_Q30; /*-1 Q30*/ move32(); } ELSE { az = index_azimuth; move16(); - f = ONE_IN_Q30; + f = ONE_IN_Q30; /*1 Q30*/ move32(); } @@ -4452,10 +4464,10 @@ void ivas_dirac_dec_compute_directional_responses_fx( const Word16 *azimuth, const Word16 *elevation, const Word16 md_idx, - const Word32 *surCohRatio_fx, + const Word32 *surCohRatio_fx, /*i:Q_surCohRatio*/ Word16 Q_surCohRatio, const Word16 shd_rot_max_order, /* i : split-order rotation method */ - const Word32 *p_Rmat, /* i : rotation matrix */ + const Word32 *p_Rmat, /* i : rotation matrix Q30*/ const Word16 hodirac_flag /* i : flag to indicate HO-DirAC mode */ ) { @@ -4515,9 +4527,9 @@ void ivas_dirac_dec_compute_directional_responses_fx( move16(); IF( EQ_16( hSpatParamRendCom->numParametricDirections, 2 ) ) { - azimuth2 = hSpatParamRendCom->azimuth2[md_idx]; + azimuth2 = hSpatParamRendCom->azimuth2[md_idx]; /*q0*/ move16(); - elevation2 = hSpatParamRendCom->elevation2[md_idx]; + elevation2 = hSpatParamRendCom->elevation2[md_idx]; /*q0*/ move16(); } @@ -4527,11 +4539,15 @@ void ivas_dirac_dec_compute_directional_responses_fx( FOR( k = 0; k < hSpatParamRendCom->num_freq_bands; ++k ) { + test(); if ( masa_band_mapping != NULL && EQ_16( k, MASA_band_grouping_24[masa_band_mapping[add( codingBand, 1 )]] ) ) { codingBand = add( codingBand, 1 ); } + test(); + test(); + test(); IF( masa_band_mapping != NULL && GT_16( k, MASA_band_grouping_24[masa_band_mapping[codingBand]] ) && LT_16( k, MASA_band_grouping_24[masa_band_mapping[add( codingBand, 1 )]] ) && NE_16( k, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ) ) @@ -4541,20 +4557,20 @@ void ivas_dirac_dec_compute_directional_responses_fx( { mvr2r_inc_fixed( &hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx[k - 1], hSpatParamRendCom->num_freq_bands, &hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx[k], - hSpatParamRendCom->num_freq_bands, num_channels_dir ); + hSpatParamRendCom->num_freq_bands, num_channels_dir ); /*direct_response_square_q*/ } mvr2r_inc_fixed( &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[k - 1], hSpatParamRendCom->num_freq_bands, &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[k], - hSpatParamRendCom->num_freq_bands, num_channels_dir ); + hSpatParamRendCom->num_freq_bands, num_channels_dir ); /*direct_response_q*/ } ELSE { /* HOA3 PANNING */ IF( EQ_16( hDirACRend->panningConf, DIRAC_PANNING_HOA3 ) ) { - set32_fx( direct_response_hoa_fx, ONE_IN_Q29, MAX_OUTPUT_CHANNELS ); - set32_fx( direct_response_dir2_fx, ONE_IN_Q29, MAX_OUTPUT_CHANNELS ); + set32_fx( direct_response_hoa_fx, ONE_IN_Q29, MAX_OUTPUT_CHANNELS ); /*q29*/ + set32_fx( direct_response_dir2_fx, ONE_IN_Q29, MAX_OUTPUT_CHANNELS ); /*q29*/ Q_direct_response_hoa = Q29; move16(); @@ -4590,11 +4606,11 @@ void ivas_dirac_dec_compute_directional_responses_fx( test(); IF( masa_band_mapping == NULL && EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - mvr2r_inc_fixed( direct_response_hoa_fx, 1, &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[k], hSpatParamRendCom->num_freq_bands, num_channels_dir ); + mvr2r_inc_fixed( direct_response_hoa_fx, 1, &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[k], hSpatParamRendCom->num_freq_bands, num_channels_dir ); /*Q_direct_response_hoa*/ IF( hodirac_flag ) { - mvr2r_inc_fixed( direct_response_dir2_fx, 1, &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[add( k, i_mult( hSpatParamRendCom->num_freq_bands, num_channels_dir ) )], hSpatParamRendCom->num_freq_bands, num_channels_dir ); + mvr2r_inc_fixed( direct_response_dir2_fx, 1, &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[k + hSpatParamRendCom->num_freq_bands * num_channels_dir], hSpatParamRendCom->num_freq_bands, num_channels_dir ); /*Q_direct_response_dir2*/ } } ELSE IF( ( ( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) && ( masa_band_mapping != NULL ) ) || @@ -4603,7 +4619,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( /* Synthesize the first direction */ IF( GT_16( Q_direct_response_hoa, Q29 ) ) { - Scale_sig32( direct_response_hoa_fx, MAX_OUTPUT_CHANNELS, sub( Q_direct_response_hoa, Q29 ) ); + Scale_sig32( direct_response_hoa_fx, MAX_OUTPUT_CHANNELS, sub( Q_direct_response_hoa, Q29 ) ); /*Q_direct_response_hoa->q29*/ Q_direct_response_hoa = Q29; move16(); exp_direct_response_hoa = sub( 31, Q_direct_response_hoa ); @@ -4617,7 +4633,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( { IF( GT_16( Q_direct_response_dir2, Q29 ) ) { - Scale_sig32( direct_response_dir2_fx, MAX_OUTPUT_CHANNELS, sub( Q_direct_response_dir2, Q29 ) ); + Scale_sig32( direct_response_dir2_fx, MAX_OUTPUT_CHANNELS, sub( Q_direct_response_dir2, Q29 ) ); /*Q_direct_response_dir2->q29*/ Q_direct_response_dir2 = Q29; move16(); exp_direct_response_dir2 = sub( 31, Q_direct_response_dir2 ); @@ -4627,7 +4643,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( exp_direct_response_hoa = sub( 31, Q_direct_response_hoa ); /* Combine gains from the two directions */ - totalDirect_fx = L_add( hSpatParamRendCom->energy_ratio1_fx[md_idx][k], hSpatParamRendCom->energy_ratio2_fx[md_idx][k] ); + totalDirect_fx = L_add( hSpatParamRendCom->energy_ratio1_fx[md_idx][k], hSpatParamRendCom->energy_ratio2_fx[md_idx][k] ); /*q30*/ IF( totalDirect_fx == 0 ) { totalDirect_fx = EPSILON_FIX; @@ -4635,12 +4651,12 @@ void ivas_dirac_dec_compute_directional_responses_fx( } Word16 var_a, var_b, exp_1, exp_2; - var_a = BASOP_Util_Divide3232_Scale( hSpatParamRendCom->energy_ratio1_fx[md_idx][k], totalDirect_fx, &exp_1 ); - var_b = BASOP_Util_Divide3232_Scale( hSpatParamRendCom->energy_ratio2_fx[md_idx][k], totalDirect_fx, &exp_2 ); + var_a = BASOP_Util_Divide3232_Scale( hSpatParamRendCom->energy_ratio1_fx[md_idx][k], totalDirect_fx, &exp_1 ); /*15-exp_1*/ + var_b = BASOP_Util_Divide3232_Scale( hSpatParamRendCom->energy_ratio2_fx[md_idx][k], totalDirect_fx, &exp_2 ); /*15-exp_2*/ - directRatio_fx[0] = L_deposit_h( var_a ); + directRatio_fx[0] = L_deposit_h( var_a ); /*15-exp_1+16*/ move32(); - directRatio_fx[1] = L_deposit_h( var_b ); + directRatio_fx[1] = L_deposit_h( var_b ); /*15-exp_2+16*/ move32(); Word32 temp_a; @@ -4650,13 +4666,13 @@ void ivas_dirac_dec_compute_directional_responses_fx( FOR( l = 0; l < num_channels_dir; l++ ) { - direct_response_hoa_fx[l] = Mpy_32_32( direct_response_hoa_fx[l], directRatio_fx[0] ); + direct_response_hoa_fx[l] = Mpy_32_32( direct_response_hoa_fx[l], directRatio_fx[0] ); /*Q(Q_direct_response_hoa+31-exp_1-31)*/ move32(); exp_arr[l] = add( exp_1, sub( 31, Q_direct_response_hoa ) ); move16(); - temp_a = Mpy_32_32( directRatio_fx[1], direct_response_dir2_fx[l] ); + temp_a = Mpy_32_32( directRatio_fx[1], direct_response_dir2_fx[l] ); /*Q(Q_direct_response_dir2+31-exp_2-31)*/ exp_temp_a = add( exp_2, sub( 31, Q_direct_response_dir2 ) ); - direct_response_hoa_fx[l] = BASOP_Util_Add_Mant32Exp( direct_response_hoa_fx[l], exp_arr[l], temp_a, exp_temp_a, &final_exp ); + direct_response_hoa_fx[l] = BASOP_Util_Add_Mant32Exp( direct_response_hoa_fx[l], exp_arr[l], temp_a, exp_temp_a, &final_exp ); /*Q(31-final_exp)*/ move32(); exp_arr[l] = final_exp; move16(); @@ -4667,7 +4683,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( maximum_fx( exp_arr, MAX_OUTPUT_CHANNELS, &max_exp ); FOR( l = 0; l < MAX_OUTPUT_CHANNELS; l++ ) { - direct_response_hoa_fx[l] = L_shr( direct_response_hoa_fx[l], sub( max_exp, exp_arr[l] ) ); + direct_response_hoa_fx[l] = L_shr( direct_response_hoa_fx[l], sub( max_exp, exp_arr[l] ) ); /*Q(31-exp_arr[l])->Q(31-max_exp)*/ move32(); } exp_direct_response_hoa = max_exp; @@ -4707,8 +4723,8 @@ void ivas_dirac_dec_compute_directional_responses_fx( set16_fx( exp_arr, 0, MAX_OUTPUT_CHANNELS ); FOR( l = 0; l < num_channels_dir; l++ ) { - temp_1 = Mpy_32_32( direct_response_temp_fx[l], hMasaIsm->energy_ratio_ism_fx[dir][md_idx][k] ); // Q28 - direct_response_ism_fx[l] = BASOP_Util_Add_Mant32Exp( direct_response_ism_fx[l], exp_direct_response_ism, temp_1, exp_direct_response_temp + 1, &exp_temp ); + temp_1 = Mpy_32_32( direct_response_temp_fx[l], hMasaIsm->energy_ratio_ism_fx[dir][md_idx][k] ); // Q28 + direct_response_ism_fx[l] = BASOP_Util_Add_Mant32Exp( direct_response_ism_fx[l], exp_direct_response_ism, temp_1, add( exp_direct_response_temp, 1 ), &exp_temp ); //(31-exp_temp) move32(); exp_arr[l] = exp_temp; move16(); @@ -4718,38 +4734,38 @@ void ivas_dirac_dec_compute_directional_responses_fx( maximum_fx( exp_arr, num_channels_dir, &max_exp ); FOR( l = 0; l < num_channels_dir; l++ ) { - direct_response_ism_fx[l] = L_shr( direct_response_ism_fx[l], max_exp - exp_arr[l] ); + direct_response_ism_fx[l] = L_shr( direct_response_ism_fx[l], sub( max_exp, exp_arr[l] ) ); /*Q(31- exp_arr[l])->Q(31-max_exp)*/ move32(); } exp_direct_response_ism = max_exp; move16(); } Word16 exp_1, exp_2; - masaDirect_fx = hSpatParamRendCom->energy_ratio1_fx[md_idx][k]; + masaDirect_fx = hSpatParamRendCom->energy_ratio1_fx[md_idx][k]; /*q30*/ move32(); if ( masaDirect_fx == 0 ) { - masaDirect_fx = L_add( masaDirect_fx, EPSILLON_FX ); + masaDirect_fx = L_add( masaDirect_fx, EPSILLON_FX ); /*q30*/ } if ( EQ_16( hSpatParamRendCom->numParametricDirections, 2 ) ) { - masaDirect_fx = L_add( masaDirect_fx, hSpatParamRendCom->energy_ratio2_fx[md_idx][k] ); + masaDirect_fx = L_add( masaDirect_fx, hSpatParamRendCom->energy_ratio2_fx[md_idx][k] ); /*q30*/ } - ismDirect_fx = hMasaIsm->energy_ratio_ism_fx[0][md_idx][k]; + ismDirect_fx = hMasaIsm->energy_ratio_ism_fx[0][md_idx][k]; /*q30*/ move32(); FOR( dir = 1; dir < hSpatParamRendCom->numIsmDirections; dir++ ) { - ismDirect_fx = L_add( ismDirect_fx, hMasaIsm->energy_ratio_ism_fx[dir][md_idx][k] ); + ismDirect_fx = L_add( ismDirect_fx, hMasaIsm->energy_ratio_ism_fx[dir][md_idx][k] ); /*q30*/ } - totalDirect_fx = L_add_sat( masaDirect_fx, ismDirect_fx ); // saturating as 1.0 (Q30) + 1.0 (Q30) is observed + totalDirect_fx = L_add_sat( masaDirect_fx, ismDirect_fx ); /*q30*/ // saturating as 1.0 (Q30) + 1.0 (Q30) is observed Word16 var_a = 0, var_b = 0; - var_a = BASOP_Util_Divide3232_Scale( masaDirect_fx, totalDirect_fx, &exp_1 ); - var_b = BASOP_Util_Divide3232_Scale( ismDirect_fx, totalDirect_fx, &exp_2 ); - directRatio_fx[0] = L_deposit_h( var_a ); + var_a = BASOP_Util_Divide3232_Scale( masaDirect_fx, totalDirect_fx, &exp_1 ); /*Q(15-exp_1)*/ + var_b = BASOP_Util_Divide3232_Scale( ismDirect_fx, totalDirect_fx, &exp_2 ); /*q(15-exp_2)*/ + directRatio_fx[0] = L_deposit_h( var_a ); // Q(31-exp_1) move32(); - directRatio_fx[1] = L_deposit_h( var_b ); + directRatio_fx[1] = L_deposit_h( var_b ); // Q(31-exp_2) move32(); Word32 temp_2, temp_3; @@ -4757,14 +4773,14 @@ void ivas_dirac_dec_compute_directional_responses_fx( set16_fx( exp_arr, exp_direct_response_hoa, MAX_OUTPUT_CHANNELS ); FOR( l = 0; l < num_channels_dir; l++ ) { - direct_response_hoa_fx[l] = Mpy_32_32( direct_response_hoa_fx[l], directRatio_fx[0] ); + direct_response_hoa_fx[l] = Mpy_32_32( direct_response_hoa_fx[l], directRatio_fx[0] ); /*31-exp_direct_response_hoa+31-exp_1-31*/ move32(); exp_arr[l] = add( exp_direct_response_hoa, exp_1 ); move16(); - temp_2 = Mpy_32_32( directRatio_fx[1], direct_response_ism_fx[l] ); - temp_3 = BASOP_Util_Add_Mant32Exp( direct_response_hoa_fx[l], exp_arr[l], temp_2, exp_2 + exp_direct_response_ism, &exp_temp_3 ); + temp_2 = Mpy_32_32( directRatio_fx[1], direct_response_ism_fx[l] ); /*31-exp_direct_response_ism+31-exp_2-31*/ + temp_3 = BASOP_Util_Add_Mant32Exp( direct_response_hoa_fx[l], exp_arr[l], temp_2, add( exp_2, exp_direct_response_ism ), &exp_temp_3 ); /*31-exp_temp_3*/ - direct_response_hoa_fx[l] = temp_3; + direct_response_hoa_fx[l] = temp_3; /*31-exp_temp_3*/ move32(); exp_arr[l] = exp_temp_3; move16(); @@ -4775,7 +4791,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( maximum_fx( exp_arr, num_channels_dir, &max_exp ); FOR( l = 0; l < num_channels_dir; l++ ) { - direct_response_hoa_fx[l] = L_shr( direct_response_hoa_fx[l], sub( max_exp, exp_arr[l] ) ); + direct_response_hoa_fx[l] = L_shr( direct_response_hoa_fx[l], sub( max_exp, exp_arr[l] ) ); /*q(31-exp_arr[l])->q(31-max_exp)*/ move32(); } Q_direct_response_hoa = sub( 31, max_exp ); @@ -4794,9 +4810,9 @@ void ivas_dirac_dec_compute_directional_responses_fx( { exp = 0; move16(); - var_a = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30, 1, L_negate( surCohRatio_fx[k] ), exp_surCohRatio, &exp ); - var_b = Sqrt32( var_a, &exp ); - direct_response_hoa_fx[l] = Mpy_32_32( direct_response_hoa_fx[l], var_b ); + var_a = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30 /*1 Q30*/, 1, L_negate( surCohRatio_fx[k] ), exp_surCohRatio, &exp ); /*q(31-exp)*/ + var_b = Sqrt32( var_a, &exp ); /*31-exp*/ + direct_response_hoa_fx[l] = Mpy_32_32( direct_response_hoa_fx[l], var_b ); /*Q_direct_response_hoa+31-exp-31*/ move32(); exp_arr[l] = add( sub( 31, Q_direct_response_hoa ), exp ); move16(); @@ -4806,7 +4822,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( maximum_fx( exp_arr, MAX_OUTPUT_CHANNELS, &max_exp ); FOR( l = 0; l < MAX_OUTPUT_CHANNELS; l++ ) { - direct_response_hoa_fx[l] = L_shr( direct_response_hoa_fx[l], sub( max_exp, exp_arr[l] ) ); + direct_response_hoa_fx[l] = L_shr( direct_response_hoa_fx[l], sub( max_exp, exp_arr[l] ) ); /*q(31-exp_arr[l])->q(31-max_exp)*/ move32(); } Q_direct_response_hoa = sub( 31, max_exp ); @@ -4816,36 +4832,36 @@ void ivas_dirac_dec_compute_directional_responses_fx( Q_direct_response_hoa = sub( Q31, exp_direct_response_hoa ); - Scale_sig32( direct_response_hoa_fx, MAX_OUTPUT_CHANNELS, sub( Q29, Q_direct_response_hoa ) ); + Scale_sig32( direct_response_hoa_fx, MAX_OUTPUT_CHANNELS, sub( Q29, Q_direct_response_hoa ) ); /*Q_direct_response_hoa->q29*/ direct_response_q = Q29; move16(); direct_response_fx = direct_response_hoa_fx; IF( NE_32( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - v_mult_fixed( direct_response_fx, direct_response_fx, direct_response_square_fx, num_channels_dir ); + v_mult_fixed( direct_response_fx, direct_response_fx, direct_response_square_fx, num_channels_dir ); /*Q(2*direct_response_q-31)*/ direct_response_square_q = sub( add( direct_response_q, direct_response_q ), 31 ); - mvr2r_inc_fixed( direct_response_square_fx, 1, &hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx[k], hSpatParamRendCom->num_freq_bands, num_channels_dir ); + mvr2r_inc_fixed( direct_response_square_fx, 1, &hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx[k], hSpatParamRendCom->num_freq_bands, num_channels_dir ); /*direct_response_square_q*/ IF( EQ_16( transport_signal_type, MASA_STEREO_SPACED_MICS ) ) { - direct_response_fx[0] = ONE_IN_Q29; + direct_response_fx[0] = ONE_IN_Q29; /*q29*/ move32(); test(); IF( GE_16( k, dipole_freq_range[0] ) && LT_16( k, dipole_freq_range[1] ) ) { - direct_response_fx[1] = ONE_IN_Q29; + direct_response_fx[1] = ONE_IN_Q29; /*q29*/ move32(); } } ELSE { - set32_fx( direct_response_fx, ONE_IN_Q29, hDirACRend->num_protos_ambi ); + set32_fx( direct_response_fx, ONE_IN_Q29, hDirACRend->num_protos_ambi ); /*q29*/ } } - mvr2r_inc_fixed( direct_response_fx, 1, &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[k], hSpatParamRendCom->num_freq_bands, num_channels_dir ); + mvr2r_inc_fixed( direct_response_fx, 1, &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[k], hSpatParamRendCom->num_freq_bands, num_channels_dir ); /*q29*/ } ELSE { @@ -4867,7 +4883,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( normalizePanningGains_fx( direct_response_dir2_fx, &Q_direct_response_dir2, num_channels_dir ); /* Combine gains from the two directions */ - Word32 test = L_add( hSpatParamRendCom->energy_ratio1_fx[md_idx][k], hSpatParamRendCom->energy_ratio2_fx[md_idx][k] ); + Word32 test = L_add( hSpatParamRendCom->energy_ratio1_fx[md_idx][k], hSpatParamRendCom->energy_ratio2_fx[md_idx][k] ); /*q30*/ IF( test == 0 ) { @@ -4875,16 +4891,16 @@ void ivas_dirac_dec_compute_directional_responses_fx( } ELSE { - totalDirect_fx = test; + totalDirect_fx = test; // q30 move32(); } Word16 var_1, var_2, exp_1, exp_2; - var_1 = BASOP_Util_Divide3232_Scale( hSpatParamRendCom->energy_ratio1_fx[md_idx][k], totalDirect_fx, &exp_1 ); - var_2 = BASOP_Util_Divide3232_Scale( hSpatParamRendCom->energy_ratio2_fx[md_idx][k], totalDirect_fx, &exp_2 ); + var_1 = BASOP_Util_Divide3232_Scale( hSpatParamRendCom->energy_ratio1_fx[md_idx][k], totalDirect_fx, &exp_1 ); // 15-exp_1 + var_2 = BASOP_Util_Divide3232_Scale( hSpatParamRendCom->energy_ratio2_fx[md_idx][k], totalDirect_fx, &exp_2 ); // 15-exp_2 - directRatio_fx[0] = L_deposit_h( var_1 ); + directRatio_fx[0] = L_deposit_h( var_1 ); // 31-exp_1 move32(); - directRatio_fx[1] = L_deposit_h( var_2 ); + directRatio_fx[1] = L_deposit_h( var_2 ); // 31-exp_2 move32(); Word32 var_a; @@ -4904,7 +4920,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( var_a = Mpy_32_32( directRatio_fx[1], direct_response_dir2_fx[l] ); // exp_direct_response_dir2 + exp_2 exp_tmp = 0; move16(); - direct_response_ls_fx[l] = BASOP_Util_Add_Mant32Exp( temp, add( exp_direct_response_ls, exp_1 ), var_a, add( exp_direct_response_dir2, exp_2 ), &exp_tmp ); + direct_response_ls_fx[l] = BASOP_Util_Add_Mant32Exp( temp, add( exp_direct_response_ls, exp_1 ), var_a, add( exp_direct_response_dir2, exp_2 ), &exp_tmp ); // q(31-exp_tmp) move32(); exp_table[l] = exp_tmp; move16(); @@ -4914,7 +4930,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { - direct_response_ls_fx[i] = L_shr( direct_response_ls_fx[i], sub( exp_max, exp_table[i] ) ); + direct_response_ls_fx[i] = L_shr( direct_response_ls_fx[i], sub( exp_max, exp_table[i] ) ); /*(q(31-exp_table[i])->q(31-exp_max))*/ move32(); } Q_direct_response_ls = sub( 31, exp_max ); @@ -4953,8 +4969,8 @@ void ivas_dirac_dec_compute_directional_responses_fx( Word16 Q_arr[MAX_OUTPUT_CHANNELS], exp_tmp; FOR( l = 0; l < num_channels_dir; l++ ) { - tmp = Mpy_32_32( direct_response_temp_fx[l], hMasaIsm->energy_ratio_ism_fx[dir][md_idx][k] ); // Q30 * 2 - 31 - direct_response_ism_fx[l] = BASOP_Util_Add_Mant32Exp( direct_response_ism_fx[l], 0, tmp, 31 - ( 60 - 31 ), &exp_tmp ); + tmp = Mpy_32_32( direct_response_temp_fx[l], hMasaIsm->energy_ratio_ism_fx[dir][md_idx][k] ); // Q30 * 2 - 31 + direct_response_ism_fx[l] = BASOP_Util_Add_Mant32Exp( direct_response_ism_fx[l], 0, tmp, 31 - ( 60 - 31 ), &exp_tmp ); // q(31-exp_tmp) move32(); Q_arr[l] = sub( 31, exp_tmp ); move16(); @@ -4964,7 +4980,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( minimum_fx( Q_arr, num_channels_dir, &Q_min ); FOR( i = 0; i < num_channels_dir; i++ ) { - direct_response_ism_fx[i] = L_shr( direct_response_ism_fx[i], sub( Q_arr[i], Q_min ) ); + direct_response_ism_fx[i] = L_shr( direct_response_ism_fx[i], sub( Q_arr[i], Q_min ) ); // Q_arr[i]->Q_min move32(); } Q_direct_response_temp = Q_min; @@ -4973,31 +4989,31 @@ void ivas_dirac_dec_compute_directional_responses_fx( } Word16 exp_1, exp_2; - masaDirect_fx = hSpatParamRendCom->energy_ratio1_fx[md_idx][k]; + masaDirect_fx = hSpatParamRendCom->energy_ratio1_fx[md_idx][k]; // q30 move32(); IF( masaDirect_fx == 0 ) { - masaDirect_fx = L_add( masaDirect_fx, EPSILLON_FX ); + masaDirect_fx = L_add( masaDirect_fx, EPSILLON_FX ); // q30 } IF( EQ_32( hSpatParamRendCom->numParametricDirections, 2 ) ) { - masaDirect_fx = L_add( masaDirect_fx, hSpatParamRendCom->energy_ratio2_fx[md_idx][k] ); + masaDirect_fx = L_add( masaDirect_fx, hSpatParamRendCom->energy_ratio2_fx[md_idx][k] ); // q30 } - ismDirect_fx = hMasaIsm->energy_ratio_ism_fx[0][md_idx][k]; + ismDirect_fx = hMasaIsm->energy_ratio_ism_fx[0][md_idx][k]; // q30 move32(); FOR( dir = 1; dir < hSpatParamRendCom->numIsmDirections; dir++ ) { - ismDirect_fx = L_add( ismDirect_fx, hMasaIsm->energy_ratio_ism_fx[dir][md_idx][k] ); + ismDirect_fx = L_add( ismDirect_fx, hMasaIsm->energy_ratio_ism_fx[dir][md_idx][k] ); // q30 } - totalDirect_fx = L_add_sat( masaDirect_fx, ismDirect_fx ); // saturating as 1.0 (Q30) + 1.0 (Q30) is observed + totalDirect_fx = L_add_sat( masaDirect_fx, ismDirect_fx ); // q30 // saturating as 1.0 (Q30) + 1.0 (Q30) is observed Word16 var_a, var_b; - var_a = BASOP_Util_Divide3232_Scale( masaDirect_fx, totalDirect_fx, &exp_1 ); - var_b = BASOP_Util_Divide3232_Scale( ismDirect_fx, totalDirect_fx, &exp_2 ); - directRatio_fx[0] = L_deposit_h( var_a ); + var_a = BASOP_Util_Divide3232_Scale( masaDirect_fx, totalDirect_fx, &exp_1 ); // 15-exp_1 + var_b = BASOP_Util_Divide3232_Scale( ismDirect_fx, totalDirect_fx, &exp_2 ); // 15- exp_2 + directRatio_fx[0] = L_deposit_h( var_a ); // 31- exp_1 move32(); - directRatio_fx[1] = L_deposit_h( var_b ); + directRatio_fx[1] = L_deposit_h( var_b ); // 31 - exp_2 move32(); Word32 temp_2, temp_3; @@ -5005,14 +5021,14 @@ void ivas_dirac_dec_compute_directional_responses_fx( set16_fx( exp_arr, exp_direct_response_ls, MAX_OUTPUT_CHANNELS ); FOR( l = 0; l < num_channels_dir; l++ ) { - direct_response_ls_fx[l] = Mpy_32_32( direct_response_ls_fx[l], directRatio_fx[0] ); + direct_response_ls_fx[l] = Mpy_32_32( direct_response_ls_fx[l], directRatio_fx[0] ); // q(31-exp_direct_response_ls+31-exp_1-31) move32(); exp_arr[l] = add( exp_direct_response_ls, exp_1 ); move16(); - temp_2 = Mpy_32_32( directRatio_fx[1], direct_response_ism_fx[l] ); - temp_3 = BASOP_Util_Add_Mant32Exp( direct_response_ls_fx[l], exp_arr[l], temp_2, exp_2 + 31 - Q_direct_response_temp, &exp_temp_3 ); + temp_2 = Mpy_32_32( directRatio_fx[1], direct_response_ism_fx[l] ); // q(Q_direct_response_temp+31-exp_2-31) + temp_3 = BASOP_Util_Add_Mant32Exp( direct_response_ls_fx[l], exp_arr[l], temp_2, add( exp_2, sub( 31, Q_direct_response_temp ) ), &exp_temp_3 ); // 31-exp_temp_3 - direct_response_ls_fx[l] = temp_3; + direct_response_ls_fx[l] = temp_3; // 31-exp_temp_3 move32(); exp_arr[l] = exp_temp_3; move16(); @@ -5023,7 +5039,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( maximum_fx( exp_arr, num_channels_dir, &max_exp ); FOR( l = 0; l < num_channels_dir; l++ ) { - direct_response_ls_fx[l] = L_shr( direct_response_ls_fx[l], sub( max_exp, exp_arr[l] ) ); + direct_response_ls_fx[l] = L_shr( direct_response_ls_fx[l], sub( max_exp, exp_arr[l] ) ); /*q(31-exp_arr[l])->q(31-max_exp)*/ move16(); } Q_direct_response_ls = sub( 31, max_exp ); @@ -5035,6 +5051,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( } /* Synthesize surrounding coherence */ + test(); IF( surCohRatio_fx != NULL && surCohRatio_fx[k] > 0 ) { Word16 num_channels_surrCoh; @@ -5052,9 +5069,9 @@ void ivas_dirac_dec_compute_directional_responses_fx( { exp_temp = 0; move16(); - temp = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30, 1, L_negate( surCohRatio_fx[k] ), exp_surCohRatio, &exp_temp ); - temp = Sqrt32( temp, &exp_temp ); - direct_response_ls_fx[l] = Mpy_32_32( direct_response_ls_fx[l], temp ); // exp_direct_response_ls + exp_temp + temp = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30 /*1 Q30*/, 1, L_negate( surCohRatio_fx[k] ), exp_surCohRatio, &exp_temp ); // q(31-exp_temp) + temp = Sqrt32( temp, &exp_temp ); // q(31-exp_temp) + direct_response_ls_fx[l] = Mpy_32_32( direct_response_ls_fx[l], temp ); // Q31-(exp_direct_response_ls + exp_temp) move32(); exp_arr[l] = add( exp_direct_response_ls, exp_temp ); @@ -5063,25 +5080,25 @@ void ivas_dirac_dec_compute_directional_responses_fx( { exp_temp_a = 0; move16(); - temp_a = BASOP_Util_Divide3216_Scale( surCohRatio_fx[k], num_channels_surrCoh, &exp_temp_a ); + temp_a = BASOP_Util_Divide3216_Scale( surCohRatio_fx[k], num_channels_surrCoh, &exp_temp_a ); /*15-(exp_temp_a+exp_surCohRatio-15)*/ exp_temp_a = add( exp_temp_a, sub( exp_surCohRatio, 15 ) ); - temp_a = Sqrt16( temp_a, &exp_temp_a ); + temp_a = Sqrt16( temp_a, &exp_temp_a ); /*15-temp_a*/ final_exp = 0; move16(); - final = BASOP_Util_Add_Mant32Exp( direct_response_ls_fx[l], exp_arr[l], L_deposit_h( temp_a ), exp_temp_a, &final_exp ); - direct_response_ls_fx[l] = final; + final = BASOP_Util_Add_Mant32Exp( direct_response_ls_fx[l], exp_arr[l], L_deposit_h( temp_a ), exp_temp_a, &final_exp ); /*31-final_exp*/ + direct_response_ls_fx[l] = final; /*31-final_exp*/ move32(); exp_arr[l] = final_exp; move16(); } } - max_exp = MIN16B; + max_exp = MIN16B; /*Q0*/ move16(); maximum_fx( exp_arr, MAX_OUTPUT_CHANNELS, &max_exp ); FOR( l = 0; l < MAX_OUTPUT_CHANNELS; l++ ) { - direct_response_ls_fx[l] = L_shr( direct_response_ls_fx[l], sub( max_exp, exp_arr[l] ) ); + direct_response_ls_fx[l] = L_shr( direct_response_ls_fx[l], sub( max_exp, exp_arr[l] ) ); /*Q(31-exp_arr[l])->Q(31-max_exp)*/ move32(); } @@ -5093,17 +5110,17 @@ void ivas_dirac_dec_compute_directional_responses_fx( normalizePanningGains_fx( direct_response_ls_fx, &Q_direct_response_ls, num_channels_dir ); exp_direct_response_ls = sub( 31, Q_direct_response_ls ); - Scale_sig32( direct_response_ls_fx, MAX_OUTPUT_CHANNELS, sub( Q29, Q_direct_response_ls ) ); + Scale_sig32( direct_response_ls_fx, MAX_OUTPUT_CHANNELS, sub( Q29, Q_direct_response_ls ) ); /*Q_direct_response_ls->Q29*/ direct_response_q = Q29; move16(); /* Set computed gains */ direct_response_fx = direct_response_ls_fx; - v_mult_fixed( direct_response_fx, direct_response_fx, direct_response_square_fx, num_channels_dir ); + v_mult_fixed( direct_response_fx, direct_response_fx, direct_response_square_fx, num_channels_dir ); /*2*direct_response_q-31*/ direct_response_square_q = sub( add( direct_response_q, direct_response_q ), 31 ); - mvr2r_inc_fixed( direct_response_square_fx, 1, &hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx[k], hSpatParamRendCom->num_freq_bands, num_channels_dir ); - mvr2r_inc_fixed( direct_response_fx, 1, &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[k], hSpatParamRendCom->num_freq_bands, num_channels_dir ); + mvr2r_inc_fixed( direct_response_square_fx, 1, &hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx[k], hSpatParamRendCom->num_freq_bands, num_channels_dir ); /*direct_response_square_q*/ + mvr2r_inc_fixed( direct_response_fx, 1, &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[k], hSpatParamRendCom->num_freq_bands, num_channels_dir ); /*direct_response_q*/ } ELSE { @@ -5459,9 +5476,9 @@ void ivas_dirac_dec_compute_directional_responses( #ifdef IVAS_FLOAT_FIXED void ivas_dirac_dec_compute_gain_factors_fx( const Word16 num_freq_bands, - const Word32 *diffuseness_fx, - Word32 *direct_gain_factor, - Word32 *diffuse_gain_factor, + const Word32 *diffuseness_fx, /*i:q30*/ + Word32 *direct_gain_factor, /*o:exponent is max_exp_direct*/ + Word32 *diffuse_gain_factor, /*o:exponent is max_exp_diffusion*/ Word16 *max_exp_direct_fx, Word16 *max_exp_diffusion ) { @@ -5475,9 +5492,9 @@ void ivas_dirac_dec_compute_gain_factors_fx( move16(); exp2 = 1; move16(); - direct_gain_factor[i] = Sqrt32( L_sub( ONE_IN_Q30, diffuseness_fx[i] ), &exp1 ); + direct_gain_factor[i] = Sqrt32( L_sub( ONE_IN_Q30 /*1 Q30*/, diffuseness_fx[i] ), &exp1 ); /*31-exp1*/ move32(); - diffuse_gain_factor[i] = Sqrt32( diffuseness_fx[i], &exp2 ); + diffuse_gain_factor[i] = Sqrt32( diffuseness_fx[i], &exp2 ); /*31-exp2*/ move32(); exp_direct_gain_factor[i] = exp1; move16(); @@ -5486,9 +5503,9 @@ void ivas_dirac_dec_compute_gain_factors_fx( } /*make common exp for both buffers*/ - Word16 max_exp_direct = MIN16B; + Word16 max_exp_direct = MIN16B; /*Q0*/ move16(); - Word16 max_exp_diffuse = MIN16B; + Word16 max_exp_diffuse = MIN16B; /*Q0*/ move16(); FOR( i = 0; i < num_freq_bands; i++ ) { @@ -5503,9 +5520,9 @@ void ivas_dirac_dec_compute_gain_factors_fx( FOR( i = 0; i < num_freq_bands; i++ ) { - direct_gain_factor[i] = L_shr( direct_gain_factor[i], sub( max_exp_direct, exp_direct_gain_factor[i] ) ); + direct_gain_factor[i] = L_shr( direct_gain_factor[i], sub( max_exp_direct, exp_direct_gain_factor[i] ) ); /*Q(31-max_exp_direct)*/ move32(); - diffuse_gain_factor[i] = L_shr( diffuse_gain_factor[i], sub( max_exp_diffuse, exp_diffuse_gain_factor[i] ) ); + diffuse_gain_factor[i] = L_shr( diffuse_gain_factor[i], sub( max_exp_diffuse, exp_diffuse_gain_factor[i] ) ); /*Q(31-max_exp_diffuse)*/ move32(); } @@ -5569,8 +5586,8 @@ void ivas_dirac_dec_compute_power_factors_fx( const Word16 num_freq_bands, const Word32 *diffuseness_fx, // Q3O const Word16 max_band_decorr, - Word32 *direct_power_factor, - Word32 *diffuse_power_factor ) + Word32 *direct_power_factor, /*input is q30 and ouput is q29*/ + Word32 *diffuse_power_factor /*input is q30 and ouput is q29*/ ) { Word16 i; @@ -5630,12 +5647,12 @@ void ivas_lfe_synth_with_filters_fx( /* Delay the separated channel to sync the LFE synthesis with the DirAC rendering */ delay = hMasaLfeSynth->delayBuffer_syncDirAC_size; move16(); - delay_signal_fx( data_fx[separateChannelIndex], output_frame, hMasaLfeSynth->delayBuffer_syncDirAC_fx, delay ); + delay_signal_fx( data_fx[separateChannelIndex], output_frame, hMasaLfeSynth->delayBuffer_syncDirAC_fx, delay ); /*q11*/ /* Filterbank for dividing the separated channel to LFE frequencies and higher frequencies */ lowpassCoef_fx_exp = 15; move16(); - lowpassCoef_fx = Inv16( hMasaLfeSynth->ringBufferSize, &lowpassCoef_fx_exp ); + lowpassCoef_fx = Inv16( hMasaLfeSynth->ringBufferSize, &lowpassCoef_fx_exp ); /*15-lowpassCoef_fx_exp*/ FOR( i = 0; i < output_frame; i++ ) { hMasaLfeSynth->lowpassSum_fx = L_add( hMasaLfeSynth->lowpassSum_fx, L_shl( Mpy_32_16_1( L_sub( data_fx[separateChannelIndex][i], hMasaLfeSynth->lfeSynthRingBuffer_fx[hMasaLfeSynth->ringBufferLoPointer] ), lowpassCoef_fx ), lowpassCoef_fx_exp ) ); // Q11 @@ -5685,7 +5702,7 @@ void ivas_lfe_synth_with_filters_fx( Word16 tmp_shift = W_norm( W_tmp ); - W_tmp = W_shl( W_tmp, tmp_shift ); + W_tmp = W_shl( W_tmp, tmp_shift ); /*Q22+tmp_shift*/ Word16 tmp_q = sub( add( Q22, tmp_shift ), 32 ); Word16 tmp_exp; @@ -5716,62 +5733,62 @@ void ivas_lfe_synth_with_filters_fx( IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneLfeSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneLfeSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) ) { - lfeGain_fx = MAX_16; + lfeGain_fx = MAX_16; /* 1.0 in q15*/ move16(); } ELSE { - lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_cadence( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); + lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_cadence( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/ lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); - lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); - lfeGain_fx = shl_r( lfeGain_fx, lfeGain_fx_exp ); // Q15 + lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp + lfeGain_fx = shl_r( lfeGain_fx, lfeGain_fx_exp ); // Q15 } IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) ) { - transportGain_fx = MAX_16; + transportGain_fx = MAX_16; // q15 move16(); } ELSE { Flag overFlow; - transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); + transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); /*Q=15-(transportGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneTransSmooth_q)*/ transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); - transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); + transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp, &overFlow ); // Q15 } j = 0; move16(); FOR( i = mrange[0]; i < mrange[1]; i++ ) { - Word32 L_tmp1 = L_mult( transportGain_fx, hMasaLfeSynth->interpolator_fx[j] ); // Q31 - Word32 L_tmp2 = L_mult( hMasaLfeSynth->transportGainPrev_fx, sub( MAX_16, hMasaLfeSynth->interpolator_fx[j] ) ); // Q31 - data_fx[separateChannelIndex][i] = L_add( Mpy_32_32( L_add( L_tmp1, L_tmp2 ), lowPassSignal_fx[i] ), highPassSignal_fx[i] ); + Word32 L_tmp1 = L_mult( transportGain_fx, hMasaLfeSynth->interpolator_fx[j] ); // Q31 + Word32 L_tmp2 = L_mult( hMasaLfeSynth->transportGainPrev_fx, sub( MAX_16, hMasaLfeSynth->interpolator_fx[j] ) ); // Q31 + data_fx[separateChannelIndex][i] = L_add( Mpy_32_32( L_add( L_tmp1, L_tmp2 ), lowPassSignal_fx[i] ), highPassSignal_fx[i] ); /*q31+q11-q31->q11*/ move32(); - Word32 L_tmp3 = L_mult( lfeGain_fx, hMasaLfeSynth->interpolator_fx[j] ); // Q31 - Word32 L_tmp4 = L_mult( hMasaLfeSynth->lfeGainPrev_fx, sub( MAX_16, hMasaLfeSynth->interpolator_fx[j] ) ); - data_fx[lfeChannelIndex][i] = Mpy_32_32( L_add( L_tmp3, L_tmp4 ), lowPassSignal_fx[i] ); + Word32 L_tmp3 = L_mult( lfeGain_fx, hMasaLfeSynth->interpolator_fx[j] ); // Q31 + Word32 L_tmp4 = L_mult( hMasaLfeSynth->lfeGainPrev_fx, sub( MAX_16, hMasaLfeSynth->interpolator_fx[j] ) ); /*q31*/ + data_fx[lfeChannelIndex][i] = Mpy_32_32( L_add( L_tmp3, L_tmp4 ), lowPassSignal_fx[i] ); /*q31+q11-q31->q11*/ move32(); j = add( j, 1 ); } - hMasaLfeSynth->lfeGainPrev_fx = lfeGain_fx; + hMasaLfeSynth->lfeGainPrev_fx = lfeGain_fx; /*q15*/ move16(); - hMasaLfeSynth->transportGainPrev_fx = transportGain_fx; + hMasaLfeSynth->transportGainPrev_fx = transportGain_fx; /*q15*/ move16(); } /* Lowpass filter for removing remaining mid and high frequencies from the LFE signal */ lowpassCoef_fx_exp = 15; move16(); - lowpassCoef_fx = Inv16( hMasaLfeSynth->ringBufferSize2, &lowpassCoef_fx_exp ); + lowpassCoef_fx = Inv16( hMasaLfeSynth->ringBufferSize2, &lowpassCoef_fx_exp ); // q15-lowpassCoef_fx_exp FOR( i = 0; i < output_frame; i++ ) { hMasaLfeSynth->lowpassSum2_fx = L_add( hMasaLfeSynth->lowpassSum2_fx, L_shl_r( L_sub( Mpy_32_16_1( data_fx[lfeChannelIndex][i], lowpassCoef_fx ), Mpy_32_16_1( hMasaLfeSynth->lfeSynthRingBuffer2_fx[hMasaLfeSynth->ringBufferLoPointer2], lowpassCoef_fx ) ), - lowpassCoef_fx_exp ) ); + lowpassCoef_fx_exp ) ); /*q11+15-lowpassCoef_fx_exp-15+lowpassCoef_fx_exp->q11*/ move32(); - hMasaLfeSynth->lfeSynthRingBuffer2_fx[hMasaLfeSynth->ringBufferLoPointer2] = data_fx[lfeChannelIndex][i]; + hMasaLfeSynth->lfeSynthRingBuffer2_fx[hMasaLfeSynth->ringBufferLoPointer2] = data_fx[lfeChannelIndex][i]; /*q11*/ move32(); hMasaLfeSynth->ringBufferLoPointer2 = sub( hMasaLfeSynth->ringBufferLoPointer2, 1 ); @@ -5782,14 +5799,14 @@ void ivas_lfe_synth_with_filters_fx( move16(); } - data_fx[lfeChannelIndex][i] = hMasaLfeSynth->lowpassSum2_fx; + data_fx[lfeChannelIndex][i] = hMasaLfeSynth->lowpassSum2_fx; /*q11*/ move32(); } /* Delay the separated channel to match the delay of the lowpass filter */ delay = hMasaLfeSynth->delayBuffer_syncLp_size; move16(); - delay_signal_fx( data_fx[separateChannelIndex], output_frame, hMasaLfeSynth->delayBuffer_syncLp_fx, delay ); + delay_signal_fx( data_fx[separateChannelIndex], output_frame, hMasaLfeSynth->delayBuffer_syncLp_fx, delay ); /*q11*/ return; } @@ -5912,14 +5929,14 @@ void ivas_lfe_synth_with_filters( static void computeTargetPSDs_direct_fx( const Word16 num_channels, const Word16 num_freq_bands, - const Word32 *direct_power_factor, - const Word32 *reference_power, + const Word32 *direct_power_factor, /*q31*/ + const Word32 *reference_power, /*q_reference_power*/ const Word16 *q_reference_power, - const Word32 *direct_responses, - const Word32 *direct_responses_square, - Word32 *cy_auto_dir_smooth, + const Word32 *direct_responses, /*q31*/ + const Word32 *direct_responses_square, /*q31*/ + Word32 *cy_auto_dir_smooth, /*q_cy_auto_dir_smooth*/ Word16 *q_cy_auto_dir_smooth, - Word32 *cy_cross_dir_smooth, + Word32 *cy_cross_dir_smooth, /*q_cy_cross_dir_smooth*/ Word16 *q_cy_cross_dir_smooth ) { Word16 ch_idx, cur_idx; @@ -5999,14 +6016,14 @@ static void computeTargetPSDs_direct( static void computeTargetPSDs_direct_subframe_fx( const Word16 num_channels, const Word16 num_freq_bands, - const Word32 *direct_power_factor, - const Word32 *reference_power, + const Word32 *direct_power_factor, /*q31*/ + const Word32 *reference_power, /*q_reference_power*/ const Word16 *q_reference_power, - const Word32 *direct_responses, - const Word32 *direct_responses_square, - Word32 *cy_auto_dir_smooth, + const Word32 *direct_responses, /*q31*/ + const Word32 *direct_responses_square, /*q31*/ + Word32 *cy_auto_dir_smooth, /*q_cy_auto_dir_smooth*/ Word16 *q_cy_auto_dir_smooth, - Word32 *cy_cross_dir_smooth, + Word32 *cy_cross_dir_smooth, /*q_cy_cross_dir_smooth*/ Word16 *q_cy_cross_dir_smooth ) { Word16 ch_idx, cur_idx, i, q_tmp; @@ -6028,14 +6045,17 @@ static void computeTargetPSDs_direct_subframe_fx( move64(); FOR( i = 0; i < num_freq_bands; i++ ) { - W_tmp[i] = W_mult_32_32( direct_power[i], direct_responses_square[cur_idx + i] ); // (q_reference_power, Q31) + 1 + W_tmp[i] = W_mult_32_32( direct_power[i], direct_responses_square[cur_idx + i] ); // q_reference_power + Q31 + 1 move64(); - W_max = W_max < W_abs( W_tmp[i] ) ? W_abs( W_tmp[i] ) : W_max; + IF( LT_64( W_max, W_abs( W_tmp[i] ) ) ) + { + W_max = W_abs( W_tmp[i] ); + } } q_tmp = W_norm( W_max ); FOR( i = 0; i < num_freq_bands; i++ ) { - cy_auto_dir_smooth[cur_idx + i] = W_extract_h( W_shl( W_tmp[i], q_tmp ) ); + cy_auto_dir_smooth[cur_idx + i] = W_extract_h( W_shl( W_tmp[i], q_tmp ) ); /*q_reference_power+q_tmp*/ move32(); } q_cy_auto_dir_smooth[ch_idx] = add( *q_reference_power, q_tmp ); @@ -6086,11 +6106,11 @@ static void computeTargetPSDs_diffuse_fx( const Word16 num_channels, const Word16 num_freq_bands, const Word16 start_band, - const Word32 *diffuse_power_factor, - const Word32 *reference_power, + const Word32 *diffuse_power_factor, /*q31*/ + const Word32 *reference_power, /*q_reference_power*/ const Word16 *q_reference_power, - const Word32 *diffuse_responses_square, - Word32 *cy_auto_diff_smooth, + const Word32 *diffuse_responses_square, /*Q31*/ + Word32 *cy_auto_diff_smooth, /*q_cy_auto_diff_smooth*/ Word16 *q_cy_auto_diff_smooth ) { Word16 ch_idx, cur_idx; @@ -6109,10 +6129,10 @@ static void computeTargetPSDs_diffuse_fx( { cur_idx = imult1616( ch_idx, num_freq_bands ); - v_multc_fixed( &diffuse_power[start_band], diffuse_responses_square[ch_idx], aux_buffer_res, sub( num_freq_bands, start_band ) ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ - scale_sig32( aux_buffer_res, sub( num_freq_bands, start_band ), sub( common_q, *q_reference_power ) ); /* Q(common_q) */ - scale_sig32( &cy_auto_diff_smooth[add( cur_idx, start_band )], sub( num_freq_bands, start_band ), sub( common_q, *q_cy_auto_diff_smooth ) ); /* Q(common_q) */ - v_add_fixed( &cy_auto_diff_smooth[add( cur_idx, start_band )], aux_buffer_res, &cy_auto_diff_smooth[add( cur_idx, start_band )], sub( num_freq_bands, start_band ), Q1 ); /* Q(common_q) - Q1 */ + v_multc_fixed( &diffuse_power[start_band], diffuse_responses_square[ch_idx], aux_buffer_res, sub( num_freq_bands, start_band ) ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ + scale_sig32( aux_buffer_res, sub( num_freq_bands, start_band ), sub( common_q, *q_reference_power ) ); /* Q(common_q) */ + scale_sig32( &cy_auto_diff_smooth[cur_idx + start_band], sub( num_freq_bands, start_band ), sub( common_q, *q_cy_auto_diff_smooth ) ); /* Q(common_q) */ + v_add_fixed( &cy_auto_diff_smooth[cur_idx + start_band], aux_buffer_res, &cy_auto_diff_smooth[cur_idx + start_band], sub( num_freq_bands, start_band ), Q1 ); /* Q(common_q) - Q1 */ } /* Q adjustment */ @@ -6158,11 +6178,11 @@ static void computeTargetPSDs_diffuse_subframe_fx( const Word16 num_channels, const Word16 num_freq_bands, const Word16 start_band, - const Word32 *diffuse_power_factor, - const Word32 *reference_power, + const Word32 *diffuse_power_factor, /*q31*/ + const Word32 *reference_power, /*q_reference_power*/ const Word16 *q_reference_power, - const Word32 *diffuse_responses_square, - Word32 *cy_auto_diff_smooth, + const Word32 *diffuse_responses_square, /*q31*/ + Word32 *cy_auto_diff_smooth, /*q_cy_auto_diff_smooth*/ Word16 *q_cy_auto_diff_smooth ) { Word16 ch_idx, cur_idx; @@ -6176,7 +6196,7 @@ static void computeTargetPSDs_diffuse_subframe_fx( { cur_idx = imult1616( ch_idx, num_freq_bands ); - v_multc_fixed( &diffuse_power[start_band], diffuse_responses_square[ch_idx], &cy_auto_diff_smooth[add( cur_idx, start_band )], sub( num_freq_bands, start_band ) ); // (q_reference_power, Q31) -> q_reference_power + v_multc_fixed( &diffuse_power[start_band], diffuse_responses_square[ch_idx], &cy_auto_diff_smooth[cur_idx + start_band], sub( num_freq_bands, start_band ) ); // (q_reference_power, Q31) -> q_reference_power } *q_cy_auto_diff_smooth = *q_reference_power; @@ -6219,12 +6239,12 @@ static void computeTargetPSDs_diffuse_with_onsets_fx( const Word16 num_freq_bands, const Word16 num_decorr_freq_bands, const Word16 *proto_frame_diff_index, - const Word32 *diffuse_power_factor, - const Word32 *reference_power, + const Word32 *diffuse_power_factor, /*q31*/ + const Word32 *reference_power, /* q_reference_power */ const Word16 *q_reference_power, - const Word32 *diffuse_responses_square, - const Word32 *onset_filter, - Word32 *cy_auto_diff_smooth, + const Word32 *diffuse_responses_square, /*q31*/ + const Word32 *onset_filter, /*q31*/ + Word32 *cy_auto_diff_smooth, /*q_cy_auto_diff_smooth*/ Word16 *q_cy_auto_diff_smooth ) { Word16 ch_idx, cur_idx, diff_idx; @@ -6328,7 +6348,7 @@ static void computeTargetPSDs_diffuse_with_onsets( #ifdef IVAS_FLOAT_FIXED -static void computeAlphaSynthesis_fx( Word16 *alpha_synthesis_fx, const Word16 averaging_length_ms, const Word16 maxAlpha_fx, Word16 *numAlphas, const Word16 slot_size, const Word16 num_freq_bands, Word16 *frequency_axis_fx, const Word32 output_Fs ) +static void computeAlphaSynthesis_fx( Word16 *alpha_synthesis_fx /*q15*/, const Word16 averaging_length_ms, const Word16 maxAlpha_fx /*q15*/, Word16 *numAlphas, const Word16 slot_size, const Word16 num_freq_bands, Word16 *frequency_axis_fx /*q0*/, const Word32 output_Fs ) { Word16 k; Word16 avg_length_f_ms_fx; @@ -6341,28 +6361,29 @@ static void computeAlphaSynthesis_fx( Word16 *alpha_synthesis_fx, const Word16 a IF( averaging_length_ms == 0 ) { - set16_fx( alpha_synthesis_fx, MAX16B, num_freq_bands ); + set16_fx( alpha_synthesis_fx, MAX16B, num_freq_bands ); /*q15*/ } ELSE { FOR( k = 0; k < num_freq_bands; k++ ) { Word16 faxis_idx = s_max( k, 1 ); + // avg_length_f_ms = 1000.f * (float)averaging_length_ms / fabsf(frequency_axis[faxis_idx]); Word16 tmp_exp = 0; - Word16 tmp_1 = BASOP_Util_Divide1616_Scale( averaging_length_ms, frequency_axis_fx[faxis_idx], &tmp_exp ); - Word16 tmp_2 = mult( tmp_1, 1000 ); // 15 - tmp_exp + 0 -15 = -tmp_exp (Q-fac) - avg_length_f_ms_fx = tmp_2; + Word16 tmp_1 = BASOP_Util_Divide1616_Scale( averaging_length_ms, frequency_axis_fx[faxis_idx], &tmp_exp ); /*Q(15-(tmp_exp+15-15))*/ + Word16 tmp_2 = mult( tmp_1, 1000 ); // 15 - tmp_exp + 0 -15 = -tmp_exp (Q-fac) + avg_length_f_ms_fx = tmp_2; // Q(-tmp_exp) move16(); move16(); - + /* alpha_synthesis[k] = min( (float) slot_size / ( avg_length_f_ms * (float) output_Fs / 1000.f ), 1.0f );*/ Word32 tmp_3 = Mpy_32_16_1( output_Fs, avg_length_f_ms_fx ); // 0 - tmp_exp - 15 (Q-fac) Word16 tmp_exp_3; - Word16 tmp_4 = BASOP_Util_Divide3232_Scale( tmp_3, 1000, &tmp_exp_3 ); + Word16 tmp_4 = BASOP_Util_Divide3232_Scale( tmp_3, 1000, &tmp_exp_3 ); /*tmp_exp_4 stores resultant exponent*/ Word16 tmp_exp_4 = sub( add( tmp_exp_3, add( add( 31, tmp_exp ), 15 ) ), 31 ); Word16 tmp_exp_5; - Word16 tmp_5 = BASOP_Util_Divide1616_Scale( slot_size, tmp_4, &tmp_exp_5 ); + Word16 tmp_5 = BASOP_Util_Divide1616_Scale( slot_size, tmp_4, &tmp_exp_5 ); /*res_exp stores resultant exponent*/ Word16 res_exp = sub( add( tmp_exp_5, 15 ), tmp_exp_4 ); Word16 flag = BASOP_Util_Cmp_Mant32Exp( L_deposit_h( tmp_5 ), res_exp, 1, 31 ); @@ -6373,7 +6394,7 @@ static void computeAlphaSynthesis_fx( Word16 *alpha_synthesis_fx, const Word16 a } ELSE { - alpha_synthesis_fx[k] = MAX16B; + alpha_synthesis_fx[k] = MAX16B; /*q15*/ move16(); } @@ -6381,7 +6402,7 @@ static void computeAlphaSynthesis_fx( Word16 *alpha_synthesis_fx, const Word16 a test(); IF( flag2 == 0 || EQ_16( flag2, 1 ) ) { - alpha_synthesis_fx[k] = maxAlpha_fx; + alpha_synthesis_fx[k] = maxAlpha_fx; /*q15*/ move16(); *numAlphas = add( k, 1 ); move16(); @@ -6441,9 +6462,9 @@ static void computeAlphaSynthesis( static void spreadCoherencePanningHoa_fx( const Word16 azimuth, const Word16 elevation, - const Word16 spreadCoh_fx, /*Q15*/ - Word32 *direct_response_fx, /*Q29*/ - Word16 *Q_direct_response, /*Q29*/ + const Word16 spreadCoh_fx, /*i:Q15*/ + Word32 *direct_response_fx, /*i/o:Q_direct_response*/ + Word16 *Q_direct_response, /*i/o:stores q for direct_response_fx*/ const Word16 num_channels_dir, const Word16 ambisonics_order ) { @@ -6454,18 +6475,18 @@ static void spreadCoherencePanningHoa_fx( Word32 gainCenter_fx; Word32 gainSide_fx; - ivas_dirac_dec_get_response_fx( azimuth, elevation, direct_response_fx, ambisonics_order, *Q_direct_response ); + ivas_dirac_dec_get_response_fx( azimuth, elevation, direct_response_fx /*Q_direct_response*/, ambisonics_order, *Q_direct_response ); Word16 exp_Gain_side, exp_Gain_center; IF( spreadCoh_fx > 0 ) { - ivas_dirac_dec_get_response_fx( add( azimuth, 30 ), elevation, direct_response_left_fx, ambisonics_order, *Q_direct_response ); - ivas_dirac_dec_get_response_fx( add( azimuth, 330 ), elevation, direct_response_right_fx, ambisonics_order, *Q_direct_response ); + ivas_dirac_dec_get_response_fx( add( azimuth, 30 ), elevation, direct_response_left_fx /*Q_direct_response*/, ambisonics_order, *Q_direct_response ); + ivas_dirac_dec_get_response_fx( add( azimuth, 330 ), elevation, direct_response_right_fx /*Q_direct_response*/, ambisonics_order, *Q_direct_response ); Word16 var_a, var_b, exp_a; - IF( LT_16( spreadCoh_fx, ONE_IN_Q14 ) ) + IF( LT_16( spreadCoh_fx, ONE_IN_Q14 /*0.5 q15*/ ) ) { /*gainCenter = (3 - 4*spreadCoh )/3*/ var_a = sub( 24576 /*3 in Q13*/, spreadCoh_fx ); // Q13 @@ -6480,16 +6501,16 @@ static void spreadCoherencePanningHoa_fx( } ELSE { - var_a = shl( sub( 16384 /*2 in Q13*/, shr( spreadCoh_fx, 2 ) ), 1 ); + var_a = shl( sub( 16384 /*2 in Q13*/, shr( spreadCoh_fx, 2 ) ), 1 ); // q13 exp_a = 15 - Q13; move16(); - var_a = Inv16( var_a, &exp_a ); - gainSide_fx = L_deposit_h( var_a ); // Q14 + 16 = Q30 //exp_a + var_a = Inv16( var_a, &exp_a ); // 15-exp_a + gainSide_fx = L_deposit_h( var_a ); // 15-exp_a + 16 = Q31 -exp_a exp_Gain_side = exp_a; move16(); var_b = sub( 8192 /*2 in Q12*/, shr( spreadCoh_fx, 2 ) /*Q14*/ ); // exp => 3 - gainCenter_fx = L_deposit_h( mult( var_b, var_a ) ); // Q13 + 16 = Q29 // 3 + exp_a + gainCenter_fx = L_deposit_h( mult( var_b, var_a ) ); // 15-exp_a + 12-15+16=>28-exp_a = // 3 + exp_a exp_Gain_center = add( 3, exp_a ); } @@ -6503,7 +6524,7 @@ static void spreadCoherencePanningHoa_fx( mpy2 = Mpy_32_32( direct_response_fx[i], gainCenter_fx ); // 31 - Q_direct_response + exp_Gain_Center exp = 0; move16(); - direct_response_fx[i] = BASOP_Util_Add_Mant32Exp( mpy1, 31 - *Q_direct_response + exp_Gain_side, mpy2, add( sub( 31, *Q_direct_response ), exp_Gain_center ), &exp ); + direct_response_fx[i] = BASOP_Util_Add_Mant32Exp( mpy1, add( sub( 31, *Q_direct_response ), exp_Gain_side ), mpy2, add( sub( 31, *Q_direct_response ), exp_Gain_center ), &exp ); // 31-exp move32(); exp_arr[i] = exp; move16(); @@ -6516,7 +6537,7 @@ static void spreadCoherencePanningHoa_fx( } FOR( i = 0; i < 16; i++ ) { - direct_response_fx[i] = L_shr( direct_response_fx[i], sub( max_val, exp_arr[i] ) ); + direct_response_fx[i] = L_shr( direct_response_fx[i], sub( max_val, exp_arr[i] ) ); // Q(31-exp_arr[i])->q(31-max_val) move32(); } *Q_direct_response = sub( 31, max_val ); @@ -6572,11 +6593,11 @@ static void spreadCoherencePanningHoa( #ifdef IVAS_FLOAT_FIXED static void spreadCoherencePanningVbap_fx( - const Word16 azimuth, - const Word16 elevation, - const Word16 spreadCoh_fx, - Word32 *direct_response_fx, - Word16 *Q_direct_response, + const Word16 azimuth, /*i:q0*/ + const Word16 elevation, /*i:q0*/ + const Word16 spreadCoh_fx, /*i:q15*/ + Word32 *direct_response_fx, /*i/o:Q_direct_response*/ + Word16 *Q_direct_response, /*o: stores q for direct_response_fx*/ const Word16 num_channels_dir, const VBAP_HANDLE hVBAPdata ) { @@ -6602,14 +6623,14 @@ static void spreadCoherencePanningVbap_fx( } set32_fx( direct_response_fx, 0, MAX_OUTPUT_CHANNELS ); - vbap_determine_gains_fx( hVBAPdata, direct_response_fx, azimuth, elevation, 0 ); + vbap_determine_gains_fx( hVBAPdata, direct_response_fx /*q29*/, azimuth, elevation, 0 ); *Q_direct_response = Q29; move16(); IF( spreadCoh_fx > 0 ) { - vbap_determine_gains_fx( hVBAPdata, direct_response_left_fx, add( azimuth, 30 ), elevation, 0 ); - vbap_determine_gains_fx( hVBAPdata, direct_response_right_fx, sub( azimuth, 30 ), elevation, 0 ); + vbap_determine_gains_fx( hVBAPdata, direct_response_left_fx /*q29*/, add( azimuth, 30 ), elevation, 0 ); + vbap_determine_gains_fx( hVBAPdata, direct_response_right_fx /*q29*/, sub( azimuth, 30 ), elevation, 0 ); Word32 var1 = 0; move32(); @@ -6703,8 +6724,8 @@ static void spreadCoherencePanningVbap( #ifdef IVAS_FLOAT_FIXED static void normalizePanningGains_fx( - Word32 *direct_response_fx, - Word16 *q_direct_res, + Word32 *direct_response_fx, /*i/o:resultant q is q_direct_res*/ + Word16 *q_direct_res, /*i/o: stores q for direct_response_fx*/ const Word16 num_channels_dir ) { Word32 energySum_fx; @@ -6714,7 +6735,7 @@ static void normalizePanningGains_fx( move16(); Word16 gb = find_guarded_bits_fx( num_channels_dir ); - energySum_fx = sum2_f_32_fx( direct_response_fx, num_channels_dir, gb ); + energySum_fx = sum2_f_32_fx( direct_response_fx, num_channels_dir, gb ); // exp_energySum stores resultant exponent IF( GT_16( *q_direct_res, Q31 ) ) { exp_energySum = add( shl( sub( Q31, *q_direct_res ), 1 ), gb ); @@ -6723,17 +6744,17 @@ static void normalizePanningGains_fx( IF( energySum_fx > 0 ) { - normVal_fx = ISqrt32( energySum_fx, &exp_energySum ); + normVal_fx = ISqrt32( energySum_fx, &exp_energySum ); // 31-exp_energySum } ELSE { - energySum_fx = BASOP_Util_Add_Mant32Exp( energySum_fx, exp_energySum, ONE_IN_Q30, 1, &exp_energySum ); - normVal_fx = ISqrt32( energySum_fx, &exp_energySum ); + energySum_fx = BASOP_Util_Add_Mant32Exp( energySum_fx, exp_energySum, ONE_IN_Q30, 1, &exp_energySum ); // 31-exp_energySum + normVal_fx = ISqrt32( energySum_fx, &exp_energySum ); // 31-exp_energySum } FOR( i = 0; i < num_channels_dir; i++ ) { - direct_response_fx[i] = Mpy_32_32( direct_response_fx[i], normVal_fx ); + direct_response_fx[i] = Mpy_32_32( direct_response_fx[i], normVal_fx ); // q_direct_res stores resultant q for the same move32(); } Word16 exp = add( sub( Q31, *q_direct_res ), exp_energySum ); -- GitLab From 8a552db21379224392a5451afbd1ba62c6997cf3 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 23 Oct 2024 14:05:53 +0530 Subject: [PATCH 2/2] Clang formatting changes --- lib_dec/tonalMDCTconcealment_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index b46d0abd5..adb73de03 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -1621,10 +1621,10 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( { Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; move16(); - Word32 y = concealment_noise[l];//concealment_noise_e + Word32 y = concealment_noise[l]; // concealment_noise_e move32(); - last_block_nrg_correct = L_add( last_block_nrg_correct, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // exp = 2 * x_exp + ld - y = L_negate( Mpy_32_32( y, y ) );//Q31-2* concealment_noise_e + last_block_nrg_correct = L_add( last_block_nrg_correct, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // exp = 2 * x_exp + ld + y = L_negate( Mpy_32_32( y, y ) ); // Q31-2* concealment_noise_e hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, y, 2 * concealment_noise_e, &hTonalMDCTConc->curr_noise_nrg_exp ); // Q31- hTonalMDCTConc->curr_noise_nrg_exp move32(); } -- GitLab