author | llornkcor <llornkcor> | 2005-11-08 23:16:03 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2005-11-08 23:16:03 (UTC) |
commit | 6bd52d3658f01c966d690b12235592a5473a4d57 (patch) (side-by-side diff) | |
tree | 76e25003b738fde6ebbea5d338b7cf76b82f47fa /core/multimedia/opieplayer/libmad/timer.c | |
parent | a8063e0797d6edf2ead22fc8c5346ddf187f0b5d (diff) | |
download | opie-6bd52d3658f01c966d690b12235592a5473a4d57.zip opie-6bd52d3658f01c966d690b12235592a5473a4d57.tar.gz opie-6bd52d3658f01c966d690b12235592a5473a4d57.tar.bz2 |
update libmad and add 64bit define
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,35 +1,35 @@ /* * libmad - MPEG audio decoder library - * Copyright (C) 2000-2001 Robert Leslie + * Copyright (C) 2000-2004 Underbit Technologies, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id$ */ # ifdef HAVE_CONFIG_H # include "libmad_config.h" # endif # include "libmad_global.h" # include <stdio.h> # ifdef HAVE_ASSERT_H # include <assert.h> # endif # include "timer.h" @@ -49,65 +49,65 @@ int mad_timer_compare(mad_timer_t timer1, mad_timer_t timer2) else if (diff > 0) return +1; diff = timer1.fraction - timer2.fraction; if (diff < 0) return -1; else if (diff > 0) return +1; return 0; } /* * NAME: timer->negate() * DESCRIPTION: invert the sign of a timer */ void mad_timer_negate(mad_timer_t *timer) { timer->seconds = -timer->seconds; if (timer->fraction) { timer->seconds -= 1; timer->fraction = MAD_TIMER_RESOLUTION - timer->fraction; } } /* * NAME: timer->abs() * DESCRIPTION: return the absolute value of a timer */ mad_timer_t mad_timer_abs(mad_timer_t timer) { - if (mad_timer_sign(timer) < 0) + if (timer.seconds < 0) mad_timer_negate(&timer); return timer; } /* * NAME: reduce_timer() * DESCRIPTION: carry timer fraction into seconds */ static void reduce_timer(mad_timer_t *timer) { timer->seconds += timer->fraction / MAD_TIMER_RESOLUTION; timer->fraction %= MAD_TIMER_RESOLUTION; } /* * NAME: gcd() * DESCRIPTION: compute greatest common denominator */ static unsigned long gcd(unsigned long num1, unsigned long num2) { unsigned long tmp; while (num2) { tmp = num2; num2 = num1 % num2; num1 = tmp; } return num1; @@ -298,65 +298,66 @@ signed long mad_timer_count(mad_timer_t timer, enum mad_units units) case MAD_UNITS_30_FPS: case MAD_UNITS_48_FPS: case MAD_UNITS_50_FPS: case MAD_UNITS_60_FPS: case MAD_UNITS_75_FPS: return timer.seconds * (signed long) units + (signed long) scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, units); case MAD_UNITS_23_976_FPS: case MAD_UNITS_24_975_FPS: case MAD_UNITS_29_97_FPS: case MAD_UNITS_47_952_FPS: case MAD_UNITS_49_95_FPS: case MAD_UNITS_59_94_FPS: return (mad_timer_count(timer, -units) + 1) * 1000 / 1001; } /* unsupported units */ return 0; } /* * NAME: timer->fraction() * DESCRIPTION: return fractional part of timer in arbitrary terms */ unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long denom) { timer = mad_timer_abs(timer); switch (denom) { case 0: - return MAD_TIMER_RESOLUTION / timer.fraction; + return timer.fraction ? + MAD_TIMER_RESOLUTION / timer.fraction : MAD_TIMER_RESOLUTION + 1; case MAD_TIMER_RESOLUTION: return timer.fraction; default: return scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, denom); } } /* * NAME: timer->string() * DESCRIPTION: write a string representation of a timer using a template */ void mad_timer_string(mad_timer_t timer, char *dest, char const *format, enum mad_units units, enum mad_units fracunits, unsigned long subparts) { unsigned long hours, minutes, seconds, sub; unsigned int frac; timer = mad_timer_abs(timer); seconds = timer.seconds; frac = sub = 0; switch (fracunits) { case MAD_UNITS_HOURS: case MAD_UNITS_MINUTES: case MAD_UNITS_SECONDS: break; case MAD_UNITS_DECISECONDS: |