#include "global.h"
#include <stdio.h>
#include "timer.h"

Go to the source code of this file.
Functions | |
| int | mad_timer_compare (mad_timer_t timer1, mad_timer_t timer2) |
| Indicates relative order of two timers. | |
| void | mad_timer_negate (mad_timer_t *timer) |
| Inverts the sign of a timer. | |
| mad_timer_t | mad_timer_abs (mad_timer_t timer) |
| Returns the absolute value of a timer. | |
| static void | reduce_timer (mad_timer_t *timer) |
| Carrys timer fraction into seconds. | |
| static unsigned long | gcd (unsigned long num1, unsigned long num2) |
| Computes greatest common denominator. | |
| static void | reduce_rational (unsigned long *numer, unsigned long *denom) |
| Converts rational expression to lowest terms. | |
| static unsigned long | scale_rational (unsigned long numer, unsigned long denom, unsigned long scale) |
| Solves numer/denom == ?/scale avoiding overflowing. | |
| void | mad_timer_set (mad_timer_t *timer, unsigned long seconds, unsigned long numer, unsigned long denom) |
| Sets timer to specific (positive) value. | |
| void | mad_timer_add (mad_timer_t *timer, mad_timer_t incr) |
| Adds one timer to another. | |
| void | mad_timer_multiply (mad_timer_t *timer, signed long scalar) |
| Multiplies a timer by a scalar value. | |
| signed long | mad_timer_count (mad_timer_t timer, enum mad_units units) |
| Returns timer value in selected units. | |
| unsigned long | mad_timer_fraction (mad_timer_t timer, unsigned long denom) |
| Returns fractional part of timer in arbitrary terms. | |
| void | mad_timer_string (mad_timer_t timer, char *dest, char const *format, enum mad_units units, enum mad_units fracunits, unsigned long subparts) |
| Writes a string representation of a timer using a template. | |
Variables | |
| mad_timer_t const | mad_timer_zero = { 0, 0 } |
Definition in file timer.c.
| static unsigned long gcd | ( | unsigned long | num1, | |
| unsigned long | num2 | |||
| ) | [static] |
Computes greatest common denominator.
Definition at line 101 of file timer.c.
Referenced by reduce_rational().
| mad_timer_t mad_timer_abs | ( | mad_timer_t | timer | ) |
Returns the absolute value of a timer.
Definition at line 79 of file timer.c.
References mad_timer_negate(), and mad_timer_t::seconds.
Referenced by mad_timer_fraction(), and mad_timer_string().

| void mad_timer_add | ( | mad_timer_t * | timer, | |
| mad_timer_t | incr | |||
| ) |
Adds one timer to another.
Definition at line 224 of file timer.c.
References mad_timer_t::fraction, MAD_TIMER_RESOLUTION, reduce_timer(), and mad_timer_t::seconds.
Referenced by mad_timer_multiply().

| int mad_timer_compare | ( | mad_timer_t | timer1, | |
| mad_timer_t | timer2 | |||
| ) |
Indicates relative order of two timers.
Definition at line 44 of file timer.c.
References mad_timer_t::fraction, and mad_timer_t::seconds.
| signed long mad_timer_count | ( | mad_timer_t | timer, | |
| enum mad_units | units | |||
| ) |
Returns timer value in selected units.
Definition at line 262 of file timer.c.
References mad_timer_t::fraction, mad_timer_count(), MAD_TIMER_RESOLUTION, MAD_UNITS_11025_HZ, MAD_UNITS_12000_HZ, MAD_UNITS_16000_HZ, MAD_UNITS_22050_HZ, MAD_UNITS_23_976_FPS, MAD_UNITS_24000_HZ, MAD_UNITS_24_975_FPS, MAD_UNITS_24_FPS, MAD_UNITS_25_FPS, MAD_UNITS_29_97_FPS, MAD_UNITS_30_FPS, MAD_UNITS_32000_HZ, MAD_UNITS_44100_HZ, MAD_UNITS_47_952_FPS, MAD_UNITS_48000_HZ, MAD_UNITS_48_FPS, MAD_UNITS_49_95_FPS, MAD_UNITS_50_FPS, MAD_UNITS_59_94_FPS, MAD_UNITS_60_FPS, MAD_UNITS_75_FPS, MAD_UNITS_8000_HZ, MAD_UNITS_CENTISECONDS, MAD_UNITS_DECISECONDS, MAD_UNITS_HOURS, MAD_UNITS_MILLISECONDS, MAD_UNITS_MINUTES, MAD_UNITS_SECONDS, scale_rational(), and mad_timer_t::seconds.
Referenced by mad_timer_count(), and mad_timer_string().

