Diffstat (limited to 'core/multimedia/opieplayer/libmad/timer.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/libmad/timer.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/core/multimedia/opieplayer/libmad/timer.c b/core/multimedia/opieplayer/libmad/timer.c index 299fe0b..fa377d0 100644 --- a/core/multimedia/opieplayer/libmad/timer.c +++ b/core/multimedia/opieplayer/libmad/timer.c | |||
@@ -1,27 +1,27 @@ | |||
1 | /* | 1 | /* |
2 | * libmad - MPEG audio decoder library | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifdef HAVE_CONFIG_H | 22 | # ifdef HAVE_CONFIG_H |
23 | # include "libmad_config.h" | 23 | # include "libmad_config.h" |
24 | # endif | 24 | # endif |
25 | 25 | ||
26 | # include "libmad_global.h" | 26 | # include "libmad_global.h" |
27 | 27 | ||
@@ -57,49 +57,49 @@ int mad_timer_compare(mad_timer_t timer1, mad_timer_t timer2) | |||
57 | 57 | ||
58 | return 0; | 58 | return 0; |
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 | { |
67 | timer->seconds = -timer->seconds; | 67 | timer->seconds = -timer->seconds; |
68 | 68 | ||
69 | if (timer->fraction) { | 69 | if (timer->fraction) { |
70 | timer->seconds -= 1; | 70 | timer->seconds -= 1; |
71 | timer->fraction = MAD_TIMER_RESOLUTION - timer->fraction; | 71 | timer->fraction = MAD_TIMER_RESOLUTION - timer->fraction; |
72 | } | 72 | } |
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 | { |
81 | if (mad_timer_sign(timer) < 0) | 81 | if (timer.seconds < 0) |
82 | mad_timer_negate(&timer); | 82 | mad_timer_negate(&timer); |
83 | 83 | ||
84 | return timer; | 84 | return 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) |
93 | { | 93 | { |
94 | timer->seconds += timer->fraction / MAD_TIMER_RESOLUTION; | 94 | timer->seconds += timer->fraction / MAD_TIMER_RESOLUTION; |
95 | timer->fraction %= MAD_TIMER_RESOLUTION; | 95 | timer->fraction %= MAD_TIMER_RESOLUTION; |
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) |
104 | { | 104 | { |
105 | unsigned long tmp; | 105 | unsigned long tmp; |
@@ -306,49 +306,50 @@ signed long mad_timer_count(mad_timer_t timer, enum mad_units 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: |
309 | case MAD_UNITS_29_97_FPS: | 309 | case MAD_UNITS_29_97_FPS: |
310 | case MAD_UNITS_47_952_FPS: | 310 | case MAD_UNITS_47_952_FPS: |
311 | case MAD_UNITS_49_95_FPS: | 311 | case MAD_UNITS_49_95_FPS: |
312 | case MAD_UNITS_59_94_FPS: | 312 | case MAD_UNITS_59_94_FPS: |
313 | return (mad_timer_count(timer, -units) + 1) * 1000 / 1001; | 313 | return (mad_timer_count(timer, -units) + 1) * 1000 / 1001; |
314 | } | 314 | } |
315 | 315 | ||
316 | /* unsupported units */ | 316 | /* unsupported units */ |
317 | return 0; | 317 | return 0; |
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 | { |
326 | timer = mad_timer_abs(timer); | 326 | timer = mad_timer_abs(timer); |
327 | 327 | ||
328 | switch (denom) { | 328 | switch (denom) { |
329 | case 0: | 329 | case 0: |
330 | return MAD_TIMER_RESOLUTION / timer.fraction; | 330 | return timer.fraction ? |
331 | MAD_TIMER_RESOLUTION / timer.fraction : MAD_TIMER_RESOLUTION + 1; | ||
331 | 332 | ||
332 | case MAD_TIMER_RESOLUTION: | 333 | case MAD_TIMER_RESOLUTION: |
333 | return timer.fraction; | 334 | return timer.fraction; |
334 | 335 | ||
335 | default: | 336 | default: |
336 | return scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, denom); | 337 | return scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, denom); |
337 | } | 338 | } |
338 | } | 339 | } |
339 | 340 | ||
340 | /* | 341 | /* |
341 | * NAME:timer->string() | 342 | * NAME:timer->string() |
342 | * DESCRIPTION:write a string representation of a timer using a template | 343 | * DESCRIPTION:write a string representation of a timer using a template |
343 | */ | 344 | */ |
344 | void mad_timer_string(mad_timer_t timer, | 345 | void mad_timer_string(mad_timer_t timer, |
345 | char *dest, char const *format, enum mad_units units, | 346 | char *dest, char const *format, enum mad_units units, |
346 | enum mad_units fracunits, unsigned long subparts) | 347 | enum mad_units fracunits, unsigned long subparts) |
347 | { | 348 | { |
348 | unsigned long hours, minutes, seconds, sub; | 349 | unsigned long hours, minutes, seconds, sub; |
349 | unsigned int frac; | 350 | unsigned int frac; |
350 | 351 | ||
351 | timer = mad_timer_abs(timer); | 352 | timer = mad_timer_abs(timer); |
352 | 353 | ||
353 | seconds = timer.seconds; | 354 | seconds = timer.seconds; |
354 | frac = sub = 0; | 355 | frac = sub = 0; |