36 |
ASM_X86_MMX_SSE |
ASM_X86_MMX_SSE |
37 |
}; |
}; |
38 |
|
|
39 |
|
/** @brief Real Time Math Base Class |
40 |
|
* |
41 |
|
* Math functions for real time operation. This base class contains all |
42 |
|
* non-template methods. |
43 |
|
*/ |
44 |
class RTMathBase { |
class RTMathBase { |
45 |
public: |
public: |
46 |
/** |
/** |
82 |
static float* InitCentsToFreqTable(); |
static float* InitCentsToFreqTable(); |
83 |
}; |
}; |
84 |
|
|
85 |
/** Real Time Math |
/** @brief Real Time Math |
86 |
* |
* |
87 |
* Math functions for real time operation. |
* This is a template which provides customized methods for the desired low |
88 |
|
* level implementation. The ASM_X86_MMX_SSE implementation of each method |
89 |
|
* for example doesn't use 387 FPU instruction. This is needed for MMX |
90 |
|
* algorithms which do not allow mixed MMX and 387 instructions. |
91 |
*/ |
*/ |
92 |
template<implementation_t IMPL = CPP> |
template<implementation_t IMPL = CPP> |
93 |
class __RTMath : public RTMathBase { |
class __RTMath : public RTMathBase { |
98 |
case CPP: { |
case CPP: { |
99 |
return (int) a; |
return (int) a; |
100 |
} |
} |
101 |
#if ARCH_X86 |
#if CONFIG_ASM && ARCH_X86 |
102 |
case ASM_X86_MMX_SSE: { |
case ASM_X86_MMX_SSE: { |
103 |
int ret; |
int ret; |
104 |
asm ( |
asm ( |
108 |
); |
); |
109 |
return ret; |
return ret; |
110 |
} |
} |
111 |
#endif // ARCH_X86 |
#endif // CONFIG_ASM && ARCH_X86 |
112 |
} |
} |
113 |
} |
} |
114 |
|
|
122 |
case CPP: { |
case CPP: { |
123 |
return (float) a; |
return (float) a; |
124 |
} |
} |
125 |
#if ARCH_X86 |
#if CONFIG_ASM && ARCH_X86 |
126 |
case ASM_X86_MMX_SSE: { |
case ASM_X86_MMX_SSE: { |
127 |
float ret; |
float ret; |
128 |
asm ( |
asm ( |
133 |
); |
); |
134 |
return ret; |
return ret; |
135 |
} |
} |
136 |
#endif // ARCH_X86 |
#endif // CONFIG_ASM && ARCH_X86 |
137 |
} |
} |
138 |
} |
} |
139 |
|
|
149 |
case CPP: { |
case CPP: { |
150 |
return (a + b); |
return (a + b); |
151 |
} |
} |
152 |
#if ARCH_X86 |
#if CONFIG_ASM && ARCH_X86 |
153 |
case ASM_X86_MMX_SSE: { |
case ASM_X86_MMX_SSE: { |
154 |
float ret; |
float ret; |
155 |
asm ( |
asm ( |
161 |
); |
); |
162 |
return ret; |
return ret; |
163 |
} |
} |
164 |
#endif // ARCH_X86 |
#endif // CONFIG_ASM && ARCH_X86 |
165 |
} |
} |
166 |
} |
} |
167 |
|
|
174 |
case CPP: { |
case CPP: { |
175 |
return (a - b); |
return (a - b); |
176 |
} |
} |
177 |
#if ARCH_X86 |
#if CONFIG_ASM && ARCH_X86 |
178 |
case ASM_X86_MMX_SSE: { |
case ASM_X86_MMX_SSE: { |
179 |
float ret; |
float ret; |
180 |
asm ( |
asm ( |
186 |
); |
); |
187 |
return ret; |
return ret; |
188 |
} |
} |
189 |
#endif // ARCH_X86 |
#endif // CONFIG_ASM && ARCH_X86 |
190 |
} |
} |
191 |
} |
} |
192 |
|
|
199 |
case CPP: { |
case CPP: { |
200 |
return (a * b); |
return (a * b); |
201 |
} |
} |
202 |
#if ARCH_X86 |
#if CONFIG_ASM && ARCH_X86 |
203 |
case ASM_X86_MMX_SSE: { |
case ASM_X86_MMX_SSE: { |
204 |
float ret; |
float ret; |
205 |
asm ( |
asm ( |
211 |
); |
); |
212 |
return ret; |
return ret; |
213 |
} |
} |
214 |
#endif // ARCH_X86 |
#endif // CONFIG_ASM && ARCH_X86 |
215 |
} |
} |
216 |
} |
} |
217 |
|
|
224 |
case CPP: { |
case CPP: { |
225 |
return (a / b); |
return (a / b); |
226 |
} |
} |
227 |
#if ARCH_X86 |
#if CONFIG_ASM && ARCH_X86 |
228 |
case ASM_X86_MMX_SSE: { |
case ASM_X86_MMX_SSE: { |
229 |
float ret; |
float ret; |
230 |
asm ( |
asm ( |
236 |
); |
); |
237 |
return ret; |
return ret; |
238 |
} |
} |
239 |
#endif // ARCH_X86 |
#endif // CONFIG_ASM && ARCH_X86 |
240 |
} |
} |
241 |
} |
} |
242 |
|
|
249 |
case CPP: { |
case CPP: { |
250 |
return (b < a) ? b : a; |
return (b < a) ? b : a; |
251 |
} |
} |
252 |
#if ARCH_X86 |
#if CONFIG_ASM && ARCH_X86 |
253 |
case ASM_X86_MMX_SSE: { |
case ASM_X86_MMX_SSE: { |
254 |
float ret; |
float ret; |
255 |
asm ( |
asm ( |
261 |
); |
); |
262 |
return ret; |
return ret; |
263 |
} |
} |
264 |
#endif // ARCH_X86 |
#endif // CONFIG_ASM && ARCH_X86 |
265 |
} |
} |
266 |
} |
} |
267 |
|
|
274 |
case CPP: { |
case CPP: { |
275 |
return (b > a) ? b : a; |
return (b > a) ? b : a; |
276 |
} |
} |
277 |
#if ARCH_X86 |
#if CONFIG_ASM && ARCH_X86 |
278 |
case ASM_X86_MMX_SSE: { |
case ASM_X86_MMX_SSE: { |
279 |
float ret; |
float ret; |
280 |
asm ( |
asm ( |
286 |
); |
); |
287 |
return ret; |
return ret; |
288 |
} |
} |
289 |
#endif // ARCH_X86 |
#endif // CONFIG_ASM && ARCH_X86 |
290 |
} |
} |
291 |
} |
} |
292 |
|
|
299 |
case CPP: { |
case CPP: { |
300 |
return fmodf(a, b); |
return fmodf(a, b); |
301 |
} |
} |
302 |
#if ARCH_X86 |
#if CONFIG_ASM && ARCH_X86 |
303 |
case ASM_X86_MMX_SSE: { |
case ASM_X86_MMX_SSE: { |
304 |
float ret; |
float ret; |
305 |
asm ( |
asm ( |
318 |
); |
); |
319 |
return ret; |
return ret; |
320 |
} |
} |
321 |
#endif // ARCH_X86 |
#endif // CONFIG_ASM && ARCH_X86 |
322 |
} |
} |
323 |
} |
} |
324 |
}; |
}; |