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.h | |
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.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,9 +1,9 @@ | |||
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 | * |
@@ -205,12 +205,27 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y) | |||
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) \ |
@@ -229,18 +244,14 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y) | |||
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" \ |
@@ -272,13 +283,13 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y) | |||
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 | ||
@@ -340,64 +351,75 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t 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) |
@@ -425,14 +447,14 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y) | |||
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) |
@@ -466,11 +488,12 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y) | |||
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 |