summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/libmpeg3/audio/mpeg3real.h
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/libmpeg3/audio/mpeg3real.h') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/mpeg3real.h232
1 files changed, 232 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/mpeg3real.h b/core/multimedia/opieplayer/libmpeg3/audio/mpeg3real.h
new file mode 100644
index 0000000..cdcac3d
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/mpeg3real.h
@@ -0,0 +1,232 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef MPEG3REAL_H
21#define MPEG3REAL_H
22
23#ifdef USE_FIXED_POINT
24
25#include <limits.h>
26#include <stdio.h>
27
28#ifndef LONGLONG
29#define LONGLONG long long
30#endif
31
32//#define SC (1<<16)
33#define SC (1<<15)
34
35class mpeg3_real_t {
36 long v;
37public:
38 mpeg3_real_t() { } // Uninitialized, just like a float
39 mpeg3_real_t(double d) { v=long(d*SC); }
40 mpeg3_real_t(float f) { v=long(f*SC); }
41 mpeg3_real_t(int i) { v=long(i*SC); }
42 long fixedPoint() const { return v; }
43 operator float() const { return ((float)v)/SC; }
44 operator int() const { return (int)(v/SC); }
45 mpeg3_real_t operator+() const;
46 mpeg3_real_t operator-() const;
47 mpeg3_real_t& operator= (const mpeg3_real_t&);
48 mpeg3_real_t& operator+= (const mpeg3_real_t&);
49 mpeg3_real_t& operator-= (const mpeg3_real_t&);
50 mpeg3_real_t& operator*= (const mpeg3_real_t&);
51 mpeg3_real_t& operator/= (const mpeg3_real_t&);
52 friend mpeg3_real_t operator+ (const mpeg3_real_t&, const mpeg3_real_t&);
53 friend mpeg3_real_t operator- (const mpeg3_real_t&, const mpeg3_real_t&);
54 friend mpeg3_real_t operator* (const mpeg3_real_t&, const mpeg3_real_t&);
55 friend mpeg3_real_t operator/ (const mpeg3_real_t&, const mpeg3_real_t&);
56 friend mpeg3_real_t operator+ (const mpeg3_real_t&, const float&);
57 friend mpeg3_real_t operator- (const mpeg3_real_t&, const float&);
58 friend mpeg3_real_t operator* (const mpeg3_real_t&, const float&);
59 friend mpeg3_real_t operator/ (const mpeg3_real_t&, const float&);
60 friend mpeg3_real_t operator+ (const float&, const mpeg3_real_t&);
61 friend mpeg3_real_t operator- (const float&, const mpeg3_real_t&);
62 friend mpeg3_real_t operator* (const float&, const mpeg3_real_t&);
63 friend mpeg3_real_t operator/ (const float&, const mpeg3_real_t&);
64 friend mpeg3_real_t operator+ (const mpeg3_real_t&, const int&);
65 friend mpeg3_real_t operator- (const mpeg3_real_t&, const int&);
66 friend mpeg3_real_t operator* (const mpeg3_real_t&, const int&);
67 friend mpeg3_real_t operator/ (const mpeg3_real_t&, const int&);
68 friend mpeg3_real_t operator+ (const int&, const mpeg3_real_t&);
69 friend mpeg3_real_t operator- (const int&, const mpeg3_real_t&);
70 friend mpeg3_real_t operator* (const int&, const mpeg3_real_t&);
71 friend mpeg3_real_t operator/ (const int&, const mpeg3_real_t&);
72};
73
74inline mpeg3_real_t mpeg3_real_t::operator+() const
75{
76 return *this;
77}
78
79inline mpeg3_real_t mpeg3_real_t::operator-() const
80{
81 mpeg3_real_t r;
82 r.v=-v;
83 return r;
84}
85
86inline mpeg3_real_t& mpeg3_real_t::operator= (const mpeg3_real_t& o)
87{
88 v=o.v;
89 return *this;
90}
91
92inline mpeg3_real_t& mpeg3_real_t::operator+= (const mpeg3_real_t& o)
93{
94 v += o.v;
95 return *this;
96}
97
98inline mpeg3_real_t& mpeg3_real_t::operator-= (const mpeg3_real_t& o)
99{
100 v -= o.v;
101 return *this;
102}
103
104inline mpeg3_real_t& mpeg3_real_t::operator*= (const mpeg3_real_t& o)
105{
106 *this = *this * o;
107 return *this;
108}
109
110inline mpeg3_real_t& mpeg3_real_t::operator/= (const mpeg3_real_t& o)
111{
112 *this = *this / o;
113 return *this;
114}
115
116
117inline mpeg3_real_t operator+ (const mpeg3_real_t&a, const mpeg3_real_t&b)
118{
119 mpeg3_real_t r;
120 r.v=a.v+b.v;
121 return r;
122}
123
124inline mpeg3_real_t operator- (const mpeg3_real_t&a, const mpeg3_real_t&b)
125{
126 mpeg3_real_t r;
127 r.v=a.v-b.v;
128 return r;
129}
130
131inline mpeg3_real_t operator* (const mpeg3_real_t&a, const mpeg3_real_t&b)
132{
133 mpeg3_real_t r;
134 r.v = (LONGLONG)a.v * b.v / SC;
135 return r;
136}
137
138inline mpeg3_real_t operator/ (const mpeg3_real_t&a, const mpeg3_real_t&b)
139{
140 mpeg3_real_t r;
141 r.v = (LONGLONG)a.v * SC / b.v;
142 return r;
143}
144
145inline mpeg3_real_t operator+ (const mpeg3_real_t&a, const float&b)
146{
147 return a+mpeg3_real_t(b);
148}
149
150inline mpeg3_real_t operator- (const mpeg3_real_t&a, const float&b)
151{
152 return a-mpeg3_real_t(b);
153}
154
155inline mpeg3_real_t operator* (const mpeg3_real_t&a, const float&b)
156{
157 return a*mpeg3_real_t(b);
158}
159
160inline mpeg3_real_t operator/ (const mpeg3_real_t&a, const float&b)
161{
162 return a/mpeg3_real_t(b);
163}
164
165
166inline mpeg3_real_t operator+ (const float&a, const mpeg3_real_t&b)
167{
168 return mpeg3_real_t(a)+b;
169}
170
171inline mpeg3_real_t operator- (const float&a, const mpeg3_real_t&b)
172{
173 return mpeg3_real_t(a)-b;
174}
175
176inline mpeg3_real_t operator* (const float&a, const mpeg3_real_t&b)
177{
178 return mpeg3_real_t(a)*b;
179}
180
181inline mpeg3_real_t operator/ (const float&a, const mpeg3_real_t&b)
182{
183 return mpeg3_real_t(a)/b;
184}
185
186
187inline mpeg3_real_t operator+ (const mpeg3_real_t&a, const int&b)
188{
189 return a+mpeg3_real_t(b);
190}
191
192inline mpeg3_real_t operator- (const mpeg3_real_t&a, const int&b)
193{
194 return a-mpeg3_real_t(b);
195}
196
197inline mpeg3_real_t operator* (const mpeg3_real_t&a, const int&b)
198{
199 return a*mpeg3_real_t(b);
200}
201
202inline mpeg3_real_t operator/ (const mpeg3_real_t&a, const int&b)
203{
204 return a/mpeg3_real_t(b);
205}
206
207
208inline mpeg3_real_t operator+ (const int&a, const mpeg3_real_t&b)
209{
210 return mpeg3_real_t(a)+b;
211}
212
213inline mpeg3_real_t operator- (const int&a, const mpeg3_real_t&b)
214{
215 return mpeg3_real_t(a)-b;
216}
217
218inline mpeg3_real_t operator* (const int&a, const mpeg3_real_t&b)
219{
220 return mpeg3_real_t(a)*b;
221}
222
223inline mpeg3_real_t operator/ (const int&a, const mpeg3_real_t&b)
224{
225 return mpeg3_real_t(a)/b;
226}
227
228#else
229typedef float mpeg3_real_t;
230#endif
231
232#endif