From 97b17e51bbc9b0c15b6f561a9f1dfd1afdf57912 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 24 Apr 2025 15:25:28 +0200 Subject: [PATCH] use 32b sin_cos --- lib_com/fft_rel.c | 44 ++++++++++++++ lib_com/options.h | 11 +++- lib_com/prot_fx.h | 5 ++ lib_com/rom_com.c | 39 ++++++++++++ lib_com/rom_com.h | 3 + lib_enc/analy_sp_fx.c | 86 ++++++++++++++++++++++++++- lib_enc/ivas_core_pre_proc_front_fx.c | 56 ++++++++++++++++- lib_enc/ivas_front_vad_fx.c | 11 +++- lib_enc/prot_fx_enc.h | 6 ++ lib_enc/speech_music_classif_fx.c | 76 ++++++++++++++++++++++- 10 files changed, 330 insertions(+), 7 deletions(-) diff --git a/lib_com/fft_rel.c b/lib_com/fft_rel.c index 1d020cabd..ae31575f0 100644 --- a/lib_com/fft_rel.c +++ b/lib_com/fft_rel.c @@ -306,13 +306,22 @@ void fft_rel_16_32fx( Word16 i_subfr, const Word16 n, /* i : vector length */ const Word16 m /* i : log2 of vector length */ +#ifdef FFT_PREC32 + , + Word32 x32[], + Word16 *q_x32 +#endif ) { Word16 i, j, k, n1, n2, n4; Word16 step; Word32 xt, t1, t2; Word32 *x0, *x1, *x2; +#ifdef FFT_PREC32 + const Word32 *s32, *c32; +#else const Word16 *s, *c; +#endif Word32 *xi2, *xi3, *xi4, *xi1; Word32 fft_bff32[L_FFT]; @@ -404,8 +413,13 @@ void fft_rel_16_32fx( move32(); /* x[i+n2+n4] = -x[i+n2+n4]; */ +#ifdef FFT_PREC32 + s32 = sincos_t_fx32 + step; // Q31 + c32 = s32 + 64; // Q31 +#else s = sincos_t_fx + step; // Q15 c = s + 64; // Q15 +#endif xi1 = fft_bff32 + add( i, 1 ); xi3 = xi1 + n2; xi2 = xi3 - 2; @@ -413,8 +427,13 @@ void fft_rel_16_32fx( FOR( j = 1; j < n4; j++ ) { +#ifdef FFT_PREC32 + t1 = L_add( Mpy_32_32( *xi3, *c32 ), Mpy_32_32( *xi4, *s32 ) ); /* t1 = *xi3**(pt_c+ind) + *xi4**(pt_s+ind); Qx */ + t2 = L_sub( Mpy_32_32( *xi3, *s32 ), Mpy_32_32( *xi4, *c32 ) ); /* t2 = *xi3**(pt_s+ind) - *xi4**(pt_c+ind); Qx */ +#else t1 = L_add( Mpy_32_16_1( *xi3, *c ), Mpy_32_16_1( *xi4, *s ) ); /* t1 = *xi3**(pt_c+ind) + *xi4**(pt_s+ind); Qx */ t2 = L_sub( Mpy_32_16_1( *xi3, *s ), Mpy_32_16_1( *xi4, *c ) ); /* t2 = *xi3**(pt_s+ind) - *xi4**(pt_c+ind); Qx */ +#endif *xi4 = L_sub( *xi2, t2 ); move32(); *xi3 = L_negate( L_add( *xi2, t2 ) ); @@ -428,8 +447,13 @@ void fft_rel_16_32fx( xi2--; xi3++; xi1++; +#ifdef FFT_PREC32 + c32 += step; + s32 += step; /* autoincrement by ar0 */ +#else c += step; s += step; /* autoincrement by ar0 */ +#endif } x0 += n1; @@ -443,6 +467,11 @@ void fft_rel_16_32fx( { Copy_Scale_sig32_16( fft_bff32, x, L_FFT, norm ); *q_x = sub( norm, 16 ); + +#ifdef FFT_PREC32 + Copy_Scale_sig32( fft_bff32, x32, L_FFT, norm ); + *q_x32 = norm; +#endif move16(); } ELSE @@ -458,6 +487,21 @@ void fft_rel_16_32fx( { Copy_Scale_sig32_16( fft_bff32, x, L_FFT, add( 16, *q_x ) ); } + +#ifdef FFT_PREC32 + IF( LT_16( norm, *q_x32 ) ) + { + scale_sig32( x32 - L_FFT, L_FFT, sub( norm, *q_x32 ) ); + Copy_Scale_sig32( fft_bff32, x32, L_FFT, norm ); + *q_x32 = norm; + move16(); + } + ELSE + { + Copy_Scale_sig32( fft_bff32, x32, L_FFT, *q_x32 ); + } +#endif + } return; diff --git a/lib_com/options.h b/lib_com/options.h index cbc77b6e7..7587fffd7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -41,10 +41,10 @@ /* ################### Start DEBUGGING switches ######################## */ -/*#define DEBUGGING*/ /* Allows debugging message to be printed out during runtime */ +#define DEBUGGING /* Allows debugging message to be printed out during runtime */ #ifdef DEBUGGING #define DEBUG_MODE_INFO /* Define to output most important parameters to the subdirectory "res/" */ -#define DEBUG_MODE_INFO_TWEAK /* Enable command line switch to specify subdirectory for debug info output inside "./res/" */ +//#define DEBUG_MODE_INFO_TWEAK /* Enable command line switch to specify subdirectory for debug info output inside "./res/" */ #define DEBUG_FORCE_MDCT_STEREO_MODE /* Force stereo mode decision for MDCT stereo: -stereo 3 1 forces L/R coding and -stereo 3 2 forces full M/S coding */ /*#define DEBUG_FORCE_DIR*/ /* Force modes/parameters by reading from external binary files */ /*#define DBG_WAV_WRITER*/ /* Enable dbgwrite_wav() function for generating ".wav" files */ @@ -61,6 +61,13 @@ /*#define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ #endif + +//#define ENFORCE_float_PS +//#define ENFORCE_float_fft +#define ENFORCE_float_inp_12k8 +#define ENFORCE_float_smc_vad +#define FFT_PREC32 + /* #################### End DEBUGGING switches ############################ */ #ifndef BASOP_NOGLOB_DEV_USE_GLOBALS diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 86b5ec0b7..ed6fbd1c1 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1534,6 +1534,11 @@ void fft_rel_16_32fx( Word16 i_subfr, const Word16 n, /* i : vector length */ const Word16 m /* i : log2 of vector length */ +#ifdef FFT_PREC32 + , + Word32 x32[], + Word16 *q_x32 +#endif ); void fft_rel_fx32( Word32 x[], /* i/o: i /output vector */ diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index a5c8a3b7c..617cad902 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -1002,6 +1002,45 @@ const Word16 sincos_t_fx[161] = -20787, -21403, -22005, -22594, -23170, }; +#ifdef FFT_PREC32 +const Word32 sincos_t_fx32[161] = +{ + /* Q31 */ + 0, + 52701887, 105372028, 157978697, 210490206, 262874923, + 315101295, 367137861, 418953276, 470516330, 521795963, + 572761285, 623381598, 673626408, 723465451, 772868706, + 821806413, 870249095, 918167572, 965532978, 1012316784, + 1058490808, 1104027237, 1148898640, 1193077991, 1236538675, + 1279254516, 1321199781, 1362349204, 1402678000, 1442161874, + 1480777044, 1518500250, 1555308768, 1591180426, 1626093616, + 1660027308, 1692961062, 1724875040, 1755750017, 1785567396, + 1814309216, 1841958164, 1868497586, 1893911494, 1918184581, + 1941302225, 1963250501, 1984016189, 2003586779, 2021950484, + 2039096241, 2055013723, 2069693342, 2083126254, 2095304370, + 2106220352, 2115867626, 2124240380, 2131333572, 2137142927, + 2141664948, 2144896910, 2146836866, 2147483647, 2146836866, + 2144896910, 2141664948, 2137142927, 2131333572, 2124240380, + 2115867626, 2106220352, 2095304370, 2083126254, 2069693342, + 2055013723, 2039096241, 2021950484, 2003586779, 1984016189, + 1963250501, 1941302225, 1918184581, 1893911494, 1868497586, + 1841958164, 1814309216, 1785567396, 1755750017, 1724875040, + 1692961062, 1660027308, 1626093616, 1591180426, 1555308768, + 1518500250, 1480777044, 1442161874, 1402678000, 1362349204, + 1321199781, 1279254516, 1236538675, 1193077991, 1148898640, + 1104027237, 1058490808, 1012316784, 965532978, 918167572, + 870249095, 821806413, 772868706, 723465451, 673626408, + 623381598, 572761285, 521795963, 470516330, 418953276, + 367137861, 315101295, 262874923, 210490206, 157978697, + 105372028, 52701887, 0, -52701887, -105372028, + -157978697, -210490206, -262874923, -315101295, -367137861, + -418953276, -470516330, -521795963, -572761285, -623381598, + -673626408, -723465451, -772868706, -821806413, -870249095, + -918167572, -965532978, -1012316784, -1058490808, -1104027237, + -1148898640, -1193077991, -1236538675, -1279254516, -1321199781, + -1362349204, -1402678000, -1442161874, -1480777044, -1518500250 + }; +#endif /*----------------------------------------------------------------------------------* * Sinus & Cosinus - table for the FFT and IFFT of 1024 points, value range [0 ... sin(-5pi/4)] diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index 73156b989..dbe3bb7f3 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -167,6 +167,9 @@ extern const FrameSizeParams FrameSizeConfig[FRAME_SIZE_NB]; extern const Word16 h_high_fx[5]; // Q15 extern const Word16 sincos_t_fx[161]; // Q15 +#ifdef FFT_PREC32 +extern const Word32 sincos_t_fx32[161]; // Q31 +#endif extern const Word16 sincos_t_ext_fx[]; // Q15 extern const Word32 crit_bands_fx[]; extern const float sincos_t_ext[]; // fft_rel dep diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 49bb03f57..effda584a 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -13,6 +13,8 @@ #include "rom_com.h" #include #include +#include "debug.h" + /*-------------------------------------------------------------------* * Local prototypes *-------------------------------------------------------------------*/ @@ -452,6 +454,10 @@ void ivas_analy_sp_fx( Word16 *q_band_energies, /* o : Q of energy in critical frequency bands without minimum noise floor MODE2_E_MIN */ Word16 *fft_buff, /* o : FFT coefficients (q_fft_buff) */ Word16 *q_fft_buff /* o : Q of FFT coefficients Q0 */ +#ifdef FFT_PREC32 + ,Word32 *fft_buff32 /* o : FFT coefficients (q_fft_buff32) */ + ,Word16 *q_fft_buff32 /* o : Q of FFT coefficients Q0 */ +#endif ) { Word16 *pt; @@ -459,12 +465,16 @@ void ivas_analy_sp_fx( Word32 *pt_bands; Word32 Ltmp; Word16 *pt_fft; +#ifdef FFT_PREC32 + Word32 *pt_fft32; +#endif Word16 exp, tmp; Word16 resultant_q; Word16 exp2; Word64 LEtot; LEtot = 0; move64(); + /*-----------------------------------------------------------------* * Compute spectrum * find energy per critical frequency band and total energy in dB @@ -472,6 +482,9 @@ void ivas_analy_sp_fx( pt_bands = fr_bands; pt_fft = fft_buff; +#ifdef FFT_PREC32 + pt_fft32 = fft_buff32; +#endif IF( NE_16( element_mode, IVAS_CPE_DFT ) ) { @@ -479,8 +492,17 @@ void ivas_analy_sp_fx( { set16_fx( pt_fft, 0, 2 * L_FFT ); *q_fft_buff = Q15; +#ifdef FFT_PREC32 + set32_fx( pt_fft32, 0, 2 * L_FFT ); + *q_fft_buff32 = Q31; +#endif move16(); +#ifdef ENFORCE_float_fft + float float_fft[2 * L_FFT]; + dbgread( float_fft, sizeof( float ), 2 * L_FFT, "../ivas-float-update/ivas-basop/res/float_fft" ); +#endif + set32_fx( Bin_E, 0, L_FFT ); set32_fx( lf_E, 0, 2 * VOIC_BINS ); set32_fx( band_energies, 0, 2 * NB_BANDS ); @@ -495,6 +517,9 @@ void ivas_analy_sp_fx( ELSE { Word16 scale = 0, shift; +#ifdef FFT_PREC32 + Word16 scale32; +#endif move16(); shift = s_min( norm_arr( speech + 3 * ( L_SUBFR / 2 ) - L_FFT / 2, L_FFT ), norm_arr( speech + 7 * ( L_SUBFR / 2 ) - L_FFT / 2, L_FFT ) ); FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ ) @@ -512,6 +537,12 @@ void ivas_analy_sp_fx( move16(); pt_fft[L_FFT / 2] = shl( pt[L_FFT / 2], shift ); // (Q_new + shift) - preemph_bits move16(); +#ifdef FFT_PREC32 + pt_fft32[0] = 0; + move16(); + pt_fft32[L_FFT / 2] = L_shl( L_deposit_h( pt[L_FFT / 2] ), shift ); // (Q_new + shift) - preemph_bits + move16(); +#endif FOR( i = 1; i < L_FFT / 2; i++ ) { @@ -525,8 +556,28 @@ void ivas_analy_sp_fx( } /* compute the spectrum */ - fft_rel_16_32fx( pt_fft, &scale, i_subfr, L_FFT, LOG2_L_FFT ); + fft_rel_16_32fx( pt_fft, &scale, i_subfr, L_FFT, LOG2_L_FFT +#ifdef FFT_PREC32 + ,pt_fft32, &scale32 +#endif + ); *q_fft_buff = add( add( Q_new, shift ), scale ); // resultant q for fft_buff +#ifdef FFT_PREC32 + *q_fft_buff32 = add( add( add( Q_new, shift ), scale ), 16); // resultant q for fft_buff32 +#endif + + +#ifdef ENFORCE_float_fft + float fixed_fft[L_FFT]; + fixedToFloat_arr( pt_fft, fixed_fft, *q_fft_buff, L_FFT ); + + float float_fft[L_FFT]; + dbgread( float_fft, sizeof( float ), L_FFT, "../ivas-float-update/ivas-basop/res/float_fft" ); + + /* convert float_fft[] to pt_fft[] with q_fft_buff */ + floatToFixed_arr( float_fft, pt_fft, *q_fft_buff, L_FFT ); +#endif + move16(); IF( EQ_16( i_subfr, 1 ) ) { @@ -549,9 +600,29 @@ void ivas_analy_sp_fx( pt_bands += NB_BANDS; pt_fft += L_FFT; +#ifdef FFT_PREC32 + pt_fft32 += L_FFT; +#endif } } +#ifdef DEBUGGING + /* fft_buff is stored as q_fft_buff */ + float tmpf; + + for ( i = 0; i < 2 * L_FFT; i++ ) + { + tmpf = fft_buff[i] / powf( 2, *q_fft_buff ); + dbgwrite( &tmpf, sizeof( float ), 1, 1, "res/fft_fx" ); + } + + for ( i = 0; i < 2 * L_FFT; i++ ) + { + tmpf = fft_buff32[i] / powf( 2, *q_fft_buff32 ); + dbgwrite( &tmpf, sizeof( float ), 1, 1, "res/fft_fx32" ); + } +#endif + *q_Bin_E = *q_lf_E; move16(); @@ -634,6 +705,19 @@ void ivas_analy_sp_fx( move32(); Bin_E[L_FFT - 1] = Bin_E[L_FFT - 2]; // *q_Bin_E move32(); + +#ifdef DEBUGGING + /* Bin_E is stored as q_Bin_E */ + float tmpf; + + for ( i = 0; i < L_FFT / 2; i++ ) + { + tmpf = Bin_E[i] / powf( 2, *q_Bin_E ); + dbgwrite( &tmpf, sizeof( float ), 1, 1, "res/Bin_E_fx" ); + } +#endif + + Word32 add_const = 21475; // 1e-5 in Q31 FOR( i = 0; i < L_FFT / 2; i++ ) { diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 3d7d87bc2..4dfbc5836 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -227,6 +227,11 @@ ivas_error pre_proc_front_ivas_fx( Word32 *in_buff_temp; Word16 in_q_temp; #endif +#ifdef FFT_PREC32 + Word32 fft_buff32[2 * L_FFT]; + Word16 q_fft_buff32; +#endif + mem_decim_dummy_fx = (Word16 *) malloc( 90 * sizeof( Word16 * ) ); temp1F_icatdmResampBuf_fx = (Word16 *) malloc( 45 * sizeof( Word16 * ) ); @@ -739,9 +744,22 @@ ivas_error pre_proc_front_ivas_fx( lgBin_E_fx = &st->lgBin_E_fx[0]; } +#ifdef ENFORCE_float_inp_12k8 + float temp_array[384]; + dbgread( temp_array, sizeof( float ), 384, "../ivas-float-update/ivas-basop/res/float_inp_12k8" ); + for ( i = 0; i < 384; i++ ) + { + inp_12k8_fx[-32 + i] = (Word16)(temp_array[i] * powf( 2, *Q_new )); + } +#endif + ivas_analy_sp_fx( element_mode, hCPE, input_Fs, inp_12k8_fx /*old_inp_12k8_e*/, *Q_new, fr_bands_fx, &fr_bands_fx_q, lf_E_fx, &q_lf_E_fx, &Etot_fx, st->min_band, st->max_band, st->Bin_E_fx, &st->q_Bin_E, st->Bin_E_old_fx, &st->q_Bin_E_old, PS_fx, &Qfact_PS, - lgBin_E_fx, band_energies_fx, &q_band_energies, fft_buff_fx, fft_buff_fx_q ); + lgBin_E_fx, band_energies_fx, &q_band_energies, fft_buff_fx, fft_buff_fx_q +#ifdef FFT_PREC32 + ,fft_buff32, &q_fft_buff32 +#endif + ); IF( hStereoClassif != NULL ) { @@ -1467,7 +1485,37 @@ ivas_error pre_proc_front_ivas_fx( scale_sig32( PS_fx, 128, shift ); Qfact_PS = add( Qfact_PS, shift ); - smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, extract_h( Etot_fx ), lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, hSpMusClas->past_PS_Q ); /* Q0 */ +#ifdef ENFORCE_float_smc_vad + short float_localVAD_HE_SAD; + dbgread( &float_localVAD_HE_SAD, sizeof( short ), 1, "../ivas-float-update/ivas-basop/res/float_localVAD_HE_SAD" ); +#endif + +#ifdef ENFORCE_float_PS + float float_PS[128]; + Word32 float_PS_fx[128]; + dbgread( float_PS, sizeof( float ), 128, "../ivas-float-update/ivas-basop/res/float_PS" ); + + /* convert float_PS[] to float_PS_fx[] with Qfact_PS */ + if ( Qfact_PS > 31 ) + { + Qfact_PS = 31; + } + floatToFixed_arrL32( float_PS, float_PS_fx, Qfact_PS, 128 ); +#endif + + smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, +#ifdef ENFORCE_float_smc_vad + float_localVAD_HE_SAD, +#else + localVAD_HE_SAD, +#endif + extract_h(Etot_fx), lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, +#ifdef ENFORCE_float_PS + float_PS_fx, +#else + PS_fx, +#endif + non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, hSpMusClas->past_PS_Q ); /* Q0 */ #ifdef DEBUG_FORCE_DIR if ( st->force_dir[0] != '\0' ) @@ -1685,6 +1733,10 @@ ivas_error pre_proc_front_ivas_fx( ivas_smc_mode_selection_fx( st, element_brate, smc_dec, *relE_fx, extract_h( Etot_fx ), attack_flag, inp_12k8_fx, *Q_new, S_map_fx, flag_spitch ); } +#ifdef DEBUG_MODE_INFO + dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/smc_dec" ); +#endif + #ifdef DEBUG_FORCE_DIR if ( st->force_dir[0] != '\0' ) { diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index 124ab2996..778a549cc 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -84,6 +84,11 @@ ivas_error front_vad_fx( Word32 Bin_E_old_fx[L_FFT / 2] = { 0 }; /* old per bin log energy spectrum for mid-frame */ Word16 fft_buffLR_fx[2 * L_FFT]; /* fft buffer */ // Word16 front_create_flag = 0; +#ifdef FFT_PREC32 + Word32 fft_buff32[2 * L_FFT]; + Word16 q_fft_buff32; +#endif + Word16 n, n_chan, dummy; Word16 dummy_short; Word16 element_mode, last_element_mode; @@ -250,7 +255,11 @@ ivas_error front_vad_fx( ivas_analy_sp_fx( IVAS_CPE_TD, hCPE, sts[0]->input_Fs, hFrontVad->buffer_12k8_fx + L_FFT / 2 - 3 * ( L_SUBFR / 2 ), Q_new, fr_bands_fx[n], &q_fr_bands[n], lf_E_fx[n], &q_lf_E[n], &Etot_LR_32fx, sts[0]->min_band, sts[0]->max_band, Bin_E_fx, &q_Bin_E, Bin_E_old_fx, - &q_Bin_E_old, PS_fx, q_PS_out, lgBin_E_fx, band_energies_fx, &q_band_energies, fft_buffLR_fx, &q_fft_buffLR ); + &q_Bin_E_old, PS_fx, q_PS_out, lgBin_E_fx, band_energies_fx, &q_band_energies, fft_buffLR_fx, &q_fft_buffLR +#ifdef FFT_PREC32 + , fft_buff32, &q_fft_buff32 +#endif + ); if ( n == 0 ) { *q_band_energies_LR = q_band_energies; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 4237aa9c3..438fd5479 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2244,6 +2244,12 @@ void ivas_analy_sp_fx( Word16 *q_band_energies, /* o : Q of energy in critical frequency bands without minimum noise floor MODE2_E_MIN */ Word16 *fft_buff, /* o : FFT coefficients (q_fft_buff) */ Word16 *q_fft_buff /* o : Q of FFT coefficients Q0 */ +#ifdef FFT_PREC32 + , + Word32 *fft_buff32 /* o : FFT coefficients (q_fft_buff32) */ + , + Word16 *q_fft_buff32 /* o : Q of FFT coefficients Q0 */ +#endif ); void find_wsp_fx( const Word16 Az[], diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index cf6ba543b..e43b993a6 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -1895,6 +1895,17 @@ Word16 ivas_smc_gmm_fx( move32(); //*pFV++ = logf( epsP[14] + 1e-5f ) - logf( epsP[0] + 1e-5f ); +#ifdef DEBUG_MODE_INFO + { + /* epsP14 is stored as Q20 */ + float tmpf; + Word32 tmpS = L_shr( L_sub( temp32_log1, temp32_log2 ), Q5 ); + + tmpf = tmpS / powf( 2, Q20 ); + dbgwrite( &tmpf, sizeof( float ), 1, 1, "res/epsP14" ); + } +#endif + /* [10,11,12] MFCCs */ set_zero_fx( melS_fx, NB_MEL_BANDS ); @@ -1934,6 +1945,37 @@ Word16 ivas_smc_gmm_fx( *pFV++ = mfcc[6]; *pFV++ = mfcc[12];*/ +#ifdef DEBUG_MODE_INFO + { + /* MFCC is stored as Q20 */ + float tmpf; + Word32 tmpS; + + tmpS = L_shl( mfcc_fx[2], 1 ); + tmpf = tmpS / powf( 2, Q20 ); + dbgwrite( &tmpf, sizeof( float ), 1, 1, "res/mfcc2" ); + + tmpS = L_shl( mfcc_fx[6], 1 ); + tmpf = tmpS / powf( 2, Q20 ); + dbgwrite( &tmpf, sizeof( float ), 1, 1, "res/mfcc6" ); + + tmpS = L_shl( mfcc_fx[12], 1 ); + tmpf = tmpS / powf( 2, Q20 ); + dbgwrite( &tmpf, sizeof( float ), 1, 1, "res/mfcc12" ); + } + { + /* PS is stored as Qfact_PS */ + float tmpf; + + for ( i = 0; i < 128; i++ ) + { + tmpf = PS_fx[i] / powf( 2, Qfact_PS ); + dbgwrite( &tmpf, sizeof( float ), 1, 1, "res/PS_fx" ); + } + } +#endif + + /* calculation of differential normalized power spectrum */ sum_PS_fx = 0; move32(); @@ -2039,6 +2081,24 @@ Word16 ivas_smc_gmm_fx( move16(); } +#ifdef DEBUG_MODE_INFO + FOR( i = 0; i < N_SMC_FEATURES; i++ ) + { + /* FV is stored as Q20 */ + float tmpf = FV_fx[i] / powf( 2, Q20 ); + dbgwrite( &tmpf, sizeof( float ), 1, 1, "res/fv" ); + + if ( localVAD_HE_SAD ) + { + dbgwrite( &tmpf, sizeof( float ), 1, 1, "res/fv_act" ); + } + else + { + dbgwrite( &tmpf, sizeof( float ), 1, 1, "res/fv_inact" ); + } + } +#endif + /*------------------------------------------------------------------* * Outlier detection based on feature histograms *------------------------------------------------------------------*/ @@ -2277,8 +2337,15 @@ Word16 ivas_smc_gmm_fx( dec = (Word16) GT_32( dlp_fx, 0 ); move16(); - /* calculate weight based on relE (higher relE -> lower weight, lower relE -> higher weight) */ +#ifdef DEBUG_MODE_INFO + { + float tmpf = dlp_fx / 524288.0f; + dbgwrite( &tmpf, sizeof( float ), 1, 1, "res/dlp_fx.x" ); + } +#endif + + /* calculate weight based on relE (higher relE -> lower weight, lower relE -> higher weight) */ wrelE_fx = lin_interp32_fx( L_deposit_h( relE_fx ), 15 << 24, 1932735283 /*0.9 in Q31*/, -( 15 << 24 ), 2126008812 /*0.99 in Q31*/, 1 ); // Q31 /* calculate weight based on drops of dlp (close to 1 during sudden drops of dlp, close to 0 otherwise) */ // hSpMusClas->dlp_mean_ST = 0.8f * hSpMusClas->dlp_mean_ST + 0.2f * dlp; @@ -2306,6 +2373,13 @@ Word16 ivas_smc_gmm_fx( } wdrop_fx = lin_interp32_fx( hSpMusClas->wdrop_32fx, 7864320, 1503238554 /* 0.7 in Q31 */, 0, ONE_IN_Q31 /* 1.0f in Q31 */, 1 ); /* Q31 */ +#ifdef DEBUG_MODE_INFO + { + float tmpf = hSpMusClas->wdrop_32fx / powf(2, 19); + dbgwrite( &tmpf, sizeof( float ), 1, 1, "res/wdrop_fx" ); + } +#endif + test(); test(); /* calculate weight based on rises of dlp (close to 1 during sudden rise of dlp, close to 0 otherwise) */ -- GitLab