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_HAVE_RTCD) && !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_IMPL[ OPUS_ARCHMASK + 1 ] )( 45 const opus_int16 *inVec1, 46 const opus_int16 *inVec2, 47 const opus_int len 48 ) = { 49 silk_inner_prod16_c, /* non-sse */ 50 silk_inner_prod16_c, 51 silk_inner_prod16_c, 52 MAY_HAVE_SSE4_1( silk_inner_prod16 ), /* sse4.1 */ 53 MAY_HAVE_SSE4_1( silk_inner_prod16 ) /* 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 Encoder State */ 71 silk_nsq_state *NSQ, /* I/O NSQ state */ 72 SideInfoIndices *psIndices, /* I/O Quantization Indices */ 73 const opus_int16 x16[], /* I Input */ 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 AR_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 *res_nrg_Q15, /* O best residual energy */ 96 opus_int32 *rate_dist_Q8, /* O best total bitrate */ 97 opus_int *gain_Q7, /* O sum of absolute LTP coefficients */ 98 const opus_int32 *XX_Q17, /* I correlation matrix */ 99 const opus_int32 *xX_Q17, /* I correlation vector */ 100 const opus_int8 *cb_Q7, /* I codebook */ 101 const opus_uint8 *cb_gain_Q7, /* I codebook effective gain */ 102 const opus_uint8 *cl_Q5, /* I code length for each codebook vector */ 103 const opus_int subfr_len, /* I number of samples per subframe */ 104 const opus_int32 max_gain_Q7, /* I maximum sum of absolute LTP coefficients */ 105 const opus_int L /* I number of vectors in codebook */ 106 ) = { 107 silk_VQ_WMat_EC_c, /* non-sse */ 108 silk_VQ_WMat_EC_c, 109 silk_VQ_WMat_EC_c, 110 MAY_HAVE_SSE4_1( silk_VQ_WMat_EC ), /* sse4.1 */ 111 MAY_HAVE_SSE4_1( silk_VQ_WMat_EC ) /* avx */ 112 }; 113 114 void (*const SILK_NSQ_DEL_DEC_IMPL[ OPUS_ARCHMASK + 1 ] )( 115 const silk_encoder_state *psEncC, /* I Encoder State */ 116 silk_nsq_state *NSQ, /* I/O NSQ state */ 117 SideInfoIndices *psIndices, /* I/O Quantization Indices */ 118 const opus_int16 x16[], /* I Input */ 119 opus_int8 pulses[], /* O Quantized pulse signal */ 120 const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ 121 const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ 122 const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ 123 const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ 124 const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ 125 const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ 126 const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ 127 const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ 128 const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ 129 const opus_int LTP_scale_Q14 /* I LTP state scaling */ 130 ) = { 131 silk_NSQ_del_dec_c, /* non-sse */ 132 silk_NSQ_del_dec_c, 133 silk_NSQ_del_dec_c, 134 MAY_HAVE_SSE4_1( silk_NSQ_del_dec ), /* sse4.1 */ 135 MAY_HAVE_SSE4_1( silk_NSQ_del_dec ) /* avx */ 136 }; 137 138 #if defined(FIXED_POINT) 139 140 void (*const SILK_BURG_MODIFIED_IMPL[ OPUS_ARCHMASK + 1 ] )( 141 opus_int32 *res_nrg, /* O Residual energy */ 142 opus_int *res_nrg_Q, /* O Residual energy Q value */ 143 opus_int32 A_Q16[], /* O Prediction coefficients (length order) */ 144 const opus_int16 x[], /* I Input signal, length: nb_subfr * ( D + subfr_length ) */ 145 const opus_int32 minInvGain_Q30, /* I Inverse of max prediction gain */ 146 const opus_int subfr_length, /* I Input signal subframe length (incl. D preceding samples) */ 147 const opus_int nb_subfr, /* I Number of subframes stacked in x */ 148 const opus_int D, /* I Order */ 149 int arch /* I Run-time architecture */ 150 ) = { 151 silk_burg_modified_c, /* non-sse */ 152 silk_burg_modified_c, 153 silk_burg_modified_c, 154 MAY_HAVE_SSE4_1( silk_burg_modified ), /* sse4.1 */ 155 MAY_HAVE_SSE4_1( silk_burg_modified ) /* avx */ 156 }; 157 158 #endif 159 #endif 160