media/libopus/silk/float/main_FLP.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libopus/silk/float/main_FLP.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,312 @@
     1.4 +/***********************************************************************
     1.5 +Copyright (c) 2006-2011, Skype Limited. All rights reserved.
     1.6 +Redistribution and use in source and binary forms, with or without
     1.7 +modification, are permitted provided that the following conditions
     1.8 +are met:
     1.9 +- Redistributions of source code must retain the above copyright notice,
    1.10 +this list of conditions and the following disclaimer.
    1.11 +- Redistributions in binary form must reproduce the above copyright
    1.12 +notice, this list of conditions and the following disclaimer in the
    1.13 +documentation and/or other materials provided with the distribution.
    1.14 +- Neither the name of Internet Society, IETF or IETF Trust, nor the
    1.15 +names of specific contributors, may be used to endorse or promote
    1.16 +products derived from this software without specific prior written
    1.17 +permission.
    1.18 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    1.19 +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.20 +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.21 +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
    1.22 +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    1.23 +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    1.24 +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    1.25 +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    1.26 +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    1.27 +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    1.28 +POSSIBILITY OF SUCH DAMAGE.
    1.29 +***********************************************************************/
    1.30 +
    1.31 +#ifndef SILK_MAIN_FLP_H
    1.32 +#define SILK_MAIN_FLP_H
    1.33 +
    1.34 +#include "SigProc_FLP.h"
    1.35 +#include "SigProc_FIX.h"
    1.36 +#include "structs_FLP.h"
    1.37 +#include "main.h"
    1.38 +#include "define.h"
    1.39 +#include "debug.h"
    1.40 +#include "entenc.h"
    1.41 +
    1.42 +#ifdef __cplusplus
    1.43 +extern "C"
    1.44 +{
    1.45 +#endif
    1.46 +
    1.47 +#define silk_encoder_state_Fxx      silk_encoder_state_FLP
    1.48 +#define silk_encode_do_VAD_Fxx      silk_encode_do_VAD_FLP
    1.49 +#define silk_encode_frame_Fxx       silk_encode_frame_FLP
    1.50 +
    1.51 +/*********************/
    1.52 +/* Encoder Functions */
    1.53 +/*********************/
    1.54 +
    1.55 +/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */
    1.56 +void silk_HP_variable_cutoff(
    1.57 +    silk_encoder_state_Fxx          state_Fxx[]                         /* I/O  Encoder states                              */
    1.58 +);
    1.59 +
    1.60 +/* Encoder main function */
    1.61 +void silk_encode_do_VAD_FLP(
    1.62 +    silk_encoder_state_FLP          *psEnc                              /* I/O  Encoder state FLP                           */
    1.63 +);
    1.64 +
    1.65 +/* Encoder main function */
    1.66 +opus_int silk_encode_frame_FLP(
    1.67 +    silk_encoder_state_FLP          *psEnc,                             /* I/O  Encoder state FLP                           */
    1.68 +    opus_int32                      *pnBytesOut,                        /* O    Number of payload bytes;                    */
    1.69 +    ec_enc                          *psRangeEnc,                        /* I/O  compressor data structure                   */
    1.70 +    opus_int                        condCoding,                         /* I    The type of conditional coding to use       */
    1.71 +    opus_int                        maxBits,                            /* I    If > 0: maximum number of output bits       */
    1.72 +    opus_int                        useCBR                              /* I    Flag to force constant-bitrate operation    */
    1.73 +);
    1.74 +
    1.75 +/* Initializes the Silk encoder state */
    1.76 +opus_int silk_init_encoder(
    1.77 +    silk_encoder_state_FLP          *psEnc,                             /* I/O  Encoder state FLP                           */
    1.78 +    int                              arch                               /* I    Run-tim architecture                        */
    1.79 +);
    1.80 +
    1.81 +/* Control the Silk encoder */
    1.82 +opus_int silk_control_encoder(
    1.83 +    silk_encoder_state_FLP          *psEnc,                             /* I/O  Pointer to Silk encoder state FLP           */
    1.84 +    silk_EncControlStruct           *encControl,                        /* I    Control structure                           */
    1.85 +    const opus_int32                TargetRate_bps,                     /* I    Target max bitrate (bps)                    */
    1.86 +    const opus_int                  allow_bw_switch,                    /* I    Flag to allow switching audio bandwidth     */
    1.87 +    const opus_int                  channelNb,                          /* I    Channel number                              */
    1.88 +    const opus_int                  force_fs_kHz
    1.89 +);
    1.90 +
    1.91 +/****************/
    1.92 +/* Prefiltering */
    1.93 +/****************/
    1.94 +void silk_prefilter_FLP(
    1.95 +    silk_encoder_state_FLP          *psEnc,                             /* I/O  Encoder state FLP                           */
    1.96 +    const silk_encoder_control_FLP  *psEncCtrl,                         /* I    Encoder control FLP                         */
    1.97 +    silk_float                      xw[],                               /* O    Weighted signal                             */
    1.98 +    const silk_float                x[]                                 /* I    Speech signal                               */
    1.99 +);
   1.100 +
   1.101 +/**************************/
   1.102 +/* Noise shaping analysis */
   1.103 +/**************************/
   1.104 +/* Compute noise shaping coefficients and initial gain values */
   1.105 +void silk_noise_shape_analysis_FLP(
   1.106 +    silk_encoder_state_FLP          *psEnc,                             /* I/O  Encoder state FLP                           */
   1.107 +    silk_encoder_control_FLP        *psEncCtrl,                         /* I/O  Encoder control FLP                         */
   1.108 +    const silk_float                *pitch_res,                         /* I    LPC residual from pitch analysis            */
   1.109 +    const silk_float                *x                                  /* I    Input signal [frame_length + la_shape]      */
   1.110 +);
   1.111 +
   1.112 +/* Autocorrelations for a warped frequency axis */
   1.113 +void silk_warped_autocorrelation_FLP(
   1.114 +    silk_float                      *corr,                              /* O    Result [order + 1]                          */
   1.115 +    const silk_float                *input,                             /* I    Input data to correlate                     */
   1.116 +    const silk_float                warping,                            /* I    Warping coefficient                         */
   1.117 +    const opus_int                  length,                             /* I    Length of input                             */
   1.118 +    const opus_int                  order                               /* I    Correlation order (even)                    */
   1.119 +);
   1.120 +
   1.121 +/* Calculation of LTP state scaling */
   1.122 +void silk_LTP_scale_ctrl_FLP(
   1.123 +    silk_encoder_state_FLP          *psEnc,                             /* I/O  Encoder state FLP                           */
   1.124 +    silk_encoder_control_FLP        *psEncCtrl,                         /* I/O  Encoder control FLP                         */
   1.125 +    opus_int                        condCoding                          /* I    The type of conditional coding to use       */
   1.126 +);
   1.127 +
   1.128 +/**********************************************/
   1.129 +/* Prediction Analysis                        */
   1.130 +/**********************************************/
   1.131 +/* Find pitch lags */
   1.132 +void silk_find_pitch_lags_FLP(
   1.133 +    silk_encoder_state_FLP          *psEnc,                             /* I/O  Encoder state FLP                           */
   1.134 +    silk_encoder_control_FLP        *psEncCtrl,                         /* I/O  Encoder control FLP                         */
   1.135 +    silk_float                      res[],                              /* O    Residual                                    */
   1.136 +    const silk_float                x[],                                /* I    Speech signal                               */
   1.137 +    int                             arch                                /* I    Run-time architecture                       */
   1.138 +);
   1.139 +
   1.140 +/* Find LPC and LTP coefficients */
   1.141 +void silk_find_pred_coefs_FLP(
   1.142 +    silk_encoder_state_FLP          *psEnc,                             /* I/O  Encoder state FLP                           */
   1.143 +    silk_encoder_control_FLP        *psEncCtrl,                         /* I/O  Encoder control FLP                         */
   1.144 +    const silk_float                res_pitch[],                        /* I    Residual from pitch analysis                */
   1.145 +    const silk_float                x[],                                /* I    Speech signal                               */
   1.146 +    opus_int                        condCoding                          /* I    The type of conditional coding to use       */
   1.147 +);
   1.148 +
   1.149 +/* LPC analysis */
   1.150 +void silk_find_LPC_FLP(
   1.151 +    silk_encoder_state              *psEncC,                            /* I/O  Encoder state                               */
   1.152 +    opus_int16                      NLSF_Q15[],                         /* O    NLSFs                                       */
   1.153 +    const silk_float                x[],                                /* I    Input signal                                */
   1.154 +    const silk_float                minInvGain                          /* I    Prediction gain from LTP (dB)               */
   1.155 +);
   1.156 +
   1.157 +/* LTP analysis */
   1.158 +void silk_find_LTP_FLP(
   1.159 +    silk_float                      b[ MAX_NB_SUBFR * LTP_ORDER ],      /* O    LTP coefs                                   */
   1.160 +    silk_float                      WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O    Weight for LTP quantization       */
   1.161 +    silk_float                      *LTPredCodGain,                     /* O    LTP coding gain                             */
   1.162 +    const silk_float                r_lpc[],                            /* I    LPC residual                                */
   1.163 +    const opus_int                  lag[  MAX_NB_SUBFR ],               /* I    LTP lags                                    */
   1.164 +    const silk_float                Wght[ MAX_NB_SUBFR ],               /* I    Weights                                     */
   1.165 +    const opus_int                  subfr_length,                       /* I    Subframe length                             */
   1.166 +    const opus_int                  nb_subfr,                           /* I    number of subframes                         */
   1.167 +    const opus_int                  mem_offset                          /* I    Number of samples in LTP memory             */
   1.168 +);
   1.169 +
   1.170 +void silk_LTP_analysis_filter_FLP(
   1.171 +    silk_float                      *LTP_res,                           /* O    LTP res MAX_NB_SUBFR*(pre_lgth+subfr_lngth) */
   1.172 +    const silk_float                *x,                                 /* I    Input signal, with preceding samples        */
   1.173 +    const silk_float                B[ LTP_ORDER * MAX_NB_SUBFR ],      /* I    LTP coefficients for each subframe          */
   1.174 +    const opus_int                  pitchL[   MAX_NB_SUBFR ],           /* I    Pitch lags                                  */
   1.175 +    const silk_float                invGains[ MAX_NB_SUBFR ],           /* I    Inverse quantization gains                  */
   1.176 +    const opus_int                  subfr_length,                       /* I    Length of each subframe                     */
   1.177 +    const opus_int                  nb_subfr,                           /* I    number of subframes                         */
   1.178 +    const opus_int                  pre_length                          /* I    Preceding samples for each subframe         */
   1.179 +);
   1.180 +
   1.181 +/* Calculates residual energies of input subframes where all subframes have LPC_order   */
   1.182 +/* of preceding samples                                                                 */
   1.183 +void silk_residual_energy_FLP(
   1.184 +    silk_float                      nrgs[ MAX_NB_SUBFR ],               /* O    Residual energy per subframe                */
   1.185 +    const silk_float                x[],                                /* I    Input signal                                */
   1.186 +    silk_float                      a[ 2 ][ MAX_LPC_ORDER ],            /* I    AR coefs for each frame half                */
   1.187 +    const silk_float                gains[],                            /* I    Quantization gains                          */
   1.188 +    const opus_int                  subfr_length,                       /* I    Subframe length                             */
   1.189 +    const opus_int                  nb_subfr,                           /* I    number of subframes                         */
   1.190 +    const opus_int                  LPC_order                           /* I    LPC order                                   */
   1.191 +);
   1.192 +
   1.193 +/* 16th order LPC analysis filter */
   1.194 +void silk_LPC_analysis_filter_FLP(
   1.195 +    silk_float                      r_LPC[],                            /* O    LPC residual signal                         */
   1.196 +    const silk_float                PredCoef[],                         /* I    LPC coefficients                            */
   1.197 +    const silk_float                s[],                                /* I    Input signal                                */
   1.198 +    const opus_int                  length,                             /* I    Length of input signal                      */
   1.199 +    const opus_int                  Order                               /* I    LPC order                                   */
   1.200 +);
   1.201 +
   1.202 +/* LTP tap quantizer */
   1.203 +void silk_quant_LTP_gains_FLP(
   1.204 +    silk_float                      B[ MAX_NB_SUBFR * LTP_ORDER ],      /* I/O  (Un-)quantized LTP gains                    */
   1.205 +    opus_int8                       cbk_index[ MAX_NB_SUBFR ],          /* O    Codebook index                              */
   1.206 +    opus_int8                       *periodicity_index,                 /* O    Periodicity index                           */
   1.207 +    opus_int32                      *sum_log_gain_Q7,                   /* I/O  Cumulative max prediction gain  */
   1.208 +    const silk_float                W[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* I    Error weights                        */
   1.209 +    const opus_int                  mu_Q10,                             /* I    Mu value (R/D tradeoff)                     */
   1.210 +    const opus_int                  lowComplexity,                      /* I    Flag for low complexity                     */
   1.211 +    const opus_int                  nb_subfr                            /* I    number of subframes                         */
   1.212 +);
   1.213 +
   1.214 +/* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */
   1.215 +silk_float silk_residual_energy_covar_FLP(                              /* O    Weighted residual energy                    */
   1.216 +    const silk_float                *c,                                 /* I    Filter coefficients                         */
   1.217 +    silk_float                      *wXX,                               /* I/O  Weighted correlation matrix, reg. out       */
   1.218 +    const silk_float                *wXx,                               /* I    Weighted correlation vector                 */
   1.219 +    const silk_float                wxx,                                /* I    Weighted correlation value                  */
   1.220 +    const opus_int                  D                                   /* I    Dimension                                   */
   1.221 +);
   1.222 +
   1.223 +/* Processing of gains */
   1.224 +void silk_process_gains_FLP(
   1.225 +    silk_encoder_state_FLP          *psEnc,                             /* I/O  Encoder state FLP                           */
   1.226 +    silk_encoder_control_FLP        *psEncCtrl,                         /* I/O  Encoder control FLP                         */
   1.227 +    opus_int                        condCoding                          /* I    The type of conditional coding to use       */
   1.228 +);
   1.229 +
   1.230 +/******************/
   1.231 +/* Linear Algebra */
   1.232 +/******************/
   1.233 +/* Calculates correlation matrix X'*X */
   1.234 +void silk_corrMatrix_FLP(
   1.235 +    const silk_float                *x,                                 /* I    x vector [ L+order-1 ] used to create X     */
   1.236 +    const opus_int                  L,                                  /* I    Length of vectors                           */
   1.237 +    const opus_int                  Order,                              /* I    Max lag for correlation                     */
   1.238 +    silk_float                      *XX                                 /* O    X'*X correlation matrix [order x order]     */
   1.239 +);
   1.240 +
   1.241 +/* Calculates correlation vector X'*t */
   1.242 +void silk_corrVector_FLP(
   1.243 +    const silk_float                *x,                                 /* I    x vector [L+order-1] used to create X       */
   1.244 +    const silk_float                *t,                                 /* I    Target vector [L]                           */
   1.245 +    const opus_int                  L,                                  /* I    Length of vecors                            */
   1.246 +    const opus_int                  Order,                              /* I    Max lag for correlation                     */
   1.247 +    silk_float                      *Xt                                 /* O    X'*t correlation vector [order]             */
   1.248 +);
   1.249 +
   1.250 +/* Add noise to matrix diagonal */
   1.251 +void silk_regularize_correlations_FLP(
   1.252 +    silk_float                      *XX,                                /* I/O  Correlation matrices                        */
   1.253 +    silk_float                      *xx,                                /* I/O  Correlation values                          */
   1.254 +    const silk_float                noise,                              /* I    Noise energy to add                         */
   1.255 +    const opus_int                  D                                   /* I    Dimension of XX                             */
   1.256 +);
   1.257 +
   1.258 +/* Function to solve linear equation Ax = b, where A is an MxM symmetric matrix */
   1.259 +void silk_solve_LDL_FLP(
   1.260 +    silk_float                      *A,                                 /* I/O  Symmetric square matrix, out: reg.          */
   1.261 +    const opus_int                  M,                                  /* I    Size of matrix                              */
   1.262 +    const silk_float                *b,                                 /* I    Pointer to b vector                         */
   1.263 +    silk_float                      *x                                  /* O    Pointer to x solution vector                */
   1.264 +);
   1.265 +
   1.266 +/* Apply sine window to signal vector.  */
   1.267 +/* Window types:                        */
   1.268 +/*  1 -> sine window from 0 to pi/2     */
   1.269 +/*  2 -> sine window from pi/2 to pi    */
   1.270 +void silk_apply_sine_window_FLP(
   1.271 +    silk_float                      px_win[],                           /* O    Pointer to windowed signal                  */
   1.272 +    const silk_float                px[],                               /* I    Pointer to input signal                     */
   1.273 +    const opus_int                  win_type,                           /* I    Selects a window type                       */
   1.274 +    const opus_int                  length                              /* I    Window length, multiple of 4                */
   1.275 +);
   1.276 +
   1.277 +/* Wrapper functions. Call flp / fix code */
   1.278 +
   1.279 +/* Convert AR filter coefficients to NLSF parameters */
   1.280 +void silk_A2NLSF_FLP(
   1.281 +    opus_int16                      *NLSF_Q15,                          /* O    NLSF vector      [ LPC_order ]              */
   1.282 +    const silk_float                *pAR,                               /* I    LPC coefficients [ LPC_order ]              */
   1.283 +    const opus_int                  LPC_order                           /* I    LPC order                                   */
   1.284 +);
   1.285 +
   1.286 +/* Convert NLSF parameters to AR prediction filter coefficients */
   1.287 +void silk_NLSF2A_FLP(
   1.288 +    silk_float                      *pAR,                               /* O    LPC coefficients [ LPC_order ]              */
   1.289 +    const opus_int16                *NLSF_Q15,                          /* I    NLSF vector      [ LPC_order ]              */
   1.290 +    const opus_int                  LPC_order                           /* I    LPC order                                   */
   1.291 +);
   1.292 +
   1.293 +/* Limit, stabilize, and quantize NLSFs */
   1.294 +void silk_process_NLSFs_FLP(
   1.295 +    silk_encoder_state              *psEncC,                            /* I/O  Encoder state                               */
   1.296 +    silk_float                      PredCoef[ 2 ][ MAX_LPC_ORDER ],     /* O    Prediction coefficients                     */
   1.297 +    opus_int16                      NLSF_Q15[      MAX_LPC_ORDER ],     /* I/O  Normalized LSFs (quant out) (0 - (2^15-1))  */
   1.298 +    const opus_int16                prev_NLSF_Q15[ MAX_LPC_ORDER ]      /* I    Previous Normalized LSFs (0 - (2^15-1))     */
   1.299 +);
   1.300 +
   1.301 +/* Floating-point Silk NSQ wrapper      */
   1.302 +void silk_NSQ_wrapper_FLP(
   1.303 +    silk_encoder_state_FLP          *psEnc,                             /* I/O  Encoder state FLP                           */
   1.304 +    silk_encoder_control_FLP        *psEncCtrl,                         /* I/O  Encoder control FLP                         */
   1.305 +    SideInfoIndices                 *psIndices,                         /* I/O  Quantization indices                        */
   1.306 +    silk_nsq_state                  *psNSQ,                             /* I/O  Noise Shaping Quantzation state             */
   1.307 +    opus_int8                       pulses[],                           /* O    Quantized pulse signal                      */
   1.308 +    const silk_float                x[]                                 /* I    Prefiltered input signal                    */
   1.309 +);
   1.310 +
   1.311 +#ifdef __cplusplus
   1.312 +}
   1.313 +#endif
   1.314 +
   1.315 +#endif

mercurial