Coverage Report

Created: 2024-03-26 07:25

/src/opus/celt/mathops.h
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (c) 2002-2008 Jean-Marc Valin
2
   Copyright (c) 2007-2008 CSIRO
3
   Copyright (c) 2007-2009 Xiph.Org Foundation
4
   Written by Jean-Marc Valin */
5
/**
6
   @file mathops.h
7
   @brief Various math functions
8
*/
9
/*
10
   Redistribution and use in source and binary forms, with or without
11
   modification, are permitted provided that the following conditions
12
   are met:
13
14
   - Redistributions of source code must retain the above copyright
15
   notice, this list of conditions and the following disclaimer.
16
17
   - Redistributions in binary form must reproduce the above copyright
18
   notice, this list of conditions and the following disclaimer in the
19
   documentation and/or other materials provided with the distribution.
20
21
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
25
   OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26
   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27
   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28
   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29
   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30
   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
*/
33
34
#ifndef MATHOPS_H
35
#define MATHOPS_H
36
37
#include "arch.h"
38
#include "entcode.h"
39
#include "os_support.h"
40
41
291M
#define PI 3.141592653f
42
43
/* Multiplies two 16-bit fractional values. Bit-exactness of this macro is important */
44
268M
#define FRAC_MUL16(a,b) ((16384+((opus_int32)(opus_int16)(a)*(opus_int16)(b)))>>15)
45
46
unsigned isqrt32(opus_uint32 _val);
47
48
/* CELT doesn't need it for fixed-point, by analysis.c does. */
49
#if !defined(FIXED_POINT) || defined(ANALYSIS_C)
50
173M
#define cA 0.43157974f
51
173M
#define cB 0.67848403f
52
173M
#define cC 0.08595542f
53
260M
#define cE ((float)PI/2)
54
174M
static OPUS_INLINE float fast_atan2f(float y, float x) {
55
174M
   float x2, y2;
56
174M
   x2 = x*x;
57
174M
   y2 = y*y;
58
   /* For very small values, we don't care about the answer, so
59
      we can just return 0. */
60
174M
   if (x2 + y2 < 1e-18f)
61
1.24M
   {
62
1.24M
      return 0;
63
1.24M
   }
64
173M
   if(x2<y2){
65
86.6M
      float den = (y2 + cB*x2) * (y2 + cC*x2);
66
86.6M
      return -x*y*(y2 + cA*x2) / den + (y<0 ? -cE : cE);
67
86.8M
   }else{
68
86.8M
      float den = (x2 + cB*y2) * (x2 + cC*y2);
69
86.8M
      return  x*y*(x2 + cA*y2) / den + (y<0 ? -cE : cE) - (x*y<0 ? -cE : cE);
70
86.8M
   }
71
173M
}
analysis.c:fast_atan2f
Line
Count
Source
54
174M
static OPUS_INLINE float fast_atan2f(float y, float x) {
55
174M
   float x2, y2;
56
174M
   x2 = x*x;
57
174M
   y2 = y*y;
58
   /* For very small values, we don't care about the answer, so
59
      we can just return 0. */
60
174M
   if (x2 + y2 < 1e-18f)
61
1.24M
   {
62
1.24M
      return 0;
63
1.24M
   }
64
172M
   if(x2<y2){
65
86.3M
      float den = (y2 + cB*x2) * (y2 + cC*x2);
66
86.3M
      return -x*y*(y2 + cA*x2) / den + (y<0 ? -cE : cE);
67
86.5M
   }else{
68
86.5M
      float den = (x2 + cB*y2) * (x2 + cC*y2);
69
86.5M
      return  x*y*(x2 + cA*y2) / den + (y<0 ? -cE : cE) - (x*y<0 ? -cE : cE);
70
86.5M
   }
71
172M
}
Unexecuted instantiation: opus_multistream_decode_fuzzer.cc:fast_atan2f(float, float)
Unexecuted instantiation: opus_multistream_encoder.c:fast_atan2f
Unexecuted instantiation: bands.c:fast_atan2f
Unexecuted instantiation: celt.c:fast_atan2f
Unexecuted instantiation: celt_encoder.c:fast_atan2f
Unexecuted instantiation: mathops.c:fast_atan2f
Unexecuted instantiation: mdct.c:fast_atan2f
Unexecuted instantiation: modes.c:fast_atan2f
Unexecuted instantiation: pitch.c:fast_atan2f
Unexecuted instantiation: celt_lpc.c:fast_atan2f
Unexecuted instantiation: quant_bands.c:fast_atan2f
vq.c:fast_atan2f
Line
Count
Source
54
621k
static OPUS_INLINE float fast_atan2f(float y, float x) {
55
621k
   float x2, y2;
56
621k
   x2 = x*x;
57
621k
   y2 = y*y;
58
   /* For very small values, we don't care about the answer, so
59
      we can just return 0. */
60
621k
   if (x2 + y2 < 1e-18f)
61
0
   {
62
0
      return 0;
63
0
   }
64
621k
   if(x2<y2){
65
311k
      float den = (y2 + cB*x2) * (y2 + cC*x2);
66
311k
      return -x*y*(y2 + cA*x2) / den + (y<0 ? -cE : cE);
67
311k
   }else{
68
310k
      float den = (x2 + cB*y2) * (x2 + cC*y2);
69
310k
      return  x*y*(x2 + cA*y2) / den + (y<0 ? -cE : cE) - (x*y<0 ? -cE : cE);
70
310k
   }
71
621k
}
Unexecuted instantiation: pitch_sse.c:fast_atan2f
Unexecuted instantiation: vq_sse2.c:fast_atan2f
Unexecuted instantiation: opus_decoder.c:fast_atan2f
Unexecuted instantiation: opus_encoder.c:fast_atan2f
Unexecuted instantiation: celt_decoder.c:fast_atan2f
Unexecuted instantiation: cwrs.c:fast_atan2f
Unexecuted instantiation: kiss_fft.c:fast_atan2f
Unexecuted instantiation: laplace.c:fast_atan2f
Unexecuted instantiation: opus_projection_decoder_fuzzer.cc:fast_atan2f(float, float)
Unexecuted instantiation: opus_projection_decoder.c:fast_atan2f
Unexecuted instantiation: opus_projection_encoder.c:fast_atan2f
72
#undef cA
73
#undef cB
74
#undef cC
75
#undef cE
76
#endif
77
78
79
#ifndef OVERRIDE_CELT_MAXABS16
80
static OPUS_INLINE opus_val32 celt_maxabs16(const opus_val16 *x, int len)
81
204M
{
82
204M
   int i;
83
204M
   opus_val16 maxval = 0;
84
204M
   opus_val16 minval = 0;
85
52.0G
   for (i=0;i<len;i++)
86
51.7G
   {
87
51.7G
      maxval = MAX16(maxval, x[i]);
88
51.7G
      minval = MIN16(minval, x[i]);
89
51.7G
   }
90
204M
   return MAX32(EXTEND32(maxval),-EXTEND32(minval));
91
204M
}
Unexecuted instantiation: opus_multistream_encoder.c:celt_maxabs16
Unexecuted instantiation: bands.c:celt_maxabs16
Unexecuted instantiation: celt.c:celt_maxabs16
celt_encoder.c:celt_maxabs16
Line
Count
Source
81
187M
{
82
187M
   int i;
83
187M
   opus_val16 maxval = 0;
84
187M
   opus_val16 minval = 0;
85
40.5G
   for (i=0;i<len;i++)
86
40.3G
   {
87
40.3G
      maxval = MAX16(maxval, x[i]);
88
40.3G
      minval = MIN16(minval, x[i]);
89
40.3G
   }
90
187M
   return MAX32(EXTEND32(maxval),-EXTEND32(minval));
91
187M
}
Unexecuted instantiation: mathops.c:celt_maxabs16
Unexecuted instantiation: mdct.c:celt_maxabs16
Unexecuted instantiation: modes.c:celt_maxabs16
pitch.c:celt_maxabs16
Line
Count
Source
81
2.22M
{
82
2.22M
   int i;
83
2.22M
   opus_val16 maxval = 0;
84
2.22M
   opus_val16 minval = 0;
85
582M
   for (i=0;i<len;i++)
86
579M
   {
87
579M
      maxval = MAX16(maxval, x[i]);
88
579M
      minval = MIN16(minval, x[i]);
89
579M
   }
90
2.22M
   return MAX32(EXTEND32(maxval),-EXTEND32(minval));
91
2.22M
}
Unexecuted instantiation: celt_lpc.c:celt_maxabs16
Unexecuted instantiation: quant_bands.c:celt_maxabs16
Unexecuted instantiation: vq.c:celt_maxabs16
Unexecuted instantiation: pitch_sse2.c:celt_maxabs16
Unexecuted instantiation: celt_lpc_sse4_1.c:celt_maxabs16
Unexecuted instantiation: pitch_sse4_1.c:celt_maxabs16
Unexecuted instantiation: opus_decoder.c:celt_maxabs16
opus_encoder.c:celt_maxabs16
Line
Count
Source
81
14.2M
{
82
14.2M
   int i;
83
14.2M
   opus_val16 maxval = 0;
84
14.2M
   opus_val16 minval = 0;
85
10.8G
   for (i=0;i<len;i++)
86
10.8G
   {
87
10.8G
      maxval = MAX16(maxval, x[i]);
88
10.8G
      minval = MIN16(minval, x[i]);
89
10.8G
   }
90
14.2M
   return MAX32(EXTEND32(maxval),-EXTEND32(minval));
91
14.2M
}
Unexecuted instantiation: analysis.c:celt_maxabs16
celt_decoder.c:celt_maxabs16
Line
Count
Source
81
83.0k
{
82
83.0k
   int i;
83
83.0k
   opus_val16 maxval = 0;
84
83.0k
   opus_val16 minval = 0;
85
39.4M
   for (i=0;i<len;i++)
86
39.3M
   {
87
39.3M
      maxval = MAX16(maxval, x[i]);
88
39.3M
      minval = MIN16(minval, x[i]);
89
39.3M
   }
90
83.0k
   return MAX32(EXTEND32(maxval),-EXTEND32(minval));
91
83.0k
}
Unexecuted instantiation: cwrs.c:celt_maxabs16
Unexecuted instantiation: kiss_fft.c:celt_maxabs16
Unexecuted instantiation: laplace.c:celt_maxabs16
Unexecuted instantiation: opus_multistream_decode_fuzzer.cc:celt_maxabs16(float const*, int)
Unexecuted instantiation: pitch_sse.c:celt_maxabs16
Unexecuted instantiation: vq_sse2.c:celt_maxabs16
Unexecuted instantiation: opus_projection_decoder_fuzzer.cc:celt_maxabs16(float const*, int)
Unexecuted instantiation: opus_projection_decoder.c:celt_maxabs16
Unexecuted instantiation: opus_projection_encoder.c:celt_maxabs16
92
#endif
93
94
#ifndef OVERRIDE_CELT_MAXABS32
95
#ifdef FIXED_POINT
96
static OPUS_INLINE opus_val32 celt_maxabs32(const opus_val32 *x, int len)
97
975M
{
98
975M
   int i;
99
975M
   opus_val32 maxval = 0;
100
975M
   opus_val32 minval = 0;
101
12.9G
   for (i=0;i<len;i++)
102
11.9G
   {
103
11.9G
      maxval = MAX32(maxval, x[i]);
104
11.9G
      minval = MIN32(minval, x[i]);
105
11.9G
   }
106
975M
   return MAX32(maxval, -minval);
107
975M
}
Unexecuted instantiation: opus_multistream_encoder.c:celt_maxabs32
bands.c:celt_maxabs32
Line
Count
Source
97
969M
{
98
969M
   int i;
99
969M
   opus_val32 maxval = 0;
100
969M
   opus_val32 minval = 0;
101
7.07G
   for (i=0;i<len;i++)
102
6.10G
   {
103
6.10G
      maxval = MAX32(maxval, x[i]);
104
6.10G
      minval = MIN32(minval, x[i]);
105
6.10G
   }
106
969M
   return MAX32(maxval, -minval);
107
969M
}
Unexecuted instantiation: celt.c:celt_maxabs32
Unexecuted instantiation: celt_encoder.c:celt_maxabs32
Unexecuted instantiation: mathops.c:celt_maxabs32
Unexecuted instantiation: mdct.c:celt_maxabs32
Unexecuted instantiation: modes.c:celt_maxabs32
pitch.c:celt_maxabs32
Line
Count
Source
97
1.44M
{
98
1.44M
   int i;
99
1.44M
   opus_val32 maxval = 0;
100
1.44M
   opus_val32 minval = 0;
101
2.31G
   for (i=0;i<len;i++)
102
2.31G
   {
103
2.31G
      maxval = MAX32(maxval, x[i]);
104
2.31G
      minval = MIN32(minval, x[i]);
105
2.31G
   }
106
1.44M
   return MAX32(maxval, -minval);
107
1.44M
}
Unexecuted instantiation: celt_lpc.c:celt_maxabs32
Unexecuted instantiation: quant_bands.c:celt_maxabs32
Unexecuted instantiation: vq.c:celt_maxabs32
Unexecuted instantiation: pitch_sse2.c:celt_maxabs32
Unexecuted instantiation: celt_lpc_sse4_1.c:celt_maxabs32
Unexecuted instantiation: pitch_sse4_1.c:celt_maxabs32
Unexecuted instantiation: opus_decoder.c:celt_maxabs32
Unexecuted instantiation: opus_encoder.c:celt_maxabs32
analysis.c:celt_maxabs32
Line
Count
Source
97
4.93M
{
98
4.93M
   int i;
99
4.93M
   opus_val32 maxval = 0;
100
4.93M
   opus_val32 minval = 0;
101
3.55G
   for (i=0;i<len;i++)
102
3.55G
   {
103
3.55G
      maxval = MAX32(maxval, x[i]);
104
3.55G
      minval = MIN32(minval, x[i]);
105
3.55G
   }
106
4.93M
   return MAX32(maxval, -minval);
107
4.93M
}
Unexecuted instantiation: celt_decoder.c:celt_maxabs32
Unexecuted instantiation: cwrs.c:celt_maxabs32
Unexecuted instantiation: kiss_fft.c:celt_maxabs32
Unexecuted instantiation: laplace.c:celt_maxabs32
Unexecuted instantiation: opus_projection_encoder.c:celt_maxabs32
Unexecuted instantiation: opus_projection_decoder.c:celt_maxabs32
108
#else
109
#define celt_maxabs32(x,len) celt_maxabs16(x,len)
110
#endif
111
#endif
112
113
114
#ifndef FIXED_POINT
115
116
584M
#define celt_sqrt(x) ((float)sqrt(x))
117
645k
#define celt_rsqrt(x) (1.f/celt_sqrt(x))
118
623k
#define celt_rsqrt_norm(x) (celt_rsqrt(x))
119
30.7M
#define celt_cos_norm(x) ((float)cos((.5f*PI)*(x)))
120
59.2k
#define celt_rcp(x) (1.f/(x))
121
15.3M
#define celt_div(a,b) ((a)/(b))
122
439k
#define frac_div32(a,b) ((float)(a)/(b))
123
124
#ifdef FLOAT_APPROX
125
126
/* Note: This assumes radix-2 floating point with the exponent at bits 23..30 and an offset of 127
127
         denorm, +/- inf and NaN are *not* handled */
