OLD | NEW |
(Empty) | |
| 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 #ifndef MAIN_SSE_H |
| 29 #define MAIN_SSE_H |
| 30 |
| 31 #ifdef HAVE_CONFIG_H |
| 32 #include "config.h" |
| 33 #endif |
| 34 |
| 35 # if defined(OPUS_X86_MAY_HAVE_SSE4_1) |
| 36 |
| 37 # define OVERRIDE_silk_VQ_WMat_EC |
| 38 |
| 39 void silk_VQ_WMat_EC_sse4_1( |
| 40 opus_int8 *ind, /* O index of
best codebook vector */ |
| 41 opus_int32 *rate_dist_Q14, /* O best wei
ghted quant error + mu * rate */ |
| 42 opus_int *gain_Q7, /* O sum of a
bsolute LTP coefficients */ |
| 43 const opus_int16 *in_Q14, /* I input ve
ctor to be quantized */ |
| 44 const opus_int32 *W_Q18, /* I weightin
g matrix */ |
| 45 const opus_int8 *cb_Q7, /* I codebook
*/ |
| 46 const opus_uint8 *cb_gain_Q7, /* I codebook
effective gain */ |
| 47 const opus_uint8 *cl_Q5, /* I code len
gth for each codebook vector */ |
| 48 const opus_int mu_Q9, /* I tradeoff
betw. weighted error and rate */ |
| 49 const opus_int32 max_gain_Q7, /* I maximum
sum of absolute LTP coefficients */ |
| 50 opus_int L /* I number o
f vectors in codebook */ |
| 51 ); |
| 52 |
| 53 extern void (*const SILK_VQ_WMAT_EC_IMPL[OPUS_ARCHMASK + 1])( |
| 54 opus_int8 *ind, /* O index of
best codebook vector */ |
| 55 opus_int32 *rate_dist_Q14, /* O best wei
ghted quant error + mu * rate */ |
| 56 opus_int *gain_Q7, /* O sum of a
bsolute LTP coefficients */ |
| 57 const opus_int16 *in_Q14, /* I input ve
ctor to be quantized */ |
| 58 const opus_int32 *W_Q18, /* I weightin
g matrix */ |
| 59 const opus_int8 *cb_Q7, /* I codebook
*/ |
| 60 const opus_uint8 *cb_gain_Q7, /* I codebook
effective gain */ |
| 61 const opus_uint8 *cl_Q5, /* I code len
gth for each codebook vector */ |
| 62 const opus_int mu_Q9, /* I tradeoff
betw. weighted error and rate */ |
| 63 const opus_int32 max_gain_Q7, /* I maximum
sum of absolute LTP coefficients */ |
| 64 opus_int L /* I number o
f vectors in codebook */ |
| 65 ); |
| 66 |
| 67 # define silk_VQ_WMat_EC(ind, rate_dist_Q14, gain_Q7, in_Q14, W_Q18, cb_Q7, cb_
gain_Q7, cl_Q5, \ |
| 68 mu_Q9, max_gain_Q7, L, arch) \ |
| 69 ((*SILK_VQ_WMAT_EC_IMPL[(arch) & OPUS_ARCHMASK])(ind, rate_dist_Q14, gain_Q7
, in_Q14, W_Q18, cb_Q7, cb_gain_Q7, cl_Q5, \ |
| 70 mu_Q9, max_gain_Q7, L)) |
| 71 |
| 72 # define OVERRIDE_silk_NSQ |
| 73 |
| 74 void silk_NSQ_sse4_1( |
| 75 const silk_encoder_state *psEncC, /* I
/O Encoder State */ |
| 76 silk_nsq_state *NSQ, /* I
/O NSQ state */ |
| 77 SideInfoIndices *psIndices, /* I
/O Quantization Indices */ |
| 78 const opus_int32 x_Q3[], /* I
Prefiltered input signal */ |
| 79 opus_int8 pulses[], /* O
Quantized pulse signal */ |
| 80 const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I
Short term prediction coefs */ |
| 81 const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I
Long term prediction coefs */ |
| 82 const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /
* I Noise shaping coefs */ |
| 83 const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I
Long term shaping coefs */ |
| 84 const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I
Spectral tilt */ |
| 85 const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I
Low frequency shaping coefs */ |
| 86 const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I
Quantization step sizes */ |
| 87 const opus_int pitchL[ MAX_NB_SUBFR ], /* I
Pitch lags */ |
| 88 const opus_int Lambda_Q10, /* I
Rate/distortion tradeoff */ |
| 89 const opus_int LTP_scale_Q14 /* I
LTP state scaling */ |
| 90 ); |
| 91 |
| 92 extern void (*const SILK_NSQ_IMPL[OPUS_ARCHMASK + 1])( |
| 93 const silk_encoder_state *psEncC, /* I
/O Encoder State */ |
| 94 silk_nsq_state *NSQ, /* I
/O NSQ state */ |
| 95 SideInfoIndices *psIndices, /* I
/O Quantization Indices */ |
| 96 const opus_int32 x_Q3[], /* I
Prefiltered input signal */ |
| 97 opus_int8 pulses[], /* O
Quantized pulse signal */ |
| 98 const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I
Short term prediction coefs */ |
| 99 const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I
Long term prediction coefs */ |
| 100 const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /
* I Noise shaping coefs */ |
| 101 const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I
Long term shaping coefs */ |
| 102 const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I
Spectral tilt */ |
| 103 const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I
Low frequency shaping coefs */ |
| 104 const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I
Quantization step sizes */ |
| 105 const opus_int pitchL[ MAX_NB_SUBFR ], /* I
Pitch lags */ |
| 106 const opus_int Lambda_Q10, /* I
Rate/distortion tradeoff */ |
| 107 const opus_int LTP_scale_Q14 /* I
LTP state scaling */ |
| 108 ); |
| 109 |
| 110 # define silk_NSQ(psEncC, NSQ, psIndices, x_Q3, pulses, PredCoef_Q12, LTPCoef_Q
14, AR2_Q13, \ |
| 111 HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, L
ambda_Q10, LTP_scale_Q14, arch) \ |
| 112 ((*SILK_NSQ_IMPL[(arch) & OPUS_ARCHMASK])(psEncC, NSQ, psIndices, x_Q3, puls
es, PredCoef_Q12, LTPCoef_Q14, AR2_Q13, \ |
| 113 HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, L
ambda_Q10, LTP_scale_Q14)) |
| 114 |
| 115 # define OVERRIDE_silk_NSQ_del_dec |
| 116 |
| 117 void silk_NSQ_del_dec_sse4_1( |
| 118 const silk_encoder_state *psEncC, /* I
/O Encoder State */ |
| 119 silk_nsq_state *NSQ, /* I
/O NSQ state */ |
| 120 SideInfoIndices *psIndices, /* I
/O Quantization Indices */ |
| 121 const opus_int32 x_Q3[], /* I
Prefiltered input signal */ |
| 122 opus_int8 pulses[], /* O
Quantized pulse signal */ |
| 123 const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I
Short term prediction coefs */ |
| 124 const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I
Long term prediction coefs */ |
| 125 const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /
* I Noise shaping coefs */ |
| 126 const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I
Long term shaping coefs */ |
| 127 const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I
Spectral tilt */ |
| 128 const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I
Low frequency shaping coefs */ |
| 129 const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I
Quantization step sizes */ |
| 130 const opus_int pitchL[ MAX_NB_SUBFR ], /* I
Pitch lags */ |
| 131 const opus_int Lambda_Q10, /* I
Rate/distortion tradeoff */ |
| 132 const opus_int LTP_scale_Q14 /* I
LTP state scaling */ |
| 133 ); |
| 134 |
| 135 extern void (*const SILK_NSQ_DEL_DEC_IMPL[OPUS_ARCHMASK + 1])( |
| 136 const silk_encoder_state *psEncC, /* I
/O Encoder State */ |
| 137 silk_nsq_state *NSQ, /* I
/O NSQ state */ |
| 138 SideInfoIndices *psIndices, /* I
/O Quantization Indices */ |
| 139 const opus_int32 x_Q3[], /* I
Prefiltered input signal */ |
| 140 opus_int8 pulses[], /* O
Quantized pulse signal */ |
| 141 const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I
Short term prediction coefs */ |
| 142 const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I
Long term prediction coefs */ |
| 143 const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /
* I Noise shaping coefs */ |
| 144 const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I
Long term shaping coefs */ |
| 145 const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I
Spectral tilt */ |
| 146 const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I
Low frequency shaping coefs */ |
| 147 const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I
Quantization step sizes */ |
| 148 const opus_int pitchL[ MAX_NB_SUBFR ], /* I
Pitch lags */ |
| 149 const opus_int Lambda_Q10, /* I
Rate/distortion tradeoff */ |
| 150 const opus_int LTP_scale_Q14 /* I
LTP state scaling */ |
| 151 ); |
| 152 |
| 153 # define silk_NSQ_del_dec(psEncC, NSQ, psIndices, x_Q3, pulses, PredCoef_Q12, L
TPCoef_Q14, AR2_Q13, \ |
| 154 HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, p
itchL, Lambda_Q10, LTP_scale_Q14, arch) \ |
| 155 ((*SILK_NSQ_DEL_DEC_IMPL[(arch) & OPUS_ARCHMASK])(psEncC, NSQ, psIndices, x_
Q3, pulses, PredCoef_Q12, LTPCoef_Q14, AR2_Q13, \ |
| 156 HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, p
itchL, Lambda_Q10, LTP_scale_Q14)) |
| 157 |
| 158 void silk_noise_shape_quantizer( |
| 159 silk_nsq_state *NSQ, /* I/O NSQ state
*/ |
| 160 opus_int signalType, /* I Signal type
*/ |
| 161 const opus_int32 x_sc_Q10[], /* I
*/ |
| 162 opus_int8 pulses[], /* O
*/ |
| 163 opus_int16 xq[], /* O
*/ |
| 164 opus_int32 sLTP_Q15[], /* I/O LTP state
*/ |
| 165 const opus_int16 a_Q12[], /* I Short term prediction co
efs */ |
| 166 const opus_int16 b_Q14[], /* I Long term prediction coe
fs */ |
| 167 const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs
*/ |
| 168 opus_int lag, /* I Pitch lag
*/ |
| 169 opus_int32 HarmShapeFIRPacked_Q14, /* I
*/ |
| 170 opus_int Tilt_Q14, /* I Spectral tilt
*/ |
| 171 opus_int32 LF_shp_Q14, /* I
*/ |
| 172 opus_int32 Gain_Q16, /* I
*/ |
| 173 opus_int Lambda_Q10, /* I
*/ |
| 174 opus_int offset_Q10, /* I
*/ |
| 175 opus_int length, /* I Input length
*/ |
| 176 opus_int shapingLPCOrder, /* I Noise shaping AR filter
order */ |
| 177 opus_int predictLPCOrder /* I Prediction filter order
*/ |
| 178 ); |
| 179 |
| 180 /**************************/ |
| 181 /* Noise level estimation */ |
| 182 /**************************/ |
| 183 void silk_VAD_GetNoiseLevels( |
| 184 const opus_int32 pX[ VAD_N_BANDS ], /* I subband energies
*/ |
| 185 silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD
state */ |
| 186 ); |
| 187 |
| 188 # define OVERRIDE_silk_VAD_GetSA_Q8 |
| 189 |
| 190 opus_int silk_VAD_GetSA_Q8_sse4_1( |
| 191 silk_encoder_state *psEnC, |
| 192 const opus_int16 pIn[] |
| 193 ); |
| 194 |
| 195 # define silk_VAD_GetSA_Q8(psEnC, pIn, arch) \ |
| 196 ((*SILK_VAD_GETSA_Q8_IMPL[(arch) & OPUS_ARCHMASK])(psEnC, pIn)) |
| 197 |
| 198 extern opus_int (*const SILK_VAD_GETSA_Q8_IMPL[OPUS_ARCHMASK + 1])( |
| 199 silk_encoder_state *psEnC, |
| 200 const opus_int16 pIn[]); |
| 201 |
| 202 # define OVERRIDE_silk_warped_LPC_analysis_filter_FIX |
| 203 |
| 204 void silk_warped_LPC_analysis_filter_FIX_sse4_1( |
| 205 opus_int32 state[], /* I/O State [order
+ 1] */ |
| 206 opus_int32 res_Q2[], /* O Residual sig
nal [length] */ |
| 207 const opus_int16 coef_Q13[], /* I Coefficients
[order] */ |
| 208 const opus_int16 input[], /* I Input signal
[length] */ |
| 209 const opus_int16 lambda_Q16, /* I Warping fact
or */ |
| 210 const opus_int length, /* I Length of in
put signal */ |
| 211 const opus_int order /* I Filter order
(even) */ |
| 212 ); |
| 213 |
| 214 extern void (*const SILK_WARPED_LPC_ANALYSIS_FILTER_FIX_IMPL[OPUS_ARCHMASK + 1])
( |
| 215 opus_int32 state[], /* I/O State [order
+ 1] */ |
| 216 opus_int32 res_Q2[], /* O Residual sig
nal [length] */ |
| 217 const opus_int16 coef_Q13[], /* I Coefficients
[order] */ |
| 218 const opus_int16 input[], /* I Input signal
[length] */ |
| 219 const opus_int16 lambda_Q16, /* I Warping fact
or */ |
| 220 const opus_int length, /* I Length of in
put signal */ |
| 221 const opus_int order /* I Filter order
(even) */ |
| 222 ); |
| 223 |
| 224 # define silk_warped_LPC_analysis_filter_FIX(state, res_Q2, coef_Q13, input, la
mbda_Q16, length, order, arch) \ |
| 225 ((*SILK_WARPED_LPC_ANALYSIS_FILTER_FIX_IMPL[(arch) & OPUS_ARCHMASK])(state,
res_Q2, coef_Q13, input, lambda_Q16, length, order)) |
| 226 |
| 227 # endif |
| 228 #endif |
OLD | NEW |