1 /* Copyright (C) 2002 Jean-Marc Valin */
4 @brief Long-Term Prediction functions (SSE version)
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions
11 - Redistributions of source code must retain the above copyright
12 notice, this list of conditions and the following disclaimer.
14 - Redistributions in binary form must reproduce the above copyright
15 notice, this list of conditions and the following disclaimer in the
16 documentation and/or other materials provided with the distribution.
18 - Neither the name of the Xiph.org Foundation nor the names of its
19 contributors may be used to endorse or promote products derived from
20 this software without specific prior written permission.
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include <xmmintrin.h>
37 #define OVERRIDE_INNER_PROD
38 float inner_prod(const float *a
, const float *b
, int len
)
42 __m128 sum
= _mm_setzero_ps();
43 for (i
=0;i
<(len
>>2);i
+=2)
45 sum
= _mm_add_ps(sum
, _mm_mul_ps(_mm_loadu_ps(a
+0), _mm_loadu_ps(b
+0)));
46 sum
= _mm_add_ps(sum
, _mm_mul_ps(_mm_loadu_ps(a
+4), _mm_loadu_ps(b
+4)));
50 sum
= _mm_add_ps(sum
, _mm_movehl_ps(sum
, sum
));
51 sum
= _mm_add_ss(sum
, _mm_shuffle_ps(sum
, sum
, 0x55));
52 _mm_store_ss(&ret
, sum
);
56 #define OVERRIDE_PITCH_XCORR
57 void pitch_xcorr(const float *_x
, const float *_y
, float *corr
, int len
, int nb_pitch
, char *stack
)
66 ALLOC(y
, N
+L
, __m128
);
68 x
[i
] = _mm_loadu_ps(_x
+(i
<<2));
69 for (offset
=0;offset
<4;offset
++)
72 y
[i
] = _mm_loadu_ps(_y
+(i
<<2)+offset
);
77 sum
= _mm_setzero_ps();
82 sum
= _mm_add_ps(sum
, _mm_mul_ps(xx
[0], yy
[0]));
83 sum
= _mm_add_ps(sum
, _mm_mul_ps(xx
[1], yy
[1]));
87 sum
= _mm_add_ps(sum
, _mm_movehl_ps(sum
, sum
));
88 sum
= _mm_add_ss(sum
, _mm_shuffle_ps(sum
, sum
, 0x55));
89 _mm_store_ss(corr
+nb_pitch
-1-(i
<<2)-offset
, sum
);