fixed.h File Reference

Fixed-point format definitions and tools. More...

This graph shows which files directly or indirectly include this file:

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.


Detailed Description

Fixed-point format definitions and tools.

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 Documentation

#define MAD_F (  )     ((mad_fixed_t) (x##L))

Definition at line 85 of file fixed.h.

Referenced by dctIV(), fastsdct(), and sdctII().

#define mad_f_add ( x,
 )     ((x) + (y))

Definition at line 116 of file fixed.h.

#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) & ((1L << MAD_F_FRACBITS) - 1))

Definition at line 111 of file fixed.h.

#define mad_f_fromint (  )     ((x) << MAD_F_FRACBITS)

Definition at line 114 of file fixed.h.

#define mad_f_intpart (  )     ((x) >> MAD_F_FRACBITS)

Definition at line 110 of file fixed.h.

Referenced by mad_f_div().

#define MAD_F_MAX   ((mad_fixed_t) +0x7fffffffL)

Definition at line 101 of file fixed.h.

Referenced by III_requantize(), and mad_f_div().

#define MAD_F_MIN   ((mad_fixed_t) -0x80000000L)

Definition at line 100 of file fixed.h.

Referenced by mad_f_div().

#define MAD_F_ML0 ( hi,
lo,
x,
 )     ((lo) = mad_f_mul((x), (y)))

Definition at line 471 of file fixed.h.

Referenced by III_aliasreduce(), and III_imdct_s().

#define MAD_F_MLA ( hi,
lo,
x,
 )     ((lo) += mad_f_mul((x), (y)))

Definition at line 472 of file fixed.h.

Referenced by III_aliasreduce(), and III_imdct_s().

#define MAD_F_MLN ( hi,
lo   )     ((lo) = -(lo))

Definition at line 473 of file fixed.h.

#define MAD_F_MLZ ( hi,
lo   )     ((void) (hi), (mad_fixed_t) (lo))

Definition at line 474 of file fixed.h.

Referenced by III_aliasreduce(), and III_imdct_s().

#define mad_f_mul ( x,
 ) 

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)

Definition at line 103 of file fixed.h.

Referenced by I_sample(), and scale().

#define mad_f_scale64 ( hi,
lo   ) 

Value:

((mad_fixed_t)  \
     (((hi) << (32 - MAD_F_SCALEBITS)) |  \
      ((lo) >> MAD_F_SCALEBITS)))

Definition at line 496 of file fixed.h.

#define MAD_F_SCALEBITS   MAD_F_FRACBITS

Definition at line 501 of file fixed.h.

#define mad_f_sub ( x,
 )     ((x) - (y))

Definition at line 117 of file fixed.h.

#define mad_f_todouble (  ) 

Value:

((double)  \
                                 ((x) / (double) (1L << MAD_F_FRACBITS)))

Definition at line 107 of file fixed.h.

Referenced by III_requantize().

#define mad_f_tofixed (  ) 

Value:

((mad_fixed_t)  \
                                 ((x) * (double) (1L << MAD_F_FRACBITS) + 0.5))

Definition at line 105 of file fixed.h.

#define mad_fixed64_t   signed long long

Definition at line 40 of file fixed.h.


Typedef Documentation

typedef signed long mad_fixed64hi_t

Definition at line 33 of file fixed.h.

typedef unsigned long mad_fixed64lo_t

Definition at line 34 of file fixed.h.

typedef signed long mad_fixed_t

Definition at line 31 of file fixed.h.

Definition at line 46 of file fixed.h.


Function Documentation

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.

Here is the call graph for this function:


Generated on Tue Jun 10 12:14:17 2008 for libmad by  doxygen 1.5.5