diff options
author | Koen Vos <koenvos@users.noreply.github.com> | 2016-02-19 05:54:41 +0300 |
---|---|---|
committer | Koen Vos <koenvos@users.noreply.github.com> | 2016-02-19 05:54:41 +0300 |
commit | e572f8a5c5bcdcb2f6755c749c611b0edd0e78f3 (patch) | |
tree | 4edae4ff281ec4db74b2148218007ebd90f753f4 | |
parent | 199d906367862dbfb9fb88509ff445bf70736ed5 (diff) |
replaced 64-bit correlations with scaled 32-bit ones, in Burg
-rw-r--r-- | silk/fixed/burg_modified_FIX.c | 3 | ||||
-rw-r--r-- | silk/inner_prod_aligned.c | 15 |
2 files changed, 13 insertions, 5 deletions
diff --git a/silk/fixed/burg_modified_FIX.c b/silk/fixed/burg_modified_FIX.c index 7d072a46..769205bd 100644 --- a/silk/fixed/burg_modified_FIX.c +++ b/silk/fixed/burg_modified_FIX.c @@ -84,8 +84,7 @@ void silk_burg_modified_c( for( s = 0; s < nb_subfr; s++ ) { x_ptr = x + s * subfr_length; for( n = 1; n < D + 1; n++ ) { - c[ n ] += (opus_int32)silk_RSHIFT64( - silk_inner_prod16_aligned_64( x_ptr, x_ptr + n, subfr_length - n, arch ), rshifts ); + c[ n ] += silk_inner_prod_aligned_scale( x_ptr, x_ptr + n, rshifts, subfr_length - n ); } } } else { diff --git a/silk/inner_prod_aligned.c b/silk/inner_prod_aligned.c index 257ae9e0..e192e946 100644 --- a/silk/inner_prod_aligned.c +++ b/silk/inner_prod_aligned.c @@ -39,9 +39,18 @@ opus_int32 silk_inner_prod_aligned_scale( ) { opus_int i; - opus_int32 sum = 0; - for( i = 0; i < len; i++ ) { - sum = silk_ADD_RSHIFT32( sum, silk_SMULBB( inVec1[ i ], inVec2[ i ] ), scale ); + opus_int32 sum, bias; + + /* The bias serves two purposes: */ + /* - round to nearest (instead of rounding down) */ + /* - enable two-fold unrolling without risk of wrap around when multiplying values of -32768 */ + bias = silk_LSHIFT32( 1, scale - 1 ) - silk_LSHIFT32( 1, 15 ); + sum = silk_LSHIFT32( ( len + 1 ) >> 1, 15 - scale ); + for( i = 0; i < len - 1; i += 2 ) { + sum = silk_ADD_RSHIFT32( sum, silk_SMLABB( silk_SMLABB( bias, inVec1[ i ], inVec2[ i ] ), inVec1[ i + 1 ], inVec2[ i + 1 ] ), scale ); } + if( i < len ) { + sum = silk_ADD_RSHIFT32( sum, silk_SMLABB( bias, inVec1[ i ], inVec2[ i ] ), scale ); + } return sum; } |