Go to the source code of this file.
Defines | |
#define | mad_fixed64_t signed long long |
#define | MAD_F_FRACBITS 28 |
Changing the definition of MAD_F_FRACBITS is only partially supported, and must be done with care. | |
#define | MAD_F(x) ((mad_fixed_t) (x##L)) |
#define | MAD_F_MIN ((mad_fixed_t) -0x80000000L) |
#define | MAD_F_MAX ((mad_fixed_t) +0x7fffffffL) |
#define | MAD_F_ONE MAD_F(0x10000000) |
#define | mad_f_tofixed(x) |
#define | mad_f_todouble(x) |
#define | mad_f_intpart(x) ((x) >> MAD_F_FRACBITS) |
#define | mad_f_fracpart(x) ((x) & ((1L << MAD_F_FRACBITS) - 1)) |
#define | mad_f_fromint(x) ((x) << MAD_F_FRACBITS) |
#define | mad_f_add(x, y) ((x) + (y)) |
#define | mad_f_sub(x, y) ((x) - (y)) |
#define | mad_f_mul(x, y) |
#define | MAD_F_ML0(hi, lo, x, y) ((lo) = mad_f_mul((x), (y))) |
#define | MAD_F_MLA(hi, lo, x, y) ((lo) += mad_f_mul((x), (y))) |
#define | MAD_F_MLN(hi, lo) ((lo) = -(lo)) |
#define | MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) |
#define | mad_f_scale64(hi, lo) |
#define | MAD_F_SCALEBITS MAD_F_FRACBITS |
Typedefs | |
typedef signed long | mad_fixed_t |
typedef signed long | mad_fixed64hi_t |
typedef unsigned long | mad_fixed64lo_t |
typedef mad_fixed_t | mad_sample_t |
Functions | |
mad_fixed_t | mad_f_abs (mad_fixed_t) |
return absolute value of a fixed-point number. | |
mad_fixed_t | mad_f_div (mad_fixed_t, mad_fixed_t) |
perform division using fixed-point math. |
Fixed-point format: 0xABBBBBBB
A == whole part (sign + 3 bits) B == fractional part (28 bits)
Values are signed two's complement, so the effective range is:
0x80000000 to 0x7fffffff -8.0 to +7.9999999962747097015380859375
The smallest representable value is:
0x00000001 == 0.0000000037252902984619140625 (i.e. about 3.725e-9)
28 bits of fractional accuracy represent about 8.6 digits of decimal accuracy.
Fixed-point numbers can be added or subtracted as normal integers, but multiplication requires shifting the 64-bit result from 56 fractional bits back to 28 (and rounding.)
Definition in file fixed.h.
#define MAD_F | ( | x | ) | ((mad_fixed_t) (x##L)) |
#define MAD_F_FRACBITS 28 |
Changing the definition of MAD_F_FRACBITS is only partially supported, and must be done with care.
Definition at line 82 of file fixed.h.
Referenced by I_sample(), II_samples(), mad_f_div(), and scale().
#define mad_f_fracpart | ( | x | ) | ((x) & ((1L << MAD_F_FRACBITS) - 1)) |
#define mad_f_intpart | ( | x | ) | ((x) >> MAD_F_FRACBITS) |
#define MAD_F_MAX ((mad_fixed_t) +0x7fffffffL) |
#define MAD_F_MIN ((mad_fixed_t) -0x80000000L) |
#define MAD_F_ML0 | ( | hi, | |||
lo, | |||||
x, | |||||
y | ) | ((lo) = mad_f_mul((x), (y))) |
#define MAD_F_MLA | ( | hi, | |||
lo, | |||||
x, | |||||
y | ) | ((lo) += mad_f_mul((x), (y))) |
#define MAD_F_MLZ | ( | hi, | |||
lo | ) | ((void) (hi), (mad_fixed_t) (lo)) |
#define mad_f_mul | ( | x, | |||
y | ) |
Value:
({ register mad_fixed64hi_t __hi; \ register mad_fixed64lo_t __lo; \ MAD_F_MLX(__hi, __lo, (x), (y)); \ mad_f_scale64(__hi, __lo); \ })
Definition at line 462 of file fixed.h.
Referenced by dctIV(), fastsdct(), I_sample(), II_samples(), III_imdct_l(), III_imdct_s(), III_requantize(), III_stereo(), mad_layer_I(), mad_layer_II(), and sdctII().
#define MAD_F_ONE MAD_F(0x10000000) |
#define mad_f_scale64 | ( | hi, | |||
lo | ) |
Value:
((mad_fixed_t) \ (((hi) << (32 - MAD_F_SCALEBITS)) | \ ((lo) >> MAD_F_SCALEBITS)))
#define mad_f_todouble | ( | x | ) |
Value:
((double) \ ((x) / (double) (1L << MAD_F_FRACBITS)))
Definition at line 107 of file fixed.h.
Referenced by III_requantize().
#define mad_f_tofixed | ( | x | ) |
Value:
((mad_fixed_t) \ ((x) * (double) (1L << MAD_F_FRACBITS) + 0.5))
typedef signed long mad_fixed64hi_t |
typedef unsigned long mad_fixed64lo_t |
typedef signed long mad_fixed_t |
typedef mad_fixed_t mad_sample_t |
mad_fixed_t mad_f_abs | ( | mad_fixed_t | ) |
return absolute value of a fixed-point number.
Definition at line 36 of file fixed.c.
Referenced by mad_f_div().
mad_fixed_t mad_f_div | ( | mad_fixed_t | , | |
mad_fixed_t | ||||
) |
perform division using fixed-point math.
Definition at line 44 of file fixed.c.
References mad_f_abs(), MAD_F_FRACBITS, mad_f_intpart, MAD_F_MAX, and MAD_F_MIN.