diff options
Diffstat (limited to 'lib/rbcodec/codecs/libopus/silk/SigProc_FIX.h')
-rw-r--r-- | lib/rbcodec/codecs/libopus/silk/SigProc_FIX.h | 80 |
1 files changed, 61 insertions, 19 deletions
diff --git a/lib/rbcodec/codecs/libopus/silk/SigProc_FIX.h b/lib/rbcodec/codecs/libopus/silk/SigProc_FIX.h index 4be0985435..f9ae326326 100644 --- a/lib/rbcodec/codecs/libopus/silk/SigProc_FIX.h +++ b/lib/rbcodec/codecs/libopus/silk/SigProc_FIX.h | |||
@@ -35,13 +35,22 @@ extern "C" | |||
35 | 35 | ||
36 | /*#define silk_MACRO_COUNT */ /* Used to enable WMOPS counting */ | 36 | /*#define silk_MACRO_COUNT */ /* Used to enable WMOPS counting */ |
37 | 37 | ||
38 | #define SILK_MAX_ORDER_LPC 16 /* max order of the LPC analysis in schur() and k2a() */ | 38 | #define SILK_MAX_ORDER_LPC 24 /* max order of the LPC analysis in schur() and k2a() */ |
39 | 39 | ||
40 | #include <string.h> /* for memset(), memcpy(), memmove() */ | 40 | #include <string.h> /* for memset(), memcpy(), memmove() */ |
41 | #include "typedef.h" | 41 | #include "typedef.h" |
42 | #include "resampler_structs.h" | 42 | #include "resampler_structs.h" |
43 | #include "macros.h" | 43 | #include "macros.h" |
44 | #include "cpu_support.h" | ||
44 | 45 | ||
46 | #if defined(OPUS_X86_MAY_HAVE_SSE4_1) | ||
47 | #include "x86/SigProc_FIX_sse.h" | ||
48 | #endif | ||
49 | |||
50 | #if (defined(OPUS_ARM_ASM) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)) | ||
51 | #include "arm/biquad_alt_arm.h" | ||
52 | #include "arm/LPC_inv_pred_gain_arm.h" | ||
53 | #endif | ||
45 | 54 | ||
46 | /********************************************************************/ | 55 | /********************************************************************/ |
47 | /* SIGNAL PROCESSING FUNCTIONS */ | 56 | /* SIGNAL PROCESSING FUNCTIONS */ |
@@ -92,14 +101,22 @@ void silk_resampler_down2_3( | |||
92 | * slower than biquad() but uses more precise coefficients | 101 | * slower than biquad() but uses more precise coefficients |
93 | * can handle (slowly) varying coefficients | 102 | * can handle (slowly) varying coefficients |
94 | */ | 103 | */ |
95 | void silk_biquad_alt( | 104 | void silk_biquad_alt_stride1( |
96 | const opus_int16 *in, /* I input signal */ | 105 | const opus_int16 *in, /* I input signal */ |
97 | const opus_int32 *B_Q28, /* I MA coefficients [3] */ | 106 | const opus_int32 *B_Q28, /* I MA coefficients [3] */ |
98 | const opus_int32 *A_Q28, /* I AR coefficients [2] */ | 107 | const opus_int32 *A_Q28, /* I AR coefficients [2] */ |
99 | opus_int32 *S, /* I/O State vector [2] */ | 108 | opus_int32 *S, /* I/O State vector [2] */ |
100 | opus_int16 *out, /* O output signal */ | 109 | opus_int16 *out, /* O output signal */ |
101 | const opus_int32 len, /* I signal length (must be even) */ | 110 | const opus_int32 len /* I signal length (must be even) */ |
102 | opus_int stride /* I Operate on interleaved signal if > 1 */ | 111 | ); |
112 | |||
113 | void silk_biquad_alt_stride2_c( | ||
114 | const opus_int16 *in, /* I input signal */ | ||
115 | const opus_int32 *B_Q28, /* I MA coefficients [3] */ | ||
116 | const opus_int32 *A_Q28, /* I AR coefficients [2] */ | ||
117 | opus_int32 *S, /* I/O State vector [4] */ | ||
118 | opus_int16 *out, /* O output signal */ | ||
119 | const opus_int32 len /* I signal length (must be even) */ | ||
103 | ); | 120 | ); |
104 | 121 | ||
105 | /* Variable order MA prediction error filter. */ | 122 | /* Variable order MA prediction error filter. */ |
@@ -108,7 +125,8 @@ void silk_LPC_analysis_filter( | |||
108 | const opus_int16 *in, /* I Input signal */ | 125 | const opus_int16 *in, /* I Input signal */ |
109 | const opus_int16 *B, /* I MA prediction coefficients, Q12 [order] */ | 126 | const opus_int16 *B, /* I MA prediction coefficients, Q12 [order] */ |
110 | const opus_int32 len, /* I Signal length */ | 127 | const opus_int32 len, /* I Signal length */ |
111 | const opus_int32 d /* I Filter order */ | 128 | const opus_int32 d, /* I Filter order */ |
129 | int arch /* I Run-time architecture */ | ||
112 | ); | 130 | ); |
113 | 131 | ||
114 | /* Chirp (bandwidth expand) LP AR filter */ | 132 | /* Chirp (bandwidth expand) LP AR filter */ |
@@ -127,17 +145,11 @@ void silk_bwexpander_32( | |||
127 | 145 | ||
128 | /* Compute inverse of LPC prediction gain, and */ | 146 | /* Compute inverse of LPC prediction gain, and */ |
129 | /* test if LPC coefficients are stable (all poles within unit circle) */ | 147 | /* test if LPC coefficients are stable (all poles within unit circle) */ |
130 | opus_int32 silk_LPC_inverse_pred_gain( /* O Returns inverse prediction gain in energy domain, Q30 */ | 148 | opus_int32 silk_LPC_inverse_pred_gain_c( /* O Returns inverse prediction gain in energy domain, Q30 */ |
131 | const opus_int16 *A_Q12, /* I Prediction coefficients, Q12 [order] */ | 149 | const opus_int16 *A_Q12, /* I Prediction coefficients, Q12 [order] */ |
132 | const opus_int order /* I Prediction order */ | 150 | const opus_int order /* I Prediction order */ |
133 | ); | 151 | ); |
134 | 152 | ||
135 | /* For input in Q24 domain */ | ||
136 | opus_int32 silk_LPC_inverse_pred_gain_Q24( /* O Returns inverse prediction gain in energy domain, Q30 */ | ||
137 | const opus_int32 *A_Q24, /* I Prediction coefficients [order] */ | ||
138 | const opus_int order /* I Prediction order */ | ||
139 | ); | ||
140 | |||
141 | /* Split signal in two decimated bands using first-order allpass filters */ | 153 | /* Split signal in two decimated bands using first-order allpass filters */ |
142 | void silk_ana_filt_bank_1( | 154 | void silk_ana_filt_bank_1( |
143 | const opus_int16 *in, /* I Input signal [N] */ | 155 | const opus_int16 *in, /* I Input signal [N] */ |
@@ -147,6 +159,14 @@ void silk_ana_filt_bank_1( | |||
147 | const opus_int32 N /* I Number of input samples */ | 159 | const opus_int32 N /* I Number of input samples */ |
148 | ); | 160 | ); |
149 | 161 | ||
162 | #if !defined(OVERRIDE_silk_biquad_alt_stride2) | ||
163 | #define silk_biquad_alt_stride2(in, B_Q28, A_Q28, S, out, len, arch) ((void)(arch), silk_biquad_alt_stride2_c(in, B_Q28, A_Q28, S, out, len)) | ||
164 | #endif | ||
165 | |||
166 | #if !defined(OVERRIDE_silk_LPC_inverse_pred_gain) | ||
167 | #define silk_LPC_inverse_pred_gain(A_Q12, order, arch) ((void)(arch), silk_LPC_inverse_pred_gain_c(A_Q12, order)) | ||
168 | #endif | ||
169 | |||
150 | /********************************************************************/ | 170 | /********************************************************************/ |
151 | /* SCALAR FUNCTIONS */ | 171 | /* SCALAR FUNCTIONS */ |
152 | /********************************************************************/ | 172 | /********************************************************************/ |
@@ -266,7 +286,17 @@ void silk_A2NLSF( | |||
266 | void silk_NLSF2A( | 286 | void silk_NLSF2A( |
267 | opus_int16 *a_Q12, /* O monic whitening filter coefficients in Q12, [ d ] */ | 287 | opus_int16 *a_Q12, /* O monic whitening filter coefficients in Q12, [ d ] */ |
268 | const opus_int16 *NLSF, /* I normalized line spectral frequencies in Q15, [ d ] */ | 288 | const opus_int16 *NLSF, /* I normalized line spectral frequencies in Q15, [ d ] */ |
269 | const opus_int d /* I filter order (should be even) */ | 289 | const opus_int d, /* I filter order (should be even) */ |
290 | int arch /* I Run-time architecture */ | ||
291 | ); | ||
292 | |||
293 | /* Convert int32 coefficients to int16 coefs and make sure there's no wrap-around */ | ||
294 | void silk_LPC_fit( | ||
295 | opus_int16 *a_QOUT, /* O Output signal */ | ||
296 | opus_int32 *a_QIN, /* I/O Input signal */ | ||
297 | const opus_int QOUT, /* I Input Q domain */ | ||
298 | const opus_int QIN, /* I Input Q domain */ | ||
299 | const opus_int d /* I Filter order */ | ||
270 | ); | 300 | ); |
271 | 301 | ||
272 | void silk_insertion_sort_increasing( | 302 | void silk_insertion_sort_increasing( |
@@ -303,7 +333,7 @@ void silk_NLSF_VQ_weights_laroia( | |||
303 | ); | 333 | ); |
304 | 334 | ||
305 | /* Compute reflection coefficients from input signal */ | 335 | /* Compute reflection coefficients from input signal */ |
306 | void silk_burg_modified( | 336 | void silk_burg_modified_c( |
307 | opus_int32 *res_nrg, /* O Residual energy */ | 337 | opus_int32 *res_nrg, /* O Residual energy */ |
308 | opus_int *res_nrg_Q, /* O Residual energy Q value */ | 338 | opus_int *res_nrg_Q, /* O Residual energy Q value */ |
309 | opus_int32 A_Q16[], /* O Prediction coefficients (length order) */ | 339 | opus_int32 A_Q16[], /* O Prediction coefficients (length order) */ |
@@ -335,12 +365,15 @@ void silk_scale_vector32_Q26_lshift_18( | |||
335 | /********************************************************************/ | 365 | /********************************************************************/ |
336 | 366 | ||
337 | /* return sum( inVec1[i] * inVec2[i] ) */ | 367 | /* return sum( inVec1[i] * inVec2[i] ) */ |
368 | |||
338 | opus_int32 silk_inner_prod_aligned( | 369 | opus_int32 silk_inner_prod_aligned( |
339 | const opus_int16 *const inVec1, /* I input vector 1 */ | 370 | const opus_int16 *const inVec1, /* I input vector 1 */ |
340 | const opus_int16 *const inVec2, /* I input vector 2 */ | 371 | const opus_int16 *const inVec2, /* I input vector 2 */ |
341 | const opus_int len /* I vector lengths */ | 372 | const opus_int len, /* I vector lengths */ |
373 | int arch /* I Run-time architecture */ | ||
342 | ); | 374 | ); |
343 | 375 | ||
376 | |||
344 | opus_int32 silk_inner_prod_aligned_scale( | 377 | opus_int32 silk_inner_prod_aligned_scale( |
345 | const opus_int16 *const inVec1, /* I input vector 1 */ | 378 | const opus_int16 *const inVec1, /* I input vector 1 */ |
346 | const opus_int16 *const inVec2, /* I input vector 2 */ | 379 | const opus_int16 *const inVec2, /* I input vector 2 */ |
@@ -348,7 +381,7 @@ opus_int32 silk_inner_prod_aligned_scale( | |||
348 | const opus_int len /* I vector lengths */ | 381 | const opus_int len /* I vector lengths */ |
349 | ); | 382 | ); |
350 | 383 | ||
351 | opus_int64 silk_inner_prod16_aligned_64( | 384 | opus_int64 silk_inner_prod16_aligned_64_c( |
352 | const opus_int16 *inVec1, /* I input vector 1 */ | 385 | const opus_int16 *inVec1, /* I input vector 1 */ |
353 | const opus_int16 *inVec2, /* I input vector 2 */ | 386 | const opus_int16 *inVec2, /* I input vector 2 */ |
354 | const opus_int len /* I vector lengths */ | 387 | const opus_int len /* I vector lengths */ |
@@ -463,8 +496,7 @@ static OPUS_INLINE opus_int32 silk_ROR32( opus_int32 a32, opus_int rot ) | |||
463 | /* Add with saturation for positive input values */ | 496 | /* Add with saturation for positive input values */ |
464 | #define silk_ADD_POS_SAT8(a, b) ((((a)+(b)) & 0x80) ? silk_int8_MAX : ((a)+(b))) | 497 | #define silk_ADD_POS_SAT8(a, b) ((((a)+(b)) & 0x80) ? silk_int8_MAX : ((a)+(b))) |
465 | #define silk_ADD_POS_SAT16(a, b) ((((a)+(b)) & 0x8000) ? silk_int16_MAX : ((a)+(b))) | 498 | #define silk_ADD_POS_SAT16(a, b) ((((a)+(b)) & 0x8000) ? silk_int16_MAX : ((a)+(b))) |
466 | #define silk_ADD_POS_SAT32(a, b) ((((a)+(b)) & 0x80000000) ? silk_int32_MAX : ((a)+(b))) | 499 | #define silk_ADD_POS_SAT32(a, b) ((((opus_uint32)(a)+(opus_uint32)(b)) & 0x80000000) ? silk_int32_MAX : ((a)+(b))) |
467 | #define silk_ADD_POS_SAT64(a, b) ((((a)+(b)) & 0x8000000000000000LL) ? silk_int64_MAX : ((a)+(b))) | ||
468 | 500 | ||
469 | #define silk_LSHIFT8(a, shift) ((opus_int8)((opus_uint8)(a)<<(shift))) /* shift >= 0, shift < 8 */ | 501 | #define silk_LSHIFT8(a, shift) ((opus_int8)((opus_uint8)(a)<<(shift))) /* shift >= 0, shift < 8 */ |
470 | #define silk_LSHIFT16(a, shift) ((opus_int16)((opus_uint16)(a)<<(shift))) /* shift >= 0, shift < 16 */ | 502 | #define silk_LSHIFT16(a, shift) ((opus_int16)((opus_uint16)(a)<<(shift))) /* shift >= 0, shift < 16 */ |
@@ -564,7 +596,9 @@ static OPUS_INLINE opus_int64 silk_max_64(opus_int64 a, opus_int64 b) | |||
564 | /* Make sure to store the result as the seed for the next call (also in between */ | 596 | /* Make sure to store the result as the seed for the next call (also in between */ |
565 | /* frames), otherwise result won't be random at all. When only using some of the */ | 597 | /* frames), otherwise result won't be random at all. When only using some of the */ |
566 | /* bits, take the most significant bits by right-shifting. */ | 598 | /* bits, take the most significant bits by right-shifting. */ |
567 | #define silk_RAND(seed) (silk_MLA_ovflw(907633515, (seed), 196314165)) | 599 | #define RAND_MULTIPLIER 196314165 |
600 | #define RAND_INCREMENT 907633515 | ||
601 | #define silk_RAND(seed) (silk_MLA_ovflw((RAND_INCREMENT), (seed), (RAND_MULTIPLIER))) | ||
568 | 602 | ||
569 | /* Add some multiplication functions that can be easily mapped to ARM. */ | 603 | /* Add some multiplication functions that can be easily mapped to ARM. */ |
570 | 604 | ||
@@ -575,6 +609,14 @@ static OPUS_INLINE opus_int64 silk_max_64(opus_int64 a, opus_int64 b) | |||
575 | /* the following seems faster on x86 */ | 609 | /* the following seems faster on x86 */ |
576 | #define silk_SMMUL(a32, b32) (opus_int32)silk_RSHIFT64(silk_SMULL((a32), (b32)), 32) | 610 | #define silk_SMMUL(a32, b32) (opus_int32)silk_RSHIFT64(silk_SMULL((a32), (b32)), 32) |
577 | 611 | ||
612 | #if !defined(OPUS_X86_MAY_HAVE_SSE4_1) | ||
613 | #define silk_burg_modified(res_nrg, res_nrg_Q, A_Q16, x, minInvGain_Q30, subfr_length, nb_subfr, D, arch) \ | ||
614 | ((void)(arch), silk_burg_modified_c(res_nrg, res_nrg_Q, A_Q16, x, minInvGain_Q30, subfr_length, nb_subfr, D, arch)) | ||
615 | |||
616 | #define silk_inner_prod16_aligned_64(inVec1, inVec2, len, arch) \ | ||
617 | ((void)(arch),silk_inner_prod16_aligned_64_c(inVec1, inVec2, len)) | ||
618 | #endif | ||
619 | |||
578 | #include "Inlines.h" | 620 | #include "Inlines.h" |
579 | #include "MacroCount.h" | 621 | #include "MacroCount.h" |
580 | #include "MacroDebug.h" | 622 | #include "MacroDebug.h" |