diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2016-08-11 11:05:51 -0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2016-08-11 11:05:51 -0400 |
commit | 2ff6556f1fbf93be4f58b3e132859082941890f8 (patch) | |
tree | 43094e6ae60aa1d9b14dcc8c9e15173dea3a3dbe /celt/mathops.h | |
parent | 76674feae22db03848a40446beb2fcec70d2180d (diff) | |
download | opus-2ff6556f1fbf93be4f58b3e132859082941890f8.tar.gz |
Making stereo_itheta() use the same atan2() approximation as tonality_analysis()
Diffstat (limited to 'celt/mathops.h')
-rw-r--r-- | celt/mathops.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/celt/mathops.h b/celt/mathops.h index a0525a96..948df655 100644 --- a/celt/mathops.h +++ b/celt/mathops.h @@ -43,6 +43,37 @@ unsigned isqrt32(opus_uint32 _val); +/* CELT doesn't need it for fixed-point, by analysis.c does. */ +#if !defined(FIXED_POINT) || defined(ANALYSIS_C) +#define cA 0.43157974f +#define cB 0.67848403f +#define cC 0.08595542f +#define cE ((float)M_PI/2) +static OPUS_INLINE float fast_atan2f(float y, float x) { + float x2, y2; + x2 = x*x; + y2 = y*y; + /* For very small values, we don't care about the answer, so + we can just return 0. */ + if (x2 + y2 < 1e-18f) + { + return 0; + } + if(x2<y2){ + float den = (y2 + cB*x2) * (y2 + cC*x2); + return -x*y*(y2 + cA*x2) / den + (y<0 ? -cE : cE); + }else{ + float den = (x2 + cB*y2) * (x2 + cC*y2); + return x*y*(x2 + cA*y2) / den + (y<0 ? -cE : cE) - (x*y<0 ? -cE : cE); + } +} +#undef cA +#undef cB +#undef cC +#undef cD +#endif + + #ifndef OVERRIDE_CELT_MAXABS16 static OPUS_INLINE opus_val32 celt_maxabs16(const opus_val16 *x, int len) { |