summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/fixedpoint.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lib/fixedpoint.h')
-rw-r--r--apps/plugins/lib/fixedpoint.h45
1 files changed, 40 insertions, 5 deletions
diff --git a/apps/plugins/lib/fixedpoint.h b/apps/plugins/lib/fixedpoint.h
index dfabbad8dc..ef50dd0085 100644
--- a/apps/plugins/lib/fixedpoint.h
+++ b/apps/plugins/lib/fixedpoint.h
@@ -21,11 +21,44 @@
21 * 21 *
22 ****************************************************************************/ 22 ****************************************************************************/
23 23
24long fsincos(unsigned long phase, long *cos); 24/** PLUGINS - FIXED POINT MATH ROUTINES - USAGE
25long fsqrt(long a, unsigned int fracbits); 25 *
26long cos_int(int val); 26 * - x and y arguments are fixed point integers
27long sin_int(int val); 27 * - fracbits is the number of fractional bits in the argument(s)
28long flog(int x); 28 * - functions return long fixed point integers with the specified number
29 * of fractional bits unless otherwise specified
30 *
31 * Calculate sin and cos of an angle:
32 * fp_sincos(phase, *cos)
33 * where phase is a 32 bit unsigned integer with 0 representing 0
34 * and 0xFFFFFFFF representing 2*pi, and *cos is the address to
35 * a long signed integer. Value returned is a long signed integer
36 * from LONG_MIN to LONG_MAX, representing -1 to 1 respectively.
37 * That is, value is a fixed point integer with 31 fractional bits.
38 *
39 * Take square root of a fixed point number:
40 * fp_sqrt(x, fracbits)
41 *
42 * Calculate sin or cos of an angle (very fast, from a table):
43 * fp14_sin(angle)
44 * fp14_cos(angle)
45 * where angle is a non-fixed point integer in degrees. Value
46 * returned is a fixed point integer with 14 fractional bits.
47 *
48 * Calculate the natural log of a positive fixed point integer
49 * fp16_log(x)
50 * where x and the value returned are fixed point integers
51 * with 16 fractional bits.
52 */
53
54#ifndef _FIXEDPOINT_H_PLUGINS
55#define _FIXEDPOINT_H_PLUGINS
56
57long fp_sincos(unsigned long phase, long *cos);
58long fp_sqrt(long a, unsigned int fracbits);
59long fp14_cos(int val);
60long fp14_sin(int val);
61long fp16_log(int x);
29 62
30/* fast unsigned multiplication (16x16bit->32bit or 32x32bit->32bit, 63/* fast unsigned multiplication (16x16bit->32bit or 32x32bit->32bit,
31 * whichever is faster for the architecture) */ 64 * whichever is faster for the architecture) */
@@ -34,3 +67,5 @@ long flog(int x);
34#else /* SH1, coldfire */ 67#else /* SH1, coldfire */
35#define FMULU(a, b) ((uint32_t) (((uint16_t) (a)) * ((uint16_t) (b)))) 68#define FMULU(a, b) ((uint32_t) (((uint16_t) (a)) * ((uint16_t) (b))))
36#endif 69#endif
70
71#endif