[vlc-commits] date_Increment: use lldiv()

Rémi Denis-Courmont git at videolan.org
Sat Jun 4 15:58:21 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jun  4 13:59:24 2011 +0300| [195f14da6f0ba3db354aab766d5b90a1ac9e35f1] | committer: Rémi Denis-Courmont

date_Increment: use lldiv()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=195f14da6f0ba3db354aab766d5b90a1ac9e35f1
---

 src/misc/mtime.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/misc/mtime.c b/src/misc/mtime.c
index ac8afb5..5f8e730 100644
--- a/src/misc/mtime.c
+++ b/src/misc/mtime.c
@@ -434,9 +434,11 @@ void date_Move( date_t *p_date, mtime_t i_difference )
  */
 mtime_t date_Increment( date_t *p_date, uint32_t i_nb_samples )
 {
-    mtime_t i_dividend = (mtime_t)i_nb_samples * 1000000 * p_date->i_divider_den;
-    p_date->date += i_dividend / p_date->i_divider_num;
-    p_date->i_remainder += (int)(i_dividend % p_date->i_divider_num);
+    mtime_t i_dividend = i_nb_samples * CLOCK_FREQ * p_date->i_divider_den;
+    lldiv_t d = lldiv( i_dividend, p_date->i_divider_num );
+
+    p_date->date += d.quot;
+    p_date->i_remainder += (int)d.rem;
 
     if( p_date->i_remainder >= p_date->i_divider_num )
     {



More information about the vlc-commits mailing list