gst-libs/gst/audio/audio.h: Use gst_util_uint64_scale() instead of doing the math...
authorSebastian Dröge <slomo@circular-chaos.org>
Fri, 17 Aug 2007 15:24:43 +0000 (15:24 +0000)
committerSebastian Dröge <slomo@circular-chaos.org>
Fri, 17 Aug 2007 15:24:43 +0000 (15:24 +0000)
Original commit message from CVS:
* gst-libs/gst/audio/audio.h:
Use gst_util_uint64_scale() instead of doing the math
with double for GST_FRAMES_TO_CLOCK_TIME() and
GST_CLOCK_TIME_TO_FRAMES(). For large timestamps this
prevents rounding errors. Fixes #467667.

ChangeLog
gst-libs/gst/audio/audio.h

index fba1e7b..fcda2a3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-08-17  Sebastian Dröge  <slomo@circular-chaos.org>
+
+       * gst-libs/gst/audio/audio.h:
+       Use gst_util_uint64_scale() instead of doing the math
+       with double for GST_FRAMES_TO_CLOCK_TIME() and
+       GST_CLOCK_TIME_TO_FRAMES(). For large timestamps this
+       prevents rounding errors. Fixes #467667.
+
 2007-08-17  Wim Taymans  <wim.taymans@gmail.com>
 
        * gst-libs/gst/rtsp/gstrtspconnection.c:
index 01eca75..e764ae1 100644 (file)
@@ -58,7 +58,7 @@ G_BEGIN_DECLS
  * Calculate clocktime from sample @frames and @rate.
  */
 #define GST_FRAMES_TO_CLOCK_TIME(frames, rate) \
-  ((GstClockTime) (((gdouble) frames / rate) * GST_SECOND))
+  ((GstClockTime) gst_util_uint64_scale (frames, GST_SECOND, rate))
 
 /**
  * GST_CLOCK_TIME_TO_FRAMES:
@@ -68,7 +68,7 @@ G_BEGIN_DECLS
  * Calculate frames from @clocktime and sample @rate.
  */
 #define GST_CLOCK_TIME_TO_FRAMES(clocktime, rate) \
-  ((gint64) ((gst_guint64_to_gdouble (clocktime) / GST_SECOND) * rate))
+  gst_util_uint64_scale (clocktime, rate, GST_SECOND)
 
 /**
  * GST_AUDIO_DEF_RATE: