Coverage Report

Created: 2025-11-24 06:18

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/speex/libspeex/ltp_sse.h
Line
Count
Source
1
/* Copyright (C) 2002 Jean-Marc Valin */
2
/**
3
   @file ltp_sse.h
4
   @brief Long-Term Prediction functions (SSE version)
5
*/
6
/*
7
   Redistribution and use in source and binary forms, with or without
8
   modification, are permitted provided that the following conditions
9
   are met:
10
11
   - Redistributions of source code must retain the above copyright
12
   notice, this list of conditions and the following disclaimer.
13
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.
17
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.
21
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.
33
*/
34
35
#include <xmmintrin.h>
36
37
#define OVERRIDE_INNER_PROD
38
float inner_prod(const float *a, const float *b, int len)
39
825k
{
40
825k
   int i;
41
825k
   float ret;
42
825k
   __m128 sum = _mm_setzero_ps();
43
6.69M
   for (i=0;i<(len>>2);i+=2)
44
5.86M
   {
45
5.86M
      sum = _mm_add_ps(sum, _mm_mul_ps(_mm_loadu_ps(a+0), _mm_loadu_ps(b+0)));
46
5.86M
      sum = _mm_add_ps(sum, _mm_mul_ps(_mm_loadu_ps(a+4), _mm_loadu_ps(b+4)));
47
5.86M
      a += 8;
48
5.86M
      b += 8;
49
5.86M
   }
50
825k
   sum = _mm_add_ps(sum, _mm_movehl_ps(sum, sum));
51
825k
   sum = _mm_add_ss(sum, _mm_shuffle_ps(sum, sum, 0x55));
52
825k
   _mm_store_ss(&ret, sum);
53
825k
   return ret;
54
825k
}
55
56
#define OVERRIDE_PITCH_XCORR
57
void pitch_xcorr(const float *_x, const float *_y, float *corr, int len, int nb_pitch, char *stack)
58
15.7k
{
59
15.7k
   int i, offset;
60
15.7k
   VARDECL(__m128 *x);
61
15.7k
   VARDECL(__m128 *y);
62
15.7k
   int N, L;
63
15.7k
   N = len>>2;
64
15.7k
   L = nb_pitch>>2;
65
15.7k
   ALLOC(x, N, __m128);
66
15.7k
   ALLOC(y, N+L, __m128);
67
397k
   for (i=0;i<N;i++)
68
381k
      x[i] = _mm_loadu_ps(_x+(i<<2));
69
78.5k
   for (offset=0;offset<4;offset++)
70
62.8k
   {
71
3.49M
      for (i=0;i<N+L;i++)
72
3.42M
         y[i] = _mm_loadu_ps(_y+(i<<2)+offset);
73
1.96M
      for (i=0;i<L;i++)
74
1.90M
      {
75
1.90M
         int j;
76
1.90M
         __m128 sum, *xx, *yy;
77
1.90M
         sum = _mm_setzero_ps();
78
1.90M
         yy = y+i;
79
1.90M
         xx = x;
80
25.7M
         for (j=0;j<N;j+=2)
81
23.8M
         {
82
23.8M
            sum = _mm_add_ps(sum, _mm_mul_ps(xx[0], yy[0]));
83
23.8M
            sum = _mm_add_ps(sum, _mm_mul_ps(xx[1], yy[1]));
84
23.8M
            xx += 2;
85
23.8M
            yy += 2;
86
23.8M
         }
87
1.90M
         sum = _mm_add_ps(sum, _mm_movehl_ps(sum, sum));
88
         sum = _mm_add_ss(sum, _mm_shuffle_ps(sum, sum, 0x55));
89
1.90M
         _mm_store_ss(corr+nb_pitch-1-(i<<2)-offset, sum);
90
1.90M
      }
91
62.8k
   }
92
15.7k
}