Update SILK code using the CELT range coder
[opus.git] / src_FIX / SKP_Silk_main_FIX.h
similarity index 72%
rename from src/SKP_Silk_main_FIX.h
rename to src_FIX/SKP_Silk_main_FIX.h
index ff28f9a..6d7d0dd 100644 (file)
@@ -34,8 +34,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "SKP_Silk_main.h"\r
 #include "SKP_Silk_define_FIX.h"\r
 #include "SKP_Silk_PLC.h"\r
-#define TIC(TAG_NAME)\r
-#define TOC(TAG_NAME)\r
+#include "SKP_debug.h"\r
+#include "entenc.h"\r
 \r
 #ifndef FORCE_CPP_BUILD\r
 #ifdef __cplusplus\r
@@ -55,12 +55,13 @@ SKP_int SKP_Silk_init_encoder_FIX(
 \r
 /* Control the Silk encoder */\r
 SKP_int SKP_Silk_control_encoder_FIX( \r
-    SKP_Silk_encoder_state_FIX  *psEnc,             /* I/O  Pointer to Silk FIX encoder state               */\r
-    const SKP_int               API_fs_kHz,         /* I    External (API) sampling rate (kHz)              */\r
+    SKP_Silk_encoder_state_FIX  *psEnc,             /* I/O  Pointer to Silk encoder state                   */\r
+    const SKP_int32             API_fs_Hz,          /* I    External (API) sampling rate (Hz)               */\r
+    const SKP_int               max_internal_fs_kHz,/* I    Maximum internal sampling rate (kHz)            */\r
     const SKP_int               PacketSize_ms,      /* I    Packet length (ms)                              */\r
     SKP_int32                   TargetRate_bps,     /* I    Target max bitrate (bps) (used if SNR_dB == 0)  */\r
     const SKP_int               PacketLoss_perc,    /* I    Packet loss rate (in percent)                   */\r
-    const SKP_int               INBandFec_enabled,  /* I    Enable (1) / disable (0) inband FEC             */\r
+    const SKP_int               INBandFEC_enabled,  /* I    Enable (1) / disable (0) inband FEC             */\r
     const SKP_int               DTX_enabled,        /* I    Enable / disable DTX                            */\r
     const SKP_int               InputFramesize_ms,  /* I    Inputframe in ms                                */\r
     const SKP_int               Complexity          /* I    Complexity (0->low; 1->medium; 2->high)         */\r
@@ -106,10 +107,20 @@ void SKP_Silk_prefilter_FIX(
 /* Compute noise shaping coefficients and initial gain values */\r
 /**************************************************************/\r
 void SKP_Silk_noise_shape_analysis_FIX(\r
-    SKP_Silk_encoder_state_FIX      *psEnc,         /* I/O  Encoder state                               */\r
-    SKP_Silk_encoder_control_FIX    *psEncCtrl,     /* I/O  Encoder control                             */\r
+    SKP_Silk_encoder_state_FIX      *psEnc,         /* I/O  Encoder state FIX                           */\r
+    SKP_Silk_encoder_control_FIX    *psEncCtrl,     /* I/O  Encoder control FIX                         */\r
     const SKP_int16                 *pitch_res,     /* I    LPC residual from pitch analysis            */\r
-    const SKP_int16                 *x              /* I    Input signal [ 2 * frame_length + la_shape ]*/\r
+    const SKP_int16                 *x              /* I    Input signal [ frame_length + la_shape ]    */\r
+);\r
+\r
+/* Autocorrelations for a warped frequency axis */\r
+void SKP_Silk_warped_autocorrelation_FIX(\r
+          SKP_int32                 *corr,              /* O    Result [order + 1]                      */\r
+          SKP_int                   *scale,             /* O    Scaling of the correlation vector       */\r
+    const SKP_int16                 *input,             /* I    Input data to correlate                 */\r
+    const SKP_int16                 warping_Q16,        /* I    Warping coefficient                     */\r
+    const SKP_int                   length,             /* I    Length of input                         */\r
+    const SKP_int                   order               /* I    Correlation order (even)                */\r
 );\r
 \r
 /* Processing of gains */\r
@@ -118,7 +129,6 @@ void SKP_Silk_process_gains_FIX(
     SKP_Silk_encoder_control_FIX    *psEncCtrl      /* I/O  Encoder control                             */\r
 );\r
 \r
-\r
 /* Control low bitrate redundancy usage */\r
 void SKP_Silk_LBRR_ctrl_FIX(\r
     SKP_Silk_encoder_state_FIX      *psEnc,         /* I/O  encoder state                               */\r
@@ -150,48 +160,50 @@ void SKP_Silk_find_pred_coefs_FIX(
 );\r
 \r
 void SKP_Silk_find_LPC_FIX(\r
-    SKP_int             NLSF_Q15[],             /* O    LSFs                                                                        */\r
-    SKP_int             *interpIndex,           /* O    LSF interpolation index, only used for LSF interpolation                    */\r
-    const SKP_int       prev_NLSFq_Q15[],       /* I    previous LSFs, only used for LSF interpolation                              */\r
-    const SKP_int       useInterpolatedLSFs,    /* I    Flag                                                                        */\r
-    const SKP_int       LPC_order,              /* I    LPC order                                                                   */\r
-    const SKP_int16     x[],                    /* I    Input signal                                                                */\r
-    const SKP_int       subfr_length            /* I    Input signal subframe length including preceeding samples                   */\r
+    SKP_int             NLSF_Q15[],                 /* O    NLSFs                                                                       */\r
+    SKP_int             *interpIndex,               /* O    NLSF interpolation index, only used for NLSF interpolation                  */\r
+    const SKP_int       prev_NLSFq_Q15[],           /* I    previous NLSFs, only used for NLSF interpolation                            */\r
+    const SKP_int       useInterpolatedNLSFs,       /* I    Flag                                                                        */\r
+    const SKP_int       LPC_order,                  /* I    LPC order                                                                   */\r
+    const SKP_int16     x[],                        /* I    Input signal                                                                */\r
+    const SKP_int       subfr_length,               /* I    Input signal subframe length including preceeding samples                   */\r
+    const SKP_int       nb_subfr                    /* I:   Number of subframes                                                         */\r
 );\r
 \r
 void SKP_Silk_LTP_analysis_filter_FIX(\r
-    SKP_int16       *LTP_res,                           /* O:   LTP residual signal of length NB_SUBFR * ( pre_length + subfr_length )  */\r
-    const SKP_int16 *x,                                 /* I:   Pointer to input signal with at least max( pitchL ) preceeding samples  */\r
-    const SKP_int16 LTPCoef_Q14[ LTP_ORDER * NB_SUBFR ],/* I:   LTP_ORDER LTP coefficients for each NB_SUBFR subframe                   */\r
-    const SKP_int   pitchL[ NB_SUBFR ],                 /* I:   Pitch lag, one for each subframe                                        */\r
-    const SKP_int32 invGains_Qxx[ NB_SUBFR ],           /* I:   Inverse quantization gains, one for each subframe                       */\r
-    const SKP_int   Qxx,                                /* I:   Inverse quantization gains Q domain                                     */\r
-    const SKP_int   subfr_length,                       /* I:   Length of each subframe                                                 */\r
-    const SKP_int   pre_length                          /* I:   Length of the preceeding samples starting at &x[0] for each subframe    */\r
+    SKP_int16           *LTP_res,                               /* O:   LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length )  */\r
+    const SKP_int16     *x,                                     /* I:   Pointer to input signal with at least max( pitchL ) preceeding samples      */\r
+    const SKP_int16     LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],/* I:   LTP_ORDER LTP coefficients for each MAX_NB_SUBFR subframe                   */\r
+    const SKP_int       pitchL[ MAX_NB_SUBFR ],                 /* I:   Pitch lag, one for each subframe                                            */\r
+    const SKP_int32     invGains_Q16[ MAX_NB_SUBFR ],           /* I:   Inverse quantization gains, one for each subframe                           */\r
+    const SKP_int       subfr_length,                           /* I:   Length of each subframe                                                     */\r
+    const SKP_int       nb_subfr,                               /* I:   Number of subframes                                                         */\r
+    const SKP_int       pre_length                              /* I:   Length of the preceeding samples starting at &x[0] for each subframe        */\r
 );\r
 \r
 /* Finds LTP vector from correlations */\r
 void SKP_Silk_find_LTP_FIX(\r
-    SKP_int16           b_Q14[ NB_SUBFR * LTP_ORDER ],              /* O    LTP coefs                                                   */\r
-    SKP_int32           WLTP[ NB_SUBFR * LTP_ORDER * LTP_ORDER ],   /* O    Weight for LTP quantization                                 */\r
-    SKP_int             *LTPredCodGain_Q7,                          /* O    LTP coding gain                                             */\r
-    const SKP_int16     r_first[],                                  /* I    residual signal after LPC signal + state for first 10 ms    */\r
-    const SKP_int16     r_last[],                                   /* I    residual signal after LPC signal + state for last 10 ms     */\r
-    const SKP_int       lag[ NB_SUBFR ],                            /* I    LTP lags                                                    */\r
-    const SKP_int32     Wght_Q15[ NB_SUBFR ],                       /* I    weights                                                     */\r
-    const SKP_int       subfr_length,                               /* I    subframe length                                             */\r
-    const SKP_int       mem_offset,                                 /* I    number of samples in LTP memory                             */\r
-    SKP_int             corr_rshifts[ NB_SUBFR ]                    /* O    right shifts applied to correlations                        */\r
+    SKP_int16           b_Q14[ MAX_NB_SUBFR * LTP_ORDER ],              /* O    LTP coefs                                                   */\r
+    SKP_int32           WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ],   /* O    Weight for LTP quantization                                 */\r
+    SKP_int             *LTPredCodGain_Q7,                              /* O    LTP coding gain                                             */\r
+    const SKP_int16     r_lpc[],                                        /* I    residual signal after LPC signal + state for first 10 ms    */\r
+    const SKP_int       lag[ MAX_NB_SUBFR ],                            /* I    LTP lags                                                    */\r
+    const SKP_int32     Wght_Q15[ MAX_NB_SUBFR ],                       /* I    weights                                                     */\r
+    const SKP_int       subfr_length,                                   /* I    subframe length                                             */\r
+    const SKP_int       nb_subfr,                                       /* I    number of subframes                                         */\r
+    const SKP_int       mem_offset,                                     /* I    number of samples in LTP memory                             */\r
+    SKP_int             corr_rshifts[ MAX_NB_SUBFR ]                    /* O    right shifts applied to correlations                        */\r
 );\r
 \r
 /* LTP tap quantizer */\r
 void SKP_Silk_quant_LTP_gains_FIX(\r
-    SKP_int16               B_Q14[],                /* I/O  (un)quantized LTP gains     */\r
-    SKP_int                 cbk_index[],            /* O    Codebook Index              */\r
-    SKP_int                 *periodicity_index,     /* O    Periodicity Index           */\r
-    const SKP_int32         W_Q18[],                /* I    Error Weights in Q18        */\r
-    SKP_int                 mu_Q8,                  /* I    Mu value (R/D tradeoff)     */\r
-    SKP_int                 lowComplexity           /* I    Flag for low complexity     */\r
+    SKP_int16           B_Q14[],                /* I/O  (un)quantized LTP gains     */\r
+    SKP_int             cbk_index[],            /* O    Codebook Index              */\r
+    SKP_int             *periodicity_index,     /* O    Periodicity Index           */\r
+    const SKP_int32     W_Q18[],                /* I    Error Weights in Q18        */\r
+    SKP_int             mu_Q8,                  /* I    Mu value (R/D tradeoff)     */\r
+    SKP_int             lowComplexity,          /* I    Flag for low complexity     */\r
+    const SKP_int       nb_subfr                /* I    number of subframes         */\r
 );\r
 \r
 /******************/\r
@@ -270,7 +282,7 @@ void SKP_Silk_corrMatrix_FIX(
 /* Calculates correlation vector X'*t */\r
 void SKP_Silk_corrVector_FIX(\r
     const SKP_int16                 *x,         /* I    x vector [L + order - 1] used to form data matrix X */\r
-    const SKP_int16                 *t,         /* I    target vector [L]                                   */\r
+    const SKP_int16                 *t,         /* I    Target vector [L]                                   */\r
     const SKP_int                   L,          /* I    Length of vectors                                   */\r
     const SKP_int                   order,      /* I    Max lag for correlation                             */\r
     SKP_int32                       *Xt,        /* O    Pointer to X'*t correlation vector [order]          */\r
@@ -306,14 +318,14 @@ SKP_int32 SKP_Silk_residual_energy16_covar_FIX(
 /* Calculates residual energies of input subframes where all subframes have LPC_order   */\r
 /* of preceeding samples                                                                */\r
 void SKP_Silk_residual_energy_FIX(\r
-          SKP_int32 nrgs[ NB_SUBFR ],           /* O    Residual energy per subframe    */\r
-          SKP_int   nrgsQ[ NB_SUBFR ],          /* O    Q value per subframe            */\r
-    const SKP_int16 x[],                        /* I    Input signal                    */\r
-    const SKP_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ],/* I    AR coefs for each frame half    */\r
-    const SKP_int32 gains_Qx[ NB_SUBFR ],       /* I    Quantization gains in Qx        */\r
-    const SKP_int   Qx,                         /* I    Quantization gains Q value      */\r
-    const SKP_int   subfr_length,               /* I    Subframe length                 */\r
-    const SKP_int   LPC_order                   /* I    LPC order                       */\r
+          SKP_int32 nrgs[ MAX_NB_SUBFR ],           /* O    Residual energy per subframe    */\r
+          SKP_int   nrgsQ[ MAX_NB_SUBFR ],          /* O    Q value per subframe            */\r
+    const SKP_int16 x[],                            /* I    Input signal                    */\r
+    const SKP_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ],    /* I    AR coefs for each frame half    */\r
+    const SKP_int32 gains[ MAX_NB_SUBFR ],          /* I    Quantization gains              */\r
+    const SKP_int   subfr_length,                   /* I    Subframe length                 */\r
+    const SKP_int   nb_subfr,                       /* I    Number of subframes             */\r
+    const SKP_int   LPC_order                       /* I    LPC order                       */\r
 );\r
 \r
 #ifndef FORCE_CPP_BUILD\r