22 #ifndef M4_CORE_IMATH_H 23 #define M4_CORE_IMATH_H 25 #include "common/endian.h" 26 #include "m4/m4_types.h" 30 #define FRAC16(a,b) ((a<<16) + (b)) 32 #define Atan2F16(x1, x2) ArcTan(x1, x2) 33 #define MulSF16(x1, x2) FixedMul(x1, x2) 34 #define DivSF16(x1, x2) FixedDiv(x1, x2) 35 #define RecipUF16(x) FixedDiv(1, x) 36 #define SquareSF16(x) FixedMul(x, x) 38 #define SWAP_INT16(x) ((((x)>>8)&0x00ff) + (((x)&0x00ff)<<8)) 39 #define SWAP_INT32(x) ((((int32)(x)&0x000000ff)<<24) + (((int32)(x)&0x0000ff00)<<8) + \ 40 (((int32)(x)&0x00ff0000)>>8) + (((int32)(x)>>24)&0x000000ff)) 46 unsigned long sqrtul(
unsigned long v);
48 int32 imath_max(int32 a, int32 b);
49 int32 imath_min(int32 a, int32 b);
50 int32 imath_abs(int32 a);
52 void imath_seed(int32 seednum);
53 uint32 imath_random();
54 int32 imath_ranged_rand(int32 a, int32 b);
56 bool imath_rand_bool(
int max);
58 frac16 dist2d(int32 x1, int32 y1, int32 x2, int32 y2);
62 uint16 HighWord(uint32 n);
63 uint16 LowWord(uint32 n);
65 uint32 convert_intel32(uint32 a);
66 uint16 convert_intel16(uint16 a);
72 inline short abs(
short a) {
73 return (a >= 0) ? a : -a;
76 inline long abs(
long a) {
77 return (a >= 0) ? a : -a;
80 inline int16 convert_intel16(
void *src) {
81 return READ_LE_INT16(src);
intptr frac16
Definition: m4_types.h:46
Definition: database.h:28