Diffstat (limited to 'core/multimedia/opieplayer/libmad/fixed.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/libmad/fixed.h | 111 |
1 files changed, 67 insertions, 44 deletions
diff --git a/core/multimedia/opieplayer/libmad/fixed.h b/core/multimedia/opieplayer/libmad/fixed.h index c9b98ca..baa7dc5 100644 --- a/core/multimedia/opieplayer/libmad/fixed.h +++ b/core/multimedia/opieplayer/libmad/fixed.h | |||
@@ -1,27 +1,27 @@ | |||
1 | /* | 1 | /* |
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 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifndef LIBMAD_FIXED_H | 22 | # ifndef LIBMAD_FIXED_H |
23 | # define LIBMAD_FIXED_H | 23 | # define LIBMAD_FIXED_H |
24 | 24 | ||
25 | # if SIZEOF_INT >= 4 | 25 | # if SIZEOF_INT >= 4 |
26 | typedef signed int mad_fixed_t; | 26 | typedef signed int mad_fixed_t; |
27 | 27 | ||
@@ -187,116 +187,127 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y) | |||
187 | : "cc"); \ | 187 | : "cc"); \ |
188 | }) | 188 | }) |
189 | # endif /* OPT_ACCURACY */ | 189 | # endif /* OPT_ACCURACY */ |
190 | 190 | ||
191 | # if defined(OPT_ACCURACY) | 191 | # if defined(OPT_ACCURACY) |
192 | /* | 192 | /* |
193 | * Surprisingly, this is faster than SHRD followed by ADC. | 193 | * Surprisingly, this is faster than SHRD followed by ADC. |
194 | */ | 194 | */ |
195 | # define mad_f_scale64(hi, lo) \ | 195 | # define mad_f_scale64(hi, lo) \ |
196 | ({ mad_fixed64hi_t __hi_; \ | 196 | ({ mad_fixed64hi_t __hi_; \ |
197 | mad_fixed64lo_t __lo_; \ | 197 | mad_fixed64lo_t __lo_; \ |
198 | mad_fixed_t __result; \ | 198 | mad_fixed_t __result; \ |
199 | asm ("addl %4,%2\n\t" \ | 199 | asm ("addl %4,%2\n\t" \ |
200 | "adcl %5,%3" \ | 200 | "adcl %5,%3" \ |
201 | : "=rm" (__lo_), "=rm" (__hi_) \ | 201 | : "=rm" (__lo_), "=rm" (__hi_) \ |
202 | : "0" (lo), "1" (hi), \ | 202 | : "0" (lo), "1" (hi), \ |
203 | "ir" (1L << (MAD_F_SCALEBITS - 1)), "ir" (0) \ | 203 | "ir" (1L << (MAD_F_SCALEBITS - 1)), "ir" (0) \ |
204 | : "cc"); \ | 204 | : "cc"); \ |
205 | asm ("shrdl %3,%2,%1" \ | 205 | asm ("shrdl %3,%2,%1" \ |
206 | : "=rm" (__result) \ | 206 | : "=rm" (__result) \ |
207 | : "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \ | 207 | : "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \ |
208 | : "cc"); \ | 208 | : "cc"); \ |
209 | __result; \ | 209 | __result; \ |
210 | }) | 210 | }) |
211 | # elif defined(OPT_INTEL) | ||
212 | /* | ||
213 | * Alternate Intel scaling that may or may not perform better. | ||
214 | */ | ||
215 | # define mad_f_scale64(hi, lo) \ | ||
216 | ({ mad_fixed_t __result; \ | ||
217 | asm ("shrl %3,%1\n\t" \ | ||
218 | "shll %4,%2\n\t" \ | ||
219 | "orl %2,%1" \ | ||
220 | : "=rm" (__result) \ | ||
221 | : "0" (lo), "r" (hi), \ | ||
222 | "I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS) \ | ||
223 | : "cc"); \ | ||
224 | __result; \ | ||
225 | }) | ||
211 | # else | 226 | # else |
212 | # define mad_f_scale64(hi, lo) \ | 227 | # define mad_f_scale64(hi, lo) \ |
213 | ({ mad_fixed_t __result; \ | 228 | ({ mad_fixed_t __result; \ |
214 | asm ("shrdl %3,%2,%1" \ | 229 | asm ("shrdl %3,%2,%1" \ |
215 | : "=rm" (__result) \ | 230 | : "=rm" (__result) \ |
216 | : "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \ | 231 | : "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \ |
217 | : "cc"); \ | 232 | : "cc"); \ |
218 | __result; \ | 233 | __result; \ |
219 | }) | 234 | }) |
220 | # endif /* OPT_ACCURACY */ | 235 | # endif /* OPT_ACCURACY */ |
221 | 236 | ||
222 | # define MAD_F_SCALEBITS MAD_F_FRACBITS | 237 | # define MAD_F_SCALEBITS MAD_F_FRACBITS |
223 | # endif | 238 | # endif |
224 | 239 | ||
225 | /* --- ARM ----------------------------------------------------------------- */ | 240 | /* --- ARM ----------------------------------------------------------------- */ |
226 | 241 | ||
227 | # elif defined(FPM_ARM) | 242 | # elif defined(FPM_ARM) |
228 | 243 | ||
229 | /* | 244 | /* |
230 | * This ARM V4 version is as accurate as FPM_64BIT but much faster. The | 245 | * This ARM V4 version is as accurate as FPM_64BIT but much faster. The |
231 | * least significant bit is properly rounded at no CPU cycle cost! | 246 | * least significant bit is properly rounded at no CPU cycle cost! |
232 | */ | 247 | */ |
233 | # if 1 | 248 | # if 1 |
234 | /* | 249 | /* |
235 | * There's a bug somewhere, possibly in the compiler, that sometimes makes | 250 | * This is faster than the default implementation via MAD_F_MLX() and |
236 | * this necessary instead of the default implementation via MAD_F_MLX and | 251 | * mad_f_scale64(). |
237 | * mad_f_scale64. It may be related to the use (or lack) of | ||
238 | * -finline-functions and/or -fstrength-reduce. | ||
239 | * | ||
240 | * This is also apparently faster than MAD_F_MLX/mad_f_scale64. | ||
241 | */ | 252 | */ |
242 | # define mad_f_mul(x, y) \ | 253 | # define mad_f_mul(x, y) \ |
243 | ({ mad_fixed64hi_t __hi; \ | 254 | ({ mad_fixed64hi_t __hi; \ |
244 | mad_fixed64lo_t __lo; \ | 255 | mad_fixed64lo_t __lo; \ |
245 | mad_fixed_t __result; \ | 256 | mad_fixed_t __result; \ |
246 | asm ("smull%0, %1, %3, %4\n\t" \ | 257 | asm ("smull%0, %1, %3, %4\n\t" \ |
247 | "movs%0, %0, lsr %5\n\t" \ | 258 | "movs%0, %0, lsr %5\n\t" \ |
248 | "adc%2, %0, %1, lsl %6" \ | 259 | "adc%2, %0, %1, lsl %6" \ |
249 | : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \ | 260 | : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \ |
250 | : "%r" (x), "r" (y), \ | 261 | : "%r" (x), "r" (y), \ |
251 | "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ | 262 | "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ |
252 | : "cc"); \ | 263 | : "cc"); \ |
253 | __result; \ | 264 | __result; \ |
254 | }) | 265 | }) |
255 | # endif | 266 | # endif |
256 | 267 | ||
257 | # define MAD_F_MLX(hi, lo, x, y) \ | 268 | # define MAD_F_MLX(hi, lo, x, y) \ |
258 | asm ("smull%0, %1, %2, %3" \ | 269 | asm ("smull%0, %1, %2, %3" \ |
259 | : "=&r" (lo), "=&r" (hi) \ | 270 | : "=&r" (lo), "=&r" (hi) \ |
260 | : "%r" (x), "r" (y)) | 271 | : "%r" (x), "r" (y)) |
261 | 272 | ||
262 | # define MAD_F_MLA(hi, lo, x, y) \ | 273 | # define MAD_F_MLA(hi, lo, x, y) \ |
263 | asm ("smlal%0, %1, %2, %3" \ | 274 | asm ("smlal%0, %1, %2, %3" \ |
264 | : "+r" (lo), "+r" (hi) \ | 275 | : "+r" (lo), "+r" (hi) \ |
265 | : "%r" (x), "r" (y)) | 276 | : "%r" (x), "r" (y)) |
266 | 277 | ||
267 | # define MAD_F_MLN(hi, lo) \ | 278 | # define MAD_F_MLN(hi, lo) \ |
268 | asm ("rsbs%0, %2, #0\n\t" \ | 279 | asm ("rsbs%0, %2, #0\n\t" \ |
269 | "rsc%1, %3, #0" \ | 280 | "rsc%1, %3, #0" \ |
270 | : "=r" (lo), "=r" (hi) \ | 281 | : "=r" (lo), "=r" (hi) \ |
271 | : "0" (lo), "1" (hi) \ | 282 | : "0" (lo), "1" (hi) \ |
272 | : "cc") | 283 | : "cc") |
273 | 284 | ||
274 | # define mad_f_scale64(hi, lo) \ | 285 | # define mad_f_scale64(hi, lo) \ |
275 | ({ mad_fixed_t __result; \ | 286 | ({ mad_fixed_t __result; \ |
276 | asm ("movs%0, %1, lsr %3\n\t" \ | 287 | asm ("movs%0, %1, lsr %3\n\t" \ |
277 | "adc%0, %0, %2, lsl %4" \ | 288 | "adc%0, %0, %2, lsl %4" \ |
278 | : "=r" (__result) \ | 289 | : "=&r" (__result) \ |
279 | : "r" (lo), "r" (hi), \ | 290 | : "r" (lo), "r" (hi), \ |
280 | "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ | 291 | "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ |
281 | : "cc"); \ | 292 | : "cc"); \ |
282 | __result; \ | 293 | __result; \ |
283 | }) | 294 | }) |
284 | 295 | ||
285 | # define MAD_F_SCALEBITS MAD_F_FRACBITS | 296 | # define MAD_F_SCALEBITS MAD_F_FRACBITS |
286 | 297 | ||
287 | /* --- MIPS ---------------------------------------------------------------- */ | 298 | /* --- MIPS ---------------------------------------------------------------- */ |
288 | 299 | ||
289 | # elif defined(FPM_MIPS) | 300 | # elif defined(FPM_MIPS) |
290 | 301 | ||
291 | /* | 302 | /* |
292 | * This MIPS version is fast and accurate; the disposition of the least | 303 | * This MIPS version is fast and accurate; the disposition of the least |
293 | * significant bit depends on OPT_ACCURACY via mad_f_scale64(). | 304 | * significant bit depends on OPT_ACCURACY via mad_f_scale64(). |
294 | */ | 305 | */ |
295 | # define MAD_F_MLX(hi, lo, x, y) \ | 306 | # define MAD_F_MLX(hi, lo, x, y) \ |
296 | asm ("mult%2,%3" \ | 307 | asm ("mult%2,%3" \ |
297 | : "=l" (lo), "=h" (hi) \ | 308 | : "=l" (lo), "=h" (hi) \ |
298 | : "%r" (x), "r" (y)) | 309 | : "%r" (x), "r" (y)) |
299 | 310 | ||
300 | # if defined(HAVE_MADD_ASM) | 311 | # if defined(HAVE_MADD_ASM) |
301 | # define MAD_F_MLA(hi, lo, x, y) \ | 312 | # define MAD_F_MLA(hi, lo, x, y) \ |
302 | asm ("madd%2,%3" \ | 313 | asm ("madd%2,%3" \ |
@@ -322,155 +333,167 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y) | |||
322 | # define mad_f_scale64(hi, lo) \ | 333 | # define mad_f_scale64(hi, lo) \ |
323 | ((mad_fixed_t) ((hi) << (32 - MAD_F_SCALEBITS))) | 334 | ((mad_fixed_t) ((hi) << (32 - MAD_F_SCALEBITS))) |
324 | # define MAD_F_SCALEBITS MAD_F_FRACBITS | 335 | # define MAD_F_SCALEBITS MAD_F_FRACBITS |
325 | # endif | 336 | # endif |
326 | 337 | ||
327 | /* --- SPARC --------------------------------------------------------------- */ | 338 | /* --- SPARC --------------------------------------------------------------- */ |
328 | 339 | ||
329 | # elif defined(FPM_SPARC) | 340 | # elif defined(FPM_SPARC) |
330 | 341 | ||
331 | /* | 342 | /* |
332 | * This SPARC V8 version is fast and accurate; the disposition of the least | 343 | * This SPARC V8 version is fast and accurate; the disposition of the least |
333 | * significant bit depends on OPT_ACCURACY via mad_f_scale64(). | 344 | * significant bit depends on OPT_ACCURACY via mad_f_scale64(). |
334 | */ | 345 | */ |
335 | # define MAD_F_MLX(hi, lo, x, y) \ | 346 | # define MAD_F_MLX(hi, lo, x, y) \ |
336 | asm ("smul %2, %3, %0\n\t" \ | 347 | asm ("smul %2, %3, %0\n\t" \ |
337 | "rd %%y, %1" \ | 348 | "rd %%y, %1" \ |
338 | : "=r" (lo), "=r" (hi) \ | 349 | : "=r" (lo), "=r" (hi) \ |
339 | : "%r" (x), "rI" (y)) | 350 | : "%r" (x), "rI" (y)) |
340 | 351 | ||
341 | /* --- PowerPC ------------------------------------------------------------- */ | 352 | /* --- PowerPC ------------------------------------------------------------- */ |
342 | 353 | ||
343 | # elif defined(FPM_PPC) | 354 | # elif defined(FPM_PPC) |
344 | 355 | ||
345 | /* | 356 | /* |
346 | * This PowerPC version is tuned for the 4xx embedded processors. It is | 357 | * This PowerPC version is fast and accurate; the disposition of the least |
347 | * effectively a tuned version of FPM_64BIT. It is a little faster and just | 358 | * significant bit depends on OPT_ACCURACY via mad_f_scale64(). |
348 | * as accurate. The disposition of the least significant bit depends on | ||
349 | * OPT_ACCURACY via mad_f_scale64(). | ||
350 | */ | 359 | */ |
351 | # define MAD_F_MLX(hi, lo, x, y) \ | 360 | # define MAD_F_MLX(hi, lo, x, y) \ |
352 | asm ("mulhw %1, %2, %3\n\t" \ | 361 | do { \ |
353 | "mullw %0, %2, %3" \ | 362 | asm ("mullw %0,%1,%2" \ |
354 | : "=&r" (lo), "=&r" (hi) \ | 363 | : "=r" (lo) \ |
355 | : "%r" (x), "r" (y)) | 364 | : "%r" (x), "r" (y)); \ |
365 | asm ("mulhw %0,%1,%2" \ | ||
366 | : "=r" (hi) \ | ||
367 | : "%r" (x), "r" (y)); \ | ||
368 | } \ | ||
369 | while (0) | ||
356 | 370 | ||
357 | # define MAD_F_MLA(hi, lo, x, y) \ | 371 | # if defined(OPT_ACCURACY) |
372 | /* | ||
373 | * This gives best accuracy but is not very fast. | ||
374 | */ | ||
375 | # define MAD_F_MLA(hi, lo, x, y) \ | ||
358 | ({ mad_fixed64hi_t __hi; \ | 376 | ({ mad_fixed64hi_t __hi; \ |
359 | mad_fixed64lo_t __lo; \ | 377 | mad_fixed64lo_t __lo; \ |
360 | MAD_F_MLX(__hi, __lo, (x), (y)); \ | 378 | MAD_F_MLX(__hi, __lo, (x), (y)); \ |
361 | asm ("addc %0, %2, %3\n\t" \ | 379 | asm ("addc %0,%2,%3\n\t" \ |
362 | "adde %1, %4, %5" \ | 380 | "adde %1,%4,%5" \ |
363 | : "=r" (lo), "=r" (hi) \ | 381 | : "=r" (lo), "=r" (hi) \ |
364 | : "%r" (__lo), "0" (lo), "%r" (__hi), "1" (hi)); \ | 382 | : "%r" (lo), "r" (__lo), \ |
383 | "%r" (hi), "r" (__hi) \ | ||
384 | : "xer"); \ | ||
365 | }) | 385 | }) |
386 | # endif | ||
366 | 387 | ||
367 | # if defined(OPT_ACCURACY) | 388 | # if defined(OPT_ACCURACY) |
368 | /* | 389 | /* |
369 | * This is accurate and ~2 - 2.5 times slower than the unrounded version. | 390 | * This is slower than the truncating version below it. |
370 | * | ||
371 | * The __volatile__ improves the generated code by another 5% (fewer spills | ||
372 | * to memory); eventually they should be removed. | ||
373 | */ | 391 | */ |
374 | # define mad_f_scale64(hi, lo) \ | 392 | # define mad_f_scale64(hi, lo) \ |
375 | ({ mad_fixed_t __result; \ | 393 | ({ mad_fixed_t __result, __round; \ |
376 | mad_fixed64hi_t __hi_; \ | 394 | asm ("rotrwi %0,%1,%2" \ |
377 | mad_fixed64lo_t __lo_; \ | 395 | : "=r" (__result) \ |
378 | asm __volatile__ ("addc %0, %2, %4\n\t" \ | 396 | : "r" (lo), "i" (MAD_F_SCALEBITS)); \ |
379 | "addze %1, %3" \ | 397 | asm ("extrwi %0,%1,1,0" \ |
380 | : "=r" (__lo_), "=r" (__hi_) \ | 398 | : "=r" (__round) \ |
381 | : "r" (lo), "r" (hi), "r" (1 << (MAD_F_SCALEBITS - 1))); \ | 399 | : "r" (__result)); \ |
382 | asm __volatile__ ("rlwinm %0, %2,32-%3,0,%3-1\n\t" \ | 400 | asm ("insrwi %0,%1,%2,0" \ |
383 | "rlwimi %0, %1,32-%3,%3,31" \ | 401 | : "+r" (__result) \ |
384 | : "=&r" (__result) \ | 402 | : "r" (hi), "i" (MAD_F_SCALEBITS)); \ |
385 | : "r" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS)); \ | 403 | asm ("add %0,%1,%2" \ |
386 | __result; \ | 404 | : "=r" (__result) \ |
405 | : "%r" (__result), "r" (__round)); \ | ||
406 | __result; \ | ||
387 | }) | 407 | }) |
388 | # else | 408 | # else |
389 | # define mad_f_scale64(hi, lo) \ | 409 | # define mad_f_scale64(hi, lo) \ |
390 | ({ mad_fixed_t __result; \ | 410 | ({ mad_fixed_t __result; \ |
391 | asm ("rlwinm %0, %2,32-%3,0,%3-1\n\t" \ | 411 | asm ("rotrwi %0,%1,%2" \ |
392 | "rlwimi %0, %1,32-%3,%3,31" \ | ||
393 | : "=r" (__result) \ | 412 | : "=r" (__result) \ |
394 | : "r" (lo), "r" (hi), "I" (MAD_F_SCALEBITS)); \ | 413 | : "r" (lo), "i" (MAD_F_SCALEBITS)); \ |
395 | __result; \ | 414 | asm ("insrwi %0,%1,%2,0" \ |
415 | : "+r" (__result) \ | ||
416 | : "r" (hi), "i" (MAD_F_SCALEBITS)); \ | ||
417 | __result; \ | ||
396 | }) | 418 | }) |
397 | # endif /* OPT_ACCURACY */ | 419 | # endif |
398 | 420 | ||
399 | # define MAD_F_SCALEBITS MAD_F_FRACBITS | 421 | # define MAD_F_SCALEBITS MAD_F_FRACBITS |
400 | 422 | ||
401 | /* --- Default ------------------------------------------------------------- */ | 423 | /* --- Default ------------------------------------------------------------- */ |
402 | 424 | ||
403 | # elif defined(FPM_DEFAULT) | 425 | # elif defined(FPM_DEFAULT) |
404 | 426 | ||
405 | /* | 427 | /* |
406 | * This version is the most portable but it loses significant accuracy. | 428 | * This version is the most portable but it loses significant accuracy. |
407 | * Furthermore, accuracy is biased against the second argument, so care | 429 | * Furthermore, accuracy is biased against the second argument, so care |
408 | * should be taken when ordering operands. | 430 | * should be taken when ordering operands. |
409 | * | 431 | * |
410 | * The scale factors are constant as this is not used with SSO. | 432 | * The scale factors are constant as this is not used with SSO. |
411 | * | 433 | * |
412 | * Pre-rounding is required to stay within the limits of compliance. | 434 | * Pre-rounding is required to stay within the limits of compliance. |
413 | */ | 435 | */ |
414 | # if defined(OPT_SPEED) | 436 | # if defined(OPT_SPEED) |
415 | # define mad_f_mul(x, y)(((x) >> 12) * ((y) >> 16)) | 437 | # define mad_f_mul(x, y)(((x) >> 12) * ((y) >> 16)) |
416 | # else | 438 | # else |
417 | # define mad_f_mul(x, y)((((x) + (1L << 11)) >> 12) * \ | 439 | # define mad_f_mul(x, y)((((x) + (1L << 11)) >> 12) * \ |
418 | (((y) + (1L << 15)) >> 16)) | 440 | (((y) + (1L << 15)) >> 16)) |
419 | # endif | 441 | # endif |
420 | 442 | ||
421 | /* ------------------------------------------------------------------------- */ | 443 | /* ------------------------------------------------------------------------- */ |
422 | 444 | ||
423 | # else | 445 | # else |
424 | # error "no FPM selected" | 446 | # error "no FPM selected" |
425 | # endif | 447 | # endif |
426 | 448 | ||
427 | /* default implementations */ | 449 | /* default implementations */ |
428 | 450 | ||
429 | # if !defined(mad_f_mul) | 451 | # if !defined(mad_f_mul) |
430 | # define mad_f_mul(x, y) \ | 452 | # define mad_f_mul(x, y) \ |
431 | ({ mad_fixed64hi_t __hi; \ | 453 | ({ register mad_fixed64hi_t __hi; \ |
432 | mad_fixed64lo_t __lo; \ | 454 | register mad_fixed64lo_t __lo; \ |
433 | MAD_F_MLX(__hi, __lo, (x), (y)); \ | 455 | MAD_F_MLX(__hi, __lo, (x), (y)); \ |
434 | mad_f_scale64(__hi, __lo); \ | 456 | mad_f_scale64(__hi, __lo); \ |
435 | }) | 457 | }) |
436 | # endif | 458 | # endif |
437 | 459 | ||
438 | # if !defined(MAD_F_MLA) | 460 | # if !defined(MAD_F_MLA) |
439 | # define MAD_F_ML0(hi, lo, x, y)((lo) = mad_f_mul((x), (y))) | 461 | # define MAD_F_ML0(hi, lo, x, y)((lo) = mad_f_mul((x), (y))) |
440 | # define MAD_F_MLA(hi, lo, x, y)((lo) += mad_f_mul((x), (y))) | 462 | # define MAD_F_MLA(hi, lo, x, y)((lo) += mad_f_mul((x), (y))) |
441 | # define MAD_F_MLN(hi, lo) ((lo) = -(lo)) | 463 | # define MAD_F_MLN(hi, lo) ((lo) = -(lo)) |
442 | # define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) | 464 | # define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) |
443 | # endif | 465 | # endif |
444 | 466 | ||
445 | # if !defined(MAD_F_ML0) | 467 | # if !defined(MAD_F_ML0) |
446 | # define MAD_F_ML0(hi, lo, x, y)MAD_F_MLX((hi), (lo), (x), (y)) | 468 | # define MAD_F_ML0(hi, lo, x, y)MAD_F_MLX((hi), (lo), (x), (y)) |
447 | # endif | 469 | # endif |
448 | 470 | ||
449 | # if !defined(MAD_F_MLN) | 471 | # if !defined(MAD_F_MLN) |
450 | # define MAD_F_MLN(hi, lo) ((hi) = ((lo) = -(lo)) ? ~(hi) : -(hi)) | 472 | # define MAD_F_MLN(hi, lo) ((hi) = ((lo) = -(lo)) ? ~(hi) : -(hi)) |
451 | # endif | 473 | # endif |
452 | 474 | ||
453 | # if !defined(MAD_F_MLZ) | 475 | # if !defined(MAD_F_MLZ) |
454 | # define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo)) | 476 | # define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo)) |
455 | # endif | 477 | # endif |
456 | 478 | ||
457 | # if !defined(mad_f_scale64) | 479 | # if !defined(mad_f_scale64) |
458 | # if defined(OPT_ACCURACY) | 480 | # if defined(OPT_ACCURACY) |
459 | # define mad_f_scale64(hi, lo) \ | 481 | # define mad_f_scale64(hi, lo) \ |
460 | ((((mad_fixed_t) \ | 482 | ((((mad_fixed_t) \ |
461 | (((hi) << (32 - (MAD_F_SCALEBITS - 1))) | \ | 483 | (((hi) << (32 - (MAD_F_SCALEBITS - 1))) | \ |
462 | ((lo) >> (MAD_F_SCALEBITS - 1)))) + 1) >> 1) | 484 | ((lo) >> (MAD_F_SCALEBITS - 1)))) + 1) >> 1) |
463 | # else | 485 | # else |
464 | # define mad_f_scale64(hi, lo) \ | 486 | # define mad_f_scale64(hi, lo) \ |
465 | ((mad_fixed_t) \ | 487 | ((mad_fixed_t) \ |
466 | (((hi) << (32 - MAD_F_SCALEBITS)) | \ | 488 | (((hi) << (32 - MAD_F_SCALEBITS)) | \ |
467 | ((lo) >> MAD_F_SCALEBITS))) | 489 | ((lo) >> MAD_F_SCALEBITS))) |
468 | # endif | 490 | # endif |
469 | # define MAD_F_SCALEBITS MAD_F_FRACBITS | 491 | # define MAD_F_SCALEBITS MAD_F_FRACBITS |
470 | # endif | 492 | # endif |
471 | 493 | ||
472 | /* miscellaneous C routines */ | 494 | /* C routines */ |
473 | 495 | ||
474 | mad_fixed_t mad_f_abs(mad_fixed_t); | 496 | mad_fixed_t mad_f_abs(mad_fixed_t); |
497 | mad_fixed_t mad_f_div(mad_fixed_t, mad_fixed_t); | ||
475 | 498 | ||
476 | # endif | 499 | # endif |