media/libopus/silk/float/SigProc_FLP.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libopus/silk/float/SigProc_FLP.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,204 @@
     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_SIGPROC_FLP_H
    1.32 +#define SILK_SIGPROC_FLP_H
    1.33 +
    1.34 +#include "SigProc_FIX.h"
    1.35 +#include "float_cast.h"
    1.36 +#include <math.h>
    1.37 +
    1.38 +#ifdef  __cplusplus
    1.39 +extern "C"
    1.40 +{
    1.41 +#endif
    1.42 +
    1.43 +/********************************************************************/
    1.44 +/*                    SIGNAL PROCESSING FUNCTIONS                   */
    1.45 +/********************************************************************/
    1.46 +
    1.47 +/* Chirp (bw expand) LP AR filter */
    1.48 +void silk_bwexpander_FLP(
    1.49 +    silk_float          *ar,                /* I/O  AR filter to be expanded (without leading 1)                */
    1.50 +    const opus_int      d,                  /* I    length of ar                                                */
    1.51 +    const silk_float    chirp               /* I    chirp factor (typically in range (0..1) )                   */
    1.52 +);
    1.53 +
    1.54 +/* compute inverse of LPC prediction gain, and                          */
    1.55 +/* test if LPC coefficients are stable (all poles within unit circle)   */
    1.56 +/* this code is based on silk_FLP_a2k()                                 */
    1.57 +silk_float silk_LPC_inverse_pred_gain_FLP(  /* O    return inverse prediction gain, energy domain               */
    1.58 +    const silk_float    *A,                 /* I    prediction coefficients [order]                             */
    1.59 +    opus_int32          order               /* I    prediction order                                            */
    1.60 +);
    1.61 +
    1.62 +silk_float silk_schur_FLP(                  /* O    returns residual energy                                     */
    1.63 +    silk_float          refl_coef[],        /* O    reflection coefficients (length order)                      */
    1.64 +    const silk_float    auto_corr[],        /* I    autocorrelation sequence (length order+1)                   */
    1.65 +    opus_int            order               /* I    order                                                       */
    1.66 +);
    1.67 +
    1.68 +void silk_k2a_FLP(
    1.69 +    silk_float          *A,                 /* O     prediction coefficients [order]                            */
    1.70 +    const silk_float    *rc,                /* I     reflection coefficients [order]                            */
    1.71 +    opus_int32          order               /* I     prediction order                                           */
    1.72 +);
    1.73 +
    1.74 +/* Solve the normal equations using the Levinson-Durbin recursion */
    1.75 +silk_float silk_levinsondurbin_FLP(         /* O    prediction error energy                                     */
    1.76 +    silk_float          A[],                /* O    prediction coefficients [order]                             */
    1.77 +    const silk_float    corr[],             /* I    input auto-correlations [order + 1]                         */
    1.78 +    const opus_int      order               /* I    prediction order                                            */
    1.79 +);
    1.80 +
    1.81 +/* compute autocorrelation */
    1.82 +void silk_autocorrelation_FLP(
    1.83 +    silk_float          *results,           /* O    result (length correlationCount)                            */
    1.84 +    const silk_float    *inputData,         /* I    input data to correlate                                     */
    1.85 +    opus_int            inputDataSize,      /* I    length of input                                             */
    1.86 +    opus_int            correlationCount    /* I    number of correlation taps to compute                       */
    1.87 +);
    1.88 +
    1.89 +opus_int silk_pitch_analysis_core_FLP(      /* O    Voicing estimate: 0 voiced, 1 unvoiced                      */
    1.90 +    const silk_float    *frame,             /* I    Signal of length PE_FRAME_LENGTH_MS*Fs_kHz                  */
    1.91 +    opus_int            *pitch_out,         /* O    Pitch lag values [nb_subfr]                                 */
    1.92 +    opus_int16          *lagIndex,          /* O    Lag Index                                                   */
    1.93 +    opus_int8           *contourIndex,      /* O    Pitch contour Index                                         */
    1.94 +    silk_float          *LTPCorr,           /* I/O  Normalized correlation; input: value from previous frame    */
    1.95 +    opus_int            prevLag,            /* I    Last lag of previous frame; set to zero is unvoiced         */
    1.96 +    const silk_float    search_thres1,      /* I    First stage threshold for lag candidates 0 - 1              */
    1.97 +    const silk_float    search_thres2,      /* I    Final threshold for lag candidates 0 - 1                    */
    1.98 +    const opus_int      Fs_kHz,             /* I    sample frequency (kHz)                                      */
    1.99 +    const opus_int      complexity,         /* I    Complexity setting, 0-2, where 2 is highest                 */
   1.100 +    const opus_int      nb_subfr,           /* I    Number of 5 ms subframes                                    */
   1.101 +    int                 arch                /* I    Run-time architecture                                       */
   1.102 +);
   1.103 +
   1.104 +void silk_insertion_sort_decreasing_FLP(
   1.105 +    silk_float          *a,                 /* I/O  Unsorted / Sorted vector                                    */
   1.106 +    opus_int            *idx,               /* O    Index vector for the sorted elements                        */
   1.107 +    const opus_int      L,                  /* I    Vector length                                               */
   1.108 +    const opus_int      K                   /* I    Number of correctly sorted positions                        */
   1.109 +);
   1.110 +
   1.111 +/* Compute reflection coefficients from input signal */
   1.112 +silk_float silk_burg_modified_FLP(          /* O    returns residual energy                                     */
   1.113 +    silk_float          A[],                /* O    prediction coefficients (length order)                      */
   1.114 +    const silk_float    x[],                /* I    input signal, length: nb_subfr*(D+L_sub)                    */
   1.115 +    const silk_float    minInvGain,         /* I    minimum inverse prediction gain                             */
   1.116 +    const opus_int      subfr_length,       /* I    input signal subframe length (incl. D preceding samples)    */
   1.117 +    const opus_int      nb_subfr,           /* I    number of subframes stacked in x                            */
   1.118 +    const opus_int      D                   /* I    order                                                       */
   1.119 +);
   1.120 +
   1.121 +/* multiply a vector by a constant */
   1.122 +void silk_scale_vector_FLP(
   1.123 +    silk_float          *data1,
   1.124 +    silk_float          gain,
   1.125 +    opus_int            dataSize
   1.126 +);
   1.127 +
   1.128 +/* copy and multiply a vector by a constant */
   1.129 +void silk_scale_copy_vector_FLP(
   1.130 +    silk_float          *data_out,
   1.131 +    const silk_float    *data_in,
   1.132 +    silk_float          gain,
   1.133 +    opus_int            dataSize
   1.134 +);
   1.135 +
   1.136 +/* inner product of two silk_float arrays, with result as double */
   1.137 +double silk_inner_product_FLP(
   1.138 +    const silk_float    *data1,
   1.139 +    const silk_float    *data2,
   1.140 +    opus_int            dataSize
   1.141 +);
   1.142 +
   1.143 +/* sum of squares of a silk_float array, with result as double */
   1.144 +double silk_energy_FLP(
   1.145 +    const silk_float    *data,
   1.146 +    opus_int            dataSize
   1.147 +);
   1.148 +
   1.149 +/********************************************************************/
   1.150 +/*                                MACROS                            */
   1.151 +/********************************************************************/
   1.152 +
   1.153 +#define PI              (3.1415926536f)
   1.154 +
   1.155 +#define silk_min_float( a, b )                  (((a) < (b)) ? (a) :  (b))
   1.156 +#define silk_max_float( a, b )                  (((a) > (b)) ? (a) :  (b))
   1.157 +#define silk_abs_float( a )                     ((silk_float)fabs(a))
   1.158 +
   1.159 +/* sigmoid function */
   1.160 +static OPUS_INLINE silk_float silk_sigmoid( silk_float x )
   1.161 +{
   1.162 +    return (silk_float)(1.0 / (1.0 + exp(-x)));
   1.163 +}
   1.164 +
   1.165 +/* floating-point to integer conversion (rounding) */
   1.166 +static OPUS_INLINE opus_int32 silk_float2int( silk_float x )
   1.167 +{
   1.168 +    return (opus_int32)float2int( x );
   1.169 +}
   1.170 +
   1.171 +/* floating-point to integer conversion (rounding) */
   1.172 +static OPUS_INLINE void silk_float2short_array(
   1.173 +    opus_int16       *out,
   1.174 +    const silk_float *in,
   1.175 +    opus_int32       length
   1.176 +)
   1.177 +{
   1.178 +    opus_int32 k;
   1.179 +    for( k = length - 1; k >= 0; k-- ) {
   1.180 +        out[k] = silk_SAT16( (opus_int32)float2int( in[k] ) );
   1.181 +    }
   1.182 +}
   1.183 +
   1.184 +/* integer to floating-point conversion */
   1.185 +static OPUS_INLINE void silk_short2float_array(
   1.186 +    silk_float       *out,
   1.187 +    const opus_int16 *in,
   1.188 +    opus_int32       length
   1.189 +)
   1.190 +{
   1.191 +    opus_int32 k;
   1.192 +    for( k = length - 1; k >= 0; k-- ) {
   1.193 +        out[k] = (silk_float)in[k];
   1.194 +    }
   1.195 +}
   1.196 +
   1.197 +/* using log2() helps the fixed-point conversion */
   1.198 +static OPUS_INLINE silk_float silk_log2( double x )
   1.199 +{
   1.200 +    return ( silk_float )( 3.32192809488736 * log10( x ) );
   1.201 +}
   1.202 +
   1.203 +#ifdef  __cplusplus
   1.204 +}
   1.205 +#endif
   1.206 +
   1.207 +#endif /* SILK_SIGPROC_FLP_H */

mercurial