Update SILK code using the CELT range coder
[opus.git] / src_FIX / SKP_Silk_find_pitch_lags_FIX.c
similarity index 85%
rename from src/SKP_Silk_find_pitch_lags_FIX.c
rename to src_FIX/SKP_Silk_find_pitch_lags_FIX.c
index dc7b2d3..3601b25 100644 (file)
@@ -26,6 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/\r
 \r
 #include "SKP_Silk_main_FIX.h"\r
+#include "SKP_Silk_common_pitch_est_defines.h"\r
 \r
 /* Find pitch lags */\r
 void SKP_Silk_find_pitch_lags_FIX(\r
@@ -36,29 +37,28 @@ void SKP_Silk_find_pitch_lags_FIX(
 )\r
 {\r
     SKP_Silk_predict_state_FIX *psPredSt = &psEnc->sPred;\r
-    SKP_int   buf_len, i;\r
-    SKP_int32 scale;\r
+    SKP_int   buf_len, i, scale;\r
     SKP_int32 thrhld_Q15;\r
     const SKP_int16 *x_buf, *x_buf_ptr;\r
     SKP_int16 Wsig[      FIND_PITCH_LPC_WIN_MAX ], *Wsig_ptr;\r
-    SKP_int32 auto_corr[ FIND_PITCH_LPC_ORDER_MAX + 1 ];\r
-    SKP_int16 rc_Q15[    FIND_PITCH_LPC_ORDER_MAX ];\r
-    SKP_int32 A_Q24[     FIND_PITCH_LPC_ORDER_MAX ];\r
-    SKP_int32 FiltState[ FIND_PITCH_LPC_ORDER_MAX ];\r
-    SKP_int16 A_Q12[     FIND_PITCH_LPC_ORDER_MAX ];\r
+    SKP_int32 auto_corr[ MAX_FIND_PITCH_LPC_ORDER + 1 ];\r
+    SKP_int16 rc_Q15[    MAX_FIND_PITCH_LPC_ORDER ];\r
+    SKP_int32 A_Q24[     MAX_FIND_PITCH_LPC_ORDER ];\r
+    SKP_int32 FiltState[ MAX_FIND_PITCH_LPC_ORDER ];\r
+    SKP_int16 A_Q12[     MAX_FIND_PITCH_LPC_ORDER ];\r
 \r
     /******************************************/\r
-    /* Setup buffer lengths etc based of Fs.  */\r
+    /* Setup buffer lengths etc based on Fs   */\r
     /******************************************/\r
-    buf_len = SKP_ADD_LSHIFT( psEnc->sCmn.la_pitch, psEnc->sCmn.frame_length, 1 );\r
+    buf_len = psEnc->sCmn.la_pitch + psEnc->sCmn.frame_length + psEnc->sCmn.ltp_mem_length;\r
 \r
     /* Safty check */\r
     SKP_assert( buf_len >= psPredSt->pitch_LPC_win_length );\r
 \r
-    x_buf = x - psEnc->sCmn.frame_length;\r
+    x_buf = x - psEnc->sCmn.ltp_mem_length;\r
 \r
     /*************************************/\r
-    /* Estimate LPC AR coeficients */\r
+    /* Estimate LPC AR coefficients      */\r
     /*************************************/\r
     \r
     /* Calculate windowed signal */\r
@@ -101,7 +101,7 @@ void SKP_Silk_find_pitch_lags_FIX(
     /*****************************************/\r
     /* LPC analysis filtering                */\r
     /*****************************************/\r
-    SKP_memset( FiltState, 0, psEnc->sCmn.pitchEstimationLPCOrder * sizeof( SKP_int16 ) );\r
+    SKP_memset( FiltState, 0, psEnc->sCmn.pitchEstimationLPCOrder * sizeof( SKP_int32 ) ); /* Not really necessary, but Valgrind will complain otherwise */\r
     SKP_Silk_MA_Prediction( x_buf, A_Q12, FiltState, res, buf_len, psEnc->sCmn.pitchEstimationLPCOrder );\r
     SKP_memset( res, 0, psEnc->sCmn.pitchEstimationLPCOrder * sizeof( SKP_int16 ) );\r
 \r
@@ -114,9 +114,11 @@ void SKP_Silk_find_pitch_lags_FIX(
     thrhld_Q15 = SKP_SAT16(  thrhld_Q15 );\r
 \r
     /*****************************************/\r
-    /* Call Pitch estimator */\r
+    /* Call pitch estimator                  */\r
     /*****************************************/\r
+TIC(pitch_analysis_core_FIX)\r
     psEncCtrl->sCmn.sigtype = SKP_Silk_pitch_analysis_core( res, psEncCtrl->sCmn.pitchL, &psEncCtrl->sCmn.lagIndex, \r
         &psEncCtrl->sCmn.contourIndex, &psEnc->LTPCorr_Q15, psEnc->sCmn.prevLag, psEnc->pitchEstimationThreshold_Q16, \r
-        ( SKP_int16 )thrhld_Q15, psEnc->sCmn.fs_kHz, psEnc->sCmn.pitchEstimationComplexity );\r
+        ( SKP_int16 )thrhld_Q15, psEnc->sCmn.fs_kHz, psEnc->sCmn.pitchEstimationComplexity, psEnc->sCmn.nb_subfr );\r
+TOC(pitch_analysis_core_FIX)\r
 }\r