128
129
/** Base-2 log approximation (log2(x)). */
130
static OPUS_INLINE float celt_log2(float x)
131
1.91M
{
132
1.91M
   int integer;
133
1.91M
   float frac;
134
1.91M
   union {
135
1.91M
      float f;
136
1.91M
      opus_uint32 i;
137
1.91M
   } in;
138
1.91M
   in.f = x;
139
1.91M
   integer = (in.i>>23)-127;
140
1.91M
   in.i -= (opus_uint32)integer<<23;
141
1.91M
   frac = in.f - 1.5f;
142
1.91M
   frac = -0.41445418f + frac*(0.95909232f
143
1.91M
          + frac*(-0.33951290f + frac*0.16541097f));
144
1.91M
   return 1+integer+frac;
145
1.91M
}
opus_multistream_encoder.c:celt_log2
Line
Count
Source
131
558
{
132
558
   int integer;
133
558
   float frac;
134
558
   union {
135
558
      float f;
136
558
      opus_uint32 i;
137
558
   } in;
138
558
   in.f = x;
139
558
   integer = (in.i>>23)-127;
140
558
   in.i -= (opus_uint32)integer<<23;
141
558
   frac = in.f - 1.5f;
142
558
   frac = -0.41445418f + frac*(0.95909232f
143
558
          + frac*(-0.33951290f + frac*0.16541097f));
144
558
   return 1+integer+frac;
145
558
}
celt_encoder.c:celt_log2
Line
Count
Source
131
43.4k
{
132
43.4k
   int integer;
133
43.4k
   float frac;
134
43.4k
   union {
135
43.4k
      float f;
136
43.4k
      opus_uint32 i;
137
43.4k
   } in;
138
43.4k
   in.f = x;
139
43.4k
   integer = (in.i>>23)-127;
140
43.4k
   in.i -= (opus_uint32)integer<<23;
141
43.4k
   frac = in.f - 1.5f;
142
43.4k
   frac = -0.41445418f + frac*(0.95909232f
143
43.4k
          + frac*(-0.33951290f + frac*0.16541097f));
144
43.4k
   return 1+integer+frac;
145
43.4k
}
quant_bands.c:celt_log2
Line
Count
Source
131
1.87M
{
132
1.87M
   int integer;
133
1.87M
   float frac;
134
1.87M
   union {
135
1.87M
      float f;
136
1.87M
      opus_uint32 i;
137
1.87M
   } in;
138
1.87M
   in.f = x;
139
1.87M
   integer = (in.i>>23)-127;
140
1.87M
   in.i -= (opus_uint32)integer<<23;
141
1.87M
   frac = in.f - 1.5f;
142
1.87M
   frac = -0.41445418f + frac*(0.95909232f
143
1.87M
          + frac*(-0.33951290f + frac*0.16541097f));
144
1.87M
   return 1+integer+frac;
145
1.87M
}
Unexecuted instantiation: pitch_sse.c:celt_log2
Unexecuted instantiation: vq_sse2.c:celt_log2
Unexecuted instantiation: opus_projection_decoder.c:celt_log2
Unexecuted instantiation: opus_projection_encoder.c:celt_log2
146
147
/** Base-2 exponential approximation (2^x). */
148
static OPUS_INLINE float celt_exp2(float x)
149
1.71M
{
150
1.71M
   int integer;
151
1.71M
   float frac;
152
1.71M
   union {
153
1.71M
      float f;
154
1.71M
      opus_uint32 i;
155
1.71M
   } res;
156
1.71M
   integer = (int)floor(x);
157
1.71M
   if (integer < -50)
158
1.63k
      return 0;
159
1.71M
   frac = x-integer;
160
   /* K0 = 1, K1 = log(2), K2 = 3-4*log(2), K3 = 3*log(2) - 2 */
161
1.71M
   res.f = 0.99992522f + frac * (0.69583354f
162
1.71M
           + frac * (0.22606716f + 0.078024523f*frac));
163
1.71M
   res.i = (res.i + ((opus_uint32)integer<<23)) & 0x7fffffff;
164
1.71M
   return res.f;
165
1.71M
}
bands.c:celt_exp2
Line
Count
Source
149
1.28M
{
150
1.28M
   int integer;
151
1.28M
   float frac;
152
1.28M
   union {
153
1.28M
      float f;
154
1.28M
      opus_uint32 i;
155
1.28M
   } res;
156
1.28M
   integer = (int)floor(x);
157
1.28M
   if (integer < -50)
158
1.55k
      return 0;
159
1.28M
   frac = x-integer;
160
   /* K0 = 1, K1 = log(2), K2 = 3-4*log(2), K3 = 3*log(2) - 2 */
161
1.28M
   res.f = 0.99992522f + frac * (0.69583354f
162
1.28M
           + frac * (0.22606716f + 0.078024523f*frac));
163
1.28M
   res.i = (res.i + ((opus_uint32)integer<<23)) & 0x7fffffff;
164
1.28M
   return res.f;
165
1.28M
}
celt_encoder.c:celt_exp2
Line
Count
Source
149
423k
{
150
423k
   int integer;
151
423k
   float frac;
152
423k
   union {
153
423k
      float f;
154
423k
      opus_uint32 i;
155
423k
   } res;
156
423k
   integer = (int)floor(x);
157
423k
   if (integer < -50)
158
0
      return 0;
159
423k
   frac = x-integer;
160
   /* K0 = 1, K1 = log(2), K2 = 3-4*log(2), K3 = 3*log(2) - 2 */
161
423k
   res.f = 0.99992522f + frac * (0.69583354f
162
423k
           + frac * (0.22606716f + 0.078024523f*frac));
163
423k
   res.i = (res.i + ((opus_uint32)integer<<23)) & 0x7fffffff;
164
423k
   return res.f;
165
423k
}
Unexecuted instantiation: pitch_sse.c:celt_exp2
Unexecuted instantiation: vq_sse2.c:celt_exp2
Unexecuted instantiation: opus_decoder.c:celt_exp2
opus_encoder.c:celt_exp2
Line
Count
Source
149
4.28k
{
150
4.28k
   int integer;
151
4.28k
   float frac;
152
4.28k
   union {
153
4.28k
      float f;
154
4.28k
      opus_uint32 i;
155
4.28k
   } res;
156
4.28k
   integer = (int)floor(x);
157
4.28k
   if (integer < -50)
158
89
      return 0;
159
4.19k
   frac = x-integer;
160
   /* K0 = 1, K1 = log(2), K2 = 3-4*log(2), K3 = 3*log(2) - 2 */
161
4.19k
   res.f = 0.99992522f + frac * (0.69583354f
162
4.19k
           + frac * (0.22606716f + 0.078024523f*frac));
163
4.19k
   res.i = (res.i + ((opus_uint32)integer<<23)) & 0x7fffffff;
164
4.19k
   return res.f;
165
4.28k
}
Unexecuted instantiation: opus_projection_decoder.c:celt_exp2
Unexecuted instantiation: opus_projection_encoder.c:celt_exp2
166
167
#else
168
#define celt_log2(x) ((float)(1.442695040888963387*log(x)))
169
#define celt_exp2(x) ((float)exp(0.6931471805599453094*(x)))
170
#endif
171
172
#endif
173
174
#ifdef FIXED_POINT
175
176
#include "os_support.h"
177
178
#ifndef OVERRIDE_CELT_ILOG2
179
/** Integer log in base2. Undefined for zero and negative numbers */
180
static OPUS_INLINE opus_int16 celt_ilog2(opus_int32 x)
181
5.21G
{
182
5.21G
   celt_sig_assert(x>0);
183
5.21G
   return EC_ILOG(x)-1;
184
5.21G
}
opus_multistream_encoder.c:celt_ilog2
Line
Count
Source
181
625
{
182
625
   celt_sig_assert(x>0);
183
625
   return EC_ILOG(x)-1;
184
625
}
bands.c:celt_ilog2
Line
Count
Source
181
1.40G
{
182
1.40G
   celt_sig_assert(x>0);
183
1.40G
   return EC_ILOG(x)-1;
184
1.40G
}
Unexecuted instantiation: celt.c:celt_ilog2
celt_encoder.c:celt_ilog2
Line
Count
Source
181
59.4M
{
182
59.4M
   celt_sig_assert(x>0);
183
59.4M
   return EC_ILOG(x)-1;
184
59.4M
}
mathops.c:celt_ilog2
Line
Count
Source
181
2.22G
{
182
2.22G
   celt_sig_assert(x>0);
183
2.22G
   return EC_ILOG(x)-1;
184
2.22G
}
Unexecuted instantiation: mdct.c:celt_ilog2
Unexecuted instantiation: modes.c:celt_ilog2
pitch.c:celt_ilog2
Line
Count
Source
181
34.8M
{
182
34.8M
   celt_sig_assert(x>0);
183
34.8M
   return EC_ILOG(x)-1;
184
34.8M
}
celt_lpc.c:celt_ilog2
Line
Count
Source
181
58.5M
{
182
58.5M
   celt_sig_assert(x>0);
183
58.5M
   return EC_ILOG(x)-1;
184
58.5M
}
quant_bands.c:celt_ilog2
Line
Count
Source
181
969M
{
182
969M
   celt_sig_assert(x>0);
183
969M
   return EC_ILOG(x)-1;
184
969M
}
vq.c:celt_ilog2
Line
Count
Source
181
419M
{
182
419M
   celt_sig_assert(x>0);
183
419M
   return EC_ILOG(x)-1;
184
419M
}
Unexecuted instantiation: pitch_sse2.c:celt_ilog2
Unexecuted instantiation: celt_lpc_sse4_1.c:celt_ilog2
Unexecuted instantiation: pitch_sse4_1.c:celt_ilog2
Unexecuted instantiation: opus_decoder.c:celt_ilog2
opus_encoder.c:celt_ilog2
Line
Count
Source
181
43.2M
{
182
43.2M
   celt_sig_assert(x>0);
183
43.2M
   return EC_ILOG(x)-1;
184
43.2M
}
Unexecuted instantiation: analysis.c:celt_ilog2
celt_decoder.c:celt_ilog2
Line
Count
Source
181
67.4k
{
182
67.4k
   celt_sig_assert(x>0);
183
67.4k
   return EC_ILOG(x)-1;
184
67.4k
}
Unexecuted instantiation: cwrs.c:celt_ilog2
Unexecuted instantiation: kiss_fft.c:celt_ilog2
Unexecuted instantiation: laplace.c:celt_ilog2
Unexecuted instantiation: opus_projection_encoder.c:celt_ilog2
Unexecuted instantiation: opus_projection_decoder.c:celt_ilog2
185
#endif
186
187
188
/** Integer log in base2. Defined for zero, but not for negative numbers */
189
static OPUS_INLINE opus_int16 celt_zlog2(opus_val32 x)
190
1.14G
{
191
1.14G
   return x <= 0 ? 0 : celt_ilog2(x);
192
1.14G
}
Unexecuted instantiation: opus_multistream_encoder.c:celt_zlog2
bands.c:celt_zlog2
Line
Count
Source
190
1.14G
{
191
1.14G
   return x <= 0 ? 0 : celt_ilog2(x);
192
1.14G
}
Unexecuted instantiation: celt.c:celt_zlog2
Unexecuted instantiation: celt_encoder.c:celt_zlog2
Unexecuted instantiation: mathops.c:celt_zlog2
Unexecuted instantiation: mdct.c:celt_zlog2
Unexecuted instantiation: modes.c:celt_zlog2
Unexecuted instantiation: pitch.c:celt_zlog2
Unexecuted instantiation: celt_lpc.c:celt_zlog2
Unexecuted instantiation: quant_bands.c:celt_zlog2
Unexecuted instantiation: vq.c:celt_zlog2
Unexecuted instantiation: pitch_sse2.c:celt_zlog2
Unexecuted instantiation: celt_lpc_sse4_1.c:celt_zlog2
Unexecuted instantiation: pitch_sse4_1.c:celt_zlog2
Unexecuted instantiation: opus_decoder.c:celt_zlog2
Unexecuted instantiation: opus_encoder.c:celt_zlog2
Unexecuted instantiation: analysis.c:celt_zlog2
celt_decoder.c:celt_zlog2
Line
Count
Source
190
83.0k
{
191
83.0k
   return x <= 0 ? 0 : celt_ilog2(x);
192
83.0k
}
Unexecuted instantiation: cwrs.c:celt_zlog2
Unexecuted instantiation: kiss_fft.c:celt_zlog2
Unexecuted instantiation: laplace.c:celt_zlog2
Unexecuted instantiation: opus_projection_encoder.c:celt_zlog2
Unexecuted instantiation: opus_projection_decoder.c:celt_zlog2
193
194
opus_val16 celt_rsqrt_norm(opus_val32 x);
195
196
opus_val32 celt_sqrt(opus_val32 x);
197
198
opus_val16 celt_cos_norm(opus_val32 x);
199
200
/** Base-2 logarithm approximation (log2(x)). (Q14 input, Q10 output) */
201
static OPUS_INLINE opus_val16 celt_log2(opus_val32 x)
202
973M
{
203
973M
   int i;
204
973M
   opus_val16 n, frac;
205
   /* -0.41509302963303146, 0.9609890551383969, -0.31836011537636605,
206
       0.15530808010959576, -0.08556153059057618 */
207
973M
   static const opus_val16 C[5] = {-6801+(1<<(13-DB_SHIFT)), 15746, -5217, 2545, -1401};
208
973M
   if (x==0)
209
0
      return -32767;
210
973M
   i = celt_ilog2(x);
211
973M
   n = VSHR32(x,i-15)-32768-16384;
212
973M
   frac = ADD16(C[0], MULT16_16_Q15(n, ADD16(C[1], MULT16_16_Q15(n, ADD16(C[2], MULT16_16_Q15(n, ADD16(C[3], MULT16_16_Q15(n, C[4]))))))));
213
973M
   return SHL16(i-13,DB_SHIFT)+SHR16(frac,14-DB_SHIFT);
214
973M
}
opus_multistream_encoder.c:celt_log2
Line
Count
Source
202
625
{
203
625
   int i;
204
625
   opus_val16 n, frac;
205
   /* -0.41509302963303146, 0.9609890551383969, -0.31836011537636605,
206
       0.15530808010959576, -0.08556153059057618 */
207
625
   static const opus_val16 C[5] = {-6801+(1<<(13-DB_SHIFT)), 15746, -5217, 2545, -1401};
208
625
   if (x==0)
209
0
      return -32767;
210
625
   i = celt_ilog2(x);
211
625
   n = VSHR32(x,i-15)-32768-16384;
212
625
   frac = ADD16(C[0], MULT16_16_Q15(n, ADD16(C[1], MULT16_16_Q15(n, ADD16(C[2], MULT16_16_Q15(n, ADD16(C[3], MULT16_16_Q15(n, C[4]))))))));
213
625
   return SHL16(i-13,DB_SHIFT)+SHR16(frac,14-DB_SHIFT);
214
625
}
Unexecuted instantiation: bands.c:celt_log2
Unexecuted instantiation: celt.c:celt_log2
celt_encoder.c:celt_log2
Line
Count
Source
202
3.96M
{
203
3.96M
   int i;
204
3.96M
   opus_val16 n, frac;
205
   /* -0.41509302963303146, 0.9609890551383969, -0.31836011537636605,
206
       0.15530808010959576, -0.08556153059057618 */
207
3.96M
   static const opus_val16 C[5] = {-6801+(1<<(13-DB_SHIFT)), 15746, -5217, 2545, -1401};
208
3.96M
   if (x==0)
209
0
      return -32767;
210
3.96M
   i = celt_ilog2(x);
211
3.96M
   n = VSHR32(x,i-15)-32768-16384;
212
3.96M
   frac = ADD16(C[0], MULT16_16_Q15(n, ADD16(C[1], MULT16_16_Q15(n, ADD16(C[2], MULT16_16_Q15(n, ADD16(C[3], MULT16_16_Q15(n, C[4]))))))));
213
3.96M
   return SHL16(i-13,DB_SHIFT)+SHR16(frac,14-DB_SHIFT);
214
3.96M
}
Unexecuted instantiation: mathops.c:celt_log2
Unexecuted instantiation: mdct.c:celt_log2
Unexecuted instantiation: modes.c:celt_log2
Unexecuted instantiation: pitch.c:celt_log2
Unexecuted instantiation: celt_lpc.c:celt_log2
quant_bands.c:celt_log2
Line
Count
Source
202
969M
{
203
969M
   int i;
204
969M
   opus_val16 n, frac;
205
   /* -0.41509302963303146, 0.9609890551383969, -0.31836011537636605,
206
       0.15530808010959576, -0.08556153059057618 */
207
969M
   static const opus_val16 C[5] = {-6801+(1<<(13-DB_SHIFT)), 15746, -5217, 2545, -1401};
208
969M
   if (x==0)
209
0
      return -32767;
210
969M
   i = celt_ilog2(x);
211
969M
   n = VSHR32(x,i-15)-32768-16384;
212
969M
   frac = ADD16(C[0], MULT16_16_Q15(n, ADD16(C[1], MULT16_16_Q15(n, ADD16(C[2], MULT16_16_Q15(n, ADD16(C[3], MULT16_16_Q15(n, C[4]))))))));
213
969M
   return SHL16(i-13,DB_SHIFT)+SHR16(frac,14-DB_SHIFT);
214
969M
}
Unexecuted instantiation: vq.c:celt_log2
Unexecuted instantiation: pitch_sse2.c:celt_log2
Unexecuted instantiation: celt_lpc_sse4_1.c:celt_log2
Unexecuted instantiation: pitch_sse4_1.c:celt_log2
Unexecuted instantiation: opus_decoder.c:celt_log2
Unexecuted instantiation: opus_encoder.c:celt_log2
Unexecuted instantiation: analysis.c:celt_log2
Unexecuted instantiation: celt_decoder.c:celt_log2
Unexecuted instantiation: cwrs.c:celt_log2
Unexecuted instantiation: kiss_fft.c:celt_log2
Unexecuted instantiation: laplace.c:celt_log2
215
216
/*
217
 K0 = 1
218
 K1 = log(2)
219
 K2 = 3-4*log(2)
220
 K3 = 3*log(2) - 2
221
*/
222
#define D0 16383
223
#define D1 22804
224
#define D2 14819
225
#define D3 10204
226
227
static OPUS_INLINE opus_val32 celt_exp2_frac(opus_val16 x)
228
130M
{
229
130M
   opus_val16 frac;
230
130M
   frac = SHL16(x, 4);
231
130M
   return ADD16(D0, MULT16_16_Q15(frac, ADD16(D1, MULT16_16_Q15(frac, ADD16(D2 , MULT16_16_Q15(D3,frac))))));
232
130M
}
Unexecuted instantiation: opus_multistream_encoder.c:celt_exp2_frac
bands.c:celt_exp2_frac
Line
Count
Source
228
1.75M
{
229
1.75M
   opus_val16 frac;
230
1.75M
   frac = SHL16(x, 4);
231
1.75M
   return ADD16(D0, MULT16_16_Q15(frac, ADD16(D1, MULT16_16_Q15(frac, ADD16(D2 , MULT16_16_Q15(D3,frac))))));
232
1.75M
}
Unexecuted instantiation: celt.c:celt_exp2_frac
celt_encoder.c:celt_exp2_frac
Line
Count
Source
228
126M
{
229
126M
   opus_val16 frac;
230
126M
   frac = SHL16(x, 4);
231
126M
   return ADD16(D0, MULT16_16_Q15(frac, ADD16(D1, MULT16_16_Q15(frac, ADD16(D2 , MULT16_16_Q15(D3,frac))))));
232
126M
}
Unexecuted instantiation: mathops.c:celt_exp2_frac
Unexecuted instantiation: mdct.c:celt_exp2_frac
Unexecuted instantiation: modes.c:celt_exp2_frac
Unexecuted instantiation: pitch.c:celt_exp2_frac
Unexecuted instantiation: celt_lpc.c:celt_exp2_frac
Unexecuted instantiation: quant_bands.c:celt_exp2_frac
Unexecuted instantiation: vq.c:celt_exp2_frac
Unexecuted instantiation: pitch_sse2.c:celt_exp2_frac
Unexecuted instantiation: celt_lpc_sse4_1.c:celt_exp2_frac
Unexecuted instantiation: pitch_sse4_1.c:celt_exp2_frac
Unexecuted instantiation: opus_decoder.c:celt_exp2_frac
opus_encoder.c:celt_exp2_frac
Line
Count
Source
228
1.66M
{
229
1.66M
   opus_val16 frac;
230
1.66M
   frac = SHL16(x, 4);
231
1.66M
   return ADD16(D0, MULT16_16_Q15(frac, ADD16(D1, MULT16_16_Q15(frac, ADD16(D2 , MULT16_16_Q15(D3,frac))))));
232
1.66M
}
Unexecuted instantiation: analysis.c:celt_exp2_frac
Unexecuted instantiation: celt_decoder.c:celt_exp2_frac
Unexecuted instantiation: cwrs.c:celt_exp2_frac
Unexecuted instantiation: kiss_fft.c:celt_exp2_frac
Unexecuted instantiation: laplace.c:celt_exp2_frac
Unexecuted instantiation: opus_projection_encoder.c:celt_exp2_frac
Unexecuted instantiation: opus_projection_decoder.c:celt_exp2_frac
233
234
#undef D0
235
#undef D1
236
#undef D2
237
#undef D3
238
239
/** Base-2 exponential approximation (2^x). (Q10 input, Q16 output) */
240
static OPUS_INLINE opus_val32 celt_exp2(opus_val16 x)
241
129M
{
242
129M
   int integer;
243
129M
   opus_val16 frac;
244
129M
   integer = SHR16(x,10);
245
129M
   if (integer>14)
246
76.2k
      return 0x7f000000;
247
129M
   else if (integer < -15)
248
576k
      return 0;
249
128M
   frac = celt_exp2_frac(x-SHL16(integer,10));
250
128M
   return VSHR32(EXTEND32(frac), -integer-2);
251
129M
}
Unexecuted instantiation: opus_multistream_encoder.c:celt_exp2
bands.c:celt_exp2
Line
Count
Source
241
25.9k
{
242
25.9k
   int integer;
243
25.9k
   opus_val16 frac;
244
25.9k
   integer = SHR16(x,10);
245
25.9k
   if (integer>14)
246
0
      return 0x7f000000;
247
25.9k
   else if (integer < -15)
248
503
      return 0;
249
25.4k
   frac = celt_exp2_frac(x-SHL16(integer,10));
250
25.4k
   return VSHR32(EXTEND32(frac), -integer-2);
251
25.9k
}
Unexecuted instantiation: celt.c:celt_exp2
celt_encoder.c:celt_exp2
Line
Count
Source
241
126M
{
242
126M
   int integer;
243
126M
   opus_val16 frac;
244
126M
   integer = SHR16(x,10);
245
126M
   if (integer>14)
246
0
      return 0x7f000000;
247
126M
   else if (integer < -15)
248
0
      return 0;
249
126M
   frac = celt_exp2_frac(x-SHL16(integer,10));
250
126M
   return VSHR32(EXTEND32(frac), -integer-2);
251
126M
}
Unexecuted instantiation: mathops.c:celt_exp2
Unexecuted instantiation: mdct.c:celt_exp2
Unexecuted instantiation: modes.c:celt_exp2
Unexecuted instantiation: pitch.c:celt_exp2
Unexecuted instantiation: celt_lpc.c:celt_exp2
Unexecuted instantiation: quant_bands.c:celt_exp2
Unexecuted instantiation: vq.c:celt_exp2
Unexecuted instantiation: pitch_sse2.c:celt_exp2
Unexecuted instantiation: celt_lpc_sse4_1.c:celt_exp2
Unexecuted instantiation: pitch_sse4_1.c:celt_exp2
Unexecuted instantiation: opus_decoder.c:celt_exp2
opus_encoder.c:celt_exp2
Line
Count
Source
241
2.31M
{
242
2.31M
   int integer;
243
2.31M
   opus_val16 frac;
244
2.31M
   integer = SHR16(x,10);
245
2.31M
   if (integer>14)
246
76.2k
      return 0x7f000000;
247
2.23M
   else if (integer < -15)
248
576k
      return 0;
249
1.66M
   frac = celt_exp2_frac(x-SHL16(integer,10));
250
1.66M
   return VSHR32(EXTEND32(frac), -integer-2);
251
2.31M
}
Unexecuted instantiation: analysis.c:celt_exp2
Unexecuted instantiation: celt_decoder.c:celt_exp2
Unexecuted instantiation: cwrs.c:celt_exp2
Unexecuted instantiation: kiss_fft.c:celt_exp2
Unexecuted instantiation: laplace.c:celt_exp2
252
253
opus_val32 celt_rcp(opus_val32 x);
254
255
251M
#define celt_div(a,b) MULT32_32_Q31((opus_val32)(a),celt_rcp(b))
256
257
opus_val32 frac_div32(opus_val32 a, opus_val32 b);
258
259
#define M1 32767
260
#define M2 -21
261
#define M3 -11943
262
#define M4 4936
263
264
/* Atan approximation using a 4th order polynomial. Input is in Q15 format
265
   and normalized by pi/4. Output is in Q15 format */
