After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 607381 - GST_FRAMES_TO_CLOCK_TIME() GST_CLOCK_TIME_TO_FRAMES() should round result
GST_FRAMES_TO_CLOCK_TIME() GST_CLOCK_TIME_TO_FRAMES() should round result
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other All
: Normal minor
: 0.10.26
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-01-18 23:04 UTC by Kipp
Modified: 2010-01-19 08:26 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Kipp 2010-01-18 23:04:21 UTC
The macros GST_FRAMES_TO_CLOCK_TIME() and GST_CLOCK_TIME_TO_FRAMES() use gst_util_uint64_scale() to convert a sample offset to a clock time and vice versa.  This function truncates its results.  gst_util_uint64_scale_round() should be used instead to round the answer to the nearest integer result.  This prevents a clock drift when sample indexes are converted to clock times and back to sample indexes, etc., repeatedly when working with data streams whose sample periods are not exactly an integer number of nanoseconds (e.g., power-of-2 sample rates like 16384 Hz).

For example, GST_CLOCK_TIME_TO_FRAMES(GST_FRAMES_TO_CLOCK_TIME(n,16384),16384) returns n-1 for most n.

Changing these macros to the rounding versions does not break the unit tests for the elements that use them already.
Comment 1 Sebastian Dröge (slomo) 2010-01-19 08:26:55 UTC
commit 6dfc0270eccc394fc46f4c83127fc7b600a991cd
Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
Date:   Tue Jan 19 09:25:35 2010 +0100

    audio: Use rounding scaling functions for GST_CLOCK_TIME_TO_FRAMES and _FRAM
    
    Fixes bug #607381.