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 #if 0 /* FIXME: SSE disabled until the NSQ code gets updated. */ 70 void (*const SILK_NSQ_IMPL[ OPUS_ARCHMASK + 1 ] )( 71 const silk_encoder_state *psEncC, /* I Encoder State */ 72 silk_nsq_state *NSQ, /* I/O NSQ state */ 73 SideInfoIndices *psIndices, /* I/O Quantization Indices */ 74 const opus_int32 x_Q3[], /* I Prefiltered input signal */ 75 opus_int8 pulses[], /* O Quantized pulse signal */ 76 const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ 77 const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ 78 const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ 79 const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ 80 const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ 81 const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ 82 const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ 83 const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ 84 const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ 85 const opus_int LTP_scale_Q14 /* I LTP state scaling */ 86 ) = { 87 silk_NSQ_c, /* non-sse */ 88 silk_NSQ_c, 89 silk_NSQ_c, 90 MAY_HAVE_SSE4_1( silk_NSQ ), /* sse4.1 */ 91 MAY_HAVE_SSE4_1( silk_NSQ ) /* avx */ 92 }; 93 #endif 94 95 #if 0 /* FIXME: SSE disabled until silk_VQ_WMat_EC_sse4_1() gets updated. */ 96 void (*const SILK_VQ_WMAT_EC_IMPL[ OPUS_ARCHMASK + 1 ] )( 97 opus_int8 *ind, /* O index of best codebook vector */ 98 opus_int32 *rate_dist_Q14, /* O best weighted quant error + mu * rate */ 99 opus_int *gain_Q7, /* O sum of absolute LTP coefficients */ 100 const opus_int16 *in_Q14, /* I input vector to be quantized */ 101 const opus_int32 *W_Q18, /* I weighting matrix */ 102 const opus_int8 *cb_Q7, /* I codebook */ 103 const opus_uint8 *cb_gain_Q7, /* I codebook effective gain */ 104 const opus_uint8 *cl_Q5, /* I code length for each codebook vector */ 105 const opus_int mu_Q9, /* I tradeoff betw. weighted error and rate */ 106 const opus_int32 max_gain_Q7, /* I maximum sum of absolute LTP coefficients */ 107 opus_int L /* I number of vectors in codebook */ 108 ) = { 109 silk_VQ_WMat_EC_c, /* non-sse */ 110 silk_VQ_WMat_EC_c, 111 silk_VQ_WMat_EC_c, 112 MAY_HAVE_SSE4_1( silk_VQ_WMat_EC ), /* sse4.1 */ 113 MAY_HAVE_SSE4_1( silk_VQ_WMat_EC ) /* avx */ 114 }; 115 #endif 116 117 #if 0 /* FIXME: SSE disabled until the NSQ code gets updated. */ 118 void (*const SILK_NSQ_DEL_DEC_IMPL[ OPUS_ARCHMASK + 1 ] )( 119 const silk_encoder_state *psEncC, /* I Encoder State */ 120 silk_nsq_state *NSQ, /* I/O NSQ state */ 121 SideInfoIndices *psIndices, /* I/O Quantization Indices */ 122 const opus_int32 x_Q3[], /* I Prefiltered input signal */ 123 opus_int8 pulses[], /* O Quantized pulse signal */ 124 const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ 125 const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ 126 const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ 127 const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ 128 const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ 129 const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ 130 const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ 131 const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ 132 const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ 133 const opus_int LTP_scale_Q14 /* I LTP state scaling */ 134 ) = { 135 silk_NSQ_del_dec_c, /* non-sse */ 136 silk_NSQ_del_dec_c, 137 silk_NSQ_del_dec_c, 138 MAY_HAVE_SSE4_1( silk_NSQ_del_dec ), /* sse4.1 */ 139 MAY_HAVE_SSE4_1( silk_NSQ_del_dec ) /* avx */ 140 }; 141 #endif 142 143 #if defined(FIXED_POINT) 144 145 void (*const SILK_BURG_MODIFIED_IMPL[ OPUS_ARCHMASK + 1 ] )( 146 opus_int32 *res_nrg, /* O Residual energy */ 147 opus_int *res_nrg_Q, /* O Residual energy Q value */ 148 opus_int32 A_Q16[], /* O Prediction coefficients (length order) */ 149 const opus_int16 x[], /* I Input signal, length: nb_subfr * ( D + subfr_length ) */ 150 const opus_int32 minInvGain_Q30, /* I Inverse of max prediction gain */ 151 const opus_int subfr_length, /* I Input signal subframe length (incl. D preceding samples) */ 152 const opus_int nb_subfr, /* I Number of subframes stacked in x */ 153 const opus_int D, /* I Order */ 154 int arch /* I Run-time architecture */ 155 ) = { 156 silk_burg_modified_c, /* non-sse */ 157 silk_burg_modified_c, 158 silk_burg_modified_c, 159 MAY_HAVE_SSE4_1( silk_burg_modified ), /* sse4.1 */ 160 MAY_HAVE_SSE4_1( silk_burg_modified ) /* avx */ 161 }; 162 163 #endif 164 #endif 165