本文整理汇总了C++中SKP_assert函数的典型用法代码示例。如果您正苦于以下问题:C++ SKP_assert函数的具体用法?C++ SKP_assert怎么用?C++ SKP_assert使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SKP_assert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SKP_Silk_NLSF_VQ_weights_laroia_FLP
/* Laroia low complexity NLSF weights */
void SKP_Silk_NLSF_VQ_weights_laroia_FLP(
SKP_float *pXW, /* 0: Pointer to input vector weights [D x 1] */
const SKP_float *pX, /* I: Pointer to input vector [D x 1] */
const SKP_int D /* I: Input vector dimension */
)
{
SKP_int k;
SKP_float tmp1, tmp2;
/* Safety checks */
SKP_assert( D > 0 );
SKP_assert( ( D & 1 ) == 0 );
/* First value */
tmp1 = 1.0f / SKP_max_float( pX[ 0 ], MIN_NDELTA );
tmp2 = 1.0f / SKP_max_float( pX[ 1 ] - pX[ 0 ], MIN_NDELTA );
pXW[ 0 ] = tmp1 + tmp2;
/* Main loop */
for( k = 1; k < D - 1; k += 2 ) {
tmp1 = 1.0f / SKP_max_float( pX[ k + 1 ] - pX[ k ], MIN_NDELTA );
pXW[ k ] = tmp1 + tmp2;
tmp2 = 1.0f / SKP_max_float( pX[ k + 2 ] - pX[ k + 1 ], MIN_NDELTA );
pXW[ k + 1 ] = tmp1 + tmp2;
}
/* Last value */
tmp1 = 1.0f / SKP_max_float( 1.0f - pX[ D - 1 ], MIN_NDELTA );
pXW[ D - 1 ] = tmp1 + tmp2;
}
示例2: SKP_Silk_CNG_exc
/* Generates excitation for CNG LPC synthesis */
SKP_INLINE void SKP_Silk_CNG_exc(
SKP_int16 residual[], /* O CNG residual signal Q0 */
SKP_int32 exc_buf_Q10[], /* I Random samples buffer Q10 */
SKP_int32 Gain_Q16, /* I Gain to apply */
SKP_int length, /* I Length */
SKP_int32 *rand_seed /* I/O Seed to random index generator */
)
{
SKP_int32 seed;
SKP_int i, idx, exc_mask;
exc_mask = CNG_BUF_MASK_MAX;
while( exc_mask > length ) {
exc_mask = SKP_RSHIFT( exc_mask, 1 );
}
seed = *rand_seed;
for( i = 0; i < length; i++ ) {
seed = SKP_RAND( seed );
idx = ( SKP_int )( SKP_RSHIFT( seed, 24 ) & exc_mask );
SKP_assert( idx >= 0 );
SKP_assert( idx <= CNG_BUF_MASK_MAX );
residual[ i ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( SKP_SMULWW( exc_buf_Q10[ idx ], Gain_Q16 ), 10 ) );
}
*rand_seed = seed;
}
示例3: SKP_Silk_VAD_GetNoiseLevels
void SKP_Silk_VAD_GetNoiseLevels(
const SKP_int32 pX[ VAD_N_BANDS ], /* I subband energies */
SKP_Silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */
)
{
SKP_int k;
SKP_int32 nl, nrg, inv_nrg;
SKP_int coef, min_coef;
/* Initially faster smoothing */
if( psSilk_VAD->counter < 1000 ) { /* 1000 = 20 sec */
min_coef = SKP_DIV32_16( SKP_int16_MAX, SKP_RSHIFT( psSilk_VAD->counter, 4 ) + 1 );
} else {
min_coef = 0;
}
for( k = 0; k < VAD_N_BANDS; k++ ) {
/* Get old noise level estimate for current band */
nl = psSilk_VAD->NL[ k ];
SKP_assert( nl >= 0 );
/* Add bias */
nrg = SKP_ADD_POS_SAT32( pX[ k ], psSilk_VAD->NoiseLevelBias[ k ] );
SKP_assert( nrg > 0 );
/* Invert energies */
inv_nrg = SKP_DIV32( SKP_int32_MAX, nrg );
SKP_assert( inv_nrg >= 0 );
/* Less update when subband energy is high */
if( nrg > SKP_LSHIFT( nl, 3 ) ) {
coef = VAD_NOISE_LEVEL_SMOOTH_COEF_Q16 >> 3;
} else if( nrg < nl ) {
示例4: silk_NLSF_VQ
/* Compute quantization errors for an LPC_order element input vector for a VQ codebook */
void silk_NLSF_VQ(
SKP_int32 err_Q26[], /* O Quantization errors [K] */
const SKP_int16 in_Q15[], /* I Input vectors to be quantized [LPC_order] */
const SKP_uint8 pCB_Q8[], /* I Codebook vectors [K*LPC_order] */
const SKP_int K, /* I Number of codebook vectors */
const SKP_int LPC_order /* I Number of LPCs */
)
{
SKP_int i, m;
SKP_int32 diff_Q15, sum_error_Q30, sum_error_Q26;
SKP_assert( LPC_order <= 16 );
SKP_assert( ( LPC_order & 1 ) == 0 );
/* Loop over codebook */
for( i = 0; i < K; i++ ) {
sum_error_Q26 = 0;
for( m = 0; m < LPC_order; m += 2 ) {
/* Compute weighted squared quantization error for index m */
diff_Q15 = SKP_SUB_LSHIFT32( in_Q15[ m ], ( SKP_int32 )*pCB_Q8++, 7 ); // range: [ -32767 : 32767 ]
sum_error_Q30 = SKP_SMULBB( diff_Q15, diff_Q15 );
/* Compute weighted squared quantization error for index m + 1 */
diff_Q15 = SKP_SUB_LSHIFT32( in_Q15[m + 1], ( SKP_int32 )*pCB_Q8++, 7 ); // range: [ -32767 : 32767 ]
sum_error_Q30 = SKP_SMLABB( sum_error_Q30, diff_Q15, diff_Q15 );
sum_error_Q26 = SKP_ADD_RSHIFT32( sum_error_Q26, sum_error_Q30, 4 );
SKP_assert( sum_error_Q26 >= 0 );
SKP_assert( sum_error_Q30 >= 0 );
}
err_Q26[ i ] = sum_error_Q26;
}
}
示例5: SKP_Silk_shell_insertion_sort_increasing
void SKP_Silk_shell_insertion_sort_increasing(
SKP_int32 *a, /* I/O: Unsorted / Sorted vector */
SKP_int *index, /* O: Index vector for the sorted elements */
const SKP_int L, /* I: Vector length */
const SKP_int K /* I: Number of correctly sorted positions */
)
{
SKP_int32 value, inc_Q16_tmp;
SKP_int i, j, inc, idx;
/* Safety checks */
SKP_assert( K > 0 );
SKP_assert( L > 0 );
SKP_assert( L >= K );
/* Calculate initial step size */
inc_Q16_tmp = SKP_LSHIFT( (SKP_int32)L, 15 );
inc = SKP_RSHIFT( inc_Q16_tmp, 16 );
/* Write start indices in index vector */
for( i = 0; i < K; i++ ) {
index[ i ] = i;
}
/* Shell sort first values */
while( inc > 0 ) {
for( i = inc; i < K; i++ ) {
value = a[ i ];
idx = index[ i ];
for( j = i - inc; ( j >= 0 ) && ( value < a[ j ] ); j -= inc ) {
a[ j + inc ] = a[ j ]; /* Shift value */
index[ j + inc ] = index[ j ]; /* Shift index */
}
a[ j + inc ] = value; /* Write value */
index[ j + inc ] = idx; /* Write index */
}
inc_Q16_tmp = SKP_SMULWB( inc_Q16_tmp, 29789 ); // 29789_Q16 = 2.2^(-1)_Q0
inc = SKP_RSHIFT_ROUND( inc_Q16_tmp, 16 );
}
/* If less than L values are asked for, check the remaining values, */
/* but only spend CPU to ensure that the K first values are correct */
/* Insertion sort remaining values */
for( i = K; i < L; i++ ) {
value = a[ i ];
if( value < a[ K - 1 ] ) {
for( j = K - 2; ( j >= 0 ) && ( value < a[ j ] ); j-- ) {
a[ j + 1 ] = a[ j ]; /* Shift value */
index[ j + 1 ] = index[ j ]; /* Shift index */
}
a[ j + 1 ] = value; /* Write value */
index[ j + 1 ] = i; /* Write index */
}
}
}
示例6: SKP_Silk_apply_sine_window
/* every other sample of window is linearly interpolated, for speed */
void SKP_Silk_apply_sine_window(
SKP_int16 px_win[], /* O Pointer to windowed signal */
const SKP_int16 px[], /* I Pointer to input signal */
const SKP_int win_type, /* I Selects a window type */
const SKP_int length /* I Window length, multiple of 4 */
)
{
SKP_int k;
SKP_int32 f_Q16, c_Q20, S0_Q16, S1_Q16;
/* Length must be multiple of 4 */
SKP_assert( ( length & 3 ) == 0 );
/* Input pointer must be 4-byte aligned */
SKP_assert( ( (SKP_int64)px & 3 ) == 0 );
if( win_type == 0 ) {
f_Q16 = SKP_DIV32_16( 411775, length + 1 ); // 411775 = 2 * 65536 * pi
} else {
f_Q16 = SKP_DIV32_16( 205887, length + 1 ); // 205887 = 65536 * pi
}
/* factor used for cosine approximation */
c_Q20 = -SKP_RSHIFT( SKP_MUL( f_Q16, f_Q16 ), 12 );
/* c_Q20 becomes too large if length is too small */
SKP_assert( c_Q20 >= -32768 );
/* initialize state */
if( win_type < 2 ) {
/* start from 0 */
S0_Q16 = 0;
/* approximation of sin(f) */
S1_Q16 = f_Q16;
} else {
/* start from 1 */
S0_Q16 = ( 1 << 16 );
/* approximation of cos(f) */
S1_Q16 = ( 1 << 16 ) + SKP_RSHIFT( c_Q20, 5 );
}
/* Uses the recursive equation: sin(n*f) = 2 * cos(f) * sin((n-1)*f) - sin((n-2)*f) */
/* 4 samples at a time */
for( k = 0; k < length; k += 4 ) {
px_win[ k ] = (SKP_int16)SKP_SMULWB( SKP_RSHIFT( S0_Q16 + S1_Q16, 1 ), px[ k ] );
px_win[ k + 1 ] = (SKP_int16)SKP_SMULWB( S1_Q16, px[ k + 1] );
S0_Q16 = SKP_RSHIFT( SKP_MUL( c_Q20, S1_Q16 ), 20 ) + SKP_LSHIFT( S1_Q16, 1 ) - S0_Q16 + 1;
S0_Q16 = SKP_min( S0_Q16, ( 1 << 16 ) );
px_win[ k + 2 ] = (SKP_int16)SKP_SMULWB( SKP_RSHIFT( S0_Q16 + S1_Q16, 1 ), px[ k + 2] );
px_win[ k + 3 ] = (SKP_int16)SKP_SMULWB( S0_Q16, px[ k + 3 ] );
S1_Q16 = SKP_RSHIFT( SKP_MUL( c_Q20, S0_Q16 ), 20 ) + SKP_LSHIFT( S0_Q16, 1 ) - S1_Q16;
S1_Q16 = SKP_min( S1_Q16, ( 1 << 16 ) );
}
}
示例7: silk_warped_autocorrelation_FIX
/* Autocorrelations for a warped frequency axis */
void silk_warped_autocorrelation_FIX(
opus_int32 *corr, /* O Result [order + 1] */
opus_int *scale, /* O Scaling of the correlation vector */
const opus_int16 *input, /* I Input data to correlate */
const opus_int warping_Q16, /* I Warping coefficient */
const opus_int length, /* I Length of input */
const opus_int order /* I Correlation order (even) */
)
{
opus_int n, i, lsh;
opus_int32 tmp1_QS, tmp2_QS;
opus_int32 state_QS[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 };
opus_int64 corr_QC[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 };
/* Order must be even */
SKP_assert( ( order & 1 ) == 0 );
SKP_assert( 2 * QS - QC >= 0 );
/* Loop over samples */
for( n = 0; n < length; n++ ) {
tmp1_QS = SKP_LSHIFT32( ( opus_int32 )input[ n ], QS );
/* Loop over allpass sections */
for( i = 0; i < order; i += 2 ) {
/* Output of allpass section */
tmp2_QS = SKP_SMLAWB( state_QS[ i ], state_QS[ i + 1 ] - tmp1_QS, warping_Q16 );
state_QS[ i ] = tmp1_QS;
corr_QC[ i ] += SKP_RSHIFT64( SKP_SMULL( tmp1_QS, state_QS[ 0 ] ), 2 * QS - QC );
/* Output of allpass section */
tmp1_QS = SKP_SMLAWB( state_QS[ i + 1 ], state_QS[ i + 2 ] - tmp2_QS, warping_Q16 );
state_QS[ i + 1 ] = tmp2_QS;
corr_QC[ i + 1 ] += SKP_RSHIFT64( SKP_SMULL( tmp2_QS, state_QS[ 0 ] ), 2 * QS - QC );
}
state_QS[ order ] = tmp1_QS;
corr_QC[ order ] += SKP_RSHIFT64( SKP_SMULL( tmp1_QS, state_QS[ 0 ] ), 2 * QS - QC );
}
lsh = silk_CLZ64( corr_QC[ 0 ] ) - 35;
lsh = SKP_LIMIT( lsh, -12 - QC, 30 - QC );
*scale = -( QC + lsh );
SKP_assert( *scale >= -30 && *scale <= 12 );
if( lsh >= 0 ) {
for( i = 0; i < order + 1; i++ ) {
corr[ i ] = ( opus_int32 )SKP_CHECK_FIT32( SKP_LSHIFT64( corr_QC[ i ], lsh ) );
}
} else {
for( i = 0; i < order + 1; i++ ) {
corr[ i ] = ( opus_int32 )SKP_CHECK_FIT32( SKP_RSHIFT64( corr_QC[ i ], -lsh ) );
}
}
SKP_assert( corr_QC[ 0 ] >= 0 ); // If breaking, decrease QC
}
示例8: SKP_Silk_LDL_FLP
void SKP_Silk_LDL_FLP(
SKP_float *A, /* (I/O) Pointer to Symetric Square Matrix */
SKP_int M, /* (I) Size of Matrix */
SKP_float *L, /* (I/O) Pointer to Square Upper triangular Matrix */
SKP_float *Dinv /* (I/O) Pointer to vector holding the inverse diagonal elements of D */
)
{
SKP_int i, j, k, loop_count, err = 1;
SKP_float *ptr1, *ptr2;
double temp, diag_min_value;
SKP_float v[ MAX_MATRIX_SIZE ], D[ MAX_MATRIX_SIZE ]; // temp arrays
SKP_assert( M <= MAX_MATRIX_SIZE );
diag_min_value = FIND_LTP_COND_FAC * 0.5f * ( A[ 0 ] + A[ M * M - 1 ] );
for( loop_count = 0; loop_count < M && err == 1; loop_count++ ) {
err = 0;
for( j = 0; j < M; j++ ) {
ptr1 = matrix_adr( L, j, 0, M );
temp = matrix_ptr( A, j, j, M ); // element in row j column j
for( i = 0; i < j; i++ ) {
v[ i ] = ptr1[ i ] * D[ i ];
temp -= ptr1[ i ] * v[ i ];
}
if( temp < diag_min_value ) {
/* Badly conditioned matrix: add white noise and run again */
temp = ( loop_count + 1 ) * diag_min_value - temp;
for( i = 0; i < M; i++ ) {
matrix_ptr( A, i, i, M ) += ( SKP_float )temp;
}
err = 1;
break;
}
D[ j ] = ( SKP_float )temp;
Dinv[ j ] = ( SKP_float )( 1.0f / temp );
matrix_ptr( L, j, j, M ) = 1.0f;
ptr1 = matrix_adr( A, j, 0, M );
ptr2 = matrix_adr( L, j + 1, 0, M);
for( i = j + 1; i < M; i++ ) {
temp = 0.0;
for( k = 0; k < j; k++ ) {
temp += ptr2[ k ] * v[ k ];
}
matrix_ptr( L, i, j, M ) = ( SKP_float )( ( ptr1[ i ] - temp ) * Dinv[ j ] );
ptr2 += M; // go to next column
}
}
}
SKP_assert( err == 0 );
}
示例9: SKP_Silk_NLSF_VQ_sum_error_FIX
/* Compute weighted quantization errors for an LPC_order element input vector, over one codebook stage */
void SKP_Silk_NLSF_VQ_sum_error_FIX(
SKP_int32 *err_Q20, /* O Weighted quantization errors [N*K] */
const SKP_int *in_Q15, /* I Input vectors to be quantized [N*LPC_order] */
const SKP_int *w_Q6, /* I Weighting vectors [N*LPC_order] */
const SKP_int16 *pCB_Q15, /* I Codebook vectors [K*LPC_order] */
const SKP_int N, /* I Number of input vectors */
const SKP_int K, /* I Number of codebook vectors */
const SKP_int LPC_order /* I Number of LPCs */
)
{
SKP_int i, n, m;
SKP_int32 diff_Q15, sum_error, Wtmp_Q6;
SKP_int32 Wcpy_Q6[ MAX_LPC_ORDER / 2 ];
const SKP_int16 *cb_vec_Q15;
SKP_assert( LPC_order <= 16 );
SKP_assert( ( LPC_order & 1 ) == 0 );
/* Copy to local stack and pack two weights per int32 */
for( m = 0; m < SKP_RSHIFT( LPC_order, 1 ); m++ ) {
Wcpy_Q6[ m ] = w_Q6[ 2 * m ] | SKP_LSHIFT( ( SKP_int32 )w_Q6[ 2 * m + 1 ], 16 );
}
/* Loop over input vectors */
for( n = 0; n < N; n++ ) {
/* Loop over codebook */
cb_vec_Q15 = pCB_Q15;
for( i = 0; i < K; i++ ) {
sum_error = 0;
for( m = 0; m < LPC_order; m += 2 ) {
/* Get two weights packed in an int32 */
Wtmp_Q6 = Wcpy_Q6[ SKP_RSHIFT( m, 1 ) ];
/* Compute weighted squared quantization error for index m */
diff_Q15 = in_Q15[ m ] - *cb_vec_Q15++; // range: [ -32767 : 32767 ]
sum_error = SKP_SMLAWB( sum_error, SKP_SMULBB( diff_Q15, diff_Q15 ), Wtmp_Q6 );
/* Compute weighted squared quantization error for index m + 1 */
diff_Q15 = in_Q15[m + 1] - *cb_vec_Q15++; // range: [ -32767 : 32767 ]
sum_error = SKP_SMLAWT( sum_error, SKP_SMULBB( diff_Q15, diff_Q15 ), Wtmp_Q6 );
}
SKP_assert( sum_error >= 0 );
err_Q20[ i ] = sum_error;
}
err_Q20 += K;
in_Q15 += LPC_order;
}
}
示例10: SKP_Silk_NLSF2A_stable
/* Convert NLSF parameters to stable AR prediction filter coefficients */
void SKP_Silk_NLSF2A_stable(
SKP_int16 pAR_Q12[ MAX_LPC_ORDER ], /* O Stabilized AR coefs [LPC_order] */
const SKP_int pNLSF[ MAX_LPC_ORDER ], /* I NLSF vector [LPC_order] */
const SKP_int LPC_order /* I LPC/LSF order */
)
{
SKP_int i;
SKP_int32 invGain_Q30;
SKP_Silk_NLSF2A( pAR_Q12, pNLSF, LPC_order );
/* Ensure stable LPCs */
for( i = 0; i < MAX_LPC_STABILIZE_ITERATIONS; i++ ) {
if( SKP_Silk_LPC_inverse_pred_gain( &invGain_Q30, pAR_Q12, LPC_order ) == 1 ) {
SKP_Silk_bwexpander( pAR_Q12, LPC_order, 65536 - SKP_SMULBB( 10 + i, i ) ); /* 10_Q16 = 0.00015 */
} else {
break;
}
}
/* Reached the last iteration */
if( i == MAX_LPC_STABILIZE_ITERATIONS ) {
SKP_assert( 0 );
for( i = 0; i < LPC_order; i++ ) {
pAR_Q12[ i ] = 0;
}
}
}
示例11: SKP_Silk_energy_FLP
/* sum of squares of a SKP_float array, with result as double */
double SKP_Silk_energy_FLP(
const SKP_float *data,
SKP_int dataSize
)
{
SKP_int i, dataSize4;
double result;
/* 4x unrolled loop */
result = 0.0f;
dataSize4 = dataSize & 0xFFFC;
for( i = 0; i < dataSize4; i += 4 ) {
result += data[ i + 0 ] * data[ i + 0 ] +
data[ i + 1 ] * data[ i + 1 ] +
data[ i + 2 ] * data[ i + 2 ] +
data[ i + 3 ] * data[ i + 3 ];
}
/* add any remaining products */
for( ; i < dataSize; i++ ) {
result += data[ i ] * data[ i ];
}
SKP_assert( result >= 0.0 );
return result;
}
示例12: SKP_Silk_shell_decoder
/* Shell decoder, operates on one shell code frame of 16 pulses */
void SKP_Silk_shell_decoder(
SKP_int *pulses0, /* O data: nonnegative pulse amplitudes */
ec_dec *psRangeDec, /* I/O Compressor data structure */
const SKP_int pulses4 /* I number of pulses per pulse-subframe */
)
{
SKP_int pulses3[ 2 ], pulses2[ 4 ], pulses1[ 8 ];
/* this function operates on one shell code frame of 16 pulses */
SKP_assert( SHELL_CODEC_FRAME_LENGTH == 16 );
decode_split( &pulses3[ 0 ], &pulses3[ 1 ], psRangeDec, pulses4, SKP_Silk_shell_code_table3 );
decode_split( &pulses2[ 0 ], &pulses2[ 1 ], psRangeDec, pulses3[ 0 ], SKP_Silk_shell_code_table2 );
decode_split( &pulses1[ 0 ], &pulses1[ 1 ], psRangeDec, pulses2[ 0 ], SKP_Silk_shell_code_table1 );
decode_split( &pulses0[ 0 ], &pulses0[ 1 ], psRangeDec, pulses1[ 0 ], SKP_Silk_shell_code_table0 );
decode_split( &pulses0[ 2 ], &pulses0[ 3 ], psRangeDec, pulses1[ 1 ], SKP_Silk_shell_code_table0 );
decode_split( &pulses1[ 2 ], &pulses1[ 3 ], psRangeDec, pulses2[ 1 ], SKP_Silk_shell_code_table1 );
decode_split( &pulses0[ 4 ], &pulses0[ 5 ], psRangeDec, pulses1[ 2 ], SKP_Silk_shell_code_table0 );
decode_split( &pulses0[ 6 ], &pulses0[ 7 ], psRangeDec, pulses1[ 3 ], SKP_Silk_shell_code_table0 );
decode_split( &pulses2[ 2 ], &pulses2[ 3 ], psRangeDec, pulses3[ 1 ], SKP_Silk_shell_code_table2 );
decode_split( &pulses1[ 4 ], &pulses1[ 5 ], psRangeDec, pulses2[ 2 ], SKP_Silk_shell_code_table1 );
decode_split( &pulses0[ 8 ], &pulses0[ 9 ], psRangeDec, pulses1[ 4 ], SKP_Silk_shell_code_table0 );
decode_split( &pulses0[ 10 ], &pulses0[ 11 ], psRangeDec, pulses1[ 5 ], SKP_Silk_shell_code_table0 );
decode_split( &pulses1[ 6 ], &pulses1[ 7 ], psRangeDec, pulses2[ 3 ], SKP_Silk_shell_code_table1 );
decode_split( &pulses0[ 12 ], &pulses0[ 13 ], psRangeDec, pulses1[ 6 ], SKP_Silk_shell_code_table0 );
decode_split( &pulses0[ 14 ], &pulses0[ 15 ], psRangeDec, pulses1[ 7 ], SKP_Silk_shell_code_table0 );
}
示例13: SKP_Silk_corrVector_FIX
/* Calculates correlation vector X'*t */
void SKP_Silk_corrVector_FIX(
const SKP_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
const SKP_int16 *t, /* I target vector [L] */
const SKP_int L, /* I Length of vectors */
const SKP_int order, /* I Max lag for correlation */
SKP_int32 *Xt, /* O Pointer to X'*t correlation vector [order] */
const SKP_int rshifts /* I Right shifts of correlations */
)
{
SKP_int lag, i;
const SKP_int16 *ptr1, *ptr2;
SKP_int32 inner_prod;
ptr1 = &x[ order - 1 ]; /* Points to first sample of column 0 of X: X[:,0] */
ptr2 = t;
/* Calculate X'*t */
if( rshifts > 0 ) {
/* Right shifting used */
for( lag = 0; lag < order; lag++ ) {
inner_prod = 0;
for( i = 0; i < L; i++ ) {
inner_prod += SKP_RSHIFT32( SKP_SMULBB( ptr1[ i ], ptr2[i] ), rshifts );
}
Xt[ lag ] = inner_prod; /* X[:,lag]'*t */
ptr1--; /* Go to next column of X */
}
} else {
SKP_assert( rshifts == 0 );
for( lag = 0; lag < order; lag++ ) {
Xt[ lag ] = SKP_Silk_inner_prod_aligned( ptr1, ptr2, L ); /* X[:,lag]'*t */
ptr1--; /* Go to next column of X */
}
}
}
示例14: SKP_Silk_LPC_analysis_filter
/*
Variable order MA prediction error filter. Inverse filter of
SKP_Silk_LPC_synthesis_filter.
The inlined assembly makes it over 30% faster than the generic C.
*/
void SKP_Silk_LPC_analysis_filter(
const SKP_int16 *in, /* I: Input signal */
const SKP_int16 *B, /* I: MA prediction coefficients, Q12 [order] */
SKP_int16 *S, /* I/O: State vector [order] */
SKP_int16 *out, /* O: Output signal */
const SKP_int32 len, /* I: Signal length */
const SKP_int32 Order /* I: Filter order */
)
{
SKP_int k;
SKP_int32 out32_Q12, out32;
/* Order must be even */
SKP_assert( 2 * Order_half == Order );
/* S[] values are in Q0 */
for( k = 0; k < len; k++ ) {
LPC_ANALYSYS(out32_Q12, S, B, Order);
/* Subtract prediction */
out32_Q12 = SKP_SUB_SAT32( SKP_LSHIFT(
(SKP_int32)in[ k ], 12 ), out32_Q12 );
/* Scale to Q0 */
out32 = SKP_RSHIFT_ROUND( out32_Q12, 12 );
out[ k ] = (SKP_int16)SKP_SAT16( out32 );
/* Move input line */
S[ 0 ] = in[ k ];
}
}
示例15: SKP_Silk_insertion_sort_decreasing_FLP
void SKP_Silk_insertion_sort_decreasing_FLP(
SKP_float *a, /* I/O: Unsorted / Sorted vector */
SKP_int *index, /* O: Index vector for the sorted elements */
const SKP_int L, /* I: Vector length */
const SKP_int K /* I: Number of correctly sorted positions */
)
{
SKP_float value;
SKP_int i, j;
/* Safety checks */
SKP_assert( K > 0 );
SKP_assert( L > 0 );
SKP_assert( L >= K );
/* Write start indices in index vector */
for( i = 0; i < K; i++ ) {
index[ i ] = i;
}
/* Sort vector elements by value, decreasing order */
for( i = 1; i < K; i++ ) {
value = a[ i ];
for( j = i - 1; ( j >= 0 ) && ( value > a[ j ] ); j-- ) {
a[ j + 1 ] = a[ j ]; /* Shift value */
index[ j + 1 ] = index[ j ]; /* Shift index */
}
a[ j + 1 ] = value; /* Write value */
index[ j + 1 ] = i; /* Write index */
}
/* If less than L values are asked check the remaining values, */
/* but only spend CPU to ensure that the K first values are correct */
for( i = K; i < L; i++ ) {
value = a[ i ];
if( value > a[ K - 1 ] ) {
for( j = K - 2; ( j >= 0 ) && ( value > a[ j ] ); j-- ) {
a[ j + 1 ] = a[ j ]; /* Shift value */
index[ j + 1 ] = index[ j ]; /* Shift index */
}
a[ j + 1 ] = value; /* Write value */
index[ j + 1 ] = i; /* Write index */
}
}
}