diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2013-08-29 01:55:34 +0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2013-08-29 01:55:34 +0400 |
commit | 6a7ee7fb55b4a41fca2dea19624600fe42d3b7f7 (patch) | |
tree | e64ce7be7536a89105ad6fa460782785b28769f5 /silk/fixed | |
parent | a156c5ece7133383468d4cba33f067595d9da391 (diff) |
Share auto-correlation code between SILK and CELT
Diffstat (limited to 'silk/fixed')
-rw-r--r-- | silk/fixed/autocorr_FIX.c | 35 |
1 files changed, 3 insertions, 32 deletions
diff --git a/silk/fixed/autocorr_FIX.c b/silk/fixed/autocorr_FIX.c index 3ac6650b..4cd8f6fc 100644 --- a/silk/fixed/autocorr_FIX.c +++ b/silk/fixed/autocorr_FIX.c @@ -30,6 +30,7 @@ POSSIBILITY OF SUCH DAMAGE. #endif #include "SigProc_FIX.h" +#include "celt_lpc.h" /* Compute autocorrelation */ void silk_autocorr( @@ -40,37 +41,7 @@ void silk_autocorr( const opus_int correlationCount /* I Number of correlation taps to compute */ ) { - opus_int i, lz, nRightShifts, corrCount; - opus_int64 corr64; - + opus_int corrCount; corrCount = silk_min_int( inputDataSize, correlationCount ); - - /* compute energy (zero-lag correlation) */ - corr64 = silk_inner_prod16_aligned_64( inputData, inputData, inputDataSize ); - - /* deal with all-zero input data */ - corr64 += 1; - - /* number of leading zeros */ - lz = silk_CLZ64( corr64 ); - - /* scaling: number of right shifts applied to correlations */ - nRightShifts = 35 - lz; - *scale = nRightShifts; - - if( nRightShifts <= 0 ) { - results[ 0 ] = silk_LSHIFT( (opus_int32)silk_CHECK_FIT32( corr64 ), -nRightShifts ); - - /* compute remaining correlations based on int32 inner product */ - for( i = 1; i < corrCount; i++ ) { - results[ i ] = silk_LSHIFT( silk_inner_prod_aligned( inputData, inputData + i, inputDataSize - i ), -nRightShifts ); - } - } else { - results[ 0 ] = (opus_int32)silk_CHECK_FIT32( silk_RSHIFT64( corr64, nRightShifts ) ); - - /* compute remaining correlations based on int64 inner product */ - for( i = 1; i < corrCount; i++ ) { - results[ i ] = (opus_int32)silk_CHECK_FIT32( silk_RSHIFT64( silk_inner_prod16_aligned_64( inputData, inputData + i, inputDataSize - i ), nRightShifts ) ); - } - } + *scale = _celt_autocorr(inputData, results, NULL, 0, corrCount-1, inputDataSize); } |