Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: third_party/opus/src/celt/mathops.h

Issue 2962373002: [Opus] Update to v1.2.1 (Closed)
Patch Set: Pre-increment instead of post-increment Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/opus/src/celt/kiss_fft.c ('k') | third_party/opus/src/celt/mdct.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2002-2008 Jean-Marc Valin 1 /* Copyright (c) 2002-2008 Jean-Marc Valin
2 Copyright (c) 2007-2008 CSIRO 2 Copyright (c) 2007-2008 CSIRO
3 Copyright (c) 2007-2009 Xiph.Org Foundation 3 Copyright (c) 2007-2009 Xiph.Org Foundation
4 Written by Jean-Marc Valin */ 4 Written by Jean-Marc Valin */
5 /** 5 /**
6 @file mathops.h 6 @file mathops.h
7 @brief Various math functions 7 @brief Various math functions
8 */ 8 */
9 /* 9 /*
10 Redistribution and use in source and binary forms, with or without 10 Redistribution and use in source and binary forms, with or without
(...skipping 20 matching lines...) Expand all
31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34 #ifndef MATHOPS_H 34 #ifndef MATHOPS_H
35 #define MATHOPS_H 35 #define MATHOPS_H
36 36
37 #include "arch.h" 37 #include "arch.h"
38 #include "entcode.h" 38 #include "entcode.h"
39 #include "os_support.h" 39 #include "os_support.h"
40 40
41 #define PI 3.141592653f
42
41 /* Multiplies two 16-bit fractional values. Bit-exactness of this macro is impor tant */ 43 /* Multiplies two 16-bit fractional values. Bit-exactness of this macro is impor tant */
42 #define FRAC_MUL16(a,b) ((16384+((opus_int32)(opus_int16)(a)*(opus_int16)(b)))>> 15) 44 #define FRAC_MUL16(a,b) ((16384+((opus_int32)(opus_int16)(a)*(opus_int16)(b)))>> 15)
43 45
44 unsigned isqrt32(opus_uint32 _val); 46 unsigned isqrt32(opus_uint32 _val);
45 47
48 /* CELT doesn't need it for fixed-point, by analysis.c does. */
49 #if !defined(FIXED_POINT) || defined(ANALYSIS_C)
50 #define cA 0.43157974f
51 #define cB 0.67848403f
52 #define cC 0.08595542f
53 #define cE ((float)PI/2)
54 static OPUS_INLINE float fast_atan2f(float y, float x) {
55 float x2, y2;
56 x2 = x*x;
57 y2 = y*y;
58 /* For very small values, we don't care about the answer, so
59 we can just return 0. */
60 if (x2 + y2 < 1e-18f)
61 {
62 return 0;
63 }
64 if(x2<y2){
65 float den = (y2 + cB*x2) * (y2 + cC*x2);
66 return -x*y*(y2 + cA*x2) / den + (y<0 ? -cE : cE);
67 }else{
68 float den = (x2 + cB*y2) * (x2 + cC*y2);
69 return x*y*(x2 + cA*y2) / den + (y<0 ? -cE : cE) - (x*y<0 ? -cE : cE);
70 }
71 }
72 #undef cA
73 #undef cB
74 #undef cC
75 #undef cD
76 #endif
77
78
46 #ifndef OVERRIDE_CELT_MAXABS16 79 #ifndef OVERRIDE_CELT_MAXABS16
47 static OPUS_INLINE opus_val32 celt_maxabs16(const opus_val16 *x, int len) 80 static OPUS_INLINE opus_val32 celt_maxabs16(const opus_val16 *x, int len)
48 { 81 {
49 int i; 82 int i;
50 opus_val16 maxval = 0; 83 opus_val16 maxval = 0;
51 opus_val16 minval = 0; 84 opus_val16 minval = 0;
52 for (i=0;i<len;i++) 85 for (i=0;i<len;i++)
53 { 86 {
54 maxval = MAX16(maxval, x[i]); 87 maxval = MAX16(maxval, x[i]);
55 minval = MIN16(minval, x[i]); 88 minval = MIN16(minval, x[i]);
(...skipping 17 matching lines...) Expand all
73 return MAX32(maxval, -minval); 106 return MAX32(maxval, -minval);
74 } 107 }
75 #else 108 #else
76 #define celt_maxabs32(x,len) celt_maxabs16(x,len) 109 #define celt_maxabs32(x,len) celt_maxabs16(x,len)
77 #endif 110 #endif
78 #endif 111 #endif
79 112
80 113
81 #ifndef FIXED_POINT 114 #ifndef FIXED_POINT
82 115
83 #define PI 3.141592653f
84 #define celt_sqrt(x) ((float)sqrt(x)) 116 #define celt_sqrt(x) ((float)sqrt(x))
85 #define celt_rsqrt(x) (1.f/celt_sqrt(x)) 117 #define celt_rsqrt(x) (1.f/celt_sqrt(x))
86 #define celt_rsqrt_norm(x) (celt_rsqrt(x)) 118 #define celt_rsqrt_norm(x) (celt_rsqrt(x))
87 #define celt_cos_norm(x) ((float)cos((.5f*PI)*(x))) 119 #define celt_cos_norm(x) ((float)cos((.5f*PI)*(x)))
88 #define celt_rcp(x) (1.f/(x)) 120 #define celt_rcp(x) (1.f/(x))
89 #define celt_div(a,b) ((a)/(b)) 121 #define celt_div(a,b) ((a)/(b))
90 #define frac_div32(a,b) ((float)(a)/(b)) 122 #define frac_div32(a,b) ((float)(a)/(b))
91 123
92 #ifdef FLOAT_APPROX 124 #ifdef FLOAT_APPROX
93 125
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 opus_val32 arg; 281 opus_val32 arg;
250 arg = celt_div(SHL32(EXTEND32(x),15),y); 282 arg = celt_div(SHL32(EXTEND32(x),15),y);
251 if (arg >= 32767) 283 if (arg >= 32767)
252 arg = 32767; 284 arg = 32767;
253 return 25736-SHR16(celt_atan01(EXTRACT16(arg)),1); 285 return 25736-SHR16(celt_atan01(EXTRACT16(arg)),1);
254 } 286 }
255 } 287 }
256 288
257 #endif /* FIXED_POINT */ 289 #endif /* FIXED_POINT */
258 #endif /* MATHOPS_H */ 290 #endif /* MATHOPS_H */
OLDNEW
« no previous file with comments | « third_party/opus/src/celt/kiss_fft.c ('k') | third_party/opus/src/celt/mdct.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698