diff options
Diffstat (limited to 'apps/codecs/libmad/timer.c')
-rw-r--r-- | apps/codecs/libmad/timer.c | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/apps/codecs/libmad/timer.c b/apps/codecs/libmad/timer.c index a24595dde3..33ea4a6fbc 100644 --- a/apps/codecs/libmad/timer.c +++ b/apps/codecs/libmad/timer.c | |||
@@ -36,8 +36,8 @@ | |||
36 | mad_timer_t const mad_timer_zero = { 0, 0 }; | 36 | mad_timer_t const mad_timer_zero = { 0, 0 }; |
37 | 37 | ||
38 | /* | 38 | /* |
39 | * NAME: timer->compare() | 39 | * NAME: timer->compare() |
40 | * DESCRIPTION: indicate relative order of two timers | 40 | * DESCRIPTION: indicate relative order of two timers |
41 | */ | 41 | */ |
42 | int mad_timer_compare(mad_timer_t timer1, mad_timer_t timer2) | 42 | int mad_timer_compare(mad_timer_t timer1, mad_timer_t timer2) |
43 | { | 43 | { |
@@ -59,8 +59,8 @@ int mad_timer_compare(mad_timer_t timer1, mad_timer_t timer2) | |||
59 | } | 59 | } |
60 | 60 | ||
61 | /* | 61 | /* |
62 | * NAME: timer->negate() | 62 | * NAME: timer->negate() |
63 | * DESCRIPTION: invert the sign of a timer | 63 | * DESCRIPTION: invert the sign of a timer |
64 | */ | 64 | */ |
65 | void mad_timer_negate(mad_timer_t *timer) | 65 | void mad_timer_negate(mad_timer_t *timer) |
66 | { | 66 | { |
@@ -73,8 +73,8 @@ void mad_timer_negate(mad_timer_t *timer) | |||
73 | } | 73 | } |
74 | 74 | ||
75 | /* | 75 | /* |
76 | * NAME: timer->abs() | 76 | * NAME: timer->abs() |
77 | * DESCRIPTION: return the absolute value of a timer | 77 | * DESCRIPTION: return the absolute value of a timer |
78 | */ | 78 | */ |
79 | mad_timer_t mad_timer_abs(mad_timer_t timer) | 79 | mad_timer_t mad_timer_abs(mad_timer_t timer) |
80 | { | 80 | { |
@@ -85,8 +85,8 @@ mad_timer_t mad_timer_abs(mad_timer_t timer) | |||
85 | } | 85 | } |
86 | 86 | ||
87 | /* | 87 | /* |
88 | * NAME: reduce_timer() | 88 | * NAME: reduce_timer() |
89 | * DESCRIPTION: carry timer fraction into seconds | 89 | * DESCRIPTION: carry timer fraction into seconds |
90 | */ | 90 | */ |
91 | static | 91 | static |
92 | void reduce_timer(mad_timer_t *timer) | 92 | void reduce_timer(mad_timer_t *timer) |
@@ -96,8 +96,8 @@ void reduce_timer(mad_timer_t *timer) | |||
96 | } | 96 | } |
97 | 97 | ||
98 | /* | 98 | /* |
99 | * NAME: gcd() | 99 | * NAME: gcd() |
100 | * DESCRIPTION: compute greatest common denominator | 100 | * DESCRIPTION: compute greatest common denominator |
101 | */ | 101 | */ |
102 | static | 102 | static |
103 | unsigned long gcd(unsigned long num1, unsigned long num2) | 103 | unsigned long gcd(unsigned long num1, unsigned long num2) |
@@ -114,8 +114,8 @@ unsigned long gcd(unsigned long num1, unsigned long num2) | |||
114 | } | 114 | } |
115 | 115 | ||
116 | /* | 116 | /* |
117 | * NAME: reduce_rational() | 117 | * NAME: reduce_rational() |
118 | * DESCRIPTION: convert rational expression to lowest terms | 118 | * DESCRIPTION: convert rational expression to lowest terms |
119 | */ | 119 | */ |
120 | static | 120 | static |
121 | void reduce_rational(unsigned long *numer, unsigned long *denom) | 121 | void reduce_rational(unsigned long *numer, unsigned long *denom) |
@@ -131,12 +131,12 @@ void reduce_rational(unsigned long *numer, unsigned long *denom) | |||
131 | } | 131 | } |
132 | 132 | ||
133 | /* | 133 | /* |
134 | * NAME: scale_rational() | 134 | * NAME: scale_rational() |
135 | * DESCRIPTION: solve numer/denom == ?/scale avoiding overflowing | 135 | * DESCRIPTION: solve numer/denom == ?/scale avoiding overflowing |
136 | */ | 136 | */ |
137 | static | 137 | static |
138 | unsigned long scale_rational(unsigned long numer, unsigned long denom, | 138 | unsigned long scale_rational(unsigned long numer, unsigned long denom, |
139 | unsigned long scale) | 139 | unsigned long scale) |
140 | { | 140 | { |
141 | reduce_rational(&numer, &denom); | 141 | reduce_rational(&numer, &denom); |
142 | reduce_rational(&scale, &denom); | 142 | reduce_rational(&scale, &denom); |
@@ -152,11 +152,11 @@ unsigned long scale_rational(unsigned long numer, unsigned long denom, | |||
152 | } | 152 | } |
153 | 153 | ||
154 | /* | 154 | /* |
155 | * NAME: timer->set() | 155 | * NAME: timer->set() |
156 | * DESCRIPTION: set timer to specific (positive) value | 156 | * DESCRIPTION: set timer to specific (positive) value |
157 | */ | 157 | */ |
158 | void mad_timer_set(mad_timer_t *timer, unsigned long seconds, | 158 | void mad_timer_set(mad_timer_t *timer, unsigned long seconds, |
159 | unsigned long numer, unsigned long denom) | 159 | unsigned long numer, unsigned long denom) |
160 | { | 160 | { |
161 | timer->seconds = seconds; | 161 | timer->seconds = seconds; |
162 | if (numer >= denom && denom > 0) { | 162 | if (numer >= denom && denom > 0) { |
@@ -224,8 +224,8 @@ void mad_timer_set(mad_timer_t *timer, unsigned long seconds, | |||
224 | } | 224 | } |
225 | 225 | ||
226 | /* | 226 | /* |
227 | * NAME: timer->add() | 227 | * NAME: timer->add() |
228 | * DESCRIPTION: add one timer to another | 228 | * DESCRIPTION: add one timer to another |
229 | */ | 229 | */ |
230 | void mad_timer_add(mad_timer_t *timer, mad_timer_t incr) | 230 | void mad_timer_add(mad_timer_t *timer, mad_timer_t incr) |
231 | { | 231 | { |
@@ -237,8 +237,8 @@ void mad_timer_add(mad_timer_t *timer, mad_timer_t incr) | |||
237 | } | 237 | } |
238 | 238 | ||
239 | /* | 239 | /* |
240 | * NAME: timer->multiply() | 240 | * NAME: timer->multiply() |
241 | * DESCRIPTION: multiply a timer by a scalar value | 241 | * DESCRIPTION: multiply a timer by a scalar value |
242 | */ | 242 | */ |
243 | void mad_timer_multiply(mad_timer_t *timer, signed long scalar) | 243 | void mad_timer_multiply(mad_timer_t *timer, signed long scalar) |
244 | { | 244 | { |
@@ -264,8 +264,8 @@ void mad_timer_multiply(mad_timer_t *timer, signed long scalar) | |||
264 | } | 264 | } |
265 | 265 | ||
266 | /* | 266 | /* |
267 | * NAME: timer->count() | 267 | * NAME: timer->count() |
268 | * DESCRIPTION: return timer value in selected units | 268 | * DESCRIPTION: return timer value in selected units |
269 | */ | 269 | */ |
270 | signed long mad_timer_count(mad_timer_t timer, enum mad_units units) | 270 | signed long mad_timer_count(mad_timer_t timer, enum mad_units units) |
271 | { | 271 | { |
@@ -302,7 +302,7 @@ signed long mad_timer_count(mad_timer_t timer, enum mad_units units) | |||
302 | case MAD_UNITS_75_FPS: | 302 | case MAD_UNITS_75_FPS: |
303 | return timer.seconds * (signed long) units + | 303 | return timer.seconds * (signed long) units + |
304 | (signed long) scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, | 304 | (signed long) scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, |
305 | units); | 305 | units); |
306 | 306 | ||
307 | case MAD_UNITS_23_976_FPS: | 307 | case MAD_UNITS_23_976_FPS: |
308 | case MAD_UNITS_24_975_FPS: | 308 | case MAD_UNITS_24_975_FPS: |
@@ -318,8 +318,8 @@ signed long mad_timer_count(mad_timer_t timer, enum mad_units units) | |||
318 | } | 318 | } |
319 | 319 | ||
320 | /* | 320 | /* |
321 | * NAME: timer->fraction() | 321 | * NAME: timer->fraction() |
322 | * DESCRIPTION: return fractional part of timer in arbitrary terms | 322 | * DESCRIPTION: return fractional part of timer in arbitrary terms |
323 | */ | 323 | */ |
324 | unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long denom) | 324 | unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long denom) |
325 | { | 325 | { |
@@ -339,12 +339,12 @@ unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long denom) | |||
339 | } | 339 | } |
340 | 340 | ||
341 | /* | 341 | /* |
342 | * NAME: timer->string() | 342 | * NAME: timer->string() |
343 | * DESCRIPTION: write a string representation of a timer using a template | 343 | * DESCRIPTION: write a string representation of a timer using a template |
344 | */ | 344 | */ |
345 | void mad_timer_string(mad_timer_t timer, | 345 | void mad_timer_string(mad_timer_t timer, |
346 | char *dest, char const *format, enum mad_units units, | 346 | char *dest, char const *format, enum mad_units units, |
347 | enum mad_units fracunits, unsigned long subparts) | 347 | enum mad_units fracunits, unsigned long subparts) |
348 | { | 348 | { |
349 | unsigned long hours, minutes, seconds, sub; | 349 | unsigned long hours, minutes, seconds, sub; |
350 | unsigned int frac; | 350 | unsigned int frac; |
@@ -413,7 +413,7 @@ void mad_timer_string(mad_timer_t timer, | |||
413 | m = frame % cycle; | 413 | m = frame % cycle; |
414 | frame += (10 - 1) * 2 * d; | 414 | frame += (10 - 1) * 2 * d; |
415 | if (m > 2) | 415 | if (m > 2) |
416 | frame += 2 * ((m - 2) / (cycle / 10)); | 416 | frame += 2 * ((m - 2) / (cycle / 10)); |
417 | 417 | ||
418 | frac = frame % -fracunits; | 418 | frac = frame % -fracunits; |
419 | seconds = frame / -fracunits; | 419 | seconds = frame / -fracunits; |
@@ -427,25 +427,25 @@ void mad_timer_string(mad_timer_t timer, | |||
427 | hours = minutes / 60; | 427 | hours = minutes / 60; |
428 | 428 | ||
429 | // sprintf(dest, format, | 429 | // sprintf(dest, format, |
430 | // hours, | 430 | // hours, |
431 | // (unsigned int) (minutes % 60), | 431 | // (unsigned int) (minutes % 60), |
432 | // (unsigned int) (seconds % 60), | 432 | // (unsigned int) (seconds % 60), |
433 | // frac, sub); | 433 | // frac, sub); |
434 | break; | 434 | break; |
435 | 435 | ||
436 | case MAD_UNITS_MINUTES: | 436 | case MAD_UNITS_MINUTES: |
437 | minutes = seconds / 60; | 437 | minutes = seconds / 60; |
438 | 438 | ||
439 | // sprintf(dest, format, | 439 | // sprintf(dest, format, |
440 | // minutes, | 440 | // minutes, |
441 | // (unsigned int) (seconds % 60), | 441 | // (unsigned int) (seconds % 60), |
442 | // frac, sub); | 442 | // frac, sub); |
443 | break; | 443 | break; |
444 | 444 | ||
445 | case MAD_UNITS_SECONDS: | 445 | case MAD_UNITS_SECONDS: |
446 | // sprintf(dest, format, | 446 | // sprintf(dest, format, |
447 | // seconds, | 447 | // seconds, |
448 | // frac, sub); | 448 | // frac, sub); |
449 | break; | 449 | break; |
450 | 450 | ||
451 | case MAD_UNITS_23_976_FPS: | 451 | case MAD_UNITS_23_976_FPS: |