diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index f5efb77d27dec18fdd9713d4d40e00a5127f3369..d324afcc5b57a48d13dd7f754fa541cac48c687b 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -1974,7 +1974,7 @@ void analysisCldfbEncoder_ivas_fx( Word16 *ppBuf_Real16[CLDFB_NO_COL_MAX]; Word16 *ppBuf_Imag16[CLDFB_NO_COL_MAX]; Word32 l_timeIn[L_FRAME48k]; - Word16 norm_timeIn = L_norm_arr( timeIn, samplesToProcess ); + Word16 norm_timeIn = s_min( L_norm_arr( timeIn, samplesToProcess ), L_norm_arr( st->cldfbAnaEnc->cldfb_state_fx, sub( st->cldfbAnaEnc->p_filter_length, st->cldfbAnaEnc->no_channels ) ) ); Word16 guard_bits = find_guarded_bits_fx( shl( samplesToProcess, 1 ) ); Word16 shift = 0; move16(); @@ -1990,6 +1990,7 @@ void analysisCldfbEncoder_ivas_fx( { shift = sub( guard_bits, norm_timeIn ); v_shr_32( timeIn, l_timeIn, samplesToProcess, shift ); + scale_sig32( st->cldfbAnaEnc->cldfb_state_fx, sub( st->cldfbAnaEnc->p_filter_length, st->cldfbAnaEnc->no_channels ), negate( shift ) ); } ELSE { @@ -1998,6 +1999,12 @@ void analysisCldfbEncoder_ivas_fx( cldfbAnalysis_ivas_fx( l_timeIn, ppBuf_Real, ppBuf_Imag, samplesToProcess, st->cldfbAnaEnc ); + IF( GT_16( guard_bits, norm_timeIn ) ) + { + shift = sub( guard_bits, norm_timeIn ); + scale_sig32( st->cldfbAnaEnc->cldfb_state_fx, sub( st->cldfbAnaEnc->p_filter_length, st->cldfbAnaEnc->no_channels ), shift ); + } + scale->lb_scale = sub( 16 + 5, sub( timeInq, shift ) ); enerScale.lb_scale = negate( scale->lb_scale ); enerScale.lb_scale16 = negate( scale->lb_scale ); @@ -2148,6 +2155,11 @@ void deleteCldfb_ivas_fx( free( hs->cldfb_state_fx ); } + IF( hs->FilterStates ) + { + free( hs->FilterStates ); + } + free( hs ); *h_cldfb = NULL; diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c index b68ac560e557f0207bae321bafa4e67e16a5afae..696b58640cdfe1e7c7a3ad1297640d004b60ba46 100644 --- a/lib_com/cng_exc_fx.c +++ b/lib_com/cng_exc_fx.c @@ -28,24 +28,24 @@ void CNG_exc_fx( Word16 *seed, /* i/o: random generator seed */ Word16 exc[], /* o : current non-enhanced excitation Q_new */ Word16 exc2[], /* o : current enhanced excitation Q_new */ - Word32 *lp_ener, /* i/o: LP filtered E */ + Word32 *lp_ener, /* i/o: LP filtered E Q6 */ const Word32 last_core_brate, /* i : previous frame core bitrate */ Word16 *first_CNG, /* i/o: first CNG frame flag for energy init. */ Word16 *cng_ener_seed, /* i/o: random generator seed for CNG energy */ - Word16 bwe_exc[], /* o : excitation for SWB TBE */ + Word16 bwe_exc[], /* o : excitation for SWB TBE Q_syn */ const Word16 allow_cn_step, /* i : allow CN step */ Word16 *last_allow_cn_step, /* i/o: last allow step */ const Word16 OldQ_exc, /* i : Old excitation scaling */ const Word16 Q_exc, /* i : excitation scaling */ const Word16 num_ho, /* i : number of selected hangover frames */ - Word32 q_env[], - Word32 *lp_env, - Word32 *old_env, - Word16 *exc_mem, - Word16 *exc_mem1, + Word32 q_env[], /*Q6*/ + Word32 *lp_env, /*Q6*/ + Word32 *old_env, /*Q6*/ + Word16 *exc_mem, /*Q0*/ + Word16 *exc_mem1, /*Q0*/ Word16 *sid_bw, Word16 *cng_ener_seed1, - Word16 exc3[], + Word16 exc3[], /*Q_exc*/ Word16 Opt_AMR_WB, const int16_t element_mode /* i : IVAS Element mode */ ) @@ -93,9 +93,9 @@ void CNG_exc_fx( L_tmp_ener = Mult_32_16( L_tmp_ener, 9079 ); /* divide by PIT_MAX (in Q15 + Q6 to get output in Q6)*/ L_tmp_ener = L_shr( L_tmp_ener, Q_ener ); /* -> If we want ener in Q6 */ - if ( EQ_16( L_frame, L_FRAME16k ) ) + IF( EQ_16( L_frame, L_FRAME16k ) ) { - L_tmp_ener = Mult_32_16( L_tmp_ener, 26214 ); /* Compensate for 16kHz */ + L_tmp_ener = Mult_32_16( L_tmp_ener, 26214 /*.8f in Q15*/ ); /* Compensate for 16kHz */ } *Enew = L_tmp_ener; move32(); @@ -123,14 +123,14 @@ void CNG_exc_fx( IF( LT_16( num_ho, 3 ) || LT_32( Mult_32_16( *Enew, 21845 /*1/1.5f, Q15*/ ), *lp_ener ) ) { /**lp_ener = 0.8f * *lp_ener + 0.2f * *Enew;*/ - L_tmp_ener = Mult_32_16( *lp_ener, 26214 ); - L_tmp_ener = Madd_32_16( L_tmp_ener, *Enew, 6554 ); + L_tmp_ener = Mult_32_16( *lp_ener, 26214 /*.8f in Q15*/ ); + L_tmp_ener = Madd_32_16( L_tmp_ener, *Enew, 6554 /*.2f in Q15*/ ); } ELSE { /**lp_ener = 0.95f * *lp_ener + 0.05f * *Enew;*/ - L_tmp_ener = Mult_32_16( *lp_ener, 31130 ); - L_tmp_ener = Madd_32_16( L_tmp_ener, *Enew, 1638 ); + L_tmp_ener = Mult_32_16( *lp_ener, 31130 /*.95f in Q15*/ ); + L_tmp_ener = Madd_32_16( L_tmp_ener, *Enew, 1638 /* .05f in Q15*/ ); } } ELSE @@ -192,8 +192,8 @@ FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR ) * Insert random variation for excitation energy * (random variation is scaled according to *lp_ener value) *------------------------------------------------------------*/ - L_tmp = Mult_32_16( *lp_ener, Random( cng_ener_seed ) ); - L_tmp = Mult_32_16( L_tmp, GAIN_VAR ); + L_tmp = Mult_32_16( *lp_ener, Random( cng_ener_seed ) ); // Q6 + L_tmp = Mult_32_16( L_tmp, GAIN_VAR ); // Q6 #ifdef BASOP_NOGLOB L_tmp = L_add_sat( L_tmp, *lp_ener ); #else @@ -212,11 +212,11 @@ FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR ) exp = sub( exp, exp2 ); - if ( GT_16( tmp, tmp2 ) ) + IF( GT_16( tmp, tmp2 ) ) { exp = add( exp, 1 ); } - if ( GT_16( tmp, tmp2 ) ) + IF( GT_16( tmp, tmp2 ) ) { tmp = shr( tmp, 1 ); } @@ -233,12 +233,13 @@ FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR ) FOR( i = 0; i < L_SUBFR; i++ ) { /* exc2[i] *= enr */ - L_tmp = L_mult( exc2[add( i_subfr, i )], tmp ); /* Q-4 * Q_exc+19 -> Q_exc +16 */ + L_tmp = L_mult( exc2[i_subfr + i], tmp ); /* Q-4 * Q_exc+19 -> Q_exc +16 */ #ifdef BASOP_NOGLOB - exc2[add( i_subfr, i )] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); + exc2[i_subfr + i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); #else exc2[i_subfr + i] = round_fx( L_shl( L_tmp, exp ) ); #endif + move16(); } } IF( NE_16( Opt_AMR_WB, 1 ) ) @@ -298,8 +299,8 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) { /* get AR low-passed envelope */ /* lp_env[i] = 0.9f*lp_env[i] + (1-0.9f)*old_env[i]; */ - L_tmp = Mult_32_16( lp_env[i], 29491 ); - lp_env[i] = L_add( L_tmp, Mult_32_16( old_env[i], 3277 ) ); + L_tmp = Mult_32_16( lp_env[i], 29491 /*.9f in Q15*/ ); + lp_env[i] = L_add( L_tmp, Mult_32_16( old_env[i], 3277 /*.1f in Q15*/ ) ); move32(); /* Q6 */ } @@ -381,8 +382,8 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) FOR( i = 0; i < NUM_ENV_CNG; i++ ) { /* itmp[i] += own_random( cng_ener_seed1 )*denv[i]*0.000011f + denv[i]; */ - L_tmp = Mult_32_16( denv[i], Random( cng_ener_seed1 ) ); - L_tmp = Mult_32_16( L_tmp, GAIN_VAR ); + L_tmp = Mult_32_16( denv[i], Random( cng_ener_seed1 ) ); // Q6 + L_tmp = Mult_32_16( L_tmp, GAIN_VAR ); // Q6 #ifdef BASOP_NOGLOB L_tmp = L_add_sat( L_tmp, denv[i] ); itmp[i] = L_add_sat( L_tmp, itmp[i] ); @@ -394,7 +395,8 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) if ( itmp[i] < 0 ) { - itmp[i] = L_deposit_l( 0 ); + itmp[i] = 0; + move32(); } } ptR = &fft_io[1]; @@ -413,11 +415,11 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) exp2 = sub( 31 - 6, exp2 ); /* in Q15 (L_tmp in Q6)*/ exp = sub( exp2, exp ); /* Denormalize and substract */ - if ( GT_16( tmp2, tmp ) ) + IF( GT_16( tmp2, tmp ) ) { exp = add( exp, 1 ); } - if ( GT_16( tmp2, tmp ) ) + IF( GT_16( tmp2, tmp ) ) { tmp2 = shr( tmp2, 1 ); } @@ -452,7 +454,8 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) /* enr1 = dotp( fft_io, fft_io, L_frame ) / L_frame; */ - enr1 = L_deposit_l( 1 ); + enr1 = 1; + move32(); pt_fft_io = fft_io; IF( EQ_16( L_frame, L_FRAME ) ) { @@ -498,11 +501,11 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) exp = sub( exp, exp2 ); - if ( GT_16( tmp, tmp2 ) ) + IF( GT_16( tmp, tmp2 ) ) { exp = add( exp, 1 ); } - if ( GT_16( tmp, tmp2 ) ) + IF( GT_16( tmp, tmp2 ) ) { tmp = shr( tmp, 1 ); } @@ -529,8 +532,8 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) FOR( i = 0; i < L_SUBFR; i++ ) { /* fft_io[i] *= enr */ - L_tmp = L_mult( fft_io[add( i_subfr, i )], tmp ); /* Q_exc + 16 - exp */ - fft_io[add( i_subfr, i )] = round_fx( L_shl( L_tmp, exp ) ); /*Q_exc*/ + L_tmp = L_mult( fft_io[i_subfr + i], tmp ); /* Q_exc + 16 - exp */ + fft_io[i_subfr + i] = round_fx( L_shl( L_tmp, exp ) ); /*Q_exc*/ move16(); } } @@ -538,7 +541,7 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) FOR( i = 0; i < L_frame; i++ ) { /* fft_io[i] = 0.75f*fft_io[i] + exc2[i];*/ - tmp = mult( fft_io[i], 24576 ); + tmp = mult( fft_io[i], 24576 /*.75f in Q15*/ ); #ifdef BASOP_NOGLOB fft_io[i] = add_sat( tmp, exc2[i] ); #else @@ -549,7 +552,8 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) /* enr = (dotp( fft_io, fft_io, L_frame ) / L_frame) + 0.01f */ - L_tmp2 = L_deposit_l( 1 ); + L_tmp2 = 1; + move32(); pt_fft_io = fft_io; IF( EQ_16( L_frame, L_FRAME ) ) { @@ -598,11 +602,11 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) exp2 = sub( 31 - 6, exp2 ); /* in Q15 (L_tmp in Q6)*/ exp = sub( exp2, exp ); /* Denormalize and substract */ - if ( GT_16( tmp2, tmp ) ) + IF( GT_16( tmp2, tmp ) ) { exp = add( exp, 1 ); } - if ( GT_16( tmp2, tmp ) ) + IF( GT_16( tmp2, tmp ) ) { tmp2 = shr( tmp2, 1 ); } @@ -654,7 +658,7 @@ void cng_params_postupd_fx( const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ - Word32 ho_env_circ[] /* i/o: Envelope buffer */ + Word32 ho_env_circ[] /* i/o: Envelope buffer Q6 */ #ifdef IVAS_CODE_CNG_COM , const Word16 element_mode, /* i : Element mode */ @@ -683,7 +687,7 @@ void cng_params_postupd_fx( #endif ptr = add( sub( ho_circ_ptr, *cng_buf_cnt ), 1 ); - if ( ptr < 0 ) + IF( ptr < 0 ) { ptr = add( ptr, HO_HIST_SIZE ); } @@ -782,7 +786,7 @@ void cng_params_postupd_ivas_fx( const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ - Word32 ho_env_circ[], /* i/o: Envelope buffer */ + Word32 ho_env_circ[], /* i/o: Envelope buffer Q6 */ const Word16 element_mode, /* i : Element mode */ const Word16 bwidth /* i : Audio bandwidth */ ) @@ -808,7 +812,7 @@ void cng_params_postupd_ivas_fx( #endif ptr = add( sub( ho_circ_ptr, *cng_buf_cnt ), 1 ); - if ( ptr < 0 ) + IF( ptr < 0 ) { ptr = add( ptr, HO_HIST_SIZE ); } @@ -922,7 +926,7 @@ void cng_params_upd_fx( Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ const Word16 Q_exc, /* i : Q value of excitation */ const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ - Word32 ho_env_circ[], /* i/o: Envelope buffer */ + Word32 ho_env_circ[], /* i/o: Envelope buffer Q6 */ Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ @@ -979,7 +983,8 @@ void cng_params_upd_fx( scale = norm_s( maxv ); pt_exc2 = exc2; - L_ener = L_deposit_l( 0 ); + L_ener = 0; + move32(); IF( EQ_16( L_frame, L_FRAME ) ) { FOR( j = 0; j < 128; j++ ) @@ -1046,7 +1051,7 @@ void cng_params_upd_fx( cng_Qexc_buf[*ho_circ_ptr] = Q_exc; move16(); cng_brate_buf[*ho_circ_ptr] = last_active_brate; - move16(); + move32(); } ELSE { @@ -1137,7 +1142,7 @@ void cng_params_upd_ivas_fx( Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ const Word16 Q_exc, /* i : Q value of excitation */ const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ - Word32 ho_env_circ[], /* i/o: Envelope buffer */ + Word32 ho_env_circ[], /* i/o: Envelope buffer Q(6+shift) */ Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ @@ -1192,7 +1197,8 @@ void cng_params_upd_ivas_fx( scale = norm_s( maxv ); pt_exc2 = exc2; - L_ener = L_deposit_l( 0 ); + L_ener = 0; + move32(); IF( EQ_16( L_frame, L_FRAME ) ) { FOR( j = 0; j < 128; j++ ) @@ -1259,7 +1265,7 @@ void cng_params_upd_ivas_fx( cng_Qexc_buf[*ho_circ_ptr] = Q_exc; move16(); cng_brate_buf[*ho_circ_ptr] = last_active_brate; - move16(); + move32(); } ELSE { @@ -1305,7 +1311,6 @@ void cng_params_upd_ivas_fx( att_fx = pow_10_q23[index]; // Q23 move32(); tmp = extract_h( att_fx ); // Q7 - move16(); shift = 8; move16(); } @@ -1336,7 +1341,7 @@ void cng_params_upd_ivas_fx( /* update the circular buffer of old residual envelope */ /* Copy32( env, &(ho_env_circ[add(shl(*ho_circ_ptr,4),shl(*ho_circ_ptr,2))]), NUM_ENV_CNG ); */ Copy32( env, &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG ); - scale_sig32( &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG, shift ); + scale_sig32( &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG, shift ); // Q(6+shift) } *ho_circ_size = add( *ho_circ_size, 1 ); move16(); diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 6bcb3ea4bcee71acffee8afd903144ba89f9d740..2f886ed1e50a9cd46ef6824e58a2597ee5499e37 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -1940,6 +1940,7 @@ typedef enum _DCTTYPE #define N_SMC_FEATURES 15 /* number of features */ #define N_SMC_MIXTURES 6 /* number of mixtures */ #define N_PCA_COEF 12 /* number of PCA components */ +#define HALF_N_PCA_COEF_LOG_P12_Q19 5781461//Q19 of (0.5f * N_PCA_COEF *logf( PI2 )) #define SMC_ST_MEAN_FACT 0.5 /* forgetting factor of short-term IIR mean filter */ #define SMC_ST_MEAN_RSHIFT_FACT_FX 1 /* SMC_ST_MEAN_FACT equivalent right shift factor */ diff --git a/lib_com/codec_tcx_common.c b/lib_com/codec_tcx_common.c index 9beef9275b62b7d79ccd4b0e88914f25579d03db..85e353d597392ef3eee1c7bdb521b4dc803b53ab 100644 --- a/lib_com/codec_tcx_common.c +++ b/lib_com/codec_tcx_common.c @@ -19,7 +19,8 @@ Word16 tcxGetNoiseFillingTilt( const Word16 lpcorder, const Word16 L_frame, const Word16 mode, - Word16 *noiseTiltFactor ) + Word16 *noiseTiltFactor /*Q15*/ +) { Word16 firstLine; Word32 tmp; @@ -36,7 +37,7 @@ Word16 tcxGetNoiseFillingTilt( { firstLine = shr( L_frame, 3 ); - Copy_Scale_sig( A, As, add( lpcorder, 1 ), sub( norm_s( A[0] ), 2 ) ); + Copy_Scale_sig( A, As, add( lpcorder, 1 ), sub( norm_s( A[0] ), 2 ) ); // Q(12) tmp = get_gain( As + 1, As, lpcorder ); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef BASOP_NOGLOB @@ -54,10 +55,10 @@ Word16 tcxGetNoiseFillingTilt( void tcxFormantEnhancement( - Word16 xn_buf[], - const Word16 gainlpc[], + Word16 xn_buf[], // Q(15-xn_buf_e) + const Word16 gainlpc[], // Q(15-gainlpc_e) const Word16 gainlpc_e[], - Word32 spectrum[], + Word32 spectrum[], // Q(31-spectrum_e) Word16 *spectrum_e, const Word16 L_frame, const Word16 L_frameTCX ) @@ -88,13 +89,13 @@ void tcxFormantEnhancement( e = gainlpc_e[0]; move16(); m = Sqrt16( gainlpc[0], &e ); - xn_buf[0] = shl( m, sub( e, xn_buf_e ) ); + xn_buf[0] = shl( m, sub( e, xn_buf_e ) ); // Q(15-xn_buf_e) move16(); e = gainlpc_e[1]; move16(); m = Sqrt16( gainlpc[1], &e ); - xn_buf[1] = shl( m, sub( e, xn_buf_e ) ); + xn_buf[1] = shl( m, sub( e, xn_buf_e ) ); // Q(15-xn_buf_e) move16(); fac0 = s_min( xn_buf[0], xn_buf[1] ); @@ -107,7 +108,7 @@ void tcxFormantEnhancement( e = gainlpc_e[i + 1]; move16(); m = Sqrt16( gainlpc[i + 1], &e ); - xn_buf[i + 1] = shl( m, sub( e, xn_buf_e ) ); + xn_buf[i + 1] = shl( m, sub( e, xn_buf_e ) ); // Q(15-xn_buf_e) move16(); test(); @@ -122,10 +123,10 @@ void tcxFormantEnhancement( move16(); tmp = sub( e, fac_e ); - if ( tmp > 0 ) - fac0 = shr( fac0, tmp ); - if ( tmp < 0 ) - fac1 = shl( fac1, tmp ); + IF( tmp > 0 ) + fac0 = shr( fac0, tmp ); + IF( tmp < 0 ) + fac1 = shl( fac1, tmp ); if ( tmp > 0 ) { @@ -144,7 +145,7 @@ void tcxFormantEnhancement( fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) ); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef BASOP_NOGLOB - xn_buf[add( l, j )] = s_min( xn_one, shl_o( mult( xn_buf[add( l, j )], fac ), fac_e, &Overflow ) ); + xn_buf[l + j] = s_min( xn_one, shl_o( mult( xn_buf[l + j], fac ), fac_e, &Overflow ) ); #else xn_buf[l + j] = s_min( xn_one, shl( mult( xn_buf[l + j], fac ), fac_e ) ); #endif @@ -171,10 +172,10 @@ void tcxFormantEnhancement( move16(); tmp = sub( e, fac_e ); - if ( tmp > 0 ) - fac0 = shr( fac0, tmp ); - if ( tmp < 0 ) - fac1 = shl( fac1, tmp ); + IF( tmp > 0 ) + fac0 = shr( fac0, tmp ); + IF( tmp < 0 ) + fac1 = shl( fac1, tmp ); if ( tmp > 0 ) { @@ -193,7 +194,7 @@ void tcxFormantEnhancement( fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) ); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef BASOP_NOGLOB - xn_buf[add( l, j )] = s_min( xn_one, shl_sat( mult( xn_buf[add( l, j )], fac ), fac_e ) ); + xn_buf[l + j] = s_min( xn_one, shl_sat( mult( xn_buf[l + j], fac ), fac_e ) ); #else xn_buf[l + j] = s_min( xn_one, shl( mult( xn_buf[l + j], fac ), fac_e ) ); #endif @@ -209,7 +210,7 @@ void tcxFormantEnhancement( { FOR( l = 0; l < k; l++ ) { - *spectrum = Mpy_32_16_1( *spectrum, *xn_buf ); + *spectrum = Mpy_32_16_1( *spectrum, *xn_buf ); // Q(15-xn_buf_e)+Q(31-spectrum_e)+1 -16 move32(); spectrum++; } @@ -219,7 +220,7 @@ void tcxFormantEnhancement( tmp = sub( L_frameTCX, L_frame ); FOR( i = 0; i < tmp; i++ ) { - spectrum[i] = L_shr( spectrum[i], xn_buf_e ); + spectrum[i] = L_shr( spectrum[i], xn_buf_e ); // Q(31-(specturm_e+xn_buf_e)) move32(); } *spectrum_e = add( *spectrum_e, xn_buf_e ); @@ -227,11 +228,11 @@ void tcxFormantEnhancement( } void tcxFormantEnhancement_with_shift( - Word16 xn_buf[], + Word16 xn_buf[], // Q(15-xn_buf_e_out) Word16 *xn_buf_e_out, - const Word16 gainlpc[], + const Word16 gainlpc[], // Q(15-gainlpc_e) const Word16 gainlpc_e[], - Word32 spectrum[], + Word32 spectrum[], // Q(31-spectrum_e) Word16 *spectrum_e, const Word16 L_frame, const Word16 L_frameTCX ) @@ -262,13 +263,13 @@ void tcxFormantEnhancement_with_shift( e = gainlpc_e[0]; move16(); m = Sqrt16( gainlpc[0], &e ); - xn_buf[0] = shl( m, sub( e, xn_buf_e ) ); + xn_buf[0] = shl( m, sub( e, xn_buf_e ) ); // Q(15-xn_buf_e) move16(); e = gainlpc_e[1]; move16(); m = Sqrt16( gainlpc[1], &e ); - xn_buf[1] = shl( m, sub( e, xn_buf_e ) ); + xn_buf[1] = shl( m, sub( e, xn_buf_e ) ); // Q(15-xn_buf_e) move16(); fac0 = s_min( xn_buf[0], xn_buf[1] ); @@ -281,7 +282,7 @@ void tcxFormantEnhancement_with_shift( e = gainlpc_e[i + 1]; move16(); m = Sqrt16( gainlpc[i + 1], &e ); - xn_buf[i + 1] = shl( m, sub( e, xn_buf_e ) ); + xn_buf[i + 1] = shl( m, sub( e, xn_buf_e ) ); // Q(15-xn_buf_e) move16(); test(); @@ -322,7 +323,7 @@ void tcxFormantEnhancement_with_shift( fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) ); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef BASOP_NOGLOB - xn_buf[add( l, j )] = s_min( xn_one, shl_o( mult( xn_buf[add( l, j )], fac ), fac_e, &Overflow ) ); + xn_buf[l + j] = s_min( xn_one, shl_o( mult( xn_buf[l + j], fac ), fac_e, &Overflow ) ); #else xn_buf[l + j] = s_min( xn_one, shl( mult( xn_buf[l + j], fac ), fac_e ) ); #endif @@ -349,10 +350,10 @@ void tcxFormantEnhancement_with_shift( move16(); tmp = sub( e, fac_e ); - if ( tmp > 0 ) - fac0 = shr( fac0, tmp ); - if ( tmp < 0 ) - fac1 = shl( fac1, tmp ); + IF( tmp > 0 ) + fac0 = shr( fac0, tmp ); + IF( tmp < 0 ) + fac1 = shl( fac1, tmp ); if ( tmp > 0 ) { @@ -371,7 +372,7 @@ void tcxFormantEnhancement_with_shift( fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) ); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef BASOP_NOGLOB - xn_buf[add( l, j )] = s_min( xn_one, shl_o( mult( xn_buf[add( l, j )], fac ), fac_e, &Overflow ) ); + xn_buf[l + j] = s_min( xn_one, shl_o( mult( xn_buf[l + j], fac ), fac_e, &Overflow ) ); #else xn_buf[l + j] = s_min( xn_one, shl( mult( xn_buf[l + j], fac ), fac_e ) ); #endif @@ -387,7 +388,7 @@ void tcxFormantEnhancement_with_shift( { FOR( l = 0; l < k; l++ ) { - *spectrum = Mpy_32_16_1( *spectrum, *xn_buf ); + *spectrum = Mpy_32_16_1( *spectrum, *xn_buf ); // Q(15-xn_buf_e)+Q(31-spectrum_e)+1 -16 move32(); spectrum++; } @@ -397,7 +398,7 @@ void tcxFormantEnhancement_with_shift( tmp = sub( L_frameTCX, L_frame ); FOR( i = 0; i < tmp; i++ ) { - spectrum[i] = L_shr( spectrum[i], xn_buf_e ); + spectrum[i] = L_shr( spectrum[i], xn_buf_e ); // Q(31-(specturm_e+xn_buf_e)) move32(); } *spectrum_e = add( *spectrum_e, xn_buf_e ); @@ -409,8 +410,8 @@ void tcxFormantEnhancement_with_shift( void tcxInvertWindowGrouping( TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - Word32 xn_buf[], - Word32 spectrum[], + Word32 xn_buf[], // Qx + Word32 spectrum[], // Qx const Word16 L_frame, const Word8 fUseTns, const Word16 last_core, @@ -461,7 +462,7 @@ void tcxInvertWindowGrouping( } p = spectrum + sub( L_frame, 1 ); - FOR( i = sub( L_frame, 1 ); i > L_win; i -= 2 ) + FOR( i = L_frame - 1; i > L_win; i -= 2 ) { *p-- = spectrum[i]; move32(); @@ -632,7 +633,8 @@ void tcx5TnsUngrouping( void tcx5SpectrumInterleaving_fx( const Word16 tcx5Size, - Word32 *spectrum ) + Word32 *spectrum // Qx +) { Word16 i; Word32 interleaveBuf[N_TCX10_MAX]; @@ -643,7 +645,9 @@ void tcx5SpectrumInterleaving_fx( FOR( i = 0; i < tcx5Size; i++ ) { interleaveBuf[2 * i] = spectrum[i]; - interleaveBuf[add( 2 * i, 1 )] = spectrum[add( tcx5Size, i )]; + interleaveBuf[2 * i + 1] = spectrum[tcx5Size + i]; + move32(); + move32(); } Copy32( interleaveBuf, spectrum, shl( tcx5Size, 1 ) ); @@ -659,7 +663,8 @@ void tcx5SpectrumInterleaving_fx( void tcx5SpectrumDeinterleaving_fx( const Word16 tcx5Size, - Word32 *spectrum ) + Word32 *spectrum // Qx +) { Word16 i; Word32 interleaveBuf[N_TCX10_MAX]; @@ -670,7 +675,9 @@ void tcx5SpectrumDeinterleaving_fx( FOR( i = 0; i < tcx5Size; i++ ) { interleaveBuf[i] = spectrum[2 * i]; - interleaveBuf[add( tcx5Size, i )] = spectrum[add( 2 * i, 1 )]; + interleaveBuf[tcx5Size + i] = spectrum[2 * i + 1]; + move32(); + move32(); } Copy32( interleaveBuf, spectrum, shl( tcx5Size, 1 ) ); @@ -687,7 +694,8 @@ void tcx5SpectrumDeinterleaving_fx( void tcx5TnsGrouping_fx( const Word16 L_frame, /* i : frame length (TCX5) */ const Word16 L_spec, /* i : coded spec length (TCX5, derived from filter borders*/ - Word32 *spectrum ) + Word32 *spectrum /*Qx*/ +) { /* rearrange LF sub-window lines prior to TNS synthesis filtering */ IF( LT_16( L_spec, L_frame ) ) @@ -716,8 +724,8 @@ void tcx5TnsGrouping_fx( void tcx5TnsUngrouping_fx( const Word16 L_frame, /* i : frame length (TCX5) */ const Word16 L_spec, /* i : coded spec length (TCX5, derived from filter borders*/ - Word32 *spectrum, - const Word16 enc_dec /* i : 0: encoder, else decoder */ + Word32 *spectrum, /*Qx*/ + const Word16 enc_dec /* i : 0: encoder, else decoder */ ) { /* undo rearrangement of LF sub-window lines prior to TNS analysis */ diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index ed75c249b36c8f32c700ac4825c2c202d11ad2c0..9a6e2ceed43e8a94681d699579b1d9b95303dddb 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -195,8 +195,8 @@ typedef struct _IVAS_LS_CUSTOM_LAYOUT float azimuth[IVAS_MAX_OUTPUT_CHANNELS]; float elevation[IVAS_MAX_OUTPUT_CHANNELS]; #ifdef IVAS_FLOAT_FIXED - Word32 azimuth_fx[IVAS_MAX_OUTPUT_CHANNELS]; - Word32 elevation_fx[IVAS_MAX_OUTPUT_CHANNELS]; + Word32 azimuth_fx[IVAS_MAX_OUTPUT_CHANNELS]; // Q22 + Word32 elevation_fx[IVAS_MAX_OUTPUT_CHANNELS]; // Q22 #endif int16_t num_lfe; int16_t lfe_idx[IVAS_MAX_OUTPUT_CHANNELS]; @@ -235,9 +235,9 @@ typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG float acousticPreDelay; /* Time elapsed between input signal and late reverberation start, float, range [0.001..10] */ float inputPreDelay; /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10] */ #ifdef IVAS_FLOAT_FIXED - Word32 pFc_input_fx[IVAS_CLDFB_NO_CHANNELS_MAX]; /* Center frequencies for which following values are provided: */ - Word32 pAcoustic_rt60_fx[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's T60 per center frequency */ - Word32 pAcoustic_dsr_fx[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's Diffuse to Source Ratio per center frequency */ + Word32 pFc_input_fx[IVAS_CLDFB_NO_CHANNELS_MAX]; /*Q16 Center frequencies for which following values are provided: */ + Word32 pAcoustic_rt60_fx[IVAS_CLDFB_NO_CHANNELS_MAX]; /*Q26 - The room's T60 per center frequency */ + Word32 pAcoustic_dsr_fx[IVAS_CLDFB_NO_CHANNELS_MAX]; /*Q30 - The room's Diffuse to Source Ratio per center frequency */ Word32 acousticPreDelay_fx; /* Time elapsed between input signal and late reverberation start, float, range [0.001..10] */ /*Assumed Q-27*/ Word32 inputPreDelay_fx; /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10] */ /* Assumed Q-27*/ #endif // IVAS_FLOAT_FIXED diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index 69228a482880131ac55af4b80f3ea42d94ed114b..ac1fa1a2bed39a739848645e8cccb8bef948783b 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -279,7 +279,7 @@ void initFdCngCom( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale ) * * Delete an instance of type FD_CNG_COM *-------------------------------------------------------------------*/ -void deleteFdCngCom( HANDLE_FD_CNG_COM *hFdCngCom ) /* i/o: Contains the variables related to the CLDFB-based CNG process */ +void deleteFdCngCom_fx( HANDLE_FD_CNG_COM *hFdCngCom ) /* i/o: Contains the variables related to the CLDFB-based CNG process */ { HANDLE_FD_CNG_COM hsCom; hsCom = *hFdCngCom; diff --git a/lib_com/igf_base_fx.c b/lib_com/igf_base_fx.c index 5b2f81f932e0454e9e0bf662a01689feaa2358c4..a7ebb203f176ce63d26401a3dfdace365bf1db3c 100644 --- a/lib_com/igf_base_fx.c +++ b/lib_com/igf_base_fx.c @@ -1432,19 +1432,19 @@ Word16 IGFCommonFuncsIGFConfiguration_ivas_fx( /**********************************************************************/ /* selects cumulative frequency tables and offsets for the IGF SCF arithmetic coder **************************************************************************/ -Word16 IGFCommonFuncsIGFGetCFTables( +Word16 IGFCommonFuncsIGFGetCFTables_fx( const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ const Word16 bwidth, /* i : audio bandwidth */ const Word16 element_mode, /* i : element mode */ const Word16 rf_mode, /* i : flag to signal the RF mode */ - const uint16_t **cf_se00, /* o : CF table for t == 0 and f == 0 */ - const uint16_t **cf_se01, /* o : CF table for t == 0 and f == 1 */ + const UWord16 **cf_se00, /* o : CF table for t == 0 and f == 0 */ + const UWord16 **cf_se01, /* o : CF table for t == 0 and f == 1 */ Word16 *cf_off_se01, /* o : offset for CF table above */ - const uint16_t **cf_se02, /* o : CF tables for t == 0 and f >= 2 */ + const UWord16 **cf_se02, /* o : CF tables for t == 0 and f >= 2 */ const Word16 **cf_off_se02, /* o : offsets for CF tables above */ - const uint16_t **cf_se10, /* o : CF table for t == 1 and f == 0 */ + const UWord16 **cf_se10, /* o : CF table for t == 1 and f == 0 */ Word16 *cf_off_se10, /* o : offset for CF table above */ - const uint16_t **cf_se11, /* o : CF tables for t == 1 and f >= 1 */ + const UWord16 **cf_se11, /* o : CF tables for t == 1 and f >= 1 */ const Word16 **cf_off_se11 /* o : offsets for CF tables above */ ) { @@ -1523,15 +1523,6 @@ Word16 IGFCommonFuncsIGFGetCFTables( *cf_off_se10 = cf_off_se10_tab; *cf_se11 = &cf_se11_tab[0][0][0]; *cf_off_se11 = &cf_off_se11_tab[0][0]; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); BREAK; case IGF_BITRATE_FB_16400: @@ -1547,15 +1538,6 @@ Word16 IGFCommonFuncsIGFGetCFTables( *cf_off_se10 = cf_off_se10_tab; *cf_se11 = &cf_se11_tab[0][0][0]; *cf_off_se11 = &cf_off_se11_tab[0][0]; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); BREAK; case IGF_BITRATE_FB_48000: case IGF_BITRATE_FB_64000: @@ -1569,15 +1551,6 @@ Word16 IGFCommonFuncsIGFGetCFTables( *cf_off_se10 = cf_off_se10_tab; *cf_se11 = &cf_se11_tab[0][0][0]; *cf_off_se11 = &cf_off_se11_tab[0][0]; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); BREAK; case IGF_BITRATE_FB_96000: case IGF_BITRATE_FB_128000: @@ -1594,15 +1567,6 @@ Word16 IGFCommonFuncsIGFGetCFTables( *cf_off_se10 = cf_off_se10_tab; *cf_se11 = &cf_se11_tab[0][0][0]; *cf_off_se11 = &cf_off_se11_tab[0][0]; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); BREAK; case IGF_BITRATE_SWB_48000_CPE: bitRateIndex = IGF_BITRATE_SWB_16400; @@ -1615,15 +1579,6 @@ Word16 IGFCommonFuncsIGFGetCFTables( *cf_off_se10 = cf_off_se10_tab; *cf_se11 = &cf_se11_tab[0][0][0]; *cf_off_se11 = &cf_off_se11_tab[0][0]; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); BREAK; case IGF_BITRATE_SWB_64000_CPE: case IGF_BITRATE_SWB_80000_CPE: @@ -1638,15 +1593,6 @@ Word16 IGFCommonFuncsIGFGetCFTables( *cf_off_se10 = cf_off_se10_tab; *cf_se11 = &cf_se11_tab[0][0][0]; *cf_off_se11 = &cf_off_se11_tab[0][0]; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); BREAK; case IGF_BITRATE_UNKNOWN: default: diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 8bc0f6749c0912bbc09778145e4a86d298ab92b1..214910cd36e1a47f6e6b1aac45be1c94650f1717 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -80,7 +80,7 @@ Word16 ivas_get_hodirac_flag_fx( return 0; } } -#endif +#else int16_t ivas_get_hodirac_flag( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ @@ -96,7 +96,7 @@ int16_t ivas_get_hodirac_flag( return 0; } } - +#endif /*------------------------------------------------------------------------- * ivas_dirac_sba_config() * @@ -852,7 +852,7 @@ ivas_error ivas_dirac_sba_config_fx( move32(); move16(); - hodirac_flag = ivas_get_hodirac_flag_fx( sba_total_brate, sba_order ); // implemented on 100861_dirac_dec + hodirac_flag = ivas_get_hodirac_flag_fx( sba_total_brate, sba_order ); /* map the bitrate for SID frame */ IF( EQ_32( sba_total_brate, IVAS_SID_5k2 ) ) @@ -883,13 +883,13 @@ ivas_error ivas_dirac_sba_config_fx( } nbands_coded = nbands; + move16(); IF( LE_32( sba_total_brate, res ) ) { hQMetaData->useLowerBandRes = 1; - Word16 tmp = nbands % 2; + Word16 tmp = s_and( nbands, 1 ); - move16(); move16(); nbands_coded = add( shr( nbands, 1 ), tmp ); } diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index bf819845cb6735d455d4bef5254da5cf239e5ba6..a22e45e87c4aeb373024124b416525a39e7adf05 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -118,11 +118,6 @@ ivas_error create_mct_enc( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); -ivas_error mct_enc_reconfigure( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const uint16_t b_nchan_change /* i : flag indicating different channel count */ -); - ivas_error ivas_sba_enc_reconfigure( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); @@ -367,10 +362,6 @@ ivas_error ivas_init_encoder( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); -void destroy_core_enc( - ENC_CORE_HANDLE hCoreCoder /* i/o: core encoder structure */ -); - void ivas_destroy_enc( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); @@ -3793,11 +3784,13 @@ void ivas_sba_dirac_stereo_config( STEREO_DFT_CONFIG_DATA_HANDLE hConfig /* o : DFT stereo configuration */ ); +#ifndef IVAS_FLOAT_FIXED /*! r: HO-DirAC flag */ int16_t ivas_get_hodirac_flag( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t sba_order /* i : Ambisonic (SBA) order */ ); +#endif Word16 ivas_get_sba_dirac_stereo_flag( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ @@ -4362,13 +4355,6 @@ ivas_error ivas_spar_enc_open( const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ ); -void ivas_spar_enc_close( - SPAR_ENC_HANDLE *hSpar, /* i/o: SPAR encoder handle */ - const int32_t input_Fs, /* i : input sampling rate */ - const int16_t nchan_inp, /* i : number of input channels */ - const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -); - ivas_error ivas_spar_enc( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ float *data_f[], /* i/o: input/transport audio channels */ diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index eff881370b46dc53af3bdfd06272f34e53be5e8a..59be73bfb6effd29267c0ca4568d71a829bafe36 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -775,6 +775,10 @@ void destroy_sce_dec( SCE_DEC_HANDLE hSCE /* i/o: SCE decoder structure */ ); +void destroy_core_enc_fx( + ENC_CORE_HANDLE hCoreCoder /* i/o: core encoder structure */ +); + ivas_error ivas_sce_dec_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 sce_id, /* i : SCE # identifier */ @@ -3346,6 +3350,12 @@ void ivas_mct_core_enc_fx( const Word16 sba_order /* i : Ambisonic (SBA) order */ ); + +ivas_error mct_enc_reconfigure_fx( + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + const UWord16 b_nchan_change /* i : flag indicating different channel count */ +); + Word16 quantize_phi_chan_compand_fx( Word32 phi, /* i : azimuth value Q22 */ Word32 *phi_hat, /* o : quantized azimuth Q22 */ @@ -5205,6 +5215,13 @@ ivas_error ivas_spar_enc_open_fx( const Word16 spar_reconfig_flag /* i : SPAR reconfiguration flag */ ); +void ivas_spar_enc_close_fx( + SPAR_ENC_HANDLE *hSpar, /* i/o: SPAR encoder handle */ + const Word32 input_Fs, /* i : input sampling rate */ + const Word16 nchan_inp, /* i : number of input channels */ + const Word16 spar_reconfig_flag /* i : SPAR reconfiguration flag */ +); + void ivas_spar_dec_close_fx( SPAR_DEC_HANDLE *hSpar, /* i/o: SPAR decoder handle */ const Word32 output_Fs, /* i : output sampling rate */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 7564cdc488d992560d3f5c8f0c39d4d25e466928..4448177589c08bccead5c96af0f4b912b88ef2c5 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -2286,9 +2286,6 @@ void LPDmem_enc_init( LPD_state_HANDLE hLPDmem /* i/o: LP memories */ ); -void destroy_cldfb_encoder( - Encoder_State *st /* i/o: state structure */ -); ivas_error evs_enc( Encoder_State *st, /* i/o: state structure */ const int16_t *data, /* i : input signal */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 089a92b5387ef05833b3efdbf9b80cd8c122cc95..ea3dd0530fbdf1ffd0d0b97e3a0a77328cf91083 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -5027,7 +5027,7 @@ ivas_error createFdCngCom( HANDLE_FD_CNG_COM *hFdCngCom ); void initFdCngCom( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale ); /* Delete the instance of type FD_CNG */ -void deleteFdCngCom( HANDLE_FD_CNG_COM *hFdCngCom ); +void deleteFdCngCom_fx( HANDLE_FD_CNG_COM *hFdCngCom ); /* Initialize the spectral partitioning */ void initPartitions( @@ -5734,19 +5734,19 @@ Word16 IGFCommonFuncsIGFConfiguration_ivas_fx( const Word16 rf_mode /* i : flag to signal the RF mode */ ); -Word16 IGFCommonFuncsIGFGetCFTables( +Word16 IGFCommonFuncsIGFGetCFTables_fx( const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ const Word16 bwidth, /* i : audio bandwidth */ const Word16 element_mode, /* i : element mode */ const Word16 rf_mode, /* i : flag to signal the RF mode */ - const uint16_t **cf_se00, /* o : CF table for t == 0 and f == 0 */ - const uint16_t **cf_se01, /* o : CF table for t == 0 and f == 1 */ + const UWord16 **cf_se00, /* o : CF table for t == 0 and f == 0 */ + const UWord16 **cf_se01, /* o : CF table for t == 0 and f == 1 */ Word16 *cf_off_se01, /* o : offset for CF table above */ - const uint16_t **cf_se02, /* o : CF tables for t == 0 and f >= 2 */ + const UWord16 **cf_se02, /* o : CF tables for t == 0 and f >= 2 */ const Word16 **cf_off_se02, /* o : offsets for CF tables above */ - const uint16_t **cf_se10, /* o : CF table for t == 1 and f == 0 */ + const UWord16 **cf_se10, /* o : CF table for t == 1 and f == 0 */ Word16 *cf_off_se10, /* o : offset for CF table above */ - const uint16_t **cf_se11, /* o : CF tables for t == 1 and f >= 1 */ + const UWord16 **cf_se11, /* o : CF tables for t == 1 and f >= 1 */ const Word16 **cf_off_se11 /* o : offsets for CF tables above */ ); // ari_fx.c @@ -7565,6 +7565,10 @@ void destroy_cldfb_decoder_fx( Decoder_State *st_fx /* o: Decoder static variables structure */ ); +void destroy_cldfb_encoder_fx( + Encoder_State *st /* i/o: state structure */ +); + // swb_bwe_dec_fx.c Word16 WB_BWE_gain_deq_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index cce8ed4199ff51ec4d562a6a98a5d1ee012e509c..9645e3bbee5503961554944277bd8ab22033c2b5 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -549,7 +549,7 @@ void deleteFdCngDec_fx( HANDLE_FD_CNG_DEC *hFdCngDec ) IF( hsDec != NULL ) { - deleteFdCngCom( &( hsDec->hFdCngCom ) ); + deleteFdCngCom_fx( &( hsDec->hFdCngCom ) ); free( hsDec ); *hFdCngDec = NULL; } diff --git a/lib_dec/igf_scf_dec_fx.c b/lib_dec/igf_scf_dec_fx.c index fe670df5652665d8354deb09e7b475c48e6df481..73af50879af1aaa2fce2af7ed375f915f40aeca9 100644 --- a/lib_dec/igf_scf_dec_fx.c +++ b/lib_dec/igf_scf_dec_fx.c @@ -36,7 +36,7 @@ void IGFSCFDecoderOpen( hPublicData->t = 0; move16(); /* protect against the invalid request of starting decoding with a dependent block */ - IGFCommonFuncsIGFGetCFTables( total_brate, bwidth, element_mode, rf_mode, &hPublicData->cf_se00, &hPublicData->cf_se01, &hPublicData->cf_off_se01, &hPublicData->cf_se02, &hPublicData->cf_off_se02, &hPublicData->cf_se10, &hPublicData->cf_off_se10, &hPublicData->cf_se11, &hPublicData->cf_off_se11 ); + IGFCommonFuncsIGFGetCFTables_fx( total_brate, bwidth, element_mode, rf_mode, &hPublicData->cf_se00, &hPublicData->cf_se01, &hPublicData->cf_off_se01, &hPublicData->cf_se02, &hPublicData->cf_off_se02, &hPublicData->cf_se10, &hPublicData->cf_off_se10, &hPublicData->cf_se11, &hPublicData->cf_off_se11 ); } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 71c6eeb9e5378be8e44f633f917ff06d36e3358d..2b91f3811d4fee1ff2de3b2b803ce619384051a7 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -1033,7 +1033,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer ); } - if ( NE_32( ( error = ivas_dirac_sba_config_fx( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), + if ( NE_32( ( error = ivas_dirac_sba_config_fx( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), st_ivas->ivas_format ) ), IVAS_ERR_OK ) ) { diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index e2b193791056068f83d3839b65a649ecb35d6770..04d57260676361528ba1abc896275a999528b012 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -1658,15 +1658,14 @@ void QuantizeSpectrum_ivas_fx( QuantizeTCXSpectrum_fx( st, frame_cnt, hTcxEnc->spectrum_fx[frame_cnt], hTcxEnc->spectrum_e[frame_cnt], gainlpc_fx, gainlpc_e, Aqind, tnsSize, nb_bits, vad_hover_flag, &L_frameTCX, &L_frame, &L_spec, &tcx_offset, &noiseFillingBorder, quantized_spectrum_fx, &quantized_spectrum_e, hm_cfg, &hm_active, lf_deemph_fact_fx, &nf_seed, &ener_fx, &ener_e, &gain_tcx_fx, &gain_tcx_e, prm ); - Word16 s = sub( getScaleFactor32( st->hTcxEnc->spectrum_fx[frame_cnt], L_frame ), 6 ); - scale_sig32( st->hTcxEnc->spectrum_fx[frame_cnt], L_frame, s ); - st->hTcxEnc->spectrum_e[frame_cnt] = sub( st->hTcxEnc->spectrum_e[frame_cnt], s ); - move16(); + Word16 s1 = sub( getScaleFactor32( st->hTcxEnc->spectrum_fx[frame_cnt], L_frame ), 6 ); + Word16 s2 = getScaleFactor32( quantized_spectrum_fx, s_max( L_frame, L_spec ) ); + Word16 max_e = s_max( sub( hTcxEnc->spectrum_e[frame_cnt], s1 ), sub( quantized_spectrum_e, s2 ) ); - IF( NE_16( quantized_spectrum_e, hTcxEnc->spectrum_e[frame_cnt] ) ) - { - scale_sig32( quantized_spectrum_fx, s_max( L_frame, L_spec ), sub( quantized_spectrum_e, hTcxEnc->spectrum_e[frame_cnt] ) ); - } + scale_sig32( quantized_spectrum_fx, s_max( L_frame, L_spec ), sub( quantized_spectrum_e, max_e ) ); // max_e + scale_sig32( st->hTcxEnc->spectrum_fx[frame_cnt], L_frame, sub( hTcxEnc->spectrum_e[frame_cnt], max_e ) ); // max_e + hTcxEnc->spectrum_e[frame_cnt] = max_e; + move16(); /*-----------------------------------------------------------* * Estimate and quantize noise factor * diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c index d78459371c4c543af3cb28eb4c7b05cfef52932f..481d7fdf13d0531ba3d7472754b0376166df8ceb 100644 --- a/lib_enc/fd_cng_enc.c +++ b/lib_enc/fd_cng_enc.c @@ -314,7 +314,7 @@ void deleteFdCngEnc( IF( hsEnc != NULL ) { - deleteFdCngCom_flt( &( hsEnc->hFdCngCom ) ); + deleteFdCngCom_fx( &( hsEnc->hFdCngCom ) ); free( hsEnc ); *hFdCngEnc = NULL; } diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index e439e5f22e5d870faff13d475d2ef9013f1f35e2..1c5a0a177f0188e843191de9f5594fa9cdd74fb4 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -412,7 +412,7 @@ void deleteFdCngEnc_fx( HANDLE_FD_CNG_ENC *hFdCngEnc ) move16(); IF( hsEnc != NULL ) { - deleteFdCngCom( &( hsEnc->hFdCngCom ) ); + deleteFdCngCom_fx( &( hsEnc->hFdCngCom ) ); free( hsEnc ); *hFdCngEnc = NULL; move16(); diff --git a/lib_enc/igf_scf_enc_fx.c b/lib_enc/igf_scf_enc_fx.c index 28d228e631db59c11161e8acc3d16c1d2dd120f8..b8125cbd6d408bd4de4d065d72e3fb8e5769580f 100644 --- a/lib_enc/igf_scf_enc_fx.c +++ b/lib_enc/igf_scf_enc_fx.c @@ -19,10 +19,10 @@ initialization of an instance of this module void IGFSCFEncoderOpen_fx( IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data */ H_IGF_INFO hIgfInfo, /* i : IGF info handle */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t element_mode, /* i : IVAS element mode */ - const int16_t rf_mode /* i : flag to signal the RF mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ ) { @@ -44,17 +44,14 @@ void IGFSCFEncoderOpen_fx( set16_fx( hPublicData->prev, 0, 64 ); set16_fx( hPublicData->prevSave, 0, 64 ); - hPublicData->scfCountLongBlock[0] = hIgfInfo->grid[0].swb_offset_len - 1; - hPublicData->scfCountLongBlock[1] = hIgfInfo->grid[1].swb_offset_len - 1; - hPublicData->scfCountLongBlock[2] = hIgfInfo->grid[2].swb_offset_len - 1; - move16(); - move16(); - move16(); + hPublicData->scfCountLongBlock[0] = sub( hIgfInfo->grid[0].swb_offset_len, 1 ); + hPublicData->scfCountLongBlock[1] = sub( hIgfInfo->grid[1].swb_offset_len, 1 ); + hPublicData->scfCountLongBlock[2] = sub( hIgfInfo->grid[2].swb_offset_len, 1 ); hPublicData->t = 0; move16(); /* protect against the invalid request of starting encoding with a dependent block */ - IGFCommonFuncsIGFGetCFTables( total_brate, bwidth, element_mode, rf_mode, &hPublicData->cf_se00, &hPublicData->cf_se01, &hPublicData->cf_off_se01, &hPublicData->cf_se02, &hPublicData->cf_off_se02, &hPublicData->cf_se10, &hPublicData->cf_off_se10, &hPublicData->cf_se11, &hPublicData->cf_off_se11 ); + IGFCommonFuncsIGFGetCFTables_fx( total_brate, bwidth, element_mode, rf_mode, &hPublicData->cf_se00, &hPublicData->cf_se01, &hPublicData->cf_off_se01, &hPublicData->cf_se02, &hPublicData->cf_off_se02, &hPublicData->cf_se10, &hPublicData->cf_off_se10, &hPublicData->cf_se11, &hPublicData->cf_off_se11 ); } diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index acf99f33d3eddd995db09e5508b7e5a22fe29dc4..0792fce03a24fbefb72c6adfb07d91fed6752989 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -2437,14 +2437,14 @@ void LPDmem_enc_init( * Free memory which was allocated in init_encoder() *-----------------------------------------------------------------------*/ -void destroy_cldfb_encoder( +void destroy_cldfb_encoder_fx( Encoder_State *st /* i/o: Encoder static variables structure */ ) { - deleteCldfb_ivas( &st->cldfbSynTd ); - deleteCldfb_ivas( &st->cldfbAnaEnc ); + deleteCldfb_ivas_fx( &st->cldfbSynTd ); + deleteCldfb_ivas_fx( &st->cldfbAnaEnc ); - deleteFdCngEnc( &st->hFdCngEnc ); + deleteFdCngEnc_fx( &st->hFdCngEnc ); return; } diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc.c index 51ddc90803cdd39b0f5684fc25e6e62887efffef..17bc8c2fee5696448147dd45a7116e832c1327db 100644 --- a/lib_enc/ivas_agc_enc.c +++ b/lib_enc/ivas_agc_enc.c @@ -465,7 +465,8 @@ void ivas_spar_agc_enc_close_fx( { ivas_agc_enc_state_t *hAgc; - if ( hAgcEnc == NULL || *hAgcEnc == NULL ) + test(); + IF( hAgcEnc == NULL || *hAgcEnc == NULL ) { return; } diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc.c index 7902d1cf85ab2da31b884acd9956b5df6de0217e..ecb5d2ecd04429948b1d02008427429156123d88 100644 --- a/lib_enc/ivas_core_pre_proc.c +++ b/lib_enc/ivas_core_pre_proc.c @@ -1871,6 +1871,7 @@ ivas_error ivas_compute_core_buffers( ELSE IF( GT_32( input_Fs, 8000 ) ) { lerp( st->old_inp_12k8_fx + L_INP_MEM - L_INP_MEM * 4 / 5, st->old_inp_16k_fx, L_INP_MEM, L_INP_MEM * 4 / 5 ); + Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( -1 /* Q st->old_inp_16k_fx = -1 */, sub( 15, st->exp_old_inp_12k8 ) ) ); } IF( inp16k_out != NULL ) diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index bac876c5765cade5a15ee4b0f798ec38a570f6d6..1dfe55f3b2ddb9a07b6ddfae7bc3b44ecdc4f384 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -1606,11 +1606,6 @@ ivas_error pre_proc_front_ivas_fx( #ifdef IVAS_FLOAT_FIXED_CONVERSIONS /*float to fix conversions for noise_est_pre_32fx*/ Etot_fx = (Word32) ( Etot * ( 1 << 24 ) ); - st->hNoiseEst->Etot_l_lp_32fx = (Word32) ( st->hNoiseEst->Etot_l_lp * 16777216.0 ); - st->hNoiseEst->Etot_last_32fx = (Word32) ( st->hNoiseEst->Etot_last * 16777216.0 ); - st->hNoiseEst->Etot_v_h2_32fx = (Word32) ( st->hNoiseEst->Etot_v_h2 * 16777216.0 ); - st->hNoiseEst->Etot_lp_32fx = (Word32) ( st->hNoiseEst->Etot_lp * 16777216.0 ); - st->hNoiseEst->sign_dyn_lp_32fx = (Word32) ( st->hNoiseEst->sign_dyn_lp * 16777216.0 ); /*float to fix conversions for wb_vad_ivas_fx*/ Word16 Q_new = Q_factor_arr( fr_bands, 40 ) + 3; @@ -1620,9 +1615,6 @@ ivas_error pre_proc_front_ivas_fx( floatToFixed_arrL( st->hNoiseEst->enrO, st->hNoiseEst->enrO_fx, Q_new + QSCALE, 20 ); st->flag_noisy_speech_snr_fx = (Word8) st->flag_noisy_speech_snr; - /*float to fix for dtx_hangover_addition_fx*/ - st->hNoiseEst->Etot_lp_fx = (Word16) ( st->hNoiseEst->Etot_lp * ( 1 << 8 ) ); - if ( st->cldfbAnaEnc ) st->cldfbAnaEnc->scale = (Word16) ( st->cldfbAnaEnc->scale_flt * ( 1 << 8 ) ); @@ -1637,10 +1629,6 @@ ivas_error pre_proc_front_ivas_fx( floatToFixed_arrL( hCPE->hFrontVad[1]->hNoiseEst->bckr, hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, Q_bands1 + QSCALE, NB_BANDS ); Etot_LR_fx[0] = float_to_fix16( Etot_LR[0], 8 ); Etot_LR_fx[1] = float_to_fix16( Etot_LR[1], 8 ); - hCPE->hFrontVad[0]->hNoiseEst->Etot_last_fx = float_to_fix16( hCPE->hFrontVad[0]->hNoiseEst->Etot_last, 8 ); - hCPE->hFrontVad[1]->hNoiseEst->Etot_last_fx = float_to_fix16( hCPE->hFrontVad[1]->hNoiseEst->Etot_last, 8 ); - hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_fx = float_to_fix16( hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2, 8 ); - hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_fx = float_to_fix16( hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2, 8 ); } #endif // IVAS_FLOAT_FIXED_TO_BE_REMOVED @@ -1675,8 +1663,6 @@ ivas_error pre_proc_front_ivas_fx( move16(); } - st->hNoiseEst->Etot_v_h2_fx = extract_h( st->hNoiseEst->Etot_v_h2_32fx ); /*q24 to q8*/ - st->hNoiseEst->sign_dyn_lp_fx = extract_h( st->hNoiseEst->sign_dyn_lp_32fx ); /*q24 to q8*/ st->vad_flag = wb_vad_ivas_fx( st, fr_bands_fx, &i, &i, &i, &snr_sum_he_fx, &localVAD_HE_SAD, &( st->flag_noisy_speech_snr_fx ), Q_new, NULL, NULL, -MAX_16, -MAX_16 ); //-100000f == max 16bit float move16(); move16(); @@ -1783,20 +1769,12 @@ ivas_error pre_proc_front_ivas_fx( corr_shiftR_fx = correlation_shift_fx( hCPE->hFrontVad[1]->hNoiseEst->totalNoise_fx ); } #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - /*cleanup changes for noise_est_pre_32fx*/ - st->hNoiseEst->Etot_l_lp = (float) ( st->hNoiseEst->Etot_l_lp_32fx / 16777216.0 ); - st->hNoiseEst->Etot_last = (float) ( st->hNoiseEst->Etot_last_32fx / 16777216.0 ); - st->hNoiseEst->Etot_lp = (float) ( st->hNoiseEst->Etot_lp_32fx / 16777216.0 ); - - /*cleanup changes for wb_vad_ivas_fx*/ - st->hNoiseEst->sign_dyn_lp = fixedToFloat( st->hNoiseEst->sign_dyn_lp_fx, 8 ); st->flag_noisy_speech_snr = (Word16) st->flag_noisy_speech_snr_fx; /*fixed to float for noise_est_down*/ fixedToFloat_arrL( st->hNoiseEst->bckr_fx, st->hNoiseEst->bckr, Q_new + QSCALE, NB_BANDS ); fixedToFloat_arrL( tmpN_fx, tmpN, Q_new + QSCALE, 20 ); fixedToFloat_arrL( tmpE_fx, tmpE, Q_new + QSCALE, 20 ); - st->hNoiseEst->Etot_v_h2 = fixedToFloat( st->hNoiseEst->Etot_v_h2_fx, 8 ); /*fixed to float for noise_est_down_fx concerned with fr_bands_LR*/ IF( lr_vad_enabled && st->idchan == 0 ) @@ -1805,10 +1783,8 @@ ivas_error pre_proc_front_ivas_fx( fixedToFloat_arrL( hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, hCPE->hFrontVad[1]->hNoiseEst->bckr, Q_bands1 + QSCALE, NB_BANDS ); fixedToFloat_arrL( tmpN_LR_fx[0], tmpN_LR[0], Q_bands0 + QSCALE, 20 ); fixedToFloat_arrL( tmpE_LR_fx[0], tmpE_LR[0], Q_bands0 + QSCALE, 20 ); - hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2 = fixedToFloat( hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_fx, 8 ); fixedToFloat_arrL( tmpN_LR_fx[1], tmpN_LR[1], Q_bands1 + QSCALE, 20 ); fixedToFloat_arrL( tmpE_LR_fx[1], tmpE_LR[1], Q_bands1 + QSCALE, 20 ); - hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2 = fixedToFloat( hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_fx, 8 ); // performing fix to float conversion of (corr_shift_fx) corr_shiftL = fix16_to_float( corr_shiftL_fx, 15 ); @@ -2354,24 +2330,13 @@ ivas_error pre_proc_front_ivas_fx( L_Extract( epsP_fx[j], &epsP_h[j], &epsP_l[j] ); } - st->hNoiseEst->Etot_lp_fx = float_to_fix16( st->hNoiseEst->Etot_lp, Q8 ); - st->hNoiseEst->Etot_v_h2_fx = float_to_fix16( st->hNoiseEst->Etot_v_h2, Q8 ); - st->hNoiseEst->Etot_l_lp_fx = float_to_fix16( st->hNoiseEst->Etot_l_lp, Q8 ); - st->hNoiseEst->sign_dyn_lp_fx = float_to_fix16( st->hNoiseEst->sign_dyn_lp, Q8 ); - if ( lr_vad_enabled && st->idchan == 0 ) { for ( int j = 0; j < 2; j++ ) { - hCPE->hFrontVad[j]->hNoiseEst->Etot_lp_fx = float_to_fix16( hCPE->hFrontVad[j]->hNoiseEst->Etot_lp, Q8 ); - hCPE->hFrontVad[j]->hNoiseEst->Etot_v_h2_fx = float_to_fix16( hCPE->hFrontVad[j]->hNoiseEst->Etot_v_h2, Q8 ); - hCPE->hFrontVad[j]->hNoiseEst->Etot_l_lp_fx = float_to_fix16( hCPE->hFrontVad[j]->hNoiseEst->Etot_l_lp, Q8 ); - hCPE->hFrontVad[j]->hNoiseEst->sign_dyn_lp_fx = float_to_fix16( hCPE->hFrontVad[j]->hNoiseEst->sign_dyn_lp, Q8 ); Etot_LR_fx[j] = float_to_fix16( Etot_LR[j], Q8 ); } } - - st->hNoiseEst->Etot_last_fx = float_to_fix16( st->hNoiseEst->Etot_last, Q8 ); #endif // IVAS_FLOAT_FIXED_CONVERSIONS /* Detection of very short stable pitch period */ @@ -2476,22 +2441,6 @@ ivas_error pre_proc_front_ivas_fx( fixedToFloat_arrL32( st->hNoiseEst->fr_bands2_fx, st->hNoiseEst->fr_bands2, q_fr_bands, NB_BANDS ); fixedToFloat_arrL32( st->hNoiseEst->ave_enr_fx, st->hNoiseEst->ave_enr, q_fr_bands, NB_BANDS ); fixedToFloat_arrL32( st->hNoiseEst->ave_enr2_fx, st->hNoiseEst->ave_enr2, q_fr_bands, NB_BANDS ); - - st->hNoiseEst->Etot_lp = fixedToFloat_16( st->hNoiseEst->Etot_lp_fx, Q8 ); - st->hNoiseEst->Etot_v_h2 = fixedToFloat_16( st->hNoiseEst->Etot_v_h2_fx, Q8 ); - st->hNoiseEst->Etot_l_lp = fixedToFloat_16( st->hNoiseEst->Etot_l_lp_fx, Q8 ); - st->hNoiseEst->sign_dyn_lp = fixedToFloat_16( st->hNoiseEst->sign_dyn_lp_fx, Q8 ); - if ( lr_vad_enabled && st->idchan == 0 ) - { - for ( int j = 0; j < 2; j++ ) - { - hCPE->hFrontVad[j]->hNoiseEst->Etot_lp = fixedToFloat_16( hCPE->hFrontVad[j]->hNoiseEst->Etot_lp_fx, Q8 ); - hCPE->hFrontVad[j]->hNoiseEst->Etot_v_h2 = fixedToFloat_16( hCPE->hFrontVad[j]->hNoiseEst->Etot_v_h2_fx, Q8 ); - hCPE->hFrontVad[j]->hNoiseEst->Etot_l_lp = fixedToFloat_16( hCPE->hFrontVad[j]->hNoiseEst->Etot_l_lp_fx, Q8 ); - hCPE->hFrontVad[j]->hNoiseEst->sign_dyn_lp = fixedToFloat_16( hCPE->hFrontVad[j]->hNoiseEst->sign_dyn_lp_fx, Q8 ); - } - } - #endif #else @@ -2676,13 +2625,11 @@ ivas_error pre_proc_front_ivas_fx( Etot_fx = float_to_fix( Etot, 8 ); Etot16_fx = extract_l( Etot_fx ); st->lp_speech_fx = float_to_fix16( st->lp_speech, 8 ); - st->hNoiseEst->Etot_last_fx = float_to_fix16( st->hNoiseEst->Etot_last, 8 ); #endif ivas_long_enr_fx( st, Etot16_fx, localVAD_HE_SAD, high_lpn_flag, NULL, 1, NULL, NULL ); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS // conv params from fix to float st->lp_speech = fix16_to_float( st->lp_speech_fx, 8 ); - st->hNoiseEst->Etot_last = fix16_to_float( st->hNoiseEst->Etot_last_fx, 8 ); #endif #endif mvr2r( fr_bands + NB_BANDS, st->hNoiseEst->enrO, NB_BANDS ); @@ -2698,11 +2645,6 @@ ivas_error pre_proc_front_ivas_fx( Etot_LR_fx[1] = float_to_fix16( Etot_LR[1], 8 ); #endif ivas_long_enr_fx( st, -1, localVAD_HE_SAD, high_lpn_flag, hCPE->hFrontVad, CPE_CHANNELS, localVAD_HE_SAD_LR, Etot_LR_fx ); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - hCPE->hFrontVad[0]->hNoiseEst->Etot_last = fix16_to_float( hCPE->hFrontVad[0]->hNoiseEst->Etot_last_fx, 8 ); - hCPE->hFrontVad[1]->hNoiseEst->Etot_last = fix16_to_float( hCPE->hFrontVad[1]->hNoiseEst->Etot_last_fx, 8 ); - -#endif #endif mvr2r( fr_bands_LR[0] + NB_BANDS, hCPE->hFrontVad[0]->hNoiseEst->enrO, NB_BANDS ); mvr2r( fr_bands_LR[1] + NB_BANDS, hCPE->hFrontVad[1]->hNoiseEst->enrO, NB_BANDS ); diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index c7b25cee85e2ddd64ce3111a45450c9f20b59bd1..e0bc2f18f01026f2c7fa0420435e7e27433ae01a 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -584,7 +584,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( IF( GT_16( st_ivas->nCPE, 1 ) ) { - IF( ( error = mct_enc_reconfigure( st_ivas, 0 ) ) != IVAS_ERR_OK ) + IF( ( error = mct_enc_reconfigure_fx( st_ivas, 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -1040,7 +1040,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( } ELSE IF( st_ivas->hMCT != NULL && GT_16( st_ivas->nCPE, 1 ) ) { - IF( ( error = mct_enc_reconfigure( st_ivas, st_ivas->nchan_transport != nchan_transport_old ) ) != IVAS_ERR_OK ) + IF( ( error = mct_enc_reconfigure_fx( st_ivas, st_ivas->nchan_transport != nchan_transport_old ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index ec599c5fc044c1b27bfa1608eee61c73901dfa11..4796a9a7b8dacd28588f38777870f172335a8f8d 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -264,11 +264,6 @@ ivas_error ivas_cpe_enc( hCPE->hFrontVad[n]->mem_preemph_fx = (Word16) floatToFixed( hCPE->hFrontVad[n]->mem_preemph, Q_inp - 1 ); Q_buffer[n] = Q_factor_arr( hCPE->hFrontVad[n]->buffer_12k8 + L_FFT, L_FFT / 2 ); floatToFixed_arr( hCPE->hFrontVad[n]->buffer_12k8, hCPE->hFrontVad[n]->buffer_12k8_fx, Q_buffer[n], 384 ); - hCPE->hFrontVad[n]->hNoiseEst->Etot_l_lp_32fx = (Word32) ( hCPE->hFrontVad[n]->hNoiseEst->Etot_l_lp * 16777216.0 ); - hCPE->hFrontVad[n]->hNoiseEst->Etot_last_32fx = (Word32) ( hCPE->hFrontVad[n]->hNoiseEst->Etot_last * 16777216.0 ); - hCPE->hFrontVad[n]->hNoiseEst->Etot_v_h2_32fx = (Word32) ( hCPE->hFrontVad[n]->hNoiseEst->Etot_v_h2 * 16777216.0 ); - hCPE->hFrontVad[n]->hNoiseEst->Etot_lp_32fx = (Word32) ( hCPE->hFrontVad[n]->hNoiseEst->Etot_lp * 16777216.0 ); - hCPE->hFrontVad[n]->hNoiseEst->sign_dyn_lp_32fx = (Word32) ( hCPE->hFrontVad[n]->hNoiseEst->sign_dyn_lp * 16777216.0 ); floatToFixed_arrL( hCPE->hFrontVad[n]->hNoiseEst->bckr, hCPE->hFrontVad[n]->hNoiseEst->bckr_fx, Q_new_old + QSCALE, 20 ); floatToFixed_arrL( hCPE->hFrontVad[n]->hNoiseEst->enrO, hCPE->hFrontVad[n]->hNoiseEst->enrO_fx, Q_new_old + QSCALE, 20 ); } @@ -302,12 +297,6 @@ ivas_error ivas_cpe_enc( Etot_LR[n] = fixedToFloat( Etot_LR_fx[n], Q8 ); fixedToFloat_arrL( hCPE->hFrontVad[n]->hNoiseEst->bckr_fx, hCPE->hFrontVad[n]->hNoiseEst->bckr, Q_new_old + QSCALE, 20 ); fixedToFloat_arrL( hCPE->hFrontVad[n]->hNoiseEst->enrO_fx, hCPE->hFrontVad[n]->hNoiseEst->enrO, Q_new_old + QSCALE, 20 ); - hCPE->hFrontVad[n]->hNoiseEst->Etot_l_lp = (float) ( hCPE->hFrontVad[n]->hNoiseEst->Etot_l_lp_32fx / 16777216.0 ); - hCPE->hFrontVad[n]->hNoiseEst->Etot_last = (float) ( hCPE->hFrontVad[n]->hNoiseEst->Etot_last_32fx / 16777216.0 ); - // hCPE->hFrontVad[n]->hNoiseEst->Etot_v_h2 = (float) ( hCPE->hFrontVad[n]->hNoiseEst->Etot_v_h2_32fx / 16777216.0 ); - hCPE->hFrontVad[n]->hNoiseEst->Etot_lp = (float) ( hCPE->hFrontVad[n]->hNoiseEst->Etot_lp_32fx / 16777216.0 ); - hCPE->hFrontVad[n]->hNoiseEst->Etot_v_h2 = (float) ( hCPE->hFrontVad[n]->hNoiseEst->Etot_v_h2_fx / ( 256.0 ) ); - hCPE->hFrontVad[n]->hNoiseEst->sign_dyn_lp = (float) ( hCPE->hFrontVad[n]->hNoiseEst->sign_dyn_lp_fx / ( 256.0 ) ); if ( front_create_flag ) { fixedToFloat_arrL( hCPE->hFrontVad[n]->hNoiseEst->fr_bands1_fx, hCPE->hFrontVad[n]->hNoiseEst->fr_bands1, Q17, NB_BANDS ); @@ -316,7 +305,6 @@ ivas_error ivas_cpe_enc( fixedToFloat_arrL( hCPE->hFrontVad[n]->hNoiseEst->ave_enr2_fx, hCPE->hFrontVad[n]->hNoiseEst->ave_enr2, Q8, NB_BANDS ); } } - // fixedToFloat_arrL( band_energies_fx, band_energies, Q_new + QSCALE + 2, 40 ); fixedToFloat_arrL( &band_energies_LR_fx[0], &band_energies_LR[0], Q_buffer[1] + QSCALE - band_ener_guardbits, 40 ); } #endif @@ -728,8 +716,6 @@ ivas_error ivas_cpe_enc( floatToFixed_arr16( sts[0]->input, sts[0]->input_fx, 0, input_frame ); floatToFixed_arr16( sts[1]->input, sts[1]->input_fx, 0, input_frame ); - sts[0]->hNoiseEst->Etot_last_fx = float_to_fix16( sts[0]->hNoiseEst->Etot_last, Q8 ); - sts[1]->hNoiseEst->Etot_last_fx = float_to_fix16( sts[1]->hNoiseEst->Etot_last, Q8 ); sts[0]->old_corr_fx = float_to_fix16( sts[0]->old_corr, Q15 ); sts[1]->old_corr_fx = float_to_fix16( sts[1]->old_corr, Q15 ); @@ -737,8 +723,6 @@ ivas_error ivas_cpe_enc( { floatToFixed_arr16( sts[0]->input, sts[0]->input_fx, 0, input_frame ); floatToFixed_arr16( sts[1]->input, sts[1]->input_fx, 0, input_frame ); - sts[0]->hNoiseEst->Etot_last_fx = float_to_fix16( sts[0]->hNoiseEst->Etot_last, Q8 ); - sts[1]->hNoiseEst->Etot_last_fx = float_to_fix16( sts[1]->hNoiseEst->Etot_last, Q8 ); sts[0]->old_corr_fx = float_to_fix16( sts[0]->old_corr, Q15 ); sts[1]->old_corr_fx = float_to_fix16( sts[1]->old_corr, Q15 ); } @@ -747,10 +731,6 @@ ivas_error ivas_cpe_enc( tdm_ratio_idx = stereo_tdm_ener_analysis_fx( ivas_format, hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM ); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - sts[0]->hNoiseEst->Etot_last = fix16_to_float( sts[0]->hNoiseEst->Etot_last_fx, Q8 ); - sts[1]->hNoiseEst->Etot_last = fix16_to_float( sts[1]->hNoiseEst->Etot_last_fx, Q8 ); -#endif /* Compute the downmix signal based on the ratio index */ #ifdef IVAS_FLOAT_FIXED @@ -782,15 +762,25 @@ ivas_error ivas_cpe_enc( /* signal the bitrate for BW selection in the SCh */ sts[0]->bits_frame_channel = 0; - sts[1]->bits_frame_channel = (int16_t) ( hCPE->element_brate / FRAMES_PER_SEC ); - sts[1]->bits_frame_channel += (int16_t) ( hCPE->brate_surplus / FRAMES_PER_SEC ); - if ( st_ivas->hQMetaData != NULL ) + sts[1]->bits_frame_channel = extract_l( Mpy_32_32( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + sts[1]->bits_frame_channel = add( sts[1]->bits_frame_channel, extract_l( Mpy_32_32( hCPE->brate_surplus, ONE_BY_FRAMES_PER_SEC_Q31 ) ) ); + move16(); + move16(); + move16(); + IF( st_ivas->hQMetaData != NULL ) { - sts[1]->bits_frame_channel -= st_ivas->hQMetaData->metadata_max_bits; + sts[1]->bits_frame_channel = sub( sts[1]->bits_frame_channel, st_ivas->hQMetaData->metadata_max_bits ); + move16(); } - Etot_last[0] = sts[0]->hNoiseEst->Etot_last; - Etot_last[1] = sts[1]->hNoiseEst->Etot_last; + Etot_last_fx[0] = sts[0]->hNoiseEst->Etot_last_fx; + Etot_last_fx[1] = sts[1]->hNoiseEst->Etot_last_fx; + move16(); + move16(); +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + Etot_last[0] = fix16_to_float( Etot_last_fx[0], Q8 ); + Etot_last[1] = fix16_to_float( Etot_last_fx[1], Q8 ); +#endif } else if ( hCPE->element_mode == IVAS_CPE_MDCT ) { @@ -840,7 +830,6 @@ ivas_error ivas_cpe_enc( /* iDFT at input sampling rate */ #ifdef IVAS_FLOAT_FIXED - // stereo_dft_enc_synthesize( hCPE->hStereoDft, sts[0]->input, 0, input_Fs, input_Fs, 0 ); Word16 out_start_ind, out_end_ind; Word16 out_12k8_start_ind[CPE_CHANNELS], out_12k8_end_ind[CPE_CHANNELS]; Word16 out_16k_start_ind = 0, out_16k_end_ind = 0; @@ -849,20 +838,17 @@ ivas_error ivas_cpe_enc( stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, sts[0]->input32_fx, &out_start_ind, &out_end_ind, 0, input_Fs, input_Fs, 0, NULL ); /* iDFT & resampling to 12.8kHz internal sampling rate */ - // stereo_dft_enc_synthesize( hCPE->hStereoDft, old_inp_12k8[0] + L_INP_MEM, 0, input_Fs, INT_FS_12k8, 0 ); stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_12k8_fx[0] + L_INP_MEM, &out_12k8_start_ind[0], &out_12k8_end_ind[0], 0, input_Fs, INT_FS_12k8, 0, NULL ); /* iDFT & resampling to 16kHz internal sampling rate for M channel */ IF( EQ_32( input_Fs, internal_Fs ) ) { - // mvr2r( sts[0]->input - STEREO_DFT_OVL_16k, old_inp_16k[0] + L_INP_MEM - STEREO_DFT_OVL_16k, input_frame + STEREO_DFT_OVL_16k ); Copy32( sts[0]->input32_fx - STEREO_DFT_OVL_16k, old_inp_16k_fx[0] + L_INP_MEM - STEREO_DFT_OVL_16k, input_frame + STEREO_DFT_OVL_16k ); out_16k_start_ind = -STEREO_DFT_OVL_16k; out_16k_end_ind = out_16k_start_ind + input_frame + STEREO_DFT_OVL_16k; } ELSE { - // stereo_dft_enc_synthesize( hCPE->hStereoDft, old_inp_16k[0] + L_INP_MEM, 0, input_Fs, internal_Fs, 0 ); stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_16k_fx[0] + L_INP_MEM, &out_16k_start_ind, &out_16k_end_ind, 0, input_Fs, internal_Fs, 0, NULL ); } @@ -870,13 +856,10 @@ ivas_error ivas_cpe_enc( test(); IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] ) { - // mvr2r( sts[1]->old_inp_12k8, old_inp_12k8[1], L_INP_MEM ); Copy_Scale_sig_16_32_no_sat( sts[1]->old_inp_12k8_fx, old_inp_12k8_fx[1], L_INP_MEM, 16 - 0 ); - // stereo_dft_enc_synthesize( hCPE->hStereoDft, old_inp_12k8[1] + L_INP_MEM, 1, input_Fs, 8000, 0 ); stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_12k8_fx[1] + L_INP_MEM, &out_12k8_start_ind[1], &out_12k8_end_ind[1], 1, input_Fs, 8000, 0, NULL ); /* update old input signal buffer */ - // mvr2r( old_inp_12k8[1] + L_FRAME8k, sts[1]->old_inp_12k8, L_INP_MEM ); Copy_Scale_sig_32_16( old_inp_12k8_fx[1] + L_FRAME8k, sts[1]->old_inp_12k8_fx, L_INP_MEM, 0 - 16 ); } @@ -2792,7 +2775,7 @@ FOR( n = 0; n < CPE_CHANNELS; n++ ) IF( st != NULL ) { - destroy_core_enc( st ); + destroy_core_enc_fx( st ); st = NULL; } } @@ -2837,7 +2820,7 @@ IF( hCPE->hFrontVad[0] != NULL ) { FOR( n = 0; n < CPE_CHANNELS; n++ ) { - front_vad_destroy( &hCPE->hFrontVad[n] ); + front_vad_destroy_fx( &hCPE->hFrontVad[n] ); hCPE->hFrontVad[n] = NULL; } } diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index cdca906927bed49956b2f804815126cc7d16bda3..af515d836d3a8cf6ddbefef65565711644d0ecf2 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -423,8 +423,6 @@ ivas_error front_vad_fx( /* wb_vad */ Scale_sig32( hFrontVads[n]->hNoiseEst->bckr_fx, NB_BANDS, Q_new + QSCALE - ( Q_new_old + QSCALE ) ); Scale_sig32( hFrontVads[n]->hNoiseEst->enrO_fx, NB_BANDS, Q_new + QSCALE - ( Q_new_old + QSCALE ) ); - hFrontVad->hNoiseEst->sign_dyn_lp_fx = extract_h( hFrontVad->hNoiseEst->sign_dyn_lp_32fx ); - hFrontVad->hNoiseEst->Etot_v_h2_fx = extract_h( hFrontVad->hNoiseEst->Etot_v_h2_32fx ); hFrontVad->hVAD->vad_flag = wb_vad_ivas_fx( sts[n], fr_bands_fx[n], &dummy, &dummy, &dummy, &snr_sum_he_fx, &localVAD_HE_SAD[n], &dummy_short, Q_new, hFrontVad->hVAD, hFrontVad->hNoiseEst, hFrontVad->lp_speech_fx, hFrontVad->lp_noise_fx ); test(); @@ -729,9 +727,6 @@ ivas_error front_vad_spar( Word32 tmpN_fx[NB_BANDS] = { 0 }; Word32 tmpE_fx[NB_BANDS] = { 0 }; float corr_shift; - // float res_energy; - // float ncharX; - // float sp_div, dummy; Word16 corr_shift_fx; #if 1 @@ -796,15 +791,7 @@ ivas_error front_vad_spar( FILE *fptmpE_fx = fopen( "tmpE_fx.txt", "ab+" ); FILE *fpbckr_fx = fopen( "bckr_fx.txt", "ab+" ); #endif -#if 1 - FILE *fp_pitch = fopen( "fp_pitch.txt", "ab+" ); - FILE *fp_voice = fopen( "fp_voice.txt", "ab+" ); - /* FILE *fpbckr_fl = fopen( "bckr_fl.txt", "ab+" ); - FILE *fptmpN_fx = fopen( "tmpN_fx.txt", "ab+" ); - FILE *fptmpE_fx = fopen( "tmpE_fx.txt", "ab+" ); - FILE *fpbckr_fx = fopen( "bckr_fx.txt", "ab+" );*/ -#endif push_wmops( "front_vad_SPAR" ); error = IVAS_ERR_OK; hFrontVad = hSpar->hFrontVad; @@ -828,7 +815,6 @@ ivas_error front_vad_spar( floatToFixed_arr( st->old_wsp, st->old_wsp_fx, Q9, L_WSP_MEM ); floatToFixed_arr( st->old_wsp2, st->old_wsp2_fx, Q9, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ); floatToFixed_arr( st->mem_decim2, st->mem_decim2_fx, Q9, 3 ); - // st->mem_wsp_fx = (Word16) floatToFixed( st->mem_wsp, Q_inp_12k8 ); MVR2R_WORD16( st->old_wsp_fx, old_wsp_fx, L_WSP_MEM ); wsp = old_wsp + L_WSP_MEM; @@ -847,15 +833,7 @@ ivas_error front_vad_spar( delay_signal_float( st->input, input_frame, hFrontVad->delay_buf, hFrontVad->delay_samples ); Word16 Q_inp; Q_inp = Q_factor_arr( st->input, L_FRAME48k ); -#if 0 - FILE *fp = fopen( "input_before.txt", "ab+" ); - for ( int i = 0; i < L_FRAME48k; i++ ) - { - fprintf( fp, "%d\t", i ); - fprintf( fp, "%f\n", st->input[i] ); - } - fclose( fp ); -#endif + floatToFixed_arr( st->input, st->input_fx, Q_inp, L_FRAME48k ); Word16 Q_add = 0; move16(); @@ -880,11 +858,6 @@ ivas_error front_vad_spar( hFrontVad->mem_preemph_fx = (Word16) floatToFixed( hFrontVad->mem_preemph, Q_inp - 1 ); Word16 Q_buffer = Q_factor_arr( hFrontVad->buffer_12k8 + L_FFT, L_FFT / 2 ); floatToFixed_arr( hFrontVad->buffer_12k8, hFrontVad->buffer_12k8_fx, Q_buffer, 384 ); - hFrontVad->hNoiseEst->Etot_l_lp_32fx = (Word32) ( hFrontVad->hNoiseEst->Etot_l_lp * 16777216.0 ); - hFrontVad->hNoiseEst->Etot_last_32fx = (Word32) ( hFrontVad->hNoiseEst->Etot_last * 16777216.0 ); - hFrontVad->hNoiseEst->Etot_v_h2_32fx = (Word32) ( hFrontVad->hNoiseEst->Etot_v_h2 * 16777216.0 ); - hFrontVad->hNoiseEst->Etot_lp_32fx = (Word32) ( hFrontVad->hNoiseEst->Etot_lp * 16777216.0 ); - hFrontVad->hNoiseEst->sign_dyn_lp_32fx = (Word32) ( hFrontVad->hNoiseEst->sign_dyn_lp * 16777216.0 ); st->lp_speech_fx = (Word16) floatToFixed( st->lp_speech, Q8 ); floatToFixed_arrL( hFrontVad->hNoiseEst->bckr, hFrontVad->hNoiseEst->bckr_fx, Q_new_old + QSCALE + 2, 20 ); floatToFixed_arrL( hFrontVad->hNoiseEst->enrO, hFrontVad->hNoiseEst->enrO_fx, Q_new_old + QSCALE + 2, 20 ); @@ -910,14 +883,6 @@ ivas_error front_vad_spar( } fixedToFloat_arrL( PS_fx, PS, Q_buffer + QSCALE, 128 ); Etot[0] = fixedToFloat( Etot_fx[0], Q8 ); - hFrontVad->hNoiseEst->Etot_l_lp = (float) ( hFrontVad->hNoiseEst->Etot_l_lp_32fx / 16777216.0 ); - hFrontVad->hNoiseEst->Etot_last = (float) ( hFrontVad->hNoiseEst->Etot_last_32fx / 16777216.0 ); - // hFrontVad->hNoiseEst->Etot_v_h2 = (float) ( hFrontVad->hNoiseEst->Etot_v_h2_32fx / 16777216.0 ); - hFrontVad->hNoiseEst->Etot_lp = (float) ( hFrontVad->hNoiseEst->Etot_lp_32fx / 16777216.0 ); - // hFrontVad->hNoiseEst->sign_dyn_lp = (float) ( hFrontVad->hNoiseEst->sign_dyn_lp_32fx / 16777216.0 ); - - hFrontVad->hNoiseEst->Etot_v_h2 = (float) ( hFrontVad->hNoiseEst->Etot_v_h2_fx / ( 256.0 ) ); - hFrontVad->hNoiseEst->sign_dyn_lp = (float) ( hFrontVad->hNoiseEst->sign_dyn_lp_fx / ( 256.0 ) ); fixedToFloat_arrL( &band_energies_fx[0], &band_energies[0], Q_buffer + QSCALE + 2 - band_ener_guardbits, 40 ); #endif #endif @@ -932,10 +897,7 @@ ivas_error front_vad_spar( floatToFixed_arrL( tmpE, tmpE_fx, Q_bands + QSCALE, NB_BANDS ); #endif Etot_fx[0] = (Word16) ( Etot[0] * ONE_IN_Q8 ); - hFrontVad->hNoiseEst->Etot_last_fx = (Word16) ( hFrontVad->hNoiseEst->Etot_last * ONE_IN_Q8 ); - hFrontVad->hNoiseEst->Etot_v_h2_fx = (Word16) ( hFrontVad->hNoiseEst->Etot_v_h2 * ONE_IN_Q8 ); noise_est_down_fx( fr_bands_fx[0], hFrontVad->hNoiseEst->bckr_fx, tmpN_fx, tmpE_fx, st->min_band, st->max_band, &hFrontVad->hNoiseEst->totalNoise_fx, Etot_fx[0], &hFrontVad->hNoiseEst->Etot_last_fx, &hFrontVad->hNoiseEst->Etot_v_h2_fx, Q_bands, e_min_scaled ); - // noise_est_down( fr_bands[0], hFrontVad->hNoiseEst->bckr, tmpN, tmpE, st->min_band, st->max_band, &hFrontVad->hNoiseEst->totalNoise, Etot[0], &hFrontVad->hNoiseEst->Etot_last, &hFrontVad->hNoiseEst->Etot_v_h2 ); #ifdef DUMP_VAD_SPAR for ( Word16 i = 0; i < 20; i++ ) { @@ -948,9 +910,6 @@ ivas_error front_vad_spar( fixedToFloat_arrL( hFrontVad->hNoiseEst->bckr_fx, hFrontVad->hNoiseEst->bckr, Q_bands + Q7, NB_BANDS ); fixedToFloat_arrL( tmpN_fx, tmpN, Q_bands + QSCALE, 20 ); fixedToFloat_arrL( tmpE_fx, tmpE, Q_bands + QSCALE, 20 ); - // Etot[0] = (float) Etot_fx[0] / ONE_IN_Q8; - hFrontVad->hNoiseEst->Etot_last = (float) hFrontVad->hNoiseEst->Etot_last_fx / ONE_IN_Q8; - hFrontVad->hNoiseEst->Etot_v_h2 = (float) hFrontVad->hNoiseEst->Etot_v_h2_fx / ONE_IN_Q8; #ifdef DUMP_VAD_SPAR for ( Word16 i = 0; i < 20; i++ ) { @@ -965,7 +924,6 @@ ivas_error front_vad_spar( #if 1 Q_inp_12k8 = Q_factor_arr( inp_12k8, 3 * L_FRAME / 2 ); floatToFixed_arr( inp_12k8, inp_12k8_fx, Q_inp_12k8, 3 * L_FRAME / 2 ); - // Q_lp_noise = Q_factor( st->lp_noise ); dtx_ivas_fx( st, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 ); #else dtx( st, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8 ); @@ -1014,7 +972,6 @@ ivas_error front_vad_spar( ivas_find_wsp( L_FRAME, L_SUBFR, NB_SUBFR, A_fx, Aw_fx, inp_12k8_fx, TILT_FAC_FX, wsp_fx, &st->mem_wsp_fx, GAMMA1, L_LOOK_12k8 ); fixedToFloat_arr( wsp_fx, wsp, Q_inp_12k8, 368 ); fixedToFloat_arr( Aw_fx, Aw, Q12, NB_SUBFR16k * ( M + 1 ) ); - // st->mem_wsp = fixedToFloat( st->mem_wsp_fx, Q_inp_12k8 ); #endif if ( st->vad_flag == 0 ) @@ -1047,14 +1004,6 @@ ivas_error front_vad_spar( fixedToFloat_arr( st->old_wsp2_fx, st->old_wsp2, Q8, 115 ); fixedToFloat_arr( st->mem_decim2_fx, st->mem_decim2, Q8, 3 ); st->old_corr = fixedToFloat( st->old_corr_fx, Q15 ); - // corr_shift_fx = floatToFixed( corr_shift, Q15 ); - // st->old_thres_fx = floatToFixed( relE, Q8 ); - /*for ( Word16 i = 0; i < 3; i++ ) - { - fprintf( fp_pitch, "%d\n", st->pitch[i] ); - fprintf( fp_voice, "%f\n", st->voicing[i] ); - }*/ - // fprintf( fpbckr_fl, "%f\n", hFrontVad->hNoiseEst->bckr[i] ); #else pitch_ol( st->pitch, st->voicing, &st->old_pitch, &st->old_corr, corr_shift, &st->old_thres, &st->delta_pit, st->old_wsp2, wsp, st->mem_decim2, relE, L_LOOK_12k8, st->clas, st->input_bwidth, st->Opt_SC_VBR ); #endif @@ -1100,11 +1049,7 @@ ivas_error front_vad_spar( floatToFixed_arrL( hFrontVad->hNoiseEst->fr_bands2, hFrontVad->hNoiseEst->fr_bands2_fx, Q_bands + QSCALE, NB_BANDS ); floatToFixed_arrL( hFrontVad->hNoiseEst->ave_enr, hFrontVad->hNoiseEst->ave_enr_fx, Q_bands + QSCALE, NB_BANDS ); floatToFixed_arrL( hFrontVad->hNoiseEst->ave_enr2, hFrontVad->hNoiseEst->ave_enr2_fx, Q_bands + QSCALE, NB_BANDS ); - hFrontVad->hNoiseEst->sign_dyn_lp_fx = (Word16) floatToFixed( hFrontVad->hNoiseEst->sign_dyn_lp, Q8 ); - hFrontVad->hNoiseEst->Etot_l_lp_fx = (Word16) floatToFixed( hFrontVad->hNoiseEst->Etot_l_lp, Q8 ); - hFrontVad->hNoiseEst->Etot_lp_fx = (Word16) floatToFixed( hFrontVad->hNoiseEst->Etot_lp, Q8 ); - hFrontVad->hNoiseEst->Etot_v_h2_fx = (Word16) floatToFixed( hFrontVad->hNoiseEst->Etot_v_h2, Q8 ); corr_shift_fx = (Word16) floatToFixed( corr_shift, Q15 ); floatToFixed_arrL( hFrontVad->hNoiseEst->bckr, hFrontVad->hNoiseEst->bckr_fx, Q_bands + QSCALE, NB_BANDS ); @@ -1138,13 +1083,8 @@ ivas_error front_vad_spar( #else SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas; #if 1 - // Word16 relE_fx; - // Word16 lsp_new_fx[M]; - // Word32 PS_fx[128]; - // Word32 epsP_fx[M + 1]; cor_map_sum_fx = float_to_fix16( cor_map_sum, Q8 ); Word16 non_sta_fx = float_to_fix16( non_staX, Q6 ); - // Word32 epsP_fx[M + 1]; Word16 Etot_fx_0 = float_to_fix16( Etot[0], Q8 ); floatToFixed_arr( lsp_new, lsp_new_fx, Q15, M ); relE_fx = float_to_fix16( relE, 8 ); @@ -1162,14 +1102,10 @@ ivas_error front_vad_spar( fixedToFloat_arrL32( hSpMusClas->past_PS_fx, hSpMusClas->past_PS, Qfact_PS_past, 67 ); #endif #endif -#if 0 - /* long-term energy update */ - long_enr( st, -1, localVAD_HE_SAD[0], high_lpn_flag, &hFrontVad, 1, localVAD_HE_SAD, Etot ); -#else + /* long-term energy update */ ivas_long_enr_fx( st, -1, localVAD_HE_SAD[0], high_lpn_flag, &hFrontVad, 1, localVAD_HE_SAD, Etot_fx ); - hFrontVad->hNoiseEst->Etot_last = fixedToFloat( hFrontVad->hNoiseEst->Etot_last_fx, Q8 ); -#endif + /* increase ini_frame counter */ hFrontVad->ini_frame = min( hFrontVad->ini_frame + 1, MAX_FRAME_COUNTER ); st->ini_frame = hFrontVad->ini_frame; @@ -1198,10 +1134,7 @@ ivas_error front_vad_spar( fclose( fptmpE_fx ); fclose( fpbckr_fx ); #endif -#if 1 - fclose( fp_pitch ); - fclose( fp_voice ); -#endif + pop_wmops(); return error; } diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index e0fd588022d89bfc41c396f7ad419ae166654b2b..2378bd8d413c18b9ba6a1bd31ad94b5e72155fd7 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -1949,13 +1949,13 @@ ivas_error ivas_init_encoder_fx( * Close core encoder handles *-------------------------------------------------------------------------*/ -void destroy_core_enc( +void destroy_core_enc_fx( ENC_CORE_HANDLE hCoreCoder /* i/o: core encoder structure */ ) { Word16 i; - destroy_cldfb_encoder( hCoreCoder ); + destroy_cldfb_encoder_fx( hCoreCoder ); IF( hCoreCoder->hSignalBuf != NULL ) { @@ -1969,6 +1969,7 @@ void destroy_core_enc( FOR( i = 0; i < hCoreCoder->hBstr->nb_ind_tot; i++ ) { hCoreCoder->hBstr->ind_list[i].nb_bits = -1; + move16(); } free( hCoreCoder->hBstr ); hCoreCoder->hBstr = NULL; @@ -2185,7 +2186,7 @@ void ivas_destroy_enc( ivas_param_ism_enc_close( &( st_ivas->hParamIsm ), st_ivas->hEncoderConfig->input_Fs ); /* SPAR handle */ - ivas_spar_enc_close( &( st_ivas->hSpar ), st_ivas->hEncoderConfig->input_Fs, nchan_inp, 0 ); + ivas_spar_enc_close_fx( &( st_ivas->hSpar ), st_ivas->hEncoderConfig->input_Fs, nchan_inp, 0 ); /* MASA handle */ ivas_masa_enc_close( &( st_ivas->hMasa ) ); diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 51aff96df92d2fbac8dbed8c320f221435f464bd..4750162a7405e209968766401d71d3d45f0516f1 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -121,12 +121,6 @@ static void set_mct_enc_params( set16_fx( hMCT->lowE_ch, 0, MCT_MAX_CHANNELS ); -#if 1 // TODO: To be removed later - for ( n = 0; n < MCT_MAX_CHANNELS; n++ ) - { - set_f( hMCT->lastxCorrMatrix[n], 0, MCT_MAX_CHANNELS ); - } -#endif FOR( n = 0; n < MCT_MAX_CHANNELS; n++ ) { set32_fx( hMCT->lastxCorrMatrix_fx[n], 0, MCT_MAX_CHANNELS ); @@ -1228,7 +1222,7 @@ ivas_error mct_enc_reconfigure( return error; } #else -ivas_error mct_enc_reconfigure( +ivas_error mct_enc_reconfigure_fx( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ const UWord16 b_nchan_change /* i : flag indicating different channel count */ ) @@ -1305,7 +1299,7 @@ ivas_error mct_enc_reconfigure( } /* in case we have an uneven number of transport channels, indicate last channel ID as inactive */ - IF( hMCT->nchan_out_woLFE % 2 ) + IF( s_and( hMCT->nchan_out_woLFE, 1 ) ) { st_ivas->hCPE[st_ivas->nCPE - 1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; move16(); diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index aafe494b43704d6d956d209d4c8beaa94f91f996..f9fcd6ca90106990f209827e3a7992bf91045ca6 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -432,7 +432,7 @@ ivas_error ivas_osba_enc_reconfig( } spar_reconfig_flag = 1; move16(); - ivas_spar_enc_close( &( st_ivas->hSpar ), hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag ); + ivas_spar_enc_close_fx( &( st_ivas->hSpar ), hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag ); IF( ( error = ivas_spar_enc_open( st_ivas, spar_reconfig_flag ) ) != IVAS_ERR_OK ) { diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index c1e8a4b4222dace120c2c8fa844ea81327680ce9..f246cb49db23249079dca7425cedb77c7022e838 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -226,7 +226,7 @@ ivas_error ivas_sba_enc_reconfigure( } spar_reconfig_flag = 1; move16(); - ivas_spar_enc_close( &( st_ivas->hSpar ), hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag ); + ivas_spar_enc_close_fx( &( st_ivas->hSpar ), hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag ); IF( ( error = ivas_spar_enc_open( st_ivas, spar_reconfig_flag ) ) != IVAS_ERR_OK ) { diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 6637128dd65aa575e57a27c7b8e4d96d20a83e5f..7c86f194af19acc5095e967f70df855979914d34 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -687,7 +687,7 @@ void destroy_sce_enc( } ELSE { - destroy_core_enc( st ); + destroy_core_enc_fx( st ); st = NULL; } } diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 788f9dec25f75c0be3f51319db01afbc62776a41..6e506a1251b70ba8245399052b772797abe76637 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -489,75 +489,65 @@ ivas_error ivas_spar_enc_open_fx( * Deallocate SPAR encoder handle *------------------------------------------------------------------------*/ -void ivas_spar_enc_close( - SPAR_ENC_HANDLE *hSpar, /* i/o: SPAR encoder handle */ - const int32_t input_Fs, /* i : input sampling rate */ - const int16_t nchan_inp, /* i : number of input channels */ - const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ +void ivas_spar_enc_close_fx( + SPAR_ENC_HANDLE *hSpar, /* i/o: SPAR encoder handle */ + const Word32 input_Fs, /* i : input sampling rate */ + const Word16 nchan_inp, /* i : number of input channels */ + const Word16 spar_reconfig_flag /* i : SPAR reconfiguration flag */ ) { - int16_t num_chans; + Word16 num_chans; - if ( hSpar == NULL || *hSpar == NULL ) + test(); + IF( hSpar == NULL || *hSpar == NULL ) { return; } - if ( !spar_reconfig_flag ) + IF( !spar_reconfig_flag ) { /* core-coder-VAD handle */ - if ( ( *hSpar )->hCoreCoderVAD != NULL ) + IF( ( *hSpar )->hCoreCoderVAD != NULL ) { - destroy_core_enc( ( *hSpar )->hCoreCoderVAD ); + destroy_core_enc_fx( ( *hSpar )->hCoreCoderVAD ); ( *hSpar )->hCoreCoderVAD = NULL; } /* front-VAD handle */ - if ( ( *hSpar )->hFrontVad != NULL ) + IF( ( *hSpar )->hFrontVad != NULL ) { - front_vad_destroy( &( *hSpar )->hFrontVad ); + front_vad_destroy_fx( &( *hSpar )->hFrontVad ); ( *hSpar )->hFrontVad = NULL; } } num_chans = ( *hSpar )->hFbMixer->fb_cfg->num_in_chans; + move16(); assert( num_chans <= nchan_inp ); /* MD handle */ ivas_spar_md_enc_close_fx( &( *hSpar )->hMdEnc ); /* Covar. State handle */ -#ifdef IVAS_FLOAT_FIXED ivas_spar_covar_enc_close_fx( &( *hSpar )->hCovEnc, num_chans ); -#else - ivas_spar_covar_enc_close( &( *hSpar )->hCovEnc, num_chans ); -#endif /* FB mixer handle */ ivas_FB_mixer_close_fx( &( *hSpar )->hFbMixer, input_Fs, spar_reconfig_flag ); /* AGC */ -#ifdef IVAS_FLOAT_FIXED ivas_spar_agc_enc_close_fx( &( *hSpar )->hAgcEnc ); -#else - ivas_spar_agc_enc_close( &( *hSpar )->hAgcEnc ); -#endif /* PCA */ - if ( ( *hSpar )->hPCA != NULL ) + IF( ( *hSpar )->hPCA != NULL ) { free( ( *hSpar )->hPCA ); ( *hSpar )->hPCA = NULL; } - if ( !spar_reconfig_flag ) + IF( !spar_reconfig_flag ) { /* Trans Det handle */ -#ifdef IVAS_FLOAT_FIXED ivas_transient_det_close_fx( &( *hSpar )->hTranDet ); -#else - ivas_transient_det_close( &( *hSpar )->hTranDet ); -#endif free( ( *hSpar ) ); ( *hSpar ) = NULL; } diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 2c75c4f984490701f5286215af5b49338d6ea036..8ca0113c33dda0e6a546f50f419ffd18566e3ff8 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -293,6 +293,7 @@ void ivas_spar_md_enc_close_fx( Word16 num_channels, i, j; ivas_spar_md_enc_state_t *hMdEnc; + test(); IF( hMdEnc_in == NULL || *hMdEnc_in == NULL ) { return; diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index e154ab7ca459f34f7d406367c4ce50fd695825a8..da7514f9d3cec7884029aa44f2906137a7b23339 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -1587,7 +1587,6 @@ typedef struct mct_enc_data_structure int16_t bitsChannelPairIndex; /* bits needed to code channel pair index, depends on number of active channels */ MCT_BLOCK_DATA_HANDLE hBlockData[MCT_MAX_BLOCKS]; - float lastxCorrMatrix[MCT_MAX_CHANNELS][MCT_MAX_CHANNELS]; #ifdef IVAS_FLOAT_FIXED Word32 lastxCorrMatrix_fx[MCT_MAX_CHANNELS][MCT_MAX_CHANNELS]; Word16 lastxCorrMatrix_e; diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c index c8c0fdc95c6507cc80c40af9f368043eb2065817..e6c8341a8daa843b535607b90f8715db4601cc15 100644 --- a/lib_enc/ivas_stereo_switching_enc.c +++ b/lib_enc/ivas_stereo_switching_enc.c @@ -463,7 +463,7 @@ ivas_error stereo_memory_enc_fx( IF( hCPE->hCoreCoder[1]->hFdCngEnc != NULL ) { - deleteFdCngEnc( &hCPE->hCoreCoder[1]->hFdCngEnc ); + deleteFdCngEnc_fx( &hCPE->hCoreCoder[1]->hFdCngEnc ); } } diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 1bfc4a4bf83a68767169b4c2bc1c490430fc0a75..d5f2028f05f8c89635a0b5772d76b266f0551058 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -51,8 +51,10 @@ #define LN_E_MIN_PLUS_ONE_FX 1 /* max(1, ln(E_MIN+1.0)) = max(1,ln(0.0035f+1f)) in Q8 */ #define COR_MAX_NNE_FX 27853 /* 0.85 Q15 */ -#define HE_LT_THR1_FX 2560 /*10.0 Q8*/ -#define HE_LT_THR2_FX 7680 /*30.0 Q8*/ +#define HE_LT_THR1_FX 2560 /*10.0 Q8*/ +#define HE_LT_THR2_FX 7680 /*30.0 Q8*/ +#define HE_LT_THR1_Q24 167772160 /*10.0 Q24 */ +#define HE_LT_THR2_Q24 503316480 /*30.0 Q24 */ /*-----------------------------------------------------------------* * noise_est_AR1_Qx() @@ -224,20 +226,7 @@ void noise_est_init_fx( move16(); hNoiseEst->lt_aEn_zero_fx = 0; move16(); - hNoiseEst->Etot_h_32fx = 0; - move32(); - hNoiseEst->Etot_l_32fx = 0; - move32(); - hNoiseEst->Etot_l_lp_32fx = 0; - move32(); - hNoiseEst->Etot_last_32fx = 0; - move32(); - hNoiseEst->Etot_v_h2_32fx = 0; - move32(); - hNoiseEst->Etot_lp_32fx = 0; - move32(); - hNoiseEst->sign_dyn_lp_32fx = 0; - move32(); + /* Tonal detector */ FOR( i = 0; i < L_FFT / 2; i++ ) { @@ -293,12 +282,6 @@ void noise_est_init_ivas_fx( hNoiseEst->harm_cor_cnt = 0; hNoiseEst->bg_cnt = 0; hNoiseEst->low_tn_track_cnt = 0; - - hNoiseEst->Etot_lp = 0.0f; - hNoiseEst->Etot_l_lp = 0.0f; - hNoiseEst->Etot_last = 0.0f; - hNoiseEst->Etot_v_h2 = 0.0f; - hNoiseEst->sign_dyn_lp = 0.0f; #endif FOR( i = 0; i < NB_BANDS; i++ ) { @@ -358,20 +341,7 @@ void noise_est_init_ivas_fx( move16(); hNoiseEst->lt_aEn_zero_fx = 0; move16(); - hNoiseEst->Etot_h_32fx = 0; - move32(); - hNoiseEst->Etot_l_32fx = 0; - move32(); - hNoiseEst->Etot_l_lp_32fx = 0; - move32(); - hNoiseEst->Etot_last_32fx = 0; - move32(); - hNoiseEst->Etot_v_h2_32fx = 0; - move32(); - hNoiseEst->Etot_lp_32fx = 0; - move32(); - hNoiseEst->sign_dyn_lp_32fx = 0; - move32(); + /* Tonal detector */ FOR( i = 0; i < L_FFT / 2; i++ ) { @@ -514,83 +484,82 @@ void noise_est_pre_fx( } void noise_est_pre_32fx( - const Word32 Etot, /* i : Energy of current frame */ - const Word16 ini_frame_fx, /* i : Frame number (init) */ - NOISE_EST_HANDLE hNoiseEst, /* i/o: Noise estimation handle */ - const int16_t idchan, /* i : channel ID */ - const int16_t element_mode, /* i : element mode */ - const int16_t last_element_mode /* i : last element mode */ + const Word32 Etot, /* i : Energy of current frame Q24 */ + const Word16 ini_frame_fx, /* i : Frame number (init) */ + NOISE_EST_HANDLE hNoiseEst, /* i/o: Noise estimation handle */ + const Word16 idchan, /* i : channel ID */ + const Word16 element_mode, /* i : element mode */ + const Word16 last_element_mode /* i : last element mode */ ) { Word32 tmp; + Word32 Etot_h_32fx; + Word32 Etot_l_32fx; + Word32 Etot_lp_32fx; + test(); + test(); + test(); IF( LE_16( ini_frame_fx, 1 ) || ( EQ_16( idchan, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) { - hNoiseEst->Etot_h_32fx = Etot; - move16(); - hNoiseEst->Etot_l_32fx = Etot; - move16(); - hNoiseEst->Etot_l_lp_32fx = Etot; - move16(); - hNoiseEst->Etot_last_32fx = Etot; + Etot_h_32fx = Etot; + move32(); + Etot_l_32fx = Etot; + move32(); + hNoiseEst->Etot_l_lp_fx = extract_h( Etot ); // Q8 move16(); - hNoiseEst->Etot_v_h2_32fx = 0; + hNoiseEst->Etot_last_fx = extract_h( Etot ); // Q8 move16(); - hNoiseEst->Etot_lp_32fx = Etot; + hNoiseEst->Etot_v_h2_fx = 0; move16(); - hNoiseEst->sign_dyn_lp_32fx = 0; + Etot_lp_32fx = Etot; + move32(); + hNoiseEst->sign_dyn_lp_fx = 0; move16(); } ELSE { /* *Etot_lp = 0.20f*Etot + 0.80f* *Etot_lp; */ - hNoiseEst->Etot_lp_32fx = L_add( Mpy_32_32( 429496730, Etot ), Mpy_32_32( 1717986918, hNoiseEst->Etot_lp_32fx ) ); - move16(); - - hNoiseEst->Etot_h_32fx = L_sub( hNoiseEst->Etot_h_32fx, 671089 ); - move16(); /* 10=0.04 in Q8 */ - hNoiseEst->Etot_h_32fx = L_max( hNoiseEst->Etot_h_32fx, Etot ); - move16(); - hNoiseEst->Etot_l_32fx = L_add( hNoiseEst->Etot_l_32fx, 1342177 ); - move16(); /* 20 = .08 in Q8 */ + Etot_lp_32fx = L_add( Mpy_32_32( 429496730 /* 0.2 in Q31 */, Etot ), Mpy_32_32( 1717986918 /* 0.8 in Q31 */, L_deposit_h( hNoiseEst->Etot_lp_fx ) ) ); + Etot_h_32fx = L_sub( L_deposit_h( hNoiseEst->Etot_h_fx ), 671089 ); /* 671089=0.04 in Q24 */ + Etot_h_32fx = L_max( Etot_h_32fx, Etot ); + Etot_l_32fx = L_add( L_deposit_h( hNoiseEst->Etot_l_fx ), 1342177 ); /* 1342177 = .08 in Q24 */ /* Could even be higher but it also delays first entry to DTX */ IF( GT_16( hNoiseEst->harm_cor_cnt, HE_LT_CNT_PRE_FX ) ) { test(); - IF( ( LT_16( ini_frame_fx, s_min( HE_LT_CNT_INIT_FX, MAX_FRAME_COUNTER - 1 ) ) ) && ( LT_32( L_sub( hNoiseEst->Etot_h_32fx, hNoiseEst->Etot_lp_32fx ), (Word32) 3 * 16777216 ) ) /* 3.0 Q8 */ + IF( ( LT_16( ini_frame_fx, s_min( HE_LT_CNT_INIT_FX, MAX_FRAME_COUNTER - 1 ) ) ) && ( LT_32( L_sub( Etot_h_32fx, Etot_lp_32fx ), (Word32) 3 * ONE_IN_Q24 ) ) /* 3.0 Q24 */ ) { /* *Etot_l += min(2,(*Etot_last-*Etot_l)*0.1f); */ - tmp = Mpy_32_32( L_sub( hNoiseEst->Etot_last_32fx, hNoiseEst->Etot_l_32fx ), 214748365 ); /* factor in Q15 3277 .1*32768 */ - tmp = L_min( 33554432, tmp ); /* 2.0 in Q8 is 512*/ - hNoiseEst->Etot_l_32fx = L_add( hNoiseEst->Etot_l_32fx, tmp ); - move16(); /* Q8 */ + tmp = Mpy_32_32( L_sub( L_deposit_h( hNoiseEst->Etot_last_fx ), Etot_l_32fx ), 214748365 ); /* 0.1f factor in Q31 */ + tmp = L_min( 33554432, tmp ); /* 2.0 in Q24 is 33554432 */ + Etot_l_32fx = L_add( Etot_l_32fx, tmp ); /* Q24 */ } /* Avoids large steps in short active segments */ test(); - IF( ( GT_32( L_sub( hNoiseEst->Etot_last_32fx, hNoiseEst->Etot_l_32fx ), 503316480 ) ) /* 30.0f*Q8 */ + IF( ( GT_32( L_sub( L_deposit_h( hNoiseEst->Etot_last_fx ), Etot_l_32fx ), 503316480 ) ) /* 30.0f*Q24 */ && ( GT_16( hNoiseEst->harm_cor_cnt, HE_LT_CNT_PRE_SHORT_FX ) ) ) { /* *Etot_l += (*Etot_last-*Etot_l)*0.02f; */ - hNoiseEst->Etot_l_32fx = L_add( hNoiseEst->Etot_l_32fx, Mpy_32_32( L_sub( hNoiseEst->Etot_last_32fx, hNoiseEst->Etot_l_32fx ), 42949673 ) ); - move16(); /* 0.02 = 655 Q8*/ + Etot_l_32fx = L_add( Etot_l_32fx, Mpy_32_32( L_sub( L_deposit_h( hNoiseEst->Etot_last_fx ), Etot_l_32fx ), 42949673 ) ); /* 0.02 in Q24*/ } - ELSE IF( GT_32( L_sub( hNoiseEst->Etot_last_32fx, hNoiseEst->Etot_l_32fx ), 167772160 ) ) /* 10.0 in Q8*/ + ELSE IF( GT_32( L_sub( L_deposit_h( hNoiseEst->Etot_last_fx ), Etot_l_32fx ), 167772160 ) ) /* 10.0 in Q24*/ { - hNoiseEst->Etot_l_32fx = L_add( hNoiseEst->Etot_l_32fx, 1342177 ); - move16(); /* 0.08 is 20 in Q8*/ + Etot_l_32fx = L_add( Etot_l_32fx, 1342177 ); /* 0.08 in Q24*/ } } - hNoiseEst->Etot_l_32fx = L_min( hNoiseEst->Etot_l_32fx, Etot ); + Etot_l_32fx = L_min( Etot_l_32fx, Etot ); // Q24 - IF( LT_16( ini_frame_fx, 100 ) && LT_32( hNoiseEst->Etot_l_32fx, hNoiseEst->Etot_l_lp_32fx ) ) + test(); + IF( LT_16( ini_frame_fx, 100 ) && LT_32( Etot_l_32fx, L_deposit_h( hNoiseEst->Etot_l_lp_fx ) ) ) { /**Etot_l_lp = 0.1f * *Etot_l + (1.0f - 0.1) * *Etot_l_lp; */ - hNoiseEst->Etot_l_lp_32fx = L_add( Mpy_32_32( 214748364, hNoiseEst->Etot_l_32fx ), Mpy_32_32( 1932735283, hNoiseEst->Etot_l_lp_32fx ) ); + hNoiseEst->Etot_l_lp_fx = extract_h( L_add( Mpy_32_32( 214748364 /* 0.1f in Q31*/, Etot_l_32fx ), Mpy_32_32( 1932735283 /* 0.9f in Q31*/, L_deposit_h( hNoiseEst->Etot_l_lp_fx ) ) ) ); // Q8 move16(); } ELSE @@ -599,22 +568,31 @@ void noise_est_pre_32fx( test(); test(); test(); - IF( ( ( GT_16( hNoiseEst->harm_cor_cnt, HE_LT_CNT_FX ) ) && ( GT_32( L_sub_sat( hNoiseEst->Etot_last_32fx, hNoiseEst->Etot_l_32fx ), 503316480 ) ) ) || ( ( sub( hNoiseEst->harm_cor_cnt, HE_LT_CNT_FX ) > 0 ) && ( LT_16( ini_frame_fx, HE_LT_CNT_INIT_FX ) ) ) || ( GT_32( L_sub_sat( hNoiseEst->Etot_l_lp_32fx, hNoiseEst->Etot_l_32fx ), 503316480 ) ) ) + IF( ( ( GT_16( hNoiseEst->harm_cor_cnt, HE_LT_CNT_FX ) ) && ( GT_32( L_sub_sat( L_deposit_h( hNoiseEst->Etot_last_fx ), Etot_l_32fx ), HE_LT_THR2_Q24 ) ) ) || ( ( sub( hNoiseEst->harm_cor_cnt, HE_LT_CNT_FX ) > 0 ) && ( LT_16( ini_frame_fx, HE_LT_CNT_INIT_FX ) ) ) || ( GT_32( L_sub_sat( L_deposit_h( hNoiseEst->Etot_l_lp_fx ), Etot_l_32fx ), HE_LT_THR2_Q24 ) ) ) { /**Etot_l_lp = 0.03f * *Etot_l + (1.0f - 0.03f) * *Etot_l_lp; */ - hNoiseEst->Etot_l_lp_32fx = L_add( Mpy_32_32( 64424509, hNoiseEst->Etot_l_32fx ), Mpy_32_32( 2083059139, hNoiseEst->Etot_l_lp_32fx ) ); + hNoiseEst->Etot_l_lp_fx = extract_h( L_add( Mpy_32_32( 64424509 /* 0.03f in Q31*/, Etot_l_32fx ), Mpy_32_32( 2083059139 /* 0.97f in Q31*/, L_deposit_h( hNoiseEst->Etot_l_lp_fx ) ) ) ); // Q8 move16(); } ELSE { /* *Etot_l_lp = 0.02f * *Etot_l + (1.0f - 0.02f) * *Etot_l_lp; */ - hNoiseEst->Etot_l_lp_32fx = L_add( Mpy_32_32( 42949673, hNoiseEst->Etot_l_32fx ), Mpy_32_32( 2104533975, hNoiseEst->Etot_l_lp_32fx ) ); + hNoiseEst->Etot_l_lp_fx = extract_h( L_add( Mpy_32_32( 42949673 /* 0.02f in Q31*/, Etot_l_32fx ), Mpy_32_32( 2104533975 /* 0.98f in Q31*/, L_deposit_h( hNoiseEst->Etot_l_lp_fx ) ) ) ); // Q8 + move16(); } } /**sign_dyn_lp = 0.1f * (*Etot_h - *Etot_l) + (1.0f - 0.1f) * *sign_dyn_lp;*/ - hNoiseEst->sign_dyn_lp_32fx = L_add( Mpy_32_32( 214748365, L_sub_sat( hNoiseEst->Etot_h_32fx, hNoiseEst->Etot_l_32fx ) ), Mpy_32_32( 1932735283, hNoiseEst->sign_dyn_lp_32fx ) ); + hNoiseEst->sign_dyn_lp_fx = extract_h( L_add( Mpy_32_32( 214748365 /* 0.1f in Q31*/, L_sub_sat( Etot_h_32fx, Etot_l_32fx ) ), Mpy_32_32( 1932735283 /*( 1.0f - 0.1f ) in Q31*/, L_deposit_h( hNoiseEst->sign_dyn_lp_fx ) ) ) ); // Q8 + move16(); } + hNoiseEst->Etot_l_fx = extract_h( Etot_l_32fx ); // Q8 + hNoiseEst->Etot_h_fx = extract_h( Etot_h_32fx ); // Q8 + hNoiseEst->Etot_lp_fx = extract_h( Etot_lp_32fx ); // Q8 + move16(); + move16(); + move16(); + return; } /*==================================================================================*/ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 05737285388a4d0ef438e4e4e5791e342f6b5127..c126c56e9b06faa7b8a9a7f64f705c497a8e7b88 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -428,9 +428,9 @@ void noise_est_pre_fx( ); void noise_est_pre_32fx( - const Word32 Etot, /* i : Energy of current frame */ - const Word16 ini_frame_fx, /* i : Frame number (init) */ - NOISE_EST_HANDLE hNoiseEst, /* i/o: Noise estimation handle */ + const Word32 Etot, /* i : Energy of current frame Q24 */ + const Word16 ini_frame_fx, /* i : Frame number (init) */ + NOISE_EST_HANDLE hNoiseEst, /* i/o: Noise estimation handle */ const Word16 idchan, /* i : channel ID */ const Word16 element_mode, /* i : element mode */ const Word16 last_element_mode /* i : last element mode */ diff --git a/lib_enc/rom_enc.c b/lib_enc/rom_enc.c index c8fe848f5fd95f8118e0d1abccd2f5db3168cbea..7e6b1cf11c65fd32060ac1a4ef7052689ca2de39 100644 --- a/lib_enc/rom_enc.c +++ b/lib_enc/rom_enc.c @@ -539,23 +539,32 @@ const float means_speech[N_SMC_MIXTURES*N_PCA_COEF] = #ifdef IVAS_FLOAT_FIXED const Word32 means_speech_fx[N_SMC_MIXTURES*N_PCA_COEF] = { - //Q27 - 556269120, -59860300, -9435775, 48301740, -5395016, -15873260, 86538896, -23373078, --15379338, 88411368, 37326888, -35021164, -4035256, -161975568, 85803920, -81899120, --7169642, 64167884, -82728320, -29112898, 81431240, 15287399, -468956, 29038140, --256403904, -208488720, 86349912, 56074020, 36843036, 19549348, 1753688, -32431970, -29630308, 14530545, -8338545, 4083037, 253332208, -116034448, -127942512, -33905276, -8696369, -14094204, -30782970, 37237904, 4475893, -12044833, -4461531, 2582617, --55476752, -239552208, -25126230, -52574964, -32635712, -29946256, -2421556, 17400254, -18426080, -6647267, 3984253, -3254377, -93225080, -235751824, 80155632, 138254992, -39954200, 51441360, 18226768, -23774524, 12971472, -36022428, -20379082, -13683497, + //Q20 + 4345853, +-467659, -73717, 377357, -42149, -124010, 676085, -182602, -120151, +690714, 291616, -273603, -31525, -1265434, 670343, -639837, -56013, +501312, -646315, -227445, 636182, 119433, -3664, 226860, -2003156, +-1628818, 674609, 438078, 287836, 152729, 13701, -253375, 231487, +113520, -65145, 31899, 1979158, -906519, -999551, -264885, 67940, +-110111, -240492, 290921, 34968, -94100, -34856, 20177, -433412, +-1871502, -196299, -410742, -254967, -233955, -18918, 135939, 143954, +-51932, 31127, -25425, -728321, -1841811, 626216, 1080117, 312142, +401886, 142397, -185738, 101340, -281425, -159212, -106902, }; #endif const float log_det_chol_speech[N_SMC_MIXTURES] = { 6.500575f, 5.852711f, 5.579274f, 6.652653f, 4.752021f, 5.338445f, }; - +const Word32 log_det_chol_speech_fx[N_SMC_MIXTURES] = +{//Q19 + 3408173, + 3068506, + 2925146, + 3487906, + 2491427, + 2798882, +}; const float prec_chol_speech[N_SMC_MIXTURES*(N_PCA_COEF*N_PCA_COEF + N_PCA_COEF) / 2] = { 0.865878f, -0.223069f, 1.134475f, -0.467260f, 0.369334f, 1.214700f, -0.211695f, 0.172669f, 0.139801f, 1.227951f, 0.116632f, -0.073137f, 0.119470f, 0.215339f, 1.501916f, 0.013243f, 0.241111f, -0.233638f, 0.209664f, -0.018477f, 1.781218f, -0.379717f, -0.055418f, 0.148630f, -0.151909f, -0.176478f, 0.700080f, 1.271311f, 0.079390f, -0.578062f, 0.405159f, -0.535997f, -0.075627f, -0.020922f, 0.275374f, 2.125945f, 0.814927f, -0.606386f, -0.240098f, -0.027454f, -0.137439f, -0.139499f, -0.299115f, 0.030554f, 2.224794f, -0.568133f, -0.955587f, -0.171094f, -0.289375f, -0.522709f, -0.635692f, -0.351548f, 0.418509f, 0.752386f, 2.817156f, -0.775162f, 0.841142f, 0.217873f, 0.245892f, -0.180432f, 0.026225f, -0.382074f, 0.147919f, -1.265659f, -0.335493f, 2.967484f, 0.754874f, 0.141008f, 0.037836f, 0.308811f, 0.275340f, -0.452874f, -0.553189f, -0.418168f, 0.103281f, 0.201651f, 0.314494f, 3.377585f, @@ -649,16 +658,17 @@ const float means_music[N_SMC_MIXTURES*N_PCA_COEF] = #ifdef IVAS_FLOAT_FIXED const Word32 means_music_fx[N_SMC_MIXTURES*N_PCA_COEF] = { - //Q27 - 88128840, 204692912, 12705453, 71462352, 12596468, 40563280, -1386066, -52265056, --39146480, -6666997, 9846481, 10781844, -57806772, -1044348, 8851928, -134822384, --26193530, -61436556, 53966400, 37307696, -3429397, 19347082, 13950591, -11268518, --48344556, 197877728, -36032360, -8134399, -1136958, -20838778, -32593702, 16027207, --26324122, -40342764, -3959959, 8085410, -332178944, 164642336, -341718, 34049964, --15855543, 8985877, 22481872, 6408225, -40554556, 2538594, 4626216, 1585111, --126774552, 174976704, 43837656, 59459124, 45605440, 47483012, 108907616, -26984474, -7563974, 110854584, 57102664, -53801580, 324371776, 133068016, -33550808, -35531324, --528952, -32556524, -15345650, 24060810, 11499641, -221325, -35890224, 3875939, + //Q20 + 688507, +1599163, 99261, 558300, 98410, 316901, -10829, -408321, -305832, +-52086, 76926, 84233, -451615, -8159, 69156, -1053300, -204637, +-479973, 421613, 291466, -26792, 151149, 108989, -88035, -377692, +1545920, -281503, -63550, -8882, -162803, -254638, 125213, -205657, +-315178, -30937, 63167, -2595148, 1286268, -2670, 266015, -123871, +70202, 175640, 50064, -316832, 19833, 36142, 12384, -990426, +1367006, 342482, 464524, 356293, 370961, 850841, -210816, 59094, +866051, 446115, -420325, 2534155, 1039594, -262116, -277588, -4132, +-254348, -119888, 187975, 89841, -1729, -280392, 30281, }; #endif const float log_det_chol_music[N_SMC_MIXTURES] = @@ -666,6 +676,15 @@ const float log_det_chol_music[N_SMC_MIXTURES] = 3.236255f, 3.517110f, 5.675361f, 2.875446f, -2.234983f, 7.961542f, }; +const Word32 log_det_chol_music_fx[N_SMC_MIXTURES] = +{//Q19 + 1696729, + 1843978, + 2975523, + 1507561, + -1171774, + 4174141, +}; const float prec_chol_music[N_SMC_MIXTURES*(N_PCA_COEF*N_PCA_COEF + N_PCA_COEF) / 2] = { 0.865468f, 0.096250f, 0.875676f, -0.081846f, -0.330935f, 1.076934f, 0.141790f, 0.047793f, 0.095596f, 0.805507f, 0.014703f, 0.133837f, -0.185849f, 0.065923f, 0.878885f, -0.023521f, -0.109075f, 0.293645f, -0.004503f, 0.103060f, 1.017106f, -0.140600f, -0.264764f, 0.386274f, -0.037347f, -0.140433f, -0.230523f, 1.476784f, -0.097932f, 0.056998f, -0.001711f, -0.088553f, 0.012943f, -0.094897f, 0.176247f, 1.239658f, 0.145315f, 0.034242f, -0.028931f, -0.132416f, 0.080181f, 0.025223f, -0.464244f, 0.005253f, 1.895192f, -0.096706f, -0.029121f, 0.072887f, 0.005231f, -0.191996f, -0.169344f, 0.616334f, -0.105826f, -0.302582f, 2.184961f, -0.173989f, -0.194028f, 0.036340f, -0.116044f, -0.145628f, -0.150018f, 0.249165f, 0.112598f, 0.374794f, 0.091387f, 2.450082f, 0.253605f, 0.179610f, -0.178889f, 0.182902f, -0.015903f, 0.219889f, -0.718143f, -0.189849f, -0.115940f, -0.439124f, -0.679777f, 2.330453f, @@ -759,23 +778,32 @@ const float means_noise[N_SMC_MIXTURES*N_PCA_COEF] = #ifdef IVAS_FLOAT_FIXED const Word32 means_noise_fx[N_SMC_MIXTURES*N_PCA_COEF] = { - //Q27 - 139344176, 85522728, -140739360, -127496240, -11822971, -83343840, -30885916, 128914920, -55142280, 43453528, -85148664, 1472368, -161889936, -113373848, -98158928, -153415568, --42456556, -57162792, 60016264, 208695008, -13554783, 127521472, -30868064, -26999372, -178972768, 74413936, -168077904, -33409476, 6877316, -59676692, -21294850, 147021424, -33076482, 7783688, -105503456, 23490786, 165446160, 44187832, -118290112, -7072334, -20942126, -40746756, -14936017, 106057376, 17580778, 8650601, -64193252, 13850330, --267202400, -97157928, -160526960, -237423248, -46269548, -90877888, -34388460, 181443312, --47476032, 103093176, -51608460, -49874636, -282058432, -173686864, -25287426, -247458976, --105534592, -72460928, 32371168, 214770112, -40301020, 164500864, 10863583, -31030468, + //Q20 + 1088626, +668146, -1099526, -996064, -92367, -651124, -241296, 1007148, 430799, +339481, -665224, 11503, -1264765, -885733, -766867, -1198559, -331692, +-446584, 468877, 1630430, -105897, 996262, -241157, -210933, 1398225, +581359, -1313109, -261012, 53729, -466224, -166366, 1148605, 258410, +60810, -824246, 183522, 1292548, 345217, -924142, -55253, 163610, +-318334, -116688, 828573, 137350, 67583, -501510, 108206, -2087519, +-759046, -1254117, -1854869, -361481, -709984, -268660, 1417526, -370907, +805415, -403191, -389646, -2203582, -1356929, -197558, -1933273, -824489, +-566101, 252900, 1677892, -314852, 1285163, 84872, -242426, }; #endif const float log_det_chol_noise[N_SMC_MIXTURES] = { 11.878154f, 13.025598f, 12.831137f, 7.099546f, 13.242941f, 11.898383f, }; - +const Word32 log_det_chol_noise_fx[N_SMC_MIXTURES] = +{//Q19 + 6227573, + 6829164, + 6727211, + 3722206, + 6943115, + 6238179, +}; const float prec_chol_noise[N_SMC_MIXTURES*(N_PCA_COEF*N_PCA_COEF + N_PCA_COEF) / 2] = { 1.632699f, -0.379077f, 1.966804f, -0.344223f, -0.149261f, 2.120968f, -0.643124f, 0.344982f, 0.335749f, 1.870530f, -0.261820f, 0.059065f, 0.158862f, -0.280203f, 2.457868f, 0.081479f, 0.745744f, -0.249165f, -0.769764f, -1.012361f, 2.160652f, -0.156229f, 0.672157f, -0.261424f, 0.116279f, -0.228307f, -0.056947f, 3.407241f, 0.356097f, -0.736238f, 0.705233f, -1.408321f, -0.717390f, -1.037433f, 0.333510f, 2.484870f, 0.323039f, -1.483297f, -0.500337f, -0.090107f, -0.439007f, -0.290405f, 0.327256f, -0.243020f, 2.511947f, 0.442037f, 0.525936f, -1.436016f, 0.336699f, 0.176533f, -0.643667f, 0.793828f, -0.342947f, 0.672485f, 4.147797f, 0.332162f, 0.594025f, -1.072022f, 0.522281f, 0.199482f, 0.046997f, 0.786233f, -0.726740f, -1.173474f, 0.744190f, 3.950012f, -0.607163f, -0.630364f, 1.025563f, -0.779746f, -0.553567f, 0.336951f, -1.148469f, 0.489795f, 0.770505f, -1.178058f, -0.433118f, 6.111872f, diff --git a/lib_enc/rom_enc.h b/lib_enc/rom_enc.h index 87537fc80ce0acc536f8161183045746086e4e4e..27e368e2a9b1e6e7bab4977d4725d1a23e68d698 100644 --- a/lib_enc/rom_enc.h +++ b/lib_enc/rom_enc.h @@ -135,11 +135,14 @@ extern const Word32 bcox_add_cnst_fx[N_SMC_FEATURES]; extern const Word32 prec_chol_speech_fx[]; extern const Word32 prec_chol_music_fx[]; extern const Word32 prec_chol_noise_fx[]; -extern const Word32 means_speech_fx[]; -extern const Word32 means_music_fx[]; -extern const Word32 means_noise_fx[]; +extern const Word32 means_speech_fx[]; // Q20 +extern const Word32 means_music_fx[]; // Q20 +extern const Word32 means_noise_fx[]; // Q20 extern const Word32 mel_fb_fx[]; extern const Word32 dct_mtx_fx[]; +extern const Word32 log_det_chol_speech_fx[]; // Q19 +extern const Word32 log_det_chol_music_fx[]; // Q19 +extern const Word32 log_det_chol_noise_fx[]; // Q19 #endif extern const float log_det_chol_speech[]; extern const float prec_chol_music[]; diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 2453ebf94b730cddc01e7c7a9b613f4e771bf60e..cc240abe4922714aef7a99c4cfe83ab63bf9f37d 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -73,28 +73,28 @@ static void order_spectrum_fx( Word16 *vec, Word16 len ); static void detect_sparseness_fx( Encoder_State *st_fx, const Word16 localVAD_HE_SAD, const Word16 voi_fv ); // Q19 Word32 log_weights_speech_compute[N_SMC_MIXTURES] = { - -3529378, - -3679759, - -3803054, - -3229859, - -4048972, - -3929047, + -1156091, + -966805, + -946740, + -936304, + -758939, + -946469, }; Word32 log_weights_music_compute[N_SMC_MIXTURES] = { - -5058325, - -4983143, - -3436984, - -5133896, - -8505198, - -2561831, + -973594, + -1045660, + -631047, + -859997, + -1551963, + -954511, }; Word32 log_weights_noise_compute[N_SMC_MIXTURES] = { - -433769, - -105783, - 407264, - -3350157, - 103199, - -627672, + -879882, + -1153486, + -538486, + -1290903, + -1058455, + -1084391, }; /*---------------------------------------------------------------------* * speech_music_clas_init_fx() @@ -2304,43 +2304,27 @@ Word16 ivas_smc_gmm_fx( move32(); move32(); move32(); + FOR( m = 0; m < N_SMC_MIXTURES; m++ ) { - Word32 temp[N_PCA_COEF]; - FOR( Word16 ind = 0; ind < N_PCA_COEF; ind++ ) - { - temp[ind] = L_shr( means_speech_fx[m * N_PCA_COEF + ind], sub( 27, Qfact_FV ) ); - move32(); - } - v_sub32_fx( FV_fx, temp, fvm_fx, N_PCA_COEF ); + v_sub32_fx( FV_fx, &means_speech_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); fvm_exp = sub( 31, Qfact_FV ); lprob_exp = 0; move16(); lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); - ps_fx[m] = L_sub( log_weights_speech_compute[m], L_shl( lprob_fx, sub( Q19 - 1, sub( Q31, lprob_exp ) ) ) ); + ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), L_shl( lprob_fx, sub( Q19 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q19 ); // Q19 move32(); - FOR( Word16 ind = 0; ind < N_PCA_COEF; ind++ ) - { - temp[ind] = L_shr( means_music_fx[m * N_PCA_COEF + ind], sub( 27, Qfact_FV ) ); - move32(); - } - v_sub32_fx( FV_fx, temp, fvm_fx, N_PCA_COEF ); + v_sub32_fx( FV_fx, &means_music_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); lprob_exp = 0; move16(); lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); - pm_fx[m] = L_sub( log_weights_music_compute[m], L_shl( lprob_fx, sub( Q19 - 1, sub( Q31, lprob_exp ) ) ) ); + pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), L_shl( lprob_fx, sub( Q19 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q19 ); // Q19 move32(); - FOR( Word16 ind = 0; ind < N_PCA_COEF; ind++ ) - { - temp[ind] = L_shr( means_noise_fx[m * N_PCA_COEF + ind], sub( 27, Qfact_FV ) ); - move32(); - } - v_sub32_fx( FV_fx, temp, fvm_fx, N_PCA_COEF ); - + v_sub32_fx( FV_fx, &means_noise_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); lprob_exp = 0; move16(); lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); - pn_fx[m] = L_sub( log_weights_noise_compute[m], L_shl( lprob_fx, sub( Q19 - 1, sub( Q31, lprob_exp ) ) ) ); + pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), L_shl( lprob_fx, sub( Q19 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q19 ); // Q19 move32(); } diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index d067986e2b2e1265650731d9ebbb72e687452bba..d5fbcc018f6e577e116004b6c3d310d0843547c7 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -786,24 +786,24 @@ typedef struct noise_estimation_structure Word32 bckr_fx[NB_BANDS]; /* Q_new + Q_SCALE Noise estimator - background noise estimation per critical band */ Word32 ave_enr_fx[NB_BANDS]; /* Q_new + Q_SCALE Noise estimator - long-term average energy per critical band */ - int16_t aEn; /* Noise estimator - noise estimator adaptation flag */ + Word16 aEn; /* Noise estimator - noise estimator adaptation flag */ #ifndef IVAS_FLOAT_FIXED float totalNoise; /* Noise estimator - total noise energy */ #endif Word16 totalNoise_fx; /* Q8 Noise estimator - total noise energy */ - int16_t first_noise_updt; /* Noise estimator - flag used to determine if the first noise update frame */ - int16_t first_noise_updt_cnt; /* Noise estimator - counter of frame after first noise update */ - int16_t harm_cor_cnt; /* Noise estimator - 1st memory counter of harm or correlation frame */ - int16_t bg_cnt; /* Noise estimator - pause length counter */ + Word16 first_noise_updt; /* Noise estimator - flag used to determine if the first noise update frame */ + Word16 first_noise_updt_cnt; /* Noise estimator - counter of frame after first noise update */ + Word16 harm_cor_cnt; /* Noise estimator - 1st memory counter of harm or correlation frame */ + Word16 bg_cnt; /* Noise estimator - pause length counter */ #ifndef IVAS_FLOAT_FIXED float Etot_l; /* Noise estimator - Track energy from below */ float Etot_h; /* Noise estimator - Track energy from above */ -#endif + float Etot_l_lp; /* Noise estimator - Smoothed low energy */ float Etot_last; /* Noise estimator - Energy of last frame */ float Etot_lp; /* Noise estimator - Filtered input energy */ -#ifndef IVAS_FLOAT_FIXED + float lt_tn_track; float lt_tn_dist; float lt_Ellp_dist; @@ -815,17 +815,11 @@ typedef struct noise_estimation_structure Word16 Etot_last_fx; /*Q8*/ Word16 Etot_lp_fx; /* Q8 Noise estimator - Filtered input energy */ - Word32 Etot_l_32fx; /* Q24 Noise estimator - Track energy from below */ - Word32 Etot_h_32fx; /* Q24 Noise estimator - Track energy from above */ - Word32 Etot_l_lp_32fx; /* Q24 Noise estimator - Smoothed low energy */ - Word32 Etot_last_32fx; /*Q24*/ - Word32 Etot_lp_32fx; /* Q24 Noise estimator - Filtered input energy */ - Word16 lt_tn_track_fx; /* Q15 */ Word16 lt_tn_dist_fx; /* Q8*/ Word16 lt_Ellp_dist_fx; /* Etot low lp same domain as *Etot_l_lp, Q8 */ Word16 lt_haco_ev_fx; /* Q15 */ - int16_t low_tn_track_cnt; + Word16 low_tn_track_cnt; #ifndef IVAS_FLOAT_FIXED float epsP_0_2_lp; float epsP_0_2_ad_lp; @@ -842,22 +836,19 @@ typedef struct noise_estimation_structure Word16 epsP_2_16_dlp_lp2_fx; /* Q12 */ Word16 lt_aEn_zero_fx; /* Q15 */ +#ifndef IVAS_FLOAT_FIXED float Etot_v_h2; float sign_dyn_lp; -#ifndef IVAS_FLOAT_FIXED float Etot_st_est; /* Noise estimation - short term estimate of E{ Etot } */ float Etot_sq_st_est; /* Noise estimation - short term estimate of E{ Etot^2 } */ #endif Word16 Etot_v_h2_fx; Word16 sign_dyn_lp_fx; /*Q8*/ - Word32 Etot_v_h2_32fx; - Word32 sign_dyn_lp_32fx; /*Q8*/ - Word16 Etot_st_est_fx; /* Q8 Noise estimation - short term estimate of E{ Etot } */ Word16 Etot_sq_st_est_fx; /* Q2 Noise estimation - short term estimate of E{ Etot^2 } */ - int16_t aEn_inac_cnt; + Word16 aEn_inac_cnt; } NOISE_EST_DATA, *NOISE_EST_HANDLE;