author | llornkcor <llornkcor> | 2005-11-08 23:16:03 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2005-11-08 23:16:03 (UTC) |
commit | 6bd52d3658f01c966d690b12235592a5473a4d57 (patch) (unidiff) | |
tree | 76e25003b738fde6ebbea5d338b7cf76b82f47fa /core/multimedia/opieplayer/libmad/fixed.c | |
parent | a8063e0797d6edf2ead22fc8c5346ddf187f0b5d (diff) | |
download | opie-6bd52d3658f01c966d690b12235592a5473a4d57.zip opie-6bd52d3658f01c966d690b12235592a5473a4d57.tar.gz opie-6bd52d3658f01c966d690b12235592a5473a4d57.tar.bz2 |
update libmad and add 64bit define
Diffstat (limited to 'core/multimedia/opieplayer/libmad/fixed.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/libmad/fixed.c | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/core/multimedia/opieplayer/libmad/fixed.c b/core/multimedia/opieplayer/libmad/fixed.c index af1e87e..e71418a 100644 --- a/core/multimedia/opieplayer/libmad/fixed.c +++ b/core/multimedia/opieplayer/libmad/fixed.c | |||
@@ -2,3 +2,3 @@ | |||
2 | * libmad - MPEG audio decoder library | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. |
4 | * | 4 | * |
@@ -37 +37,45 @@ mad_fixed_t mad_f_abs(mad_fixed_t x) | |||
37 | } | 37 | } |
38 | |||
39 | /* | ||
40 | * NAME:fixed->div() | ||
41 | * DESCRIPTION:perform division using fixed-point math | ||
42 | */ | ||
43 | mad_fixed_t mad_f_div(mad_fixed_t x, mad_fixed_t y) | ||
44 | { | ||
45 | mad_fixed_t q, r; | ||
46 | unsigned int bits; | ||
47 | |||
48 | q = mad_f_abs(x / y); | ||
49 | |||
50 | if (x < 0) { | ||
51 | x = -x; | ||
52 | y = -y; | ||
53 | } | ||
54 | |||
55 | r = x % y; | ||
56 | |||
57 | if (y < 0) { | ||
58 | x = -x; | ||
59 | y = -y; | ||
60 | } | ||
61 | |||
62 | if (q > mad_f_intpart(MAD_F_MAX) && | ||
63 | !(q == -mad_f_intpart(MAD_F_MIN) && r == 0 && (x < 0) != (y < 0))) | ||
64 | return 0; | ||
65 | |||
66 | for (bits = MAD_F_FRACBITS; bits && r; --bits) { | ||
67 | q <<= 1, r <<= 1; | ||
68 | if (r >= y) | ||
69 | r -= y, ++q; | ||
70 | } | ||
71 | |||
72 | /* round */ | ||
73 | if (2 * r >= y) | ||
74 | ++q; | ||
75 | |||
76 | /* fix sign */ | ||
77 | if ((x < 0) != (y < 0)) | ||
78 | q = -q; | ||
79 | |||
80 | return q << bits; | ||
81 | } | ||