From 714c56a8330260d000b9886359491464c1c1bc45 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 6 Nov 2024 20:33:22 +0530 Subject: [PATCH] Float struct elements cleanup in lib_com and lib_enc, Q-info lib_com updates [x] Float structure elements cleanup for various FORMATS [x] Q-info updates for lib_com [x] LTV crash fixes --- lib_com/fd_cng_com.c | 2 - lib_com/ifft_rel.c | 378 ++++----- lib_com/igf_base_fx.c | 298 +++---- lib_com/index_pvq_opt_fx.c | 255 +++--- lib_com/int_lsp.c | 56 +- lib_com/interpol.c | 30 +- lib_com/isf_dec_amr_wb_fx.c | 88 +- lib_com/ivas_fb_mixer.c | 1208 +-------------------------- lib_com/ivas_mc_param_com.c | 42 +- lib_com/ivas_mdct_imdct.c | 4 +- lib_com/ivas_prot.h | 45 +- lib_com/ivas_prot_fx.h | 13 +- lib_com/ivas_rom_com.c | 80 +- lib_com/ivas_spar_com.c | 4 +- lib_com/ivas_spar_com_quant_util.c | 9 +- lib_com/ivas_stat_com.h | 243 +++--- lib_com/ivas_tools.c | 762 ++++++++--------- lib_com/ivas_transient_det.c | 154 ++-- lib_com/lag_wind.c | 74 +- lib_com/prot_fx.h | 138 +-- lib_com/rom_com.c | 170 ++-- lib_com/rom_com.h | 8 +- lib_com/stat_com.h | 18 +- lib_com/tcx_mdct_fx.c | 147 ++-- lib_com/vlpc_2st_com_fx.c | 8 +- lib_com/weight_a_fx.c | 75 +- lib_com/weight_fx.c | 148 ++-- lib_com/wi_fx.c | 109 +-- lib_dec/ivas_qmetadata_dec.c | 8 +- lib_dec/jbm_pcmdsp_apa.c | 2 + lib_enc/acelp_core_enc.c | 67 +- lib_enc/cod_tcx_fx.c | 17 +- lib_enc/core_enc_init.c | 114 ++- lib_enc/core_enc_switch.c | 9 +- lib_enc/core_switching_enc.c | 30 +- lib_enc/dtx.c | 6 + lib_enc/fd_cng_enc.c | 20 + lib_enc/fd_cng_enc_fx.c | 10 - lib_enc/init_enc.c | 108 ++- lib_enc/ivas_core_enc.c | 34 - lib_enc/ivas_core_pre_proc_front.c | 30 - lib_enc/ivas_dirac_enc.c | 2 +- lib_enc/ivas_enc.c | 14 +- lib_enc/ivas_front_vad.c | 5 - lib_enc/ivas_masa_enc.c | 2 +- lib_enc/ivas_mc_param_enc.c | 7 - lib_enc/ivas_mc_paramupmix_enc.c | 4 +- lib_enc/ivas_mcmasa_enc.c | 53 +- lib_enc/ivas_osba_enc.c | 2 +- lib_enc/ivas_pca_enc.c | 514 +----------- lib_enc/ivas_sba_enc.c | 2 +- lib_enc/ivas_spar_encoder.c | 549 ++++-------- lib_enc/ivas_spar_md_enc.c | 36 +- lib_enc/ivas_stat_enc.h | 23 +- lib_enc/ivas_stereo_switching_enc.c | 3 - lib_enc/ivas_tcx_core_enc.c | 6 - lib_enc/prot_fx_enc.h | 4 +- lib_enc/speech_music_classif_fx.c | 14 +- lib_enc/stat_enc.h | 104 ++- 59 files changed, 2231 insertions(+), 4134 deletions(-) diff --git a/lib_com/fd_cng_com.c b/lib_com/fd_cng_com.c index 91750b486..37a10990b 100644 --- a/lib_com/fd_cng_com.c +++ b/lib_com/fd_cng_com.c @@ -652,7 +652,6 @@ void minimum_statistics_flt( return; } -#endif /*------------------------------------------------------------------- @@ -689,7 +688,6 @@ void apply_scale_flt( } -#ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------- * bandcombinepow_flt() * diff --git a/lib_com/ifft_rel.c b/lib_com/ifft_rel.c index 41599cdd8..a54cbb350 100644 --- a/lib_com/ifft_rel.c +++ b/lib_com/ifft_rel.c @@ -45,7 +45,7 @@ *-----------------------------------------------------------------*/ #define N_MAX_FFT 1024 -#define INV_SQR2_FX 23170 +#define INV_SQR2_FX 23170 /*Q15*/ #define N_MAX_SAS 256 /*---------------------------------------------------------------------* * ifft_rel() @@ -288,9 +288,9 @@ void ifft_rel( } void ifft_rel_fx( - Word16 io[], /* i/o: input/output vector */ - const Word16 n, /* i : vector length */ - const Word16 m /* i : log2 of vector length */ + Word16 io[], /* Qx i/o: input/output vector */ + const Word16 n, /* Q0 i : vector length */ + const Word16 m /* Q0 i : log2 of vector length */ ) { Word16 i, j, k; @@ -316,7 +316,6 @@ void ifft_rel_fx( *-----------------------------------------------------------------*/ x = &io[-1]; - move16(); n2 = shl( n, 1 ); FOR( k = 1; k < m; k++ ) { @@ -325,120 +324,105 @@ void ifft_rel_fx( id = n2; move16(); n2 = shr( n2, 1 ); - move16(); n4 = shr( n2, 2 ); - move16(); n8 = shr( n4, 1 ); - move16(); tmp = sub( n, 1 ); WHILE( LT_16( is, tmp ) ) { - xi1 = x + is + 1; - move16(); - xi2 = xi1 + n4; - move16(); - xi3 = xi2 + n4; - move16(); - xi4 = xi3 + n4; - move16(); + xi1 = x + is + 1; /*Qx*/ + xi2 = xi1 + n4; /*Qx*/ + xi3 = xi2 + n4; /*Qx*/ + xi4 = xi3 + n4; /*Qx*/ FOR( i = is; i < n; i += id ) { #ifdef BASOP_NOGLOB - t1 = sub_o( *xi1, *xi3, &Overflow ); - *xi1 = add_o( *xi1, *xi3, &Overflow ); -#else /* BASOP_NOGLOB */ + t1 = sub_o( *xi1, *xi3, &Overflow ); /*Qx*/ + *xi1 = add_o( *xi1, *xi3, &Overflow ); /*Qx*/ +#else /* BASOP_NOGLOB */ t1 = sub( *xi1, *xi3 ); *xi1 = add( *xi1, *xi3 ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ move16(); #ifdef BASOP_NOGLOB - *xi2 = shl_o( *xi2, 1, &Overflow ); -#else /* BASOP_NOGLOB */ + *xi2 = shl_o( *xi2, 1, &Overflow ); /*Qx*/ +#else /* BASOP_NOGLOB */ *xi2 = shl( *xi2, 1 ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ move16(); #ifdef BASOP_NOGLOB - *xi3 = sub_o( t1, shl_o( *xi4, 1, &Overflow ), &Overflow ); -#else /* BASOP_NOGLOB */ + *xi3 = sub_o( t1, shl_o( *xi4, 1, &Overflow ), &Overflow ); /*Qx*/ +#else /* BASOP_NOGLOB */ *xi3 = sub( t1, shl( *xi4, 1 ) ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ move16(); #ifdef BASOP_NOGLOB - *xi4 = add_o( t1, shl_o( *xi4, 1, &Overflow ), &Overflow ); -#else /* BASOP_NOGLOB */ + *xi4 = add_o( t1, shl_o( *xi4, 1, &Overflow ), &Overflow ); /*Qx*/ +#else /* BASOP_NOGLOB */ *xi4 = add( t1, shl( *xi4, 1 ) ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ move16(); IF( NE_16( n4, 1 ) ) { #ifdef BASOP_NOGLOB - t1 = mult_r( sub_o( *( xi2 + n8 ), *( xi1 + n8 ), &Overflow ), INV_SQR2_FX ); - t2 = mult_r( add_o( *( xi4 + n8 ), *( xi3 + n8 ), &Overflow ), INV_SQR2_FX ); -#else /* BASOP_NOGLOB */ + t1 = mult_r( sub_o( *( xi2 + n8 ), *( xi1 + n8 ), &Overflow ), INV_SQR2_FX /*Q15*/ ); /*Qx*/ + t2 = mult_r( add_o( *( xi4 + n8 ), *( xi3 + n8 ), &Overflow ), INV_SQR2_FX /*Q15*/ ); /*Qx*/ +#else /* BASOP_NOGLOB */ t1 = mult_r( sub( *( xi2 + n8 ), *( xi1 + n8 ) ), INV_SQR2_FX ); t2 = mult_r( add( *( xi4 + n8 ), *( xi3 + n8 ) ), INV_SQR2_FX ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ #ifdef BASOP_NOGLOB - *( xi1 + n8 ) = add_o( *( xi1 + n8 ), *( xi2 + n8 ), &Overflow ); -#else /* BASOP_NOGLOB */ + *( xi1 + n8 ) = add_o( *( xi1 + n8 ), *( xi2 + n8 ), &Overflow ); /*Qx*/ +#else /* BASOP_NOGLOB */ *( xi1 + n8 ) = add( *( xi1 + n8 ), *( xi2 + n8 ) ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ move16(); #ifdef BASOP_NOGLOB - *( xi2 + n8 ) = sub_o( *( xi4 + n8 ), *( xi3 + n8 ), &Overflow ); -#else /* BASOP_NOGLOB */ + *( xi2 + n8 ) = sub_o( *( xi4 + n8 ), *( xi3 + n8 ), &Overflow ); /*Qx*/ +#else /* BASOP_NOGLOB */ *( xi2 + n8 ) = sub( *( xi4 + n8 ), *( xi3 + n8 ) ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ move16(); #ifdef BASOP_NOGLOB - *( xi3 + n8 ) = negate( shl_o( add_o( t2, t1, &Overflow ), 1, &Overflow ) ); -#else /* BASOP_NOGLOB */ + *( xi3 + n8 ) = negate( shl_o( add_o( t2, t1, &Overflow ), 1, &Overflow ) ); /*Qx*/ +#else /* BASOP_NOGLOB */ *( xi3 + n8 ) = negate( shl( add( t2, t1 ), 1 ) ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ move16(); #ifdef BASOP_NOGLOB - *( xi4 + n8 ) = shl_o( sub_o( t1, t2, &Overflow ), 1, &Overflow ); -#else /* BASOP_NOGLOB */ + *( xi4 + n8 ) = shl_o( sub_o( t1, t2, &Overflow ), 1, &Overflow ); /*Qx*/ +#else /* BASOP_NOGLOB */ *( xi4 + n8 ) = shl( sub( t1, t2 ), 1 ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ move16(); } xi1 += id; - move16(); xi2 += id; - move16(); xi3 += id; - move16(); xi4 += id; - move16(); } is = sub( shl( id, 1 ), n2 ); id = shl( id, 2 ); } /*Can be acheived with a shr */ - step = N_MAX_SAS / n2; + step = idiv1616( N_MAX_SAS, n2 ); move16(); - s = sincos_t_fx + step; - move16(); - c = s + 64; - move16(); - s3 = sincos_t_fx + i_mult2( step, 3 ); - move16(); - c3 = s3 + 64; - move16(); + s = sincos_t_fx + step; /*Q15 */ + c = s + 64; /*Q15 */ + s3 = sincos_t_fx + i_mult2( step, 3 ); /*Q15 */ + c3 = s3 + 64; /*Q15 */ FOR( j = 2; j <= n8; j++ ) { - cc1 = *c; + cc1 = *c; /*Q15 */ move16(); - ss1 = *s; + ss1 = *s; /*Q15 */ move16(); - cc3 = *c3; + cc3 = *c3; /*Q15 */ move16(); - ss3 = *s3; + ss3 = *s3; /*Q15 */ move16(); is = 0; @@ -446,123 +430,103 @@ void ifft_rel_fx( id = shl( n2, 1 ); c += step; - move16(); s += step; - move16(); - c3 += 3 * step; - move16(); - s3 += 3 * step; - move16(); + c3 += imult1616( 3, step ); + s3 += imult1616( 3, step ); WHILE( LT_16( is, sub( n, 1 ) ) ) { - xup1 = x + j + is; - move16(); - xup3 = xup1 + shl( n4, 1 ); - move16(); - xdn6 = xup3 - shl( j, 1 ) + 2; - move16(); + xup1 = x + j + is; /*Qx*/ + xup3 = xup1 + shl( n4, 1 ); /*Qx*/ + xdn6 = xup3 - shl( j, 1 ) + 2; /*Qx*/ - xdn8 = xdn6 + shl( n4, 1 ); - move16(); + xdn8 = xdn6 + shl( n4, 1 ); /*Qx*/ FOR( i = is; i < n; i += id ) { #ifdef BASOP_NOGLOB - t1 = sub_o( *xup1, *xdn6, &Overflow ); - *xup1 = add_o( *xup1, *xdn6, &Overflow ); -#else /* BASOP_NOGLOB */ + t1 = sub_o( *xup1, *xdn6, &Overflow ); /*Qx*/ + *xup1 = add_o( *xup1, *xdn6, &Overflow ); /*Qx*/ +#else /* BASOP_NOGLOB */ t1 = sub( *xup1, *xdn6 ); *xup1 = add( *xup1, *xdn6 ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ move16(); xup1 += n4; - move16(); xdn6 -= n4; - move16(); #ifdef BASOP_NOGLOB - t2 = sub_o( *xdn6, *xup1, &Overflow ); - *xdn6 = add_o( *xup1, *xdn6, &Overflow ); -#else /* BASOP_NOGLOB */ + t2 = sub_o( *xdn6, *xup1, &Overflow ); /*Qx*/ + *xdn6 = add_o( *xup1, *xdn6, &Overflow ); /*Qx*/ +#else /* BASOP_NOGLOB */ t2 = sub( *xdn6, *xup1 ); *xdn6 = add( *xup1, *xdn6 ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ move16(); xdn6 += n4; - move16(); #ifdef BASOP_NOGLOB - t3 = add_o( *xdn8, *xup3, &Overflow ); - *xdn6 = sub_o( *xdn8, *xup3, &Overflow ); -#else /* BASOP_NOGLOB */ + t3 = add_o( *xdn8, *xup3, &Overflow ); /*Qx*/ + *xdn6 = sub_o( *xdn8, *xup3, &Overflow ); /*Qx*/ +#else /* BASOP_NOGLOB */ t3 = add( *xdn8, *xup3 ); *xdn6 = sub( *xdn8, *xup3 ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ move16(); xup3 += n4; - move16(); xdn8 -= n4; - move16(); #ifdef BASOP_NOGLOB - t4 = add_o( *xup3, *xdn8, &Overflow ); - *xup1 = sub_o( *xup3, *xdn8, &Overflow ); -#else /* BASOP_NOGLOB */ + t4 = add_o( *xup3, *xdn8, &Overflow ); /*Qx*/ + *xup1 = sub_o( *xup3, *xdn8, &Overflow ); /*Qx*/ +#else /* BASOP_NOGLOB */ t4 = add( *xup3, *xdn8 ); *xup1 = sub( *xup3, *xdn8 ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ move16(); #ifdef BASOP_NOGLOB - t5 = sub_o( t1, t4, &Overflow ); - t1 = add_o( t1, t4, &Overflow ); - t4 = sub_o( t2, t3, &Overflow ); - t2 = add_o( t2, t3, &Overflow ); - *xup3 = sub_o( mult_r( t1, cc3 ), mult_r( t2, ss3 ), &Overflow ); -#else /* BASOP_NOGLOB */ + t5 = sub_o( t1, t4, &Overflow ); /*Qx*/ + t1 = add_o( t1, t4, &Overflow ); /*Qx*/ + t4 = sub_o( t2, t3, &Overflow ); /*Qx*/ + t2 = add_o( t2, t3, &Overflow ); /*Qx*/ + *xup3 = sub_o( mult_r( t1, cc3 ), mult_r( t2, ss3 ), &Overflow ); /*Qx*/ +#else /* BASOP_NOGLOB */ t5 = sub( t1, t4 ); t1 = add( t1, t4 ); t4 = sub( t2, t3 ); t2 = add( t2, t3 ); *xup3 = sub( mult_r( t1, cc3 ), mult_r( t2, ss3 ) ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ move16(); xup3 -= n4; - move16(); #ifdef BASOP_NOGLOB - *xup3 = add_o( mult_r( t5, cc1 ), mult_r( t4, ss1 ), &Overflow ); -#else /* BASOP_NOGLOB */ + *xup3 = add_o( mult_r( t5, cc1 ), mult_r( t4, ss1 ), &Overflow ); /*Qx*/ +#else /* BASOP_NOGLOB */ *xup3 = add( mult_r( t5, cc1 ), mult_r( t4, ss1 ) ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ move16(); #ifdef BASOP_NOGLOB - *xdn8 = sub_o( mult_r( t5, ss1 ), mult_r( t4, cc1 ), &Overflow ); -#else /* BASOP_NOGLOB */ + *xdn8 = sub_o( mult_r( t5, ss1 ), mult_r( t4, cc1 ), &Overflow ); /*Qx*/ +#else /* BASOP_NOGLOB */ *xdn8 = sub( mult_r( t5, ss1 ), mult_r( t4, cc1 ) ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ move16(); xdn8 += n4; - move16(); #ifdef BASOP_NOGLOB - *xdn8 = add_o( mult_r( t2, cc3 ), mult_r( t1, ss3 ), &Overflow ); -#else /* BASOP_NOGLOB */ + *xdn8 = add_o( mult_r( t2, cc3 ), mult_r( t1, ss3 ), &Overflow ); /*Qx*/ +#else /* BASOP_NOGLOB */ *xdn8 = add( mult_r( t2, cc3 ), mult_r( t1, ss3 ) ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ move16(); xup1 -= n4; - move16(); xup1 += id; - move16(); xup3 += id; - move16(); xdn6 += id; - move16(); xdn8 += id; - move16(); } is = sub( shl( id, 1 ), n2 ); id = shl( id, 2 ); @@ -581,30 +545,26 @@ void ifft_rel_fx( WHILE( is < n ) { xi0 = x + is; - move16(); xi1 = xi0 + 1; - move16(); FOR( i0 = is; i0 <= n; i0 += id ) { r1 = *xi0; move16(); #ifdef BASOP_NOGLOB - *xi0 = add_o( r1, *xi1, &Overflow ); -#else /* BASOP_NOGLOB */ + *xi0 = add_o( r1, *xi1, &Overflow ); /*Qx*/ +#else /* BASOP_NOGLOB */ *xi0 = add( r1, *xi1 ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ move16(); #ifdef BASOP_NOGLOB - *xi1 = sub_o( r1, *xi1, &Overflow ); -#else /* BASOP_NOGLOB */ + *xi1 = sub_o( r1, *xi1, &Overflow ); /*Qx*/ +#else /* BASOP_NOGLOB */ *xi1 = sub( r1, *xi1 ); #endif move16(); xi0 += id; - move16(); xi1 += id; - move16(); } is = sub( shl( id, 1 ), 1 ); id = shl( id, 2 ); @@ -620,11 +580,11 @@ void ifft_rel_fx( { IF( LT_16( i, j ) ) { - xt = x[j]; + xt = x[j]; /*Qx*/ move16(); - x[j] = x[i]; + x[j] = x[i]; /*Qx*/ move16(); - x[i] = xt; + x[i] = xt; /*Qx*/ move16(); } k = shr( n, 1 ); @@ -643,18 +603,18 @@ void ifft_rel_fx( tmp = div_s( 1, n ); /*Q15 */ FOR( i = 1; i <= n; i++ ) { - x[i] = mult_r( x[i], tmp ); + x[i] = mult_r( x[i], tmp ); /*Qx*/ move16(); } return; } -#define INV_SQRT_2_16 ( Word16 )( 0x5A82 ) +#define INV_SQRT_2_16 ( Word16 )( 0x5A82 ) /*Q15*/ void ifft_rel_fx32( - Word32 io[], /* i/o: input/output vector */ - const Word16 n, /* i : vector length */ - const Word16 m /* i : log2 of vector length */ + Word32 io[], /* Qx i/o: input/output vector */ + const Word16 n, /* Q0 i : vector length */ + const Word16 m /* Q0 i : log2 of vector length */ ) { Word16 i, j, k; @@ -669,19 +629,19 @@ void ifft_rel_fx32( const Word16 *s, *s3, *c, *c3; const Word16 *idx; Word32 temp[512]; - Word16 n_inv = 128; + Word16 n_inv = 128; /*1/256 in Q15*/ move16(); SWITCH( n ) { case 128: - n_inv = 256; + n_inv = 256; /*1/128 in Q15*/ BREAK; case 256: - n_inv = 128; + n_inv = 128; /*1/256 in Q15*/ BREAK; case 512: - n_inv = 64; + n_inv = 64; /*1/512 in Q15*/ BREAK; default: assert( 0 ); @@ -694,46 +654,46 @@ void ifft_rel_fx32( *-----------------------------------------------------------------*/ x = &io[-1]; - n2 = shl( n, 1 ); + n2 = shl( n, 1 ); /*Q0*/ FOR( k = 1; k < m; k++ ) { is = 0; move16(); id = n2; move16(); - n2 = shr( n2, 1 ); - n4 = shr( n2, 2 ); - n8 = shr( n4, 1 ); + n2 = shr( n2, 1 ); /*Q0*/ + n4 = shr( n2, 2 ); /*Q0*/ + n8 = shr( n4, 1 ); /*Q0*/ WHILE( LT_16( is, sub( n, 1 ) ) ) { - xi1 = x + is + 1; - xi2 = xi1 + n4; - xi3 = xi2 + n4; - xi4 = xi3 + n4; + xi1 = x + is + 1; /*Qx*/ + xi2 = xi1 + n4; /*Qx*/ + xi3 = xi2 + n4; /*Qx*/ + xi4 = xi3 + n4; /*Qx*/ FOR( i = is; i < n; i += id ) { - t1 = L_sub( *xi1, *xi3 ); - *xi1 = L_add( *xi1, *xi3 ); + t1 = L_sub( *xi1, *xi3 ); /*Qx*/ + *xi1 = L_add( *xi1, *xi3 ); /*Qx*/ move32(); - *xi2 = L_shl( *xi2, 1 ); + *xi2 = L_shl( *xi2, 1 ); /*Qx*/ move32(); - *xi3 = L_sub( t1, L_shl( *xi4, 1 ) ); + *xi3 = L_sub( t1, L_shl( *xi4, 1 ) ); /*Qx*/ move32(); - *xi4 = L_add( t1, L_shl( *xi4, 1 ) ); + *xi4 = L_add( t1, L_shl( *xi4, 1 ) ); /*Qx*/ move32(); IF( NE_16( n4, 1 ) ) { - t1 = Mpy_32_16_1( L_sub( *( xi2 + n8 ), *( xi1 + n8 ) ), INV_SQRT_2_16 ); - t2 = Mpy_32_16_1( L_add( *( xi4 + n8 ), *( xi3 + n8 ) ), INV_SQRT_2_16 ); + t1 = Mpy_32_16_1( L_sub( *( xi2 + n8 ), *( xi1 + n8 ) ), INV_SQRT_2_16 ); /*Qx*/ + t2 = Mpy_32_16_1( L_add( *( xi4 + n8 ), *( xi3 + n8 ) ), INV_SQRT_2_16 ); /*Qx*/ - *( xi1 + n8 ) = L_add( *( xi1 + n8 ), *( xi2 + n8 ) ); + *( xi1 + n8 ) = L_add( *( xi1 + n8 ), *( xi2 + n8 ) ); /*Qx*/ move32(); - *( xi2 + n8 ) = L_sub( *( xi4 + n8 ), *( xi3 + n8 ) ); + *( xi2 + n8 ) = L_sub( *( xi4 + n8 ), *( xi3 + n8 ) ); /*Qx*/ move32(); - *( xi3 + n8 ) = L_shl( L_negate( L_add( t2, t1 ) ), 1 ); + *( xi3 + n8 ) = L_shl( L_negate( L_add( t2, t1 ) ), 1 ); /*Qx*/ move32(); - *( xi4 + n8 ) = L_shl( L_sub( t1, t2 ), 1 ); + *( xi4 + n8 ) = L_shl( L_sub( t1, t2 ), 1 ); /*Qx*/ move32(); } xi1 += id; @@ -741,23 +701,27 @@ void ifft_rel_fx32( xi3 += id; xi4 += id; } - is = sub( shl( id, 1 ), n2 ); - id = shl( id, 2 ); + is = sub( shl( id, 1 ), n2 ); /*Q0*/ + id = shl( id, 2 ); /*Q0*/ } /*Can be acheived with a shr */ - step = N_MAX_FFT / n2; + step = idiv1616( N_MAX_FFT, n2 ); move16(); - s = sincos_t_ext_fx + step; - c = s + N_MAX_FFT / 4; - s3 = sincos_t_ext_fx + imult1616( 3, step ); - c3 = s3 + N_MAX_FFT / 4; + s = sincos_t_ext_fx + step; /*Q15*/ + c = s + shr( N_MAX_FFT, 2 ); /*Q15*/ + s3 = sincos_t_ext_fx + imult1616( 3, step ); /*Q15*/ + c3 = s3 + shr( N_MAX_FFT, 2 ); /*Q15*/ FOR( j = 2; j <= n8; j++ ) { - cc1 = *c; - ss1 = *s; - cc3 = *c3; - ss3 = *s3; + cc1 = *c; /*Q15*/ + ss1 = *s; /*Q15*/ + cc3 = *c3; /*Q15*/ + ss3 = *s3; /*Q15*/ + move16(); + move16(); + move16(); + move16(); is = 0; move16(); @@ -767,53 +731,53 @@ void ifft_rel_fx32( c += step; s += step; - c3 += imult1616( 3, step ); - s3 += imult1616( 3, step ); + c3 += imult1616( 3, step ); /*Q15*/ + s3 += imult1616( 3, step ); /*Q15*/ WHILE( LT_16( is, sub( n, 1 ) ) ) { - xup1 = x + add( j, is ); - xup3 = xup1 + shl( n4, 1 ); - xdn6 = xup3 - sub( shl( j, 1 ), 2 ); - xdn8 = xdn6 + shl( n4, 1 ); + xup1 = x + add( j, is ); /*Qx*/ + xup3 = xup1 + shl( n4, 1 ); /*Qx*/ + xdn6 = xup3 - sub( shl( j, 1 ), 2 ); /*Qx*/ + xdn8 = xdn6 + shl( n4, 1 ); /*Qx*/ FOR( i = is; i < n; i += id ) { - t1 = L_sub( *xup1, *xdn6 ); - *xup1 = L_add( *xup1, *xdn6 ); + t1 = L_sub( *xup1, *xdn6 ); /*Qx*/ + *xup1 = L_add( *xup1, *xdn6 ); /*Qx*/ move32(); xup1 += n4; xdn6 -= n4; - t2 = L_sub( *xdn6, *xup1 ); - *xdn6 = L_add( *xup1, *xdn6 ); + t2 = L_sub( *xdn6, *xup1 ); /*Qx*/ + *xdn6 = L_add( *xup1, *xdn6 ); /*Qx*/ move32(); xdn6 += n4; - t3 = L_add( *xdn8, *xup3 ); - *xdn6 = L_sub( *xdn8, *xup3 ); + t3 = L_add( *xdn8, *xup3 ); /*Qx*/ + *xdn6 = L_sub( *xdn8, *xup3 ); /*Qx*/ move32(); xup3 += n4; xdn8 -= n4; - t4 = L_add( *xup3, *xdn8 ); - *xup1 = L_sub( *xup3, *xdn8 ); + t4 = L_add( *xup3, *xdn8 ); /*Qx*/ + *xup1 = L_sub( *xup3, *xdn8 ); /*Qx*/ move32(); - t5 = L_sub( t1, t4 ); - t1 = L_add( t1, t4 ); - t4 = L_sub( t2, t3 ); - t2 = L_add( t2, t3 ); - *xup3 = L_sub( Mpy_32_16_1( t1, cc3 ), Mpy_32_16_1( t2, ss3 ) ); + t5 = L_sub( t1, t4 ); /*Qx*/ + t1 = L_add( t1, t4 ); /*Qx*/ + t4 = L_sub( t2, t3 ); /*Qx*/ + t2 = L_add( t2, t3 ); /*Qx*/ + *xup3 = L_sub( Mpy_32_16_1( t1, cc3 ), Mpy_32_16_1( t2, ss3 ) ); /*Qx*/ move32(); xup3 -= n4; - *xup3 = L_add( Mpy_32_16_1( t5, cc1 ), Mpy_32_16_1( t4, ss1 ) ); + *xup3 = L_add( Mpy_32_16_1( t5, cc1 ), Mpy_32_16_1( t4, ss1 ) ); /*Qx*/ move32(); - *xdn8 = L_sub( Mpy_32_16_1( t5, ss1 ), Mpy_32_16_1( t4, cc1 ) ); + *xdn8 = L_sub( Mpy_32_16_1( t5, ss1 ), Mpy_32_16_1( t4, cc1 ) ); /*Qx*/ move32(); xdn8 += n4; - *xdn8 = L_add( Mpy_32_16_1( t2, cc3 ), Mpy_32_16_1( t1, ss3 ) ); + *xdn8 = L_add( Mpy_32_16_1( t2, cc3 ), Mpy_32_16_1( t1, ss3 ) ); /*Qx*/ move32(); xup1 -= n4; @@ -822,8 +786,8 @@ void ifft_rel_fx32( xdn6 += id; xdn8 += id; } - is = sub( shl( id, 1 ), n2 ); - id = shl( id, 2 ); + is = sub( shl( id, 1 ), n2 ); /*Q0*/ + id = shl( id, 2 ); /*Q0*/ } } } @@ -843,11 +807,11 @@ void ifft_rel_fx32( FOR( i0 = is; i0 <= n; i0 += id ) { - r1 = *xi0; + r1 = *xi0; /*Qx*/ move32(); - *xi0 = L_add( r1, *xi1 ); + *xi0 = L_add( r1, *xi1 ); /*Qx*/ move32(); - *xi1 = L_sub( r1, *xi1 ); + *xi1 = L_sub( r1, *xi1 ); /*Qx*/ move32(); xi0 += id; xi1 += id; @@ -867,7 +831,8 @@ void ifft_rel_fx32( FOR( i = 0; i < n; i++ ) { j = *idx++; - temp[i] = x[1 + shr( j, 1 )]; + move16(); + temp[i] = x[1 + shr( j, 1 )]; /*Qx*/ move32(); } } @@ -876,7 +841,7 @@ void ifft_rel_fx32( FOR( i = 0; i < n; i++ ) { j = *idx++; - temp[i] = x[1 + j]; + temp[i] = x[1 + j]; /*Qx*/ move32(); } } @@ -885,9 +850,9 @@ void ifft_rel_fx32( FOR( i = 0; i < 256; i++ ) { j = *idx++; - temp[i] = x[1 + 2 * j]; + temp[i] = x[1 + 2 * j]; /*Qx*/ move32(); - temp[i + 256] = x[2 + 2 * j]; + temp[i + 256] = x[2 + 2 * j]; /*Qx*/ move32(); } } @@ -895,13 +860,14 @@ void ifft_rel_fx32( { xi0 = x; j = 1; + move16(); FOR( i = 1; i < n; i++ ) { IF( LT_16( i, j ) ) { - xt = x[j]; - x[j] = x[i]; - x[i] = xt; + xt = x[j]; /*Qx*/ + x[j] = x[i]; /*Qx*/ + x[i] = xt; /*Qx*/ move32(); move32(); move32(); @@ -922,7 +888,7 @@ void ifft_rel_fx32( FOR( i = 1; i <= n; i++ ) { - x[i] = Mpy_32_16_1( xi0[i], n_inv ); + x[i] = Mpy_32_16_1( xi0[i], n_inv ); /*Qx*/ move32(); } diff --git a/lib_com/igf_base_fx.c b/lib_com/igf_base_fx.c index b087695b5..5b2f81f93 100644 --- a/lib_com/igf_base_fx.c +++ b/lib_com/igf_base_fx.c @@ -22,17 +22,17 @@ Word16 IGF_ApplyTransFac( /**< ou { Word16 ret; - IF( EQ_16( transFac, 0x4000 ) ) + IF( EQ_16( transFac, 0x4000 /*ONE in Q14*/ ) ) { return val; } ret = shl( val, 1 ); ret = mac_r( 0x00000000, ret, transFac ); - ret = add( ret, s_and( ret, 1 ) ); + ret = add( ret, s_and( ret, 1 ) ); /*Q0*/ - return ret; + return ret; /*Q0*/ } /**********************************************************************/ /* @@ -53,6 +53,7 @@ Word16 IGF_MapBitRateToIndex( SWITCH( bwidth ) { case IGF_MODE_WB: + test(); IF( LE_32( brate, IVAS_13k2 ) && EQ_16( rf_mode, 1 ) ) { bitRateIndex = IGF_BITRATE_RF_WB_13200; @@ -178,6 +179,7 @@ Word16 IGF_MapBitRateToIndex( SWITCH( bwidth ) { case IGF_MODE_WB: + test(); IF( LE_32( brate, IVAS_13k2 ) && EQ_16( rf_mode, 1 ) ) { bitRateIndex = IGF_BITRATE_RF_WB_13200; @@ -279,6 +281,7 @@ Word16 IGF_MapBitRateToIndex( SWITCH( bwidth ) { case IGF_MODE_WB: + test(); IF( LE_32( brate, ACELP_13k20 ) && EQ_16( rf_mode, 1 ) ) { bitRateIndex = IGF_BITRATE_RF_WB_13200; @@ -375,7 +378,7 @@ Word16 IGF_MapBitRateToIndex( } } - return bitRateIndex; + return bitRateIndex; /*Q0*/ } /**********************************************************************/ /* @@ -385,7 +388,7 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou Word16 bitRateIndex, /**< in: Q0 | IGF bitrate index */ Word32 sampleRate, /**< in: | sample rate */ Word16 frameLength, /**< in: | frame length */ - Word16 transFac, /**< in: | transFac */ + Word16 transFac, /**< in: Q14 |transFac */ Word16 igfMinFq /**< in: | IGF minimum frequency indicating lower start frequency for copy up */ ) { @@ -401,7 +404,6 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou Word32 L_tmp2; swb_offset = NULL; - move16(); swb_offset_len = 0; move16(); @@ -417,7 +419,7 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou case IGF_BITRATE_SWB_32000: case IGF_BITRATE_SWB_48000: swb_offset = &swb_offset_LB_new[bitRateIndex][1]; - swb_offset_len = swb_offset_LB_new[bitRateIndex][0]; + swb_offset_len = swb_offset_LB_new[bitRateIndex][0]; /*Q0*/ move16(); Copy( &igf_whitening_TH[bitRateIndex][0][0], &hGrid->whiteningThreshold[0][0], IGF_MAX_TILES * 2 ); BREAK; @@ -425,7 +427,7 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou case IGF_BITRATE_FB_24400: case IGF_BITRATE_FB_32000: swb_offset = &swb_offset_LB_new[bitRateIndex][1]; - swb_offset_len = swb_offset_LB_new[bitRateIndex][0]; + swb_offset_len = swb_offset_LB_new[bitRateIndex][0]; /*Q0*/ move16(); Copy( &igf_whitening_TH[bitRateIndex][0][0], &hGrid->whiteningThreshold[0][0], IGF_MAX_TILES * 2 ); BREAK; @@ -433,7 +435,7 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou case IGF_BITRATE_FB_96000: case IGF_BITRATE_FB_128000: swb_offset = &swb_offset_LB_new[bitRateIndex][1]; - swb_offset_len = swb_offset_LB_new[bitRateIndex][0]; + swb_offset_len = swb_offset_LB_new[bitRateIndex][0]; /*Q0*/ move16(); Copy( &igf_whitening_TH[bitRateIndex][0][0], &hGrid->whiteningThreshold[0][0], IGF_MAX_TILES * 2 ); BREAK; @@ -444,50 +446,50 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou FOR( sfb = 0; sfb < swb_offset_len; sfb++ ) { - hGrid->swb_offset[sfb] = IGF_ApplyTransFac( swb_offset[sfb], transFac ); + hGrid->swb_offset[sfb] = IGF_ApplyTransFac( swb_offset[sfb], transFac ); /*Q0*/ move16(); } hGrid->infoIsRefined = 0; move16(); - frameLength = IGF_ApplyTransFac( frameLength, transFac ); + frameLength = IGF_ApplyTransFac( frameLength, transFac ); /*Q0*/ tmp2 = norm_s( frameLength ); - bandwidth = shl( frameLength, tmp2 ); - hGrid->swb_offset_len = extract_l( L_shr( sampleRate, 2 ) ); + bandwidth = shl( frameLength, tmp2 ); /*tmp2*/ + hGrid->swb_offset_len = extract_l( L_shr( sampleRate, 2 ) ); /*-1*/ move16(); tmp1 = sub( norm_s( hGrid->swb_offset_len ), 1 ); - hGrid->swb_offset_len = shl( hGrid->swb_offset_len, tmp1 ); + hGrid->swb_offset_len = shl( hGrid->swb_offset_len, tmp1 ); /*tmp1-1*/ move16(); - bandwidth = div_s( hGrid->swb_offset_len, bandwidth ); + bandwidth = div_s( hGrid->swb_offset_len, bandwidth ); /*15 + tmp1-1-tmp2*/ tmp2 = sub( add( tmp2, 1 ), tmp1 ); - bandwidth = shr( bandwidth, sub( 15, tmp2 ) ); + bandwidth = shr( bandwidth, sub( 15, tmp2 ) ); /*Q0*/ - hGrid->swb_offset_len = swb_offset_len; + hGrid->swb_offset_len = swb_offset_len; /*Q0*/ move16(); hGrid->startSfb = 0; move16(); - hGrid->stopSfb = sub( hGrid->swb_offset_len, 1 ); + hGrid->stopSfb = sub( hGrid->swb_offset_len, 1 ); /*Q0*/ move16(); - hGrid->startLine = hGrid->swb_offset[hGrid->startSfb]; + hGrid->startLine = hGrid->swb_offset[hGrid->startSfb]; /*Q0*/ move16(); - hGrid->stopLine = hGrid->swb_offset[hGrid->stopSfb]; + hGrid->stopLine = hGrid->swb_offset[hGrid->stopSfb]; /*Q0*/ move16(); - hGrid->startFrequency = imult1616( bandwidth, hGrid->startLine ); + hGrid->startFrequency = imult1616( bandwidth, hGrid->startLine ); /*Q0*/ move16(); - hGrid->stopFrequency = imult1616( bandwidth, hGrid->stopLine ); + hGrid->stopFrequency = imult1616( bandwidth, hGrid->stopLine ); /*Q0*/ move16(); - L_tmp1 = L_mult0( igfMinFq, frameLength ); + L_tmp1 = L_mult0( igfMinFq, frameLength ); /*Q0*/ tmp1 = sub( norm_l( L_tmp1 ), 1 ); - L_tmp1 = L_shl( L_tmp1, tmp1 ); + L_tmp1 = L_shl( L_tmp1, tmp1 ); /*tmp1*/ tmp2 = norm_l( sampleRate ); - L_tmp2 = L_shl( sampleRate, tmp2 ); + L_tmp2 = L_shl( sampleRate, tmp2 ); /*tmp2*/ tmp1 = add( WORD16_BITS - 1, sub( tmp1, add( tmp2, 1 ) ) ); /* takes into account sampleRate >> 1 */ - hGrid->minSrcSubband = div_s( extract_h( L_tmp1 ), extract_h( L_tmp2 ) ); - hGrid->minSrcSubband = shr( hGrid->minSrcSubband, tmp1 ); + hGrid->minSrcSubband = div_s( extract_h( L_tmp1 ), extract_h( L_tmp2 ) ); /*tmp1*/ + hGrid->minSrcSubband = shr( hGrid->minSrcSubband, tmp1 ); /*Q0*/ move16(); move16(); @@ -496,14 +498,14 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou move16(); hGrid->minSrcFrequency = imult1616( bandwidth, hGrid->minSrcSubband ); move16(); - hGrid->infoGranuleLen = frameLength; + hGrid->infoGranuleLen = frameLength; /*Q0*/ move16(); - hGrid->infoTransFac = transFac; + hGrid->infoTransFac = transFac; /*Q14*/ move16(); hGrid->sfbWrap[0] = 0; move16(); - hGrid->tile[0] = hGrid->startLine; + hGrid->tile[0] = hGrid->startLine; /*Q0*/ move16(); @@ -518,19 +520,19 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou move16(); /*1st*/ - hGrid->sfbWrap[0 + 1] = wrp_sfb; + hGrid->sfbWrap[0 + 1] = wrp_sfb; /*Q0*/ move16(); - hGrid->sbWrap[0] = hGrid->minSrcSubband; + hGrid->sbWrap[0] = hGrid->minSrcSubband; /*Q0*/ move16(); - hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb]; + hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb]; /*Q0*/ move16(); /*2nd*/ - hGrid->sfbWrap[1 + 1] = hGrid->stopSfb; + hGrid->sfbWrap[1 + 1] = hGrid->stopSfb; /*Q0*/ move16(); - hGrid->sbWrap[1] = hGrid->minSrcSubband; + hGrid->sbWrap[1] = hGrid->minSrcSubband; /*Q0*/ move16(); - hGrid->tile[1 + 1] = hGrid->swb_offset[hGrid->stopSfb]; + hGrid->tile[1 + 1] = hGrid->swb_offset[hGrid->stopSfb]; /*Q0*/ move16(); BREAK; @@ -541,19 +543,19 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou move16(); /*1st*/ - hGrid->sfbWrap[0 + 1] = wrp_sfb; + hGrid->sfbWrap[0 + 1] = wrp_sfb; /*Q0*/ move16(); - hGrid->sbWrap[0] = hGrid->minSrcSubband; + hGrid->sbWrap[0] = hGrid->minSrcSubband; /*Q0*/ move16(); - hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb]; + hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb]; /*Q0*/ move16(); /*2nd*/ - hGrid->sfbWrap[1 + 1] = hGrid->stopSfb; + hGrid->sfbWrap[1 + 1] = hGrid->stopSfb; /*Q0*/ move16(); - hGrid->sbWrap[1] = hGrid->minSrcSubband; + hGrid->sbWrap[1] = hGrid->minSrcSubband; /*Q0*/ move16(); - hGrid->tile[1 + 1] = hGrid->swb_offset[hGrid->stopSfb]; + hGrid->tile[1 + 1] = hGrid->swb_offset[hGrid->stopSfb]; /*Q0*/ move16(); BREAK; @@ -564,29 +566,29 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou move16(); /*1st*/ - hGrid->sfbWrap[0 + 1] = wrp_sfb; + hGrid->sfbWrap[0 + 1] = wrp_sfb; /*Q0*/ move16(); - hGrid->sbWrap[0] = hGrid->minSrcSubband; + hGrid->sbWrap[0] = hGrid->minSrcSubband; /*Q0*/ move16(); - hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb]; + hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb]; /*Q0*/ move16(); /*2nd*/ wrp_sfb = 2; move16(); - hGrid->sfbWrap[1 + 1] = wrp_sfb; + hGrid->sfbWrap[1 + 1] = wrp_sfb; /*Q0*/ move16(); - hGrid->sbWrap[1] = hGrid->minSrcSubband + IGF_ApplyTransFac( 32, transFac ); + hGrid->sbWrap[1] = hGrid->minSrcSubband + IGF_ApplyTransFac( 32, transFac ); /*Q0*/ move16(); - hGrid->tile[1 + 1] = hGrid->swb_offset[wrp_sfb]; + hGrid->tile[1 + 1] = hGrid->swb_offset[wrp_sfb]; /*Q0*/ move16(); /*3rd*/ - hGrid->sfbWrap[2 + 1] = hGrid->stopSfb; + hGrid->sfbWrap[2 + 1] = hGrid->stopSfb; /*Q0*/ move16(); - hGrid->sbWrap[2] = hGrid->minSrcSubband + IGF_ApplyTransFac( 46, transFac ); + hGrid->sbWrap[2] = hGrid->minSrcSubband + IGF_ApplyTransFac( 46, transFac ); /*Q0*/ move16(); - hGrid->tile[2 + 1] = hGrid->swb_offset[hGrid->stopSfb]; + hGrid->tile[2 + 1] = hGrid->swb_offset[hGrid->stopSfb]; /*Q0*/ move16(); BREAK; @@ -597,29 +599,29 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou move16(); /*1st*/ - hGrid->sfbWrap[0 + 1] = wrp_sfb; + hGrid->sfbWrap[0 + 1] = wrp_sfb; /*Q0*/ move16(); - hGrid->sbWrap[0] = hGrid->minSrcSubband; + hGrid->sbWrap[0] = hGrid->minSrcSubband; /*Q0*/ move16(); - hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb]; + hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb]; /*Q0*/ move16(); /*2nd*/ wrp_sfb = 2; move16(); - hGrid->sfbWrap[1 + 1] = wrp_sfb; + hGrid->sfbWrap[1 + 1] = wrp_sfb; /*Q0*/ move16(); - hGrid->sbWrap[1] = hGrid->minSrcSubband + IGF_ApplyTransFac( 32, transFac ); + hGrid->sbWrap[1] = hGrid->minSrcSubband + IGF_ApplyTransFac( 32, transFac ); /*Q0*/ move16(); - hGrid->tile[1 + 1] = hGrid->swb_offset[wrp_sfb]; + hGrid->tile[1 + 1] = hGrid->swb_offset[wrp_sfb]; /*Q0*/ move16(); /*3rd*/ - hGrid->sfbWrap[2 + 1] = hGrid->stopSfb; + hGrid->sfbWrap[2 + 1] = hGrid->stopSfb; /*Q0*/ move16(); - hGrid->sbWrap[2] = hGrid->minSrcSubband + IGF_ApplyTransFac( 46, transFac ); + hGrid->sbWrap[2] = hGrid->minSrcSubband + IGF_ApplyTransFac( 46, transFac ); /*Q0*/ move16(); - hGrid->tile[2 + 1] = hGrid->swb_offset[hGrid->stopSfb]; + hGrid->tile[2 + 1] = hGrid->swb_offset[hGrid->stopSfb]; /*Q0*/ move16(); BREAK; @@ -631,19 +633,19 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou move16(); /*1st*/ - hGrid->sfbWrap[0 + 1] = wrp_sfb; + hGrid->sfbWrap[0 + 1] = wrp_sfb; /*Q0*/ move16(); - hGrid->sbWrap[0] = hGrid->minSrcSubband; + hGrid->sbWrap[0] = hGrid->minSrcSubband; /*Q0*/ move16(); - hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb]; + hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb]; /*Q0*/ move16(); /*2nd*/ - hGrid->sfbWrap[1 + 1] = hGrid->stopSfb; + hGrid->sfbWrap[1 + 1] = hGrid->stopSfb; /*Q0*/ move16(); - hGrid->sbWrap[1] = add( hGrid->minSrcSubband, IGF_ApplyTransFac( 32, transFac ) ); + hGrid->sbWrap[1] = add( hGrid->minSrcSubband, IGF_ApplyTransFac( 32, transFac ) ); /*Q0*/ move16(); - hGrid->tile[1 + 1] = hGrid->swb_offset[hGrid->stopSfb]; + hGrid->tile[1 + 1] = hGrid->swb_offset[hGrid->stopSfb]; /*Q0*/ move16(); BREAK; @@ -654,27 +656,27 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou move16(); /*1st*/ - hGrid->sfbWrap[0 + 1] = wrp_sfb; + hGrid->sfbWrap[0 + 1] = wrp_sfb; /*Q0*/ move16(); - hGrid->sbWrap[0] = hGrid->minSrcSubband; + hGrid->sbWrap[0] = hGrid->minSrcSubband; /*Q0*/ move16(); - hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb]; + hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb]; /*Q0*/ move16(); /*2nd*/ hGrid->sfbWrap[1 + 1] = 6; move16(); - hGrid->sbWrap[1] = add( hGrid->minSrcSubband, IGF_ApplyTransFac( 48, transFac ) ); + hGrid->sbWrap[1] = add( hGrid->minSrcSubband, IGF_ApplyTransFac( 48, transFac ) ); /*Q0*/ move16(); - hGrid->tile[1 + 1] = hGrid->swb_offset[6]; + hGrid->tile[1 + 1] = hGrid->swb_offset[6]; /*Q0*/ move16(); /*3nd*/ - hGrid->sfbWrap[2 + 1] = hGrid->stopSfb; + hGrid->sfbWrap[2 + 1] = hGrid->stopSfb; /*Q0*/ move16(); - hGrid->sbWrap[2] = add( hGrid->minSrcSubband, IGF_ApplyTransFac( 64, transFac ) ); + hGrid->sbWrap[2] = add( hGrid->minSrcSubband, IGF_ApplyTransFac( 64, transFac ) ); /*Q0*/ move16(); - hGrid->tile[2 + 1] = hGrid->swb_offset[hGrid->stopSfb]; + hGrid->tile[2 + 1] = hGrid->swb_offset[hGrid->stopSfb]; /*Q0*/ move16(); BREAK; @@ -686,27 +688,27 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou move16(); /*1st*/ - hGrid->sfbWrap[0 + 1] = wrp_sfb; + hGrid->sfbWrap[0 + 1] = wrp_sfb; /*Q0*/ move16(); - hGrid->sbWrap[0] = hGrid->minSrcSubband; + hGrid->sbWrap[0] = hGrid->minSrcSubband; /*Q0*/ move16(); - hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb]; + hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb]; /*Q0*/ move16(); /*2nd*/ hGrid->sfbWrap[1 + 1] = 7; move16(); - hGrid->sbWrap[1] = add( hGrid->minSrcSubband, IGF_ApplyTransFac( 32, transFac ) ); + hGrid->sbWrap[1] = add( hGrid->minSrcSubband, IGF_ApplyTransFac( 32, transFac ) ); /*Q0*/ move16(); - hGrid->tile[1 + 1] = hGrid->swb_offset[7]; + hGrid->tile[1 + 1] = hGrid->swb_offset[7]; /*Q0*/ move16(); /*3nd*/ - hGrid->sfbWrap[2 + 1] = hGrid->stopSfb; + hGrid->sfbWrap[2 + 1] = hGrid->stopSfb; /*Q0*/ move16(); - hGrid->sbWrap[2] = add( hGrid->minSrcSubband, IGF_ApplyTransFac( 64, transFac ) ); + hGrid->sbWrap[2] = add( hGrid->minSrcSubband, IGF_ApplyTransFac( 64, transFac ) ); /*Q0*/ move16(); - hGrid->tile[2 + 1] = hGrid->swb_offset[hGrid->stopSfb]; + hGrid->tile[2 + 1] = hGrid->swb_offset[hGrid->stopSfb]; /*Q0*/ move16(); BREAK; case IGF_BITRATE_SWB_48000: @@ -716,11 +718,11 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou move16(); /*1st*/ - hGrid->sfbWrap[0 + 1] = hGrid->stopSfb; + hGrid->sfbWrap[0 + 1] = hGrid->stopSfb; /*Q0*/ move16(); - hGrid->sbWrap[0] = sub( shl( hGrid->startLine, 1 ), hGrid->stopLine ); + hGrid->sbWrap[0] = sub( shl( hGrid->startLine, 1 ), hGrid->stopLine ); /*Q0*/ move16(); - hGrid->tile[0 + 1] = hGrid->swb_offset[hGrid->stopSfb]; + hGrid->tile[0 + 1] = hGrid->swb_offset[hGrid->stopSfb]; /*Q0*/ move16(); BREAK; @@ -731,29 +733,29 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou move16(); /*1st*/ - hGrid->sfbWrap[0 + 1] = wrp_sfb; + hGrid->sfbWrap[0 + 1] = wrp_sfb; /*Q0*/ move16(); - hGrid->sbWrap[0] = hGrid->minSrcSubband; + hGrid->sbWrap[0] = hGrid->minSrcSubband; /*Q0*/ move16(); - hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb]; + hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb]; /*Q0*/ move16(); wrp_sfb = 7; move16(); /*2nd*/ - hGrid->sfbWrap[1 + 1] = wrp_sfb; + hGrid->sfbWrap[1 + 1] = wrp_sfb; /*Q0*/ move16(); - hGrid->sbWrap[1] = hGrid->minSrcSubband; + hGrid->sbWrap[1] = hGrid->minSrcSubband; /*Q0*/ move16(); - hGrid->tile[1 + 1] = hGrid->swb_offset[wrp_sfb]; + hGrid->tile[1 + 1] = hGrid->swb_offset[wrp_sfb]; /*Q0*/ move16(); /*3nd*/ - hGrid->sfbWrap[2 + 1] = hGrid->stopSfb; + hGrid->sfbWrap[2 + 1] = hGrid->stopSfb; /*Q0*/ move16(); - hGrid->sbWrap[2] = hGrid->minSrcSubband; + hGrid->sbWrap[2] = hGrid->minSrcSubband; /*Q0*/ move16(); - hGrid->tile[2 + 1] = hGrid->swb_offset[hGrid->stopSfb]; + hGrid->tile[2 + 1] = hGrid->swb_offset[hGrid->stopSfb]; /*Q0*/ move16(); BREAK; @@ -766,39 +768,39 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou move16(); /*1st*/ - hGrid->sfbWrap[0 + 1] = wrp_sfb; + hGrid->sfbWrap[0 + 1] = wrp_sfb; /*Q0*/ move16(); - hGrid->sbWrap[0] = hGrid->minSrcSubband; + hGrid->sbWrap[0] = hGrid->minSrcSubband; /*Q0*/ move16(); - hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb]; + hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb]; /*Q0*/ move16(); wrp_sfb = 6; move16(); /*2nd*/ - hGrid->sfbWrap[1 + 1] = wrp_sfb; + hGrid->sfbWrap[1 + 1] = wrp_sfb; /*Q0*/ move16(); - hGrid->sbWrap[1] = add( hGrid->minSrcSubband, IGF_ApplyTransFac( 32, transFac ) ); + hGrid->sbWrap[1] = add( hGrid->minSrcSubband, IGF_ApplyTransFac( 32, transFac ) ); /*Q0*/ move16(); - hGrid->tile[1 + 1] = hGrid->swb_offset[wrp_sfb]; + hGrid->tile[1 + 1] = hGrid->swb_offset[wrp_sfb]; /*Q0*/ move16(); wrp_sfb = 9; move16(); /*3nd*/ - hGrid->sfbWrap[2 + 1] = wrp_sfb; + hGrid->sfbWrap[2 + 1] = wrp_sfb; /*Q0*/ move16(); - hGrid->sbWrap[2] = hGrid->minSrcSubband; + hGrid->sbWrap[2] = hGrid->minSrcSubband; /*Q0*/ move16(); - hGrid->tile[2 + 1] = hGrid->swb_offset[wrp_sfb]; + hGrid->tile[2 + 1] = hGrid->swb_offset[wrp_sfb]; /*Q0*/ move16(); /*4nd*/ - hGrid->sfbWrap[3 + 1] = hGrid->stopSfb; + hGrid->sfbWrap[3 + 1] = hGrid->stopSfb; /*Q0*/ move16(); - hGrid->sbWrap[3] = add( hGrid->minSrcSubband, sub( hGrid->swb_offset[9], hGrid->swb_offset[8] ) ); + hGrid->sbWrap[3] = add( hGrid->minSrcSubband, sub( hGrid->swb_offset[9], hGrid->swb_offset[8] ) ); /*Q0*/ move16(); - hGrid->tile[3 + 1] = hGrid->swb_offset[hGrid->stopSfb]; + hGrid->tile[3 + 1] = hGrid->swb_offset[hGrid->stopSfb]; /*Q0*/ move16(); BREAK; case IGF_BITRATE_FB_48000: @@ -808,11 +810,11 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou move16(); /*1st*/ - hGrid->sfbWrap[0 + 1] = hGrid->stopSfb; + hGrid->sfbWrap[0 + 1] = hGrid->stopSfb; /*Q0*/ move16(); - hGrid->sbWrap[0] = sub( shl( hGrid->startLine, 1 ), hGrid->stopLine ); + hGrid->sbWrap[0] = sub( shl( hGrid->startLine, 1 ), hGrid->stopLine ); /*Q0*/ move16(); - hGrid->tile[0 + 1] = hGrid->swb_offset[hGrid->stopSfb]; + hGrid->tile[0 + 1] = hGrid->swb_offset[hGrid->stopSfb]; /*Q0*/ move16(); BREAK; @@ -913,12 +915,12 @@ static void IGF_gridSetUp_ivas_fx( test(); test(); - IF( EQ_16( transFac, 8192 ) && EQ_16( bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) ) + IF( EQ_16( transFac, 8192 /*0.5 in Q14*/ ) && EQ_16( bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) ) { bitRateIndex = IGF_BITRATE_SWB_48000_CPE_TCX10; move16(); } - ELSE IF( EQ_16( transFac, 8192 ) && EQ_16( bitRateIndex, IGF_BITRATE_FB_48000_CPE ) ) + ELSE IF( EQ_16( transFac, 8192 /*0.5 in Q14*/ ) && EQ_16( bitRateIndex, IGF_BITRATE_FB_48000_CPE ) ) { bitRateIndex = IGF_BITRATE_FB_48000_CPE_TCX10; move16(); @@ -949,18 +951,18 @@ static void IGF_gridSetUp_ivas_fx( hGrid->infoIsRefined = 0; move16(); - frameLength = IGF_ApplyTransFac( frameLength, transFac ); + frameLength = IGF_ApplyTransFac( frameLength, transFac ); /*Q0*/ tmp2 = norm_s( frameLength ); - bandwidth_fx = shl( frameLength, tmp2 ); - hGrid->swb_offset_len = extract_l( L_shr( sampleRate, 2 ) ); + bandwidth_fx = shl( frameLength, tmp2 ); /*tmp2*/ + hGrid->swb_offset_len = extract_l( L_shr( sampleRate, 2 ) ); /*-1*/ move16(); tmp1 = sub( norm_s( hGrid->swb_offset_len ), 1 ); - hGrid->swb_offset_len = shl( hGrid->swb_offset_len, tmp1 ); + hGrid->swb_offset_len = shl( hGrid->swb_offset_len, tmp1 ); /*tmp1-1*/ move16(); - bandwidth_fx = div_s( hGrid->swb_offset_len, bandwidth_fx ); + bandwidth_fx = div_s( hGrid->swb_offset_len, bandwidth_fx ); /*15 + tmp1-1-tmp2*/ tmp2 = sub( add( tmp2, 1 ), tmp1 ); bandwidth_fx = shr( bandwidth_fx, sub( 15, tmp2 ) ); - hGrid->swb_offset_len = swb_offset_len; + hGrid->swb_offset_len = swb_offset_len; /*Q0*/ move16(); hGrid->startSfb = 0; move16(); @@ -982,17 +984,17 @@ static void IGF_gridSetUp_ivas_fx( tmp1 = add( WORD16_BITS - 1, sub( tmp1, add( tmp2, 1 ) ) ); /* takes into account sampleRate >> 1 */ hGrid->minSrcSubband = div_s( extract_h( L_tmp1 ), extract_h( L_tmp2 ) ); move16(); - hGrid->minSrcSubband = shr( hGrid->minSrcSubband, tmp1 ); + hGrid->minSrcSubband = shr( hGrid->minSrcSubband, tmp1 ); /*Q0*/ move16(); hGrid->minSrcSubband = add( hGrid->minSrcSubband, s_and( hGrid->minSrcSubband, 1 ) ); move16(); - hGrid->minSrcFrequency = imult1616( bandwidth_fx, hGrid->minSrcSubband ); + hGrid->minSrcFrequency = imult1616( bandwidth_fx, hGrid->minSrcSubband ); /*Q0*/ move16(); - hGrid->infoGranuleLen = frameLength; + hGrid->infoGranuleLen = frameLength; /*Q0*/ move16(); hGrid->sfbWrap[0] = 0; move16(); - hGrid->tile[0] = hGrid->startLine; + hGrid->tile[0] = hGrid->startLine; /*Q0*/ move16(); igf_tile_offset = &igf_tile_offset_table[bitRateIndex][1]; @@ -1008,7 +1010,7 @@ static void IGF_gridSetUp_ivas_fx( move16(); hGrid->sbWrap[k] = add( hGrid->minSrcSubband, IGF_ApplyTransFac( igf_tile_offset[2 * k + 1], transFac ) ); move16(); - hGrid->tile[k + 1] = hGrid->swb_offset[igf_tile_offset[2 * k]]; + hGrid->tile[k + 1] = hGrid->swb_offset[igf_tile_offset[2 * k]]; /*Q0*/ move16(); } FOR( t = hGrid->nTiles + 1; t < IGF_MAX_TILES; t++ ) @@ -1128,7 +1130,7 @@ void IGFCommonFuncsCalcSfbEnergyPowerSpec( const Word16 startSfb, /**< in FOR( sfb = startSfb; sfb < stopSfb; sfb++ ) { sfbEnergy[sfb] = L_deposit_l( 0 ); - move16(); + move32(); } IF( NULL == pPowerSpectrum ) { @@ -1168,9 +1170,9 @@ calculate the MDCT square spectrum in the IGF range **************************************************************************/ void IGFCommonFuncsMDCTSquareSpec( const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ - const Word32 *mdctSpec, /**< in: Q31 | MDCT spectrum to square */ + const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ - Word32 *mdctSquareSpec, /**< out:Q31 | MDCT square spectrum */ + Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ Word16 indexOffset /**< in: Q0 | index offset */ ) @@ -1195,11 +1197,11 @@ void IGFCommonFuncsMDCTSquareSpec( const Word16 sqrtBgn, /**< in FOR( i = sqrtBgn; i < sqrtEnd; i++ ) { #ifdef BASOP_NOGLOB - tmp = round_fx_sat( L_shl_sat( mdctSpec[i], s1 ) ); + tmp = round_fx_sat( L_shl_sat( mdctSpec[i], s1 ) ); /*(15 - mdctSpec_e)+ S1*/ #else tmp = round_fx( L_shl( mdctSpec[i], s1 ) ); #endif - mdctSquareSpec[j++] = L_mult0( tmp, tmp ); + mdctSquareSpec[j++] = L_mult0( tmp, tmp ); /*31 - mdctSquareSpec_e*/ move32(); } } @@ -1209,9 +1211,9 @@ calculate the MDCT square spectrum in the IGF range (for IVAS) **************************************************************************/ void IGFCommonFuncsMDCTSquareSpec_ivas( const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ - const Word32 *mdctSpec, /**< in: Q31 | MDCT spectrum to square */ + const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ - Word32 *mdctSquareSpec, /**< out:Q31 | MDCT square spectrum */ + Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ Word16 indexOffset /**< in: Q0 | index offset */ ) @@ -1235,8 +1237,8 @@ void IGFCommonFuncsMDCTSquareSpec_ivas( const Word16 sqrtBgn, /**< in FOR( i = sqrtBgn; i < sqrtEnd; i++ ) { - tmp = extract_h( L_shl( mdctSpec[i], s1 ) ); - mdctSquareSpec[j++] = L_mult0( tmp, tmp ); + tmp = extract_h( L_shl( mdctSpec[i], s1 ) ); /*(15 - mdctSpec_e)+ S1*/ + mdctSquareSpec[j++] = L_mult0( tmp, tmp ); /*31 - mdctSquareSpec_e*/ move32(); } } @@ -1284,7 +1286,7 @@ Word16 IGFCommonFuncsIGFConfiguration( move16(); /* interface call for reading in settings */ - hIGFInfo->bitRateIndex = IGF_MapBitRateToIndex( total_brate, bwidth, element_mode, rf_mode ); + hIGFInfo->bitRateIndex = IGF_MapBitRateToIndex( total_brate, bwidth, element_mode, rf_mode ); /*Q0*/ move16(); IF( NE_16( hIGFInfo->bitRateIndex, IGF_BITRATE_UNKNOWN ) ) @@ -1293,21 +1295,21 @@ Word16 IGFCommonFuncsIGFConfiguration( move16(); /* mapping to local values */ - sampleRate = igfMode[hIGFInfo->bitRateIndex].sampleRate; + sampleRate = igfMode[hIGFInfo->bitRateIndex].sampleRate; /*Q0*/ move32(); - frameLength = igfMode[hIGFInfo->bitRateIndex].frameLength; + frameLength = igfMode[hIGFInfo->bitRateIndex].frameLength; /*Q0*/ move16(); - igfMinFq = igfMode[hIGFInfo->bitRateIndex].igfMinFq; + igfMinFq = igfMode[hIGFInfo->bitRateIndex].igfMinFq; /*Q0*/ move16(); - maxHopsize = igfMode[hIGFInfo->bitRateIndex].maxHopsize; + maxHopsize = igfMode[hIGFInfo->bitRateIndex].maxHopsize; /*Q0*/ move16(); /* basic information */ - hIGFInfo->sampleRate = sampleRate; + hIGFInfo->sampleRate = sampleRate; /*Q0*/ move32(); - hIGFInfo->frameLength = frameLength; + hIGFInfo->frameLength = frameLength; /*Q0*/ move16(); - hIGFInfo->maxHopsize = maxHopsize; + hIGFInfo->maxHopsize = maxHopsize; /*Q0*/ move16(); hIGFInfo->nfSeedBuf[0] = 0; @@ -1366,7 +1368,7 @@ Word16 IGFCommonFuncsIGFConfiguration_ivas_fx( move16(); /* interface call for reading in settings */ - hIGFInfo->bitRateIndex = IGF_MapBitRateToIndex( total_brate, bwidth, element_mode, rf_mode ); + hIGFInfo->bitRateIndex = IGF_MapBitRateToIndex( total_brate, bwidth, element_mode, rf_mode ); /*Q0*/ IF( NE_16( hIGFInfo->bitRateIndex, IGF_BITRATE_UNKNOWN ) ) { @@ -1374,21 +1376,21 @@ Word16 IGFCommonFuncsIGFConfiguration_ivas_fx( move16(); /* mapping to local values */ - sampleRate = igfMode[hIGFInfo->bitRateIndex].sampleRate; + sampleRate = igfMode[hIGFInfo->bitRateIndex].sampleRate; /*Q0*/ move32(); - frameLength = igfMode[hIGFInfo->bitRateIndex].frameLength; + frameLength = igfMode[hIGFInfo->bitRateIndex].frameLength; /*Q0*/ move16(); - igfMinFq = igfMode[hIGFInfo->bitRateIndex].igfMinFq; + igfMinFq = igfMode[hIGFInfo->bitRateIndex].igfMinFq; /*Q0*/ move16(); - maxHopsize = igfMode[hIGFInfo->bitRateIndex].maxHopsize; + maxHopsize = igfMode[hIGFInfo->bitRateIndex].maxHopsize; /*Q0*/ move16(); /* basic information */ - hIGFInfo->sampleRate = sampleRate; + hIGFInfo->sampleRate = sampleRate; /*Q0*/ move32(); - hIGFInfo->frameLength = frameLength; + hIGFInfo->frameLength = frameLength; /*Q0*/ move16(); - hIGFInfo->maxHopsize = maxHopsize; + hIGFInfo->maxHopsize = maxHopsize; /*Q0*/ move16(); hIGFInfo->nfSeedBuf[0] = 0; move16(); @@ -1423,7 +1425,7 @@ Word16 IGFCommonFuncsIGFConfiguration_ivas_fx( igfMinFq ); } - return retValue; + return retValue; /*Q0*/ } #endif // IVAS_FLOAT_FIXED diff --git a/lib_com/index_pvq_opt_fx.c b/lib_com/index_pvq_opt_fx.c index 650b3b764..e2d2690ce 100644 --- a/lib_com/index_pvq_opt_fx.c +++ b/lib_com/index_pvq_opt_fx.c @@ -32,16 +32,16 @@ typedef void ( *NDIM_FUNCM )( Word16, Word16, UWord32, Word16 * ); * find 1/(den1*2+1) * ( num1p*num2p - num3) , * if the result is known a priori to be exactly a 32bit UWord32 *-------------------------------------------------------------------*/ -static UWord32 f_odd_exact_div_opt_fx( /* o : see Eq. */ +static UWord32 f_odd_exact_div_opt_fx( /* o Q0 : see Eq. */ UWord32 num1p, - /* i : see Eq. */ /* (2n-1) or n , i.e can be short also */ - UWord32 num2p, /* i : see Eq. */ - UWord32 num3, /* i : see Eq. */ - Word16 den1 /* i : see Eq. */ /*range [0..127] can be made to short */ + /* i : see Eq. */ /* (2n-1) or n , i.e can be short also */ + UWord32 num2p, /* i : see Eq. */ + UWord32 num3, /* i : see Eq. */ + Word16 den1 /* Q0 i : see Eq. */ /*range [0..127] can be made to short */ ) { UWord32 UL_tmp; - UL_tmp = UL_Mpy_32_32( exactdivodd[den1], UL_subNsD( UL_Mpy_32_32( num1p, num2p ), num3 ) ); + UL_tmp = UL_Mpy_32_32( exactdivodd[den1], UL_subNsD( UL_Mpy_32_32( num1p, num2p ), num3 ) ); /*Q0*/ return ( UL_tmp ); } @@ -52,7 +52,7 @@ static UWord32 f_odd_exact_div_opt_fx( /* o : see Eq. */ * returns (num1p*num2p - num3 )/ den1 * if the result is known a priori to be exactly a 32bit unsigned integer *--------------------------------------------------------------------------*/ -static UWord32 f_even_exact_div_opt_fx( /* o : see Eq. */ +static UWord32 f_even_exact_div_opt_fx( /* o Q0 : see Eq. */ UWord32 UL_num1p, /* i : see Eq. 2n-1 or n can be short input */ UWord32 UL_num2p, /* i : see Eq. range should be larger than num1p */ UWord32 UL_num3, /* i : see Eq. */ @@ -82,7 +82,7 @@ static UWord32 f_even_exact_div_opt_fx( /* o : see Eq. /* total cost 9-11 , old solution had 15-16*/ /* now use tabled modular multiplicative inverse for the odd part division */ - return UL_Mpy_32_32( UL_tmp, UL_oddfactor ); + return UL_Mpy_32_32( UL_tmp, UL_oddfactor ); /*Q0*/ } /* direct calculation functions for smaller dimensions to speed up indexing @@ -122,14 +122,14 @@ U(n,k) = 1 + A(n-1,k-1)>>1 + A(n-1,k)>>1 + A(n,k-1)>>1; A(n,k) is always odd /*-------------------------------------------------------------------* * a_three_fx() *-------------------------------------------------------------------*/ -static UWord32 a_three_fx( /* o: offset for dim 3 */ - UWord32 k_val /* i: nb unit pulses */ +static UWord32 a_three_fx( /* Q0 o: offset for dim 3 */ + UWord32 k_val /* Q0 i: nb unit pulses */ ) /* k_val may be higher than 16 bit signed */ { IF( k_val ) { /* return (ONE_U + k_val*((k_val - ONE_U) << ONE)); */ - return UL_addNsD( 1U, UL_Mpy_32_32( k_val, UL_lshl( UL_subNsD( k_val, 1U ), 1 ) ) ); + return UL_addNsD( 1U, UL_Mpy_32_32( k_val, UL_lshl( UL_subNsD( k_val, 1U ), 1 ) ) ); /*Q0*/ } ELSE { @@ -140,8 +140,8 @@ static UWord32 a_three_fx( /* o: offset for dim 3 */ /*-------------------------------------------------------------------* * a_four_fx() *-------------------------------------------------------------------*/ -static UWord32 a_four_fx( /* o: offset for dim 4 */ - UWord32 k_val /* i: nb unit pulses */ +static UWord32 a_four_fx( /* Q0 o: offset for dim 4 */ + UWord32 k_val /* Q0 i: nb unit pulses */ ) { UWord32 UL_2k; @@ -150,7 +150,7 @@ static UWord32 a_four_fx( /* o: offset for dim 4 */ /* return UDIVBY3*((k_val<0 */ @@ -361,7 +362,7 @@ static void a_u_fwd_fx( UWord32 *a_u_in, /* Note, A(n,k) always odd for k>0 , subtracted one always shifted out */ u_kp1 = UL_lshr( a_u_in[k_val_in], 1 ); - a_u_in[mem_size_m1] = UL_addNsD( 1U, UL_addNsD( u_kp1_prev, UL_addNsD( u_k_prev, u_kp1 ) ) ); + a_u_in[mem_size_m1] = UL_addNsD( 1U, UL_addNsD( u_kp1_prev, UL_addNsD( u_k_prev, u_kp1 ) ) ); /*Q0*/ move32(); return; } @@ -371,10 +372,10 @@ static void a_u_fwd_fx( UWord32 *a_u_in, * * find and return N_MPVQ(n,k) and also offsets A(n, 0 to k ) and U(n,k+1). *-------------------------------------------------------------------*/ -static UWord32 nm_h_prep_opt_fx( /* o: msize for dim */ +static UWord32 nm_h_prep_opt_fx( /* o: Q0 msize for dim */ Word16 dim_in, /* i: dimension */ Word16 k_val_in, /* i: nb unit pulses */ - UWord32 *h /* o: A/U offsets array */ + UWord32 *h /* o: Q0 A/U offsets array */ ) { Word16 mem_size_m1, k_val, tmp; @@ -408,13 +409,13 @@ static UWord32 nm_h_prep_opt_fx( /* o: msize for dim */ } a_k = h[k_val_in]; move32(); - u_kp1 = h[mem_size_m1]; + u_kp1 = h[mem_size_m1]; /*Q0*/ move32(); } ELSE { - numDsub1 = UL_deposit_l( sub( shl( dim_in, 1 ), 1 ) ); - h[2] = numDsub1; + numDsub1 = UL_deposit_l( sub( shl( dim_in, 1 ), 1 ) ); /*Q0*/ + h[2] = numDsub1; /*Q0*/ move32(); /* interleaved " odd, even [odd]" divisor calls */ @@ -436,7 +437,7 @@ static UWord32 nm_h_prep_opt_fx( /* o: msize for dim */ IF( tmp > 0 ) { /* k_val_in = 3,4, 5,6, 7 ... */ - end_loop = mem_size_m1; + end_loop = mem_size_m1; /*Q0*/ move16(); add_last_odd = s_and( k_val_in, 0x1 ); move16(); /* odd -> 0x00100*/ @@ -450,15 +451,15 @@ static UWord32 nm_h_prep_opt_fx( /* o: msize for dim */ /* the optimized non broken loop k=(3,4)(5,6)...(odd,even)*/ /* A(n,k) = A(n,k-2) + ((2*n-1)*A(n,k-1)-A(n,k-2)) /(k-1) */ /* first odd k, even divisor */ - h_saveB = UL_addNsD( h_saveB, f_even_exact_div_opt_fx( numDsub1, h_saveA, h_saveB, sub( k_val, 1 ) ) ); - h[k_val] = h_saveB; + h_saveB = UL_addNsD( h_saveB, f_even_exact_div_opt_fx( numDsub1, h_saveA, h_saveB, sub( k_val, 1 ) ) ); /*Q0*/ + h[k_val] = h_saveB; /*Q0*/ move32(); /* next even k, odd divisor */ /*k_val++; */ - h_saveA = UL_addNsD( h_saveA, f_odd_exact_div_opt_fx( numDsub1, h_saveB, h_saveA, shr( k_val, 1 ) ) ); - k_val++; /* ptr incr */ - h[k_val] = h_saveA; + h_saveA = UL_addNsD( h_saveA, f_odd_exact_div_opt_fx( numDsub1, h_saveB, h_saveA, shr( k_val, 1 ) ) ); /*Q0*/ + k_val++; /* ptr incr */ + h[k_val] = h_saveA; /*Q0*/ move32(); } } @@ -474,13 +475,13 @@ static UWord32 nm_h_prep_opt_fx( /* o: msize for dim */ /* always do the last (k+1) recursion based on U(n,k+1) = func( A(n-2,k+1), A(n-1,k+1) ) */ a_k = h[k_val_in]; move32(); - u_kp1 = direct_row_A2U_rec_calc_fx( dim_in, mem_size_m1, h[sub( mem_size_m1, 2 )], a_k ); - h[mem_size_m1] = u_kp1; + u_kp1 = direct_row_A2U_rec_calc_fx( dim_in, mem_size_m1, h[mem_size_m1 - 2], a_k ); /*Q0*/ + h[mem_size_m1] = u_kp1; /*Q0*/ move32(); } /* N_MPVQ(n,k) = 1 + U(n,k+1) + U(n,k) = 1 + U(n,k+1) + floor(A(n,k))/2) ; */ /* as A(n,k) always odd */ - return ( UL_addNsD( 1U, UL_addNsD( u_kp1, UL_lshr( a_k, 1 ) ) ) ); + return ( UL_addNsD( 1U, UL_addNsD( u_kp1, UL_lshr( a_k, 1 ) ) ) ); /*Q0*/ } /* @@ -488,11 +489,11 @@ static UWord32 nm_h_prep_opt_fx( /* o: msize for dim */ find first offset in range 0..k_val_in that is less than ind_in using a tree search with direct function calls [ or memory iteration] */ -static Word16 find_amp_split_offset_func_mem_fx( /* o: found k_value */ +static Word16 find_amp_split_offset_func_mem_fx( /* o: Q0 found k_value */ UWord32 ind_in, Word16 high, /* i: k_val_in (high bound) */ H_FUNCM h_func_ptr, /* i: offset function pointer */ - UWord32 *UL_tmp_offset ) /* o: offset found */ + UWord32 *UL_tmp_offset ) /* o: Q0 offset found */ { Word16 not_ready, low, k_test = 0; move16(); @@ -512,7 +513,7 @@ static Word16 find_amp_split_offset_func_mem_fx( /* o: found k_value */ *UL_tmp_offset = ( *h_func_ptr )( UL_deposit_l( k_test ) ); /* call direct A offset-function */ move32(); - UL_tmp = UL_subNs( *UL_tmp_offset, ind_in, &sgn ); + UL_tmp = UL_subNs( *UL_tmp_offset, ind_in, &sgn ); /*Q0*/ IF( sgn ) { /* (*tmp_offset < ind_in) */ @@ -535,7 +536,7 @@ static Word16 find_amp_split_offset_func_mem_fx( /* o: found k_value */ } } } - return k_test; + return k_test; /*Q0*/ } /* @@ -554,10 +555,10 @@ static Word16 get_lead_sign_fx( UWord32 *ind ) leading_sign = -1; move16(); } - ( *ind ) = UL_lshr( *ind, 1 ); + ( *ind ) = UL_lshr( *ind, 1 ); /*Q0*/ move32(); - return leading_sign; + return leading_sign; /*Q0*/ } /*-------------------------------------------------------------------* @@ -589,7 +590,7 @@ static void mind2vec_two_fx( Word16 k_val_in, /* i: nb unit pulses */ Word16 leading_sign, /* i: leading sign -1,0, 1 */ UWord32 ind_in, /* i: index */ - Word16 *vec_out /* o: pulse train */ + Word16 *vec_out /* o: Q0 pulse train */ ) { UWord32 UL_ind_tmp; @@ -609,7 +610,7 @@ static void mind2vec_two_fx( ELSE { UL_ind_tmp = UL_subNsD( ind_in, 1U ); - val1 = (Word16) u_extract_l( UL_addNsD( 1U, UL_lshr( UL_ind_tmp, 1 ) ) ); /*(Word16) to avoid warning */ + val1 = (Word16) u_extract_l( UL_addNsD( 1U, UL_lshr( UL_ind_tmp, 1 ) ) ); /*(Word16) to avoid warning */ /*Q0*/ mind2vec_one_fx( sub( k_val_in, val1 ), leading_sign, ind_in, vec_out ); @@ -617,7 +618,7 @@ static void mind2vec_two_fx( { val1 = negate( val1 ); /*single basicop */ } - vec_out[1] = val1; + vec_out[1] = val1; /*Q0*/ move16(); } } @@ -631,11 +632,11 @@ static Word16 setval_update_sign_fx( Word16 k_delta, IF( k_delta != 0 ) { mind2vec_one_fx( k_delta, *leading_sign, *ind_in, vec_out ); - *leading_sign = get_lead_sign_fx( ind_in ); + *leading_sign = get_lead_sign_fx( ind_in ); /*Q0*/ move16(); - k_max_local = sub( k_max_local, k_delta ); + k_max_local = sub( k_max_local, k_delta ); /*Q0*/ } - return k_max_local; + return k_max_local; /*Q0*/ } /*-------------------------------------------------------------------* @@ -645,7 +646,7 @@ static void mind2vec_three_fx( Word16 k_max_local, /* i: nb unit pulses */ Word16 leading_sign, /* i: leading sign */ UWord32 ind_in, /* i: index */ - Word16 *vec_out /* o: pulse train */ + Word16 *vec_out /* Q0 o: pulse train */ ) { /* @@ -658,9 +659,9 @@ static void mind2vec_three_fx( IF( ind_in != 0 ) { /* acc_val=idivide(uint32(floor(real(sqrt(double(ind)*2-1))))+1, 2); % (exact_integer_sqrt((ind*2-1) +1)*2 */ - acc_val = lshr( add( 1, getSqrtWord32( UL_subNsD( UL_lshl( ind_in, 1 ), 1U ) ) ), 1 ); - k_delta = sub( k_max_local, acc_val ); - ind_in = UL_subNsD( ind_in, a_three_fx( UL_deposit_l( acc_val ) ) ); /* remove amplitude offset A(3,k_acc) */ + acc_val = lshr( add( 1, getSqrtWord32( UL_subNsD( UL_lshl( ind_in, 1 ), 1U ) ) ), 1 ); /*Q0*/ + k_delta = sub( k_max_local, acc_val ); /*Q0*/ + ind_in = UL_subNsD( ind_in, a_three_fx( UL_deposit_l( acc_val ) ) ); /* remove amplitude offset A(3,k_acc) */ k_max_local = setval_update_sign_fx( k_delta, k_max_local, &leading_sign, &ind_in, vec_out ); @@ -685,7 +686,7 @@ static void mind2vec_direct_fx( UWord32 ind, /* i: index */ H_FUNCM h_func_ptr, /* i : offset function */ NDIM_FUNCM nd_func_ptr, /* i : next dimension function */ - Word16 *vec_out /* o: pulse train */ + Word16 *vec_out /* Q0 o: pulse train */ ) { @@ -717,7 +718,7 @@ static void mind2vec_four_fx( Word16 k_val_in, /* i: nb unit pulses */ Word16 leading_sign, /* i: leading sign */ UWord32 ind_in, /* i: index */ - Word16 *vec_out /* o: pulse train */ + Word16 *vec_out /* Q0 o: pulse train */ ) { mind2vec_direct_fx( k_val_in, leading_sign, ind_in, a_four_fx, mind2vec_three_fx, vec_out ); @@ -746,7 +747,7 @@ static void mind2vec_fx( Word16 k_max_local, /* i: nb unit pulses */ Word16 leading_sign, /* i: leading sign */ UWord32 ind, /* i: index */ - Word16 *vec_out, /* o: pulse train */ + Word16 *vec_out, /* Q0 o: pulse train */ UWord32 *h_in /* i: offset vector A=1+2U */ ) { @@ -785,7 +786,7 @@ static void mind2vec_fx( BREAK; /* "fast" recursion exit*/ } - k_max_local = setval_update_sign_fx( k_delta, k_max_local, &leading_sign, &ind, &vec_out[pos] ); + k_max_local = setval_update_sign_fx( k_delta, k_max_local, &leading_sign, &ind, &vec_out[pos] ); /*Q0*/ /* move from A(n,kmax) to A(n-1, k_max_local), */ a_bwd_fx( h_in, add( k_max_local, 1 ) ); /* [0 ... k_max_local], no need to update U(n,k_max_local+1) in index decoding */ @@ -803,7 +804,7 @@ static void mind2vec_fx( PvqEntry get_size_mpvq_calc_offset_fx( /* o : size, dim, k_val */ Word16 dim_in, /* i : dimension */ Word16 k_val_in, /* i : nb unit pulses */ - UWord32 *h_mem /* o : offsets */ + UWord32 *h_mem /* Q0 o : offsets */ ) { PvqEntry entry; @@ -819,16 +820,16 @@ PvqEntry get_size_mpvq_calc_offset_fx( /* o : size, dim, k_val IF( GT_16( dim_in, N_OPT_FX ) ) /* non-direct solutions, use A+U relation */ { - entry.size = nm_h_prep_opt_fx( entry.dim, entry.k_val, h_mem ); + entry.size = nm_h_prep_opt_fx( entry.dim, entry.k_val, h_mem ); /*Q0*/ move32(); } ELSE { - entry.size = direct_msize_fx( dim_in, entry.k_val ); + entry.size = direct_msize_fx( dim_in, entry.k_val ); /*Q0*/ move32(); } - return entry; + return entry; /*Q0*/ } /*-------------------------------------------------------------------* @@ -837,7 +838,7 @@ PvqEntry get_size_mpvq_calc_offset_fx( /* o : size, dim, k_val void mpvq_decode_vec_fx( /* o : void */ const PvqEntry *entry, /* i : sign_ind, index, dim, k_val */ UWord32 *h_mem, /* i : A/U offsets */ - Word16 *vec_out /* o : pulse train */ + Word16 *vec_out /* Q0 o : pulse train */ ) { Word16 i, leading_sign; @@ -880,9 +881,9 @@ void mpvq_decode_vec_fx( /* o : void static void vec2mind_one_fx( const Word16 *vec_in, /* i : PVQ pulse train */ Word16 *k_val_out_ptr, - /* o : number of unit pulses */ /* parameter needed as it is used in a function array */ - UWord32 *next_sign_ind, /* i/o: next sign ind */ - UWord32 *ind /* o: MPVQ index */ + /* Q0 o : number of unit pulses */ /* parameter needed as it is used in a function array */ + UWord32 *next_sign_ind, /* i/o: next sign ind */ + UWord32 *ind /* Q0 o: MPVQ index */ ) { *ind = (Word32) ( *k_val_out_ptr ); /* dummy assignment to avoid gcc "unused parameter" warning for *k_val_out_ptr, i.e no move32 needed() */ @@ -894,7 +895,7 @@ static void vec2mind_one_fx( move32(); if ( *vec_in < 0 ) { - *next_sign_ind = UL_deposit_l( 1 ); /*single basicop */ + *next_sign_ind = UL_deposit_l( 1 ); /*single basicop */ /*Q0*/ move32(); } return; @@ -905,9 +906,9 @@ static void vec2mind_one_fx( *-------------------------------------------------------------------*/ static void vec2mind_two_fx( const Word16 *vec_in, /* i : PVQ pulse train */ - Word16 *k_val_out_ptr, /* o : number of unit pulses */ - UWord32 *next_sign_ind, /* i/o: next sign ind */ - UWord32 *ind /* o: MPVQ index */ + Word16 *k_val_out_ptr, /* Q0 o : number of unit pulses */ + UWord32 *next_sign_ind, /* Q0 i/o: next sign ind */ + UWord32 *ind /* Q0 o: MPVQ index */ ) { UWord32 lead_sign_ind_add; @@ -928,8 +929,8 @@ static void vec2mind_two_fx( IF( abs01 != 0 ) { sptr = 0; - move16(); /*used as ptr to vec0 or vec1 value */ - *next_sign_ind = UL_deposit_l( sptr ); + move16(); /*used as ptr to vec0 or vec1 value */ + *next_sign_ind = UL_deposit_l( sptr ); /*Q0*/ move32(); test(); @@ -943,7 +944,7 @@ static void vec2mind_two_fx( { lead_sign_ind_add = UL_deposit_l( 2 ); /* single op */ } - *ind = UL_addNsD( UL_deposit_l( (UWord16) lshl( sub( abs1, 1 ), 1 ) ), lead_sign_ind_add ); + *ind = UL_addNsD( UL_deposit_l( (UWord16) lshl( sub( abs1, 1 ), 1 ) ), lead_sign_ind_add ); /*Q0*/ move32(); } ELSE @@ -952,7 +953,7 @@ static void vec2mind_two_fx( IF( abs0 == 0 ) { /* [ 0 KMAX]*/ - *ind = UL_deposit_l( (UWord16) sub( lshl( abs1, 1 ), 1 ) ); + *ind = UL_deposit_l( (UWord16) sub( lshl( abs1, 1 ), 1 ) ); /*Q0*/ move32(); sptr = 1; move16(); @@ -962,7 +963,7 @@ static void vec2mind_two_fx( /* *next_sign_ind= (unsigned int)(vec_in[*next_sign_ind]<0); */ if ( vec_in[sptr] < 0 ) { - *next_sign_ind = UL_deposit_l( 1 ); /*single instruction */ + *next_sign_ind = UL_deposit_l( 1 ); /*single instruction */ /*Q0*/ move32(); } } @@ -1004,9 +1005,9 @@ static void enc_push_sign( Word16 val, UWord32 *next_sign_ind, UWord32 *index ) static void vec2mind_gen345_fx( const Word16 *vec_in, /* i : PVQ abs pulse train */ - Word16 *k_val_out_ptr, /* o : number of unit pulses */ + Word16 *k_val_out_ptr, /* Q0 o : number of unit pulses */ UWord32 *next_sign_ind, /* i/o: next sign ind */ - UWord32 *index, /* o: MPVQ index */ + UWord32 *index, /* Q0 o: MPVQ index */ VEC2INDFUNCM vec2indfunc_ptr, /* i: */ H_FUNCM a_func_ptr /*i: offset function */ ) @@ -1020,11 +1021,11 @@ static void vec2mind_gen345_fx( enc_push_sign( tmp_val, next_sign_ind, index ); - move32(); /* adaptive function call setup */ - *index = UL_addNsD( *index, ( *a_func_ptr )( UL_deposit_l( *k_val_out_ptr ) ) ); + move32(); /* adaptive function call setup */ + *index = UL_addNsD( *index, ( *a_func_ptr )( UL_deposit_l( *k_val_out_ptr ) ) ); /*Q0*/ move32(); - *k_val_out_ptr = add( *k_val_out_ptr, abs_s( tmp_val ) ); + *k_val_out_ptr = add( *k_val_out_ptr, abs_s( tmp_val ) ); /*Q0*/ move16(); return; @@ -1035,9 +1036,9 @@ static void vec2mind_gen345_fx( *-------------------------------------------------------------------*/ static void vec2mind_three_fx( const Word16 *vec_in, /* i : PVQ pulse train */ - Word16 *k_val_out_ptr, /* o : number of unit pulses */ - UWord32 *next_sign_ind, /* i/o: next sign ind */ - UWord32 *index /* o: MPVQ index */ + Word16 *k_val_out_ptr, /* Q0 o : number of unit pulses */ + UWord32 *next_sign_ind, /* Q0 i/o: next sign ind */ + UWord32 *index /* Q0 o: MPVQ index */ ) { vec2mind_gen345_fx( vec_in, k_val_out_ptr, next_sign_ind, index, vec2mind_two_fx, a_three_fx ); @@ -1050,9 +1051,9 @@ static void vec2mind_three_fx( *-------------------------------------------------------------------*/ static void vec2mind_four_fx( const Word16 *vec_in, /* i : PVQ pulse train */ - Word16 *k_val_out_ptr, /* o : number of unit pulses */ - UWord32 *next_sign_ind, /* i/o: next sign ind */ - UWord32 *index /* o: MPVQ index */ + Word16 *k_val_out_ptr, /* Q0 o : number of unit pulses */ + UWord32 *next_sign_ind, /* Q0 i/o: next sign ind */ + UWord32 *index /* Q0 o: MPVQ index */ ) { vec2mind_gen345_fx( vec_in, k_val_out_ptr, next_sign_ind, index, vec2mind_three_fx, a_four_fx ); @@ -1064,9 +1065,9 @@ static void vec2mind_four_fx( *-------------------------------------------------------------------*/ static void vec2mind_five_fx( const Word16 *vec_in, /* i : PVQ abs pulse train */ - Word16 *k_val_out_ptr, /* o : number of unit pulses */ - UWord32 *next_sign_ind, /* i/o: next sign ind */ - UWord32 *index /* o: MPVQ index */ + Word16 *k_val_out_ptr, /* Q0 o : number of unit pulses */ + UWord32 *next_sign_ind, /* Q0 i/o: next sign ind */ + UWord32 *index /* Q0 o: MPVQ index */ ) { vec2mind_gen345_fx( vec_in, k_val_out_ptr, next_sign_ind, index, vec2mind_four_fx, a_five_fx ); @@ -1079,10 +1080,10 @@ static void vec2mind_five_fx( static void vec2mind_fx( Word16 dim_in, /* i : dim */ Word16 k_val_in, /* i : number of unit pulses */ const Word16 *vec_in, /* i : PVQ pulse train */ - UWord32 *next_sign_ind, /* o : pushed leading sign */ - UWord32 *index, /* o : MPVQ index */ - UWord32 *N_MPVQ_ptr, /* o : size(N_MPVQ(dim,K_val_in))*/ - UWord32 *h_mem ) /* o : offsets */ + UWord32 *next_sign_ind, /* Q0 o : pushed leading sign */ + UWord32 *index, /* Q0 o : MPVQ index */ + UWord32 *N_MPVQ_ptr, /* Q0 o : size(N_MPVQ(dim,K_val_in))*/ + UWord32 *h_mem ) /* Q0 o : offsets */ { Word16 pos, mem_size_m1, k_val_acc, tmp_val; UWord32 tmp_h; @@ -1101,10 +1102,10 @@ static void vec2mind_fx( Word16 dim_in, /* i : dim */ mem_size_m1 = add( k_val_in, 1 ); - *next_sign_ind = UL_deposit_h( SIGNBIT_SHRT_FX ); /* highest bit set signals no sign found yet, should always be 0 or 1 out, */ + *next_sign_ind = UL_deposit_h( SIGNBIT_SHRT_FX ); /* highest bit set signals no sign found yet, should always be 0 or 1 out, */ /*Q0*/ move32(); - pos = sub( dim_in, 2 ); /* adress 2nd last sample */ + pos = sub( dim_in, 2 ); /* adress 2nd last sample */ /*Q0*/ vec2mind_two_fx( &vec_in[pos], &k_val_acc, next_sign_ind, index ); initOffsets_fx( 3, h_mem, k_val_in ); /* start recursions at 3rd sample */ @@ -1117,11 +1118,11 @@ static void vec2mind_fx( Word16 dim_in, /* i : dim enc_push_sign( tmp_val, next_sign_ind, index ); /* now add indexing offset up to this reverse (r_l) accumulated amplitude point */ - *index = UL_addNsD( *index, tmp_h ); /* k_val_acc==0 ==>0 */ + *index = UL_addNsD( *index, tmp_h ); /* k_val_acc==0 ==>0 */ /*Q0*/ move32(); - /* k_val_acc = k_val_acc + vec_abs[pos];*/ /* now increase acc k value for next N */ - k_val_acc = add( k_val_acc, abs_s( tmp_val ) ); + /* k_val_acc = k_val_acc + vec_abs[pos];*/ /* now increase acc k value for next N */ + k_val_acc = add( k_val_acc, abs_s( tmp_val ) ); /*Q0*/ IF( pos != 0 ) { @@ -1129,14 +1130,14 @@ static void vec2mind_fx( Word16 dim_in, /* i : dim /* update A(n,k=1:k_val_in) and U(n,k_val_in+1) */ /* NB here (k_val_in + 2 elements always has to be updated */ } - tmp_h = UL_addNsD( h_mem[k_val_acc], 0U ); + tmp_h = UL_addNsD( h_mem[k_val_acc], 0U ); /*Q0*/ } /* size is needed for the subseqent arithmetic encoding/transmission of the index. use relation N_MPVQ(n,K) = 1 + (A(n, K)-1)/2 + U(n, 1 + K) = N_MPVQ(n,K) = 1 + (A(n, K)>>1) + U(n, 1 + K) , as A(n,K) is odd) */ - *N_MPVQ_ptr = UL_addNsD( 1U, UL_addNsD( UL_lshr( tmp_h, 1 ), h_mem[mem_size_m1] ) ); - move32(); /* calc total size */ + *N_MPVQ_ptr = UL_addNsD( 1U, UL_addNsD( UL_lshr( tmp_h, 1 ), h_mem[mem_size_m1] ) ); /*Q0*/ + move32(); /* calc total size */ return; } @@ -1147,7 +1148,7 @@ static void vec2mind_fx( Word16 dim_in, /* i : dim * returns struct with lead sign index, MPVQ-index, dim and N_MPVQ size *-------------------------------------------------------------------------*/ -PvqEntry mpvq_encode_vec_fx( /* o : leading_sign_index, index, size, k_val */ +PvqEntry mpvq_encode_vec_fx( /* Q0 o : leading_sign_index, index, size, k_val */ const Word16 *vec_in, /* i : signed pulse train */ Word16 dim_in, /* i : dimension */ Word16 k_val_local /* i : nb unit pulses */ @@ -1160,9 +1161,9 @@ PvqEntry mpvq_encode_vec_fx( /* o : leading_sign_index, in VEC2INDFUNCM vec2mind_f[1 + N_OPT_FX] = { (VEC2INDFUNCM) NULL, vec2mind_one_fx, vec2mind_two_fx, vec2mind_three_fx, vec2mind_four_fx, vec2mind_five_fx }; - result.k_val = k_val_local; + result.k_val = k_val_local; /*Q0*/ move16(); - result.dim = dim_in; + result.dim = dim_in; /*Q0*/ move16(); /* NB , k_val_local may be changed in some sub encoding routines */ IF( GT_16( dim_in, N_OPT_FX ) ) @@ -1174,9 +1175,9 @@ PvqEntry mpvq_encode_vec_fx( /* o : leading_sign_index, in { move32(); /* adaptive function ptr setup */ ( vec2mind_f[dim_in] )( vec_in, &k_val_local, &lead_sign_ind, &result.index ); - result.size = direct_msize_fx( dim_in, k_val_local ); + result.size = direct_msize_fx( dim_in, k_val_local ); /*Q0*/ } - result.lead_sign_ind = u_extract_l( lead_sign_ind ); + result.lead_sign_ind = u_extract_l( lead_sign_ind ); /*Q0*/ move16(); return result; diff --git a/lib_com/int_lsp.c b/lib_com/int_lsp.c index 522f62fe0..0adb332fa 100644 --- a/lib_com/int_lsp.c +++ b/lib_com/int_lsp.c @@ -98,12 +98,12 @@ void int_lsp( void int_lsp_fx( const Word16 L_frame, /* i : length of the frame */ - const Word16 lsp_old[], /* i : LSPs from past frame */ - const Word16 lsp_new[], /* i : LSPs from present frame */ - Word16 *Aq, /* o : LP coefficients in both subframes */ + const Word16 lsp_old[], /* i : Q15 LSPs from past frame */ + const Word16 lsp_new[], /* i : Q15 LSPs from present frame */ + Word16 *Aq, /* o : Q12 LP coefficients in both subframes */ const Word16 m, /* i : order of LP filter */ - const Word16 *int_coeffs, /* i : interpolation coefficients */ - const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ + const Word16 *int_coeffs, /* i : Q15 interpolation coefficients */ + const Word16 Opt_AMR_WB /* i : Q0 flag indicating AMR-WB IO mode */ ) { Word16 lsp[M], fnew, fold; @@ -116,12 +116,12 @@ void int_lsp_fx( IF( EQ_16( L_frame, L_FRAME ) ) { - pt_int_coeffs = int_coeffs; + pt_int_coeffs = int_coeffs; /*Q15*/ move16(); } ELSE /* L_frame == L_FRAME16k */ { - pt_int_coeffs = interpol_frac_16k_fx; + pt_int_coeffs = interpol_frac_16k_fx; /*Q15*/ } FOR( k = 0; k < tmp; k++ ) { @@ -134,13 +134,13 @@ void int_lsp_fx( } FOR( i = 0; i < m; i++ ) { - L_tmp = L_mult( lsp_old[i], fold ); - L_tmp = L_mac( L_tmp, lsp_new[i], fnew ); + L_tmp = L_mult( lsp_old[i], fold ); /*Q31*/ + L_tmp = L_mac( L_tmp, lsp_new[i], fnew ); /*Q31*/ IF( fold == 0 ) { L_tmp = L_mac( L_tmp, lsp_new[i], 1 ); /* 'fnew' should have been 32768 */ } - lsp[i] = round_fx( L_tmp ); + lsp[i] = round_fx( L_tmp ); /*Q15*/ } IF( Opt_AMR_WB ) { @@ -257,38 +257,38 @@ void int_lsp4_fx( { IF( EQ_16( relax_prev_lsf_interp, 1 ) ) { - pt_int_coeffs = interpol_frac_mid_relaxprev_12k8_fx; + pt_int_coeffs = interpol_frac_mid_relaxprev_12k8_fx; /*Q15*/ } ELSE IF( EQ_16( relax_prev_lsf_interp, 2 ) ) { - pt_int_coeffs = interpol_frac_mid_FEC_fx; + pt_int_coeffs = interpol_frac_mid_FEC_fx; /*Q15*/ } ELSE IF( EQ_16( relax_prev_lsf_interp, -1 ) ) { - pt_int_coeffs = interpol_frac_mid_relaxprev_pred_12k8_fx; + pt_int_coeffs = interpol_frac_mid_relaxprev_pred_12k8_fx; /*Q15*/ } ELSE { - pt_int_coeffs = interpol_frac_mid_fx; + pt_int_coeffs = interpol_frac_mid_fx; /*Q15*/ } } ELSE /* L_frame == L_FRAME16k */ { IF( EQ_16( relax_prev_lsf_interp, 1 ) ) { - pt_int_coeffs = interpol_frac_mid_relaxprev_16k_fx; + pt_int_coeffs = interpol_frac_mid_relaxprev_16k_fx; /*Q15*/ } ELSE IF( EQ_16( relax_prev_lsf_interp, 2 ) ) { - pt_int_coeffs = interpol_frac_mid_16k_FEC_fx; + pt_int_coeffs = interpol_frac_mid_16k_FEC_fx; /*Q15*/ } ELSE IF( EQ_16( relax_prev_lsf_interp, -1 ) ) { - pt_int_coeffs = interpol_frac_mid_relaxprev_pred_16k_fx; + pt_int_coeffs = interpol_frac_mid_relaxprev_pred_16k_fx; /*Q15*/ } ELSE { - pt_int_coeffs = interpol_frac_mid_16k_fx; + pt_int_coeffs = interpol_frac_mid_16k_fx; /*Q15*/ } } k = sub( shr( L_frame, 6 ), 1 ); @@ -302,11 +302,9 @@ void int_lsp4_fx( move16(); } pt_int_coeffs += 3; - move16(); E_LPC_f_lsp_a_conversion( lsp, Aq, m ); Aq += add( m, 1 ); - move16(); } /* Last subframe */ @@ -334,42 +332,42 @@ void int_lsp4_ivas_fx( { IF( EQ_16( relax_prev_lsf_interp, 1 ) ) { - pt_int_coeffs = interpol_frac_mid_relaxprev_12k8_fx; + pt_int_coeffs = interpol_frac_mid_relaxprev_12k8_fx; /*Q15*/ } ELSE IF( EQ_16( relax_prev_lsf_interp, 2 ) ) { - pt_int_coeffs = interpol_frac_mid_FEC_fx; + pt_int_coeffs = interpol_frac_mid_FEC_fx; /*Q15*/ } ELSE IF( EQ_16( relax_prev_lsf_interp, -1 ) ) { - pt_int_coeffs = interpol_frac_mid_relaxprev_pred_12k8_fx; + pt_int_coeffs = interpol_frac_mid_relaxprev_pred_12k8_fx; /*Q15*/ } ELSE IF( EQ_16( relax_prev_lsf_interp, -2 ) ) { - pt_int_coeffs = interpol_frac2_mid_fx; + pt_int_coeffs = interpol_frac2_mid_fx; /*Q15*/ } ELSE { - pt_int_coeffs = interpol_frac_mid_fx; + pt_int_coeffs = interpol_frac_mid_fx; /*Q15*/ } } ELSE /* L_frame == L_FRAME16k */ { IF( EQ_16( relax_prev_lsf_interp, 1 ) ) { - pt_int_coeffs = interpol_frac_mid_relaxprev_16k_fx; + pt_int_coeffs = interpol_frac_mid_relaxprev_16k_fx; /*Q15*/ } ELSE IF( EQ_16( relax_prev_lsf_interp, 2 ) ) { - pt_int_coeffs = interpol_frac_mid_16k_FEC_fx; + pt_int_coeffs = interpol_frac_mid_16k_FEC_fx; /*Q15*/ } ELSE IF( EQ_16( relax_prev_lsf_interp, -1 ) ) { - pt_int_coeffs = interpol_frac_mid_relaxprev_pred_16k_fx; + pt_int_coeffs = interpol_frac_mid_relaxprev_pred_16k_fx; /*Q15*/ } ELSE { - pt_int_coeffs = interpol_frac_mid_16k_fx; + pt_int_coeffs = interpol_frac_mid_16k_fx; /*Q15*/ } } k = sub( shr( L_frame, 6 ), 1 ); diff --git a/lib_com/interpol.c b/lib_com/interpol.c index d063baadc..67292ad17 100644 --- a/lib_com/interpol.c +++ b/lib_com/interpol.c @@ -79,7 +79,7 @@ float interpolation( return s; } -Word32 Interpol_lc_fx( /* o : interpolated value Qx+16 */ +Word32 Interpol_lc_fx( /* o : interpolated value Q15 */ const Word16 *x, /* i : input vector Q0 */ const Word16 *win, /* i : interpolation window Q14 */ const Word16 frac, /* i : fraction (0..up_samp) Q0 */ @@ -100,17 +100,17 @@ Word32 Interpol_lc_fx( /* o : interpolated value FOR( i = 0; i < nb_coef; i++ ) { /* Using L_mac0 limits the risk of saturation during the loop, saturation may occures after the loop */ - L_sum64 = W_mac0_16_16( L_sum64, *x, *c1 ); + L_sum64 = W_mac0_16_16( L_sum64, *x, *c1 ); /*Q14*/ --x; - L_sum64 = W_mac0_16_16( L_sum64, *x2, *c2 ); + L_sum64 = W_mac0_16_16( L_sum64, *x2, *c2 ); /*Q14*/ ++x2; c2 += up_samp; /* move16() not needed, since the coefficient can be rearrange in bit exact way */ c1 += up_samp; } - L_sum = W_sat_l( L_sum64 ); + L_sum = W_sat_l( L_sum64 ); /*Q14*/ } #ifdef BASOP_NOGLOB - L_sum = L_shl_sat( L_sum, 1 ); + L_sum = L_shl_sat( L_sum, 1 ); /*Q15*/ #else L_sum = L_shl( L_sum, 1 ); #endif @@ -118,9 +118,9 @@ Word32 Interpol_lc_fx( /* o : interpolated value } -Word16 Interpol_4( /* o : interpolated value */ - Word16 *x, /* i : input vector */ - Word16 frac /* i : fraction (-4..+3) */ +Word16 Interpol_4( /* Qx o : interpolated value */ + Word16 *x, /* Qx i : input vector */ + Word16 frac /* Q0 i : fraction (-4..+3) */ ) { Word16 i; @@ -131,7 +131,7 @@ Word16 Interpol_4( /* o : interpolated value */ x = x - L_INTERPOL1 + 1; - L_sum = L_mult( x[0], ( inter4_1_fx + UP_SAMP - 1 )[-frac] ); + L_sum = L_mult( x[0], ( inter4_1_fx + UP_SAMP - 1 )[-frac] ); /*Qx+14+1*/ FOR( i = 1; i < 2 * L_INTERPOL1; i++ ) { /* @@ -140,19 +140,19 @@ Word16 Interpol_4( /* o : interpolated value */ * so that the values needed are contiguous. */ frac -= UP_SAMP; - L_sum = L_mac( L_sum, x[i], ( inter4_1_fx + UP_SAMP - 1 )[-frac] ); + L_sum = L_mac( L_sum, x[i], ( inter4_1_fx + UP_SAMP - 1 )[-frac] ); /*Qx+14+1*/ } BASOP_SATURATE_WARNING_OFF_EVS /* Here, saturation might occur by intention */ #ifdef BASOP_NOGLOB - L_sum = L_shl_o( L_sum, 1, &Overflow ); -#else /* BASOP_NOGLOB */ + L_sum = L_shl_o( L_sum, 1, &Overflow ); /*Qx+14+2*/ +#else /* BASOP_NOGLOB */ L_sum = L_shl( L_sum, 1 ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ BASOP_SATURATE_WARNING_ON_EVS #ifdef BASOP_NOGLOB - return round_fx_o( L_sum, &Overflow ); -#else /* BASOP_NOGLOB */ + return round_fx_o( L_sum, &Overflow ); /*Qx*/ +#else /* BASOP_NOGLOB */ return round_fx( L_sum ); #endif } diff --git a/lib_com/isf_dec_amr_wb_fx.c b/lib_com/isf_dec_amr_wb_fx.c index 54ab5c16f..3b98b1346 100644 --- a/lib_com/isf_dec_amr_wb_fx.c +++ b/lib_com/isf_dec_amr_wb_fx.c @@ -48,9 +48,9 @@ void E_LPC_isf_isp_conversion( const Word16 isf[], Word16 isp[], const Word16 m void isf_dec_amr_wb_fx( Decoder_State *st, /* i/o: State structure */ - Word16 *Aq, /* o : quantized A(z) for 4 subframes */ - Word16 *isf_new, /* o : de-quantized ISF vector */ - Word16 *isp_new /* o : de-quantized ISP vector */ + Word16 *Aq, /* Q12 o : quantized A(z) for 4 subframes */ + Word16 *isf_new, /* Qlog2(2.56) o : de-quantized ISF vector */ + Word16 *isp_new /* Q15 o : de-quantized ISP vector */ ) { Word16 i; @@ -135,9 +135,9 @@ void isf_dec_amr_wb_fx( FOR( i = 0; i < M; i++ ) { /*st->lsf_adaptive_mean[i] = (st->lsfoldbfi1[i] + st->lsfoldbfi0[i] + isf_new[i]) / 3;*/ - L_tmp = L_mult( st->lsfoldbfi1_fx[i], 10923 ); - L_tmp = L_mac( L_tmp, st->lsfoldbfi0_fx[i], 10923 ); - st->lsf_adaptive_mean_fx[i] = round_fx( L_mac( L_tmp, isf_new[i], 10923 ) ); + L_tmp = L_mult( st->lsfoldbfi1_fx[i], 10923 /*0.3333 in Q15*/ ); /*Q2.56+15+1*/ + L_tmp = L_mac( L_tmp, st->lsfoldbfi0_fx[i], 10923 /*0.3333 in Q15*/ ); /*Q2.56+15+1*/ + st->lsf_adaptive_mean_fx[i] = round_fx( L_mac( L_tmp, isf_new[i], 10923 /*0.3333 in Q15*/ ) ); /*Q2.56*/ } /*-------------------------------------------------------------------------------------* @@ -161,12 +161,12 @@ void isf_dec_amr_wb_fx( IF( st->element_mode == EVS_MONO ) { - st->stab_fac_fx = lsf_stab_fx( isf_new, st->lsf_old_fx, 1, st->L_frame ); + st->stab_fac_fx = lsf_stab_fx( isf_new, st->lsf_old_fx, 1, st->L_frame ); /*Q15*/ move16(); } ELSE { - st->stab_fac_fx = lsf_stab_ivas_fx( isf_new, st->lsf_old_fx, 1, st->L_frame ); + st->stab_fac_fx = lsf_stab_ivas_fx( isf_new, st->lsf_old_fx, 1, st->L_frame ); /*Q15*/ move16(); } @@ -180,37 +180,37 @@ void isf_dec_amr_wb_fx( *-------------------------------------------------------------------*/ void disf_ns_28b_fx( - Word16 *indice, /* i : quantized indices (use indice[0] = -1 in the decoder) */ - Word16 *isf_q /* o : ISF in the frequency domain (0..6400) */ + Word16 *indice, /* Q0 / i : quantized indices (use indice[0] = -1 in the decoder) */ + Word16 *isf_q /* Q1 / o : ISF in the frequency domain (0..6400) */ ) { Word16 i; FOR( i = 0; i < 2; i++ ) { - isf_q[i] = dico1_ns_28b_fx[indice[0] * 2 + i]; + isf_q[i] = dico1_ns_28b_fx[indice[0] * 2 + i]; /* Q1 */ move16(); } FOR( i = 0; i < 3; i++ ) { - isf_q[i + 2] = dico2_ns_28b_fx[indice[1] * 3 + i]; + isf_q[i + 2] = dico2_ns_28b_fx[indice[1] * 3 + i]; /* Q1 */ move16(); - isf_q[i + 5] = dico3_ns_28b_fx[indice[2] * 3 + i]; + isf_q[i + 5] = dico3_ns_28b_fx[indice[2] * 3 + i]; /* Q1 */ move16(); } FOR( i = 0; i < 4; i++ ) { - isf_q[i + 8] = dico4_ns_28b_fx[indice[3] * 4 + i]; + isf_q[i + 8] = dico4_ns_28b_fx[indice[3] * 4 + i]; /* Q1 */ move16(); - isf_q[i + 12] = dico5_ns_28b_fx[indice[4] * 4 + i]; + isf_q[i + 12] = dico5_ns_28b_fx[indice[4] * 4 + i]; /* Q1 */ move16(); } FOR( i = 0; i < M; i++ ) { - isf_q[i] = add( isf_q[i], mean_isf_noise_amr_wb_fx[i] ); + isf_q[i] = add( isf_q[i], mean_isf_noise_amr_wb_fx[i] ); /* Q1 */ move16(); } @@ -225,9 +225,9 @@ void disf_ns_28b_fx( void disf_2s_46b_fx( Word16 *indice, /* i : quantized indices (use indice[0] = -1 in the decoder) */ - Word16 *isf_q, /* o : quantized ISFs in the cosine domain */ - Word16 *mem_AR, /* o : quantizer memory for AR model */ - Word16 *mem_MA, /* i/o: quantizer memory for MA model */ + Word16 *isf_q, /* (Qx2.56) o : quantized ISFs in the cosine domain */ + Word16 *mem_AR, /* (Qx2.56) o : quantizer memory for AR model */ + Word16 *mem_MA, /* (Qx2.56) i/o: quantizer memory for MA model */ const Word16 enc_dec /* i : encoder (0), decoder (1) G722.2 FER */ ) { @@ -247,42 +247,42 @@ void disf_2s_46b_fx( FOR( i = 0; i < 9; i++ ) { - isf_q[i] = dico1_isf_fx[indice[0] * 9 + i]; + isf_q[i] = dico1_isf_fx[indice[0] * 9 + i]; /*(Qx2.56)*/ move16(); } FOR( i = 0; i < 7; i++ ) { - isf_q[i + 9] = dico2_isf_fx[indice[1] * 7 + i]; + isf_q[i + 9] = dico2_isf_fx[indice[1] * 7 + i]; /*(Qx2.56)*/ move16(); } FOR( i = 0; i < 3; i++ ) { - isf_q[i] = add( isf_q[i], dico21_isf_46b_fx[indice[2] * 3 + i] ); + isf_q[i] = add( isf_q[i], dico21_isf_46b_fx[indice[2] * 3 + i] ); /*(Qx2.56)*/ move16(); - isf_q[i + 3] = add( isf_q[i + 3], dico22_isf_46b_fx[indice[3] * 3 + i] ); + isf_q[i + 3] = add( isf_q[i + 3], dico22_isf_46b_fx[indice[3] * 3 + i] ); /*(Qx2.56)*/ move16(); - isf_q[i + 6] = add( isf_q[i + 6], dico23_isf_46b_fx[indice[4] * 3 + i] ); + isf_q[i + 6] = add( isf_q[i + 6], dico23_isf_46b_fx[indice[4] * 3 + i] ); /*(Qx2.56)*/ move16(); - isf_q[i + 9] = add( isf_q[i + 9], dico24_isf_46b_fx[indice[5] * 3 + i] ); + isf_q[i + 9] = add( isf_q[i + 9], dico24_isf_46b_fx[indice[5] * 3 + i] ); /*(Qx2.56)*/ move16(); } FOR( i = 0; i < 4; i++ ) { - isf_q[i + 12] = add( isf_q[i + 12], dico25_isf_46b_fx[indice[6] * 4 + i] ); + isf_q[i + 12] = add( isf_q[i + 12], dico25_isf_46b_fx[indice[6] * 4 + i] ); /*(Qx2.56)*/ move16(); } FOR( i = 0; i < M; i++ ) { - mem_AR[i] = add( isf_q[i], mult_r( MU_MA_FX, mem_MA[i] ) ); - move16(); /* Update with quantized ISF vector for AR model */ + mem_AR[i] = add( isf_q[i], mult_r( MU_MA_FX, mem_MA[i] ) ); /*(Qx2.56)*/ + move16(); /* Update with quantized ISF vector for AR model */ mem_MA[i] = isf_q[i]; - move16(); /* Update with quantized prediction error for MA model */ - isf_q[i] = add( mem_AR[i], mean_isf_amr_wb_fx[i] ); - move16(); /* Quantized ISFs */ + move16(); /* Update with quantized prediction error for MA model */ + isf_q[i] = add( mem_AR[i], mean_isf_amr_wb_fx[i] ); /*(Qx2.56)*/ + move16(); /* Quantized ISFs */ } return; @@ -297,9 +297,9 @@ void disf_2s_46b_fx( void disf_2s_36b_fx( Word16 *indice, /* i : quantized indices (use indice[0] = -1 in the decoder) */ - Word16 *isf_q, /* o : quantized ISFs in the cosine domain */ - Word16 *mem_AR, /* i/o: quantizer memory for AR model */ - Word16 *mem_MA, /* i/o: quantizer memory for MA model */ + Word16 *isf_q, /* (Qx2.56) o : quantized ISFs in the cosine domain */ + Word16 *mem_AR, /* (Qx2.56) i/o: quantizer memory for AR model */ + Word16 *mem_MA, /* (Qx2.56) i/o: quantizer memory for MA model */ const Word16 enc_dec /* i : encoder (0), decoder (1) G722.2 FER */ ) { @@ -323,42 +323,42 @@ void disf_2s_36b_fx( FOR( i = 0; i < 9; i++ ) { - isf_q[i] = pt_dico1[indice[0] * 9 + i]; + isf_q[i] = pt_dico1[indice[0] * 9 + i]; /*(Qx2.56)*/ move16(); } FOR( i = 0; i < 7; i++ ) { - isf_q[i + 9] = dico2_isf_fx[indice[1] * 7 + i]; + isf_q[i + 9] = dico2_isf_fx[indice[1] * 7 + i]; /*(Qx2.56)*/ move16(); } FOR( i = 0; i < 5; i++ ) { - isf_q[i] = add( isf_q[i], dico21_isf_36b_fx[indice[2] * 5 + i] ); + isf_q[i] = add( isf_q[i], dico21_isf_36b_fx[indice[2] * 5 + i] ); /*(Qx2.56)*/ move16(); } FOR( i = 0; i < 4; i++ ) { - isf_q[i + 5] = add( isf_q[i + 5], dico22_isf_36b_fx[indice[3] * 4 + i] ); + isf_q[i + 5] = add( isf_q[i + 5], dico22_isf_36b_fx[indice[3] * 4 + i] ); /*(Qx2.56)*/ move16(); } FOR( i = 0; i < 7; i++ ) { - isf_q[i + 9] = add( isf_q[i + 9], dico23_isf_36b_fx[indice[4] * 7 + i] ); + isf_q[i + 9] = add( isf_q[i + 9], dico23_isf_36b_fx[indice[4] * 7 + i] ); /*(Qx2.56)*/ move16(); } FOR( i = 0; i < M; i++ ) { - mem_AR[i] = add( isf_q[i], mult_r( MU_MA_FX, mem_MA[i] ) ); - move16(); /* Update with quantized ISF vector for AR model */ + mem_AR[i] = add( isf_q[i], mult_r( MU_MA_FX, mem_MA[i] ) ); /*(Qx2.56)*/ + move16(); /* Update with quantized ISF vector for AR model */ mem_MA[i] = isf_q[i]; - move16(); /* Update with quantized prediction error for MA model */ - isf_q[i] = mem_AR[i] + mean_isf_amr_wb_fx[i]; - move16(); /* Quantized ISFs */ + move16(); /* Update with quantized prediction error for MA model */ + isf_q[i] = add( mem_AR[i], mean_isf_amr_wb_fx[i] ); /*(Qx2.56)*/ + move16(); /* Quantized ISFs */ } return; diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 86e9e9e47..0a45a3600 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -49,20 +49,10 @@ * Static functions declarations *------------------------------------------------------------------------------------------*/ static void ivas_cmult_fix( Word32 in1_re, Word32 in1_im, Word32 in2_re, Word32 in2_im, Word32 *out1_re, Word32 *out1_im ); -static void ivas_get_active_bins( const int16_t **pActive_bins, const int16_t **pActive_bins_abs, const int16_t **pStart_offset, const int16_t **pStart_offset_ab, const int32_t sampling_rate ); -static void ivas_get_ld_fb_resp( float **ppIdeal_FRs_re, float **ppIdeal_FRs_im, float **ppNew_FRs_re, float **ppNew_FRs_im, const int16_t *pActive_bins, const int16_t *pStart_offset, const int16_t num_bands, const int16_t delay, const int32_t sampling_rate ); -#ifdef IVAS_FLOAT_FIXED static void ivas_get_active_bins_fx( const Word16 **pActive_bins, const Word16 **pActive_bins_abs, const Word16 **pStart_offset, const Word16 **pStart_offset_ab, const Word32 sampling_rate ); static void ivas_get_ld_fb_resp_fx( Word32 **ppIdeal_FRs_re_fx, Word32 **ppIdeal_FRs_im_fx, Word32 **ppNew_FRs_re_fx, Word32 **ppNew_FRs_im_fx, const Word16 *pActive_bins, const Word16 *pStart_offset, const Word16 num_bands, const Word16 delay, const Word32 sampling_rate ); -#endif -static ivas_error ivas_filterbank_setup( IVAS_FB_MIXER_HANDLE hFbMixer, const int32_t sampling_rate ); -#ifdef IVAS_FLOAT_FIXED static ivas_error ivas_filterbank_setup_fx( IVAS_FB_MIXER_HANDLE hFbMixer, const Word32 sampling_rate, Word16 *index ); -#endif -static ivas_error ivas_fb_mixer_get_window( const int16_t fade_len, const int32_t sampling_rate, const float **pWindow ); -#ifdef IVAS_FLOAT_FIXED static ivas_error ivas_fb_mixer_get_window_fx( const Word16 fade_len, const Word32 sampling_rate, const Word16 **pWindow ); -#endif #ifdef IVAS_FLOAT_FIXED @@ -192,7 +182,8 @@ ivas_error ivas_fb_set_cfg( Word16 tmp = shl( div_l( sampling_rate, FRAMES_PER_SEC ), 1 ); // Q0 tmp = mult0( tmp, 3 ); // Q0 tmp = shr( tmp, 2 ); // Q0 - pFb_cfg->windowed_fr_offset = (Word16) ( tmp - NS2SA_FX2( sampling_rate, DELAY_DIRAC_SPAR_ENC_CMP_NS ) ); + pFb_cfg->windowed_fr_offset = sub( tmp, NS2SA_FX2( sampling_rate, DELAY_DIRAC_SPAR_ENC_CMP_NS ) ); + move16(); move16(); move16(); move16(); @@ -287,244 +278,6 @@ ivas_error ivas_fb_set_cfg( * * Allocate and initialize FB mixer handle *------------------------------------------------------------------------*/ - -ivas_error ivas_FB_mixer_open( - IVAS_FB_MIXER_HANDLE *hFbMixer_out, /* i/o: FB mixer handle */ - const int32_t sampling_rate, /* i : sampling rate */ - IVAS_FB_CFG *fb_cfg, /* i : FB config. handle */ - const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -) -{ - IVAS_FB_MIXER_HANDLE hFbMixer; - int16_t i, j, frame_len, num_bands; - int16_t num_chs_alloc; - ivas_error error; - - error = IVAS_ERR_OK; - - frame_len = (int16_t) ( sampling_rate / FRAMES_PER_SEC ); - - hFbMixer = *hFbMixer_out; - - if ( !spar_reconfig_flag ) - { - if ( ( hFbMixer = (IVAS_FB_MIXER_HANDLE) malloc( sizeof( IVAS_FB_MIXER_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); - } - - if ( fb_cfg->num_out_chans > 0 ) - { - if ( ( hFbMixer->pFb = (ivas_filterbank_t *) malloc( sizeof( ivas_filterbank_t ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); - } - } - else - { - hFbMixer->pFb = NULL; - } - } - - if ( fb_cfg->active_w_mixing == -1 ) - { - num_chs_alloc = 0; - } - else if ( fb_cfg->active_w_mixing ) - { - num_chs_alloc = max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ); - } - else - { - num_chs_alloc = 1; /* only W channel processed for predicting YZX */ - } - - for ( i = 0; i < num_chs_alloc; i++ ) - { - if ( fb_cfg->num_out_chans == 0 ) - { -#ifndef IVAS_FLOAT_FIXED - hFbMixer->ppFilterbank_inFR_re[i] = NULL; - hFbMixer->ppFilterbank_inFR_im[i] = NULL; -#else - hFbMixer->ppFilterbank_inFR_re_fx[i] = NULL; - hFbMixer->ppFilterbank_inFR_im_fx[i] = NULL; -#endif - } - else - { - j = fb_cfg->remix_order[i]; -#ifndef IVAS_FLOAT_FIXED - if ( ( hFbMixer->ppFilterbank_inFR_re[j] = (float *) malloc( sizeof( float ) * frame_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); - } - - if ( ( hFbMixer->ppFilterbank_inFR_im[j] = (float *) malloc( sizeof( float ) * frame_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); - } -#else - if ( ( hFbMixer->ppFilterbank_inFR_re_fx[j] = (Word32 *) malloc( sizeof( Word32 ) * frame_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); - } - - if ( ( hFbMixer->ppFilterbank_inFR_im_fx[j] = (Word32 *) malloc( sizeof( Word32 ) * frame_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); - } -#endif - } - } - - if ( fb_cfg->active_w_mixing == -1 ) - { - num_chs_alloc = 0; - } - else - { - num_chs_alloc = max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ); - } - - for ( i = 0; i < num_chs_alloc; i++ ) - { - if ( ( hFbMixer->ppFilterbank_prior_input[i] = (float *) malloc( sizeof( float ) * fb_cfg->prior_input_length ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); - } - set_f( hFbMixer->ppFilterbank_prior_input[i], 0, fb_cfg->prior_input_length ); -#ifdef IVAS_FLOAT_FIXED - IF( ( hFbMixer->ppFilterbank_prior_input_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * fb_cfg->prior_input_length ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); - } - set32_fx( hFbMixer->ppFilterbank_prior_input_fx[i], 0, fb_cfg->prior_input_length ); -#endif - } - -#ifdef IVAS_FLOAT_FIXED - FOR( i = 0; i < num_chs_alloc; i++ ) - { - IF( ( hFbMixer->ppFilterbank_prior_input_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * fb_cfg->prior_input_length ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); - } - set32_fx( hFbMixer->ppFilterbank_prior_input_fx[i], 0, fb_cfg->prior_input_length ); - } -#endif - - if ( ( fb_cfg->active_w_mixing != -1 ) && ( fb_cfg->num_out_chans > 0 ) ) - { - Word32 *pTemp_mem_fx; - if ( ( pTemp_mem_fx = (Word32 *) malloc( sizeof( Word32 ) * fb_cfg->num_out_chans * max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ) * IVAS_MAX_NUM_BANDS ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer" ); - } - for ( i = 0; i < fb_cfg->num_out_chans; i++ ) - { - for ( j = 0; j < fb_cfg->num_in_chans; j++ ) - { - hFbMixer->prior_mixer_fx[i][j] = pTemp_mem_fx; - pTemp_mem_fx += IVAS_MAX_NUM_BANDS; - set32_fx( hFbMixer->prior_mixer_fx[i][j], 0, IVAS_MAX_NUM_BANDS ); - } - } - hFbMixer->q_prior_mixer_fx = Q31; - move16(); - } - - if ( !spar_reconfig_flag ) - { - if ( fb_cfg->num_out_chans > 0 ) - { - const int16_t *pActive_bins_per_band, *pActive_bins_per_band_abs, *pStart_offset, *pStart_offset_abs; - - num_bands = ivas_get_num_bands( sampling_rate ); - - ivas_get_active_bins( &pActive_bins_per_band, &pActive_bins_per_band_abs, &pStart_offset, &pStart_offset_abs, sampling_rate ); - - if ( fb_cfg->active_w_mixing != -1 ) - { - for ( i = 0; i < num_bands; i++ ) - { - if ( ( hFbMixer->pFb->fb_bin_to_band.pFb_bin_to_band[i] = (float *) malloc( sizeof( float ) * pActive_bins_per_band_abs[i] ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); - } -#ifdef IVAS_FLOAT_FIXED - IF( ( hFbMixer->pFb->fb_bin_to_band.pFb_bin_to_band_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * pActive_bins_per_band_abs[i] ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder fixed" ); - } -#endif - } - } - - if ( sampling_rate != 48000 ) - { - int16_t num_diff_bands, start_diff_band_non48k; - - num_diff_bands = MAX_NUM_BANDS_DIFF_NON48K; - start_diff_band_non48k = num_bands - num_diff_bands; - - hFbMixer->num_diff_bands = num_diff_bands; - - for ( j = start_diff_band_non48k; j < num_bands; j++ ) - { - if ( ( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[0][j] = (float *) malloc( sizeof( float ) * pActive_bins_per_band[j] ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); - } - - if ( ( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[1][j] = (float *) malloc( sizeof( float ) * pActive_bins_per_band[j] ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); - } -#ifdef IVAS_FLOAT_FIXED - IF( ( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[0][j] = (Word32 *) malloc( sizeof( Word32 ) * pActive_bins_per_band[j] ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); - } - - IF( ( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[1][j] = (Word32 *) malloc( sizeof( Word32 ) * pActive_bins_per_band[j] ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); - } -#endif - } - } - } - else - { - /* ignore all the deeper filter bank stuff for now */ - hFbMixer->num_diff_bands = 0; - } - } - - hFbMixer->fb_cfg = fb_cfg; - set_s( hFbMixer->first_frame, 1, hFbMixer->fb_cfg->num_out_chans ); - set_s( hFbMixer->first_frame + hFbMixer->fb_cfg->num_out_chans, 0, IVAS_SPAR_MAX_CH - hFbMixer->fb_cfg->num_out_chans ); - - if ( !spar_reconfig_flag ) - { - if ( ( error = ivas_filterbank_setup( hFbMixer, sampling_rate ) ) != IVAS_ERR_OK ) - { - return error; - } - Word16 index[IVAS_MAX_NUM_FB_BANDS]; - set16_fx( index, 0, IVAS_MAX_NUM_FB_BANDS ); - if ( ( error = ivas_filterbank_setup_fx( hFbMixer, sampling_rate, index ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - *hFbMixer_out = hFbMixer; - - return error; -} - #ifdef IVAS_FLOAT_FIXED ivas_error ivas_FB_mixer_open_fx( IVAS_FB_MIXER_HANDLE *hFbMixer_out, /* i/o: FB mixer handle */ @@ -622,13 +375,6 @@ ivas_error ivas_FB_mixer_open_fx( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); } set32_fx( hFbMixer->ppFilterbank_prior_input_fx[i], 0, fb_cfg->prior_input_length ); -#if 1 // TODO: To be removed later - if ( ( hFbMixer->ppFilterbank_prior_input[i] = (float *) malloc( sizeof( float ) * fb_cfg->prior_input_length ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); - } - set_f( hFbMixer->ppFilterbank_prior_input[i], 0, fb_cfg->prior_input_length ); -#endif } test(); @@ -670,12 +416,6 @@ ivas_error ivas_FB_mixer_open_fx( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder fixed" ); } -#if 1 // TODO: To be removed later - if ( ( hFbMixer->pFb->fb_bin_to_band.pFb_bin_to_band[i] = (float *) malloc( sizeof( float ) * pActive_bins_per_band_abs[i] ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); - } -#endif } } @@ -738,147 +478,6 @@ ivas_error ivas_FB_mixer_open_fx( * Deallocate FB mixer handle *------------------------------------------------------------------------*/ - -void ivas_FB_mixer_close( - IVAS_FB_MIXER_HANDLE *hFbMixer_in, /* i/o: FB mixer handle */ - const int32_t sampling_rate, /* i : sampling rate in Hz */ - const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -) -{ - IVAS_FB_MIXER_HANDLE hFbMixer; - IVAS_FB_CFG *fb_cfg; - int16_t i, j, num_bands; - int16_t num_chs_alloc; - - hFbMixer = *hFbMixer_in; - fb_cfg = hFbMixer->fb_cfg; - - if ( fb_cfg->active_w_mixing == -1 ) - { - num_chs_alloc = 0; - } - else if ( fb_cfg->active_w_mixing ) - { - num_chs_alloc = max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ); - } - else - { - num_chs_alloc = 1; /* only W channel processed for predicting YZX */ - } - - if ( hFbMixer != NULL ) - { - for ( i = 0; i < num_chs_alloc; i++ ) - { - if ( fb_cfg->num_out_chans > 0 ) - { - j = fb_cfg->remix_order[i]; -#ifndef IVAS_FLOAT_FIXED - free( hFbMixer->ppFilterbank_inFR_re[j] ); - hFbMixer->ppFilterbank_inFR_re[j] = NULL; - - free( hFbMixer->ppFilterbank_inFR_im[j] ); - hFbMixer->ppFilterbank_inFR_im[j] = NULL; -#else - free( hFbMixer->ppFilterbank_inFR_re_fx[j] ); - hFbMixer->ppFilterbank_inFR_re_fx[j] = NULL; - - free( hFbMixer->ppFilterbank_inFR_im_fx[j] ); - hFbMixer->ppFilterbank_inFR_im_fx[j] = NULL; -#endif - } - } - - if ( fb_cfg->active_w_mixing == -1 ) - { - num_chs_alloc = 0; - } - else - { - num_chs_alloc = max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ); - } - - for ( i = 0; i < num_chs_alloc; i++ ) - { - free( hFbMixer->ppFilterbank_prior_input[i] ); - hFbMixer->ppFilterbank_prior_input[i] = NULL; - } -#ifdef IVAS_FLOAT_FIXED - for ( i = 0; i < num_chs_alloc; i++ ) - { - free( hFbMixer->ppFilterbank_prior_input_fx[i] ); - hFbMixer->ppFilterbank_prior_input_fx[i] = NULL; - } -#endif - if ( !spar_reconfig_flag ) - { - if ( fb_cfg->num_out_chans > 0 ) - { - num_bands = hFbMixer->pFb->filterbank_num_bands; - - if ( fb_cfg->active_w_mixing != -1 ) - { - for ( i = 0; i < num_bands; i++ ) - { - free( hFbMixer->pFb->fb_bin_to_band.pFb_bin_to_band[i] ); - hFbMixer->pFb->fb_bin_to_band.pFb_bin_to_band[i] = NULL; -#ifdef IVAS_FLOAT_FIXED - free( hFbMixer->pFb->fb_bin_to_band.pFb_bin_to_band_fx[i] ); - hFbMixer->pFb->fb_bin_to_band.pFb_bin_to_band_fx[i] = NULL; -#endif - } - } - - if ( sampling_rate != 48000 ) - { - int16_t start_diff_band_non48k; - start_diff_band_non48k = num_bands - hFbMixer->num_diff_bands; - - for ( j = start_diff_band_non48k; j < num_bands; j++ ) - { - free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[0][j] ); - hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[0][j] = NULL; - - free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[1][j] ); - hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[1][j] = NULL; - } - -#ifdef IVAS_FLOAT_FIXED - FOR( j = start_diff_band_non48k; j < num_bands; j++ ) - { - free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[0][j] ); - hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[0][j] = NULL; - - free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[1][j] ); - hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[1][j] = NULL; - } -#endif - } - } - if ( hFbMixer->pFb != NULL ) - { - free( hFbMixer->pFb ); - hFbMixer->pFb = NULL; - } - } - - if ( hFbMixer->fb_cfg != NULL ) - { - free( hFbMixer->fb_cfg ); - hFbMixer->fb_cfg = NULL; - } - - if ( !spar_reconfig_flag ) - { - free( hFbMixer ); - hFbMixer = NULL; - } - } - - return; -} - - #ifdef IVAS_FLOAT_FIXED void ivas_FB_mixer_close_fx( IVAS_FB_MIXER_HANDLE *hFbMixer_in, /* i/o: FB mixer handle */ @@ -954,6 +553,7 @@ void ivas_FB_mixer_close_fx( IF( fb_cfg->num_out_chans > 0 ) { num_bands = hFbMixer->pFb->filterbank_num_bands; + move16(); IF( NE_16( fb_cfg->active_w_mixing, -1 ) ) { @@ -1048,7 +648,7 @@ void ivas_fb_mixer_pcm_ingest_fx( Word32 **ppOut_pcm, /* o : output audio channels Qq_ppOut_pcm[] */ const Word16 frame_len, /* i : frame length */ const Word16 HOA_md_ind[IVAS_SPAR_MAX_CH], - Word16 q_data_fix[MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS], + Word16 q_data_fix, Word16 *q_ppOut_pcm ) { Word16 i; @@ -1069,7 +669,7 @@ void ivas_fb_mixer_pcm_ingest_fx( FOR( i = 0; i < fb_cfg->num_in_chans; i++ ) { - Word16 q_temp = s_min( hFbMixer->q_ppFilterbank_prior_input_fx[i], q_data_fix[HOA_md_ind[i]] ); + Word16 q_temp = s_min( hFbMixer->q_ppFilterbank_prior_input_fx[i], q_data_fix ); // mvr2r(&hFbMixer->ppFilterbank_prior_input[i][fb_cfg->prior_input_length - frame_len], ppOut_pcm[i], frame_len); @@ -1086,11 +686,11 @@ void ivas_fb_mixer_pcm_ingest_fx( // mvr2r(pcm_in[HOA_md_ind[i]], &ppOut_pcm[i][frame_len], frame_len); Copy32( pcm_in[HOA_md_ind[i]], &ppOut_pcm[i][frame_len], frame_len ); - IF( LT_16( q_temp, q_data_fix[HOA_md_ind[i]] ) ) + IF( LT_16( q_temp, q_data_fix ) ) { FOR( Word16 x = frame_len; x < shl( frame_len, 1 ); x++ ) { - ppOut_pcm[i][x] = L_shr( ppOut_pcm[i][x], sub( q_data_fix[HOA_md_ind[i]], q_temp ) ); + ppOut_pcm[i][x] = L_shr( ppOut_pcm[i][x], sub( q_data_fix, q_temp ) ); move32(); } } @@ -1102,11 +702,14 @@ void ivas_fb_mixer_pcm_ingest_fx( FOR( i = 0; i < num_chs_ingest; i++ ) { - Word16 q_shift = sub( getScaleFactor32( ppOut_pcm[fb_cfg->remix_order[i]], shl( frame_len, 1 ) ), guard_bits ); + Word16 q_shift = sub( L_norm_arr( ppOut_pcm[fb_cfg->remix_order[i]], shl( frame_len, 1 ) ), guard_bits ); Scale_sig32( ppOut_pcm[fb_cfg->remix_order[i]], shl( frame_len, 1 ), q_shift ); q_ppOut_pcm[fb_cfg->remix_order[i]] = add( q_ppOut_pcm[fb_cfg->remix_order[i]], q_shift ); + move16(); ivas_mdft_fx( ppOut_pcm[fb_cfg->remix_order[i]], hFbMixer->ppFilterbank_inFR_re_fx[fb_cfg->remix_order[i]], hFbMixer->ppFilterbank_inFR_im_fx[fb_cfg->remix_order[i]], shl( frame_len, 1 ), frame_len ); + hFbMixer->q_ppFilterbank_inFR[fb_cfg->remix_order[i]] = q_ppOut_pcm[fb_cfg->remix_order[i]]; + move16(); } return; @@ -1182,8 +785,8 @@ void ivas_fb_mixer_get_windowed_fr_fx( n_old_samples = s_min( ( sub( hFbMixer->fb_cfg->prior_input_length, hFbMixer->fb_cfg->windowed_fr_offset ) ), ( shl( mdft_len, 1 ) ) ); n_new_samples = s_max( 0, sub( shl( length, 1 ), n_old_samples ) ); - offset = (Word16) ( sub( sub( shl( mdft_len, 1 ), length ), hFbMixer->ana_window_offset ) ); - rev_offset = (Word16) ( sub( shl( mdft_len, 1 ), hFbMixer->ana_window_offset ) ); + offset = sub( sub( shl( mdft_len, 1 ), length ), hFbMixer->ana_window_offset ); + rev_offset = sub( shl( mdft_len, 1 ), hFbMixer->ana_window_offset ); set32_fx( fr_in_block_fx, 0, offset ); FOR( ch_idx = 0; ch_idx < nchan_fb_in; ch_idx++ ) @@ -1211,7 +814,7 @@ void ivas_fb_mixer_get_windowed_fr_fx( move16(); } - ivas_mdft_fx( fr_in_block_fx, frame_f_real_fx[ch_idx], frame_f_imag_fx[ch_idx], mdft_len << 1, mdft_len ); + ivas_mdft_fx( fr_in_block_fx, frame_f_real_fx[ch_idx], frame_f_imag_fx[ch_idx], shl( mdft_len, 1 ), mdft_len ); } return; @@ -1269,50 +872,6 @@ void ivas_fb_mixer_get_windowed_fr( * FB Mixer cross fading *-----------------------------------------------------------------------------------------*/ -void ivas_fb_mixer_cross_fading( - IVAS_FB_MIXER_HANDLE hFbMixer, - float **ppOut_pcm, - float *pMdft_out_old, - float *pMdft_out_new, - const int16_t ch, - const int16_t frame_len, - const int16_t cf_offset ) -{ - int16_t k, fade_start_offset, fade_end_offset; - - if ( hFbMixer->first_frame[ch] == 0 ) - { - fade_start_offset = hFbMixer->cross_fade_start_offset; - fade_end_offset = hFbMixer->cross_fade_end_offset; - - for ( k = 0; k < fade_start_offset; k++ ) - { - ppOut_pcm[ch][k] = pMdft_out_old[k + cf_offset]; - } - - for ( k = fade_start_offset; k < fade_end_offset; k++ ) - { - ppOut_pcm[ch][k] = pMdft_out_new[k + cf_offset] * hFbMixer->pFilterbank_cross_fade[k - fade_start_offset] + pMdft_out_old[k + cf_offset] * ( 1.0f - hFbMixer->pFilterbank_cross_fade[k - fade_start_offset] ); - } - - for ( k = fade_end_offset; k < frame_len; k++ ) - { - ppOut_pcm[ch][k] = pMdft_out_new[k + cf_offset]; - } - } - else - { - hFbMixer->first_frame[ch] = 0; - - for ( k = 0; k < frame_len; k++ ) - { - ppOut_pcm[ch][k] = pMdft_out_new[k + cf_offset]; - } - } - - return; -} - #ifdef IVAS_FLOAT_FIXED void ivas_fb_mixer_cross_fading_fx( IVAS_FB_MIXER_HANDLE hFbMixer, @@ -1375,10 +934,12 @@ void ivas_fb_mixer_cross_fading_fx( void ivas_cmult_fix( Word32 in1_re, Word32 in1_im, Word32 in2_re, Word32 in2_im, Word32 *out1_re, Word32 *out1_im ) { *out1_re = L_sub_sat( Mpy_32_32( in1_re, in2_re ), Mpy_32_32( in1_im, in2_im ) ); + move32(); *out1_im = L_add_sat( Mpy_32_32( in1_re, in2_im ), Mpy_32_32( in2_re, in1_im ) ); + move32(); } -void ivas_fb_mixer_process( +void ivas_fb_mixer_process_fx( IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle */ Word32 ***mixer_mat_fx, /* i : mixer matrix */ Word16 *q_mixer_mat_fx, /* i : mixer matrix */ @@ -1462,36 +1023,10 @@ void ivas_fb_mixer_process( { Word32 temp_out_re_fx, temp_out_im_fx; - Word16 Fb_inFR_com_q = s_min( hFbMixer->q_ppFilterbank_inFR_re_fx[j], hFbMixer->q_ppFilterbank_inFR_im_fx[j] ); - Word32 inp_Fb_inFR_re, inp_Fb_inFR_im; - IF( NE_16( hFbMixer->q_ppFilterbank_inFR_re_fx[j], Fb_inFR_com_q ) ) - { - inp_Fb_inFR_re = L_shr( pFb_inFR_re_fx[k], sub( hFbMixer->q_ppFilterbank_inFR_re_fx[j], Fb_inFR_com_q ) ); - /*common q for real and imag hFbMixer->q_ppFilterbank_inFR_re_fx[j]*/ - } - ELSE - { - inp_Fb_inFR_re = pFb_inFR_re_fx[k]; - /*q hFbMixer->q_ppFilterbank_inFR_re_fx[j]*/ - move32(); - } - IF( NE_16( hFbMixer->q_ppFilterbank_inFR_im_fx[j], Fb_inFR_com_q ) ) - { - inp_Fb_inFR_im = L_shr( pFb_inFR_im_fx[k], sub( hFbMixer->q_ppFilterbank_inFR_im_fx[j], Fb_inFR_com_q ) ); - /*common q for real and imag hFbMixer->q_ppFilterbank_inFR_re_fx[j]*/ - } - ELSE - { - inp_Fb_inFR_im = pFb_inFR_im_fx[k]; - /*q hFbMixer->q_ppFilterbank_inFR_im_fx[j]*/ - move32(); - } - ivas_cmult_fix( filterbank_mixer_bins_re_fx[k], filterbank_mixer_bins_im_fx[k], inp_Fb_inFR_re, - inp_Fb_inFR_im, &temp_out_re_fx, &temp_out_im_fx ); - res_q = sub( add( sub( sub( add( 30, *q_mixer_mat_fx ), 31 ), total_guard ), Fb_inFR_com_q ), 31 ); - move16(); + ivas_cmult_fix( filterbank_mixer_bins_re_fx[k], filterbank_mixer_bins_im_fx[k], pFb_inFR_re_fx[k], + pFb_inFR_im_fx[k], &temp_out_re_fx, &temp_out_im_fx ); + res_q = sub( add( sub( sub( add( 30, *q_mixer_mat_fx ), 31 ), total_guard ), hFbMixer->q_ppFilterbank_inFR[j] ), 31 ); Word16 q_check = s_min( q_pOut_fr_fx, res_q ); - move16(); IF( NE_16( q_check, q_pOut_fr_fx ) ) { pOut_fr_re_fx[k] = L_shr( pOut_fr_re_fx[k], sub( q_pOut_fr_fx, q_check ) ); @@ -1499,7 +1034,7 @@ void ivas_fb_mixer_process( pOut_fr_im_fx[k] = L_shr( pOut_fr_im_fx[k], sub( q_pOut_fr_fx, q_check ) ); move32(); } - IF( q_check != res_q ) + IF( NE_16( q_check, res_q ) ) { temp_out_re_fx = L_shr( temp_out_re_fx, sub( res_q, q_check ) ); temp_out_im_fx = L_shr( temp_out_im_fx, sub( res_q, q_check ) ); @@ -1648,31 +1183,34 @@ void ivas_fb_mixer_process( * *-----------------------------------------------------------------------------------------*/ -void ivas_fb_mixer_get_in_out_mapping( - const IVAS_FB_CFG *fb_cfg, /* i : FB config. handle */ - int16_t in_out_mixer_map[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH] /* i/o: mixing mapping */ +void ivas_fb_mixer_get_in_out_mapping_fx( + const IVAS_FB_CFG *fb_cfg, /* i : FB config. handle */ + Word16 in_out_mixer_map[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH] /* i/o: mixing mapping */ ) { - int16_t i, j; + Word16 i, j; - set_s( (int16_t *) in_out_mixer_map, 0, IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH ); + set_s( (Word16 *) in_out_mixer_map, 0, IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH ); - if ( fb_cfg->active_w_mixing ) + IF( fb_cfg->active_w_mixing ) { - for ( i = 0; i < fb_cfg->num_out_chans; i++ ) + FOR( i = 0; i < fb_cfg->num_out_chans; i++ ) { - for ( j = 0; j < fb_cfg->num_in_chans; j++ ) + FOR( j = 0; j < fb_cfg->num_in_chans; j++ ) { in_out_mixer_map[i][j] = 1; + move16(); } } } - else + ELSE { in_out_mixer_map[0][0] = 1; /* W depends on only W input*/ - for ( i = 1; i < fb_cfg->num_out_chans; i++ ) + move16(); + FOR( i = 1; i < fb_cfg->num_out_chans; i++ ) { in_out_mixer_map[i][0] = 1; + move16(); } } @@ -1686,255 +1224,6 @@ void ivas_fb_mixer_get_in_out_mapping( * Function to calculate number of active bands *-----------------------------------------------------------------------------------------*/ -static int16_t ivas_calculate_abs_fr( - ivas_filterbank_t *pFb, - const int32_t sampling_rate, - const int16_t alloc_fb_resp ) -{ - int16_t frame_len; - float ppFilterbank_FRs_s[L_FRAME48k]; -#ifdef IVAS_FLOAT_FIXED - Word32 ppFilterbank_FRs_s_fx[L_FRAME48k]; -#endif - int16_t bands = pFb->filterbank_num_bands; - int16_t i, j, num_active_bands = 0; - int16_t idx_short_stride_bin_to_band = 0; - - for ( i = 0; i < bands; i++ ) - { - const float *long_mdft_ptr_re = pFb->fb_consts.ppFilterbank_FRs[0][i]; - const float *long_mdft_ptr_im = pFb->fb_consts.ppFilterbank_FRs[1][i]; - int16_t start_offset = pFb->fb_consts.pFilterbank_bins_start_offset[i]; - int16_t num_bins = pFb->fb_consts.pFilterbank_bins_per_band[i]; - int16_t short_mdft_start_bin = -1; - float short_stride_pow_spec[MDFT_FB_BANDS_240]; - float short_stride_nrg = 0.0f; -#ifdef IVAS_FLOAT_FIXED - Word32 short_stride_pow_spec_fx[MDFT_FB_BANDS_240]; - Word32 short_stride_nrg_fx = 0; - Word16 exp_diff = 0, tmp; -#endif - float cldfb_nrg = 0.0f; - int16_t short_stride = pFb->fb_bin_to_band.short_stride; - const int16_t num_bins_per_short_stride_bin = ( const int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / short_stride ); - const int16_t num_bins_per_cldfb_band = ( const int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / pFb->fb_bin_to_band.num_cldfb_bands ); - float short_stride_max_per_spar_band = 1e-9f; -#ifdef IVAS_FLOAT_FIXED - Word32 short_stride_max_per_spar_band_fx = 1; -#endif - - /*loop over all stored Filter Bank Response MDFT coefficients*/ - set_f( short_stride_pow_spec, 0, MDFT_FB_BANDS_240 ); -#ifdef IVAS_FLOAT_FIXED - set32_fx( short_stride_pow_spec_fx, 0, MDFT_FB_BANDS_240 ); -#endif - for ( j = start_offset; j < num_bins + start_offset; j++ ) - { - float sq_abs; -#ifdef IVAS_FLOAT_FIXED - Word32 sq_abs_fx; -#endif - - /*calculate bin energy */ - IVAS_CALCULATE_SQ_ABS( *long_mdft_ptr_re, *long_mdft_ptr_im, sq_abs ); -#ifdef IVAS_FLOAT_FIXED - sq_abs_fx = (Word32) ( sq_abs * ONE_IN_Q22 ); -#endif - long_mdft_ptr_re++; - long_mdft_ptr_im++; - - /* accumulate bin energies within a short stride bin */ - short_stride_nrg += sq_abs; -#ifdef IVAS_FLOAT_FIXED - short_stride_nrg_fx = L_add( short_stride_nrg_fx, sq_abs_fx ); -#endif - if ( !( ( j + 1 ) % num_bins_per_short_stride_bin ) ) - { /* new short stride bin */ - short_stride_pow_spec[j / num_bins_per_short_stride_bin] = short_stride_nrg; /* energy rather than magnitude works better for covariance weighting*/ - short_stride_max_per_spar_band = max( short_stride_nrg, short_stride_max_per_spar_band ); /*compute highest magnitude per band*/ - short_stride_nrg = 0.0f; -#ifdef IVAS_FLOAT_FIXED - short_stride_pow_spec_fx[j / num_bins_per_short_stride_bin] = short_stride_nrg_fx; /* energy rather than magnitude works better for covariance weighting*/ - short_stride_max_per_spar_band_fx = max( short_stride_nrg_fx, short_stride_max_per_spar_band_fx ); /*compute highest magnitude per band*/ - short_stride_nrg_fx = 0; -#endif - } - - /* accumulate bin energies within a CLDFB band */ - cldfb_nrg += sq_abs; - if ( !( ( j + 1 ) % num_bins_per_cldfb_band ) ) - { - pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band[j / num_bins_per_cldfb_band][i] = sqrtf( cldfb_nrg ); - cldfb_nrg = 0.0f; - } - } - - /*loop over the short MDFT bins*/ - for ( j = 0; j < short_stride; j++ ) - { - /* normalize and sparsify the energies */ - short_stride_pow_spec[j] /= short_stride_max_per_spar_band; - short_stride_pow_spec[j] = max( short_stride_pow_spec[j] - 0.3f, 0.0f ) / 0.7f; -#ifdef IVAS_FLOAT_FIXED - tmp = BASOP_Util_Divide3232_Scale( short_stride_pow_spec_fx[j], short_stride_max_per_spar_band_fx, &exp_diff ); - short_stride_pow_spec_fx[j] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22 - short_stride_pow_spec_fx[j] = L_max( L_sub( short_stride_pow_spec_fx[j], (Word32) ( 0.3f * ONE_IN_Q22 ) ), 0 ); - tmp = BASOP_Util_Divide3232_Scale( short_stride_pow_spec_fx[j], (Word32) ( 0.7f * ONE_IN_Q22 ), &exp_diff ); - short_stride_pow_spec_fx[j] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22 - - IF( GT_32( short_stride_pow_spec_fx[j], 0 ) ) -#else - if ( short_stride_pow_spec[j] > 0.0f ) -#endif - { - assert( idx_short_stride_bin_to_band < 2 * MDFT_FB_BANDS_240 ); /* array size of p_short_stride_bin_to_band */ - if ( short_mdft_start_bin == -1 ) - { - short_mdft_start_bin = j; - pFb->fb_bin_to_band.p_short_stride_start_bin_per_band[i] = j; - pFb->fb_bin_to_band.pp_short_stride_bin_to_band[i] = &pFb->fb_bin_to_band.p_short_stride_bin_to_band[idx_short_stride_bin_to_band]; -#ifdef IVAS_FLOAT_FIXED - pFb->fb_bin_to_band.pp_short_stride_bin_to_band_fx[i] = &pFb->fb_bin_to_band.p_short_stride_bin_to_band_fx[idx_short_stride_bin_to_band]; -#endif - } -#ifdef IVAS_FLOAT_FIXED - pFb->fb_bin_to_band.p_short_stride_bin_to_band[idx_short_stride_bin_to_band] = short_stride_pow_spec[j]; - pFb->fb_bin_to_band.p_short_stride_bin_to_band_fx[idx_short_stride_bin_to_band] = short_stride_pow_spec_fx[j]; - idx_short_stride_bin_to_band++; -#else - pFb->fb_bin_to_band.p_short_stride_bin_to_band[idx_short_stride_bin_to_band++] = short_stride_pow_spec[j]; -#endif - pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[i]++; - } - } - } - - /*loop over CLDFB bands*/ - for ( j = 0; j < pFb->fb_bin_to_band.num_cldfb_bands; j++ ) - { - float sum_over_spar_bands = 0.0f; - float max_spar_band_contribution = 0.0f; - int16_t spar_start = 0; - int16_t any_non_zero = 0; - - for ( i = 0; i < bands; i++ ) - { - sum_over_spar_bands += pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band[j][i]; - if ( pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band[j][i] > max_spar_band_contribution ) - { - max_spar_band_contribution = pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band[j][i]; - pFb->fb_bin_to_band.p_cldfb_map_to_spar_band[j] = i; - } - } - sum_over_spar_bands = max( sum_over_spar_bands, EPSILON ); - for ( i = 0; i < bands; i++ ) - { - if ( pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band[j][i] == 0.0f && !any_non_zero ) - { - spar_start++; - } - else - { - any_non_zero = 1; - } - pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band[j][i] /= sum_over_spar_bands; - } - pFb->fb_bin_to_band.p_spar_start_bands[j] = spar_start; - } - - frame_len = (int16_t) ( sampling_rate / FRAMES_PER_SEC ); - - set_f( ppFilterbank_FRs_s, 0, frame_len ); -#ifdef IVAS_FLOAT_FIXED - set32_fx( ppFilterbank_FRs_s_fx, 0, frame_len ); -#endif - - /*Commented logic is for calculating number of active bands, can be removed if not needed */ - for ( i = 0; i < bands; i++ ) - { - const float *pFilterbank_bin_to_band_re = pFb->fb_consts.ppFilterbank_FRs[0][i]; - const float *pFilterbank_bin_to_band_im = pFb->fb_consts.ppFilterbank_FRs[1][i]; - - int16_t start_offset = pFb->fb_consts.pFilterbank_bins_start_offset[i]; - int16_t num_bins = pFb->fb_consts.pFilterbank_bins_per_band[i]; - int16_t idx = 0; - int16_t abs_active_bins = pFb->fb_bin_to_band.pFb_active_bins_per_band[i]; - int16_t abs_start_offset = pFb->fb_bin_to_band.pFb_start_bin_per_band[i]; - - for ( j = start_offset; j < num_bins + start_offset; j++ ) - { - float temp = 0; - - IVAS_CALCULATE_ABS( *pFilterbank_bin_to_band_re, *pFilterbank_bin_to_band_im, temp ); - - pFilterbank_bin_to_band_re++; - pFilterbank_bin_to_band_im++; - - temp -= 0.3f; - - if ( temp < 0.0f ) - { - temp = 0; - } - - if ( j < ( abs_active_bins + abs_start_offset ) && j >= abs_start_offset && alloc_fb_resp != -1 ) - { -#ifdef IVAS_FLOAT_FIXED - pFb->fb_bin_to_band.pFb_bin_to_band[i][idx] = temp; - pFb->fb_bin_to_band.pFb_bin_to_band_fx[i][idx] = (Word32) ( temp * ONE_IN_Q22 ); - idx = add( idx, 1 ); -#else - pFb->fb_bin_to_band.pFb_bin_to_band[i][idx++] = temp; -#endif - } - - ppFilterbank_FRs_s[j] += temp; -#ifdef IVAS_FLOAT_FIXED - ppFilterbank_FRs_s_fx[j] = L_add( ppFilterbank_FRs_s_fx[j], (Word32) ( temp * ONE_IN_Q22 ) ); -#endif - } - } - - for ( i = 0; i < frame_len; i++ ) - { - if ( ppFilterbank_FRs_s[i] < 0.1f ) - { - ppFilterbank_FRs_s[i] = 0.1f; -#ifdef IVAS_FLOAT_FIXED - ppFilterbank_FRs_s_fx[i] = (Word32) ( 0.1f * ONE_IN_Q22 ); -#endif - } - } - - if ( alloc_fb_resp != -1 ) - { - for ( j = 0; j < bands; j++ ) - { - int16_t abs_active_bins = pFb->fb_bin_to_band.pFb_active_bins_per_band[j]; - int16_t abs_start_offset = pFb->fb_bin_to_band.pFb_start_bin_per_band[j]; -#ifdef IVAS_FLOAT_FIXED - Word16 exp_diff = 0, tmp; -#endif - - for ( i = 0; i < abs_active_bins; i++ ) - { - pFb->fb_bin_to_band.pFb_bin_to_band[j][i] /= ppFilterbank_FRs_s[i + abs_start_offset]; -#ifdef IVAS_FLOAT_FIXED - tmp = BASOP_Util_Divide3232_Scale( pFb->fb_bin_to_band.pFb_bin_to_band_fx[j][i], ppFilterbank_FRs_s_fx[i + abs_start_offset], &exp_diff ); - pFb->fb_bin_to_band.pFb_bin_to_band_fx[j][i] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22 -#endif - /*if(pFb->fb_bin_to_band.pFb_bin_to_band[j][i] > 0.5f) - { - num_active_bands = j + 1; - break; - }*/ - } - } - } - - return num_active_bands; -} - #ifdef IVAS_FLOAT_FIXED static Word16 ivas_calculate_abs_fr_fx( ivas_filterbank_t *pFb, @@ -1945,6 +1234,7 @@ static Word16 ivas_calculate_abs_fr_fx( Word16 frame_len; Word32 ppFilterbank_FRs_s_fx[L_FRAME48k]; Word16 bands = pFb->filterbank_num_bands; + move16(); Word16 i, j, num_active_bands = 0; move16(); Word16 idx_short_stride_bin_to_band = 0; @@ -1975,8 +1265,12 @@ static Word16 ivas_calculate_abs_fr_fx( move16(); Word16 short_stride = pFb->fb_bin_to_band.short_stride; move16(); - const Word16 num_bins_per_short_stride_bin = ( const Word16 )( ( sampling_rate / FRAMES_PER_SEC ) / short_stride ); - const Word16 num_bins_per_cldfb_band = ( const Word16 )( ( sampling_rate / FRAMES_PER_SEC ) / pFb->fb_bin_to_band.num_cldfb_bands ); + Word32 res_dec1, res_frac, res_dec2; + iDiv_and_mod_32( sampling_rate, FRAMES_PER_SEC, &res_dec1, &res_frac, 0 ); + iDiv_and_mod_32( res_dec1, short_stride, &res_dec2, &res_frac, 0 ); + const Word16 num_bins_per_short_stride_bin = extract_l( res_dec2 ); + iDiv_and_mod_32( res_dec1, pFb->fb_bin_to_band.num_cldfb_bands, &res_dec2, &res_frac, 0 ); + const Word16 num_bins_per_cldfb_band = extract_l( res_dec2 ); Word32 short_stride_max_per_spar_band_fx = 1; move32(); @@ -2010,7 +1304,6 @@ static Word16 ivas_calculate_abs_fr_fx( move32(); sq_abs_fx = BASOP_Util_Add_Mant32Exp( real_sq, real_exp, imag_sq, imag_exp, &sq_abs_e ); // Q22 - move32(); long_mdft_ptr_re_fx++; long_mdft_ptr_im_fx++; @@ -2018,7 +1311,6 @@ static Word16 ivas_calculate_abs_fr_fx( /* accumulate bin energies within a short stride bin */ short_stride_nrg_fx = L_add( short_stride_nrg_fx, L_shl( sq_abs_fx, sub( Q22, sub( Q31, sq_abs_e ) ) ) ); - move32(); IF( !( ( j + 1 ) % num_bins_per_short_stride_bin ) ) { @@ -2026,7 +1318,6 @@ static Word16 ivas_calculate_abs_fr_fx( short_stride_pow_spec_fx[j / num_bins_per_short_stride_bin] = short_stride_nrg_fx; /* energy rather than magnitude works better for covariance weighting*/ move32(); short_stride_max_per_spar_band_fx = L_max( short_stride_nrg_fx, short_stride_max_per_spar_band_fx ); /*compute highest magnitude per band*/ - move32(); short_stride_nrg_fx = 0; move32(); } @@ -2037,10 +1328,9 @@ static Word16 ivas_calculate_abs_fr_fx( IF( !( ( j + 1 ) % num_bins_per_cldfb_band ) ) { Word32 temp = Sqrt32( cldfb_nrg_fx, &cldfb_nrg_e ); - move32(); temp = L_shl( temp, sub( cldfb_nrg_e, Q9 ) ); // Q22 - move32(); pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j / num_bins_per_cldfb_band][i] = temp; + move32(); cldfb_nrg_fx = 0; move32(); cldfb_nrg_e = 0; @@ -2052,14 +1342,12 @@ static Word16 ivas_calculate_abs_fr_fx( FOR( j = 0; j < short_stride; j++ ) { tmp = BASOP_Util_Divide3232_Scale( short_stride_pow_spec_fx[j], short_stride_max_per_spar_band_fx, &exp_diff ); - move16(); short_stride_pow_spec_fx[j] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22 move32(); short_stride_pow_spec_fx[j] = L_max( L_sub( short_stride_pow_spec_fx[j], 1258291 ), 0 ); // 0.3f * ONE_IN_Q22c move32(); tmp = BASOP_Util_Divide3232_Scale( short_stride_pow_spec_fx[j], 2936012, &exp_diff ); // 0.7f * ONE_IN_Q22 - move16(); - short_stride_pow_spec_fx[j] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22 + short_stride_pow_spec_fx[j] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22 move32(); IF( short_stride_pow_spec_fx[j] > 0 ) @@ -2103,7 +1391,6 @@ static Word16 ivas_calculate_abs_fr_fx( FOR( i = 0; i < bands; i++ ) { sum_over_spar_bands_fx = L_add( sum_over_spar_bands_fx, pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i] ); - move32(); IF( pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i] > max_spar_band_contribution_fx ) { @@ -2115,7 +1402,6 @@ static Word16 ivas_calculate_abs_fr_fx( } sum_over_spar_bands_fx = L_max( sum_over_spar_bands_fx, EPSILON_FX ); - move32(); FOR( i = 0; i < bands; i++ ) { @@ -2133,7 +1419,6 @@ static Word16 ivas_calculate_abs_fr_fx( Word16 exp_diff = 0; move16(); Word16 tmp = BASOP_Util_Divide3232_Scale( pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i], sum_over_spar_bands_fx, &exp_diff ); - move16(); pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22 move32(); } @@ -2174,32 +1459,24 @@ static Word16 ivas_calculate_abs_fr_fx( Word16 exp_diff = 0; move16(); Word32 real = L_shr( *pFilterbank_bin_to_band_re_fx, 3 ); // Q27 - move32(); Word32 imag = L_shr( *pFilterbank_bin_to_band_im_fx, 3 ); - move32(); Word32 real_sq, imag_sq; real_sq = Mpy_32_32( real, real ); - move32(); imag_sq = Mpy_32_32( imag, imag ); - move32(); temp_fx = L_add( L_shr( real_sq, 1 ), L_shr( imag_sq, 1 ) ); // Q22 - move32(); exp_diff = 9; move16(); temp_fx = Sqrt32( temp_fx, &exp_diff ); - move32(); temp_fx = L_shl( temp_fx, sub( exp_diff, Q9 ) ); // Q22 - move32(); pFilterbank_bin_to_band_re_fx++; pFilterbank_bin_to_band_im_fx++; temp_fx = L_sub( temp_fx, 1258291 ); - move32(); if ( temp_fx < 0 ) { @@ -2267,36 +1544,6 @@ static Word16 ivas_calculate_abs_fr_fx( * *-----------------------------------------------------------------------------------------*/ -static void ivas_get_active_bins( - const int16_t **pActive_bins, - const int16_t **pActive_bins_abs, - const int16_t **pStart_offset, - const int16_t **pStart_offset_abs, - const int32_t sampling_rate ) -{ - int16_t sr_idx; - - if ( sampling_rate == 32000 ) - { - sr_idx = 1; - } - else if ( sampling_rate == 16000 ) - { - sr_idx = 2; - } - else - { - sr_idx = 0; - } - - *pActive_bins_abs = ivas_fb_abs_bins_per_band_12band_1ms[sr_idx]; - *pActive_bins = ivas_fb_bins_per_band_12band_1ms[sr_idx]; - *pStart_offset_abs = ivas_fb_abs_bins_start_offset_12band_1ms[sr_idx]; - *pStart_offset = ivas_fb_bins_start_offset_12band_1ms[sr_idx]; - - return; -} - #ifdef IVAS_FLOAT_FIXED static void ivas_get_active_bins_fx( const Word16 **pActive_bins, @@ -2343,168 +1590,6 @@ static void ivas_get_active_bins_fx( * Filterbank setup, initialization *-----------------------------------------------------------------------------------------*/ -static ivas_error ivas_filterbank_setup( - IVAS_FB_MIXER_HANDLE hFbMixer, - const int32_t sampling_rate ) -{ - int16_t i, j; - const float *pAll_fb_fr[2]; - const int16_t *pAll_bins_start_offset = NULL; - const int16_t *pAll_bins_per_band = NULL; - const int16_t *pAll_bins_start_offset_abs = NULL; - const int16_t *pAll_bins_per_band_abs = NULL; - const int16_t *pAll_bins_per_band_48k = NULL; - ivas_error error; - IVAS_FB_CFG *pCfg = hFbMixer->fb_cfg; - - error = IVAS_ERR_OK; - - if ( pCfg->num_out_chans > 0 ) - { - hFbMixer->pFb->filterbank_num_bands = ivas_get_num_bands( sampling_rate ); - - ivas_get_active_bins( &pAll_bins_per_band, &pAll_bins_per_band_abs, &pAll_bins_start_offset, &pAll_bins_start_offset_abs, sampling_rate ); - - if ( pCfg->fb_latency == NS2SA( sampling_rate, DELAY_FB_1_NS ) ) - { - pAll_fb_fr[0] = ivas_fb_fr_12band_1ms_re; - pAll_fb_fr[1] = ivas_fb_fr_12band_1ms_im; - pAll_bins_per_band_48k = ivas_fb_bins_per_band_12band_1ms[0]; - } - else - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong FB in ivas_filterbank_setup()!" ); - } - } - - hFbMixer->cross_fade_end_offset = pCfg->fade_len + pCfg->pcm_offset; - hFbMixer->cross_fade_start_offset = hFbMixer->cross_fade_end_offset - pCfg->fade_len; - hFbMixer->ana_window_offset = pCfg->fb_latency + pCfg->pcm_offset; - - if ( ( error = ivas_fb_mixer_get_window( pCfg->fb_latency, sampling_rate, &( hFbMixer->pAna_window ) ) ) != IVAS_ERR_OK ) - { - return error; - } -#ifdef IVAS_FLOAT_FIXED - IF( ( error = ivas_fb_mixer_get_window_fx( pCfg->fb_latency, sampling_rate, &( hFbMixer->pAna_window_fx ) ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif - - if ( ( error = ivas_fb_mixer_get_window( pCfg->fade_len, sampling_rate, &( hFbMixer->pFilterbank_cross_fade ) ) ) != IVAS_ERR_OK ) - { - return error; - } - -#ifdef IVAS_FLOAT_FIXED - if ( ( error = ivas_fb_mixer_get_window_fx( pCfg->fade_len, sampling_rate, &( hFbMixer->pFilterbank_cross_fade_fx ) ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif - - if ( pCfg->num_out_chans > 0 ) - { - ivas_filterbank_t *pFb = hFbMixer->pFb; - int16_t offset = 0; - - pFb->fb_consts.pFilterbank_bins_per_band = pAll_bins_per_band; - pFb->fb_consts.pFilterbank_bins_start_offset = pAll_bins_start_offset; - pFb->fb_bin_to_band.pFb_active_bins_per_band = pAll_bins_per_band_abs; - pFb->fb_bin_to_band.pFb_start_bin_per_band = pAll_bins_start_offset_abs; - - /* Initialization for short stride Parameter calculation and SPAR CLDFB reconstruction */ - pFb->fb_bin_to_band.num_cldfb_bands = (int16_t) ( sampling_rate * INV_CLDFB_BANDWIDTH + 0.5f ); - /*pFb->fb_bin_to_band.cldfb_stride = ( int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX );*/ /* equals num_cldfb_bands*/ - pFb->fb_bin_to_band.short_stride = (int16_t) ( ( sampling_rate / FRAMES_PER_SEC ) / 4 ); - set_f( pFb->fb_bin_to_band.p_short_stride_bin_to_band, 0.0f, 2 * MDFT_FB_BANDS_240 ); -#ifdef IVAS_FLOAT_FIXED - set32_fx( pFb->fb_bin_to_band.p_short_stride_bin_to_band_fx, 0, 2 * MDFT_FB_BANDS_240 ); -#endif - set_s( pFb->fb_bin_to_band.p_cldfb_map_to_spar_band, 0, CLDFB_NO_CHANNELS_MAX ); - set_s( pFb->fb_bin_to_band.p_spar_start_bands, 0, CLDFB_NO_CHANNELS_MAX ); - - for ( j = 0; j < IVAS_MAX_NUM_FB_BANDS; j++ ) - { - pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[j] = 0; /* aka num_active_bins per SPAR band */ - pFb->fb_bin_to_band.p_short_stride_start_bin_per_band[j] = 0; /* first considered bin index per SPAR band */ - pFb->fb_bin_to_band.pp_short_stride_bin_to_band[j] = NULL; -#ifdef IVAS_FLOAT_FIXED - pFb->fb_bin_to_band.pp_short_stride_bin_to_band_fx[j] = NULL; -#endif - for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band[i][j] = 0.0f; - } - } - if ( sampling_rate == 48000 ) - { - for ( j = 0; j < pFb->filterbank_num_bands; j++ ) - { - pFb->fb_consts.ppFilterbank_FRs[0][j] = &pAll_fb_fr[0][offset]; - pFb->fb_consts.ppFilterbank_FRs[1][j] = &pAll_fb_fr[1][offset]; - offset += pFb->fb_consts.pFilterbank_bins_per_band[j]; - } - - ivas_calculate_abs_fr( pFb, sampling_rate, pCfg->active_w_mixing ); - } - else - { - float *ppFilterbank_FRs_re_temp[MAX_NUM_BANDS_DIFF_NON48K]; - float *ppFilterbank_FRs_im_temp[MAX_NUM_BANDS_DIFF_NON48K]; - int16_t active_bins_temp[MAX_NUM_BANDS_DIFF_NON48K]; - int16_t start_offset_temp[MAX_NUM_BANDS_DIFF_NON48K]; - int16_t num_diff_bands, start_diff_band_non48k; - - num_diff_bands = MAX_NUM_BANDS_DIFF_NON48K; - start_diff_band_non48k = pFb->filterbank_num_bands - num_diff_bands; - - pFb->fb_consts.pFilterbank_bins_per_band = pAll_bins_per_band; - pFb->fb_consts.pFilterbank_bins_start_offset = pAll_bins_start_offset; - - for ( j = 0; j < pFb->filterbank_num_bands; j++ ) - { - int16_t num_active_bins = pFb->fb_consts.pFilterbank_bins_per_band[j]; - - if ( j < start_diff_band_non48k ) - { - pFb->fb_consts.ppFilterbank_FRs[0][j] = &pAll_fb_fr[0][offset]; - pFb->fb_consts.ppFilterbank_FRs[1][j] = &pAll_fb_fr[1][offset]; - } - else - { - mvr2r( &pAll_fb_fr[0][offset], pFb->fb_consts.ppFilterbank_FRs_non48k[0][j], num_active_bins ); - mvr2r( &pAll_fb_fr[1][offset], pFb->fb_consts.ppFilterbank_FRs_non48k[1][j], num_active_bins ); - } - - offset += pAll_bins_per_band_48k[j]; - } - - for ( j = start_diff_band_non48k; j < pFb->filterbank_num_bands; j++ ) - { - ppFilterbank_FRs_re_temp[j - start_diff_band_non48k] = pFb->fb_consts.ppFilterbank_FRs_non48k[0][j]; - ppFilterbank_FRs_im_temp[j - start_diff_band_non48k] = pFb->fb_consts.ppFilterbank_FRs_non48k[1][j]; - active_bins_temp[j - start_diff_band_non48k] = pFb->fb_consts.pFilterbank_bins_per_band[j]; - start_offset_temp[j - start_diff_band_non48k] = pFb->fb_consts.pFilterbank_bins_start_offset[j]; - } - - ivas_get_ld_fb_resp( ppFilterbank_FRs_re_temp, ppFilterbank_FRs_im_temp, ppFilterbank_FRs_re_temp, ppFilterbank_FRs_im_temp, - active_bins_temp, start_offset_temp, num_diff_bands, pCfg->fb_latency, sampling_rate ); - - for ( j = start_diff_band_non48k; j < pFb->filterbank_num_bands; j++ ) - { - pFb->fb_consts.ppFilterbank_FRs[0][j] = (const float *) pFb->fb_consts.ppFilterbank_FRs_non48k[0][j]; - pFb->fb_consts.ppFilterbank_FRs[1][j] = (const float *) pFb->fb_consts.ppFilterbank_FRs_non48k[1][j]; - } - - ivas_calculate_abs_fr( pFb, sampling_rate, pCfg->active_w_mixing ); - } - } - - return error; -} - #ifdef IVAS_FLOAT_FIXED static ivas_error ivas_filterbank_setup_fx( IVAS_FB_MIXER_HANDLE hFbMixer, @@ -2595,7 +1680,7 @@ static ivas_error ivas_filterbank_setup_fx( /*pFb->fb_bin_to_band.cldfb_stride = ( int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX );*/ /* equals num_cldfb_bands*/ // pFb->fb_bin_to_band.short_stride = extract_l( ( sampling_rate / FRAMES_PER_SEC ) / 4 ); tmp = BASOP_Util_Divide3232_Scale( sampling_rate, FRAMES_PER_SEC, &exp ); - pFb->fb_bin_to_band.short_stride = shr( tmp, sub( 15, exp ) + 2 ); + pFb->fb_bin_to_band.short_stride = shr( tmp, add( sub( 15, exp ), 2 ) ); move16(); @@ -2710,58 +1795,6 @@ static ivas_error ivas_filterbank_setup_fx( * *-----------------------------------------------------------------------------------------*/ -static ivas_error ivas_fb_mixer_get_window( - const int16_t fade_len, /* i : window fading length in samples */ - const int32_t sampling_rate, /* i : sampling rate */ - const float **pWindow /* o : pointer to the window coefficents */ -) -{ - ivas_error error; - - error = IVAS_ERR_OK; - - if ( fade_len == NS2SA( sampling_rate, DELAY_FB_4_NS ) ) - { - switch ( sampling_rate ) - { - case 48000: - *pWindow = ivas_fb_cf_4ms_48k; - break; - case 32000: - *pWindow = ivas_fb_cf_4ms_32k; - break; - case 16000: - *pWindow = ivas_fb_cf_4ms_16k; - break; - default: - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Unsupported Sampling frequency!" ); - } - } - else if ( fade_len == NS2SA( sampling_rate, DELAY_FB_1_NS ) ) - { - switch ( sampling_rate ) - { - case 48000: - *pWindow = ivas_fb_cf_1ms_48k; - break; - case 32000: - *pWindow = ivas_fb_cf_1ms_32k; - break; - case 16000: - *pWindow = ivas_fb_cf_1ms_16k; - break; - default: - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Unsupported Sampling frequency!" ); - } - } - else - { - IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Incorrect FB window fade len (%f ms)\n", ( fade_len / 1000000.f ) ); - } - - return error; -} - #ifdef IVAS_FLOAT_FIXED static ivas_error ivas_fb_mixer_get_window_fx( const Word16 fade_len, /* i : window fading length in samples */ @@ -2818,26 +1851,6 @@ static ivas_error ivas_fb_mixer_get_window_fx( #endif -static const float *ivas_get_cheby_ramp( - const int16_t delay ) -{ - const float *pCheby = NULL; - - switch ( delay ) - { - case IVAS_FB_1MS_32K_SAMP: - pCheby = ivas_fb_resp_cheby_ramp_32del; - break; - case IVAS_FB_1MS_16K_SAMP: - pCheby = ivas_fb_resp_cheby_ramp_16del; - break; - default: - assert( !"Unsupported cheby ramp length!" ); - } - - return pCheby; -} - #ifdef IVAS_FLOAT_FIXED static const Word32 *ivas_get_cheby_ramp_fx( const Word16 delay ) @@ -2860,139 +1873,6 @@ static const Word32 *ivas_get_cheby_ramp_fx( } #endif - -/*get first half of the hanning window*/ -static void ivas_get_hanning_win( - const int16_t len, - float *pH_win ) -{ - int16_t i; - - for ( i = 0; i < len; i++ ) - { - pH_win[i] = 0.5f * ( 1.0f - cosf( ( PI2 * ( i + 1 ) ) / ( ( 2 * len ) + 1 ) ) ); - } - - return; -} - - -static void ivas_get_ld_fb_resp( - float **ppIdeal_FRs_re, - float **ppIdeal_FRs_im, - float **ppNew_FRs_re, - float **ppNew_FRs_im, - const int16_t *pActive_bins, - const int16_t *pStart_offset, - const int16_t num_bands, - const int16_t delay, - const int32_t sampling_rate ) -{ - int16_t b, s, frame_len; - const float *pCheby; - - /*common scratch buffers for computing impulse/frequency responses, - pre-ring, post-ring and circular shifted outputs to optimize stack*/ - float scratch1[L_FRAME32k * 2]; - float scratch2[L_FRAME32k * 2]; - float han_win[L_FRAME32k]; - - frame_len = (int16_t) ( sampling_rate / FRAMES_PER_SEC ); - pCheby = ivas_get_cheby_ramp( delay ); - b = 0; - s = 0; - - assert( sampling_rate == 32000 || sampling_rate == 16000 ); - - ivas_get_hanning_win( frame_len, han_win ); - for ( b = 0; b < num_bands; b++ ) - { - set_f( scratch2, 0, frame_len << 1 ); - mvr2r( ppIdeal_FRs_re[b], &scratch2[pStart_offset[b]], pActive_bins[b] ); - mvr2r( ppIdeal_FRs_im[b], &scratch2[frame_len + pStart_offset[b]], pActive_bins[b] ); - ivas_imdft( scratch2, &scratch2[frame_len], scratch1, frame_len ); - - /*apply circular shift and hanning window*/ - - for ( s = delay; s < frame_len + delay; s++ ) - { - scratch2[s - delay] = scratch1[s] * ( 1 - han_win[s - delay] ); - } - - for ( ; s < 2 * frame_len; s++ ) - { - scratch2[s - delay] = scratch1[s] * han_win[s - ( frame_len + delay )]; - } - - for ( s = 0; s < delay; s++ ) - { - scratch2[2 * frame_len - delay + s] = -1 * scratch1[s] * han_win[frame_len - delay + s]; - } - - /*apply heavy/cheby ramp window and compute pre ring*/ - - for ( s = 0; s < delay + 1; s++ ) - { - scratch1[s] = scratch2[s] * pCheby[delay - s]; - } - - for ( ; s < frame_len; s++ ) - { - scratch1[s] = 0; - } - - for ( ; s < 2 * frame_len - delay; s++ ) - { - scratch1[s] = scratch2[s]; - } - - for ( ; s < 2 * frame_len; s++ ) - { - scratch1[s] = scratch2[s] * ( 1 - pCheby[s - ( 2 * frame_len - delay )] ); - } - - /*IR - pre ring + post ring*/ - for ( s = 1; s < 2 * frame_len; s++ ) - { - scratch2[s] = scratch2[s] /*pre ring*/ - scratch1[s] /*post ring*/ - scratch1[( 2 * frame_len ) - s]; - } - - for ( s = 0; s < 2 * frame_len - delay; s++ ) - { - scratch1[s + delay] = scratch2[s]; - } - - for ( ; s < 2 * frame_len; s++ ) - { - scratch1[s - ( 2 * frame_len - delay )] = -1 * ( scratch2[s] ); - } - - /* apply final window*/ - for ( s = 0; s < delay; s++ ) - { - scratch1[s] = scratch1[s] * sinf( ( EVS_PI * ( s + 1 ) ) / ( 2 * delay ) ); - } - - for ( s = 2 * delay; s < frame_len + 1; s++ ) - { - scratch1[s] = scratch1[s] * sinf( ( EVS_PI * ( frame_len - s ) ) / ( 2 * ( frame_len + 1 - ( 2 * delay ) ) ) ); - } - - for ( ; s < 2 * frame_len; s++ ) - { - scratch1[s] = 0; - } - - /*compute frequency response*/ - ivas_mdft( scratch1, scratch2, &scratch2[frame_len], frame_len << 1, frame_len ); - - mvr2r( &scratch2[pStart_offset[b]], ppNew_FRs_re[b], pActive_bins[b] ); - mvr2r( &scratch2[frame_len + pStart_offset[b]], ppNew_FRs_im[b], pActive_bins[b] ); - } - - return; -} - #ifdef IVAS_FLOAT_FIXED static void ivas_get_ld_fb_resp_fx( Word32 **ppIdeal_FRs_re_fx, diff --git a/lib_com/ivas_mc_param_com.c b/lib_com/ivas_mc_param_com.c index dc26644b9..a20b9b3af 100644 --- a/lib_com/ivas_mc_param_com.c +++ b/lib_com/ivas_mc_param_com.c @@ -51,10 +51,11 @@ * Local function prototypes *------------------------------------------------------------------------*/ -static void ivas_param_mc_set_coding_scheme( const MC_LS_SETUP mc_ls_setup, const int32_t ivas_total_brate, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC ); #ifdef IVAS_FLOAT_FIXED static void ivas_param_mc_set_coding_scheme_fx( const MC_LS_SETUP mc_ls_setup, const Word32 ivas_total_brate, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC ); +#else +static void ivas_param_mc_set_coding_scheme( const MC_LS_SETUP mc_ls_setup, const int32_t ivas_total_brate, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC ); #endif /*------------------------------------------------------------------------- @@ -195,12 +196,11 @@ void ivas_param_mc_metadata_open_fx( return; } -#endif - +#else void ivas_param_mc_metadata_open( - const MC_LS_SETUP mc_ls_setup, /* i : MC ls setup */ + const MC_LS_SETUP mc_ls_setup, /* i : MC ls setup */ #ifndef FIX_901_PARAMMC_DEAD_CODE - const int16_t lfe_index, /* i : channel index of LFE */ + const int16_t lfe_index, /* i : channel index of LFE */ #endif const int32_t ivas_total_brate, /* i : IVAS total bitrate */ HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* o : handle for the Parametric MC parameter coding state */ @@ -253,9 +253,10 @@ void ivas_param_mc_metadata_open( #endif hMetadataPMC->icc_mapping_conf = ivas_param_mc_conf[config_index].icc_mapping_conf; hMetadataPMC->ild_mapping_conf = ivas_param_mc_conf[config_index].ild_mapping_conf; - hMetadataPMC->ild_factors = ivas_param_mc_conf[config_index].ild_factors; #ifdef IVAS_FLOAT_FIXED hMetadataPMC->ild_factors_fx = ivas_param_mc_conf[config_index].ild_factors_fx; /*Q15*/ +#else + hMetadataPMC->ild_factors = ivas_param_mc_conf[config_index].ild_factors; #endif #ifndef FIX_901_PARAMMC_DEAD_CODE @@ -282,6 +283,7 @@ void ivas_param_mc_metadata_open( return; } +#endif /*------------------------------------------------------------------------- * ivas_param_mc_set_coded_bands() @@ -924,8 +926,7 @@ static void ivas_param_mc_set_coding_scheme_fx( return; } -#endif - +#else static void ivas_param_mc_set_coding_scheme( const MC_LS_SETUP mc_ls_setup, /* i : MC ls setup */ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ @@ -941,10 +942,11 @@ static void ivas_param_mc_set_coding_scheme( hMetadataPMC->icc_coding.sym_freq = &ivas_param_mc_sym_freq_icc_cicp6_48_16bits[0]; hMetadataPMC->icc_coding.cum_freq_delta = &ivas_param_mc_cum_freq_icc_delta_cicp6_48_16bits[0]; hMetadataPMC->icc_coding.sym_freq_delta = &ivas_param_mc_sym_freq_icc_delta_cicp6_48_16bits[0]; - hMetadataPMC->icc_coding.quantizer = &ivas_param_mc_quant_icc[0]; hMetadataPMC->icc_coding.quantizer_size = PARAM_MC_SZ_ICC_QUANTIZER; #ifdef IVAS_FLOAT_FIXED hMetadataPMC->icc_coding.quantizer_fx = &ivas_param_mc_quant_icc_fx[0]; +#else + hMetadataPMC->icc_coding.quantizer = &ivas_param_mc_quant_icc[0]; #endif hMetadataPMC->icc_coding.uni_bits = PARAM_MC_NUM_BITS_ICC_SCALAR_QUANT; /* ILD */ @@ -952,9 +954,10 @@ static void ivas_param_mc_set_coding_scheme( hMetadataPMC->ild_coding.sym_freq = &ivas_param_mc_sym_freq_ild_cicp6_48_16bits[0]; hMetadataPMC->ild_coding.cum_freq_delta = &ivas_param_mc_cum_freq_ild_delta_cicp6_48_16bits[0]; hMetadataPMC->ild_coding.sym_freq_delta = &ivas_param_mc_sym_freq_ild_delta_cicp6_48_16bits[0]; - hMetadataPMC->ild_coding.quantizer = &ivas_param_mc_quant_ild_5d1_48[0]; #ifdef IVAS_FLOAT_FIXED hMetadataPMC->ild_coding.quantizer_fx = &ivas_param_mc_quant_ild_5d1_48_fx[0]; +#else + hMetadataPMC->ild_coding.quantizer = &ivas_param_mc_quant_ild_5d1_48[0]; #endif hMetadataPMC->ild_coding.quantizer_size = PARAM_MC_SZ_ILD_QUANTIZER_4BITS; hMetadataPMC->ild_coding.uni_bits = PARAM_MC_NUM_BITS_ILD_SCALAR_QUANT; @@ -965,9 +968,10 @@ static void ivas_param_mc_set_coding_scheme( hMetadataPMC->icc_coding.sym_freq = &ivas_param_mc_sym_freq_icc_cicp12_48_16bits[0]; hMetadataPMC->icc_coding.cum_freq_delta = &ivas_param_mc_cum_freq_icc_delta_cicp12_48_16bits[0]; hMetadataPMC->icc_coding.sym_freq_delta = &ivas_param_mc_sym_freq_icc_delta_cicp12_48_16bits[0]; - hMetadataPMC->icc_coding.quantizer = &ivas_param_mc_quant_icc[0]; #ifdef IVAS_FLOAT_FIXED hMetadataPMC->icc_coding.quantizer_fx = &ivas_param_mc_quant_icc_fx[0]; // Q15 +#else + hMetadataPMC->icc_coding.quantizer = &ivas_param_mc_quant_icc[0]; #endif hMetadataPMC->icc_coding.quantizer_size = PARAM_MC_SZ_ICC_QUANTIZER; hMetadataPMC->icc_coding.uni_bits = PARAM_MC_NUM_BITS_ICC_SCALAR_QUANT; @@ -976,9 +980,10 @@ static void ivas_param_mc_set_coding_scheme( hMetadataPMC->ild_coding.sym_freq = &ivas_param_mc_sym_freq_ild_cicp12_48_16bits[0]; hMetadataPMC->ild_coding.cum_freq_delta = &ivas_param_mc_cum_freq_ild_delta_cicp12_48_16bits[0]; hMetadataPMC->ild_coding.sym_freq_delta = &ivas_param_mc_sym_freq_ild_delta_cicp12_48_16bits[0]; - hMetadataPMC->ild_coding.quantizer = &ivas_param_mc_quant_ild_5d1_48[0]; #ifdef IVAS_FLOAT_FIXED hMetadataPMC->ild_coding.quantizer_fx = &ivas_param_mc_quant_ild_5d1_48_fx[0]; // Q8 +#else + hMetadataPMC->ild_coding.quantizer = &ivas_param_mc_quant_ild_5d1_48[0]; #endif hMetadataPMC->ild_coding.quantizer_size = PARAM_MC_SZ_ILD_QUANTIZER_4BITS; hMetadataPMC->ild_coding.uni_bits = PARAM_MC_NUM_BITS_ILD_SCALAR_QUANT; @@ -989,9 +994,10 @@ static void ivas_param_mc_set_coding_scheme( hMetadataPMC->icc_coding.sym_freq = &ivas_param_mc_sym_freq_icc_cicp14_48_16bits[0]; hMetadataPMC->icc_coding.cum_freq_delta = &ivas_param_mc_cum_freq_icc_delta_cicp14_48_16bits[0]; hMetadataPMC->icc_coding.sym_freq_delta = &ivas_param_mc_sym_freq_icc_delta_cicp14_48_16bits[0]; - hMetadataPMC->icc_coding.quantizer = &ivas_param_mc_quant_icc[0]; #ifdef IVAS_FLOAT_FIXED hMetadataPMC->icc_coding.quantizer_fx = &ivas_param_mc_quant_icc_fx[0]; // Q15 +#else + hMetadataPMC->icc_coding.quantizer = &ivas_param_mc_quant_icc[0]; #endif hMetadataPMC->icc_coding.quantizer_size = PARAM_MC_SZ_ICC_QUANTIZER; hMetadataPMC->icc_coding.uni_bits = PARAM_MC_NUM_BITS_ICC_SCALAR_QUANT; @@ -1000,9 +1006,10 @@ static void ivas_param_mc_set_coding_scheme( hMetadataPMC->ild_coding.sym_freq = &ivas_param_mc_sym_freq_ild_cicp14_48_16bits[0]; hMetadataPMC->ild_coding.cum_freq_delta = &ivas_param_mc_cum_freq_ild_delta_cicp14_48_16bits[0]; hMetadataPMC->ild_coding.sym_freq_delta = &ivas_param_mc_sym_freq_ild_delta_cicp14_48_16bits[0]; - hMetadataPMC->ild_coding.quantizer = &ivas_param_mc_quant_ild_5d1_48[0]; #ifdef IVAS_FLOAT_FIXED hMetadataPMC->ild_coding.quantizer_fx = &ivas_param_mc_quant_ild_5d1_48_fx[0]; // Q8 +#else + hMetadataPMC->ild_coding.quantizer = &ivas_param_mc_quant_ild_5d1_48[0]; #endif hMetadataPMC->ild_coding.quantizer_size = PARAM_MC_SZ_ILD_QUANTIZER_4BITS; hMetadataPMC->ild_coding.uni_bits = PARAM_MC_NUM_BITS_ILD_SCALAR_QUANT; @@ -1014,9 +1021,10 @@ static void ivas_param_mc_set_coding_scheme( hMetadataPMC->icc_coding.sym_freq = &ivas_param_mc_sym_freq_icc_combined_48_16bits[0]; hMetadataPMC->icc_coding.cum_freq_delta = &ivas_param_mc_cum_freq_icc_delta_combined_48_16bits[0]; hMetadataPMC->icc_coding.sym_freq_delta = &ivas_param_mc_sym_freq_icc_delta_combined_48_16bits[0]; - hMetadataPMC->icc_coding.quantizer = &ivas_param_mc_quant_icc[0]; #ifdef IVAS_FLOAT_FIXED hMetadataPMC->icc_coding.quantizer_fx = &ivas_param_mc_quant_icc_fx[0]; // Q15 +#else + hMetadataPMC->icc_coding.quantizer = &ivas_param_mc_quant_icc[0]; #endif hMetadataPMC->icc_coding.quantizer_size = PARAM_MC_SZ_ICC_QUANTIZER; hMetadataPMC->icc_coding.uni_bits = PARAM_MC_NUM_BITS_ICC_SCALAR_QUANT; @@ -1025,9 +1033,10 @@ static void ivas_param_mc_set_coding_scheme( hMetadataPMC->ild_coding.sym_freq = &ivas_param_mc_sym_freq_ild_combined_48_16bits[0]; hMetadataPMC->ild_coding.cum_freq_delta = &ivas_param_mc_cum_freq_ild_delta_combined_48_16bits[0]; hMetadataPMC->ild_coding.sym_freq_delta = &ivas_param_mc_sym_freq_ild_delta_combined_48_16bits[0]; - hMetadataPMC->ild_coding.quantizer = &ivas_param_mc_quant_ild_5d1_48[0]; #ifdef IVAS_FLOAT_FIXED hMetadataPMC->ild_coding.quantizer_fx = &ivas_param_mc_quant_ild_5d1_48_fx[0]; // Q8 +#else + hMetadataPMC->ild_coding.quantizer = &ivas_param_mc_quant_ild_5d1_48[0]; #endif hMetadataPMC->ild_coding.quantizer_size = PARAM_MC_SZ_ILD_QUANTIZER_4BITS; hMetadataPMC->ild_coding.uni_bits = PARAM_MC_NUM_BITS_ILD_SCALAR_QUANT; @@ -1040,3 +1049,4 @@ static void ivas_param_mc_set_coding_scheme( return; } +#endif diff --git a/lib_com/ivas_mdct_imdct.c b/lib_com/ivas_mdct_imdct.c index d4e756775..2d0c824e3 100644 --- a/lib_com/ivas_mdct_imdct.c +++ b/lib_com/ivas_mdct_imdct.c @@ -39,6 +39,7 @@ #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ @@ -56,7 +57,6 @@ * Time domain aliasing *-----------------------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED void ivas_tda( const float *pIn, /* i : time domain buffer of size 2*length */ float *pOut, /* o : time domain buffer of size length */ @@ -74,7 +74,6 @@ void ivas_tda( return; } -#endif /*-----------------------------------------------------------------------------------------* * Function ivas_dct_windowing() @@ -378,3 +377,4 @@ float ivas_get_mdct_scaling_gain( return gain; } +#endif diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index d845d8778..6b5cf7868 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4043,7 +4043,6 @@ void ivas_mc_paramupmix_dec_render( float *input_f[], /* i : core-coder transport channels */ float *output_f[] /* i/o: synthesized core-coder transport channels */ ); -#endif void ivas_param_mc_metadata_open( const MC_LS_SETUP mc_ls_setup, /* i : MC ls setup */ #ifndef FIX_901_PARAMMC_DEAD_CODE @@ -4052,6 +4051,7 @@ void ivas_param_mc_metadata_open( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* o : handle for the Parametric MC parameter coding state */ ); +#endif void ivas_param_mc_set_coded_bands( HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* i/o: handle for the Parametric MC parameter coding state */ @@ -4459,12 +4459,14 @@ void ivas_spar_agc_dec_close( ivas_agc_dec_state_t **hAgcDec /* i/o: AGC decoder handle */ ); +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_spar_md_enc_init ( ivas_spar_md_enc_state_t *hMdEnc, /* o : MD encoder handle */ const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ const int16_t sba_order /* i : Ambisonic (SBA) order */ ); +#endif void ivas_agc_dec_process( ivas_agc_dec_state_t *hAgcDec, /* i/o: AGC decoder handle */ @@ -4522,6 +4524,7 @@ int16_t ivas_get_sba_num_TCs( const int16_t sba_order /* i : IVAS SBA order */ ); +#ifndef IVAS_FLOAT_FIXED void ivas_spar_set_bitrate_config( ivas_spar_md_com_cfg *pSpar_md_cfg, /* i/o: SPAR MD config. handle */ const int16_t table_idx, /* i : config. table index */ @@ -4531,6 +4534,7 @@ void ivas_spar_set_bitrate_config( const int16_t pca_flag, const int16_t agc_flag ); +#endif void ivas_spar_bitrate_dist( int32_t core_brates_act[], /* o : bitrates per core-coder */ @@ -4939,15 +4943,6 @@ void ivas_pca_enc_init( PCA_ENC_STATE *hPCA /* i/o: PCA encoder structure */ ); -void ivas_pca_enc( - const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ - PCA_ENC_STATE *hPCA, /* i : PCA encoder structure */ - BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ - float *data_f[8], /* i : input/transformed audio channels */ - const int16_t input_frame, /* i : input frame length */ - const int16_t n_channels /* i : number of channels */ -); - void ivas_pca_read_bits( Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/ PCA_DEC_STATE *hPCA /* i/o: PCA encoder structure */ @@ -5156,10 +5151,12 @@ void ivas_quantise_real_values( const int16_t dim ); +#ifndef IVAS_FLOAT_FIXED void ivas_spar_get_uniform_quant_strat( ivas_spar_md_com_cfg *pSpar_md_com_cfg, const int16_t table_idx ); +#endif void ivas_spar_quant_dtx_init( ivas_spar_md_t *spar_md, @@ -6202,19 +6199,6 @@ ivas_error ivas_fb_set_cfg( const int16_t nachan_dirac_ana /* i : number of DirAR analysis channels */ ); -ivas_error ivas_FB_mixer_open( - IVAS_FB_MIXER_HANDLE *hFbMixer, /* i/o: FB mixer handle */ - const int32_t sampling_rate, /* i : sampling rate */ - IVAS_FB_CFG *fb_cfg, /* i : FB config. handle */ - const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -); - -void ivas_FB_mixer_close( - IVAS_FB_MIXER_HANDLE *hFbMixer, /* i/o: FB mixer handle */ - const int32_t sampling_rate, /* i : sampling rate in Hz */ - const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -); - void ivas_fb_mixer_pcm_ingest( IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle */ float *pcm_in[], /* i : input audio channels */ @@ -6240,21 +6224,6 @@ void ivas_fb_mixer_get_windowed_fr( const int16_t nchan_fb_in /* i : number of analysis channels */ ); -void ivas_fb_mixer_get_in_out_mapping( - const IVAS_FB_CFG *fb_cfg, /* i : FB config. handle */ - int16_t in_out_mixer_map[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH] /* i/o: mixing mapping */ -); - -void ivas_fb_mixer_cross_fading( - IVAS_FB_MIXER_HANDLE hFbMixer, - float **ppOut_pcm, - float *pMdft_out_old, - float *pMdft_out_new, - const int16_t ch, - const int16_t frame_len, - const int16_t cf_offset -); - /*! r: number of spectral bands */ #ifndef IVAS_FLOAT_FIXED int16_t ivas_get_num_bands_from_bw_idx( diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 5d1a5137a..b93158e31 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2438,6 +2438,11 @@ void ivas_FB_mixer_close_fx( const Word16 spar_reconfig_flag /* i : SPAR reconfiguration flag */ ); +void ivas_fb_mixer_get_in_out_mapping_fx( + const IVAS_FB_CFG *fb_cfg, /* i : FB config. handle */ + Word16 in_out_mixer_map[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH] /* i/o: mixing mapping */ +); + void ivas_fb_mixer_cross_fading_fx( IVAS_FB_MIXER_HANDLE hFbMixer, Word32 **ppOut_pcm_fx, @@ -3826,10 +3831,10 @@ void ivas_fb_mixer_pcm_ingest_fx( Word32 **ppOut_pcm, /* o : output audio channels Qq_ppOut_pcm[] */ const Word16 frame_len, /* i : frame length */ const Word16 HOA_md_ind[IVAS_SPAR_MAX_CH], - Word16 q_data_fix[MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS], + Word16 q_data_fix, Word16 *q_ppOut_pcm ); -void ivas_fb_mixer_process( +void ivas_fb_mixer_process_fx( IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle */ Word32 ***mixer_mat_fx, /* i : mixer matrix in q_mixer_mat_fx */ Word16 *q_mixer_mat_fx, /* i : mixer matrix */ @@ -5311,6 +5316,10 @@ ivas_error ivas_spar_md_enc_open_fx( const Word16 sba_order /* i : Ambisonic (SBA) order */ ); +void ivas_spar_md_enc_close_fx( + ivas_spar_md_enc_state_t **hMdEnc /* i/o: SPAR MD encoder handle */ +); + void ivas_create_fullr_dmx_mat_fx( Word32 pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], /*q_pred_coeffs_re*/ Word16 q_pred_coeffs_re, diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 805900f8f..20529b3d4 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -2680,11 +2680,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = IVAS_48k, &ivas_param_mc_ild_mapping_CICP6_2tc, &ivas_param_mc_icc_mapping_CICP6_2tc, - &ivas_param_mc_dmx_fac_CICP6_2tc[0], - &ivas_param_mc_ild_fac_CICP6_2tc[0], #ifdef IVAS_FLOAT_FIXED &ivas_param_mc_ild_fac_CICP6_2tc_fx[0], &ivas_param_mc_dmx_fac_CICP6_2tc_fx[0] +#else + &ivas_param_mc_ild_fac_CICP6_2tc[0], + &ivas_param_mc_dmx_fac_CICP6_2tc[0], #endif }, /* CICP6 64000 */ @@ -2695,11 +2696,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = IVAS_64k, &ivas_param_mc_ild_mapping_CICP6_2tc, &ivas_param_mc_icc_mapping_CICP6_2tc, - &ivas_param_mc_dmx_fac_CICP6_2tc[0], - &ivas_param_mc_ild_fac_CICP6_2tc[0], #ifdef IVAS_FLOAT_FIXED &ivas_param_mc_ild_fac_CICP6_2tc_fx[0], & ivas_param_mc_dmx_fac_CICP6_2tc_fx[0] +#else + &ivas_param_mc_ild_fac_CICP6_2tc[0], + &ivas_param_mc_dmx_fac_CICP6_2tc[0], #endif }, /* CICP6 80000 */ @@ -2710,11 +2712,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = IVAS_80k, &ivas_param_mc_ild_mapping_CICP6_2tc, &ivas_param_mc_icc_mapping_CICP6_2tc, - &ivas_param_mc_dmx_fac_CICP6_2tc[0], - &ivas_param_mc_ild_fac_CICP6_2tc[0], #ifdef IVAS_FLOAT_FIXED &ivas_param_mc_ild_fac_CICP6_2tc_fx[0], & ivas_param_mc_dmx_fac_CICP6_2tc_fx[0] +#else + &ivas_param_mc_ild_fac_CICP6_2tc[0], + &ivas_param_mc_dmx_fac_CICP6_2tc[0], #endif }, /* CICP12 48000 */ @@ -2725,11 +2728,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = IVAS_48k, &ivas_param_mc_ild_mapping_CICP12_2tc, &ivas_param_mc_icc_mapping_CICP12_2tc, - &ivas_param_mc_dmx_fac_CICP12_2tc[0], - &ivas_param_mc_ild_fac_CICP12_2tc[0], #ifdef IVAS_FLOAT_FIXED &ivas_param_mc_ild_fac_CICP12_2tc_fx[0], &ivas_param_mc_dmx_fac_CICP12_2tc_fx[0] +#else + &ivas_param_mc_ild_fac_CICP12_2tc[0], + &ivas_param_mc_dmx_fac_CICP12_2tc[0], #endif }, /* CICP12 64000 */ @@ -2740,11 +2744,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = IVAS_64k, &ivas_param_mc_ild_mapping_CICP12_2tc, &ivas_param_mc_icc_mapping_CICP12_2tc, - &ivas_param_mc_dmx_fac_CICP12_2tc[0], - &ivas_param_mc_ild_fac_CICP12_2tc[0], #ifdef IVAS_FLOAT_FIXED &ivas_param_mc_ild_fac_CICP12_2tc_fx[0], &ivas_param_mc_dmx_fac_CICP12_2tc_fx[0] +#else + &ivas_param_mc_ild_fac_CICP12_2tc[0], + &ivas_param_mc_dmx_fac_CICP12_2tc[0], #endif }, /* CICP12 80000 */ @@ -2755,11 +2760,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = IVAS_80k, &ivas_param_mc_ild_mapping_CICP12_2tc, &ivas_param_mc_icc_mapping_CICP12_2tc, - &ivas_param_mc_dmx_fac_CICP12_2tc[0], - &ivas_param_mc_ild_fac_CICP12_2tc[0], #ifdef IVAS_FLOAT_FIXED &ivas_param_mc_ild_fac_CICP12_2tc_fx[0], &ivas_param_mc_dmx_fac_CICP12_2tc_fx[0], +#else + &ivas_param_mc_ild_fac_CICP12_2tc[0], + &ivas_param_mc_dmx_fac_CICP12_2tc[0], #endif }, /* CICP12 96000 */ @@ -2770,11 +2776,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = IVAS_96k, &ivas_param_mc_ild_mapping_CICP12_3tc, &ivas_param_mc_icc_mapping_CICP12_3tc, - &ivas_param_mc_dmx_fac_CICP12_3tc[0], - &ivas_param_mc_ild_fac_CICP12_3tc[0], #ifdef IVAS_FLOAT_FIXED &ivas_param_mc_ild_fac_CICP12_3tc_fx[0], &ivas_param_mc_dmx_fac_CICP12_3tc_fx[0] +#else + &ivas_param_mc_ild_fac_CICP12_3tc[0], + &ivas_param_mc_dmx_fac_CICP12_3tc[0], #endif }, /* CICP14 48000 */ @@ -2785,11 +2792,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = IVAS_48k, &ivas_param_mc_ild_mapping_CICP14_2tc, &ivas_param_mc_icc_mapping_CICP14_2tc, - &ivas_param_mc_dmx_fac_CICP14_2tc[0], - &ivas_param_mc_ild_fac_CICP14_2tc[0], #ifdef IVAS_FLOAT_FIXED &ivas_param_mc_ild_fac_CICP14_2tc_fx[0], &ivas_param_mc_dmx_fac_CICP14_2tc_fx[0] +#else + &ivas_param_mc_ild_fac_CICP14_2tc[0], + &ivas_param_mc_dmx_fac_CICP14_2tc[0], #endif }, /* CICP14 64000 */ @@ -2800,11 +2808,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = IVAS_64k, &ivas_param_mc_ild_mapping_CICP14_2tc, &ivas_param_mc_icc_mapping_CICP14_2tc, - &ivas_param_mc_dmx_fac_CICP14_2tc[0], - &ivas_param_mc_ild_fac_CICP14_2tc[0], #ifdef IVAS_FLOAT_FIXED &ivas_param_mc_ild_fac_CICP14_2tc_fx[0], &ivas_param_mc_dmx_fac_CICP14_2tc_fx[0] +#else + &ivas_param_mc_ild_fac_CICP14_2tc[0], + &ivas_param_mc_dmx_fac_CICP14_2tc[0], #endif }, /* CICP14 80000 */ @@ -2815,11 +2824,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = IVAS_80k, &ivas_param_mc_ild_mapping_CICP14_2tc, &ivas_param_mc_icc_mapping_CICP14_2tc, - &ivas_param_mc_dmx_fac_CICP14_2tc[0], - &ivas_param_mc_ild_fac_CICP14_2tc[0], #ifdef IVAS_FLOAT_FIXED &ivas_param_mc_ild_fac_CICP14_2tc_fx[0], - & ivas_param_mc_dmx_fac_CICP14_2tc_fx[0] + &ivas_param_mc_dmx_fac_CICP14_2tc_fx[0] +#else + &ivas_param_mc_ild_fac_CICP14_2tc[0], + &ivas_param_mc_dmx_fac_CICP14_2tc[0], #endif }, /* CICP14 96000 */ @@ -2830,11 +2840,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = IVAS_96k, &ivas_param_mc_ild_mapping_CICP14_3tc, &ivas_param_mc_icc_mapping_CICP14_3tc, - &ivas_param_mc_dmx_fac_CICP14_3tc[0], - &ivas_param_mc_ild_fac_CICP14_3tc[0], #ifdef IVAS_FLOAT_FIXED &ivas_param_mc_ild_fac_CICP14_3tc_fx[0], - & ivas_param_mc_dmx_fac_CICP14_3tc_fx[0] + &ivas_param_mc_dmx_fac_CICP14_3tc_fx[0] +#else + &ivas_param_mc_ild_fac_CICP14_3tc[0], + &ivas_param_mc_dmx_fac_CICP14_3tc[0], #endif }, /* CICP16 96000 */ @@ -2845,11 +2856,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = IVAS_96k, &ivas_param_mc_ild_mapping_CICP16_3tc, &ivas_param_mc_icc_mapping_CICP16_3tc, - &ivas_param_mc_dmx_fac_CICP16_3tc[0], - &ivas_param_mc_ild_fac_CICP16_3tc[0], #ifdef IVAS_FLOAT_FIXED &ivas_param_mc_ild_fac_CICP16_3tc_fx[0], - & ivas_param_mc_dmx_fac_CICP16_3tc_fx[0] + &ivas_param_mc_dmx_fac_CICP16_3tc_fx[0] +#else + &ivas_param_mc_ild_fac_CICP16_3tc[0], + &ivas_param_mc_dmx_fac_CICP16_3tc[0], #endif }, /* CICP16 128000 */ @@ -2860,11 +2872,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = IVAS_128k, &ivas_param_mc_ild_mapping_CICP16_3tc, &ivas_param_mc_icc_mapping_CICP16_3tc, - &ivas_param_mc_dmx_fac_CICP16_3tc[0], - &ivas_param_mc_ild_fac_CICP16_3tc[0], #ifdef IVAS_FLOAT_FIXED &ivas_param_mc_ild_fac_CICP16_3tc_fx[0], - & ivas_param_mc_dmx_fac_CICP16_3tc_fx[0] + &ivas_param_mc_dmx_fac_CICP16_3tc_fx[0] +#else + &ivas_param_mc_ild_fac_CICP16_3tc[0], + &ivas_param_mc_dmx_fac_CICP16_3tc[0], #endif }, /* CICP19 128000 */ @@ -2875,11 +2888,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = IVAS_128k, &ivas_param_mc_ild_mapping_CICP19_3tc, &ivas_param_mc_icc_mapping_CICP19_3tc, - &ivas_param_mc_dmx_fac_CICP19_3tc[0], - &ivas_param_mc_ild_fac_CICP19_3tc[0], #ifdef IVAS_FLOAT_FIXED &ivas_param_mc_ild_fac_CICP19_3tc_fx[0], - & ivas_param_mc_dmx_fac_CICP19_3tc_fx[0] + &ivas_param_mc_dmx_fac_CICP19_3tc_fx[0] +#else + &ivas_param_mc_ild_fac_CICP19_3tc[0], + &ivas_param_mc_dmx_fac_CICP19_3tc[0], #endif } #ifndef FIX_901_PARAMMC_DEAD_CODE diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index bae0da15f..4b206e1ca 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -6961,6 +6961,7 @@ int16_t ivas_get_bits_to_encode( * Set SPAR bitrate config *-----------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_spar_set_bitrate_config( ivas_spar_md_com_cfg *pSpar_md_cfg, /* i/o: SPAR MD config. handle */ const int16_t table_idx, /* i : config. table index */ @@ -7109,8 +7110,7 @@ void ivas_spar_set_bitrate_config( return; } - -#ifdef IVAS_FLOAT_FIXED +#else void ivas_spar_set_bitrate_config_fx( ivas_spar_md_com_cfg *pSpar_md_cfg, /* i/o: SPAR MD config. handle */ const Word16 table_idx, /* i : config. table index */ diff --git a/lib_com/ivas_spar_com_quant_util.c b/lib_com/ivas_spar_com_quant_util.c index 8b0bf766f..f0f509375 100644 --- a/lib_com/ivas_spar_com_quant_util.c +++ b/lib_com/ivas_spar_com_quant_util.c @@ -272,6 +272,7 @@ void ivas_quantise_real_values_enc_fx( * * Sets the quant strat values *-----------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_spar_get_uniform_quant_strat( ivas_spar_md_com_cfg *pSpar_md_com_cfg, const int16_t table_idx ) @@ -343,9 +344,7 @@ void ivas_spar_get_uniform_quant_strat( return; } - - -#ifdef IVAS_FLOAT_FIXED +#else /*-----------------------------------------------------------------------------------------* * Function ivas_spar_get_uniform_quant_strat_fx() * @@ -581,6 +580,7 @@ void ivas_map_prior_coeffs_quant( * * Init SPAR MD with minmax vals *-----------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_spar_quant_dtx_init( ivas_spar_md_t *spar_md, float *min_max ) @@ -590,7 +590,7 @@ void ivas_spar_quant_dtx_init( return; } - +#else void ivas_spar_quant_dtx_init_fx( ivas_spar_md_t *spar_md, Word32 *min_max /*q28*/ ) @@ -602,6 +602,7 @@ void ivas_spar_quant_dtx_init_fx( return; } +#endif /*-----------------------------------------------------------------------------------------* * Function ivas_copy_band_coeffs_idx_to_arr() diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index d306ed04c..b893c1d84 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -214,16 +214,22 @@ typedef struct ivas_spar_md_t { ivas_band_coeffs_t *band_coeffs; ivas_band_coeffs_ind_t band_coeffs_idx[IVAS_MAX_NUM_BANDS]; - int16_t num_bands; + Word16 num_bands; +#ifndef IVAS_FLOAT_FIXED float min_max[2]; +#endif Word32 min_max_fx[2]; /*q28*/ int16_t dtx_vad; +#ifndef IVAS_FLOAT_FIXED float en_ratio_slow[IVAS_MAX_NUM_BANDS]; +#endif Word32 en_ratio_slow_fx[IVAS_MAX_NUM_BANDS]; +#ifndef IVAS_FLOAT_FIXED float ref_pow_slow[IVAS_MAX_NUM_BANDS]; +#endif Word32 ref_pow_slow_fx[IVAS_MAX_NUM_BANDS]; - int16_t res_ind; - int16_t prior_dyn_active_w_flag; + Word16 res_ind; + Word16 prior_dyn_active_w_flag; } ivas_spar_md_t; typedef struct ivas_spar_md_prev_t @@ -235,9 +241,13 @@ typedef struct ivas_spar_md_prev_t typedef struct ivas_quant_coeffs_t { +#ifndef IVAS_FLOAT_FIXED float min; +#endif Word32 min_fx; /* Q28 */ +#ifndef IVAS_FLOAT_FIXED float max; +#endif Word32 max_fx; /* Q28 */ int16_t q_levels[2]; } ivas_quant_coeffs_t; @@ -430,22 +440,24 @@ typedef struct ivas_spar_br_table_t typedef struct ivas_MASA_spherical_grid_deindexing { +#ifndef IVAS_FLOAT_FIXED float theta_cb[NO_THETA16_MAX]; - int16_t no_theta; - int16_t no_phi[NO_THETA16_MAX]; +#endif + Word16 no_theta; + Word16 no_phi[NO_THETA16_MAX]; } SPHERICAL_GRID_DATA; typedef struct ivas_masa_descriptive_meta_struct { - uint8_t formatDescriptor[8]; /* 8x 8 bits */ - uint8_t numberOfDirections; /* 1 bit */ - uint8_t numberOfChannels; /* 1 bit */ - uint8_t sourceFormat; /* 2 bits */ - uint8_t transportDefinition; /* 3 bits */ - uint8_t channelAngle; /* 3 bits */ - uint8_t channelDistance; /* 6 bits */ - uint8_t channelLayout; /* 3 bits, used only when sourceFormat == bit value 10 */ + UWord8 formatDescriptor[8]; /* 8x 8 bits */ + UWord8 numberOfDirections; /* 1 bit */ + UWord8 numberOfChannels; /* 1 bit */ + UWord8 sourceFormat; /* 2 bits */ + UWord8 transportDefinition; /* 3 bits */ + UWord8 channelAngle; /* 3 bits */ + UWord8 channelDistance; /* 6 bits */ + UWord8 channelLayout; /* 3 bits, used only when sourceFormat == bit value 10 */ } MASA_DECRIPTIVE_META; @@ -462,7 +474,7 @@ typedef struct ivas_masa_directional_spatial_meta_struct Word32 energy_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Q30 */ Word16 spread_coherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Q15 */ #endif - uint16_t spherical_index[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + UWord16 spherical_index[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; } MASA_DIRECTIONAL_SPATIAL_META; @@ -530,7 +542,7 @@ typedef struct typedef struct ivas_qdirection_band_data_struct { - uint16_t spherical_index[MAX_PARAM_SPATIAL_SUBFRAMES]; + UWord16 spherical_index[MAX_PARAM_SPATIAL_SUBFRAMES]; #ifndef IVAS_FLOAT_FIXED float azimuth[MAX_PARAM_SPATIAL_SUBFRAMES]; float elevation[MAX_PARAM_SPATIAL_SUBFRAMES]; @@ -538,21 +550,21 @@ typedef struct ivas_qdirection_band_data_struct Word32 azimuth_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; /* Q22 */ Word32 elevation_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; /* Q22 */ #endif - int16_t elevation_m_alphabet[MAX_PARAM_SPATIAL_SUBFRAMES]; - int16_t azimuth_m_alphabet[MAX_PARAM_SPATIAL_SUBFRAMES]; + Word16 elevation_m_alphabet[MAX_PARAM_SPATIAL_SUBFRAMES]; + Word16 azimuth_m_alphabet[MAX_PARAM_SPATIAL_SUBFRAMES]; #ifdef IVAS_FLOAT_FIXED Word32 energy_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; /* Q30 */ #else float energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES]; #endif - uint8_t distance[MAX_PARAM_SPATIAL_SUBFRAMES]; + UWord8 distance[MAX_PARAM_SPATIAL_SUBFRAMES]; - uint16_t bits_sph_idx[MAX_PARAM_SPATIAL_SUBFRAMES]; - uint16_t energy_ratio_index[MAX_PARAM_SPATIAL_SUBFRAMES]; - uint16_t energy_ratio_index_mod[MAX_PARAM_SPATIAL_SUBFRAMES]; - uint16_t azimuth_index[MAX_PARAM_SPATIAL_SUBFRAMES]; - uint16_t elevation_index[MAX_PARAM_SPATIAL_SUBFRAMES]; + UWord16 bits_sph_idx[MAX_PARAM_SPATIAL_SUBFRAMES]; + UWord16 energy_ratio_index[MAX_PARAM_SPATIAL_SUBFRAMES]; + UWord16 energy_ratio_index_mod[MAX_PARAM_SPATIAL_SUBFRAMES]; + UWord16 azimuth_index[MAX_PARAM_SPATIAL_SUBFRAMES]; + UWord16 elevation_index[MAX_PARAM_SPATIAL_SUBFRAMES]; #ifndef IVAS_FLOAT_FIXED float q_azimuth[MAX_PARAM_SPATIAL_SUBFRAMES]; float q_elevation[MAX_PARAM_SPATIAL_SUBFRAMES]; @@ -565,15 +577,15 @@ typedef struct ivas_qdirection_band_data_struct typedef struct ivas_qdirection_band_coherence_data_struct { - uint8_t spread_coherence[MAX_PARAM_SPATIAL_SUBFRAMES]; - uint16_t spread_coherence_dct0_index; - uint16_t spread_coherence_dct1_index; + UWord8 spread_coherence[MAX_PARAM_SPATIAL_SUBFRAMES]; + UWord16 spread_coherence_dct0_index; + UWord16 spread_coherence_dct1_index; } IVAS_QDIRECTION_BAND_COHERENCE_DATA; typedef struct ivas_surround_coherence_band_data_struct { - uint8_t surround_coherence[MAX_PARAM_SPATIAL_SUBFRAMES]; - uint16_t sur_coherence_index; + UWord8 surround_coherence[MAX_PARAM_SPATIAL_SUBFRAMES]; + UWord16 sur_coherence_index; } IVAS_SURROUND_COHERENCE_BAND_DATA; @@ -584,39 +596,39 @@ typedef struct IVAS_QDIRECTION_BAND_DATA *band_data; IVAS_QDIRECTION_BAND_COHERENCE_DATA *coherence_band_data; - int16_t not_in_2D; + Word16 not_in_2D; } IVAS_QDIRECTION; /* IVAS_QMETADATA; */ typedef struct ivas_masa_qmetadata_frame_struct { IVAS_QDIRECTION *q_direction; - uint16_t no_directions; - int16_t bits_frame_nominal; - uint16_t coherence_flag; - uint8_t all_coherence_zero; - uint8_t twoDirBands[MASA_MAXIMUM_CODING_SUBBANDS]; - uint8_t numTwoDirBands; - int16_t qmetadata_max_bit_req; - int16_t metadata_max_bits; /* maximum allowed number of bits for metadata per frame */ - uint8_t useLowerRes; - uint8_t useLowerBandRes; - int16_t dirac_mono_flag; + UWord16 no_directions; + Word16 bits_frame_nominal; + UWord16 coherence_flag; + UWord8 all_coherence_zero; + UWord8 twoDirBands[MASA_MAXIMUM_CODING_SUBBANDS]; + UWord8 numTwoDirBands; + Word16 qmetadata_max_bit_req; + Word16 metadata_max_bits; /* maximum allowed number of bits for metadata per frame */ + UWord8 useLowerRes; + UWord8 useLowerBandRes; + Word16 dirac_mono_flag; IVAS_SURROUND_COHERENCE_BAND_DATA *surcoh_band_data; /* Additional helper values to include all data required for writing to output file */ - uint8_t numCodingBands; - int16_t *bandMap; - int16_t nchan_transport; - int16_t sba_inactive_mode; + UWord8 numCodingBands; + Word16 *bandMap; + Word16 nchan_transport; + Word16 sba_inactive_mode; /* Status values on metadata quality */ - int16_t ec_flag; + Word16 ec_flag; #ifndef IVAS_FLOAT_FIXED float dir_comp_ratio; #else Word16 dir_comp_ratio_fx; /* Q15 */ #endif - uint8_t is_masa_ivas_format; + UWord8 is_masa_ivas_format; } IVAS_QMETADATA, *IVAS_QMETADATA_HANDLE; @@ -627,52 +639,53 @@ typedef struct ivas_masa_qmetadata_frame_struct typedef struct ivas_param_mc_ild_mapping_struct { - int16_t ild_map_size_wo_lfe; - int16_t ild_map_size_lfe; - int16_t ild_index[MAX_CICP_CHANNELS]; - int16_t num_ref_channels[MAX_CICP_CHANNELS]; - int16_t ref_channel_idx[MAX_CICP_CHANNELS][PARAM_MC_MAX_ILD_REF_CHANNELS]; + Word16 ild_map_size_wo_lfe; + Word16 ild_map_size_lfe; + Word16 ild_index[MAX_CICP_CHANNELS]; + Word16 num_ref_channels[MAX_CICP_CHANNELS]; + Word16 ref_channel_idx[MAX_CICP_CHANNELS][PARAM_MC_MAX_ILD_REF_CHANNELS]; } PARAM_MC_ILD_MAPPING, *HANDLE_PARAM_MC_ILD_MAPPING; typedef struct ivas_param_mc_icc_mapping_struct { - int16_t icc_map_size_wo_lfe; - int16_t icc_map_size_lfe; - int16_t icc_mapping[PARAM_MC_SZ_ICC_MAP][2]; + Word16 icc_map_size_wo_lfe; + Word16 icc_map_size_lfe; + Word16 icc_mapping[PARAM_MC_SZ_ICC_MAP][2]; } PARAM_MC_ICC_MAPPING, *HANDLE_PARAM_MC_ICC_MAPPING; typedef struct ivas_param_mc_conf_struct /* structure for ROM Table */ { MC_LS_SETUP mc_ls_setup; - int16_t num_input_chan; - int16_t num_transport_chan; - int32_t ivas_total_brate; + Word16 num_input_chan; + Word16 num_transport_chan; + Word32 ivas_total_brate; const PARAM_MC_ILD_MAPPING *ild_mapping_conf; const PARAM_MC_ICC_MAPPING *icc_mapping_conf; - const float *dmx_fac; - const float *ild_factors; #ifdef IVAS_FLOAT_FIXED const Word16 *ild_factors_fx; const Word32 *dmx_fac_fx; /* Q31 */ +#else + const float *ild_factors; + const float *dmx_fac; #endif } PARAM_MC_CONF; typedef struct ivas_parametric_mc_metadata_value_coding_info_struct { - const uint16_t *cum_freq; - const uint16_t *sym_freq; - const uint16_t *cum_freq_delta; - const uint16_t *sym_freq_delta; - const float *quantizer; + const UWord16 *cum_freq; + const UWord16 *sym_freq; + const UWord16 *cum_freq_delta; + const UWord16 *sym_freq_delta; #ifdef IVAS_FLOAT_FIXED const Word16 *quantizer_fx; - Word16 Q_quant; +#else + const float *quantizer; #endif - int16_t quantizer_size; - int16_t uni_bits; + Word16 quantizer_size; + Word16 uni_bits; } PARAM_MC_PARAMETER_CODING_INFO, *HANDLE_PARAM_MC_PARAMETER_CODING_INFO; @@ -684,24 +697,25 @@ typedef struct ivas_parametric_mc_metadata_struct int16_t icc_mapping[PARAM_MC_PARAMETER_FRAMES][PARAM_MC_SZ_ICC_MAP][2]; int16_t *icc_map_full[2]; #endif - int16_t icc_map_size_full; - int16_t param_frame_idx; + Word16 icc_map_size_full; + Word16 param_frame_idx; #ifndef FIX_901_PARAMMC_DEAD_CODE int16_t flag_use_adaptive_icc_map; #endif - const float *ild_factors; #ifdef IVAS_FLOAT_FIXED const Word16 *ild_factors_fx; +#else + const float *ild_factors; #endif - int16_t coding_band_mapping[PARAM_MC_MAX_PARAMETER_BANDS]; - int16_t nbands_in_param_frame[PARAM_MC_PARAMETER_FRAMES]; - int16_t bAttackPresent; - int16_t attackIndex; - int16_t nbands_coded; - int16_t num_parameter_bands; - int16_t coded_bwidth; - int16_t last_coded_bwidth; - int16_t lfe_on; + Word16 coding_band_mapping[PARAM_MC_MAX_PARAMETER_BANDS]; + Word16 nbands_in_param_frame[PARAM_MC_PARAMETER_FRAMES]; + Word16 bAttackPresent; + Word16 attackIndex; + Word16 nbands_coded; + Word16 num_parameter_bands; + Word16 coded_bwidth; + Word16 last_coded_bwidth; + Word16 lfe_on; PARAM_MC_PARAMETER_CODING_INFO icc_coding; PARAM_MC_PARAMETER_CODING_INFO ild_coding; @@ -718,8 +732,9 @@ typedef struct ivas_lfe_window int16_t fade_len; int16_t zero_pad_len; int16_t full_len; +#ifndef IVAS_FLOAT_FIXED const float *pWindow_coeffs; -#ifdef IVAS_FLOAT_FIXED +#else const Word32 *pWindow_coeffs_fx; #endif @@ -741,8 +756,8 @@ typedef struct ivas_lfe_freq_models typedef struct ivas_filters_process_state_t { - int16_t order; - int16_t filt_len; + Word16 order; + Word16 filt_len; #ifdef IVAS_FLOAT_FIXED Word32 num_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word32 den_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; @@ -790,53 +805,42 @@ typedef struct ivas_trans_det_state_t typedef struct ivas_fb_mixer_cfg_t { - int16_t fb_latency; - int16_t num_in_chans; - int16_t num_out_chans; - int16_t nchan_fb_in; - int16_t pcm_offset; - int16_t fade_len; /* this sets the stride length; no delay is introduced */ - int16_t prior_input_length; - int16_t windowed_fr_offset; - int16_t active_w_mixing; - const int16_t *remix_order; + Word16 fb_latency; + Word16 num_in_chans; + Word16 num_out_chans; + Word16 nchan_fb_in; + Word16 pcm_offset; + Word16 fade_len; /* this sets the stride length; no delay is introduced */ + Word16 prior_input_length; + Word16 windowed_fr_offset; + Word16 active_w_mixing; + const Word16 *remix_order; } IVAS_FB_CFG; typedef struct ivas_fb_consts_t { - const float *ppFilterbank_FRs[2][IVAS_MAX_NUM_BANDS]; - float *ppFilterbank_FRs_non48k[2][IVAS_MAX_NUM_BANDS]; - const int16_t *pFilterbank_bins_per_band; - const int16_t *pFilterbank_bins_start_offset; - -#ifdef IVAS_FLOAT_FIXED + const Word16 *pFilterbank_bins_per_band; + const Word16 *pFilterbank_bins_start_offset; const Word32 *ppFilterbank_FRs_fx[2][IVAS_MAX_NUM_BANDS]; // Q30 Word32 *ppFilterbank_FRs_non48k_fx[2][IVAS_MAX_NUM_BANDS]; // Q30 -#endif } ivas_fb_consts_t; typedef struct ivas_fb_bin_to_band_data_t { - float *pFb_bin_to_band[IVAS_MAX_NUM_FB_BANDS]; - const int16_t *pFb_start_bin_per_band; - const int16_t *pFb_active_bins_per_band; - float pp_cldfb_weights_per_spar_band[CLDFB_NO_CHANNELS_MAX][IVAS_MAX_NUM_FB_BANDS]; /* weights for linear combination of parameters from different SPAR bands*/ - int16_t p_spar_start_bands[CLDFB_NO_CHANNELS_MAX]; /* the first SPAR band per CLFB band when the weight is > 0 */ - int16_t p_cldfb_map_to_spar_band[CLDFB_NO_CHANNELS_MAX]; /* a direct mapping from CLDFB band to SPAR band */ - int16_t p_short_stride_start_bin_per_band[IVAS_MAX_NUM_FB_BANDS]; - int16_t p_short_stride_num_bins_per_band[IVAS_MAX_NUM_FB_BANDS]; - float p_short_stride_bin_to_band[2 * MDFT_FB_BANDS_240]; - float *pp_short_stride_bin_to_band[IVAS_MAX_NUM_FB_BANDS]; - int16_t short_stride; - int16_t num_cldfb_bands; -#ifdef IVAS_FLOAT_FIXED + const Word16 *pFb_start_bin_per_band; + const Word16 *pFb_active_bins_per_band; + Word16 p_spar_start_bands[CLDFB_NO_CHANNELS_MAX]; /* the first SPAR band per CLFB band when the weight is > 0 */ + Word16 p_cldfb_map_to_spar_band[CLDFB_NO_CHANNELS_MAX]; /* a direct mapping from CLDFB band to SPAR band */ + Word16 p_short_stride_start_bin_per_band[IVAS_MAX_NUM_FB_BANDS]; + Word16 p_short_stride_num_bins_per_band[IVAS_MAX_NUM_FB_BANDS]; + Word16 short_stride; + Word16 num_cldfb_bands; Word32 *pFb_bin_to_band_fx[IVAS_MAX_NUM_FB_BANDS]; Word32 p_short_stride_bin_to_band_fx[2 * MDFT_FB_BANDS_240]; Word32 *pp_short_stride_bin_to_band_fx[IVAS_MAX_NUM_FB_BANDS]; Word32 pp_cldfb_weights_per_spar_band_fx[CLDFB_NO_CHANNELS_MAX][IVAS_MAX_NUM_FB_BANDS]; -#endif } ivas_fb_bin_to_band_data_t; @@ -854,23 +858,13 @@ typedef struct ivas_fb_mixer_state_structure Word16 num_diff_bands; ivas_filterbank_t *pFb; -#ifndef IVAS_FLOAT_FIXED - float *ppFilterbank_inFR_re[IVAS_MAX_FB_MIXER_IN_CH]; - float *ppFilterbank_inFR_im[IVAS_MAX_FB_MIXER_IN_CH]; -#endif - float *ppFilterbank_prior_input[IVAS_MAX_FB_MIXER_IN_CH]; - -#ifdef IVAS_FLOAT_FIXED Word32 *ppFilterbank_inFR_re_fx[IVAS_MAX_FB_MIXER_IN_CH]; Word32 *ppFilterbank_inFR_im_fx[IVAS_MAX_FB_MIXER_IN_CH]; Word32 *ppFilterbank_prior_input_fx[IVAS_MAX_FB_MIXER_IN_CH]; - Word16 q_ppFilterbank_inFR_re_fx[IVAS_MAX_FB_MIXER_IN_CH]; - Word16 q_ppFilterbank_inFR_im_fx[IVAS_MAX_FB_MIXER_IN_CH]; + Word16 q_ppFilterbank_inFR[IVAS_MAX_FB_MIXER_IN_CH]; Word16 q_ppFilterbank_prior_input_fx[IVAS_MAX_FB_MIXER_IN_CH]; Word32 *prior_mixer_fx[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH]; Word16 q_prior_mixer_fx; -#endif - /* store sin part in const table (no need to store 1s and 0s, no need to do windowing for 1's and 0's as well) */ Word16 cross_fade_start_offset; Word16 cross_fade_end_offset; @@ -931,6 +925,7 @@ typedef struct ivas_param_ism_data_structure Word16 last_dmx_gain_fx; Word16 last_dmx_gain_e; Word16 last_cardioid_left_fx[MAX_NUM_OBJECTS]; // Q14 + } PARAM_ISM_CONFIG_DATA, *PARAM_ISM_CONFIG_HANDLE; #ifdef IVAS_FLOAT_FIXED diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index 88a0200eb..87984f205 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -76,18 +76,18 @@ float sumAbs( #ifdef IVAS_FLOAT_FIXED Word32 sumAbs_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec /* i : length of input vector */ + const Word32 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector Q0*/ ) { Word16 i; - Word32 tmp; + Word32 tmp; /*Qx*/ tmp = 0; move32(); FOR( i = 0; i < lvec; i++ ) { - tmp = L_add( tmp, L_abs( vec[i] ) ); + tmp = L_add( tmp, L_abs( vec[i] ) ); /*Qx*/ } return tmp; @@ -171,11 +171,11 @@ uint32_t ivas_syn_output( #ifdef IVAS_FLOAT_FIXED UWord32 ivas_syn_output_fx( - Word32 *synth[], /* i/o: float synthesis signal */ + Word32 *synth[], /* i/o: float synthesis signal q_synth*/ const Word16 q_synth, - const Word16 output_frame, /* i : output frame length (one channel) */ - const Word16 n_channels, /* i : number of output channels */ - Word16 *synth_out /* o : integer 16 bits synthesis signal */ + const Word16 output_frame, /* i : output frame length (one channel) Q0*/ + const Word16 n_channels, /* i : number of output channels Q0*/ + Word16 *synth_out /* o : integer 16 bits synthesis signal Q0*/ ) { Word16 i, n; @@ -190,17 +190,17 @@ UWord32 ivas_syn_output_fx( FOR( n = 0; n < n_channels; n++ ) { - tmp = mvl2s_r( synth[n], q_synth, synth_loc, output_frame ); + tmp = mvl2s_r( synth[n], q_synth, synth_loc, output_frame ); /*Q0*/ noClipping = UL_addNsD( noClipping, tmp ); FOR( i = 0; i < output_frame; i++ ) { - synth_out[L_add( imult1616( i, n_channels ), n )] = synth_loc[i]; + synth_out[( ( i * n_channels ) + n )] = synth_loc[i]; /*q_synth*/ move16(); } } - return noClipping; + return noClipping; /*Q0*/ } #endif @@ -239,10 +239,10 @@ void ivas_syn_output_f( #ifdef IVAS_FLOAT_FIXED void ivas_syn_output_f_fx( - Word32 *synth[], /* i/o: float synthesis signal */ - const Word16 output_frame, /* i : output frame length (one channel) */ - const Word16 n_channels, /* i : number of output channels */ - Word32 *synth_out /* o : integer 16 bits synthesis signal */ + Word32 *synth[], /* i/o: float synthesis signal Q11*/ + const Word16 output_frame, /* i : output frame length (one channel) Q0*/ + const Word16 n_channels, /* i : number of output channels Q0*/ + Word32 *synth_out /* o : integer 16 bits synthesis signal Q11*/ ) { Word16 i, n; @@ -255,7 +255,7 @@ void ivas_syn_output_f_fx( { FOR( i = 0; i < output_frame; i++ ) { - synth_out[L_add( imult1616( i, n_channels ), n )] = synth[n][i]; + synth_out[( ( i * n_channels ) + n )] = synth[n][i]; /*Q11*/ move16(); } } @@ -272,11 +272,11 @@ void ivas_syn_output_f_fx( *-------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED void mvr2r_inc_fixed_one( - const Word32 x_fx[], /* i : input vector */ - const Word16 x_inc, /* i : increment for vector x[] */ - Word32 y_fx[], /* o : output vector */ - const Word16 y_inc, /* i : increment for vector y[] */ - const Word16 n /* i : vector size */ + const Word32 x_fx[], /* i : input vector Q29*/ + const Word16 x_inc, /* i : increment for vector x[] Q0*/ + Word32 y_fx[], /* o : output vector Q29*/ + const Word16 y_inc, /* i : increment for vector y[] Q0*/ + const Word16 n /* i : vector size Q0*/ ) { Word16 i; @@ -297,7 +297,7 @@ void mvr2r_inc_fixed_one( move16(); FOR( i = 0; i < n; i++ ) { - y_fx[iy] = x_fx[ix]; + y_fx[iy] = x_fx[ix]; /*Q29*/ move32(); ix = add( ix, x_inc ); @@ -306,11 +306,11 @@ void mvr2r_inc_fixed_one( } ELSE { - ix = imult1616( sub( n, 1 ), x_inc ); - iy = imult1616( sub( n, 1 ), y_inc ); - FOR( i = sub( n, 1 ); i >= 0; i-- ) + ix = imult1616( sub( n, 1 ), x_inc ); /*Q0*/ + iy = imult1616( sub( n, 1 ), y_inc ); /*Q0*/ + FOR( i = ( n - 1 ); i >= 0; i-- ) { - y_fx[iy] = x_fx[ix]; + y_fx[iy] = x_fx[ix]; /*Q29*/ move32(); ix = sub( ix, x_inc ); @@ -322,11 +322,11 @@ void mvr2r_inc_fixed_one( } void mvr2r_inc_fixed( - const Word32 x_fx[], /* i : input vector */ - const Word16 x_inc, /* i : increment for vector x[] */ - Word32 y_fx[], /* o : output vector */ - const Word16 y_inc, /* i : increment for vector y[] */ - const Word16 n /* i : vector size */ + const Word32 x_fx[], /* i : input vector Q29*/ + const Word16 x_inc, /* i : increment for vector x[] Q0*/ + Word32 y_fx[], /* o : output vector Q29*/ + const Word16 y_inc, /* i : increment for vector y[] Q0*/ + const Word16 n /* i : vector size Q0*/ ) { Word16 i; @@ -347,7 +347,7 @@ void mvr2r_inc_fixed( move16(); FOR( i = 0; i < n; i++ ) { - y_fx[iy] = x_fx[ix]; + y_fx[iy] = x_fx[ix]; /*Q29*/ move32(); ix = add( ix, x_inc ); @@ -356,11 +356,11 @@ void mvr2r_inc_fixed( } ELSE { - ix = i_mult( sub( n, 1 ), x_inc ); + ix = i_mult( sub( n, 1 ), x_inc ); /*Q0*/ iy = i_mult( sub( n, 1 ), y_inc ); FOR( i = sub( n, 1 ); i >= 0; i-- ) { - y_fx[iy] = x_fx[ix]; + y_fx[iy] = x_fx[ix]; /*Q29*/ move32(); ix = sub( ix, x_inc ); @@ -451,13 +451,13 @@ void v_add_inc( #ifdef IVAS_FLOAT_FIXED // for same q// void v_add_inc_fx( - const Word32 x1[], /* i : Input vector 1 */ - const Word16 x_inc, /* i : Increment for input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - const Word16 x2_inc, /* i : Increment for input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 y_inc, /* i : increment for vector y[] */ - const Word16 N /* i : Vector length */ + const Word32 x1[], /* i : Input vector 1 Qx*/ + const Word16 x_inc, /* i : Increment for input vector 1 Q0*/ + const Word32 x2[], /* i : Input vector 2 Qx*/ + const Word16 x2_inc, /* i : Increment for input vector 2 Q0*/ + Word32 y[], /* o : Output vector that contains vector 1 + vector 2 Qx*/ + const Word16 y_inc, /* i : increment for vector y[] Q0*/ + const Word16 N /* i : Vector length Q0*/ ) { Word16 i; @@ -469,11 +469,11 @@ void v_add_inc_fx( move16(); FOR( i = 0; i < N; i++ ) { - y[iy] = L_add( x1[ix1], x2[ix2] ); + y[iy] = L_add( x1[ix1], x2[ix2] ); /*Qx*/ move32(); - ix1 = add( ix1, x_inc ); - ix2 = add( ix2, x2_inc ); - iy = add( iy, y_inc ); + ix1 = add( ix1, x_inc ); /*Q0*/ + ix2 = add( ix2, x2_inc ); /*Q0*/ + iy = add( iy, y_inc ); /*Q0*/ } return; } @@ -487,16 +487,16 @@ void v_add_inc_fx( *-------------------------------------------------------------------*/ void v_mult_inc_fx( - const Word32 x1_fx[], /* i : Input vector 1 */ + const Word32 x1_fx[], /* i : Input vector 1 x1_q_fx*/ Word16 *x1_q_fx, - const Word16 x1_inc, /* i : Increment for input vector 1 */ - const Word32 x2_fx[], /* i : Input vector 2 */ + const Word16 x1_inc, /* i : Increment for input vector 1 Q0*/ + const Word32 x2_fx[], /* i : Input vector 2 x2_q_fx*/ Word16 *x2_q_fx, - const Word16 x2_inc, /* i : Increment for input vector 1 */ - Word32 y_fx[], /* o : Output vector that contains vector 1 .* vector 2 */ + const Word16 x2_inc, /* i : Increment for input vector 1 Q0*/ + Word32 y_fx[], /* o : Output vector that contains vector 1 .* vector 2 y_q_fx*/ Word16 *y_q_fx, - const Word16 y_inc, /* i : increment for vector y[i] */ - const Word16 N /* i : Vector length */ + const Word16 y_inc, /* i : increment for vector y[i] Q0*/ + const Word16 N /* i : Vector length Q0*/ ) { Word16 i; @@ -510,14 +510,14 @@ void v_mult_inc_fx( FOR( i = 0; i < N; i++ ) { - y_fx[iy] = Mpy_32_32( x1_fx[ix1], x2_fx[ix2] ); + y_fx[iy] = Mpy_32_32( x1_fx[ix1], x2_fx[ix2] ); /* x1_q_fx + x2_q_fx - 31 */ move32(); y_q_fx[iy] = sub( add( x1_q_fx[ix1], x2_q_fx[ix2] ), 31 ); move16(); - ix1 = add( ix1, x1_inc ); - ix2 = add( ix2, x2_inc ); - iy = add( iy, y_inc ); + ix1 = add( ix1, x1_inc ); /*Q0*/ + ix2 = add( ix2, x2_inc ); /*Q0*/ + iy = add( iy, y_inc ); /*Q0*/ } return; @@ -525,13 +525,13 @@ void v_mult_inc_fx( // when buffers have constant q/ void v_mult_inc_fixed( - const Word32 x1_fx[], /* i : Input vector 1 */ - const Word16 x1_inc, /* i : Increment for input vector 1 */ - const Word32 x2_fx[], /* i : Input vector 2 */ - const Word16 x2_inc, /* i : Increment for input vector 1 */ - Word32 y_fx[], /* o : Output vector that contains vector 1 .* vector 2 */ - const Word16 y_inc, /* i : increment for vector y[i] */ - const Word16 N /* i : Vector length */ + const Word32 x1_fx[], /* i : Input vector 1 Qx1*/ + const Word16 x1_inc, /* i : Increment for input vector 1 Q0*/ + const Word32 x2_fx[], /* i : Input vector 2 Qx2*/ + const Word16 x2_inc, /* i : Increment for input vector 1 Q0*/ + Word32 y_fx[], /* o : Output vector that contains vector 1 .* vector 2 Qx1 + Qx2 - 31*/ + const Word16 y_inc, /* i : increment for vector y[i] Q0*/ + const Word16 N /* i : Vector length Q0*/ ) { Word16 i; @@ -545,7 +545,7 @@ void v_mult_inc_fixed( FOR( i = 0; i < N; i++ ) { - y_fx[iy] = Mpy_32_32( x1_fx[ix1], x2_fx[ix2] ); + y_fx[iy] = Mpy_32_32( x1_fx[ix1], x2_fx[ix2] ); /*Qx1 + Qx2 - 31*/ move32(); ix1 = add( ix1, x1_inc ); @@ -597,17 +597,17 @@ void v_mult_inc( *-------------------------------------------------------------------*/ void v_addc_fx( - const Word32 x_fx[], /* i : Input vector */ - const Word32 c_fx, /* i : Constant */ - Word32 y_fx[], /* o : Output vector that contains c*x */ - const Word16 N /* i : Vector length */ + const Word32 x_fx[], /* i : Input vector Qx*/ + const Word32 c_fx, /* i : Constant Qx*/ + Word32 y_fx[], /* o : Output vector that contains c*x Qx*/ + const Word16 N /* i : Vector length Q0*/ ) { Word16 i; FOR( i = 0; i < N; i++ ) { - y_fx[i] = L_add( c_fx, x_fx[i] ); + y_fx[i] = L_add( c_fx, x_fx[i] ); /*Qx*/ move32(); } @@ -621,17 +621,17 @@ void v_addc_fx( *-------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED void v_addc_fixed( - const Word32 x[], /* i : Input vector */ - const Word32 c, /* i : Constant */ - Word32 y[], /* o : Output vector that contains c*x */ - const Word16 N /* i : Vector length */ + const Word32 x[], /* i : Input vector Qx*/ + const Word32 c, /* i : Constant Qx*/ + Word32 y[], /* o : Output vector that contains c*x Qx*/ + const Word16 N /* i : Vector length Q0*/ ) { Word16 i; FOR( i = 0; i < N; i++ ) { - y[i] = L_add( c, x[i] ); + y[i] = L_add( c, x[i] ); /*Qx*/ move32(); } @@ -664,13 +664,13 @@ void v_addc( *-------------------------------------------------------------------*/ void v_min_fx( - const Word32 x1_fx[], /* i : Input vector 1 */ + const Word32 x1_fx[], /* i : Input vector 1 x1_q_fx*/ Word16 *x1_q_fx, - const Word32 x2_fx[], /* i : Input vector 2 */ + const Word32 x2_fx[], /* i : Input vector 2 x2_q_fx*/ Word16 *x2_q_fx, - Word32 y_fx[], /* o : Output vector that contains vector 1 .* vector 2 */ + Word32 y_fx[], /* o : Output vector that contains vector 1 .* vector 2 y_q_fx*/ Word16 *y_q_fx, - const Word16 N /* i : Vector length */ + const Word16 N /* i : Vector length Q0*/ ) { Word16 i; @@ -681,14 +681,14 @@ void v_min_fx( { IF( LT_32( L_shr( x1_fx[i], sub( x1_q_fx[i], x2_q_fx[i] ) ), x2_fx[i] ) ) { - y_fx[i] = x1_fx[i]; + y_fx[i] = x1_fx[i]; /*x1_q_fx*/ move32(); y_q_fx[i] = x1_q_fx[i]; move16(); } ELSE { - y_fx[i] = x2_fx[i]; + y_fx[i] = x2_fx[i]; /*x2_q_fx*/ move32(); y_q_fx[i] = x2_q_fx[i]; move16(); @@ -698,14 +698,14 @@ void v_min_fx( { IF( LT_32( x1_fx[i], L_shr( x2_fx[i], sub( x2_q_fx[i], x1_q_fx[i] ) ) ) ) { - y_fx[i] = x1_fx[i]; + y_fx[i] = x1_fx[i]; /*x1_q_fx*/ move32(); y_q_fx[i] = x1_q_fx[i]; move16(); } ELSE { - y_fx[i] = x2_fx[i]; + y_fx[i] = x2_fx[i]; /*x2_q_fx*/ move32(); y_q_fx[i] = x2_q_fx[i]; move16(); @@ -747,17 +747,17 @@ void v_min( *-------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED void v_sqrt_fx( - const Word32 x[], /* i : Input vector */ + const Word32 x[], /* i : Input vector Qx*/ Word16 exp[], - Word32 y[], /* o : Output vector that contains sqrt(x) */ - const Word16 N /* i : Vector length */ + Word32 y[], /* o : Output vector that contains sqrt(x) Q31 - exp[]*/ + const Word16 N /* i : Vector length Q0*/ ) { Word16 i; FOR( i = 0; i < N; i++ ) { - y[i] = Sqrt32( x[i], &exp[i] ); + y[i] = Sqrt32( x[i], &exp[i] ); /*Q31 - exp[i]*/ move32(); } @@ -790,10 +790,10 @@ void v_sqrt( #ifdef IVAS_FLOAT_FIXED void v_sub_s16_fx( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ + const Word16 x1[], /* i : Input vector 1 Qx*/ + const Word16 x2[], /* i : Input vector 2 Qx*/ + Word16 y[], /* o : Output vector that contains vector 1 - vector 2 Qx*/ + const Word16 N /* i : Vector length Q0*/ ) { Word16 i; @@ -804,7 +804,7 @@ void v_sub_s16_fx( FOR( i = 0; LT_16( i, N ); i++ ) #endif { - y[i] = sub( x1[i], x2[i] ); + y[i] = sub( x1[i], x2[i] ); /*Qx*/ move16(); } @@ -815,10 +815,10 @@ void v_sub_s16_fx( #ifdef IVAS_FLOAT_FIXED void v_sub32_fx( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ + const Word32 x1[], /* i : Input vector 1 Qx*/ + const Word32 x2[], /* i : Input vector 2 Qx*/ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 Qx*/ + const Word16 N /* i : Vector length Q0*/ ) { Word16 i; @@ -829,7 +829,7 @@ void v_sub32_fx( FOR( i = 0; LT_16( i, N ); i++ ) #endif { - y[i] = L_sub( x1[i], x2[i] ); + y[i] = L_sub( x1[i], x2[i] ); /*Qx*/ move32(); } @@ -894,9 +894,9 @@ float dot_product_cholesky( } #ifdef IVAS_FLOAT_FIXED Word32 dot_product_cholesky_fixed( - const Word32 *x, /* i : vector x */ - const Word32 *A, /* i : Cholesky matrix A */ - const Word16 N, /* i : vector & matrix size */ + const Word32 *x, /* i : vector x Q31 - exp_x*/ + const Word32 *A, /* i : Cholesky matrix A Q31 - exp_A*/ + const Word16 N, /* i : vector & matrix size Q0*/ const Word16 exp_x, const Word16 exp_A, Word16 *exp_sum ) @@ -919,11 +919,11 @@ Word32 dot_product_cholesky_fixed( FOR( j = 0; j <= i; j++ ) { - mul = Mpy_32_32( *pt_x++, *pt_A++ ); + mul = Mpy_32_32( *pt_x++, *pt_A++ ); /*Q31 - (exp_x + exp_A)*/ tmp_sum = BASOP_Util_Add_Mant32Exp( tmp_sum, tmp_sum_exp, mul, mul_exp, &tmp_sum_exp ); // exp_x+exp_A } - suma = BASOP_Util_Add_Mant32Exp( suma, *exp_sum, Mpy_32_32( tmp_sum, tmp_sum ), shl( tmp_sum_exp, 1 ), exp_sum ); + suma = BASOP_Util_Add_Mant32Exp( suma, *exp_sum, Mpy_32_32( tmp_sum, tmp_sum ), shl( tmp_sum_exp, 1 ), exp_sum ); /*Q31 - exp_sum*/ } return suma; @@ -931,11 +931,11 @@ Word32 dot_product_cholesky_fixed( #endif #ifdef IVAS_FLOAT_FIXED void v_mult_mat_fixed( - Word32 *y, /* o : the product x*A */ - const Word32 *x, /* i : vector x */ - const Word32 *A, /* i : matrix A */ - const Word16 Nr, /* i : number of rows */ - const Word16 Nc, /* i : number of columns */ + Word32 *y, /* o : the product x*A Qx - guardbits*/ + const Word32 *x, /* i : vector x Qx*/ + const Word32 *A, /* i : matrix A Q31*/ + const Word16 Nr, /* i : number of rows Q0*/ + const Word16 Nc, /* i : number of columns Q0*/ Word16 guardbits ) { Word16 i, j; @@ -944,28 +944,28 @@ void v_mult_mat_fixed( Word32 *pt_y; pt_y = tmp_y; - pt_A = A; + pt_A = A; /*Q31*/ FOR( i = 0; i < Nc; i++ ) { - pt_x = x; + pt_x = x; /*Qx*/ *pt_y = 0; move32(); FOR( j = 0; j < Nr; j++ ) { - *pt_y = L_add( *pt_y, L_shr( Mpy_32_32( ( *pt_x++ ), ( *pt_A++ ) ), guardbits ) ); + *pt_y = L_add( *pt_y, L_shr( Mpy_32_32( ( *pt_x++ ), ( *pt_A++ ) ), guardbits ) ); /*Qx - guardbits*/ move32(); } pt_y++; } - MVR2R_WORD32( tmp_y, y, Nc ); + MVR2R_WORD32( tmp_y, y, Nc ); /*Qx - guardbits*/ } Word32 dot_product_cholesky_fx( - const Word32 *x, /* i : vector x */ - const Word32 *A, /* i : Cholesky matrix A */ - const Word16 N /* i : vector & matrix size */ + const Word32 *x, /* i : vector x Qx1*/ + const Word32 *A, /* i : Cholesky matrix A Qx2*/ + const Word16 N /* i : vector & matrix size Q0*/ ) { Word16 i, j; @@ -983,7 +983,7 @@ Word32 dot_product_cholesky_fx( pt_x = x; FOR( j = 0; j <= i; j++ ) { - tmp_sum = L_add( tmp_sum, Mpy_32_32( *pt_x++, *pt_A++ ) ); + tmp_sum = L_add( tmp_sum, Mpy_32_32( *pt_x++, *pt_A++ ) ); /*Qx1 + Qx2 - 31*/ } suma = L_add( suma, Mpy_32_32( tmp_sum, tmp_sum ) ); @@ -1004,14 +1004,14 @@ Word32 dot_product_cholesky_fx( *---------------------------------------------------------------------*/ void v_mult_mat_fx( - Word32 *y_fx, /* o : the product x*A */ + Word32 *y_fx, /* o : the product x*A y_q_fx*/ Word16 *y_q_fx, - const Word32 *x_fx, /* i : vector x */ + const Word32 *x_fx, /* i : vector x x_q_fx*/ Word16 *x_q_fx, - const Word32 *A_fx, /* i : matrix A */ + const Word32 *A_fx, /* i : matrix A A_q_fx*/ Word16 *A_q_fx, - const Word16 Nr, /* i : number of rows */ - const Word16 Nc /* i : number of columns */ + const Word16 Nr, /* i : number of rows Q0*/ + const Word16 Nc /* i : number of columns Q0*/ ) { Word16 i, j; @@ -1022,19 +1022,19 @@ void v_mult_mat_fx( Word16 temp_q; pt_y_fx = tmp_y_fx; - pt_A_fx = A_fx; - pt_x_fx = x_fx; + pt_A_fx = A_fx; /*A_q_fx*/ + pt_x_fx = x_fx; /*x_q_fx*/ FOR( i = 0; i < Nc; i++ ) { - pt_x_fx = x_fx; + pt_x_fx = x_fx; /*x_q_fx*/ *pt_y_fx = 0; move32(); y_q_fx[i] = 0; move32(); FOR( j = 0; j < Nr; j++ ) { - temp = Mpy_32_32( *pt_x_fx++, *pt_A_fx++ ); + temp = Mpy_32_32( *pt_x_fx++, *pt_A_fx++ ); /*x_q_fx + A_q_fx - 31*/ temp_q = sub( add( x_q_fx[j], A_q_fx[Nr * i + j] ), 31 ); IF( j == 0 ) { @@ -1062,7 +1062,7 @@ void v_mult_mat_fx( pt_y_fx++; } - MVR2R_WORD32( tmp_y_fx, y_fx, Nc ); + MVR2R_WORD32( tmp_y_fx, y_fx, Nc ); /*y_q_fx*/ return; } @@ -1144,9 +1144,9 @@ float logsumexp( } #ifdef IVAS_FLOAT_FIXED Word32 logsumexp_fx( - const Word32 x[], /* i : input array x */ + const Word32 x[], /* i : input array x Q31 - x_e*/ const Word16 x_e, - const Word16 N /* i : number of elements in array x */ + const Word16 N /* i : number of elements in array x Q0*/ ) { Word32 max_exp, temp32_sub; @@ -1158,7 +1158,7 @@ Word32 logsumexp_fx( Word16 i; Word16 pow_e, sum_e = 0; move16(); - max_exp = x[0]; + max_exp = x[0]; /*Q31 - x_e*/ move32(); sum = 0; move32(); @@ -1166,24 +1166,24 @@ Word32 logsumexp_fx( { IF( GT_32( x[i], max_exp ) ) { - max_exp = x[i]; + max_exp = x[i]; /*Q31 - x_e*/ move32(); } } FOR( i = 0; i < N; i++ ) { - temp32_sub = L_sub( x[i], max_exp ); + temp32_sub = L_sub( x[i], max_exp ); /*Q31 - x_e*/ pow_e = 0; move16(); - temp32 = Mpy_32_32( log2_e_fx, temp32_sub ); - pow_temp = BASOP_util_Pow2( temp32, add( x_e, log2_e_fx_e ), &pow_e ); - sum = BASOP_Util_Add_Mant32Exp( sum, sum_e, pow_temp, pow_e, &sum_e ); + temp32 = Mpy_32_32( log2_e_fx, temp32_sub ); /*Q30 - x_e*/ + pow_temp = BASOP_util_Pow2( temp32, add( x_e, log2_e_fx_e ), &pow_e ); /*Q31 - pow_e*/ + sum = BASOP_Util_Add_Mant32Exp( sum, sum_e, pow_temp, pow_e, &sum_e ); /*Q31 - sum_e*/ } - temp32 = L_add( BASOP_Util_Log2( sum ), L_shl( sum_e, Q25 ) ); - temp32 = Mpy_32_32( temp32, 1488522239 ); /*logf(x) = log2(x)*logf(2)*/ - temp32 = L_add( L_shr( temp32, sub( x_e, 6 ) ), max_exp ); // q = 31-x_e - return temp32; + temp32 = L_add( BASOP_Util_Log2( sum ), L_shl( sum_e, Q25 ) ); /*Q25*/ + temp32 = Mpy_32_32( temp32, 1488522239 ); /*logf(x) = log2(x)*logf(2) Q25*/ + temp32 = L_add( L_shr( temp32, sub( x_e, 6 ) ), max_exp ); // q = 31-x_e + return temp32; /*31-x_e*/ } #endif @@ -1195,12 +1195,12 @@ Word32 logsumexp_fx( #ifdef IVAS_FLOAT_FIXED /*! r: mapped output value */ Word32 lin_interp32_fx( - const Word32 x, /* i : the value to be mapped */ - const Word32 x1, /* i : source range interval: low end */ - const Word32 y1, /* i : source range interval: high end */ - const Word32 x2, /* i : target range interval: low */ - const Word32 y2, /* i : target range interval: high */ - const Word16 flag_sat, /* i : flag to indicate whether to apply saturation */ + const Word32 x, /* i : the value to be mapped Qin*/ + const Word32 x1, /* i : source range interval: low end Qin*/ + const Word32 y1, /* i : source range interval: high end Qin*/ + const Word32 x2, /* i : target range interval: low Qin*/ + const Word32 y2, /* i : target range interval: high Qin*/ + const Word16 flag_sat, /* i : flag to indicate whether to apply saturation Q0*/ Word16 *Q_io /*i/o : i/o Q factor of the output*/ ) { @@ -1231,7 +1231,7 @@ Word32 lin_interp32_fx( temp32 = BASOP_Util_Add_Mant32Exp( y1, sub( 31, *Q_io ), temp_div, sub( 31, sub( *Q_io, temp_e ) ), &exp_out ); // Qin-temp_e *Q_io = sub( 31, exp_out ); move16(); - return temp32; + return temp32; /*Q_io*/ } #endif @@ -1307,16 +1307,16 @@ int16_t check_bounds_s( } #ifdef IVAS_FLOAT_FIXED Word16 check_bounds_s_fx( - const Word16 value, /* i : Input value */ - const Word16 low, /* i : Low limit */ - const Word16 high /* i : High limit */ + const Word16 value, /* i : Input value Q0*/ + const Word16 low, /* i : Low limit Q0*/ + const Word16 high /* i : High limit Q0*/ ) { Word16 value_adj; - value_adj = s_min( s_max( value, low ), high ); + value_adj = s_min( s_max( value, low ), high ); /*Q0*/ - return value_adj; + return value_adj; /*Q0*/ } #endif @@ -1328,16 +1328,16 @@ Word16 check_bounds_s_fx( /*! r: Adjusted value */ Word32 check_bounds_l( - const Word32 value, /* i : Input value */ - const Word32 low, /* i : Low limit */ - const Word32 high /* i : High limit */ + const Word32 value, /* i : Input value Q0*/ + const Word32 low, /* i : Low limit Q0*/ + const Word32 high /* i : High limit Q0*/ ) { Word32 value_adj; - value_adj = L_min( L_max( value, low ), high ); + value_adj = L_min( L_max( value, low ), high ); /*Q0*/ - return value_adj; + return value_adj; /*Q0*/ } /****************************************************************************/ @@ -1452,17 +1452,17 @@ int16_t matrix_product( #ifdef IVAS_FLOAT_FIXED Word16 matrix_product_mant_exp_fx( - const Word32 *X_fx, /* i : left hand matrix */ + const Word32 *X_fx, /* i : left hand matrix Q31 - X_fx_e*/ const Word16 X_fx_e, /* i : left hand matrix */ - const Word16 rowsX, /* i : number of rows of the left hand matrix */ - const Word16 colsX, /* i : number of columns of the left hand matrix */ - const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */ - const Word32 *Y_fx, /* i : right hand matrix */ + const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ + const Word32 *Y_fx, /* i : right hand matrix Q31 - Y_fx_e*/ const Word16 Y_fx_e, /* i : right hand matrix */ - const Word16 rowsY, /* i : number of rows of the right hand matrix */ - const Word16 colsY, /* i : number of columns of the right hand matrix */ - const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication */ - Word32 *Z_fx, /* o : resulting matrix after the matrix multiplication */ + const Word16 rowsY, /* i : number of rows of the right hand matrix Q0*/ + const Word16 colsY, /* i : number of columns of the right hand matrix Q0*/ + const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication Q0*/ + Word32 *Z_fx, /* o : resulting matrix after the matrix multiplication Q31 - Z_fx_e*/ Word16 *Z_fx_e /* o : resulting matrix after the matrix multiplication */ ) { @@ -1495,16 +1495,16 @@ Word16 matrix_product_mant_exp_fx( { x_idx = add( k, imult1616( i, rowsX ) ); y_idx = add( k, imult1616( j, rowsY ) ); - ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ), add( X_fx_e, Y_fx_e ), Zp_fx_e ); + ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ), add( X_fx_e, Y_fx_e ), Zp_fx_e ); /*Q31 - Zp_fx_e*/ move32(); } Zp_fx++; Zp_fx_e++; } } - row = colsY; + row = colsY; /*Q0*/ move16(); - col = colsX; + col = colsX; /*Q0*/ move16(); } ELSE IF( transpX == 0 && EQ_16( transpY, 1 ) ) /* We use Y transpose */ @@ -1525,16 +1525,16 @@ Word16 matrix_product_mant_exp_fx( { x_idx = add( i, imult1616( k, rowsX ) ); y_idx = add( j, imult1616( k, rowsY ) ); - ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ), add( X_fx_e, Y_fx_e ), Zp_fx_e ); + ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ), add( X_fx_e, Y_fx_e ), Zp_fx_e ); /*Q31 - Zp_fx_e*/ move32(); } Zp_fx++; Zp_fx_e++; } } - row = rowsY; + row = rowsY; /*Q0*/ move16(); - col = rowsX; + col = rowsX; /*Q0*/ move16(); } ELSE IF( EQ_16( transpX, 1 ) && EQ_16( transpY, 1 ) ) /* We use both transpose */ @@ -1555,7 +1555,7 @@ Word16 matrix_product_mant_exp_fx( { x_idx = add( k, imult1616( i, rowsX ) ); y_idx = add( j, imult1616( k, rowsY ) ); - ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ), add( X_fx_e, Y_fx_e ), Zp_fx_e ); + ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ), add( X_fx_e, Y_fx_e ), Zp_fx_e ); /*Q31 - Zp_fx_e*/ move32(); } @@ -1563,9 +1563,9 @@ Word16 matrix_product_mant_exp_fx( Zp_fx_e++; } } - row = rowsY; + row = rowsY; /*Q0*/ move16(); - col = colsX; + col = colsX; /*Q0*/ move16(); } ELSE /* Regular case */ @@ -1587,19 +1587,19 @@ Word16 matrix_product_mant_exp_fx( { x_idx = add( i, imult1616( k, rowsX ) ); y_idx = add( k, imult1616( j, rowsY ) ); - ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ), add( X_fx_e, Y_fx_e ), Zp_fx_e ); + ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ), add( X_fx_e, Y_fx_e ), Zp_fx_e ); /*Q31 - Zp_fx_e*/ move32(); } Zp_fx++; Zp_fx_e++; } } - row = colsY; + row = colsY; /*Q0*/ move16(); - col = rowsX; + col = rowsX; /*Q0*/ move16(); } - Zp_fx = Z_fx; + Zp_fx = Z_fx; /*Q31 - Zp_fx_e*/ Zp_fx_e = out_e; Word16 max_exp = -31; move16(); @@ -1618,7 +1618,7 @@ Word16 matrix_product_mant_exp_fx( { FOR( i = 0; i < col; ++i ) { - *Zp_fx = L_shr_r( *Zp_fx, sub( *Z_fx_e, *Zp_fx_e ) ); + *Zp_fx = L_shr_r( *Zp_fx, sub( *Z_fx_e, *Zp_fx_e ) ); /*Q31 - Zp_fx_e*/ move32(); Zp_fx++; Zp_fx_e++; @@ -1629,15 +1629,15 @@ Word16 matrix_product_mant_exp_fx( } Word16 matrix_product_fx( - const Word32 *X_fx, /* i : left hand matrix */ - const Word16 rowsX, /* i : number of rows of the left hand matrix */ - const Word16 colsX, /* i : number of columns of the left hand matrix */ - const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */ - const Word32 *Y_fx, /* i : right hand matrix */ - const Word16 rowsY, /* i : number of rows of the right hand matrix */ - const Word16 colsY, /* i : number of columns of the right hand matrix */ - const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication */ - Word32 *Z_fx /* o : resulting matrix after the matrix multiplication */ + const Word32 *X_fx, /* i : left hand matrix Qx*/ + const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ + const Word32 *Y_fx, /* i : right hand matrix Qy*/ + const Word16 rowsY, /* i : number of rows of the right hand matrix Q0*/ + const Word16 colsY, /* i : number of columns of the right hand matrix Q0*/ + const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication Q0*/ + Word32 *Z_fx /* o : resulting matrix after the matrix multiplication Qx + Qy - 31*/ ) { Word16 i, j, k; @@ -1662,9 +1662,9 @@ Word16 matrix_product_fx( move32(); FOR( k = 0; k < rowsX; ++k ) { - x_idx = add( k, imult1616( i, rowsX ) ); - y_idx = add( k, imult1616( j, rowsY ) ); - ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); + x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ + y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ + ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/ move32(); } Zp_fx++; @@ -1685,9 +1685,9 @@ Word16 matrix_product_fx( move32(); FOR( k = 0; k < colsX; ++k ) { - x_idx = add( i, imult1616( k, rowsX ) ); - y_idx = add( j, imult1616( k, rowsY ) ); - ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); + x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ + y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ + ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/ move32(); } Zp_fx++; @@ -1708,9 +1708,9 @@ Word16 matrix_product_fx( move32(); FOR( k = 0; k < colsX; ++k ) { - x_idx = add( k, imult1616( i, rowsX ) ); - y_idx = add( j, imult1616( k, rowsY ) ); - ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); + x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ + y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ + ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/ move32(); } @@ -1733,9 +1733,9 @@ Word16 matrix_product_fx( move32(); FOR( k = 0; k < colsX; ++k ) { - x_idx = add( i, imult1616( k, rowsX ) ); - y_idx = add( k, imult1616( j, rowsY ) ); - ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); + x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ + y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ + ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/ move32(); } Zp_fx++; @@ -1747,15 +1747,15 @@ Word16 matrix_product_fx( } Word16 matrix_product_q30_fx( - const Word32 *X_fx, /* i : left hand matrix */ - const Word16 rowsX, /* i : number of rows of the left hand matrix */ - const Word16 colsX, /* i : number of columns of the left hand matrix */ - const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */ - const Word32 *Y_fx, /* i : right hand matrix */ - const Word16 rowsY, /* i : number of rows of the right hand matrix */ - const Word16 colsY, /* i : number of columns of the right hand matrix */ - const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication */ - Word32 *Z_fx /* o : resulting matrix after the matrix multiplication */ + const Word32 *X_fx, /* i : left hand matrix Q31*/ + const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ + const Word32 *Y_fx, /* i : right hand matrix Q25*/ + const Word16 rowsY, /* i : number of rows of the right hand matrix Q0*/ + const Word16 colsY, /* i : number of columns of the right hand matrix Q0*/ + const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication Q0*/ + Word32 *Z_fx /* o : resulting matrix after the matrix multiplication Q30*/ ) { Word16 i, j, k; @@ -1783,12 +1783,12 @@ Word16 matrix_product_q30_fx( FOR( k = 0; k < rowsX; ++k ) { //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ) ); - x_idx = add( k, imult1616( i, rowsX ) ); - y_idx = add( k, imult1616( j, rowsY ) ); + x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ + y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); // Q56 } - W_tmp = W_shl( W_tmp, 6 ); - ( *Zp_fx ) = W_round64_L( W_tmp ); + W_tmp = W_shl( W_tmp, 6 ); /*Q62*/ + ( *Zp_fx ) = W_round64_L( W_tmp ); /*Q30*/ move32(); Zp_fx++; } @@ -1810,12 +1810,12 @@ Word16 matrix_product_q30_fx( FOR( k = 0; k < colsX; ++k ) { //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ) ); - x_idx = add( i, imult1616( k, rowsX ) ); - y_idx = add( j, imult1616( k, rowsY ) ); + x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ + y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); // Q56 } - W_tmp = W_shl( W_tmp, 6 ); - ( *Zp_fx ) = W_round64_L( W_tmp ); + W_tmp = W_shl( W_tmp, 6 ); /*Q62*/ + ( *Zp_fx ) = W_round64_L( W_tmp ); /*Q30*/ move32(); Zp_fx++; } @@ -1837,13 +1837,13 @@ Word16 matrix_product_q30_fx( FOR( k = 0; k < colsX; ++k ) { //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) ); - x_idx = add( k, imult1616( i, rowsX ) ); - y_idx = add( j, imult1616( k, rowsY ) ); + x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ + y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) ); // Q56 } - W_tmp = W_shl( W_tmp, 6 ); - ( *Zp_fx ) = W_round64_L( W_tmp ); + W_tmp = W_shl( W_tmp, 6 ); /*Q62*/ + ( *Zp_fx ) = W_round64_L( W_tmp ); /*Q30*/ move32(); Zp_fx++; } @@ -1866,12 +1866,12 @@ Word16 matrix_product_q30_fx( FOR( k = 0; k < colsX; ++k ) { //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) ); - x_idx = add( i, imult1616( k, rowsX ) ); - y_idx = add( k, imult1616( j, rowsY ) ); + x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ + y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); // Q56 } - W_tmp = W_shl( W_tmp, 6 ); - ( *Zp_fx ) = W_round64_L( W_tmp ); + W_tmp = W_shl( W_tmp, 6 ); /*Q62*/ + ( *Zp_fx ) = W_round64_L( W_tmp ); /*Q30*/ move32(); Zp_fx++; } @@ -1882,17 +1882,17 @@ Word16 matrix_product_q30_fx( } /*takes input matrices in mantissa and exponent forms*/ Word16 matrix_product_mant_exp( - const Word32 *X_fx, /* i : left hand matrix */ + const Word32 *X_fx, /* i : left hand matrix Q31 - X_e*/ const Word16 *X_e, /* i : left hand matrix */ - const Word16 rowsX, /* i : number of rows of the left hand matrix */ - const Word16 colsX, /* i : number of columns of the left hand matrix */ - const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */ - const Word32 *Y_fx, /* i : right hand matrix */ + const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ + const Word32 *Y_fx, /* i : right hand matrix Q31 - Y_e*/ const Word16 *Y_e, /* i : right hand matrix */ - const Word16 rowsY, /* i : number of rows of the right hand matrix */ - const Word16 colsY, /* i : number of columns of the right hand matrix */ - const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication */ - Word32 *Z_fx, /* o : resulting matrix after the matrix multiplication */ + const Word16 rowsY, /* i : number of rows of the right hand matrix Q0*/ + const Word16 colsY, /* i : number of columns of the right hand matrix Q0*/ + const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication Q0*/ + Word32 *Z_fx, /* o : resulting matrix after the matrix multiplication Q31 - Z_e*/ Word16 *Z_e /* o : resulting matrix after the matrix multiplication */ ) { @@ -1923,10 +1923,10 @@ Word16 matrix_product_mant_exp( move16(); FOR( k = 0; k < rowsX; ++k ) { - x_idx = add( k, imult1616( i, rowsX ) ); - y_idx = add( k, imult1616( j, rowsY ) ); + x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ + y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ //( *Zp ) += X[k + i * rowsX] * Y[k + j * rowsY]; - L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); + L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Q31 - (X_e + Y_e)*/ tmp_e = add( X_e[x_idx], Y_e[y_idx] ); ( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e ); @@ -1955,10 +1955,10 @@ Word16 matrix_product_mant_exp( move16(); FOR( k = 0; k < colsX; ++k ) { - x_idx = add( i, imult1616( k, rowsX ) ); - y_idx = add( j, imult1616( k, rowsY ) ); + x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ + y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ //( *Zp ) += X_fx[i + k * rowsX] * Y_fx[j + k * rowsY]; - L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); + L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Q31 - (X_e + Y_e)*/ tmp_e = add( X_e[x_idx], Y_e[y_idx] ); ( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e ); @@ -1986,10 +1986,10 @@ Word16 matrix_product_mant_exp( move16(); FOR( k = 0; k < colsX; ++k ) { - x_idx = add( k, imult1616( i, rowsX ) ); - y_idx = add( j, imult1616( k, rowsY ) ); + x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ + y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ //( *Zp ) += X_fx[k + i * rowsX] * Y_fx[j + k * rowsY]; - L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); + L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Q31 - (X_e + Y_e)*/ tmp_e = add( X_e[x_idx], Y_e[y_idx] ); ( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e ); @@ -2020,10 +2020,10 @@ Word16 matrix_product_mant_exp( move16(); FOR( k = 0; k < colsX; ++k ) { - x_idx = add( i, imult1616( k, rowsX ) ); - y_idx = add( k, imult1616( j, rowsY ) ); + x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ + y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ //( *Zp ) += X_fx[i + k * rowsX] * Y_fx[k + j * rowsY]; - L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); + L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Q31 - (X_e + Y_e)*/ tmp_e = add( X_e[x_idx], Y_e[y_idx] ); ( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e ); @@ -2099,15 +2099,15 @@ int16_t matrix_diag_product( #ifdef IVAS_FLOAT_FIXED Word16 matrix_diag_product_fx( - const Word32 *X, /* i : left hand matrix */ + const Word32 *X, /* i : left hand matrix Q31 - X_e*/ Word16 X_e, - const Word16 rowsX, /* i : number of rows of the left hand matrix */ - const Word16 colsX, /* i : number of columns of the left hand matrix */ - const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */ - const Word32 *Y, /* i : right hand diagonal matrix as vector containing the diagonal elements */ + const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ + const Word32 *Y, /* i : right hand diagonal matrix as vector containing the diagonal elements Q31 - Y_e*/ Word16 Y_e, - const Word16 entriesY, /* i : number of entries in the diagonal */ - Word32 *Z, /* o : resulting matrix after the matrix multiplication */ + const Word16 entriesY, /* i : number of entries in the diagonal Q0*/ + Word32 *Z, /* o : resulting matrix after the matrix multiplication Q31 - Z_e*/ Word16 *Z_e ) { Word16 i, j; @@ -2126,7 +2126,7 @@ Word16 matrix_diag_product_fx( FOR( i = 0; i < colsX; ++i ) { tmp = add( j, imult1616( i, rowsX ) ); - *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); + *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/ move32(); Zp++; } @@ -2143,7 +2143,7 @@ Word16 matrix_diag_product_fx( { FOR( i = 0; i < rowsX; ++i ) { - *( Zp ) = Mpy_32_32( *( X ), Y[j] ); + *( Zp ) = Mpy_32_32( *( X ), Y[j] ); /*Q31 - (X_e + Y_e)*/ move32(); Zp++; X++; @@ -2158,15 +2158,15 @@ Word16 matrix_diag_product_fx( } Word16 matrix_diag_product_fx_1( - const Word32 *X, /* i : left hand matrix */ + const Word32 *X, /* i : left hand matrix Q31 - X_e*/ const Word16 *X_e, - const Word16 rowsX, /* i : number of rows of the left hand matrix */ - const Word16 colsX, /* i : number of columns of the left hand matrix */ - const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */ - const Word32 *Y, /* i : right hand diagonal matrix as vector containing the diagonal elements */ + const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ + const Word32 *Y, /* i : right hand diagonal matrix as vector containing the diagonal elements Q31 - Y_e*/ const Word16 *Y_e, - const Word16 entriesY, /* i : number of entries in the diagonal */ - Word32 *Z, /* o : resulting matrix after the matrix multiplication */ + const Word16 entriesY, /* i : number of entries in the diagonal Q0*/ + Word32 *Z, /* o : resulting matrix after the matrix multiplication Q31 - Z_e*/ Word16 *Z_e ) { Word16 i, j; @@ -2185,8 +2185,8 @@ Word16 matrix_diag_product_fx_1( { FOR( i = 0; i < colsX; ++i ) { - tmp = add( j, imult1616( i, rowsX ) ); - *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); + tmp = add( j, imult1616( i, rowsX ) ); /*Q0*/ + *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/ move32(); Zp++; *( Z_ep ) = add( X_e[tmp], Y_e[j] ); @@ -2206,7 +2206,7 @@ Word16 matrix_diag_product_fx_1( { FOR( i = 0; i < rowsX; ++i ) { - *( Zp ) = Mpy_32_32( *( X ), Y[j] ); + *( Zp ) = Mpy_32_32( *( X ), Y[j] ); /*Q31 - (X_e + Y_e)*/ move32(); Zp++; *( Z_ep ) = add( *( X_e ), Y_e[j] ); @@ -2224,15 +2224,15 @@ Word16 matrix_diag_product_fx_1( #ifdef IVAS_FLOAT_FIXED Word16 diag_matrix_product_fx( - const Word32 *Y, /* i : left hand diagonal matrix as vector containing the diagonal elements */ + const Word32 *Y, /* i : left hand diagonal matrix as vector containing the diagonal elements Q31 - Y_e*/ Word16 Y_e, - const Word16 entriesY, /* i : length of the diagonal of the left hand matrix */ - const Word32 *X, /* i : right hand matrix */ + const Word16 entriesY, /* i : length of the diagonal of the left hand matrix Q0*/ + const Word32 *X, /* i : right hand matrix Q31 - X_e*/ Word16 X_e, - const Word16 rowsX, /* i : number of rows of the right hand matrix */ - const Word16 colsX, /* i : number of columns of the right hand matrix */ - const Word16 transpX, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication */ - Word32 *Z, /* o : resulting matrix after the matrix multiplication */ + const Word16 rowsX, /* i : number of rows of the right hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the right hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication Q0*/ + Word32 *Z, /* o : resulting matrix after the matrix multiplication Q31 - Z_e*/ Word16 *Z_e ) { Word16 i, j; @@ -2250,8 +2250,8 @@ Word16 diag_matrix_product_fx( { FOR( j = 0; j < entriesY; ++j ) { - tmp = add( i, imult1616( j, rowsX ) ); - *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); + tmp = add( i, imult1616( j, rowsX ) ); /*Q0*/ + *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/ move32(); Zp++; } @@ -2267,7 +2267,7 @@ Word16 diag_matrix_product_fx( { FOR( j = 0; j < entriesY; ++j ) { - *( Zp ) = Mpy_32_32( *( X ), Y[j] ); + *( Zp ) = Mpy_32_32( *( X ), Y[j] ); /*Q31 - (X_e + Y_e)*/ move32(); Zp++; X++; @@ -2338,17 +2338,17 @@ int16_t diag_matrix_product( #ifdef IVAS_FLOAT_FIXED Word16 matrix_product_diag_fx( - const Word32 *X, /* i : left hand matrix */ + const Word32 *X, /* i : left hand matrix Q31 - X_e*/ Word16 X_e, - const Word16 rowsX, /* i : number of rows of the left hand matrix */ - const Word16 colsX, /* i : number of columns of the left hand matrix */ - const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */ - const Word32 *Y, /* i : right hand matrix */ + const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ + const Word32 *Y, /* i : right hand matrix Q31 - Y_e*/ Word16 Y_e, - const Word16 rowsY, /* i : number of rows of the right hand matrix */ - const Word16 colsY, /* i : number of columns of the right hand matrix */ - const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication */ - Word32 *Z, /* o : resulting matrix after the matrix multiplication */ + const Word16 rowsY, /* i : number of rows of the right hand matrix Q0*/ + const Word16 colsY, /* i : number of columns of the right hand matrix Q0*/ + const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication Q0*/ + Word32 *Z, /* o : resulting matrix after the matrix multiplication Q31 - Z_e*/ Word16 *Z_e ) { Word16 j, k; @@ -2372,9 +2372,9 @@ Word16 matrix_product_diag_fx( move32(); FOR( k = 0; k < rowsX; ++k ) { - x_idx = add( k, imult1616( j, rowsX ) ); - y_idx = add( k, imult1616( j, rowsY ) ); - ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); + x_idx = add( k, imult1616( j, rowsX ) ); /*Q0*/ + y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ + ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); /*Q31 - (X_e + Y_e)*/ move32(); } Zp++; @@ -2392,9 +2392,9 @@ Word16 matrix_product_diag_fx( move32(); FOR( k = 0; k < colsX; ++k ) { - x_idx = add( j, imult1616( k, rowsX ) ); - y_idx = add( j, imult1616( k, rowsY ) ); - ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); + x_idx = add( j, imult1616( k, rowsX ) ); /*Q0*/ + y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ + ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); /*Q31 - (X_e + Y_e)*/ move32(); } Zp++; @@ -2414,9 +2414,9 @@ Word16 matrix_product_diag_fx( move32(); FOR( k = 0; k < colsX; ++k ) { - x_idx = add( k, imult1616( j, rowsX ) ); - y_idx = add( j, imult1616( k, rowsY ) ); - ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); + x_idx = add( k, imult1616( j, rowsX ) ); /*Q0*/ + y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ + ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); /*Q31 - (X_e + Y_e)*/ move32(); } @@ -2436,9 +2436,9 @@ Word16 matrix_product_diag_fx( move32(); FOR( k = 0; k < colsX; ++k ) { - x_idx = add( j, imult1616( k, rowsX ) ); - y_idx = add( k, imult1616( j, rowsY ) ); - ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); + x_idx = add( j, imult1616( k, rowsX ) ); /*Q0*/ + y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ + ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); /*Q31 - (X_e + Y_e)*/ move32(); } Zp++; @@ -2550,12 +2550,12 @@ int16_t matrix_product_diag( #ifdef IVAS_FLOAT_FIXED void cmplx_matrix_square_fx( - const Word32 *realX, /* i : real part of the matrix */ - const Word32 *imagX, /* i : imaginary part of the matrix */ - const Word16 mRows, /* i : number of rows of the matrix */ - const Word16 nCols, /* i : number of columns of the matrix */ - Word32 *realZ, /* o : real part of the resulting matrix */ - Word32 *imagZ, /* o : imaginary part of the resulting matrix */ + const Word32 *realX, /* i : real part of the matrix Q31 - input_exp*/ + const Word32 *imagX, /* i : imaginary part of the matrix Q31 - input_exp*/ + const Word16 mRows, /* i : number of rows of the matrix Q0*/ + const Word16 nCols, /* i : number of columns of the matrix Q0*/ + Word32 *realZ, /* o : real part of the resulting matrix Q31 - output_exp*/ + Word32 *imagZ, /* o : imaginary part of the resulting matrix Q31 - output_exp*/ Word16 input_exp, Word16 *output_exp ) { @@ -2572,12 +2572,12 @@ void cmplx_matrix_square_fx( { FOR( j = i; j < nCols; j++ ) { - p_real1 = realX + imult1616( i, mRows ); - p_imag1 = imagX + imult1616( i, mRows ); - p_real2 = realX + imult1616( j, mRows ); - p_imag2 = imagX + imult1616( j, mRows ); - realZp = realZ + add( i, imult1616( nCols, j ) ); - imagZp = imagZ + add( i, imult1616( nCols, j ) ); + p_real1 = realX + imult1616( i, mRows ); /*Q31 - input_exp*/ + p_imag1 = imagX + imult1616( i, mRows ); /*Q31 - input_exp*/ + p_real2 = realX + imult1616( j, mRows ); /*Q31 - input_exp*/ + p_imag2 = imagX + imult1616( j, mRows ); /*Q31 - input_exp*/ + realZp = realZ + add( i, imult1616( nCols, j ) ); /*Q31 - output_exp*/ + imagZp = imagZ + add( i, imult1616( nCols, j ) ); /*Q31 - output_exp*/ *( realZp ) = 0; move32(); *( imagZp ) = 0; @@ -2585,9 +2585,9 @@ void cmplx_matrix_square_fx( FOR( k = 0; k < mRows; k++ ) { - *( imagZp ) = L_add( *( imagZp ), L_sub( Mpy_32_32( *( p_real1 ), *( p_imag2 ) ), Mpy_32_32( *( p_real2 ), *( p_imag1 ) ) ) ); + *( imagZp ) = L_add( *( imagZp ), L_sub( Mpy_32_32( *( p_real1 ), *( p_imag2 ) ), Mpy_32_32( *( p_real2 ), *( p_imag1 ) ) ) ); /* Q31 - 2*input_exp */ move32(); - *( realZp ) = L_add( *( realZp ), L_add( Mpy_32_32( *( p_real1 ), *( p_real2 ) ), Mpy_32_32( *( p_imag1 ), *( p_imag2 ) ) ) ); + *( realZp ) = L_add( *( realZp ), L_add( Mpy_32_32( *( p_real1 ), *( p_real2 ) ), Mpy_32_32( *( p_imag1 ), *( p_imag2 ) ) ) ); /* Q31 - 2*input_exp */ move32(); p_real1++; p_real2++; @@ -2602,11 +2602,11 @@ void cmplx_matrix_square_fx( { FOR( j = 0; j < i; j++ ) { - tmp1 = add( i, imult1616( nCols, j ) ); - tmp2 = add( j, imult1616( nCols, i ) ); - realZ[tmp1] = realZ[tmp2]; + tmp1 = add( i, imult1616( nCols, j ) ); /*Q0*/ + tmp2 = add( j, imult1616( nCols, i ) ); /*Q0*/ + realZ[tmp1] = realZ[tmp2]; /*Q31 - output_exp*/ move32(); - imagZ[tmp1] = imagZ[tmp2]; + imagZ[tmp1] = imagZ[tmp2]; /*Q31 - output_exp*/ move32(); } } @@ -2702,10 +2702,10 @@ void v_multc_acc( #ifdef IVAS_FLOAT_FIXED void v_multc_acc_32_16( - const Word32 x[], /* i : Input vector */ - const Word16 c, /* i : Constant */ - Word32 y[], /* o : Output vector that contains y + c*x */ - const Word16 N /* i : Vector length */ + const Word32 x[], /* i : Input vector Qx*/ + const Word16 c, /* i : Constant Q31*/ + Word32 y[], /* o : Output vector that contains y + c*x Qx*/ + const Word16 N /* i : Vector length Q0*/ ) { Word16 i; @@ -2719,17 +2719,17 @@ void v_multc_acc_32_16( return; } void v_multc_acc_32_32( - const Word32 x[], /* i : Input vector */ - const Word32 c, /* i : Constant */ - Word32 y[], /* o : Output vector that contains y + c*x */ - const Word16 N /* i : Vector length */ + const Word32 x[], /* i : Input vector Qx*/ + const Word32 c, /* i : Constant Q31*/ + Word32 y[], /* o : Output vector that contains y + c*x Qx*/ + const Word16 N /* i : Vector length Q0*/ ) { Word16 i; FOR( i = 0; i < N; i++ ) { - y[i] = L_add( y[i], Mpy_32_32( x[i], c ) ); + y[i] = L_add( y[i], Mpy_32_32( x[i], c ) ); /*Qx*/ move32(); } @@ -2793,11 +2793,11 @@ void lls_interp_n( #ifdef IVAS_FLOAT_FIXED void lls_interp_n_fx( - Word16 x_fx[], /* i/o: input/output vector */ - const Word16 N, /* i : length of the input vector */ - Word16 *a_fx, /* o : calculated slope */ - Word16 *b_fx, /* o : calculated offset */ - const Word16 upd /* i : use 1 to update x[] with the interpolated output */ + Word16 x_fx[], /* i/o: input/output vector Q15*/ + const Word16 N, /* i : length of the input vector Q0*/ + Word16 *a_fx, /* o : calculated slope Q15*/ + Word16 *b_fx, /* o : calculated offset Q15*/ + const Word16 upd /* i : use 1 to update x[] with the interpolated output Q0*/ ) { Word16 i; @@ -2814,7 +2814,7 @@ void lls_interp_n_fx( move16(); move16(); - const Word16 one_by_n_fx[11] = { 0, 32767, 16384, 10911, 8192, 6553, 5459, 4681, 4096, 3640, 3276 }; + const Word16 one_by_n_fx[11] = { 0, 32767, 16384, 10911, 8192, 6553, 5459, 4681, 4096, 3640, 3276 }; /*Q15*/ move16(); move16(); move16(); @@ -2827,7 +2827,7 @@ void lls_interp_n_fx( move16(); move16(); - const Word16 sum_i_fx[12] = { 0, 0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55 }; + const Word16 sum_i_fx[12] = { 0, 0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55 }; /*Q0*/ move16(); move16(); move16(); @@ -2842,7 +2842,7 @@ void lls_interp_n_fx( move16(); // 1.0f/ ( N * sum_ii[N] - sum_i[N] * sum_i[N] ) - const Word32 res_table[12] = { 0, 0, 0, 357913952, 107374184, 42949672, 20452226, 10956549, 6391320, 3976821, 2603010, 385 }; + const Word32 res_table[12] = { 0, 0, 0, 357913952, 107374184, 42949672, 20452226, 10956549, 6391320, 3976821, 2603010, 385 }; /*Q31*/ move16(); move16(); move16(); @@ -2873,15 +2873,15 @@ void lls_interp_n_fx( FOR( int idx = 0; idx < N; idx++ ) #endif { - sum_x_fx = L_add( sum_x_fx, x_fx[idx] ); + sum_x_fx = L_add( sum_x_fx, x_fx[idx] ); /*Q15*/ } - sum_ix_fx = dotp_fx( x_fx, n_i_fx, N, &dot_exp ); + sum_ix_fx = dotp_fx( x_fx, n_i_fx, N, &dot_exp ); /*sum_ix_q*/ sum_ix_q = sub( 30, sub( dot_exp, ( 11 + 15 ) ) ); - sum_ix_fx = L_shr( sum_ix_fx, sub( sum_ix_q, 15 ) ); - num = L_sub( imult3216( sum_ix_fx, N ), imult3216( sum_x_fx, sum_i_fx[N] ) ); - slope_fx = Mpy_32_32( num, res_table[N] ); - offset_fx = Mpy_32_16_1( L_sub( sum_x_fx, imult3216( slope_fx, sum_i_fx[N] ) ), one_by_n_fx[N] ); + sum_ix_fx = L_shr( sum_ix_fx, sub( sum_ix_q, 15 ) ); /*Q15*/ + num = L_sub( imult3216( sum_ix_fx, N ), imult3216( sum_x_fx, sum_i_fx[N] ) ); /*Q15*/ + slope_fx = Mpy_32_32( num, res_table[N] ); /*Q15*/ + offset_fx = Mpy_32_16_1( L_sub( sum_x_fx, imult3216( slope_fx, sum_i_fx[N] ) ), one_by_n_fx[N] ); /*Q15*/ IF( upd ) { @@ -2889,12 +2889,12 @@ void lls_interp_n_fx( { IF( GT_32( imult3216( slope_fx, i ), MAX_WORD16 ) ) { - x_fx[i] = MAX_WORD16; + x_fx[i] = MAX_WORD16; /*Q15*/ move16(); } ELSE { - x_fx[i] = extract_l( L_add_sat( imult3216( slope_fx, i ), offset_fx ) ); + x_fx[i] = extract_l( L_add_sat( imult3216( slope_fx, i ), offset_fx ) ); /*Q15*/ move16(); } } @@ -2902,13 +2902,13 @@ void lls_interp_n_fx( IF( a_fx != NULL ) { - *a_fx = extract_l( slope_fx ); + *a_fx = extract_l( slope_fx ); /*Q15*/ move16(); } IF( b_fx != NULL ) { - *b_fx = extract_l( offset_fx ); + *b_fx = extract_l( offset_fx ); /*Q15*/ move16(); } @@ -2941,21 +2941,21 @@ static float wrap_azi( static Word32 wrap_azi_fx( const Word32 azi_deg /* Q22 */ ) { - Word32 azi = azi_deg; + Word32 azi = azi_deg; /*Q22*/ move32(); /* Wrap azimuth value */ WHILE( GT_32( azi, ANGLE_180_DEG_Q22 ) ) { - azi = L_sub( azi, ANGLE_360_DEG_Q22 ); + azi = L_sub( azi, ANGLE_360_DEG_Q22 ); /*Q22*/ } WHILE( LE_32( azi, -ANGLE_180_DEG_Q22 ) ) { - azi = L_add( azi, ANGLE_360_DEG_Q22 ); + azi = L_add( azi, ANGLE_360_DEG_Q22 ); /*Q22*/ } - return azi; + return azi; /*Q22*/ } #endif /*-------------------------------------------------------------------* @@ -3043,16 +3043,16 @@ void panning_wrap_angles_fx( { Word32 azi, ele; - azi = azi_deg; + azi = azi_deg; /*Q22*/ move32(); - ele = ele_deg; + ele = ele_deg; /*Q22*/ move32(); IF( LT_32( L_abs( ele ), ANGLE_90_DEG_Q22 ) ) { - *ele_wrapped = ele; + *ele_wrapped = ele; /*Q22*/ move32(); - *azi_wrapped = wrap_azi_fx( azi ); + *azi_wrapped = wrap_azi_fx( azi ); /*Q22*/ move32(); return; } @@ -3092,9 +3092,9 @@ void panning_wrap_angles_fx( ele = L_sub( -ANGLE_180_DEG_Q22, ele ); } } - *azi_wrapped = wrap_azi_fx( azi ); + *azi_wrapped = wrap_azi_fx( azi ); /*Q22*/ move32(); - *ele_wrapped = ele; + *ele_wrapped = ele; /*Q22*/ move32(); } @@ -3150,9 +3150,9 @@ void v_sort_ind( *-------------------------------------------------------------------------*/ void v_sort_ind_fixed( - Word32 *x, /* i/o: Vector to be sorted */ - Word16 *idx, /* o : Original index positions */ - const Word16 len /* i : vector length */ + Word32 *x, /* i/o: Vector to be sorted Qx*/ + Word16 *idx, /* o : Original index positions Q0*/ + const Word16 len /* i : vector length Q0*/ ) { Word16 i, j; @@ -3167,22 +3167,22 @@ void v_sort_ind_fixed( FOR( i = len - 2; i >= 0; i-- ) { - tempr = x[i]; + tempr = x[i]; /*Qx*/ move32(); - tempi = idx[i]; + tempi = idx[i]; /*Qx*/ move16(); test(); - FOR( j = add( i, 1 ); LT_16( j, len ) && GT_32( tempr, x[j] ); j++ ) + FOR( j = ( i + 1 ); LT_16( j, len ) && GT_32( tempr, x[j] ); j++ ) { test(); - x[j - 1] = x[j]; + x[j - 1] = x[j]; /*Qx*/ move32(); - idx[j - 1] = idx[j]; + idx[j - 1] = idx[j]; /*Qx*/ move16(); } - x[j - 1] = tempr; + x[j - 1] = tempr; /*Qx*/ move32(); - idx[j - 1] = tempi; + idx[j - 1] = tempi; /*Qx*/ move16(); } @@ -3198,7 +3198,7 @@ void v_sort_ind_fixed( /*! r: flag indicating a valid bitrate */ Word16 is_IVAS_bitrate_fx( - const Word32 ivas_total_brate /* i : IVAS total bitrate */ + const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/ ) { Word16 j; @@ -3229,7 +3229,7 @@ Word16 is_IVAS_bitrate_fx( #ifdef IVAS_FLOAT_FIXED Word16 is_DTXrate( - const Word32 ivas_total_brate /* i : IVAS total bitrate */ + const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/ ) { Word16 dtx_rate_flag = 0; @@ -3242,7 +3242,7 @@ Word16 is_DTXrate( move16(); } - return dtx_rate_flag; + return dtx_rate_flag; /*Q0*/ } #else int16_t is_DTXrate( @@ -3268,7 +3268,7 @@ int16_t is_DTXrate( #ifdef IVAS_FLOAT_FIXED Word16 is_SIDrate( - const Word32 ivas_total_brate /* i : IVAS total bitrate */ + const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/ ) { Word16 sid_rate_flag = 0; @@ -3284,7 +3284,7 @@ Word16 is_SIDrate( move16(); } - return sid_rate_flag; + return sid_rate_flag; /*Q0*/ } #else int16_t is_SIDrate( @@ -3330,7 +3330,7 @@ float rand_triangular_signed( #ifdef IVAS_FLOAT_FIXED Word16 rand_triangular_signed_fx( - Word16 *seed, + Word16 *seed, /*Q0*/ Word16 *exp_fac ) { Word16 rand_val; @@ -3342,9 +3342,9 @@ Word16 rand_triangular_signed_fx( { /* rand_val in [-1, 0] */ /*0.5f * (sqrtf(rand_val + 1.0f) - 1)*/ - tmp1 = Sqrt16( add( shr( rand_val, 1 ), ONE_IN_Q14 ), &exp ); - exp1 = BASOP_Util_Add_MantExp( tmp1, exp, negate( ONE_IN_Q14 ), 1, &tmp2 ); - tmp2 = shr( tmp2, 1 ); + tmp1 = Sqrt16( add( shr( rand_val, 1 ), ONE_IN_Q14 ), &exp ); /*Q15 - exp*/ + exp1 = BASOP_Util_Add_MantExp( tmp1, exp, negate( ONE_IN_Q14 ), 1, &tmp2 ); /*Q15 - exp1*/ + tmp2 = shr( tmp2, 1 ); /*Q15 - exp1*/ *exp_fac = exp1; move16(); return tmp2; @@ -3353,16 +3353,16 @@ Word16 rand_triangular_signed_fx( { /* rand_val in (0, 1) */ /*0.5f * ( 1 - sqrtf(1.0f - rand_val))*/ - Word16 one_minus_rand = sub( MAX16B, rand_val ); + Word16 one_minus_rand = sub( MAX16B, rand_val ); /*Q15*/ exp = 0; move16(); - tmp1 = Sqrt16( one_minus_rand, &exp ); // q15 - exp - exp1 = BASOP_Util_Add_MantExp( ONE_IN_Q14, 1, negate( tmp1 ), exp, &tmp2 ); - tmp2 = shr( tmp2, 1 ); + tmp1 = Sqrt16( one_minus_rand, &exp ); // q15 - exp + exp1 = BASOP_Util_Add_MantExp( ONE_IN_Q14, 1, negate( tmp1 ), exp, &tmp2 ); /*Q15 - exp1*/ + tmp2 = shr( tmp2, 1 ); /*Q15 - exp1*/ *exp_fac = exp1; move16(); - return tmp2; + return tmp2; /*Q15 - exp_fac*/ } } @@ -3372,7 +3372,7 @@ Word16 rand_triangular_signed_fx( * calculates ceil(log2(val)) *-------------------------------------------------------------------*/ Word16 ceil_log_2( - UWord64 val ) + UWord64 val /*Q0*/ ) { IF( val <= 0 ) @@ -3648,8 +3648,8 @@ Word16 ceil_log_2( *-------------------------------------------------------------------*/ Word64 var_32_fx( - const Word32 *x, /* i : input vector */ - const Word16 len, /* i : length of inputvector */ + const Word32 *x, /* i : input vector q*/ + const Word16 len, /* i : length of inputvector Q0*/ Word16 q /* q : q-factor for the array */ ) { @@ -3663,20 +3663,20 @@ Word64 var_32_fx( FOR( int i = 0; i < len; i++ ) { - mean = W_add( mean, x[i] ); + mean = W_add( mean, x[i] ); /*q*/ } - mean = mean / len; /* NOTE: No BASOP for 64 bit division */ + mean = mean / len; /* NOTE: No BASOP for 64 bit division q*/ FOR( int i = 0; i < len; i++ ) { - var = W_add( var, Mpy_32_32( L_sub( x[i], W_extract_l( mean ) ), L_sub( x[i], W_extract_l( mean ) ) ) ); + var = W_add( var, Mpy_32_32( L_sub( x[i], W_extract_l( mean ) ), L_sub( x[i], W_extract_l( mean ) ) ) ); /*q + q - 31*/ } - var = W_shl( var, sub( 31, q ) ); + var = W_shl( var, sub( 31, q ) ); /*q*/ - var = var / len; /* NOTE: No BASOP for 64 bit division */ + var = var / len; /* NOTE: No BASOP for 64 bit division q*/ - return var; + return var; /*q*/ } #endif diff --git a/lib_com/ivas_transient_det.c b/lib_com/ivas_transient_det.c index 019874fc9..a41e5ea92 100644 --- a/lib_com/ivas_transient_det.c +++ b/lib_com/ivas_transient_det.c @@ -127,7 +127,7 @@ #ifdef IVAS_FLOAT_FIXED static void ivas_transient_det_init( ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */ - const Word32 sampling_rate /* i : sampling rate */ + const Word32 sampling_rate /* i : sampling rate Q0*/ ) { Word16 i; @@ -148,104 +148,104 @@ static void ivas_transient_det_init( { case 48000: /*env_hpf*/ - filt_coeff_arr_fx[0][0] = IVAS_C_HPF_48k_fx; + filt_coeff_arr_fx[0][0] = IVAS_C_HPF_48k_fx; /*Q30*/ move32(); - filt_coeff_arr_fx[0][1] = L_negate( IVAS_C_HPF_48k_fx ); + filt_coeff_arr_fx[0][1] = L_negate( IVAS_C_HPF_48k_fx ); /*Q30*/ move32(); - filt_coeff_arr_fx[0][3] = ONE_IN_Q30; + filt_coeff_arr_fx[0][3] = ONE_IN_Q30; /*Q30*/ move32(); - filt_coeff_arr_fx[0][4] = L_negate( IVAS_C_HPF_48k_fx ); + filt_coeff_arr_fx[0][4] = L_negate( IVAS_C_HPF_48k_fx ); /*Q30*/ move32(); /*env_fast*/ - filt_coeff_arr_fx[1][0] = L_sub( ONE_IN_Q30, IVAS_C_FAST_48k_fx ); + filt_coeff_arr_fx[1][0] = L_sub( ONE_IN_Q30, IVAS_C_FAST_48k_fx ); /*Q30*/ move32(); - filt_coeff_arr_fx[1][3] = ONE_IN_Q30; + filt_coeff_arr_fx[1][3] = ONE_IN_Q30; /*Q30*/ move32(); - filt_coeff_arr_fx[1][4] = L_negate( IVAS_C_FAST_48k_fx ); + filt_coeff_arr_fx[1][4] = L_negate( IVAS_C_FAST_48k_fx ); /*Q30*/ move32(); /*env_slow*/ - filt_coeff_arr_fx[2][0] = L_sub( ONE_IN_Q30, IVAS_C_SLOW_48k_fx ); + filt_coeff_arr_fx[2][0] = L_sub( ONE_IN_Q30, IVAS_C_SLOW_48k_fx ); /*Q30*/ move32(); - filt_coeff_arr_fx[2][3] = ONE_IN_Q30; + filt_coeff_arr_fx[2][3] = ONE_IN_Q30; /*Q30*/ move32(); - filt_coeff_arr_fx[2][4] = L_negate( IVAS_C_SLOW_48k_fx ); + filt_coeff_arr_fx[2][4] = L_negate( IVAS_C_SLOW_48k_fx ); /*Q30*/ move32(); - hTranDet->in_duck_coeff = IVAS_C_IN_DUCK_48k_fx; + hTranDet->in_duck_coeff = IVAS_C_IN_DUCK_48k_fx; /*Q30*/ move32(); - hTranDet->out_duck_coeff = IVAS_C_OUT_DUCK_48k_fx; + hTranDet->out_duck_coeff = IVAS_C_OUT_DUCK_48k_fx; /*Q30*/ move32(); BREAK; case 32000: /*env_hpf*/ - filt_coeff_arr_fx[0][0] = IVAS_C_HPF_32k_fx; + filt_coeff_arr_fx[0][0] = IVAS_C_HPF_32k_fx; /*Q30*/ move32(); - filt_coeff_arr_fx[0][1] = L_negate( IVAS_C_HPF_32k_fx ); + filt_coeff_arr_fx[0][1] = L_negate( IVAS_C_HPF_32k_fx ); /*Q30*/ move32(); - filt_coeff_arr_fx[0][3] = ONE_IN_Q30; + filt_coeff_arr_fx[0][3] = ONE_IN_Q30; /*Q30*/ move32(); - filt_coeff_arr_fx[0][4] = L_negate( IVAS_C_HPF_32k_fx ); + filt_coeff_arr_fx[0][4] = L_negate( IVAS_C_HPF_32k_fx ); /*Q30*/ move32(); /*env_fast*/ - filt_coeff_arr_fx[1][0] = L_sub( ONE_IN_Q30, IVAS_C_FAST_32k_fx ); + filt_coeff_arr_fx[1][0] = L_sub( ONE_IN_Q30, IVAS_C_FAST_32k_fx ); /*Q30*/ move32(); - filt_coeff_arr_fx[1][3] = ONE_IN_Q30; + filt_coeff_arr_fx[1][3] = ONE_IN_Q30; /*Q30*/ move32(); - filt_coeff_arr_fx[1][4] = L_negate( IVAS_C_FAST_32k_fx ); + filt_coeff_arr_fx[1][4] = L_negate( IVAS_C_FAST_32k_fx ); /*Q30*/ move32(); /*env_slow*/ - filt_coeff_arr_fx[2][0] = L_sub( ONE_IN_Q30, IVAS_C_SLOW_32k_fx ); + filt_coeff_arr_fx[2][0] = L_sub( ONE_IN_Q30, IVAS_C_SLOW_32k_fx ); /*Q30*/ move32(); - filt_coeff_arr_fx[2][3] = ONE_IN_Q30; + filt_coeff_arr_fx[2][3] = ONE_IN_Q30; /*Q30*/ move32(); - filt_coeff_arr_fx[2][4] = L_negate( IVAS_C_SLOW_32k_fx ); + filt_coeff_arr_fx[2][4] = L_negate( IVAS_C_SLOW_32k_fx ); /*Q30*/ move32(); - hTranDet->in_duck_coeff = IVAS_C_IN_DUCK_32k_fx; + hTranDet->in_duck_coeff = IVAS_C_IN_DUCK_32k_fx; /*Q30*/ move32(); - hTranDet->out_duck_coeff = IVAS_C_OUT_DUCK_32k_fx; + hTranDet->out_duck_coeff = IVAS_C_OUT_DUCK_32k_fx; /*Q30*/ move32(); BREAK; case 16000: /*env_hpf*/ - filt_coeff_arr_fx[0][0] = IVAS_C_HPF_16k_fx; + filt_coeff_arr_fx[0][0] = IVAS_C_HPF_16k_fx; /*Q30*/ move32(); - filt_coeff_arr_fx[0][1] = L_negate( IVAS_C_HPF_16k_fx ); + filt_coeff_arr_fx[0][1] = L_negate( IVAS_C_HPF_16k_fx ); /*Q30*/ move32(); - filt_coeff_arr_fx[0][3] = ONE_IN_Q30; + filt_coeff_arr_fx[0][3] = ONE_IN_Q30; /*Q30*/ move32(); - filt_coeff_arr_fx[0][4] = L_negate( IVAS_C_HPF_16k_fx ); + filt_coeff_arr_fx[0][4] = L_negate( IVAS_C_HPF_16k_fx ); /*Q30*/ move32(); /*env_fast*/ - filt_coeff_arr_fx[1][0] = L_sub( ONE_IN_Q30, IVAS_C_FAST_16k_fx ); + filt_coeff_arr_fx[1][0] = L_sub( ONE_IN_Q30, IVAS_C_FAST_16k_fx ); /*Q30*/ move32(); - filt_coeff_arr_fx[1][3] = ONE_IN_Q30; + filt_coeff_arr_fx[1][3] = ONE_IN_Q30; /*Q30*/ move32(); - filt_coeff_arr_fx[1][4] = L_negate( IVAS_C_FAST_16k_fx ); + filt_coeff_arr_fx[1][4] = L_negate( IVAS_C_FAST_16k_fx ); /*Q30*/ move32(); /*env_slow*/ - filt_coeff_arr_fx[2][0] = L_sub( ONE_IN_Q30, IVAS_C_SLOW_16k_fx ); + filt_coeff_arr_fx[2][0] = L_sub( ONE_IN_Q30, IVAS_C_SLOW_16k_fx ); /*Q30*/ move32(); - filt_coeff_arr_fx[2][3] = ONE_IN_Q30; + filt_coeff_arr_fx[2][3] = ONE_IN_Q30; /*Q30*/ move32(); - filt_coeff_arr_fx[2][4] = L_negate( IVAS_C_SLOW_16k_fx ); + filt_coeff_arr_fx[2][4] = L_negate( IVAS_C_SLOW_16k_fx ); /*Q30*/ move32(); - hTranDet->in_duck_coeff = IVAS_C_IN_DUCK_16k_fx; + hTranDet->in_duck_coeff = IVAS_C_IN_DUCK_16k_fx; /*Q30*/ move32(); - hTranDet->out_duck_coeff = IVAS_C_OUT_DUCK_16k_fx; + hTranDet->out_duck_coeff = IVAS_C_OUT_DUCK_16k_fx; /*Q30*/ move32(); @@ -256,7 +256,7 @@ static void ivas_transient_det_init( ivas_filters_init_fx( &hTranDet->env_fast, (const Word32 *) filt_coeff_arr_fx[1], filt_coeff_arr_e, IVAS_FILTER_ORDER_1 ); ivas_filters_init_fx( &hTranDet->env_slow, (const Word32 *) filt_coeff_arr_fx[2], filt_coeff_arr_e, IVAS_FILTER_ORDER_1 ); - hTranDet->duck_mult_fac = IVAS_TDET_DUCK_MULT_FAC; + hTranDet->duck_mult_fac = IVAS_TDET_DUCK_MULT_FAC; /*Q29*/ move32(); return; @@ -353,7 +353,7 @@ static void ivas_transient_det_init( #ifdef IVAS_FLOAT_FIXED ivas_error ivas_transient_det_open_fx( ivas_trans_det_state_t **hTranDet_in, /* i/o: Transient detector handle */ - const Word32 sampling_rate /* i : sampling rate */ + const Word32 sampling_rate /* i : sampling rate Q0*/ ) { ivas_trans_det_state_t *hTranDet; @@ -439,14 +439,14 @@ void ivas_transient_det_close( void ivas_transient_det_process_fx( ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ - Word32 *pIn_pcm, /* i : input audio channels */ - const Word16 frame_len, /* i : frame length in samples */ - Word16 transient_det[2] /* o : transient det outputs */ + Word32 *pIn_pcm, /* i : input audio channels Q11*/ + const Word16 frame_len, /* i : frame length in samples Q0*/ + Word16 transient_det[2] /* o : transient det outputs Q0*/ ) { Word32 in_duck_gain[L_FRAME48k]; Word16 num_sf, sf, sf_samp, idx; - Word32 mem = hTranDet->in_duck_gain; + Word32 mem = hTranDet->in_duck_gain; /*Q30*/ move32(); ivas_td_decorr_get_ducking_gains_fx( hTranDet, pIn_pcm, in_duck_gain, NULL, frame_len, IVAS_TDET_ONLY ); @@ -460,9 +460,9 @@ void ivas_transient_det_process_fx( move16(); } - num_sf = 16; + num_sf = 16; /*Q0*/ move16(); - sf_samp = idiv1616( frame_len, num_sf ); + sf_samp = idiv1616( frame_len, num_sf ); /*Q0*/ FOR( sf = 1; sf <= num_sf; sf++ ) { idx = sub( imult1616( sf_samp, sf ), 1 ); @@ -471,7 +471,7 @@ void ivas_transient_det_process_fx( transient_det[1] = 1; move16(); } - mem = in_duck_gain[idx]; + mem = in_duck_gain[idx]; /*Q30*/ move32(); } @@ -552,15 +552,15 @@ static float ivas_calc_duck_gain( *-----------------------------------------------------------------------------------------*/ static Word32 ivas_calc_duck_gain_fx( - const Word32 duck_gain, - const Word32 duck_coeff, - const Word32 env_1, - const Word32 env_2, - const Word32 duck_mult_fac ) + const Word32 duck_gain, /*Q30*/ + const Word32 duck_coeff, /*Q30*/ + const Word32 env_1, /*Q14*/ + const Word32 env_2, /*Q14*/ + const Word32 duck_mult_fac /*Q29*/ ) { Word32 duck_gain_out; - duck_gain_out = L_add( L_shl( Mpy_32_32( L_sub( duck_gain, ONE_IN_Q30 ), duck_coeff ), Q1 ), ONE_IN_Q30 ); + duck_gain_out = L_add( L_shl( Mpy_32_32( L_sub( duck_gain, ONE_IN_Q30 ), duck_coeff ), Q1 ), ONE_IN_Q30 ); /*Q30*/ IF( LT_32( Mpy_32_32( duck_mult_fac, env_1 ), Mpy_32_32( L_shr( duck_gain_out, 1 ), env_2 ) ) ) { @@ -572,12 +572,12 @@ static Word32 ivas_calc_duck_gain_fx( } ELSE { - duck_gain_out = Mpy_32_32( duck_mult_fac, L_shl( (Word32) ( divide3232( env_1, env_2 ) ), Q16 ) ); - duck_gain_out = L_shl( duck_gain_out, Q1 ); + duck_gain_out = Mpy_32_32( duck_mult_fac, L_shl( (Word32) ( divide3232( env_1, env_2 ) ), Q16 ) ); /*Q29*/ + duck_gain_out = L_shl( duck_gain_out, Q1 ); /*Q30*/ } } - return duck_gain_out; + return duck_gain_out; /*Q30*/ } #endif #ifndef IVAS_FLOAT_FIXED @@ -654,27 +654,27 @@ void ivas_td_decorr_get_ducking_gains( void ivas_td_decorr_get_ducking_gains_fx( ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */ - Word32 *pIn_pcm, - Word32 *pIn_duck_gains, - Word32 *pOut_duck_gains, - const Word16 frame_len, - const Word16 tdet_flag ) + Word32 *pIn_pcm, /*Q11*/ + Word32 *pIn_duck_gains, /*Q30*/ + Word32 *pOut_duck_gains, /*Q30*/ + const Word16 frame_len, /*Q0*/ + const Word16 tdet_flag /*Q0*/ ) { Word16 i, q = Q14; move16(); Word32 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k]; - Word32 in_duck_gain = hTranDet->in_duck_gain; + Word32 in_duck_gain = hTranDet->in_duck_gain; /*Q30*/ move32(); - Word32 out_duck_gain = hTranDet->out_duck_gain; + Word32 out_duck_gain = hTranDet->out_duck_gain; /*Q30*/ move32(); - Word32 in_duck_coeff = hTranDet->in_duck_coeff; + Word32 in_duck_coeff = hTranDet->in_duck_coeff; /*Q30*/ move32(); - Word32 out_duck_coeff = hTranDet->out_duck_coeff; + Word32 out_duck_coeff = hTranDet->out_duck_coeff; /*Q30*/ move32(); - Word32 duck_mult_fac = hTranDet->duck_mult_fac; + Word32 duck_mult_fac = hTranDet->duck_mult_fac; /*Q29*/ move32(); - Copy32( pIn_pcm, e_fast_fx, frame_len ); + Copy32( pIn_pcm, e_fast_fx, frame_len ); /*Q11*/ /* env hpf */ ivas_filter_process_fx( &hTranDet->env_hpf, e_fast_fx, frame_len, q ); @@ -683,9 +683,9 @@ void ivas_td_decorr_get_ducking_gains_fx( FOR( i = 0; i < frame_len; i++ ) { - e_fast_fx[i] = L_add( L_abs( e_fast_fx[i] ), L_shr( IVAS_TDET_PARM_ENV_EPS_fx, q_factor_diff ) ); + e_fast_fx[i] = L_add( L_abs( e_fast_fx[i] ), L_shr( IVAS_TDET_PARM_ENV_EPS_fx, q_factor_diff ) ); /*Q14*/ move32(); - e_slow_fx[i] = e_fast_fx[i]; + e_slow_fx[i] = e_fast_fx[i]; /*Q14*/ move32(); } @@ -699,27 +699,27 @@ void ivas_td_decorr_get_ducking_gains_fx( { FOR( i = 0; i < frame_len; i++ ) { - in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], e_fast_fx[i], duck_mult_fac ); - pIn_duck_gains[i] = in_duck_gain; + in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], e_fast_fx[i], duck_mult_fac ); /*Q30*/ + pIn_duck_gains[i] = in_duck_gain; /*Q30*/ move32(); } - hTranDet->in_duck_gain = in_duck_gain; + hTranDet->in_duck_gain = in_duck_gain; /*Q30*/ move32(); } ELSE { FOR( i = 0; i < frame_len; i++ ) { - in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], e_fast_fx[i], duck_mult_fac ); - pIn_duck_gains[i] = in_duck_gain; + in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], e_fast_fx[i], duck_mult_fac ); /*Q30*/ + pIn_duck_gains[i] = in_duck_gain; /*Q30*/ move32(); - out_duck_gain = ivas_calc_duck_gain_fx( out_duck_gain, out_duck_coeff, e_fast_fx[i], e_slow_fx[i], duck_mult_fac ); - pOut_duck_gains[i] = out_duck_gain; + out_duck_gain = ivas_calc_duck_gain_fx( out_duck_gain, out_duck_coeff, e_fast_fx[i], e_slow_fx[i], duck_mult_fac ); /*Q30*/ + pOut_duck_gains[i] = out_duck_gain; /*Q30*/ move32(); } - hTranDet->in_duck_gain = in_duck_gain; + hTranDet->in_duck_gain = in_duck_gain; /*Q30*/ move32(); - hTranDet->out_duck_gain = out_duck_gain; + hTranDet->out_duck_gain = out_duck_gain; /*Q30*/ move32(); } diff --git a/lib_com/lag_wind.c b/lib_com/lag_wind.c index 2d1ec48da..82279af86 100644 --- a/lib_com/lag_wind.c +++ b/lib_com/lag_wind.c @@ -175,11 +175,11 @@ void adapt_lag_wind_fx( *-------------------------------------------------------------*/ void lag_wind( - Word16 r_h[], /* in/out: autocorrelations */ - Word16 r_l[], /* in/out: autocorrelations */ - Word16 m, /* input : order of LP filter */ - Word32 sr_core, /* input : sampling rate */ - Word16 strength /* input : LAGW_WEAK, LAGW_MEDIUM, or LAGW_STRONG */ + Word16 r_h[], /* in/out: autocorrelations Q15(Q_r -16)*/ + Word16 r_l[], /* in/out: autocorrelations Q(r)-1*/ + Word16 m, /* input : order of LP filter Q0*/ + Word32 sr_core, /* input : sampling rate Q0*/ + Word16 strength /* input : LAGW_WEAK, LAGW_MEDIUM, or LAGW_STRONG Q0*/ ) { Word16 i; @@ -193,35 +193,35 @@ void lag_wind( case 8000: assert( m <= 16 ); assert( strength == LAGW_STRONG ); - wnd_h = lag_window_8k[0]; - wnd_l = lag_window_8k[1]; + wnd_h = lag_window_8k[0]; /*Q15(Q_r -16)*/ + wnd_l = lag_window_8k[1]; /*Q(r)-1*/ BREAK; case 12800: assert( m <= 16 ); - wnd_h = lag_window_12k8[strength][0]; - wnd_l = lag_window_12k8[strength][1]; + wnd_h = lag_window_12k8[strength][0]; /*Q15(Q_r -16)*/ + wnd_l = lag_window_12k8[strength][1]; /*Q(r)-1*/ BREAK; case 16000: assert( m <= 16 ); - wnd_h = lag_window_16k[strength][0]; - wnd_l = lag_window_16k[strength][1]; + wnd_h = lag_window_16k[strength][0]; /*Q15(Q_r -16)*/ + wnd_l = lag_window_16k[strength][1]; /*Q(r)-1*/ BREAK; case 24000: case 25600: assert( m <= 16 ); - wnd_h = lag_window_25k6[strength][0]; - wnd_l = lag_window_25k6[strength][1]; + wnd_h = lag_window_25k6[strength][0]; /*Q15(Q_r -16)*/ + wnd_l = lag_window_25k6[strength][1]; /*Q(r)-1*/ BREAK; case 32000: assert( m <= 16 ); - wnd_h = lag_window_32k[strength][0]; - wnd_l = lag_window_32k[strength][1]; + wnd_h = lag_window_32k[strength][0]; /*Q15(Q_r -16)*/ + wnd_l = lag_window_32k[strength][1]; /*Q(r)-1*/ BREAK; case 48000: assert( m <= 16 ); assert( strength == LAGW_STRONG ); - wnd_h = lag_window_48k[0]; - wnd_l = lag_window_48k[1]; + wnd_h = lag_window_48k[0]; /*Q15(Q_r -16)*/ + wnd_l = lag_window_48k[1]; /*Q(r)-1*/ BREAK; default: assert( !"Lag window not implemented for this sampling rate" ); @@ -230,20 +230,20 @@ void lag_wind( FOR( i = 1; i <= m; i++ ) { - tmp = Mpy_32( r_h[i], r_l[i], wnd_h[sub( i, 1 )], wnd_l[sub( i, 1 )] ); + tmp = Mpy_32( r_h[i], r_l[i], wnd_h[( i - 1 )], wnd_l[( i - 1 )] ); /*Q31*/ L_Extract( tmp, &r_h[i], &r_l[i] ); } } void lag_wind_32( - Word32 r[], /* in/out: autocorrelations */ - Word16 m, /* input : order of LP filter */ - Word32 sr_core, /* input : sampling rate */ - Word16 strength /* input : LAGW_WEAK, LAGW_MEDIUM, or LAGW_STRONG */ + Word32 r[], /* in/out: autocorrelations Qx*/ + Word16 m, /* input : order of LP filter Q0*/ + Word32 sr_core, /* input : sampling rate Q0*/ + Word16 strength /* input : LAGW_WEAK, LAGW_MEDIUM, or LAGW_STRONG Q0*/ ) { Word16 i; - const Word32 *wnd; + const Word32 *wnd; /*Q31*/ assert( 0 <= strength && strength <= NUM_LAGW_STRENGTHS ); @@ -252,29 +252,29 @@ void lag_wind_32( case 8000: assert( m <= 16 ); assert( strength == LAGW_STRONG ); - wnd = lag_window_8k_32; + wnd = lag_window_8k_32; /*Q31*/ BREAK; case 12800: assert( m <= 16 ); - wnd = lag_window_12k8_32[strength]; + wnd = lag_window_12k8_32[strength]; /*Q31*/ BREAK; case 16000: assert( m <= 16 ); - wnd = lag_window_16k_32[strength]; + wnd = lag_window_16k_32[strength]; /*Q31*/ BREAK; case 24000: case 25600: assert( m <= 16 ); - wnd = lag_window_25k6_32[strength]; + wnd = lag_window_25k6_32[strength]; /*Q31*/ BREAK; case 32000: assert( m <= 16 ); - wnd = lag_window_32k_32[strength]; + wnd = lag_window_32k_32[strength]; /*Q31*/ BREAK; case 48000: assert( m <= 16 ); assert( strength == LAGW_STRONG ); - wnd = lag_window_48k_32; + wnd = lag_window_48k_32; /*Q31*/ BREAK; default: assert( !"Lag window not implemented for this sampling rate" ); @@ -283,27 +283,27 @@ void lag_wind_32( FOR( i = 1; i <= m; i++ ) { - r[i] = Mpy_32_32( r[i], wnd[sub( i, 1 )] ); + r[i] = Mpy_32_32( r[i], wnd[( i - 1 )] ); /*Qx*/ move32(); } } void adapt_lag_wind( - Word16 r_h[], /* in/out: autocorrelations */ + Word16 r_h[], /* in/out: autocorrelations Q15*/ Word16 r_l[], /* in/out: autocorrelations */ - Word16 m, /* input : order of LP filter */ - const Word16 Top, /* input : open loop pitch lag */ - const Word16 Tnc, /* input : open loop pitch gain */ - Word32 sr_core /* input : sampling rate */ + Word16 m, /* input : order of LP filter Q0*/ + const Word16 Top, /* input : open loop pitch lag Q0*/ + const Word16 Tnc, /* input : open loop pitch gain Q15*/ + Word32 sr_core /* input : sampling rate Q0*/ ) { Word16 strength, pitch_lag; Word16 pitch_gain; - pitch_lag = Top; + pitch_lag = Top; /*Q0*/ move16(); - pitch_gain = Tnc; + pitch_gain = Tnc; /*Q15*/ move16(); IF( LT_16( pitch_lag, 80 ) ) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 1fa1b3549..4bead686b 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1457,14 +1457,14 @@ void fft_rel_fx32( ); // ifft_rel.c void ifft_rel_fx( - Word16 io[], /* i/o: i /output vector */ - const Word16 n, /* i : vector length */ - const Word16 m /* i : log2 of vector length */ + Word16 io[], /* Qx i/o: i /output vector */ + const Word16 n, /* Q0 i : vector length */ + const Word16 m /* Q0 i : log2 of vector length */ ); void ifft_rel_fx32( - Word32 io[], /* i/o: i /output vector */ - const Word16 n, /* i : vector length */ - const Word16 m /* i : log2 of vector length */ + Word32 io[], /* Qx i/o: i /output vector */ + const Word16 n, /* Q0 i : vector length */ + const Word16 m /* Q0 i : log2 of vector length */ ); // gs_gains_fx.c Word16 gsc_gaindec_fx( /* o : average frequency gain */ @@ -1585,12 +1585,12 @@ void deemph_fx_32( // int_lsp.c void int_lsp_fx( const Word16 L_frame, /* i : length of the frame */ - const Word16 lsp_old[], /* i : LSPs from past frame */ - const Word16 lsp_new[], /* i : LSPs from present frame */ - Word16 *Aq, /* o : LP coefficients in both subframes */ + const Word16 lsp_old[], /* i : Q15 LSPs from past frame */ + const Word16 lsp_new[], /* i : Q15 LSPs from present frame */ + Word16 *Aq, /* o : Q12 LP coefficients in both subframes */ const Word16 m, /* i : order of LP filter */ - const Word16 *int_coeffs, /* i : interpolation coefficients */ - const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ + const Word16 *int_coeffs, /* i : Q15 interpolation coefficients */ + const Word16 Opt_AMR_WB /* i : Q0 flag indicating AMR-WB IO mode */ ); void int_lsp4_fx( @@ -2098,17 +2098,17 @@ isf_dec_amr_wb_fx.c void disf_2s_36b_fx( Word16 *indice, /* i : quantized indices (use indice[0] = -1 in the decoder) */ - Word16 *isf_q, /* o : quantized ISFs in the cosine domain */ - Word16 *mem_AR, /* i/o: quantizer memory for AR model */ - Word16 *mem_MA, /* i/o: quantizer memory for MA model */ + Word16 *isf_q, /* (Qx2.56) o : quantized ISFs in the cosine domain */ + Word16 *mem_AR, /* (Qx2.56) i/o: quantizer memory for AR model */ + Word16 *mem_MA, /* (Qx2.56) i/o: quantizer memory for MA model */ const Word16 enc_dec /* i : encoder (0), decoder (1) G722.2 FER */ ); void disf_2s_46b_fx( Word16 *indice, /* i : quantized indices (use indice[0] = -1 in the decoder) */ - Word16 *isf_q, /* o : quantized ISFs in the cosine domain */ - Word16 *mem_AR, /* o : quantizer memory for AR model */ - Word16 *mem_MA, /* i/o: quantizer memory for MA model */ + Word16 *isf_q, /* (Qx2.56) o : quantized ISFs in the cosine domain */ + Word16 *mem_AR, /* (Qx2.56) o : quantizer memory for AR model */ + Word16 *mem_MA, /* (Qx2.56) i/o: quantizer memory for MA model */ const Word16 enc_dec /* i : encoder (0), decoder (1) G722.2 FER */ ); @@ -2118,9 +2118,9 @@ void disf_ns_28b_fx( void isf_dec_amr_wb_fx( Decoder_State *st, /* i/o: State structure */ - Word16 *Aq, /* o : quantized A(z) for 4 subframes */ - Word16 *isf_new, /* o : de-quantized ISF vector */ - Word16 *isp_new /* o : de-quantized ISP vector */ + Word16 *Aq, /* Q12 o : quantized A(z) for 4 subframes */ + Word16 *isf_new, /* Qlog2(2.56) o : de-quantized ISF vector */ + Word16 *isp_new /* Q15 o : de-quantized ISP vector */ ); /*========================================================================================================/ @@ -2423,11 +2423,11 @@ void mpvq_decode_vec_fx( /* o : void ); // weight_a_fx.c void weight_a_subfr_fx( - const Word16 nb_subfr, /* i : number of subframes */ + const Word16 nb_subfr, /* i : number of subframes Q0 */ const Word16 *A, /* i : LP filter coefficients Q12 */ Word16 *Aw, /* o : weighted LP filter coefficients Q12 */ - const Word16 gamma, /* i : weighting factor */ - const Word16 m /* i : order of LP filter */ + const Word16 gamma, /* i : weighting factor Q15 */ + const Word16 order /* i : order of LP filter Q0 */ ); void weight_a_lc_fx( @@ -2443,7 +2443,12 @@ void weight_a_fx( const Word16 gamma, /* i: weighting factor Q15 */ const Word16 m /* i: order of LP filter Q0 */ ); -void E_LPC_a_weight_inv( const Word16 *a, Word16 *ap, const Word16 gamma, const Word16 m ); +void E_LPC_a_weight_inv( + const Word16 *a, /* Q12 */ + Word16 *ap, /* Q12 */ + const Word16 inv_gamma, /* Q14 */ + const Word16 m /* Q0 */ +); // residu_fx.c void Residu3_lc_fx( @@ -2477,7 +2482,7 @@ void calc_residu_fx( const Word16 *p_Aq /* i : quantized LP filter coefficients */ ); // inerpol_lc.c -Word32 Interpol_lc_fx( /* o : interpolated value Qx+16 */ +Word32 Interpol_lc_fx( /* o : interpolated value Q15 */ const Word16 *x, /* i : input vector Q0 */ const Word16 *win, /* i : interpolation window Q14 */ const Word16 frac, /* i : fraction (0..up_samp) Q0 */ @@ -4310,48 +4315,53 @@ void set_TEC_TFA_code_fx( const Word16 corrFlag, Word16 *tec_flag, Word16 *tfa_f // tcx_mdct_fx.c void TCX_MDCT( - const Word16 *x, - Word32 *y, + const Word16 *x, /* Qx */ + Word32 *y, /* exp(y_e) */ Word16 *y_e, - const Word16 l, - const Word16 m, - const Word16 r, - const Word16 element_mode ); + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode /* Q0 */ +); void TCX_MDST( - const Word16 *x, - Word32 *y, + const Word16 *x, /* Qx */ + Word32 *y, /* exp(y_e) */ Word16 *y_e, - const Word16 l, - const Word16 m, - const Word16 r, - const Word16 element_mode ); + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode /* Q0 */ +); void TCX_MDCT_Inverse( - Word32 *x, + Word32 *x, /* exp(x_e) */ Word16 x_e, - Word16 *y, - const Word16 l, - const Word16 m, - const Word16 r, - const Word16 element_mode ); + Word16 *y, /* Qy */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode /* Q0 */ +); void TCX_MDST_Inverse_fx( - Word32 *x, + Word32 *x, /* exp(x_e) */ Word16 x_e, - Word16 *y, - const Word16 l, - const Word16 m, - const Word16 r ); + Word16 *y, /* Qx */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r /* Q0 */ +); void TCX_MDXT_Inverse_fx( - const Word32 *x, + const Word32 *x, /* exp(x_e) */ Word16 x_e, - Word16 *y, - const Word16 l, - const Word16 m, - const Word16 r, - const UWord16 kernel_type ); + Word16 *y, /* Qx */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const UWord16 kernel_type /* Q0 */ +); // edct_fx.c #define EDCT_FACTOR_SCALE 2 @@ -5420,9 +5430,9 @@ void hq_bit_allocation_fx( // weight_fx.c void map_quant_weight_fx( - const Word16 normqlg2[], /* i : quantized norms */ - Word16 wnorm[], /* o : weighted norm */ - const Word16 is_transient /* i : transient flag */ + const Word16 normqlg2[], /* i : quantized norms Q0*/ + Word16 wnorm[], /* o : weighted norm Q0*/ + const Word16 is_transient /* i : transient flag Q0*/ ); // bitalloc_fx.c @@ -5675,9 +5685,9 @@ void IGFCommonFuncsCalcSfbEnergyPowerSpec( const Word16 startSfb, /**< in: void IGFCommonFuncsMDCTSquareSpec( const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ - const Word32 *mdctSpec, /**< in: Q31 | MDCT spectrum to square */ + const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ - Word32 *mdctSquareSpec, /**< out:Q31 | MDCT square spectrum */ + Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ Word16 indexOffset /**< in: Q0 | index offset */ ); @@ -5685,9 +5695,9 @@ void IGFCommonFuncsMDCTSquareSpec( const Word16 sqrtBgn, /**< in: Q0 | star void IGFCommonFuncsMDCTSquareSpec_ivas( const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ - const Word32 *mdctSpec, /**< in: Q31 | MDCT spectrum to square */ + const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ - Word32 *mdctSquareSpec, /**< out:Q31 | MDCT square spectrum */ + Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ Word16 indexOffset /**< in: Q0 | index offset */ ); @@ -9058,9 +9068,9 @@ void vlpc_2st_dec( Word32 sr_core ); // vlpc_2st_com_fx.c -void lsf_weight_2st( const Word16 *lsfq, /* i : quantized lsf coefficients (3Q12) */ - Word16 *w, /* o : weighting function (0Q15) */ - const Word16 mode /* i : operational mode */ +void lsf_weight_2st( const Word16 *lsfq, /* input: quantized lsf coefficients (14Q1*1.28) */ + Word16 *w, /* output: weighting function (0Q15*1.28) */ + const Word16 mode /* input: operational mode Q0 */ ); // ACcontextMapping_fx.c diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 7430b18e6..a1fc49304 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -1670,7 +1670,7 @@ const Word16 sincos_t_ext_fx[641] = -20788, -20943, -21097, -21251, -21403, -21555, -21706, -21856, -22006, -22154, -22302, -22449, -22595, -22740, -22884, -23028, -23028 -}; +};/*Q15*/ const float Asr_LP32[41] = @@ -1733,7 +1733,7 @@ const Word16 Asr_LP48_fx[61] = 0, -407, -592, -571, -408, -192, 0, 123, 167, 146, 93, 38, 0 }; -const int16_t fft256_read_indexes[]= +const Word16 fft256_read_indexes[]= { 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, @@ -2639,7 +2639,7 @@ const Word16 interpol_frac2_mid_fx[NB_SUBFR * 3] = { 8191, 24575, 0, 0, 8191, 24575, 0, 8191, 24575 -}; +};/*Q15*/ const float interpol_frac_12k8[NB_SUBFR] = { 0.25f, 0.5f, 0.75f, 1.0f @@ -2649,19 +2649,19 @@ const Word16 interpol_frac_12k8_fx[NB_SUBFR] = { 8191, 16383, 24575, 32767 }; -const Word16 interpol_frac_fx[NB_SUBFR] = { 8192, 16384, 24576,32767 }; +const Word16 interpol_frac_fx[NB_SUBFR] = { 8192, 16384, 24576,32767 };/*Q15*/ const float interpol_isp_amr_wb[NB_SUBFR] = { 0.45f, 0.8f, 0.96f, 1.0f }; -const Word16 interpol_isp_amr_wb_fx[] = { 14746, 26214, 31457, 32767 }; +const Word16 interpol_isp_amr_wb_fx[] = { 14746, 26214, 31457, 32767 };/*Q15*/ const float interpol_frac_16k[NB_SUBFR16k] = { 0.2f, 0.4f, 0.6f, 0.8f, 1.0f }; -const Word16 interpol_frac_16k_fx[NB_SUBFR16k] = { 6554, 13107, 19661, 26214, 32767 }; +const Word16 interpol_frac_16k_fx[NB_SUBFR16k] = { 6554, 13107, 19661, 26214, 32767 };/*Q15*/ const float interpol_frac_mid[NB_SUBFR*3] = { 0.5f, 0.5f, 0.0f, @@ -2673,7 +2673,7 @@ const Word16 interpol_frac_mid_fx[NB_SUBFR * 3] = { 16384, 16384, 0, 0, 32767, 0, 0, 16384, 16384, 0, 0, 32767 -}; +};/*Q15*/ const float interpol_frac_mid_16k[NB_SUBFR16k*3] = { 0.55f, 0.45f, 0.0f, @@ -2699,7 +2699,7 @@ const Word16 interpol_frac_mid_relaxprev_12k8_fx[NB_SUBFR * 3] = { 0, 22938, 983 0, 0, 32767, 0, 0, 32767, 0, 0, 32767 -}; +};/*Q15*/ const float interpol_frac_mid_FEC[NB_SUBFR*3] = { 0.25f, 0.55f, 0.20f, 0.00f, 0.70f, 0.30f, @@ -2710,7 +2710,7 @@ const Word16 interpol_frac_mid_FEC_fx[NB_SUBFR * 3] = { 8192, 18022, 6554, 0, 22938, 9830, 0, 14746, 18022, 0, 0, 32767 -}; +};/*Q15*/ const float interpol_frac_mid_relaxprev_pred_12k8[NB_SUBFR*3] = { @@ -2737,7 +2737,7 @@ const Word16 interpol_frac_mid_relaxprev_16k_fx[NB_SUBFR16k * 3] = { 0, 22938, 9 0, 0, 32767, 0, 0, 32767, 0, 0, 32767 -}; +};/*Q15*/ const float interpol_frac_mid_16k_FEC[NB_SUBFR16k*3] = { @@ -2752,7 +2752,7 @@ const Word16 interpol_frac_mid_16k_FEC_fx[NB_SUBFR16k * 3] = { 13107, 13107, 655 0, 21299, 11469, 0, 4915, 27853, 0, 0, 32767 -}; +};/*Q15*/ const float interpol_frac_mid_relaxprev_pred_16k[NB_SUBFR16k*3] = { 0.15f, 0.70f, 0.15f, @@ -2766,7 +2766,7 @@ const Word16 interpol_frac_mid_relaxprev_pred_16k_fx[NB_SUBFR16k * 3] = { 4915, 0, 16384, 16384, 0, 4915, 27853, 0, 0, 32767 -}; +};/*Q15*/ /*----------------------------------------------------------------------------------* * Innovative codebook @@ -8298,7 +8298,7 @@ const Word16 mean_isf_amr_wb_fx[M] = { 738, 1326, 2336, 3578, 4596, 5662, 6711, 7730, 8750, 9753,10705, 11728, 12833, 13971,15043, 4037 -}; +};/*1.28f Q1*/ /*----------------------------------------------------------------------------------* * Mean ISF vector for SID frames (only in AMR-WB IO mode) @@ -11633,97 +11633,97 @@ const Word16 msNoiseSlopeMax[4] = { 32767/*2.f Q14*/, 26214/*1.6f Q14*/, 21299 const SCALE_SETUP scaleTableStereo[SIZE_SCALE_TABLE_STEREO] = { - { 1, 0, 8000, -5.5f, -704/*-5.5f Q7*/, -704 }, - { 1, 8000, 9600, -5.0f, -640/*-5.0f Q7*/, -640 }, - { 1, 9600, 13200, -4.0f, -512/*-4.0f Q7*/, -512 }, - { 1, 13200, 16400, -3.0f, -384/*-3.0f Q7*/, -384 }, - { 1, 16400, 24400, -1.6f, -204/*-1.6f Q7*/, -204 }, - { 1, 24400, 32000, -0.2f, -26/*-1.6f Q7*/, -26 }, - { 1, 32000,512001, 0.0f, 0 /*0.0f Q7*/, 0 }, - - { 2, 0, 8000, -0.9f , -115/*-0.9f Q7*/, -115 }, - { 2, 8000, 9600, -0.65f, -83/*-0.65f Q7*/, -83 }, - { 2, 9600, 13200, -2.0f , -256/*-2.0f Q7*/, -256 }, - { 2, 13200, 16400, -3.0f , -384/*-3.0f Q7*/, -384 }, - { 2, 16400, 24400, -0.8f , -102/*-0.8f Q7*/, -102 }, - { 2, 24400, 32000, -0.25f, -32/*-0.25f Q7*/, -32 }, - { 2, 32000,512001, 0.0f , 0/* 0.0f Q7*/, 0 } + { 1, 0, 8000, /* -5.5f,*/ -704/*-5.5f Q7*/, -704 }, + { 1, 8000, 9600, /* -5.0f,*/ -640/*-5.0f Q7*/, -640 }, + { 1, 9600, 13200, /* -4.0f,*/ -512/*-4.0f Q7*/, -512 }, + { 1, 13200, 16400, /* -3.0f,*/ -384/*-3.0f Q7*/, -384 }, + { 1, 16400, 24400, /* -1.6f,*/ -204/*-1.6f Q7*/, -204 }, + { 1, 24400, 32000, /* -0.2f,*/ -26/*-1.6f Q7*/, -26 }, + { 1, 32000,512001, /* 0.0f,*/ 0 /*0.0f Q7*/, 0 }, + + { 2, 0, 8000, /*-0.9f ,*/ -115/*-0.9f Q7*/, -115 }, + { 2, 8000, 9600, /*-0.65f,*/ -83/*-0.65f Q7*/, -83 }, + { 2, 9600, 13200, /*-2.0f ,*/ -256/*-2.0f Q7*/, -256 }, + { 2, 13200, 16400, /*-3.0f ,*/ -384/*-3.0f Q7*/, -384 }, + { 2, 16400, 24400, /*-0.8f ,*/ -102/*-0.8f Q7*/, -102 }, + { 2, 24400, 32000, /*-0.25f,*/ -32/*-0.25f Q7*/, -32 }, + { 2, 32000,512001, /* 0.0f ,*/ 0/* 0.0f Q7*/, 0 } }; #if 0 //scaleTableStereo recheck extended from scaleTableMono #endif const SCALE_SETUP scaleTableMono[SIZE_SCALE_TABLE_MONO] = { - { 0, 0, 8000, -5.5f, -704/*-5.5f Q7*/, -704 }, - { 0, 8000, 9600, -5.0f, -640/*-5.0f Q7*/, -640 }, - { 0, 9600, 13200, -4.0f, -512/*-4.0f Q7*/, -512 }, - { 0, 13200, 16400, -3.0f, -384/*-3.0f Q7*/, -384 }, - { 0, 16400, 24400, -1.5f, -192/*-1.5f Q7*/, -192 }, - { 0, 24400,128001, -0.5f, -64/*-0.5f Q7*/, -64 }, - - { 1, 0, 8000, -5.5f , -704/*-5.5f Q7*/, -704 }, - { 1, 8000, 9600, -5.0f , -640/*-5.0f Q7*/, -640 }, - { 1, 9600, 13200, -1.55f, -198/*-1.55f Q7*/, -198 }, - { 1, 13200, 16400, -3.0f , -384/*-3.0f Q7*/,-384 }, - { 1, 16400, 24400, -0.6f , -77/*-0.6f Q7*/, -77 }, - { 1, 24400, 32000, -0.2f , -26/*-0.2f Q7*/, -26 }, - { 1, 32000,128001, 0.0f , 0/* 0.0f Q7*/, 0 }, - - { 2, 0, 8000, -0.9f , -115/*-0.9f Q7*/, -115 }, - { 2, 8000, 9600, -0.65f, -83/*-0.65f Q7*/, -83 }, - { 2, 9600, 13200, -2.0f , -256/*-2.0f Q7*/, -256 }, - { 2, 13200, 16400, -3.0f , -384/*-3.0f Q7*/, -384 }, - { 2, 16400, 24400, -0.8f , -102/*-0.8f Q7*/, -102 }, - { 2, 24400, 32000, -0.25f, -32/*-0.25f Q7*/, -32 }, - { 2, 32000,128001, 0.0f , 0/* 0.0f Q7*/,0 } + { 0, 0, 8000, /* -5.5f,*/ -704/*-5.5f Q7*/, -704 }, + { 0, 8000, 9600, /* -5.0f,*/ -640/*-5.0f Q7*/, -640 }, + { 0, 9600, 13200, /* -4.0f,*/ -512/*-4.0f Q7*/, -512 }, + { 0, 13200, 16400, /* -3.0f,*/ -384/*-3.0f Q7*/, -384 }, + { 0, 16400, 24400, /* -1.5f,*/ -192/*-1.5f Q7*/, -192 }, + { 0, 24400,128001, /* -0.5f,*/ -64/*-0.5f Q7*/, -64 }, + + { 1, 0, 8000, /*-5.5f ,*/ -704/*-5.5f Q7*/, -704 }, + { 1, 8000, 9600, /*-5.0f ,*/ -640/*-5.0f Q7*/, -640 }, + { 1, 9600, 13200, /*-1.55f,*/ -198/*-1.55f Q7*/, -198 }, + { 1, 13200, 16400, /*-3.0f ,*/ -384/*-3.0f Q7*/,-384 }, + { 1, 16400, 24400, /*-0.6f ,*/ -77/*-0.6f Q7*/, -77 }, + { 1, 24400, 32000, /*-0.2f ,*/ -26/*-0.2f Q7*/, -26 }, + { 1, 32000,128001, /* 0.0f ,*/ 0/* 0.0f Q7*/, 0 }, + + { 2, 0, 8000, /*-0.9f ,*/ -115/*-0.9f Q7*/, -115 }, + { 2, 8000, 9600, /*-0.65f,*/ -83/*-0.65f Q7*/, -83 }, + { 2, 9600, 13200, /*-2.0f ,*/ -256/*-2.0f Q7*/, -256 }, + { 2, 13200, 16400, /*-3.0f ,*/ -384/*-3.0f Q7*/, -384 }, + { 2, 16400, 24400, /*-0.8f ,*/ -102/*-0.8f Q7*/, -102 }, + { 2, 24400, 32000, /*-0.25f,*/ -32/*-0.25f Q7*/, -32 }, + { 2, 32000,128001, /* 0.0f ,*/ 0/* 0.0f Q7*/,0 } }; const SCALE_SETUP scaleTable_cn_only[SIZE_SCALE_TABLE_CN] = { - { 0, 0, 8000, -3.5f, 20295/*1.2387211385 Q14*/ /*-3.5f*/, 20295 }, - { 0, 8000, 9600, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/, 16306 }, - { 0, 9600, 13200, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, - { 0, 13200, 16400, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/, 9583 }, - { 0, 16400,128001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 }, + { 0, 0, 8000, /*-3.5f,*/ 20295/*1.2387211385 Q14*/ /*-3.5f*/, 20295 }, + { 0, 8000, 9600, /*-3.0f,*/ 16306/*0.9952622652 Q14*/ /*-3.0f*/, 16306 }, + { 0, 9600, 13200, /*-2.5f,*/ 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, + { 0, 13200, 16400, /*-2.0f,*/ 9583/*0.5848932266 Q14*/ /*-2.0f*/, 9583 }, + { 0, 16400,128001, /* 0.0f,*/ 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 }, - { 1, 0, 8000, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/, 16306 }, - { 1, 8000, 9600, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, - { 1, 9600, 13200, -1.5f, 6759/*0.4125375748 Q14*/ /*-1.5f*/, 6759 }, - { 1, 13200, 16400, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, - { 1, 16400, 24400, -0.5f, 1999/*0.1220184565 Q14*/ /*-0.5f*/, 1999 }, - { 1, 24400,128001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 }, + { 1, 0, 8000, /*-3.0f,*/ 16306/*0.9952622652 Q14*/ /*-3.0f*/, 16306 }, + { 1, 8000, 9600, /*-2.5f,*/ 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, + { 1, 9600, 13200, /*-1.5f,*/ 6759/*0.4125375748 Q14*/ /*-1.5f*/, 6759 }, + { 1, 13200, 16400, /*-2.5f,*/ 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, + { 1, 16400, 24400, /*-0.5f,*/ 1999/*0.1220184565 Q14*/ /*-0.5f*/, 1999 }, + { 1, 24400,128001, /* 0.0f,*/ 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 }, - { 2, 0, 8000, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, - { 2, 8000, 9600, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, - { 2, 9600, 13200, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/, 9583 }, - { 2, 13200, 16400, -1.0f, 4242/*0.2589254379 Q14*/ /*-1.0f*/, 4242 }, + { 2, 0, 8000, /*-2.5f,*/ 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, + { 2, 8000, 9600, /*-2.5f,*/ 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, + { 2, 9600, 13200, /*-2.0f,*/ 9583/*0.5848932266 Q14*/ /*-2.0f*/, 9583 }, + { 2, 13200, 16400, /*-1.0f,*/ 4242/*0.2589254379 Q14*/ /*-1.0f*/, 4242 }, - { 2, 16400, 24400, -0.5f, 1999/*0.1220184565 Q14*/ /*-0.5f*/, 1999 }, - { 2, 24400, 32000, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 }, - { 2, 32000,128001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 } + { 2, 16400, 24400, /*-0.5f,*/ 1999/*0.1220184565 Q14*/ /*-0.5f*/, 1999 }, + { 2, 24400, 32000, /* 0.0f,*/ 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 }, + { 2, 32000,128001, /* 0.0f,*/ 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 } }; #if 0 //scaleTable_cn_dirac recheck extended from scaleTable_cn_only #endif const SCALE_SETUP scaleTable_cn_dirac[15] = { - { 0, 0, 13200, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/, 16306 }, - { 0, 13200, 16400, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, - { 0, 16400, 24400, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/, 9583 }, - { 0, 24400, 32000, -1.5f, 6759/*0.4125375748 Q14*/ /*-1.5f*/, 6759 }, - { 0, 32000,512001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 }, + { 0, 0, 13200, /*-3.0f,*/ 16306/*0.9952622652 Q14*/ /*-3.0f*/, 16306 }, + { 0, 13200, 16400, /*-2.5f,*/ 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, + { 0, 16400, 24400, /*-2.0f,*/ 9583/*0.5848932266 Q14*/ /*-2.0f*/, 9583 }, + { 0, 24400, 32000, /*-1.5f,*/ 6759/*0.4125375748 Q14*/ /*-1.5f*/, 6759 }, + { 0, 32000,512001, /* 0.0f,*/ 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 }, - { 1, 0, 13200, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/, 16306 }, - { 1, 13200, 16400, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, - { 1, 16400, 24400, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/, 9583 }, - { 1, 24400, 32000, -1.5f, 6759/*0.4125375748 Q14*/ /*-1.5f*/, 6759 }, - { 1, 32000,512001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 }, + { 1, 0, 13200, /*-3.0f,*/ 16306/*0.9952622652 Q14*/ /*-3.0f*/, 16306 }, + { 1, 13200, 16400, /*-2.5f,*/ 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, + { 1, 16400, 24400, /*-2.0f,*/ 9583/*0.5848932266 Q14*/ /*-2.0f*/, 9583 }, + { 1, 24400, 32000, /*-1.5f,*/ 6759/*0.4125375748 Q14*/ /*-1.5f*/, 6759 }, + { 1, 32000,512001, /* 0.0f,*/ 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 }, - { 2, 0, 13200, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/, 16306 }, - { 2, 13200, 16400, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, - { 2, 16400, 24400, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/, 9583 }, - { 2, 24400, 32000, -1.5f, 6759/*0.4125375748 Q14*/ /*-1.5f*/, 6759 }, - { 2, 32000,512001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 } + { 2, 0, 13200, /*-3.0f,*/ 16306/*0.9952622652 Q14*/ /*-3.0f*/, 16306 }, + { 2, 13200, 16400, /*-2.5f,*/ 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, + { 2, 16400, 24400, /*-2.0f,*/ 9583/*0.5848932266 Q14*/ /*-2.0f*/, 9583 }, + { 2, 24400, 32000, /*-1.5f,*/ 6759/*0.4125375748 Q14*/ /*-1.5f*/, 6759 }, + { 2, 32000,512001, /* 0.0f,*/ 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 } }; const float scaleTable_cn_only_amrwbio_flt[SIZE_SCALE_TABLE_CN_AMRWB][2] = { @@ -37400,7 +37400,7 @@ const Word16 tnsCoeff4[16] = * IGF settings for each bitrate *----------------------------------------------------------------------------------*/ -const int16_t swb_offset_LB_new[IGF_BITRATE_UNKNOWN][IGF_MAX_SFB] = +const Word16 swb_offset_LB_new[IGF_BITRATE_UNKNOWN][IGF_MAX_SFB] = { /* 0: for 9600 kbs WB */ { @@ -37546,7 +37546,7 @@ const int16_t swb_offset_LB_new[IGF_BITRATE_UNKNOWN][IGF_MAX_SFB] = { 3, 640, 720, 800 } -}; +};/*Q0*/ const int16_t igf_tile_offset_table[IGF_BITRATE_UNKNOWN][2*IGF_MAX_TILES+1] = { { 2, 2, 0, 3, 0}, /* 9600 WB*/ diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index ce044a4e6..9035c3144 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -194,9 +194,9 @@ extern const float sincos_t_ext[]; extern const Word16 sincos_t_ext_fx[]; extern const float sincos_t_rad3[]; extern const Word16 sincos_t_rad3_fx[]; -extern const int16_t fft256_read_indexes[]; /* FFT */ -extern const float inter4_2[]; /* 1/4 resolution interpolation filter */ -extern const Word16 inter4_2_fx_Q15[]; /* 1/4 resolution interpolation filter */ +extern const Word16 fft256_read_indexes[]; /* FFT */ +extern const float inter4_2[]; /* 1/4 resolution interpolation filter */ +extern const Word16 inter4_2_fx_Q15[]; /* 1/4 resolution interpolation filter */ extern const Word16 inter4_2_fx[]; extern const Word16 pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1]; /*1Q14*/ extern const Word16 pitch_inter4_2[PIT_FIR_SIZE2]; /*1Q14*/ @@ -1976,7 +1976,7 @@ typedef struct igf_mode_type } IGF_MODE; extern const IGF_MODE igfMode[IGF_BITRATE_UNKNOWN]; -extern const int16_t swb_offset_LB_new[IGF_BITRATE_UNKNOWN][IGF_MAX_SFB]; +extern const Word16 swb_offset_LB_new[IGF_BITRATE_UNKNOWN][IGF_MAX_SFB]; extern const int16_t igf_tile_offset_table[IGF_BITRATE_UNKNOWN][2 * IGF_MAX_TILES + 1]; extern const float igf_whitening_TH_flt[IGF_BITRATE_UNKNOWN][2][IGF_MAX_TILES]; extern const Word16 igf_whitening_TH[][2][IGF_MAX_TILES]; diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 53a29ca93..487d94dbf 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -389,9 +389,12 @@ typedef struct int32_t bitrateFrom; int32_t bitrateTo; +#ifndef IVAS_FLOAT_FIXED float scale_flt; - Word16 scale; /* EVS implementation Q14 */ - Word16 scale_ivas; /* IVAS implementation Q14 */ +#else + Word16 scale; /* EVS implementation Q14 */ + Word16 scale_ivas; /* IVAS implementation Q14 */ +#endif } SCALE_SETUP; @@ -424,15 +427,14 @@ typedef struct #ifdef IVAS_FLOAT_FIXED Word32 olapBufferSynth2_fx[FFTLEN]; #endif +#ifndef IVAS_FLOAT_FIXED const float *olapWinAna_flt; const float *olapWinSyn_flt; -#ifdef IVAS_FLOAT_FIXED - const Word32 *olapWinAna_fx; - const Word16 *olapWinSyn_fx; -#endif const float *fftSineTab_flt; -#ifdef IVAS_FLOAT_FIXED - const Word16 *fftSineTab_fx; +#else + const Word32 *olapWinAna_fx; /* Q30 */ + const Word16 *olapWinSyn_fx; /* Q15 */ + const Word16 *fftSineTab_fx; /* Q15 */ #endif Word32 fftBuffer[FFTLEN]; Word16 fftBuffer_exp; diff --git a/lib_com/tcx_mdct_fx.c b/lib_com/tcx_mdct_fx.c index 474f8779b..c45513511 100644 --- a/lib_com/tcx_mdct_fx.c +++ b/lib_com/tcx_mdct_fx.c @@ -9,8 +9,9 @@ #include "basop_util.h" static Word16 TCX_MDCT_GetScaleFactor( - const Word16 L, - Word16 *factor_e ) + const Word16 L, /* Q0 */ + Word16 *factor_e /* Q0 */ +) { Word16 factor; @@ -50,8 +51,9 @@ static Word16 TCX_MDCT_GetScaleFactor( } static Word16 TCX_MDCT_Inverse_GetScaleFactor( - const Word16 L, - Word16 *factor_e ) + const Word16 L, /* Q0 */ + Word16 *factor_e /* Q0 */ +) { Word16 factor; @@ -91,13 +93,14 @@ static Word16 TCX_MDCT_Inverse_GetScaleFactor( void TCX_MDCT( - const Word16 *x, - Word32 *y, + const Word16 *x, /* Qx */ + Word32 *y, /* exp(y_e) */ Word16 *y_e, - const Word16 l, - const Word16 m, - const Word16 r, - const Word16 element_mode ) + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode /* Q0 */ +) { Word16 i; @@ -112,6 +115,7 @@ void TCX_MDCT( #endif factor = TCX_MDCT_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &factor_e ); *y_e = add( *y_e, factor_e ); + move16(); neg_factor = negate( factor ); @@ -119,30 +123,30 @@ void TCX_MDCT( /* Init */ FOR( i = 0; i < m / 2; i++ ) { - y[add( add( shr( m, 1 ), shr( r, 1 ) ), i )] = L_mult( x[sub( sub( add( l, shr( m, 1 ) ), 1 ), i )], neg_factor ); + y[m / 2 + r / 2 + i] = L_mult( x[l + m / 2 - 1 - i], neg_factor ); /* exp(y_e) */ move32(); } FOR( i = 0; i < l / 2; i++ ) { #ifdef BASOP_NOGLOB - y[add( add( add( shr( m, 1 ), shr( r, 1 ) ), shr( m, 1 ) ), i )] = L_msu_o( L_mult( x[i], factor ), x[sub( sub( l, 1 ), i )], factor, &Overflow ); -#else /* BASOP_NOGLOB */ + y[m / 2 + r / 2 + m / 2 + i] = L_msu_o( L_mult( x[i], factor ), x[l - 1 - i], factor, &Overflow ); /* exp(y_e) */ +#else /* BASOP_NOGLOB */ y[m / 2 + r / 2 + m / 2 + i] = L_msu( L_mult( x[i], factor ), x[l - 1 - i], factor ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ move32(); } FOR( i = 0; i < m / 2; i++ ) { - y[sub( sub( add( shr( m, 1 ), shr( r, 1 ) ), 1 ), i )] = L_mult( x[add( add( l, shr( m, 1 ) ), i )], neg_factor ); + y[m / 2 + r / 2 - 1 - i] = L_mult( x[l + m / 2 + i], neg_factor ); /* exp(y_e) */ move32(); } FOR( i = 0; i < r / 2; i++ ) { #ifdef BASOP_NOGLOB - y[sub( sub( sub( add( shr( m, 1 ), shr( r, 1 ) ), 1 ), shr( m, 1 ) ), i )] = L_mac_o( L_mult( x[add( add( l, m ), i )], neg_factor ), x[sub( sub( add( add( l, m ), r ), 1 ), i )], neg_factor, &Overflow ); -#else /* BASOP_NOGLOB */ + y[m / 2 + r / 2 - 1 - m / 2 - i] = L_mac_o( L_mult( x[l + m + i], neg_factor ), x[l + m + r - 1 - i], neg_factor, &Overflow ); /* exp(y_e) */ +#else /* BASOP_NOGLOB */ y[m / 2 + r / 2 - 1 - m / 2 - i] = L_mac( L_mult( x[l + m + i], neg_factor ), x[l + m + r - 1 - i], neg_factor ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ move32(); } @@ -155,13 +159,14 @@ void TCX_MDCT( } void TCX_MDST( - const Word16 *x, - Word32 *y, + const Word16 *x, /* Qx */ + Word32 *y, /* exp(y_e) */ Word16 *y_e, - const Word16 l, - const Word16 m, - const Word16 r, - const Word16 element_mode ) + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode /* Q0 */ +) { Word16 i; @@ -174,35 +179,37 @@ void TCX_MDST( Flag Overflow = 0; move32(); #endif - factor = TCX_MDCT_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &factor_e ); + factor = TCX_MDCT_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &factor_e ); /* exp(factor_e) */ *y_e = add( *y_e, factor_e ); + move16(); + neg_factor = negate( factor ); /* Init */ FOR( i = 0; i < m / 2; i++ ) { - y[add( add( shr( m, 1 ), shr( r, 1 ) ), i )] = L_mult( x[sub( sub( add( l, shr( m, 1 ) ), 1 ), i )], neg_factor ); + y[m / 2 + r / 2 + i] = L_mult( x[l + m / 2 - 1 - i], neg_factor ); /* exp(y_e) */ move32(); } FOR( i = 0; i < l / 2; i++ ) { #ifdef BASOP_NOGLOB - y[add( add( add( shr( m, 1 ), shr( r, 1 ) ), shr( m, 1 ) ), i )] = L_msu_o( L_mult( x[i], neg_factor ), x[sub( sub( l, 1 ), i )], factor, &Overflow ); -#else /* BASOP_NOGLOB */ + y[m / 2 + r / 2 + m / 2 + i] = L_msu_o( L_mult( x[i], neg_factor ), x[l - 1 - i], factor, &Overflow ); /* exp(y_e) */ +#else /* BASOP_NOGLOB */ y[m / 2 + r / 2 + m / 2 + i] = L_msu( L_mult( x[i], neg_factor ), x[l - 1 - i], factor ); #endif move32(); } FOR( i = 0; i < m / 2; i++ ) { - y[sub( sub( add( shr( m, 1 ), shr( r, 1 ) ), 1 ), i )] = L_mult( x[add( add( l, shr( m, 1 ) ), i )], neg_factor ); + y[m / 2 + r / 2 - 1 - i] = L_mult( x[l + m / 2 + i], neg_factor ); /* exp(y_e) */ move32(); } FOR( i = 0; i < r / 2; i++ ) { #ifdef BASOP_NOGLOB - y[sub( sub( sub( add( shr( m, 1 ), shr( r, 1 ) ), 1 ), m / 2 ), i )] = L_mac_sat( L_mult( x[add( add( l, m ), i )], neg_factor ), x[sub( sub( add( add( l, m ), r ), 1 ), i )], factor ); + y[m / 2 + r / 2 - 1 - m / 2 - i] = L_mac_sat( L_mult( x[l + m + i], neg_factor ), x[l + m + r - 1 - i], factor ); /* exp(y_e) */ #else y[m / 2 + r / 2 - 1 - m / 2 - i] = L_mac( L_mult( x[l + m + i], neg_factor ), x[l + m + r - 1 - i], factor ); #endif @@ -210,19 +217,25 @@ void TCX_MDST( } *y_e = sub( 15, *y_e ); + move16(); + edst_fx( y, y, add( add( shr( l, 1 ), m ), shr( r, 1 ) ), y_e ); + *y_e = sub( 15 - 1, *y_e ); + move16(); + return; } void TCX_MDCT_Inverse( - Word32 *x, + Word32 *x, /* exp(x_e) */ Word16 x_e, - Word16 *y, - const Word16 l, - const Word16 m, - const Word16 r, - const Word16 element_mode ) + Word16 *y, /* Qy */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode /* Q0 */ +) { Word16 i, fac, negfac, s; @@ -239,7 +252,7 @@ void TCX_MDCT_Inverse( edct_fx( x, tmp_buf + L2, add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &x_e ); x_e = sub( 15, x_e ); - fac = TCX_MDCT_Inverse_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &fac_e ); + fac = TCX_MDCT_Inverse_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &fac_e ); /* exp(fac_e) */ x_e = add( x_e, fac_e ); negfac = negate( fac ); @@ -250,7 +263,7 @@ void TCX_MDCT_Inverse( FOR( i = 0; i < R2; i++ ) { #ifdef BASOP_NOGLOB - y[add( add( add( l, m ), R2 ), i )] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[add( L2, i )], negfac ), s ) ); /* fold out right end of DCT */ + y[l + m + R2 + i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); /* fold out right end of DCT exp(fac_e)*/ #else y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); /* fold out right end of DCT */ #endif @@ -261,38 +274,39 @@ void TCX_MDCT_Inverse( FOR( i = 0; i < L2; i++ ) { #ifdef BASOP_NOGLOB - y[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[add( add( add( L2, m ), R2 ), i )], fac ), s ) ); /* negate, fold out left end of DCT */ + y[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], fac ), s ) ); /* negate, fold out left end of DCT exp(fac_e)*/ #else y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], fac ), s ) ); /* negate, fold out left end of DCT */ #endif move16(); } - FOR( i = 0; i < shr( add( L2, add( m, R2 ) ), 1 ); i++ ) + FOR( i = 0; i < ( ( L2 + m + R2 ) >> 1 ); i++ ) { Word16 f; #ifdef BASOP_NOGLOB - f = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[add( L2, i )], negfac ), s ) ); - y[add( L2, i )] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[sub( sub( add( add( l, m ), R2 ), 1 ), i )], negfac ), s ) ); /* time-reverse mid of DCT */ + f = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); + y[L2 + i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT exp(fac_e)*/ #else f = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); y[L2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT */ #endif move16(); - y[sub( sub( add( add( l, m ), R2 ), 1 ), i )] = f; + y[l + m + R2 - 1 - i] = f; move16(); } } #ifdef IVAS_FLOAT_FIXED void TCX_MDST_Inverse_fx( - Word32 *x, + Word32 *x, /* exp(x_e) */ Word16 x_e, - Word16 *y, - const Word16 l, - const Word16 m, - const Word16 r ) + Word16 *y, /* Qx */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r /* Q0 */ +) { Word16 i, fac, negfac, s; @@ -319,25 +333,25 @@ void TCX_MDST_Inverse_fx( FOR( i = 0; i < R2; i++ ) { - y[add( add( add( l, m ), R2 ), i )] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[add( L2, i )], fac ), s ) ); /* fold out right end of DCT */ + y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], fac ), s ) ); /* fold out right end of DCT exp(fac_e)*/ move16(); } FOR( i = 0; i < L2; i++ ) { - y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[add( add( add( L2, m ), R2 ), i )], negfac ), s ) ); /* negate, fold out left end of DCT */ + y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], negfac ), s ) ); /* negate, fold out left end of DCT exp(fac_e)*/ move16(); } - FOR( i = 0; i < shr( add( L2, add( m, R2 ) ), 1 ); i++ ) + FOR( i = 0; i < ( ( L2 + m + R2 ) >> 1 ); i++ ) { Word16 f; - f = round_fx( L_shl( Mpy_32_16_1( tmp_buf[add( L2, i )], fac ), s ) ); + f = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], fac ), s ) ); - y[add( L2, i )] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[sub( sub( add( add( l, m ), R2 ), 1 ), i )], negfac ), s ) ); /* time-reverse mid of DCT */ + y[L2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT exp(fac_e)*/ move16(); - y[sub( sub( add( add( l, m ), R2 ), 1 ), i )] = negate( f ); + y[l + m + R2 - 1 - i] = negate( f ); move16(); } } @@ -349,13 +363,14 @@ void TCX_MDST_Inverse_fx( *-------------------------------------------------------------------*/ void TCX_MDXT_Inverse_fx( - const Word32 *x, + const Word32 *x, /* exp(x_e) */ Word16 x_e, - Word16 *y, - const Word16 l, - const Word16 m, - const Word16 r, - const UWord16 kernel_type ) + Word16 *y, /* Qx */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const UWord16 kernel_type /* Q0 */ +) { Word16 signLeft; Word16 signRight; @@ -395,24 +410,24 @@ void TCX_MDXT_Inverse_fx( FOR( i = 0; i < L2; i++ ) { - y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[add( add( add( L2, m ), R2 ), i )], signLeft ), s ) ); /* fold out the left end */ + y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], signLeft ), s ) ); /* fold out the left end exp(fac_e)*/ } FOR( i = 0; i < R2; i++ ) { - y[add( add( add( l, m ), R2 ), i )] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[add( L2, i )], signRight ), s ) ); /* ...and right end */ + y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], signRight ), s ) ); /* ...and right end exp(fac_e)*/ move16(); } - FOR( i = 0; i < ( ( add( add( L2, m ), R2 ) ) >> 1 ); i++ ) + FOR( i = 0; i < ( ( L2 + m + R2 ) >> 1 ); i++ ) { - f = round_fx( L_shl( Mpy_32_16_1( tmp_buf[add( L2, i )], negfac ), s ) ); + f = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); - y[add( L2, i )] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[sub( sub( add( add( l, m ), R2 ), 1 ), i )], negfac ), s ) ); /* time-reverse mid of DCT */ + y[L2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT exp(fac_e)*/ move16(); - y[sub( sub( add( add( l, m ), R2 ), 1 ), i )] = f; + y[l + m + R2 - 1 - i] = f; move16(); } diff --git a/lib_com/vlpc_2st_com_fx.c b/lib_com/vlpc_2st_com_fx.c index c54e5632f..3f06d3508 100644 --- a/lib_com/vlpc_2st_com_fx.c +++ b/lib_com/vlpc_2st_com_fx.c @@ -11,9 +11,9 @@ void lsf_weight_2st( - const Word16 *lsfq, /* input: quantized lsf coefficients (14Q1*1.28) */ - Word16 *w, /* output: weighting function (0Q15*1.28) */ - const Word16 mode /* input: operational mode */ + const Word16 *lsfq, /* input: quantized lsf coefficients (14Q1*1.28) */ + Word16 *w, /* output: weighting function (0Q15*1.28) */ + const Word16 mode /* input: operational mode Q0 */ ) { Word16 i; @@ -50,7 +50,7 @@ void lsf_weight_2st( /*w[i] = (weight * sqrt(d[i]*d[i+1])));*/ - w[i] = mult_r( weight, getSqrtWord32( L_shl( L_mult0( d[i], d[i + 1] ), 6 ) ) ); + w[i] = mult_r( weight, getSqrtWord32( L_shl( L_mult0( d[i], d[i + 1] ), 6 ) ) ); /* Q15 * 1.28 */ move16(); } diff --git a/lib_com/weight_a_fx.c b/lib_com/weight_a_fx.c index 99b621fa5..782979236 100644 --- a/lib_com/weight_a_fx.c +++ b/lib_com/weight_a_fx.c @@ -15,11 +15,11 @@ *------------------------------------------------------------------*/ void weight_a_subfr_fx( - const Word16 nb_subfr, /* i : number of subframes */ + const Word16 nb_subfr, /* i : number of subframes Q0 */ const Word16 *A, /* i : LP filter coefficients Q12 */ Word16 *Aw, /* o : weighted LP filter coefficients Q12 */ - const Word16 gamma, /* i : weighting factor */ - const Word16 order /* i : order of LP filter */ + const Word16 gamma, /* i : weighting factor Q15 */ + const Word16 order /* i : order of LP filter Q0 */ ) { Word16 k, orderp1; @@ -28,7 +28,7 @@ void weight_a_subfr_fx( orderp1 = add( order, 1 ); FOR( k = 0; k < nb_subfr; k++ ) { - weight_a_fx( &A[imult1616( k, ( orderp1 ) )], &Aw[imult1616( k, ( orderp1 ) )], gamma, order ); + weight_a_fx( &A[k * ( orderp1 )], &Aw[k * ( orderp1 )], gamma, order ); } return; @@ -63,23 +63,23 @@ void weight_a_lc_fx( Word16 shift; const Word16 *ptr_gamma; - ptr_gamma = gammatbl; - Amax = L_mult( 16384, a[0] ); + ptr_gamma = gammatbl; /* Q15 */ + Amax = L_mult( 16384, a[0] ); /* Q27 */ FOR( i = 1; i < m; i++ ) { - Amax = L_max( Amax, L_abs( L_mult0( *ptr_gamma++, a[i] ) ) ); + Amax = L_max( Amax, L_abs( L_mult0( *ptr_gamma++, a[i] ) ) ); /* Q27 */ } - Amax = L_max( Amax, L_abs( L_mult0( *ptr_gamma++, a[m] ) ) ); + Amax = L_max( Amax, L_abs( L_mult0( *ptr_gamma++, a[m] ) ) ); /* Q27 */ shift = norm_l( Amax ); - ptr_gamma = gammatbl; - ap[0] = shl( a[0], sub( shift, 1 ) ); + ptr_gamma = gammatbl; /* Q15 */ + ap[0] = shl( a[0], sub( shift, 1 ) ); /* Q11 + shift */ move16(); FOR( i = 1; i < m; i++ ) { - ap[i] = round_fx( L_shl( L_mult0( a[i], *ptr_gamma++ ), shift ) ); + ap[i] = round_fx( L_shl( L_mult0( a[i], *ptr_gamma++ ), shift ) ); /* Q11 + shift */ move16(); } - ap[m] = round_fx( L_shl( L_mult0( a[m], *ptr_gamma++ ), shift ) ); + ap[m] = round_fx( L_shl( L_mult0( a[m], *ptr_gamma++ ), shift ) ); /* Q11 + shift */ move16(); return; @@ -106,31 +106,31 @@ void weight_a_fx( move32(); #endif - fac = gamma; + fac = gamma; /* Q15 */ move16(); - Amax = L_mult( 16384, a[0] ); + Amax = L_mult( 16384, a[0] ); /* Q27 */ FOR( i = 1; i < m; i++ ) { - Amax = L_max( Amax, L_abs( L_mult0( fac, a[i] ) ) ); - fac = mult_r( fac, gamma ); + Amax = L_max( Amax, L_abs( L_mult0( fac, a[i] ) ) ); /* Q27 */ + fac = mult_r( fac, gamma ); /* Q15 */ } Amax = L_max( Amax, L_abs( L_mult0( fac, a[m] ) ) ); shift = norm_l( Amax ); - fac = gamma; + fac = gamma; /* Q15 */ move16(); - ap[0] = shl( a[0], sub( shift, 1 ) ); + ap[0] = shl( a[0], sub( shift, 1 ) ); /* Q11 + shift */ move16(); FOR( i = 1; i < m; i++ ) { #ifdef BASOP_NOGLOB - ap[i] = round_fx_o( L_shl( L_mult0( a[i], fac ), shift ), &Overflow ); -#else /* BASOP_NOGLOB */ + ap[i] = round_fx_o( L_shl( L_mult0( a[i], fac ), shift ), &Overflow ); /* Q11 + shift */ +#else /* BASOP_NOGLOB */ ap[i] = round_fx( L_shl( L_mult0( a[i], fac ), shift ) ); #endif move16(); - fac = mult_r( fac, gamma ); + fac = mult_r( fac, gamma ); /* Q15 */ } - ap[m] = round_fx( L_shl( L_mult0( a[m], fac ), shift ) ); + ap[m] = round_fx( L_shl( L_mult0( a[m], fac ), shift ) ); /* Q11 + shift */ move16(); return; @@ -152,10 +152,11 @@ void weight_a_fx( * void */ void E_LPC_a_weight_inv( - const Word16 *a, - Word16 *ap, - const Word16 inv_gamma, - const Word16 m ) + const Word16 *a, /* Q12 */ + Word16 *ap, /* Q12 */ + const Word16 inv_gamma, /* Q14 */ + const Word16 m /* Q0 */ +) { Word16 i; static const Word16 inv_gamma_tab_12k8[16] = { 17809, 19357, 21041, 22870, 24859, 27020, 29370, 31924, /* Q14 */ @@ -201,11 +202,11 @@ void E_LPC_a_weight_inv( Word16 shift; - IF( EQ_16( inv_gamma, 16384 ) ) + IF( EQ_16( inv_gamma, 16384 /* 1 in Q14 */ ) ) { FOR( i = 0; i <= m; i++ ) { - ap[i] = a[i]; + ap[i] = a[i]; /* Q12 */ move16(); } return; @@ -214,36 +215,36 @@ void E_LPC_a_weight_inv( assert( inv_gamma == GAMMA1_INV || inv_gamma == GAMMA16k_INV ); assert( m == 16 ); - inv_gamma_tab = inv_gamma_tab_12k8; + inv_gamma_tab = inv_gamma_tab_12k8; /* Q14 */ if ( EQ_16( inv_gamma, GAMMA16k_INV ) ) { - inv_gamma_tab = inv_gamma_tab_16k; + inv_gamma_tab = inv_gamma_tab_16k; /* Q14 */ } Amax = L_mult( 16384, a[0] ); FOR( i = 1; i < 9; i++ ) { - Amax = L_max( Amax, L_abs( L_mult( a[i], inv_gamma_tab[i - 1] ) ) ); + Amax = L_max( Amax, L_abs( L_mult( a[i], inv_gamma_tab[i - 1] ) ) ); /* Q27 */ } FOR( i = 9; i < 17; i++ ) { - Amax = L_max( Amax, L_abs( L_shl( L_mult( a[i], inv_gamma_tab[i - 1] ), 1 ) ) ); + Amax = L_max( Amax, L_abs( L_shl( L_mult( a[i], inv_gamma_tab[i - 1] ), 1 ) ) ); /* Q27 */ } shift = norm_l( Amax ); - ap[0] = shl( a[0], sub( shift, 1 ) ); + ap[0] = shl( a[0], sub( shift, 1 ) ); /* Q11 + shift */ move16(); FOR( i = 1; i < 9; i++ ) { - L_tmp = L_mult( a[i], inv_gamma_tab[i - 1] ); - ap[i] = round_fx( L_shl( L_tmp, shift ) ); + L_tmp = L_mult( a[i], inv_gamma_tab[i - 1] ); /* Q27 */ + ap[i] = round_fx( L_shl( L_tmp, shift ) ); /* Q11 + shift */ move16(); } shift = add( shift, 1 ); FOR( i = 9; i < 17; i++ ) { - L_tmp = L_mult( a[i], inv_gamma_tab[i - 1] ); - ap[i] = round_fx( L_shl( L_tmp, shift ) ); + L_tmp = L_mult( a[i], inv_gamma_tab[i - 1] ); /* Q26 */ + ap[i] = round_fx( L_shl( L_tmp, shift ) ); /* Q11 + shift */ move16(); } diff --git a/lib_com/weight_fx.c b/lib_com/weight_fx.c index 6c123cbf2..eb3f19bf7 100644 --- a/lib_com/weight_fx.c +++ b/lib_com/weight_fx.c @@ -15,45 +15,45 @@ *--------------------------------------------------------------------------*/ static void sfm2mqb_fx( - Word16 spe[], /* i : sub-vectors */ - Word16 spe2q[], /* o : pbands */ - const Word16 nb_sfm /* i : number of norms */ + Word16 spe[], /* i : sub-vectors Q0*/ + Word16 spe2q[], /* o : pbands Q0*/ + const Word16 nb_sfm /* i : number of norms Q0*/ ) { Word16 tmp, i; /* short groups */ - spe2q[0] = add( spe[0], 3 ); + spe2q[0] = add( spe[0], 3 ); /* Q0 */ move16(); - spe2q[1] = add( spe[1], 3 ); + spe2q[1] = add( spe[1], 3 ); /* Q0 */ move16(); - spe2q[2] = add( spe[2], 3 ); + spe2q[2] = add( spe[2], 3 ); /* Q0 */ move16(); - spe2q[3] = add( spe[3], 3 ); + spe2q[3] = add( spe[3], 3 ); /* Q0 */ move16(); - spe2q[4] = add( spe[4], 3 ); + spe2q[4] = add( spe[4], 3 ); /* Q0 */ move16(); - spe2q[5] = add( spe[5], 3 ); + spe2q[5] = add( spe[5], 3 ); /* Q0 */ move16(); - spe2q[6] = add( spe[6], 3 ); + spe2q[6] = add( spe[6], 3 ); /* Q0 */ move16(); - spe2q[7] = add( spe[7], 3 ); + spe2q[7] = add( spe[7], 3 ); /* Q0 */ move16(); - spe2q[8] = add( spe[8], 3 ); + spe2q[8] = add( spe[8], 3 ); /* Q0 */ move16(); - spe2q[9] = add( spe[9], 3 ); + spe2q[9] = add( spe[9], 3 ); /* Q0 */ move16(); - spe2q[10] = add( shr( add( spe[10], spe[11] ), 1 ), 4 ); + spe2q[10] = add( shr( add( spe[10], spe[11] ), 1 ), 4 ); /* Q0 */ move16(); - spe2q[11] = add( shr( add( spe[12], spe[13] ), 1 ), 4 ); + spe2q[11] = add( shr( add( spe[12], spe[13] ), 1 ), 4 ); /* Q0 */ move16(); - spe2q[12] = add( shr( add( spe[14], spe[15] ), 1 ), 4 ); + spe2q[12] = add( shr( add( spe[14], spe[15] ), 1 ), 4 ); /* Q0 */ move16(); - spe2q[13] = add( shr( add( spe[16], spe[17] ), 1 ), 5 ); + spe2q[13] = add( shr( add( spe[16], spe[17] ), 1 ), 5 ); /* Q0 */ move16(); - spe2q[14] = add( shr( add( spe[18], spe[19] ), 1 ), 5 ); + spe2q[14] = add( shr( add( spe[18], spe[19] ), 1 ), 5 ); /* Q0 */ move16(); tmp = 0; @@ -62,16 +62,16 @@ static void sfm2mqb_fx( { tmp = add( tmp, spe[i] ); } - spe2q[15] = add( mult( tmp, 8192 ), 6 ); + spe2q[15] = add( mult( tmp, 8192 ), 6 ); /* Q0 */ move16(); tmp = 0; move16(); FOR( i = 24; i < 27; i++ ) { - tmp = add( tmp, spe[i] ); + tmp = add( tmp, spe[i] ); /* Q0 */ } - spe2q[16] = add( mult( tmp, 10923 ), 6 ); + spe2q[16] = add( mult( tmp, 10923 ), 6 ); /* Q0 */ move16(); IF( GT_16( nb_sfm, SFM_N_STA_8k ) ) @@ -80,9 +80,9 @@ static void sfm2mqb_fx( move16(); FOR( i = 27; i < 30; i++ ) { - tmp = add( tmp, spe[i] ); + tmp = add( tmp, spe[i] ); /* Q0 */ } - spe2q[17] = add( mult( tmp, 10923 ), 6 ); + spe2q[17] = add( mult( tmp, 10923 ), 6 ); /* Q0 */ move16(); IF( GT_16( nb_sfm, SFM_N_STA_10k ) ) @@ -91,18 +91,18 @@ static void sfm2mqb_fx( move16(); FOR( i = 30; i < 35; i++ ) { - tmp = add( tmp, spe[i] ); + tmp = add( tmp, spe[i] ); /* Q0 */ } - spe2q[18] = add( mult( tmp, 6553 ), 7 ); + spe2q[18] = add( mult( tmp, 6553 ), 7 ); /* Q0 */ move16(); tmp = 0; move16(); FOR( i = 35; i < 44; i++ ) { - tmp = add( tmp, spe[i] ); + tmp = add( tmp, spe[i] ); /* Q0 */ } - spe2q[19] = add( mult( tmp, 3641 ), 8 ); + spe2q[19] = add( mult( tmp, 3641 ), 8 ); /* Q0 */ move16(); } } @@ -117,68 +117,68 @@ static void sfm2mqb_fx( *--------------------------------------------------------------------------*/ static void mqb2sfm_fx( - Word16 spe2q[], /* i : pbands */ - Word16 spe[], /* o : sub-vectors */ - const Word16 lnb_sfm /* i : number of norms */ + Word16 spe2q[], /* i : pbands Q0*/ + Word16 spe[], /* o : sub-vectors Q0*/ + const Word16 lnb_sfm /* i : number of norms Q0*/ ) { Word16 i; - spe[0] = spe2q[0]; + spe[0] = spe2q[0]; /* Q0 */ move16(); - spe[1] = spe2q[1]; + spe[1] = spe2q[1]; /* Q0 */ move16(); - spe[2] = spe2q[2]; + spe[2] = spe2q[2]; /* Q0 */ move16(); - spe[3] = spe2q[3]; + spe[3] = spe2q[3]; /* Q0 */ move16(); - spe[4] = spe2q[4]; + spe[4] = spe2q[4]; /* Q0 */ move16(); - spe[5] = spe2q[5]; + spe[5] = spe2q[5]; /* Q0 */ move16(); - spe[6] = spe2q[6]; + spe[6] = spe2q[6]; /* Q0 */ move16(); - spe[7] = spe2q[7]; + spe[7] = spe2q[7]; /* Q0 */ move16(); - spe[8] = spe2q[8]; + spe[8] = spe2q[8]; /* Q0 */ move16(); - spe[9] = spe2q[9]; + spe[9] = spe2q[9]; /* Q0 */ move16(); - spe[10] = spe2q[10]; + spe[10] = spe2q[10]; /* Q0 */ move16(); - spe[11] = spe2q[10]; + spe[11] = spe2q[10]; /* Q0 */ move16(); - spe[12] = spe2q[11]; + spe[12] = spe2q[11]; /* Q0 */ move16(); - spe[13] = spe2q[11]; + spe[13] = spe2q[11]; /* Q0 */ move16(); - spe[14] = spe2q[12]; + spe[14] = spe2q[12]; /* Q0 */ move16(); - spe[15] = spe2q[12]; + spe[15] = spe2q[12]; /* Q0 */ move16(); - spe[16] = spe2q[13]; + spe[16] = spe2q[13]; /* Q0 */ move16(); - spe[17] = spe2q[13]; + spe[17] = spe2q[13]; /* Q0 */ move16(); - spe[18] = spe2q[14]; + spe[18] = spe2q[14]; /* Q0 */ move16(); - spe[19] = spe2q[14]; + spe[19] = spe2q[14]; /* Q0 */ move16(); FOR( i = 20; i < 24; i++ ) { - spe[i] = spe2q[15]; + spe[i] = spe2q[15]; /* Q0 */ move16(); } FOR( i = 24; i < 27; i++ ) { - spe[i] = spe2q[16]; + spe[i] = spe2q[16]; /* Q0 */ move16(); } @@ -186,7 +186,7 @@ static void mqb2sfm_fx( { FOR( i = 27; i < 30; i++ ) { - spe[i] = spe2q[17]; + spe[i] = spe2q[17]; /* Q0 */ move16(); } @@ -194,13 +194,13 @@ static void mqb2sfm_fx( { FOR( i = 30; i < 35; i++ ) { - spe[i] = spe2q[18]; + spe[i] = spe2q[18]; /* Q0 */ move16(); } FOR( i = 35; i < 44; i++ ) { - spe[i] = spe2q[19]; + spe[i] = spe2q[19]; /* Q0 */ move16(); } } @@ -216,9 +216,9 @@ static void mqb2sfm_fx( *--------------------------------------------------------------------------*/ void map_quant_weight_fx( - const Word16 normqlg2[], /* i : quantized norms */ - Word16 wnorm[], /* o : weighted norm */ - const Word16 is_transient /* i : transient flag */ + const Word16 normqlg2[], /* i : quantized norms Q0*/ + Word16 wnorm[], /* o : weighted norm Q0*/ + const Word16 is_transient /* i : transient flag Q0*/ ) { Word16 sfm; @@ -247,13 +247,13 @@ void map_quant_weight_fx( move16(); FOR( k = 0; k < 4; k++ ) { - sum = add( sum, normqlg2[sfm + k] ); + sum = add( sum, normqlg2[sfm + k] ); /* Q0 */ } sum = shr( sum, 2 ); FOR( k = 0; k < 4; k++ ) { - spe[sfm + k] = sum; + spe[sfm + k] = sum; /* Q0 */ move16(); } } @@ -262,7 +262,7 @@ void map_quant_weight_fx( { FOR( sfm = 0; sfm < lnb_sfm; sfm++ ) { - spe[sfm] = normqlg2[sfm]; + spe[sfm] = normqlg2[sfm]; /* Q0 */ move16(); } } @@ -271,28 +271,28 @@ void map_quant_weight_fx( FOR( sfm = 0; sfm < num_map_bands; sfm++ ) { - spe2q[sfm] = sub( spe2q[sfm], 10 ); + spe2q[sfm] = sub( spe2q[sfm], 10 ); /* Q0 */ move16(); } /* spectral smoothing */ FOR( sfm = 1; sfm < num_map_bands; sfm++ ) { - tmp16 = sub( spe2q[sfm - 1], 4 ); - spe2q[sfm] = s_max( spe2q[sfm], tmp16 ); + tmp16 = sub( spe2q[sfm - 1], 4 ); /* Q0 */ + spe2q[sfm] = s_max( spe2q[sfm], tmp16 ); /* Q0 */ move16(); } FOR( sfm = num_map_bands - 2; sfm >= 0; sfm-- ) { - tmp16 = sub( spe2q[sfm + 1], 8 ); - spe2q[sfm] = s_max( spe2q[sfm], tmp16 ); + tmp16 = sub( spe2q[sfm + 1], 8 ); /* Q0 */ + spe2q[sfm] = s_max( spe2q[sfm], tmp16 ); /* Q0 */ move16(); } FOR( sfm = 0; sfm < num_map_bands; sfm++ ) { - spe2q[sfm] = s_max( spe2q[sfm], a_map[sfm] ); + spe2q[sfm] = s_max( spe2q[sfm], a_map[sfm] ); /* Q0 */ move16(); } @@ -304,15 +304,15 @@ void map_quant_weight_fx( FOR( sfm = 0; sfm < num_map_bands; sfm++ ) { - spe2q[sfm] = sub( sfm_width[sfm], spe2q[sfm] ); + spe2q[sfm] = sub( sfm_width[sfm], spe2q[sfm] ); /* Q0 */ move16(); - spe2q_max = s_max( spe2q[sfm], spe2q_max ); - spe2q_min = s_min( spe2q[sfm], spe2q_min ); + spe2q_max = s_max( spe2q[sfm], spe2q_max ); /* Q0 */ + spe2q_min = s_min( spe2q[sfm], spe2q_min ); /* Q0 */ } FOR( sfm = 0; sfm < num_map_bands; sfm++ ) { - spe2q[sfm] = sub( spe2q[sfm], spe2q_min ); + spe2q[sfm] = sub( spe2q[sfm], spe2q_min ); /* Q0 */ move16(); } @@ -338,12 +338,12 @@ void map_quant_weight_fx( move16(); FOR( k = 0; k < 4; k++ ) { - sum = add( sum, spe[sfm + k] ); + sum = add( sum, spe[sfm + k] ); /* Q0 */ } sum = shr( sum, 2 ); FOR( k = 0; k < 4; k++ ) { - spe[sfm + k] = sum; + spe[sfm + k] = sum; /* Q0 */ move16(); } } @@ -352,7 +352,7 @@ void map_quant_weight_fx( /* modify the norms for bit-allocation */ FOR( sfm = 0; sfm < lnb_sfm; sfm++ ) { - wnorm[sfm] = add( spe[sfm], normqlg2[sfm] ); + wnorm[sfm] = add( spe[sfm], normqlg2[sfm] ); /* Q0 */ move16(); } diff --git a/lib_com/wi_fx.c b/lib_com/wi_fx.c index 675ba31aa..19788dc0a 100644 --- a/lib_com/wi_fx.c +++ b/lib_com/wi_fx.c @@ -57,18 +57,18 @@ ivas_error DTFS_new_fx( move16(); dtfs_fx->nH_4kHz_fx = 0; move16(); - dtfs_fx->upper_cut_off_freq_of_interest_fx = 3300; + dtfs_fx->upper_cut_off_freq_of_interest_fx = 3300; // Q0 move16(); - dtfs_fx->upper_cut_off_freq_fx = 4000; + dtfs_fx->upper_cut_off_freq_fx = 4000; // Q0 move16(); dtfs_fx->Q = 0; move16(); FOR( i = 0; i < MAXLAG_WI; i++ ) { - dtfs_fx->a_fx[i] = 0; + dtfs_fx->a_fx[i] = 0; // dtfs_fx->Q move16(); - dtfs_fx->b_fx[i] = 0; + dtfs_fx->b_fx[i] = 0; // dtfs_fx->Q move16(); } *dtfs_out = dtfs_fx; @@ -90,13 +90,13 @@ void DTFS_copy_fx( Word16 k; FOR( k = 0; k < MAXLAG_WI; k++ ) { - Xout_fx->a_fx[k] = Xinp_fx.a_fx[k]; + Xout_fx->a_fx[k] = Xinp_fx.a_fx[k]; /* Q(DTFS_STRUCTURE.Q) */ move16(); } FOR( k = 0; k < MAXLAG_WI; k++ ) { - Xout_fx->b_fx[k] = Xinp_fx.b_fx[k]; + Xout_fx->b_fx[k] = Xinp_fx.b_fx[k]; /* Q(DTFS_STRUCTURE.Q) */ move16(); } @@ -106,9 +106,9 @@ void DTFS_copy_fx( move16(); Xout_fx->nH_4kHz_fx = Xinp_fx.nH_4kHz_fx; move16(); - Xout_fx->upper_cut_off_freq_of_interest_fx = Xinp_fx.upper_cut_off_freq_of_interest_fx; + Xout_fx->upper_cut_off_freq_of_interest_fx = Xinp_fx.upper_cut_off_freq_of_interest_fx; // Q0 move16(); - Xout_fx->upper_cut_off_freq_fx = Xinp_fx.upper_cut_off_freq_fx; + Xout_fx->upper_cut_off_freq_fx = Xinp_fx.upper_cut_off_freq_fx; // Q0 move16(); Xout_fx->Q = Xinp_fx.Q; move16(); @@ -176,7 +176,7 @@ void DTFS_sub_fx( * DTFS inverse. *-------------------------------------------------------------------*/ -static void DTFS_fast_fs_inv_fx( DTFS_STRUCTURE *X_fx, Word16 *out_fx, Word16 N_fx, Word16 LOG2N ) +static void DTFS_fast_fs_inv_fx( DTFS_STRUCTURE *X_fx, Word16 *out_fx /* Q0 */, Word16 N_fx, Word16 LOG2N ) { Word16 i, M_2, N_2, s; Word16 dbuf_fx[256 + 1]; @@ -194,7 +194,7 @@ static void DTFS_fast_fs_inv_fx( DTFS_STRUCTURE *X_fx, Word16 *out_fx, Word16 N_ { dbuf_fx[2 * i] = shl_r( X_fx->a_fx[i], s ); move16(); - dbuf_fx[add( 2 * i, 1 )] = shl_r( X_fx->b_fx[i], s ); + dbuf_fx[( 2 * i + 1 )] = shl_r( X_fx->b_fx[i], s ); move16(); } @@ -202,7 +202,7 @@ static void DTFS_fast_fs_inv_fx( DTFS_STRUCTURE *X_fx, Word16 *out_fx, Word16 N_ { dbuf_fx[2 * i] = 0; move16(); - dbuf_fx[add( 2 * i, 1 )] = 0; + dbuf_fx[( 2 * i + 1 )] = 0; move16(); } @@ -269,7 +269,7 @@ static Word16 DTFS_alignment_weight_fx( move32(); #endif diff_fx = 0; /* to avoid compilation warnings */ - + move16(); DTFS_copy_fx( &X1, *X_fx ); /* X1 = *X_fx ; */ DTFS_adjustLag_fx( &X1, X2.lag_fx ); @@ -474,7 +474,7 @@ Word16 DTFS_alignment_full_fx( } - IF( X1_DTFS_fx.lag_fx < X2_DTFS_fx.lag_fx ) + IF( LT_16( X1_DTFS_fx.lag_fx, X2_DTFS_fx.lag_fx ) ) { DTFS_zeroPadd_fx( X2_DTFS_fx.lag_fx, &X1_DTFS_fx ); } @@ -531,7 +531,7 @@ Word16 DTFS_alignment_full_fx( #endif } - if ( GT_32( corr_fx, maxcorr_fx ) ) + IF( GT_32( corr_fx, maxcorr_fx ) ) { fshift_fx = n; /* Q1 */ move16(); @@ -708,7 +708,7 @@ void DTFS_zeroPadd_fx( { Word16 i, start, end, diff_fx, rem_fx; - if ( EQ_16( N_fx, X_fx->lag_fx ) ) + IF( EQ_16( N_fx, X_fx->lag_fx ) ) { return; } @@ -732,7 +732,7 @@ void DTFS_zeroPadd_fx( X_fx->nH_fx = find_rem( X_fx->upper_cut_off_freq_fx, diff_fx, &rem_fx ); move16(); - if ( GE_16( sub( X_fx->upper_cut_off_freq_fx, shr( (Word16) L_mult( diff_fx, X_fx->nH_fx ), 1 ) ), diff_fx ) ) + if ( GE_16( sub( X_fx->upper_cut_off_freq_fx, shr( extract_l( L_mult( diff_fx, X_fx->nH_fx ) ), 1 ) ), diff_fx ) ) { X_fx->nH_fx = add( X_fx->nH_fx, 1 ); move16(); @@ -1006,7 +1006,7 @@ void DTFS_to_fs_fx( move16(); tmp = s_min( shr( X_fx->lag_fx, 1 ), sub( MAXLAG_WI, 1 ) ); - FOR( k = add( nH_band, 1 ); k <= tmp; k++ ) + FOR( k = ( nH_band + 1 ); k <= tmp; k++ ) { X_fx->a_fx[k] = 0; move16(); @@ -1215,7 +1215,7 @@ static void DTFS_transform_fx( } ELSE { - w_fx = 16384; + w_fx = 16384; // 1.Q14 move16(); } } @@ -1321,7 +1321,7 @@ void DTFS_zeroFilter_fx( FOR( n = 0; n < N; n++ ) { #ifdef BASOP_NOGLOB - sum1_fx = L_mac_o( sum1_fx, LPC[n], C_fx[i_mult( 4, temp2 ) % i_mult( 4, X_fx->lag_fx )], &Overflow ); /* Q(12+15+1) */ + sum1_fx = L_mac_o( sum1_fx, LPC[n], C_fx[( 4 * temp2 ) % ( 4 * X_fx->lag_fx )], &Overflow ); /* Q(12+15+1) */ sum2_fx = L_mac_o( sum2_fx, LPC[n], S_fx[( 4 * temp2 ) % ( 4 * X_fx->lag_fx )], &Overflow ); #else sum1_fx = L_mac( sum1_fx, LPC[n], C_fx[i_mult( 4, temp2 ) % i_mult( 4, X_fx->lag_fx )] ); /* Q(12+15+1) */ @@ -1554,7 +1554,7 @@ void DTFS_adjustLag_fx( Word16 exp, tmp; Word32 L_tmp; - if ( EQ_16( N_fx, X_DTFS_FX->lag_fx ) ) + IF( EQ_16( N_fx, X_DTFS_FX->lag_fx ) ) { return; } @@ -1568,7 +1568,7 @@ void DTFS_adjustLag_fx( en_fx = DTFS_getEngy_fx( X_DTFS_FX ); /* Q = 2*(X_DTFS_FX->Q) */ tmp = s_min( shr( X_DTFS_FX->lag_fx, 1 ), X_DTFS_FX->nH_fx ); - FOR( k = add( shr( N_fx, 1 ), 1 ); k <= tmp; k++ ) + FOR( k = ( ( N_fx >> 1 ) + 1 ); k <= tmp; k++ ) { X_DTFS_FX->a_fx[k] = 0; move16(); @@ -1599,7 +1599,7 @@ void DTFS_adjustLag_fx( X_DTFS_FX->nH_4kHz_fx = extract_l( L_shl( L_tmp, sub( exp, 29 ) ) ); move16(); - if ( GE_16( sub( X_DTFS_FX->upper_cut_off_freq_fx, shr( extract_l( L_mult( diff_fx, X_DTFS_FX->nH_fx ) ), 1 ) ), diff_fx ) ) + IF( GE_16( sub( X_DTFS_FX->upper_cut_off_freq_fx, shr( extract_l( L_mult( diff_fx, X_DTFS_FX->nH_fx ) ), 1 ) ), diff_fx ) ) { X_DTFS_FX->nH_fx = add( X_DTFS_FX->nH_fx, 1 ); move16(); @@ -1610,7 +1610,7 @@ void DTFS_adjustLag_fx( tempnH_fx = Mult_32_32( mul1_fx, mul2_fx ); /* Q6 */ tempnH_fx = L_sub( (Word32) 256000, tempnH_fx ); /* Q6 */ - if ( GE_32( tempnH_fx, temp32_fx ) ) + IF( GE_32( tempnH_fx, temp32_fx ) ) { X_DTFS_FX->nH_4kHz_fx = add( X_DTFS_FX->nH_4kHz_fx, 1 ); move16(); @@ -2029,7 +2029,7 @@ Word32 DTFS_setEngyHarm_fx( count = add( count, 1 ); } - IF( GE_32( Lacc_max, 2147483647 ) ) + IF( GE_32( Lacc_max, 2147483647 /*1.Q31*/ ) ) { tmp = sub( HalfLag_fx, f_low_fx ); exp = norm_s( tmp ); @@ -2077,7 +2077,7 @@ Word32 DTFS_setEngyHarm_fx( #else fracb = round_fx( L_shl( en1_fx, expb ) ); #endif - IF( GE_32( Lacc_max, 2147483647 ) ) + IF( GE_32( Lacc_max, 2147483647 /*1.Q31*/ ) ) { expb = sub( 30, add( expb, sub( shl( X_fx->Q, 1 ), expp ) ) ); } @@ -2122,12 +2122,12 @@ Word32 DTFS_setEngyHarm_fx( move16(); } - if ( GE_32( Lacc_max, 2147483647 ) ) + IF( GE_32( Lacc_max, 2147483647 /*1.Q31*/ ) ) { *Qa_fx = sub( sub( X_fx->Q, add( 1, s_min( 2, expp ) ) ), exp ); move16(); } - else + ELSE { *Qa_fx = sub( sub( X_fx->Q, 1 ), exp ); move16(); @@ -2401,6 +2401,7 @@ static void cubicPhase_fx( /* Computation of the phase value at each sample point */ /* ph[n]= c0*n^3+c1*n^2+c2*n+c3, Q15 */ phOut_fx[0] = L_shl( ph1_fx, 11 ); /* Q27 */ + move32(); IF( LT_16( N, 181 ) ) { @@ -2526,6 +2527,7 @@ void DTFS_to_erb_fx( num_erb_fx = NUM_ERB_NB; move16(); + test(); test(); IF( EQ_16( X_fx.upper_cut_off_freq_fx, 0x02800 ) || EQ_16( X_fx.upper_cut_off_freq_fx, 4000 ) ) /* 0x2800=0.3125 in Q15 (4000Hz) */ { @@ -2536,7 +2538,6 @@ void DTFS_to_erb_fx( } ELSE IF( EQ_16( X_fx.upper_cut_off_freq_fx, 0x04000 ) || EQ_16( X_fx.upper_cut_off_freq_fx, 6400 ) ) /* 0x4000=0.5 in Q15 (6400Hz) */ { - test(); num_erb_fx = NUM_ERB_WB; move16(); erb_fx = &( erb_WB_fx[0] ); @@ -2551,6 +2552,7 @@ void DTFS_to_erb_fx( count[i] = 0; move16(); sum_a_fx[i] = L_deposit_l( 0 ); + move32(); } exp = norm_s( X_fx.lag_fx ); @@ -2587,6 +2589,7 @@ void DTFS_to_erb_fx( { #ifdef BASOP_NOGLOB out_fx[i] = round_fx_o( L_shl_o( sum_a_fx[i], n, &Overflow ), &Overflow ); /* Q13 */ + move16(); #else out_fx[i] = round_fx( L_shl( sum_a_fx[i], n ) ); /* Q13 */ #endif @@ -2710,7 +2713,7 @@ void erb_slot_fx( L_tmp = L_mult0( diff_fx, nH_band_fx ); /* Q0 */ - if ( L_sub( upper_cut_off_freq_fx, L_tmp ) >= diff_fx ) /* Q0 compare */ + IF( GE_32( L_sub( upper_cut_off_freq_fx, L_tmp ), L_deposit_l( diff_fx ) ) ) /* Q0 compare */ { nH_band_fx = add( nH_band_fx, 1 ); /* Q0 */ } @@ -2786,6 +2789,7 @@ void erb_slot_fx( L_tmp = L_shl_o( tmp, add( exp, 16 ), &Overflow ); mfreq_fx[j] = round_fx_o( L_tmp, &Overflow ); + move16(); #else L_tmp = L_shl( tmp, add( exp, 16 ) ); @@ -2838,6 +2842,9 @@ void DTFS_erb_inv_fx( Word32 Ltemp_fx, Ltemp2_fx; Word32 Lacc_fx; Word16 exp, tmp; + move16(); + move16(); + move16(); #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -3031,8 +3038,8 @@ void erb_add_fx( } ELSE IF( GT_16( l_fx, pl_fx ) ) { - tmp_fx = t_prev_erb_fx[sub( num_erb_fx, 1 )]; /* Q13 */ - FOR( i = sub( num_erb_fx, 1 ); i >= 0; i-- ) + tmp_fx = t_prev_erb_fx[( num_erb_fx - 1 )]; /* Q13 */ + FOR( i = ( num_erb_fx - 1 ); i >= 0; i-- ) { IF( pslot_fx[i] != 0 ) @@ -3054,7 +3061,7 @@ void erb_add_fx( IF( cslot_fx[i] != 0 ) { - curr_erb_fx[i] = add( AmpCB1_fx[sub( add( tmp_fx, i ), 1 )], t_prev_erb_fx[i] ); + curr_erb_fx[i] = add( AmpCB1_fx[( ( tmp_fx + i ) - 1 )], t_prev_erb_fx[i] ); move16(); /* Q13+Q13=Q13 */ curr_erb_fx[i] = s_max( 0, curr_erb_fx[i] ); move16(); @@ -3076,14 +3083,14 @@ void erb_add_fx( { IF( EQ_16( num_erb_fx, NUM_ERB_NB ) ) { - curr_erb_fx[i] = add( AmpCB2_NB_fx[sub( add( tmp_fx, i ), 11 )], t_prev_erb_fx[i] ); /* Q13+Q13=Q13 */ + curr_erb_fx[i] = add( AmpCB2_NB_fx[( ( tmp_fx + i ) - 11 )], t_prev_erb_fx[i] ); /* Q13+Q13=Q13 */ move16(); curr_erb_fx[i] = s_max( 0, curr_erb_fx[i] ); move16(); } ELSE IF( EQ_16( num_erb_fx, NUM_ERB_WB ) ) { - curr_erb_fx[i] = add( AmpCB2_WB_fx[sub( add( tmp2_fx, i ), 11 )], t_prev_erb_fx[i] ); /* Q13 */ + curr_erb_fx[i] = add( AmpCB2_WB_fx[( ( tmp2_fx + i ) - 11 )], t_prev_erb_fx[i] ); /* Q13 */ move16(); curr_erb_fx[i] = s_max( 0, curr_erb_fx[i] ); move16(); @@ -3322,8 +3329,7 @@ ivas_error WIsyn_fx( IF( FR_flag == 0 ) { alignment_fx = DTFS_alignment_weight_fx( &PREVCW_FX, *CURRCW_DTFS_FX, tmp_fx, curr_lpc_fx, curr_lpc_fx, S_fx, - C_fx, pf_temp1, pf_temp2, pf_temp, pf_n2 ); - move16(); /* Q7 */ + C_fx, pf_temp1, pf_temp2, pf_temp, pf_n2 ); /* Q7 */ } ELSE { @@ -3530,7 +3536,7 @@ Word16 ppp_extract_pitch_period_fx( } - tmp = (Word16) ( L_max( L_mult( CUTFREE_REL_RANGE_Q2, l ), CUTFREE_ABS_RANGE_Q3 ) ); /* Q3 */ + tmp = extract_l( ( L_max( L_mult( CUTFREE_REL_RANGE_Q2, l ), CUTFREE_ABS_RANGE_Q3 ) ) ); /* Q3 */ IF( tmp > 0 ) { @@ -4008,7 +4014,7 @@ static void c_fft_wi_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word1 k = n_2; move16(); - WHILE( GE_16( j, k ) ) + WHILE( ( j >= k ) ) { j = sub( j, k ); k = shr( k, 1 ); @@ -4041,12 +4047,12 @@ static void c_fft_wi_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word1 /* Butterfly computations */ /* ftmp_real_fx = L_sub(L_mult(*(farray_ptr_fx + kj), cos_table[ji*K]), */ /* L_mult(*(farray_ptr_fx + kj + 1), cos_table[(ji*K+384)%512])); */ - ftmp_real_fx = L_msu( L_mult( *( farray_ptr_fx + kj ), cos_table[i_mult( ji, K )] ), + ftmp_real_fx = L_msu( L_mult( *( farray_ptr_fx + kj ), cos_table[( ji * K )] ), *( farray_ptr_fx + add( kj, 1 ) ), cos_table[temp_sand] ); /* ftmp_imag_fx = L_add(L_mult(*(farray_ptr_fx + kj + 1), cos_table[ji*K]), */ /* L_mult(*(farray_ptr_fx + kj), cos_table[(ji*K+384)%512])); */ - ftmp_imag_fx = L_mac( L_mult( *( farray_ptr_fx + add( kj, 1 ) ), cos_table[i_mult( ji, K )] ), + ftmp_imag_fx = L_mac( L_mult( *( farray_ptr_fx + add( kj, 1 ) ), cos_table[( ji * K )] ), *( farray_ptr_fx + kj ), cos_table[temp_sand] ); tmp1 = round_fx( ftmp_real_fx ); @@ -4092,12 +4098,12 @@ static void c_fft_wi_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word1 /* Butterfly computations */ /* ftmp_real_fx = L_add(L_mult(*(farray_ptr_fx + kj), cos_table[ji*K]), */ /* L_mult(*(farray_ptr_fx + kj + 1), cos_table[(ji*K+384)%512])); */ - ftmp_real_fx = L_mac( L_mult( *( farray_ptr_fx + kj ), cos_table[i_mult( ji, K )] ), + ftmp_real_fx = L_mac( L_mult( *( farray_ptr_fx + kj ), cos_table[( ji * K )] ), *( farray_ptr_fx + kj + 1 ), cos_table[temp_sand] ); /* ftmp_imag_fx = L_sub(L_mult(*(farray_ptr_fx + kj + 1), cos_table[ji*K]), */ /* L_mult(*(farray_ptr_fx + kj), cos_table[(ji*K+384)%512])); */ - ftmp_imag_fx = L_msu( L_mult( *( farray_ptr_fx + add( kj, 1 ) ), cos_table[i_mult( ji, K )] ), + ftmp_imag_fx = L_msu( L_mult( *( farray_ptr_fx + add( kj, 1 ) ), cos_table[( ji * K )] ), *( farray_ptr_fx + kj ), cos_table[temp_sand] ); tmp1 = round_fx( ftmp_real_fx ); @@ -4130,7 +4136,7 @@ static void c_fft_wi_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word1 } /* end of c_fft () */ -void r_fft_4_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word16 isign ) +void r_fft_4_fx( Word16 *farray_ptr_fx /*Q0*/, Word16 size, Word16 stage, Word16 isign ) { Word16 ftmp1_real_fx, ftmp1_imag_fx, ftmp2_real_fx, ftmp2_imag_fx; @@ -4175,22 +4181,22 @@ void r_fft_4_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word16 isign Lftmp1_imag_fx = L_deposit_h( ftmp1_imag_fx ); temp_sand = s_and( add( i_mult( i, K ), 384 ), 511 ); /* Ltmp1_fx = L_sub(L_mult(ftmp2_real_fx, cos_table[i*K]), L_mult(ftmp2_imag_fx, cos_table[(i*K+384)%512])); */ - Ltmp1_fx = L_msu( L_mult( ftmp2_real_fx, cos_table[i_mult( i, K )] ), ftmp2_imag_fx, cos_table[temp_sand] ); + Ltmp1_fx = L_msu( L_mult( ftmp2_real_fx, cos_table[( i * K )] ), ftmp2_imag_fx, cos_table[temp_sand] ); *( farray_ptr_fx + i ) = round_fx( L_shr( L_add( Lftmp1_real_fx, Ltmp1_fx ), 1 ) ); move16(); /* Ltmp1_fx = L_add(L_mult(ftmp2_imag_fx, cos_table[i*K]), L_mult(ftmp2_real_fx, cos_table[(i*K+384)%512])); */ - Ltmp1_fx = L_mac( L_mult( ftmp2_imag_fx, cos_table[i_mult( i, K )] ), ftmp2_real_fx, cos_table[temp_sand] ); + Ltmp1_fx = L_mac( L_mult( ftmp2_imag_fx, cos_table[( i * K )] ), ftmp2_real_fx, cos_table[temp_sand] ); *( farray_ptr_fx + i + 1 ) = round_fx( L_shr( L_add( Lftmp1_imag_fx, Ltmp1_fx ), 1 ) ); move16(); /* Ltmp1_fx = L_add(L_mult(ftmp2_real_fx, cos_table[j*K]), L_mult(ftmp2_imag_fx, cos_table[(j*K+384)%512])); */ - Ltmp1_fx = L_mac( L_mult( ftmp2_real_fx, cos_table[i_mult( j, K )] ), ftmp2_imag_fx, cos_table[temp_sand] ); + Ltmp1_fx = L_mac( L_mult( ftmp2_real_fx, cos_table[( j * K )] ), ftmp2_imag_fx, cos_table[temp_sand] ); *( farray_ptr_fx + j ) = round_fx( L_shr( L_add( Lftmp1_real_fx, Ltmp1_fx ), 1 ) ); move16(); /* Ltmp1_fx = L_add(L_negate(L_mult(ftmp2_imag_fx, cos_table[j*K])), L_mult(ftmp2_real_fx, cos_table[(j*K+384)%512])); */ - Ltmp1_fx = L_msu( L_mult( ftmp2_real_fx, cos_table[temp_sand] ), ftmp2_imag_fx, cos_table[i_mult( j, K )] ); + Ltmp1_fx = L_msu( L_mult( ftmp2_real_fx, cos_table[temp_sand] ), ftmp2_imag_fx, cos_table[( j * K )] ); Ltmp2_fx = L_sub( Ltmp1_fx, Lftmp1_imag_fx ); *( farray_ptr_fx + j + 1 ) = round_fx( L_shr( Ltmp2_fx, 1 ) ); move16(); @@ -4226,22 +4232,22 @@ void r_fft_4_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word16 isign Lftmp1_imag_fx = L_deposit_h( ftmp1_imag_fx ); temp_sand = s_and( ( add( i_mult( i, K ), 384 ) ), 511 ); /* Ltmp1_fx = L_add(L_mult(ftmp2_real_fx, cos_table[i*K]), L_mult(ftmp2_imag_fx, cos_table[(i*K+384)%512])); */ - Ltmp1_fx = L_mac( L_mult( ftmp2_real_fx, cos_table[i_mult( i, K )] ), ftmp2_imag_fx, cos_table[temp_sand] ); + Ltmp1_fx = L_mac( L_mult( ftmp2_real_fx, cos_table[( i * K )] ), ftmp2_imag_fx, cos_table[temp_sand] ); *( farray_ptr_fx + i ) = round_fx( L_shr( L_add( Lftmp1_real_fx, Ltmp1_fx ), 1 ) ); move16(); /* Ltmp1_fx = L_sub(L_mult(ftmp2_imag_fx, cos_table[i*K]), L_mult(ftmp2_real_fx, cos_table[(i*K+384)%512])); */ - Ltmp1_fx = L_msu( L_mult( ftmp2_imag_fx, cos_table[i_mult( i, K )] ), ftmp2_real_fx, cos_table[temp_sand] ); + Ltmp1_fx = L_msu( L_mult( ftmp2_imag_fx, cos_table[( i * K )] ), ftmp2_real_fx, cos_table[temp_sand] ); *( farray_ptr_fx + i + 1 ) = round_fx( L_shr( L_add( Lftmp1_imag_fx, Ltmp1_fx ), 1 ) ); move16(); /* Ltmp1_fx = L_sub(L_mult(ftmp2_real_fx, cos_table[j*K]), L_mult(ftmp2_imag_fx, cos_table[(j*K+384)%512])); */ - Ltmp1_fx = L_msu( L_mult( ftmp2_real_fx, cos_table[i_mult( j, K )] ), ftmp2_imag_fx, cos_table[temp_sand] ); + Ltmp1_fx = L_msu( L_mult( ftmp2_real_fx, cos_table[( j * K )] ), ftmp2_imag_fx, cos_table[temp_sand] ); *( farray_ptr_fx + j ) = round_fx( L_shr( L_add( Lftmp1_real_fx, Ltmp1_fx ), 1 ) ); move16(); /* Ltmp1_fx = L_negate(L_add(L_mult(ftmp2_imag_fx, cos_table[j*K]), L_mult(ftmp2_real_fx, cos_table[(j*K+384)%512]))); */ - Ltmp1_fx = L_negate( L_mac( L_mult( ftmp2_imag_fx, cos_table[i_mult( j, K )] ), ftmp2_real_fx, cos_table[temp_sand] ) ); + Ltmp1_fx = L_negate( L_mac( L_mult( ftmp2_imag_fx, cos_table[( j * K )] ), ftmp2_real_fx, cos_table[temp_sand] ) ); Ltmp2_fx = L_sub( Ltmp1_fx, Lftmp1_imag_fx ); *( farray_ptr_fx + j + 1 ) = round_fx( L_shr( Ltmp2_fx, 1 ) ); move16(); @@ -4327,6 +4333,7 @@ void copy_phase_fx( DTFS_STRUCTURE *X1_fx, DTFS_STRUCTURE X2_fx, DTFS_STRUCTURE ELSE { tmp = 0; + move16(); } tmp = shr( tmp, 1 ); q = sub( add( add( 15, exp1 ), 16 ), 1 ); diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index 2e17020cd..37315192f 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -8705,19 +8705,19 @@ void ivas_omasa_decode_masa_to_total_fx( { case 4: matrix_product_q30_fx( dct4_fx, nblocks, nblocks, 1, q_dct_data_fx, nblocks, 1, 0, dct_data_tmp_fx ); - Copy32( dct_data_tmp_fx, q_dct_data_fx, nblocks ); /*Q25*/ + Copy32( dct_data_tmp_fx, q_dct_data_fx, nblocks ); /*Q30*/ BREAK; case 5: matrix_product_q30_fx( dct5_fx, nbands, nbands, 1, q_dct_data_fx, nbands, 1, 0, dct_data_tmp_fx ); - Copy32( dct_data_tmp_fx, q_dct_data_fx, nbands ); /*Q25*/ + Copy32( dct_data_tmp_fx, q_dct_data_fx, nbands ); /*Q30*/ BREAK; case 8: matrix_product_q30_fx( dct8_fx, nbands, nbands, 1, q_dct_data_fx, nbands, 1, 0, dct_data_tmp_fx ); - Copy32( dct_data_tmp_fx, q_dct_data_fx, nbands ); /*Q25*/ + Copy32( dct_data_tmp_fx, q_dct_data_fx, nbands ); /*Q30*/ BREAK; case 12: matrix_product_q30_fx( dct12_fx, nbands, nbands, 1, q_dct_data_fx, nbands, 1, 0, dct_data_tmp_fx ); - Copy32( dct_data_tmp_fx, q_dct_data_fx, nbands ); /*Q25*/ + Copy32( dct_data_tmp_fx, q_dct_data_fx, nbands ); /*Q30*/ BREAK; case 20: matrix_product_fx( dct5_fx, nbands, nbands, 1, q_dct_data_fx, nbands, nblocks, 0, dct_data_tmp_fx ); diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index 9b94503da..f8cce92ca 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "options.h" #include "prot.h" #include "wmc_auto.h" @@ -184,6 +185,7 @@ ivas_error apa_init( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM\n" ) ); } + memset( ps->buf_out_fx, 0, ( sizeof( Word16 ) * ps->buf_out_capacity ) ); ps->Q_buf_out = Q15; move16(); diff --git a/lib_enc/acelp_core_enc.c b/lib_enc/acelp_core_enc.c index eef3bcbd2..36861985c 100644 --- a/lib_enc/acelp_core_enc.c +++ b/lib_enc/acelp_core_enc.c @@ -198,8 +198,6 @@ ivas_error acelp_core_enc( f2me_buf_16( &st->hLPDmem->old_exc_flt[-M - 1], &st->hLPDmem->old_exc[-M - 1], &st->hLPDmem->e_old_exc, L_EXC_MEM + M + 1 ); IF( st->hBWE_TD ) floatToFixed_arr16( st->hBWE_TD->old_bwe_exc, st->hBWE_TD->old_bwe_exc_fx, Q_exc, PIT16k_MAX * 2 ); - floatToFixed_arr16( st->lsp_old, st->lsp_old_fx, 15, M ); - floatToFixed_arr16( st->lsp_old16k, st->lsp_old16k_fx, 15, M ); floatToFixed_arr16( lsp_mid, lsp_mid_fx, 15, M ); floatToFixed_arr16( lsp_new, lsp_new_fx, 15, M ); IF( st->hLPDmem ) @@ -215,10 +213,6 @@ ivas_error acelp_core_enc( floatToFixed_arr( st->hLPDmem->mem_syn3_flt, st->hLPDmem->mem_syn3, Q_temp, 16 ); floatToFixed_arr( st->hLPDmem->mem_syn_r_flt, st->hLPDmem->mem_syn_r, Q_temp, 60 ); } - for ( int ii = 0; ii < M; ii++ ) - { - st->lsf_old_fx[ii] = (Word16) ( ( st->lsf_old[ii] ) * 2.56f ); - } Word16 inp_buff[L_FRAME16k + M + 1]; Word16 *inp_fx; inp_fx = &inp_buff[M + 1]; @@ -230,10 +224,6 @@ ivas_error acelp_core_enc( floatToFixed_arr( &inp[-M - 1], &inp_fx[-M - 1], Q_new, L_FRAME16k + M + 1 ); floatToFixed_arrL( st->Bin_E_old, st->Bin_E_old_fx, Q_new + Q_SCALE - 2, 128 ); floatToFixed_arrL( st->Bin_E, st->Bin_E_fx, Q_new + Q_SCALE - 2, 256 ); - IF( hStereoTD ) - { - floatToFixed_arr( hStereoTD->tdm_Pri_pitch_buf, hStereoTD->tdm_Pri_pitch_buf_fx, Q6, 4 ); - } #endif ivas_error error; @@ -358,13 +348,17 @@ ivas_error acelp_core_enc( test(); /* TD stereo */ + + float tdm_Pri_pitch_buf_flt[NB_SUBFR]; + set_zero( tdm_Pri_pitch_buf_flt, NB_SUBFR ); IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) { tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag; tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode; tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag; - tdm_Pri_pitch_buf = hStereoTD->tdm_Pri_pitch_buf; tdm_Pri_pitch_buf_fx = hStereoTD->tdm_Pri_pitch_buf_fx; + fixedToFloat_arr( tdm_Pri_pitch_buf_fx, tdm_Pri_pitch_buf_flt, Q6, NB_SUBFR ); + tdm_Pri_pitch_buf = tdm_Pri_pitch_buf_flt; } ELSE { @@ -442,12 +436,6 @@ ivas_error acelp_core_enc( weight_a_subfr_fx( shr( st->L_frame, 6 ), A_fx, Aw_fx, st->gamma, M ); } #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - - for ( i = 0; i < M; i++ ) - { - st->lsf_old[i] = st->lsf_old_fx[i] / 2.56f; - } - fixedToFloat_arr( st->lsp_old_fx, st->lsp_old, 15, M ); IF( st->hLPDmem ) { Word16 Q_temp = Q31 - st->hLPDmem->e_mem_syn; @@ -492,7 +480,6 @@ ivas_error acelp_core_enc( f2me_buf_16( &st->hTdCngEnc->cng_exc2_buf_flt[ii * L_FFT], &st->hTdCngEnc->cng_exc2_buf[ii * L_FFT], &st->hTdCngEnc->cng_Qexc_buf[ii], L_FFT ); st->hTdCngEnc->cng_Qexc_buf[ii] = Q15 - st->hTdCngEnc->cng_Qexc_buf[ii]; } - floatToFixed_arr32( st->hTdCngEnc->ho_env_circ, st->hTdCngEnc->ho_env_circ_fx, Q6, 160 ); #endif cng_params_postupd_ivas_fx( st->hTdCngEnc->ho_circ_ptr, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hTdCngEnc->ho_env_circ_fx, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS @@ -502,14 +489,10 @@ ivas_error acelp_core_enc( floatToFixed_arr( inp, inp_fx, q_inp, st->L_frame ); floatToFixed_arr( lsp_mid, lsp_mid_fx, Q15, M ); floatToFixed_arr( lsp_new, lsp_new_fx, Q15, M ); - floatToFixed_arr( st->lsp_old, st->lsp_old_fx, Q15, M ); - floatToFixed_arr( st->hTdCngEnc->ho_lsp_circ, st->hTdCngEnc->ho_lsp_circ_fx, Q15, HO_HIST_SIZE * M ); - floatToFixed_arrL( st->hTdCngEnc->ho_ener_circ, st->hTdCngEnc->ho_ener_circ_fx, Q6, HO_HIST_SIZE ); floatToFixed_arr( st->hTdCngEnc->exc_mem2, st->hTdCngEnc->exc_mem2_fx, q_inp, 30 ); for ( i = 0; i < M; i++ ) { lsf_new_fx[i] = (Word16) ( lsf_new[i] * 2.56f ); - st->lsf_old_fx[i] = (Word16) ( st->lsf_old[i] * 2.56f ); } #endif /* encode CNG parameters */ @@ -518,15 +501,10 @@ ivas_error acelp_core_enc( fixedToFloat_arr( Aq_fx, Aq, Q12, NB_SUBFR16k * ( M + 1 ) ); fixedToFloat_arr( lsp_new_fx, lsp_new, Q15, M ); fixedToFloat_arrL32( q_env_fx, q_env, Q6, NUM_ENV_CNG ); - fixedToFloat_arr( st->lsp_old_fx, st->lsp_old, Q15, M ); - fixedToFloat_arr( st->hTdCngEnc->ho_lsp_circ_fx, st->hTdCngEnc->ho_lsp_circ, Q15, HO_HIST_SIZE * M ); - fixedToFloat_arrL( st->hTdCngEnc->ho_env_circ_fx, st->hTdCngEnc->ho_env_circ, Q6, 160 ); - fixedToFloat_arrL( st->hTdCngEnc->ho_ener_circ_fx, st->hTdCngEnc->ho_ener_circ, Q6, HO_HIST_SIZE ); fixedToFloat_arr( st->hTdCngEnc->exc_mem2_fx, st->hTdCngEnc->exc_mem2, q_inp, 30 ); for ( i = 0; i < M; i++ ) { lsf_new[i] = ( (float) lsf_new_fx[i] / 2.56f ); - st->lsf_old[i] = ( (float) st->lsf_old_fx[i] / 2.56f ); } #endif #else @@ -599,7 +577,6 @@ ivas_error acelp_core_enc( floatToFixed_arr( st->hFdCngEnc->hFdCngCom->A_cng_flt, st->hFdCngEnc->hFdCngCom->A_cng, Q12, ( M + 1 ) ); // Word16 Q_exc_cng_l = Q_factor_arr( st->hFdCngEnc->hFdCngCom->exc_cng_flt, st->L_frame ); floatToFixed_arr( st->hFdCngEnc->hFdCngCom->exc_cng_flt, st->hFdCngEnc->hFdCngCom->exc_cng, Q_new, st->L_frame ); - floatToFixed_arr( st->lsp_old, st->lsp_old_fx, Q15, M ); #endif // FdCng_exc_flt( st->hFdCngEnc->hFdCngCom, &st->hDtxEnc->CNG_mode, st->L_frame, st->lsp_old, st->hDtxEnc->first_CNG, st->hDtxEnc->lspCNG, Aq, lsp_new, lsf_new, exc, exc2, bwe_exc ); FdCng_exc( st->hFdCngEnc->hFdCngCom, &st->hDtxEnc->CNG_mode, st->L_frame, st->lsp_old_fx, st->hDtxEnc->first_CNG, st->hDtxEnc->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx ); @@ -753,10 +730,6 @@ ivas_error acelp_core_enc( } } - for ( i = 0; i < M; i++ ) - { - st->lsf_old_fx[i] = (Word16) ( st->lsf_old[i] * 2.56f ); - } st->mem_deemp_preQ_fx = (Word16) floatToFixed( st->mem_deemp_preQ, -1 ); IF( st->hLPDmem ) { @@ -1005,13 +978,11 @@ ivas_error acelp_core_enc( { lsf_new[i] = lsf_new_fx[i] / 2.56f; - st->lsf_old[i] = st->lsf_old_fx[i] / 2.56f; } fixedToFloat_arrL( st->Bin_E_old_fx, st->Bin_E_old, q_comm_Bin, 128 ); fixedToFloat_arrL( st->Bin_E_fx, st->Bin_E, q_comm_Bin, 256 ); st->clip_var[0] = st->clip_var_fx[0] / 2.56f; fixedToFloat_arr( &st->clip_var_fx[1], &st->clip_var[1], Q14, 5 ); - fixedToFloat_arr( st->lsp_old_fx, st->lsp_old, 15, M ); for ( i = 0; i < NB_SUBFR16k; i++ ) { // Array is getting modified in chunks of 17 inside. @@ -1254,7 +1225,6 @@ ivas_error acelp_core_enc( st->exc_pe_fx = float_to_fix16( st->exc_pe, st->Q_stat_noise ); floatToFixed_arr( lsp_new, lsp_new_fx, 15, 16 ); floatToFixed_arr( lsp_mid, lsp_mid_fx, 15, 16 ); - floatToFixed_arr( st->lsp_old, st->lsp_old_fx, 15, 16 ); #endif LepsP[0] = epsP_fx[2]; move32(); @@ -1391,7 +1361,6 @@ ivas_error acelp_core_enc( #ifdef IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED_CONVERSIONS floatToFixed_arr( pitch_buf, pitch_buf_fx, Q6, NB_SUBFR16k ); // Saturation Conversion used as last values have garbage values even in float - floatToFixed_arr16( st->old_pitch_buf, st->old_pitch_buf_fx, Q6, 2 * NB_SUBFR16k ); Es_pred_fx = float_to_fix16( Es_pred, Q8 ); floatToFixed_arr16( Aq, Aq_fx, 12, NB_SUBFR16k * ( M + 1 ) ); @@ -1418,11 +1387,6 @@ ivas_error acelp_core_enc( { st->hGSCEnc->mid_dyn_fx = float_to_fix16( st->hGSCEnc->mid_dyn, Q7 ); } - - if ( st->L_frame == L_FRAME ) - { - floatToFixed_arr( st->lsp_old, st->lsp_old_fx, Q15, M ); - } #endif // IVAS_FLOAT_FIXED_CONVERSIONS updt_enc_fx( st, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, old_bwe_exc_fx ); @@ -1433,19 +1397,8 @@ ivas_error acelp_core_enc( { fixedToFloat_arr( st->hBWE_TD->old_bwe_exc_fx, st->hBWE_TD->old_bwe_exc, q_old_bwe_exc, PIT16k_MAX * 2 ); } - fixedToFloat_arr( st->lsp_old_fx, st->lsp_old, Q15, M ); - for ( i = 0; i < M; i++ ) - { - st->lsf_old[i] = (float) ( st->lsf_old_fx[i] / 2.56f ); - } st->hGSCEnc->mid_dyn = fixedToFloat( st->hGSCEnc->mid_dyn_fx, Q7 ); - IF( EQ_16( st->L_frame, L_FRAME ) ) - { - fixedToFloat_arr( st->lsp_old16k_fx, st->lsp_old16k, Q15, M ); - } - fixedToFloat_arr( st->old_pitch_buf_fx, st->old_pitch_buf, Q6, shl( shr( st->L_frame, 6 ), 1 ) ); // Q6 - fixedToFloat_arr( st->old_Aq_12_8_fx, st->old_Aq_12_8, Q12, M + 1 ); // Q12 - st->old_Es_pred = fixedToFloat( st->old_Es_pred_fx, Q8 ); + fixedToFloat_arr( st->old_Aq_12_8_fx, st->old_Aq_12_8, Q12, M + 1 ); // Q12 #endif #else updt_enc( st, old_exc_flt, pitch_buf, Es_pred, Aq, lsf_new, lsp_new, old_bwe_exc ); @@ -1460,17 +1413,12 @@ ivas_error acelp_core_enc( q_exc = min( q_exc, Q_factor_arr( st->hTdCngEnc->cng_exc2_buf_flt, HO_HIST_SIZE * L_FFT ) ); floatToFixed_arr16( exc, exc_fx, q_exc, L_EXC - L_EXC_MEM ); floatToFixed_arr16( st->hTdCngEnc->cng_exc2_buf_flt, st->hTdCngEnc->cng_exc2_buf, q_exc, HO_HIST_SIZE * L_FFT ); - - floatToFixed_arr32( st->hTdCngEnc->ho_env_circ, st->hTdCngEnc->ho_env_circ_fx, Q6, HO_HIST_SIZE * NUM_ENV_CNG ); - floatToFixed_arr16( st->hTdCngEnc->ho_lsp_circ, st->hTdCngEnc->ho_lsp_circ_fx, Q15, HO_HIST_SIZE * M ); #endif // IVAS_FLOAT_FIXED_CONVERSIONS cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, q_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - fixedToFloat_arr( st->hTdCngEnc->ho_lsp_circ_fx, st->hTdCngEnc->ho_lsp_circ, Q15, HO_HIST_SIZE * M ); - fixedToFloat_arrL( st->hTdCngEnc->ho_env_circ_fx, st->hTdCngEnc->ho_env_circ, Q6, HO_HIST_SIZE * NUM_ENV_CNG ); fixedToFloat_arr( st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_exc2_buf_flt, Q6, HO_HIST_SIZE * L_FFT ); #endif #else @@ -1495,9 +1443,6 @@ ivas_error acelp_core_enc( mvr2r( st->lsp_old16k, &( st->hTdCngEnc->ho_lsp_circ2[( st->hTdCngEnc->ho_circ_ptr ) * M] ), M ); } #else -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - floatToFixed_arr( st->lsp_old16k, st->lsp_old16k_fx, Q15, M ); -#endif IF( EQ_16( st->L_frame, L_FRAME ) ) { /* store LSPs@16k, potentially to be used in CNG@16k */ diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 86be7be4e..e2b193791 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -8,11 +8,11 @@ #include #include "rom_com.h" #include "stat_com.h" -//#include "prot_fx.h" +// #include "prot_fx.h" #include "prot_fx.h" #include "basop_util.h" #include "stl.h" -//#include "basop_mpy.h" +// #include "basop_mpy.h" #include "prot_fx_enc.h" #ifdef IVAS_FLOAT_FIXED_CONVERSIONS #include @@ -1798,6 +1798,19 @@ void EstimateStereoTCXNoiseLevel_fx( noiseTransWidth = GetTransWidth_ivas_fx( st->tcxonly, (Word16) EQ_16( L_frame[ch][n], shr( st->L_frame, 1 ) ), smooth_gain, ( st->hTcxCfg->ctx_hm && NE_16( st->last_core, ACELP_CORE ) && hm_active[ch][n] ) ); Copy32( q_spectrum[ch][n], combined_q_spectrum, L_frame[ch][n] ); + + /* Scaling down 1-bit to resolve crashes during accumulation in tcx_noise_factor_ivas_fx() */ + Word32 L_tmp, L_tmp1; + maximum_abs_32_fx( hTcxEnc->spectrum_fx[n], L_frame[ch][n], &L_tmp ); + maximum_abs_32_fx( combined_q_spectrum, L_frame[ch][n], &L_tmp1 ); + test(); + IF( L_tmp != 0 || L_tmp1 != 0 ) + { + scale_sig32( hTcxEnc->spectrum_fx[n], L_frame[ch][n], -Q1 ); + scale_sig32( combined_q_spectrum, L_frame[ch][n], -Q1 ); + hTcxEnc->spectrum_e[n] = add( hTcxEnc->spectrum_e[n], Q1 ); + move16(); + } tcx_noise_factor_ivas_fx( hTcxEnc->spectrum_fx[n], hTcxEnc->spectrum_e[n], combined_q_spectrum, iStart, maxNfCalcBw, noiseTransWidth, L_frame[ch][n], gain_tcx[ch][n], gain_tcx_e, hTcxEnc->noiseTiltFactor, &fac_ns[ch][n], fac_ns_q, st->element_mode ); /* hysteresis for very tonal passages (more stationary noise filling level) */ diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c index add6c9675..b1fd1d7f2 100644 --- a/lib_enc/core_enc_init.c +++ b/lib_enc/core_enc_init.c @@ -480,14 +480,6 @@ void init_coder_ace_plus( { floatToFixed_arr16( st->lspold_enc, &st->lspold_enc_fx[0], Q15, M ); } - if ( st->lsp_old1 != NULL ) - { - floatToFixed_arr16( st->lsp_old1, &st->lsp_old1_fx[0], Q15, M ); - } - if ( st->lsp_old != NULL ) - { - floatToFixed_arr16( st->lsp_old, &st->lsp_old_fx[0], Q15, M ); - } init_acelp_ivas_fx( st, L_frame_old, 0 ); #endif @@ -1277,14 +1269,36 @@ static void init_acelp( /* unquantized LPC*/ if ( !( ( total_brate >= ACELP_16k40 && total_brate <= ACELP_24k40 ) && total_brate == last_total_brate && st->last_bwidth == st->bwidth ) ) { +#ifndef IVAS_FLOAT_FIXED mvr2r( st->lsp_old1, st->lspold_enc, M ); /*lsp old @12.8kHz*/ +#else + Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /*lsp old @12.8kHz*/ +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + fixedToFloat_arr( st->lspold_enc_fx, st->lspold_enc, Q15, M ); +#endif +#endif if ( st->L_frame == L_FRAME16k ) { lsp_convert_poly( st->lspold_enc, st->L_frame, 0 ); } } +#ifndef IVAS_FLOAT_FIXED mvr2r( st->lspold_enc, st->lsp_old, M ); /*used unquantized values for mid-LSF Q*/ lsp2lsf( st->lsp_old, st->lsf_old, M, st->sr_core ); +#else +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + floatToFixed_arr( st->lspold_enc, st->lspold_enc_fx, Q15, M ); +#endif + Copy( st->lspold_enc_fx, st->lsp_old_fx, M ); /*used unquantized values for mid-LSF Q*/ + IF( st->tcxonly == 0 ) + { + lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); + } + ELSE + { + E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsf_old_fx, M ); + } +#endif st->last_core = TCX_20_CORE; @@ -1299,11 +1313,28 @@ static void init_acelp( if ( st->L_frame != L_frame_old && st->L_frame <= L_FRAME16k && L_frame_old <= L_FRAME16k ) /* Rate switching between 12.8 and 16 kHz*/ { float tmp, A[M + 1], Ap[M + 1], tmp_buf[M + 1]; +#ifdef IVAS_FLOAT_FIXED + Word16 A_fx[M + 1]; +#endif /* convert quantized LSP vector */ +#ifndef IVAS_FLOAT_FIXED st->rate_switching_reset = lsp_convert_poly( st->lsp_old, st->L_frame, 0 ); lsp2lsf( st->lsp_old, st->lsf_old, M, st->sr_core ); +#else + st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 ); + move16(); + IF( st->tcxonly == 0 ) + { + lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); + } + ELSE + { + E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsf_old_fx, M ); + } +#endif +#ifndef IVAS_FLOAT_FIXED if ( st->L_frame == L_FRAME16k ) { mvr2r( st->lsp_old, st->lspold_enc, M ); @@ -1312,12 +1343,32 @@ static void init_acelp( { mvr2r( st->lsp_old1, st->lspold_enc, M ); } +#else + IF( st->L_frame == L_FRAME16k ) + { + Copy( st->lsp_old_fx, st->lspold_enc_fx, M ); + } + ELSE + { + Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); + } +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + fixedToFloat_arr( st->lspold_enc_fx, st->lspold_enc, Q15, M ); +#endif +#endif /* Update wsyn */ if ( hLPDmem != NULL ) { synth_mem_updt2_flt( st->L_frame, st->last_L_frame, hLPDmem->old_exc_flt, hLPDmem->mem_syn_r_flt, hLPDmem->mem_syn2_flt, hLPDmem->mem_syn_flt, ENC ); +#ifndef IVAS_FLOAT_FIXED lsp2a_stab( st->lsp_old, A, M ); +#else + E_LPC_f_lsp_a_conversion( st->lsp_old_fx, A_fx, M ); +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + fixedToFloat_arr( A_fx, A, Q14 - norm_s( A_fx[0] ), M + 1 ); +#endif +#endif weight_a( A, Ap, GAMMA1_FLT, M ); tmp = 0.f; tmp_buf[0] = 0.f; @@ -1352,13 +1403,35 @@ static void init_acelp( } /* unquantized LPC*/ +#ifndef IVAS_FLOAT_FIXED mvr2r( st->lsp_old1, st->lspold_enc, M ); /*lsp old @12.8kHz*/ +#else + Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /*lsp old @12.8kHz*/ +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + fixedToFloat_arr( st->lspold_enc_fx, st->lspold_enc, Q15, M ); +#endif +#endif if ( st->L_frame == L_FRAME16k ) { lsp_convert_poly( st->lspold_enc, st->L_frame, 0 ); } +#ifndef IVAS_FLOAT_FIXED mvr2r( st->lspold_enc, st->lsp_old, M ); /*used unquantized values for mid-LSF Q*/ lsp2lsf( st->lsp_old, st->lsf_old, M, st->sr_core ); +#else +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + floatToFixed_arr( st->lspold_enc, st->lspold_enc_fx, Q15, M ); +#endif + Copy( st->lspold_enc_fx, st->lsp_old_fx, M ); /*used unquantized values for mid-LSF Q*/ + IF( st->tcxonly == 0 ) + { + lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); + } + ELSE + { + E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsf_old_fx, M ); + } +#endif } /* necessary in BASOP only, due to different representations of st->lsf_old */ /* else if ( !st->tcxonly && (st->L_frame == L_FRAME16k) && (st->last_total_brate > ACELP_32k) ) */ @@ -1394,6 +1467,7 @@ static void init_acelp( } /*BPF parameters for adjusting gain in function of background noise*/ +#ifndef IVAS_FLOAT_FIXED if ( st->codec_mode == MODE2 ) { st->pst_lp_ener = 0.0f; @@ -1402,6 +1476,20 @@ static void init_acelp( st->pst_mem_deemp_err = 0.0f; } } +#else + IF( EQ_16( st->codec_mode, MODE2 ) ) + { + st->mem_bpf_fx.lp_error_ener = L_deposit_l( 0 ); + st->pst_lp_ener_fx = 0; + move16(); + if ( EQ_16( st->last_codec_mode, MODE1 ) ) + { + st->mem_bpf_fx.lp_error = L_deposit_l( 0 ); + st->pst_mem_deemp_err_fx = 0; + move16(); + } + } +#endif return; @@ -1675,16 +1763,14 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh /*BPF parameters for adjusting gain in function of background noise*/ IF( EQ_16( st->codec_mode, MODE2 ) ) { - /*EVS specific*/ - // st->mem_bpf_fx.lp_error_ener = L_deposit_l( 0 ); - /*------------*/ + st->mem_bpf_fx.lp_error_ener = L_deposit_l( 0 ); + move32(); st->pst_lp_ener_fx = 0; move16(); if ( EQ_16( st->last_codec_mode, MODE1 ) ) { - /*EVS specific*/ - // st->mem_bpf_fx.lp_error = L_deposit_l( 0 ); - /*------------*/ + st->mem_bpf_fx.lp_error = L_deposit_l( 0 ); + move32(); st->pst_mem_deemp_err_fx = 0; move16(); } diff --git a/lib_enc/core_enc_switch.c b/lib_enc/core_enc_switch.c index 6397c2d4c..d39efad14 100644 --- a/lib_enc/core_enc_switch.c +++ b/lib_enc/core_enc_switch.c @@ -238,14 +238,6 @@ void core_coder_mode_switch_ivas_fx( { floatToFixed_arr16( st->lspold_enc, &st->lspold_enc_fx[0], Q15, M ); } - if ( st->lsp_old1 != NULL ) - { - floatToFixed_arr16( st->lsp_old1, &st->lsp_old1_fx[0], Q15, M ); - } - if ( st->lsp_old != NULL ) - { - floatToFixed_arr16( st->lsp_old, &st->lsp_old_fx[0], Q15, M ); - } /* Adaptive BPF */ set_zero( st->mem_bpf, 2 * L_FILT16k ); @@ -254,6 +246,7 @@ void core_coder_mode_switch_ivas_fx( init_coder_ace_plus_ivas_fx( st, last_total_brate, MCT_flag ); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS st->preemph_fac_flt = fix16_to_float( st->preemph_fac, Q15 ); + fixedToFloat_arr( st->lspold_enc_fx, st->lspold_enc, Q15, M ); IF( st->hLPDmem != NULL ) { me2f_buf_16( st->hLPDmem->old_exc, st->hLPDmem->e_old_exc, st->hLPDmem->old_exc_flt, L_EXC_MEM ); diff --git a/lib_enc/core_switching_enc.c b/lib_enc/core_switching_enc.c index 029bdb8bb..147a0d015 100644 --- a/lib_enc/core_switching_enc.c +++ b/lib_enc/core_switching_enc.c @@ -131,8 +131,13 @@ void core_switching_pre_enc( } if ( st->L_frame == L_FRAME16k && st->last_L_frame == L_FRAME ) { +#ifndef IVAS_FLOAT_FIXED mvr2r( st->lsp_old, st->lsp_old16k, M ); st->rate_switching_reset_16kHz = lsp_convert_poly( st->lsp_old16k, L_FRAME16k, 0 ); +#else + Copy( st->lsp_old_fx, st->lsp_old16k_fx, M ); + st->rate_switching_reset_16kHz = lsp_convert_poly_fx( st->lsp_old16k_fx, L_FRAME16k, 0 ); +#endif } st->use_acelp_preq = 0; @@ -192,7 +197,7 @@ void core_switching_pre_enc( if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && st->last_core == HQ_CORE ) || ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_MDCT && last_element_mode == IVAS_CPE_DFT ) ) && active_cnt == 1 ) ) { /* Reset the ACELP core in case of HQ->ACELP core switching */ - +#ifndef IVAS_FLOAT_FIXED if ( st->L_frame == L_FRAME16k ) { mvr2r( TRWB2_Ave, st->lsf_old, M ); /* init of LSP */ @@ -203,6 +208,18 @@ void core_switching_pre_enc( mvr2r( TRWB_Ave, st->lsf_old, M ); /* init of LSP */ lsf2lsp( st->lsf_old, st->lsp_old, M, INT_FS_12k8 ); } +#else + IF( st->L_frame == L_FRAME16k ) + { + Copy( TRWB2_Ave_fx, st->lsf_old_fx, M ); /* init of LSP */ + lsf2lsp_fx( st->lsf_old_fx, st->lsp_old_fx, M, INT_FS_16k ); + } + ELSE + { + Copy( TRWB_Ave_fx, st->lsf_old_fx, M ); /* init of LSP */ + lsf2lsp_fx( st->lsf_old_fx, st->lsp_old_fx, M, INT_FS_12k8 ); + } +#endif /* Reset ACELP parameters */ if ( hLPDmem != NULL ) @@ -233,8 +250,13 @@ void core_switching_pre_enc( st->last_coder_type = GENERIC; +#ifndef IVAS_FLOAT_FIXED mvr2r( st->old_pitch_buf + st->L_frame / L_SUBFR, st->old_pitch_buf, st->L_frame / L_SUBFR ); set_f( st->old_pitch_buf + st->L_frame / L_SUBFR, L_SUBFR, st->L_frame / L_SUBFR ); +#else + Copy( st->old_pitch_buf_fx + st->L_frame / L_SUBFR, st->old_pitch_buf_fx, st->L_frame / L_SUBFR ); + set16_fx( st->old_pitch_buf_fx + st->L_frame / L_SUBFR, L_SUBFR_Q6, st->L_frame / L_SUBFR ); +#endif /* Reset old ACELP buffers */ if ( st->element_mode == EVS_MONO && hLPDmem != NULL ) @@ -280,8 +302,13 @@ void core_switching_pre_enc( st->last_coder_type = GENERIC; +#ifndef IVAS_FLOAT_FIXED mvr2r( st->old_pitch_buf + st->L_frame / L_SUBFR, st->old_pitch_buf, st->L_frame / L_SUBFR ); set_f( st->old_pitch_buf + st->L_frame / L_SUBFR, L_SUBFR, st->L_frame / L_SUBFR ); +#else + Copy( st->old_pitch_buf_fx + st->L_frame / L_SUBFR, st->old_pitch_buf_fx, st->L_frame / L_SUBFR ); + set16_fx( st->old_pitch_buf_fx + st->L_frame / L_SUBFR, L_SUBFR_Q6, st->L_frame / L_SUBFR ); +#endif /* Reset old TD BWE buffers */ if ( st->hBWE_TD != NULL ) @@ -840,7 +867,6 @@ void core_switching_post_enc( floatToFixed_arr( st->voicing, st->voicing_fx, 15, 3 ); st->hLPDmem->tilt_code = float_to_fix16( st->hLPDmem->tilt_code_flt, 15 ); floatToFixed_arr( st->old_Aq_12_8, st->old_Aq_12_8_fx, 12, M + 1 ); - st->old_Es_pred_fx = float_to_fix16( st->old_Es_pred, 8 ); st->hLPDmem->mem_w0 = float_to_fix16( st->hLPDmem->mem_w0_flt, Q_new - 1 ); floatToFixed_arr( st->hLPDmem->mem_syn_flt, st->hLPDmem->mem_syn, Q_new - 1, M ); diff --git a/lib_enc/dtx.c b/lib_enc/dtx.c index 896d58b4b..ac6b98299 100644 --- a/lib_enc/dtx.c +++ b/lib_enc/dtx.c @@ -823,9 +823,15 @@ void td_cng_enc_init( hTdCngEnc->num_ho = 0; hTdCngEnc->ho_circ_ptr = -1; +#ifndef IVAS_FLOAT_FIXED set_f( hTdCngEnc->ho_lsp_circ, 0, HO_HIST_SIZE * M ); set_f( hTdCngEnc->ho_ener_circ, 0, HO_HIST_SIZE ); set_f( hTdCngEnc->ho_env_circ, 0, HO_HIST_SIZE * NUM_ENV_CNG ); +#else + set16_fx( hTdCngEnc->ho_lsp_circ_fx, 0, HO_HIST_SIZE * M ); + set32_fx( hTdCngEnc->ho_ener_circ_fx, 0, HO_HIST_SIZE ); + set32_fx( hTdCngEnc->ho_env_circ_fx, 0, HO_HIST_SIZE * NUM_ENV_CNG ); +#endif hTdCngEnc->ho_circ_size = 0; hTdCngEnc->burst_ho_cnt = 0; hTdCngEnc->cng_buf_cnt = 0; diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c index 00b2aef90..d78459371 100644 --- a/lib_enc/fd_cng_enc.c +++ b/lib_enc/fd_cng_enc.c @@ -261,14 +261,34 @@ void configureFdCngEnc( switch ( hsCom->fftlen ) { case 512: +#ifndef IVAS_FLOAT_FIXED hsCom->fftSineTab_flt = NULL; hsCom->olapWinAna_flt = olapWinAna512; hsCom->olapWinSyn_flt = olapWinSyn256; +#else + hsCom->fftSineTab_fx = NULL; + hsCom->olapWinAna_fx = olapWinAna512_fx; + hsCom->olapWinSyn_fx = olapWinSyn256_fx; + hsCom->fftlenShift = 8; + move16(); + hsCom->fftlenFac = 32767 /*1.0 Q15*/; + move16(); +#endif break; case 640: +#ifndef IVAS_FLOAT_FIXED hsCom->fftSineTab_flt = fftSineTab640; hsCom->olapWinAna_flt = olapWinAna640; hsCom->olapWinSyn_flt = olapWinSyn320; +#else + hsCom->fftSineTab_fx = fftSineTab640_fx; + hsCom->olapWinAna_fx = olapWinAna640_fx; + hsCom->olapWinSyn_fx = olapWinSyn320_fx; + hsCom->fftlenShift = 9; + move16(); + hsCom->fftlenFac = 20480 /*0.625 Q15*/; + move16(); +#endif break; default: assert( !"Unsupported FFT length for FD-based CNG" ); diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 8ef56f72f..e439e5f22 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -372,11 +372,6 @@ void configureFdCngEnc_ivas_fx( SWITCH( hsCom->fftlen ) { case 512: -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - hsCom->fftSineTab_flt = NULL; - hsCom->olapWinAna_flt = olapWinAna512; - hsCom->olapWinSyn_flt = olapWinSyn256; -#endif hsCom->fftSineTab_fx = NULL; hsCom->olapWinAna_fx = olapWinAna512_fx; hsCom->olapWinSyn_fx = olapWinSyn256_fx; @@ -386,11 +381,6 @@ void configureFdCngEnc_ivas_fx( move16(); BREAK; case 640: -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - hsCom->fftSineTab_flt = fftSineTab640; - hsCom->olapWinAna_flt = olapWinAna640; - hsCom->olapWinSyn_flt = olapWinSyn320; -#endif hsCom->fftSineTab_fx = fftSineTab640_fx; hsCom->olapWinAna_fx = olapWinAna640_fx; hsCom->olapWinSyn_fx = olapWinSyn320_fx; diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index 98f4a3df5..d8bccaa05 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -228,6 +228,7 @@ ivas_error init_encoder( st->max_band = 19; } +#ifndef IVAS_FLOAT_FIXED if ( st->Opt_AMR_WB ) { mvr2r( mean_isf_amr_wb, st->lsf_old, M ); @@ -238,11 +239,33 @@ ivas_error init_encoder( mvr2r( GEWB_Ave, st->lsf_old, M ); lsf2lsp( st->lsf_old, st->lsp_old1, M, INT_FS_12k8 ); } +#else + IF( st->Opt_AMR_WB ) + { + Copy( mean_isf_amr_wb_fx, st->lsf_old_fx, M ); + E_LPC_isf_isp_conversion( st->lsf_old_fx, st->lsp_old1_fx, M ); + } + ELSE + { + Copy( GEWB_Ave_fx, st->lsf_old_fx, M ); + lsf2lsp_fx( st->lsf_old_fx, st->lsp_old1_fx, M, INT_FS_12k8 ); + } +#endif +#ifndef IVAS_FLOAT_FIXED mvr2r( st->lsf_old, st->lsf_old1, M ); mvr2r( st->lsp_old1, st->lsp_old, M ); mvr2r( st->lsp_old, st->lsp_old16k, M ); mvr2r( st->lsp_old, st->lspold_enc, M ); +#else + Copy( st->lsf_old_fx, st->lsf_old1_fx, M ); + Copy( st->lsp_old1_fx, st->lsp_old_fx, M ); + Copy( st->lsp_old_fx, st->lsp_old16k_fx, M ); + Copy( st->lsp_old_fx, st->lspold_enc_fx, M ); +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + fixedToFloat_arr( st->lspold_enc_fx, st->lspold_enc, Q15, M ); +#endif +#endif #ifndef IVAS_FLOAT_FIXED st->stab_fac = 0.0f; @@ -252,8 +275,13 @@ ivas_error init_encoder( #endif /* Bass post-filter memories - encoder side of MODE2 */ st->bpf_off = 0; +#ifndef IVAS_FLOAT_FIXED st->pst_mem_deemp_err = 0.0f; st->pst_lp_ener = 0.0f; +#else + st->pst_mem_deemp_err_fx = 0; + st->pst_lp_ener_fx = 0; +#endif /* TC coder type */ st->tc_cnt = 0; @@ -295,9 +323,6 @@ ivas_error init_encoder( #ifndef IVAS_FLOAT_FIXED mvr2r( st->lsp_old, st->lspold_s, M ); #else -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - floatToFixed_arr( st->lsp_old, st->lsp_old_fx, Q15, M ); -#endif Copy( st->lsp_old_fx, st->lspold_s_fx, M ); #endif st->noimix_seed = RANDOM_INITSEED; @@ -324,27 +349,42 @@ ivas_error init_encoder( #endif st->Last_pulse_pos = 0; +#ifndef IVAS_FLOAT_FIXED for ( i = 0; i < 2 * NB_SUBFR16k; i++ ) { st->old_pitch_buf[i] = L_SUBFR; } +#else + for ( i = 0; i < 2 * NB_SUBFR16k; i++ ) + { + st->old_pitch_buf_fx[i] = L_SUBFR_Q6; + } +#endif /* mode1 core switching */ +#ifndef IVAS_FLOAT_FIXED st->old_Es_pred = 0; +#else + st->old_Es_pred_fx = 0; +#endif set_f( st->old_Aq_12_8 + 1, 0, M ); st->old_Aq_12_8[0] = 1; /* stable short pitch detection */ +#ifndef IVAS_FLOAT_FIXED st->voicing0_sm = 0; st->voicing_sm = 0; st->LF_EnergyRatio_sm = 1; - st->predecision_flag = 0; - st->diff_sm = 0; - st->energy_sm = 0; -#ifdef IVAS_FLOAT_FIXED +#else st->voicing0_sm_fx = 0; st->voicing_sm_fx = 0; st->LF_EnergyRatio_sm_fx = ONE_IN_Q7; +#endif + st->predecision_flag = 0; +#ifndef IVAS_FLOAT_FIXED + st->diff_sm = 0; + st->energy_sm = 0; +#else st->diff_sm_fx = 0; st->energy_sm_fx = 0; #endif @@ -600,9 +640,6 @@ ivas_error init_encoder( #ifndef IVAS_FLOAT_FIXED dtx_enc_init( st, var_SID_rate_flag, interval_SID ); #else -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - floatToFixed_arr( st->lsp_old1, st->lsp_old1_fx, Q15, M ); -#endif dtx_enc_init_fx( st, var_SID_rate_flag, interval_SID ); #endif } @@ -1302,31 +1339,12 @@ ivas_error init_encoder_ivas_fx( st->mem_wsp = 0.0f; set_f( st->mem_decim2, 0, 3 ); set_f( st->Bin_E, 0, L_FFT ); - if ( st->Opt_AMR_WB ) - { - mvr2r( mean_isf_amr_wb, st->lsf_old, M ); - isf2isp( st->lsf_old, st->lsp_old1, M, INT_FS_12k8 ); - } - else - { - mvr2r( GEWB_Ave, st->lsf_old, M ); - lsf2lsp( st->lsf_old, st->lsp_old1, M, INT_FS_12k8 ); - } - mvr2r( st->lsf_old, st->lsf_old1, M ); - mvr2r( st->lsp_old1, st->lsp_old, M ); - mvr2r( st->lsp_old, st->lsp_old16k, M ); - mvr2r( st->lsp_old, st->lspold_enc, M ); st->mem_preemph_DFT = 0.0f; set_f( st->inp_12k8_mem_stereo_sw, 0, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); st->mem_preemph16k_DFT = 0.0f; set_f( st->inp_16k_mem_stereo_sw, 0, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); set_f( st->old_Aq_12_8 + 1, 0, M ); st->old_Aq_12_8[0] = 4096; - st->voicing0_sm = 0; - st->voicing_sm = 0; - st->LF_EnergyRatio_sm = 1; - st->diff_sm = 0; - st->energy_sm = 0; set_f( st->voicing, 0.0f, 3 ); st->lp_speech = 45.0f; /* Initialize the long-term active speech level in dB */ st->active_cnt = 0; @@ -1337,14 +1355,12 @@ ivas_error init_encoder_ivas_fx( st->EnergyLT = 0.0f; st->Energy_Old = 0; #endif -#ifndef IVAS_FLOAT_FIXED - st->prev_fmerit_flt = 0; - st->fmerit_dt_flt = 0; #endif - st->pst_mem_deemp_err = 0.0f; - st->pst_lp_ener = 0.0f; -#endif + st->pst_mem_deemp_err_fx = 0; + move16(); + st->pst_lp_ener_fx = 0; + move16(); /* AVQ pre-quantizer memory */ st->mem_preemp_preQ_fx = 0; @@ -1480,15 +1496,12 @@ ivas_error init_encoder_ivas_fx( FOR( i = 0; i < shl( NB_SUBFR16k, 1 ); i++ ) { -#if 1 // TODO: To be removed later - st->old_pitch_buf[i] = L_SUBFR; -#endif st->old_pitch_buf_fx[i] = L_SUBFR_Q6; move16(); } /* mode1 core switching */ - st->old_Es_pred = 0; + st->old_Es_pred_fx = 0; move16(); set16_fx( st->old_Aq_12_8_fx + 1, 0, M ); st->old_Aq_12_8_fx[0] = ONE_IN_Q12; @@ -1766,9 +1779,6 @@ ivas_error init_encoder_ivas_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX variables\n" ) ); } -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - floatToFixed_arr( st->lsp_old1, st->lsp_old1_fx, Q15, M ); -#endif dtx_enc_init_fx( st, var_SID_rate_flag, interval_SID ); } ELSE @@ -2279,19 +2289,6 @@ ivas_error init_encoder_ivas_fx( f2me_buf_16( st->buf_wspeech_enc_flt + st->L_frame + L_SUBFR - L_WSP_MEM, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, &st->exp_old_inp_16k, L_WSP_MEM ); /* Initialize ACELP */ - if ( st->lspold_enc != NULL ) - { - floatToFixed_arr16( st->lspold_enc, &st->lspold_enc_fx[0], Q15, M ); - } - if ( st->lsp_old1 != NULL ) - { - floatToFixed_arr16( st->lsp_old1, &st->lsp_old1_fx[0], Q15, M ); - } - if ( st->lsp_old != NULL ) - { - floatToFixed_arr16( st->lsp_old, &st->lsp_old_fx[0], Q15, M ); - } - /* Adaptive BPF */ set_zero( st->mem_bpf, 2 * L_FILT16k ); set_zero( st->mem_error_bpf, 2 * L_FILT16k ); @@ -2299,6 +2296,7 @@ ivas_error init_encoder_ivas_fx( init_coder_ace_plus_ivas_fx( st, st->last_total_brate, 0 ); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS st->preemph_fac_flt = fix16_to_float( st->preemph_fac, Q15 ); + fixedToFloat_arr( st->lspold_enc_fx, st->lspold_enc, Q15, M ); IF( st->hLPDmem != NULL ) { me2f_buf_16( st->hLPDmem->old_exc, st->hLPDmem->e_old_exc, st->hLPDmem->old_exc_flt, L_EXC_MEM ); diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index d1a548d1d..a550f76de 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -229,8 +229,6 @@ ivas_error ivas_core_enc( st->preemph_fac = (Word16) floatToFixed( st->preemph_fac_flt, Q15 ); - floatToFixed_arr16( st->lsp_old, st->lsp_old_fx, Q15, M ); - floatToFixed_arr16( st->lsp_old1, st->lsp_old1_fx, Q15, M ); floatToFixed_arr16( st->lspold_enc, st->lspold_enc_fx, Q15, M ); floatToFixed_arr16( st->voicing, st->voicing_fx, Q15, 3 ); @@ -310,8 +308,6 @@ ivas_error ivas_core_enc( #ifdef IVAS_FLOAT_FIXED_CONVERSIONS st->preemph_fac_flt = fixedToFloat_16( st->preemph_fac, Q15 ); - fixedToFloat_arr( st->lsp_old_fx, st->lsp_old, Q15, M ); - fixedToFloat_arr( st->lsp_old1_fx, st->lsp_old1, Q15, M ); fixedToFloat_arr( st->lspold_enc_fx, st->lspold_enc, Q15, M ); fixedToFloat_arr( st->voicing_fx, st->voicing, Q15, 3 ); @@ -388,7 +384,6 @@ ivas_error ivas_core_enc( #ifdef IVAS_FLOAT_FIXED_CONVERSIONS Word16 last_core = st->last_core; Word16 bwidth_sw_cnt = st->bwidth_sw_cnt; - floatToFixed_arr16( st->lsp_old, st->lsp_old_fx, 15, M ); Word16 q_old_inp_16k_fx; Word16 q_old_inp_12k8_fx; @@ -463,15 +458,6 @@ ivas_error ivas_core_enc( st->hTcxEnc->Q_old_out = Q_factor_arr( st->hTcxEnc->old_out, L_FRAME32k ) - 1; floatToFixed_arr( st->hTcxEnc->old_out, st->hTcxEnc->old_out_fx, st->hTcxEnc->Q_old_out, L_FRAME32k ); - - IF( st->hTdCngEnc != NULL ) - { - floatToFixed_arrL( st->hTdCngEnc->ho_ener_circ, st->hTdCngEnc->ho_ener_circ_fx, Q6, HO_HIST_SIZE ); - floatToFixed_arr( st->hTdCngEnc->ho_lsp_circ, st->hTdCngEnc->ho_lsp_circ_fx, Q15, HO_HIST_SIZE * M ); - floatToFixed_arrL( st->hTdCngEnc->ho_env_circ, st->hTdCngEnc->ho_env_circ_fx, Q6, HO_HIST_SIZE * NUM_ENV_CNG ); - // floatToFixed_arr( st->hTdCngEnc->cng_exc2_buf_flt, st->hTdCngEnc->cng_exc2_buf, Q_exc, HO_HIST_SIZE * L_FFT ); - } - #endif // IVAS_FLOAT_FIXED_CONVERSIONS @@ -483,17 +469,8 @@ ivas_error ivas_core_enc( fixedToFloat_arr( st->hTcxEnc->old_out_fx, st->hTcxEnc->old_out, st->hTcxEnc->Q_old_out, L_FRAME32k ); - IF( st->hTdCngEnc != NULL ) - { - fixedToFloat_arrL( st->hTdCngEnc->ho_ener_circ_fx, st->hTdCngEnc->ho_ener_circ, Q6, HO_HIST_SIZE ); - fixedToFloat_arr( st->hTdCngEnc->ho_lsp_circ_fx, st->hTdCngEnc->ho_lsp_circ, Q15, HO_HIST_SIZE * M ); - fixedToFloat_arrL( st->hTdCngEnc->ho_env_circ_fx, st->hTdCngEnc->ho_env_circ, Q6, HO_HIST_SIZE * NUM_ENV_CNG ); - // fixedToFloat_arr( st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_exc2_buf_flt, Q_exc, HO_HIST_SIZE * L_FFT ); - } - st->hTcxEnc->measuredBwRatio_flt = fix16_to_float( st->hTcxEnc->measuredBwRatio, Q14 ); - fixedToFloat_arr( st->lsp_old_fx, st->lsp_old, Q15, M ); { st->clip_var[0] = (float) st->clip_var_fx[0] / 2.56f; st->clip_var[1] = fix16_to_float( st->clip_var_fx[1], Q14 ); @@ -502,11 +479,6 @@ ivas_error ivas_core_enc( st->clip_var[4] = fix16_to_float( st->clip_var_fx[4], Q14 ); st->clip_var[5] = fix16_to_float( st->clip_var_fx[5], Q14 ); } - - for ( int j = 0; j < M; j++ ) - { - st->lsf_old[j] = (float) st->lsf_old_fx[j] / 2.56f; - } for ( int k = 0; k < 2; k++ ) { fixedToFloat_arrL( st->hTcxEnc->spectrum_fx[k], st->hTcxEnc->spectrum[k], 31 - st->hTcxEnc->spectrum_e[k], 720 ); @@ -699,11 +671,6 @@ ivas_error ivas_core_enc( #else #ifdef IVAS_FLOAT_FIXED_CONVERSIONS // lsp_old - Q15, lsf_old - Qlog2(2.56), pitch_buf - Q6 - floatToFixed_arr16( st->lsp_old, st->lsp_old_fx, Q15, M ); - for ( i = 0; i < M; i++ ) - { - st->lsf_old_fx[i] = (Word16) ( st->lsf_old[i] * 2.56f ); - } floatToFixed_arr16( pitch_buf[0], pitch_buf_fx[0], Q6, NB_SUBFR ); #endif td_stereo_param_updt_fx( st->lsp_old_fx, st->lsf_old_fx, pitch_buf_fx[0], tdm_lspQ_PCh_fx, tdm_lsfQ_PCh_fx, hStereoTD->tdm_Pri_pitch_buf_fx, st->flag_ACELP16k, hStereoTD->tdm_use_IAWB_Ave_lpc ); @@ -714,7 +681,6 @@ ivas_error ivas_core_enc( { tdm_lsfQ_PCh[i] = tdm_lsfQ_PCh_fx[i] / 2.56f; } - fixedToFloat_arr( hStereoTD->tdm_Pri_pitch_buf_fx, hStereoTD->tdm_Pri_pitch_buf, Q6, NB_SUBFR ); #endif #endif } diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 335e85063..bac876c57 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -2061,8 +2061,6 @@ ivas_error pre_proc_front_ivas_fx( for ( int idx = 0; idx < M; idx++ ) { lsp_new_loc_fx[idx] = (Word16) ( lsp_new[idx] * 32767 ); - st->lsp_old1_fx[idx] = (Word16) ( st->lsp_old1[idx] * 32767 ); - st->lsf_old1_fx[idx] = (Word16) ( st->lsf_old1[idx] * 2.56 ); } for ( int idx = 0; idx < 3; idx++ ) { @@ -2116,8 +2114,6 @@ ivas_error pre_proc_front_ivas_fx( lsp_new[idx] = (float) lsp_new_loc_fx[idx] / 32767.0f; lsp_mid[idx] = (float) lsp_mid_loc_fx[idx] / 32767.0f; - st->lsp_old1[idx] = (float) ( (float) st->lsp_old1_fx[idx] / 32767.0f ); - st->lsf_old1[idx] = (float) ( (float) st->lsf_old1_fx[idx] / 2.56f ); lsf_new[idx] = (float) ( (float) lsf_new_16_loc_fx[idx] / 2.56f ); } for ( int idx = 0; idx < NB_SUBFR16k * ( M + 1 ); idx++ ) @@ -2277,11 +2273,6 @@ ivas_error pre_proc_front_ivas_fx( Word16 q_wsp = Q_factor_arr( old_wsp, L_WSP ) - 3; floatToFixed_arr16( old_wsp, old_wsp_fx, q_wsp, L_WSP ); floatToFixed_arr16( st->voicing, st->voicing_fx, Q15, 3 ); - st->voicing_sm_fx = float_to_fix16( st->voicing_sm, Q15 ); - st->voicing0_sm_fx = float_to_fix16( st->voicing0_sm, Q15 ); - st->LF_EnergyRatio_sm_fx = float_to_fix16( st->LF_EnergyRatio_sm, Q7 ); - st->diff_sm_fx = float_to_fix( st->diff_sm, Q7 ); - st->energy_sm_fx = float_to_fix( st->energy_sm, Q7 ); floatToFixed_arr16( st->Bin_E, st->lgBin_E_fx, Q7, L_FFT / 2 ); // Function StableHighPitchDetect_fx excepts st->lgBin_E_fx to be in Q7 @@ -2454,14 +2445,6 @@ ivas_error pre_proc_front_ivas_fx( st->coder_type = find_uv_ivas_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, relE_fx, Etot16_fx, hp_E_fx, &flag_spitch, last_core_orig, hStereoClassif, q_inp_12k8, q_fr_bands ); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - - st->diff_sm = fixedToFloat_32( st->diff_sm_fx, Q7 ); - st->energy_sm = fixedToFloat_32( st->energy_sm_fx, Q7 ); - - st->voicing_sm = fixedToFloat_16( st->voicing_sm_fx, Q15 ); - st->voicing0_sm = fixedToFloat_16( st->voicing0_sm_fx, Q15 ); - st->LF_EnergyRatio_sm = fixedToFloat_16( st->LF_EnergyRatio_sm_fx, Q7 ); - fixedToFloat_arr( pitch_fr_fx, pitch_fr, Q6, NB_SUBFR ); fixedToFloat_arr( voicing_fr_fx, voicing_fr, Q15, NB_SUBFR ); @@ -2775,11 +2758,6 @@ ivas_error pre_proc_front_ivas_fx( { st->hTcxCfg->bandwidth_flt = getTcxBandwidth_flt( st->bwidth ); } - IF( st->envWeighted && !st->enableTcxLpc ) - { - /* Unweight the envelope */ - floatToFixed_arr( st->lsp_old, st->lsp_old_fx, Q15, M ); - } } #endif @@ -2787,14 +2765,6 @@ ivas_error pre_proc_front_ivas_fx( st->sba_br_sw_while_no_data = 0; move16(); - -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - IF( st->envWeighted && !st->enableTcxLpc ) - { - fixedToFloat_arr( st->lsp_old_fx, st->lsp_old, Q15, M ); - fixedToFloat_arr( st->lsf_old_fx, st->lsf_old, Q15, M ); - } -#endif #else SetModeIndex( st, st->bits_frame_nominal * FRAMES_PER_SEC, element_mode, MCT_flag ); diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index 5dc8c4f61..36abcd18f 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -410,7 +410,7 @@ void ivas_dirac_enc_close_fx( IF( hDirAC->hFbMixer != NULL ) { - ivas_FB_mixer_close( &hDirAC->hFbMixer, input_Fs, 0 ); + ivas_FB_mixer_close_fx( &hDirAC->hFbMixer, input_Fs, 0 ); } /* intensity 3-dim */ FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 9c114e061..580ac60a8 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -800,7 +800,8 @@ ivas_error ivas_enc( } for ( i = 0; i < st_ivas->hEncoderConfig->nchan_ism; i++ ) { - floatToFixed_arr32( st_ivas->hParamIsm->hFbMixer->ppFilterbank_prior_input[i], st_ivas->hParamIsm->hFbMixer->ppFilterbank_prior_input_fx[i], Q14, st_ivas->hParamIsm->hFbMixer->fb_cfg->prior_input_length ); + scale_sig32( st_ivas->hParamIsm->hFbMixer->ppFilterbank_prior_input_fx[i], st_ivas->hParamIsm->hFbMixer->fb_cfg->prior_input_length, sub( Q14, st_ivas->hParamIsm->hFbMixer->q_ppFilterbank_prior_input_fx[i] ) ); + st_ivas->hParamIsm->hFbMixer->q_ppFilterbank_prior_input_fx[i] = Q14; } #endif @@ -814,10 +815,6 @@ ivas_error ivas_enc( { fixedToFloat_arrL32( data_fx[i], data_f[i], Q14, input_frame ); } - for ( i = 0; i < st_ivas->hEncoderConfig->nchan_ism; i++ ) - { - fixedToFloat_arrL32( st_ivas->hParamIsm->hFbMixer->ppFilterbank_prior_input_fx[i], st_ivas->hParamIsm->hFbMixer->ppFilterbank_prior_input[i], Q14, st_ivas->hParamIsm->hFbMixer->fb_cfg->prior_input_length ); - } #endif #else ivas_param_ism_enc( st_ivas, data_f, input_frame ); @@ -1203,13 +1200,6 @@ ivas_error ivas_enc( ivas_mc_paramupmix_enc_fx( st_ivas, hMetaData, data_fx, input_frame ); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( int ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) - { - for ( int ch_idx = 0; ch_idx < st_ivas->hMCParamUpmix->hFbMixer->fb_cfg->num_in_chans; ch_idx++ ) - { - fixedToFloat_arrL( st_ivas->hMCParamUpmix->hFbMixer->ppFilterbank_prior_input_fx[ch_idx], st_ivas->hMCParamUpmix->hFbMixer->ppFilterbank_prior_input[ch_idx], Q14, input_frame / MAX_PARAM_SPATIAL_SUBFRAMES ); - } - } for ( i = 4; i < 12; i++ ) { for ( int l = 0; l < input_frame; l++ ) diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index ca21f7b64..cdca90692 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -981,7 +981,6 @@ ivas_error front_vad_spar( // analy_lp( inp_12k8, L_FRAME, L_LOOK_12k8, &res_energy, A, epsP, lsp_new, lsp_mid, st->lsp_old1, alw_pitch_lag_12k8, alw_voicing, INT_FS_12k8, 0 /* <-- sec_chan_low_rate */ ); Word16 Q_r[2] = { 0 }; - floatToFixed_arr( st->lsp_old1, st->lsp_old1_fx, Q15, M ); floatToFixed_arr( alw_voicing, alw_voicing_fx, Q15, 2 ); Q_inp_12k8 = Q9; // Q_factor_arr( inp_12k8 - 90, 3 * L_FRAME / 2 + 90 ); floatToFixed_arr( inp_12k8 - 90, inp_12k8_fx - 90, Q_inp_12k8, 3 * L_FRAME / 2 + 90 ); @@ -994,7 +993,6 @@ ivas_error front_vad_spar( fixedToFloat_arr( A_fx, A, Q14, NB_SUBFR16k * ( M + 1 ) ); fixedToFloat_arr( lsp_new_fx, lsp_new, Q15, M ); fixedToFloat_arr( lsp_mid_fx, lsp_mid, Q15, M ); - fixedToFloat_arr( st->lsp_old1_fx, st->lsp_old1, Q15, M ); fixedToFloat_arr( st->mem_decim2_fx, st->mem_decim2, Q9, 3 ); #endif @@ -1072,9 +1070,6 @@ ivas_error front_vad_spar( floatToFixed_arr( st->Bin_E, st->lgBin_E_fx, Q7, 128 ); StableHighPitchDetect_ivas_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, Q12, st->lgBin_E_fx ); fixedToFloat_arr( st->lgBin_E_fx, st->Bin_E, Q7, 128 ); - st->LF_EnergyRatio_sm = fixedToFloat( st->LF_EnergyRatio_sm_fx, Q7 ); - st->voicing_sm = fixedToFloat( st->voicing_sm_fx, Q15 ); - st->voicing0_sm = fixedToFloat( st->voicing0_sm_fx, Q15 ); #endif if ( st->hSpMusClas != NULL ) { diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index baebbcee5..a2fd102b1 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -5204,7 +5204,7 @@ static void average_masa_metadata_fx( hMeta->common_meta.surround_coherence_fx[j][k] = BASOP_Util_Divide3232_Scale( surr_coh_sum_fx, L_add( energy_sum_fx, EPSILON_FX ), &temp2_e ); move16(); temp2_e = add( temp2_e, sub( surr_coh_sum_e, energy_sum_e ) ); - hMeta->common_meta.surround_coherence_fx[j][k] = shl( hMeta->common_meta.surround_coherence_fx[j][k], temp2_e ); /*changing q from 15-temp2_e to q15*/ + hMeta->common_meta.surround_coherence_fx[j][k] = shl_sat( hMeta->common_meta.surround_coherence_fx[j][k], temp2_e ); /*changing q from 15-temp2_e to q15*/ move16(); } diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index 024532450..4c5c7905e 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -1013,13 +1013,6 @@ void ivas_param_mc_enc_fx( } } -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( i = 0; i < hParamMC->hFbMixer->fb_cfg->num_in_chans; i++ ) - { - fixedToFloat_arrL( hParamMC->hFbMixer->ppFilterbank_prior_input_fx[i], hParamMC->hFbMixer->ppFilterbank_prior_input[i], Q11, input_frame / PARAM_MC_MDFT_NO_SLOTS ); - } -#endif - pop_wmops(); return; diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc.c index d26e6bee4..0671e2f3f 100644 --- a/lib_enc/ivas_mc_paramupmix_enc.c +++ b/lib_enc/ivas_mc_paramupmix_enc.c @@ -281,7 +281,7 @@ ivas_error ivas_mc_paramupmix_enc_open( fb_cfg->prior_input_length = (int16_t) max( fb_cfg->prior_input_length, input_frame / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Allocate and initialize FB mixer handle */ - IF( ( error = ivas_FB_mixer_open( &( hMCParamUpmix->hFbMixer ), input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_FB_mixer_open_fx( &( hMCParamUpmix->hFbMixer ), input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -605,7 +605,7 @@ void ivas_mc_paramupmix_enc_close( IF( ( *hMCParamUpmix )->hFbMixer != NULL ) { - ivas_FB_mixer_close( &( *hMCParamUpmix )->hFbMixer, input_Fs, 0 ); + ivas_FB_mixer_close_fx( &( *hMCParamUpmix )->hFbMixer, input_Fs, 0 ); } FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index c38bd5ec6..fa699e0af 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -128,42 +128,6 @@ static void computeEvenLayout_fx( static void computeLfeEnergy_fx( MCMASA_ENC_HANDLE hMcMasa, Word32 *data_fx[], const Word16 input_frame, Word16 q_fac ); -static Word16 ivas_getScaleFactor32( /* o: measured headroom in range [0..31], 0 if all x[i] == 0 */ - const Word32 *x, /* i: array containing 32-bit data */ - const Word16 len_x ) /* i: length of the array to scan */ -{ - Word16 i, i_min, i_max; - Word32 x_min, x_max; - - - x_max = 0; - move32(); - x_min = 0; - move32(); - FOR( i = 0; i < len_x; i++ ) - { - IF( x[i] >= 0 ) - x_max = L_max( x_max, x[i] ); - IF( x[i] < 0 ) - x_min = L_min( x_min, x[i] ); - } - - i_max = 0x1f; - move16(); - i_min = 0x1f; - move16(); - - IF( x_max != 0 ) - i_max = norm_l( x_max ); - - IF( x_min != 0 ) - i_min = norm_l( x_min ); - - i = s_and( s_min( i_max, i_min ), 0x1F ); - - - return i; -} #endif #ifdef IVAS_FLOAT_FIXED @@ -297,11 +261,6 @@ ivas_error ivas_mcmasa_enc_open_fx( return error; } - /* Allocate and initialize FB mixer handle */ - IF( NE_32( ( error = ivas_FB_mixer_open( &( hMcMasa->hFbMixer ), input_Fs, fb_cfg, 0 ) ), IVAS_ERR_OK ) ) - { - return error; - } /* Allocate and initialize FB mixer handle */ IF( NE_32( ( error = ivas_FB_mixer_open_fx( &( hMcMasa->hFbMixer ), input_Fs, fb_cfg, 0 ) ), IVAS_ERR_OK ) ) { @@ -332,10 +291,6 @@ ivas_error ivas_mcmasa_enc_open_fx( return error; } - IF( NE_32( ( error = ivas_FB_mixer_open( &( hMcMasa->hFbMixerLfe ), input_Fs, fb_cfgLfe, 0 ) ), IVAS_ERR_OK ) ) - { - return error; - } IF( NE_32( ( error = ivas_FB_mixer_open_fx( &( hMcMasa->hFbMixerLfe ), input_Fs, fb_cfgLfe, 0 ) ), IVAS_ERR_OK ) ) { return error; @@ -1073,11 +1028,11 @@ void ivas_mcmasa_enc_close_fx( } } - ivas_FB_mixer_close( &( *hMcMasa )->hFbMixer, input_Fs, 0 ); + ivas_FB_mixer_close_fx( &( *hMcMasa )->hFbMixer, input_Fs, 0 ); IF( !( *hMcMasa )->separateChannelEnabled ) { - ivas_FB_mixer_close( &( *hMcMasa )->hFbMixerLfe, input_Fs, 0 ); + ivas_FB_mixer_close_fx( &( *hMcMasa )->hFbMixerLfe, input_Fs, 0 ); } /* intensity 3-dim */ @@ -1761,8 +1716,8 @@ void ivas_mcmasa_param_est_enc_fx( FOR( i = 0; i < numAnalysisChannels; i++ ) { pcm_in[i] += l_ts; - cr_q = s_min( cr_q, ivas_getScaleFactor32( Chnl_ImagBuffer_fx[i], DIRAC_NO_FB_BANDS_MAX ) ); - ci_q = s_min( ci_q, ivas_getScaleFactor32( Chnl_RealBuffer_fx[i], DIRAC_NO_FB_BANDS_MAX ) ); + cr_q = s_min( cr_q, L_norm_arr( Chnl_ImagBuffer_fx[i], DIRAC_NO_FB_BANDS_MAX ) ); + ci_q = s_min( ci_q, L_norm_arr( Chnl_RealBuffer_fx[i], DIRAC_NO_FB_BANDS_MAX ) ); } sf = sub( s_min( cr_q, ci_q ), 5 ); diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index ec1e0f9fa..aafe494b4 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -427,7 +427,7 @@ ivas_error ivas_osba_enc_reconfig( /* FB mixer handle */ IF( hDirAC->hFbMixer != NULL ) { - ivas_FB_mixer_close( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs, 0 ); + ivas_FB_mixer_close_fx( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs, 0 ); hDirAC->hFbMixer = NULL; } spar_reconfig_flag = 1; diff --git a/lib_enc/ivas_pca_enc.c b/lib_enc/ivas_pca_enc.c index aff3a54e9..4e81efaac 100644 --- a/lib_enc/ivas_pca_enc.c +++ b/lib_enc/ivas_pca_enc.c @@ -89,35 +89,12 @@ static void ivas_bitstream_write_int32( #endif -#ifndef IVAS_FLOAT_FIXED -static void pca_enc_reset( - PCA_ENC_STATE *hPCA ) -{ - int16_t i; - - /* reset states for interpolation and multiplexing */ - eye_matrix( hPCA->prev_eigVec, FOA_CHANNELS, 1.0f ); - set_zero( hPCA->prev_ql, IVAS_PCA_INTERP ); - hPCA->prev_ql[0] = 1.0f; - set_zero( hPCA->prev_qr, IVAS_PCA_INTERP ); - hPCA->prev_qr[0] = 1.0f; - - for ( i = 0; i < FOA_CHANNELS; i++ ) - { - hPCA->prev_D[i] = 0.25f; - } - - eye_matrix( hPCA->mem_eigVec_interp, FOA_CHANNELS, 1.0f ); - set_zero( hPCA->old_r_sm, FOA_CHANNELS * FOA_CHANNELS ); - - return; -} -#else static void pca_enc_reset_fx( PCA_ENC_STATE *hPCA ) { Word16 i; + /* reset states for interpolation and multiplexing */ eye_matrix_fx( hPCA->prev_eigVec_fx, FOA_CHANNELS, MAX_WORD16 ); set16_fx( hPCA->prev_ql_fx, 0, IVAS_PCA_INTERP ); hPCA->prev_ql_fx[0] = MAX_WORD16; @@ -137,39 +114,7 @@ static void pca_enc_reset_fx( return; } -#endif -#ifndef IVAS_FLOAT_FIXED -static void pca_transform_sub( - float *eigVec, - float *transformed_data[8], /* i : input/transformed audio channels */ - const int16_t start, - const int16_t len, - const int16_t n_channels ) -{ - int16_t i, j, k; - float temp; - float buffer_data[FOA_CHANNELS]; - for ( j = 0; j < len; j++ ) - { - for ( k = 0; k < n_channels; k++ ) - { - buffer_data[k] = transformed_data[k][j + start]; - } - for ( k = 0; k < n_channels; k++ ) - { - temp = 0.0f; - for ( i = 0; i < n_channels; i++ ) - { - temp += eigVec[i * IVAS_PCA_INTERP + k] * buffer_data[i]; - } - transformed_data[k][j + start] = temp; - } - } - - return; -} -#else static void pca_transform_sub_fx( Word16 *eigVec, Word32 *transformed_data[8], /* i : input/transformed audio channels Q11 */ @@ -204,38 +149,7 @@ static void pca_transform_sub_fx( return; } -#endif - -#ifndef IVAS_FLOAT_FIXED -static void pca_enc_transform( - PCA_ENC_STATE *hPCA, - float *ql, - float *qr, - float *transformed_data[8], /* i : input/transformed audio channels */ - const int16_t input_frame, - const int16_t n_channels ) -{ - float eigVec_interp[FOA_CHANNELS * FOA_CHANNELS]; /* eigenvectors in current frame */ - float ql_interp[IVAS_PCA_LEN_INTERP_Q], qr_interp[IVAS_PCA_LEN_INTERP_Q]; - int16_t time_slot; - int16_t slot_len; - quat_shortestpath( hPCA->prev_ql, ql, hPCA->prev_qr, qr ); - - pca_interp_preproc( hPCA->prev_ql, hPCA->prev_qr, ql, qr, IVAS_PCA_N_SLOTS, ql_interp, qr_interp ); - - slot_len = (int16_t) ( input_frame / IVAS_PCA_N_SLOTS ); - - for ( time_slot = 0; time_slot < IVAS_PCA_N_SLOTS; time_slot++ ) - { - /* convert from double quaternion to 4D matrix */ - dquat2mat( &ql_interp[IVAS_PCA_INTERP * time_slot], &qr_interp[IVAS_PCA_INTERP * time_slot], eigVec_interp ); - pca_transform_sub( eigVec_interp, transformed_data, slot_len * time_slot, slot_len, n_channels ); - } - - return; -} -#else static void pca_enc_transform_fx( PCA_ENC_STATE *hPCA, Word16 *ql_fx, // Q15 @@ -263,23 +177,7 @@ static void pca_enc_transform_fx( return; } -#endif -#ifndef IVAS_FLOAT_FIXED -static void pca_update_state( - PCA_ENC_STATE *hPCA, - float *ql, - float *qr, - float *eigVec, - const int16_t n_channels ) -{ - mvr2r( qr, hPCA->prev_qr, IVAS_PCA_INTERP ); - mvr2r( ql, hPCA->prev_ql, IVAS_PCA_INTERP ); - mvr2r( eigVec, hPCA->prev_eigVec, n_channels * n_channels ); - - return; -} -#else static void pca_update_state_fx( PCA_ENC_STATE *hPCA, Word16 *ql, // Q15 @@ -293,33 +191,7 @@ static void pca_update_state_fx( return; } -#endif - -#ifndef IVAS_FLOAT_FIXED -static void swap_eigvec( - float *eigVec, - const int16_t i, - const int16_t j ) -{ - float eigVec_tmp[FOA_CHANNELS]; - int16_t k; - - for ( k = 0; k < FOA_CHANNELS; k++ ) - { - eigVec_tmp[k] = eigVec[k * FOA_CHANNELS + i]; - } - for ( k = 0; k < FOA_CHANNELS; k++ ) - { - eigVec[k * FOA_CHANNELS + i] = eigVec[k * FOA_CHANNELS + j]; - } - for ( k = 0; k < FOA_CHANNELS; k++ ) - { - eigVec[k * FOA_CHANNELS + j] = eigVec_tmp[k]; - } - return; -} -#else static void swap_eigvec_fx( Word32 *eigVec, // Q31 const Word32 i, @@ -346,52 +218,7 @@ static void swap_eigvec_fx( return; } -#endif -#ifndef IVAS_FLOAT_FIXED -static void sort4_D_eigVec( - float *D, - float *eigVec ) -{ - float tempr; - - if ( D[0] < D[1] ) - { - SWAP( D[0], D[1] ); - swap_eigvec( eigVec, 0, 1 ); - } - - if ( D[2] < D[3] ) - { - SWAP( D[2], D[3] ); - swap_eigvec( eigVec, 2, 3 ); - } - - if ( D[0] < D[2] ) - { - SWAP( D[0], D[2] ); - swap_eigvec( eigVec, 0, 2 ); - } - - if ( D[1] < D[3] ) - { - SWAP( D[1], D[3] ); - swap_eigvec( eigVec, 1, 3 ); - } - - if ( D[1] < D[2] ) - { - SWAP( D[1], D[2] ); - swap_eigvec( eigVec, 1, 2 ); - } - - /* swap last 2 values */ - SWAP( D[2], D[3] ); - swap_eigvec( eigVec, 2, 3 ); - - return; -} -#else static void sort4_D_eigVec_fx( Word32 *D, // Q Word32 *eigVec // Q31 @@ -435,7 +262,6 @@ static void sort4_D_eigVec_fx( return; } -#endif /*------------------------------------------------------------------------- * ivas_pca_enc_init() @@ -472,343 +298,6 @@ void ivas_pca_enc_init( * PCA encoder *------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED -void ivas_pca_enc( - const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ - PCA_ENC_STATE *hPCA, /* i : PCA encoder structure */ - BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ - float *data_f[8], /* i : input/transformed audio channels */ - const int16_t input_frame, /* i : input frame length */ - const int16_t n_channels /* i : number of channels */ -) -{ - int16_t i, j, k, l; - int16_t len_subfr; - float r[FOA_CHANNELS * FOA_CHANNELS]; /* covariance matrix */ - float eigVec[FOA_CHANNELS * FOA_CHANNELS]; /* eigenvectors in current frame */ - float eigVec_tmp[FOA_CHANNELS * FOA_CHANNELS]; /* transpose / tmp matrix for permutation */ - float cost_mtx[FOA_CHANNELS * FOA_CHANNELS]; /* cost matrix */ - int16_t path[FOA_CHANNELS]; - float D[FOA_CHANNELS]; /* eigenvalues in current frame */ - float ql[IVAS_PCA_INTERP], qr[IVAS_PCA_INTERP]; - float det; - float temp; - float *ptr_sig[FOA_CHANNELS]; - int32_t index[2]; - float fac_D, sum_D; - float fac_cost; - float r_sm[16]; - float alpha; - float D_tmp[FOA_CHANNELS]; - int32_t ivas_total_brate; - float min_dot, dotl, dotr; - float min_dot2; - int16_t bypass_decision; - float dist_alt; - - ivas_total_brate = hEncoderConfig->ivas_total_brate; - - /* if PCA is disabled, just pass-through */ - if ( hEncoderConfig->Opt_PCA_ON == 0 ) - { - /* write by-pass indicator */ - push_next_indice( hMetaData, PCA_MODE_INACTIVE, 1 ); - - return; - } - - /* handle bitrate switching */ - if ( ivas_total_brate != PCA_BRATE ) - { - pca_enc_reset( hPCA ); - - if ( hEncoderConfig->last_ivas_total_brate != PCA_BRATE ) - { - eye_matrix( hPCA->mem_eigVec_interp, FOA_CHANNELS, 1.0f ); - /* copy input data into output directly as previous frame was already in by-pass mode */ - for ( k = 0; k < n_channels; k++ ) - { - // ToDo: TBV - } - } - else - { - /* set PCA by-pass mode in current frame and interpolate transform as previous frame used PCA */ - pca_enc_transform( hPCA, ql, qr, data_f, input_frame, n_channels ); - } - - pca_update_state( hPCA, ql, qr, eigVec, n_channels ); - - hPCA->prev_bypass_decision = PCA_MODE_INACTIVE; - - return; - } - - /*-----------------------------------------------------------------* - * Covariance - *-----------------------------------------------------------------*/ - - len_subfr = input_frame / 2; - - for ( i = 0; i < input_frame; i += len_subfr ) - { - for ( k = 0; k < FOA_CHANNELS; k++ ) - { - ptr_sig[k] = &data_f[k][i]; - } - - cov_subfr( ptr_sig, r, n_channels, input_frame / 2 ); - - alpha = IVAS_PCA_SM_FAC; - for ( k = 0; k < 16; k++ ) - { - r_sm[k] = alpha * r[k] + ( 1.f - alpha ) * hPCA->old_r_sm[k]; - hPCA->old_r_sm[k] = r_sm[k]; - } - } - - /* conditioning */ - for ( k = 0; k < FOA_CHANNELS; k++ ) - { - temp = r_sm[k * FOA_CHANNELS + k]; - - - if ( temp < IVAS_PCA_COV_THRES ) - { - temp = IVAS_PCA_COV_THRES; - } - r_sm[k * FOA_CHANNELS + k] = temp; /* pointer reuse */ - } - - /*-----------------------------------------------------------------* - * Eigenvalue decomposition - *-----------------------------------------------------------------*/ - - eig_qr( r_sm, IVAS_PCA_N_ITER_QR, eigVec, D, n_channels ); - - /* force positive eigenvalues */ - sum_D = 0.0; - for ( k = 0; k < n_channels; k++ ) - { - if ( D[k] < 0.f ) - { - D[k] = -D[k]; - - for ( l = 0; l < n_channels; l++ ) - { - eigVec[l * n_channels + k] = -eigVec[l * n_channels + k]; - } - } - sum_D += D[k]; - } - - /* normalize */ - fac_D = 1 / sum_D; - for ( k = 0; k < n_channels; k++ ) - { - D[k] *= fac_D; - } - - /* sorting (sanity check) with SPAR inversion of last two channels */ - sort4_D_eigVec( D, eigVec ); - - /* normalize and compute amount of decorrelation */ - dist_alt = 0.0; - for ( k = 0; k < FOA_CHANNELS; k++ ) - { - dist_alt += logf( r[k * FOA_CHANNELS + k] * fac_D + 1e-8f ); - dist_alt -= logf( D[k] + 1e-8f ); - } - - /*-----------------------------------------------------------------* - * Eigenvector alignment - *-----------------------------------------------------------------*/ - - if ( hPCA->prev_bypass_decision == PCA_MODE_ACTIVE ) - { - /* compute absolute cost matrix */ - for ( k = 0; k < n_channels; k++ ) /* column */ - { - for ( l = 0; l < n_channels; l++ ) /* row */ - { - fac_cost = hPCA->prev_D[l] * D[k]; - temp = 0.0; - for ( i = 0; i < n_channels; i++ ) /* row */ - { - temp += hPCA->prev_eigVec[i * n_channels + l] * eigVec[i * n_channels + k]; - } - if ( temp < 0 ) - { - temp = -temp; - } - cost_mtx[k * n_channels + l] = temp * fac_cost; - } - } - - /* find optimal permutation */ - exhst_4x4( cost_mtx, path, 1 ); - } - else - { - /* no alignment needed if previous PCA is inactive */ - for ( i = 0; i < 4; i++ ) - { - path[i] = i; - } - } - - /* permute eigenvectors */ - for ( k = 0; k < n_channels; k++ ) - { - j = path[k]; - /* copy j-th column to column k */ - for ( l = 0; l < n_channels; l++ ) - { - eigVec_tmp[l * n_channels + k] = eigVec[l * n_channels + j]; - } - D_tmp[k] = D[j]; - } - - for ( k = 0; k < n_channels * n_channels; k++ ) - { - eigVec[k] = eigVec_tmp[k]; - } - - /* check for sign inversions */ - for ( k = 0; k < n_channels; k++ ) /* column */ - { - temp = 0.0; - for ( i = 0; i < n_channels; i++ ) /* row */ - { - temp += hPCA->prev_eigVec[i * n_channels + k] * eigVec[i * n_channels + k]; - } - - if ( temp < 0 ) - { - for ( i = 0; i < n_channels; i++ ) - { - eigVec[i * n_channels + k] = -eigVec[i * n_channels + k]; - } - } - } - - /* force rotation matrix(det = +1) */ - det = mat_det4( eigVec ); - if ( det < 0 ) - { - swap_eigvec( eigVec, 2, 3 ); - temp = D_tmp[3]; - D_tmp[3] = D_tmp[2]; - D_tmp[2] = temp; - } - - /* update state */ - for ( k = 0; k < n_channels; k++ ) - { - hPCA->prev_D[k] = D_tmp[k]; - } - - /*-----------------------------------------------------------------* - * Rotation matrix parametrization and quantization - *-----------------------------------------------------------------*/ - - /* convert frrm rotation matrix to double quaternion */ - mat2dquat( eigVec, ql, qr ); - - dotl = dotp( hPCA->prev_ql, ql, 4 ); - dotr = dotp( hPCA->prev_qr, qr, 4 ); - if ( dotl < dotr ) - { - min_dot = dotl; - } - else - { - min_dot = dotr; - } - - if ( ql[0] < qr[0] ) - { - min_dot2 = ql[0]; - } - else - { - min_dot2 = qr[0]; - } - - bypass_decision = PCA_MODE_ACTIVE; - if ( dist_alt < IVAS_PCA_THRES_DIST_ALT ) - { - bypass_decision = PCA_MODE_INACTIVE; - } - if ( min_dot < IVAS_PCA_THRES_MIN_DOT ) - { - bypass_decision = PCA_MODE_INACTIVE; - } - if ( min_dot2 < IVAS_PCA_THRES_MIN_DOT2 ) - { - bypass_decision = PCA_MODE_INACTIVE; - } - - /* if PCA is inactive */ - if ( bypass_decision == PCA_MODE_INACTIVE ) - { - eye_matrix( eigVec, 4, 1. ); - set_zero( ql, 4 ); - set_zero( qr, 4 ); - ql[0] = 1.; - qr[0] = 1.; - - /* write by-pass indicator */ - push_next_indice( hMetaData, PCA_MODE_INACTIVE, 1 ); - if ( hPCA->prev_bypass_decision == PCA_MODE_INACTIVE ) - { - eye_matrix( hPCA->mem_eigVec_interp, FOA_CHANNELS, 1.0f ); - } - else - { - /* set PCA by-pass mode in current frame and interpolate transform as previous frame used PCA */ - pca_enc_transform( hPCA, ql, qr, data_f, input_frame, n_channels ); - } - - pca_update_state( hPCA, ql, qr, eigVec, n_channels ); - hPCA->prev_bypass_decision = PCA_MODE_INACTIVE; - - return; - } - - /* force ql to have first component with positive sign */ - if ( ql[0] < 0 ) - { - for ( i = 0; i < 4; i++ ) - { - ql[i] = -ql[i]; - qr[i] = -qr[i]; - } - } - - /* quantize double quaternion */ - pca_enc_s3( ql, &index[0] ); - pca_enc_s3( qr, &index[1] ); - - /* write bypass flag to bitstream to indicate active mode */ - push_next_indice( hMetaData, PCA_MODE_ACTIVE, 1 ); - - ivas_bitstream_write_int32( hMetaData, index[0], IVAS_PCA_QBITS - 1 ); - ivas_bitstream_write_int32( hMetaData, index[1], IVAS_PCA_QBITS ); - - /* transform */ - pca_enc_transform( hPCA, ql, qr, data_f, input_frame, n_channels ); - - /*-----------------------------------------------------------------* - * update state for next frame - *-----------------------------------------------------------------*/ - - hPCA->prev_bypass_decision = bypass_decision; - pca_update_state( hPCA, ql, qr, eigVec, n_channels ); - - return; -} -#else void ivas_pca_enc_fx( const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ PCA_ENC_STATE *hPCA, /* i : PCA encoder structure */ @@ -1254,4 +743,3 @@ void ivas_pca_enc_fx( pca_update_state_fx( hPCA, ql_fx, qr_fx, eigVec_fx16, n_channels ); return; } -#endif diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 501c6796a..c1e8a4b42 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -221,7 +221,7 @@ ivas_error ivas_sba_enc_reconfigure( /* FB mixer handle */ IF( hDirAC->hFbMixer != NULL ) { - ivas_FB_mixer_close( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs, 0 ); + ivas_FB_mixer_close_fx( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs, 0 ); hDirAC->hFbMixer = NULL; } spar_reconfig_flag = 1; diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index af5829365..bb0a77866 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -53,7 +53,7 @@ * Local function prototypes *--------------------------------------------------------------------*/ -static ivas_error ivas_spar_enc_process( Encoder_Struct *st_ivas, const ENCODER_CONFIG_HANDLE hEncoderConfig, BSTR_ENC_HANDLE hMetaData, const int16_t front_vad_flag, float *data_f[] ); +static ivas_error ivas_spar_enc_process_fx( Encoder_Struct *st_ivas, const ENCODER_CONFIG_HANDLE hEncoderConfig, BSTR_ENC_HANDLE hMetaData, const Word16 front_vad_flag, Word32 *data_fx[], const Word16 q_data ); #if 0 static Word16 Q_factor_L_abs( float x ); #endif @@ -131,7 +131,7 @@ ivas_error ivas_spar_enc_open( table_idx = ivas_get_spar_table_idx_fx( ivas_total_brate, sba_order_internal, SPAR_CONFIG_BW, NULL, NULL ); /* MD handle */ - if ( ( error = ivas_spar_md_enc_open( &( hSpar->hMdEnc ), hEncoderConfig, sba_order_internal ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_md_enc_open_fx( &( hSpar->hMdEnc ), hEncoderConfig, sba_order_internal ) ) != IVAS_ERR_OK ) { return error; } @@ -145,7 +145,7 @@ ivas_error ivas_spar_enc_open( fb_cfg->remix_order = remix_order_set[hSpar->hMdEnc->spar_md_cfg.remix_unmix_order]; /* FB mixer handle */ - if ( ( error = ivas_FB_mixer_open( &( hSpar->hFbMixer ), input_Fs, fb_cfg, spar_reconfig_flag ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_FB_mixer_open_fx( &( hSpar->hFbMixer ), input_Fs, fb_cfg, spar_reconfig_flag ) ) != IVAS_ERR_OK ) { return error; } @@ -524,7 +524,7 @@ void ivas_spar_enc_close( assert( num_chans <= nchan_inp ); /* MD handle */ - ivas_spar_md_enc_close( &( *hSpar )->hMdEnc ); + ivas_spar_md_enc_close_fx( &( *hSpar )->hMdEnc ); /* Covar. State handle */ #ifdef IVAS_FLOAT_FIXED @@ -534,7 +534,7 @@ void ivas_spar_enc_close( #endif /* FB mixer handle */ - ivas_FB_mixer_close( &( *hSpar )->hFbMixer, input_Fs, spar_reconfig_flag ); + ivas_FB_mixer_close_fx( &( *hSpar )->hFbMixer, input_Fs, spar_reconfig_flag ); /* AGC */ #ifdef IVAS_FLOAT_FIXED @@ -629,13 +629,42 @@ ivas_error ivas_spar_enc( { ivas_sba_zero_vert_comp( data_f, st_ivas->sba_analysis_order, hEncoderConfig->sba_planar, input_frame ); } +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + Word32 data_fx_arr[MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; + Word32 *data_fx[MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS]; + Word16 i, q_data = Q11; + Word16 num_ch = ivas_sba_get_nchan_fx( st_ivas->sba_analysis_order, 0 ); /*planar input arg. deliberately set to zero since input always in ACN/SN3D*/ + for ( i = 0; i < num_ch; i++ ) + { + data_fx[i] = data_fx_arr[i]; + if ( data_f[i] != NULL ) + { + floatToFixed_arrL( data_f[i], data_fx[i], q_data, input_frame ); + } + } + FOR( i = 0; i < st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans; i++ ) + { + scale_sig32( st_ivas->hSpar->hFbMixer->ppFilterbank_prior_input_fx[i], st_ivas->hSpar->hFbMixer->fb_cfg->prior_input_length, sub( q_data, st_ivas->hSpar->hFbMixer->q_ppFilterbank_prior_input_fx[i] ) ); + st_ivas->hSpar->hFbMixer->q_ppFilterbank_prior_input_fx[i] = q_data; + } +#endif /* SPAR encoder */ - if ( ( error = ivas_spar_enc_process( st_ivas, hEncoderConfig, hMetaData, st_ivas->hSpar->front_vad_flag, data_f ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_spar_enc_process_fx( st_ivas, hEncoderConfig, hMetaData, st_ivas->hSpar->front_vad_flag, data_fx, q_data ) ), IVAS_ERR_OK ) ) { return error; } +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + for ( i = 0; i < num_ch; i++ ) + { + if ( data_f[i] != NULL ) + { + fixedToFloat_arrL( data_fx[i], data_f[i], q_data, input_frame ); + } + } +#endif + *nb_bits_metadata = hMetaData->nb_bits_tot; /* Force IVAS front pre-proc decision for higher bitrates */ @@ -654,7 +683,7 @@ ivas_error ivas_spar_enc( * Process call for SPAR covariance and MD encoder *-------------------------------------------------------------------*/ -static ivas_error ivas_spar_cov_md_process( +static ivas_error ivas_spar_cov_md_process_fx( const ENCODER_CONFIG_HANDLE hEncoderConfig, SPAR_ENC_HANDLE hSpar, const IVAS_QMETADATA_HANDLE hQMetaData, @@ -709,7 +738,7 @@ static ivas_error ivas_spar_cov_md_process( test(); IF( NE_32( hEncoderConfig->ivas_total_brate, hEncoderConfig->last_ivas_total_brate ) && !hSpar->spar_reconfig_flag ) { - IF( NE_32( ( error = ivas_spar_md_enc_init( hSpar->hMdEnc, hEncoderConfig, sba_order ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_spar_md_enc_init_fx( hSpar->hMdEnc, hEncoderConfig, sba_order ) ), IVAS_ERR_OK ) ) { return error; } @@ -934,49 +963,34 @@ static ivas_error ivas_spar_cov_md_process( *-----------------------------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -static ivas_error ivas_spar_enc_process( +static ivas_error ivas_spar_enc_process_fx( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ - const int16_t front_vad_flag, /* i : front-VAD decision */ - float *data_f[] /* i/o: input/transport audio channels */ -) + const Word16 front_vad_flag, /* i : front-VAD decision */ + Word32 *data_fx[], /* i/o: input/transport audio channels */ + const Word16 q_data ) { - float pcm_tmp[DIRAC_MAX_ANA_CHANS][L_FRAME48k * 2]; - float *p_pcm_tmp[DIRAC_MAX_ANA_CHANS]; -#ifdef IVAS_FLOAT_FIXED Word32 pcm_tmp_fx[DIRAC_MAX_ANA_CHANS][L_FRAME48k * 2]; Word32 *p_pcm_tmp_fx[DIRAC_MAX_ANA_CHANS]; - // Word16 q_pcm_tmp_fx[DIRAC_MAX_ANA_CHANS][L_FRAME48k * 2]; - // Word16 *q_p_pcm_tmp_fx[DIRAC_MAX_ANA_CHANS]; Word16 q_pcm_fx[DIRAC_MAX_ANA_CHANS]; -#endif -#ifdef IVAS_FLOAT_FIXED - // Word32 *ppIn_FR_real_fx[IVAS_SPAR_MAX_CH], *ppIn_FR_imag_fx[IVAS_SPAR_MAX_CH]; - // Word32 wyzx_del_buf_fx[FOA_CHANNELS][IVAS_FB_1MS_48K_SAMP]; - Word32 data_fix[MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; - Word16 q_data_fix[MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS]; - Word32 *data_fx[MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS]; - // Word16 q_cmplx[IVAS_SPAR_MAX_CH]; Word16 q_p_pcm_tmp_fx[DIRAC_MAX_ANA_CHANS]; -#endif - int16_t i, j, input_frame, dtx_vad; - int16_t transient_det[2]; - int16_t hodirac_flag; - int32_t ivas_total_brate, input_Fs; - int16_t nchan_inp, sba_order, nchan_transport; - int16_t in_out_mixer_map[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH]; + Word16 i, j, input_frame, dtx_vad; + Word16 transient_det[2]; + Word16 hodirac_flag; + Word32 ivas_total_brate, input_Fs; + Word16 nchan_inp, sba_order, nchan_transport; + Word16 in_out_mixer_map[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH]; ivas_error error; - const int16_t *order; + const Word16 *order; SPAR_ENC_HANDLE hSpar = st_ivas->hSpar; IVAS_QMETADATA_HANDLE hQMetaData = st_ivas->hQMetaData; - int16_t ts, l_ts, num_del_samples, b, i_ts; + Word16 ts, l_ts, num_del_samples, b, i_ts; - float *ppIn_FR_real[IVAS_SPAR_MAX_CH], *ppIn_FR_imag[IVAS_SPAR_MAX_CH]; Word32 *ppIn_FR_real_fx[IVAS_SPAR_MAX_CH], *ppIn_FR_imag_fx[IVAS_SPAR_MAX_CH]; - float wyzx_del_buf[FOA_CHANNELS][IVAS_FB_1MS_48K_SAMP]; - int16_t dyn_active_w_flag; - int16_t nchan_fb_in; + Word32 wyzx_del_buf[FOA_CHANNELS][IVAS_FB_1MS_48K_SAMP]; + Word16 dyn_active_w_flag; + Word16 nchan_fb_in; push_wmops( "ivas_spar_enc_process" ); @@ -985,43 +999,36 @@ static ivas_error ivas_spar_enc_process( *-----------------------------------------------------------------------------------------*/ error = IVAS_ERR_OK; + move32(); input_Fs = hEncoderConfig->input_Fs; + move32(); ivas_total_brate = hEncoderConfig->ivas_total_brate; + move32(); num_del_samples = hSpar->hFbMixer->fb_cfg->fb_latency; + move16(); - input_frame = (int16_t) ( input_Fs / FRAMES_PER_SEC ); - sba_order = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); -#ifndef IVAS_FLOAT_FIXED - nchan_inp = ivas_sba_get_nchan_metadata( sba_order, hEncoderConfig->ivas_total_brate ); -#else + Word32 res_dec, res_frac; + iDiv_and_mod_32( input_Fs, FRAMES_PER_SEC, &res_dec, &res_frac, 0 ); + input_frame = extract_l( res_dec ); + + sba_order = s_min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); nchan_inp = ivas_sba_get_nchan_metadata_fx( sba_order, hEncoderConfig->ivas_total_brate ); -#endif assert( nchan_inp <= hEncoderConfig->nchan_inp ); nchan_fb_in = hSpar->hFbMixer->fb_cfg->nchan_fb_in; + move16(); nchan_transport = st_ivas->nchan_transport; + move16(); - for ( i = FOA_CHANNELS + 1; i < nchan_fb_in; i++ ) + FOR( i = FOA_CHANNELS + 1; i < nchan_fb_in; i++ ) { - mvr2r( data_f[HOA_keep_ind[i]], data_f[i], input_frame ); + Copy32( data_fx[HOA_keep_ind[i]], data_fx[i], input_frame ); } - /*-----------------------------------------------------------------------------------------* * Transient detector *-----------------------------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED - { - // Word32 data_fix[L_FRAME48k]; - FOR( i = 0; i < input_frame; i++ ) - { - data_fix[0][i] = (Word32) ( data_f[0][i] * ( 1 << Q14 ) ); - } - ivas_transient_det_process_fx( hSpar->hTranDet, data_fix[0], input_frame, transient_det ); - } -#else - ivas_transient_det_process( hSpar->hTranDet, data_f[0], input_frame, transient_det ); -#endif + ivas_transient_det_process_fx( hSpar->hTranDet, data_fx[0], input_frame, transient_det ); #ifdef DEBUGGING { @@ -1032,125 +1039,50 @@ static ivas_error ivas_spar_enc_process( } #endif - if ( ivas_total_brate < IVAS_24k4 ) + if ( LT_32( ivas_total_brate, IVAS_24k4 ) ) { transient_det[1] = 0; + move16(); } /* store previous input samples for W in local buffer */ assert( num_del_samples <= IVAS_FB_1MS_48K_SAMP ); - if ( hSpar->hFbMixer->fb_cfg->active_w_mixing == 0 ) + IF( hSpar->hFbMixer->fb_cfg->active_w_mixing == 0 ) { /* fill delay (1 ms) buffer for all Transport channels */ - for ( i = 0; i < FOA_CHANNELS; i++ ) + FOR( i = 0; i < FOA_CHANNELS; i++ ) { - int16_t idx = hSpar->hFbMixer->fb_cfg->remix_order[i]; - mvr2r( &hSpar->hFbMixer->ppFilterbank_prior_input[idx][hSpar->hFbMixer->fb_cfg->prior_input_length - num_del_samples], wyzx_del_buf[idx], num_del_samples ); + Word16 idx = hSpar->hFbMixer->fb_cfg->remix_order[i]; + move16(); + Copy32( &hSpar->hFbMixer->ppFilterbank_prior_input_fx[idx][hSpar->hFbMixer->fb_cfg->prior_input_length - num_del_samples], wyzx_del_buf[idx], num_del_samples ); } } /*-----------------------------------------------------------------------------------------* * FB mixer ingest *-----------------------------------------------------------------------------------------*/ - - for ( i = 0; i < nchan_fb_in; i++ ) - { - p_pcm_tmp[i] = pcm_tmp[i]; - } - - FOR( i = 0; i < nchan_fb_in; i++ ) { - - p_pcm_tmp[i] = pcm_tmp[i]; -#ifdef IVAS_FLOAT_FIXED p_pcm_tmp_fx[i] = pcm_tmp_fx[i]; - move32(); -#endif } /* Need to remove flt to fix conversions */ -#ifdef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + ivas_fb_mixer_pcm_ingest_fx( hSpar->hFbMixer, data_fx, p_pcm_tmp_fx, input_frame, hSpar->hMdEnc->HOA_md_ind, q_data, q_p_pcm_tmp_fx ); FOR( i = 0; i < hSpar->hFbMixer->fb_cfg->num_in_chans; i++ ) { - hSpar->hFbMixer->q_ppFilterbank_prior_input_fx[i] = Q_factor_arrL( hSpar->hFbMixer->ppFilterbank_prior_input[i], hSpar->hFbMixer->fb_cfg->prior_input_length ); - - floatToFixed_arrL( hSpar->hFbMixer->ppFilterbank_prior_input[i], - hSpar->hFbMixer->ppFilterbank_prior_input_fx[i], hSpar->hFbMixer->q_ppFilterbank_prior_input_fx[i], hSpar->hFbMixer->fb_cfg->prior_input_length ); + /* changing q format to q_data*/ + scale_sig32( p_pcm_tmp_fx[i], input_frame, sub( q_data, q_p_pcm_tmp_fx[i] ) ); } - /* In order to get the number of channels */ - Word16 num_chs_alloc; - - IF( hSpar->hFbMixer->fb_cfg->active_w_mixing == -1 ) - { - num_chs_alloc = 0; - } - ELSE IF( hSpar->hFbMixer->fb_cfg->active_w_mixing ) - { - num_chs_alloc = hSpar->hFbMixer->fb_cfg->num_in_chans; - } - ELSE - { - num_chs_alloc = 1; /* only W channel processed for predicting YZX */ - } -#ifdef MSAN_FIX - FOR( Word16 m = 0; m < nchan_fb_in; m++ ) -#else - FOR( Word16 m = 0; m <= nchan_fb_in + nchan_transport; m++ ) -#endif - { - IF( data_f[m] != NULL ) - { - q_data_fix[m] = Q_factor_arrL( data_f[m], input_frame ); - floatToFixed_arrL( data_f[m], data_fix[m], q_data_fix[m], input_frame ); - data_fx[m] = data_fix[m]; - } - } -#endif - ivas_fb_mixer_pcm_ingest_fx( hSpar->hFbMixer, data_fx, p_pcm_tmp_fx, input_frame, hSpar->hMdEnc->HOA_md_ind, q_data_fix, q_p_pcm_tmp_fx ); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - FOR( i = 0; i < hSpar->hFbMixer->fb_cfg->num_in_chans; i++ ) - { - me2f_buf( p_pcm_tmp_fx[i], 31 - q_p_pcm_tmp_fx[i], p_pcm_tmp[i], input_frame * 2 ); - } - FOR( Word16 x = 0; x < num_chs_alloc; x++ ) - { - me2f_buf( p_pcm_tmp_fx[hSpar->hFbMixer->fb_cfg->remix_order[x]], 31 - q_p_pcm_tmp_fx[hSpar->hFbMixer->fb_cfg->remix_order[x]], p_pcm_tmp[hSpar->hFbMixer->fb_cfg->remix_order[x]], input_frame * 2 ); - - hSpar->hFbMixer->q_ppFilterbank_inFR_re_fx[hSpar->hFbMixer->fb_cfg->remix_order[x]] = q_p_pcm_tmp_fx[hSpar->hFbMixer->fb_cfg->remix_order[x]]; - hSpar->hFbMixer->q_ppFilterbank_inFR_im_fx[hSpar->hFbMixer->fb_cfg->remix_order[x]] = q_p_pcm_tmp_fx[hSpar->hFbMixer->fb_cfg->remix_order[x]]; - } - /* Need to remove fix to flt conversions */ -#endif -#else - ivas_fb_mixer_pcm_ingest( hSpar->hFbMixer, data_f, p_pcm_tmp, input_frame, hSpar->hMdEnc->HOA_md_ind ); -#endif /* prepare Parameter MDFT analysis */ -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( i = 0; i < nchan_fb_in; i++ ) - { - ppIn_FR_real[i] = p_pcm_tmp[i]; - ppIn_FR_imag[i] = p_pcm_tmp[i] + input_frame; - p_pcm_tmp[i] = data_f[i]; - } -#endif - - for ( i = 0; i < nchan_fb_in; i++ ) + FOR( i = 0; i < nchan_fb_in; i++ ) { ppIn_FR_real_fx[i] = p_pcm_tmp_fx[i]; ppIn_FR_imag_fx[i] = p_pcm_tmp_fx[i] + input_frame; p_pcm_tmp_fx[i] = data_fx[i]; } -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - FOR( i = 0; i < nchan_fb_in; i++ ) - { - floatToFixed_arrL( p_pcm_tmp[i], p_pcm_tmp_fx[i], Q14, input_frame ); - floatToFixed_arrL( hSpar->hFbMixer->ppFilterbank_prior_input[i], hSpar->hFbMixer->ppFilterbank_prior_input_fx[i], Q14, input_frame ); - } -#endif - l_ts = input_frame / MAX_PARAM_SPATIAL_SUBFRAMES; + l_ts = idiv1616( input_frame, MAX_PARAM_SPATIAL_SUBFRAMES ); + Word16 gb = find_guarded_bits_fx( l_ts ); FOR( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { @@ -1166,137 +1098,70 @@ static ivas_error ivas_spar_enc_process( } } -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - /*To be removed*/ - FOR( i = 0; i < nchan_fb_in; i++ ) - { - fixedToFloat_arrL( hSpar->hFbMixer->ppFilterbank_prior_input_fx[i], hSpar->hFbMixer->ppFilterbank_prior_input[i], Q14, input_frame ); - } - - for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) - { - for ( i = 0; i < nchan_fb_in; i++ ) - { - p_pcm_tmp_fx[i] -= l_ts; - ppIn_FR_real_fx[i] -= l_ts; - ppIn_FR_imag_fx[i] -= l_ts; - } - } - for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) - { - for ( int ch_idx = 0; ch_idx < nchan_fb_in; ch_idx++ ) - { - fixedToFloat_arrL( ppIn_FR_real_fx[ch_idx], ppIn_FR_real[ch_idx], Q14 - gb, l_ts ); - fixedToFloat_arrL( ppIn_FR_imag_fx[ch_idx], ppIn_FR_imag[ch_idx], Q14 - gb, l_ts ); - fixedToFloat_arrL( p_pcm_tmp_fx[ch_idx], p_pcm_tmp[ch_idx], Q14, l_ts ); - } - for ( i = 0; i < nchan_fb_in; i++ ) - { - p_pcm_tmp_fx[i] += l_ts; - ppIn_FR_real_fx[i] += l_ts; - ppIn_FR_imag_fx[i] += l_ts; - - p_pcm_tmp[i] += l_ts; - ppIn_FR_real[i] += l_ts; - ppIn_FR_imag[i] += l_ts; - } - } -#endif /* turn pointers back to the local buffer, needed for the following processing */ - for ( i = 0; i < nchan_fb_in; i++ ) - { - ppIn_FR_real[i] = pcm_tmp[i]; - ppIn_FR_imag[i] = pcm_tmp[i] + input_frame; - p_pcm_tmp[i] = pcm_tmp[i]; - } FOR( i = 0; i < nchan_fb_in; i++ ) { ppIn_FR_real_fx[i] = pcm_tmp_fx[i]; ppIn_FR_imag_fx[i] = pcm_tmp_fx[i] + input_frame; p_pcm_tmp_fx[i] = pcm_tmp_fx[i]; } - - dtx_vad = ( hEncoderConfig->Opt_DTX_ON == 1 ) ? front_vad_flag : 1; + IF( EQ_16( hEncoderConfig->Opt_DTX_ON, 1 ) ) + { + dtx_vad = front_vad_flag; + move16(); + } + ELSE + { + dtx_vad = 1; + move16(); + } /*-----------------------------------------------------------------------------------------* * DirAC encoding *-----------------------------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED hodirac_flag = ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order ); -#else - hodirac_flag = ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ); -#endif -#ifdef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - Word16 pcm_q; + /*Finding max possible q*/ Word16 pp_fr_q; - float max_val = 0.0f; - /* Find Q-factor */ - for ( i = 0; i < nchan_fb_in; i++ ) - { - for ( j = 0; j < input_frame; j++ ) - { - max_val = max( max_val, (float) fabs( data_f[i][j] ) ); - } - } - pcm_q = Q_factor_L( max_val ); - - max_val = 0; - for ( i = 0; i < nchan_fb_in; i++ ) - { - for ( j = 0; j < input_frame; j++ ) - { - max_val = max( max_val, (float) fabs( ppIn_FR_real[i][j] ) ); - max_val = max( max_val, (float) fabs( ppIn_FR_imag[i][j] ) ); - } - } - pp_fr_q = Q_factor_L( max_val ); - - Word32 fr_real_fx[DIRAC_MAX_ANA_CHANS][L_FRAME48k * 2]; - Word32 fr_imag_fx[DIRAC_MAX_ANA_CHANS][L_FRAME48k * 2]; - Word32 data_f_buf[DIRAC_MAX_ANA_CHANS][L_FRAME48k]; - Word32 *pp_fr_real_fx[DIRAC_MAX_ANA_CHANS]; - Word32 *pp_fr_imag_fx[DIRAC_MAX_ANA_CHANS]; - Word32 *data_f_fx[DIRAC_MAX_ANA_CHANS]; - for ( i = 0; i < nchan_fb_in; i++ ) + pp_fr_q = sub( q_data, gb ); + Word16 re_q = MAX_16, im_q = MAX_16, FR_q; + move16(); + move16(); + FOR( i = 0; i < nchan_fb_in; i++ ) { - data_f_fx[i] = data_f_buf[i]; - pp_fr_real_fx[i] = fr_real_fx[i]; - pp_fr_imag_fx[i] = fr_imag_fx[i]; - for ( j = 0; j < input_frame; j++ ) - { - data_f_fx[i][j] = float_to_fix( data_f[i][j], pcm_q ); - pp_fr_real_fx[i][j] = float_to_fix( ppIn_FR_real[i][j], pp_fr_q ); - pp_fr_imag_fx[i][j] = float_to_fix( ppIn_FR_imag[i][j], pp_fr_q ); - } + re_q = s_min( re_q, L_norm_arr( ppIn_FR_real_fx[i], input_frame ) ); + im_q = s_min( im_q, L_norm_arr( ppIn_FR_imag_fx[i], input_frame ) ); } -#endif - IF( ( error = ivas_dirac_enc_fx( st_ivas->hDirAC, hQMetaData, hMetaData, data_f_fx, pp_fr_real_fx, pp_fr_imag_fx, pp_fr_q, input_frame, dtx_vad, hEncoderConfig->ivas_format, hodirac_flag ) ) != IVAS_ERR_OK ) + FR_q = s_min( re_q, im_q ); + FOR( i = 0; i < nchan_fb_in; i++ ) { - return error; + scale_sig32( ppIn_FR_real_fx[i], input_frame, FR_q ); + scale_sig32( ppIn_FR_imag_fx[i], input_frame, FR_q ); } -#else + pp_fr_q = add( FR_q, pp_fr_q ); - if ( ( error = ivas_dirac_enc( st_ivas->hDirAC, hQMetaData, hMetaData, data_f, ppIn_FR_real, ppIn_FR_imag, input_frame, dtx_vad, hEncoderConfig->ivas_format, hodirac_flag ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_dirac_enc_fx( st_ivas->hDirAC, hQMetaData, hMetaData, data_fx, ppIn_FR_real_fx, ppIn_FR_imag_fx, pp_fr_q, input_frame, dtx_vad, hEncoderConfig->ivas_format, hodirac_flag ) ), IVAS_ERR_OK ) ) { return error; } -#endif /* Set Energy Ratio to 0.0 if the mono flag has been set */ - if ( hQMetaData->dirac_mono_flag ) + IF( hQMetaData->dirac_mono_flag ) { - for ( b = hQMetaData->q_direction->cfg.start_band; b < hQMetaData->q_direction->cfg.nbands; b++ ) + FOR( b = hQMetaData->q_direction->cfg.start_band; b < hQMetaData->q_direction->cfg.nbands; b++ ) { - for ( i_ts = 0; i_ts < ( ( dtx_vad == 1 ) ? hQMetaData->q_direction[0].cfg.nblocks : 1 ); i_ts++ ) + Word16 loop_count = 1; + move16(); + IF( EQ_16( dtx_vad, 1 ) ) + { + loop_count = hQMetaData->q_direction[0].cfg.nblocks; + move16(); + } + FOR( i_ts = 0; i_ts < loop_count; i_ts++ ) { -#ifndef IVAS_FLOAT_FIXED - hQMetaData->q_direction[0].band_data[b].energy_ratio[i_ts] = 0.0f; -#else hQMetaData->q_direction[0].band_data[b].energy_ratio_fx[i_ts] = 0; -#endif + move32(); } } } @@ -1304,15 +1169,7 @@ static ivas_error ivas_spar_enc_process( /*-----------------------------------------------------------------------------------------* * Covariance and MD processing *-----------------------------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( int ch_idx = 0; ch_idx < nchan_fb_in; ch_idx++ ) - { - floatToFixed_arrL32( ppIn_FR_real[ch_idx], ppIn_FR_real_fx[ch_idx], Q14 - gb, input_frame ); - floatToFixed_arrL32( ppIn_FR_imag[ch_idx], ppIn_FR_imag_fx[ch_idx], Q14 - gb, input_frame ); - } -#endif - - if ( ( error = ivas_spar_cov_md_process( hEncoderConfig, st_ivas->hSpar, st_ivas->hQMetaData, hMetaData, nchan_inp, sba_order, ppIn_FR_real_fx, ppIn_FR_imag_fx, transient_det, dtx_vad, nchan_transport, &dyn_active_w_flag, Q14 - gb ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_spar_cov_md_process_fx( hEncoderConfig, st_ivas->hSpar, st_ivas->hQMetaData, hMetaData, nchan_inp, sba_order, ppIn_FR_real_fx, ppIn_FR_imag_fx, transient_det, dtx_vad, nchan_transport, &dyn_active_w_flag, pp_fr_q ) ), IVAS_ERR_OK ) ) { return error; } @@ -1321,7 +1178,7 @@ static ivas_error ivas_spar_enc_process( * FB mixer *-----------------------------------------------------------------------------------------*/ - ivas_fb_mixer_get_in_out_mapping( hSpar->hFbMixer->fb_cfg, in_out_mixer_map ); + ivas_fb_mixer_get_in_out_mapping_fx( hSpar->hFbMixer->fb_cfg, in_out_mixer_map ); #ifdef DEBUG_SPAR_DIRAC_WRITE_OUT_PRED_PARS { @@ -1334,142 +1191,77 @@ static ivas_error ivas_spar_enc_process( fprintf( fid, "%.6f\n", hSpar->hMdEnc->mixer_mat[1][0][band] ); } #endif -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - Word16 q_p_pcm_tmp_loc_fx[DIRAC_MAX_ANA_CHANS]; -#endif - // both mixer_mat_fx and prior mixer_mat_fx should have a common q as there are values being copied inside function - // or need to do loop for updating values for unused values - ivas_fb_mixer_process( hSpar->hFbMixer, hSpar->hMdEnc->mixer_mat_fx, &hSpar->hMdEnc->q_mixer_mat_fx, p_pcm_tmp_fx, q_p_pcm_tmp_loc_fx, input_frame, in_out_mixer_map ); + ivas_fb_mixer_process_fx( hSpar->hFbMixer, hSpar->hMdEnc->mixer_mat_fx, &hSpar->hMdEnc->q_mixer_mat_fx, p_pcm_tmp_fx, q_p_pcm_tmp_fx, input_frame, in_out_mixer_map ); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( int ch = ( hSpar->hFbMixer->fb_cfg->active_w_mixing == 0 ); ch < hSpar->hFbMixer->fb_cfg->num_out_chans; ch++ ) + FOR( Word32 ch = ( hSpar->hFbMixer->fb_cfg->active_w_mixing == 0 ); ch < hSpar->hFbMixer->fb_cfg->num_out_chans; ch++ ) { - for ( int k = 0; k < input_frame; k++ ) - { - p_pcm_tmp[ch][k] = (float) fixedToFloat( p_pcm_tmp_fx[ch][k], q_p_pcm_tmp_loc_fx[ch] ); - } + /* changing q format to q_data*/ + scale_sig32( p_pcm_tmp_fx[ch], input_frame, sub( q_data, q_p_pcm_tmp_fx[ch] ) ); + q_p_pcm_tmp_fx[ch] = q_data; + move16(); } -#endif - if ( hSpar->hFbMixer->fb_cfg->active_w_mixing == 0 ) + IF( hSpar->hFbMixer->fb_cfg->active_w_mixing == 0 ) { - /*cross fade between new active W channels and old passive W channel*/ - if ( dyn_active_w_flag == 1 ) + IF( EQ_16( dyn_active_w_flag, 1 ) ) { - if ( hSpar->hMdEnc->spar_md.prior_dyn_active_w_flag != dyn_active_w_flag ) + IF( NE_16( hSpar->hMdEnc->spar_md.prior_dyn_active_w_flag, dyn_active_w_flag ) ) { - float new_w[L_FRAME48k]; - Word32 new_w_fx[L_FRAME48k]; + Word32 new_w[L_FRAME48k]; /* delayed W */ - mvr2r( wyzx_del_buf[0], p_pcm_tmp[0], num_del_samples ); - mvr2r( data_f[0], p_pcm_tmp[0] + num_del_samples, input_frame - num_del_samples ); + Copy32( wyzx_del_buf[0], p_pcm_tmp_fx[0], num_del_samples ); + Copy32( data_fx[0], p_pcm_tmp_fx[0] + num_del_samples, sub( input_frame, num_del_samples ) ); - mvr2r( wyzx_del_buf[hSpar->hMdEnc->spar_md.res_ind], new_w, num_del_samples ); - mvr2r( data_f[hSpar->hMdEnc->spar_md.res_ind], &new_w[num_del_samples], input_frame - num_del_samples ); + Copy32( wyzx_del_buf[hSpar->hMdEnc->spar_md.res_ind], new_w, num_del_samples ); + Copy32( data_fx[hSpar->hMdEnc->spar_md.res_ind], &new_w[num_del_samples], sub( input_frame, num_del_samples ) ); - if ( hSpar->hMdEnc->spar_md.prior_dyn_active_w_flag == 0 && dyn_active_w_flag == 1 ) + test(); + test(); + IF( hSpar->hMdEnc->spar_md.prior_dyn_active_w_flag == 0 && EQ_16( dyn_active_w_flag, 1 ) ) { -#ifndef IVAS_FLOAT_FIXED - ivas_fb_mixer_cross_fading( hSpar->hFbMixer, p_pcm_tmp, p_pcm_tmp[0], new_w, 0, input_frame, 0 ); -#else -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - floatToFixed_arrL32( new_w, new_w_fx, Q11, input_frame ); - FOR( i = 0; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) - { - p_pcm_tmp_fx[i] = &pcm_tmp_fx[i][0]; - floatToFixed_arrL32( p_pcm_tmp[i], p_pcm_tmp_fx[i], Q11, input_frame ); - } -#endif - ivas_fb_mixer_cross_fading_fx( hSpar->hFbMixer, p_pcm_tmp_fx, p_pcm_tmp_fx[0], new_w_fx, 0, input_frame, 0 ); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - FOR( i = 0; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) - { - fixedToFloat_arrL32( p_pcm_tmp_fx[i], p_pcm_tmp[i], Q11, input_frame ); - } -#endif -#endif + ivas_fb_mixer_cross_fading_fx( hSpar->hFbMixer, p_pcm_tmp_fx, p_pcm_tmp_fx[0], new_w, 0, input_frame, 0 ); } - else if ( hSpar->hMdEnc->spar_md.prior_dyn_active_w_flag == 1 && dyn_active_w_flag == 0 ) + ELSE IF( EQ_16( hSpar->hMdEnc->spar_md.prior_dyn_active_w_flag, 1 ) && dyn_active_w_flag == 0 ) { -#ifndef IVAS_FLOAT_FIXED - ivas_fb_mixer_cross_fading( hSpar->hFbMixer, p_pcm_tmp, new_w, p_pcm_tmp[0], 0, input_frame, 0 ); -#else -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - floatToFixed_arrL32( new_w, new_w_fx, Q11, input_frame ); - FOR( i = 0; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) - { - p_pcm_tmp_fx[i] = &pcm_tmp_fx[i][0]; - floatToFixed_arrL32( p_pcm_tmp[i], p_pcm_tmp_fx[i], Q11, input_frame ); - } -#endif - ivas_fb_mixer_cross_fading_fx( hSpar->hFbMixer, p_pcm_tmp_fx, new_w_fx, p_pcm_tmp_fx[0], 0, input_frame, 0 ); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - FOR( i = 0; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) - { - fixedToFloat_arrL32( p_pcm_tmp_fx[i], p_pcm_tmp[i], Q11, input_frame ); - } -#endif -#endif + ivas_fb_mixer_cross_fading_fx( hSpar->hFbMixer, p_pcm_tmp_fx, new_w, p_pcm_tmp_fx[0], 0, input_frame, 0 ); } } - else + ELSE { - mvr2r( wyzx_del_buf[hSpar->hMdEnc->spar_md.res_ind], p_pcm_tmp[0], num_del_samples ); - mvr2r( data_f[hSpar->hMdEnc->spar_md.res_ind], p_pcm_tmp[0] + num_del_samples, input_frame - num_del_samples ); + Copy32( wyzx_del_buf[hSpar->hMdEnc->spar_md.res_ind], p_pcm_tmp_fx[0], num_del_samples ); + Copy32( data_fx[hSpar->hMdEnc->spar_md.res_ind], p_pcm_tmp_fx[0] + num_del_samples, sub( input_frame, num_del_samples ) ); } } - else + ELSE { /* delayed W */ - mvr2r( wyzx_del_buf[0], p_pcm_tmp[0], num_del_samples ); - mvr2r( data_f[0], p_pcm_tmp[0] + num_del_samples, input_frame - num_del_samples ); + Copy32( wyzx_del_buf[0], p_pcm_tmp_fx[0], num_del_samples ); + Copy32( data_fx[0], p_pcm_tmp_fx[0] + num_del_samples, sub( input_frame, num_del_samples ) ); } - for ( i = 1; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) + FOR( i = 1; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) { - int16_t idx = hSpar->hFbMixer->fb_cfg->remix_order[i]; + Word16 idx = hSpar->hFbMixer->fb_cfg->remix_order[i]; + move16(); /* delayed, reorderd and accumulated with (negative) prediction from W */ - v_add( wyzx_del_buf[idx], p_pcm_tmp[i], p_pcm_tmp[i], num_del_samples ); - v_add( data_f[idx], p_pcm_tmp[i] + num_del_samples, p_pcm_tmp[i] + num_del_samples, input_frame - num_del_samples ); + v_add_fx( wyzx_del_buf[idx], p_pcm_tmp_fx[i], p_pcm_tmp_fx[i], num_del_samples ); + v_add_fx( data_fx[idx], p_pcm_tmp_fx[i] + num_del_samples, p_pcm_tmp_fx[i] + num_del_samples, sub( input_frame, num_del_samples ) ); } } - /*-----------------------------------------------------------------------------------------* * PCA encoder *-----------------------------------------------------------------------------------------*/ - if ( hSpar->hPCA != NULL ) + IF( hSpar->hPCA != NULL ) { -#ifdef IVAS_FLOAT_FIXED - FOR( i = 0; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) - { - p_pcm_tmp_fx[i] = &pcm_tmp_fx[i][0]; - q_pcm_fx[i] = Q11; - FOR( j = 0; j < input_frame; j++ ) - { - p_pcm_tmp_fx[i][j] = float_to_fix( p_pcm_tmp[i][j], q_pcm_fx[i] ); - } - } - ivas_pca_enc_fx( hEncoderConfig, hSpar->hPCA, hMetaData, p_pcm_tmp_fx, input_frame, FOA_CHANNELS ); - FOR( i = 0; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) - { - p_pcm_tmp_fx[i] = &pcm_tmp_fx[i][0]; - q_pcm_fx[i] = Q11; - FOR( j = 0; j < input_frame; j++ ) - { - p_pcm_tmp[i][j] = fix_to_float( p_pcm_tmp_fx[i][j], q_pcm_fx[i] ); - } - } -#else - ivas_pca_enc( hEncoderConfig, hSpar->hPCA, hMetaData, p_pcm_tmp, input_frame, FOA_CHANNELS ); -#endif } - else + ELSE { - if ( ivas_total_brate == PCA_BRATE && sba_order == SBA_FOA_ORDER ) + test(); + IF( EQ_32( ivas_total_brate, PCA_BRATE ) && EQ_16( sba_order, SBA_FOA_ORDER ) ) { /* write PCA bypass bit */ push_next_indice( hMetaData, PCA_MODE_INACTIVE, 1 ); @@ -1481,33 +1273,24 @@ static ivas_error ivas_spar_enc_process( * AGC *-----------------------------------------------------------------------------------------*/ - if ( dtx_vad == 1 ) + IF( EQ_16( dtx_vad, 1 ) ) { - if ( hSpar->AGC_Enable != 0 ) + IF( hSpar->AGC_Enable != 0 ) { -#ifdef IVAS_FLOAT_FIXED FOR( i = 0; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) { - p_pcm_tmp_fx[i] = &pcm_tmp_fx[i][0]; - q_pcm_fx[i] = Q_factor_arrL( &p_pcm_tmp[i][0], input_frame ); - FOR( j = 0; j < input_frame; j++ ) - { - p_pcm_tmp_fx[i][j] = float_to_fix( p_pcm_tmp[i][j], q_pcm_fx[i] ); - } + q_pcm_fx[i] = q_data; + move16(); } ivas_agc_enc_process_fx( hSpar->hAgcEnc, hMetaData, p_pcm_tmp_fx, p_pcm_tmp_fx, hSpar->hFbMixer->fb_cfg->num_out_chans, hEncoderConfig, q_pcm_fx ); FOR( i = 0; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) { - FOR( j = 0; j < input_frame; j++ ) - { - p_pcm_tmp[i][j] = fix_to_float( p_pcm_tmp_fx[i][j], q_pcm_fx[i] ); - } + scale_sig32( p_pcm_tmp_fx[i], input_frame, sub( q_data, q_pcm_fx[i] ) ); + q_pcm_fx[i] = q_data; + move16(); } -#else - ivas_agc_enc_process( hSpar->hAgcEnc, hMetaData, p_pcm_tmp, p_pcm_tmp, hSpar->hFbMixer->fb_cfg->num_out_chans, hEncoderConfig ); -#endif } } @@ -1517,24 +1300,26 @@ static ivas_error ivas_spar_enc_process( *-----------------------------------------------------------------------------------------*/ order = remix_order_set[hSpar->hMdEnc->spar_md_cfg.remix_unmix_order]; + move16(); - for ( j = 0; j < nchan_transport; j++ ) + FOR( j = 0; j < nchan_transport; j++ ) { - if ( st_ivas->nchan_transport < 3 ) + IF( LT_16( st_ivas->nchan_transport, 3 ) ) { - mvr2r( p_pcm_tmp[j], data_f[j], input_frame ); + Copy32( p_pcm_tmp_fx[j], data_fx[j], input_frame ); } - else + ELSE { - mvr2r( p_pcm_tmp[j], data_f[order[j]], input_frame ); + Copy32( p_pcm_tmp_fx[j], data_fx[order[j]], input_frame ); } } - for ( ; j < IVAS_SPAR_MAX_DMX_CHS; j++ ) + FOR( ; j < IVAS_SPAR_MAX_DMX_CHS; j++ ) { - set_f( data_f[order[j]], 0.0f, input_frame ); + set32_fx( data_fx[order[j]], 0, input_frame ); } hSpar->hMdEnc->spar_md.prior_dyn_active_w_flag = dyn_active_w_flag; + move16(); pop_wmops(); diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 11c2007a1..2c75c4f98 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -97,9 +97,10 @@ static int16_t ivas_get_arith_coded_bs( ivas_spar_md_enc_state_t *hMdEnc, BSTR_E #endif -static void ivas_spar_set_enc_config( ivas_spar_md_enc_state_t *hMdEnc, int16_t *max_freq_per_chan, const int16_t nchan_transport, float *pFC, const int16_t nchan_inp ); #ifdef IVAS_FLOAT_FIXED static void ivas_spar_set_enc_config_fx( ivas_spar_md_enc_state_t *hMdEnc, Word16 *max_freq_per_chan, const Word16 nchan_transport, Word32 *pFC, const Word16 nchan_inp ); +#else +static void ivas_spar_set_enc_config( ivas_spar_md_enc_state_t *hMdEnc, int16_t *max_freq_per_chan, const int16_t nchan_transport, float *pFC, const int16_t nchan_inp ); #endif // IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED @@ -285,27 +286,27 @@ ivas_error ivas_spar_md_enc_open_fx( *------------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -void ivas_spar_md_enc_close( +void ivas_spar_md_enc_close_fx( ivas_spar_md_enc_state_t **hMdEnc_in /* i/o: SPAR MD encoder handle */ ) { - int16_t num_channels, i, j; + Word16 num_channels, i, j; ivas_spar_md_enc_state_t *hMdEnc; - if ( hMdEnc_in == NULL || *hMdEnc_in == NULL ) + IF( hMdEnc_in == NULL || *hMdEnc_in == NULL ) { return; } hMdEnc = *hMdEnc_in; num_channels = hMdEnc->num_umx_ch; + move16(); - if ( hMdEnc->spar_md.band_coeffs != NULL ) + IF( hMdEnc->spar_md.band_coeffs != NULL ) { free( hMdEnc->spar_md.band_coeffs ); hMdEnc->spar_md.band_coeffs = NULL; } -#ifdef IVAS_FLOAT_FIXED IF( hMdEnc->mixer_mat_fx != NULL ) { FOR( i = 0; i < num_channels; i++ ) @@ -318,7 +319,6 @@ void ivas_spar_md_enc_close( } free( hMdEnc->mixer_mat_fx ); } -#endif free( *hMdEnc_in ); *hMdEnc_in = NULL; @@ -387,6 +387,7 @@ void ivas_spar_md_enc_close( * SPAR MD encoder initialization *-----------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_spar_md_enc_init( ivas_spar_md_enc_state_t *hMdEnc, /* o : MD encoder handle */ const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ @@ -398,15 +399,10 @@ ivas_error ivas_spar_md_enc_init( float PR_minmax[2]; int16_t num_channels, i, j, k; -#ifndef IVAS_FLOAT_FIXED ivas_sba_get_spar_hoa_md_flag( sba_order, hEncoderConfig->ivas_total_brate, &hMdEnc->spar_hoa_md_flag, &hMdEnc->spar_hoa_dirac2spar_md_flag ); num_channels = ivas_sba_get_nchan_metadata( sba_order, hEncoderConfig->ivas_total_brate ); ivas_sba_get_spar_hoa_ch_ind( num_channels, hEncoderConfig->ivas_total_brate, hMdEnc->HOA_md_ind ); -#else - ivas_sba_get_spar_hoa_md_flag_fx( sba_order, hEncoderConfig->ivas_total_brate, &hMdEnc->spar_hoa_md_flag, &hMdEnc->spar_hoa_dirac2spar_md_flag ); - num_channels = ivas_sba_get_nchan_metadata_fx( sba_order, hEncoderConfig->ivas_total_brate ); - ivas_sba_get_spar_hoa_ch_ind_fx( num_channels, hEncoderConfig->ivas_total_brate, hMdEnc->HOA_md_ind ); -#endif + table_idx = ivas_get_spar_table_idx( hEncoderConfig->ivas_total_brate, sba_order, SPAR_CONFIG_BW, NULL, NULL ); hMdEnc->spar_md.prior_dyn_active_w_flag = 0; @@ -427,13 +423,8 @@ ivas_error ivas_spar_md_enc_init( return IVAS_ERR_INTERNAL; } -#ifndef IVAS_FLOAT_FIXED ivas_spar_arith_coeffs_com_init( &hMdEnc->arith_coeffs, &hMdEnc->spar_md_cfg, table_idx, ENC ); ivas_spar_huff_coeffs_com_init( &hMdEnc->huff_coeffs, NULL, table_idx, ENC ); -#else - ivas_spar_arith_coeffs_com_init_fx( &hMdEnc->arith_coeffs, &hMdEnc->spar_md_cfg, table_idx, ENC ); - ivas_spar_huff_coeffs_com_init_fx( &hMdEnc->huff_coeffs, NULL, table_idx, ENC ); -#endif if ( hEncoderConfig->Opt_DTX_ON == 1 ) { @@ -468,7 +459,7 @@ ivas_error ivas_spar_md_enc_init( return IVAS_ERR_OK; } -#ifdef IVAS_FLOAT_FIXED +#else ivas_error ivas_spar_md_enc_init_fx( ivas_spar_md_enc_state_t *hMdEnc, /* o : MD encoder handle */ const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ @@ -557,6 +548,7 @@ ivas_error ivas_spar_md_enc_init_fx( * Set configuration for SPAR MD encoder *-----------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static void ivas_spar_set_enc_config( ivas_spar_md_enc_state_t *hMdEnc, int16_t *max_freq_per_chan, @@ -598,7 +590,7 @@ static void ivas_spar_set_enc_config( return; } -#ifdef IVAS_FLOAT_FIXED +#else static void ivas_spar_set_enc_config_fx( ivas_spar_md_enc_state_t *hMdEnc, Word16 *max_freq_per_chan, @@ -735,7 +727,7 @@ static void ivas_band_mixing_fx( * *-----------------------------------------------------------------------------------------*/ -static void write_metadata_buffer( +static void write_metadata_buffer_fx( BSTR_ENC_HANDLE hMetaData_tmp, BSTR_ENC_HANDLE hMetaData, const Word16 bit_pos_start, @@ -1170,7 +1162,7 @@ ivas_error ivas_spar_md_enc_process_fx( test(); IF( EQ_16( hMetaData->nb_bits_tot, bit_pos_start ) || LT_16( hMetaData_tmp.nb_bits_tot, sub( hMetaData->nb_bits_tot, bit_pos_start ) ) ) { - write_metadata_buffer( &hMetaData_tmp, hMetaData, bit_pos_start, next_ind_start ); + write_metadata_buffer_fx( &hMetaData_tmp, hMetaData, bit_pos_start, next_ind_start ); code_strat = strat; move16(); } diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 84b5fa9cb..e154ab7ca 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -491,8 +491,8 @@ typedef struct stereo_td_enc_data_structure Word16 tdm_lp_reuse_flag; /* Flag that indicate if it is possible to reuse the LP coefficient from the primary channel or not */ Word16 tdm_low_rate_mode; /* secondary channel low rate mode flag */ - float tdm_Pri_pitch_buf[NB_SUBFR]; #ifndef IVAS_FLOAT_FIXED + float tdm_Pri_pitch_buf[NB_SUBFR]; float tdm_lt_corr_RM; /* Long term right-mono correlation */ float tdm_lt_corr_LM; /* Long term left-mono correlation */ float tdm_last_diff_lt_corr; /* long term correlation difference mem */ @@ -954,9 +954,9 @@ typedef struct ivas_dirac_enc_data_structure float **direction_vector[DIRAC_NUM_DIMS]; float diffuseness_m[DIRAC_MAX_NBANDS]; #endif - int16_t band_grouping[DIRAC_MAX_NBANDS + 1]; - int16_t block_grouping[5]; - int16_t firstrun_sector_params; + Word16 band_grouping[DIRAC_MAX_NBANDS + 1]; + Word16 block_grouping[5]; + Word16 firstrun_sector_params; #ifdef IVAS_FLOAT_FIXED Word32 sec_I_vec_smth_x_fx[NUM_ANA_SECTORS][IVAS_MAX_NUM_BANDS]; @@ -984,8 +984,8 @@ typedef struct ivas_dirac_enc_data_structure /* diffuseness */ - int16_t index_buffer_intensity; - int16_t no_col_avg_diff; + Word16 index_buffer_intensity; + Word16 no_col_avg_diff; #ifdef IVAS_FLOAT_FIXED Word32 **buffer_intensity_real_fx[DIRAC_NUM_DIMS]; Word16 buffer_intensity_real_q[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF][DIRAC_MAX_NBANDS]; @@ -997,7 +997,7 @@ typedef struct ivas_dirac_enc_data_structure #endif /* Frame count for detecting mono */ - int16_t mono_frame_count; + Word16 mono_frame_count; } DIRAC_ENC_DATA, *DIRAC_ENC_HANDLE; @@ -1085,14 +1085,6 @@ typedef struct ivas_spar_md_enc_state_t typedef struct { Word16 prev_bypass_decision; -#ifndef IVAS_FLOAT_FIXED - float prev_eigVec[FOA_CHANNELS * FOA_CHANNELS]; - float prev_ql[IVAS_PCA_INTERP]; - float prev_qr[IVAS_PCA_INTERP]; - float prev_D[IVAS_PCA_INTERP]; - float mem_eigVec_interp[FOA_CHANNELS * FOA_CHANNELS]; - float old_r_sm[FOA_CHANNELS * FOA_CHANNELS]; -#else Word16 prev_eigVec_fx[FOA_CHANNELS * FOA_CHANNELS]; // Q15 Word16 prev_ql_fx[IVAS_PCA_INTERP]; // Q15 Word16 prev_qr_fx[IVAS_PCA_INTERP]; // Q15 @@ -1100,7 +1092,6 @@ typedef struct Word16 mem_eigVec_interp_fx[FOA_CHANNELS * FOA_CHANNELS]; // Q15 Word32 old_r_sm_fx[FOA_CHANNELS * FOA_CHANNELS]; // old_r_sm_q Word16 old_r_sm_q; -#endif } PCA_ENC_STATE; diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c index 5cb71c096..c8c0fdc95 100644 --- a/lib_enc/ivas_stereo_switching_enc.c +++ b/lib_enc/ivas_stereo_switching_enc.c @@ -681,9 +681,6 @@ ivas_error stereo_memory_enc_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX variables\n" ) ); } } -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - floatToFixed_arr( st->lsp_old1, st->lsp_old1_fx, Q15, M ); -#endif dtx_enc_init_fx( st, 0, FIXED_SID_RATE ); IF( st->hTdCngEnc != NULL ) diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index 8a73b6616..d007e50a5 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -470,11 +470,6 @@ void stereo_tcx_core_enc( floatToFixed_arrL( st->Bin_E_old, st->Bin_E_old_fx, q_comm_Bin, 128 ); floatToFixed_arrL( st->Bin_E, st->Bin_E_fx, q_comm_Bin, 256 ); - floatToFixed_arr( st->lsp_old, st->lsp_old_fx, Q15, M ); - for ( int j = 0; j < M; j++ ) - { - st->lsf_old_fx[j] = (Word16) ( st->lsf_old[j] * 2.56f ); - } floatToFixed_arr( st->lspold_enc, st->lspold_enc_fx, Q15, M ); @@ -509,7 +504,6 @@ void stereo_tcx_core_enc( Q_new = 0; st->hTcxCfg->bandwidth = float_to_fix16( st->hTcxCfg->bandwidth_flt, Q15 ); - floatToFixed_arr( st->lsp_old16k, st->lsp_old16k_fx, Q15, M ); Word16 exp_exc; f2me_buf_16( st->hLPDmem->old_exc_flt, st->hLPDmem->old_exc, &exp_exc, L_EXC_MEM ); Q_exc = 15 - exp_exc; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index d41b70076..057372853 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -4164,8 +4164,8 @@ void pvq_encode_frame_ivas_fx( const Word16 core /* i : core */ ); #endif -Word16 Interpol_4( /* o : interpolated value */ - Word16 *x, /* i : i vector */ +Word16 Interpol_4( /*Qx o : interpolated value */ + Word16 *x, /*Qx i : i vector */ Word16 frac /* i : fraction (-4..+3) */ ); diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 56efcb482..2453ebf94 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -2079,19 +2079,21 @@ Word16 ivas_smc_gmm_fx( *pFV++ = mfcc[12];*/ /* calculation of differential normalized power spectrum */ - sum_PS_fx = 1; + sum_PS_fx = 0; + Word16 sum_PS_e = 0; move32(); + move16(); FOR( i = LOWEST_FBIN; i < HIGHEST_FBIN; i++ ) { - sum_PS_fx = L_add( L_shr( PS_fx[i], Q7 ), sum_PS_fx ); // Qfact_PS - Q7 + sum_PS_fx = BASOP_Util_Add_Mant32Exp( sum_PS_fx, sum_PS_e, PS_fx[i], sub( 31, Qfact_PS ), &sum_PS_e ); // sum_PS_e } + sum_PS_e = add( sum_PS_e, 1 ); // to avoid overflow + sum_PS_fx = L_add( L_shr( sum_PS_fx, 1 ), L_shr( 21475 /*1 e-5 q31*/, sum_PS_e ) ); // 31-sum_PS_e - temp_exp = 0; - move16(); FOR( i = LOWEST_FBIN; i < HIGHEST_FBIN; i++ ) { - temp32 = BASOP_Util_Divide3232_Scale( PS_fx[i], sum_PS_fx, &temp_exp ); - PS_norm_fx[i] = L_shl( temp32, sub( Qfact_PS_past, add( sub( 15, temp_exp ), 7 ) ) ); // Qfact_PS_past + temp32 = BASOP_Util_Divide3232_Scale_cadence( PS_fx[i], sum_PS_fx, &temp_exp ); // 31-temp_exp + PS_norm_fx[i] = L_shl( temp32, sub( Qfact_PS_past, add( sub( 31, temp_exp ), sub( Qfact_PS, sub( 31, sum_PS_e ) ) ) ) ); // Qfact_PS_past move32(); dPS_fx[i] = L_abs( L_sub( PS_norm_fx[i], hSpMusClas->past_PS_fx[i - LOWEST_FBIN] ) ); move32(); diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 87076409e..849397efc 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -437,15 +437,18 @@ typedef struct td_cng_enc_structure Word32 ho_env_hist_fx[HO_HIST_SIZE * NUM_ENV_CNG]; /* Q6 */ #endif - Word16 ho_lsp_circ_fx[HO_HIST_SIZE * M]; /* CNG and DTX - old LSP buffer for averaging */ - Word32 ho_ener_circ_fx[HO_HIST_SIZE]; /* CNG and DTX - energy buffer for averaging */ - Word32 ho_env_circ_fx[HO_HIST_SIZE * NUM_ENV_CNG]; - int16_t act_cnt; /* CNG and DTX - counter of active frames */ - int16_t ho_circ_size; /* CNG and DTX - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ - int16_t ho_circ_ptr; /* CNG and DTX - pointer for averaging buffers */ + int16_t act_cnt; /* CNG and DTX - counter of active frames */ + int16_t ho_circ_size; /* CNG and DTX - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ + int16_t ho_circ_ptr; /* CNG and DTX - pointer for averaging buffers */ +#ifndef IVAS_FLOAT_FIXED float ho_lsp_circ[HO_HIST_SIZE * M]; /* CNG and DTX - old LSP buffer for averaging */ float ho_ener_circ[HO_HIST_SIZE]; /* CNG and DTX - energy buffer for averaging */ float ho_env_circ[HO_HIST_SIZE * NUM_ENV_CNG]; +#else + Word16 ho_lsp_circ_fx[HO_HIST_SIZE * M]; /* CNG and DTX - old LSP buffer for averaging Q15 */ + Word32 ho_ener_circ_fx[HO_HIST_SIZE]; /* CNG and DTX - energy buffer for averaging Q6 */ + Word32 ho_env_circ_fx[HO_HIST_SIZE * NUM_ENV_CNG]; /* Q6 */ +#endif int16_t burst_ho_cnt; /* CNG and DTX - counter of hangover frames at end of active burst */ int16_t cng_buf_cnt; /* CNG and DTX - Counter of buffered CNG parameters */ float cng_exc2_buf_flt[HO_HIST_SIZE * L_FFT]; /* CNG and DTX - exc2 buffer for storing */ @@ -2080,21 +2083,24 @@ typedef struct enc_core_structure LPD_state_HANDLE hLPDmem; /* ACELP LPDmem memories */ - float Bin_E[L_FFT]; /* per bin energy of two frames */ - float lsp_old1[M]; /* old unquantized LSP vector at the end of the frame at 12k8 */ - float lsf_old1[M]; /* old unquantized LSF vector at the end of the frame at 12k8 */ - float lsp_old[M]; /* old LSP vector at the end of the frame */ - float lsf_old[M]; /* old LSF vector at the end of the frame */ - float lsp_old16k[M]; /* old LSP vector at the end of the frame @16kHz */ - float lspold_enc[M]; /* old lsp (immittance spectral pairs) */ - Word32 Bin_E_fx[L_FFT]; /* Q_new + Q_SCALE -2 per bin energy of two frames */ - Word16 lsp_old1_fx[M]; /* old unquantized LSP vector at the end of the frame */ - Word16 lsf_old1_fx[M]; /* old LSF vector at the end of the frame */ - Word16 lsp_old_fx[M]; /* old LSP vector at the end of the frame */ // Q15 - Word16 lsf_old_fx[M]; /* old LSF vector at the end of the frame Qlog2(2.56) */ - Word16 lsp_old16k_fx[M]; /* old LSP vector at the end of the frame @16kHz */ - Word16 lspold_enc_fx[M]; /* old LSP vector at the end of the frame @16kHz */ - int16_t pstreaklen; /* LSF quantizer */ + float Bin_E[L_FFT]; /* per bin energy of two frames */ + Word32 Bin_E_fx[L_FFT]; /* Q_new + Q_SCALE -2 per bin energy of two frames */ +#ifndef IVAS_FLOAT_FIXED + float lsp_old1[M]; /* old unquantized LSP vector at the end of the frame at 12k8 */ + float lsf_old1[M]; /* old unquantized LSF vector at the end of the frame at 12k8 */ + float lsp_old[M]; /* old LSP vector at the end of the frame */ + float lsf_old[M]; /* old LSF vector at the end of the frame */ + float lsp_old16k[M]; /* old LSP vector at the end of the frame @16kHz */ +#else + Word16 lsp_old1_fx[M]; /* old unquantized LSP vector at the end of the frame Q15 */ + Word16 lsf_old1_fx[M]; /* old LSF vector at the end of the frame Qlog2(2.56) */ + Word16 lsp_old_fx[M]; /* old LSP vector at the end of the frame Q15 */ + Word16 lsf_old_fx[M]; /* old LSF vector at the end of the frame Qlog2(2.56) */ + Word16 lsp_old16k_fx[M]; /* old LSP vector at the end of the frame @16kHz Q15 */ +#endif + float lspold_enc[M]; /* old lsp (immittance spectral pairs) */ + Word16 lspold_enc_fx[M]; /* old LSP vector at the end of the frame @16kHz */ + int16_t pstreaklen; /* LSF quantizer */ #ifndef IVAS_FLOAT_FIXED float streaklimit; /* LSF quantizer */ float stab_fac; /* LSF stability factor */ @@ -2207,10 +2213,13 @@ typedef struct enc_core_structure int16_t spike_hyst; /* Hysteresis to prevent UC after sharp energy spike */ int16_t last_harm_flag_acelp; /* harmonicity flag for ACELP @32kbps rate */ float old_Aq_12_8[M + 1]; /* old Aq[] for core switching */ - float old_Es_pred; /* old Es_pred for core switching */ Word16 old_Aq_12_8_fx[M + 1]; /* Q12 old Aq[] for core switching */ - Word16 old_Es_pred_fx; /* Q8 old Es_pred for core switching */ - Word16 music_hysteresis_fx; /* Counter of frames after AUDIO coding mode to prevent UC */ +#ifndef IVAS_FLOAT_FIXED + float old_Es_pred; /* old Es_pred for core switching */ +#else + Word16 old_Es_pred_fx; /* old Es_pred for core switching Q8 */ +#endif + Word16 music_hysteresis_fx; /* Counter of frames after AUDIO coding mode to prevent UC */ Word16 last_vad_spa_fx; Word16 last_L_frame; /* ACELP@16kHz - last L_frame value */ @@ -2224,26 +2233,36 @@ typedef struct enc_core_structure Word16 last_code_preq; /* ACELP@16kHz - last coefficient of the pre-quantizer contribution */ Word16 use_acelp_preq; /* ACELP@16kHz - flag of prequantizer usage */ - Word16 bpf_off; /* Bass post-filter - do not use BPF when this flag is set to 1 */ - float old_pitch_buf[2 * NB_SUBFR16k]; /* Bass post-filter - buffer of old subframe pitch values */ - Word16 old_pitch_buf_fx[2 * NB_SUBFR16k]; /*Q6 Bass post-filter - buffer of old subframe pitch values */ - float pst_mem_deemp_err; /* Bass post-filter - filter memory of noise LP filter */ - Word16 pst_mem_deemp_err_fx; /* Bass post-filter - filter memory of noise LP filter */ - float pst_lp_ener; /* Bass post-filter - long-term energy */ - Word16 pst_lp_ener_fx; /* Bass post-filter - long-term energy */ + Word16 bpf_off; /* Bass post-filter - do not use BPF when this flag is set to 1 */ +#ifndef IVAS_FLOAT_FIXED + float old_pitch_buf[2 * NB_SUBFR16k]; /* Bass post-filter - buffer of old subframe pitch values */ + float pst_mem_deemp_err; /* Bass post-filter - filter memory of noise LP filter */ + float pst_lp_ener; /* Bass post-filter - long-term energy */ +#else + Word16 old_pitch_buf_fx[2 * NB_SUBFR16k]; /* Bass post-filter - buffer of old subframe pitch values Q6 */ + Word16 pst_mem_deemp_err_fx; /* Bass post-filter - filter memory of noise LP filter */ + Word16 pst_lp_ener_fx; /* Bass post-filter - long-term energy */ +#endif /* stable short pitch detection */ +#ifndef IVAS_FLOAT_FIXED float voicing0_sm; float voicing_sm; float LF_EnergyRatio_sm; +#else Word16 voicing0_sm_fx; Word16 voicing_sm_fx; Word16 LF_EnergyRatio_sm_fx; +#endif int16_t predecision_flag; +#ifndef IVAS_FLOAT_FIXED float diff_sm; float energy_sm; - Word32 diff_sm_fx; - Word32 energy_sm_fx; +#else + Word32 diff_sm_fx; /* Q7 */ + Word32 energy_sm_fx; /* Q7 */ +#endif + Word16 finalVAD; int16_t flag_noisy_speech_snr; /* encoder detector for noisy speech */ @@ -2335,14 +2354,14 @@ typedef struct enc_core_structure #ifndef IVAS_FLOAT_FIXED float bckr_tilt_lt_flt; #else - Word32 bckr_tilt_lt; /* Q16 */ + Word32 bckr_tilt_lt; /* Q16 */ #endif float lp_speech; Word16 lp_speech_fx; // Q8 #ifndef IVAS_FLOAT_FIXED float lp_noise; /* CNG and DTX - LP filtered total noise estimation */ #else - Word16 lp_noise_fx; /* CNG and DTX - LP filtered total noise estimation Q8 */ + Word16 lp_noise_fx; /* CNG and DTX - LP filtered total noise estimation Q8 */ #endif Word16 Opt_HE_SAD_ON_fx; Word16 nb_active_frames_HE_SAD_fx; @@ -2381,8 +2400,8 @@ typedef struct enc_core_structure float last_totalNoise; float totalNoise_increase_hist[TOTALNOISE_HIST_SIZE]; #else - Word16 last_totalNoise_fx; /* Q8 */ - Word16 totalNoise_increase_hist_fx[TOTALNOISE_HIST_SIZE]; /* Q8 */ + Word16 last_totalNoise_fx; /* Q8 */ + Word16 totalNoise_increase_hist_fx[TOTALNOISE_HIST_SIZE]; /* Q8 */ #endif int16_t totalNoise_increase_len; @@ -3237,7 +3256,9 @@ typedef struct enc_core_structure typedef struct GainItemStr { +#ifndef IVAS_FLOAT_FIXED float nmrValue; +#endif int16_t gainIndex; } GainItem; @@ -3245,14 +3266,15 @@ typedef struct context_rc_mem_struct { int16_t nbits_old; int16_t ctx; +#ifndef IVAS_FLOAT_FIXED float bit_estimate; - int16_t rateFlag; - int16_t lastnz; - int16_t nt_half; -#ifdef IVAS_FLOAT_FIXED +#else Word32 bit_estimate_fx; Word16 bit_estimate_e; #endif + int16_t rateFlag; + int16_t lastnz; + int16_t nt_half; } RC_CONTEXT_MEM, *HANDLE_RC_CONTEXT_MEM; -- GitLab