#### /project/jni/sdl-1.3/src/video/android/atan2i.h

https://github.com/aichunyu/FFPlayer
C Header | 36 lines | 29 code | 5 blank | 2 comment | 4 complexity | 5863bb864ba08a2d1bb4b13b00e420cf MD5 | raw file
``` 1#ifndef __ATAN2I_H__
2#define __ATAN2I_H__
3#include <math.h>
4
5// Fast arctan2, returns angle in radians as integer, with fractional part in lower 16 bits
6// Stolen from http://www.dspguru.com/dsp/tricks/fixed-point-atan2-with-self-normalization , precision is said to be 0.07 rads
7
8#ifndef M_PI
9#define M_PI 3.14159265358979323846
10#endif
11enum { atan2i_coeff_1 = ((int)(M_PI*65536.0/4)), atan2i_coeff_2 = (3*atan2i_coeff_1), atan2i_PI = (int)(M_PI * 65536.0) };
12
13static inline int atan2i(int y, int x)
14{
15   int angle;
16   int abs_y = abs(y);
17   if( abs_y == 0 )
18      abs_y = 1;
19   if (x>=0)
20   {
21      angle = atan2i_coeff_1 - atan2i_coeff_1 * (x - abs_y) / (x + abs_y);
22   }
23   else
24   {
25      angle = atan2i_coeff_2 - atan2i_coeff_1 * (x + abs_y) / (abs_y - x);
26   }
27   if (y < 0)
28      return(-angle);     // negate if in quad III or IV
29   else
30      return(angle);
31};
32
33#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
34#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
35
36#endif
```