Diffstat (limited to 'core/multimedia/opieplayer/libmad/fixed.h') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/libmad/fixed.h | 75 |
1 files changed, 69 insertions, 6 deletions
diff --git a/core/multimedia/opieplayer/libmad/fixed.h b/core/multimedia/opieplayer/libmad/fixed.h index 00ade62..c9b98ca 100644 --- a/core/multimedia/opieplayer/libmad/fixed.h +++ b/core/multimedia/opieplayer/libmad/fixed.h | |||
@@ -1,8 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
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. |
@@ -31,12 +31,24 @@ typedef unsigned int mad_fixed64lo_t; | |||
31 | typedef signed long mad_fixed_t; | 31 | typedef signed long mad_fixed_t; |
32 | 32 | ||
33 | typedef signed long mad_fixed64hi_t; | 33 | typedef signed long mad_fixed64hi_t; |
34 | typedef unsigned long mad_fixed64lo_t; | 34 | typedef unsigned long mad_fixed64lo_t; |
35 | # endif | 35 | # endif |
36 | 36 | ||
37 | # if defined(_MSC_VER) | ||
38 | # define mad_fixed64_t signed __int64 | ||
39 | # elif 1 || defined(__GNUC__) | ||
40 | # define mad_fixed64_t signed long long | ||
41 | # endif | ||
42 | |||
43 | # if defined(FPM_FLOAT) | ||
44 | typedef double mad_sample_t; | ||
45 | # else | ||
46 | typedef mad_fixed_t mad_sample_t; | ||
47 | # endif | ||
48 | |||
37 | /* | 49 | /* |
38 | * Fixed-point format: 0xABBBBBBB | 50 | * Fixed-point format: 0xABBBBBBB |
39 | * A == whole part (sign + 3 bits) | 51 | * A == whole part (sign + 3 bits) |
40 | * B == fractional part (28 bits) | 52 | * B == fractional part (28 bits) |
41 | * | 53 | * |
42 | * Values are signed two's complement, so the effective range is: | 54 | * Values are signed two's complement, so the effective range is: |
@@ -91,34 +103,68 @@ typedef unsigned long mad_fixed64lo_t; | |||
91 | 103 | ||
92 | # define mad_f_fromint(x)((x) << MAD_F_FRACBITS) | 104 | # define mad_f_fromint(x)((x) << MAD_F_FRACBITS) |
93 | 105 | ||
94 | # define mad_f_add(x, y)((x) + (y)) | 106 | # define mad_f_add(x, y)((x) + (y)) |
95 | # define mad_f_sub(x, y)((x) - (y)) | 107 | # define mad_f_sub(x, y)((x) - (y)) |
96 | 108 | ||
97 | # if defined(FPM_64BIT) | 109 | # if defined(FPM_FLOAT) |
110 | # error "FPM_FLOAT not yet supported" | ||
111 | |||
112 | # undef MAD_F | ||
113 | # define MAD_F(x) mad_f_todouble(x) | ||
114 | |||
115 | # define mad_f_mul(x, y)((x) * (y)) | ||
116 | # define mad_f_scale64 | ||
117 | |||
118 | # undef ASO_ZEROCHECK | ||
119 | |||
120 | # elif defined(FPM_64BIT) | ||
98 | 121 | ||
99 | /* | 122 | /* |
100 | * This version should be the most accurate if 64-bit (long long) types are | 123 | * This version should be the most accurate if 64-bit types are supported by |
101 | * supported by the compiler, although it may not be the most efficient. | 124 | * the compiler, although it may not be the most efficient. |
102 | */ | 125 | */ |
103 | # if defined(OPT_ACCURACY) | 126 | # if defined(OPT_ACCURACY) |
104 | # define mad_f_mul(x, y) \ | 127 | # define mad_f_mul(x, y) \ |
105 | ((mad_fixed_t) \ | 128 | ((mad_fixed_t) \ |
106 | ((((signed long long) (x) * (y)) + \ | 129 | ((((mad_fixed64_t) (x) * (y)) + \ |
107 | (1L << (MAD_F_SCALEBITS - 1))) >> MAD_F_SCALEBITS)) | 130 | (1L << (MAD_F_SCALEBITS - 1))) >> MAD_F_SCALEBITS)) |
108 | # else | 131 | # else |
109 | # define mad_f_mul(x, y) \ | 132 | # define mad_f_mul(x, y) \ |
110 | ((mad_fixed_t) (((signed long long) (x) * (y)) >> MAD_F_SCALEBITS)) | 133 | ((mad_fixed_t) (((mad_fixed64_t) (x) * (y)) >> MAD_F_SCALEBITS)) |
111 | # endif | 134 | # endif |
112 | 135 | ||
113 | # define MAD_F_SCALEBITS MAD_F_FRACBITS | 136 | # define MAD_F_SCALEBITS MAD_F_FRACBITS |
114 | 137 | ||
115 | /* --- Intel --------------------------------------------------------------- */ | 138 | /* --- Intel --------------------------------------------------------------- */ |
116 | 139 | ||
117 | # elif defined(FPM_INTEL) | 140 | # elif defined(FPM_INTEL) |
118 | 141 | ||
142 | # if defined(_MSC_VER) | ||
143 | # pragma warning(push) | ||
144 | # pragma warning(disable: 4035) /* no return value */ | ||
145 | static __forceinline | ||
146 | mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y) | ||
147 | { | ||
148 | enum { | ||
149 | fracbits = MAD_F_FRACBITS | ||
150 | }; | ||
151 | |||
152 | __asm { | ||
153 | mov eax, x | ||
154 | imul y | ||
155 | shrd eax, edx, fracbits | ||
156 | } | ||
157 | |||
158 | /* implicit return of eax */ | ||
159 | } | ||
160 | # pragma warning(pop) | ||
161 | |||
162 | # define mad_f_mul mad_f_mul_inline | ||
163 | # define mad_f_scale64 | ||
164 | # else | ||
119 | /* | 165 | /* |
120 | * This Intel version is fast and accurate; the disposition of the least | 166 | * This Intel version is fast and accurate; the disposition of the least |
121 | * significant bit depends on OPT_ACCURACY via mad_f_scale64(). | 167 | * significant bit depends on OPT_ACCURACY via mad_f_scale64(). |
122 | */ | 168 | */ |
123 | # define MAD_F_MLX(hi, lo, x, y) \ | 169 | # define MAD_F_MLX(hi, lo, x, y) \ |
124 | asm ("imull %3" \ | 170 | asm ("imull %3" \ |
@@ -171,12 +217,13 @@ typedef unsigned long mad_fixed64lo_t; | |||
171 | : "cc"); \ | 217 | : "cc"); \ |
172 | __result; \ | 218 | __result; \ |
173 | }) | 219 | }) |
174 | # endif /* OPT_ACCURACY */ | 220 | # endif /* OPT_ACCURACY */ |
175 | 221 | ||
176 | # define MAD_F_SCALEBITS MAD_F_FRACBITS | 222 | # define MAD_F_SCALEBITS MAD_F_FRACBITS |
223 | # endif | ||
177 | 224 | ||
178 | /* --- ARM ----------------------------------------------------------------- */ | 225 | /* --- ARM ----------------------------------------------------------------- */ |
179 | 226 | ||
180 | # elif defined(FPM_ARM) | 227 | # elif defined(FPM_ARM) |
181 | 228 | ||
182 | /* | 229 | /* |
@@ -214,12 +261,19 @@ typedef unsigned long mad_fixed64lo_t; | |||
214 | 261 | ||
215 | # define MAD_F_MLA(hi, lo, x, y) \ | 262 | # define MAD_F_MLA(hi, lo, x, y) \ |
216 | asm ("smlal%0, %1, %2, %3" \ | 263 | asm ("smlal%0, %1, %2, %3" \ |
217 | : "+r" (lo), "+r" (hi) \ | 264 | : "+r" (lo), "+r" (hi) \ |
218 | : "%r" (x), "r" (y)) | 265 | : "%r" (x), "r" (y)) |
219 | 266 | ||
267 | # define MAD_F_MLN(hi, lo) \ | ||
268 | asm ("rsbs%0, %2, #0\n\t" \ | ||
269 | "rsc%1, %3, #0" \ | ||
270 | : "=r" (lo), "=r" (hi) \ | ||
271 | : "0" (lo), "1" (hi) \ | ||
272 | : "cc") | ||
273 | |||
220 | # define mad_f_scale64(hi, lo) \ | 274 | # define mad_f_scale64(hi, lo) \ |
221 | ({ mad_fixed_t __result; \ | 275 | ({ mad_fixed_t __result; \ |
222 | asm ("movs%0, %1, lsr %3\n\t" \ | 276 | asm ("movs%0, %1, lsr %3\n\t" \ |
223 | "adc%0, %0, %2, lsl %4" \ | 277 | "adc%0, %0, %2, lsl %4" \ |
224 | : "=r" (__result) \ | 278 | : "=r" (__result) \ |
225 | : "r" (lo), "r" (hi), \ | 279 | : "r" (lo), "r" (hi), \ |
@@ -354,14 +408,18 @@ typedef unsigned long mad_fixed64lo_t; | |||
354 | * should be taken when ordering operands. | 408 | * should be taken when ordering operands. |
355 | * | 409 | * |
356 | * The scale factors are constant as this is not used with SSO. | 410 | * The scale factors are constant as this is not used with SSO. |
357 | * | 411 | * |
358 | * Pre-rounding is required to stay within the limits of compliance. | 412 | * Pre-rounding is required to stay within the limits of compliance. |
359 | */ | 413 | */ |
414 | # if defined(OPT_SPEED) | ||
415 | # define mad_f_mul(x, y)(((x) >> 12) * ((y) >> 16)) | ||
416 | # else | ||
360 | # define mad_f_mul(x, y)((((x) + (1L << 11)) >> 12) * \ | 417 | # define mad_f_mul(x, y)((((x) + (1L << 11)) >> 12) * \ |
361 | (((y) + (1L << 15)) >> 16)) | 418 | (((y) + (1L << 15)) >> 16)) |
419 | # endif | ||
362 | 420 | ||
363 | /* ------------------------------------------------------------------------- */ | 421 | /* ------------------------------------------------------------------------- */ |
364 | 422 | ||
365 | # else | 423 | # else |
366 | # error "no FPM selected" | 424 | # error "no FPM selected" |
367 | # endif | 425 | # endif |
@@ -377,19 +435,24 @@ typedef unsigned long mad_fixed64lo_t; | |||
377 | }) | 435 | }) |
378 | # endif | 436 | # endif |
379 | 437 | ||
380 | # if !defined(MAD_F_MLA) | 438 | # if !defined(MAD_F_MLA) |
381 | # define MAD_F_ML0(hi, lo, x, y)((lo) = mad_f_mul((x), (y))) | 439 | # define MAD_F_ML0(hi, lo, x, y)((lo) = mad_f_mul((x), (y))) |
382 | # define MAD_F_MLA(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))) |
441 | # define MAD_F_MLN(hi, lo) ((lo) = -(lo)) | ||
383 | # define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) | 442 | # define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) |
384 | # endif | 443 | # endif |
385 | 444 | ||
386 | # if !defined(MAD_F_ML0) | 445 | # if !defined(MAD_F_ML0) |
387 | # define MAD_F_ML0(hi, lo, x, y)MAD_F_MLX((hi), (lo), (x), (y)) | 446 | # define MAD_F_ML0(hi, lo, x, y)MAD_F_MLX((hi), (lo), (x), (y)) |
388 | # endif | 447 | # endif |
389 | 448 | ||
449 | # if !defined(MAD_F_MLN) | ||
450 | # define MAD_F_MLN(hi, lo) ((hi) = ((lo) = -(lo)) ? ~(hi) : -(hi)) | ||
451 | # endif | ||
452 | |||
390 | # if !defined(MAD_F_MLZ) | 453 | # if !defined(MAD_F_MLZ) |
391 | # define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo)) | 454 | # define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo)) |
392 | # endif | 455 | # endif |
393 | 456 | ||
394 | # if !defined(mad_f_scale64) | 457 | # if !defined(mad_f_scale64) |
395 | # if defined(OPT_ACCURACY) | 458 | # if defined(OPT_ACCURACY) |