diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index 30ade5444ded3be6b7ffa7548147b588f007fb3f..02a735e80c0baf8914c90526bd7fde29581f5dd8 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -2066,7 +2066,7 @@ void dec_FDCNG_MSVQ_stage1( for ( col = 0; col < cdk1_ivas_cols_per_segment[segm_ind]; col++ ) { dct_vec[col] = (float) ( ( (Word16) cbpW8[col] ) << dct_col_shift_tab[col] ); - /* LOGIC( 1 );SHIFT( 1 ); ADD( 1 ); + /* LOGIC( 1 ); SHIFT( 1 ); ADD( 1 ); in BASOP: s_and(for W8->W16), shl(), sub() */ } diff --git a/lib_com/options.h b/lib_com/options.h index cc884679fc690211305312fc577d3c593f019964..d841a798e20bf1070ae3b84ec88d6d49ae03abef 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -156,6 +156,9 @@ #define FIX_419_ISM_BRATE_SW_DTX /* VA: issue 419: fix ISM Bitrate Switching with dtx */ #define FIX_422 /* FhG: Issue 422: re-introduce fix for noisy speech buffer in ParamISM */ + +#define ERI_MSVQ_CLEANUP /* Eri: Contribution #31 BE modularization of msvq encoder side DCT21&DCT24 within msvq_enc() */ + #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 33fba361ce3cdb1c0814c84c4d0567adc9990a5d..69bcaa6647e5993a78d229b349a279ab79e90b4d 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -8076,6 +8076,7 @@ void msvq_dec( Word16 *uq_ind /* o : quantized vector (fixed point) */ ); + void dec_FDCNG_MSVQ_stage1( int16_t j_full, /* i: index full range */ int16_t n, /* i: dimension to generate */ @@ -8112,6 +8113,42 @@ void extend_dctN_input( const int16_t n_cols, /* i: number of columns == truncation length */ DCTTYPE dcttype ); /* i: matrix type */ +#ifdef ERI_MSVQ_CLEANUP +int16_t msvq_stage1_dct_search( /* o : (p_max , best candidate sofar ) */ + const float *u, /* i : target */ + const int16_t N, /* i : target length and IDCT synthesis length */ + const int16_t maxC_st1, /* i : number of final stage 1 candidates to provide */ + const DCTTYPE dcttype, /* e.g. DCT_T2_16_XX, DCT_T2_24_XX; */ + const int16_t max_dct_trunc, /* i: maximum of truncation lenghts */ + float *invTrfMatrix, /* i : IDCT synthesis matrix for dim N */ + const float *midQ_truncQ, /* i: midQ vector */ + const float *dct_invScaleF, /* i: global inv scale factors*/ + const float *dct_scaleF, /* i: global scale factors*/ + const Word16 n_segm, /* i: number of segments */ + const Word16 *cols_per_segment, /* i: remaining length per segment */ + const Word16 *trunc_dct_cols_per_segment, /* i: trunc length per segment */ + const Word16 *entries_per_segment, /* i: number of rows per segment */ + const Word16 *cum_entries_per_segment, /* i: number of cumulative entries */ + const Word8 *const W8Qx_dct_sections[], /*i: Word8(byte) segment table ptrs */ + const Word16 *col_syn_shift[], /*i: columnwise syn shift tables */ + const Word8 *segm_neighbour_fwd, /*i: circular neighbour list fwd */ + const Word8 *segm_neighbour_rev, /*i: circular neighbour list reverse */ + const Word16 npost_check, /*i: number of neigbours to check , should be even */ + float *st1_mse_ptr, /*i: dynRAM buffer for MSEs */ + int16_t *indices_st1_local, /*o: selected cand indices */ + float *st1_syn_vec_ptr, /*i/o: buffer for IDCT24 synthesis */ + float *dist1_ptr /*o: resulting stage 1 MSEs in DCT-N domain */ +); + +int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb( + /* o : (updated p_max) */ + 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 */ + float *dist_ptr /* i/o: updated MSE vector for stage1 */ +); +#endif + void PulseResynchronization( const float *src_exc, /* i : Input excitation buffer */ float *dst_exc, /* o : output excitation buffer */ diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c index 4d1cfb0a5cf083e32b582825641c9b2c6bf0c9e4..d71c24d45c0c8a1d04170f0f884658ab2cccbbcf 100644 --- a/lib_enc/fd_cng_enc.c +++ b/lib_enc/fd_cng_enc.c @@ -1264,6 +1264,7 @@ void FdCngEncodeDiracMDCTStereoSID( E[0] = sum_f( ms_ptr[0], NPART ); /* TBD Note: NPART should likely be N[0] if N[0] may change */ + /* Quantize M noise shape */ /* Normalize MSVQ input */ gain[0] = sum_f( ms_ptr[0] + N_GAIN_MIN, N_GAIN_MAX - N_GAIN_MIN ); diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index 44844839cd43e94720e99512ef26caff7b46512c..0f7a798a75a8971530b55965a1ae43a7cb1b5a64 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -50,7 +50,262 @@ #include "ivas_prot.h" -void dctT2_N_apply_matrix( const float *input, float *output, const int16_t dct_dim, int16_t fdcngvq_dim, const float *idctT2_24_X_matrixQ16, const int16_t matrix_1st_dim, DCTTYPE dcttype ); + +// void dctT2_N_apply_matrix( const float *input, float *output, const int16_t dct_dim, int16_t fdcngvq_dim, const float *idctT2_24_X_matrixQ16, const int16_t matrix_1st_dim, DCTTYPE dcttype ); + + +#ifdef ERI_MSVQ_CLEANUP + +int16_t msvq_stage1_dct_search( + /* o : (p_max , best candidate sofar ) */ + const float *u, /* i : target */ + const int16_t N, /* i : target length and IDCT synthesis length */ + + /* parameterization of segmented DCT domain storage */ + const int16_t maxC_st1, /* i : number of final stage 1 candidates to provide */ + + const DCTTYPE dcttype, /* e.g. DCT_T2_16_XX, DCT_T2_24_XX; */ + const int16_t max_dct_trunc, /* i: maximum of truncation lenghts */ + float *invTrfMatrix, /* i : IDCT synthesis matrix for dim N */ + + const float *midQ_truncQ, /* i: midQ vector */ + const float *dct_invScaleF, /* i: global inv scale factors*/ + const float *dct_scaleF, /* i: global scale factors*/ + const Word16 n_segm, /* i: number of segments */ + const Word16 *cols_per_segment, /* i: remaining length per segment */ + const Word16 *trunc_dct_cols_per_segment, /* i: trunc length per segment */ + const Word16 *entries_per_segment, /* i: number of rows per segment */ + const Word16 *cum_entries_per_segment, /* i: number of cumulative entries */ + + const Word8 *const W8Qx_dct_sections[], /*i: Word8(byte) segment table ptrs */ + const Word16 *col_syn_shift[], /*i: columnwise syn shift tables */ + const Word8 *segm_neighbour_fwd, /*i: circular neighbour list fwd */ + const Word8 *segm_neighbour_rev, /*i: circular neighbour list reverse */ + const Word16 npost_check, /*i: number of neigbours to check , should be even */ + + float *st1_mse_ptr, /*i: dynRAM buffer for MSEs */ + int16_t *indices_st1_local, /*o: selected cand indices */ + float *st1_syn_vec_ptr, /*i/o: buffer for IDCT24 synthesis */ + float *dist1_ptr /*o: resulting stage 1 MSEs in DCT-N domain */ +) +{ /* stage1 search in a segmentwise truncated dct N domain without weights */ + + float dct_target[FDCNG_VQ_DCT_MAXTRUNC]; + float u_mr[FDCNG_VQ_MAX_LEN]; + float u_mr_scaled[FDCNG_VQ_MAX_LEN]; + float mse_trunc_segm[FDCNG_VQ_DCT_NSEGM]; + float tmp, check_mse; + float mse; /* Word32 in BASOP */ + + int16_t p_max, c, c2, segm, j_full, j, i; + int16_t n_ana, p_mins[2], idx_min[2]; + + const Word8 *cbpW8; + const Word16 *dct_col_shift_tab; + + float *st1_mse_pair; + int16_t *st1_idx_pair; + + float tmp2; + int16_t check_ind[FDCNG_VQ_DCT_NPOST]; + assert( ( npost_check % 2 == 0 ) && ( npost_check <= FDCNG_VQ_DCT_NPOST ) ); + + assert( n_segm <= FDCNG_VQ_DCT_NSEGM ); + + n_ana = N; /* VQ stage#1 core is currently always using stored DCT N coeffs */ + assert( n_ana >= max_dct_trunc ); /* check for FDCNGVQ WB , SWB, FB operation */ + + /* remove mid stage#1 vector, in original input domain */ + v_sub( u, midQ_truncQ, u_mr, n_ana ); + + v_multc( u_mr, dct_invScaleF[1], u_mr_scaled, n_ana ); /* scale up target to upscaled W8x storage domain */ + /* 16.0-->scale up from Q0 to search domain in Q4, not really needed in BASOP , impl. by shifts */ + + dctT2_N_apply_matrix( (const float *) u_mr_scaled, dct_target, min( max_dct_trunc, n_ana ), n_ana, invTrfMatrix, max_dct_trunc, dcttype ); + + /* init search state ptr's at the top */ + set_f( dist1_ptr, FLT_MAX, maxC_st1 ); + st1_mse_pair = &( dist1_ptr[0] ); /* req. ptr post upd +=2 */ + st1_idx_pair = &( indices_st1_local[0] ); /* req. ptr post upd +=2 */ + set_f( mse_trunc_segm, 0.0f, n_segm ); + + for ( segm = 0; segm < n_segm; segm++ ) + { /* point to a new paired location for each segment */ + p_max = 0; /* req. to point to one of 1 or 0, this init can potentially be omitted here,as p_max is always 1 or 0 */ + + /* compute segment common trunction error in dctN domain */ + mse_trunc_segm[segm] += sum2_f( (const float *) ( &( dct_target[cols_per_segment[segm]] ) ), trunc_dct_cols_per_segment[segm] ); + + cbpW8 = W8Qx_dct_sections[segm]; /* Word8 column variable Qx storage , table ptr init */ + + for ( j = 0; j < entries_per_segment[segm]; j++ ) + { + /* unweighted segmented search DCT domain loop */ + j_full = j + cum_entries_per_segment[segm]; /* or simply use j_full++ */ + + mse = mse_trunc_segm[segm]; /* init mse with with common mse truncation part, in BASOP a move32() */ + + dct_col_shift_tab = col_syn_shift[segm]; /* ptr init */ + + for ( c2 = 0; c2 < cols_per_segment[segm]; c2++ ) + { +#define WMC_TOOL_SKIP + tmp = dct_target[c2] - (float) ( ( (Word16) cbpW8[c2] ) << dct_col_shift_tab[c2] ); /* Word8 storage MSE inner loop */ + LOGIC( 1 ); + SHIFT( 1 ); + ADD( 1 ); /* in BASOP: s_and(for W8->W16), shl(), sub()*/ +#undef WMC_TOOL_SKIP + mse += tmp * tmp; /* L_mac or L_mac0() square Word16 -> Word32*/ + } + st1_mse_ptr[j_full] = mse; /* save MSE in shared dynamic RAM, move32() in BASOP */ + +#define WMC_TOOL_SKIP + cbpW8 += cols_per_segment[segm]; /* fixed pointer increment for each segment */ +#undef WMC_TOOL_SKIP + + /* overwrite with a new worst index at p_max */ + + /* Note: The three inner loop if's below are not 100% properly instrumented by WMC tool */ + if ( mse < st1_mse_pair[p_max] ) /* L_sub */ + { + st1_idx_pair[p_max] = j_full; /* move16, single BASOP */ + } /* BASOP 2 ops */ + + if ( st1_idx_pair[p_max] == j_full ) + { /* idx updated --> also update mse */ + st1_mse_pair[p_max] = mse; /* move32(), single BASOP */ + } /* BASOP 3 ops */ + + /* avoid WC costly candidate list management by always updating p_max, + as we have only a pair in each segment to maintain */ + p_max = 0; /* move16() */ + if ( ( st1_mse_pair[0] - st1_mse_pair[1] ) < 0 ) /* L_sub()*/ + { + p_max = 1; /* move16() */ + } /* BASOP 3 ops ,Note 2 ops possible in BASOP with L_sub and L_lshr */ + + /* Note: logical shift right not available in ANSI-C */ + /* p_max = (st1_mse_pair[0] - st1_mse_pair[1]) ">>>" 31; */ + /* in java logical shift right is available as >>> , in BASOP it is available as L_lshr */ + + /* Cost: weighted sum with cond moves ('if') => 8 in float , 7 in BASOP with L_lshr */ + } /* j in section */ + + st1_mse_pair += 2; /* req. ptr init */ + st1_idx_pair += 2; /* req. ptr init */ + + } /* next segment */ + + for ( j = 0; j < maxC_st1; j++ ) + { + /* compute_full mse using stored DCT24 domain MSE's */ + /* calculate MSE from stage1 inner using existing inner DCT domain variables */ + dist1_ptr[j] *= dct_scaleF[2]; /* multiplication to get the DCT inner MSE scale to the correct input domain */ + } + + assert( ( maxC_st1 >= 3 ) ); + assert( ( maxC_st1 <= 8 ) ); + + p_max = maximum( dist1_ptr, maxC_st1, NULL ); /* establish current worst candidate for MSVQ stage#2 among all maxC_st1 candidates so far */ + + p_mins[0] = minimum( dist1_ptr, maxC_st1, NULL ); /* find best entry among all maxC_pre */ + tmp = dist1_ptr[p_mins[0]]; + dist1_ptr[p_mins[0]] = FLT_MAX; /* exclude 1st */ + + p_mins[1] = minimum( dist1_ptr, maxC_st1, NULL ); /* find 2nd best entry */ + tmp2 = dist1_ptr[p_mins[1]]; + dist1_ptr[p_mins[1]] = FLT_MAX; /* exclude 2nd */ + + dist1_ptr[p_mins[0]] = tmp; /* restore 1st */ + dist1_ptr[p_mins[1]] = tmp2; /* restore 2nd */ + + idx_min[0] = indices_st1_local[p_mins[0]]; + idx_min[1] = indices_st1_local[p_mins[1]]; + + + /* use global exclusion list to never reselect the two (best) global MSE values sofar */ + st1_mse_ptr[idx_min[0]] = FLT_MAX; /* move32() */ + st1_mse_ptr[idx_min[1]] = FLT_MAX; /* move32() */ + + /* circular MSE-neigbour list in use to potentially replace some segment search candidates */ + /* using both 1st and 2nd best neighbours in fwd and rev directions */ + check_ind[0] = segm_neighbour_fwd[idx_min[0]]; + check_ind[1] = segm_neighbour_rev[idx_min[0]]; + + check_ind[2] = segm_neighbour_fwd[idx_min[1]]; + check_ind[3] = segm_neighbour_rev[idx_min[1]]; + + check_ind[4] = segm_neighbour_fwd[check_ind[0]]; + check_ind[5] = segm_neighbour_rev[check_ind[1]]; + + check_ind[6] = segm_neighbour_fwd[check_ind[2]]; + check_ind[FDCNG_VQ_DCT_NPOST - 1] = segm_neighbour_rev[check_ind[3]]; + + for ( i = 0; i < npost_check; i++ ) + { + /* move MSE from DCT-inner loop search to input synthesis domain */ + /* multiplication by fdcng_dct_scaleF[2] to get the float outer loop scale correct in IDCT synthesis domain */ + check_mse = st1_mse_ptr[check_ind[i]] * dct_scaleF[2]; + + if ( check_mse < dist1_ptr[p_max] ) + { /* new winner , replace worst */ + dist1_ptr[p_max] = check_mse; + indices_st1_local[p_max] = check_ind[i]; + st1_mse_ptr[check_ind[i]] = FLT_MAX; /* exclude, BASOP: move32() */ + p_max = maximum( dist1_ptr, maxC_st1, NULL ); /* establish a new current worst candidate among all maxC */ + } + } + + /* extract the selected stage one vectors in DCT_N domain , apply IDCT_N and scale up */ + /* always extract full length signal(e.g. 24) to be able to update WB(e.g. N_in==21) candidate MSE values */ + /* in the case that only a part of the IDCT N vector is in final use */ + + /* note: synthesis not yet fully parameterized/generalized for other IDCT lengths */ + assert( N == 24 ); + { + for ( c = 0; c < maxC_st1; c++ ) + { + dec_FDCNG_MSVQ_stage1( indices_st1_local[c], N, invTrfMatrix, dcttype + 1, &( st1_syn_vec_ptr[c * N] ), NULL ); + } + } + + return p_max; /*ptr to worst performing candidate */ +} + + +/* recalc MSE for fdcng WB(0..20) coeffs , + 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) */ + 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 */ + float *dist_ptr /* i/o: updated MSE vector for stage1 */ +) +{ + int16_t p_max_local, c; + const float *p2; + float res24, high_diff[FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB]; + + for ( c = 0; c < maxC_st1; c++ ) + { /* point to extended synthesis part */ + 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 */ + + dist_ptr[c] -= res24; /* remove DCT24 high band error contribution */ + } + + /* finally update p_max, as it may potentially change, + due to the core DCT24 search originally optimizing over the longer basis vectors than DCT21 */ + p_max_local = maximum( dist_ptr, maxC_st1, NULL ); + + return p_max_local; +} +#endif + /*--------------------------------------------------------------------------* * msvq_enc() @@ -82,8 +337,7 @@ void msvq_enc( float resid_buf[2 * LSFMBEST_MAX * M_MAX], dist_buf[2 * LSFMBEST_MAX], Tmp[M_MAX]; int16_t idx_buf[2 * LSFMBEST_MAX * MAX_VQ_STAGES_USED], parents[LSFMBEST_MAX]; int16_t n, maxn, start; - - +#ifndef ERI_MSVQ_CLEANUP /* buffers */ float dct_target[FDCNG_VQ_DCT_MAXTRUNC]; float u_mr[FDCNG_VQ_MAX_LEN]; @@ -104,20 +358,27 @@ void msvq_enc( int16_t check_ind[FDCNG_VQ_DCT_NPOST]; int16_t segm, j_full, maxC_pre; - float *st1_syn_vec_ptr; /* 8* 24 floats in dynRAM */ - float *st1_mse_ptr; /* 2^7 == 128 floats in existing dRAM used for stage 1 candidate analysis, 128 Word32 in BASOP */ +#endif + float *st1_syn_vec_ptr; /* ptr to buffer in dynRAM */ + float *st1_mse_ptr; /* ptr to buffer in existing dRAM used for stage 1 candidate analysis */ +#ifdef ERI_MSVQ_CLEANUP + int16_t indices_st1_local[FDCNG_VQ_DCT_NSEGM * 2]; /* after stage#1 DCT search this is copied to the global indices[1][s*stages] structure */ +#else float res24, high_diff[FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB]; - maxC_pre = ( FDCNG_VQ_DCT_NSEGM * 2 ); +#endif assert( maxC <= LSFMBEST_MAX ); assert( ( LSFMBEST_MAX * M_MAX ) > ( N * maxC ) ); /* top of resid_buf is resid[1] and used for stage#1 residuals (input target u), - we here reuse resid[0] part of the buffer for stage#1 DCT dynamic RAM needs - */ - st1_mse_ptr = &( resid_buf[1 * LSFMBEST_MAX * M_MAX] ) - ( levels[0] ); /* reuse top of residual resid[0] scratch RAM for stage1 MSEs */ + we here reuse resid[0] part of the buffer for stage#1 DCT dynamic RAM needs */ + st1_mse_ptr = &( resid_buf[1 * LSFMBEST_MAX * M_MAX] ) - ( levels[0] ); /* reuse top of residual resid[0] scratch RAM for stage1 MSEs */ + st1_syn_vec_ptr = &( resid_buf[1 * LSFMBEST_MAX * M_MAX] ) - FDCNG_VQ_MAX_LEN * maxC; /* reuse top of resid[0] scratch RAM for residual */ +#ifndef ERI_MSVQ_CLEANUP dcttype = DCT_T2_24_XX; +#endif + /*----------------------------------------------------------------* * Allocate memory for previous (parent) and current nodes. @@ -201,6 +462,40 @@ void msvq_enc( dist[1][j] = FLT_MAX; } +#ifdef ERI_MSVQ_CLEANUP + if ( !s && applyDCT_flag != 0 ) /* means: m==1 */ + { + /* stage 1 candidates search in truncated dct24 domain without any weights */ + assert( N == FDCNG_VQ_MAX_LEN || N == FDCNG_VQ_MAX_LEN_WB ); /* 21 and 24 allowed */ + assert( maxC == 2 * FDCNG_VQ_DCT_NSEGM ); + + p_max = msvq_stage1_dct_search( u, FDCNG_VQ_MAX_LEN, maxC, + DCT_T2_24_XX, + FDCNG_VQ_DCT_MAXTRUNC, + invTrfMatrix, /* i : IDCT synthesis matrix for dim N */ + cdk1r_tr_midQ_truncQ, /* i: midQ vector */ + fdcng_dct_invScaleF, /* i: global inv scale factors*/ + fdcng_dct_scaleF, /* i: global scale factors*/ + FDCNG_VQ_DCT_NSEGM, /* i: number of segments */ + cdk1_ivas_cols_per_segment, /* i: remaining length per segment */ + cdk1_ivas_trunc_dct_cols_per_segment, /* i: trunc length per segment */ + cdk1_ivas_entries_per_segment, /* i: number of rows per segment */ + cdk1_ivas_cum_entries_per_segment, /* i: number of cumulative entries */ + cdk_37bits_ivas_stage1_W8Qx_dct_sections, /*i: Word8(byte) segment table ptrs */ + stage1_dct_col_syn_shift, /*i: columnwise syn shift tables */ + cdk1_ivas_segm_neighbour_fwd, /*i: circular neighbour list fwd */ + cdk1_ivas_segm_neighbour_rev, /*i: circular neighbour list reverse */ + FDCNG_VQ_DCT_NPOST, /*i: number of circ. neigbours to post check */ + st1_mse_ptr, indices_st1_local, st1_syn_vec_ptr, dist[1] ); + + + /* move established stage#1 indices to the global MSVQ list structure */ + for ( c = 0; c < maxC; c++ ) + { + indices[1][c * stages] = indices_st1_local[c]; + } + } +#else if ( !s && applyDCT_flag != 0 ) /* means: m==1 */ { /* stage 1 search in truncated dct domain without any weights */ @@ -255,7 +550,7 @@ void msvq_enc( mse += tmp * tmp; /* L_mac or L_mac0() square Word16 -> Word32*/ } - st1_mse_ptr[j_full] = mse; /* save MSE in shared dynamic 2^7=128 RAM, move32() in BASOP */ + st1_mse_ptr[j_full] = mse; /* save MSE in shared dynamic 2^7=128 RAM, move32() in BASOP */ #define WMC_TOOL_SKIP cbpW8 += cdk1_ivas_cols_per_segment[segm]; /* pointer increment */ @@ -360,12 +655,13 @@ void msvq_enc( assert( maxC == maxC_pre ); } +#endif 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. */ + loop over c=0..m is hardcoded to c=0, since m=1. */ /* dist[0][0] */ for ( j = 0; j < levels[s]; j++ ) { @@ -488,6 +784,12 @@ void msvq_enc( 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 WB MSEs update for the subsequent stages */ +#ifdef ERI_MSVQ_CLEANUP + if ( s == 0 && applyDCT_flag != 0 && n == FDCNG_VQ_MAX_LEN_WB ) + { + p_max = msvq_stage1_dct_recalc_candidates_fdcng_wb( st1_syn_vec_ptr, u, maxC, dist[1] ); + } +#else if ( s == 0 && applyDCT_flag != 0 && n == FDCNG_VQ_MAX_LEN_WB ) { assert( start == 0 ); @@ -503,6 +805,7 @@ void msvq_enc( /* update p_max, as it may potentially change, due to the core DCT24 search originally optimizing over longer basis vectors than 21 */ p_max = maximum( dist[1], maxC, NULL ); } +#endif m = maxC; } /* for (m=1, s=0; s