00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 # ifndef LIBMAD_TIMER_H
00023 # define LIBMAD_TIMER_H
00024
00025 typedef struct {
00026 signed long seconds;
00027 unsigned long fraction;
00028 } mad_timer_t;
00029
00030 extern mad_timer_t const mad_timer_zero;
00031
00032 # define MAD_TIMER_RESOLUTION 352800000UL
00033
00034 enum mad_units {
00035 MAD_UNITS_HOURS = -2,
00036 MAD_UNITS_MINUTES = -1,
00037 MAD_UNITS_SECONDS = 0,
00038
00039
00040
00041 MAD_UNITS_DECISECONDS = 10,
00042 MAD_UNITS_CENTISECONDS = 100,
00043 MAD_UNITS_MILLISECONDS = 1000,
00044
00045
00046
00047 MAD_UNITS_8000_HZ = 8000,
00048 MAD_UNITS_11025_HZ = 11025,
00049 MAD_UNITS_12000_HZ = 12000,
00050
00051 MAD_UNITS_16000_HZ = 16000,
00052 MAD_UNITS_22050_HZ = 22050,
00053 MAD_UNITS_24000_HZ = 24000,
00054
00055 MAD_UNITS_32000_HZ = 32000,
00056 MAD_UNITS_44100_HZ = 44100,
00057 MAD_UNITS_48000_HZ = 48000,
00058
00059
00060
00061 MAD_UNITS_24_FPS = 24,
00062 MAD_UNITS_25_FPS = 25,
00063 MAD_UNITS_30_FPS = 30,
00064 MAD_UNITS_48_FPS = 48,
00065 MAD_UNITS_50_FPS = 50,
00066 MAD_UNITS_60_FPS = 60,
00067
00068
00069
00070 MAD_UNITS_75_FPS = 75,
00071
00072
00073
00074 MAD_UNITS_23_976_FPS = -24,
00075 MAD_UNITS_24_975_FPS = -25,
00076 MAD_UNITS_29_97_FPS = -30,
00077 MAD_UNITS_47_952_FPS = -48,
00078 MAD_UNITS_49_95_FPS = -50,
00079 MAD_UNITS_59_94_FPS = -60
00080 };
00081
00082 # define mad_timer_reset(timer) ((void) (*(timer) = mad_timer_zero))
00083
00084 int mad_timer_compare(mad_timer_t, mad_timer_t);
00085
00086 # define mad_timer_sign(timer) mad_timer_compare((timer), mad_timer_zero)
00087
00088 void mad_timer_negate(mad_timer_t *);
00089 mad_timer_t mad_timer_abs(mad_timer_t);
00090
00091 void mad_timer_set(mad_timer_t *, unsigned long, unsigned long, unsigned long);
00092 void mad_timer_add(mad_timer_t *, mad_timer_t);
00093 void mad_timer_multiply(mad_timer_t *, signed long);
00094
00095 signed long mad_timer_count(mad_timer_t, enum mad_units);
00096 unsigned long mad_timer_fraction(mad_timer_t, unsigned long);
00097 void mad_timer_string(mad_timer_t, char *, char const *,
00098 enum mad_units, enum mad_units, unsigned long);
00099
00100 # endif