summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libopus/silk/fixed/x86/prefilter_FIX_sse.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/libopus/silk/fixed/x86/prefilter_FIX_sse.c')
-rw-r--r--lib/rbcodec/codecs/libopus/silk/fixed/x86/prefilter_FIX_sse.c160
1 files changed, 160 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libopus/silk/fixed/x86/prefilter_FIX_sse.c b/lib/rbcodec/codecs/libopus/silk/fixed/x86/prefilter_FIX_sse.c
new file mode 100644
index 0000000000..555432cd96
--- /dev/null
+++ b/lib/rbcodec/codecs/libopus/silk/fixed/x86/prefilter_FIX_sse.c
@@ -0,0 +1,160 @@
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#ifdef HAVE_CONFIG_H
29#include "config.h"
30#endif
31
32#include <xmmintrin.h>
33#include <emmintrin.h>
34#include <smmintrin.h>
35#include "main.h"
36#include "celt/x86/x86cpu.h"
37
38void silk_warped_LPC_analysis_filter_FIX_sse4_1(
39 opus_int32 state[], /* I/O State [order + 1] */
40 opus_int32 res_Q2[], /* O Residual signal [length] */
41 const opus_int16 coef_Q13[], /* I Coefficients [order] */
42 const opus_int16 input[], /* I Input signal [length] */
43 const opus_int16 lambda_Q16, /* I Warping factor */
44 const opus_int length, /* I Length of input signal */
45 const opus_int order /* I Filter order (even) */
46)
47{
48 opus_int n, i;
49 opus_int32 acc_Q11, tmp1, tmp2;
50
51 /* Order must be even */
52 celt_assert( ( order & 1 ) == 0 );
53
54 if (order == 10)
55 {
56 if (0 == lambda_Q16)
57 {
58 __m128i coef_Q13_3210, coef_Q13_7654;
59 __m128i coef_Q13_0123, coef_Q13_4567;
60 __m128i state_0123, state_4567;
61 __m128i xmm_product1, xmm_product2;
62 __m128i xmm_tempa, xmm_tempb;
63
64 register opus_int32 sum;
65 register opus_int32 state_8, state_9, state_a;
66 register opus_int64 coef_Q13_8, coef_Q13_9;
67
68 celt_assert( length > 0 );
69
70 coef_Q13_3210 = OP_CVTEPI16_EPI32_M64( &coef_Q13[ 0 ] );
71 coef_Q13_7654 = OP_CVTEPI16_EPI32_M64( &coef_Q13[ 4 ] );
72
73 coef_Q13_0123 = _mm_shuffle_epi32( coef_Q13_3210, _MM_SHUFFLE( 0, 1, 2, 3 ) );
74 coef_Q13_4567 = _mm_shuffle_epi32( coef_Q13_7654, _MM_SHUFFLE( 0, 1, 2, 3 ) );
75
76 coef_Q13_8 = (opus_int64) coef_Q13[ 8 ];
77 coef_Q13_9 = (opus_int64) coef_Q13[ 9 ];
78
79 state_0123 = _mm_loadu_si128( (__m128i *)(&state[ 0 ] ) );
80 state_4567 = _mm_loadu_si128( (__m128i *)(&state[ 4 ] ) );
81
82 state_0123 = _mm_shuffle_epi32( state_0123, _MM_SHUFFLE( 0, 1, 2, 3 ) );
83 state_4567 = _mm_shuffle_epi32( state_4567, _MM_SHUFFLE( 0, 1, 2, 3 ) );
84
85 state_8 = state[ 8 ];
86 state_9 = state[ 9 ];
87 state_a = 0;
88
89 for( n = 0; n < length; n++ )
90 {
91 xmm_product1 = _mm_mul_epi32( coef_Q13_0123, state_0123 ); /* 64-bit multiply, only 2 pairs */
92 xmm_product2 = _mm_mul_epi32( coef_Q13_4567, state_4567 );
93
94 xmm_tempa = _mm_shuffle_epi32( state_0123, _MM_SHUFFLE( 0, 1, 2, 3 ) );
95 xmm_tempb = _mm_shuffle_epi32( state_4567, _MM_SHUFFLE( 0, 1, 2, 3 ) );
96
97 xmm_product1 = _mm_srli_epi64( xmm_product1, 16 ); /* >> 16, zero extending works */
98 xmm_product2 = _mm_srli_epi64( xmm_product2, 16 );
99
100 xmm_tempa = _mm_mul_epi32( coef_Q13_3210, xmm_tempa );
101 xmm_tempb = _mm_mul_epi32( coef_Q13_7654, xmm_tempb );
102
103 xmm_tempa = _mm_srli_epi64( xmm_tempa, 16 );
104 xmm_tempb = _mm_srli_epi64( xmm_tempb, 16 );
105
106 xmm_tempa = _mm_add_epi32( xmm_tempa, xmm_product1 );
107 xmm_tempb = _mm_add_epi32( xmm_tempb, xmm_product2 );
108 xmm_tempa = _mm_add_epi32( xmm_tempa, xmm_tempb );
109
110 sum = (opus_int32)((coef_Q13_8 * state_8) >> 16);
111 sum += (opus_int32)((coef_Q13_9 * state_9) >> 16);
112
113 xmm_tempa = _mm_add_epi32( xmm_tempa, _mm_shuffle_epi32( xmm_tempa, _MM_SHUFFLE( 0, 0, 0, 2 ) ) );
114 sum += _mm_cvtsi128_si32( xmm_tempa);
115 res_Q2[ n ] = silk_LSHIFT( (opus_int32)input[ n ], 2 ) - silk_RSHIFT_ROUND( ( 5 + sum ), 9);
116
117 /* move right */
118 state_a = state_9;
119 state_9 = state_8;
120 state_8 = _mm_cvtsi128_si32( state_4567 );
121 state_4567 = _mm_alignr_epi8( state_0123, state_4567, 4 );
122
123 state_0123 = _mm_alignr_epi8( _mm_cvtsi32_si128( silk_LSHIFT( input[ n ], 14 ) ), state_0123, 4 );
124 }
125
126 _mm_storeu_si128( (__m128i *)( &state[ 0 ] ), _mm_shuffle_epi32( state_0123, _MM_SHUFFLE( 0, 1, 2, 3 ) ) );
127 _mm_storeu_si128( (__m128i *)( &state[ 4 ] ), _mm_shuffle_epi32( state_4567, _MM_SHUFFLE( 0, 1, 2, 3 ) ) );
128 state[ 8 ] = state_8;
129 state[ 9 ] = state_9;
130 state[ 10 ] = state_a;
131
132 return;
133 }
134 }
135
136 for( n = 0; n < length; n++ ) {
137 /* Output of lowpass section */
138 tmp2 = silk_SMLAWB( state[ 0 ], state[ 1 ], lambda_Q16 );
139 state[ 0 ] = silk_LSHIFT( input[ n ], 14 );
140 /* Output of allpass section */
141 tmp1 = silk_SMLAWB( state[ 1 ], state[ 2 ] - tmp2, lambda_Q16 );
142 state[ 1 ] = tmp2;
143 acc_Q11 = silk_RSHIFT( order, 1 );
144 acc_Q11 = silk_SMLAWB( acc_Q11, tmp2, coef_Q13[ 0 ] );
145 /* Loop over allpass sections */
146 for( i = 2; i < order; i += 2 ) {
147 /* Output of allpass section */
148 tmp2 = silk_SMLAWB( state[ i ], state[ i + 1 ] - tmp1, lambda_Q16 );
149 state[ i ] = tmp1;
150 acc_Q11 = silk_SMLAWB( acc_Q11, tmp1, coef_Q13[ i - 1 ] );
151 /* Output of allpass section */
152 tmp1 = silk_SMLAWB( state[ i + 1 ], state[ i + 2 ] - tmp2, lambda_Q16 );
153 state[ i + 1 ] = tmp2;
154 acc_Q11 = silk_SMLAWB( acc_Q11, tmp2, coef_Q13[ i ] );
155 }
156 state[ order ] = tmp1;
157 acc_Q11 = silk_SMLAWB( acc_Q11, tmp1, coef_Q13[ order - 1 ] );
158 res_Q2[ n ] = silk_LSHIFT( (opus_int32)input[ n ], 2 ) - silk_RSHIFT_ROUND( acc_Q11, 9 );
159 }
160}