| unsigned long mad_timer_fraction | ( | mad_timer_t | timer, | |
| unsigned long | denom | |||
| ) |
Returns fractional part of timer in arbitrary terms.
Definition at line 315 of file timer.c.
References mad_timer_t::fraction, mad_timer_abs(), MAD_TIMER_RESOLUTION, and scale_rational().

| void mad_timer_multiply | ( | mad_timer_t * | timer, | |
| signed long | scalar | |||
| ) |
Multiplies a timer by a scalar value.
Definition at line 236 of file timer.c.
References mad_timer_add(), and mad_timer_negate().

| void mad_timer_negate | ( | mad_timer_t * | timer | ) |
Inverts the sign of a timer.
Definition at line 66 of file timer.c.
References mad_timer_t::fraction, MAD_TIMER_RESOLUTION, and mad_timer_t::seconds.
Referenced by mad_timer_abs(), and mad_timer_multiply().
| void mad_timer_set | ( | mad_timer_t * | timer, | |
| unsigned long | seconds, | |||
| unsigned long | numer, | |||
| unsigned long | denom | |||
| ) |
Sets timer to specific (positive) value.
Definition at line 153 of file timer.c.
References mad_timer_t::fraction, MAD_TIMER_RESOLUTION, reduce_timer(), scale_rational(), and mad_timer_t::seconds.
Referenced by mad_header_decode().

| void mad_timer_string | ( | mad_timer_t | timer, | |
| char * | dest, | |||
| char const * | format, | |||
| enum mad_units | units, | |||
| enum mad_units | fracunits, | |||
| unsigned long | subparts | |||
| ) |
Writes a string representation of a timer using a template.
Definition at line 335 of file timer.c.
References mad_timer_t::fraction, m, mad_timer_abs(), mad_timer_count(), MAD_TIMER_RESOLUTION, MAD_UNITS_11025_HZ, MAD_UNITS_12000_HZ, MAD_UNITS_16000_HZ, MAD_UNITS_22050_HZ, MAD_UNITS_23_976_FPS, MAD_UNITS_24000_HZ, MAD_UNITS_24_975_FPS, MAD_UNITS_24_FPS, MAD_UNITS_25_FPS, MAD_UNITS_29_97_FPS, MAD_UNITS_30_FPS, MAD_UNITS_32000_HZ, MAD_UNITS_44100_HZ, MAD_UNITS_47_952_FPS, MAD_UNITS_48000_HZ, MAD_UNITS_48_FPS, MAD_UNITS_49_95_FPS, MAD_UNITS_50_FPS, MAD_UNITS_59_94_FPS, MAD_UNITS_60_FPS, MAD_UNITS_75_FPS, MAD_UNITS_8000_HZ, MAD_UNITS_CENTISECONDS, MAD_UNITS_DECISECONDS, MAD_UNITS_HOURS, MAD_UNITS_MILLISECONDS, MAD_UNITS_MINUTES, MAD_UNITS_SECONDS, scale_rational(), and mad_timer_t::seconds.

| static void reduce_rational | ( | unsigned long * | numer, | |
| unsigned long * | denom | |||
| ) | [static] |
Converts rational expression to lowest terms.
Definition at line 118 of file timer.c.
Referenced by scale_rational().

| static void reduce_timer | ( | mad_timer_t * | timer | ) | [static] |
Carrys timer fraction into seconds.
Definition at line 91 of file timer.c.
References mad_timer_t::fraction, MAD_TIMER_RESOLUTION, and mad_timer_t::seconds.
Referenced by mad_timer_add(), and mad_timer_set().
| static unsigned long scale_rational | ( | unsigned long | numer, | |
| unsigned long | denom, | |||
| unsigned long | scale | |||
| ) | [static] |
Solves numer/denom == ?/scale avoiding overflowing.
Definition at line 134 of file timer.c.
References assert, and reduce_rational().
Referenced by mad_timer_count(), mad_timer_fraction(), mad_timer_set(), and mad_timer_string().

| mad_timer_t const mad_timer_zero = { 0, 0 } |
1.5.5