summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libopus/silk/main.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/libopus/silk/main.h')
-rw-r--r--lib/rbcodec/codecs/libopus/silk/main.h108
1 files changed, 73 insertions, 35 deletions
diff --git a/lib/rbcodec/codecs/libopus/silk/main.h b/lib/rbcodec/codecs/libopus/silk/main.h
index 77524f5b57..1a33eed549 100644
--- a/lib/rbcodec/codecs/libopus/silk/main.h
+++ b/lib/rbcodec/codecs/libopus/silk/main.h
@@ -38,6 +38,14 @@ POSSIBILITY OF SUCH DAMAGE.
38#include "entenc.h" 38#include "entenc.h"
39#include "entdec.h" 39#include "entdec.h"
40 40
41#if defined(OPUS_X86_MAY_HAVE_SSE4_1)
42#include "x86/main_sse.h"
43#endif
44
45#if (defined(OPUS_ARM_ASM) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR))
46#include "arm/NSQ_del_dec_arm.h"
47#endif
48
41/* Convert Left/Right stereo signal to adaptive Mid/Side representation */ 49/* Convert Left/Right stereo signal to adaptive Mid/Side representation */
42void silk_stereo_LR_to_MS( 50void silk_stereo_LR_to_MS(
43 stereo_enc_state *state, /* I/O State */ 51 stereo_enc_state *state, /* I/O State */
@@ -105,22 +113,22 @@ void silk_stereo_decode_mid_only(
105 113
106/* Encodes signs of excitation */ 114/* Encodes signs of excitation */
107void silk_encode_signs( 115void silk_encode_signs(
108 ec_enc *psRangeEnc, /* I/O Compressor data structure */ 116 ec_enc *psRangeEnc, /* I/O Compressor data structure */
109 const opus_int8 pulses[], /* I pulse signal */ 117 const opus_int8 pulses[], /* I pulse signal */
110 opus_int length, /* I length of input */ 118 opus_int length, /* I length of input */
111 const opus_int signalType, /* I Signal type */ 119 const opus_int signalType, /* I Signal type */
112 const opus_int quantOffsetType, /* I Quantization offset type */ 120 const opus_int quantOffsetType, /* I Quantization offset type */
113 const opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */ 121 const opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */
114); 122);
115 123
116/* Decodes signs of excitation */ 124/* Decodes signs of excitation */
117void silk_decode_signs( 125void silk_decode_signs(
118 ec_dec *psRangeDec, /* I/O Compressor data structure */ 126 ec_dec *psRangeDec, /* I/O Compressor data structure */
119 opus_int16 pulses[], /* I/O pulse signal */ 127 opus_int16 pulses[], /* I/O pulse signal */
120 opus_int length, /* I length of input */ 128 opus_int length, /* I length of input */
121 const opus_int signalType, /* I Signal type */ 129 const opus_int signalType, /* I Signal type */
122 const opus_int quantOffsetType, /* I Quantization offset type */ 130 const opus_int quantOffsetType, /* I Quantization offset type */
123 const opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */ 131 const opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */
124); 132);
125 133
126/* Check encoder control struct */ 134/* Check encoder control struct */
@@ -201,43 +209,52 @@ void silk_interpolate(
201 209
202/* LTP tap quantizer */ 210/* LTP tap quantizer */
203void silk_quant_LTP_gains( 211void silk_quant_LTP_gains(
204 opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* I/O (un)quantized LTP gains */ 212 opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O Quantized LTP gains */
205 opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook Index */ 213 opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook Index */
206 opus_int8 *periodicity_index, /* O Periodicity Index */ 214 opus_int8 *periodicity_index, /* O Periodicity Index */
207 opus_int32 *sum_gain_dB_Q7, /* I/O Cumulative max prediction gain */ 215 opus_int32 *sum_gain_dB_Q7, /* I/O Cumulative max prediction gain */
208 const opus_int32 W_Q18[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ], /* I Error Weights in Q18 */ 216 opus_int *pred_gain_dB_Q7, /* O LTP prediction gain */
209 opus_int mu_Q9, /* I Mu value (R/D tradeoff) */ 217 const opus_int32 XX_Q17[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ], /* I Correlation matrix in Q18 */
210 opus_int lowComplexity, /* I Flag for low complexity */ 218 const opus_int32 xX_Q17[ MAX_NB_SUBFR*LTP_ORDER ], /* I Correlation vector in Q18 */
211 const opus_int nb_subfr /* I number of subframes */ 219 const opus_int subfr_len, /* I Number of samples per subframe */
220 const opus_int nb_subfr, /* I Number of subframes */
221 int arch /* I Run-time architecture */
212); 222);
213 223
214/* Entropy constrained matrix-weighted VQ, for a single input data vector */ 224/* Entropy constrained matrix-weighted VQ, for a single input data vector */
215void silk_VQ_WMat_EC( 225void silk_VQ_WMat_EC_c(
216 opus_int8 *ind, /* O index of best codebook vector */ 226 opus_int8 *ind, /* O index of best codebook vector */
217 opus_int32 *rate_dist_Q14, /* O best weighted quant error + mu * rate */ 227 opus_int32 *res_nrg_Q15, /* O best residual energy */
228 opus_int32 *rate_dist_Q8, /* O best total bitrate */
218 opus_int *gain_Q7, /* O sum of absolute LTP coefficients */ 229 opus_int *gain_Q7, /* O sum of absolute LTP coefficients */
219 const opus_int16 *in_Q14, /* I input vector to be quantized */ 230 const opus_int32 *XX_Q17, /* I correlation matrix */
220 const opus_int32 *W_Q18, /* I weighting matrix */ 231 const opus_int32 *xX_Q17, /* I correlation vector */
221 const opus_int8 *cb_Q7, /* I codebook */ 232 const opus_int8 *cb_Q7, /* I codebook */
222 const opus_uint8 *cb_gain_Q7, /* I codebook effective gain */ 233 const opus_uint8 *cb_gain_Q7, /* I codebook effective gain */
223 const opus_uint8 *cl_Q5, /* I code length for each codebook vector */ 234 const opus_uint8 *cl_Q5, /* I code length for each codebook vector */
224 const opus_int mu_Q9, /* I tradeoff betw. weighted error and rate */ 235 const opus_int subfr_len, /* I number of samples per subframe */
225 const opus_int32 max_gain_Q7, /* I maximum sum of absolute LTP coefficients */ 236 const opus_int32 max_gain_Q7, /* I maximum sum of absolute LTP coefficients */
226 opus_int L /* I number of vectors in codebook */ 237 const opus_int L /* I number of vectors in codebook */
227); 238);
228 239
240#if !defined(OVERRIDE_silk_VQ_WMat_EC)
241#define silk_VQ_WMat_EC(ind, res_nrg_Q15, rate_dist_Q8, gain_Q7, XX_Q17, xX_Q17, cb_Q7, cb_gain_Q7, cl_Q5, subfr_len, max_gain_Q7, L, arch) \
242 ((void)(arch),silk_VQ_WMat_EC_c(ind, res_nrg_Q15, rate_dist_Q8, gain_Q7, XX_Q17, xX_Q17, cb_Q7, cb_gain_Q7, cl_Q5, subfr_len, max_gain_Q7, L))
243#endif
244
229/************************************/ 245/************************************/
230/* Noise shaping quantization (NSQ) */ 246/* Noise shaping quantization (NSQ) */
231/************************************/ 247/************************************/
232void silk_NSQ( 248
233 const silk_encoder_state *psEncC, /* I/O Encoder State */ 249void silk_NSQ_c(
250 const silk_encoder_state *psEncC, /* I Encoder State */
234 silk_nsq_state *NSQ, /* I/O NSQ state */ 251 silk_nsq_state *NSQ, /* I/O NSQ state */
235 SideInfoIndices *psIndices, /* I/O Quantization Indices */ 252 SideInfoIndices *psIndices, /* I/O Quantization Indices */
236 const opus_int32 x_Q3[], /* I Prefiltered input signal */ 253 const opus_int16 x16[], /* I Input */
237 opus_int8 pulses[], /* O Quantized pulse signal */ 254 opus_int8 pulses[], /* O Quantized pulse signal */
238 const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ 255 const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */
239 const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ 256 const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */
240 const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ 257 const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */
241 const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ 258 const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */
242 const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ 259 const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
243 const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ 260 const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */
@@ -247,16 +264,23 @@ void silk_NSQ(
247 const opus_int LTP_scale_Q14 /* I LTP state scaling */ 264 const opus_int LTP_scale_Q14 /* I LTP state scaling */
248); 265);
249 266
267#if !defined(OVERRIDE_silk_NSQ)
268#define silk_NSQ(psEncC, NSQ, psIndices, x16, pulses, PredCoef_Q12, LTPCoef_Q14, AR_Q13, \
269 HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14, arch) \
270 ((void)(arch),silk_NSQ_c(psEncC, NSQ, psIndices, x16, pulses, PredCoef_Q12, LTPCoef_Q14, AR_Q13, \
271 HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14))
272#endif
273
250/* Noise shaping using delayed decision */ 274/* Noise shaping using delayed decision */
251void silk_NSQ_del_dec( 275void silk_NSQ_del_dec_c(
252 const silk_encoder_state *psEncC, /* I/O Encoder State */ 276 const silk_encoder_state *psEncC, /* I Encoder State */
253 silk_nsq_state *NSQ, /* I/O NSQ state */ 277 silk_nsq_state *NSQ, /* I/O NSQ state */
254 SideInfoIndices *psIndices, /* I/O Quantization Indices */ 278 SideInfoIndices *psIndices, /* I/O Quantization Indices */
255 const opus_int32 x_Q3[], /* I Prefiltered input signal */ 279 const opus_int16 x16[], /* I Input */
256 opus_int8 pulses[], /* O Quantized pulse signal */ 280 opus_int8 pulses[], /* O Quantized pulse signal */
257 const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ 281 const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */
258 const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ 282 const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */
259 const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ 283 const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */
260 const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ 284 const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */
261 const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ 285 const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
262 const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ 286 const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */
@@ -266,6 +290,13 @@ void silk_NSQ_del_dec(
266 const opus_int LTP_scale_Q14 /* I LTP state scaling */ 290 const opus_int LTP_scale_Q14 /* I LTP state scaling */
267); 291);
268 292
293#if !defined(OVERRIDE_silk_NSQ_del_dec)
294#define silk_NSQ_del_dec(psEncC, NSQ, psIndices, x16, pulses, PredCoef_Q12, LTPCoef_Q14, AR_Q13, \
295 HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14, arch) \
296 ((void)(arch),silk_NSQ_del_dec_c(psEncC, NSQ, psIndices, x16, pulses, PredCoef_Q12, LTPCoef_Q14, AR_Q13, \
297 HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14))
298#endif
299
269/************/ 300/************/
270/* Silk VAD */ 301/* Silk VAD */
271/************/ 302/************/
@@ -275,11 +306,15 @@ opus_int silk_VAD_Init( /* O Return v
275); 306);
276 307
277/* Get speech activity level in Q8 */ 308/* Get speech activity level in Q8 */
278opus_int silk_VAD_GetSA_Q8( /* O Return value, 0 if success */ 309opus_int silk_VAD_GetSA_Q8_c( /* O Return value, 0 if success */
279 silk_encoder_state *psEncC, /* I/O Encoder state */ 310 silk_encoder_state *psEncC, /* I/O Encoder state */
280 const opus_int16 pIn[] /* I PCM input */ 311 const opus_int16 pIn[] /* I PCM input */
281); 312);
282 313
314#if !defined(OVERRIDE_silk_VAD_GetSA_Q8)
315#define silk_VAD_GetSA_Q8(psEnC, pIn, arch) ((void)(arch),silk_VAD_GetSA_Q8_c(psEnC, pIn))
316#endif
317
283/* Low-pass filter with variable cutoff frequency based on */ 318/* Low-pass filter with variable cutoff frequency based on */
284/* piece-wise linear interpolation between elliptic filters */ 319/* piece-wise linear interpolation between elliptic filters */
285/* Start by setting transition_frame_no = 1; */ 320/* Start by setting transition_frame_no = 1; */
@@ -315,6 +350,7 @@ void silk_NLSF_VQ(
315 opus_int32 err_Q26[], /* O Quantization errors [K] */ 350 opus_int32 err_Q26[], /* O Quantization errors [K] */
316 const opus_int16 in_Q15[], /* I Input vectors to be quantized [LPC_order] */ 351 const opus_int16 in_Q15[], /* I Input vectors to be quantized [LPC_order] */
317 const opus_uint8 pCB_Q8[], /* I Codebook vectors [K*LPC_order] */ 352 const opus_uint8 pCB_Q8[], /* I Codebook vectors [K*LPC_order] */
353 const opus_int16 pWght_Q9[], /* I Codebook weights [K*LPC_order] */
318 const opus_int K, /* I Number of codebook vectors */ 354 const opus_int K, /* I Number of codebook vectors */
319 const opus_int LPC_order /* I Number of LPCs */ 355 const opus_int LPC_order /* I Number of LPCs */
320); 356);
@@ -373,7 +409,8 @@ opus_int silk_decode_frame(
373 opus_int16 pOut[], /* O Pointer to output speech frame */ 409 opus_int16 pOut[], /* O Pointer to output speech frame */
374 opus_int32 *pN, /* O Pointer to size of output frame */ 410 opus_int32 *pN, /* O Pointer to size of output frame */
375 opus_int lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */ 411 opus_int lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */
376 opus_int condCoding /* I The type of conditional coding to use */ 412 opus_int condCoding, /* I The type of conditional coding to use */
413 int arch /* I Run-time architecture */
377); 414);
378 415
379/* Decode indices from bitstream */ 416/* Decode indices from bitstream */
@@ -397,7 +434,8 @@ void silk_decode_core(
397 silk_decoder_state *psDec, /* I/O Decoder state */ 434 silk_decoder_state *psDec, /* I/O Decoder state */
398 silk_decoder_control *psDecCtrl, /* I Decoder control */ 435 silk_decoder_control *psDecCtrl, /* I Decoder control */
399 opus_int16 xq[], /* O Decoded speech */ 436 opus_int16 xq[], /* O Decoded speech */
400 const opus_int16 pulses[ MAX_FRAME_LENGTH ] /* I Pulse signal */ 437 const opus_int16 pulses[ MAX_FRAME_LENGTH ], /* I Pulse signal */
438 int arch /* I Run-time architecture */
401); 439);
402 440
403/* Decode quantization indices of excitation (Shell coding) */ 441/* Decode quantization indices of excitation (Shell coding) */