Home | History | Annotate | Download | only in x86
      1 /* Copyright (c) 2014, Cisco Systems, INC
      2    Written by XiangMingZhu WeiZhou MinPeng YanWang
      3 
      4    Redistribution and use in source and binary forms, with or without
      5    modification, are permitted provided that the following conditions
      6    are met:
      7 
      8    - Redistributions of source code must retain the above copyright
      9    notice, this list of conditions and the following disclaimer.
     10 
     11    - Redistributions in binary form must reproduce the above copyright
     12    notice, this list of conditions and the following disclaimer in the
     13    documentation and/or other materials provided with the distribution.
     14 
     15    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     16    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     17    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     18    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
     19    OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     20    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     21    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     22    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
     23    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
     24    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     25    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26 */
     27 
     28 #if defined(HAVE_CONFIG_H)
     29 #include "config.h"
     30 #endif
     31 
     32 #include "celt/x86/x86cpu.h"
     33 #include "structs.h"
     34 #include "SigProc_FIX.h"
     35 #include "pitch.h"
     36 #include "main.h"
     37 
     38 #if !defined(OPUS_X86_PRESUME_SSE4_1)
     39 
     40 #if defined(FIXED_POINT)
     41 
     42 #include "fixed/main_FIX.h"
     43 
     44 opus_int64 (*const SILK_INNER_PROD16_ALIGNED_64_IMPL[ OPUS_ARCHMASK + 1 ] )(
     45     const opus_int16 *inVec1,
     46     const opus_int16 *inVec2,
     47     const opus_int   len
     48 ) = {
     49   silk_inner_prod16_aligned_64_c,                  /* non-sse */
     50   silk_inner_prod16_aligned_64_c,
     51   silk_inner_prod16_aligned_64_c,
     52   MAY_HAVE_SSE4_1( silk_inner_prod16_aligned_64 ), /* sse4.1 */
     53   MAY_HAVE_SSE4_1( silk_inner_prod16_aligned_64 )  /* avx */
     54 };
     55 
     56 #endif
     57 
     58 opus_int (*const SILK_VAD_GETSA_Q8_IMPL[ OPUS_ARCHMASK + 1 ] )(
     59     silk_encoder_state *psEncC,
     60     const opus_int16   pIn[]
     61 ) = {
     62   silk_VAD_GetSA_Q8_c,                  /* non-sse */
     63   silk_VAD_GetSA_Q8_c,
     64   silk_VAD_GetSA_Q8_c,
     65   MAY_HAVE_SSE4_1( silk_VAD_GetSA_Q8 ), /* sse4.1 */
     66   MAY_HAVE_SSE4_1( silk_VAD_GetSA_Q8 )  /* avx */
     67 };
     68 
     69 void (*const SILK_NSQ_IMPL[ OPUS_ARCHMASK + 1 ] )(
     70     const silk_encoder_state    *psEncC,                                    /* I/O  Encoder State                   */
     71     silk_nsq_state              *NSQ,                                       /* I/O  NSQ state                       */
     72     SideInfoIndices             *psIndices,                                 /* I/O  Quantization Indices            */
     73     const opus_int32            x_Q3[],                                     /* I    Prefiltered input signal        */
     74     opus_int8                   pulses[],                                   /* O    Quantized pulse signal          */
     75     const opus_int16            PredCoef_Q12[ 2 * MAX_LPC_ORDER ],          /* I    Short term prediction coefs     */
     76     const opus_int16            LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],    /* I    Long term prediction coefs      */
     77     const opus_int16            AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs             */
     78     const opus_int              HarmShapeGain_Q14[ MAX_NB_SUBFR ],          /* I    Long term shaping coefs         */
     79     const opus_int              Tilt_Q14[ MAX_NB_SUBFR ],                   /* I    Spectral tilt                   */
     80     const opus_int32            LF_shp_Q14[ MAX_NB_SUBFR ],                 /* I    Low frequency shaping coefs     */
     81     const opus_int32            Gains_Q16[ MAX_NB_SUBFR ],                  /* I    Quantization step sizes         */
     82     const opus_int              pitchL[ MAX_NB_SUBFR ],                     /* I    Pitch lags                      */
     83     const opus_int              Lambda_Q10,                                 /* I    Rate/distortion tradeoff        */
     84     const opus_int              LTP_scale_Q14                               /* I    LTP state scaling               */
     85 ) = {
     86   silk_NSQ_c,                  /* non-sse */
     87   silk_NSQ_c,
     88   silk_NSQ_c,
     89   MAY_HAVE_SSE4_1( silk_NSQ ), /* sse4.1 */
     90   MAY_HAVE_SSE4_1( silk_NSQ )  /* avx */
     91 };
     92 
     93 void (*const SILK_VQ_WMAT_EC_IMPL[ OPUS_ARCHMASK + 1 ] )(
     94     opus_int8                   *ind,                           /* O    index of best codebook vector               */
     95     opus_int32                  *rate_dist_Q14,                 /* O    best weighted quant error + mu * rate       */
     96     opus_int                    *gain_Q7,                       /* O    sum of absolute LTP coefficients            */
     97     const opus_int16            *in_Q14,                        /* I    input vector to be quantized                */
     98     const opus_int32            *W_Q18,                         /* I    weighting matrix                            */
     99     const opus_int8             *cb_Q7,                         /* I    codebook                                    */
    100     const opus_uint8            *cb_gain_Q7,                    /* I    codebook effective gain                     */
    101     const opus_uint8            *cl_Q5,                         /* I    code length for each codebook vector        */
    102     const opus_int              mu_Q9,                          /* I    tradeoff betw. weighted error and rate      */
    103     const opus_int32            max_gain_Q7,                    /* I    maximum sum of absolute LTP coefficients    */
    104     opus_int                    L                               /* I    number of vectors in codebook               */
    105 ) = {
    106   silk_VQ_WMat_EC_c,                  /* non-sse */
    107   silk_VQ_WMat_EC_c,
    108   silk_VQ_WMat_EC_c,
    109   MAY_HAVE_SSE4_1( silk_VQ_WMat_EC ), /* sse4.1 */
    110   MAY_HAVE_SSE4_1( silk_VQ_WMat_EC )  /* avx */
    111 };
    112 
    113 void (*const SILK_NSQ_DEL_DEC_IMPL[ OPUS_ARCHMASK + 1 ] )(
    114     const silk_encoder_state    *psEncC,                                    /* I/O  Encoder State                   */
    115     silk_nsq_state              *NSQ,                                       /* I/O  NSQ state                       */
    116     SideInfoIndices             *psIndices,                                 /* I/O  Quantization Indices            */
    117     const opus_int32            x_Q3[],                                     /* I    Prefiltered input signal        */
    118     opus_int8                   pulses[],                                   /* O    Quantized pulse signal          */
    119     const opus_int16            PredCoef_Q12[ 2 * MAX_LPC_ORDER ],          /* I    Short term prediction coefs     */
    120     const opus_int16            LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],    /* I    Long term prediction coefs      */
    121     const opus_int16            AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs             */
    122     const opus_int              HarmShapeGain_Q14[ MAX_NB_SUBFR ],          /* I    Long term shaping coefs         */
    123     const opus_int              Tilt_Q14[ MAX_NB_SUBFR ],                   /* I    Spectral tilt                   */
    124     const opus_int32            LF_shp_Q14[ MAX_NB_SUBFR ],                 /* I    Low frequency shaping coefs     */
    125     const opus_int32            Gains_Q16[ MAX_NB_SUBFR ],                  /* I    Quantization step sizes         */
    126     const opus_int              pitchL[ MAX_NB_SUBFR ],                     /* I    Pitch lags                      */
    127     const opus_int              Lambda_Q10,                                 /* I    Rate/distortion tradeoff        */
    128     const opus_int              LTP_scale_Q14                               /* I    LTP state scaling               */
    129 ) = {
    130   silk_NSQ_del_dec_c,                  /* non-sse */
    131   silk_NSQ_del_dec_c,
    132   silk_NSQ_del_dec_c,
    133   MAY_HAVE_SSE4_1( silk_NSQ_del_dec ), /* sse4.1 */
    134   MAY_HAVE_SSE4_1( silk_NSQ_del_dec )  /* avx */
    135 };
    136 
    137 #if defined(FIXED_POINT)
    138 
    139 void (*const SILK_WARPED_LPC_ANALYSIS_FILTER_FIX_IMPL[ OPUS_ARCHMASK + 1 ] )(
    140     opus_int32                  state[],                    /* I/O  State [order + 1]                   */
    141     opus_int32                  res_Q2[],                   /* O    Residual signal [length]            */
    142     const opus_int16            coef_Q13[],                 /* I    Coefficients [order]                */
    143     const opus_int16            input[],                    /* I    Input signal [length]               */
    144     const opus_int16            lambda_Q16,                 /* I    Warping factor                      */
    145     const opus_int              length,                     /* I    Length of input signal              */
    146     const opus_int              order                       /* I    Filter order (even)                 */
    147 ) = {
    148   silk_warped_LPC_analysis_filter_FIX_c,                  /* non-sse */
    149   silk_warped_LPC_analysis_filter_FIX_c,
    150   silk_warped_LPC_analysis_filter_FIX_c,
    151   MAY_HAVE_SSE4_1( silk_warped_LPC_analysis_filter_FIX ), /* sse4.1 */
    152   MAY_HAVE_SSE4_1( silk_warped_LPC_analysis_filter_FIX )  /* avx */
    153 };
    154 
    155 void (*const SILK_BURG_MODIFIED_IMPL[ OPUS_ARCHMASK + 1 ] )(
    156     opus_int32                  *res_nrg,           /* O    Residual energy                                             */
    157     opus_int                    *res_nrg_Q,         /* O    Residual energy Q value                                     */
    158     opus_int32                  A_Q16[],            /* O    Prediction coefficients (length order)                      */
    159     const opus_int16            x[],                /* I    Input signal, length: nb_subfr * ( D + subfr_length )       */
    160     const opus_int32            minInvGain_Q30,     /* I    Inverse of max prediction gain                              */
    161     const opus_int              subfr_length,       /* I    Input signal subframe length (incl. D preceding samples)    */
    162     const opus_int              nb_subfr,           /* I    Number of subframes stacked in x                            */
    163     const opus_int              D,                  /* I    Order                                                       */
    164     int                         arch                /* I    Run-time architecture                                       */
    165 ) = {
    166   silk_burg_modified_c,                  /* non-sse */
    167   silk_burg_modified_c,
    168   silk_burg_modified_c,
    169   MAY_HAVE_SSE4_1( silk_burg_modified ), /* sse4.1 */
    170   MAY_HAVE_SSE4_1( silk_burg_modified )  /* avx */
    171 };
    172 
    173 #endif
    174 #endif
    175