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 604352 - [rganalysis] miscomputes timestamps
[rganalysis] miscomputes timestamps
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other All
: Normal normal
: 0.10.18
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2009-12-11 10:13 UTC by Branko Čibej
Modified: 2009-12-17 16:38 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Branko Čibej 2009-12-11 10:13:52 UTC
When calculating the data for the audio gain messages, rganalysis does not properly round up the timestamp. The result is that for messages generated at the beginning of a stream, the calculated timestamp can be negative.

The following fix works for me:

--- gst/replaygain/rganalysis.c	(original)
+++ gst/replaygain/rganalysis.c	(fixed)
@@ -711,7 +711,8 @@
       /* Compute the per-window gain */
       const gdouble gain = PINK_REF - (gdouble) ival / STEPS_PER_DB;
       const GstClockTime timestamp = (ctx->buffer_timestamp
-          + ctx->buffer_n_samples_done * GST_SECOND / ctx->sample_rate
+          + (ctx->buffer_n_samples_done * GST_SECOND + ctx->sample_rate - 1)
+            / ctx->sample_rate
           - RMS_WINDOW_MSECS * GST_MSECOND);
Comment 1 Sebastian Dröge (slomo) 2009-12-11 11:39:16 UTC
You should use gst_util_uint64_scale_ceil() or _scale_round() here instead.  That will prevent overflows and also make the line a bit more readable :)
Comment 2 Branko Čibej 2009-12-11 12:03:04 UTC
Interesting. I'll update the patch.
Comment 3 Branko Čibej 2009-12-13 15:48:25 UTC
Here's the updated patch:

--- gstreamer/good/gst/replaygain/rganalysis.c  (original)
+++ gstreamer/good/gst/replaygain/rganalysis.c  (fixed)
@@ -710,9 +710,11 @@
           (gint) G_N_ELEMENTS (ctx->track.histogram) - 1);
       /* Compute the per-window gain */
       const gdouble gain = PINK_REF - (gdouble) ival / STEPS_PER_DB;
-      const GstClockTime timestamp = (ctx->buffer_timestamp
-          + ctx->buffer_n_samples_done * GST_SECOND / ctx->sample_rate
-          - RMS_WINDOW_MSECS * GST_MSECOND);
+      const GstClockTime timestamp = ctx->buffer_timestamp
+          + gst_util_uint64_scale_int_ceil(GST_SECOND,
+                                           ctx->buffer_n_samples_done,
+                                           ctx->sample_rate)
+          - RMS_WINDOW_MSECS * GST_MSECOND;
 
       ctx->post_message (ctx->analysis, timestamp,
           RMS_WINDOW_MSECS * GST_MSECOND, -gain);
Comment 4 Wim Taymans 2009-12-17 16:38:14 UTC
commit 7b107f64f33108658f2883d74de3303c07f3a154
Author: Branko Čibej <brane at xbc.nu>
Date:   Thu Dec 17 17:37:03 2009 +0100

    rganalysis: fix timestamp rounding
    
    Use scaling function to round and avoid overflows.
    
    Fixes #604352