From eff6ad2d13f0370ab05322f34c2c1e0031d83cba Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Tue, 9 May 2023 16:26:13 +0200 Subject: [PATCH 1/3] added dct20 to support N=20 for fdcng WB1 bandwidth (occuring for ISM2 at bit rate 16400 ) --- lib_com/cnst.h | 11 ++- lib_com/lsf_tools.c | 16 +++- lib_com/options.h | 2 +- lib_com/prot.h | 3 + lib_com/rom_com.c | 34 ++++++- lib_com/rom_com.h | 5 ++ lib_enc/fd_cng_enc.c | 19 +++- lib_enc/lsf_msvq_ma_enc.c | 182 +++++++++++++++++++++++--------------- 8 files changed, 195 insertions(+), 77 deletions(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 261ef6f907..ac93914680 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -1395,6 +1395,10 @@ enum #define FDCNG_VQ_DCT_MAXTRUNC 18 #define FDCNG_VQ_MAX_LEN_WB 21 +#ifdef ERI_MSVQ_CLEANUP_WB1 +#define FDCNG_VQ_MAX_LEN_WB1 20 +#endif + #define FDCNG_VQ_DCT_NPOST 8 typedef enum _DCTTYPE @@ -1402,7 +1406,12 @@ typedef enum _DCTTYPE DCT_T2_24_XX = 0, /* truncated DCT_T2_24 */ IDCT_T2_XX_24 = 1, DCT_T2_21_XX = 2, /* truncated DCT_T2_21 */ - IDCT_T2_XX_21 = 3 + IDCT_T2_XX_21 = 3 +#ifdef ERI_MSVQ_CLEANUP_WB1 + ,DCT_T2_20_XX = 4, /* truncated DCT_T2_20 */ + IDCT_T2_XX_20 = 5 +#endif + } DCTTYPE; diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index 02a735e80c..4fa7a7b4d1 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -2460,7 +2460,11 @@ void dctT2_N_apply_matrix( mat_step_col = matrix_row_dim; /* matrix maximum storage size dependent, width of first row in matrix */ mat_step_row = 0; mat_step_col_flag = 1; +#ifdef ERI_MSVQ_CLEANUP_WB1 + assert( dcttype == DCT_T2_20_XX || dcttype == DCT_T2_21_XX || dcttype == DCT_T2_24_XX ); +#else assert( dcttype == DCT_T2_21_XX || dcttype == DCT_T2_24_XX ); +#endif } else { @@ -2529,7 +2533,7 @@ void extend_dctN_input( i_rev = in_dim; /*ptr init*/ for ( i = in_dim; i < out_dim; i++ ) - { /* for each extension sample */ + { /* for each extension sample */ /* i = 21 22 23; i_rev = 20 19 18; for odd dctII reflect basis vector */ @@ -2566,9 +2570,17 @@ void create_IDCT_N_Matrix( float *inv_matrixFloatQ, const int16_t N, const int16 if ( N == FDCNG_VQ_MAX_LEN_WB ) { absval_ptr = unique_idctT2_21coeffsQ16; - idx_ptr = idctT2_21_compressed_idx; + idx_ptr = idctT2_21_compressed_idx; len = N; } +#ifdef ERI_MSVQ_CLEANUP_WB1 + if ( N == FDCNG_VQ_MAX_LEN_WB1 ) + { + absval_ptr = unique_idctT2_20coeffsQ16; + idx_ptr = idctT2_20_compressed_idx; + len = N; + } +#endif assert( alloc_size >= ( n_cols * len ) ); /* enough space for the full expanded IDCT matrix */ assert( N <= len ); diff --git a/lib_com/options.h b/lib_com/options.h index ac13c07402..06ca020f80 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -158,7 +158,7 @@ #define ERI_MSVQ_CLEANUP /* Eri: Contribution #31 BE modularization of msvq encoder side DCT21&DCT24 within msvq_enc() */ - +#define ERI_MSVQ_CLEANUP_WB1 /*Eri: Contribution #31 non-BE for ISM low rate (total_rate < 8kbps) using WB1 bandwidth */ #define FIX_416_ISM_BR_SWITCHING /* FhG: add missing CLDFB reconfig to ISM BR switching */ #define FIX_SP2A /* VA: Issue 412: Adjust threshold for the S_p2a feature in the tonal detector */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 69bcaa6647..a31c999180 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -8142,6 +8142,9 @@ int16_t msvq_stage1_dct_search( /* o int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb( /* o : (updated p_max) */ +#ifdef ERI_MSVQ_CLEANUP_WB1 + const int16_t n, /*i : original target length */ +#endif const float *st1_syn_vec_ptr, /* i : IDCT24 synthesis vectors */ const float *u, /* i : target signal */ const int16_t maxC_st1, /* i : number of candidates in stage1 */ diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 9c2b49bca2..b3aa7c5146 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -6140,7 +6140,39 @@ const Word8 idctT2_21_compressed_idx[(FDCNG_VQ_DCT_MAXTRUNC *( (21/2) + 1)) /* }; /*low storage IDCT24x18 table && IDCT21*18 */ - +#ifdef ERI_MSVQ_CLEANUP_WB1 +const Word16 unique_idctT2_20coeffsQ16[21] = { + 0, 1626, 3242, 4838, 6404, 7931, 9409, 10828, + 12181, 13459, 14654, 15759, 16766, 17670, 18465, 19147, + 19710, 20152, 20469, 20660, 20724 +}; + +const Word8 idctT2_20_compressed_idx[(FDCNG_VQ_DCT_MAXTRUNC *( (20/2) )) /* == 180 Word8 */ ] = { + 10, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, + 10, 17, 14, 11, 8, 5, 2, -1, -4, -7, -10, -13, -16, -19, -18, -15, -12, -9, + 10, 15, 10, 5, 0, -5, -10, -15, -20, -15, -10, -5, 0, 5, 10, 15, 20, 15, + 10, 13, 6, -1, -8, -15, -18, -11, -4, 3, 10, 17, 16, 9, 2, -5, -12, -19, + 10, 11, 2, -7, -16, -15, -6, 3, 12, 19, 10, 1, -8, -17, -14, -5, 4, 13, + 10, 9, -2, -13, -16, -5, 6, 17, 12, 1, -10, -19, -8, 3, 14, 15, 4, -7, + 10, 7, -6, -19, -8, 5, 18, 9, -4, -17, -10, 3, 16, 11, -2, -15, -12, 1, + 10, 5, -10, -15, 0, 15, 10, -5, -20, -5, 10, 15, 0, -15, -10, 5, 20, 5, + 10, 3, -14, -9, 8, 15, -2, -19, -4, 13, 10, -7, -16, 1, 18, 5, -12, -11, + 10, 1, -18, -3, 16, 5, -14, -7, 12, 9, -10, -11, 8, 13, -6, -15, 4, 17, + /* + 10, -1, -18, 3, 16, -5, -14, 7, 12, -9, -10, 11, 8, -13, -6, 15, 4, -17, + 10, -3, -14, 9, 8, -15, -2, 19, -4, -13, 10, 7, -16, -1, 18, -5, -12, 11, + 10, -5, -10, 15, 0, -15, 10, 5, -20, 5, 10, -15, 0, 15, -10, -5, 20, -5, + 10, -7, -6, 19, -8, -5, 18, -9, -4, 17, -10, -3, 16, -11, -2, 15, -12, -1, + 10, -9, -2, 13, -16, 5, 6, -17, 12, -1, -10, 19, -8, -3, 14, -15, 4, 7, + 10, -11, 2, 7, -16, 15, -6, -3, 12, -19, 10, -1, -8, 17, -14, 5, 4, -13, + 10, -13, 6, 1, -8, 15, -18, 11, -4, -3, 10, -17, 16, -9, 2, 5, -12, 19, + 10, -15, 10, -5, 0, 5, -10, 15, -20, 15, -10, 5, 0, -5, 10, -15, 20, -15, + 10, -17, 14, -11, 8, -5, 2, 1, -4, 7, -10, 13, -16, 19, -18, 15, -12, 9, + 10, -19, 18, -17, 16, -15, 14, -13, 12, -11, 10, -9, 8, -7, 6, -5, 4, -3 */ +}; + /*low storage IDCT20x18 table */ + +#endif diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index 3ea7a7f4c3..36fadb7898 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -1163,6 +1163,11 @@ extern const Word8 idctT2_24_compressed_idx[]; extern const Word16 unique_idctT2_21coeffsQ16[]; extern const Word8 idctT2_21_compressed_idx[]; +#ifdef ERI_MSVQ_CLEANUP_WB1 +extern const Word16 unique_idctT2_20coeffsQ16[]; +extern const Word8 idctT2_20_compressed_idx[]; +#endif + extern const float idctT2_24_X_matrixFloatQ[]; diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c index d71c24d45c..6f82adcc78 100644 --- a/lib_enc/fd_cng_enc.c +++ b/lib_enc/fd_cng_enc.c @@ -102,7 +102,7 @@ void initFdCngEnc( /* Configure the Noise Estimator */ hsCom->numSlots = 16; hsCom->numCoreBands = 16; - hsCom->regularStopBand = (int16_t) ( input_Fs * INV_CLDFB_BANDWIDTH ); + hsCom->regularStopBand = ( int16_t )( input_Fs * INV_CLDFB_BANDWIDTH ); if ( hsCom->regularStopBand > 40 ) { hsCom->regularStopBand = 40; @@ -556,6 +556,21 @@ void FdCng_encodeSID( /* quantization with stage1 stored in DCT24 domain, stages 2 through 6 directly dearched in FDCNG band domain */ + +#ifdef ERI_MSVQ_CLEANUP_WB1 + if ( N == FDCNG_VQ_MAX_LEN_WB1 || N == FDCNG_VQ_MAX_LEN_WB ) + { + DCTTYPE dcttype = ( N == FDCNG_VQ_MAX_LEN_WB1 ) ? DCT_T2_20_XX : DCT_T2_21_XX; + + create_IDCT_N_Matrix( invTrfMatrix, N, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM ) / ( sizeof( float ) ) ); + /* truncated DCT 20 or DCT 21 analysis */ + dctT2_N_apply_matrix( (const float *) v, dct_target, FDCNG_VQ_DCT_MAXTRUNC, N, invTrfMatrix, FDCNG_VQ_DCT_MAXTRUNC, dcttype ); + /* truncated IDCT_N extension to 24 bands */ + extend_dctN_input( v, dct_target, N, tot_sig_ext, FDCNG_VQ_MAX_LEN, invTrfMatrix, FDCNG_VQ_DCT_MAXTRUNC, dcttype+1 ); + + mvr2r( tot_sig_ext, v, FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 */ + } +#else if ( N == FDCNG_VQ_MAX_LEN_WB ) { create_IDCT_N_Matrix( invTrfMatrix, N, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM ) / ( sizeof( float ) ) ); @@ -566,6 +581,8 @@ void FdCng_encodeSID( mvr2r( tot_sig_ext, v, FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 */ } +#endif + create_IDCT_N_Matrix( invTrfMatrix, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM ) / ( sizeof( float ) ) ); msvq_enc( cdk_37bits_ivas, NULL, NULL, v, levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, w, N, FD_CNG_maxN_37bits, 1, invTrfMatrix, indices ); msvq_dec( cdk_37bits_ivas, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix, v, NULL ); diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index 0f7a798a75..f1a5a8748f 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -277,7 +277,10 @@ int16_t msvq_stage1_dct_search( essentially subtract res21^2 ,res22^2, res23^2 that was included in stage1 MSE in the DCT24 domain truncated search, excludes the waveform contributions at pos 21,22,23 to the MSE, important to keep the WB MSEs update for the subsequent stages */ -int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb( /* o : (updated p_max) */ +int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb( /* o : (updated p_max) */ +#ifdef ERI_MSVQ_CLEANUP_WB1 + const int16_t n, /*i : original target length */ +#endif const float *st1_syn_vec_ptr, /* i : IDCT24 synthesis vectors */ const float *u, /* i : target signal */ const int16_t maxC_st1, /* i : number of candidates in stage1 */ @@ -286,20 +289,39 @@ int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb( { int16_t p_max_local, c; const float *p2; +#ifdef ERI_MSVQ_CLEANUP_WB1 + float res24, high_diff[FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB1]; + + assert( n == FDCNG_VQ_MAX_LEN_WB || n == FDCNG_VQ_MAX_LEN_WB1 ); +#else float res24, high_diff[FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB]; +#endif - for ( c = 0; c < maxC_st1; c++ ) - { /* point to extended synthesis part */ + for ( c = 0; c < maxC_st1; c++ ) + { /* point to extended synthesis part */ +#ifdef ERI_MSVQ_CLEANUP_WB1 + p2 = (const float *) &( st1_syn_vec_ptr[c * FDCNG_VQ_MAX_LEN + n] ); /* ptr init to synthesis candidate c */ + /* for stage#1 use "u" instead of the shortened resid[0], to access the extended/extrapolated input target */ + v_sub( p2, &( u[n] ), high_diff, FDCNG_VQ_MAX_LEN - n ); + res24 = dotp( high_diff, high_diff, FDCNG_VQ_MAX_LEN - n ); /* sum squared over top env. values above WB coeffs */ +#else p2 = (const float *) &( st1_syn_vec_ptr[c * FDCNG_VQ_MAX_LEN + FDCNG_VQ_MAX_LEN_WB] ); /* ptr init to synthesis candidate c */ /* for stage#1 use "u" instead of the shortened resid[0], to access the extended/extrapolated input target */ v_sub( p2, &( u[FDCNG_VQ_MAX_LEN_WB] ), high_diff, FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB ); res24 = dotp( high_diff, high_diff, FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB ); /* sum squared over top env. values above WB coeffs */ +#endif dist_ptr[c] -= res24; /* remove DCT24 high band error contribution */ } + +#ifdef ERI_MSVQ_CLEANUP_WB1 /* finally update p_max, as it may potentially change, + due to the core DCT24 search optimizing over longer basis vectors than DCT (n==20 || n==21 ) */ +#else + /* finally update p_max, as it may potentially change, due to the core DCT24 search originally optimizing over the longer basis vectors than DCT21 */ +#endif p_max_local = maximum( dist_ptr, maxC_st1, NULL ); return p_max_local; @@ -466,7 +488,11 @@ void msvq_enc( if ( !s && applyDCT_flag != 0 ) /* means: m==1 */ { /* stage 1 candidates search in truncated dct24 domain without any weights */ +#ifdef ERI_MSVQ_CLEANUP_WB1 + assert( N == FDCNG_VQ_MAX_LEN || N == FDCNG_VQ_MAX_LEN_WB1 || N == FDCNG_VQ_MAX_LEN_WB ); /* 20, 21 and 24 allowed */ +#else assert( N == FDCNG_VQ_MAX_LEN || N == FDCNG_VQ_MAX_LEN_WB ); /* 21 and 24 allowed */ +#endif assert( maxC == 2 * FDCNG_VQ_DCT_NSEGM ); p_max = msvq_stage1_dct_search( u, FDCNG_VQ_MAX_LEN, maxC, @@ -646,8 +672,14 @@ void msvq_enc( indices[1][c * stages] = indices_st1_local[c]; /* move established stage#1 indices to global MSVQ list structure */ } + +#ifdef ERI_MSVQ_CLEANUP_WB1 + /* extract the selected stage one vectors in DCT domain , apply IDCT_N and scale up */ + /*always extract full length signal(24) to be able to update WB( N==20 || N==21) candidate MSE values */ +#else /* extract the selected stage one vectors in DCT domain , apply IDCT_N and scale up */ /*always extract full length signal(24) to be able to update WB( N==21) candidate MSE values */ +#endif for ( c = 0; c < maxC_pre; c++ ) { dec_FDCNG_MSVQ_stage1( indices_st1_local[c], FDCNG_VQ_MAX_LEN, invTrfMatrix, dcttype + 1, &( st1_syn_vec_ptr[c * FDCNG_VQ_MAX_LEN] ), NULL ); @@ -659,37 +691,86 @@ void msvq_enc( else /* non-DCT Stage #1 code below */ if ( !s ) /* means: m==1 */ - { - /* This loop is identical to the one below, except, that the inner + { + /* This loop is identical to the one below, except, that the inner loop over c=0..m is hardcoded to c=0, since m=1. */ - /* dist[0][0] */ - for ( j = 0; j < levels[s]; j++ ) + /* dist[0][0] */ + for ( j = 0; j < levels[s]; j++ ) + { + en = 0.0f; + /* w,Tmp */ + /* Compute weighted codebook element and its energy */ + for ( c2 = 0; c2 < n; c2++ ) + { + Tmp[start + c2] = w[start + c2] * cbp[c2]; + en += cbp[c2] * Tmp[start + c2]; + } + cbp += maxn; /* pointer is incremented */ + + pTmp = &resid[0][0]; + /* Tmp */ + tmp = ( *pTmp++ ) * Tmp[0]; + for ( c2 = 1; c2 < N; c2++ ) + { + tmp += ( *pTmp++ ) * Tmp[c2]; + } + tmp = en - 2.0f * tmp; + tmp += dist[0][0]; + if ( tmp < dist[1][p_max] ) { - en = 0.0f; - /* w,Tmp */ - /* Compute weighted codebook element and its energy */ - for ( c2 = 0; c2 < n; c2++ ) + /* Replace worst */ + dist[1][p_max] = tmp; + indices[1][p_max * stages] = j; + parents[p_max] = 0; + + p_max = 0; + for ( c2 = 1; c2 < maxC; c2++ ) { - Tmp[start + c2] = w[start + c2] * cbp[c2]; - en += cbp[c2] * Tmp[start + c2]; + if ( dist[1][c2] > dist[1][p_max] ) + { + p_max = c2; + } } - cbp += maxn; /* pointer is incremented */ + } /* if (tmp <= dist[1][p_max]) */ + } /* for (j=0; j dist[1][p_max] ) - { - p_max = c2; - } - } - } /* if (tmp <= dist[1][p_max]) */ - } /* for(c=0; c Date: Tue, 9 May 2023 16:40:22 +0200 Subject: [PATCH 2/3] renamed define to fix#443_* --- lib_com/cnst.h | 4 ++-- lib_com/lsf_tools.c | 4 ++-- lib_com/options.h | 2 +- lib_com/prot.h | 2 +- lib_com/rom_com.c | 2 +- lib_com/rom_com.h | 2 +- lib_enc/fd_cng_enc.c | 2 +- lib_enc/lsf_msvq_ma_enc.c | 14 +++++++------- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index ac93914680..e1fe5bc8cd 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -1395,7 +1395,7 @@ enum #define FDCNG_VQ_DCT_MAXTRUNC 18 #define FDCNG_VQ_MAX_LEN_WB 21 -#ifdef ERI_MSVQ_CLEANUP_WB1 +#ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 #define FDCNG_VQ_MAX_LEN_WB1 20 #endif @@ -1407,7 +1407,7 @@ typedef enum _DCTTYPE IDCT_T2_XX_24 = 1, DCT_T2_21_XX = 2, /* truncated DCT_T2_21 */ IDCT_T2_XX_21 = 3 -#ifdef ERI_MSVQ_CLEANUP_WB1 +#ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 ,DCT_T2_20_XX = 4, /* truncated DCT_T2_20 */ IDCT_T2_XX_20 = 5 #endif diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index 4fa7a7b4d1..3cda98f707 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -2460,7 +2460,7 @@ void dctT2_N_apply_matrix( mat_step_col = matrix_row_dim; /* matrix maximum storage size dependent, width of first row in matrix */ mat_step_row = 0; mat_step_col_flag = 1; -#ifdef ERI_MSVQ_CLEANUP_WB1 +#ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 assert( dcttype == DCT_T2_20_XX || dcttype == DCT_T2_21_XX || dcttype == DCT_T2_24_XX ); #else assert( dcttype == DCT_T2_21_XX || dcttype == DCT_T2_24_XX ); @@ -2573,7 +2573,7 @@ void create_IDCT_N_Matrix( float *inv_matrixFloatQ, const int16_t N, const int16 idx_ptr = idctT2_21_compressed_idx; len = N; } -#ifdef ERI_MSVQ_CLEANUP_WB1 +#ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 if ( N == FDCNG_VQ_MAX_LEN_WB1 ) { absval_ptr = unique_idctT2_20coeffsQ16; diff --git a/lib_com/options.h b/lib_com/options.h index c98c89954e..06fff26458 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -158,7 +158,7 @@ #define ERI_MSVQ_CLEANUP /* Eri: Contribution #31 BE modularization of msvq encoder side DCT21&DCT24 within msvq_enc() */ -#define ERI_MSVQ_CLEANUP_WB1 /*Eri: Contribution #31 non-BE for ISM low rate (total_rate < 8kbps) using WB1 bandwidth */ +#define FIX_443_ERI_MSVQ_CLEANUP_WB1 /*Eri: Contribution 31 ticket #443, added support for fdcng WB1 bandwidth(N==20) used in dyx cond ISM2 at 16.4 kbps (total_rate==4450 <= 8kbps) */ #define FIX_416_ISM_BR_SWITCHING /* FhG: add missing CLDFB reconfig to ISM BR switching */ #define FIX_SP2A /* VA: Issue 412: Adjust threshold for the S_p2a feature in the tonal detector */ diff --git a/lib_com/prot.h b/lib_com/prot.h index a31c999180..f480189970 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -8142,7 +8142,7 @@ int16_t msvq_stage1_dct_search( /* o int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb( /* o : (updated p_max) */ -#ifdef ERI_MSVQ_CLEANUP_WB1 +#ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 const int16_t n, /*i : original target length */ #endif const float *st1_syn_vec_ptr, /* i : IDCT24 synthesis vectors */ diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index b3aa7c5146..89bd0bd03a 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -6140,7 +6140,7 @@ const Word8 idctT2_21_compressed_idx[(FDCNG_VQ_DCT_MAXTRUNC *( (21/2) + 1)) /* }; /*low storage IDCT24x18 table && IDCT21*18 */ -#ifdef ERI_MSVQ_CLEANUP_WB1 +#ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 const Word16 unique_idctT2_20coeffsQ16[21] = { 0, 1626, 3242, 4838, 6404, 7931, 9409, 10828, 12181, 13459, 14654, 15759, 16766, 17670, 18465, 19147, diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index 36fadb7898..f346286c30 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -1163,7 +1163,7 @@ extern const Word8 idctT2_24_compressed_idx[]; extern const Word16 unique_idctT2_21coeffsQ16[]; extern const Word8 idctT2_21_compressed_idx[]; -#ifdef ERI_MSVQ_CLEANUP_WB1 +#ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 extern const Word16 unique_idctT2_20coeffsQ16[]; extern const Word8 idctT2_20_compressed_idx[]; #endif diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c index 6f82adcc78..75dd748b02 100644 --- a/lib_enc/fd_cng_enc.c +++ b/lib_enc/fd_cng_enc.c @@ -557,7 +557,7 @@ void FdCng_encodeSID( in FDCNG band domain */ -#ifdef ERI_MSVQ_CLEANUP_WB1 +#ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 if ( N == FDCNG_VQ_MAX_LEN_WB1 || N == FDCNG_VQ_MAX_LEN_WB ) { DCTTYPE dcttype = ( N == FDCNG_VQ_MAX_LEN_WB1 ) ? DCT_T2_20_XX : DCT_T2_21_XX; diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index f1a5a8748f..0fd208357c 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -278,7 +278,7 @@ int16_t msvq_stage1_dct_search( excludes the waveform contributions at pos 21,22,23 to the MSE, important to keep the WB MSEs update for the subsequent stages */ int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb( /* o : (updated p_max) */ -#ifdef ERI_MSVQ_CLEANUP_WB1 +#ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 const int16_t n, /*i : original target length */ #endif const float *st1_syn_vec_ptr, /* i : IDCT24 synthesis vectors */ @@ -289,7 +289,7 @@ int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb( /* o : (updated p_max) { int16_t p_max_local, c; const float *p2; -#ifdef ERI_MSVQ_CLEANUP_WB1 +#ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 float res24, high_diff[FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB1]; assert( n == FDCNG_VQ_MAX_LEN_WB || n == FDCNG_VQ_MAX_LEN_WB1 ); @@ -299,7 +299,7 @@ int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb( /* o : (updated p_max) for ( c = 0; c < maxC_st1; c++ ) { /* point to extended synthesis part */ -#ifdef ERI_MSVQ_CLEANUP_WB1 +#ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 p2 = (const float *) &( st1_syn_vec_ptr[c * FDCNG_VQ_MAX_LEN + n] ); /* ptr init to synthesis candidate c */ /* for stage#1 use "u" instead of the shortened resid[0], to access the extended/extrapolated input target */ v_sub( p2, &( u[n] ), high_diff, FDCNG_VQ_MAX_LEN - n ); @@ -315,7 +315,7 @@ int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb( /* o : (updated p_max) } -#ifdef ERI_MSVQ_CLEANUP_WB1 +#ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 /* finally update p_max, as it may potentially change, due to the core DCT24 search optimizing over longer basis vectors than DCT (n==20 || n==21 ) */ #else @@ -488,7 +488,7 @@ void msvq_enc( if ( !s && applyDCT_flag != 0 ) /* means: m==1 */ { /* stage 1 candidates search in truncated dct24 domain without any weights */ -#ifdef ERI_MSVQ_CLEANUP_WB1 +#ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 assert( N == FDCNG_VQ_MAX_LEN || N == FDCNG_VQ_MAX_LEN_WB1 || N == FDCNG_VQ_MAX_LEN_WB ); /* 20, 21 and 24 allowed */ #else assert( N == FDCNG_VQ_MAX_LEN || N == FDCNG_VQ_MAX_LEN_WB ); /* 21 and 24 allowed */ @@ -673,7 +673,7 @@ void msvq_enc( } -#ifdef ERI_MSVQ_CLEANUP_WB1 +#ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 /* extract the selected stage one vectors in DCT domain , apply IDCT_N and scale up */ /*always extract full length signal(24) to be able to update WB( N==20 || N==21) candidate MSE values */ #else @@ -818,7 +818,7 @@ void msvq_enc( */ #ifdef ERI_MSVQ_CLEANUP -#ifdef ERI_MSVQ_CLEANUP_WB1 +#ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 if ( s == 0 && applyDCT_flag != 0 && ( n == FDCNG_VQ_MAX_LEN_WB1 || n == FDCNG_VQ_MAX_LEN_WB ) ) { p_max = msvq_stage1_dct_recalc_candidates_fdcng_wb( n, st1_syn_vec_ptr, u, maxC, dist[1] ); -- GitLab From f6b51ca462cd3e0b77d554fbf03a7f59f788c38d Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Tue, 9 May 2023 17:33:48 +0200 Subject: [PATCH 3/3] clang format --- lib_com/lsf_tools.c | 12 +-- lib_com/prot.h | 6 +- lib_com/rom_com.h | 4 +- lib_enc/fd_cng_enc.c | 6 +- lib_enc/lsf_msvq_ma_enc.c | 154 +++++++++++++++++++------------------- 5 files changed, 91 insertions(+), 91 deletions(-) diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index 3cda98f707..eb4276cb9a 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -2462,9 +2462,9 @@ void dctT2_N_apply_matrix( mat_step_col_flag = 1; #ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 assert( dcttype == DCT_T2_20_XX || dcttype == DCT_T2_21_XX || dcttype == DCT_T2_24_XX ); -#else +#else assert( dcttype == DCT_T2_21_XX || dcttype == DCT_T2_24_XX ); -#endif +#endif } else { @@ -2533,7 +2533,7 @@ void extend_dctN_input( i_rev = in_dim; /*ptr init*/ for ( i = in_dim; i < out_dim; i++ ) - { /* for each extension sample */ + { /* for each extension sample */ /* i = 21 22 23; i_rev = 20 19 18; for odd dctII reflect basis vector */ @@ -2570,17 +2570,17 @@ void create_IDCT_N_Matrix( float *inv_matrixFloatQ, const int16_t N, const int16 if ( N == FDCNG_VQ_MAX_LEN_WB ) { absval_ptr = unique_idctT2_21coeffsQ16; - idx_ptr = idctT2_21_compressed_idx; + idx_ptr = idctT2_21_compressed_idx; len = N; } #ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 if ( N == FDCNG_VQ_MAX_LEN_WB1 ) { absval_ptr = unique_idctT2_20coeffsQ16; - idx_ptr = idctT2_20_compressed_idx; + idx_ptr = idctT2_20_compressed_idx; len = N; } -#endif +#endif assert( alloc_size >= ( n_cols * len ) ); /* enough space for the full expanded IDCT matrix */ assert( N <= len ); diff --git a/lib_com/prot.h b/lib_com/prot.h index f480189970..8e7df63db1 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -8141,10 +8141,10 @@ int16_t msvq_stage1_dct_search( /* o ); int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb( - /* o : (updated p_max) */ +/* o : (updated p_max) */ #ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 - const int16_t n, /*i : original target length */ -#endif + const int16_t n, /*i : original target length */ +#endif const float *st1_syn_vec_ptr, /* i : IDCT24 synthesis vectors */ const float *u, /* i : target signal */ const int16_t maxC_st1, /* i : number of candidates in stage1 */ diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index f346286c30..1d0bdf494b 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -1164,9 +1164,9 @@ extern const Word16 unique_idctT2_21coeffsQ16[]; extern const Word8 idctT2_21_compressed_idx[]; #ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 -extern const Word16 unique_idctT2_20coeffsQ16[]; +extern const Word16 unique_idctT2_20coeffsQ16[]; extern const Word8 idctT2_20_compressed_idx[]; -#endif +#endif extern const float idctT2_24_X_matrixFloatQ[]; diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c index 75dd748b02..7859b8f12f 100644 --- a/lib_enc/fd_cng_enc.c +++ b/lib_enc/fd_cng_enc.c @@ -102,7 +102,7 @@ void initFdCngEnc( /* Configure the Noise Estimator */ hsCom->numSlots = 16; hsCom->numCoreBands = 16; - hsCom->regularStopBand = ( int16_t )( input_Fs * INV_CLDFB_BANDWIDTH ); + hsCom->regularStopBand = (int16_t) ( input_Fs * INV_CLDFB_BANDWIDTH ); if ( hsCom->regularStopBand > 40 ) { hsCom->regularStopBand = 40; @@ -560,13 +560,13 @@ void FdCng_encodeSID( #ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 if ( N == FDCNG_VQ_MAX_LEN_WB1 || N == FDCNG_VQ_MAX_LEN_WB ) { - DCTTYPE dcttype = ( N == FDCNG_VQ_MAX_LEN_WB1 ) ? DCT_T2_20_XX : DCT_T2_21_XX; + DCTTYPE dcttype = ( N == FDCNG_VQ_MAX_LEN_WB1 ) ? DCT_T2_20_XX : DCT_T2_21_XX; create_IDCT_N_Matrix( invTrfMatrix, N, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM ) / ( sizeof( float ) ) ); /* truncated DCT 20 or DCT 21 analysis */ dctT2_N_apply_matrix( (const float *) v, dct_target, FDCNG_VQ_DCT_MAXTRUNC, N, invTrfMatrix, FDCNG_VQ_DCT_MAXTRUNC, dcttype ); /* truncated IDCT_N extension to 24 bands */ - extend_dctN_input( v, dct_target, N, tot_sig_ext, FDCNG_VQ_MAX_LEN, invTrfMatrix, FDCNG_VQ_DCT_MAXTRUNC, dcttype+1 ); + extend_dctN_input( v, dct_target, N, tot_sig_ext, FDCNG_VQ_MAX_LEN, invTrfMatrix, FDCNG_VQ_DCT_MAXTRUNC, dcttype + 1 ); mvr2r( tot_sig_ext, v, FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 */ } diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index 0fd208357c..ea3724d25f 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -297,7 +297,7 @@ int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb( /* o : (updated p_max) float res24, high_diff[FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB]; #endif - for ( c = 0; c < maxC_st1; c++ ) + for ( c = 0; c < maxC_st1; c++ ) { /* point to extended synthesis part */ #ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 p2 = (const float *) &( st1_syn_vec_ptr[c * FDCNG_VQ_MAX_LEN + n] ); /* ptr init to synthesis candidate c */ @@ -488,11 +488,11 @@ void msvq_enc( if ( !s && applyDCT_flag != 0 ) /* means: m==1 */ { /* stage 1 candidates search in truncated dct24 domain without any weights */ -#ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 - assert( N == FDCNG_VQ_MAX_LEN || N == FDCNG_VQ_MAX_LEN_WB1 || N == FDCNG_VQ_MAX_LEN_WB ); /* 20, 21 and 24 allowed */ +#ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 + assert( N == FDCNG_VQ_MAX_LEN || N == FDCNG_VQ_MAX_LEN_WB1 || N == FDCNG_VQ_MAX_LEN_WB ); /* 20, 21 and 24 allowed */ #else - assert( N == FDCNG_VQ_MAX_LEN || N == FDCNG_VQ_MAX_LEN_WB ); /* 21 and 24 allowed */ -#endif + assert( N == FDCNG_VQ_MAX_LEN || N == FDCNG_VQ_MAX_LEN_WB ); /* 21 and 24 allowed */ +#endif assert( maxC == 2 * FDCNG_VQ_DCT_NSEGM ); p_max = msvq_stage1_dct_search( u, FDCNG_VQ_MAX_LEN, maxC, @@ -672,14 +672,14 @@ void msvq_enc( indices[1][c * stages] = indices_st1_local[c]; /* move established stage#1 indices to global MSVQ list structure */ } - -#ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 + +#ifdef FIX_443_ERI_MSVQ_CLEANUP_WB1 /* extract the selected stage one vectors in DCT domain , apply IDCT_N and scale up */ /*always extract full length signal(24) to be able to update WB( N==20 || N==21) candidate MSE values */ -#else +#else /* extract the selected stage one vectors in DCT domain , apply IDCT_N and scale up */ /*always extract full length signal(24) to be able to update WB( N==21) candidate MSE values */ -#endif +#endif for ( c = 0; c < maxC_pre; c++ ) { dec_FDCNG_MSVQ_stage1( indices_st1_local[c], FDCNG_VQ_MAX_LEN, invTrfMatrix, dcttype + 1, &( st1_syn_vec_ptr[c * FDCNG_VQ_MAX_LEN] ), NULL ); @@ -691,86 +691,37 @@ void msvq_enc( else /* non-DCT Stage #1 code below */ if ( !s ) /* means: m==1 */ - { - /* This loop is identical to the one below, except, that the inner - loop over c=0..m is hardcoded to c=0, since m=1. */ - /* dist[0][0] */ - for ( j = 0; j < levels[s]; j++ ) { - en = 0.0f; - /* w,Tmp */ - /* Compute weighted codebook element and its energy */ - for ( c2 = 0; c2 < n; c2++ ) - { - Tmp[start + c2] = w[start + c2] * cbp[c2]; - en += cbp[c2] * Tmp[start + c2]; - } - cbp += maxn; /* pointer is incremented */ - - pTmp = &resid[0][0]; - /* Tmp */ - tmp = ( *pTmp++ ) * Tmp[0]; - for ( c2 = 1; c2 < N; c2++ ) - { - tmp += ( *pTmp++ ) * Tmp[c2]; - } - tmp = en - 2.0f * tmp; - tmp += dist[0][0]; - if ( tmp < dist[1][p_max] ) + /* This loop is identical to the one below, except, that the inner + loop over c=0..m is hardcoded to c=0, since m=1. */ + /* dist[0][0] */ + for ( j = 0; j < levels[s]; j++ ) { - /* Replace worst */ - dist[1][p_max] = tmp; - indices[1][p_max * stages] = j; - parents[p_max] = 0; - - p_max = 0; - for ( c2 = 1; c2 < maxC; c2++ ) + en = 0.0f; + /* w,Tmp */ + /* Compute weighted codebook element and its energy */ + for ( c2 = 0; c2 < n; c2++ ) { - if ( dist[1][c2] > dist[1][p_max] ) - { - p_max = c2; - } + Tmp[start + c2] = w[start + c2] * cbp[c2]; + en += cbp[c2] * Tmp[start + c2]; } - } /* if (tmp <= dist[1][p_max]) */ - } /* for (j=0; j dist[1][p_max] ) + { + p_max = c2; + } + } + } /* if (tmp <= dist[1][p_max]) */ + } /* for(c=0; c