diff --git a/silk/A2NLSF.c b/silk/A2NLSF.c index 165049aa432d1e3cdf0799140733e8f3406abf7e..b487686ff9c6d129c0656fb1095de8a289fc4dba 100644 --- a/silk/A2NLSF.c +++ b/silk/A2NLSF.c @@ -245,7 +245,7 @@ void silk_A2NLSF( } /* Error: Apply progressively more bandwidth expansion and run again */ - silk_bwexpander_32( a_Q16, d, 65536 - silk_LSHIFT( 1, i ) ); + silk_bwexpander_32( a_Q16, d, 65536 - silk_LSHIFT( 1, i ) ); silk_A2NLSF_init( a_Q16, P, Q, dd ); p = P; /* Pointer to polynomial */ diff --git a/silk/LPC_fit.c b/silk/LPC_fit.c index 69ff39586d65a56f7707dc0de79396fe4f10bcec..cdea4f3abcaf7fcd141a4b86e2f924b679effd94 100644 --- a/silk/LPC_fit.c +++ b/silk/LPC_fit.c @@ -34,14 +34,14 @@ POSSIBILITY OF SUCH DAMAGE. /* Convert int32 coefficients to int16 coefs and make sure there's no wrap-around */ void silk_LPC_fit( opus_int16 *a_QOUT, /* O Output signal */ - opus_int32 *a_QIN, /* I/O Input signal */ + opus_int32 *a_QIN, /* I/O Input signal */ const opus_int QOUT, /* I Input Q domain */ const opus_int QIN, /* I Input Q domain */ const opus_int d /* I Filter order */ ) { - opus_int i, k, idx = 0; - opus_int32 maxabs, absval, chirp_Q16; + opus_int i, k, idx = 0; + opus_int32 maxabs, absval, chirp_Q16; /* Limit the maximum absolute value of the prediction coefficients, so that they'll fit in int16 */ for( i = 0; i < 10; i++ ) { diff --git a/silk/LPC_inv_pred_gain.c b/silk/LPC_inv_pred_gain.c index cb9983f50f18354bb3ff8a878fd8980bed38dc53..257b28fd567ef2834c14e47249fa7fffc280c344 100644 --- a/silk/LPC_inv_pred_gain.c +++ b/silk/LPC_inv_pred_gain.c @@ -79,7 +79,7 @@ static opus_int32 LPC_inverse_pred_gain_QA( /* O Returns inver for( n = 0; n < (k + 1) >> 1; n++ ) { tmp1 = A_QA[ n ]; tmp2 = A_QA[ k - n - 1 ]; - A_QA[ n ] = MUL32_FRAC_Q( tmp1 - MUL32_FRAC_Q( tmp2, rc_Q31, 31 ), rc_mult2, mult2Q ); + A_QA[ n ] = MUL32_FRAC_Q( tmp1 - MUL32_FRAC_Q( tmp2, rc_Q31, 31 ), rc_mult2, mult2Q ); A_QA[ k - n - 1 ] = MUL32_FRAC_Q( tmp2 - MUL32_FRAC_Q( tmp1, rc_Q31, 31 ), rc_mult2, mult2Q ); } } diff --git a/silk/NSQ.c b/silk/NSQ.c index 0f49c0d4bb315146618d6adac06d75737fc6c945..9fb05a80cfa261ae7c9515c1eb81c3b512580ab3 100644 --- a/silk/NSQ.c +++ b/silk/NSQ.c @@ -78,7 +78,7 @@ void silk_NSQ_c const silk_encoder_state *psEncC, /* I/O Encoder State */ silk_nsq_state *NSQ, /* I/O NSQ state */ SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x16[], /* I Input */ + const opus_int16 x16[], /* I Input */ opus_int8 pulses[], /* O Quantized pulse signal */ const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ @@ -436,7 +436,7 @@ static OPUS_INLINE void silk_nsq_scale_states( NSQ->sAR2_Q14[ i ] = silk_SMULWW( gain_adj_Q16, NSQ->sAR2_Q14[ i ] ); } - /* Save inverse gain */ + /* Save inverse gain */ NSQ->prev_gain_Q16 = Gains_Q16[ subfr ]; } } diff --git a/silk/NSQ_del_dec.c b/silk/NSQ_del_dec.c index e23205b4b591c8b381871e448aab3cf19999e576..709dc85899e692eb30df06cd8f2b9a7b40a6056b 100644 --- a/silk/NSQ_del_dec.c +++ b/silk/NSQ_del_dec.c @@ -118,7 +118,7 @@ void silk_NSQ_del_dec_c( const silk_encoder_state *psEncC, /* I/O Encoder State */ silk_nsq_state *NSQ, /* I/O NSQ state */ SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x16[], /* I Input */ + const opus_int16 x16[], /* I Input */ opus_int8 pulses[], /* O Quantized pulse signal */ const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ diff --git a/silk/SigProc_FIX.h b/silk/SigProc_FIX.h index 4d0e7df81baf0c2c07251a9db8ffa783a1f0ba7f..c45d187fa9d3087fc0a06abc93403abfe790ded0 100644 --- a/silk/SigProc_FIX.h +++ b/silk/SigProc_FIX.h @@ -277,7 +277,7 @@ void silk_NLSF2A( /* Convert int32 coefficients to int16 coefs and make sure there's no wrap-around */ void silk_LPC_fit( opus_int16 *a_QOUT, /* O Output signal */ - opus_int32 *a_QIN, /* I/O Input signal */ + opus_int32 *a_QIN, /* I/O Input signal */ const opus_int QOUT, /* I Input Q domain */ const opus_int QIN, /* I Input Q domain */ const opus_int d /* I Filter order */ diff --git a/silk/VQ_WMat_EC.c b/silk/VQ_WMat_EC.c index d33da26dda4216fed72fc6880d7b17fe10ebc5c8..67e6341875599e58d602dde9e423484f6b7c9841 100644 --- a/silk/VQ_WMat_EC.c +++ b/silk/VQ_WMat_EC.c @@ -34,38 +34,38 @@ POSSIBILITY OF SUCH DAMAGE. /* Entropy constrained matrix-weighted VQ, hard-coded to 5-element vectors, for a single input data vector */ void silk_VQ_WMat_EC_c( opus_int8 *ind, /* O index of best codebook vector */ - opus_int32 *res_nrg_Q15, /* O best residual energy */ - opus_int32 *rate_dist_Q8, /* O best total bitrate */ - const opus_int32 *XX_Q17, /* I correlation matrix */ - const opus_int32 *xX_Q17, /* I correlation vector */ + opus_int32 *res_nrg_Q15, /* O best residual energy */ + opus_int32 *rate_dist_Q8, /* O best total bitrate */ + const opus_int32 *XX_Q17, /* I correlation matrix */ + const opus_int32 *xX_Q17, /* I correlation vector */ const opus_int8 *cb_Q7, /* I codebook */ const opus_uint8 *cl_Q5, /* I code length for each codebook vector */ - const opus_int subfr_len, /* I number of samples per subframe */ + const opus_int subfr_len, /* I number of samples per subframe */ const opus_int L /* I number of vectors in codebook */ ) { opus_int k; const opus_int8 *cb_row_Q7; - opus_int32 neg_xX_Q24[ 5 ]; + opus_int32 neg_xX_Q24[ 5 ]; opus_int32 sum1_Q15, sum2_Q24, sum1_best_Q15; - opus_int32 bits_res_Q8, bits_tot_Q8; + opus_int32 bits_res_Q8, bits_tot_Q8; - /* Negate and convert to new Q domain */ - neg_xX_Q24[ 0 ] = -silk_LSHIFT32( xX_Q17[ 0 ], 7 ); - neg_xX_Q24[ 1 ] = -silk_LSHIFT32( xX_Q17[ 1 ], 7 ); - neg_xX_Q24[ 2 ] = -silk_LSHIFT32( xX_Q17[ 2 ], 7 ); - neg_xX_Q24[ 3 ] = -silk_LSHIFT32( xX_Q17[ 3 ], 7 ); - neg_xX_Q24[ 4 ] = -silk_LSHIFT32( xX_Q17[ 4 ], 7 ); + /* Negate and convert to new Q domain */ + neg_xX_Q24[ 0 ] = -silk_LSHIFT32( xX_Q17[ 0 ], 7 ); + neg_xX_Q24[ 1 ] = -silk_LSHIFT32( xX_Q17[ 1 ], 7 ); + neg_xX_Q24[ 2 ] = -silk_LSHIFT32( xX_Q17[ 2 ], 7 ); + neg_xX_Q24[ 3 ] = -silk_LSHIFT32( xX_Q17[ 3 ], 7 ); + neg_xX_Q24[ 4 ] = -silk_LSHIFT32( xX_Q17[ 4 ], 7 ); /* Loop over codebook */ *rate_dist_Q8 = silk_int32_MAX; - *res_nrg_Q15 = silk_int32_MAX; - sum1_best_Q15 = silk_int32_MAX; + *res_nrg_Q15 = silk_int32_MAX; + sum1_best_Q15 = silk_int32_MAX; cb_row_Q7 = cb_Q7; for( k = 0; k < L; k++ ) { /* Weighted rate */ - /* Quantization error: 1 - 2* xX * cb + cb' * XX * cb */ - sum1_Q15 = SILK_FIX_CONST( 1.0001, 15 ); + /* Quantization error: 1 - 2* xX * cb + cb' * XX * cb */ + sum1_Q15 = SILK_FIX_CONST( 1.0001, 15 ); /* first row of XX_Q17 */ sum2_Q24 = silk_MLA( neg_xX_Q24[ 0 ], XX_Q17[ 1 ], cb_row_Q7[ 1 ] ); @@ -98,25 +98,25 @@ void silk_VQ_WMat_EC_c( sum1_Q15 = silk_SMLAWB( sum1_Q15, sum2_Q24, cb_row_Q7[ 3 ] ); /* last row of XX_Q17 */ - sum2_Q24 = silk_LSHIFT32( neg_xX_Q24[ 4 ], 1 ); + sum2_Q24 = silk_LSHIFT32( neg_xX_Q24[ 4 ], 1 ); sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 24 ], cb_row_Q7[ 4 ] ); sum1_Q15 = silk_SMLAWB( sum1_Q15, sum2_Q24, cb_row_Q7[ 4 ] ); - /* If ever the following assert triggers, increase LTP_CORR_INV_MAX */ + /* If ever the following assert triggers, increase LTP_CORR_INV_MAX */ silk_assert( sum1_Q15 >= 0 ); - /* find best */ - if( sum1_Q15 <= sum1_best_Q15 ) { - sum1_best_Q15 = sum1_Q15; - /* Translate residual energy to bits using high-rate assumption (6 dB ==> 1 bit/sample) */ - bits_res_Q8 = silk_SMULBB( subfr_len, silk_lin2log( sum1_Q15 ) - (15 << 7) ); - bits_tot_Q8 = silk_ADD_LSHIFT32( bits_res_Q8, cl_Q5[ k ], 2 ); - if( bits_tot_Q8 <= *rate_dist_Q8 ) { - *rate_dist_Q8 = bits_tot_Q8; - *res_nrg_Q15 = sum1_Q15; - *ind = (opus_int8)k; - } - } + /* find best */ + if( sum1_Q15 <= sum1_best_Q15 ) { + sum1_best_Q15 = sum1_Q15; + /* Translate residual energy to bits using high-rate assumption (6 dB ==> 1 bit/sample) */ + bits_res_Q8 = silk_SMULBB( subfr_len, silk_lin2log( sum1_Q15 ) - (15 << 7) ); + bits_tot_Q8 = silk_ADD_LSHIFT32( bits_res_Q8, cl_Q5[ k ], 2 ); + if( bits_tot_Q8 <= *rate_dist_Q8 ) { + *rate_dist_Q8 = bits_tot_Q8; + *res_nrg_Q15 = sum1_Q15; + *ind = (opus_int8)k; + } + } /* Go to next cbk vector */ cb_row_Q7 += LTP_ORDER; diff --git a/silk/fixed/corrMatrix_FIX.c b/silk/fixed/corrMatrix_FIX.c index c01180092e2a07803dfc8a32a729bf8f1826d2fd..1b4a29c232bfeeaf8b6b7b532577e234c982f42f 100644 --- a/silk/fixed/corrMatrix_FIX.c +++ b/silk/fixed/corrMatrix_FIX.c @@ -78,8 +78,8 @@ void silk_corrMatrix_FIX( const opus_int L, /* I Length of vectors */ const opus_int order, /* I Max lag for correlation */ opus_int32 *XX, /* O Pointer to X'*X correlation matrix [ order x order ] */ - opus_int32 *nrg, /* O Energy of x vector */ - opus_int *rshifts, /* O Right shifts of correlations and energy */ + opus_int32 *nrg, /* O Energy of x vector */ + opus_int *rshifts, /* O Right shifts of correlations and energy */ int arch /* I Run-time architecture */ ) { @@ -89,9 +89,9 @@ void silk_corrMatrix_FIX( /* Calculate energy to find shift used to fit in 32 bits */ silk_sum_sqr_shift( nrg, rshifts, x, L + order - 1 ); - energy = *nrg; + energy = *nrg; - /* Calculate energy of first column (0) of X: X[:,0]'*X[:,0] */ + /* Calculate energy of first column (0) of X: X[:,0]'*X[:,0] */ /* Remove contribution of first order - 1 samples */ for( i = 0; i < order - 1; i++ ) { energy -= silk_RSHIFT32( silk_SMULBB( x[ i ], x[ i ] ), *rshifts ); @@ -100,13 +100,13 @@ void silk_corrMatrix_FIX( /* Calculate energy of remaining columns of X: X[:,j]'*X[:,j] */ /* Fill out the diagonal of the correlation matrix */ matrix_ptr( XX, 0, 0, order ) = energy; - silk_assert( energy >= 0 ); + silk_assert( energy >= 0 ); ptr1 = &x[ order - 1 ]; /* First sample of column 0 of X */ for( j = 1; j < order; j++ ) { energy = silk_SUB32( energy, silk_RSHIFT32( silk_SMULBB( ptr1[ L - j ], ptr1[ L - j ] ), *rshifts ) ); energy = silk_ADD32( energy, silk_RSHIFT32( silk_SMULBB( ptr1[ -j ], ptr1[ -j ] ), *rshifts ) ); matrix_ptr( XX, j, j, order ) = energy; - silk_assert( energy >= 0 ); + silk_assert( energy >= 0 ); } ptr2 = &x[ order - 2 ]; /* First sample of column 1 of X */ diff --git a/silk/fixed/find_LTP_FIX.c b/silk/fixed/find_LTP_FIX.c index 4eadd134e59d5b6ea9b750195c4f56b0f82cbc0e..aea6fc01f607404ab7cb4575759affe563be3450 100644 --- a/silk/fixed/find_LTP_FIX.c +++ b/silk/fixed/find_LTP_FIX.c @@ -33,9 +33,9 @@ POSSIBILITY OF SUCH DAMAGE. #include "tuning_parameters.h" void silk_find_LTP_FIX( - opus_int32 XXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Correlation matrix */ - opus_int32 xXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER ], /* O Correlation vector */ - const opus_int16 r_ptr[], /* I Residual signal after LPC */ + opus_int32 XXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Correlation matrix */ + opus_int32 xXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER ], /* O Correlation vector */ + const opus_int16 r_ptr[], /* I Residual signal after LPC */ const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */ const opus_int subfr_length, /* I Subframe length */ const opus_int nb_subfr, /* I Number of subframes */ @@ -43,56 +43,56 @@ void silk_find_LTP_FIX( ) { opus_int i, k, extra_shifts; - opus_int xx_shifts, xX_shifts, XX_shifts; + opus_int xx_shifts, xX_shifts, XX_shifts; const opus_int16 *lag_ptr; opus_int32 *XXLTP_Q17_ptr, *xXLTP_Q17_ptr; - opus_int32 xx, nrg, temp; + opus_int32 xx, nrg, temp; xXLTP_Q17_ptr = xXLTP_Q17; XXLTP_Q17_ptr = XXLTP_Q17; for( k = 0; k < nb_subfr; k++ ) { lag_ptr = r_ptr - ( lag[ k ] + LTP_ORDER / 2 ); - silk_sum_sqr_shift( &xx, &xx_shifts, r_ptr, subfr_length ); /* xx in Q( -xx_shifts ) */ - silk_corrMatrix_FIX( lag_ptr, subfr_length, LTP_ORDER, XXLTP_Q17_ptr, &nrg, &XX_shifts, arch ); /* XXLTP_Q17_ptr and nrg in Q( -XX_shifts ) */ - extra_shifts = xx_shifts - XX_shifts; - if( extra_shifts > 0 ) { - /* Shift XX */ - xX_shifts = xx_shifts; - for( i = 0; i < LTP_ORDER * LTP_ORDER; i++ ) { - XXLTP_Q17_ptr[ i ] = silk_RSHIFT32( XXLTP_Q17_ptr[ i ], extra_shifts ); /* Q( -xX_shifts ) */ - } - nrg = silk_RSHIFT32( nrg, extra_shifts ); /* Q( -xX_shifts ) */ - } else if( extra_shifts < 0 ) { - /* Shift xx */ - xX_shifts = XX_shifts; - xx = silk_RSHIFT32( xx, -extra_shifts ); /* Q( -xX_shifts ) */ - } else { - xX_shifts = xx_shifts; - } - silk_corrVector_FIX( lag_ptr, r_ptr, subfr_length, LTP_ORDER, xXLTP_Q17_ptr, xX_shifts, arch ); /* xXLTP_Q17_ptr in Q( -xX_shifts ) */ + silk_sum_sqr_shift( &xx, &xx_shifts, r_ptr, subfr_length ); /* xx in Q( -xx_shifts ) */ + silk_corrMatrix_FIX( lag_ptr, subfr_length, LTP_ORDER, XXLTP_Q17_ptr, &nrg, &XX_shifts, arch ); /* XXLTP_Q17_ptr and nrg in Q( -XX_shifts ) */ + extra_shifts = xx_shifts - XX_shifts; + if( extra_shifts > 0 ) { + /* Shift XX */ + xX_shifts = xx_shifts; + for( i = 0; i < LTP_ORDER * LTP_ORDER; i++ ) { + XXLTP_Q17_ptr[ i ] = silk_RSHIFT32( XXLTP_Q17_ptr[ i ], extra_shifts ); /* Q( -xX_shifts ) */ + } + nrg = silk_RSHIFT32( nrg, extra_shifts ); /* Q( -xX_shifts ) */ + } else if( extra_shifts < 0 ) { + /* Shift xx */ + xX_shifts = XX_shifts; + xx = silk_RSHIFT32( xx, -extra_shifts ); /* Q( -xX_shifts ) */ + } else { + xX_shifts = xx_shifts; + } + silk_corrVector_FIX( lag_ptr, r_ptr, subfr_length, LTP_ORDER, xXLTP_Q17_ptr, xX_shifts, arch ); /* xXLTP_Q17_ptr in Q( -xX_shifts ) */ - /* At this point all correlations are in Q(-xX_shifts) */ - temp = silk_SMLAWB( 1, nrg, SILK_FIX_CONST( LTP_CORR_INV_MAX, 16 ) ); - temp = silk_max( temp, xx ); + /* At this point all correlations are in Q(-xX_shifts) */ + temp = silk_SMLAWB( 1, nrg, SILK_FIX_CONST( LTP_CORR_INV_MAX, 16 ) ); + temp = silk_max( temp, xx ); TIC(div) #if 0 - for( i = 0; i < LTP_ORDER * LTP_ORDER; i++ ) { - XXLTP_Q17_ptr[ i ] = silk_DIV32_varQ( XXLTP_Q17_ptr[ i ], temp, 17 ); - } - for( i = 0; i < LTP_ORDER; i++ ) { - xXLTP_Q17_ptr[ i ] = silk_DIV32_varQ( xXLTP_Q17_ptr[ i ], temp, 17 ); - } + for( i = 0; i < LTP_ORDER * LTP_ORDER; i++ ) { + XXLTP_Q17_ptr[ i ] = silk_DIV32_varQ( XXLTP_Q17_ptr[ i ], temp, 17 ); + } + for( i = 0; i < LTP_ORDER; i++ ) { + xXLTP_Q17_ptr[ i ] = silk_DIV32_varQ( xXLTP_Q17_ptr[ i ], temp, 17 ); + } #else - for( i = 0; i < LTP_ORDER * LTP_ORDER; i++ ) { - XXLTP_Q17_ptr[ i ] = (opus_int32)( ( ((opus_int64)XXLTP_Q17_ptr[ i ]) << 17 ) / temp ); - } - for( i = 0; i < LTP_ORDER; i++ ) { - xXLTP_Q17_ptr[ i ] = (opus_int32)( ( ((opus_int64)xXLTP_Q17_ptr[ i ]) << 17 ) / temp ); - } + for( i = 0; i < LTP_ORDER * LTP_ORDER; i++ ) { + XXLTP_Q17_ptr[ i ] = (opus_int32)( ( ((opus_int64)XXLTP_Q17_ptr[ i ]) << 17 ) / temp ); + } + for( i = 0; i < LTP_ORDER; i++ ) { + xXLTP_Q17_ptr[ i ] = (opus_int32)( ( ((opus_int64)xXLTP_Q17_ptr[ i ]) << 17 ) / temp ); + } #endif TOC(div) - r_ptr += subfr_length; + r_ptr += subfr_length; XXLTP_Q17_ptr += LTP_ORDER * LTP_ORDER; xXLTP_Q17_ptr += LTP_ORDER; } diff --git a/silk/fixed/find_pred_coefs_FIX.c b/silk/fixed/find_pred_coefs_FIX.c index 917dee0867e1bdfaadcd2cf88f5aa800a0b62b65..2b286a6a58c531129488f3ec85df8d56f4342e8c 100644 --- a/silk/fixed/find_pred_coefs_FIX.c +++ b/silk/fixed/find_pred_coefs_FIX.c @@ -87,7 +87,7 @@ void silk_find_pred_coefs_FIX( /* LTP analysis */ silk_find_LTP_FIX( XXLTP_Q17, xXLTP_Q17, res_pitch, - psEncCtrl->pitchL, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.arch ); + psEncCtrl->pitchL, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.arch ); /* Quantize LTP gain parameters */ silk_quant_LTP_gains( psEncCtrl->LTPCoef_Q14, psEnc->sCmn.indices.LTPIndex, &psEnc->sCmn.indices.PERIndex, diff --git a/silk/fixed/main_FIX.h b/silk/fixed/main_FIX.h index 4b7513b141a10e81ab58726b371a1a0090260384..992f3bf3b56310e06ecc622af94feb6e05548bf5 100644 --- a/silk/fixed/main_FIX.h +++ b/silk/fixed/main_FIX.h @@ -147,9 +147,9 @@ void silk_find_LPC_FIX( /* LTP analysis */ void silk_find_LTP_FIX( - opus_int32 XXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Correlation matrix */ - opus_int32 xXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER ], /* O Correlation vector */ - const opus_int16 r_lpc[], /* I Residual signal after LPC */ + opus_int32 XXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Correlation matrix */ + opus_int32 xXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER ], /* O Correlation vector */ + const opus_int16 r_lpc[], /* I Residual signal after LPC */ const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */ const opus_int subfr_length, /* I Subframe length */ const opus_int nb_subfr, /* I Number of subframes */ @@ -207,7 +207,7 @@ void silk_corrMatrix_FIX( const opus_int L, /* I Length of vectors */ const opus_int order, /* I Max lag for correlation */ opus_int32 *XX, /* O Pointer to X'*X correlation matrix [ order x order ] */ - opus_int32 *nrg, /* O Energy of x vector */ + opus_int32 *nrg, /* O Energy of x vector */ opus_int *rshifts, /* O Right shifts of correlations */ int arch /* I Run-time architecture */ ); diff --git a/silk/fixed/pitch_analysis_core_FIX.c b/silk/fixed/pitch_analysis_core_FIX.c index c3e98a634457004c79785d9b0fc966eaafdce06e..7cd303d559785cddad9d630aa51afdedf67eea2f 100644 --- a/silk/fixed/pitch_analysis_core_FIX.c +++ b/silk/fixed/pitch_analysis_core_FIX.c @@ -96,7 +96,7 @@ opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 { VARDECL( opus_int16, frame_8kHz_buf ); VARDECL( opus_int16, frame_4kHz ); - VARDECL( opus_int16, frame_scaled ); + VARDECL( opus_int16, frame_scaled ); opus_int32 filt_state[ 6 ]; const opus_int16 *frame, *frame_8kHz; opus_int i, k, d, j; @@ -148,9 +148,9 @@ opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 for( i = 0; i < frame_length; i++ ) { frame_scaled[ i ] = silk_RSHIFT( frame_unscaled[ i ], shift ); } - frame = frame_scaled; - } else { - frame = frame_unscaled; + frame = frame_scaled; + } else { + frame = frame_unscaled; } ALLOC( frame_8kHz_buf, ( Fs_kHz == 8 ) ? 1 : frame_length_8kHz, opus_int16 ); @@ -158,14 +158,14 @@ opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 if( Fs_kHz == 16 ) { silk_memset( filt_state, 0, 2 * sizeof( opus_int32 ) ); silk_resampler_down2( filt_state, frame_8kHz_buf, frame, frame_length ); - frame_8kHz = frame_8kHz_buf; + frame_8kHz = frame_8kHz_buf; } else if( Fs_kHz == 12 ) { silk_memset( filt_state, 0, 6 * sizeof( opus_int32 ) ); silk_resampler_down2_3( filt_state, frame_8kHz_buf, frame, frame_length ); - frame_8kHz = frame_8kHz_buf; + frame_8kHz = frame_8kHz_buf; } else { silk_assert( Fs_kHz == 8 ); - frame_8kHz = frame; + frame_8kHz = frame; } /* Decimate again to 4 kHz */ diff --git a/silk/fixed/structs_FIX.h b/silk/fixed/structs_FIX.h index 1694db8dbaa56a5a830b5094d6bb03e0891e4dc5..2774a97b24fe677b7d182a9a12028a7c1d87fa89 100644 --- a/silk/fixed/structs_FIX.h +++ b/silk/fixed/structs_FIX.h @@ -57,7 +57,7 @@ typedef struct { /* Buffer for find pitch and noise shape analysis */ silk_DWORD_ALIGN opus_int16 x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];/* Buffer for find pitch and noise shape analysis */ opus_int LTPCorr_Q15; /* Normalized correlation from pitch lag estimator */ - opus_int32 resNrgSmth; + opus_int32 resNrgSmth; } silk_encoder_state_FIX; /************************/ diff --git a/silk/float/energy_FLP.c b/silk/float/energy_FLP.c index 8f24f93a5bee968abb9f2426e9c0c3ee822438dd..7bc7173c9cf3f46699e89cd13db3b277ade6606a 100644 --- a/silk/float/energy_FLP.c +++ b/silk/float/energy_FLP.c @@ -42,7 +42,7 @@ double silk_energy_FLP( /* 4x unrolled loop */ result = 0.0; - for( i = 0; i < dataSize - 3; i += 4 ) { + for( i = 0; i < dataSize - 3; i += 4 ) { result += data[ i + 0 ] * (double)data[ i + 0 ] + data[ i + 1 ] * (double)data[ i + 1 ] + data[ i + 2 ] * (double)data[ i + 2 ] + diff --git a/silk/float/find_LTP_FLP.c b/silk/float/find_LTP_FLP.c index 8bc10ddfb77e3a63f4844d84e51b23ab85f6bb4b..2e1a0fe50dedde30b2d6a4075456fab1d41a69eb 100644 --- a/silk/float/find_LTP_FLP.c +++ b/silk/float/find_LTP_FLP.c @@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. void silk_find_LTP_FLP( silk_float XX[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */ - silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* O Weight for LTP quantization */ + silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* O Weight for LTP quantization */ const silk_float r_ptr[], /* I LPC residual */ const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */ const opus_int subfr_length, /* I Subframe length */ diff --git a/silk/float/find_pred_coefs_FLP.c b/silk/float/find_pred_coefs_FLP.c index 0c8a896f0a69ca5e6938ad1f321d8c6f61a57713..86799742af6796a4d104c99a6436d4cdda0f71dc 100644 --- a/silk/float/find_pred_coefs_FLP.c +++ b/silk/float/find_pred_coefs_FLP.c @@ -61,12 +61,12 @@ void silk_find_pred_coefs_FLP( /**********/ silk_assert( psEnc->sCmn.ltp_mem_length - psEnc->sCmn.predictLPCOrder >= psEncCtrl->pitchL[ 0 ] + LTP_ORDER / 2 ); - /* LTP analysis */ + /* LTP analysis */ silk_find_LTP_FLP( XXLTP, xXLTP, res_pitch, psEncCtrl->pitchL, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr ); /* Quantize LTP gain parameters */ silk_quant_LTP_gains_FLP( psEncCtrl->LTPCoef, psEnc->sCmn.indices.LTPIndex, &psEnc->sCmn.indices.PERIndex, - &psEncCtrl->LTPredCodGain, XXLTP, xXLTP, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.arch ); + &psEncCtrl->LTPredCodGain, XXLTP, xXLTP, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.arch ); /* Control LTP scaling */ silk_LTP_scale_ctrl_FLP( psEnc, psEncCtrl, condCoding ); diff --git a/silk/float/k2a_FLP.c b/silk/float/k2a_FLP.c index 6eb0e89d0f6e592e64f1a4c5d76d5983bbccf4ed..1448008dbbed139791089132b0e391b2e7e07f6b 100644 --- a/silk/float/k2a_FLP.c +++ b/silk/float/k2a_FLP.c @@ -42,12 +42,12 @@ void silk_k2a_FLP( silk_float rck, tmp1, tmp2; for( k = 0; k < order; k++ ) { - rck = rc[ k ]; + rck = rc[ k ]; for( n = 0; n < (k + 1) >> 1; n++ ) { - tmp1 = A[ n ]; - tmp2 = A[ k - n - 1 ]; + tmp1 = A[ n ]; + tmp2 = A[ k - n - 1 ]; A[ n ] = tmp1 + tmp2 * rck; - A[ k - n - 1 ] = tmp2 + tmp1 * rck; + A[ k - n - 1 ] = tmp2 + tmp1 * rck; } A[ k ] = -rck; } diff --git a/silk/float/main_FLP.h b/silk/float/main_FLP.h index fbd2f1a7fd6404b9401456f5fc3102f6283e5163..343e6c10594aeedfbb8814c7f80da6636f2eac7c 100644 --- a/silk/float/main_FLP.h +++ b/silk/float/main_FLP.h @@ -144,7 +144,7 @@ void silk_find_LPC_FLP( /* LTP analysis */ void silk_find_LTP_FLP( silk_float XX[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */ - silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* O Weight for LTP quantization */ + silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* O Weight for LTP quantization */ const silk_float r_ptr[], /* I LPC residual */ const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */ const opus_int subfr_length, /* I Subframe length */ @@ -185,14 +185,14 @@ void silk_LPC_analysis_filter_FLP( /* LTP tap quantizer */ void silk_quant_LTP_gains_FLP( - silk_float B[ MAX_NB_SUBFR * LTP_ORDER ], /* O Quantized LTP gains */ + silk_float B[ MAX_NB_SUBFR * LTP_ORDER ], /* O Quantized LTP gains */ opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook index */ opus_int8 *periodicity_index, /* O Periodicity index */ - silk_float *pred_gain_dB, /* O LTP prediction gain */ - const silk_float XX[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* I Correlation matrix */ - const silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* I Correlation vector */ - const opus_int subfr_len, /* I Number of samples per subframe */ - const opus_int nb_subfr, /* I Number of subframes */ + silk_float *pred_gain_dB, /* O LTP prediction gain */ + const silk_float XX[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* I Correlation matrix */ + const silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* I Correlation vector */ + const opus_int subfr_len, /* I Number of samples per subframe */ + const opus_int nb_subfr, /* I Number of subframes */ int arch /* I Run-time architecture */ ); diff --git a/silk/float/noise_shape_analysis_FLP.c b/silk/float/noise_shape_analysis_FLP.c index 85dba009b43602c843d7b9386b7519ee2821e3fd..cb3d8a50b7cb77095bfc2bf87359a5b71cfd3dc5 100644 --- a/silk/float/noise_shape_analysis_FLP.c +++ b/silk/float/noise_shape_analysis_FLP.c @@ -121,7 +121,7 @@ static OPUS_INLINE void limit_coefs( opus_int i, iter, ind = 0; silk_float tmp, maxabs, chirp; - for( iter = 0; iter < 10; iter++ ) { + for( iter = 0; iter < 10; iter++ ) { /* Find maximum absolute value */ maxabs = -1.0f; for( i = 0; i < order; i++ ) { diff --git a/silk/float/wrappers_FLP.c b/silk/float/wrappers_FLP.c index 9f03e57635e85a36de59b7298b73e16c15707222..81e0b66e2c23f409735d8a9da1d763e2da18a1b1 100644 --- a/silk/float/wrappers_FLP.c +++ b/silk/float/wrappers_FLP.c @@ -172,14 +172,14 @@ void silk_NSQ_wrapper_FLP( /* Floating-point Silk LTP quantiation wrapper */ /***********************************************/ void silk_quant_LTP_gains_FLP( - silk_float B[ MAX_NB_SUBFR * LTP_ORDER ], /* O Quantized LTP gains */ + silk_float B[ MAX_NB_SUBFR * LTP_ORDER ], /* O Quantized LTP gains */ opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook index */ opus_int8 *periodicity_index, /* O Periodicity index */ - silk_float *pred_gain_dB, /* O LTP prediction gain */ - const silk_float XX[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* I Correlation matrix */ - const silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* I Correlation vector */ - const opus_int subfr_len, /* I Number of samples per subframe */ - const opus_int nb_subfr, /* I Number of subframes */ + silk_float *pred_gain_dB, /* O LTP prediction gain */ + const silk_float XX[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* I Correlation matrix */ + const silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* I Correlation vector */ + const opus_int subfr_len, /* I Number of samples per subframe */ + const opus_int nb_subfr, /* I Number of subframes */ int arch /* I Run-time architecture */ ) { @@ -201,5 +201,5 @@ void silk_quant_LTP_gains_FLP( B[ i ] = (silk_float)B_Q14[ i ] * ( 1.0f / 16384.0f ); } - *pred_gain_dB = (silk_float)pred_gain_dB_Q7 * ( 1.0f / 128.0f ); + *pred_gain_dB = (silk_float)pred_gain_dB_Q7 * ( 1.0f / 128.0f ); } diff --git a/silk/main.h b/silk/main.h index 6eacf6966c23f7beda7024dc79760e88a244c3e5..38e1eabd4f72984d20de6f815bd6ef541bf0832b 100644 --- a/silk/main.h +++ b/silk/main.h @@ -205,13 +205,13 @@ void silk_interpolate( /* LTP tap quantizer */ void silk_quant_LTP_gains( - opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O Quantized LTP gains */ + opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O Quantized LTP gains */ opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook Index */ opus_int8 *periodicity_index, /* O Periodicity Index */ - opus_int *pred_gain_dB_Q7, /* O LTP prediction gain */ + opus_int *pred_gain_dB_Q7, /* O LTP prediction gain */ const opus_int32 XX_Q17[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ], /* I Correlation matrix in Q18 */ const opus_int32 xX_Q17[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ], /* I Correlation vector in Q18 */ - const opus_int subfr_len, /* I Number of samples per subframe */ + const opus_int subfr_len, /* I Number of samples per subframe */ const opus_int nb_subfr, /* I Number of subframes */ int arch /* I Run-time architecture */ ); @@ -219,13 +219,13 @@ void silk_quant_LTP_gains( /* Entropy constrained matrix-weighted VQ, for a single input data vector */ void silk_VQ_WMat_EC_c( opus_int8 *ind, /* O index of best codebook vector */ - opus_int32 *res_nrg_Q15, /* O best residual energy */ - opus_int32 *rate_dist_Q8, /* O best total bitrate */ - const opus_int32 *XX_Q17, /* I correlation matrix */ - const opus_int32 *xX_Q17, /* I correlation vector */ + opus_int32 *res_nrg_Q15, /* O best residual energy */ + opus_int32 *rate_dist_Q8, /* O best total bitrate */ + const opus_int32 *XX_Q17, /* I correlation matrix */ + const opus_int32 *xX_Q17, /* I correlation vector */ const opus_int8 *cb_Q7, /* I codebook */ const opus_uint8 *cl_Q5, /* I code length for each codebook vector */ - const opus_int subfr_len, /* I number of samples per subframe */ + const opus_int subfr_len, /* I number of samples per subframe */ const opus_int L /* I number of vectors in codebook */ ); @@ -242,7 +242,7 @@ void silk_NSQ_c( const silk_encoder_state *psEncC, /* I/O Encoder State */ silk_nsq_state *NSQ, /* I/O NSQ state */ SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x16[], /* I Input */ + const opus_int16 x16[], /* I Input */ opus_int8 pulses[], /* O Quantized pulse signal */ const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ @@ -268,7 +268,7 @@ void silk_NSQ_del_dec_c( const silk_encoder_state *psEncC, /* I/O Encoder State */ silk_nsq_state *NSQ, /* I/O NSQ state */ SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x16[], /* I Input */ + const opus_int16 x16[], /* I Input */ opus_int8 pulses[], /* O Quantized pulse signal */ const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ diff --git a/silk/quant_LTP_gains.c b/silk/quant_LTP_gains.c index 684949243ba92df8e67c8cb92e6cfd35b3936e13..23f856958d79dc2ebf80e67513c1b79c9825298d 100644 --- a/silk/quant_LTP_gains.c +++ b/silk/quant_LTP_gains.c @@ -32,13 +32,13 @@ POSSIBILITY OF SUCH DAMAGE. #include "main.h" void silk_quant_LTP_gains( - opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O Quantized LTP gains */ + opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O Quantized LTP gains */ opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook Index */ opus_int8 *periodicity_index, /* O Periodicity Index */ - opus_int *pred_gain_dB_Q7, /* O LTP prediction gain */ + opus_int *pred_gain_dB_Q7, /* O LTP prediction gain */ const opus_int32 XX_Q17[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ], /* I Correlation matrix in Q18 */ const opus_int32 xX_Q17[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ], /* I Correlation vector in Q18 */ - const opus_int subfr_len, /* I Number of samples per subframe */ + const opus_int subfr_len, /* I Number of samples per subframe */ const opus_int nb_subfr, /* I Number of subframes */ int arch /* I Run-time architecture */ ) @@ -66,23 +66,23 @@ void silk_quant_LTP_gains( xX_Q17_ptr = xX_Q17; b_Q14_ptr = B_Q14; - res_nrg_Q15 = 0; + res_nrg_Q15 = 0; rate_dist_Q7 = 0; for( j = 0; j < nb_subfr; j++ ) { silk_VQ_WMat_EC( &temp_idx[ j ], /* O index of best codebook vector */ - &res_nrg_Q15_subfr, /* O residual energy */ + &res_nrg_Q15_subfr, /* O residual energy */ &rate_dist_Q7_subfr, /* O best weighted quantization error + mu * rate */ XX_Q17_ptr, /* I correlation matrix */ - xX_Q17_ptr, /* I correlation vector */ + xX_Q17_ptr, /* I correlation vector */ cbk_ptr_Q7, /* I codebook */ cl_ptr_Q5, /* I code length for each codebook vector */ - subfr_len, /* I number of samples per subframe */ + subfr_len, /* I number of samples per subframe */ cbk_size, /* I number of vectors in codebook */ arch /* I Run-time architecture */ ); - res_nrg_Q15 = silk_ADD_POS_SAT32( res_nrg_Q15, res_nrg_Q15_subfr ); + res_nrg_Q15 = silk_ADD_POS_SAT32( res_nrg_Q15, res_nrg_Q15_subfr ); rate_dist_Q7 = silk_ADD_POS_SAT32( rate_dist_Q7, rate_dist_Q7_subfr ); b_Q14_ptr += LTP_ORDER; @@ -104,12 +104,12 @@ void silk_quant_LTP_gains( } } - if( nb_subfr == 2 ) { - res_nrg_Q15 = silk_RSHIFT32( res_nrg_Q15, 1 ); - } else { - res_nrg_Q15 = silk_RSHIFT32( res_nrg_Q15, 2 ); - } + if( nb_subfr == 2 ) { + res_nrg_Q15 = silk_RSHIFT32( res_nrg_Q15, 1 ); + } else { + res_nrg_Q15 = silk_RSHIFT32( res_nrg_Q15, 2 ); + } - *pred_gain_dB_Q7 = (opus_int)silk_SMULBB( -3, silk_lin2log( res_nrg_Q15 ) - ( 15 << 7 ) ); + *pred_gain_dB_Q7 = (opus_int)silk_SMULBB( -3, silk_lin2log( res_nrg_Q15 ) - ( 15 << 7 ) ); } diff --git a/silk/tuning_parameters.h b/silk/tuning_parameters.h index 977e8ab7f0427f62942c4269ec9af3b8926ac137..128f1a9ed6a0afd326048df6b2d2953b13d5b6d0 100644 --- a/silk/tuning_parameters.h +++ b/silk/tuning_parameters.h @@ -54,7 +54,7 @@ extern "C" #define FIND_LPC_COND_FAC 1e-5f /* LTP analysis defines */ -#define LTP_CORR_INV_MAX 0.02f +#define LTP_CORR_INV_MAX 0.02f /***********************/ /* High pass filtering */