diff options
-rw-r--r-- | silk/A2NLSF.c | 2 | ||||
-rw-r--r-- | silk/LPC_fit.c | 6 | ||||
-rw-r--r-- | silk/LPC_inv_pred_gain.c | 2 | ||||
-rw-r--r-- | silk/NSQ.c | 4 | ||||
-rw-r--r-- | silk/NSQ_del_dec.c | 2 | ||||
-rw-r--r-- | silk/SigProc_FIX.h | 2 | ||||
-rw-r--r-- | silk/VQ_WMat_EC.c | 62 | ||||
-rw-r--r-- | silk/fixed/burg_modified_FIX.c | 110 | ||||
-rw-r--r-- | silk/fixed/corrMatrix_FIX.c | 12 | ||||
-rw-r--r-- | silk/fixed/find_LTP_FIX.c | 78 | ||||
-rw-r--r-- | silk/fixed/find_pred_coefs_FIX.c | 2 | ||||
-rw-r--r-- | silk/fixed/main_FIX.h | 8 | ||||
-rw-r--r-- | silk/fixed/pitch_analysis_core_FIX.c | 26 | ||||
-rw-r--r-- | silk/fixed/structs_FIX.h | 2 | ||||
-rw-r--r-- | silk/float/burg_modified_FLP.c | 54 | ||||
-rw-r--r-- | silk/float/energy_FLP.c | 2 | ||||
-rw-r--r-- | silk/float/find_LTP_FLP.c | 2 | ||||
-rw-r--r-- | silk/float/find_pred_coefs_FLP.c | 4 | ||||
-rw-r--r-- | silk/float/k2a_FLP.c | 8 | ||||
-rw-r--r-- | silk/float/main_FLP.h | 14 | ||||
-rw-r--r-- | silk/float/noise_shape_analysis_FLP.c | 2 | ||||
-rw-r--r-- | silk/float/wrappers_FLP.c | 14 | ||||
-rw-r--r-- | silk/main.h | 20 | ||||
-rw-r--r-- | silk/quant_LTP_gains.c | 28 | ||||
-rw-r--r-- | silk/sum_sqr_shift.c | 2 | ||||
-rw-r--r-- | silk/tuning_parameters.h | 2 |
26 files changed, 235 insertions, 235 deletions
diff --git a/silk/A2NLSF.c b/silk/A2NLSF.c index 165049aa..b487686f 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 69ff3958..cdea4f3a 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 cb9983f5..257b28fd 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 ); } } @@ -75,7 +75,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 */ @@ -443,7 +443,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 e5ceef1b..4b2179b9 100644 --- a/silk/NSQ_del_dec.c +++ b/silk/NSQ_del_dec.c @@ -115,7 +115,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 77dc6c8f..855f6d94 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 d33da26d..67e63418 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/burg_modified_FIX.c b/silk/fixed/burg_modified_FIX.c index 1b6373e9..dd4f691c 100644 --- a/silk/fixed/burg_modified_FIX.c +++ b/silk/fixed/burg_modified_FIX.c @@ -91,7 +91,7 @@ void silk_burg_modified_c( } else { for( s = 0; s < nb_subfr; s++ ) { int i; - opus_int32 xcorr[ SILK_MAX_ORDER_LPC ]; + opus_int32 xcorr[ SILK_MAX_ORDER_LPC ]; opus_int32 d; x_ptr = x + s * subfr_length; celt_pitch_xcorr(x_ptr, x_ptr + 1, xcorr, subfr_length - D, D, arch ); @@ -106,43 +106,43 @@ void silk_burg_modified_c( } } - /* Multiply all correlations by 2 */ - rshifts++; + /* Multiply all correlations by 2 */ + rshifts++; /* Initialize */ - c[ 0 ] = C0 + silk_SMMUL( SILK_FIX_CONST( FIND_LPC_COND_FAC, 32 ), C0 ) + 1; /* Q(-rshifts) */ - g[ 0 ] = c[ 0 ]; /* Q(-rshifts) */ - tmp1 = 0; + c[ 0 ] = C0 + silk_SMMUL( SILK_FIX_CONST( FIND_LPC_COND_FAC, 32 ), C0 ) + 1; /* Q(-rshifts) */ + g[ 0 ] = c[ 0 ]; /* Q(-rshifts) */ + tmp1 = 0; if( rshifts > -N_BITS_HEAD_ROOM ) { - for( s = 0; s < nb_subfr; s++ ) { - x_ptr = x + s * subfr_length; - x1 = x_ptr[ 0 ]; - x2 = x_ptr[ subfr_length - 1 ]; - tmp1 = silk_SMLAWB( tmp1, silk_LSHIFT32( x1, 16 - rshifts ), x1 ); /* Q(-rshifts) */ - tmp1 = silk_SMLAWB( tmp1, silk_LSHIFT32( x2, 16 - rshifts ), x2 ); /* Q(-rshifts) */ - } - } else { - for( s = 0; s < nb_subfr; s++ ) { - x_ptr = x + s * subfr_length; - x1 = x_ptr[ 0 ]; - x2 = x_ptr[ subfr_length - 1 ]; - tmp1 = silk_MLA( tmp1, silk_LSHIFT32( x1, -rshifts ), x1 ); /* Q(-rshifts) */ - tmp1 = silk_MLA( tmp1, silk_LSHIFT32( x2, -rshifts ), x2 ); /* Q(-rshifts) */ - } - } - g[ 0 ] -= tmp1; - g[ 1 ] = c[ 1 ]; - silk_assert( g[ 1 ] < g[ 0 ] && g[ 1 ] > -g[ 0 ] ); + for( s = 0; s < nb_subfr; s++ ) { + x_ptr = x + s * subfr_length; + x1 = x_ptr[ 0 ]; + x2 = x_ptr[ subfr_length - 1 ]; + tmp1 = silk_SMLAWB( tmp1, silk_LSHIFT32( x1, 16 - rshifts ), x1 ); /* Q(-rshifts) */ + tmp1 = silk_SMLAWB( tmp1, silk_LSHIFT32( x2, 16 - rshifts ), x2 ); /* Q(-rshifts) */ + } + } else { + for( s = 0; s < nb_subfr; s++ ) { + x_ptr = x + s * subfr_length; + x1 = x_ptr[ 0 ]; + x2 = x_ptr[ subfr_length - 1 ]; + tmp1 = silk_MLA( tmp1, silk_LSHIFT32( x1, -rshifts ), x1 ); /* Q(-rshifts) */ + tmp1 = silk_MLA( tmp1, silk_LSHIFT32( x2, -rshifts ), x2 ); /* Q(-rshifts) */ + } + } + g[ 0 ] -= tmp1; + g[ 1 ] = c[ 1 ]; + silk_assert( g[ 1 ] < g[ 0 ] && g[ 1 ] > -g[ 0 ] ); rc_Q31 = -silk_DIV32_varQ( g[ 1 ], g[ 0 ], 31 ); - Af_QA[ 0 ] = silk_RSHIFT32( rc_Q31, 31 - QA ); /* QA */ + Af_QA[ 0 ] = silk_RSHIFT32( rc_Q31, 31 - QA ); /* QA */ invGain_Q30 = SILK_FIX_CONST( 1, 30 ) - silk_SMMUL( rc_Q31, rc_Q31 ); reached_max_gain = 0; for( n = 1; n < D; n++ ) { for( k = 0; k < (n >> 1) + 1; k++ ) { tmp1 = g[ k ]; tmp2 = g[ n - k ]; - g[ k ] = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( tmp2, rc_Q31 ), 1 ); /* Q(-rshifts) */ - g[ n - k ] = silk_ADD_LSHIFT32( tmp2, silk_SMMUL( tmp1, rc_Q31 ), 1 ); /* Q(-rshifts) */ + g[ k ] = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( tmp2, rc_Q31 ), 1 ); /* Q(-rshifts) */ + g[ n - k ] = silk_ADD_LSHIFT32( tmp2, silk_SMMUL( tmp1, rc_Q31 ), 1 ); /* Q(-rshifts) */ } if( rshifts > -N_BITS_HEAD_ROOM ) { for( s = 0; s < nb_subfr; s++ ) { @@ -152,29 +152,29 @@ void silk_burg_modified_c( tmp1 = silk_LSHIFT32( (opus_int32)x_ptr[ n ], QA - 16 ); /* Q(QA-16) */ tmp2 = silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], QA - 16 ); /* Q(QA-16) */ for( k = 0; k < n; k++ ) { - c[ k + 1 ] = silk_SMLAWB( silk_SMLAWB( c[ k + 1 ], x1, x_ptr[ n - k - 1 ] ), /* Q( -rshifts ) */ - x2, x_ptr[ subfr_length - n + k ] ); + c[ k + 1 ] = silk_SMLAWB( silk_SMLAWB( c[ k + 1 ], x1, x_ptr[ n - k - 1 ] ), /* Q( -rshifts ) */ + x2, x_ptr[ subfr_length - n + k ] ); Atmp_QA = Af_QA[ k ]; tmp1 = silk_SMLAWB( tmp1, Atmp_QA, x_ptr[ n - k - 1 ] ); /* Q(QA-16) */ tmp2 = silk_SMLAWB( tmp2, Atmp_QA, x_ptr[ subfr_length - n + k ] ); /* Q(QA-16) */ } - tmp1 = silk_LSHIFT32( -tmp1, 32 - QA - rshifts ); /* Q(16-rshifts) */ + tmp1 = silk_LSHIFT32( -tmp1, 32 - QA - rshifts ); /* Q(16-rshifts) */ tmp2 = silk_LSHIFT32( -tmp2, 32 - QA - rshifts ); /* Q(16-rshifts) */ for( k = 0; k <= n; k++ ) { - g[ k ] = silk_SMLAWB( silk_SMLAWB( g[ k ], tmp1, x_ptr[ n - k ] ), /* Q( -rshift ) */ + g[ k ] = silk_SMLAWB( silk_SMLAWB( g[ k ], tmp1, x_ptr[ n - k ] ), /* Q( -rshift ) */ tmp2, x_ptr[ subfr_length - n + k - 1 ] ); } } } else { for( s = 0; s < nb_subfr; s++ ) { x_ptr = x + s * subfr_length; - x1 = -silk_LSHIFT32( (opus_int32)x_ptr[ n ], -rshifts ); /* Q( -rshifts ) */ + x1 = -silk_LSHIFT32( (opus_int32)x_ptr[ n ], -rshifts ); /* Q( -rshifts ) */ x2 = -silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], -rshifts ); /* Q( -rshifts ) */ tmp1 = silk_LSHIFT32( (opus_int32)x_ptr[ n ], 17 ); /* Q17 */ tmp2 = silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], 17 ); /* Q17 */ for( k = 0; k < n; k++ ) { - c[ k + 1 ] = silk_MLA( silk_MLA( c[ k + 1 ], x1, x_ptr[ n - k - 1 ] ), /* Q( -rshifts ) */ - x2, x_ptr[ subfr_length - n + k ] ); + c[ k + 1 ] = silk_MLA( silk_MLA( c[ k + 1 ], x1, x_ptr[ n - k - 1 ] ), /* Q( -rshifts ) */ + x2, x_ptr[ subfr_length - n + k ] ); Atmp1 = silk_RSHIFT_ROUND( Af_QA[ k ], QA - 17 ); /* Q17 */ tmp1 = silk_MLA( tmp1, x_ptr[ n - k - 1 ], Atmp1 ); /* Q17 */ tmp2 = silk_MLA( tmp2, x_ptr[ subfr_length - n + k ], Atmp1 ); /* Q17 */ @@ -182,27 +182,27 @@ void silk_burg_modified_c( tmp1 = -tmp1; /* Q17 */ tmp2 = -tmp2; /* Q17 */ for( k = 0; k <= n; k++ ) { - g[ k ] = silk_SMLAWW( silk_SMLAWW( g[ k ], /* Q( -rshift ) */ - tmp1, silk_LSHIFT32( (opus_int32)x_ptr[ n - k ], -rshifts - 1 ) ), - tmp2, silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n + k - 1 ], -rshifts - 1 ) ); + g[ k ] = silk_SMLAWW( silk_SMLAWW( g[ k ], /* Q( -rshift ) */ + tmp1, silk_LSHIFT32( (opus_int32)x_ptr[ n - k ], -rshifts - 1 ) ), + tmp2, silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n + k - 1 ], -rshifts - 1 ) ); } } } /* Calculate nominator and denominator for the next order reflection (parcor) coefficient */ - tmp1 = c[ n + 1 ]; /* Q( -rshifts ) */ + tmp1 = c[ n + 1 ]; /* Q( -rshifts ) */ num = 0; /* Q( -rshifts ) */ - nrg = g[ 0 ]; /* Q( -rshifts ) */ + nrg = g[ 0 ]; /* Q( -rshifts ) */ for( k = 0; k < n; k++ ) { Atmp_QA = Af_QA[ k ]; lz = silk_CLZ32( silk_abs( Atmp_QA ) ) - 1; lz = silk_min( 32 - QA, lz ); Atmp1 = silk_LSHIFT32( Atmp_QA, lz ); /* Q( QA + lz ) */ - tmp1 = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( c[ n - k ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts ) */ - num = silk_ADD_LSHIFT32( num, silk_SMMUL( g[ n - k ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts ) */ - nrg = silk_ADD_LSHIFT32( nrg, silk_SMMUL( g[ k + 1 ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts ) */ + tmp1 = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( c[ n - k ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts ) */ + num = silk_ADD_LSHIFT32( num, silk_SMMUL( g[ n - k ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts ) */ + nrg = silk_ADD_LSHIFT32( nrg, silk_SMMUL( g[ k + 1 ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts ) */ } - g[ n + 1 ] = tmp1; /* Q( -rshifts ) */ + g[ n + 1 ] = tmp1; /* Q( -rshifts ) */ num = silk_ADD32( num, tmp1 ); /* Q( -rshifts ) */ silk_assert( nrg > 0 ); @@ -214,12 +214,12 @@ void silk_burg_modified_c( } /* Update inverse prediction gain */ - tmp1 = SILK_FIX_CONST( 1, 30 ) - silk_SMMUL( rc_Q31, rc_Q31 ); + tmp1 = SILK_FIX_CONST( 1, 30 ) - silk_SMMUL( rc_Q31, rc_Q31 ); tmp1 = silk_LSHIFT( silk_SMMUL( invGain_Q30, tmp1 ), 2 ); if( tmp1 <= minInvGain_Q30 ) { /* Max prediction gain exceeded; set reflection coefficient such that max prediction gain is exactly hit */ tmp2 = SILK_FIX_CONST( 1, 30 ) - silk_DIV32_varQ( minInvGain_Q30, invGain_Q30, 30 ); /* Q30 */ - rc_Q31 = silk_SQRT_APPROX( tmp2 ); /* Q15 */ + rc_Q31 = silk_SQRT_APPROX( tmp2 ); /* Q15 */ if( rc_Q31 > 0 ) { /* Newton-Raphson iteration */ rc_Q31 = silk_RSHIFT32( rc_Q31 + silk_DIV32( tmp2, rc_Q31 ), 1 ); /* Q15 */ @@ -237,12 +237,12 @@ void silk_burg_modified_c( /* Update the AR coefficients */ for( k = 0; k < (n + 1) >> 1; k++ ) { - tmp1 = Af_QA[ k ]; /* QA */ - tmp2 = Af_QA[ n - k - 1 ]; /* QA */ - Af_QA[ k ] = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( tmp2, rc_Q31 ), 1 ); /* QA */ - Af_QA[ n - k - 1 ] = silk_ADD_LSHIFT32( tmp2, silk_SMMUL( tmp1, rc_Q31 ), 1 ); /* QA */ + tmp1 = Af_QA[ k ]; /* QA */ + tmp2 = Af_QA[ n - k - 1 ]; /* QA */ + Af_QA[ k ] = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( tmp2, rc_Q31 ), 1 ); /* QA */ + Af_QA[ n - k - 1 ] = silk_ADD_LSHIFT32( tmp2, silk_SMMUL( tmp1, rc_Q31 ), 1 ); /* QA */ } - Af_QA[ n ] = silk_RSHIFT32( rc_Q31, 31 - QA ); /* QA */ + Af_QA[ n ] = silk_RSHIFT32( rc_Q31, 31 - QA ); /* QA */ if( reached_max_gain ) { /* Reached max prediction gain; set remaining coefficients to zero and exit loop */ @@ -253,10 +253,10 @@ void silk_burg_modified_c( } } - for( k = 0; k < D; k++ ) { - /* Scale coefficients */ - A_Q16[ k ] = -silk_RSHIFT_ROUND( Af_QA[ k ], QA - 16 ); - } + for( k = 0; k < D; k++ ) { + /* Scale coefficients */ + A_Q16[ k ] = -silk_RSHIFT_ROUND( Af_QA[ k ], QA - 16 ); + } /* Subtract energy of preceding samples from C0 */ rshifts--; /* divide c0 by two */ diff --git a/silk/fixed/corrMatrix_FIX.c b/silk/fixed/corrMatrix_FIX.c index c0118009..1b4a29c2 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 4eadd134..aea6fc01 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 917dee08..2b286a6a 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 4b7513b1..992f3bf3 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 2c5a4386..f252acc0 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; @@ -139,34 +139,34 @@ opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 min_lag = PE_MIN_LAG_MS * Fs_kHz; max_lag = PE_MAX_LAG_MS * Fs_kHz - 1; - /* Downscale input if necessary */ - silk_sum_sqr_shift( &energy, &shift, frame_unscaled, frame_length ); - shift += 2 - silk_CLZ32( energy ); /* at least one bit headroom */ + /* Downscale input if necessary */ + silk_sum_sqr_shift( &energy, &shift, frame_unscaled, frame_length ); + shift += 2 - silk_CLZ32( energy ); /* at least one bit headroom */ if( shift > 0 ) { shift = silk_RSHIFT( shift + 1, 1 ); - ALLOC( frame_scaled, frame_length, opus_int16 ); + ALLOC( frame_scaled, frame_length, opus_int16 ); 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; } /* Resample from input sampled at Fs_kHz to 8 kHz */ if( Fs_kHz == 16 ) { - ALLOC( frame_8kHz_buf, frame_length_8kHz, opus_int16 ); + ALLOC( frame_8kHz_buf, frame_length_8kHz, opus_int16 ); 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 ) { - ALLOC( frame_8kHz_buf, frame_length_8kHz, opus_int16 ); + ALLOC( frame_8kHz_buf, frame_length_8kHz, opus_int16 ); 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 1694db8d..2774a97b 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/burg_modified_FLP.c b/silk/float/burg_modified_FLP.c index 7ef4cac2..c89e6305 100644 --- a/silk/float/burg_modified_FLP.c +++ b/silk/float/burg_modified_FLP.c @@ -48,8 +48,8 @@ silk_float silk_burg_modified_FLP( opus_int k, n, s, reached_max_gain; double invGain, num, nrg, rc, tmp1, tmp2, x1, x2, atmp; const silk_float *x_ptr; - double c[ SILK_MAX_ORDER_LPC + 1 ]; - double g[ SILK_MAX_ORDER_LPC + 1 ]; + double c[ SILK_MAX_ORDER_LPC + 1 ]; + double g[ SILK_MAX_ORDER_LPC + 1 ]; double a[ SILK_MAX_ORDER_LPC ]; /* Compute autocorrelations, added over subframes */ @@ -61,24 +61,24 @@ silk_float silk_burg_modified_FLP( } } for( n = 0; n < D + 1; n++ ) { - c[ n ] *= 2.0; - } + c[ n ] *= 2.0; + } /* Initialize */ - c[ 0 ] += FIND_LPC_COND_FAC * c[ 0 ] + 1e-9f ; + c[ 0 ] += FIND_LPC_COND_FAC * c[ 0 ] + 1e-9f ; g[ 0 ] = c[ 0 ]; - tmp1 = 0.0f; + tmp1 = 0.0f; for( s = 0; s < nb_subfr; s++ ) { x_ptr = x + s * subfr_length; - x1 = x_ptr[ 0 ]; - x2 = x_ptr[ subfr_length - 1 ]; - tmp1 += x1 * x1 + x2 * x2; - } - g[ 0 ] -= tmp1; - g[ 1 ] = c[ 1 ]; - rc = - g[ 1 ] / g[ 0 ]; + x1 = x_ptr[ 0 ]; + x2 = x_ptr[ subfr_length - 1 ]; + tmp1 += x1 * x1 + x2 * x2; + } + g[ 0 ] -= tmp1; + g[ 1 ] = c[ 1 ]; + rc = - g[ 1 ] / g[ 0 ]; silk_assert( rc > -1.0 && rc < 1.0 ); - a[ 0 ] = rc; + a[ 0 ] = rc; invGain = ( 1.0 - rc * rc ); reached_max_gain = 0; for( n = 1; n < D; n++ ) { @@ -90,13 +90,13 @@ silk_float silk_burg_modified_FLP( } for( s = 0; s < nb_subfr; s++ ) { x_ptr = x + s * subfr_length; - x1 = x_ptr[ n ]; - x2 = x_ptr[ subfr_length - n - 1 ]; + x1 = x_ptr[ n ]; + x2 = x_ptr[ subfr_length - n - 1 ]; tmp1 = x1; tmp2 = x2; for( k = 0; k < n; k++ ) { - atmp = a[ k ]; - c[ k + 1 ] -= x1 * x_ptr[ n - k - 1 ] + x2 * x_ptr[ subfr_length - n + k ]; + atmp = a[ k ]; + c[ k + 1 ] -= x1 * x_ptr[ n - k - 1 ] + x2 * x_ptr[ subfr_length - n + k ]; tmp1 += x_ptr[ n - k - 1 ] * atmp; tmp2 += x_ptr[ subfr_length - n + k ] * atmp; } @@ -106,17 +106,17 @@ silk_float silk_burg_modified_FLP( } /* Calculate nominator and denominator for the next order reflection (parcor) coefficient */ - tmp1 = c[ n + 1 ]; + tmp1 = c[ n + 1 ]; num = 0.0f; nrg = g[ 0 ]; for( k = 0; k < n; k++ ) { - atmp = a[ k ]; - tmp1 += c[ n - k ] * atmp; + atmp = a[ k ]; + tmp1 += c[ n - k ] * atmp; num += g[ n - k ] * atmp; nrg += g[ k + 1 ] * atmp; } - g[ n + 1] = tmp1; - num += tmp1; + g[ n + 1] = tmp1; + num += tmp1; silk_assert( nrg > 0.0 ); /* Calculate the next order reflection (parcor) coefficient */ @@ -156,10 +156,10 @@ silk_float silk_burg_modified_FLP( } } - /* Convert to silk_float */ - for( k = 0; k < D; k++ ) { - af[ k ] = (silk_float)( -a[ k ] ); - } + /* Convert to silk_float */ + for( k = 0; k < D; k++ ) { + af[ k ] = (silk_float)( -a[ k ] ); + } nrg = c[ 0 ] * 0.5 * (1.0 - FIND_LPC_COND_FAC); /* Subtract energy of preceding samples from C0 */ diff --git a/silk/float/energy_FLP.c b/silk/float/energy_FLP.c index 8f24f93a..7bc7173c 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 8bc10ddf..2e1a0fe5 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 0c8a896f..86799742 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 6eb0e89d..1448008d 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 fbd2f1a7..343e6c10 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 85dba009..cb3d8a50 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 9f03e576..81e0b66e 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 6eacf696..38e1eabd 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 68494924..23f85695 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/sum_sqr_shift.c b/silk/sum_sqr_shift.c index e387391a..eb5a910e 100644 --- a/silk/sum_sqr_shift.c +++ b/silk/sum_sqr_shift.c @@ -77,7 +77,7 @@ void silk_sum_sqr_shift( nrg = silk_RSHIFT_uint( (opus_uint32)nrg, 1 ); shft++; } - silk_assert( nrg >= 0 ); + silk_assert( nrg >= 0 ); /* Output arguments */ *shift = shft; diff --git a/silk/tuning_parameters.h b/silk/tuning_parameters.h index d63a6bad..bf1d23b2 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.015f +#define LTP_CORR_INV_MAX 0.015f /***********************/ /* High pass filtering */ |