266
static OPUS_INLINE opus_val16 celt_atan01(opus_val16 x)
267
236M
{
268
236M
   return MULT16_16_P15(x, ADD32(M1, MULT16_16_P15(x, ADD32(M2, MULT16_16_P15(x, ADD32(M3, MULT16_16_P15(M4, x)))))));
269
236M
}
Unexecuted instantiation: opus_multistream_encoder.c:celt_atan01
Unexecuted instantiation: bands.c:celt_atan01
Unexecuted instantiation: celt.c:celt_atan01
Unexecuted instantiation: celt_encoder.c:celt_atan01
Unexecuted instantiation: mathops.c:celt_atan01
Unexecuted instantiation: mdct.c:celt_atan01
Unexecuted instantiation: modes.c:celt_atan01
Unexecuted instantiation: pitch.c:celt_atan01
Unexecuted instantiation: celt_lpc.c:celt_atan01
Unexecuted instantiation: quant_bands.c:celt_atan01
vq.c:celt_atan01
Line
Count
Source
267
236M
{
268
236M
   return MULT16_16_P15(x, ADD32(M1, MULT16_16_P15(x, ADD32(M2, MULT16_16_P15(x, ADD32(M3, MULT16_16_P15(M4, x)))))));
269
236M
}
Unexecuted instantiation: pitch_sse2.c:celt_atan01
Unexecuted instantiation: celt_lpc_sse4_1.c:celt_atan01
Unexecuted instantiation: pitch_sse4_1.c:celt_atan01
Unexecuted instantiation: opus_decoder.c:celt_atan01
Unexecuted instantiation: opus_encoder.c:celt_atan01
Unexecuted instantiation: analysis.c:celt_atan01
Unexecuted instantiation: celt_decoder.c:celt_atan01
Unexecuted instantiation: cwrs.c:celt_atan01
Unexecuted instantiation: kiss_fft.c:celt_atan01
Unexecuted instantiation: laplace.c:celt_atan01
Unexecuted instantiation: opus_projection_encoder.c:celt_atan01
Unexecuted instantiation: opus_projection_decoder.c:celt_atan01
270
271
#undef M1
272
#undef M2
273
#undef M3
274
#undef M4
275
276
/* atan2() approximation valid for positive input values */
277
static OPUS_INLINE opus_val16 celt_atan2p(opus_val16 y, opus_val16 x)
278
236M
{
279
236M
   if (y < x)
280
30.3M
   {
281
30.3M
      opus_val32 arg;
282
30.3M
      arg = celt_div(SHL32(EXTEND32(y),15),x);
283
30.3M
      if (arg >= 32767)
284
0
         arg = 32767;
285
30.3M
      return SHR16(celt_atan01(EXTRACT16(arg)),1);
286
206M
   } else {
287
206M
      opus_val32 arg;
288
206M
      arg = celt_div(SHL32(EXTEND32(x),15),y);
289
206M
      if (arg >= 32767)
290
186M
         arg = 32767;
291
206M
      return 25736-SHR16(celt_atan01(EXTRACT16(arg)),1);
292
206M
   }
293
236M
}
Unexecuted instantiation: opus_multistream_encoder.c:celt_atan2p
Unexecuted instantiation: bands.c:celt_atan2p
Unexecuted instantiation: celt.c:celt_atan2p
Unexecuted instantiation: celt_encoder.c:celt_atan2p
Unexecuted instantiation: mathops.c:celt_atan2p
Unexecuted instantiation: mdct.c:celt_atan2p
Unexecuted instantiation: modes.c:celt_atan2p
Unexecuted instantiation: pitch.c:celt_atan2p
Unexecuted instantiation: celt_lpc.c:celt_atan2p
Unexecuted instantiation: quant_bands.c:celt_atan2p
vq.c:celt_atan2p
Line
Count
Source
278
236M
{
279
236M
   if (y < x)
280
30.3M
   {
281
30.3M
      opus_val32 arg;
282
30.3M
      arg = celt_div(SHL32(EXTEND32(y),15),x);
283
30.3M
      if (arg >= 32767)
284
0
         arg = 32767;
285
30.3M
      return SHR16(celt_atan01(EXTRACT16(arg)),1);
286
206M
   } else {
287
206M
      opus_val32 arg;
288
206M
      arg = celt_div(SHL32(EXTEND32(x),15),y);
289
206M
      if (arg >= 32767)
290
186M
         arg = 32767;
291
206M
      return 25736-SHR16(celt_atan01(EXTRACT16(arg)),1);
292
206M
   }
293
236M
}
Unexecuted instantiation: pitch_sse2.c:celt_atan2p
Unexecuted instantiation: celt_lpc_sse4_1.c:celt_atan2p
Unexecuted instantiation: pitch_sse4_1.c:celt_atan2p
Unexecuted instantiation: opus_decoder.c:celt_atan2p
Unexecuted instantiation: opus_encoder.c:celt_atan2p
Unexecuted instantiation: analysis.c:celt_atan2p
Unexecuted instantiation: celt_decoder.c:celt_atan2p
Unexecuted instantiation: cwrs.c:celt_atan2p
Unexecuted instantiation: kiss_fft.c:celt_atan2p
Unexecuted instantiation: laplace.c:celt_atan2p
Unexecuted instantiation: opus_projection_encoder.c:celt_atan2p
Unexecuted instantiation: opus_projection_decoder.c:celt_atan2p
294
295
#endif /* FIXED_POINT */
296
#endif /* MATHOPS_H */