annotate src/libmad-0.15.1b/fixed.h @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents 545efbb81310
children
rev   line source
cannam@85 1 /*
cannam@85 2 * libmad - MPEG audio decoder library
cannam@85 3 * Copyright (C) 2000-2004 Underbit Technologies, Inc.
cannam@85 4 *
cannam@85 5 * This program is free software; you can redistribute it and/or modify
cannam@85 6 * it under the terms of the GNU General Public License as published by
cannam@85 7 * the Free Software Foundation; either version 2 of the License, or
cannam@85 8 * (at your option) any later version.
cannam@85 9 *
cannam@85 10 * This program is distributed in the hope that it will be useful,
cannam@85 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@85 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cannam@85 13 * GNU General Public License for more details.
cannam@85 14 *
cannam@85 15 * You should have received a copy of the GNU General Public License
cannam@85 16 * along with this program; if not, write to the Free Software
cannam@85 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
cannam@85 18 *
cannam@85 19 * $Id: fixed.h,v 1.38 2004/02/17 02:02:03 rob Exp $
cannam@85 20 */
cannam@85 21
cannam@85 22 # ifndef LIBMAD_FIXED_H
cannam@85 23 # define LIBMAD_FIXED_H
cannam@85 24
cannam@85 25 # if SIZEOF_INT >= 4
cannam@85 26 typedef signed int mad_fixed_t;
cannam@85 27
cannam@85 28 typedef signed int mad_fixed64hi_t;
cannam@85 29 typedef unsigned int mad_fixed64lo_t;
cannam@85 30 # else
cannam@85 31 typedef signed long mad_fixed_t;
cannam@85 32
cannam@85 33 typedef signed long mad_fixed64hi_t;
cannam@85 34 typedef unsigned long mad_fixed64lo_t;
cannam@85 35 # endif
cannam@85 36
cannam@85 37 # if defined(_MSC_VER)
cannam@85 38 # define mad_fixed64_t signed __int64
cannam@85 39 # elif 1 || defined(__GNUC__)
cannam@85 40 # define mad_fixed64_t signed long long
cannam@85 41 # endif
cannam@85 42
cannam@85 43 # if defined(FPM_FLOAT)
cannam@85 44 typedef double mad_sample_t;
cannam@85 45 # else
cannam@85 46 typedef mad_fixed_t mad_sample_t;
cannam@85 47 # endif
cannam@85 48
cannam@85 49 /*
cannam@85 50 * Fixed-point format: 0xABBBBBBB
cannam@85 51 * A == whole part (sign + 3 bits)
cannam@85 52 * B == fractional part (28 bits)
cannam@85 53 *
cannam@85 54 * Values are signed two's complement, so the effective range is:
cannam@85 55 * 0x80000000 to 0x7fffffff
cannam@85 56 * -8.0 to +7.9999999962747097015380859375
cannam@85 57 *
cannam@85 58 * The smallest representable value is:
cannam@85 59 * 0x00000001 == 0.0000000037252902984619140625 (i.e. about 3.725e-9)
cannam@85 60 *
cannam@85 61 * 28 bits of fractional accuracy represent about
cannam@85 62 * 8.6 digits of decimal accuracy.
cannam@85 63 *
cannam@85 64 * Fixed-point numbers can be added or subtracted as normal
cannam@85 65 * integers, but multiplication requires shifting the 64-bit result
cannam@85 66 * from 56 fractional bits back to 28 (and rounding.)
cannam@85 67 *
cannam@85 68 * Changing the definition of MAD_F_FRACBITS is only partially
cannam@85 69 * supported, and must be done with care.
cannam@85 70 */
cannam@85 71
cannam@85 72 # define MAD_F_FRACBITS 28
cannam@85 73
cannam@85 74 # if MAD_F_FRACBITS == 28
cannam@85 75 # define MAD_F(x) ((mad_fixed_t) (x##L))
cannam@85 76 # else
cannam@85 77 # if MAD_F_FRACBITS < 28
cannam@85 78 # warning "MAD_F_FRACBITS < 28"
cannam@85 79 # define MAD_F(x) ((mad_fixed_t) \
cannam@85 80 (((x##L) + \
cannam@85 81 (1L << (28 - MAD_F_FRACBITS - 1))) >> \
cannam@85 82 (28 - MAD_F_FRACBITS)))
cannam@85 83 # elif MAD_F_FRACBITS > 28
cannam@85 84 # error "MAD_F_FRACBITS > 28 not currently supported"
cannam@85 85 # define MAD_F(x) ((mad_fixed_t) \
cannam@85 86 ((x##L) << (MAD_F_FRACBITS - 28)))
cannam@85 87 # endif
cannam@85 88 # endif
cannam@85 89
cannam@85 90 # define MAD_F_MIN ((mad_fixed_t) -0x80000000L)
cannam@85 91 # define MAD_F_MAX ((mad_fixed_t) +0x7fffffffL)
cannam@85 92
cannam@85 93 # define MAD_F_ONE MAD_F(0x10000000)
cannam@85 94
cannam@85 95 # define mad_f_tofixed(x) ((mad_fixed_t) \
cannam@85 96 ((x) * (double) (1L << MAD_F_FRACBITS) + 0.5))
cannam@85 97 # define mad_f_todouble(x) ((double) \
cannam@85 98 ((x) / (double) (1L << MAD_F_FRACBITS)))
cannam@85 99
cannam@85 100 # define mad_f_intpart(x) ((x) >> MAD_F_FRACBITS)
cannam@85 101 # define mad_f_fracpart(x) ((x) & ((1L << MAD_F_FRACBITS) - 1))
cannam@85 102 /* (x should be positive) */
cannam@85 103
cannam@85 104 # define mad_f_fromint(x) ((x) << MAD_F_FRACBITS)
cannam@85 105
cannam@85 106 # define mad_f_add(x, y) ((x) + (y))
cannam@85 107 # define mad_f_sub(x, y) ((x) - (y))
cannam@85 108
cannam@85 109 # if defined(FPM_FLOAT)
cannam@85 110 # error "FPM_FLOAT not yet supported"
cannam@85 111
cannam@85 112 # undef MAD_F
cannam@85 113 # define MAD_F(x) mad_f_todouble(x)
cannam@85 114
cannam@85 115 # define mad_f_mul(x, y) ((x) * (y))
cannam@85 116 # define mad_f_scale64
cannam@85 117
cannam@85 118 # undef ASO_ZEROCHECK
cannam@85 119
cannam@85 120 # elif defined(FPM_64BIT)
cannam@85 121
cannam@85 122 /*
cannam@85 123 * This version should be the most accurate if 64-bit types are supported by
cannam@85 124 * the compiler, although it may not be the most efficient.
cannam@85 125 */
cannam@85 126 # if defined(OPT_ACCURACY)
cannam@85 127 # define mad_f_mul(x, y) \
cannam@85 128 ((mad_fixed_t) \
cannam@85 129 ((((mad_fixed64_t) (x) * (y)) + \
cannam@85 130 (1L << (MAD_F_SCALEBITS - 1))) >> MAD_F_SCALEBITS))
cannam@85 131 # else
cannam@85 132 # define mad_f_mul(x, y) \
cannam@85 133 ((mad_fixed_t) (((mad_fixed64_t) (x) * (y)) >> MAD_F_SCALEBITS))
cannam@85 134 # endif
cannam@85 135
cannam@85 136 # define MAD_F_SCALEBITS MAD_F_FRACBITS
cannam@85 137
cannam@85 138 /* --- Intel --------------------------------------------------------------- */
cannam@85 139
cannam@85 140 # elif defined(FPM_INTEL)
cannam@85 141
cannam@85 142 # if defined(_MSC_VER)
cannam@85 143 # pragma warning(push)
cannam@85 144 # pragma warning(disable: 4035) /* no return value */
cannam@85 145 static __forceinline
cannam@85 146 mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
cannam@85 147 {
cannam@85 148 enum {
cannam@85 149 fracbits = MAD_F_FRACBITS
cannam@85 150 };
cannam@85 151
cannam@85 152 __asm {
cannam@85 153 mov eax, x
cannam@85 154 imul y
cannam@85 155 shrd eax, edx, fracbits
cannam@85 156 }
cannam@85 157
cannam@85 158 /* implicit return of eax */
cannam@85 159 }
cannam@85 160 # pragma warning(pop)
cannam@85 161
cannam@85 162 # define mad_f_mul mad_f_mul_inline
cannam@85 163 # define mad_f_scale64
cannam@85 164 # else
cannam@85 165 /*
cannam@85 166 * This Intel version is fast and accurate; the disposition of the least
cannam@85 167 * significant bit depends on OPT_ACCURACY via mad_f_scale64().
cannam@85 168 */
cannam@85 169 # define MAD_F_MLX(hi, lo, x, y) \
cannam@85 170 asm ("imull %3" \
cannam@85 171 : "=a" (lo), "=d" (hi) \
cannam@85 172 : "%a" (x), "rm" (y) \
cannam@85 173 : "cc")
cannam@85 174
cannam@85 175 # if defined(OPT_ACCURACY)
cannam@85 176 /*
cannam@85 177 * This gives best accuracy but is not very fast.
cannam@85 178 */
cannam@85 179 # define MAD_F_MLA(hi, lo, x, y) \
cannam@85 180 ({ mad_fixed64hi_t __hi; \
cannam@85 181 mad_fixed64lo_t __lo; \
cannam@85 182 MAD_F_MLX(__hi, __lo, (x), (y)); \
cannam@85 183 asm ("addl %2,%0\n\t" \
cannam@85 184 "adcl %3,%1" \
cannam@85 185 : "=rm" (lo), "=rm" (hi) \
cannam@85 186 : "r" (__lo), "r" (__hi), "0" (lo), "1" (hi) \
cannam@85 187 : "cc"); \
cannam@85 188 })
cannam@85 189 # endif /* OPT_ACCURACY */
cannam@85 190
cannam@85 191 # if defined(OPT_ACCURACY)
cannam@85 192 /*
cannam@85 193 * Surprisingly, this is faster than SHRD followed by ADC.
cannam@85 194 */
cannam@85 195 # define mad_f_scale64(hi, lo) \
cannam@85 196 ({ mad_fixed64hi_t __hi_; \
cannam@85 197 mad_fixed64lo_t __lo_; \
cannam@85 198 mad_fixed_t __result; \
cannam@85 199 asm ("addl %4,%2\n\t" \
cannam@85 200 "adcl %5,%3" \
cannam@85 201 : "=rm" (__lo_), "=rm" (__hi_) \
cannam@85 202 : "0" (lo), "1" (hi), \
cannam@85 203 "ir" (1L << (MAD_F_SCALEBITS - 1)), "ir" (0) \
cannam@85 204 : "cc"); \
cannam@85 205 asm ("shrdl %3,%2,%1" \
cannam@85 206 : "=rm" (__result) \
cannam@85 207 : "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \
cannam@85 208 : "cc"); \
cannam@85 209 __result; \
cannam@85 210 })
cannam@85 211 # elif defined(OPT_INTEL)
cannam@85 212 /*
cannam@85 213 * Alternate Intel scaling that may or may not perform better.
cannam@85 214 */
cannam@85 215 # define mad_f_scale64(hi, lo) \
cannam@85 216 ({ mad_fixed_t __result; \
cannam@85 217 asm ("shrl %3,%1\n\t" \
cannam@85 218 "shll %4,%2\n\t" \
cannam@85 219 "orl %2,%1" \
cannam@85 220 : "=rm" (__result) \
cannam@85 221 : "0" (lo), "r" (hi), \
cannam@85 222 "I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS) \
cannam@85 223 : "cc"); \
cannam@85 224 __result; \
cannam@85 225 })
cannam@85 226 # else
cannam@85 227 # define mad_f_scale64(hi, lo) \
cannam@85 228 ({ mad_fixed_t __result; \
cannam@85 229 asm ("shrdl %3,%2,%1" \
cannam@85 230 : "=rm" (__result) \
cannam@85 231 : "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \
cannam@85 232 : "cc"); \
cannam@85 233 __result; \
cannam@85 234 })
cannam@85 235 # endif /* OPT_ACCURACY */
cannam@85 236
cannam@85 237 # define MAD_F_SCALEBITS MAD_F_FRACBITS
cannam@85 238 # endif
cannam@85 239
cannam@85 240 /* --- ARM ----------------------------------------------------------------- */
cannam@85 241
cannam@85 242 # elif defined(FPM_ARM)
cannam@85 243
cannam@85 244 /*
cannam@85 245 * This ARM V4 version is as accurate as FPM_64BIT but much faster. The
cannam@85 246 * least significant bit is properly rounded at no CPU cycle cost!
cannam@85 247 */
cannam@85 248 # if 1
cannam@85 249 /*
cannam@85 250 * This is faster than the default implementation via MAD_F_MLX() and
cannam@85 251 * mad_f_scale64().
cannam@85 252 */
cannam@85 253 # define mad_f_mul(x, y) \
cannam@85 254 ({ mad_fixed64hi_t __hi; \
cannam@85 255 mad_fixed64lo_t __lo; \
cannam@85 256 mad_fixed_t __result; \
cannam@85 257 asm ("smull %0, %1, %3, %4\n\t" \
cannam@85 258 "movs %0, %0, lsr %5\n\t" \
cannam@85 259 "adc %2, %0, %1, lsl %6" \
cannam@85 260 : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \
cannam@85 261 : "%r" (x), "r" (y), \
cannam@85 262 "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \
cannam@85 263 : "cc"); \
cannam@85 264 __result; \
cannam@85 265 })
cannam@85 266 # endif
cannam@85 267
cannam@85 268 # define MAD_F_MLX(hi, lo, x, y) \
cannam@85 269 asm ("smull %0, %1, %2, %3" \
cannam@85 270 : "=&r" (lo), "=&r" (hi) \
cannam@85 271 : "%r" (x), "r" (y))
cannam@85 272
cannam@85 273 # define MAD_F_MLA(hi, lo, x, y) \
cannam@85 274 asm ("smlal %0, %1, %2, %3" \
cannam@85 275 : "+r" (lo), "+r" (hi) \
cannam@85 276 : "%r" (x), "r" (y))
cannam@85 277
cannam@85 278 # define MAD_F_MLN(hi, lo) \
cannam@85 279 asm ("rsbs %0, %2, #0\n\t" \
cannam@85 280 "rsc %1, %3, #0" \
cannam@85 281 : "=r" (lo), "=r" (hi) \
cannam@85 282 : "0" (lo), "1" (hi) \
cannam@85 283 : "cc")
cannam@85 284
cannam@85 285 # define mad_f_scale64(hi, lo) \
cannam@85 286 ({ mad_fixed_t __result; \
cannam@85 287 asm ("movs %0, %1, lsr %3\n\t" \
cannam@85 288 "adc %0, %0, %2, lsl %4" \
cannam@85 289 : "=&r" (__result) \
cannam@85 290 : "r" (lo), "r" (hi), \
cannam@85 291 "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \
cannam@85 292 : "cc"); \
cannam@85 293 __result; \
cannam@85 294 })
cannam@85 295
cannam@85 296 # define MAD_F_SCALEBITS MAD_F_FRACBITS
cannam@85 297
cannam@85 298 /* --- MIPS ---------------------------------------------------------------- */
cannam@85 299
cannam@85 300 # elif defined(FPM_MIPS)
cannam@85 301
cannam@85 302 /*
cannam@85 303 * This MIPS version is fast and accurate; the disposition of the least
cannam@85 304 * significant bit depends on OPT_ACCURACY via mad_f_scale64().
cannam@85 305 */
cannam@85 306 # define MAD_F_MLX(hi, lo, x, y) \
cannam@85 307 asm ("mult %2,%3" \
cannam@85 308 : "=l" (lo), "=h" (hi) \
cannam@85 309 : "%r" (x), "r" (y))
cannam@85 310
cannam@85 311 # if defined(HAVE_MADD_ASM)
cannam@85 312 # define MAD_F_MLA(hi, lo, x, y) \
cannam@85 313 asm ("madd %2,%3" \
cannam@85 314 : "+l" (lo), "+h" (hi) \
cannam@85 315 : "%r" (x), "r" (y))
cannam@85 316 # elif defined(HAVE_MADD16_ASM)
cannam@85 317 /*
cannam@85 318 * This loses significant accuracy due to the 16-bit integer limit in the
cannam@85 319 * multiply/accumulate instruction.
cannam@85 320 */
cannam@85 321 # define MAD_F_ML0(hi, lo, x, y) \
cannam@85 322 asm ("mult %2,%3" \
cannam@85 323 : "=l" (lo), "=h" (hi) \
cannam@85 324 : "%r" ((x) >> 12), "r" ((y) >> 16))
cannam@85 325 # define MAD_F_MLA(hi, lo, x, y) \
cannam@85 326 asm ("madd16 %2,%3" \
cannam@85 327 : "+l" (lo), "+h" (hi) \
cannam@85 328 : "%r" ((x) >> 12), "r" ((y) >> 16))
cannam@85 329 # define MAD_F_MLZ(hi, lo) ((mad_fixed_t) (lo))
cannam@85 330 # endif
cannam@85 331
cannam@85 332 # if defined(OPT_SPEED)
cannam@85 333 # define mad_f_scale64(hi, lo) \
cannam@85 334 ((mad_fixed_t) ((hi) << (32 - MAD_F_SCALEBITS)))
cannam@85 335 # define MAD_F_SCALEBITS MAD_F_FRACBITS
cannam@85 336 # endif
cannam@85 337
cannam@85 338 /* --- SPARC --------------------------------------------------------------- */
cannam@85 339
cannam@85 340 # elif defined(FPM_SPARC)
cannam@85 341
cannam@85 342 /*
cannam@85 343 * This SPARC V8 version is fast and accurate; the disposition of the least
cannam@85 344 * significant bit depends on OPT_ACCURACY via mad_f_scale64().
cannam@85 345 */
cannam@85 346 # define MAD_F_MLX(hi, lo, x, y) \
cannam@85 347 asm ("smul %2, %3, %0\n\t" \
cannam@85 348 "rd %%y, %1" \
cannam@85 349 : "=r" (lo), "=r" (hi) \
cannam@85 350 : "%r" (x), "rI" (y))
cannam@85 351
cannam@85 352 /* --- PowerPC ------------------------------------------------------------- */
cannam@85 353
cannam@85 354 # elif defined(FPM_PPC)
cannam@85 355
cannam@85 356 /*
cannam@85 357 * This PowerPC version is fast and accurate; the disposition of the least
cannam@85 358 * significant bit depends on OPT_ACCURACY via mad_f_scale64().
cannam@85 359 */
cannam@85 360 # define MAD_F_MLX(hi, lo, x, y) \
cannam@85 361 do { \
cannam@85 362 asm ("mullw %0,%1,%2" \
cannam@85 363 : "=r" (lo) \
cannam@85 364 : "%r" (x), "r" (y)); \
cannam@85 365 asm ("mulhw %0,%1,%2" \
cannam@85 366 : "=r" (hi) \
cannam@85 367 : "%r" (x), "r" (y)); \
cannam@85 368 } \
cannam@85 369 while (0)
cannam@85 370
cannam@85 371 # if defined(OPT_ACCURACY)
cannam@85 372 /*
cannam@85 373 * This gives best accuracy but is not very fast.
cannam@85 374 */
cannam@85 375 # define MAD_F_MLA(hi, lo, x, y) \
cannam@85 376 ({ mad_fixed64hi_t __hi; \
cannam@85 377 mad_fixed64lo_t __lo; \
cannam@85 378 MAD_F_MLX(__hi, __lo, (x), (y)); \
cannam@85 379 asm ("addc %0,%2,%3\n\t" \
cannam@85 380 "adde %1,%4,%5" \
cannam@85 381 : "=r" (lo), "=r" (hi) \
cannam@85 382 : "%r" (lo), "r" (__lo), \
cannam@85 383 "%r" (hi), "r" (__hi) \
cannam@85 384 : "xer"); \
cannam@85 385 })
cannam@85 386 # endif
cannam@85 387
cannam@85 388 # if defined(OPT_ACCURACY)
cannam@85 389 /*
cannam@85 390 * This is slower than the truncating version below it.
cannam@85 391 */
cannam@85 392 # define mad_f_scale64(hi, lo) \
cannam@85 393 ({ mad_fixed_t __result, __round; \
cannam@85 394 asm ("rotrwi %0,%1,%2" \
cannam@85 395 : "=r" (__result) \
cannam@85 396 : "r" (lo), "i" (MAD_F_SCALEBITS)); \
cannam@85 397 asm ("extrwi %0,%1,1,0" \
cannam@85 398 : "=r" (__round) \
cannam@85 399 : "r" (__result)); \
cannam@85 400 asm ("insrwi %0,%1,%2,0" \
cannam@85 401 : "+r" (__result) \
cannam@85 402 : "r" (hi), "i" (MAD_F_SCALEBITS)); \
cannam@85 403 asm ("add %0,%1,%2" \
cannam@85 404 : "=r" (__result) \
cannam@85 405 : "%r" (__result), "r" (__round)); \
cannam@85 406 __result; \
cannam@85 407 })
cannam@85 408 # else
cannam@85 409 # define mad_f_scale64(hi, lo) \
cannam@85 410 ({ mad_fixed_t __result; \
cannam@85 411 asm ("rotrwi %0,%1,%2" \
cannam@85 412 : "=r" (__result) \
cannam@85 413 : "r" (lo), "i" (MAD_F_SCALEBITS)); \
cannam@85 414 asm ("insrwi %0,%1,%2,0" \
cannam@85 415 : "+r" (__result) \
cannam@85 416 : "r" (hi), "i" (MAD_F_SCALEBITS)); \
cannam@85 417 __result; \
cannam@85 418 })
cannam@85 419 # endif
cannam@85 420
cannam@85 421 # define MAD_F_SCALEBITS MAD_F_FRACBITS
cannam@85 422
cannam@85 423 /* --- Default ------------------------------------------------------------- */
cannam@85 424
cannam@85 425 # elif defined(FPM_DEFAULT)
cannam@85 426
cannam@85 427 /*
cannam@85 428 * This version is the most portable but it loses significant accuracy.
cannam@85 429 * Furthermore, accuracy is biased against the second argument, so care
cannam@85 430 * should be taken when ordering operands.
cannam@85 431 *
cannam@85 432 * The scale factors are constant as this is not used with SSO.
cannam@85 433 *
cannam@85 434 * Pre-rounding is required to stay within the limits of compliance.
cannam@85 435 */
cannam@85 436 # if defined(OPT_SPEED)
cannam@85 437 # define mad_f_mul(x, y) (((x) >> 12) * ((y) >> 16))
cannam@85 438 # else
cannam@85 439 # define mad_f_mul(x, y) ((((x) + (1L << 11)) >> 12) * \
cannam@85 440 (((y) + (1L << 15)) >> 16))
cannam@85 441 # endif
cannam@85 442
cannam@85 443 /* ------------------------------------------------------------------------- */
cannam@85 444
cannam@85 445 # else
cannam@85 446 # error "no FPM selected"
cannam@85 447 # endif
cannam@85 448
cannam@85 449 /* default implementations */
cannam@85 450
cannam@85 451 # if !defined(mad_f_mul)
cannam@85 452 # define mad_f_mul(x, y) \
cannam@85 453 ({ register mad_fixed64hi_t __hi; \
cannam@85 454 register mad_fixed64lo_t __lo; \
cannam@85 455 MAD_F_MLX(__hi, __lo, (x), (y)); \
cannam@85 456 mad_f_scale64(__hi, __lo); \
cannam@85 457 })
cannam@85 458 # endif
cannam@85 459
cannam@85 460 # if !defined(MAD_F_MLA)
cannam@85 461 # define MAD_F_ML0(hi, lo, x, y) ((lo) = mad_f_mul((x), (y)))
cannam@85 462 # define MAD_F_MLA(hi, lo, x, y) ((lo) += mad_f_mul((x), (y)))
cannam@85 463 # define MAD_F_MLN(hi, lo) ((lo) = -(lo))
cannam@85 464 # define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo))
cannam@85 465 # endif
cannam@85 466
cannam@85 467 # if !defined(MAD_F_ML0)
cannam@85 468 # define MAD_F_ML0(hi, lo, x, y) MAD_F_MLX((hi), (lo), (x), (y))
cannam@85 469 # endif
cannam@85 470
cannam@85 471 # if !defined(MAD_F_MLN)
cannam@85 472 # define MAD_F_MLN(hi, lo) ((hi) = ((lo) = -(lo)) ? ~(hi) : -(hi))
cannam@85 473 # endif
cannam@85 474
cannam@85 475 # if !defined(MAD_F_MLZ)
cannam@85 476 # define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo))
cannam@85 477 # endif
cannam@85 478
cannam@85 479 # if !defined(mad_f_scale64)
cannam@85 480 # if defined(OPT_ACCURACY)
cannam@85 481 # define mad_f_scale64(hi, lo) \
cannam@85 482 ((((mad_fixed_t) \
cannam@85 483 (((hi) << (32 - (MAD_F_SCALEBITS - 1))) | \
cannam@85 484 ((lo) >> (MAD_F_SCALEBITS - 1)))) + 1) >> 1)
cannam@85 485 # else
cannam@85 486 # define mad_f_scale64(hi, lo) \
cannam@85 487 ((mad_fixed_t) \
cannam@85 488 (((hi) << (32 - MAD_F_SCALEBITS)) | \
cannam@85 489 ((lo) >> MAD_F_SCALEBITS)))
cannam@85 490 # endif
cannam@85 491 # define MAD_F_SCALEBITS MAD_F_FRACBITS
cannam@85 492 # endif
cannam@85 493
cannam@85 494 /* C routines */
cannam@85 495
cannam@85 496 mad_fixed_t mad_f_abs(mad_fixed_t);
cannam@85 497 mad_fixed_t mad_f_div(mad_fixed_t, mad_fixed_t);
cannam@85 498
cannam@85 499 # endif